1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 05:30:21 +02:00

whippet: ensure mutators release allocators before start_gc

This commit is contained in:
Andy Wingo 2024-08-24 09:09:23 +02:00
parent 19fdd481d5
commit 7db72e7f80
2 changed files with 7 additions and 6 deletions

View file

@ -944,17 +944,17 @@ nofl_space_prepare_gc(struct nofl_space *space, enum gc_collection_kind kind) {
static void static void
nofl_space_start_gc(struct nofl_space *space, enum gc_collection_kind gc_kind) { 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); 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 // Any block that was the target of allocation in the last cycle will need to
// be swept next cycle. // be swept next cycle.
uintptr_t block; 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))) while ((block = nofl_pop_block(&space->full)))
nofl_push_block(&space->to_sweep, block); nofl_push_block(&space->to_sweep, block);
if (gc_kind != GC_COLLECTION_MINOR) { if (gc_kind != GC_COLLECTION_MINOR) {
uintptr_t block;
while ((block = nofl_pop_block(&space->promoted))) while ((block = nofl_pop_block(&space->promoted)))
nofl_push_block(&space->to_sweep, block); nofl_push_block(&space->to_sweep, block);
while ((block = nofl_pop_block(&space->old))) while ((block = nofl_pop_block(&space->old)))

View file

@ -247,6 +247,7 @@ add_mutator(struct gc_heap *heap, struct gc_mutator *mut) {
static void static void
remove_mutator(struct gc_heap *heap, struct gc_mutator *mut) { remove_mutator(struct gc_heap *heap, struct gc_mutator *mut) {
nofl_allocator_finish(&mut->allocator, heap_nofl_space(heap));
MUTATOR_EVENT(mut, mutator_removed); MUTATOR_EVENT(mut, mutator_removed);
mut->heap = NULL; mut->heap = NULL;
heap_lock(heap); heap_lock(heap);
@ -621,7 +622,8 @@ wait_for_mutators_to_stop(struct gc_heap *heap) {
pthread_cond_wait(&heap->collector_cond, &heap->lock); 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); int active_mutators_already_marked = heap_should_mark_while_stopping(heap);
if (!active_mutators_already_marked) if (!active_mutators_already_marked)
for (struct gc_mutator *mut = atomic_load(&heap->mutator_trace_list); for (struct gc_mutator *mut = atomic_load(&heap->mutator_trace_list);
@ -654,11 +656,9 @@ trace_mutator_roots_after_stop(struct gc_heap *heap) {
} }
atomic_store(&heap->mutator_trace_list, NULL); atomic_store(&heap->mutator_trace_list, NULL);
for (struct gc_mutator *mut = heap->inactive_mutators; mut; mut = mut->next) { for (struct gc_mutator *mut = heap->inactive_mutators; mut; mut = mut->next)
nofl_allocator_finish(&mut->allocator, heap_nofl_space(heap));
trace_mutator_roots_with_lock(mut); trace_mutator_roots_with_lock(mut);
} }
}
static void static void
trace_global_conservative_roots(struct gc_heap *heap) { trace_global_conservative_roots(struct gc_heap *heap) {
@ -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) { static void deactivate_mutator(struct gc_heap *heap, struct gc_mutator *mut) {
GC_ASSERT(mut->next == NULL); GC_ASSERT(mut->next == NULL);
nofl_allocator_finish(&mut->allocator, heap_nofl_space(heap));
heap_lock(heap); heap_lock(heap);
mut->next = heap->inactive_mutators; mut->next = heap->inactive_mutators;
heap->inactive_mutators = mut; heap->inactive_mutators = mut;