1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-05-18 10:10:23 +02:00

Change gc_allocate_ephemeron to return struct gc_ephemeron

This commit is contained in:
Andy Wingo 2023-09-11 11:48:32 +02:00
parent db36c48efd
commit dc013cfb58
5 changed files with 10 additions and 11 deletions

View file

@ -18,7 +18,7 @@ struct gc_mutator;
struct gc_ephemeron; struct gc_ephemeron;
GC_API_ size_t gc_ephemeron_size(void); GC_API_ size_t gc_ephemeron_size(void);
GC_API_ struct gc_ref gc_allocate_ephemeron(struct gc_mutator *mut); GC_API_ struct gc_ephemeron* gc_allocate_ephemeron(struct gc_mutator *mut);
GC_API_ void gc_ephemeron_init(struct gc_mutator *mut, GC_API_ void gc_ephemeron_init(struct gc_mutator *mut,
struct gc_ephemeron *ephemeron, struct gc_ephemeron *ephemeron,
struct gc_ref key, struct gc_ref value); struct gc_ref key, struct gc_ref value);

View file

@ -25,9 +25,9 @@ static Box* allocate_box(struct gc_mutator *mut) {
} }
static struct gc_ephemeron* allocate_ephemeron(struct gc_mutator *mut) { static struct gc_ephemeron* allocate_ephemeron(struct gc_mutator *mut) {
struct gc_ref ret = gc_allocate_ephemeron(mut); struct gc_ephemeron *ret = gc_allocate_ephemeron(mut);
*tag_word(ret) = tag_live(ALLOC_KIND_EPHEMERON); *tag_word(gc_ref_from_heap_object(ret)) = tag_live(ALLOC_KIND_EPHEMERON);
return gc_ref_heap_object(ret); return ret;
} }
/* Get the current time in microseconds */ /* Get the current time in microseconds */

View file

@ -131,9 +131,8 @@ void gc_write_barrier_extern(struct gc_ref obj, size_t obj_size,
static int ephemeron_gc_kind; static int ephemeron_gc_kind;
struct gc_ref gc_allocate_ephemeron(struct gc_mutator *mut) { struct gc_ephemeron* gc_allocate_ephemeron(struct gc_mutator *mut) {
void *ret = GC_generic_malloc(gc_ephemeron_size(), ephemeron_gc_kind); return GC_generic_malloc(gc_ephemeron_size(), ephemeron_gc_kind);
return gc_ref_from_heap_object(ret);
} }
unsigned gc_heap_ephemeron_trace_epoch(struct gc_heap *heap) { unsigned gc_heap_ephemeron_trace_epoch(struct gc_heap *heap) {

View file

@ -445,8 +445,8 @@ void* gc_allocate_pointerless(struct gc_mutator *mut, size_t size) {
return gc_allocate(mut, size); return gc_allocate(mut, size);
} }
struct gc_ref gc_allocate_ephemeron(struct gc_mutator *mut) { struct gc_ephemeron* gc_allocate_ephemeron(struct gc_mutator *mut) {
return gc_ref_from_heap_object(gc_allocate(mut, gc_ephemeron_size())); return gc_allocate(mut, gc_ephemeron_size());
} }
void gc_ephemeron_init(struct gc_mutator *mut, struct gc_ephemeron *ephemeron, void gc_ephemeron_init(struct gc_mutator *mut, struct gc_ephemeron *ephemeron,

View file

@ -2200,14 +2200,14 @@ void* gc_allocate_pointerless(struct gc_mutator *mut, size_t size) {
return gc_allocate(mut, size); return gc_allocate(mut, size);
} }
struct gc_ref gc_allocate_ephemeron(struct gc_mutator *mut) { struct gc_ephemeron* gc_allocate_ephemeron(struct gc_mutator *mut) {
struct gc_ref ret = struct gc_ref ret =
gc_ref_from_heap_object(gc_allocate(mut, gc_ephemeron_size())); gc_ref_from_heap_object(gc_allocate(mut, gc_ephemeron_size()));
if (gc_has_conservative_intraheap_edges()) { if (gc_has_conservative_intraheap_edges()) {
uint8_t *metadata = metadata_byte_for_addr(gc_ref_value(ret)); uint8_t *metadata = metadata_byte_for_addr(gc_ref_value(ret));
*metadata |= METADATA_BYTE_EPHEMERON; *metadata |= METADATA_BYTE_EPHEMERON;
} }
return ret; return gc_ref_heap_object(ret);
} }
void gc_ephemeron_init(struct gc_mutator *mut, struct gc_ephemeron *ephemeron, void gc_ephemeron_init(struct gc_mutator *mut, struct gc_ephemeron *ephemeron,