xo-alloc2: + ACollector2
temporary, planning to codegen Collector facet
This commit is contained in:
parent
4cefdf6710
commit
48cb87bcb9
11 changed files with 812 additions and 2 deletions
|
|
@ -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
|
||||
)
|
||||
|
|
|
|||
222
xo-alloc2/idl/Collector2.json5
Normal file
222
xo-alloc2/idl/Collector2.json5
Normal file
|
|
@ -0,0 +1,222 @@
|
|||
{
|
||||
mode: "facet",
|
||||
output_cpp_dir: "src/alloc2/facet",
|
||||
output_hpp_dir: "include/xo/alloc2",
|
||||
output_impl_subdir: "gc",
|
||||
includes: [
|
||||
"<xo/alloc2/Allocator.hpp>",
|
||||
"<xo/alloc2/generation.hpp>",
|
||||
"<xo/alloc2/role.hpp>",
|
||||
// "<cstdint>",
|
||||
// "<cstddef>",
|
||||
],
|
||||
// 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<DFoo,AGCObject_DFoo> 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<AGCObject> * 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<AGCObject> *", name: "p_root"},
|
||||
],
|
||||
const: false,
|
||||
noexcept: false,
|
||||
attributes: [],
|
||||
},
|
||||
// void remove_gc_root_poly(obj<AGCObject> * 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<AGCObject> *", 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<AGCobject> * p_lhs, obj<AGCobject & rhs);
|
||||
{
|
||||
name: "assign_member",
|
||||
doc: [
|
||||
"Assign pointer @p p_lhs to destination @p rhs, within parent allocation @p parent",
|
||||
"",
|
||||
"Require: gc not in progress",
|
||||
],
|
||||
return_type: "void",
|
||||
args: [
|
||||
{type: "void *", name: "parent"},
|
||||
{type: "obj<AGCObject> *", name: "p_lhs"},
|
||||
{type: "obj<AGCObject> &", 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: []
|
||||
}
|
||||
22
xo-alloc2/include/xo/alloc2/Collector2.hpp
Normal file
22
xo-alloc2/include/xo/alloc2/Collector2.hpp
Normal file
|
|
@ -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 */
|
||||
|
|
@ -67,7 +67,6 @@ namespace xo {
|
|||
|
||||
/** add gc root with address @p p_root **/
|
||||
virtual void add_gc_root_poly(Opaque d, obj<AGCObject> * 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<AGCObject> * p_root) = 0;
|
||||
|
|
|
|||
126
xo-alloc2/include/xo/alloc2/gc/ACollector2.hpp
Normal file
126
xo-alloc2/include/xo/alloc2/gc/ACollector2.hpp
Normal file
|
|
@ -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 <xo/alloc2/Allocator.hpp>
|
||||
#include <xo/alloc2/generation.hpp>
|
||||
#include <xo/alloc2/role.hpp>
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <xo/facet/facet_implementation.hpp>
|
||||
#include <xo/facet/typeseq.hpp>
|
||||
|
||||
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<AFacet> will have non-null vtable (via IFacet_Any) with all methods terminating.
|
||||
**/
|
||||
bool _has_null_vptr() const noexcept { return *reinterpret_cast<const void * const *>(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<DFoo,AGCObject_DFoo> 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<AGCObject> * 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<AGCObject> * 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<AGCObject> * p_lhs, obj<AGCObject> & 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<ACollector2, DRepr> {
|
||||
* using Impltype = ICollector2_DRepr;
|
||||
* };
|
||||
*
|
||||
* then ICollector2_ImplType<DRepr> --> ICollector2_DRepr
|
||||
**/
|
||||
template <typename DRepr>
|
||||
using ICollector2_ImplType = xo::facet::FacetImplType<ACollector2, DRepr>;
|
||||
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* ACollector2.hpp */
|
||||
99
xo-alloc2/include/xo/alloc2/gc/ICollector2_Any.hpp
Normal file
99
xo-alloc2/include/xo/alloc2/gc/ICollector2_Any.hpp
Normal file
|
|
@ -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 <xo/facet/obj.hpp>
|
||||
|
||||
namespace xo { namespace mm { class ICollector2_Any; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
|
||||
template <>
|
||||
struct FacetImplementation<xo::mm::ACollector2,
|
||||
DVariantPlaceholder>
|
||||
{
|
||||
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<AGCObject> *) override;
|
||||
[[noreturn]] void remove_gc_root_poly(Opaque, obj<AGCObject> *) override;
|
||||
[[noreturn]] void request_gc(Opaque, Generation) override;
|
||||
[[noreturn]] void assign_member(Opaque, void *, obj<AGCObject> *, obj<AGCObject> &) 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 */
|
||||
116
xo-alloc2/include/xo/alloc2/gc/ICollector2_Xfer.hpp
Normal file
116
xo-alloc2/include/xo/alloc2/gc/ICollector2_Xfer.hpp
Normal file
|
|
@ -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 <xo/alloc2/Allocator.hpp>
|
||||
#include <xo/alloc2/generation.hpp>
|
||||
#include <xo/alloc2/role.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace mm {
|
||||
/** @class ICollector2_Xfer
|
||||
**/
|
||||
template <typename DRepr, typename ICollector2_DRepr>
|
||||
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<AGCObject> * p_root) override {
|
||||
return I::add_gc_root_poly(_dcast(data), p_root);
|
||||
}
|
||||
void remove_gc_root_poly(Opaque data, obj<AGCObject> * 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<AGCObject> * p_lhs, obj<AGCObject> & 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 <typename DRepr, typename ICollector2_DRepr>
|
||||
xo::facet::typeseq
|
||||
ICollector2_Xfer<DRepr, ICollector2_DRepr>::s_typeseq
|
||||
= xo::facet::typeseq::id<DRepr>();
|
||||
|
||||
template <typename DRepr, typename ICollector2_DRepr>
|
||||
bool
|
||||
ICollector2_Xfer<DRepr, ICollector2_DRepr>::_valid
|
||||
= xo::facet::valid_facet_implementation<ACollector2,
|
||||
ICollector2_Xfer>();
|
||||
|
||||
} /*namespace mm */
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end ICollector2_Xfer.hpp */
|
||||
115
xo-alloc2/include/xo/alloc2/gc/RCollector2.hpp
Normal file
115
xo-alloc2/include/xo/alloc2/gc/RCollector2.hpp
Normal file
|
|
@ -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 <typename Object>
|
||||
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<typename Object::DataType, xo::facet::DVariantPlaceholder>
|
||||
: 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<AGCObject> * p_root) {
|
||||
return O::iface()->add_gc_root_poly(O::data(), p_root);
|
||||
}
|
||||
void remove_gc_root_poly(obj<AGCObject> * 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<AGCObject> * p_lhs, obj<AGCObject> & 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 <typename Object>
|
||||
bool
|
||||
RCollector2<Object>::_valid = xo::facet::valid_object_router<Object>();
|
||||
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
namespace xo { namespace facet {
|
||||
template <typename Object>
|
||||
struct RoutingFor<xo::mm::ACollector2, Object> {
|
||||
using RoutingType = xo::mm::RCollector2<Object>;
|
||||
};
|
||||
} }
|
||||
|
||||
/* end RCollector2.hpp */
|
||||
|
|
@ -8,6 +8,8 @@ set(SELF_SRCS
|
|||
|
||||
CollectorTypeRegistry.cpp
|
||||
|
||||
facet/ICollector2_Any.cpp
|
||||
|
||||
ICollector_Any.cpp
|
||||
IGCObject_Any.cpp
|
||||
|
||||
|
|
|
|||
78
xo-alloc2/src/alloc2/facet/ICollector2_Any.cpp
Normal file
78
xo-alloc2/src/alloc2/facet/ICollector2_Any.cpp
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
/** @file ICollector2_Any.cpp
|
||||
*
|
||||
**/
|
||||
|
||||
#include "gc/ICollector2_Any.hpp"
|
||||
#include <iostream>
|
||||
#include <exception>
|
||||
|
||||
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<DVariantPlaceholder>();
|
||||
|
||||
bool
|
||||
ICollector2_Any::_valid
|
||||
= valid_facet_implementation<ACollector2, ICollector2_Any>();
|
||||
|
||||
// nonconst methods
|
||||
|
||||
auto
|
||||
ICollector2_Any::install_type(Opaque, const AGCObject &) -> bool
|
||||
{
|
||||
_fatal();
|
||||
}
|
||||
|
||||
auto
|
||||
ICollector2_Any::add_gc_root_poly(Opaque, obj<AGCObject> *) -> void
|
||||
{
|
||||
_fatal();
|
||||
}
|
||||
|
||||
auto
|
||||
ICollector2_Any::remove_gc_root_poly(Opaque, obj<AGCObject> *) -> void
|
||||
{
|
||||
_fatal();
|
||||
}
|
||||
|
||||
auto
|
||||
ICollector2_Any::request_gc(Opaque, Generation) -> void
|
||||
{
|
||||
_fatal();
|
||||
}
|
||||
|
||||
auto
|
||||
ICollector2_Any::assign_member(Opaque, void *, obj<AGCObject> *, obj<AGCObject> &) -> void
|
||||
{
|
||||
_fatal();
|
||||
}
|
||||
|
||||
auto
|
||||
ICollector2_Any::forward_inplace(Opaque, AGCObject *, void **) -> void
|
||||
{
|
||||
_fatal();
|
||||
}
|
||||
|
||||
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end ICollector2_Any.cpp */
|
||||
|
|
@ -6,16 +6,39 @@
|
|||
#include "GcPrimitives.hpp"
|
||||
#include <xo/object2/Integer.hpp>
|
||||
#include <xo/object2/Boolean.hpp>
|
||||
//#include <xo/gc/X1Collector.hpp>
|
||||
#include <xo/type/FunctionType.hpp>
|
||||
#include <xo/type/AtomicType.hpp>
|
||||
#include <xo/alloc2/Collector.hpp>
|
||||
#include <xo/alloc2/generation.hpp>
|
||||
|
||||
namespace xo {
|
||||
using xo::mm::ACollector;
|
||||
//using xo::mm::DX1Collector;
|
||||
using xo::mm::Generation;
|
||||
|
||||
namespace scm {
|
||||
|
||||
// ----- report-gc-status -----
|
||||
|
||||
#ifdef NOT_YET
|
||||
obj<AGCObject>
|
||||
xfer_report_gc_status(obj<ARuntimeContext> rcx)
|
||||
{
|
||||
bool have_gc = false;
|
||||
|
||||
if (rcx.collector()) {
|
||||
// status currently only implemented for X1 collector
|
||||
|
||||
auto gc = obj<ACollector,DX1Collector>::from(rcx.collector());
|
||||
|
||||
|
||||
}
|
||||
|
||||
return DBoolean::box(rcx.allocator(), false);
|
||||
}
|
||||
#endif
|
||||
|
||||
// ----- request-gc -----
|
||||
|
||||
obj<AGCObject>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue