xo-gc stack: refactor + streamline.
Retiring unused Collector typealiases. Fix #include topology. Fix/improve write barrier setup.
This commit is contained in:
parent
7264efb605
commit
b1d2ae6f19
17 changed files with 130 additions and 94 deletions
|
|
@ -18,6 +18,4 @@
|
|||
#include "gc/IGCObject_Xfer.hpp"
|
||||
#include "gc/RGCObject.hpp"
|
||||
|
||||
#include "gc/RCollector_aux.hpp"
|
||||
|
||||
/* end GCObject.hpp */
|
||||
|
|
|
|||
|
|
@ -18,5 +18,6 @@
|
|||
#include "gc/IGCObjectVisitor_Xfer.hpp"
|
||||
#include "gc/RGCObjectVisitor.hpp"
|
||||
|
||||
#include "gc/RGCObjectVisitor_aux.hpp"
|
||||
|
||||
/* end GCObjectVisitor.hpp */
|
||||
|
|
|
|||
|
|
@ -85,6 +85,13 @@ namespace xo {
|
|||
obj<AGCObject> * p_lhs,
|
||||
obj<AGCObject> rhs) noexcept;
|
||||
|
||||
// Need _drepr suffix to distinguish from .barrier_assign()
|
||||
// see [RAllocator_aux.hpp] for implementation
|
||||
template <typename DRepr>
|
||||
void barrier_assign_drepr(void * parent,
|
||||
DRepr ** lhs_data,
|
||||
DRepr * rhs_data);
|
||||
|
||||
static bool _valid;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -38,6 +38,23 @@ namespace xo {
|
|||
rhs.iface(), rhs.opaque_data());
|
||||
}
|
||||
|
||||
template <typename Object>
|
||||
template <typename DRepr>
|
||||
void
|
||||
RAllocator<Object>::barrier_assign_drepr(void * parent,
|
||||
DRepr ** lhs_data,
|
||||
DRepr * rhs_data)
|
||||
{
|
||||
// need to get AGCObject i/face that goes with DRepr.
|
||||
obj<AGCObject,DRepr> rhs_gco(rhs_data);
|
||||
|
||||
this->barrier_assign_aux(parent,
|
||||
nullptr /*not needed*/,
|
||||
lhs_data,
|
||||
rhs_gco.iface(),
|
||||
rhs_data);
|
||||
}
|
||||
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
|
|
@ -116,6 +116,7 @@ Return false if installation fails (e.g. memory exhausted) **/
|
|||
**/
|
||||
virtual void request_gc(Opaque data, Generation upto) = 0;
|
||||
/** Assign pointer @p p_lhs to destination @p rhs, within parent allocation @p parent
|
||||
DEPRECATED. Only used in MockCollector for gc unit test
|
||||
|
||||
Require: gc not in progress **/
|
||||
virtual void assign_member(Opaque data, void * parent, obj<AGCObject> * p_lhs, obj<AGCObject> & rhs) = 0;
|
||||
|
|
|
|||
|
|
@ -15,7 +15,6 @@
|
|||
|
||||
// includes (via {facet_includes})
|
||||
#include <xo/alloc2/Allocator_basic.hpp>
|
||||
#include <xo/alloc2/Collector.hpp>
|
||||
#include <xo/alloc2/GCObjectVisitor.hpp>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
|
@ -48,8 +47,6 @@ public:
|
|||
/** fomo allocator type **/
|
||||
using AAllocator = xo::mm::AAllocator;
|
||||
/** fomo collector type **/
|
||||
using ACollector = xo::mm::ACollector;
|
||||
/** fomo collector type **/
|
||||
using AGCObjectVisitor = xo::mm::AGCObjectVisitor;
|
||||
/** hint arg when navigating object graph **/
|
||||
using VisitReason = xo::mm::VisitReason;
|
||||
|
|
|
|||
|
|
@ -9,10 +9,18 @@
|
|||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/Collector.json5]
|
||||
*
|
||||
* variables:
|
||||
* {facet_hpp_fname} -> Collector.hpp
|
||||
* {impl_hpp_subdir} -> gc
|
||||
* {facet_ns1} -> xo
|
||||
* {facet_detail_subdir} -> gc
|
||||
* {abstract_facet_fname} -> ACollector.hpp
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "ACollector.hpp"
|
||||
#include <xo/alloc2/Allocator_basic.hpp>
|
||||
#include <xo/alloc2/Generation.hpp>
|
||||
#include <xo/alloc2/role.hpp>
|
||||
|
|
|
|||
|
|
@ -9,10 +9,18 @@
|
|||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/GCObjectVisitor.json5]
|
||||
*
|
||||
* variables:
|
||||
* {facet_hpp_fname} -> GCObjectVisitor.hpp
|
||||
* {impl_hpp_subdir} -> gc
|
||||
* {facet_ns1} -> xo
|
||||
* {facet_detail_subdir} -> gc
|
||||
* {abstract_facet_fname} -> AGCObjectVisitor.hpp
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AGCObjectVisitor.hpp"
|
||||
#include <xo/alloc2/Generation.hpp>
|
||||
#include <xo/alloc2/role.hpp>
|
||||
#include <xo/alloc2/VisitReason.hpp>
|
||||
|
|
|
|||
|
|
@ -46,7 +46,6 @@ namespace mm {
|
|||
using typeseq = xo::facet::typeseq;
|
||||
using size_type = AGCObject::size_type;
|
||||
using AAllocator = AGCObject::AAllocator;
|
||||
using ACollector = AGCObject::ACollector;
|
||||
using AGCObjectVisitor = AGCObject::AGCObjectVisitor;
|
||||
using VisitReason = AGCObject::VisitReason;
|
||||
|
||||
|
|
|
|||
|
|
@ -9,12 +9,19 @@
|
|||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/GCObject.json5]
|
||||
*
|
||||
* variables:
|
||||
* {facet_hpp_fname} -> GCObject.hpp
|
||||
* {impl_hpp_subdir} -> gc
|
||||
* {facet_ns1} -> xo
|
||||
* {facet_detail_subdir} -> gc
|
||||
* {abstract_facet_fname} -> AGCObject.hpp
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AGCObject.hpp"
|
||||
#include <xo/alloc2/Allocator_basic.hpp>
|
||||
#include <xo/alloc2/Collector.hpp>
|
||||
#include <xo/alloc2/GCObjectVisitor.hpp>
|
||||
#include <cstdint>
|
||||
#include <cstddef>
|
||||
|
|
@ -34,7 +41,6 @@ namespace mm {
|
|||
using typeseq = AGCObject::typeseq;
|
||||
using size_type = AGCObject::size_type;
|
||||
using AAllocator = AGCObject::AAllocator;
|
||||
using ACollector = AGCObject::ACollector;
|
||||
using AGCObjectVisitor = AGCObject::AGCObjectVisitor;
|
||||
using VisitReason = AGCObject::VisitReason;
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -17,82 +17,6 @@ namespace xo {
|
|||
class ACollector;
|
||||
class AGCObject;
|
||||
|
||||
/** defined here to avoid #include cycle, since
|
||||
* template obj<AGCObject,DRepr> awkward to make available
|
||||
* in RCollector.hpp
|
||||
**/
|
||||
template <typename Object>
|
||||
template <typename DRepr>
|
||||
void
|
||||
RGCObjectVisitor<Object>::visit_child(VisitReason reason,
|
||||
xo::facet::obj<AGCObject,DRepr> * p_obj)
|
||||
{
|
||||
this->visit_child(reason, p_obj->iface(), (void **)&(p_obj->data_));
|
||||
}
|
||||
|
||||
template <typename Object>
|
||||
template <typename DRepr>
|
||||
void
|
||||
RGCObjectVisitor<Object>::visit_child(VisitReason reason, DRepr ** p_repr)
|
||||
{
|
||||
// fetch static interface for DRepr (strip const: FacetImplementation specializations use non-const DRepr)
|
||||
auto iface = xo::facet::impl_for<AGCObject, std::remove_const_t<DRepr>>();
|
||||
|
||||
this->visit_child(reason, &iface, (void **)p_repr);
|
||||
}
|
||||
|
||||
template <typename Object>
|
||||
template <typename AFacet, typename DRepr>
|
||||
requires (!std::is_same_v<AFacet, AGCObject>)
|
||||
void
|
||||
RGCObjectVisitor<Object>::visit_poly_child(VisitReason reason, obj<AFacet, DRepr> * p_objs)
|
||||
{
|
||||
if (*p_objs) {
|
||||
auto e = xo::facet::FacetRegistry::instance().variant<AGCObject,AFacet>(*p_objs);
|
||||
|
||||
this->visit_child(reason, e.iface(), (void **)&(p_objs->data_));
|
||||
}
|
||||
}
|
||||
|
||||
// ----- DEPRECATED -----
|
||||
//
|
||||
// Moving these methods to RGCObjectVisitor
|
||||
|
||||
/** defined here to avoid #include cycle, since
|
||||
* template obj<AGCObject,DRepr> awkward to make available
|
||||
* in RCollector.hpp
|
||||
**/
|
||||
template <typename Object>
|
||||
template <typename DRepr>
|
||||
void
|
||||
RCollector<Object>::forward_inplace(xo::facet::obj<AGCObject,DRepr> * p_obj)
|
||||
{
|
||||
this->forward_inplace(p_obj->iface(), (void **)&(p_obj->data_));
|
||||
}
|
||||
|
||||
template <typename Object>
|
||||
template <typename DRepr>
|
||||
void
|
||||
RCollector<Object>::forward_inplace(DRepr ** p_repr)
|
||||
{
|
||||
// fetch static interface for DRepr (strip const: FacetImplementation specializations use non-const DRepr)
|
||||
auto iface = xo::facet::impl_for<AGCObject, std::remove_const_t<DRepr>>();
|
||||
|
||||
this->forward_inplace(&iface, (void **)p_repr);
|
||||
}
|
||||
|
||||
template <typename Object>
|
||||
template <typename AFacet, typename DRepr>
|
||||
requires (!std::is_same_v<AFacet, AGCObject>)
|
||||
void
|
||||
RCollector<Object>::forward_pivot_inplace(obj<AFacet, DRepr> * p_objs)
|
||||
{
|
||||
if (*p_objs) {
|
||||
auto e = xo::facet::FacetRegistry::instance().variant<AGCObject,AFacet>(*p_objs);
|
||||
this->forward_inplace(e.iface(), (void **)&(p_objs->data_));
|
||||
}
|
||||
}
|
||||
|
||||
// ----- mm_do_assign -----
|
||||
|
||||
/** gc-aware assignment; engage special book-keeping for cross-gen pointers **/
|
||||
|
|
@ -110,6 +34,7 @@ namespace xo {
|
|||
*p_lhs = rhs;
|
||||
}
|
||||
};
|
||||
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,6 @@ public:
|
|||
using typeseq = xo::reflect::typeseq;
|
||||
using size_type = AGCObject::size_type;
|
||||
using AAllocator = AGCObject::AAllocator;
|
||||
using ACollector = AGCObject::ACollector;
|
||||
using AGCObjectVisitor = AGCObject::AGCObjectVisitor;
|
||||
using VisitReason = AGCObject::VisitReason;
|
||||
///@}
|
||||
|
|
|
|||
61
include/xo/alloc2/gc/RGCObjectVisitor_aux.hpp
Normal file
61
include/xo/alloc2/gc/RGCObjectVisitor_aux.hpp
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
/** @file RGCObjectVisitor_aux.hpp
|
||||
*
|
||||
* Out-of-line definitions for RCollector template methods
|
||||
* that depend on RGCObject (avoiding #include cycle in RCollector.hpp).
|
||||
*
|
||||
* Included via user_hpp_includes in GCObject.json5.
|
||||
*
|
||||
* @author Roland Conybeare
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "gc/RGCObjectVisitor.hpp"
|
||||
#include <xo/facet/FacetRegistry.hpp>
|
||||
|
||||
namespace xo {
|
||||
namespace mm {
|
||||
class ACollector;
|
||||
class AGCObject;
|
||||
|
||||
/** defined here to avoid #include cycle, since
|
||||
* template obj<AGCObject,DRepr> awkward to make available
|
||||
* in RCollector.hpp
|
||||
**/
|
||||
template <typename Object>
|
||||
template <typename DRepr>
|
||||
void
|
||||
RGCObjectVisitor<Object>::visit_child(VisitReason reason,
|
||||
xo::facet::obj<AGCObject,DRepr> * p_obj)
|
||||
{
|
||||
this->visit_child(reason, p_obj->iface(), (void **)&(p_obj->data_));
|
||||
}
|
||||
|
||||
template <typename Object>
|
||||
template <typename DRepr>
|
||||
void
|
||||
RGCObjectVisitor<Object>::visit_child(VisitReason reason, DRepr ** p_repr)
|
||||
{
|
||||
// fetch static interface for DRepr (strip const: FacetImplementation specializations use non-const DRepr)
|
||||
auto iface = xo::facet::impl_for<AGCObject, std::remove_const_t<DRepr>>();
|
||||
|
||||
this->visit_child(reason, &iface, (void **)p_repr);
|
||||
}
|
||||
|
||||
template <typename Object>
|
||||
template <typename AFacet, typename DRepr>
|
||||
requires (!std::is_same_v<AFacet, AGCObject>)
|
||||
void
|
||||
RGCObjectVisitor<Object>::visit_poly_child(VisitReason reason, obj<AFacet, DRepr> * p_objs)
|
||||
{
|
||||
if (*p_objs) {
|
||||
auto e = xo::facet::FacetRegistry::instance().variant<AGCObject,AFacet>(*p_objs);
|
||||
|
||||
this->visit_child(reason, e.iface(), (void **)&(p_objs->data_));
|
||||
}
|
||||
}
|
||||
|
||||
} /*namespace mm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end RCollector_aux.hpp */
|
||||
|
|
@ -14,7 +14,7 @@
|
|||
#pragma once
|
||||
|
||||
// includes (via {facet_includes})
|
||||
#include "Allocator_basic.hpp"
|
||||
#include "Allocator.hpp"
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <xo/facet/facet_implementation.hpp>
|
||||
#include <xo/facet/typeseq.hpp>
|
||||
|
|
|
|||
|
|
@ -9,10 +9,18 @@
|
|||
* [iface_facet_any.hpp.j2]
|
||||
* 3. idl for facet methods
|
||||
* [idl/ResourceVisitor.json5]
|
||||
*
|
||||
* variables:
|
||||
* {facet_hpp_fname} -> ResourceVisitor.hpp
|
||||
* {impl_hpp_subdir} -> visitor
|
||||
* {facet_ns1} -> xo
|
||||
* {facet_detail_subdir} -> visitor
|
||||
* {abstract_facet_fname} -> AResourceVisitor.hpp
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include "AResourceVisitor.hpp"
|
||||
#include "Allocator.hpp"
|
||||
|
||||
namespace xo {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue