refactor: + narrower interface for gc pointer forwarding
add AGCObjectVisitor, instead of requiring ACollector.
This commit is contained in:
parent
57688a826a
commit
801bb9e39d
266 changed files with 952 additions and 947 deletions
|
|
@ -9,6 +9,7 @@
|
|||
#include "Metatype.hpp"
|
||||
#include <xo/alloc2/Collector.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include <xo/alloc2/GCObjectVisitor.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace scm {
|
||||
|
|
@ -19,6 +20,7 @@ namespace xo {
|
|||
class DArrayType {
|
||||
public:
|
||||
using ACollector = xo::mm::ACollector;
|
||||
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
|
||||
|
|
@ -43,7 +45,7 @@ namespace xo {
|
|||
///@{
|
||||
std::size_t shallow_size() const noexcept;
|
||||
DArrayType * shallow_move(obj<ACollector> gc) noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
|
||||
///@}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@
|
|||
#include "Type.hpp"
|
||||
#include "Metatype.hpp"
|
||||
#include <xo/alloc2/Collector.hpp>
|
||||
#include <xo/alloc2/GCObjectVisitor.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
|
||||
namespace xo {
|
||||
|
|
@ -22,6 +23,7 @@ namespace xo {
|
|||
class DAtomicType {
|
||||
public:
|
||||
using ACollector = xo::mm::ACollector;
|
||||
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
|
||||
|
|
@ -44,7 +46,7 @@ namespace xo {
|
|||
///@{
|
||||
std::size_t shallow_size() const noexcept;
|
||||
DAtomicType * shallow_move(obj<ACollector> gc) noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
|
||||
///@}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "Metatype.hpp"
|
||||
#include <xo/object2/Array.hpp>
|
||||
#include <xo/alloc2/Collector.hpp>
|
||||
#include <xo/alloc2/GCObjectVisitor.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
|
||||
namespace xo {
|
||||
|
|
@ -20,8 +21,9 @@ namespace xo {
|
|||
class DFunctionType {
|
||||
public:
|
||||
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 TypeDescr = xo::reflect::TypeDescr;
|
||||
|
||||
public:
|
||||
|
|
@ -65,7 +67,7 @@ namespace xo {
|
|||
///@{
|
||||
std::size_t shallow_size() const noexcept;
|
||||
DFunctionType * shallow_move(obj<ACollector> gc) noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
|
||||
///@}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@
|
|||
#include "Metatype.hpp"
|
||||
#include <xo/reflect/TypeDescr.hpp>
|
||||
#include <xo/alloc2/Collector.hpp>
|
||||
#include <xo/alloc2/GCObjectVisitor.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
|
||||
namespace xo {
|
||||
|
|
@ -24,6 +25,7 @@ namespace xo {
|
|||
public:
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
using ACollector = xo::mm::ACollector;
|
||||
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
|
||||
public:
|
||||
|
|
@ -51,7 +53,7 @@ namespace xo {
|
|||
///@{
|
||||
std::size_t shallow_size() const noexcept;
|
||||
DListType * shallow_move(obj<ACollector> gc) noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
|
||||
///@}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -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(DArrayType & self, obj<ACollector> gc) noexcept;
|
||||
/** during GC: forward immdiate children **/
|
||||
static void forward_children(DArrayType & 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(DArrayType & self, obj<AGCObjectVisitor> fn) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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(DAtomicType & self, obj<ACollector> gc) noexcept;
|
||||
/** during GC: forward immdiate children **/
|
||||
static void forward_children(DAtomicType & 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(DAtomicType & self, obj<AGCObjectVisitor> fn) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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(DFunctionType & self, obj<ACollector> gc) noexcept;
|
||||
/** during GC: forward immdiate children **/
|
||||
static void forward_children(DFunctionType & 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(DFunctionType & self, obj<AGCObjectVisitor> fn) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -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(DListType & self, obj<ACollector> gc) noexcept;
|
||||
/** during GC: forward immdiate children **/
|
||||
static void forward_children(DListType & 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(DListType & self, obj<AGCObjectVisitor> fn) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ namespace xo {
|
|||
class DTypeVarRef {
|
||||
public:
|
||||
using ACollector = xo::mm::ACollector;
|
||||
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
using TypeDescr = xo::reflect::TypeDescr;
|
||||
|
||||
|
|
@ -55,7 +56,7 @@ namespace xo {
|
|||
///@{
|
||||
std::size_t shallow_size() const noexcept;
|
||||
DTypeVarRef * shallow_move(obj<ACollector> gc) noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
void visit_gco_children(obj<AGCObjectVisitor> gc) noexcept;
|
||||
///@}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -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(DTypeVarRef & self, obj<ACollector> gc) noexcept;
|
||||
/** during GC: forward immdiate children **/
|
||||
static void forward_children(DTypeVarRef & 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(DTypeVarRef & self, obj<AGCObjectVisitor> fn) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -88,15 +88,14 @@ namespace xo {
|
|||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DArrayType::forward_children(obj<ACollector> gc) noexcept
|
||||
void
|
||||
DArrayType::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
{
|
||||
auto e = FacetRegistry::instance().variant<AGCObject,AType>(elt_type_);
|
||||
gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_));
|
||||
}
|
||||
|
||||
return this->shallow_size();
|
||||
gc.visit_poly_child(&elt_type_);
|
||||
//{
|
||||
// auto e = FacetRegistry::instance().variant<AGCObject,AType>(elt_type_);
|
||||
// gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_));
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -66,10 +66,10 @@ namespace xo {
|
|||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DAtomicType::forward_children(obj<ACollector>) noexcept
|
||||
void
|
||||
DAtomicType::visit_gco_children(obj<AGCObjectVisitor>) noexcept
|
||||
{
|
||||
return this->shallow_size();
|
||||
// no-op. no children
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -99,17 +99,16 @@ namespace xo {
|
|||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DFunctionType::forward_children(obj<ACollector> gc) noexcept
|
||||
void
|
||||
DFunctionType::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
{
|
||||
auto e = FacetRegistry::instance().variant<AGCObject,AType>(return_type_);
|
||||
gc.forward_inplace(e.iface(), (void **)&(return_type_.data_));
|
||||
}
|
||||
gc.visit_poly_child(&return_type_);
|
||||
//{
|
||||
// auto e = FacetRegistry::instance().variant<AGCObject,AType>(return_type_);
|
||||
// gc.forward_inplace(e.iface(), (void **)&(return_type_.data_));
|
||||
//}
|
||||
|
||||
gc.forward_inplace(&arg_types_);
|
||||
|
||||
return this->shallow_size();
|
||||
gc.visit_child(&arg_types_);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -93,15 +93,14 @@ namespace xo {
|
|||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DListType::forward_children(obj<ACollector> gc) noexcept
|
||||
void
|
||||
DListType::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
{
|
||||
auto e = FacetRegistry::instance().variant<AGCObject,AType>(elt_type_);
|
||||
gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_));
|
||||
}
|
||||
|
||||
return this->shallow_size();
|
||||
gc.visit_poly_child(&elt_type_);
|
||||
//{
|
||||
// auto e = FacetRegistry::instance().variant<AGCObject,AType>(elt_type_);
|
||||
// gc.forward_inplace(e.iface(), (void **)&(elt_type_.data_));
|
||||
//}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -87,17 +87,16 @@ namespace xo {
|
|||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
DTypeVarRef::forward_children(obj<ACollector> gc) noexcept
|
||||
void
|
||||
DTypeVarRef::visit_gco_children(obj<AGCObjectVisitor> gc) noexcept
|
||||
{
|
||||
gc.forward_pivot_inplace(&type_);
|
||||
gc.visit_poly_child(&type_);
|
||||
|
||||
//{
|
||||
// auto e = FacetRegistry::instance().variant<AGCObject,AType>(type_);
|
||||
// gc.forward_inplace(e.iface(), (void **)&type_.data_);
|
||||
//}
|
||||
|
||||
return this->shallow_size();
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DArrayType::forward_children(DArrayType & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DArrayType::visit_gco_children(DArrayType & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DAtomicType::forward_children(DAtomicType & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DAtomicType::visit_gco_children(DAtomicType & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DFunctionType::forward_children(DFunctionType & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DFunctionType::visit_gco_children(DFunctionType & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DListType::forward_children(DListType & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DListType::visit_gco_children(DListType & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -21,9 +21,9 @@ namespace xo {
|
|||
return self.shallow_move(gc);
|
||||
}
|
||||
auto
|
||||
IGCObject_DTypeVarRef::forward_children(DTypeVarRef & self, obj<ACollector> gc) noexcept -> void
|
||||
IGCObject_DTypeVarRef::visit_gco_children(DTypeVarRef & self, obj<AGCObjectVisitor> fn) noexcept -> void
|
||||
{
|
||||
self.forward_children(gc);
|
||||
self.visit_gco_children(fn);
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue