1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-09 21:40:33 +02:00

Refactor copy_space_forward to take src and dst spaces

This commit is contained in:
Andy Wingo 2024-12-10 09:40:49 +01:00
parent 274cf43864
commit 4f8c7bef61
2 changed files with 13 additions and 12 deletions

View file

@ -483,7 +483,6 @@ static inline int
copy_space_forward_atomic(struct copy_space *space, struct gc_edge edge,
struct gc_ref old_ref,
struct copy_space_allocator *alloc) {
GC_ASSERT(copy_space_object_region(old_ref) != space->active_region);
struct gc_atomic_forward fwd = gc_atomic_forward_begin(old_ref);
if (fwd.state == GC_FORWARDING_STATE_NOT_FORWARDED)
@ -532,7 +531,6 @@ static int
copy_space_forward_if_traced_atomic(struct copy_space *space,
struct gc_edge edge,
struct gc_ref old_ref) {
GC_ASSERT(copy_space_object_region(old_ref) != space->active_region);
struct gc_atomic_forward fwd = gc_atomic_forward_begin(old_ref);
switch (fwd.state) {
case GC_FORWARDING_STATE_NOT_FORWARDED:
@ -559,8 +557,6 @@ static inline int
copy_space_forward_nonatomic(struct copy_space *space, struct gc_edge edge,
struct gc_ref old_ref,
struct copy_space_allocator *alloc) {
GC_ASSERT(copy_space_object_region(old_ref) != space->active_region);
uintptr_t forwarded = gc_object_forwarded_nonatomic(old_ref);
if (forwarded) {
gc_edge_update(edge, gc_ref(forwarded));
@ -582,7 +578,6 @@ static int
copy_space_forward_if_traced_nonatomic(struct copy_space *space,
struct gc_edge edge,
struct gc_ref old_ref) {
GC_ASSERT(copy_space_object_region(old_ref) != space->active_region);
uintptr_t forwarded = gc_object_forwarded_nonatomic(old_ref);
if (forwarded) {
gc_edge_update(edge, gc_ref(forwarded));
@ -592,17 +587,23 @@ copy_space_forward_if_traced_nonatomic(struct copy_space *space,
}
static inline int
copy_space_forward(struct copy_space *space, struct gc_edge edge,
copy_space_forward(struct copy_space *src_space, struct copy_space *dst_space,
struct gc_edge edge,
struct gc_ref old_ref,
struct copy_space_allocator *alloc) {
if (GC_PARALLEL && space->atomic_forward)
return copy_space_forward_atomic(space, edge, old_ref, alloc);
return copy_space_forward_nonatomic(space, edge, old_ref, alloc);
struct copy_space_allocator *dst_alloc) {
GC_ASSERT(copy_space_contains(src_space, old_ref));
GC_ASSERT(src_space != dst_space
|| copy_space_object_region(old_ref) != src_space->active_region);
if (GC_PARALLEL && src_space->atomic_forward)
return copy_space_forward_atomic(dst_space, edge, old_ref, dst_alloc);
return copy_space_forward_nonatomic(dst_space, edge, old_ref, dst_alloc);
}
static inline int
copy_space_forward_if_traced(struct copy_space *space, struct gc_edge edge,
struct gc_ref old_ref) {
GC_ASSERT(copy_space_contains(space, old_ref));
GC_ASSERT(copy_space_object_region(old_ref) != space->active_region);
if (GC_PARALLEL && space->atomic_forward)
return copy_space_forward_if_traced_atomic(space, edge, old_ref);
return copy_space_forward_if_traced_nonatomic(space, edge, old_ref);

View file

@ -115,8 +115,8 @@ static inline int do_trace(struct gc_heap *heap, struct gc_edge edge,
struct gc_ref ref,
struct gc_trace_worker_data *data) {
if (GC_LIKELY(copy_space_contains(heap_copy_space(heap), ref)))
return copy_space_forward(heap_copy_space(heap), edge, ref,
&data->allocator);
return copy_space_forward(heap_copy_space(heap), heap_copy_space(heap),
edge, ref, &data->allocator);
else if (large_object_space_contains(heap_large_object_space(heap), ref))
return large_object_space_mark_object(heap_large_object_space(heap), ref);
else