MCPcopy Create free account
hub / github.com/GaijinEntertainment/daScript / ~ModuleGcFinalize

Method ~ModuleGcFinalize

src/ast/ast_parse.cpp:703–719  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

701 TextWriter * logs = nullptr;
702 explicit ModuleGcFinalize ( Program * p ) : prog(p) {}
703 ~ModuleGcFinalize() {
704 if ( prog ) {
705 auto m = prog->thisModule.get();
706 gc_root * oldRoot = m->module_gc_root.get();
707 auto fresh = make_unique<gc_root>();
708 m->gc_collect(oldRoot, fresh.get()); // live oldRoot -> fresh; garbage stays on oldRoot
709 if ( logs && gcStageReportEnabled() ) {
710 *logs << "=== gc survivors @ " << m->name << " : live="
711 << fresh->gc_count << " garbage=" << oldRoot->gc_count << " ===\n";
712 gcReportHistogram(*fresh, "live", *logs, 200);
713 }
714 gc_root * liveRoot = fresh.get();
715 gc_root::gc_get_active_root() = liveRoot; // repoint active before the move frees oldRoot
716 m->module_gc_root = das::move(fresh); // deletes oldRoot -> sweeps garbage
717 }
718 clearAllFunctionLookups();
719 }
720 ModuleGcFinalize ( const ModuleGcFinalize & ) = delete;
721 ModuleGcFinalize & operator = ( const ModuleGcFinalize & ) = delete;
722 };

Callers

nothing calls this directly

Calls 5

gcStageReportEnabledFunction · 0.85
gcReportHistogramFunction · 0.85
clearAllFunctionLookupsFunction · 0.85
getMethod · 0.45
gc_collectMethod · 0.45

Tested by

no test coverage detected