From e6c789b4e61ebf0f0eb8fc8aec6c081d7b8806f7 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sat, 4 Apr 2026 18:01:25 -0400 Subject: [PATCH] refactor: retire GCObject.shallow_copy() Collector gets this info from gc-owned object header --- .../interpreter2/vsm/IGCObject_DLocalEnv.hpp | 67 ------------------- xo-object2/include/xo/object2/DArray.hpp | 6 +- xo-object2/include/xo/object2/DBoolean.hpp | 3 +- xo-object2/include/xo/object2/DDictionary.hpp | 6 +- xo-object2/include/xo/object2/DFloat.hpp | 3 +- xo-object2/include/xo/object2/DInteger.hpp | 3 +- xo-object2/include/xo/object2/DList.hpp | 3 +- xo-object2/include/xo/object2/DStruct.hpp | 2 - xo-object2/src/object2/DArray.cpp | 10 +-- xo-object2/src/object2/DBoolean.cpp | 10 +-- xo-object2/src/object2/DDictionary.cpp | 10 +-- xo-object2/src/object2/DFloat.cpp | 10 +-- xo-object2/src/object2/DInteger.cpp | 11 +-- xo-object2/src/object2/DList.cpp | 16 +---- .../include/xo/procedure2/DPrimitive.hpp | 13 +--- .../include/xo/reader2/ParserStateMachine.hpp | 9 --- xo-reader2/src/reader2/ParserStateMachine.cpp | 13 +--- .../include/xo/stringtable2/DUniqueString.hpp | 4 +- .../src/stringtable2/DUniqueString.cpp | 10 +-- 19 files changed, 26 insertions(+), 183 deletions(-) delete mode 100644 xo-interpreter2/include/xo/interpreter2/vsm/IGCObject_DLocalEnv.hpp diff --git a/xo-interpreter2/include/xo/interpreter2/vsm/IGCObject_DLocalEnv.hpp b/xo-interpreter2/include/xo/interpreter2/vsm/IGCObject_DLocalEnv.hpp deleted file mode 100644 index 48b624d6..00000000 --- a/xo-interpreter2/include/xo/interpreter2/vsm/IGCObject_DLocalEnv.hpp +++ /dev/null @@ -1,67 +0,0 @@ -/** @file IGCObject_DLocalEnv.hpp - * - * Generated automagically from ingredients: - * 1. code generator: - * [xo-facet/codegen/genfacet] - * arguments: - * --input [idl/IGCObject_DVirtualSchematikaMachine.json5] - * 2. jinja2 template for abstract facet .hpp file: - * [iface_facet_repr.hpp.j2] - * 3. idl for facet methods - * [idl/IGCObject_DVirtualSchematikaMachine.json5] - **/ - -#pragma once - -#include "GCObject.hpp" -#include -#include -#include "DLocalEnv.hpp" - -namespace xo { namespace scm { class IGCObject_DLocalEnv; } } - -namespace xo { - namespace facet { - template <> - struct FacetImplementation - { - using ImplType = xo::mm::IGCObject_Xfer - ; - }; - } -} - -namespace xo { - namespace scm { - /** @class IGCObject_DLocalEnv - **/ - class IGCObject_DLocalEnv { - public: - /** @defgroup scm-gcobject-dlocalenv-type-traits **/ - ///@{ - using size_type = xo::mm::AGCObject::size_type; - using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; - using Copaque = xo::mm::AGCObject::Copaque; - using Opaque = xo::mm::AGCObject::Opaque; - ///@} - /** @defgroup scm-gcobject-dlocalenv-methods **/ - ///@{ - // const methods - /** memory consumption for this instance **/ - static size_type shallow_size(const DLocalEnv & self) noexcept; - /** copy instance using allocator **/ - static Opaque shallow_copy(const DLocalEnv & self, obj mm) noexcept; - - // non-const methods - /** during GC: forward immdiate children **/ - static size_type forward_children(DLocalEnv & self, obj gc) noexcept; - ///@} - }; - - } /*namespace scm*/ -} /*namespace xo*/ - -/* end */ \ No newline at end of file diff --git a/xo-object2/include/xo/object2/DArray.hpp b/xo-object2/include/xo/object2/DArray.hpp index a455046d..ac44c328 100644 --- a/xo-object2/include/xo/object2/DArray.hpp +++ b/xo-object2/include/xo/object2/DArray.hpp @@ -145,12 +145,10 @@ namespace xo { ///@} /** @defgroup darray-gcobject-methods **/ ///@{ - /** shallow memory consumption. Excludes child objects **/ - AAllocator::size_type shallow_size() const noexcept; - /** return shallow copy of this array, using memory from @p mm **/ + /** move to new address, mandated by @p gc **/ DArray * shallow_move(obj gc) noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ - AAllocator::size_type forward_children(obj gc) noexcept; + void forward_children(obj gc) noexcept; ///@} private: diff --git a/xo-object2/include/xo/object2/DBoolean.hpp b/xo-object2/include/xo/object2/DBoolean.hpp index 31bf41b7..f6374e3e 100644 --- a/xo-object2/include/xo/object2/DBoolean.hpp +++ b/xo-object2/include/xo/object2/DBoolean.hpp @@ -37,9 +37,8 @@ namespace xo { // GCObject facet - std::size_t shallow_size() const noexcept; DBoolean * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void forward_children(obj gc) noexcept; private: /** boxed boolean value **/ diff --git a/xo-object2/include/xo/object2/DDictionary.hpp b/xo-object2/include/xo/object2/DDictionary.hpp index 219e7838..8183a671 100644 --- a/xo-object2/include/xo/object2/DDictionary.hpp +++ b/xo-object2/include/xo/object2/DDictionary.hpp @@ -200,12 +200,10 @@ namespace xo { ///@} /** @defgroup ddictionary-gcobject-methods **/ ///@{ - /** shallow memory consumption. Excludes child objects **/ - AAllocator::size_type shallow_size() const noexcept; /** return shallow copy of this array, using memory from @p mm **/ DDictionary * shallow_move(obj gc) noexcept; - /** forward elements to @p gc to-space; replace originals with forarding pointers **/ - AAllocator::size_type forward_children(obj gc) noexcept; + /** forward elements to @p gc to-space; replace originals with forwarding pointers **/ + void forward_children(obj gc) noexcept; ///@} private: diff --git a/xo-object2/include/xo/object2/DFloat.hpp b/xo-object2/include/xo/object2/DFloat.hpp index 949883ab..50b0828c 100644 --- a/xo-object2/include/xo/object2/DFloat.hpp +++ b/xo-object2/include/xo/object2/DFloat.hpp @@ -34,9 +34,8 @@ namespace xo { bool pretty(const ppindentinfo & ppii) const; // GCObject facet - std::size_t shallow_size() const noexcept; DFloat * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void forward_children(obj gc) noexcept; private: diff --git a/xo-object2/include/xo/object2/DInteger.hpp b/xo-object2/include/xo/object2/DInteger.hpp index d3969b75..4105d92d 100644 --- a/xo-object2/include/xo/object2/DInteger.hpp +++ b/xo-object2/include/xo/object2/DInteger.hpp @@ -39,9 +39,8 @@ namespace xo { // GCObject facet - std::size_t shallow_size() const noexcept; DInteger * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void forward_children(obj gc) noexcept; private: /** boxed integer value **/ diff --git a/xo-object2/include/xo/object2/DList.hpp b/xo-object2/include/xo/object2/DList.hpp index 199ec6e5..4c37045b 100644 --- a/xo-object2/include/xo/object2/DList.hpp +++ b/xo-object2/include/xo/object2/DList.hpp @@ -69,9 +69,8 @@ namespace xo { /** @defgroup xo-scm-list-gcobject-facet gcobject facet **/ ///@{ - size_type shallow_size() const noexcept; DList * shallow_move(obj gc) noexcept; - size_type forward_children(obj gc) noexcept; + void forward_children(obj gc) noexcept; ///@} /** first member of list **/ diff --git a/xo-object2/include/xo/object2/DStruct.hpp b/xo-object2/include/xo/object2/DStruct.hpp index d7a7d84b..3776e376 100644 --- a/xo-object2/include/xo/object2/DStruct.hpp +++ b/xo-object2/include/xo/object2/DStruct.hpp @@ -141,8 +141,6 @@ namespace xo { ///@{ /** shallow memory consumption. Excludes child objects **/ AAllocator::size_type shallow_size() const noexcept; - /** return shallow copy of this array, using memory from @p mm **/ - DStruct * shallow_copy(obj mm) const noexcept; /** forward elements to @p gc to-space; replace originals with forarding pointers **/ AAllocator::size_type forward_children(obj gc) noexcept; ///@} diff --git a/xo-object2/src/object2/DArray.cpp b/xo-object2/src/object2/DArray.cpp index a9ed9288..4be2ff64 100644 --- a/xo-object2/src/object2/DArray.cpp +++ b/xo-object2/src/object2/DArray.cpp @@ -174,12 +174,6 @@ namespace xo { // gc hooks for IGCObject_DArray - std::size_t - DArray::shallow_size() const noexcept - { - return sizeof(DArray) + (capacity_ * sizeof(obj)); - } - DArray * DArray::shallow_move(obj gc) noexcept { @@ -203,7 +197,7 @@ namespace xo { return copy; } - std::size_t + void DArray::forward_children(obj gc) noexcept { scope log(XO_DEBUG(false)); @@ -215,8 +209,6 @@ namespace xo { gc.forward_inplace(&elt); } - - return shallow_size(); } } /*namespace scm*/ diff --git a/xo-object2/src/object2/DBoolean.cpp b/xo-object2/src/object2/DBoolean.cpp index f24429e3..2a196d55 100644 --- a/xo-object2/src/object2/DBoolean.cpp +++ b/xo-object2/src/object2/DBoolean.cpp @@ -29,22 +29,16 @@ namespace xo { (value_ ? "true" : "false")); } - size_t - DBoolean::shallow_size() const noexcept - { - return sizeof(DBoolean); - } - DBoolean * DBoolean::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - size_t + void DBoolean::forward_children(obj) noexcept { - return shallow_size(); + // no-op } diff --git a/xo-object2/src/object2/DDictionary.cpp b/xo-object2/src/object2/DDictionary.cpp index 48b0c97e..bd9ad11f 100644 --- a/xo-object2/src/object2/DDictionary.cpp +++ b/xo-object2/src/object2/DDictionary.cpp @@ -267,26 +267,18 @@ namespace xo { // ----- gcobject facet ----- - std::size_t - DDictionary::shallow_size() const noexcept - { - return sizeof(DDictionary); - } - DDictionary * DDictionary::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - std::size_t + void DDictionary::forward_children(obj gc) noexcept { gc.forward_inplace(&keys_); gc.forward_inplace(&values_); - - return this->shallow_size(); } } /*namespace scm*/ diff --git a/xo-object2/src/object2/DFloat.cpp b/xo-object2/src/object2/DFloat.cpp index c00286cc..32f3438b 100644 --- a/xo-object2/src/object2/DFloat.cpp +++ b/xo-object2/src/object2/DFloat.cpp @@ -27,22 +27,16 @@ namespace xo { return ppdetail_atomic::print_pretty(ppii, value_); } - size_t - DFloat::shallow_size() const noexcept - { - return sizeof(DFloat); - } - DFloat * DFloat::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - size_t + void DFloat::forward_children(obj) noexcept { - return shallow_size(); + // noop } } /*namespace scm*/ diff --git a/xo-object2/src/object2/DInteger.cpp b/xo-object2/src/object2/DInteger.cpp index 53625fd2..2b0a4c0c 100644 --- a/xo-object2/src/object2/DInteger.cpp +++ b/xo-object2/src/object2/DInteger.cpp @@ -27,25 +27,18 @@ namespace xo { return ppdetail_atomic::print_pretty(ppii, value_); } - size_t - DInteger::shallow_size() const noexcept - { - return sizeof(DInteger); - } - DInteger * DInteger::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - size_t + void DInteger::forward_children(obj) noexcept { - return shallow_size(); + // no-op } - } /*namespace scm*/ } /*namespace xo*/ diff --git a/xo-object2/src/object2/DList.cpp b/xo-object2/src/object2/DList.cpp index d9e53174..fbba2e3c 100644 --- a/xo-object2/src/object2/DList.cpp +++ b/xo-object2/src/object2/DList.cpp @@ -178,31 +178,19 @@ namespace xo { // ----- GCObject facet ------ - auto - DList::shallow_size() const noexcept -> size_type - { - return sizeof(DList); - } - DList * DList::shallow_move(obj gc) noexcept { return gc.std_move_for(this); } - auto - DList::forward_children(obj gc) noexcept -> size_type + void + DList::forward_children(obj gc) noexcept { //scope log(XO_DEBUG(true)); gc.forward_inplace(&head_); - //gc.forward_inplace(head_.iface(), (void **)&(head_.data_)); - gc.forward_inplace(&rest_); - //auto iface = xo::facet::impl_for(); - //gc.forward_inplace(&iface, (void **)(&rest_)); - - return this->shallow_size(); } } /*namespace scm*/ } /*namespace xo*/ diff --git a/xo-procedure2/include/xo/procedure2/DPrimitive.hpp b/xo-procedure2/include/xo/procedure2/DPrimitive.hpp index 0c386a50..6463ccd8 100644 --- a/xo-procedure2/include/xo/procedure2/DPrimitive.hpp +++ b/xo-procedure2/include/xo/procedure2/DPrimitive.hpp @@ -133,9 +133,8 @@ namespace xo { ///@} /** @defgroup scm-primitive-gcobject-facet **/ ///@{ - std::size_t shallow_size() const noexcept; Primitive * shallow_move(obj gc) noexcept; - std::size_t forward_children(obj gc) noexcept; + void forward_children(obj gc) noexcept; ///@} private: @@ -190,12 +189,6 @@ namespace xo { refrtag("fn", fn_)); } - template - std::size_t - Primitive::shallow_size() const noexcept { - return sizeof(*this); - } - template Primitive * Primitive::shallow_move(obj gc) noexcept { @@ -203,14 +196,12 @@ namespace xo { } template - std::size_t + void Primitive::forward_children(obj gc) noexcept { { auto e = type_.to_facet(); // FacetRegistry dep gc.forward_inplace(e.iface(), (void **)&(type_.data_)); } - - return this->shallow_size(); } } /*namespace scm*/ diff --git a/xo-reader2/include/xo/reader2/ParserStateMachine.hpp b/xo-reader2/include/xo/reader2/ParserStateMachine.hpp index f5001faa..cc313660 100644 --- a/xo-reader2/include/xo/reader2/ParserStateMachine.hpp +++ b/xo-reader2/include/xo/reader2/ParserStateMachine.hpp @@ -351,15 +351,6 @@ namespace xo { /** @defgroup scm-parserstatemachine-gcobject-facet gc support **/ ///@{ -#ifdef OBSOLETE - std::size_t shallow_size() const noexcept; - /** NOTE: - * ParserStateMachine only eligible to be a GC root. - * It's not eligible to reside in gc-owned space - **/ - ParserStateMachine * shallow_copy(obj mm) const noexcept; - std::size_t forward_children(obj gc) noexcept; -#endif /** update gc-aware exit pointers from this ParserStateMachine **/ void forward_children(obj gc) noexcept; diff --git a/xo-reader2/src/reader2/ParserStateMachine.cpp b/xo-reader2/src/reader2/ParserStateMachine.cpp index 984841b5..c3d92a0c 100644 --- a/xo-reader2/src/reader2/ParserStateMachine.cpp +++ b/xo-reader2/src/reader2/ParserStateMachine.cpp @@ -897,19 +897,12 @@ namespace xo { // ----- gc support ----- #ifdef OBSOLETE - std::size_t - ParserStateMachine::shallow_size() const noexcept + void + ParserStateMachine::shallow_copy(obj gc) noexcept { - return sizeof(ParserStateMachine); - } - - ParserStateMachine * - ParserStateMachine::shallow_copy(obj mm) const noexcept - { - (void)mm; + (void)gc; assert(false); - return nullptr; } #endif diff --git a/xo-stringtable2/include/xo/stringtable2/DUniqueString.hpp b/xo-stringtable2/include/xo/stringtable2/DUniqueString.hpp index c939f615..71427c48 100644 --- a/xo-stringtable2/include/xo/stringtable2/DUniqueString.hpp +++ b/xo-stringtable2/include/xo/stringtable2/DUniqueString.hpp @@ -88,13 +88,11 @@ namespace xo { /** @defgroup duniquestring-gcobject-methods gcobject facet methods **/ ///@{ - std::size_t shallow_size() const noexcept; - /** clone unique string, using memory from allocator @p mm. **/ DUniqueString * shallow_move(obj gc) noexcept; /** fixup child pointers (trivial for DUniqueString, no gc-owned children **/ - std::size_t forward_children(obj gc) noexcept; + void forward_children(obj gc) noexcept; ///@} diff --git a/xo-stringtable2/src/stringtable2/DUniqueString.cpp b/xo-stringtable2/src/stringtable2/DUniqueString.cpp index 1d107f67..43e7f1c3 100644 --- a/xo-stringtable2/src/stringtable2/DUniqueString.cpp +++ b/xo-stringtable2/src/stringtable2/DUniqueString.cpp @@ -81,12 +81,6 @@ namespace xo { return result; } - size_t - DUniqueString::shallow_size() const noexcept - { - return sizeof(DUniqueString); - } - DUniqueString * DUniqueString::shallow_move(obj gc) noexcept { @@ -114,10 +108,10 @@ namespace xo { return copy; } - size_t + void DUniqueString::forward_children(obj) noexcept { - return shallow_size(); + // no-op } } /*namespace scm*/ } /*namespace xo*/