1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-27 21:40:34 +02:00

gpcc: Don't mix survivors and new objects in same block

This commit is contained in:
Andy Wingo 2025-01-10 16:33:38 +01:00
parent c95b7ef046
commit 4ab72e92b0
2 changed files with 26 additions and 16 deletions

View file

@ -529,9 +529,30 @@ copy_space_flip(struct copy_space *space) {
space->in_gc = 1; space->in_gc = 1;
} }
static inline void
copy_space_allocator_init(struct copy_space_allocator *alloc) {
memset(alloc, 0, sizeof(*alloc));
}
static inline void
copy_space_allocator_finish(struct copy_space_allocator *alloc,
struct copy_space *space) {
if (alloc->block)
copy_space_allocator_release_partly_full_block(alloc, space);
}
static void static void
copy_space_finish_gc(struct copy_space *space) { copy_space_finish_gc(struct copy_space *space, int is_minor_gc) {
// Mutators stopped, can access nonatomically. // Mutators stopped, can access nonatomically.
if (is_minor_gc) {
// Avoid mixing survivors and new objects on the same blocks.
struct copy_space_allocator alloc;
copy_space_allocator_init(&alloc);
while (copy_space_allocator_acquire_partly_full_block(&alloc, space))
copy_space_allocator_release_full_block(&alloc, space);
copy_space_allocator_finish(&alloc, space);
}
space->allocated_bytes_at_last_gc = space->allocated_bytes; space->allocated_bytes_at_last_gc = space->allocated_bytes;
space->fragmentation_at_last_gc = space->fragmentation; space->fragmentation_at_last_gc = space->fragmentation;
space->in_gc = 0; space->in_gc = 0;
@ -778,18 +799,6 @@ copy_space_forget_edge(struct copy_space *space, struct gc_edge edge) {
return 1; return 1;
} }
static inline void
copy_space_allocator_init(struct copy_space_allocator *alloc) {
memset(alloc, 0, sizeof(*alloc));
}
static inline void
copy_space_allocator_finish(struct copy_space_allocator *alloc,
struct copy_space *space) {
if (alloc->block)
copy_space_allocator_release_partly_full_block(alloc, space);
}
static size_t copy_space_is_power_of_two(size_t n) { static size_t copy_space_is_power_of_two(size_t n) {
GC_ASSERT(n != 0); GC_ASSERT(n != 0);
return (n & (n - 1)) == 0; return (n & (n - 1)) == 0;

View file

@ -774,11 +774,12 @@ copy_spaces_start_gc(struct gc_heap *heap, int is_minor_gc) {
static void static void
copy_spaces_finish_gc(struct gc_heap *heap, int is_minor_gc) { copy_spaces_finish_gc(struct gc_heap *heap, int is_minor_gc) {
if (GC_GENERATIONAL) { if (GC_GENERATIONAL) {
copy_space_finish_gc(heap_new_space(heap)); copy_space_finish_gc(heap_new_space(heap), is_minor_gc);
if (!is_minor_gc) if (!is_minor_gc)
copy_space_finish_gc(heap_old_space(heap)); copy_space_finish_gc(heap_old_space(heap), 0);
} else { } else {
copy_space_finish_gc(heap_mono_space(heap)); GC_ASSERT(!is_minor_gc);
copy_space_finish_gc(heap_mono_space(heap), 0);
} }
} }