X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;ds=sidebyside;f=ghc%2Frts%2FBlockAlloc.c;h=f33ab86468a4a8649aac8b30760400cf5051870e;hb=2a59f826d3c2c5f02254f64c09f77f784a24a90f;hp=65205f8ff6a919ffbe84f232864ad1cb3c977c56;hpb=bc5c802181b513216bc88f0d1ec9574157ee05fe;p=ghc-hetmet.git diff --git a/ghc/rts/BlockAlloc.c b/ghc/rts/BlockAlloc.c index 65205f8..f33ab86 100644 --- a/ghc/rts/BlockAlloc.c +++ b/ghc/rts/BlockAlloc.c @@ -1,5 +1,5 @@ /* ----------------------------------------------------------------------------- - * $Id: BlockAlloc.c,v 1.10 2001/08/14 13:40:09 sewardj Exp $ + * $Id: BlockAlloc.c,v 1.13 2001/11/08 14:42:11 simonmar Exp $ * * (c) The GHC Team 1998-2000 * @@ -53,6 +53,7 @@ initGroup(nat n, bdescr *head) head->free = head->start; for (i=1, bd = head+1; i < n; i++, bd++) { bd->free = 0; + bd->blocks = 0; bd->link = head; } } @@ -195,15 +196,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; @@ -301,6 +304,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) { @@ -311,6 +326,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);