1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-07-04 23:36:00 +02:00

Merge pull request #1260 from disarray2077/allocstackcount

Expose `AllocStackCount` to corlib & Use it in Dbg_ObjectAlloc
This commit is contained in:
Brian Fiete 2021-12-06 09:35:55 -08:00 committed by GitHub
commit 22919dd629
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 55 additions and 19 deletions

View file

@ -5467,7 +5467,15 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
boxedTypeId = boxedType->mTypeId;
}
SizedArray<BfIRValue, 8> typeDataParams =
int stackCount = 0;
if ((typeInstance != NULL) && (typeInstance->mTypeOptionsIdx != -1))
{
auto typeOptions = mSystem->GetTypeOptions(typeInstance->mTypeOptionsIdx);
if (typeOptions->mAllocStackTraceDepth != -1)
stackCount = BF_MIN(0xFF, BF_MAX(0x01, typeOptions->mAllocStackTraceDepth));
}
SizedArray<BfIRValue, 9> typeDataParams =
{
objectData,
GetConstValue(type->mSize, intType), // mSize
@ -5476,7 +5484,8 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
GetConstValue(typeFlags, intType), // mTypeFlags
GetConstValue(memberDataOffset, intType), // mMemberDataOffset
GetConstValue(typeCode, byteType), // mTypeCode
GetConstValue(type->mAlign, byteType),
GetConstValue(type->mAlign, byteType), // mAlign
GetConstValue(stackCount, byteType), // mAllocStackCountOverride
};
auto typeData = mBfIRBuilder->CreateConstAgg_Value(mBfIRBuilder->MapTypeInst(mContext->mBfTypeType, BfIRPopulateType_Full), typeDataParams);
@ -13876,6 +13885,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)
{