// 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;
// 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, ®->rNursery->blocks);
reg->rCurrentAlloc = bd;
+ IF_DEBUG(sanity, checkNurserySanity(reg->rNursery));
}
}
p = bd->free;
}
}
+/* 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 );