1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-17 09:10:22 +02:00

Remove gc_allocator_needs_clear

Whether the returned object needs to be cleared or not depends on a
couple things:
 - Whether the embedder actually needs the object to be cleared.
 - Whether the collector allocated the object from memory that was all
   zeroes already.

The goal of course would be to prevent clearing memory if the mutator
was just going to write all over it.  But it's hard to know statically
if the memory would have been all zeroes anyway, and in that case if you
did clear it you'd be doing double work.  In the end it's simpler to
just require collectors to clear memory in bulk.  We can revisit this
later if it is an issue.
This commit is contained in:
Andy Wingo 2025-03-07 09:32:03 +01:00
parent 3db1e48ea6
commit f1b660484e
8 changed files with 1 additions and 31 deletions

View file

@ -56,14 +56,6 @@ GC_API_ void* gc_call_without_gc(struct gc_mutator *mut, void* (*f)(void*),
GC_API_ void gc_collect(struct gc_mutator *mut,
enum gc_collection_kind requested_kind);
static inline void gc_clear_fresh_allocation(struct gc_ref obj,
size_t size) GC_ALWAYS_INLINE;
static inline void gc_clear_fresh_allocation(struct gc_ref obj,
size_t size) {
if (!gc_allocator_needs_clear()) return;
memset(gc_ref_heap_object(obj), 0, size);
}
static inline void gc_update_alloc_table(struct gc_ref obj,
size_t size) GC_ALWAYS_INLINE;
static inline void gc_update_alloc_table(struct gc_ref obj,
@ -119,7 +111,6 @@ static inline void* gc_allocate_small_fast_bump_pointer(struct gc_mutator *mut,
*hp_loc = new_hp;
gc_clear_fresh_allocation(gc_ref(hp), size);
gc_update_alloc_table(gc_ref(hp), size);
return (void*)hp;
@ -140,7 +131,6 @@ static inline void* gc_allocate_small_fast_freelist(struct gc_mutator *mut, size
*freelist_loc = *(void**)head;
gc_clear_fresh_allocation(gc_ref_from_heap_object(head), size);
gc_update_alloc_table(gc_ref_from_heap_object(head), size);
return head;