diff options
author | Yi Zhang (CLR) <yizhang82@users.noreply.github.com> | 2017-05-21 07:02:40 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-05-21 07:02:40 +0300 |
commit | 8eb9ffe39300ca9647546580d1ee071a0c8de34d (patch) | |
tree | 319f1eb3e566808b85d3f5b9463b3d544681bfb8 /src/Test.CoreLib | |
parent | 422c171ff9a8e38c3e349d17c2e1344042258ff1 (diff) |
Initial support for preinitialized array in CoreRT (#3558)
* Add PreInitFieldInfo that extracts preinitialized data information from fields that have [PreInitialized] and [InitDataBlob] pointing to RVA field
* Added FrozenArrayNode for frozen arrays with data extracted from preinit RVA data field
* Added GCStaticsPreInitDataNode (CoreRT only) to hold GC pointers for GC static fields. Pre-init data fields points to frozen data, while other data initialized to null.
* Changed GCStaticsNode to emit a pointer reloc to GCStaticspreInitDataNode and mask 0x2 for the GC static EEType.
* Changed InitializedStatics in StartupCodeHelper to check for 0x2 and memcpy the GC field data as needed
* Fixed a bug in bad GCStaticsEETypeNode size calculation - it's off-by-1 as static GC static field layout in CoreRT includes EEType already.
Diffstat (limited to 'src/Test.CoreLib')
-rw-r--r-- | src/Test.CoreLib/src/System/Object.cs | 10 | ||||
-rw-r--r-- | src/Test.CoreLib/src/System/Runtime/RuntimeImports.cs | 13 |
2 files changed, 23 insertions, 0 deletions
diff --git a/src/Test.CoreLib/src/System/Object.cs b/src/Test.CoreLib/src/System/Object.cs index a6addf96b..60777622e 100644 --- a/src/Test.CoreLib/src/System/Object.cs +++ b/src/Test.CoreLib/src/System/Object.cs @@ -19,6 +19,7 @@ using System.Runtime.InteropServices; // TODO: remove when m_pEEType becomes EETypePtr using EEType = Internal.Runtime.EEType; +using ObjHeader = Internal.Runtime.ObjHeader; namespace System { @@ -89,5 +90,14 @@ namespace System { return ref Unsafe.As<RawData>(this).Data; } + + /// <summary> + /// Return size of all data (excluding ObjHeader and EEType*). + /// Note that for strings/arrays this would include the Length as well. + /// </summary> + internal unsafe uint GetRawDataSize() + { + return EEType->BaseSize - (uint)sizeof(ObjHeader) - (uint)sizeof(EEType*); + } } } diff --git a/src/Test.CoreLib/src/System/Runtime/RuntimeImports.cs b/src/Test.CoreLib/src/System/Runtime/RuntimeImports.cs index ecdda3bdc..014fe31b5 100644 --- a/src/Test.CoreLib/src/System/Runtime/RuntimeImports.cs +++ b/src/Test.CoreLib/src/System/Runtime/RuntimeImports.cs @@ -8,6 +8,12 @@ using System.Runtime.InteropServices; using System.Runtime.CompilerServices; using Internal.Runtime; +#if BIT64 +using nuint = System.UInt64; +#else +using nuint = System.UInt32; +#endif + namespace System.Runtime { // CONTRACT with Runtime @@ -96,5 +102,12 @@ namespace System.Runtime [MethodImplAttribute(MethodImplOptions.InternalCall)] [RuntimeImport(RuntimeLibrary, "RhpMemoryBarrier")] internal extern static void MemoryBarrier(); + + // Moves memory from smem to dmem. Size must be a positive value. + // This copy uses an intrinsic to be safe for copying arbitrary bits of + // heap memory + [MethodImplAttribute(MethodImplOptions.InternalCall)] + [RuntimeImport(RuntimeLibrary, "RhBulkMoveWithWriteBarrier")] + internal static extern unsafe void RhBulkMoveWithWriteBarrier(ref byte dmem, ref byte smem, nuint size); } } |