1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-04-29 19:30:36 +02:00

For freelist allocators, clear the freelist link on the returned obj

* api/gc-api.h (gc_allocate_small_fast_freelist):
* src/bdw.c (allocate_small): Clear freelist link, so the object is
completely zeroed.  In some cases the embedder / compiler / JIT will be
able to elide this write.
This commit is contained in:
Andy Wingo 2025-04-23 16:44:59 +02:00
parent e2b75d302d
commit 06b53470f4
2 changed files with 2 additions and 0 deletions

View file

@ -140,6 +140,7 @@ static inline void* gc_allocate_small_fast_freelist(struct gc_mutator *mut,
return NULL;
*freelist_loc = *(void**)head;
*(void**)head = NULL;
gc_update_alloc_table(gc_ref_from_heap_object(head), size, kind);

View file

@ -122,6 +122,7 @@ allocate_small(void **freelist, size_t idx, enum gc_inline_kind kind) {
}
*freelist = *(void **)(head);
*(void**)head = NULL;
if (kind == GC_INLINE_KIND_POINTERLESS)
memset(head, 0, gc_inline_freelist_object_size(idx));