mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-05-20 11:40:18 +02:00
Add new old-gen predicate method: check a range of addresses
This commit is contained in:
parent
d96b53facd
commit
274cf43864
6 changed files with 58 additions and 0 deletions
16
api/gc-api.h
16
api/gc-api.h
|
@ -30,6 +30,11 @@ GC_API_ int gc_init(const struct gc_options *options,
|
|||
struct gc_event_listener event_listener,
|
||||
void *event_listener_data);
|
||||
|
||||
GC_API_ struct gc_heap* gc_mutator_heap(struct gc_mutator *mut);
|
||||
|
||||
GC_API_ uintptr_t gc_small_object_nursery_low_address(struct gc_heap *heap);
|
||||
GC_API_ uintptr_t gc_small_object_nursery_high_address(struct gc_heap *heap);
|
||||
|
||||
struct gc_mutator_roots;
|
||||
GC_API_ void gc_mutator_set_roots(struct gc_mutator *mut,
|
||||
struct gc_mutator_roots *roots);
|
||||
|
@ -200,6 +205,17 @@ static inline int gc_object_is_old_generation(struct gc_mutator *mut,
|
|||
uint8_t byte = atomic_load_explicit(byte_loc, memory_order_relaxed);
|
||||
return byte & gc_old_generation_check_alloc_table_bit_pattern();
|
||||
}
|
||||
case GC_OLD_GENERATION_CHECK_SMALL_OBJECT_NURSERY: {
|
||||
struct gc_heap *heap = gc_mutator_heap(mut);
|
||||
// Note that these addresses are fixed and that the embedder might
|
||||
// want to store them somewhere or inline them into the output of
|
||||
// JIT-generated code. They may also be power-of-two aligned.
|
||||
uintptr_t low_addr = gc_small_object_nursery_low_address(heap);
|
||||
uintptr_t high_addr = gc_small_object_nursery_high_address(heap);
|
||||
uintptr_t size = high_addr - low_addr;
|
||||
uintptr_t addr = gc_ref_value(obj);
|
||||
return addr - low_addr < size;
|
||||
}
|
||||
case GC_OLD_GENERATION_CHECK_SLOW:
|
||||
return gc_object_is_old_generation_slow(mut, obj);
|
||||
default:
|
||||
|
|
|
@ -30,6 +30,7 @@ static inline int gc_allocator_needs_clear(void) GC_ALWAYS_INLINE;
|
|||
enum gc_old_generation_check_kind {
|
||||
GC_OLD_GENERATION_CHECK_NONE,
|
||||
GC_OLD_GENERATION_CHECK_ALLOC_TABLE,
|
||||
GC_OLD_GENERATION_CHECK_SMALL_OBJECT_NURSERY,
|
||||
GC_OLD_GENERATION_CHECK_SLOW
|
||||
};
|
||||
|
||||
|
|
10
src/bdw.c
10
src/bdw.c
|
@ -82,6 +82,16 @@ static inline size_t gc_inline_freelist_object_size(size_t idx) {
|
|||
return (idx + 1U) * GC_INLINE_GRANULE_BYTES;
|
||||
}
|
||||
|
||||
struct gc_heap* gc_mutator_heap(struct gc_mutator *mutator) {
|
||||
return __the_bdw_gc_heap;
|
||||
}
|
||||
uintptr_t gc_small_object_nursery_low_address(struct gc_heap *heap) {
|
||||
GC_CRASH();
|
||||
}
|
||||
uintptr_t gc_small_object_nursery_high_address(struct gc_heap *heap) {
|
||||
GC_CRASH();
|
||||
}
|
||||
|
||||
// The values of these must match the internal POINTERLESS and NORMAL
|
||||
// definitions in libgc, for which unfortunately there are no external
|
||||
// definitions. Alack.
|
||||
|
|
10
src/mmc.c
10
src/mmc.c
|
@ -104,6 +104,16 @@ mutator_heap(struct gc_mutator *mutator) {
|
|||
return mutator->heap;
|
||||
}
|
||||
|
||||
struct gc_heap* gc_mutator_heap(struct gc_mutator *mutator) {
|
||||
return mutator_heap(mutator);
|
||||
}
|
||||
uintptr_t gc_small_object_nursery_low_address(struct gc_heap *heap) {
|
||||
GC_CRASH();
|
||||
}
|
||||
uintptr_t gc_small_object_nursery_high_address(struct gc_heap *heap) {
|
||||
GC_CRASH();
|
||||
}
|
||||
|
||||
static void
|
||||
gc_trace_worker_call_with_data(void (*f)(struct gc_tracer *tracer,
|
||||
struct gc_heap *heap,
|
||||
|
|
11
src/pcc.c
11
src/pcc.c
|
@ -86,6 +86,17 @@ static inline struct gc_heap* mutator_heap(struct gc_mutator *mutator) {
|
|||
return mutator->heap;
|
||||
}
|
||||
|
||||
struct gc_heap* gc_mutator_heap(struct gc_mutator *mutator) {
|
||||
return mutator_heap(mutator);
|
||||
}
|
||||
|
||||
uintptr_t gc_small_object_nursery_low_address(struct gc_heap *heap) {
|
||||
GC_CRASH();
|
||||
}
|
||||
uintptr_t gc_small_object_nursery_high_address(struct gc_heap *heap) {
|
||||
GC_CRASH();
|
||||
}
|
||||
|
||||
static void
|
||||
gc_trace_worker_call_with_data(void (*f)(struct gc_tracer *tracer,
|
||||
struct gc_heap *heap,
|
||||
|
|
10
src/semi.c
10
src/semi.c
|
@ -81,6 +81,16 @@ static inline struct semi_space* mutator_semi_space(struct gc_mutator *mut) {
|
|||
return heap_semi_space(mutator_heap(mut));
|
||||
}
|
||||
|
||||
struct gc_heap* gc_mutator_heap(struct gc_mutator *mutator) {
|
||||
return mutator_heap(mutator);
|
||||
}
|
||||
uintptr_t gc_small_object_nursery_low_address(struct gc_heap *heap) {
|
||||
GC_CRASH();
|
||||
}
|
||||
uintptr_t gc_small_object_nursery_high_address(struct gc_heap *heap) {
|
||||
GC_CRASH();
|
||||
}
|
||||
|
||||
static uintptr_t align_up(uintptr_t addr, size_t align) {
|
||||
return (addr + align - 1) & ~(align-1);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue