xo-gc xo-object2 xo-facet: builds w/ ISequence,Dlist

This commit is contained in:
Roland Conybeare 2025-12-29 14:32:52 -05:00
commit 1a8d5fcabe
10 changed files with 35 additions and 23 deletions

View file

@ -5,7 +5,7 @@
#pragma once
#include "IGCObject_Any.hpp"
//#include "IGCObject_Any.hpp"
#include <xo/facet/facet_implementation.hpp>
#include <xo/facet/typeseq.hpp>
@ -22,6 +22,7 @@ namespace xo {
using Copaque = const void *;
using Opaque = void *;
struct AGCObject;
struct IGCObject_Any; // see IGCObject_Any.hpp
/** @class ACollector
@ -53,10 +54,12 @@ namespace xo {
virtual void install_type(Opaque d, int32_t tseq, IGCObject_Any & iface) = 0;
virtual void add_gc_root(Opaque d, int32_t tseq, Opaque * root) = 0;
/** evacuate @p *lhs to to-space and replace with forwarding pointer
/** 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 d, obj<AGCObject> * lhs) = 0;
virtual void forward_inplace(Opaque d, AGCObject * lhs_iface, void ** lhs_data) = 0;
};
}

View file

@ -17,6 +17,8 @@ namespace xo {
using Copaque = const void *;
using Opaque = void *;
struct ACollector;
/** @class AObject
* @brief Abstract facet for collector-eligible data
*
@ -30,9 +32,10 @@ namespace xo {
virtual int32_t _typeseq() const noexcept = 0;
virtual size_type shallow_size(Copaque d) const noexcept = 0;
virtual Opaque * shallow_copy(Copaque d,
obj<AAllocator> mm) const noexcept = 0;
virtual size_type forward_children(Opaque d) const noexcept = 0;
virtual Opaque shallow_copy(Copaque d,
obj<AAllocator> mm) const noexcept = 0;
virtual size_type forward_children(Opaque d,
obj<ACollector>) const noexcept = 0;
};
// implementation IGCObject_DRepr of AGCObject for state DRepr

View file

@ -36,7 +36,7 @@ namespace xo {
// non-const methods
[[noreturn]] void install_type(Opaque, int32_t, IGCObject_Any &) noexcept override { _fatal(); }
[[noreturn]] void add_gc_root(Opaque, int32_t, Opaque *) override { _fatal(); }
[[noreturn]] void forward_inplace(Opaque, obj<AGCObject> *) override { _fatal(); }
[[noreturn]] void forward_inplace(Opaque, AGCObject *, void **) override { _fatal(); }
private:
[[noreturn]] static void _fatal();

View file

@ -44,7 +44,7 @@ namespace xo {
static void install_type(DX1Collector & d,
int32_t seq, IGCObject_Any & iface);
static void add_gc_root(DX1Collector & d, int32_t tseq, Opaque * root);
static void forward_inplace(DX1Collector & d, obj<AGCObject> * lhs);
static void forward_inplace(DX1Collector & d, AGCObject * lhs_iface, void ** lhs_data);
static int32_t s_typeseq;
static bool _valid;

View file

@ -49,8 +49,8 @@ namespace xo {
void add_gc_root(Opaque d, int32_t tseq, Opaque * root) override {
I::add_gc_root(_dcast(d), tseq, root);
}
void forward_inplace(Opaque d, obj<AGCObject> * lhs) override {
I::forward_inplace(_dcast(d), lhs);
void forward_inplace(Opaque d, AGCObject * lhs_iface, void ** lhs_data) override {
I::forward_inplace(_dcast(d), lhs_iface, lhs_data);
}
private:

View file

@ -6,6 +6,7 @@
#pragma once
#include "AGCObject.hpp"
#include "Collector.hpp"
#include <new>
namespace xo {
@ -31,9 +32,10 @@ namespace xo {
int32_t _typeseq() const noexcept override { return s_typeseq; }
[[noreturn]] size_type shallow_size(Copaque) const noexcept override { _fatal(); }
[[noreturn]] Opaque * shallow_copy(Copaque,
obj<AAllocator>) const noexcept override { _fatal(); }
[[noreturn]] size_type forward_children(Opaque) const noexcept override { _fatal(); }
[[noreturn]] Opaque shallow_copy(Copaque,
obj<AAllocator>) const noexcept override { _fatal(); }
[[noreturn]] size_type forward_children(Opaque,
obj<ACollector>) const noexcept override { _fatal(); }
private:
[[noreturn]] static void _fatal();

View file

@ -6,6 +6,7 @@
#pragma once
#include "AGCObject.hpp"
#include "ACollector.hpp"
namespace xo {
namespace mm {
@ -28,16 +29,17 @@ namespace xo {
int32_t _typeseq() const noexcept override { return s_typeseq; }
size_type shallow_size(Copaque d) const noexcept override {
return I::shallow_copy(_dcast(d));
return I::shallow_size(_dcast(d));
}
Opaque * shallow_copy(Copaque d, obj<AAllocator> mm) const noexcept override {
return I::shallow_size(_dcast(d), mm);
Opaque shallow_copy(Copaque d, obj<AAllocator> mm) const noexcept override {
return I::shallow_copy(_dcast(d), mm);
}
// non-const methods
size_type forward_children(Opaque d) const noexcept override {
return I::forward_children(d);
size_type forward_children(Opaque d,
obj<ACollector> gc) const noexcept override {
return I::forward_children(_dcast(d), gc);
}
private:

View file

@ -30,7 +30,7 @@ namespace xo {
void install_type(int32_t tseq, IGCObject_Any & iface) { return O::iface()->install_type(O::data(), tseq, iface); }
void add_gc_root(int32_t tseq, Opaque * root) { O::iface()->add_gc_root(O::data(), tseq, root); }
void forward_inplace(obj<AGCObject> * lhs) { O::iface()->forward_inplace(O::data(), lhs); }
void forward_inplace(AGCObject * lhs_iface, void ** lhs_data) { O::iface()->forward_inplace(O::data(), lhs_iface, lhs_data); }
static bool _valid;
};

View file

@ -25,7 +25,7 @@ namespace xo {
int32_t _typeseq() const noexcept { return O::iface()->_typeseq(); }
size_type shallow_size() const noexcept { O::iface()->shallow_size(O::data()); }
Opaque * shallow_copy(obj<AAllocator> mm) const noexcept { O::iface()->shallow_copy(O::data(), mm); }
Opaque shallow_copy(obj<AAllocator> mm) const noexcept { O::iface()->shallow_copy(O::data(), mm); }
size_type forward_children() noexcept { O::iface()->forward_children(O::data()); }
static bool _valid;

View file

@ -73,8 +73,10 @@ namespace xo {
void
ICollector_DX1Collector::forward_inplace(DX1Collector & d,
obj<AGCObject> * lhs)
AGCObject * lhs_iface,
void ** lhs_data)
{
(void)lhs_iface;
assert(d.runstate_.is_running());
/*
@ -90,7 +92,7 @@ namespace xo {
* +----------+
*/
void * object_data = (byte *)(*lhs).opaque_data();
void * object_data = (byte *)lhs_data;
if (!d.contains(role::from_space(), object_data)) {
/* *lhs isn't in GC-allocated space.
@ -143,7 +145,7 @@ namespace xo {
void * dest = *(void**)object_data;
/* update *lhs in-place */
(*lhs).reset_opaque(dest);
*lhs_data = dest;
} else if (check_move_policy(d, alloc_hdr, object_data)) {
/* copy object *lhs + replace with forwarding pointer */