diff options
author | Simon Marlow <simonmar@microsoft.com> | 2007-10-31 12:51:36 +0000 |
---|---|---|
committer | Simon Marlow <simonmar@microsoft.com> | 2007-10-31 12:51:36 +0000 |
commit | d5bd3e829c47c03157cf41cad581d2df44dfd81b (patch) | |
tree | 98fb99c2713190f77d1999345888b2dcdabe5bf2 /rts/sm/GCUtils.h | |
parent | 9e5fe6be620eaf03a86f1321bef603ca43699a3c (diff) | |
download | haskell-d5bd3e829c47c03157cf41cad581d2df44dfd81b.tar.gz |
Refactoring of the GC in preparation for parallel GC
This patch localises the state of the GC into a gc_thread structure,
and reorganises the inner loop of the GC to scavenge one block at a
time from global work lists in each "step". The gc_thread structure
has a "workspace" for each step, in which it collects evacuated
objects until it has a full block to push out to the step's global
list. Details of the algorithm will be on the wiki in due course.
At the moment, THREADED_RTS does not compile, but the single-threaded
GC works (and is 10-20% slower than before).
Diffstat (limited to 'rts/sm/GCUtils.h')
-rw-r--r-- | rts/sm/GCUtils.h | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/rts/sm/GCUtils.h b/rts/sm/GCUtils.h index 70dd7a882f..2b22407d31 100644 --- a/rts/sm/GCUtils.h +++ b/rts/sm/GCUtils.h @@ -11,5 +11,29 @@ * * --------------------------------------------------------------------------*/ -bdescr *gc_alloc_block(step *stp); -bdescr *gc_alloc_scavd_block(step *stp); +#include "SMP.h" + +#ifdef THREADED_RTS +extern SpinLock gc_alloc_block_sync; +#endif + +bdescr *allocBlock_sync(void); + +void push_scan_block (bdescr *bd, step_workspace *ws); +bdescr *grab_todo_block (step_workspace *ws); +bdescr *gc_alloc_todo_block (step_workspace *ws); +bdescr *gc_alloc_scavd_block (step_workspace *ws); + +// Returns true if a block is 3/4 full. This predicate is used to try +// to re-use partial blocks wherever possible, and to reduce wastage. +// We might need to tweak the actual value. +INLINE_HEADER rtsBool +isPartiallyFull(bdescr *bd) +{ + return (bd->free + BLOCK_SIZE_W/4 < bd->start + BLOCK_SIZE_W); +} + + +#if DEBUG +void printMutableList (generation *gen); +#endif |