mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Allow 'DisableChecks' to remove append dtor check
This commit is contained in:
parent
f7120e4c72
commit
5b23020140
3 changed files with 27 additions and 22 deletions
|
@ -23,6 +23,7 @@ namespace System.IO
|
||||||
mString = appendStr;
|
mString = appendStr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[DisableChecks]
|
||||||
public ~this()
|
public ~this()
|
||||||
{
|
{
|
||||||
if (mStringKind == .Append)
|
if (mStringKind == .Append)
|
||||||
|
|
|
@ -437,7 +437,7 @@ namespace System
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Dbg_AppendDeleted(Object rootObj)
|
public static void Dbg_AppendDeleted(Object rootObj, bool doChecks)
|
||||||
{
|
{
|
||||||
#if BF_ENABLE_OBJECT_DEBUG_FLAGS
|
#if BF_ENABLE_OBJECT_DEBUG_FLAGS
|
||||||
void Handle(AppendAllocEntry* headAllocEntry)
|
void Handle(AppendAllocEntry* headAllocEntry)
|
||||||
|
@ -448,12 +448,15 @@ namespace System
|
||||||
switch (checkAllocEntry.mKind)
|
switch (checkAllocEntry.mKind)
|
||||||
{
|
{
|
||||||
case .Object(let obj):
|
case .Object(let obj):
|
||||||
|
if (doChecks)
|
||||||
|
{
|
||||||
#unwarn
|
#unwarn
|
||||||
if (!obj.[DisableObjectAccessChecks]IsDeleted())
|
if (!obj.[DisableObjectAccessChecks]IsDeleted())
|
||||||
{
|
{
|
||||||
if (obj.GetType().HasDestructor)
|
if (obj.GetType().HasDestructor)
|
||||||
Debug.FatalError("Appended object not deleted with 'delete:append'");
|
Debug.FatalError("Appended object not deleted with 'delete:append'");
|
||||||
}
|
}
|
||||||
|
}
|
||||||
case .Raw(let rawPtr, let allocData):
|
case .Raw(let rawPtr, let allocData):
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
|
|
|
@ -18142,9 +18142,10 @@ void BfModule::EmitDtorBody()
|
||||||
{
|
{
|
||||||
auto thisValue = GetThis();
|
auto thisValue = GetThis();
|
||||||
auto appendedObj = mBfIRBuilder->CreateBitCast(thisValue.mValue, mBfIRBuilder->MapType(mContext->mBfObjectType));
|
auto appendedObj = mBfIRBuilder->CreateBitCast(thisValue.mValue, mBfIRBuilder->MapType(mContext->mBfObjectType));
|
||||||
BfModuleMethodInstance allocMethod = GetInternalMethod("Dbg_AppendDeleted", 1);
|
BfModuleMethodInstance allocMethod = GetInternalMethod("Dbg_AppendDeleted", 2);
|
||||||
SizedArray<BfIRValue, 1> llvmArgs;
|
SizedArray<BfIRValue, 1> llvmArgs;
|
||||||
llvmArgs.push_back(appendedObj);
|
llvmArgs.Add(appendedObj);
|
||||||
|
llvmArgs.Add(mBfIRBuilder->CreateConst(BfTypeCode_Boolean, mCurMethodState->mDisableChecks ? 0 : 1));
|
||||||
if (allocMethod)
|
if (allocMethod)
|
||||||
mBfIRBuilder->CreateCall(allocMethod.mFunc, llvmArgs);
|
mBfIRBuilder->CreateCall(allocMethod.mFunc, llvmArgs);
|
||||||
}
|
}
|
||||||
|
@ -22030,6 +22031,20 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
||||||
if ((methodDef != NULL) && (propertyDeclaration != NULL) && (propertyDeclaration->mExternSpecifier != NULL))
|
if ((methodDef != NULL) && (propertyDeclaration != NULL) && (propertyDeclaration->mExternSpecifier != NULL))
|
||||||
hasExternSpecifier = true;
|
hasExternSpecifier = true;
|
||||||
|
|
||||||
|
if (methodDef->mName == BF_METHODNAME_MARKMEMBERS)
|
||||||
|
{
|
||||||
|
// We need to be able to mark deleted objects
|
||||||
|
mCurMethodState->mIgnoreObjectAccessCheck = true;
|
||||||
|
}
|
||||||
|
auto customAttributes = methodInstance->GetCustomAttributes();
|
||||||
|
if (customAttributes != NULL)
|
||||||
|
{
|
||||||
|
if (customAttributes->Contains(mCompiler->mDisableObjectAccessChecksAttributeTypeDef))
|
||||||
|
mCurMethodState->mIgnoreObjectAccessCheck = true;
|
||||||
|
if (customAttributes->Contains(mCompiler->mDisableChecksAttributeTypeDef))
|
||||||
|
mCurMethodState->mDisableChecks = true;
|
||||||
|
}
|
||||||
|
|
||||||
// Allocate, clear, set classVData
|
// Allocate, clear, set classVData
|
||||||
|
|
||||||
if ((methodDef->mMethodType == BfMethodType_Ctor) && (methodDef->mIsStatic))
|
if ((methodDef->mMethodType == BfMethodType_Ctor) && (methodDef->mIsStatic))
|
||||||
|
@ -22209,20 +22224,6 @@ void BfModule::ProcessMethod(BfMethodInstance* methodInstance, bool isInlineDup,
|
||||||
EmitIteratorBlock(skipBody);
|
EmitIteratorBlock(skipBody);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (methodDef->mName == BF_METHODNAME_MARKMEMBERS)
|
|
||||||
{
|
|
||||||
// We need to be able to mark deleted objects
|
|
||||||
mCurMethodState->mIgnoreObjectAccessCheck = true;
|
|
||||||
}
|
|
||||||
auto customAttributes = methodInstance->GetCustomAttributes();
|
|
||||||
if (customAttributes != NULL)
|
|
||||||
{
|
|
||||||
if (customAttributes->Contains(mCompiler->mDisableObjectAccessChecksAttributeTypeDef))
|
|
||||||
mCurMethodState->mIgnoreObjectAccessCheck = true;
|
|
||||||
if (customAttributes->Contains(mCompiler->mDisableChecksAttributeTypeDef))
|
|
||||||
mCurMethodState->mDisableChecks = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ((methodDef->mMethodType == BfMethodType_CtorNoBody) && (!methodDef->mIsStatic) &&
|
if ((methodDef->mMethodType == BfMethodType_CtorNoBody) && (!methodDef->mIsStatic) &&
|
||||||
((methodInstance->mChainType == BfMethodChainType_ChainHead) || (methodInstance->mChainType == BfMethodChainType_None)))
|
((methodInstance->mChainType == BfMethodChainType_ChainHead) || (methodInstance->mChainType == BfMethodChainType_None)))
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue