[project @ 2005-03-10 14:03:28 by simonmar]
[ghc-hetmet.git] / ghc / rts / GCCompact.h
1 /* -----------------------------------------------------------------------------
2  *
3  * (c) The GHC Team 1998-1999
4  *
5  * Compacting garbage collector
6  *
7  * ---------------------------------------------------------------------------*/
8
9 INLINE_HEADER void 
10 mark(StgPtr p, bdescr *bd)
11 {
12     nat offset_within_block = p - bd->start; // in words
13     StgPtr bitmap_word = (StgPtr)bd->u.bitmap + 
14         (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
15     nat bit_mask = 1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
16     *bitmap_word |= bit_mask;
17 }
18
19 INLINE_HEADER void 
20 unmark(StgPtr p, bdescr *bd)
21 {
22     nat offset_within_block = p - bd->start; // in words
23     StgPtr bitmap_word = (StgPtr)bd->u.bitmap + 
24         (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
25     nat bit_mask = 1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
26     *bitmap_word &= ~bit_mask;
27 }
28
29 INLINE_HEADER int
30 is_marked(StgPtr p, bdescr *bd)
31 {
32     nat offset_within_block = p - bd->start; // in words
33     StgPtr bitmap_word = (StgPtr)bd->u.bitmap + 
34         (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
35     nat bit_mask = 1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
36     return (*bitmap_word & bit_mask);
37 }
38
39 void compact( void (*get_roots)(evac_fn) );