[project @ 2005-05-12 10:03:42 by simonmar]
authorsimonmar <unknown>
Thu, 12 May 2005 10:03:42 +0000 (10:03 +0000)
committersimonmar <unknown>
Thu, 12 May 2005 10:03:42 +0000 (10:03 +0000)
Fix more bugginess in allocateLocal().

ghc/rts/Schedule.c
ghc/rts/Storage.c

index 95a5bce..04f5149 100644 (file)
@@ -1515,7 +1515,7 @@ scheduleHandleHeapOverflow( Capability *cap, StgTSO *t )
            
            // This assert can be a killer if the app is doing lots
            // of large block allocations.
-           ASSERT(countBlocks(cap->r.rNursery->blocks) == cap->r.rNursery->n_blocks);
+           IF_DEBUG(sanity, checkNurserySanity(cap->r.rNursery));
            
            // now update the nursery to point to the new block
            cap->r.rCurrentNursery = bd;
index 99d36d2..8643972 100644 (file)
@@ -672,9 +672,13 @@ allocateLocal( StgRegTable *reg, nat n )
                // it at the *front* of the nursery list, and use it
                // to allocate() from.
                reg->rCurrentNursery->link = bd->link;
+               if (bd->link != NULL) {
+                   bd->link->u.back = reg->rCurrentNursery;
+               }
            }
            dbl_link_onto(bd, &reg->rNursery->blocks);
            reg->rCurrentAlloc = bd;
+           IF_DEBUG(sanity, checkNurserySanity(reg->rNursery));
        }
     }
     p = bd->free;
@@ -1057,6 +1061,22 @@ checkSanity( void )
     }
 }
 
+/* Nursery sanity check */
+void
+checkNurserySanity( step *stp )
+{
+    bdescr *bd, *prev;
+    nat blocks = 0;
+
+    prev = NULL;
+    for (bd = stp->blocks; bd != NULL; bd = bd->link) {
+       ASSERT(bd->u.back == prev);
+       prev = bd;
+       blocks += bd->blocks;
+    }
+    ASSERT(blocks == stp->n_blocks);
+}
+
 // handy function for use in gdb, because Bdescr() is inlined.
 extern bdescr *_bdescr( StgPtr p );