refactor: + narrower interface for gc pointer forwarding

add AGCObjectVisitor, instead of requiring ACollector.
This commit is contained in:
Roland Conybeare 2026-04-05 23:53:02 -04:00
commit fdc3054c7c
46 changed files with 187 additions and 165 deletions

View file

@ -8,6 +8,7 @@
#include "Expression.hpp"
#include "TypeRef.hpp"
#include "exprtype.hpp"
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/object2/DArray.hpp>
#include <xo/reflect/TypeDescr.hpp>
#include <xo/indentlog/print/pretty.hpp>
@ -21,6 +22,7 @@ namespace xo {
class DApplyExpr {
public:
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
using ppindentinfo = xo::print::ppindentinfo;
@ -84,7 +86,7 @@ namespace xo {
std::size_t shallow_size() const noexcept;
DApplyExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-applyexpr-printable-facet **/

View file

@ -10,6 +10,7 @@
#include "exprtype.hpp"
#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/reflect/TaggedPtr.hpp>
namespace xo {
@ -22,8 +23,9 @@ namespace xo {
using TaggedPtr = xo::reflect::TaggedPtr;
using TypeDescr = xo::reflect::TypeDescr;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using AGCObject = xo::mm::AGCObject;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using typeseq = xo::reflect::typeseq;
using ppindentinfo = xo::print::ppindentinfo;
@ -64,7 +66,7 @@ namespace xo {
size_t shallow_size() const noexcept;
DConstant * shallow_move(obj<ACollector> gc) noexcept;
size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-constant-printable-facet **/

View file

@ -8,6 +8,7 @@
#include "Expression.hpp"
#include "DVariable.hpp"
#include <xo/alloc2/Allocator.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/indentlog/print/pretty.hpp>
namespace xo {
@ -24,6 +25,7 @@ namespace xo {
public:
using ppindentinfo = xo::print::ppindentinfo;
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
@ -74,7 +76,7 @@ namespace xo {
std::size_t shallow_size() const noexcept;
DDefineExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-defineexpr-printable-facet **/

View file

@ -9,6 +9,7 @@
#include "DVariable.hpp"
#include "DTypename.hpp"
#include <xo/object2/DArray.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/alloc2/dp.hpp>
#include <xo/arena/DArenaHashMap.hpp>
@ -30,8 +31,9 @@ namespace xo {
using ArenaHashMapConfig = xo::map::ArenaHashMapConfig;
using repr_type = xo::map::DArenaHashMap<key_type, Binding::slot_type>;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using AGCObject = xo::mm::AGCObject;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using MemorySizeVisitor = xo::mm::MemorySizeVisitor;
using ppindentinfo = xo::print::ppindentinfo;
using size_type = std::uint32_t;
@ -113,9 +115,8 @@ namespace xo {
/** @defgroup scm-globalsymtab-gcobject-facet gcobject facet **/
///@{
std::size_t shallow_size() const noexcept;
DGlobalSymtab * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-globalsymtab-printable-facet printable facet **/

View file

@ -9,10 +9,9 @@
#include "TypeRef.hpp"
#include "exprtype.hpp"
#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/alloc2/Allocator.hpp>
//#include <vector>
#include <string>
//#include <cstdint>
namespace xo {
namespace scm {
@ -23,6 +22,7 @@ namespace xo {
class DIfElseExpr {
public:
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
using ppindentinfo = xo::print::ppindentinfo;
@ -100,7 +100,7 @@ namespace xo {
std::size_t shallow_size() const noexcept;
DIfElseExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}

View file

@ -10,6 +10,7 @@
#include "exprtype.hpp"
#include "DLocalSymtab.hpp"
#include "DString.hpp"
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/facet/obj.hpp>
namespace xo {
@ -21,6 +22,7 @@ namespace xo {
class DLambdaExpr {
public:
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
using ppindentinfo = xo::print::ppindentinfo;
@ -86,7 +88,7 @@ namespace xo {
std::size_t shallow_size() const noexcept;
DLambdaExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-lambdaexpr-printable-facet **/

View file

@ -9,6 +9,7 @@
#include "DVariable.hpp"
#include "DUniqueString.hpp"
#include <xo/object2/DArray.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
namespace xo {
namespace scm {
@ -20,8 +21,9 @@ namespace xo {
using DArray = xo::scm::DArray;
using ppindentinfo = xo::print::ppindentinfo;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using AGCObject = xo::mm::AGCObject;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
/* note: uint16_t would be fine too */
using size_type = std::uint32_t;
@ -97,9 +99,8 @@ namespace xo {
/** @defgroup xo-localsymtab-gcobject-facet gcobject facet **/
///@{
std::size_t shallow_size() const noexcept;
DLocalSymtab * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup xo-localsymtab-printable-facet printable facet **/

View file

@ -8,6 +8,7 @@
#include "Expression.hpp"
#include "TypeRef.hpp"
#include <xo/object2/DArray.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
namespace xo {
namespace scm {
@ -23,6 +24,7 @@ namespace xo {
class DSequenceExpr {
public:
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
using size_type = DArray::size_type;
@ -74,7 +76,7 @@ namespace xo {
std::size_t shallow_size() const noexcept;
DSequenceExpr * shallow_move(obj<ACollector> gc) noexcept;
std::size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}

View file

@ -7,6 +7,7 @@
#include "DUniqueString.hpp"
#include <xo/type/Type.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/printable2/Printable.hpp>
#include <xo/indentlog/print/pretty.hpp>
@ -24,8 +25,9 @@ namespace xo {
public:
using ppindentinfo = xo::print::ppindentinfo;
using ACollector = xo::mm::ACollector;
using AAllocator = xo::mm::AAllocator;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AGCObject = xo::mm::AGCObject;
using AAllocator = xo::mm::AAllocator;
public:
DTypename(const DUniqueString * name,
@ -55,7 +57,7 @@ namespace xo {
size_t shallow_size() const noexcept;
DTypename * shallow_move(obj<ACollector> gc) noexcept;
size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-typename-printable-facet **/

View file

@ -6,6 +6,7 @@
#pragma once
#include "Variable.hpp"
#include <xo/alloc2/GCObjectVisitor.hpp>
namespace xo {
namespace scm {
@ -21,6 +22,7 @@ namespace xo {
public:
using ppindentinfo = xo::print::ppindentinfo;
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
@ -56,7 +58,7 @@ namespace xo {
size_t shallow_size() const noexcept;
DVarRef * shallow_move(obj<ACollector> gc) noexcept;
size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-variable-printable-facet **/

View file

@ -9,6 +9,7 @@
#include "Binding.hpp"
#include "TypeRef.hpp"
#include "exprtype.hpp"
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/reflect/TypeDescr.hpp>
#include <xo/indentlog/print/pretty.hpp>
@ -22,6 +23,7 @@ namespace xo {
public:
using ppindentinfo = xo::print::ppindentinfo;
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using AAllocator = xo::mm::AAllocator;
using TypeDescr = xo::reflect::TypeDescr;
@ -64,7 +66,7 @@ namespace xo {
size_t shallow_size() const noexcept;
DVariable * shallow_move(obj<ACollector> gc) noexcept;
size_t forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
///@}
/** @defgroup scm-variable-printable-facet **/

View file

@ -8,6 +8,7 @@
#include <xo/type/Type.hpp>
#include <xo/reflect/TypeDescr.hpp>
#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/flatstring/flatstring.hpp>
#include <xo/indentlog/print/pretty.hpp>
@ -26,6 +27,7 @@ namespace xo {
using type_var = flatstring<20>;
using prefix_type = flatstring<8>;
using ACollector = xo::mm::ACollector;
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
using ppindentinfo = xo::print::ppindentinfo;
public:
@ -73,7 +75,7 @@ namespace xo {
bool pretty(const ppindentinfo & ppii) const;
/** gc support **/
void forward_children(obj<ACollector> gc) noexcept;
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
private:
TypeRef(const type_var & id, TypeDescr td);

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DDefineExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DDefineExpr & self, obj<ACollector> gc) noexcept;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DDefineExpr & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DApplyExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DApplyExpr & self, obj<ACollector> gc) noexcept;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DApplyExpr & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DConstant & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DConstant & self, obj<ACollector> gc) noexcept;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DConstant & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DIfElseExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DIfElseExpr & self, obj<ACollector> gc) noexcept;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DIfElseExpr & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DLambdaExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DLambdaExpr & self, obj<ACollector> gc) noexcept;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DLambdaExpr & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DSequenceExpr & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DSequenceExpr & self, obj<ACollector> gc) noexcept;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DSequenceExpr & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DVarRef & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DVarRef & self, obj<ACollector> gc) noexcept;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DVarRef & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DGlobalSymtab & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DGlobalSymtab & self, obj<ACollector> gc) noexcept;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DGlobalSymtab & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DLocalSymtab & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DLocalSymtab & self, obj<ACollector> gc) noexcept;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DLocalSymtab & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -42,6 +42,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -52,8 +53,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DTypename & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DTypename & self, obj<ACollector> gc) noexcept;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DTypename & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};

View file

@ -44,6 +44,7 @@ namespace xo {
using size_type = xo::mm::AGCObject::size_type;
using AAllocator = xo::mm::AGCObject::AAllocator;
using ACollector = xo::mm::AGCObject::ACollector;
using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor;
using Copaque = xo::mm::AGCObject::Copaque;
using Opaque = xo::mm::AGCObject::Opaque;
///@}
@ -54,8 +55,10 @@ namespace xo {
// non-const methods
/** move instance using allocator **/
static Opaque shallow_move(DVariable & self, obj<ACollector> gc) noexcept;
/** during GC: forward immdiate children **/
static void forward_children(DVariable & self, obj<ACollector> gc) noexcept;
/** Invoke fn.visit_child(iface,data) for each child GCObject pointer.
Context: provides address of data pointer so it can be updated in place
when @p fn invokes garbage collector reentry point **/
static void visit_gco_children(DVariable & self, obj<AGCObjectVisitor> fn) noexcept;
///@}
};