From 3d6ad3709b28f28b8aed66162c450a7a97311aee Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Fri, 1 May 2026 19:54:26 -0400 Subject: [PATCH] refactor focusing on xo-alloc2/ xo-gc/ write-barrier ability to inform allocator of gco->gco mutation, via AAllocator i/face. --- include/xo/gc/DX1Collector.hpp | 8 ++++++++ include/xo/gc/detail/IAllocator_DX1Collector.hpp | 9 +++++++++ src/gc/DX1Collector.cpp | 15 ++++++++++++++- src/gc/GCObjectStore.cpp | 10 +++++----- src/gc/IAllocator_DX1Collector.cpp | 11 +++++++++++ utest/Collector.test.cpp | 2 -- utest/GcosTestutil.cpp | 4 ++-- 7 files changed, 49 insertions(+), 10 deletions(-) diff --git a/include/xo/gc/DX1Collector.hpp b/include/xo/gc/DX1Collector.hpp index a582ed8..84e04c5 100644 --- a/include/xo/gc/DX1Collector.hpp +++ b/include/xo/gc/DX1Collector.hpp @@ -334,6 +334,14 @@ namespace xo { /** discard all allocated memory **/ void clear() noexcept; + /** perform fop assignment of (rhs_iface,rhs_data) + * to (lhs_iface,lhs_data) within allocation @parent + * + create mlog entry if necessary. + **/ + void barrier_assign_aux(void * parent, + AGCObject * lhs_iface, void ** lhs_data, + AGCObject * rhs_iface, void * rhs_data); + private: /** aux init function: initialize @ref roots_ arena **/ void _init_gc_roots(const X1CollectorConfig & cfg, std::size_t page_z); diff --git a/include/xo/gc/detail/IAllocator_DX1Collector.hpp b/include/xo/gc/detail/IAllocator_DX1Collector.hpp index ca52999..f61d9fa 100644 --- a/include/xo/gc/detail/IAllocator_DX1Collector.hpp +++ b/include/xo/gc/detail/IAllocator_DX1Collector.hpp @@ -71,6 +71,15 @@ namespace xo { /** reset to empty state; clears all generations **/ static void clear(DX1Collector & d); + /** assignment of fop (rhs_iface,rhs_data) to (lhs_iface, lhs_data) + * with write barrier (creating mlog entry if creating older->younger pointer + **/ + static void barrier_assign_aux(DX1Collector & d, + void * parent, + AGCObject * lhs_iface, + void ** lhs_data, + AGCObject * rhs_iface, + void * rhs_data); /** invoke destructor **/ static void destruct_data(DX1Collector & d); }; diff --git a/src/gc/DX1Collector.cpp b/src/gc/DX1Collector.cpp index 239f999..af7adff 100644 --- a/src/gc/DX1Collector.cpp +++ b/src/gc/DX1Collector.cpp @@ -14,7 +14,7 @@ #include #include -#include +//#include #include #include "object_age.hpp" #include @@ -691,6 +691,19 @@ namespace xo { } } } + + void + DX1Collector::barrier_assign_aux(void * parent, + AGCObject * lhs_iface, void ** lhs_data, + AGCObject * rhs_iface, void * rhs_data) + { + scope log(XO_DEBUG(config_.debug_flag_), + xtag("parent", parent), + xtag("lhs.iface", lhs_iface), xtag("&lhs.data", lhs_data), + xtag("rhs.iface", rhs_iface), xtag("rhs.data", rhs_data)); + + // see .assign_member() + } } /*namespace mm*/ } /*namespace xo*/ diff --git a/src/gc/GCObjectStore.cpp b/src/gc/GCObjectStore.cpp index 0dc5ed3..3be2512 100644 --- a/src/gc/GCObjectStore.cpp +++ b/src/gc/GCObjectStore.cpp @@ -346,7 +346,7 @@ namespace xo { recd->upsert_cstr(mm, "n-live", DInteger::box(mm, 0)); recd->upsert_cstr(mm, "bytes", DInteger::box(mm, 0)); - stats_v->assign_at(mm.try_to_facet(), + stats_v->assign_at(mm, //mm.try_to_facet(), tseq.seqno(), obj(recd)); } } @@ -392,9 +392,9 @@ namespace xo { auto recd = stats_v->at(i); if (recd) { - obj gc = mm.try_to_facet(); + //obj mm = mm.try_to_facet(); - bool ok = final_stats_v->push_back(gc, recd); + bool ok = final_stats_v->push_back(mm, recd); assert(ok); } } @@ -451,9 +451,9 @@ namespace xo { recd->upsert_cstr(mm, "n-live", DInteger::box(mm, 0)); recd->upsert_cstr(mm, "bytes", DInteger::box(mm, 0)); - obj gc = mm.try_to_facet(); + //obj gc = mm.try_to_facet(); - stats_v->push_back(gc, obj(recd)); + stats_v->push_back(mm, obj(recd)); } log && log(xtag("soft_max_age", soft_max_age), diff --git a/src/gc/IAllocator_DX1Collector.cpp b/src/gc/IAllocator_DX1Collector.cpp index c0c93d6..cf307e0 100644 --- a/src/gc/IAllocator_DX1Collector.cpp +++ b/src/gc/IAllocator_DX1Collector.cpp @@ -133,6 +133,17 @@ namespace xo { d.clear(); } + void + IAllocator_DX1Collector::barrier_assign_aux(DX1Collector & d, + void * parent, + AGCObject * lhs_iface, + void ** lhs_data, + AGCObject * rhs_iface, + void * rhs_data) + { + d.barrier_assign_aux(parent, lhs_iface, lhs_data, rhs_iface, rhs_data); + } + void IAllocator_DX1Collector::destruct_data(DX1Collector & d) { diff --git a/utest/Collector.test.cpp b/utest/Collector.test.cpp index 94baeb5..117f4eb 100644 --- a/utest/Collector.test.cpp +++ b/utest/Collector.test.cpp @@ -13,8 +13,6 @@ #include #include #include -//#include "detail/ICollector_DX1Collector.hpp" -//#include "detail/IAllocator_DX1Collector.hpp" #include #include #include diff --git a/utest/GcosTestutil.cpp b/utest/GcosTestutil.cpp index 27e09b9..220be25 100644 --- a/utest/GcosTestutil.cpp +++ b/utest/GcosTestutil.cpp @@ -524,14 +524,14 @@ namespace ut { assert(p_mls); assert(mockgc); - lhs1->assign_head(mockgc, rhs1); + lhs1->assign_head_gc(mockgc, rhs1); // alloc2 is ord arena -> no mlog } break; } if (is_alloc) { - p_x1_v->push_back(Recd(xi, alloc_z, tseq)); + p_x1_v->push_back(Recd(xi, alloc_z, tseq)); p_x2_v->push_back(Recd(xi2, alloc_z, tseq)); } }