1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team 1998-2005
5 * Compacting garbage collector
7 * Documentation on the architecture of the Garbage Collector can be
8 * found in the online commentary:
10 * http://hackage.haskell.org/trac/ghc/wiki/Commentary/Rts/Storage/GC
12 * ---------------------------------------------------------------------------*/
18 mark_stack_empty(void)
20 return mark_sp == mark_stack;
26 return mark_sp >= mark_splim;
30 reset_mark_stack(void)
36 push_mark_stack(StgPtr p)
48 mark(StgPtr p, bdescr *bd)
50 nat offset_within_block = p - bd->start; // in words
51 StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
52 (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
53 StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
54 *bitmap_word |= bit_mask;
58 unmark(StgPtr p, bdescr *bd)
60 nat offset_within_block = p - bd->start; // in words
61 StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
62 (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
63 StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
64 *bitmap_word &= ~bit_mask;
68 is_marked(StgPtr p, bdescr *bd)
70 nat offset_within_block = p - bd->start; // in words
71 StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
72 (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
73 StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
74 return (*bitmap_word & bit_mask);
79 #endif /* GCCOMPACT_H */