mirror of
https://github.com/CPunch/Cosmo.git
synced 2024-11-21 15:00:06 +00:00
don't freezeGC during GC cycle
This commit is contained in:
parent
6a47c82179
commit
d30bcace9a
@ -302,8 +302,6 @@ COSMO_API void cosmoM_collectGarbage(CState *state)
|
|||||||
printf("-- GC start\n");
|
printf("-- GC start\n");
|
||||||
size_t start = state->allocatedBytes;
|
size_t start = state->allocatedBytes;
|
||||||
#endif
|
#endif
|
||||||
cosmoM_freezeGC(state); // we don't want a recursive garbage collection event!
|
|
||||||
|
|
||||||
markRoots(state);
|
markRoots(state);
|
||||||
|
|
||||||
tableRemoveWhite(
|
tableRemoveWhite(
|
||||||
@ -314,9 +312,6 @@ COSMO_API void cosmoM_collectGarbage(CState *state)
|
|||||||
|
|
||||||
// set our next GC event
|
// set our next GC event
|
||||||
cosmoM_updateThreshhold(state);
|
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
|
#ifdef GC_DEBUG
|
||||||
printf("-- GC end, reclaimed %ld bytes (started at %ld, ended at %ld), next garbage collection "
|
printf("-- GC end, reclaimed %ld bytes (started at %ld, ended at %ld), next garbage collection "
|
||||||
"scheduled at %ld bytes\n",
|
"scheduled at %ld bytes\n",
|
||||||
|
@ -321,8 +321,7 @@ CObjString *cosmoO_allocateString(CState *state, const char *str, size_t sz, uin
|
|||||||
strObj->length = sz;
|
strObj->length = sz;
|
||||||
strObj->hash = hash;
|
strObj->hash = hash;
|
||||||
|
|
||||||
// we push & pop the string so our GC can find it (we don't use freezeGC/unfreezeGC because we
|
// push/pop to make sure GC doesn't collect it
|
||||||
// *want* a GC event to happen)
|
|
||||||
cosmoV_pushRef(state, (CObj *)strObj);
|
cosmoV_pushRef(state, (CObj *)strObj);
|
||||||
cosmoT_insert(state, &state->strings, cosmoV_newRef((CObj *)strObj));
|
cosmoT_insert(state, &state->strings, cosmoV_newRef((CObj *)strObj));
|
||||||
cosmoV_pop(state);
|
cosmoV_pop(state);
|
||||||
|
Loading…
Reference in New Issue
Block a user