- allocated = countNurseryBlocks() * BLOCK_SIZE_W;
-
- for (i = 0; i < n_capabilities; i++) {
- Capability *cap;
- for ( bd = capabilities[i].r.rCurrentNursery->link;
- bd != NULL; bd = bd->link ) {
- allocated -= BLOCK_SIZE_W;
- }
- cap = &capabilities[i];
- if (cap->r.rCurrentNursery->free <
- cap->r.rCurrentNursery->start + BLOCK_SIZE_W) {
- allocated -= (cap->r.rCurrentNursery->start + BLOCK_SIZE_W)
- - cap->r.rCurrentNursery->free;
- }
- if (cap->pinned_object_block != NULL) {
- allocated -= (cap->pinned_object_block->start + BLOCK_SIZE_W) -
- cap->pinned_object_block->free;
+ // When called from GC.c, we already have the allocation count for
+ // the nursery from resetNurseries(), so we don't need to walk
+ // through these block lists again.
+ if (include_nurseries)
+ {
+ for (i = 0; i < n_capabilities; i++) {
+ for (bd = nurseries[i].blocks; bd; bd = bd->link) {
+ allocated += (lnat)(bd->free - bd->start);
+ }