wingo pushed a commit to branch wip-whippet
in repository guile.

commit 3c8c956f4cb42c8ee984f92f022934a22011fcb8
Author: Andy Wingo <wi...@igalia.com>
AuthorDate: Fri Oct 4 13:49:27 2024 +0200

    Add gc_edge_address
---
 api/gc-edge.h            | 3 +++
 src/large-object-space.h | 2 +-
 src/nofl-space.h         | 6 +++---
 3 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/api/gc-edge.h b/api/gc-edge.h
index 72d7b3e5b..ec487df9d 100644
--- a/api/gc-edge.h
+++ b/api/gc-edge.h
@@ -16,6 +16,9 @@ static inline struct gc_ref gc_edge_ref(struct gc_edge edge) {
 static inline struct gc_ref* gc_edge_loc(struct gc_edge edge) {
   return edge.dst;
 }
+static inline uintptr_t gc_edge_address(struct gc_edge edge) {
+  return (uintptr_t)gc_edge_loc(edge);
+}
 static inline void gc_edge_update(struct gc_edge edge, struct gc_ref ref) {
   *edge.dst = ref;
 }
diff --git a/src/large-object-space.h b/src/large-object-space.h
index 4c7277797..44f4095f2 100644
--- a/src/large-object-space.h
+++ b/src/large-object-space.h
@@ -152,7 +152,7 @@ static int large_object_space_remember_edge(struct 
large_object_space *space,
                                             struct gc_ref obj,
                                             struct gc_edge edge) {
   int remembered = 0;
-  uintptr_t edge_addr = (uintptr_t)gc_edge_loc(edge);
+  uintptr_t edge_addr = gc_edge_address(edge);
   pthread_mutex_lock(&space->lock);
   if (large_object_space_is_survivor_with_lock(space, obj)
       && !address_set_contains(&space->remembered_edges, edge_addr)) {
diff --git a/src/nofl-space.h b/src/nofl-space.h
index bc5144205..7bf818cbe 100644
--- a/src/nofl-space.h
+++ b/src/nofl-space.h
@@ -925,7 +925,7 @@ nofl_space_contains(struct nofl_space *space, struct gc_ref 
ref) {
 
 static inline int
 nofl_space_contains_edge(struct nofl_space *space, struct gc_edge edge) {
-  return nofl_space_contains_address(space, (uintptr_t)gc_edge_loc(edge));
+  return nofl_space_contains_address(space, gc_edge_address(edge));
 }  
 
 static inline int
@@ -939,13 +939,13 @@ nofl_space_is_survivor(struct nofl_space *space, struct 
gc_ref ref) {
 
 static uint8_t*
 nofl_field_logged_byte(struct gc_edge edge) {
-  return nofl_metadata_byte_for_addr((uintptr_t)gc_edge_loc(edge));
+  return nofl_metadata_byte_for_addr(gc_edge_address(edge));
 }
 
 static uint8_t
 nofl_field_logged_bit(struct gc_edge edge) {
   GC_ASSERT_EQ(sizeof(uintptr_t) * 2, NOFL_GRANULE_SIZE);
-  size_t field = ((uintptr_t)gc_edge_loc(edge)) / sizeof(uintptr_t);
+  size_t field = gc_edge_address(edge) / sizeof(uintptr_t);
   return NOFL_METADATA_BYTE_LOGGED_0 << (field % 2);
 }
 

Reply via email to