From 37e4653d40bd1bea26496c9ebd9e6c3f71845f15 Mon Sep 17 00:00:00 2001 From: CPunch Date: Tue, 29 Aug 2023 23:32:25 -0500 Subject: [PATCH] don't freezeGC during GC cycle --- src/cmem.c | 5 ----- src/cobj.c | 3 +-- 2 files changed, 1 insertion(+), 7 deletions(-) diff --git a/src/cmem.c b/src/cmem.c index 71b8514..491fc96 100644 --- a/src/cmem.c +++ b/src/cmem.c @@ -302,8 +302,6 @@ COSMO_API void cosmoM_collectGarbage(CState *state) printf("-- GC start\n"); size_t start = state->allocatedBytes; #endif - cosmoM_freezeGC(state); // we don't want a recursive garbage collection event! - markRoots(state); tableRemoveWhite( @@ -314,9 +312,6 @@ COSMO_API void cosmoM_collectGarbage(CState *state) // set our next GC event cosmoM_updateThreshhold(state); - - state->freezeGC--; // we don't want to use cosmoM_unfreezeGC because that might trigger a GC - // event (if GC_STRESS is defined) #ifdef GC_DEBUG printf("-- GC end, reclaimed %ld bytes (started at %ld, ended at %ld), next garbage collection " "scheduled at %ld bytes\n", diff --git a/src/cobj.c b/src/cobj.c index 81bead8..8bfb72d 100644 --- a/src/cobj.c +++ b/src/cobj.c @@ -321,8 +321,7 @@ CObjString *cosmoO_allocateString(CState *state, const char *str, size_t sz, uin strObj->length = sz; strObj->hash = hash; - // we push & pop the string so our GC can find it (we don't use freezeGC/unfreezeGC because we - // *want* a GC event to happen) + // push/pop to make sure GC doesn't collect it cosmoV_pushRef(state, (CObj *)strObj); cosmoT_insert(state, &state->strings, cosmoV_newRef((CObj *)strObj)); cosmoV_pop(state);