1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-30 11:50:28 +02:00

Fix some corner cases with hole zeroing of empty blocks

This commit is contained in:
Andy Wingo 2024-08-23 21:20:40 +02:00
parent d137e1397c
commit 19fdd481d5

View file

@ -676,8 +676,13 @@ nofl_allocator_next_hole(struct nofl_allocator *alloc,
if (nofl_push_evacuation_target_if_possible(space, block)) if (nofl_push_evacuation_target_if_possible(space, block))
continue; continue;
// Otherwise give the block to the allocator.
struct nofl_block_summary *summary = nofl_block_summary_for_addr(block); struct nofl_block_summary *summary = nofl_block_summary_for_addr(block);
if (nofl_block_summary_has_flag(summary, NOFL_BLOCK_ZERO))
nofl_block_summary_clear_flag(summary, NOFL_BLOCK_ZERO);
else
nofl_clear_memory(block, NOFL_BLOCK_SIZE);
// Otherwise give the block to the allocator.
summary->hole_count = 1; summary->hole_count = 1;
summary->free_granules = NOFL_GRANULES_PER_BLOCK; summary->free_granules = NOFL_GRANULES_PER_BLOCK;
summary->holes_with_fragmentation = 0; summary->holes_with_fragmentation = 0;
@ -1073,7 +1078,7 @@ nofl_space_verify_empty_blocks(struct nofl_space *space,
uint8_t *meta = nofl_metadata_byte_for_addr(addr); uint8_t *meta = nofl_metadata_byte_for_addr(addr);
while (addr < limit) { while (addr < limit) {
GC_ASSERT_EQ(*meta, 0); GC_ASSERT_EQ(*meta, 0);
if (paged_in) { if (paged_in && nofl_block_summary_has_flag(summary, NOFL_BLOCK_ZERO)) {
char zeroes[NOFL_GRANULE_SIZE] = { 0, }; char zeroes[NOFL_GRANULE_SIZE] = { 0, };
GC_ASSERT_EQ(memcmp((char*)addr, zeroes, NOFL_GRANULE_SIZE), 0); GC_ASSERT_EQ(memcmp((char*)addr, zeroes, NOFL_GRANULE_SIZE), 0);
} }