diff --git a/BeefLibs/corlib/src/Compiler.bf b/BeefLibs/corlib/src/Compiler.bf index 0206bfd3..45a8e3c3 100644 --- a/BeefLibs/corlib/src/Compiler.bf +++ b/BeefLibs/corlib/src/Compiler.bf @@ -18,6 +18,12 @@ namespace System } } + public static class Options + { + [LinkName("#AllocStackCount")] + public static extern int32 AllocStackCount; + } + [LinkName("#CallerLineNum")] public static extern int CallerLineNum; diff --git a/BeefLibs/corlib/src/Reflection/TypeInstance.bf b/BeefLibs/corlib/src/Reflection/TypeInstance.bf index 571c0704..da22df61 100644 --- a/BeefLibs/corlib/src/Reflection/TypeInstance.bf +++ b/BeefLibs/corlib/src/Reflection/TypeInstance.bf @@ -143,7 +143,7 @@ namespace System.Reflection let objType = typeof(Object) as TypeInstance; #if BF_ENABLE_OBJECT_DEBUG_FLAGS - obj = Internal.Dbg_ObjectAlloc(mTypeClassVData, mInstSize, mInstAlign, 1); + obj = Internal.Dbg_ObjectAlloc(mTypeClassVData, mInstSize, mInstAlign, Compiler.Options.AllocStackCount); #else void* mem = new [Align(16)] uint8[mInstSize]* (?); obj = Internal.UnsafeCastToObject(mem); diff --git a/BeefLibs/corlib/src/Type.bf b/BeefLibs/corlib/src/Type.bf index d12cd3c6..79d2288e 100644 --- a/BeefLibs/corlib/src/Type.bf +++ b/BeefLibs/corlib/src/Type.bf @@ -1187,7 +1187,7 @@ namespace System.Reflection let genericType = GetGenericArg(0); let arraySize = [Friend]mInstSize - genericType.Size + genericType.Stride * count; #if BF_ENABLE_OBJECT_DEBUG_FLAGS - obj = Internal.Dbg_ObjectAlloc([Friend]mTypeClassVData, arraySize, [Friend]mInstAlign, 1); + obj = Internal.Dbg_ObjectAlloc([Friend]mTypeClassVData, arraySize, [Friend]mInstAlign, Compiler.Options.AllocStackCount); #else void* mem = new [Align(16)] uint8[arraySize]* (?); obj = Internal.UnsafeCastToObject(mem); diff --git a/IDE/mintest/minlib/src/System/Compiler.bf b/IDE/mintest/minlib/src/System/Compiler.bf index d53edb15..2c559e2c 100644 --- a/IDE/mintest/minlib/src/System/Compiler.bf +++ b/IDE/mintest/minlib/src/System/Compiler.bf @@ -2,6 +2,12 @@ namespace System { class Compiler { + public static class Options + { + [LinkName("#AllocStackCount")] + public static extern int32 AllocStackCount; + } + [LinkName("#CallerLineNum")] public static extern int CallerLineNum; diff --git a/IDE/mintest/minlib/src/System/Type.bf b/IDE/mintest/minlib/src/System/Type.bf index 0392f154..9a7d25b7 100644 --- a/IDE/mintest/minlib/src/System/Type.bf +++ b/IDE/mintest/minlib/src/System/Type.bf @@ -1117,7 +1117,7 @@ namespace System.Reflection let genericType = GetGenericArg(0); let arraySize = [Friend]mInstSize - genericType.Size + genericType.Stride * count; #if BF_ENABLE_OBJECT_DEBUG_FLAGS - obj = Internal.Dbg_ObjectAlloc([Friend]mTypeClassVData, arraySize, [Friend]mInstAlign, 1); + obj = Internal.Dbg_ObjectAlloc([Friend]mTypeClassVData, arraySize, [Friend]mInstAlign, Compiler.Options.AllocStackCount); #else void* mem = new [Align(16)] uint8[arraySize]* (?); obj = Internal.UnsafeCastToObject(mem); diff --git a/IDEHelper/Compiler/BfModule.cpp b/IDEHelper/Compiler/BfModule.cpp index 272af6dd..c23d16a2 100644 --- a/IDEHelper/Compiler/BfModule.cpp +++ b/IDEHelper/Compiler/BfModule.cpp @@ -13876,6 +13876,10 @@ BfTypedValue BfModule::GetCompilerFieldValue(const StringImpl& str) if (mProject != NULL) return BfTypedValue(GetStringObjectValue(mProject->mName), ResolveTypeDef(mCompiler->mStringTypeDef)); } + if (str == "#AllocStackCount") + { + return BfTypedValue(mBfIRBuilder->CreateConst(BfTypeCode_Int32, mCompiler->mOptions.mAllocStackCount), GetPrimitiveType(BfTypeCode_Int32)); + } if (mCurMethodState->mMixinState != NULL) {