1
0
Fork 0
mirror of https://github.com/beefytech/Beef.git synced 2025-06-09 12:02:21 +02:00

Fixes to SetDeleted

This commit is contained in:
Brian Fiete 2020-05-18 08:30:42 -07:00
parent 8745b40828
commit 693334bdc8
5 changed files with 26 additions and 8 deletions

View file

@ -151,7 +151,7 @@ namespace System
[Error("Cannot be called directly"), SkipCall] [Error("Cannot be called directly"), SkipCall]
static extern void SetDeletedX(void* dest, int size); static extern void SetDeletedX(void* dest, int size);
[Error("Cannot be called directly"), SkipCall] [Error("Cannot be called directly"), SkipCall]
static extern void SetDeleted(void* dest, int size, int32 align, int arrayCount); static extern void SetDeleted(void* dest, int size, int32 align);
[Error("Cannot be called directly"), SkipCall] [Error("Cannot be called directly"), SkipCall]
static extern void SetDeletedArray(void* dest, int size, int32 align, int arrayCount); static extern void SetDeletedArray(void* dest, int size, int32 align, int arrayCount);

View file

@ -129,7 +129,7 @@ namespace System
[Error("Cannot be called directly"), SkipCall] [Error("Cannot be called directly"), SkipCall]
static extern void SetDeletedX(void* dest, int size); static extern void SetDeletedX(void* dest, int size);
[Error("Cannot be called directly"), SkipCall] [Error("Cannot be called directly"), SkipCall]
static extern void SetDeleted(void* dest, int size, int32 align, int arrayCount); static extern void SetDeleted(void* dest, int size, int32 align);
[Error("Cannot be called directly"), SkipCall] [Error("Cannot be called directly"), SkipCall]
static extern void SetDeletedArray(void* dest, int size, int32 align, int arrayCount); static extern void SetDeletedArray(void* dest, int size, int32 align, int arrayCount);

View file

@ -13045,7 +13045,7 @@ void BfModule::EmitDeferredScopeCalls(bool useSrcPositions, BfScopeData* scopeDa
continue; continue;
} }
auto prevHead = checkScope->mDeferredCallEntries.mHead; auto prevHead = checkScope->mDeferredCallEntries.mHead;
EmitDeferredCall(*deferredCallEntry); EmitDeferredCall(*deferredCallEntry, true);
if (prevHead != checkScope->mDeferredCallEntries.mHead) if (prevHead != checkScope->mDeferredCallEntries.mHead)
{ {
// The list changed, start over and ignore anything we've already handled // The list changed, start over and ignore anything we've already handled
@ -13056,7 +13056,7 @@ void BfModule::EmitDeferredScopeCalls(bool useSrcPositions, BfScopeData* scopeDa
} }
else else
{ {
EmitDeferredCall(*deferredCallEntry); EmitDeferredCall(*deferredCallEntry, true);
deferredCallEntry = deferredCallEntry->mNext; deferredCallEntry = deferredCallEntry->mNext;
} }
} }

View file

@ -1490,7 +1490,7 @@ public:
bool AddDeferredCallEntry(BfDeferredCallEntry* deferredCallEntry, BfScopeData* scope); bool AddDeferredCallEntry(BfDeferredCallEntry* deferredCallEntry, BfScopeData* scope);
void AddDeferredBlock(BfBlock* block, BfScopeData* scope, Array<BfDeferredCapture>* captures = NULL); void AddDeferredBlock(BfBlock* block, BfScopeData* scope, Array<BfDeferredCapture>* captures = NULL);
BfDeferredCallEntry* AddDeferredCall(const BfModuleMethodInstance& moduleMethodInstance, SizedArrayImpl<BfIRValue>& llvmArgs, BfScopeData* scope, BfAstNode* srcNode = NULL, bool bypassVirtual = false, bool doNullCheck = false); BfDeferredCallEntry* AddDeferredCall(const BfModuleMethodInstance& moduleMethodInstance, SizedArrayImpl<BfIRValue>& llvmArgs, BfScopeData* scope, BfAstNode* srcNode = NULL, bool bypassVirtual = false, bool doNullCheck = false);
void EmitDeferredCall(BfDeferredCallEntry& deferredCallEntry); void EmitDeferredCall(BfDeferredCallEntry& deferredCallEntry, bool moveBlocks);
void EmitDeferredCallProcessor(SLIList<BfDeferredCallEntry*>& callEntries, BfIRValue callTail); void EmitDeferredCallProcessor(SLIList<BfDeferredCallEntry*>& callEntries, BfIRValue callTail);
bool CanCast(BfTypedValue typedVal, BfType* toType, BfCastFlags castFlags = BfCastFlags_None); bool CanCast(BfTypedValue typedVal, BfType* toType, BfCastFlags castFlags = BfCastFlags_None);
bool AreSplatsCompatible(BfType* fromType, BfType* toType, bool* outNeedsMemberCasting); bool AreSplatsCompatible(BfType* fromType, BfType* toType, bool* outNeedsMemberCasting);

View file

@ -562,7 +562,8 @@ void BfModule::EmitDeferredCall(BfModuleMethodInstance moduleMethodInstance, Siz
constant = mBfIRBuilder->GetConstant(llvmArgs[2]); constant = mBfIRBuilder->GetConstant(llvmArgs[2]);
if (constant != NULL) if (constant != NULL)
typeAlign = constant->mInt64; typeAlign = constant->mInt64;
auto arraySize = llvmArgs[3]; if (llvmArgs.size() >= 4)
arraySize = llvmArgs[3];
intptr allocSize = typeSize; intptr allocSize = typeSize;
if (arraySize) if (arraySize)
@ -641,6 +642,12 @@ void BfModule::EmitDeferredCall(BfModuleMethodInstance moduleMethodInstance, Siz
mBfIRBuilder->AddBlock(ddDoneBlock); mBfIRBuilder->AddBlock(ddDoneBlock);
mBfIRBuilder->SetInsertPoint(ddDoneBlock); mBfIRBuilder->SetInsertPoint(ddDoneBlock);
if ((flags & BfDeferredBlockFlag_MoveNewBlocksToEnd) != 0)
{
mCurMethodState->mCurScope->mAtEndBlocks.push_back(ddSize1Block);
mCurMethodState->mCurScope->mAtEndBlocks.push_back(ddDoneBlock);
}
} }
else else
{ {
@ -682,6 +689,15 @@ void BfModule::EmitDeferredCall(BfModuleMethodInstance moduleMethodInstance, Siz
mBfIRBuilder->AddBlock(ddDoneBlock); mBfIRBuilder->AddBlock(ddDoneBlock);
mBfIRBuilder->SetInsertPoint(ddDoneBlock); mBfIRBuilder->SetInsertPoint(ddDoneBlock);
if ((flags & BfDeferredBlockFlag_MoveNewBlocksToEnd) != 0)
{
mCurMethodState->mCurScope->mAtEndBlocks.push_back(ddSizePtrBlock);
mCurMethodState->mCurScope->mAtEndBlocks.push_back(ddCheck1Block);
if (mayBeZero)
mCurMethodState->mCurScope->mAtEndBlocks.push_back(ddSize1Block);
mCurMethodState->mCurScope->mAtEndBlocks.push_back(ddDoneBlock);
}
} }
} }
else else
@ -764,7 +780,7 @@ void BfModule::EmitDeferredCall(BfModuleMethodInstance moduleMethodInstance, Siz
} }
} }
void BfModule::EmitDeferredCall(BfDeferredCallEntry& deferredCallEntry) void BfModule::EmitDeferredCall(BfDeferredCallEntry& deferredCallEntry, bool moveBlocks)
{ {
if ((mCompiler->mIsResolveOnly) && (deferredCallEntry.mHandlerCount > 0)) if ((mCompiler->mIsResolveOnly) && (deferredCallEntry.mHandlerCount > 0))
{ {
@ -833,6 +849,8 @@ void BfModule::EmitDeferredCall(BfDeferredCallEntry& deferredCallEntry)
flags = (BfDeferredBlockFlags)(flags | BfDeferredBlockFlag_BypassVirtual); flags = (BfDeferredBlockFlags)(flags | BfDeferredBlockFlag_BypassVirtual);
if (deferredCallEntry.mDoNullCheck) if (deferredCallEntry.mDoNullCheck)
flags = (BfDeferredBlockFlags)(flags | BfDeferredBlockFlag_DoNullChecks | BfDeferredBlockFlag_SkipObjectAccessCheck | BfDeferredBlockFlag_MoveNewBlocksToEnd); flags = (BfDeferredBlockFlags)(flags | BfDeferredBlockFlag_DoNullChecks | BfDeferredBlockFlag_SkipObjectAccessCheck | BfDeferredBlockFlag_MoveNewBlocksToEnd);
if (moveBlocks)
flags = (BfDeferredBlockFlags)(flags | BfDeferredBlockFlag_MoveNewBlocksToEnd);
EmitDeferredCall(deferredCallEntry.mModuleMethodInstance, args, flags); EmitDeferredCall(deferredCallEntry.mModuleMethodInstance, args, flags);
} }
@ -996,7 +1014,7 @@ void BfModule::EmitDeferredCallProcessor(SLIList<BfDeferredCallEntry*>& callEntr
} }
auto prevHead = callEntries.mHead; auto prevHead = callEntries.mHead;
EmitDeferredCall(*deferredCallEntry); EmitDeferredCall(*deferredCallEntry, moveBlocks);
ValueScopeEnd(valueScopeStart); ValueScopeEnd(valueScopeStart);
mBfIRBuilder->CreateBr(condBB); mBfIRBuilder->CreateBr(condBB);