diff options
author | Jan Kotas <jkotas@microsoft.com> | 2015-12-01 10:11:37 +0300 |
---|---|---|
committer | Jan Kotas <jkotas@microsoft.com> | 2015-12-01 21:45:19 +0300 |
commit | 26962d72aeb1951c472d33d9ec397a0f13385d63 (patch) | |
tree | 06aec99b010dd15a0c9ad845b899cc6786392791 /src/Runtime.Base | |
parent | a5e0aa9eb31c73b70d74a08f2803ee6a36a8ee8c (diff) |
Refactor RhMemberwiseClone
Diffstat (limited to 'src/Runtime.Base')
-rw-r--r-- | src/Runtime.Base/src/System/Object.cs | 31 | ||||
-rw-r--r-- | src/Runtime.Base/src/System/Runtime/RuntimeExports.cs | 21 |
2 files changed, 16 insertions, 36 deletions
diff --git a/src/Runtime.Base/src/System/Object.cs b/src/Runtime.Base/src/System/Object.cs index fc62c40e9..3f5375a5d 100644 --- a/src/Runtime.Base/src/System/Object.cs +++ b/src/Runtime.Base/src/System/Object.cs @@ -61,7 +61,7 @@ namespace System } } - private unsafe int GetArrayLength() + internal unsafe int GetArrayLength() { Debug.Assert(_pEEType->IsArray, "this is only supported on arrays"); @@ -69,34 +69,5 @@ namespace System fixed (EEType** ptr = &_pEEType) return *(int*)(ptr + 1); } - - internal object MemberwiseClone() - { - object objClone; -#if FEATURE_64BIT_ALIGNMENT - if (_pEEType->RequiresAlign8) - { - if (_pEEType->IsArray) - objClone = InternalCalls.RhpNewArrayAlign8(_pEEType, GetArrayLength()); - else if (_pEEType->IsFinalizable) - objClone = InternalCalls.RhpNewFinalizableAlign8(_pEEType); - else - objClone = InternalCalls.RhpNewFastAlign8(_pEEType); - } - else -#endif // FEATURE_64BIT_ALIGNMENT - { - if (_pEEType->IsArray) - objClone = InternalCalls.RhpNewArray(_pEEType, GetArrayLength()); - else if (_pEEType->IsFinalizable) - objClone = InternalCalls.RhpNewFinalizable(_pEEType); - else - objClone = InternalCalls.RhpNewFast(_pEEType); - } - - InternalCalls.RhpCopyObjectContents(objClone, this); - - return objClone; - } } } diff --git a/src/Runtime.Base/src/System/Runtime/RuntimeExports.cs b/src/Runtime.Base/src/System/Runtime/RuntimeExports.cs index 02df0880d..1e8d97a00 100644 --- a/src/Runtime.Base/src/System/Runtime/RuntimeExports.cs +++ b/src/Runtime.Base/src/System/Runtime/RuntimeExports.cs @@ -314,6 +314,21 @@ namespace System.Runtime return new Wrapper(); } + [RuntimeExport("RhMemberwiseClone")] + public unsafe static object RhMemberwiseClone(object src) + { + object objClone; + + if (src.EEType->IsArray) + objClone = RhNewArray(new EETypePtr((IntPtr)src.EEType), src.GetArrayLength()); + else + objClone = RhNewObject(new EETypePtr((IntPtr)src.EEType)); + + InternalCalls.RhpCopyObjectContents(objClone, src); + + return objClone; + } + [RuntimeExport("RhpReversePInvokeBadTransition")] public static void RhpReversePInvokeBadTransition() { @@ -334,12 +349,6 @@ namespace System.Runtime } } - [RuntimeExport("RhMemberwiseClone")] - public static object RhMemberwiseClone(object src) - { - return src.MemberwiseClone(); - } - // EEType interrogation methods. [RuntimeExport("RhGetRelatedParameterType")] |