1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team 1998-2008
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 * ---------------------------------------------------------------------------*/
17 #include "BeginPrivate.h"
20 mark(StgPtr p, bdescr *bd)
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 StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
26 *bitmap_word |= bit_mask;
30 unmark(StgPtr p, bdescr *bd)
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 StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
36 *bitmap_word &= ~bit_mask;
40 is_marked(StgPtr p, bdescr *bd)
42 nat offset_within_block = p - bd->start; // in words
43 StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
44 (offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
45 StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
46 return (*bitmap_word & bit_mask);
49 void compact (StgClosure *static_objects);
51 #include "EndPrivate.h"
53 #endif /* SM_COMPACT_H */