From 48cb87bcb9ddb6f1dac92d123d70c33fc246ff3e Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 27 Mar 2026 20:56:46 -0400 Subject: [PATCH] xo-alloc2: + ACollector2 temporary, planning to codegen Collector facet --- xo-alloc2/CMakeLists.txt | 10 +- xo-alloc2/idl/Collector2.json5 | 222 ++++++++++++++++++ xo-alloc2/include/xo/alloc2/Collector2.hpp | 22 ++ xo-alloc2/include/xo/alloc2/gc/ACollector.hpp | 1 - .../include/xo/alloc2/gc/ACollector2.hpp | 126 ++++++++++ .../include/xo/alloc2/gc/ICollector2_Any.hpp | 99 ++++++++ .../include/xo/alloc2/gc/ICollector2_Xfer.hpp | 116 +++++++++ .../include/xo/alloc2/gc/RCollector2.hpp | 115 +++++++++ xo-alloc2/src/alloc2/CMakeLists.txt | 2 + .../src/alloc2/facet/ICollector2_Any.cpp | 78 ++++++ xo-procedure2/src/procedure2/GcPrimitives.cpp | 23 ++ 11 files changed, 812 insertions(+), 2 deletions(-) create mode 100644 xo-alloc2/idl/Collector2.json5 create mode 100644 xo-alloc2/include/xo/alloc2/Collector2.hpp create mode 100644 xo-alloc2/include/xo/alloc2/gc/ACollector2.hpp create mode 100644 xo-alloc2/include/xo/alloc2/gc/ICollector2_Any.hpp create mode 100644 xo-alloc2/include/xo/alloc2/gc/ICollector2_Xfer.hpp create mode 100644 xo-alloc2/include/xo/alloc2/gc/RCollector2.hpp create mode 100644 xo-alloc2/src/alloc2/facet/ICollector2_Any.cpp diff --git a/xo-alloc2/CMakeLists.txt b/xo-alloc2/CMakeLists.txt index 702f6e55..79323a6a 100644 --- a/xo-alloc2/CMakeLists.txt +++ b/xo-alloc2/CMakeLists.txt @@ -18,9 +18,17 @@ add_definitions(${PROJECT_CXX_FLAGS}) # ---------------------------------------------------------------- +xo_add_genfacet( + TARGET xo-alloc2-facet-collector2 + FACET Collector2 + INPUT idl/Collector2.json5 +) + +# ---------------------------------------------------------------- + # note: manual target; generated code committed to git xo_add_genfacet( - TARGET xo-gc-facet-gcobject + TARGET xo-alloc2-facet-gcobject FACET GCObject INPUT idl/GCObject.json5 ) diff --git a/xo-alloc2/idl/Collector2.json5 b/xo-alloc2/idl/Collector2.json5 new file mode 100644 index 00000000..7bc94577 --- /dev/null +++ b/xo-alloc2/idl/Collector2.json5 @@ -0,0 +1,222 @@ +{ + mode: "facet", + output_cpp_dir: "src/alloc2/facet", + output_hpp_dir: "include/xo/alloc2", + output_impl_subdir: "gc", + includes: [ + "", + "", + "", +// "", +// "", + ], + // extra includes in GCObject.hpp, if any + user_hpp_includes: [ + // "\"gc/RCollector_aux.hpp\"", // not usable here, + ], + namespace1: "xo", + namespace2: "mm", + pretext: [ + "class AGCObject;", + "// more pretext here..", + ], + facet: "Collector2", + detail_subdir: "gc", + brief: "garbage collector interface", + using_doxygen: true, + doc: [ + "A collector must also suppose the @ref AAllocator facet, see also" + ], + types: [ + // using typeseq = xo::facet::typeseq; // I think this is automatically provided +// { +// name: "typeseq", +// doc: ["type for an amount of memory"], +// definition: "std::size_t", +// }, + // using size_type = std::size_t; + { + name: "size_type", + doc: ["allocation size type"], + definition: "std::size_t", + }, + ], + const_methods: [ + // size_type allocated(Generation g, role r) const noexcept + { + name: "allocated", + doc: ["memory in use for this collector"], + return_type: "size_type", + args: [ + {type: "Generation", name: "g"}, + {type: "role", name: "r"}, + ], + const: true, + noexcept: true, + attributes: [], + }, + // size_type reserved(Generation g, role r) const noexcept + { + name: "committed", + doc: ["memory committed for this collector"], + return_type: "size_type", + args: [ + {type: "Generation", name: "g"}, + {type: "role", name: "r"}, + ], + const: true, + noexcept: true, + attributes: [], + }, + // size_type reserved(Generation g, role r) const noexcept + { + name: "reserved", + doc: ["address space reserved for this collector"], + return_type: "size_type", + args: [ + {type: "Generation", name: "g"}, + {type: "role", name: "r"}, + ], + const: true, + noexcept: true, + attributes: [], + }, + // bool contains(role r, const void * addr) const noexcept + { + name: "contains", + doc: ["true if gc responsible for data at @p addr, and data belongs to role @p r"], + return_type: "bool", + args:[ + {type: "role", name: "r"}, + {type: "const void *", name: "addr"}, + ], + const: true, + noexcept: true, + attributes: [], + }, + // bool is_type_installed(typeseq tseq) const noexcept; + { + name: "is_type_installed", + doc: ["true iff gc-aware object of type @p tseq is installed in this collector"], + return_type: "bool", + args:[ + {type: "typeseq", name: "tseq"}, + ], + const: true, + noexcept: true, + attributes: [], + }, + ], + nonconst_methods: [ + // bool install_type(const AGCObject & iface) + { + name: "install_type", + doc: [ + "install interface @p iface for representation with typeseq @p tseq", + "in collector @p d.", + "", + "The type AGCObject_Any here is misleading.", + "Will have been replaced by an instance of", + " @c AGCObject_Xfer for some @c DFoo", + "in which case calls through @c std::launder(&iface)", + "will properly act on @c DFoo.", + "", + "Return false if installation fails (e.g. memory exhausted)" + ], + return_type: "bool", + args: [ + {type: "const AGCObject &", name: "iface"}, + ], + const: false, + noexcept: false, + attributes: [], + }, + // void add_gc_root_poly(obj * p_root) + { + name: "add_gc_root_poly", + doc: [ + "add gc root with address @p p_root. gc will preserve subgraph at this address" + ], + return_type: "void", + args: [ + {type: "obj *", name: "p_root"}, + ], + const: false, + noexcept: false, + attributes: [], + }, + // void remove_gc_root_poly(obj * p_root) + { + name: "remove_gc_root_poly", + doc: [ + "remove gc root with address @p p_root. Reverse effect of prior add_gc_root_poly call" + ], + return_type: "void", + args: [ + {type: "obj *", name: "p_root"}, + ], + const: false, + noexcept: false, + attributes: [], + }, + // void request_gc(Generation upto) + { + name: "request_gc", + doc: [ + "Request immediate collection.", + " 1. if collection is enabled, immediately collect all generations", + " up to (but not including) g", + " 2. may nevertheless escalate to older generations,", + " depending on collector state.", + " 3. if collection is currently disabled,", + " collection will trigger the next time gc is enabled.", + "", + ], + return_type: "void", + args: [ + {type: "Generation", name: "upto"}, + ], + const: false, + noexcept: false, + attributes: [], + }, + // void assign_member(void * parent, obj * p_lhs, obj *", name: "p_lhs"}, + {type: "obj &", name: "rhs"}, + ], + const: false, + noexcept: false, + attributes: [], + }, + // void forward_inplace(AGCObject * lhs_iface, void ** lhs_data); + { + name: "forward_inplace", + doc: [ + "evacuate @p *lhs, that refers to state with interface @p lhs_iface,", + "to collector @p d's to-space. Replace *lhs_data with forwarding pointer", + "", + "Require: gc in progress", + "", + ], + return_type: "void", + args: [ + {type: "AGCObject *", name: "lhs_iface"}, + {type: "void **", name: "lhs_data"}, + ], + const: false, + noexcept: false, + attributes: [], + }, + ], + router_facet_explicit_content: [] +} diff --git a/xo-alloc2/include/xo/alloc2/Collector2.hpp b/xo-alloc2/include/xo/alloc2/Collector2.hpp new file mode 100644 index 00000000..2f2b2847 --- /dev/null +++ b/xo-alloc2/include/xo/alloc2/Collector2.hpp @@ -0,0 +1,22 @@ +/** @file Collector2.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Collector2.json5] + * 2. jinja2 template for facet .hpp file: + * [facet.hpp.j2] + * 3. idl for facet methods + * [idl/Collector2.json5] + **/ + +#pragma once + +#include "gc/ACollector2.hpp" +#include "gc/ICollector2_Any.hpp" +#include "gc/ICollector2_Xfer.hpp" +#include "gc/RCollector2.hpp" + + +/* end Collector2.hpp */ diff --git a/xo-alloc2/include/xo/alloc2/gc/ACollector.hpp b/xo-alloc2/include/xo/alloc2/gc/ACollector.hpp index 6793f499..6b0cb90a 100644 --- a/xo-alloc2/include/xo/alloc2/gc/ACollector.hpp +++ b/xo-alloc2/include/xo/alloc2/gc/ACollector.hpp @@ -67,7 +67,6 @@ namespace xo { /** add gc root with address @p p_root **/ virtual void add_gc_root_poly(Opaque d, obj * p_root) = 0; - //virtual void add_gc_root_typed(Opaque d, typeseq tseq, Opaque * root) = 0; /** remove gc root with address @p p_root **/ virtual void remove_gc_root_poly(Opaque d, obj * p_root) = 0; diff --git a/xo-alloc2/include/xo/alloc2/gc/ACollector2.hpp b/xo-alloc2/include/xo/alloc2/gc/ACollector2.hpp new file mode 100644 index 00000000..23b0fb5d --- /dev/null +++ b/xo-alloc2/include/xo/alloc2/gc/ACollector2.hpp @@ -0,0 +1,126 @@ +/** @file ACollector2.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Collector2.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [abstract_facet.hpp.j2] + * 3. idl for facet methods + * [idl/Collector2.json5] + **/ + +#pragma once + +// includes (via {facet_includes}) +#include +#include +#include +#include +#include +#include + +class AGCObject; +// more pretext here.. + +namespace xo { +namespace mm { + +using Copaque = const void *; +using Opaque = void *; + +/** +A collector must also suppose the @ref AAllocator facet, see also +**/ +class ACollector2 { +public: + /** @defgroup mm-collector2-type-traits **/ + ///@{ + // types + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + using Copaque = const void *; + using Opaque = void *; + /** allocation size type **/ + using size_type = std::size_t; + ///@} + + /** @defgroup mm-collector2-methods **/ + ///@{ + // const methods + /** An uninitialized ACollector2 instance will have zero vtable pointer (per {linux,osx} abi). + * Use case for this is narrow. We go to some lengths to avoid null vtable pointers. For example + * obj will have non-null vtable (via IFacet_Any) with all methods terminating. + **/ + bool _has_null_vptr() const noexcept { return *reinterpret_cast(this) == nullptr; } + /** RTTI: unique id# for actual runtime data representation **/ + virtual typeseq _typeseq() const noexcept = 0; + /** destroy instance @p d; calls c++ dtor only for actual runtime type; does not recover memory **/ + virtual void _drop(Opaque d) const noexcept = 0; + /** memory in use for this collector **/ + virtual size_type allocated(Copaque data, Generation g, role r) const noexcept = 0; + /** memory committed for this collector **/ + virtual size_type committed(Copaque data, Generation g, role r) const noexcept = 0; + /** address space reserved for this collector **/ + virtual size_type reserved(Copaque data, Generation g, role r) const noexcept = 0; + /** true if gc responsible for data at @p addr, and data belongs to role @p r **/ + virtual bool contains(Copaque data, role r, const void * addr) const noexcept = 0; + /** true iff gc-aware object of type @p tseq is installed in this collector **/ + virtual bool is_type_installed(Copaque data, typeseq tseq) const noexcept = 0; + + // nonconst methods + /** install interface @p iface for representation with typeseq @p tseq +in collector @p d. + +The type AGCObject_Any here is misleading. +Will have been replaced by an instance of + @c AGCObject_Xfer for some @c DFoo +in which case calls through @c std::launder(&iface) +will properly act on @c DFoo. + +Return false if installation fails (e.g. memory exhausted) **/ + virtual bool install_type(Opaque data, const AGCObject & iface) = 0; + /** add gc root with address @p p_root. gc will preserve subgraph at this address **/ + virtual void add_gc_root_poly(Opaque data, obj * p_root) = 0; + /** remove gc root with address @p p_root. Reverse effect of prior add_gc_root_poly call **/ + virtual void remove_gc_root_poly(Opaque data, obj * p_root) = 0; + /** Request immediate collection. + 1. if collection is enabled, immediately collect all generations + up to (but not including) g + 2. may nevertheless escalate to older generations, + depending on collector state. + 3. if collection is currently disabled, + collection will trigger the next time gc is enabled. + **/ + virtual void request_gc(Opaque data, Generation upto) = 0; + /** Assign pointer @p p_lhs to destination @p rhs, within parent allocation @p parent + +Require: gc not in progress **/ + virtual void assign_member(Opaque data, void * parent, obj * p_lhs, obj & rhs) = 0; + /** evacuate @p *lhs, that refers to state with interface @p lhs_iface, +to collector @p d's to-space. Replace *lhs_data with forwarding pointer + +Require: gc in progress + **/ + virtual void forward_inplace(Opaque data, AGCObject * lhs_iface, void ** lhs_data) = 0; + ///@} +}; /*ACollector2*/ + +/** Implementation ICollector2_DRepr of ACollector2 for state DRepr + * should provide a specialization: + * + * template <> + * struct xo::facet::FacetImplementation { + * using Impltype = ICollector2_DRepr; + * }; + * + * then ICollector2_ImplType --> ICollector2_DRepr + **/ +template +using ICollector2_ImplType = xo::facet::FacetImplType; + +} /*namespace mm*/ +} /*namespace xo*/ + +/* ACollector2.hpp */ diff --git a/xo-alloc2/include/xo/alloc2/gc/ICollector2_Any.hpp b/xo-alloc2/include/xo/alloc2/gc/ICollector2_Any.hpp new file mode 100644 index 00000000..93a68154 --- /dev/null +++ b/xo-alloc2/include/xo/alloc2/gc/ICollector2_Any.hpp @@ -0,0 +1,99 @@ +/** @file ICollector2_Any.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Collector2.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Collector2.json5] + **/ + +#pragma once + +#include "ACollector2.hpp" +#include + +namespace xo { namespace mm { class ICollector2_Any; } } + +namespace xo { +namespace facet { + +template <> +struct FacetImplementation +{ + using ImplType = xo::mm::ICollector2_Any; +}; + +} +} + +namespace xo { +namespace mm { + + /** @class ICollector2_Any + * @brief ACollector2 implementation for empty variant instance + **/ + class ICollector2_Any : public ACollector2 { + public: + /** @defgroup mm-collector2-any-type-traits **/ + ///@{ + + /** integer identifying a type **/ + using typeseq = xo::facet::typeseq; + using size_type = ACollector2::size_type; + + ///@} + /** @defgroup mm-collector2-any-methods **/ + ///@{ + + const ACollector2 * iface() const { return std::launder(this); } + + // from ACollector2 + + // builtin methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + [[noreturn]] void _drop(Opaque) const noexcept override { _fatal(); } + + // const methods + [[noreturn]] size_type allocated(Copaque, Generation, role) const noexcept override { _fatal(); } + [[noreturn]] size_type committed(Copaque, Generation, role) const noexcept override { _fatal(); } + [[noreturn]] size_type reserved(Copaque, Generation, role) const noexcept override { _fatal(); } + [[noreturn]] bool contains(Copaque, role, const void *) const noexcept override { _fatal(); } + [[noreturn]] bool is_type_installed(Copaque, typeseq) const noexcept override { _fatal(); } + + // nonconst methods + [[noreturn]] bool install_type(Opaque, const AGCObject &) override; + [[noreturn]] void add_gc_root_poly(Opaque, obj *) override; + [[noreturn]] void remove_gc_root_poly(Opaque, obj *) override; + [[noreturn]] void request_gc(Opaque, Generation) override; + [[noreturn]] void assign_member(Opaque, void *, obj *, obj &) override; + [[noreturn]] void forward_inplace(Opaque, AGCObject *, void **) override; + + ///@} + + private: + /** @defgraoup mm-collector2-any-private-methods **/ + ///@{ + + [[noreturn]] static void _fatal(); + + ///@} + + public: + /** @defgroup mm-collector2-any-member-vars **/ + ///@{ + + static typeseq s_typeseq; + static bool _valid; + + ///@} + }; + +} /*namespace mm */ +} /*namespace xo */ + +/* ICollector2_Any.hpp */ diff --git a/xo-alloc2/include/xo/alloc2/gc/ICollector2_Xfer.hpp b/xo-alloc2/include/xo/alloc2/gc/ICollector2_Xfer.hpp new file mode 100644 index 00000000..0760abd8 --- /dev/null +++ b/xo-alloc2/include/xo/alloc2/gc/ICollector2_Xfer.hpp @@ -0,0 +1,116 @@ +/** @file ICollector2_Xfer.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Collector2.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Collector2.json5] + **/ + +#pragma once + +#include +#include +#include + +namespace xo { +namespace mm { + /** @class ICollector2_Xfer + **/ + template + class ICollector2_Xfer : public ACollector2 { + public: + /** @defgroup mm-collector2-xfer-type-traits **/ + ///@{ + /** actual implementation (not generated; often delegates to DRepr) **/ + using Impl = ICollector2_DRepr; + /** integer identifying a type **/ + using typeseq = ACollector2::typeseq; + using size_type = ACollector2::size_type; + ///@} + + /** @defgroup mm-collector2-xfer-methods **/ + ///@{ + + static const DRepr & _dcast(Copaque d) { return *(const DRepr *)d; } + static DRepr & _dcast(Opaque d) { return *(DRepr *)d; } + + // from ACollector2 + + // builtin methods + typeseq _typeseq() const noexcept override { return s_typeseq; } + void _drop(Opaque d) const noexcept override { _dcast(d).~DRepr(); } + + // const methods + size_type allocated(Copaque data, Generation g, role r) const noexcept override { + return I::allocated(_dcast(data), g, r); + } + size_type committed(Copaque data, Generation g, role r) const noexcept override { + return I::committed(_dcast(data), g, r); + } + size_type reserved(Copaque data, Generation g, role r) const noexcept override { + return I::reserved(_dcast(data), g, r); + } + bool contains(Copaque data, role r, const void * addr) const noexcept override { + return I::contains(_dcast(data), r, addr); + } + bool is_type_installed(Copaque data, typeseq tseq) const noexcept override { + return I::is_type_installed(_dcast(data), tseq); + } + + // non-const methods + bool install_type(Opaque data, const AGCObject & iface) override { + return I::install_type(_dcast(data), iface); + } + void add_gc_root_poly(Opaque data, obj * p_root) override { + return I::add_gc_root_poly(_dcast(data), p_root); + } + void remove_gc_root_poly(Opaque data, obj * p_root) override { + return I::remove_gc_root_poly(_dcast(data), p_root); + } + void request_gc(Opaque data, Generation upto) override { + return I::request_gc(_dcast(data), upto); + } + void assign_member(Opaque data, void * parent, obj * p_lhs, obj & rhs) override { + return I::assign_member(_dcast(data), parent, p_lhs, rhs); + } + void forward_inplace(Opaque data, AGCObject * lhs_iface, void ** lhs_data) override { + return I::forward_inplace(_dcast(data), lhs_iface, lhs_data); + } + + ///@} + + private: + using I = Impl; + + public: + /** @defgroup mm-collector2-xfer-member-vars **/ + ///@{ + + /** typeseq for template parameter DRepr **/ + static typeseq s_typeseq; + /** true iff satisfies facet implementation **/ + static bool _valid; + + ///@} + }; + + template + xo::facet::typeseq + ICollector2_Xfer::s_typeseq + = xo::facet::typeseq::id(); + + template + bool + ICollector2_Xfer::_valid + = xo::facet::valid_facet_implementation(); + +} /*namespace mm */ +} /*namespace xo*/ + +/* end ICollector2_Xfer.hpp */ diff --git a/xo-alloc2/include/xo/alloc2/gc/RCollector2.hpp b/xo-alloc2/include/xo/alloc2/gc/RCollector2.hpp new file mode 100644 index 00000000..facaf295 --- /dev/null +++ b/xo-alloc2/include/xo/alloc2/gc/RCollector2.hpp @@ -0,0 +1,115 @@ +/** @file RCollector2.hpp + * + * Generated automagically from ingredients: + * 1. code generator: + * [xo-facet/codegen/genfacet] + * arguments: + * --input [idl/Collector2.json5] + * 2. jinja2 template for abstract facet .hpp file: + * [iface_facet_any.hpp.j2] + * 3. idl for facet methods + * [idl/Collector2.json5] + **/ + +#pragma once + +#include "ACollector2.hpp" + +namespace xo { +namespace mm { + +/** @class RCollector2 + **/ +template +class RCollector2 : public Object { +private: + using O = Object; + +public: + /** @defgroup mm-collector2-router-type-traits **/ + ///@{ + using ObjectType = Object; + using DataPtr = Object::DataPtr; + using typeseq = xo::reflect::typeseq; + using size_type = ACollector2::size_type; + ///@} + + /** @defgroup mm-collector2-router-ctors **/ + ///@{ + RCollector2() {} + RCollector2(Object::DataPtr data) : Object{std::move(data)} {} + RCollector2(const ACollector2 * iface, void * data) + requires std::is_same_v + : Object(iface, data) {} + + ///@} + /** @defgroup mm-collector2-router-methods **/ + ///@{ + + // explicit injected content + + // builtin methods + typeseq _typeseq() const noexcept { return O::iface()->_typeseq(); } + void _drop() const noexcept { O::iface()->_drop(O::data()); } + + // const methods + size_type allocated(Generation g, role r) const noexcept { + return O::iface()->allocated(O::data(), g, r); + } + size_type committed(Generation g, role r) const noexcept { + return O::iface()->committed(O::data(), g, r); + } + size_type reserved(Generation g, role r) const noexcept { + return O::iface()->reserved(O::data(), g, r); + } + bool contains(role r, const void * addr) const noexcept { + return O::iface()->contains(O::data(), r, addr); + } + bool is_type_installed(typeseq tseq) const noexcept { + return O::iface()->is_type_installed(O::data(), tseq); + } + + // non-const methods (still const in router!) + bool install_type(const AGCObject & iface) { + return O::iface()->install_type(O::data(), iface); + } + void add_gc_root_poly(obj * p_root) { + return O::iface()->add_gc_root_poly(O::data(), p_root); + } + void remove_gc_root_poly(obj * p_root) { + return O::iface()->remove_gc_root_poly(O::data(), p_root); + } + void request_gc(Generation upto) { + return O::iface()->request_gc(O::data(), upto); + } + void assign_member(void * parent, obj * p_lhs, obj & rhs) { + return O::iface()->assign_member(O::data(), parent, p_lhs, rhs); + } + void forward_inplace(AGCObject * lhs_iface, void ** lhs_data) { + return O::iface()->forward_inplace(O::data(), lhs_iface, lhs_data); + } + + ///@} + /** @defgroup mm-collector2-member-vars **/ + ///@{ + + static bool _valid; + + ///@} +}; + +template +bool +RCollector2::_valid = xo::facet::valid_object_router(); + +} /*namespace mm*/ +} /*namespace xo*/ + +namespace xo { namespace facet { + template + struct RoutingFor { + using RoutingType = xo::mm::RCollector2; + }; +} } + +/* end RCollector2.hpp */ diff --git a/xo-alloc2/src/alloc2/CMakeLists.txt b/xo-alloc2/src/alloc2/CMakeLists.txt index 0fa0cfbe..ac73207e 100644 --- a/xo-alloc2/src/alloc2/CMakeLists.txt +++ b/xo-alloc2/src/alloc2/CMakeLists.txt @@ -8,6 +8,8 @@ set(SELF_SRCS CollectorTypeRegistry.cpp + facet/ICollector2_Any.cpp + ICollector_Any.cpp IGCObject_Any.cpp diff --git a/xo-alloc2/src/alloc2/facet/ICollector2_Any.cpp b/xo-alloc2/src/alloc2/facet/ICollector2_Any.cpp new file mode 100644 index 00000000..fc08a517 --- /dev/null +++ b/xo-alloc2/src/alloc2/facet/ICollector2_Any.cpp @@ -0,0 +1,78 @@ +/** @file ICollector2_Any.cpp + * + **/ + +#include "gc/ICollector2_Any.hpp" +#include +#include + +namespace xo { +namespace mm { + +using xo::facet::DVariantPlaceholder; +using xo::facet::typeseq; +using xo::facet::valid_facet_implementation; + +void +ICollector2_Any::_fatal() +{ + /* control here on uninitialized IAllocator_Any. + * Initialized instance will have specific implementation type + */ + std::cerr << "fatal" + << ": attempt to call uninitialized" + << " ICollector2_Any method" + << std::endl; + std::terminate(); +} + +typeseq +ICollector2_Any::s_typeseq = typeseq::id(); + +bool +ICollector2_Any::_valid + = valid_facet_implementation(); + +// nonconst methods + +auto +ICollector2_Any::install_type(Opaque, const AGCObject &) -> bool +{ + _fatal(); +} + +auto +ICollector2_Any::add_gc_root_poly(Opaque, obj *) -> void +{ + _fatal(); +} + +auto +ICollector2_Any::remove_gc_root_poly(Opaque, obj *) -> void +{ + _fatal(); +} + +auto +ICollector2_Any::request_gc(Opaque, Generation) -> void +{ + _fatal(); +} + +auto +ICollector2_Any::assign_member(Opaque, void *, obj *, obj &) -> void +{ + _fatal(); +} + +auto +ICollector2_Any::forward_inplace(Opaque, AGCObject *, void **) -> void +{ + _fatal(); +} + + +} /*namespace mm*/ +} /*namespace xo*/ + +/* end ICollector2_Any.cpp */ diff --git a/xo-procedure2/src/procedure2/GcPrimitives.cpp b/xo-procedure2/src/procedure2/GcPrimitives.cpp index 63a3d3a9..9948ff65 100644 --- a/xo-procedure2/src/procedure2/GcPrimitives.cpp +++ b/xo-procedure2/src/procedure2/GcPrimitives.cpp @@ -6,16 +6,39 @@ #include "GcPrimitives.hpp" #include #include +//#include #include #include #include #include namespace xo { + using xo::mm::ACollector; + //using xo::mm::DX1Collector; using xo::mm::Generation; namespace scm { + // ----- report-gc-status ----- + +#ifdef NOT_YET + obj + xfer_report_gc_status(obj rcx) + { + bool have_gc = false; + + if (rcx.collector()) { + // status currently only implemented for X1 collector + + auto gc = obj::from(rcx.collector()); + + + } + + return DBoolean::box(rcx.allocator(), false); + } +#endif + // ----- request-gc ----- obj