1 /* -----------------------------------------------------------------------------
2 * $Id: GCCompact.h,v 1.2 2001/07/30 13:06:18 simonmar Exp $
4 * (c) The GHC Team 1998-1999
6 * Compacting garbage collector
8 * ---------------------------------------------------------------------------*/
11 mark(StgPtr p, bdescr *bd)
13 nat offset_within_block = p - bd->start; // in words
14 StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
15 (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
16 nat bit_mask = 1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
17 *bitmap_word |= bit_mask;
21 unmark(StgPtr p, bdescr *bd)
23 nat offset_within_block = p - bd->start; // in words
24 StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
25 (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
26 nat bit_mask = 1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
27 *bitmap_word &= ~bit_mask;
31 is_marked(StgPtr p, bdescr *bd)
33 nat offset_within_block = p - bd->start; // in words
34 StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
35 (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
36 nat bit_mask = 1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
37 return (*bitmap_word & bit_mask);
40 void compact( void (*get_roots)(evac_fn) );