blob: 0fb39b3b12d647abd70310f40c2eb08371f64a8d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
/* -----------------------------------------------------------------------------
*
* (c) The GHC Team 1998-2005
*
* Compacting garbage collector
*
* ---------------------------------------------------------------------------*/
#ifndef GCCOMPACT_H
#define GCCOMPACT_H
STATIC_INLINE void
mark(StgPtr p, bdescr *bd)
{
nat offset_within_block = p - bd->start; // in words
StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
(offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
*bitmap_word |= bit_mask;
}
STATIC_INLINE void
unmark(StgPtr p, bdescr *bd)
{
nat offset_within_block = p - bd->start; // in words
StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
(offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
*bitmap_word &= ~bit_mask;
}
STATIC_INLINE StgWord
is_marked(StgPtr p, bdescr *bd)
{
nat offset_within_block = p - bd->start; // in words
StgPtr bitmap_word = (StgPtr)bd->u.bitmap +
(offset_within_block / (sizeof(W_)*BITS_PER_BYTE));
StgWord bit_mask = (StgWord)1 << (offset_within_block & (sizeof(W_)*BITS_PER_BYTE - 1));
return (*bitmap_word & bit_mask);
}
void compact( void (*get_roots)(evac_fn) );
#endif /* GCCOMPACT_H */
|