1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team 1998-2006
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 * ---------------------------------------------------------------------------*/
19 /* -----------------------------------------------------------------------------
20 Allocate a new to-space block in the given step.
21 -------------------------------------------------------------------------- */
24 gc_alloc_block(step *stp)
26 bdescr *bd = allocBlock();
27 bd->gen_no = stp->gen_no;
31 // blocks in to-space in generations up to and including N
32 // get the BF_EVACUATED flag.
33 if (stp->gen_no <= N) {
34 bd->flags = BF_EVACUATED;
39 // Start a new to-space block, chain it on after the previous one.
40 if (stp->hp_bd != NULL) {
41 stp->hp_bd->free = stp->hp;
42 stp->hp_bd->link = bd;
47 stp->hpLim = stp->hp + BLOCK_SIZE_W;
56 gc_alloc_scavd_block(step *stp)
58 bdescr *bd = allocBlock();
59 bd->gen_no = stp->gen_no;
62 // blocks in to-space in generations up to and including N
63 // get the BF_EVACUATED flag.
64 if (stp->gen_no <= N) {
65 bd->flags = BF_EVACUATED;
70 bd->link = stp->blocks;
73 if (stp->scavd_hp != NULL) {
74 Bdescr(stp->scavd_hp)->free = stp->scavd_hp;
76 stp->scavd_hp = bd->start;
77 stp->scavd_hpLim = stp->scavd_hp + BLOCK_SIZE_W;