MCPcopy Create free account
hub / github.com/beefytech/Beef / Cleanup

Method Cleanup

IDEHelper/Compiler/BfContext.cpp:3484–3605  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3482}
3483
3484void BfContext::Cleanup()
3485{
3486 BfLogSysM("BfContext::Cleanup() MethodWorkList: %d LocalMethodGraveyard: %d\n", mMethodWorkList.size(), mLocalMethodGraveyard.size());
3487
3488 // Can't clean up LLVM types, they are allocated with a bump allocator
3489 RemoveInvalidFailTypes();
3490
3491 mCompiler->mCompileState = BfCompiler::CompileState_Cleanup;
3492
3493 if (mCompiler->mStats.mTypesDeleted_LastUpdateAfterDeletingTypes != mCompiler->mStats.mTypesDeleted)
3494 {
3495 // Should only occur for internal compiler errors
3496 BF_ASSERT(mCompiler->mExtraCompileRequested);
3497 UpdateAfterDeletingTypes();
3498 }
3499
3500 ///
3501 {
3502 Array<BfLocalMethod*> survivingLocalMethods;
3503
3504 for (auto localMethod : mLocalMethodGraveyard)
3505 {
3506 bool inCEMachine = false;
3507 if (localMethod->mMethodInstanceGroup != NULL)
3508 {
3509 if ((localMethod->mMethodInstanceGroup->mDefault != NULL) && (localMethod->mMethodInstanceGroup->mDefault->mInCEMachine))
3510 inCEMachine = true;
3511 if (localMethod->mMethodInstanceGroup->mMethodSpecializationMap != NULL)
3512 {
3513 for (auto& kv : *localMethod->mMethodInstanceGroup->mMethodSpecializationMap)
3514 if (kv.mValue->mInCEMachine)
3515 inCEMachine = true;
3516 }
3517 }
3518
3519 if (inCEMachine)
3520 {
3521 localMethod->mMethodInstanceGroup->mOwner->mOwnedLocalMethods.Add(localMethod);
3522 }
3523 else if ((localMethod->mMethodInstanceGroup != NULL) && (localMethod->mMethodInstanceGroup->mRefCount > 0))
3524 {
3525 BfLogSysM("BfContext::Cleanup surviving local method with refs %p\n", localMethod);
3526 localMethod->Dispose();
3527 survivingLocalMethods.push_back(localMethod);
3528 }
3529 else if (!mMethodWorkList.empty())
3530 {
3531 // We can't remove the local methods if they still may be referenced by a BfMethodRefType used to specialize a method
3532 BfLogSysM("BfContext::Cleanup surviving local method %p\n", localMethod);
3533 localMethod->Dispose();
3534 survivingLocalMethods.push_back(localMethod);
3535 }
3536 else
3537 delete localMethod;
3538 }
3539 mLocalMethodGraveyard = survivingLocalMethods;
3540 }
3541

Callers

nothing calls this directly

Calls 13

sizeMethod · 0.45
AddMethod · 0.45
DisposeMethod · 0.45
push_backMethod · 0.45
emptyMethod · 0.45
IsBoxedMethod · 0.45
ClearMethod · 0.45
IsEmptyMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
RemoveMethod · 0.45
IndexOfMethod · 0.45

Tested by

no test coverage detected