diff --git a/libguile/whippet/api/bdw-attrs.h b/libguile/whippet/api/bdw-attrs.h index 7a68618cc..0f97c1340 100644 --- a/libguile/whippet/api/bdw-attrs.h +++ b/libguile/whippet/api/bdw-attrs.h @@ -92,4 +92,8 @@ static inline int gc_can_pin_objects(void) { return 1; } +static inline int gc_can_move_objects(void) { + return 0; +} + #endif // BDW_ATTRS_H diff --git a/libguile/whippet/api/gc-attrs.h b/libguile/whippet/api/gc-attrs.h index 1ce2c854b..eaba7f8bc 100644 --- a/libguile/whippet/api/gc-attrs.h +++ b/libguile/whippet/api/gc-attrs.h @@ -65,6 +65,7 @@ enum gc_cooperative_safepoint_kind { static inline enum gc_cooperative_safepoint_kind gc_cooperative_safepoint_kind(void) GC_ALWAYS_INLINE; static inline int gc_can_pin_objects(void) GC_ALWAYS_INLINE; +static inline int gc_can_move_objects(void) GC_ALWAYS_INLINE; #ifndef GC_IMPL #ifdef GC_ATTRS diff --git a/libguile/whippet/api/mmc-attrs.h b/libguile/whippet/api/mmc-attrs.h index 6e9b6487d..116c64036 100644 --- a/libguile/whippet/api/mmc-attrs.h +++ b/libguile/whippet/api/mmc-attrs.h @@ -35,30 +35,18 @@ static inline uint8_t gc_allocator_alloc_table_begin_pattern(enum gc_allocation_ uint8_t trace_precisely = 0; uint8_t trace_none = 8; uint8_t trace_conservatively = 16; - uint8_t pinned = 16; - if (GC_CONSERVATIVE_TRACE) { - switch (kind) { - case GC_ALLOCATION_TAGGED: - case GC_ALLOCATION_UNTAGGED_CONSERVATIVE: - return young | trace_conservatively; - case GC_ALLOCATION_TAGGED_POINTERLESS: - case GC_ALLOCATION_UNTAGGED_POINTERLESS: - return young | trace_none; - default: - GC_CRASH(); - }; - } else { - switch (kind) { - case GC_ALLOCATION_TAGGED: - return young | trace_precisely; - case GC_ALLOCATION_TAGGED_POINTERLESS: - return young | trace_none; - case GC_ALLOCATION_UNTAGGED_POINTERLESS: - return young | trace_none | pinned; - case GC_ALLOCATION_UNTAGGED_CONSERVATIVE: - default: - GC_CRASH(); - }; + switch (kind) { + case GC_ALLOCATION_TAGGED: + return young | trace_precisely; + case GC_ALLOCATION_UNTAGGED_CONSERVATIVE: + if (!GC_CONSERVATIVE_TRACE) + GC_CRASH (); + return young | trace_conservatively; + case GC_ALLOCATION_TAGGED_POINTERLESS: + case GC_ALLOCATION_UNTAGGED_POINTERLESS: + return young | trace_none; + default: + GC_CRASH(); } } static inline uint8_t gc_allocator_alloc_table_end_pattern(void) { @@ -117,4 +105,8 @@ static inline int gc_can_pin_objects(void) { return 1; } +static inline int gc_can_move_objects(void) { + return GC_CONSERVATIVE_TRACE ? 0 : 1; +} + #endif // MMC_ATTRS_H diff --git a/libguile/whippet/api/pcc-attrs.h b/libguile/whippet/api/pcc-attrs.h index d7ec30768..905b5cd05 100644 --- a/libguile/whippet/api/pcc-attrs.h +++ b/libguile/whippet/api/pcc-attrs.h @@ -89,4 +89,8 @@ static inline int gc_can_pin_objects(void) { return 0; } +static inline int gc_can_move_objects(void) { + return 1; +} + #endif // PCC_ATTRS_H diff --git a/libguile/whippet/api/semi-attrs.h b/libguile/whippet/api/semi-attrs.h index fb4d7ab91..c04de3a0d 100644 --- a/libguile/whippet/api/semi-attrs.h +++ b/libguile/whippet/api/semi-attrs.h @@ -78,4 +78,8 @@ static inline int gc_can_pin_objects(void) { return 0; } +static inline int gc_can_move_objects(void) { + return 1; +} + #endif // SEMI_ATTRS_H diff --git a/libguile/whippet/benchmarks/simple-gc-embedder.h b/libguile/whippet/benchmarks/simple-gc-embedder.h index bf9f4e91f..26fcef444 100644 --- a/libguile/whippet/benchmarks/simple-gc-embedder.h +++ b/libguile/whippet/benchmarks/simple-gc-embedder.h @@ -12,13 +12,12 @@ static inline size_t gc_finalizer_priority_count(void) { return 2; } static inline int gc_is_valid_conservative_ref_displacement(uintptr_t displacement) { -#if GC_CONSERVATIVE_ROOTS || GC_CONSERVATIVE_TRACE - // Here is where you would allow tagged heap object references. - return displacement == 0; -#else + if (GC_CONSERVATIVE_ROOTS || GC_CONSERVATIVE_TRACE) + // Here is where you would allow tagged heap object references. + return displacement == 0; + // Shouldn't get here. GC_CRASH(); -#endif } // No external objects in simple benchmarks. @@ -40,10 +39,6 @@ static inline void gc_trace_object(struct gc_ref ref, struct gc_heap *heap, void *trace_data, size_t *size) { -#if GC_CONSERVATIVE_TRACE - // Shouldn't get here. - GC_CRASH(); -#else switch (tag_live_alloc_kind(*tag_word(ref))) { #define SCAN_OBJECT(name, Name, NAME) \ case ALLOC_KIND_##NAME: \ @@ -58,7 +53,6 @@ static inline void gc_trace_object(struct gc_ref ref, default: GC_CRASH(); } -#endif } static inline void visit_roots(struct handle *roots, diff --git a/libguile/whippet/src/gc-trace.h b/libguile/whippet/src/gc-trace.h index cc1dd2808..2906d94c7 100644 --- a/libguile/whippet/src/gc-trace.h +++ b/libguile/whippet/src/gc-trace.h @@ -31,8 +31,7 @@ static inline int gc_has_conservative_roots(void) { enum gc_trace_kind { GC_TRACE_PRECISELY, GC_TRACE_NONE, - GC_TRACE_CONSERVATIVELY, - GC_TRACE_EPHEMERON, + GC_TRACE_CONSERVATIVELY }; struct gc_trace_plan { diff --git a/libguile/whippet/src/mmc.c b/libguile/whippet/src/mmc.c index 279f56278..d81a400a4 100644 --- a/libguile/whippet/src/mmc.c +++ b/libguile/whippet/src/mmc.c @@ -435,10 +435,6 @@ trace_one(struct gc_ref ref, struct gc_heap *heap, heap, worker); break; } - case GC_TRACE_EPHEMERON: - gc_trace_ephemeron(gc_ref_heap_object(ref), tracer_visit, heap, - worker); - break; default: GC_CRASH(); } @@ -1031,28 +1027,18 @@ void gc_safepoint_signal_reallow(struct gc_mutator *mut) { GC_CRASH(); } static enum gc_trace_kind compute_trace_kind(enum gc_allocation_kind kind) { - if (GC_CONSERVATIVE_TRACE) { - switch (kind) { - case GC_ALLOCATION_TAGGED: - case GC_ALLOCATION_UNTAGGED_CONSERVATIVE: - return GC_TRACE_CONSERVATIVELY; - case GC_ALLOCATION_TAGGED_POINTERLESS: - case GC_ALLOCATION_UNTAGGED_POINTERLESS: - return GC_TRACE_NONE; - default: - GC_CRASH(); - }; - } else { - switch (kind) { - case GC_ALLOCATION_TAGGED: - return GC_TRACE_PRECISELY; - case GC_ALLOCATION_TAGGED_POINTERLESS: - case GC_ALLOCATION_UNTAGGED_POINTERLESS: - return GC_TRACE_NONE; - case GC_ALLOCATION_UNTAGGED_CONSERVATIVE: - default: - GC_CRASH(); - }; + switch (kind) { + case GC_ALLOCATION_TAGGED: + return GC_TRACE_PRECISELY; + case GC_ALLOCATION_UNTAGGED_CONSERVATIVE: + if (!GC_CONSERVATIVE_TRACE) + GC_CRASH (); + return GC_TRACE_CONSERVATIVELY; + case GC_ALLOCATION_TAGGED_POINTERLESS: + case GC_ALLOCATION_UNTAGGED_POINTERLESS: + return GC_TRACE_NONE; + default: + GC_CRASH(); } } @@ -1164,11 +1150,7 @@ gc_write_barrier_slow(struct gc_mutator *mut, struct gc_ref obj, struct gc_ephemeron* gc_allocate_ephemeron(struct gc_mutator *mut) { - struct gc_ref ret = - gc_ref_from_heap_object(gc_allocate(mut, gc_ephemeron_size(), - GC_ALLOCATION_TAGGED)); - nofl_space_set_ephemeron_flag(ret); - return gc_ref_heap_object(ret); + return gc_allocate (mut, gc_ephemeron_size(), GC_ALLOCATION_TAGGED); } void @@ -1367,20 +1349,13 @@ gc_init(const struct gc_options *options, struct gc_stack_addr stack_base, GC_ASSERT_EQ(gc_allocator_alloc_table_alignment(), NOFL_SLAB_SIZE); GC_ASSERT_EQ(gc_allocator_alloc_table_begin_pattern(GC_ALLOCATION_TAGGED_POINTERLESS), NOFL_METADATA_BYTE_YOUNG | NOFL_METADATA_BYTE_TRACE_NONE); - if (GC_CONSERVATIVE_TRACE) { - GC_ASSERT_EQ(gc_allocator_alloc_table_begin_pattern(GC_ALLOCATION_TAGGED), - NOFL_METADATA_BYTE_YOUNG | NOFL_METADATA_BYTE_TRACE_CONSERVATIVELY); + GC_ASSERT_EQ(gc_allocator_alloc_table_begin_pattern(GC_ALLOCATION_TAGGED), + NOFL_METADATA_BYTE_YOUNG | NOFL_METADATA_BYTE_TRACE_PRECISELY); + if (GC_CONSERVATIVE_TRACE) GC_ASSERT_EQ(gc_allocator_alloc_table_begin_pattern(GC_ALLOCATION_UNTAGGED_CONSERVATIVE), NOFL_METADATA_BYTE_YOUNG | NOFL_METADATA_BYTE_TRACE_CONSERVATIVELY); - GC_ASSERT_EQ(gc_allocator_alloc_table_begin_pattern(GC_ALLOCATION_UNTAGGED_POINTERLESS), - NOFL_METADATA_BYTE_YOUNG | NOFL_METADATA_BYTE_TRACE_NONE); - } else { - GC_ASSERT_EQ(gc_allocator_alloc_table_begin_pattern(GC_ALLOCATION_TAGGED), - NOFL_METADATA_BYTE_YOUNG | NOFL_METADATA_BYTE_TRACE_PRECISELY); - GC_ASSERT_EQ(gc_allocator_alloc_table_begin_pattern(GC_ALLOCATION_UNTAGGED_POINTERLESS), - NOFL_METADATA_BYTE_YOUNG | NOFL_METADATA_BYTE_TRACE_NONE | - NOFL_METADATA_BYTE_PINNED); - } + GC_ASSERT_EQ(gc_allocator_alloc_table_begin_pattern(GC_ALLOCATION_UNTAGGED_POINTERLESS), + NOFL_METADATA_BYTE_YOUNG | NOFL_METADATA_BYTE_TRACE_NONE); GC_ASSERT_EQ(gc_allocator_alloc_table_end_pattern(), NOFL_METADATA_BYTE_END); if (GC_GENERATIONAL) { GC_ASSERT_EQ(gc_write_barrier_field_table_alignment(), NOFL_SLAB_SIZE); diff --git a/libguile/whippet/src/nofl-space.h b/libguile/whippet/src/nofl-space.h index 04e6ec649..b9a9b6b25 100644 --- a/libguile/whippet/src/nofl-space.h +++ b/libguile/whippet/src/nofl-space.h @@ -250,7 +250,7 @@ enum nofl_metadata_byte { NOFL_METADATA_BYTE_TRACE_PRECISELY = 0, NOFL_METADATA_BYTE_TRACE_NONE = 8, NOFL_METADATA_BYTE_TRACE_CONSERVATIVELY = 16, - NOFL_METADATA_BYTE_TRACE_EPHEMERON = 24, + NOFL_METADATA_BYTE_TRACE_UNUSED = 24, NOFL_METADATA_BYTE_TRACE_KIND_MASK = 0|8|16|24, NOFL_METADATA_BYTE_PINNED = 16, NOFL_METADATA_BYTE_END = 32, @@ -971,22 +971,6 @@ nofl_finish_sweeping(struct nofl_allocator *alloc, while (nofl_allocator_next_hole(alloc, space, 0)) {} } -static inline int -nofl_is_ephemeron(struct gc_ref ref) { - uint8_t meta = *nofl_metadata_byte_for_object(ref); - uint8_t kind = meta & NOFL_METADATA_BYTE_TRACE_KIND_MASK; - return kind == NOFL_METADATA_BYTE_TRACE_EPHEMERON; -} - -static void -nofl_space_set_ephemeron_flag(struct gc_ref ref) { - if (gc_has_conservative_intraheap_edges()) { - uint8_t *metadata = nofl_metadata_byte_for_object(ref); - uint8_t byte = *metadata & ~NOFL_METADATA_BYTE_TRACE_KIND_MASK; - *metadata = byte | NOFL_METADATA_BYTE_TRACE_EPHEMERON; - } -} - struct gc_trace_worker; static inline int @@ -1828,8 +1812,6 @@ nofl_metadata_byte_trace_kind(uint8_t byte) #if GC_CONSERVATIVE_TRACE case NOFL_METADATA_BYTE_TRACE_CONSERVATIVELY: return GC_TRACE_CONSERVATIVELY; - case NOFL_METADATA_BYTE_TRACE_EPHEMERON: - return GC_TRACE_EPHEMERON; #endif default: GC_CRASH(); @@ -1849,8 +1831,6 @@ nofl_space_object_trace_plan(struct nofl_space *space, struct gc_ref ref) { size_t granules = nofl_space_live_object_granules(loc); return (struct gc_trace_plan){ kind, granules * NOFL_GRANULE_SIZE }; } - case GC_TRACE_EPHEMERON: - return (struct gc_trace_plan){ kind, }; #endif default: GC_CRASH();