Forráskód Böngészése

Perform PopulateReified pass after ProcessPurgatory

Brian Fiete 3 éve
szülő
commit
6f51eca72c

+ 18 - 6
IDEHelper/Compiler/BfCompiler.cpp

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

+ 1 - 1
IDEHelper/Compiler/BfCompiler.h

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

+ 3 - 0
IDEHelper/Compiler/BfModule.cpp

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