| 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 | }; |
nothing calls this directly
no test coverage detected