mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-03 18:50:19 +02:00
Add gc_heap_contains API
This commit is contained in:
parent
c9063b8027
commit
c7fe77de0e
5 changed files with 29 additions and 0 deletions
|
@ -59,6 +59,8 @@ 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);
|
||||
|
||||
GC_API_ int gc_heap_contains(struct gc_heap *heap, struct gc_ref ref);
|
||||
|
||||
static inline void gc_update_alloc_table(struct gc_ref obj, size_t size,
|
||||
enum gc_allocation_kind kind) GC_ALWAYS_INLINE;
|
||||
static inline void gc_update_alloc_table(struct gc_ref obj, size_t size,
|
||||
|
|
|
@ -187,6 +187,11 @@ void gc_collect(struct gc_mutator *mut,
|
|||
}
|
||||
}
|
||||
|
||||
int gc_heap_contains(struct gc_heap *heap, struct gc_ref ref) {
|
||||
GC_ASSERT(gc_ref_is_heap_object(ref));
|
||||
return GC_base(gc_ref_heap_object(ref)) != 0;
|
||||
}
|
||||
|
||||
int gc_object_is_old_generation_slow(struct gc_mutator *mut,
|
||||
struct gc_ref obj) {
|
||||
return 0;
|
||||
|
|
|
@ -844,6 +844,13 @@ gc_collect(struct gc_mutator *mut, enum gc_collection_kind kind) {
|
|||
trigger_collection(mut, kind);
|
||||
}
|
||||
|
||||
int
|
||||
gc_heap_contains(struct gc_heap *heap, struct gc_ref ref) {
|
||||
GC_ASSERT(gc_ref_is_heap_object(ref));
|
||||
return nofl_space_contains(heap_nofl_space(heap), ref)
|
||||
|| large_object_space_contains(heap_large_object_space(heap), ref);
|
||||
}
|
||||
|
||||
int*
|
||||
gc_safepoint_flag_loc(struct gc_mutator *mut) {
|
||||
return &mutator_heap(mut)->collecting;
|
||||
|
|
|
@ -965,6 +965,14 @@ void gc_collect(struct gc_mutator *mut, enum gc_collection_kind kind) {
|
|||
trigger_collection(mut, kind);
|
||||
}
|
||||
|
||||
int gc_heap_contains(struct gc_heap *heap, struct gc_ref ref) {
|
||||
GC_ASSERT(gc_ref_is_heap_object(ref));
|
||||
return (GC_GENERATIONAL
|
||||
? (new_space_contains(heap, ref) || old_space_contains(heap, ref))
|
||||
: copy_space_contains(heap_mono_space(heap), ref))
|
||||
|| large_object_space_contains(heap_large_object_space(heap), ref);
|
||||
}
|
||||
|
||||
static void* allocate_large(struct gc_mutator *mut, size_t size) {
|
||||
struct gc_heap *heap = mutator_heap(mut);
|
||||
struct large_object_space *space = heap_large_object_space(heap);
|
||||
|
|
|
@ -468,6 +468,13 @@ void gc_collect(struct gc_mutator *mut,
|
|||
collect(mut);
|
||||
}
|
||||
|
||||
int
|
||||
gc_heap_contains(struct gc_heap *heap, struct gc_ref ref) {
|
||||
GC_ASSERT(gc_ref_is_heap_object(ref));
|
||||
return semi_space_contains(heap_semi_space(heap), ref)
|
||||
|| large_object_space_contains(heap_large_object_space(heap), ref);
|
||||
}
|
||||
|
||||
int gc_object_is_old_generation_slow(struct gc_mutator *mut,
|
||||
struct gc_ref obj) {
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue