]> git.mxchange.org Git - simgear.git/blobdiff - simgear/nasal/gc.c
Removal of PLIB/SG from SimGear
[simgear.git] / simgear / nasal / gc.c
index f3853c96efbe219cb0c8c355802b7a100c869971..e9d9b7b8ba60587f9618eca6e25fab55a3a8a5f5 100644 (file)
@@ -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<<hr->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; i<PTR(r).code->nConstants; 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)