mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-10 05:50:26 +02:00
Refactor copy_space_forward to take src and dst spaces
This commit is contained in:
parent
274cf43864
commit
4f8c7bef61
2 changed files with 13 additions and 12 deletions
|
@ -483,7 +483,6 @@ static inline int
|
||||||
copy_space_forward_atomic(struct copy_space *space, struct gc_edge edge,
|
copy_space_forward_atomic(struct copy_space *space, struct gc_edge edge,
|
||||||
struct gc_ref old_ref,
|
struct gc_ref old_ref,
|
||||||
struct copy_space_allocator *alloc) {
|
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);
|
struct gc_atomic_forward fwd = gc_atomic_forward_begin(old_ref);
|
||||||
|
|
||||||
if (fwd.state == GC_FORWARDING_STATE_NOT_FORWARDED)
|
if (fwd.state == GC_FORWARDING_STATE_NOT_FORWARDED)
|
||||||
|
@ -532,7 +531,6 @@ static int
|
||||||
copy_space_forward_if_traced_atomic(struct copy_space *space,
|
copy_space_forward_if_traced_atomic(struct copy_space *space,
|
||||||
struct gc_edge edge,
|
struct gc_edge edge,
|
||||||
struct gc_ref old_ref) {
|
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);
|
struct gc_atomic_forward fwd = gc_atomic_forward_begin(old_ref);
|
||||||
switch (fwd.state) {
|
switch (fwd.state) {
|
||||||
case GC_FORWARDING_STATE_NOT_FORWARDED:
|
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,
|
copy_space_forward_nonatomic(struct copy_space *space, struct gc_edge edge,
|
||||||
struct gc_ref old_ref,
|
struct gc_ref old_ref,
|
||||||
struct copy_space_allocator *alloc) {
|
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);
|
uintptr_t forwarded = gc_object_forwarded_nonatomic(old_ref);
|
||||||
if (forwarded) {
|
if (forwarded) {
|
||||||
gc_edge_update(edge, gc_ref(forwarded));
|
gc_edge_update(edge, gc_ref(forwarded));
|
||||||
|
@ -582,7 +578,6 @@ static int
|
||||||
copy_space_forward_if_traced_nonatomic(struct copy_space *space,
|
copy_space_forward_if_traced_nonatomic(struct copy_space *space,
|
||||||
struct gc_edge edge,
|
struct gc_edge edge,
|
||||||
struct gc_ref old_ref) {
|
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);
|
uintptr_t forwarded = gc_object_forwarded_nonatomic(old_ref);
|
||||||
if (forwarded) {
|
if (forwarded) {
|
||||||
gc_edge_update(edge, gc_ref(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
|
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 gc_ref old_ref,
|
||||||
struct copy_space_allocator *alloc) {
|
struct copy_space_allocator *dst_alloc) {
|
||||||
if (GC_PARALLEL && space->atomic_forward)
|
GC_ASSERT(copy_space_contains(src_space, old_ref));
|
||||||
return copy_space_forward_atomic(space, edge, old_ref, alloc);
|
GC_ASSERT(src_space != dst_space
|
||||||
return copy_space_forward_nonatomic(space, edge, old_ref, alloc);
|
|| 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
|
static inline int
|
||||||
copy_space_forward_if_traced(struct copy_space *space, struct gc_edge edge,
|
copy_space_forward_if_traced(struct copy_space *space, struct gc_edge edge,
|
||||||
struct gc_ref old_ref) {
|
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)
|
if (GC_PARALLEL && space->atomic_forward)
|
||||||
return copy_space_forward_if_traced_atomic(space, edge, old_ref);
|
return copy_space_forward_if_traced_atomic(space, edge, old_ref);
|
||||||
return copy_space_forward_if_traced_nonatomic(space, edge, old_ref);
|
return copy_space_forward_if_traced_nonatomic(space, edge, old_ref);
|
||||||
|
|
|
@ -115,8 +115,8 @@ static inline int do_trace(struct gc_heap *heap, struct gc_edge edge,
|
||||||
struct gc_ref ref,
|
struct gc_ref ref,
|
||||||
struct gc_trace_worker_data *data) {
|
struct gc_trace_worker_data *data) {
|
||||||
if (GC_LIKELY(copy_space_contains(heap_copy_space(heap), ref)))
|
if (GC_LIKELY(copy_space_contains(heap_copy_space(heap), ref)))
|
||||||
return copy_space_forward(heap_copy_space(heap), edge, ref,
|
return copy_space_forward(heap_copy_space(heap), heap_copy_space(heap),
|
||||||
&data->allocator);
|
edge, ref, &data->allocator);
|
||||||
else if (large_object_space_contains(heap_large_object_space(heap), ref))
|
else if (large_object_space_contains(heap_large_object_space(heap), ref))
|
||||||
return large_object_space_mark_object(heap_large_object_space(heap), ref);
|
return large_object_space_mark_object(heap_large_object_space(heap), ref);
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue