xo-gc stack: refactor + streamline.

Retiring unused Collector typealiases.
Fix #include topology.
Fix/improve write barrier setup.
This commit is contained in:
Roland Conybeare 2026-05-02 13:49:29 -04:00
commit b1d2ae6f19
17 changed files with 130 additions and 94 deletions

View file

@ -4,7 +4,7 @@
output_hpp_dir: "include/xo/alloc2", output_hpp_dir: "include/xo/alloc2",
output_impl_subdir: "gc", output_impl_subdir: "gc",
includes: [ includes: [
"<xo/alloc2/Allocator.hpp>", "<xo/alloc2/Allocator_basic.hpp>",
"<xo/alloc2/Generation.hpp>", "<xo/alloc2/Generation.hpp>",
"<xo/alloc2/role.hpp>", "<xo/alloc2/role.hpp>",
// "<cstdint>", // "<cstdint>",
@ -254,6 +254,7 @@
name: "assign_member", name: "assign_member",
doc: [ doc: [
"Assign pointer @p p_lhs to destination @p rhs, within parent allocation @p parent", "Assign pointer @p p_lhs to destination @p rhs, within parent allocation @p parent",
"DEPRECATED. Only used in MockCollector for gc unit test",
"", "",
"Require: gc not in progress", "Require: gc not in progress",
], ],

View file

@ -4,8 +4,8 @@
output_hpp_dir: "include/xo/alloc2", output_hpp_dir: "include/xo/alloc2",
output_impl_subdir: "gc", output_impl_subdir: "gc",
includes: [ includes: [
"<xo/alloc2/Allocator.hpp>", "<xo/alloc2/Allocator_basic.hpp>",
"<xo/alloc2/Collector.hpp>", // "<xo/alloc2/Collector.hpp>",
"<xo/alloc2/GCObjectVisitor.hpp>", "<xo/alloc2/GCObjectVisitor.hpp>",
"<cstdint>", "<cstdint>",
"<cstddef>", "<cstddef>",
@ -38,11 +38,11 @@
doc: ["fomo allocator type"], doc: ["fomo allocator type"],
definition: "xo::mm::AAllocator", definition: "xo::mm::AAllocator",
}, },
{ // {
name: "ACollector", // name: "ACollector",
doc: ["fomo collector type"], // doc: ["fomo collector type"],
definition: "xo::mm::ACollector", // definition: "xo::mm::ACollector",
}, // },
{ {
name: "AGCObjectVisitor", name: "AGCObjectVisitor",
doc: ["fomo collector type"], doc: ["fomo collector type"],

View file

@ -18,6 +18,4 @@
#include "gc/IGCObject_Xfer.hpp" #include "gc/IGCObject_Xfer.hpp"
#include "gc/RGCObject.hpp" #include "gc/RGCObject.hpp"
#include "gc/RCollector_aux.hpp"
/* end GCObject.hpp */ /* end GCObject.hpp */

View file

@ -18,5 +18,6 @@
#include "gc/IGCObjectVisitor_Xfer.hpp" #include "gc/IGCObjectVisitor_Xfer.hpp"
#include "gc/RGCObjectVisitor.hpp" #include "gc/RGCObjectVisitor.hpp"
#include "gc/RGCObjectVisitor_aux.hpp"
/* end GCObjectVisitor.hpp */ /* end GCObjectVisitor.hpp */

View file

@ -85,6 +85,13 @@ namespace xo {
obj<AGCObject> * p_lhs, obj<AGCObject> * p_lhs,
obj<AGCObject> rhs) noexcept; obj<AGCObject> rhs) noexcept;
// Need _drepr suffix to distinguish from .barrier_assign()
// see [RAllocator_aux.hpp] for implementation
template <typename DRepr>
void barrier_assign_drepr(void * parent,
DRepr ** lhs_data,
DRepr * rhs_data);
static bool _valid; static bool _valid;
}; };

View file

@ -38,6 +38,23 @@ namespace xo {
rhs.iface(), rhs.opaque_data()); rhs.iface(), rhs.opaque_data());
} }
template <typename Object>
template <typename DRepr>
void
RAllocator<Object>::barrier_assign_drepr(void * parent,
DRepr ** lhs_data,
DRepr * rhs_data)
{
// need to get AGCObject i/face that goes with DRepr.
obj<AGCObject,DRepr> rhs_gco(rhs_data);
this->barrier_assign_aux(parent,
nullptr /*not needed*/,
lhs_data,
rhs_gco.iface(),
rhs_data);
}
} /*namespace mm*/ } /*namespace mm*/
} /*namespace xo*/ } /*namespace xo*/

View file

@ -116,6 +116,7 @@ Return false if installation fails (e.g. memory exhausted) **/
**/ **/
virtual void request_gc(Opaque data, Generation upto) = 0; virtual void request_gc(Opaque data, Generation upto) = 0;
/** Assign pointer @p p_lhs to destination @p rhs, within parent allocation @p parent /** Assign pointer @p p_lhs to destination @p rhs, within parent allocation @p parent
DEPRECATED. Only used in MockCollector for gc unit test
Require: gc not in progress **/ Require: gc not in progress **/
virtual void assign_member(Opaque data, void * parent, obj<AGCObject> * p_lhs, obj<AGCObject> & rhs) = 0; virtual void assign_member(Opaque data, void * parent, obj<AGCObject> * p_lhs, obj<AGCObject> & rhs) = 0;

View file

@ -15,7 +15,6 @@
// includes (via {facet_includes}) // includes (via {facet_includes})
#include <xo/alloc2/Allocator_basic.hpp> #include <xo/alloc2/Allocator_basic.hpp>
#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp> #include <xo/alloc2/GCObjectVisitor.hpp>
#include <cstdint> #include <cstdint>
#include <cstddef> #include <cstddef>
@ -48,8 +47,6 @@ public:
/** fomo allocator type **/ /** fomo allocator type **/
using AAllocator = xo::mm::AAllocator; using AAllocator = xo::mm::AAllocator;
/** fomo collector type **/ /** fomo collector type **/
using ACollector = xo::mm::ACollector;
/** fomo collector type **/
using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
/** hint arg when navigating object graph **/ /** hint arg when navigating object graph **/
using VisitReason = xo::mm::VisitReason; using VisitReason = xo::mm::VisitReason;

View file

@ -9,10 +9,18 @@
* [iface_facet_any.hpp.j2] * [iface_facet_any.hpp.j2]
* 3. idl for facet methods * 3. idl for facet methods
* [idl/Collector.json5] * [idl/Collector.json5]
*
* variables:
* {facet_hpp_fname} -> Collector.hpp
* {impl_hpp_subdir} -> gc
* {facet_ns1} -> xo
* {facet_detail_subdir} -> gc
* {abstract_facet_fname} -> ACollector.hpp
**/ **/
#pragma once #pragma once
#include "ACollector.hpp"
#include <xo/alloc2/Allocator_basic.hpp> #include <xo/alloc2/Allocator_basic.hpp>
#include <xo/alloc2/Generation.hpp> #include <xo/alloc2/Generation.hpp>
#include <xo/alloc2/role.hpp> #include <xo/alloc2/role.hpp>

View file

@ -9,10 +9,18 @@
* [iface_facet_any.hpp.j2] * [iface_facet_any.hpp.j2]
* 3. idl for facet methods * 3. idl for facet methods
* [idl/GCObjectVisitor.json5] * [idl/GCObjectVisitor.json5]
*
* variables:
* {facet_hpp_fname} -> GCObjectVisitor.hpp
* {impl_hpp_subdir} -> gc
* {facet_ns1} -> xo
* {facet_detail_subdir} -> gc
* {abstract_facet_fname} -> AGCObjectVisitor.hpp
**/ **/
#pragma once #pragma once
#include "AGCObjectVisitor.hpp"
#include <xo/alloc2/Generation.hpp> #include <xo/alloc2/Generation.hpp>
#include <xo/alloc2/role.hpp> #include <xo/alloc2/role.hpp>
#include <xo/alloc2/VisitReason.hpp> #include <xo/alloc2/VisitReason.hpp>

View file

@ -46,7 +46,6 @@ namespace mm {
using typeseq = xo::facet::typeseq; using typeseq = xo::facet::typeseq;
using size_type = AGCObject::size_type; using size_type = AGCObject::size_type;
using AAllocator = AGCObject::AAllocator; using AAllocator = AGCObject::AAllocator;
using ACollector = AGCObject::ACollector;
using AGCObjectVisitor = AGCObject::AGCObjectVisitor; using AGCObjectVisitor = AGCObject::AGCObjectVisitor;
using VisitReason = AGCObject::VisitReason; using VisitReason = AGCObject::VisitReason;

View file

@ -9,12 +9,19 @@
* [iface_facet_any.hpp.j2] * [iface_facet_any.hpp.j2]
* 3. idl for facet methods * 3. idl for facet methods
* [idl/GCObject.json5] * [idl/GCObject.json5]
*
* variables:
* {facet_hpp_fname} -> GCObject.hpp
* {impl_hpp_subdir} -> gc
* {facet_ns1} -> xo
* {facet_detail_subdir} -> gc
* {abstract_facet_fname} -> AGCObject.hpp
**/ **/
#pragma once #pragma once
#include "AGCObject.hpp"
#include <xo/alloc2/Allocator_basic.hpp> #include <xo/alloc2/Allocator_basic.hpp>
#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp> #include <xo/alloc2/GCObjectVisitor.hpp>
#include <cstdint> #include <cstdint>
#include <cstddef> #include <cstddef>
@ -34,7 +41,6 @@ namespace mm {
using typeseq = AGCObject::typeseq; using typeseq = AGCObject::typeseq;
using size_type = AGCObject::size_type; using size_type = AGCObject::size_type;
using AAllocator = AGCObject::AAllocator; using AAllocator = AGCObject::AAllocator;
using ACollector = AGCObject::ACollector;
using AGCObjectVisitor = AGCObject::AGCObjectVisitor; using AGCObjectVisitor = AGCObject::AGCObjectVisitor;
using VisitReason = AGCObject::VisitReason; using VisitReason = AGCObject::VisitReason;
///@} ///@}

View file

@ -17,82 +17,6 @@ namespace xo {
class ACollector; class ACollector;
class AGCObject; class AGCObject;
/** defined here to avoid #include cycle, since
* template obj<AGCObject,DRepr> awkward to make available
* in RCollector.hpp
**/
template <typename Object>
template <typename DRepr>
void
RGCObjectVisitor<Object>::visit_child(VisitReason reason,
xo::facet::obj<AGCObject,DRepr> * p_obj)
{
this->visit_child(reason, p_obj->iface(), (void **)&(p_obj->data_));
}
template <typename Object>
template <typename DRepr>
void
RGCObjectVisitor<Object>::visit_child(VisitReason reason, DRepr ** p_repr)
{
// fetch static interface for DRepr (strip const: FacetImplementation specializations use non-const DRepr)
auto iface = xo::facet::impl_for<AGCObject, std::remove_const_t<DRepr>>();
this->visit_child(reason, &iface, (void **)p_repr);
}
template <typename Object>
template <typename AFacet, typename DRepr>
requires (!std::is_same_v<AFacet, AGCObject>)
void
RGCObjectVisitor<Object>::visit_poly_child(VisitReason reason, obj<AFacet, DRepr> * p_objs)
{
if (*p_objs) {
auto e = xo::facet::FacetRegistry::instance().variant<AGCObject,AFacet>(*p_objs);
this->visit_child(reason, e.iface(), (void **)&(p_objs->data_));
}
}
// ----- DEPRECATED -----
//
// Moving these methods to RGCObjectVisitor
/** defined here to avoid #include cycle, since
* template obj<AGCObject,DRepr> awkward to make available
* in RCollector.hpp
**/
template <typename Object>
template <typename DRepr>
void
RCollector<Object>::forward_inplace(xo::facet::obj<AGCObject,DRepr> * p_obj)
{
this->forward_inplace(p_obj->iface(), (void **)&(p_obj->data_));
}
template <typename Object>
template <typename DRepr>
void
RCollector<Object>::forward_inplace(DRepr ** p_repr)
{
// fetch static interface for DRepr (strip const: FacetImplementation specializations use non-const DRepr)
auto iface = xo::facet::impl_for<AGCObject, std::remove_const_t<DRepr>>();
this->forward_inplace(&iface, (void **)p_repr);
}
template <typename Object>
template <typename AFacet, typename DRepr>
requires (!std::is_same_v<AFacet, AGCObject>)
void
RCollector<Object>::forward_pivot_inplace(obj<AFacet, DRepr> * p_objs)
{
if (*p_objs) {
auto e = xo::facet::FacetRegistry::instance().variant<AGCObject,AFacet>(*p_objs);
this->forward_inplace(e.iface(), (void **)&(p_objs->data_));
}
}
// ----- mm_do_assign ----- // ----- mm_do_assign -----
/** gc-aware assignment; engage special book-keeping for cross-gen pointers **/ /** gc-aware assignment; engage special book-keeping for cross-gen pointers **/
@ -110,6 +34,7 @@ namespace xo {
*p_lhs = rhs; *p_lhs = rhs;
} }
}; };
} /*namespace mm*/ } /*namespace mm*/
} /*namespace xo*/ } /*namespace xo*/

View file

@ -33,7 +33,6 @@ public:
using typeseq = xo::reflect::typeseq; using typeseq = xo::reflect::typeseq;
using size_type = AGCObject::size_type; using size_type = AGCObject::size_type;
using AAllocator = AGCObject::AAllocator; using AAllocator = AGCObject::AAllocator;
using ACollector = AGCObject::ACollector;
using AGCObjectVisitor = AGCObject::AGCObjectVisitor; using AGCObjectVisitor = AGCObject::AGCObjectVisitor;
using VisitReason = AGCObject::VisitReason; using VisitReason = AGCObject::VisitReason;
///@} ///@}

View file

@ -0,0 +1,61 @@
/** @file RGCObjectVisitor_aux.hpp
*
* Out-of-line definitions for RCollector template methods
* that depend on RGCObject (avoiding #include cycle in RCollector.hpp).
*
* Included via user_hpp_includes in GCObject.json5.
*
* @author Roland Conybeare
**/
#pragma once
#include "gc/RGCObjectVisitor.hpp"
#include <xo/facet/FacetRegistry.hpp>
namespace xo {
namespace mm {
class ACollector;
class AGCObject;
/** defined here to avoid #include cycle, since
* template obj<AGCObject,DRepr> awkward to make available
* in RCollector.hpp
**/
template <typename Object>
template <typename DRepr>
void
RGCObjectVisitor<Object>::visit_child(VisitReason reason,
xo::facet::obj<AGCObject,DRepr> * p_obj)
{
this->visit_child(reason, p_obj->iface(), (void **)&(p_obj->data_));
}
template <typename Object>
template <typename DRepr>
void
RGCObjectVisitor<Object>::visit_child(VisitReason reason, DRepr ** p_repr)
{
// fetch static interface for DRepr (strip const: FacetImplementation specializations use non-const DRepr)
auto iface = xo::facet::impl_for<AGCObject, std::remove_const_t<DRepr>>();
this->visit_child(reason, &iface, (void **)p_repr);
}
template <typename Object>
template <typename AFacet, typename DRepr>
requires (!std::is_same_v<AFacet, AGCObject>)
void
RGCObjectVisitor<Object>::visit_poly_child(VisitReason reason, obj<AFacet, DRepr> * p_objs)
{
if (*p_objs) {
auto e = xo::facet::FacetRegistry::instance().variant<AGCObject,AFacet>(*p_objs);
this->visit_child(reason, e.iface(), (void **)&(p_objs->data_));
}
}
} /*namespace mm*/
} /*namespace xo*/
/* end RCollector_aux.hpp */

View file

@ -14,7 +14,7 @@
#pragma once #pragma once
// includes (via {facet_includes}) // includes (via {facet_includes})
#include "Allocator_basic.hpp" #include "Allocator.hpp"
#include <xo/facet/obj.hpp> #include <xo/facet/obj.hpp>
#include <xo/facet/facet_implementation.hpp> #include <xo/facet/facet_implementation.hpp>
#include <xo/facet/typeseq.hpp> #include <xo/facet/typeseq.hpp>

View file

@ -9,10 +9,18 @@
* [iface_facet_any.hpp.j2] * [iface_facet_any.hpp.j2]
* 3. idl for facet methods * 3. idl for facet methods
* [idl/ResourceVisitor.json5] * [idl/ResourceVisitor.json5]
*
* variables:
* {facet_hpp_fname} -> ResourceVisitor.hpp
* {impl_hpp_subdir} -> visitor
* {facet_ns1} -> xo
* {facet_detail_subdir} -> visitor
* {abstract_facet_fname} -> AResourceVisitor.hpp
**/ **/
#pragma once #pragma once
#include "AResourceVisitor.hpp"
#include "Allocator.hpp" #include "Allocator.hpp"
namespace xo { namespace xo {