error on nested GC

This commit is contained in:
dzaima 2024-04-03 04:08:09 +03:00
parent d21a77119f
commit 647a0b97e7
2 changed files with 5 additions and 0 deletions

View File

@ -168,8 +168,11 @@ static void gcv2_unmark_visit(Value* x) {
#endif
GLOBAL u64 gc_lastAlloc;
GLOBAL bool gc_running;
void gc_forceGC(bool toplevel) {
#if ENABLE_GC
if (gc_running) fatal("starting GC while GC is in the middle of running");
gc_running = 1;
u64 startTime=0, startSize=0;
if (gc_log_enabled) {
startTime = nsTime();
@ -193,6 +196,7 @@ void gc_forceGC(bool toplevel) {
fprintf(stderr, "; took %.3fms\n", (nsTime()-startTime)/1e6);
}
gc_lastAlloc = endSize;
gc_running = 0;
#endif
}

View File

@ -1,6 +1,7 @@
#pragma once
extern GLOBAL u64 gc_depth;
extern GLOBAL bool gc_running;
static void gc_disable() { gc_depth++; }
static void gc_enable() { gc_depth--; }