Add Stop-the-World Mark & Sweep GC for single-threaded programs.

GC implementation for testing purposes

* Only works for a single mutator
* Runs on the same thread as the mutator
* Runs every nth checkpoint and after every m bytes are allocated
* Runs finalizers after sweeping on the mutator thread.
This commit is contained in:
Alexander Shabalin
2021-04-02 12:13:44 +00:00
committed by Space
parent e7102cd63f
commit 71397a06fb
16 changed files with 2161 additions and 22 deletions
+6 -1
View File
@@ -92,7 +92,12 @@ extern "C" MemoryState* InitMemory(bool firstRuntime) {
}
extern "C" void DeinitMemory(MemoryState* state, bool destroyRuntime) {
mm::ThreadRegistry::Instance().Unregister(mm::FromMemoryState(state));
auto* node = mm::FromMemoryState(state);
if (destroyRuntime) {
node->Get()->gc().PerformFullGC();
// TODO: Also make sure that finalizers are run.
}
mm::ThreadRegistry::Instance().Unregister(node);
}
extern "C" void RestoreMemory(MemoryState*) {