more odd core count bugs
[IRC.git] / Robust / src / Runtime / bamboo / pmc_forward.c
index 14788db45ba6434b7bf8175637dd491b294f5183..c60d7ce5c4060770d4893c89559eaaaedf316910 100644 (file)
@@ -21,6 +21,8 @@ void pmc_count() {
 void pmc_countbytes(struct pmc_unit * unit, void *bottomptr, void *topptr) {
   void *tmpptr=bottomptr;
   unsigned int totalbytes=0;
+  void * lastunmarked=NULL;
+  bool padokay=false;
   while(tmpptr<topptr) {
     unsigned int type;
     unsigned int size;
@@ -31,8 +33,18 @@ void pmc_countbytes(struct pmc_unit * unit, void *bottomptr, void *topptr) {
       continue;
     }
     size=((size-1)&(~(ALIGNMENTSIZE-1)))+ALIGNMENTSIZE;
-    if (((struct ___Object___ *)tmpptr)->marked)
+    if (((struct ___Object___ *)tmpptr)->marked) {
+      if (lastunmarked!=NULL) {
+       if (padokay)
+         padspace(lastunmarked, (unsigned INTPTR) (tmpptr-lastunmarked));
+       padokay=false;
+       lastunmarked=NULL;
+      }
       totalbytes+=size;
+    } else if (lastunmarked!=NULL)
+      lastunmarked=tmpptr;
+    else
+      padokay=true;
     tmpptr+=size;
   }
   unit->numbytes=totalbytes;
@@ -74,8 +86,10 @@ void pmc_processunits() {
   for(;regionnum<NUMCORES4GC;regionnum++) {
     pmc_heapptr->regions[regionnum].highunit=NUMPMCUNITS;
     pmc_heapptr->regions[regionnum].endptr=pmc_heapptr->units[NUMPMCUNITS-1].endptr;
-    pmc_heapptr->regions[regionnum+1].startptr=pmc_heapptr->units[NUMPMCUNITS-1].endptr;
-    pmc_heapptr->regions[regionnum+1].lowunit=NUMPMCUNITS;
+    if ((regionnum+1)<NUMCORES4GC) {
+      pmc_heapptr->regions[regionnum+1].startptr=pmc_heapptr->units[NUMPMCUNITS-1].endptr;
+      pmc_heapptr->regions[regionnum+1].lowunit=NUMPMCUNITS;
+    }
   }
 }