#include "GC.h"
#include "GCUtils.h"
#include "Printer.h"
+#include "Trace.h"
#ifdef THREADED_RTS
SpinLock gc_alloc_block_sync;
if (stp->todos) {
bd = stp->todos;
stp->todos = bd->link;
+ stp->n_todos--;
bd->link = NULL;
}
RELEASE_SPIN_LOCK(&stp->sync_todo);
ACQUIRE_SPIN_LOCK(&stp->sync_todo);
bd->link = stp->todos;
stp->todos = bd;
+ stp->n_todos++;
+ trace(TRACE_gc, "step %d, n_todos: %d", stp->abs_no, stp->n_todos);
RELEASE_SPIN_LOCK(&stp->sync_todo);
}
// update stats: this is a block that has been copied & scavenged
copied += bd->free - bd->start;
- // put the scan block *second* in ws->scavd_list. The first block
- // in this list is for evacuating objects that don't need to be
- // scavenged.
- bd->link = ws->scavd_list->link;
- ws->scavd_list->link = bd;
+ // put the scan block on the ws->scavd_list.
+ bd->link = ws->scavd_list;
+ ws->scavd_list = bd;
ws->n_scavd_blocks ++;
IF_DEBUG(sanity,
ASSERT(countBlocks(ws->scavd_list) == ws->n_scavd_blocks));
}
-bdescr *
+StgPtr
gc_alloc_todo_block (step_workspace *ws)
{
bdescr *bd;
+ if (ws->todo_bd != NULL) {
+ ws->todo_bd->free = ws->todo_free;
+ }
+
// If we already have a todo block, it must be full, so we push it
// out: first to the buffer_todo_bd, then to the step. BUT, don't
// push out the block out if it is already the scan block.
}
ws->todo_bd = bd;
+ ws->todo_free = bd->start;
+ ws->todo_lim = bd->start + BLOCK_SIZE_W;
- return bd;
-}
-
-bdescr *
-gc_alloc_scavd_block (step_workspace *ws)
-{
- bdescr *bd;
-
- bd = allocBlock_sync();
-
- bd->gen_no = ws->stp->gen_no;
- bd->step = ws->stp;
-
- // blocks in to-space in generations up to and including N
- // get the BF_EVACUATED flag.
- if (ws->stp->gen_no <= N) {
- bd->flags = BF_EVACUATED;
- } else {
- bd->flags = 0;
- }
-
- // update stats: this is a block that has been copied only
- if (ws->scavd_list != NULL) {
- scavd_copied += ws->scavd_list->free - ws->scavd_list->start;
- }
-
- bd->link = ws->scavd_list;
- ws->scavd_list = bd;
- ws->n_scavd_blocks++;
-
- return bd;
+ return ws->todo_free;
}
/* -----------------------------------------------------------------------------