-
Notifications
You must be signed in to change notification settings - Fork 14
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CoreRT support #4
Comments
The flag to check if an I wonder why this was done ... |
CoreRT Code Path: while (objectId < buffer + length)
{
var typeHandle = runtimeTypeHandles[(int)Marshal.ReadIntPtr((IntPtr)objectId)].Value;
var eetype = (EEType*)typeHandle;
var objectSize = eetype->BaseSize;
var numComponents = Marshal.ReadInt32((IntPtr)objectId, IntPtr.Size);
objectSize += numComponents * eetype->ComponentSize;
bool containsPointers = (eetype->Flags & 0x0020) == 0x0020;
if (containsPointers)
{
var entries = *(int*)((byte*)eetype - IntPtr.Size);
if (entries < 0)
{
entries -= entries;
}
var slots = 1 + entries * 2;
var gcdesc = new GCDesc(buffer, (byte*)eetype - (slots * IntPtr.Size), slots * IntPtr.Size);
if (IntPtr.Size == 8)
{
gcdesc.FixupObject64(objectId, objectSize);
}
else
{
gcdesc.FixupObject32(objectId, objectSize);
}
}
Marshal.WriteIntPtr((IntPtr)objectId, (IntPtr)eetype);
objectId += objectSize + Padding(objectSize, IntPtr.Size);
} CoreCLR code path: while (objectId < buffer + length)
{
var typeHandle = runtimeTypeHandles[(int)Marshal.ReadIntPtr((IntPtr)objectId)].Value;
bool isArray = (typeHandle.ToInt64() & 0x2) == 0x2;
var mt = (MethodTable*)typeHandle;
if (isArray)
{
mt = (MethodTable*)Marshal.ReadIntPtr(typeHandle, 6);
}
var objectSize = mt->BaseSize;
var flags = mt->Flags;
bool hasComponentSize = (flags & 0x80000000) == 0x80000000;
if (hasComponentSize)
{
var numComponents = Marshal.ReadInt32((IntPtr)objectId, IntPtr.Size);
objectSize += numComponents * mt->ComponentSize;
}
bool containsPointerOrCollectible = (flags & 0x10000000) == 0x10000000 || (flags & 0x1000000) == 0x1000000;
if (containsPointerOrCollectible)
{
var entries = *(int*)((byte*)mt - IntPtr.Size);
if (entries < 0)
{
entries -= entries;
}
var slots = 1 + entries * 2;
var gcdesc = new GCDesc(buffer, (byte*)mt - (slots * IntPtr.Size), slots * IntPtr.Size);
if (IntPtr.Size == 8)
{
gcdesc.FixupObject64(objectId, objectSize);
}
else
{
gcdesc.FixupObject32(objectId, objectSize);
}
}
Marshal.WriteIntPtr((IntPtr)objectId, (IntPtr)mt);
objectId += objectSize + Padding(objectSize, IntPtr.Size);
} Notice that in the CoreCLR path I have to first check if it is an array, and switch from TypeDesc to MT. Then the Unrelated note: I'm also checking |
After bringing this up with @MichalStrehovsky & @jkotas I will fork the code paths for CoreRT as we don't want to modify the EEType bits to conform to the CoreCLR MT. |
Part of the work is exposing the helpers from S.P.C so our serialized can call it.
dotnet/corert#7589
The other part is actually understanding how to go from an
EEType*
toGCDesc
when deserializing. And for serializing hoping and praying that the layout algorithm is the same so that the serializer can run on .NET Core and deserialize on CoreRT when doing it on the same OS and architecture.The text was updated successfully, but these errors were encountered: