- // Two-space collector: free the old to-space.
- // g0s0->old_blocks is the old nursery
- // g0s0->blocks is to-space from the previous GC
- if (RtsFlags.GcFlags.generations == 1) {
- if (g0s0->blocks != NULL) {
- freeChain(g0s0->blocks);
- g0s0->blocks = NULL;
- }
- }
-
- // For each workspace, in each thread, move the copied blocks to the step
- {
- gc_thread *thr;
- step_workspace *ws;
- bdescr *prev, *next;
-
- for (t = 0; t < n_gc_threads; t++) {
- thr = gc_threads[t];
-
- // not step 0
- if (RtsFlags.GcFlags.generations == 1) {
- s = 0;
- } else {
- s = 1;
- }
- for (; s < total_steps; s++) {
- ws = &thr->steps[s];
-
- // Push the final block
- if (ws->todo_bd) {
- push_scanned_block(ws->todo_bd, ws);
- }
-
- ASSERT(gct->scan_bd == NULL);
- ASSERT(countBlocks(ws->scavd_list) == ws->n_scavd_blocks);
-
- prev = NULL;
- for (bd = ws->scavd_list; bd != NULL; bd = bd->link) {
- ws->step->n_words += bd->free - bd->start;
- prev = bd;
- }
- if (prev != NULL) {
- prev->link = ws->step->blocks;
- ws->step->blocks = ws->scavd_list;
- }
- ws->step->n_blocks += ws->n_scavd_blocks;
- }
- }
-
- // Add all the partial blocks *after* we've added all the full
- // blocks. This is so that we can grab the partial blocks back
- // again and try to fill them up in the next GC.
- for (t = 0; t < n_gc_threads; t++) {
- thr = gc_threads[t];
-
- // not step 0
- if (RtsFlags.GcFlags.generations == 1) {
- s = 0;
- } else {
- s = 1;
- }
- for (; s < total_steps; s++) {
- ws = &thr->steps[s];
-
- prev = NULL;
- for (bd = ws->part_list; bd != NULL; bd = next) {
- next = bd->link;
- if (bd->free == bd->start) {
- if (prev == NULL) {
- ws->part_list = next;
- } else {
- prev->link = next;
- }
- freeGroup(bd);
- ws->n_part_blocks--;
- } else {
- ws->step->n_words += bd->free - bd->start;
- prev = bd;
- }
- }
- if (prev != NULL) {
- prev->link = ws->step->blocks;
- ws->step->blocks = ws->part_list;
- }
- ws->step->n_blocks += ws->n_part_blocks;
-
- ASSERT(countBlocks(ws->step->blocks) == ws->step->n_blocks);
- ASSERT(countOccupied(ws->step->blocks) == ws->step->n_words);
- }
- }
- }
-