Fix bug in pmc garbage collector
authorjzhou <jzhou>
Mon, 1 Aug 2011 22:42:02 +0000 (22:42 +0000)
committerjzhou <jzhou>
Mon, 1 Aug 2011 22:42:02 +0000 (22:42 +0000)
Robust/src/Runtime/bamboo/pmc_forward.c
Robust/src/Runtime/bamboo/pmc_garbage.c
Robust/src/Runtime/bamboo/pmc_mem.c

index c2c158afde0a5bc001c27b21800c970c6ef34bc3..975b799112eed83b5e73defd50313f402bcb1249 100644 (file)
@@ -128,7 +128,13 @@ void pmc_forward(struct pmc_region *region, unsigned int totalbytes, void *botto
   if (!lower) {
     //We're resetting the boundaries of units at the low address end of the region...
     //Be sure not to reset the boundary of our last unit...it is shared with another region
-
+    //Very bottom most unit defines boundary of region...we can't move that right now
+    while((endunit<region->startptr)&&(currunit<highbound)) {
+      pmc_heapptr->units[currunit].endptr=region->startptr;
+      //tprintf("Ch6: %u -> %x\n", currunit, endunit);
+      currunit++;
+      endunit=pmc_unitend(currunit);
+    }
     while(endunit<=region->lastptr&&(currunit<highbound)) {
       pmc_heapptr->units[currunit].endptr=endunit;
       //tprintf("Ch2: %u -> %x\n", currunit, endunit);
index 334005f9ff333d30afb7d90e054357bac86e1e95..caaff1aac5853ed95cfa9b018985cfd5594ad1e1 100644 (file)
@@ -145,12 +145,12 @@ void gc(struct garbagelist *gl) {
   //tprintf("done\n");
 
   //if (BAMBOO_NUM_OF_CORE==STARTUPCORE) {
-    //    for(int i=0;i<NUMCORES4GC;i+=2) {
-    //      void *startptr=pmc_heapptr->regions[i].lastptr;
-    //      void *finishptr=pmc_heapptr->regions[i+1].lastptr;
-    //      tprintf("Partition %u from %x to %x\n", i, startptr, finishptr);
-    //      tprintf("%x %x %x %x\n", pmc_heapptr->regions[i].startptr, pmc_heapptr->regions[i].endptr, pmc_heapptr->regions[i+1].startptr, pmc_heapptr->regions[i+1].endptr);
-    //    }
+  //      for(int i=0;i<NUMCORES4GC;i+=2) {
+  //        void *startptr=pmc_heapptr->regions[i].lastptr;
+  //        void *finishptr=pmc_heapptr->regions[i+1].lastptr;
+  //        tprintf("Partition %u from %x to %x\n", i, startptr, finishptr);
+  //        tprintf("%x %x %x %x\n", pmc_heapptr->regions[i].startptr, pmc_heapptr->regions[i].endptr, pmc_heapptr->regions[i+1].startptr, pmc_heapptr->regions[i+1].endptr);
+  //      }
   //  }
 
   gcflag=false;
@@ -182,8 +182,9 @@ void padspace(void *ptr, unsigned int length) {
 
 void gettype_size(void * ptr, unsigned int * ttype, unsigned int * tsize) {
   int type = ((int *)ptr)[0];
-  //  if (type>TOTALNUMCLASSANDARRAY) {
+  //  if ((type>TOTALNUMCLASSANDARRAY)||(type<0)) {
   //    tprintf("ptr=%x type=%u\n", ptr, type);
+  //    BAMBOO_EXIT();
   //  }
 
   if(type < NUMCLASSES) {
index ac25f6b52e7db242f68c01ec0d1193e41c908d30..fc8ba4d740474dc97169749ee2f874a2cbc90a98 100644 (file)
@@ -27,7 +27,7 @@ void * pmc_alloc(unsigned int * numbytesallocated, unsigned int minimumbytes) {
        
        //update unit end points
        for(unsigned int index=startindex;index<(endindex-1);index++) {
-         void *ptr=pmc_unitend(index);
+         void *ptr=(pmc_unitend(index)>pmc_heapptr->units[index].endptr)?(pmc_unitend(index)):(pmc_heapptr->units[index].endptr);
          if ((ptr>startptr)&&(ptr<=newstartptr)) {
            //tprintf("Ch: %u -> %x\n", index, newstartptr);
            pmc_heapptr->units[index].endptr=newstartptr;