split garbage collector into three files...
authorbdemsky <bdemsky>
Fri, 15 Apr 2011 23:20:10 +0000 (23:20 +0000)
committerbdemsky <bdemsky>
Fri, 15 Apr 2011 23:20:10 +0000 (23:20 +0000)
Robust/src/Runtime/garbage.c
Robust/src/Runtime/garbage.h
Robust/src/Runtime/jni/jni-stuff.c
Robust/src/Runtime/oojgarbage.c [new file with mode: 0644]
Robust/src/Runtime/taskgarbage.c [new file with mode: 0644]
Robust/src/Runtime/thread.c
Robust/src/Tests/dotest
Robust/src/buildscript

index 0a267c0888ea9d6ade0b832eecd279610cf7b126..3b995eae1a3d072ebbf85c85710cd0fe354fc862 100644 (file)
@@ -37,7 +37,6 @@ extern deque* deques;
 #include "delaycomp.h"
 #endif
 
-
 #define NUMPTRS 100
 
 #ifndef INITIALHEAPSIZE_MB
@@ -75,10 +74,6 @@ __thread struct listitem litem;
 #endif
 #endif
 
-#ifdef MLP
-__thread SESEcommon* seseCommon;
-#endif
-
 //Need to check if pointers are transaction pointers
 //this also catches the special flag value of 1 for local copies
 #ifdef DSTM
@@ -305,20 +300,6 @@ int moreItems() {
   return 1;
 }
 
-#ifdef TASK
-struct pointerblock *taghead=NULL;
-int tagindex=0;
-
-void enqueuetag(struct ___TagDescriptor___ *ptr) {
-  if (tagindex==NUMPTRS) {
-    struct pointerblock * tmp=malloc(sizeof(struct pointerblock));
-    tmp->next=taghead;
-    taghead=tmp;
-    tagindex=0;
-  }
-  taghead->ptrs[tagindex++]=ptr;
-}
-#endif
 
 #if defined(STM)||defined(THREADS)||defined(MLP)
 #ifndef MAC
@@ -384,128 +365,6 @@ void doinitstuff() {
 #endif
 }
 
-void searchoojroots() {
-#ifdef MLP
-#ifdef SQUEUE
-  {
-    int        i;
-    deque*     dq;
-    dequeItem *di;
-    int        j;
-
-    // goes over ready-to-run SESEs
-    for( i = 0; i < numWorkSchedWorkers; ++i ) {
-      dq = &(deques[i]);
-
-      di=dq->head;
-
-      do {
-        // check all the relevant indices of this
-        // node in the deque, noting if we are in
-        // the top/bottom node which can be partially
-        // full
-
-          // WHAT? 
-          //SESEcommon* common = (SESEcommon*) n->itsDataArr[j];
-          //if(common==seseCommon){
-          // skip the current running SESE
-          //  continue;
-          //}
-       di=(dequeItem *) EXTRACTPTR((INTPTR)di);
-       SESEcommon* seseRec = (SESEcommon*) di->work;
-       if (seseRec!=NULL) {
-          struct garbagelist* gl     = (struct garbagelist*) &(seseRec[1]);
-          struct garbagelist* glroot = gl;
-         
-          updateAscendantSESE( seseRec );
-         
-          while( gl != NULL ) {
-            int k;
-            for( k = 0; k < gl->size; k++ ) {
-              void* orig = gl->array[k];
-              ENQUEUE( orig, gl->array[k] );
-            }
-            gl = gl->next;
-          } 
-        }
-        // we only have to move across the nodes
-        // of the deque if the top and bottom are
-        // not the same already
-         di=di->next;
-      } while( di !=NULL) ;
-    }
-  }    
-#else
-  {
-    int        i;
-    deque*     dq;
-    dequeNode* botNode;
-    int        botIndx;
-    dequeNode* topNode;
-    int        topIndx;
-    dequeNode* n;
-    int        j;
-    int        jLo;
-    int        jHi;
-    
-    // goes over ready-to-run SESEs
-    for( i = 0; i < numWorkSchedWorkers; ++i ) {
-      dq = &(deques[i]);
-      
-      botNode = dqDecodePtr( dq->bottom );
-      botIndx = dqDecodeIdx( dq->bottom );
-      
-      topNode = dqDecodePtr( dq->top );
-      topIndx = dqDecodeIdx( dq->top );
-      
-      
-      n = botNode;
-      do {
-       // check all the relevant indices of this
-       // node in the deque, noting if we are in
-       // the top/bottom node which can be partially
-       // full
-       if( n == botNode ) { jLo = botIndx; } else { jLo = 0; }
-       if( n == topNode ) { jHi = topIndx; } else { jHi = DQNODE_ARRAYSIZE; }
-       
-       for( j = jLo; j < jHi; ++j ) {
-         
-         // WHAT?
-         //SESEcommon* common = (SESEcommon*) n->itsDataArr[j];
-         //if(common==seseCommon){
-         //  continue;
-         //}
-         
-          SESEcommon* seseRec = (SESEcommon*) n->itsDataArr[j];
-         
-         struct garbagelist* gl     = (struct garbagelist*) &(seseRec[1]);
-          struct garbagelist* glroot = gl;
-         
-          updateAscendantSESE( seseRec );
-         
-          while( gl != NULL ) {
-            int k;
-            for( k = 0; k < gl->size; k++ ) {
-              void* orig = gl->array[k];
-              ENQUEUE( orig, gl->array[k] );
-           }
-           gl = gl->next;
-         }
-       }
-       
-       // we only have to move across the nodes
-       // of the deque if the top and bottom are
-       // not the same already
-        if( botNode != topNode ) {
-          n = n->next;
-        }
-      } while( n != topNode );
-    }
-  }
-#endif
-#endif
-}
-
 void searchglobalroots() {
 #if defined(THREADS)||defined(DSTM)||defined(STM)||defined(MLP)
   {
@@ -520,100 +379,7 @@ void searchglobalroots() {
 }
 
 
-void searchtaskroots() {
-#ifdef TASK
-  {
-    /* Update objectsets */
-    int i;
-    for(i=0; i<NUMCLASSES; i++) {
-#if !defined(MULTICORE)
-      struct parameterwrapper * p=objectqueues[i];
-      while(p!=NULL) {
-       struct ObjectHash * set=p->objectset;
-       struct ObjectNode * ptr=set->listhead;
-       while(ptr!=NULL) {
-         void *orig=(void *)ptr->key;
-         ENQUEUE(orig, *((void **)(&ptr->key)));
-         ptr=ptr->lnext;
-       }
-       ObjectHashrehash(set); /* Rehash the table */
-       p=p->next;
-      }
-#endif
-    }
-  }
-
-#ifndef FASTCHECK
-  if (forward!=NULL) {
-    struct cnode * ptr=forward->listhead;
-    while(ptr!=NULL) {
-      void * orig=(void *)ptr->key;
-      ENQUEUE(orig, *((void **)(&ptr->key)));
-      ptr=ptr->lnext;
-    }
-    crehash(forward); /* Rehash the table */
-  }
-
-  if (reverse!=NULL) {
-    struct cnode * ptr=reverse->listhead;
-    while(ptr!=NULL) {
-      void *orig=(void *)ptr->val;
-      ENQUEUE(orig, *((void**)(&ptr->val)));
-      ptr=ptr->lnext;
-    }
-  }
-#endif
-
-  {
-    struct RuntimeNode * ptr=fdtoobject->listhead;
-    while(ptr!=NULL) {
-      void *orig=(void *)ptr->data;
-      ENQUEUE(orig, *((void**)(&ptr->data)));
-      ptr=ptr->lnext;
-    }
-  }
 
-  {
-    /* Update current task descriptor */
-    int i;
-    for(i=0; i<currtpd->numParameters; i++) {
-      void *orig=currtpd->parameterArray[i];
-      ENQUEUE(orig, currtpd->parameterArray[i]);
-    }
-
-  }
-
-  /* Update active tasks */
-  {
-    struct genpointerlist * ptr=activetasks->list;
-    while(ptr!=NULL) {
-      struct taskparamdescriptor *tpd=ptr->src;
-      int i;
-      for(i=0; i<tpd->numParameters; i++) {
-       void * orig=tpd->parameterArray[i];
-       ENQUEUE(orig, tpd->parameterArray[i]);
-      }
-      ptr=ptr->inext;
-    }
-    genrehash(activetasks);
-  }
-
-  /* Update failed tasks */
-  {
-    struct genpointerlist * ptr=failedtasks->list;
-    while(ptr!=NULL) {
-      struct taskparamdescriptor *tpd=ptr->src;
-      int i;
-      for(i=0; i<tpd->numParameters; i++) {
-       void * orig=tpd->parameterArray[i];
-       ENQUEUE(orig, tpd->parameterArray[i]);
-      }
-      ptr=ptr->inext;
-    }
-    genrehash(failedtasks);
-  }
-#endif
-}
 
 void searchstack(struct garbagelist *stackptr) {
   while(stackptr!=NULL) {
@@ -626,6 +392,20 @@ void searchstack(struct garbagelist *stackptr) {
   }
 }
 
+#ifdef JNI
+void searchjnitable(struct jnireferences *jniptr) {
+  while(jniptr!=NULL) {
+    int i;
+    //update table
+    for(i=0;i<jniptr->index;i++) {
+      ENQUEUE(jniptr->array[i]->ref, jniptr->array[i]->ref);
+    }
+    //go to next table
+    jniptr=jniptr->next;
+  } 
+}
+#endif
+
 
 #if defined(THREADS)||defined(DSTM)||defined(STM)||defined(MLP)
 void searchthreadroots(struct garbagelist * stackptr) {
@@ -648,6 +428,9 @@ void searchthreadroots(struct garbagelist * stackptr) {
       ENQUEUE(orig, lvector->locks[i].object);
     }
 #endif
+#ifdef JNI
+    searchjnitable(*listptr->jnirefs);
+#endif
 #ifdef STM
     if ((*listptr->tc_table)!=NULL) {
       fixtable(listptr->tc_table, listptr->tc_list, listptr->tc_structs, listptr->tc_size);
@@ -684,8 +467,12 @@ void searchroots(struct garbagelist * stackptr) {
   ENQUEUE(___fcrevert___, ___fcrevert___);
 #endif
   searchglobalroots();
+#ifdef TASK
   searchtaskroots();
+#endif
+#ifdef MLP
   searchoojroots();
+#endif
 }
 
 
@@ -768,65 +555,6 @@ void collect(struct garbagelist * stackptr) {
 #endif
 }
 
-#ifdef TASK
-/* Fix up the references from tags.  This can't be done earlier,
-   because we don't want tags to keep objects alive */
-void fixtags() {
-  while(taghead!=NULL) {
-    int i;
-    struct pointerblock *tmp=taghead->next;
-    for(i=0; i<tagindex; i++) {
-      struct ___TagDescriptor___ *tagd=taghead->ptrs[i];
-      struct ___Object___ *obj=tagd->flagptr;
-      struct ___TagDescriptor___ *copy=((struct ___TagDescriptor___**)tagd)[1];
-      if (obj==NULL) {
-       /* Zero object case */
-      } else if (obj->type==-1) {
-       /* Single object case */
-       copy->flagptr=((struct ___Object___**)obj)[1];
-      } else if (obj->type==OBJECTARRAYTYPE) {
-       /* Array case */
-       struct ArrayObject *ao=(struct ArrayObject *) obj;
-       int livecount=0;
-       int j;
-       int k=0;
-       struct ArrayObject *aonew;
-
-       /* Count live objects */
-       for(j=0; j<ao->___cachedCode___; j++) {
-         struct ___Object___ * tobj=ARRAYGET(ao, struct ___Object___ *, j);
-         if (tobj->type==-1)
-           livecount++;
-       }
-
-       livecount=((livecount-1)/OBJECTARRAYINTERVAL+1)*OBJECTARRAYINTERVAL;
-       aonew=(struct ArrayObject *) tomalloc(sizeof(struct ArrayObject)+sizeof(struct ___Object___*)*livecount);
-       memcpy(aonew, ao, sizeof(struct ArrayObject));
-       aonew->type=OBJECTARRAYTYPE;
-       aonew->___length___=livecount;
-       copy->flagptr=aonew;
-       for(j=0; j<ao->___cachedCode___; j++) {
-         struct ___Object___ * tobj=ARRAYGET(ao, struct ___Object___ *, j);
-         if (tobj->type==-1) {
-           struct ___Object___ * tobjcpy=((struct ___Object___**)tobj)[1];
-           ARRAYSET(aonew, struct ___Object___*, k++,tobjcpy);
-         }
-       }
-       aonew->___cachedCode___=k;
-       for(; k<livecount; k++) {
-         ARRAYSET(aonew, struct ___Object___*, k, NULL);
-       }
-      } else {
-       /* No object live anymore */
-       copy->flagptr=NULL;
-      }
-    }
-    free(taghead);
-    taghead=tmp;
-    tagindex=NUMPTRS;
-  }
-}
-#endif
 
 void * tomalloc(int size) {
   void * ptr=to_heapptr;
@@ -1124,147 +852,6 @@ int gc_createcopy(void * orig, void ** copy_ptr) {
   }
 }
 
-#ifdef MLP
-updateForwardList(struct Queue *forwardList, int prevUpdate){
-
-  struct QueueItem * fqItem=getHead(forwardList);
-  while(fqItem!=NULL){
-    SESEcommon* seseRec = (SESEcommon*)(fqItem->objectptr);
-    struct garbagelist * gl=(struct garbagelist *)&(seseRec[1]);
-    if(prevUpdate==TRUE){
-      updateAscendantSESE(seseRec);    
-    }
-    // do something here
-    while(gl!=NULL) {
-      int i;
-      for(i=0; i<gl->size; i++) {
-        void * orig=gl->array[i];
-        ENQUEUE(orig, gl->array[i]);
-      }
-      gl=gl->next;
-    }    
-    // iterate forwarding list of seseRec
-    struct Queue* fList=&seseRec->forwardList;
-    updateForwardList(fList,prevUpdate);   
-    fqItem=getNextQueueItem(fqItem);
-  }   
-
-}
-
-updateMemoryQueue(SESEcommon* seseParent){
-  // update memory queue
-  int i,binidx;
-  for(i=0; i<seseParent->numMemoryQueue; i++){
-    MemoryQueue *memoryQueue=seseParent->memoryQueueArray[i];
-    MemoryQueueItem *memoryItem=memoryQueue->head;
-    while(memoryItem!=NULL){
-      if(memoryItem->type==HASHTABLE){
-       Hashtable *ht=(Hashtable*)memoryItem;
-       for(binidx=0; binidx<NUMBINS; binidx++){
-         BinElement *bin=ht->array[binidx];
-         BinItem *binItem=bin->head;
-         while(binItem!=NULL){
-           if(binItem->type==READBIN){
-             ReadBinItem* readBinItem=(ReadBinItem*)binItem;
-             int ridx;
-             for(ridx=0; ridx<readBinItem->index; ridx++){
-               REntry *rentry=readBinItem->array[ridx];
-                SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec);
-               struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]);
-               updateAscendantSESE(seseRec);
-               while(gl!=NULL) {
-                 int i;
-                 for(i=0; i<gl->size; i++) {
-                   void * orig=gl->array[i];
-                   ENQUEUE(orig, gl->array[i]);
-                 }
-                 gl=gl->next;
-               } 
-             } 
-           }else{ //writebin
-             REntry *rentry=((WriteBinItem*)binItem)->val;
-              SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec);
-              struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]);
-             updateAscendantSESE(seseRec);
-             while(gl!=NULL) {
-               int i;
-               for(i=0; i<gl->size; i++) {
-                 void * orig=gl->array[i];
-                 ENQUEUE(orig, gl->array[i]);
-               }
-               gl=gl->next;
-             } 
-           }
-           binItem=binItem->next;
-         }
-       }
-      }else if(memoryItem->type==VECTOR){
-       Vector *vt=(Vector*)memoryItem;
-       int idx;
-       for(idx=0; idx<vt->index; idx++){
-         REntry *rentry=vt->array[idx];
-         if(rentry!=NULL){
-            SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec);
-           struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]);
-           updateAscendantSESE(seseRec);
-           while(gl!=NULL) {
-             int i;
-             for(i=0; i<gl->size; i++) {
-               void * orig=gl->array[i];
-               ENQUEUE(orig, gl->array[i]);
-             }
-             gl=gl->next;
-           } 
-         }
-       }
-      }else if(memoryItem->type==SINGLEITEM){
-       SCC *scc=(SCC*)memoryItem;
-       REntry *rentry=scc->val;
-       if(rentry!=NULL){
-          SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec);
-         struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]);
-         updateAscendantSESE(seseRec);
-         while(gl!=NULL) {
-           int i;
-           for(i=0; i<gl->size; i++) {
-             void * orig=gl->array[i];
-             ENQUEUE(orig, gl->array[i]);
-           }
-           gl=gl->next;
-         } 
-       }
-      }
-      memoryItem=memoryItem->next;
-    }
-  }     
- }
- updateAscendantSESE(SESEcommon* seseRec){   
-  int prevIdx;
-  for(prevIdx=0; prevIdx<(seseRec->numDependentSESErecords); prevIdx++){
-    SESEcommon* prevSESE = (SESEcommon*) 
-      (
-       ((INTPTR)seseRec) + 
-       seseRec->offsetToDepSESErecords +
-       (sizeof(INTPTR)*prevIdx)
-      );
-       
-    if(prevSESE!=NULL){
-      struct garbagelist * prevgl=(struct garbagelist *)&(((SESEcommon*)(prevSESE))[1]);
-      while(prevgl!=NULL) {
-       int i;
-       for(i=0; i<prevgl->size; i++) {
-         void * orig=prevgl->array[i];
-         ENQUEUE(orig, prevgl->array[i]);
-       }
-       prevgl=prevgl->next;
-      } 
-    }
-  }
-  
- }
-#endif
-
 int within(void *ptr){ //debug function
   if(ptr>curr_heapptr || ptr<curr_heapbase){
     __asm__ __volatile__ ("int $3");  // breakpoint
index c504c65a43867f9b1d2dcfaab7c7f70e20e208d3..3a286e50e3b7dd1277d8027556de178d8ddbb31d 100644 (file)
@@ -3,6 +3,9 @@
 #ifdef STM
 #include "stmlookup.h"
 #endif
+#ifdef JNI
+#include "jni-private.h"
+#endif
 
 struct garbagelist {  
   int size;
index f016b9e7a23ab48b415da30af298f4ef8c2673ad..1c991712d47f6737a0f849bb84c020427f9a02a0 100644 (file)
@@ -2,6 +2,8 @@
 #include<jni-private.h>
 
 #ifndef MAC
+__thread struct jnireferences * jnirefs;
+
 struct _jobject * getwrapped(void * objptr) {
   if ((jnirefs->index)>=MAXJNIREFS)
     printf("OVERFLOW IN JOBJECT\n");
diff --git a/Robust/src/Runtime/oojgarbage.c b/Robust/src/Runtime/oojgarbage.c
new file mode 100644 (file)
index 0000000..8a14558
--- /dev/null
@@ -0,0 +1,262 @@
+#include "garbage.h"
+
+#ifdef MLP
+__thread SESEcommon* seseCommon;
+
+void searchoojroots() {
+#ifdef SQUEUE
+  {
+    int        i;
+    deque*     dq;
+    dequeItem *di;
+    int        j;
+
+    // goes over ready-to-run SESEs
+    for( i = 0; i < numWorkSchedWorkers; ++i ) {
+      dq = &(deques[i]);
+
+      di=dq->head;
+
+      do {
+        // check all the relevant indices of this
+        // node in the deque, noting if we are in
+        // the top/bottom node which can be partially
+        // full
+
+          // WHAT? 
+          //SESEcommon* common = (SESEcommon*) n->itsDataArr[j];
+          //if(common==seseCommon){
+          // skip the current running SESE
+          //  continue;
+          //}
+       di=(dequeItem *) EXTRACTPTR((INTPTR)di);
+       SESEcommon* seseRec = (SESEcommon*) di->work;
+       if (seseRec!=NULL) {
+          struct garbagelist* gl     = (struct garbagelist*) &(seseRec[1]);
+          struct garbagelist* glroot = gl;
+         
+          updateAscendantSESE( seseRec );
+         
+          while( gl != NULL ) {
+            int k;
+            for( k = 0; k < gl->size; k++ ) {
+              void* orig = gl->array[k];
+              ENQUEUE( orig, gl->array[k] );
+            }
+            gl = gl->next;
+          } 
+        }
+        // we only have to move across the nodes
+        // of the deque if the top and bottom are
+        // not the same already
+         di=di->next;
+      } while( di !=NULL) ;
+    }
+  }    
+#else
+  {
+    int        i;
+    deque*     dq;
+    dequeNode* botNode;
+    int        botIndx;
+    dequeNode* topNode;
+    int        topIndx;
+    dequeNode* n;
+    int        j;
+    int        jLo;
+    int        jHi;
+    
+    // goes over ready-to-run SESEs
+    for( i = 0; i < numWorkSchedWorkers; ++i ) {
+      dq = &(deques[i]);
+      
+      botNode = dqDecodePtr( dq->bottom );
+      botIndx = dqDecodeIdx( dq->bottom );
+      
+      topNode = dqDecodePtr( dq->top );
+      topIndx = dqDecodeIdx( dq->top );
+      
+      
+      n = botNode;
+      do {
+       // check all the relevant indices of this
+       // node in the deque, noting if we are in
+       // the top/bottom node which can be partially
+       // full
+       if( n == botNode ) { jLo = botIndx; } else { jLo = 0; }
+       if( n == topNode ) { jHi = topIndx; } else { jHi = DQNODE_ARRAYSIZE; }
+       
+       for( j = jLo; j < jHi; ++j ) {
+         
+         // WHAT?
+         //SESEcommon* common = (SESEcommon*) n->itsDataArr[j];
+         //if(common==seseCommon){
+         //  continue;
+         //}
+         
+          SESEcommon* seseRec = (SESEcommon*) n->itsDataArr[j];
+         
+         struct garbagelist* gl     = (struct garbagelist*) &(seseRec[1]);
+          struct garbagelist* glroot = gl;
+         
+          updateAscendantSESE( seseRec );
+         
+          while( gl != NULL ) {
+            int k;
+            for( k = 0; k < gl->size; k++ ) {
+              void* orig = gl->array[k];
+              ENQUEUE( orig, gl->array[k] );
+           }
+           gl = gl->next;
+         }
+       }
+       
+       // we only have to move across the nodes
+       // of the deque if the top and bottom are
+       // not the same already
+        if( botNode != topNode ) {
+          n = n->next;
+        }
+      } while( n != topNode );
+    }
+  }
+#endif
+}
+
+updateForwardList(struct Queue *forwardList, int prevUpdate) {
+  struct QueueItem * fqItem=getHead(forwardList);
+  while(fqItem!=NULL){
+    SESEcommon* seseRec = (SESEcommon*)(fqItem->objectptr);
+    struct garbagelist * gl=(struct garbagelist *)&(seseRec[1]);
+    if(prevUpdate==TRUE){
+      updateAscendantSESE(seseRec);    
+    }
+    // do something here
+    while(gl!=NULL) {
+      int i;
+      for(i=0; i<gl->size; i++) {
+        void * orig=gl->array[i];
+        ENQUEUE(orig, gl->array[i]);
+      }
+      gl=gl->next;
+    }    
+    // iterate forwarding list of seseRec
+    struct Queue* fList=&seseRec->forwardList;
+    updateForwardList(fList,prevUpdate);   
+    fqItem=getNextQueueItem(fqItem);
+  }   
+
+}
+
+updateMemoryQueue(SESEcommon* seseParent){
+  // update memory queue
+  int i,binidx;
+  for(i=0; i<seseParent->numMemoryQueue; i++){
+    MemoryQueue *memoryQueue=seseParent->memoryQueueArray[i];
+    MemoryQueueItem *memoryItem=memoryQueue->head;
+    while(memoryItem!=NULL){
+      if(memoryItem->type==HASHTABLE){
+       Hashtable *ht=(Hashtable*)memoryItem;
+       for(binidx=0; binidx<NUMBINS; binidx++){
+         BinElement *bin=ht->array[binidx];
+         BinItem *binItem=bin->head;
+         while(binItem!=NULL){
+           if(binItem->type==READBIN){
+             ReadBinItem* readBinItem=(ReadBinItem*)binItem;
+             int ridx;
+             for(ridx=0; ridx<readBinItem->index; ridx++){
+               REntry *rentry=readBinItem->array[ridx];
+                SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec);
+               struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]);
+               updateAscendantSESE(seseRec);
+               while(gl!=NULL) {
+                 int i;
+                 for(i=0; i<gl->size; i++) {
+                   void * orig=gl->array[i];
+                   ENQUEUE(orig, gl->array[i]);
+                 }
+                 gl=gl->next;
+               } 
+             } 
+           }else{ //writebin
+             REntry *rentry=((WriteBinItem*)binItem)->val;
+              SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec);
+              struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]);
+             updateAscendantSESE(seseRec);
+             while(gl!=NULL) {
+               int i;
+               for(i=0; i<gl->size; i++) {
+                 void * orig=gl->array[i];
+                 ENQUEUE(orig, gl->array[i]);
+               }
+               gl=gl->next;
+             } 
+           }
+           binItem=binItem->next;
+         }
+       }
+      }else if(memoryItem->type==VECTOR){
+       Vector *vt=(Vector*)memoryItem;
+       int idx;
+       for(idx=0; idx<vt->index; idx++){
+         REntry *rentry=vt->array[idx];
+         if(rentry!=NULL){
+            SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec);
+           struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]);
+           updateAscendantSESE(seseRec);
+           while(gl!=NULL) {
+             int i;
+             for(i=0; i<gl->size; i++) {
+               void * orig=gl->array[i];
+               ENQUEUE(orig, gl->array[i]);
+             }
+             gl=gl->next;
+           } 
+         }
+       }
+      }else if(memoryItem->type==SINGLEITEM){
+       SCC *scc=(SCC*)memoryItem;
+       REntry *rentry=scc->val;
+       if(rentry!=NULL){
+          SESEcommon* seseRec = (SESEcommon*)(rentry->seseRec);
+         struct garbagelist * gl= (struct garbagelist *)&(seseRec[1]);
+         updateAscendantSESE(seseRec);
+         while(gl!=NULL) {
+           int i;
+           for(i=0; i<gl->size; i++) {
+             void * orig=gl->array[i];
+             ENQUEUE(orig, gl->array[i]);
+           }
+           gl=gl->next;
+         } 
+       }
+      }
+      memoryItem=memoryItem->next;
+    }
+  }     
+ }
+ updateAscendantSESE(SESEcommon* seseRec){   
+  int prevIdx;
+  for(prevIdx=0; prevIdx<(seseRec->numDependentSESErecords); prevIdx++){
+    SESEcommon* prevSESE = (SESEcommon*) 
+      (
+       ((INTPTR)seseRec) + 
+       seseRec->offsetToDepSESErecords +
+       (sizeof(INTPTR)*prevIdx)
+      );
+       
+    if(prevSESE!=NULL){
+      struct garbagelist * prevgl=(struct garbagelist *)&(((SESEcommon*)(prevSESE))[1]);
+      while(prevgl!=NULL) {
+       int i;
+       for(i=0; i<prevgl->size; i++) {
+         void * orig=prevgl->array[i];
+         ENQUEUE(orig, prevgl->array[i]);
+       }
+       prevgl=prevgl->next;
+      } 
+    }
+  }
+ }
+#endif
diff --git a/Robust/src/Runtime/taskgarbage.c b/Robust/src/Runtime/taskgarbage.c
new file mode 100644 (file)
index 0000000..e2f08c4
--- /dev/null
@@ -0,0 +1,166 @@
+#include "garbage.h"
+#ifdef TASK
+void searchtaskroots() {
+  {
+    /* Update objectsets */
+    int i;
+    for(i=0; i<NUMCLASSES; i++) {
+#if !defined(MULTICORE)
+      struct parameterwrapper * p=objectqueues[i];
+      while(p!=NULL) {
+       struct ObjectHash * set=p->objectset;
+       struct ObjectNode * ptr=set->listhead;
+       while(ptr!=NULL) {
+         void *orig=(void *)ptr->key;
+         ENQUEUE(orig, *((void **)(&ptr->key)));
+         ptr=ptr->lnext;
+       }
+       ObjectHashrehash(set); /* Rehash the table */
+       p=p->next;
+      }
+#endif
+    }
+  }
+
+#ifndef FASTCHECK
+  if (forward!=NULL) {
+    struct cnode * ptr=forward->listhead;
+    while(ptr!=NULL) {
+      void * orig=(void *)ptr->key;
+      ENQUEUE(orig, *((void **)(&ptr->key)));
+      ptr=ptr->lnext;
+    }
+    crehash(forward); /* Rehash the table */
+  }
+
+  if (reverse!=NULL) {
+    struct cnode * ptr=reverse->listhead;
+    while(ptr!=NULL) {
+      void *orig=(void *)ptr->val;
+      ENQUEUE(orig, *((void**)(&ptr->val)));
+      ptr=ptr->lnext;
+    }
+  }
+#endif
+
+  {
+    struct RuntimeNode * ptr=fdtoobject->listhead;
+    while(ptr!=NULL) {
+      void *orig=(void *)ptr->data;
+      ENQUEUE(orig, *((void**)(&ptr->data)));
+      ptr=ptr->lnext;
+    }
+  }
+
+  {
+    /* Update current task descriptor */
+    int i;
+    for(i=0; i<currtpd->numParameters; i++) {
+      void *orig=currtpd->parameterArray[i];
+      ENQUEUE(orig, currtpd->parameterArray[i]);
+    }
+
+  }
+
+  /* Update active tasks */
+  {
+    struct genpointerlist * ptr=activetasks->list;
+    while(ptr!=NULL) {
+      struct taskparamdescriptor *tpd=ptr->src;
+      int i;
+      for(i=0; i<tpd->numParameters; i++) {
+       void * orig=tpd->parameterArray[i];
+       ENQUEUE(orig, tpd->parameterArray[i]);
+      }
+      ptr=ptr->inext;
+    }
+    genrehash(activetasks);
+  }
+
+  /* Update failed tasks */
+  {
+    struct genpointerlist * ptr=failedtasks->list;
+    while(ptr!=NULL) {
+      struct taskparamdescriptor *tpd=ptr->src;
+      int i;
+      for(i=0; i<tpd->numParameters; i++) {
+       void * orig=tpd->parameterArray[i];
+       ENQUEUE(orig, tpd->parameterArray[i]);
+      }
+      ptr=ptr->inext;
+    }
+    genrehash(failedtasks);
+  }
+}
+
+struct pointerblock *taghead=NULL;
+int tagindex=0;
+
+void enqueuetag(struct ___TagDescriptor___ *ptr) {
+  if (tagindex==NUMPTRS) {
+    struct pointerblock * tmp=malloc(sizeof(struct pointerblock));
+    tmp->next=taghead;
+    taghead=tmp;
+    tagindex=0;
+  }
+  taghead->ptrs[tagindex++]=ptr;
+}
+
+/* Fix up the references from tags.  This can't be done earlier,
+   because we don't want tags to keep objects alive */
+void fixtags() {
+  while(taghead!=NULL) {
+    int i;
+    struct pointerblock *tmp=taghead->next;
+    for(i=0; i<tagindex; i++) {
+      struct ___TagDescriptor___ *tagd=taghead->ptrs[i];
+      struct ___Object___ *obj=tagd->flagptr;
+      struct ___TagDescriptor___ *copy=((struct ___TagDescriptor___**)tagd)[1];
+      if (obj==NULL) {
+       /* Zero object case */
+      } else if (obj->type==-1) {
+       /* Single object case */
+       copy->flagptr=((struct ___Object___**)obj)[1];
+      } else if (obj->type==OBJECTARRAYTYPE) {
+       /* Array case */
+       struct ArrayObject *ao=(struct ArrayObject *) obj;
+       int livecount=0;
+       int j;
+       int k=0;
+       struct ArrayObject *aonew;
+
+       /* Count live objects */
+       for(j=0; j<ao->___cachedCode___; j++) {
+         struct ___Object___ * tobj=ARRAYGET(ao, struct ___Object___ *, j);
+         if (tobj->type==-1)
+           livecount++;
+       }
+
+       livecount=((livecount-1)/OBJECTARRAYINTERVAL+1)*OBJECTARRAYINTERVAL;
+       aonew=(struct ArrayObject *) tomalloc(sizeof(struct ArrayObject)+sizeof(struct ___Object___*)*livecount);
+       memcpy(aonew, ao, sizeof(struct ArrayObject));
+       aonew->type=OBJECTARRAYTYPE;
+       aonew->___length___=livecount;
+       copy->flagptr=aonew;
+       for(j=0; j<ao->___cachedCode___; j++) {
+         struct ___Object___ * tobj=ARRAYGET(ao, struct ___Object___ *, j);
+         if (tobj->type==-1) {
+           struct ___Object___ * tobjcpy=((struct ___Object___**)tobj)[1];
+           ARRAYSET(aonew, struct ___Object___*, k++,tobjcpy);
+         }
+       }
+       aonew->___cachedCode___=k;
+       for(; k<livecount; k++) {
+         ARRAYSET(aonew, struct ___Object___*, k, NULL);
+       }
+      } else {
+       /* No object live anymore */
+       copy->flagptr=NULL;
+      }
+    }
+    free(taghead);
+    taghead=tmp;
+    tagindex=NUMPTRS;
+  }
+}
+#endif
index ef75f1c456e2f88b13324b288cc12fa792ed5ff9..f3b01829a1a2cb2cea96d839b2b57a5137e2061a 100644 (file)
@@ -286,6 +286,10 @@ void initializethreads() {
   litem.prev=NULL;
   litem.next=list;
   litem.lvector=&lvector;
+#ifdef JNI
+  litem.jnirefs=&jnirefs;
+  jnirefs=NULL;
+#endif
   lvector.index=0;
   if(list!=NULL)
     list->prev=&litem;
@@ -330,6 +334,10 @@ void initthread(struct ___Thread___ * ___this___) {
   pthread_setspecific(memorybasekey, &memorybase);
   pthread_setspecific(memorytopkey, &memorytop);
   pthread_setspecific(threadlocks, &lvector);
+#endif
+#ifdef JNI
+  litem.jnirefs=&jnirefs;
+  jnirefs=NULL;
 #endif
   litem.lvector=&lvector;
   lvector.index=0;
index 09a2c52a5fbd95548cc05f2e0da93f61951e722b..ffce5033f72c91c7c51a1fc7f8368967a6cdd2b7 100755 (executable)
@@ -7,7 +7,7 @@ shift
 dir=`pwd`
 
 echo Doing Test $ARG1
-../buildscript -64bit -debug -joptimize -robustroot ${dir}/../ -mainclass $ARG1 $ARG2 -o $ARG1
+../buildscript -mac -64bit -debug -joptimize -robustroot ${dir}/../ -mainclass $ARG1 $ARG2 -o $ARG1
 $ARG1.bin $@ &> output/$ARG1.output
 diff output/$ARG1.output output/$ARG1.output.goal
 rm $ARG1.bin
index b50930c4d87100a0a704f15d69b4b81c9b36e818..77d3fe71da11c50c1ed87e462baae855b1cc2f86 100755 (executable)
@@ -1242,6 +1242,7 @@ $ROBUSTROOT/Runtime/file.c $ROBUSTROOT/Runtime/Queue.c \
 $ROBUSTROOT/Runtime/SimpleHash.c $ROBUSTROOT/Runtime/option.c \
 $ROBUSTROOT/Runtime/ObjectHash.c \
 $ROBUSTROOT/Runtime/garbage.c $ROBUSTROOT/Runtime/socket.c \
+$ROBUSTROOT/Runtime/taskgarbage.c $ROBUSTROOT/Runtime/oojgarbage.c \
 $ROBUSTROOT/Runtime/math.c \
 $ROBUSTROOT/Runtime/GenericHashtable.c $ROBUSTROOT/Runtime/object.c"