X-Git-Url: http://git.megacz.com/?a=blobdiff_plain;f=rts%2Fsm%2FCompact.h;fp=rts%2Fsm%2FCompact.h;h=4f1d6a27c72bd098a3af7bff03f2f5c239f9b562;hb=ab0e778ccfde61aed4c22679b24d175fc6cc9bf3;hp=0000000000000000000000000000000000000000;hpb=2246c514eade324d70058ba3135dc0c51ee9353b;p=ghc-hetmet.git diff --git a/rts/sm/Compact.h b/rts/sm/Compact.h new file mode 100644 index 0000000..4f1d6a2 --- /dev/null +++ b/rts/sm/Compact.h @@ -0,0 +1,74 @@ +/* ----------------------------------------------------------------------------- + * + * (c) The GHC Team 1998-2005 + * + * Compacting garbage collector + * + * ---------------------------------------------------------------------------*/ + +#ifndef GCCOMPACT_H +#define GCCOMPACT_H + +INLINE_HEADER rtsBool +mark_stack_empty(void) +{ + return mark_sp == mark_stack; +} + +INLINE_HEADER rtsBool +mark_stack_full(void) +{ + return mark_sp >= mark_splim; +} + +INLINE_HEADER void +reset_mark_stack(void) +{ + mark_sp = mark_stack; +} + +INLINE_HEADER void +push_mark_stack(StgPtr p) +{ + *mark_sp++ = p; +} + +INLINE_HEADER StgPtr +pop_mark_stack(void) +{ + return *--mark_sp; +} + +INLINE_HEADER 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; +} + +INLINE_HEADER 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; +} + +INLINE_HEADER 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); + +#endif /* GCCOMPACT_H */