diff options
| author | simonm <unknown> | 1999-01-13 17:25:59 +0000 | 
|---|---|---|
| committer | simonm <unknown> | 1999-01-13 17:25:59 +0000 | 
| commit | 4391e44f910ce579f269986faef9e5db8907a6c0 (patch) | |
| tree | a20d5c8313e7000a8bb0afd499db73b3f30dcbe5 /ghc/rts/BlockAlloc.c | |
| parent | dc49719c45797614110483c9bb74c1d271578226 (diff) | |
| download | haskell-4391e44f910ce579f269986faef9e5db8907a6c0.tar.gz | |
[project @ 1999-01-13 17:25:37 by simonm]
Added a generational garbage collector.
The collector is reliable but fairly untuned as yet.  It works with an
arbitrary number of generations: use +RTS -G<gens> to change the
number of generations used (default 2).
Stats: +RTS -Sstderr is quite useful, but to really see what's going
on compile the RTS with -DDEBUG and use +RTS -D32.
ARR_PTRS removed - it wasn't used anywhere.
Sanity checking improved:
	- free blocks are now spammed when sanity checking is turned on
	- a check for leaking blocks is performed after each GC.
Diffstat (limited to 'ghc/rts/BlockAlloc.c')
| -rw-r--r-- | ghc/rts/BlockAlloc.c | 25 | 
1 files changed, 21 insertions, 4 deletions
diff --git a/ghc/rts/BlockAlloc.c b/ghc/rts/BlockAlloc.c index e0ded8e252..26f2a60bc5 100644 --- a/ghc/rts/BlockAlloc.c +++ b/ghc/rts/BlockAlloc.c @@ -1,5 +1,5 @@  /* ----------------------------------------------------------------------------- - * $Id: BlockAlloc.c,v 1.2 1998/12/02 13:28:12 simonm Exp $ + * $Id: BlockAlloc.c,v 1.3 1999/01/13 17:25:37 simonm Exp $   *   * The block allocator and free list manager.   * @@ -210,6 +210,14 @@ freeGroup(bdescr *p)      return;    } +#ifdef DEBUG +  p->free = (void *)-1;  /* indicates that this block is free */ +  p->step = NULL; +  p->gen  = NULL; +  /* fill the block group with garbage if sanity checking is on */ +  IF_DEBUG(sanity,memset(p->start, 0xaa, p->blocks * BLOCK_SIZE)); +#endif +    /* find correct place in free list to place new group */    last = NULL;    for (bd = free_list; bd != NULL && bd->start < p->start;  @@ -252,9 +260,6 @@ freeChain(bdescr *bd)    bdescr *next_bd;    while (bd != NULL) {      next_bd = bd->link; -#ifdef DEBUG -    bd->free = (void *)-1;  /* indicates that this block is free */ -#endif      freeGroup(bd);      bd = next_bd;    } @@ -301,4 +306,16 @@ checkFreeListSanity(void)      }    }  } + +nat /* BLOCKS */ +countFreeList(void) +{ +  bdescr *bd; +  lnat total_blocks = 0; + +  for (bd = free_list; bd != NULL; bd = bd->link) { +    total_blocks += bd->blocks; +  } +  return total_blocks; +}  #endif  | 
