mirror of
https://github.com/beefytech/Beef.git
synced 2025-06-08 19:48:20 +02:00
Defer specialized module deletion
This commit is contained in:
parent
67329ac774
commit
347dc5b8cf
3 changed files with 28 additions and 10 deletions
|
@ -487,7 +487,7 @@ BfCompiler::BfCompiler(BfSystem* bfSystem, bool isResolveOnly)
|
||||||
}
|
}
|
||||||
|
|
||||||
BfCompiler::~BfCompiler()
|
BfCompiler::~BfCompiler()
|
||||||
{
|
{
|
||||||
delete mCeMachine;
|
delete mCeMachine;
|
||||||
mCeMachine = NULL;
|
mCeMachine = NULL;
|
||||||
delete mContext;
|
delete mContext;
|
||||||
|
@ -895,6 +895,7 @@ void BfCompiler::GetTestMethods(BfVDataModule* bfModule, Array<TestMethod>& test
|
||||||
testMethod.mMethodInstance = methodInstance;
|
testMethod.mMethodInstance = methodInstance;
|
||||||
testMethods.Add(testMethod);
|
testMethods.Add(testMethod);
|
||||||
|
|
||||||
|
BF_ASSERT_REL(!typeInstance->mModule->mIsDeleting);
|
||||||
if (!bfModule->mProject->mUsedModules.Contains(typeInstance->mModule))
|
if (!bfModule->mProject->mUsedModules.Contains(typeInstance->mModule))
|
||||||
{
|
{
|
||||||
bfModule->mProject->mUsedModules.Add(typeInstance->mModule);
|
bfModule->mProject->mUsedModules.Add(typeInstance->mModule);
|
||||||
|
@ -1077,6 +1078,7 @@ void BfCompiler::CreateVData(BfVDataModule* bfModule)
|
||||||
BfLogSysM("CreateVData %s\n", bfModule->mProject->mName.c_str());
|
BfLogSysM("CreateVData %s\n", bfModule->mProject->mName.c_str());
|
||||||
CompileLog("CreateVData %s\n", bfModule->mProject->mName.c_str());
|
CompileLog("CreateVData %s\n", bfModule->mProject->mName.c_str());
|
||||||
|
|
||||||
|
BF_ASSERT_REL(!bfModule->mIsDeleting);
|
||||||
bfModule->mProject->mUsedModules.Add(bfModule);
|
bfModule->mProject->mUsedModules.Add(bfModule);
|
||||||
|
|
||||||
auto project = bfModule->mProject;
|
auto project = bfModule->mProject;
|
||||||
|
@ -7609,7 +7611,7 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
||||||
|
|
||||||
if (bfModule->mParentModule != NULL)
|
if (bfModule->mParentModule != NULL)
|
||||||
{
|
{
|
||||||
for (auto&& fileName : bfModule->mOutFileNames)
|
for (auto& fileName : bfModule->mOutFileNames)
|
||||||
{
|
{
|
||||||
if (!mainModule->mOutFileNames.Contains(fileName))
|
if (!mainModule->mOutFileNames.Contains(fileName))
|
||||||
mainModule->mOutFileNames.push_back(fileName);
|
mainModule->mOutFileNames.push_back(fileName);
|
||||||
|
@ -7704,7 +7706,7 @@ bool BfCompiler::DoCompile(const StringImpl& outputDirectory)
|
||||||
BfModule* bfModule = mainModule;
|
BfModule* bfModule = mainModule;
|
||||||
if (bfModule->mIsReified)
|
if (bfModule->mIsReified)
|
||||||
{
|
{
|
||||||
for (auto outFileName : bfModule->mOutFileNames)
|
for (auto& outFileName : bfModule->mOutFileNames)
|
||||||
{
|
{
|
||||||
if (outFileName.mModuleWritten)
|
if (outFileName.mModuleWritten)
|
||||||
BeLibManager::Get()->AddUsedFileName(outFileName.mFileName);
|
BeLibManager::Get()->AddUsedFileName(outFileName.mFileName);
|
||||||
|
@ -10473,9 +10475,12 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetUsedOutputFileNames(BfCompiler*
|
||||||
HashSet<String> usedFileNames;
|
HashSet<String> usedFileNames;
|
||||||
usedFileNames.Reserve(moduleList.size());
|
usedFileNames.Reserve(moduleList.size());
|
||||||
|
|
||||||
for (auto mainModule : moduleList)
|
//for (auto mainModule : moduleList)
|
||||||
|
for (int i = 0; i < moduleList.mSize; i++)
|
||||||
{
|
{
|
||||||
BF_ASSERT(!mainModule->mIsDeleting);
|
auto mainModule = moduleList[i];
|
||||||
|
BF_ASSERT_REL(!mainModule->mIsDeleting);
|
||||||
|
BF_ASSERT_REL((mainModule->mRevision > -2) && (mainModule->mRevision < 1000000));
|
||||||
|
|
||||||
if ((flags & BfUsedOutputFlags_SkipImports) == 0)
|
if ((flags & BfUsedOutputFlags_SkipImports) == 0)
|
||||||
{
|
{
|
||||||
|
@ -10490,7 +10495,7 @@ BF_EXPORT const char* BF_CALLTYPE BfCompiler_GetUsedOutputFileNames(BfCompiler*
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
for (auto&& moduleFileName : mainModule->mOutFileNames)
|
for (auto& moduleFileName : mainModule->mOutFileNames)
|
||||||
{
|
{
|
||||||
if (!moduleFileName.mModuleWritten)
|
if (!moduleFileName.mModuleWritten)
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -1798,7 +1798,7 @@ void BfContext::DeleteType(BfType* type, bool deferDepRebuilds)
|
||||||
|
|
||||||
// This was only needed for 'zombie modules', which we don't need anymore?
|
// This was only needed for 'zombie modules', which we don't need anymore?
|
||||||
// To avoid linking errors. Used instead of directly removing from mModules.
|
// To avoid linking errors. Used instead of directly removing from mModules.
|
||||||
mDeletingModules.push_back(module);
|
mDeletingModules.Add(module);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3187,7 +3187,7 @@ void BfContext::MarkUsedModules(BfProject* project, BfModule* module)
|
||||||
{
|
{
|
||||||
BP_ZONE("BfContext::MarkUsedModules");
|
BP_ZONE("BfContext::MarkUsedModules");
|
||||||
|
|
||||||
BF_ASSERT(!module->mIsDeleting);
|
BF_ASSERT_REL(!module->mIsDeleting);
|
||||||
|
|
||||||
if (module->mIsScratchModule)
|
if (module->mIsScratchModule)
|
||||||
return;
|
return;
|
||||||
|
@ -3316,10 +3316,15 @@ void BfContext::Cleanup()
|
||||||
{
|
{
|
||||||
for (auto itr = project->mUsedModules.begin(); itr != project->mUsedModules.end(); )
|
for (auto itr = project->mUsedModules.begin(); itr != project->mUsedModules.end(); )
|
||||||
{
|
{
|
||||||
if ((*itr)->mIsDeleting)
|
auto module = *itr;
|
||||||
|
|
||||||
|
if (module->mIsDeleting)
|
||||||
itr = project->mUsedModules.Remove(itr);
|
itr = project->mUsedModules.Remove(itr);
|
||||||
else
|
else
|
||||||
|
{
|
||||||
|
BF_ASSERT_REL(module->mRevision > -2);
|
||||||
++itr;
|
++itr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -930,6 +930,8 @@ void BfReportMemory();
|
||||||
|
|
||||||
BfModule::~BfModule()
|
BfModule::~BfModule()
|
||||||
{
|
{
|
||||||
|
mRevision = -2;
|
||||||
|
|
||||||
BfLogSysM("Deleting module %p: %s \n", this, mModuleName.c_str());
|
BfLogSysM("Deleting module %p: %s \n", this, mModuleName.c_str());
|
||||||
|
|
||||||
if (!mIsDeleting)
|
if (!mIsDeleting)
|
||||||
|
@ -1311,7 +1313,13 @@ void BfModule::StartNewRevision(RebuildKind rebuildKind, bool force)
|
||||||
for (auto& specPair : mSpecializedMethodModules)
|
for (auto& specPair : mSpecializedMethodModules)
|
||||||
{
|
{
|
||||||
auto specModule = specPair.mValue;
|
auto specModule = specPair.mValue;
|
||||||
delete specModule;
|
|
||||||
|
BfLogSysM("Setting module mIsDeleting %p due to parent module starting a new revision\n", module);
|
||||||
|
|
||||||
|
// This module is no longer needed
|
||||||
|
specModule->RemoveModuleData();
|
||||||
|
specModule->mIsDeleting = true;
|
||||||
|
mContext->mDeletingModules.Add(specModule);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mSpecializedMethodModules.Clear();
|
mSpecializedMethodModules.Clear();
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue