Skip to content

Instantly share code, notes, and snippets.

@filipnavara
Created November 14, 2019 20:31
Show Gist options
  • Save filipnavara/4077e2ed3e7b483d7940a9f40d7daf64 to your computer and use it in GitHub Desktop.
Save filipnavara/4077e2ed3e7b483d7940a9f40d7daf64 to your computer and use it in GitHub Desktop.
MethodTable* GCToEEInterface::GetFreeObjectMethodTable()
{
if (!array_fill_vtable) {
static char _vtable[sizeof(MonoVTable)+8];
MonoVTable* vtable = (MonoVTable*) ALIGN_TO((size_t)_vtable, 8);
gsize bmap;
vtable->klass = mono_class_create_array_fill_type ();
bmap = 0;
mono_gc_descr_union desc;
desc.ptr_gc_descr = mono_gc_make_descr_for_array (TRUE, &bmap, 0, 1);
// Remove bounds from the reported size, since coreclr gc expects this object
// to the size of ArrayBase
desc.struct_gc_descr.m_baseSize -= 8;
// Add the header slot
//desc.struct_gc_descr.m_baseSize += 8;
vtable->gc_descr = desc.ptr_gc_descr;
vtable->rank = 1;
array_fill_vtable = vtable;
}
return (MethodTable*)&array_fill_vtable->gc_descr;//array_fill_vtable;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment