From b9e4a36d472cb7e9576ed2b53658e1a4af266f5e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Mon, 6 Apr 2026 23:18:45 -0400 Subject: [PATCH] refactor: xo-gc: + GCObjectVisitor.generation_of() Concession to narrow MutationLogStore to only use GCObjectVisitor instead of assuming X1Collector. --- include/xo/gc/detail/IGCObjectVisitor_DX1Collector.hpp | 3 +++ src/gc/MutationLogStore.cpp | 8 ++++---- src/gc/facet/IGCObjectVisitor_DX1Collector.cpp | 6 ++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/include/xo/gc/detail/IGCObjectVisitor_DX1Collector.hpp b/include/xo/gc/detail/IGCObjectVisitor_DX1Collector.hpp index ce01500..d1c0922 100644 --- a/include/xo/gc/detail/IGCObjectVisitor_DX1Collector.hpp +++ b/include/xo/gc/detail/IGCObjectVisitor_DX1Collector.hpp @@ -48,6 +48,9 @@ namespace xo { /** allocation metadata for gc-aware data at address @p gco. @p gco must be the result of a call to collector's alloc() function **/ static AllocInfo alloc_info(const DX1Collector & self, void * addr); + /** generation to which pointer @p addr belongs, given role @p r; +sentinel if @p addr is not owned by collector **/ + static Generation generation_of(const DX1Collector & self, role r, const void * addr) noexcept; // non-const methods /** allocate copy of source object at address @p src. diff --git a/src/gc/MutationLogStore.cpp b/src/gc/MutationLogStore.cpp index b96e298..24cbf86 100644 --- a/src/gc/MutationLogStore.cpp +++ b/src/gc/MutationLogStore.cpp @@ -376,8 +376,8 @@ namespace xo { /* here: mlog current */ - Generation parent_gen_to = gc->generation_of(role::to_space(), - from_entry.parent()); + Generation parent_gen_to = gc.generation_of(role::to_space(), + from_entry.parent()); if (parent_gen_to.is_sentinel()) { void * parent_fr = *from_entry.p_data(); @@ -393,8 +393,8 @@ namespace xo { // TODO: method on AllocInfo to streamline this void * parent_to = *(void **)parent_fr; - parent_gen_to = gc->generation_of(role::to_space(), - parent_to); + parent_gen_to = gc.generation_of(role::to_space(), + parent_to); parent_info = gc.alloc_info((std::byte *)parent_to); assert(!parent_gen_to.sentinel()); diff --git a/src/gc/facet/IGCObjectVisitor_DX1Collector.cpp b/src/gc/facet/IGCObjectVisitor_DX1Collector.cpp index 5dd9d3d..129ba42 100644 --- a/src/gc/facet/IGCObjectVisitor_DX1Collector.cpp +++ b/src/gc/facet/IGCObjectVisitor_DX1Collector.cpp @@ -21,6 +21,12 @@ namespace xo { return self.alloc_info(addr); } + auto + IGCObjectVisitor_DX1Collector::generation_of(const DX1Collector & self, role r, const void * addr) noexcept -> Generation + { + return self.generation_of(r, addr); + } + auto IGCObjectVisitor_DX1Collector::alloc_copy(DX1Collector & self, std::byte * src) -> void * {