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/Runtime.Base | |
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/Runtime.Base')
-rw-r--r-- | src/Runtime.Base/src/System/Object.cs | 22 | ||||
-rw-r--r-- | src/Runtime.Base/src/System/Runtime/EETypePtr.cs | 8 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/Runtime.Base/src/System/Object.cs b/src/Runtime.Base/src/System/Object.cs index 7d5475228..2e541f303 100644 --- a/src/Runtime.Base/src/System/Object.cs +++ b/src/Runtime.Base/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 { @@ -69,15 +70,36 @@ namespace System } } + internal EETypePtr EETypePtr + { + get + { + return new EETypePtr(new IntPtr(m_pEEType)); + } + } + [StructLayout(LayoutKind.Sequential)] private class RawData { public byte Data; } + /// <summary> + /// Return beginning of all data (excluding ObjHeader and EEType*) within this object. + /// Note that for strings/arrays this would include the Length as well. + /// </summary> internal ref byte GetRawData() { 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 uint GetRawDataSize() + { + return EETypePtr.BaseSize - (uint)sizeof(ObjHeader) - (uint)sizeof(EEType*); + } } } diff --git a/src/Runtime.Base/src/System/Runtime/EETypePtr.cs b/src/Runtime.Base/src/System/Runtime/EETypePtr.cs index b8bc5e4cd..26355a84a 100644 --- a/src/Runtime.Base/src/System/Runtime/EETypePtr.cs +++ b/src/Runtime.Base/src/System/Runtime/EETypePtr.cs @@ -49,6 +49,14 @@ namespace System throw new NotImplementedException(); } #endif + + internal unsafe uint BaseSize + { + get + { + return ToPointer()->BaseSize; + } + } } } |