diff --git a/src/nofl-space.h b/src/nofl-space.h index bd9516cab..1f2f17765 100644 --- a/src/nofl-space.h +++ b/src/nofl-space.h @@ -944,17 +944,17 @@ nofl_space_prepare_gc(struct nofl_space *space, enum gc_collection_kind kind) { static void nofl_space_start_gc(struct nofl_space *space, enum gc_collection_kind gc_kind) { - GC_ASSERT_EQ(nofl_block_count(&space->partly_full), 0); GC_ASSERT_EQ(nofl_block_count(&space->to_sweep), 0); // Any block that was the target of allocation in the last cycle will need to // be swept next cycle. uintptr_t block; + while ((block = nofl_pop_block(&space->partly_full))) + nofl_push_block(&space->to_sweep, block); while ((block = nofl_pop_block(&space->full))) nofl_push_block(&space->to_sweep, block); if (gc_kind != GC_COLLECTION_MINOR) { - uintptr_t block; while ((block = nofl_pop_block(&space->promoted))) nofl_push_block(&space->to_sweep, block); while ((block = nofl_pop_block(&space->old))) diff --git a/src/whippet.c b/src/whippet.c index 1a00939b1..05597b4f8 100644 --- a/src/whippet.c +++ b/src/whippet.c @@ -247,6 +247,7 @@ add_mutator(struct gc_heap *heap, struct gc_mutator *mut) { static void remove_mutator(struct gc_heap *heap, struct gc_mutator *mut) { + nofl_allocator_finish(&mut->allocator, heap_nofl_space(heap)); MUTATOR_EVENT(mut, mutator_removed); mut->heap = NULL; heap_lock(heap); @@ -621,7 +622,8 @@ wait_for_mutators_to_stop(struct gc_heap *heap) { pthread_cond_wait(&heap->collector_cond, &heap->lock); } -static void trace_mutator_conservative_roots_after_stop(struct gc_heap *heap) { +static void +trace_mutator_conservative_roots_after_stop(struct gc_heap *heap) { int active_mutators_already_marked = heap_should_mark_while_stopping(heap); if (!active_mutators_already_marked) for (struct gc_mutator *mut = atomic_load(&heap->mutator_trace_list); @@ -654,10 +656,8 @@ trace_mutator_roots_after_stop(struct gc_heap *heap) { } atomic_store(&heap->mutator_trace_list, NULL); - for (struct gc_mutator *mut = heap->inactive_mutators; mut; mut = mut->next) { - nofl_allocator_finish(&mut->allocator, heap_nofl_space(heap)); + for (struct gc_mutator *mut = heap->inactive_mutators; mut; mut = mut->next) trace_mutator_roots_with_lock(mut); - } } static void @@ -1323,6 +1323,7 @@ void gc_finish_for_thread(struct gc_mutator *mut) { static void deactivate_mutator(struct gc_heap *heap, struct gc_mutator *mut) { GC_ASSERT(mut->next == NULL); + nofl_allocator_finish(&mut->allocator, heap_nofl_space(heap)); heap_lock(heap); mut->next = heap->inactive_mutators; heap->inactive_mutators = mut;