[project @ 2004-02-12 02:04:59 by mthomas]
[ghc-hetmet.git] / ghc / rts / GCCompact.h
1 /* -----------------------------------------------------------------------------
2  * $Id: GCCompact.h,v 1.3 2003/11/12 17:49:07 sof Exp $
3  *
4  * (c) The GHC Team 1998-1999
5  *
6  * Compacting garbage collector
7  *
8  * ---------------------------------------------------------------------------*/
9
10 INLINE_HEADER void 
11 mark(StgPtr p, bdescr *bd)
12 {
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;
18 }
19
20 INLINE_HEADER void 
21 unmark(StgPtr p, bdescr *bd)
22 {
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;
28 }
29
30 INLINE_HEADER int
31 is_marked(StgPtr p, bdescr *bd)
32 {
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);
38 }
39
40 void compact( void (*get_roots)(evac_fn) );