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

Perform PopulateReified pass after ProcessPurgatory

This commit is contained in:
Brian Fiete 2022-06-05 17:46:28 -07:00
parent a82130352a
commit 6f51eca72c
3 changed files with 22 additions and 7 deletions

View file

@ -2574,10 +2574,12 @@ void BfCompiler::SanitizeDependencyMap()
// 1) It gets built on demand // 1) It gets built on demand
// 2) It gets deleted in UpdateDependencyMap // 2) It gets deleted in UpdateDependencyMap
// 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) bool BfCompiler::ProcessPurgatory(bool reifiedOnly)
{ {
BP_ZONE("BfCompiler::ProcessPurgatory"); BP_ZONE("BfCompiler::ProcessPurgatory");
bool didWork = false;
while (true) while (true)
{ {
mContext->RemoveInvalidWorkItems(); mContext->RemoveInvalidWorkItems();
@ -2614,10 +2616,12 @@ void BfCompiler::ProcessPurgatory(bool reifiedOnly)
mGenericInstancePurgatory.Clear(); mGenericInstancePurgatory.Clear();
int prevPurgatorySize = (int)mGenericInstancePurgatory.size(); int prevPurgatorySize = (int)mGenericInstancePurgatory.size();
mContext->ProcessWorkList(reifiedOnly, reifiedOnly); if (mContext->ProcessWorkList(reifiedOnly, reifiedOnly))
didWork = true;
if (prevPurgatorySize == (int)mGenericInstancePurgatory.size()) if (prevPurgatorySize == (int)mGenericInstancePurgatory.size())
break; break;
} }
return didWork;
} }
bool BfCompiler::VerifySlotNums() bool BfCompiler::VerifySlotNums()
@ -7260,9 +7264,17 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
BfLogSysM("DoCompile looping over CompileReified due to mHasReifiedQueuedRebuildTypes\n"); BfLogSysM("DoCompile looping over CompileReified due to mHasReifiedQueuedRebuildTypes\n");
} }
ProcessPurgatory(true); // Handle purgatory (ie: old generic types)
{
bool didWork = ProcessPurgatory(true);
if (mOptions.mCompileOnDemandKind != BfCompileOnDemandKind_AlwaysInclude) if (mOptions.mCompileOnDemandKind != BfCompileOnDemandKind_AlwaysInclude)
DoWorkLoop(); {
if (DoWorkLoop())
didWork = true;
if (didWork)
PopulateReified();
}
}
// Mark used modules // Mark used modules
if ((mOptions.mCompileOnDemandKind != BfCompileOnDemandKind_AlwaysInclude) && (!mCanceling)) if ((mOptions.mCompileOnDemandKind != BfCompileOnDemandKind_AlwaysInclude) && (!mCanceling))

View file

@ -481,7 +481,7 @@ public:
void CreateVData(BfVDataModule* bfModule); void CreateVData(BfVDataModule* bfModule);
void UpdateDependencyMap(bool deleteUnusued, bool& didWork); void UpdateDependencyMap(bool deleteUnusued, bool& didWork);
void SanitizeDependencyMap(); void SanitizeDependencyMap();
void ProcessPurgatory(bool reifiedOnly); bool ProcessPurgatory(bool reifiedOnly);
bool VerifySlotNums(); bool VerifySlotNums();
bool QuickGenerateSlotNums(); bool QuickGenerateSlotNums();
bool SlowGenerateSlotNums(); bool SlowGenerateSlotNums();

View file

@ -6423,6 +6423,7 @@ BfIRValue BfModule::CreateTypeData(BfType* type, Dictionary<int, int>& usedStrin
if ((methodInstance != NULL) && (!methodInstance->mMethodDef->mIsAbstract)) if ((methodInstance != NULL) && (!methodInstance->mMethodDef->mIsAbstract))
{ {
BF_ASSERT(methodInstance->mIsReified); BF_ASSERT(methodInstance->mIsReified);
// This doesn't work because we may have FOREIGN methods from implicit interface methods // This doesn't work because we may have FOREIGN methods from implicit interface methods
//auto moduleMethodInst = GetMethodInstanceAtIdx(methodRef.mTypeInstance, methodRef.mMethodNum); //auto moduleMethodInst = GetMethodInstanceAtIdx(methodRef.mTypeInstance, methodRef.mMethodNum);
auto moduleMethodInst = ReferenceExternalMethodInstance(methodInstance, BfGetMethodInstanceFlag_NoInline); auto moduleMethodInst = ReferenceExternalMethodInstance(methodInstance, BfGetMethodInstanceFlag_NoInline);
@ -13911,6 +13912,8 @@ BfModuleMethodInstance BfModule::GetMethodInstance(BfTypeInstance* typeInst, BfM
auto _SetReified = [&]() auto _SetReified = [&]()
{ {
if (!mCompiler->mIsResolveOnly)
BF_ASSERT(mCompiler->mCompileState <= BfCompiler::CompileState_Normal);
methodInstance->mIsReified = true; methodInstance->mIsReified = true;
}; };