X-Git-Url: https://git.mxchange.org/?a=blobdiff_plain;f=simgear%2Fnasal%2Fgc.c;h=e9d9b7b8ba60587f9618eca6e25fab55a3a8a5f5;hb=85e58b4a49d3c3b74afed3c766b47b65a6a95a66;hp=f3853c96efbe219cb0c8c355802b7a100c869971;hpb=b05e32fa8c11e6d66bb70850751e170dc472a1a3;p=simgear.git diff --git a/simgear/nasal/gc.c b/simgear/nasal/gc.c index f3853c96..e9d9b7b8 100644 --- a/simgear/nasal/gc.c +++ b/simgear/nasal/gc.c @@ -88,6 +88,11 @@ void naModUnlock() { LOCK(); globals->nThreads--; + // We might be the "last" thread needed for collection. Since + // we're releasing our modlock to do something else for a while, + // wake someone else up to do it. + if(globals->waitCount == globals->nThreads) + naSemUp(globals->sem, 1); UNLOCK(); } @@ -120,12 +125,7 @@ void naCheckBottleneck() static void naCode_gcclean(struct naCode* o) { - naFree(o->byteCode); o->byteCode = 0; naFree(o->constants); o->constants = 0; - naFree(o->argSyms); o->argSyms = 0; - naFree(o->optArgSyms); o->optArgSyms = 0; - naFree(o->optArgVals); o->optArgVals = 0; - naFree(o->lineIps); o->lineIps = 0; } static void naGhost_gcclean(struct naGhost* g) @@ -140,7 +140,7 @@ static void freeelem(struct naPool* p, struct naObj* o) switch(p->type) { case T_STR: naStr_gcclean ((struct naStr*) o); break; case T_VEC: naVec_gcclean ((struct naVec*) o); break; - case T_HASH: naHash_gcclean ((struct naHash*) o); break; + case T_HASH: naiGCHashClean ((struct naHash*) o); break; case T_CODE: naCode_gcclean ((struct naCode*) o); break; case T_GHOST: naGhost_gcclean((struct naGhost*)o); break; } @@ -220,21 +220,6 @@ static void markvec(naRef r) mark(vr->array[i]); } -static void markhash(naRef r) -{ - int i; - struct HashRec* hr = PTR(r).hash->rec; - if(!hr) return; - for(i=0; i < (1<lgalloced); i++) { - struct HashNode* hn = hr->table[i]; - while(hn) { - mark(hn->key); - mark(hn->val); - hn = hn->next; - } - } -} - // Sets the reference bit on the object, and recursively on all // objects reachable from it. Uses the processor stack for recursion... static void mark(naRef r) @@ -250,7 +235,7 @@ static void mark(naRef r) PTR(r).obj->mark = 1; switch(PTR(r).obj->type) { case T_VEC: markvec(r); break; - case T_HASH: markhash(r); break; + case T_HASH: naiGCMarkHash(r); break; case T_CODE: mark(PTR(r).code->srcFile); for(i=0; inConstants; i++) @@ -264,6 +249,11 @@ static void mark(naRef r) } } +void naiGCMark(naRef r) +{ + mark(r); +} + // Collects all the unreachable objects into a free list, and // allocates more space if needed. static void reap(struct naPool* p)