refactor: retire GCObject.shallow_copy()
Collector gets this info from gc-owned object header
This commit is contained in:
parent
30dee1b97f
commit
e6c789b4e6
19 changed files with 26 additions and 183 deletions
|
|
@ -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 <xo/alloc2/GCObject.hpp>
|
||||
#include <xo/alloc2/Allocator.hpp>
|
||||
#include "DLocalEnv.hpp"
|
||||
|
||||
namespace xo { namespace scm { class IGCObject_DLocalEnv; } }
|
||||
|
||||
namespace xo {
|
||||
namespace facet {
|
||||
template <>
|
||||
struct FacetImplementation<xo::mm::AGCObject,
|
||||
xo::scm::DLocalEnv>
|
||||
{
|
||||
using ImplType = xo::mm::IGCObject_Xfer
|
||||
<xo::scm::DLocalEnv,
|
||||
xo::scm::IGCObject_DLocalEnv>;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
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<AAllocator> mm) noexcept;
|
||||
|
||||
// non-const methods
|
||||
/** during GC: forward immdiate children **/
|
||||
static size_type forward_children(DLocalEnv & self, obj<ACollector> gc) noexcept;
|
||||
///@}
|
||||
};
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
/* end */
|
||||
|
|
@ -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<ACollector> gc) noexcept;
|
||||
/** forward elements to @p gc to-space; replace originals with forarding pointers **/
|
||||
AAllocator::size_type forward_children(obj<ACollector> gc) noexcept;
|
||||
void forward_children(obj<ACollector> gc) noexcept;
|
||||
///@}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -37,9 +37,8 @@ namespace xo {
|
|||
|
||||
// GCObject facet
|
||||
|
||||
std::size_t shallow_size() const noexcept;
|
||||
DBoolean * shallow_move(obj<ACollector> gc) noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
void forward_children(obj<ACollector> gc) noexcept;
|
||||
|
||||
private:
|
||||
/** boxed boolean value **/
|
||||
|
|
|
|||
|
|
@ -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<ACollector> gc) noexcept;
|
||||
/** forward elements to @p gc to-space; replace originals with forarding pointers **/
|
||||
AAllocator::size_type forward_children(obj<ACollector> gc) noexcept;
|
||||
/** forward elements to @p gc to-space; replace originals with forwarding pointers **/
|
||||
void forward_children(obj<ACollector> gc) noexcept;
|
||||
///@}
|
||||
|
||||
private:
|
||||
|
|
|
|||
|
|
@ -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<ACollector> gc) noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
void forward_children(obj<ACollector> gc) noexcept;
|
||||
|
||||
private:
|
||||
|
||||
|
|
|
|||
|
|
@ -39,9 +39,8 @@ namespace xo {
|
|||
|
||||
// GCObject facet
|
||||
|
||||
std::size_t shallow_size() const noexcept;
|
||||
DInteger * shallow_move(obj<ACollector> gc) noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
void forward_children(obj<ACollector> gc) noexcept;
|
||||
|
||||
private:
|
||||
/** boxed integer value **/
|
||||
|
|
|
|||
|
|
@ -69,9 +69,8 @@ namespace xo {
|
|||
|
||||
/** @defgroup xo-scm-list-gcobject-facet gcobject facet **/
|
||||
///@{
|
||||
size_type shallow_size() const noexcept;
|
||||
DList * shallow_move(obj<ACollector> gc) noexcept;
|
||||
size_type forward_children(obj<ACollector> gc) noexcept;
|
||||
void forward_children(obj<ACollector> gc) noexcept;
|
||||
///@}
|
||||
|
||||
/** first member of list **/
|
||||
|
|
|
|||
|
|
@ -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<AAllocator> mm) const noexcept;
|
||||
/** forward elements to @p gc to-space; replace originals with forarding pointers **/
|
||||
AAllocator::size_type forward_children(obj<ACollector> gc) noexcept;
|
||||
///@}
|
||||
|
|
|
|||
|
|
@ -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<AGCObject>));
|
||||
}
|
||||
|
||||
DArray *
|
||||
DArray::shallow_move(obj<ACollector> gc) noexcept
|
||||
{
|
||||
|
|
@ -203,7 +197,7 @@ namespace xo {
|
|||
return copy;
|
||||
}
|
||||
|
||||
std::size_t
|
||||
void
|
||||
DArray::forward_children(obj<ACollector> gc) noexcept
|
||||
{
|
||||
scope log(XO_DEBUG(false));
|
||||
|
|
@ -215,8 +209,6 @@ namespace xo {
|
|||
|
||||
gc.forward_inplace(&elt);
|
||||
}
|
||||
|
||||
return shallow_size();
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -29,22 +29,16 @@ namespace xo {
|
|||
(value_ ? "true" : "false"));
|
||||
}
|
||||
|
||||
size_t
|
||||
DBoolean::shallow_size() const noexcept
|
||||
{
|
||||
return sizeof(DBoolean);
|
||||
}
|
||||
|
||||
DBoolean *
|
||||
DBoolean::shallow_move(obj<ACollector> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
size_t
|
||||
void
|
||||
DBoolean::forward_children(obj<ACollector>) noexcept
|
||||
{
|
||||
return shallow_size();
|
||||
// no-op
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -267,26 +267,18 @@ namespace xo {
|
|||
|
||||
// ----- gcobject facet -----
|
||||
|
||||
std::size_t
|
||||
DDictionary::shallow_size() const noexcept
|
||||
{
|
||||
return sizeof(DDictionary);
|
||||
}
|
||||
|
||||
DDictionary *
|
||||
DDictionary::shallow_move(obj<ACollector> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
std::size_t
|
||||
void
|
||||
DDictionary::forward_children(obj<ACollector> gc) noexcept
|
||||
{
|
||||
|
||||
gc.forward_inplace(&keys_);
|
||||
gc.forward_inplace(&values_);
|
||||
|
||||
return this->shallow_size();
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -27,22 +27,16 @@ namespace xo {
|
|||
return ppdetail_atomic<double>::print_pretty(ppii, value_);
|
||||
}
|
||||
|
||||
size_t
|
||||
DFloat::shallow_size() const noexcept
|
||||
{
|
||||
return sizeof(DFloat);
|
||||
}
|
||||
|
||||
DFloat *
|
||||
DFloat::shallow_move(obj<ACollector> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
size_t
|
||||
void
|
||||
DFloat::forward_children(obj<ACollector>) noexcept
|
||||
{
|
||||
return shallow_size();
|
||||
// noop
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -27,25 +27,18 @@ namespace xo {
|
|||
return ppdetail_atomic<long>::print_pretty(ppii, value_);
|
||||
}
|
||||
|
||||
size_t
|
||||
DInteger::shallow_size() const noexcept
|
||||
{
|
||||
return sizeof(DInteger);
|
||||
}
|
||||
|
||||
DInteger *
|
||||
DInteger::shallow_move(obj<ACollector> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
size_t
|
||||
void
|
||||
DInteger::forward_children(obj<ACollector>) noexcept
|
||||
{
|
||||
return shallow_size();
|
||||
// no-op
|
||||
}
|
||||
|
||||
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
||||
|
|
|
|||
|
|
@ -178,31 +178,19 @@ namespace xo {
|
|||
|
||||
// ----- GCObject facet ------
|
||||
|
||||
auto
|
||||
DList::shallow_size() const noexcept -> size_type
|
||||
{
|
||||
return sizeof(DList);
|
||||
}
|
||||
|
||||
DList *
|
||||
DList::shallow_move(obj<ACollector> gc) noexcept
|
||||
{
|
||||
return gc.std_move_for(this);
|
||||
}
|
||||
|
||||
auto
|
||||
DList::forward_children(obj<ACollector> gc) noexcept -> size_type
|
||||
void
|
||||
DList::forward_children(obj<ACollector> 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<AGCObject,DList>();
|
||||
//gc.forward_inplace(&iface, (void **)(&rest_));
|
||||
|
||||
return this->shallow_size();
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
|
|
|||
|
|
@ -133,9 +133,8 @@ namespace xo {
|
|||
///@}
|
||||
/** @defgroup scm-primitive-gcobject-facet **/
|
||||
///@{
|
||||
std::size_t shallow_size() const noexcept;
|
||||
Primitive * shallow_move(obj<ACollector> gc) noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
void forward_children(obj<ACollector> gc) noexcept;
|
||||
///@}
|
||||
|
||||
private:
|
||||
|
|
@ -190,12 +189,6 @@ namespace xo {
|
|||
refrtag("fn", fn_));
|
||||
}
|
||||
|
||||
template <typename Fn>
|
||||
std::size_t
|
||||
Primitive<Fn>::shallow_size() const noexcept {
|
||||
return sizeof(*this);
|
||||
}
|
||||
|
||||
template <typename Fn>
|
||||
Primitive<Fn> *
|
||||
Primitive<Fn>::shallow_move(obj<ACollector> gc) noexcept {
|
||||
|
|
@ -203,14 +196,12 @@ namespace xo {
|
|||
}
|
||||
|
||||
template <typename Fn>
|
||||
std::size_t
|
||||
void
|
||||
Primitive<Fn>::forward_children(obj<ACollector> gc) noexcept {
|
||||
{
|
||||
auto e = type_.to_facet<AGCObject>(); // FacetRegistry dep
|
||||
gc.forward_inplace(e.iface(), (void **)&(type_.data_));
|
||||
}
|
||||
|
||||
return this->shallow_size();
|
||||
}
|
||||
|
||||
} /*namespace scm*/
|
||||
|
|
|
|||
|
|
@ -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<AAllocator> mm) const noexcept;
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
#endif
|
||||
/** update gc-aware exit pointers from this ParserStateMachine **/
|
||||
void forward_children(obj<ACollector> gc) noexcept;
|
||||
|
||||
|
|
|
|||
|
|
@ -897,19 +897,12 @@ namespace xo {
|
|||
// ----- gc support -----
|
||||
|
||||
#ifdef OBSOLETE
|
||||
std::size_t
|
||||
ParserStateMachine::shallow_size() const noexcept
|
||||
void
|
||||
ParserStateMachine::shallow_copy(obj<ACollector> gc) noexcept
|
||||
{
|
||||
return sizeof(ParserStateMachine);
|
||||
}
|
||||
|
||||
ParserStateMachine *
|
||||
ParserStateMachine::shallow_copy(obj<AAllocator> mm) const noexcept
|
||||
{
|
||||
(void)mm;
|
||||
(void)gc;
|
||||
|
||||
assert(false);
|
||||
return nullptr;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -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<ACollector> gc) noexcept;
|
||||
|
||||
/** fixup child pointers (trivial for DUniqueString, no gc-owned children **/
|
||||
std::size_t forward_children(obj<ACollector> gc) noexcept;
|
||||
void forward_children(obj<ACollector> gc) noexcept;
|
||||
|
||||
///@}
|
||||
|
||||
|
|
|
|||
|
|
@ -81,12 +81,6 @@ namespace xo {
|
|||
return result;
|
||||
}
|
||||
|
||||
size_t
|
||||
DUniqueString::shallow_size() const noexcept
|
||||
{
|
||||
return sizeof(DUniqueString);
|
||||
}
|
||||
|
||||
DUniqueString *
|
||||
DUniqueString::shallow_move(obj<ACollector> gc) noexcept
|
||||
{
|
||||
|
|
@ -114,10 +108,10 @@ namespace xo {
|
|||
return copy;
|
||||
}
|
||||
|
||||
size_t
|
||||
void
|
||||
DUniqueString::forward_children(obj<ACollector>) noexcept
|
||||
{
|
||||
return shallow_size();
|
||||
// no-op
|
||||
}
|
||||
} /*namespace scm*/
|
||||
} /*namespace xo*/
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue