/* Approximate how much we allocated.
* Todo: only when generating stats?
*/
- allocated = calcAllocated();
+ allocated = calcAllocated(rtsFalse/* don't count the nursery yet */);
/* Figure out which generation to collect
*/
inc_running();
wakeup_gc_threads(n_gc_threads, gct->thread_index);
- // Mutable lists from each generation > N
- // we want to *scavenge* these roots, not evacuate them: they're not
- // going to move in this GC.
- // Also do them in reverse generation order, for the usual reason:
- // namely to reduce the likelihood of spurious old->new pointers.
- //
- for (g = RtsFlags.GcFlags.generations-1; g > N; g--) {
-#if defined(THREADED_RTS)
- if (n_gc_threads > 1) {
- scavenge_mutable_list(generations[g].saved_mut_list, &generations[g]);
- } else {
- scavenge_mutable_list1(generations[g].saved_mut_list, &generations[g]);
- }
-#else
- scavenge_mutable_list(generations[g].saved_mut_list, &generations[g]);
-#endif
- freeChain_sync(generations[g].saved_mut_list);
- generations[g].saved_mut_list = NULL;
-
- }
-
// scavenge the capability-private mutable lists. This isn't part
// of markSomeCapabilities() because markSomeCapabilities() can only
// call back into the GC via mark_root() (due to the gct register
// stats. Every mutable list is copied during every GC.
if (g > 0) {
nat mut_list_size = 0;
- for (bd = generations[g].mut_list; bd != NULL; bd = bd->link) {
- mut_list_size += bd->free - bd->start;
- }
for (n = 0; n < n_capabilities; n++) {
- for (bd = capabilities[n].mut_lists[g];
- bd != NULL; bd = bd->link) {
- mut_list_size += bd->free - bd->start;
- }
+ mut_list_size += countOccupied(capabilities[n].mut_lists[g]);
}
copied += mut_list_size;
freeChain(gen->large_objects);
gen->large_objects = gen->scavenged_large_objects;
gen->n_large_blocks = gen->n_scavenged_large_blocks;
- gen->n_new_large_blocks = 0;
+ gen->n_new_large_words = 0;
ASSERT(countBlocks(gen->large_objects) == gen->n_large_blocks);
}
else // for generations > N
// Calculate the amount of live data for stats.
live = calcLiveWords();
- // Free the small objects allocated via allocate(), since this will
- // all have been copied into G0S1 now.
- alloc_blocks_lim = RtsFlags.GcFlags.minAllocAreaSize;
-
// Start a new pinned_object_block
for (n = 0; n < n_capabilities; n++) {
capabilities[n].pinned_object_block = NULL;
}
}
+ // Reset the nursery: make the blocks empty
+ allocated += clearNurseries();
+
resize_nursery();
- // mark the garbage collected CAFs as dead
+ resetNurseries();
+
+ // mark the garbage collected CAFs as dead
#if 0 && defined(DEBUG) // doesn't work at the moment
if (major_gc) { gcCAFs(); }
#endif
}
}
- // Reset the nursery
- resetNurseries();
-
- // send exceptions to any threads which were about to die
+ // send exceptions to any threads which were about to die
RELEASE_SM_LOCK;
resurrectThreads(resurrected_threads);
ACQUIRE_SM_LOCK;
// list always has at least one block; this means we can avoid a
// check for NULL in recordMutable().
if (g != 0) {
- freeChain(generations[g].mut_list);
- generations[g].mut_list = allocBlock();
- for (i = 0; i < n_capabilities; i++) {
+ for (i = 0; i < n_capabilities; i++) {
freeChain(capabilities[i].mut_lists[g]);
capabilities[i].mut_lists[g] = allocBlock();
}
// save the current mutable lists for this generation, and
// allocate a fresh block for each one. We'll traverse these
// mutable lists as roots early on in the GC.
- generations[g].saved_mut_list = generations[g].mut_list;
- generations[g].mut_list = allocBlock();
for (n = 0; n < n_capabilities; n++) {
capabilities[n].saved_mut_lists[g] = capabilities[n].mut_lists[g];
capabilities[n].mut_lists[g] = allocBlock();