1 /* -----------------------------------------------------------------------------
3 * (c) The GHC Team 1998-2006
5 * Generational garbage collector: utilities
7 * ---------------------------------------------------------------------------*/
14 /* -----------------------------------------------------------------------------
15 Allocate a new to-space block in the given step.
16 -------------------------------------------------------------------------- */
19 gc_alloc_block(step *stp)
21 bdescr *bd = allocBlock();
22 bd->gen_no = stp->gen_no;
26 // blocks in to-space in generations up to and including N
27 // get the BF_EVACUATED flag.
28 if (stp->gen_no <= N) {
29 bd->flags = BF_EVACUATED;
34 // Start a new to-space block, chain it on after the previous one.
35 if (stp->hp_bd != NULL) {
36 stp->hp_bd->free = stp->hp;
37 stp->hp_bd->link = bd;
42 stp->hpLim = stp->hp + BLOCK_SIZE_W;
51 gc_alloc_scavd_block(step *stp)
53 bdescr *bd = allocBlock();
54 bd->gen_no = stp->gen_no;
57 // blocks in to-space in generations up to and including N
58 // get the BF_EVACUATED flag.
59 if (stp->gen_no <= N) {
60 bd->flags = BF_EVACUATED;
65 bd->link = stp->blocks;
68 if (stp->scavd_hp != NULL) {
69 Bdescr(stp->scavd_hp)->free = stp->scavd_hp;
71 stp->scavd_hp = bd->start;
72 stp->scavd_hpLim = stp->scavd_hp + BLOCK_SIZE_W;