1 /* ----------------------------------------------------------------------------
3 * (c) The GHC Team 1998-2008
5 * Generational garbage collector: utilities
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"
21 bdescr *allocBlock_sync(void);
22 void freeChain_sync(bdescr *bd);
24 void push_scanned_block (bdescr *bd, gen_workspace *ws);
25 StgPtr todo_block_full (nat size, gen_workspace *ws);
26 StgPtr alloc_todo_block (gen_workspace *ws, nat size);
28 bdescr *grab_local_todo_block (gen_workspace *ws);
29 #if defined(THREADED_RTS)
30 bdescr *steal_todo_block (nat s);
33 // Returns true if a block is partially full. This predicate is used to try
34 // to re-use partial blocks wherever possible, and to reduce wastage.
35 // We might need to tweak the actual value.
37 isPartiallyFull(bdescr *bd)
39 return (bd->free + WORK_UNIT_WORDS < bd->start + BLOCK_SIZE_W);
44 void printMutableList (bdescr *bd);
47 // Version of recordMutableGen for use during GC. This uses the
48 // mutable lists attached to the current gc_thread structure, which
49 // are the same as the mutable lists on the Capability.
51 recordMutableGen_GC (StgClosure *p, nat gen_no)
55 bd = gct->mut_lists[gen_no];
56 if (bd->free >= bd->start + BLOCK_SIZE_W) {
58 new_bd = allocBlock_sync();
61 gct->mut_lists[gen_no] = bd;
63 *bd->free++ = (StgWord)p;
66 #include "EndPrivate.h"
68 #endif /* SM_GCUTILS_H */