Commit 8ac01a64 authored by simonmarhaskell@gmail.com's avatar simonmarhaskell@gmail.com
Browse files

free empty blocks at the end of GC

parent 12c15598
......@@ -410,7 +410,7 @@ GarbageCollect ( rtsBool force_major_gc )
{
gc_thread *thr;
step_workspace *ws;
bdescr *prev;
bdescr *prev, *next;
for (t = 0; t < n_gc_threads; t++) {
thr = gc_threads[t];
......@@ -427,28 +427,41 @@ GarbageCollect ( rtsBool force_major_gc )
ASSERT(gct->scan_bd == NULL);
ASSERT(countBlocks(ws->scavd_list) == ws->n_scavd_blocks);
prev = ws->part_list;
for (bd = ws->part_list; bd != NULL; bd = bd->link) {
prev = NULL;
for (bd = ws->scavd_list; bd != NULL; bd = bd->link) {
bd->flags &= ~BF_EVACUATED; // now from-space
ws->step->n_words += bd->free - bd->start;
prev = bd;
}
if (prev != NULL) {
prev->link = ws->scavd_list;
}
for (bd = ws->scavd_list; bd != NULL; bd = bd->link) {
bd->flags &= ~BF_EVACUATED; // now from-space
ws->step->n_words += bd->free - bd->start;
prev = bd;
prev->link = ws->step->blocks;
ws->step->blocks = ws->scavd_list;
}
ws->step->n_blocks += ws->n_scavd_blocks;
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 {
bd->flags &= ~BF_EVACUATED; // now from-space
ws->step->n_words += bd->free - bd->start;
prev = bd;
}
}
prev->link = ws->step->blocks;
if (ws->part_list != NULL) {
if (prev != NULL) {
prev->link = ws->step->blocks;
ws->step->blocks = ws->part_list;
} else {
ws->step->blocks = ws->scavd_list;
}
ws->step->n_blocks += ws->n_part_blocks;
ws->step->n_blocks += ws->n_scavd_blocks;
ASSERT(countBlocks(ws->step->blocks) == ws->step->n_blocks);
ASSERT(countOccupied(ws->step->blocks) == ws->step->n_words);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment