diff --git a/BeefLibs/corlib/src/Internal.bf b/BeefLibs/corlib/src/Internal.bf index 1a6c00ad..88a79611 100644 --- a/BeefLibs/corlib/src/Internal.bf +++ b/BeefLibs/corlib/src/Internal.bf @@ -292,11 +292,11 @@ namespace System [CallingConvention(.Cdecl)] public static extern void Dbg_ObjectCreated(Object obj, int size, ClassVData* classVData); [CallingConvention(.Cdecl)] - public static extern void Dbg_ObjectCreatedEx(Object obj, int size, ClassVData* classVData); + public static extern void Dbg_ObjectCreatedEx(Object obj, int size, ClassVData* classVData, uint8 allocFlags); [CallingConvention(.Cdecl)] public static extern void Dbg_ObjectAllocated(Object obj, int size, ClassVData* classVData); [CallingConvention(.Cdecl)] - public static extern void Dbg_ObjectAllocatedEx(Object obj, int size, ClassVData* classVData); + public static extern void Dbg_ObjectAllocatedEx(Object obj, int size, ClassVData* classVData, uint8 allocFlags); [CallingConvention(.Cdecl)] public static extern int Dbg_PrepareStackTrace(int baseAllocSize, int maxStackTraceDepth); [CallingConvention(.Cdecl)] diff --git a/BeefRT/dbg/DbgInternal.cpp b/BeefRT/dbg/DbgInternal.cpp index 90a03c33..7f0c4b43 100644 --- a/BeefRT/dbg/DbgInternal.cpp +++ b/BeefRT/dbg/DbgInternal.cpp @@ -46,9 +46,9 @@ namespace bf BFRT_EXPORT void Dbg_ReserveMetadataBytes(intptr metadataBytes, intptr& curAllocBytes); BFRT_EXPORT void* Dbg_GetMetadata(System::Object* obj); BFRT_EXPORT static void Dbg_ObjectCreated(bf::System::Object* result, intptr size, bf::System::ClassVData* classVData); - BFRT_EXPORT static void Dbg_ObjectCreatedEx(bf::System::Object* result, intptr size, bf::System::ClassVData* classVData); + BFRT_EXPORT static void Dbg_ObjectCreatedEx(bf::System::Object* result, intptr size, bf::System::ClassVData* classVData, uint8 allocFlags); BFRT_EXPORT static void Dbg_ObjectAllocated(bf::System::Object* result, intptr size, bf::System::ClassVData* classVData); - BFRT_EXPORT static void Dbg_ObjectAllocatedEx(bf::System::Object* result, intptr size, bf::System::ClassVData* classVData); + BFRT_EXPORT static void Dbg_ObjectAllocatedEx(bf::System::Object* result, intptr size, bf::System::ClassVData* classVData, uint8 allocFlags); BFRT_EXPORT static Object* Dbg_ObjectAlloc(bf::System::Reflection::TypeInstance* typeInst, intptr size); BFRT_EXPORT static Object* Dbg_ObjectAlloc(bf::System::ClassVData* classVData, intptr size, intptr align, intptr maxStackTraceDept, uint8 allocFlags); BFRT_EXPORT static void Dbg_MarkObjectDeleted(bf::System::Object* obj); @@ -455,7 +455,7 @@ void Internal::Dbg_ObjectStackInit(bf::System::Object* result, bf::System::Class #endif } -static void SetupDbgAllocInfo(bf::System::Object* result, intptr origSize) +static void SetupDbgAllocInfo(bf::System::Object* result, intptr origSize, uint8 allocFlags) { #ifndef BFRT_NODBGFLAGS if (gPendingAllocState.mStackTraceCount == 0) @@ -472,13 +472,13 @@ static void SetupDbgAllocInfo(bf::System::Object* result, intptr origSize) { result->mClassVData |= (intptr)BfObjectFlag_AllocInfo; result->mDbgAllocInfo = origSize; - *(intptr*)((uint8*)result + origSize) = gPendingAllocState.mStackTraceCount; + *(intptr*)((uint8*)result + origSize) = (gPendingAllocState.mStackTraceCount << 8) | allocFlags; memcpy((uint8*)result + origSize + sizeof(intptr), gPendingAllocState.mStackTrace, gPendingAllocState.mStackTraceCount * sizeof(intptr)); } else { result->mClassVData |= (intptr)BfObjectFlag_AllocInfo_Short; - result->mDbgAllocInfo = (origSize << 16) | gPendingAllocState.mStackTraceCount; + result->mDbgAllocInfo = (origSize << 16) | (((intptr)allocFlags) << 8) | gPendingAllocState.mStackTraceCount; memcpy((uint8*)result + origSize, gPendingAllocState.mStackTrace, gPendingAllocState.mStackTraceCount * sizeof(intptr)); } #endif @@ -493,12 +493,12 @@ void Internal::Dbg_ObjectCreated(bf::System::Object* result, intptr size, bf::Sy #endif } -void Internal::Dbg_ObjectCreatedEx(bf::System::Object* result, intptr origSize, bf::System::ClassVData* classVData) +void Internal::Dbg_ObjectCreatedEx(bf::System::Object* result, intptr origSize, bf::System::ClassVData* classVData, uint8 allocFlags) { BF_ASSERT((BFRTFLAGS & BfRtFlags_ObjectHasDebugFlags) != 0); #ifndef BFRT_NODBGFLAGS BF_ASSERT_REL((result->mClassVData & ~(BfObjectFlag_Allocated | BfObjectFlag_Mark3)) == (intptr)classVData); - SetupDbgAllocInfo(result, origSize); + SetupDbgAllocInfo(result, origSize, allocFlags); #endif } @@ -511,11 +511,11 @@ void Internal::Dbg_ObjectAllocated(bf::System::Object* result, intptr size, bf:: #endif } -void Internal::Dbg_ObjectAllocatedEx(bf::System::Object* result, intptr origSize, bf::System::ClassVData* classVData) +void Internal::Dbg_ObjectAllocatedEx(bf::System::Object* result, intptr origSize, bf::System::ClassVData* classVData, uint8 allocFlags) { BF_ASSERT((BFRTFLAGS & BfRtFlags_ObjectHasDebugFlags) != 0); result->mClassVData = (intptr)classVData; - SetupDbgAllocInfo(result, origSize); + SetupDbgAllocInfo(result, origSize, allocFlags); } void Internal::Dbg_ObjectPreDelete(bf::System::Object* object) diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 3f73dbbe..da12cfcb 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -10461,9 +10461,11 @@ BfIRValue BfModule::AllocFromType(BfType* type, const BfAllocTarget& allocTarget llvmArgs.push_back(objectPtr); llvmArgs.push_back(origSizeValue); llvmArgs.push_back(vDataRef); + if (isAllocEx) + llvmArgs.push_back(mBfIRBuilder->CreateConst(BfTypeCode_Int8, allocFlags)); auto objectCreatedMethod = GetInternalMethod(isAllocEx ? (isResultInitialized ? "Dbg_ObjectCreatedEx" : "Dbg_ObjectAllocatedEx") : - (isResultInitialized ? "Dbg_ObjectCreated" : "Dbg_ObjectAllocated")); + (isResultInitialized ? "Dbg_ObjectCreated" : "Dbg_ObjectAllocated")); mBfIRBuilder->CreateCall(objectCreatedMethod.mFunc, llvmArgs); if (wasAllocated)