1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-27 13:30:31 +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;
}
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
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.
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->fragmentation_at_last_gc = space->fragmentation;
space->in_gc = 0;
@ -778,18 +799,6 @@ copy_space_forget_edge(struct copy_space *space, struct gc_edge edge) {
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) {
GC_ASSERT(n != 0);
return (n & (n - 1)) == 0;