mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-10 12:32:20 +02:00
Sanitized deleted deps from mid-compile rebuild-deleted on-demand types
This commit is contained in:
parent
e852ba49bb
commit
0b020c2cb0
4 changed files with 54 additions and 5 deletions
|
@ -364,6 +364,7 @@ BfCompiler::BfCompiler(BfSystem* bfSystem, bool isResolveOnly)
|
||||||
mInterfaceSlotCountChanged = false;
|
mInterfaceSlotCountChanged = false;
|
||||||
mLastHadComptimeRebuilds = false;
|
mLastHadComptimeRebuilds = false;
|
||||||
mHasComptimeRebuilds = false;
|
mHasComptimeRebuilds = false;
|
||||||
|
mDepsMayHaveDeletedTypes = false;
|
||||||
|
|
||||||
mHSPreserveIdx = 0;
|
mHSPreserveIdx = 0;
|
||||||
mCompileLogFP = NULL;
|
mCompileLogFP = NULL;
|
||||||
|
@ -2529,6 +2530,39 @@ void BfCompiler::UpdateDependencyMap(bool deleteUnusued, bool& didWork)
|
||||||
}
|
}
|
||||||
|
|
||||||
mContext->mQueuedSpecializedMethodRebuildTypes.Clear();
|
mContext->mQueuedSpecializedMethodRebuildTypes.Clear();
|
||||||
|
mDepsMayHaveDeletedTypes = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void BfCompiler::SanitizeDependencyMap()
|
||||||
|
{
|
||||||
|
BfLogSysM("SanitizeDependencyMap\n");
|
||||||
|
|
||||||
|
for (auto type : mContext->mResolvedTypes)
|
||||||
|
{
|
||||||
|
if (type == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
auto depType = type->ToDependedType();
|
||||||
|
if (depType == NULL)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
// Not combined with previous loop because PopulateType could modify typeInst->mDependencyMap
|
||||||
|
for (auto itr = depType->mDependencyMap.begin(); itr != depType->mDependencyMap.end();)
|
||||||
|
{
|
||||||
|
auto dependentType = itr->mKey;
|
||||||
|
auto depTypeInst = dependentType->ToTypeInstance();
|
||||||
|
if (dependentType->IsDeleting())
|
||||||
|
{
|
||||||
|
BfLogSysM("SanitizeDependencyMap removing old dependent %p from %p\n", dependentType, depType);
|
||||||
|
itr = depType->mDependencyMap.erase(itr);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
++itr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
mContext->RemoveInvalidWorkItems();
|
||||||
|
mDepsMayHaveDeletedTypes = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
// When we are unsure of whether an old generic instance will survive, we RebuildType but don't put it in any worklist.
|
// When we are unsure of whether an old generic instance will survive, we RebuildType but don't put it in any worklist.
|
||||||
|
@ -2538,7 +2572,7 @@ void BfCompiler::UpdateDependencyMap(bool deleteUnusued, bool& didWork)
|
||||||
// 3) It stays undefined and we need to build it here
|
// 3) It stays undefined and we need to build it here
|
||||||
void BfCompiler::ProcessPurgatory(bool reifiedOnly)
|
void BfCompiler::ProcessPurgatory(bool reifiedOnly)
|
||||||
{
|
{
|
||||||
BP_ZONE("BfCompiler::ProcessPuragory");
|
BP_ZONE("BfCompiler::ProcessPurgatory");
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
@ -7432,6 +7466,12 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
||||||
}
|
}
|
||||||
|
|
||||||
ProcessPurgatory(false);
|
ProcessPurgatory(false);
|
||||||
|
// ProcessPurgatory MAY cause type rebuilds which we need to handle
|
||||||
|
DoWorkLoop();
|
||||||
|
|
||||||
|
BfLogSysM("Checking mDepsMayHaveDeletedTypes for SanitizeDependencyMap\n");
|
||||||
|
if (mDepsMayHaveDeletedTypes)
|
||||||
|
SanitizeDependencyMap();
|
||||||
|
|
||||||
// Old Mark used modules
|
// Old Mark used modules
|
||||||
|
|
||||||
|
|
|
@ -337,6 +337,7 @@ public:
|
||||||
bool mLastHadComptimeRebuilds;
|
bool mLastHadComptimeRebuilds;
|
||||||
bool mHasComptimeRebuilds;
|
bool mHasComptimeRebuilds;
|
||||||
bool mInInvalidState;
|
bool mInInvalidState;
|
||||||
|
bool mDepsMayHaveDeletedTypes;
|
||||||
float mCompletionPct;
|
float mCompletionPct;
|
||||||
int mHSPreserveIdx;
|
int mHSPreserveIdx;
|
||||||
BfModule* mLastAutocompleteModule;
|
BfModule* mLastAutocompleteModule;
|
||||||
|
@ -476,6 +477,7 @@ public:
|
||||||
void EmitTestMethod(BfVDataModule* bfModule, Array<TestMethod>& testMethods, BfIRValue& retValue);
|
void EmitTestMethod(BfVDataModule* bfModule, Array<TestMethod>& testMethods, BfIRValue& retValue);
|
||||||
void CreateVData(BfVDataModule* bfModule);
|
void CreateVData(BfVDataModule* bfModule);
|
||||||
void UpdateDependencyMap(bool deleteUnusued, bool& didWork);
|
void UpdateDependencyMap(bool deleteUnusued, bool& didWork);
|
||||||
|
void SanitizeDependencyMap();
|
||||||
void ProcessPurgatory(bool reifiedOnly);
|
void ProcessPurgatory(bool reifiedOnly);
|
||||||
bool VerifySlotNums();
|
bool VerifySlotNums();
|
||||||
bool QuickGenerateSlotNums();
|
bool QuickGenerateSlotNums();
|
||||||
|
|
|
@ -1690,6 +1690,7 @@ void BfContext::DeleteType(BfType* type, bool deferDepRebuilds)
|
||||||
if (type->mRebuildFlags & BfTypeRebuildFlag_Deleted)
|
if (type->mRebuildFlags & BfTypeRebuildFlag_Deleted)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
mCompiler->mDepsMayHaveDeletedTypes = true;
|
||||||
mCompiler->mStats.mTypesDeleted++;
|
mCompiler->mStats.mTypesDeleted++;
|
||||||
|
|
||||||
BfDependedType* dType = type->ToDependedType();
|
BfDependedType* dType = type->ToDependedType();
|
||||||
|
|
|
@ -3959,7 +3959,13 @@ void BfIRCodeGen::HandleNextCmd()
|
||||||
CMD_PARAM(int, argIdx);
|
CMD_PARAM(int, argIdx);
|
||||||
CMD_PARAM(String, name);
|
CMD_PARAM(String, name);
|
||||||
|
|
||||||
auto argItr = ((llvm::Function*)func)->arg_begin();
|
if (argIdx >= func->arg_size())
|
||||||
|
{
|
||||||
|
Fail("BfIRCmd_Func_SetParamName argIdx error");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto argItr = func->arg_begin();
|
||||||
for (int i = 1; i < argIdx; i++)
|
for (int i = 1; i < argIdx; i++)
|
||||||
++argItr;
|
++argItr;
|
||||||
argItr->setName(name.c_str());
|
argItr->setName(name.c_str());
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue