X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fsm%2FBlockAlloc.c;h=edc37620bda566dde53d17529f3c67df919243f7;hb=aeeeda3efad5266b0c52b92807bb0cc3b3f23b5c;hp=bf7a55e7a96d9d52a418d6495168b7a35c5481e5;hpb=a2a67cd520b9841114d69a87a423dabcb3b4368e;p=ghc-hetmet.git diff --git a/rts/sm/BlockAlloc.c b/rts/sm/BlockAlloc.c index bf7a55e..edc3762 100644 --- a/rts/sm/BlockAlloc.c +++ b/rts/sm/BlockAlloc.c @@ -58,7 +58,8 @@ static void initMBlock(void *mblock); The following fields are not used by the allocator: bd->flags bd->gen_no - bd->step + bd->gen + bd->dest Exceptions: we don't maintain invariants for all the blocks within a group on the free list, because it is expensive to modify every @@ -469,7 +470,7 @@ freeGroup(bdescr *p) ASSERT(p->free != (P_)-1); p->free = (void *)-1; /* indicates that this block is free */ - p->step = NULL; + p->gen = NULL; p->gen_no = 0; /* fill the block group with garbage if sanity checking is on */ IF_DEBUG(sanity,memset(p->start, 0xaa, p->blocks * BLOCK_SIZE)); @@ -628,6 +629,40 @@ initMBlock(void *mblock) } /* ----------------------------------------------------------------------------- + Stats / metrics + -------------------------------------------------------------------------- */ + +nat +countBlocks(bdescr *bd) +{ + nat n; + for (n=0; bd != NULL; bd=bd->link) { + n += bd->blocks; + } + return n; +} + +// (*1) Just like countBlocks, except that we adjust the count for a +// megablock group so that it doesn't include the extra few blocks +// that would be taken up by block descriptors in the second and +// subsequent megablock. This is so we can tally the count with the +// number of blocks allocated in the system, for memInventory(). +nat +countAllocdBlocks(bdescr *bd) +{ + nat n; + for (n=0; bd != NULL; bd=bd->link) { + n += bd->blocks; + // hack for megablock groups: see (*1) above + if (bd->blocks > BLOCKS_PER_MBLOCK) { + n -= (MBLOCK_SIZE / BLOCK_SIZE - BLOCKS_PER_MBLOCK) + * (bd->blocks/(MBLOCK_SIZE/BLOCK_SIZE)); + } + } + return n; +} + +/* ----------------------------------------------------------------------------- Debugging -------------------------------------------------------------------------- */