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:
committed by
Space
parent
e7102cd63f
commit
71397a06fb
@@ -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*) {
|
||||
|
||||
Reference in New Issue
Block a user