X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=ghc%2Frts%2FBlockAlloc.c;h=9d13719918c13fe974f07695a9f0d811200945ce;hb=6e5df3a4551b8d8b83e936b3f7b52edfc778ca8a;hp=220928520ed8f264a0d122518d8420511014bfb2;hpb=18b3cd979a185d02c88df1de61814ed808c62010;p=ghc-hetmet.git diff --git a/ghc/rts/BlockAlloc.c b/ghc/rts/BlockAlloc.c index 2209285..9d13719 100644 --- a/ghc/rts/BlockAlloc.c +++ b/ghc/rts/BlockAlloc.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: BlockAlloc.c,v 1.11 2001/11/08 10:18:49 simonmar Exp $ + * $Id: BlockAlloc.c,v 1.14 2002/07/17 09:21:49 simonmar Exp $ * * (c) The GHC Team 1998-2000 * @@ -23,6 +23,8 @@ #include "BlockAlloc.h" #include "MBlock.h" +#include + static void initMBlock(void *mblock); static bdescr *allocMegaGroup(nat mblocks); static void freeMegaGroup(bdescr *bd); @@ -196,15 +198,17 @@ static inline bdescr * coalesce(bdescr *p) { bdescr *bd, *q; - nat i; + nat i, blocks; q = p->link; if (q != NULL && p->start + p->blocks * BLOCK_SIZE_W == q->start) { /* can coalesce */ p->blocks += q->blocks; p->link = q->link; - for (i = 0, bd = q; i < q->blocks; bd++, i++) { + blocks = q->blocks; + for (i = 0, bd = q; i < blocks; bd++, i++) { bd->free = 0; + bd->blocks = 0; bd->link = p; } return p; @@ -302,6 +306,18 @@ initMBlock(void *mblock) -------------------------------------------------------------------------- */ #ifdef DEBUG +static void +checkWellFormedGroup( bdescr *bd ) +{ + nat i; + + for (i = 1; i < bd->blocks; i++) { + ASSERT(bd[i].blocks == 0); + ASSERT(bd[i].free == 0); + ASSERT(bd[i].link == bd); + } +} + void checkFreeListSanity(void) { @@ -312,6 +328,7 @@ checkFreeListSanity(void) fprintf(stderr,"group at 0x%x, length %d blocks\n", (nat)bd->start, bd->blocks)); ASSERT(bd->blocks > 0); + checkWellFormedGroup(bd); if (bd->link != NULL) { /* make sure we're fully coalesced */ ASSERT(bd->start + bd->blocks * BLOCK_SIZE_W != bd->link->start);