From fd92b4ba939103e3ade6764d7a23ca9c033975c6 Mon Sep 17 00:00:00 2001 From: Brian Fiete Date: Thu, 2 Jun 2022 10:56:29 -0700 Subject: [PATCH] Fixed CreateObject append alloc for non-debug-gc --- BeefLibs/corlib/src/Reflection/TypeInstance.bf | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/BeefLibs/corlib/src/Reflection/TypeInstance.bf b/BeefLibs/corlib/src/Reflection/TypeInstance.bf index db318971..a8a0a7e2 100644 --- a/BeefLibs/corlib/src/Reflection/TypeInstance.bf +++ b/BeefLibs/corlib/src/Reflection/TypeInstance.bf @@ -174,15 +174,22 @@ namespace System.Reflection } } -#if BF_ENABLE_OBJECT_DEBUG_FLAGS +#if BF_ENABLE_REALTIME_LEAK_CHECK int32 stackCount = Compiler.Options.AllocStackCount; if (mAllocStackCountOverride != 0) stackCount = mAllocStackCountOverride; obj = Internal.Dbg_ObjectAlloc(mTypeClassVData, allocSize, mInstAlign, stackCount); #else - void* mem = new [Align(16)] uint8[mInstSize]* (?); + void* mem = new [Align(16)] uint8[allocSize]* (?); obj = Internal.UnsafeCastToObject(mem); - obj.[Friend]mClassVData = (.)(void*)mTypeClassVData; + *(void**)mem = (void*)mTypeClassVData; +#if BF_ENABLE_OBJECT_DEBUG_FLAGS + Internal.Dbg_ObjectAllocated(obj, allocSize, (.)(void*)mTypeClassVData); + *(int*)mem |= 0x04/*BfObjectFlag_Allocate*/; +#else + *(void**)mem = (void*)mTypeClassVData; +#endif + #endif Internal.MemSet((uint8*)Internal.UnsafeCastToPtr(obj) + objType.mInstSize, 0, mInstSize - objType.mInstSize); if (methodInfo.IsInitialized)