X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2FGCCompact.h;fp=rts%2FGCCompact.h;h=0fb39b3b12d647abd70310f40c2eb08371f64a8d;hb=0065d5ab628975892cea1ec7303f968c3338cbe1;hp=0000000000000000000000000000000000000000;hpb=28a464a75e14cece5db40f2765a29348273ff2d2;p=ghc-hetmet.git diff --git a/rts/GCCompact.h b/rts/GCCompact.h new file mode 100644 index 0000000..0fb39b3 --- /dev/null +++ b/rts/GCCompact.h @@ -0,0 +1,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 */