refactor focusing on xo-alloc2/ xo-gc/ write-barrier

ability to inform allocator of gco->gco mutation, via AAllocator i/face.
This commit is contained in:
Roland Conybeare 2026-05-01 19:54:26 -04:00
commit 3d6ad3709b
7 changed files with 49 additions and 10 deletions

View file

@ -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);

View file

@ -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);
};

View file

@ -14,7 +14,7 @@
#include <xo/stringtable2/String.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/alloc2/Allocator.hpp>
//#include <xo/alloc2/Allocator_extra.hpp>
#include <xo/alloc2/Arena.hpp>
#include "object_age.hpp"
#include <xo/facet/obj.hpp>
@ -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*/

View file

@ -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<ACollector>(),
stats_v->assign_at(mm, //mm.try_to_facet<ACollector>(),
tseq.seqno(), obj<AGCObject,DDictionary>(recd));
}
}
@ -392,9 +392,9 @@ namespace xo {
auto recd = stats_v->at(i);
if (recd) {
obj<ACollector> gc = mm.try_to_facet<ACollector>();
//obj<AAllocator> mm = mm.try_to_facet<ACollector>();
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<ACollector> gc = mm.try_to_facet<ACollector>();
//obj<ACollector> gc = mm.try_to_facet<ACollector>();
stats_v->push_back(gc, obj<AGCObject,DDictionary>(recd));
stats_v->push_back(mm, obj<AGCObject,DDictionary>(recd));
}
log && log(xtag("soft_max_age", soft_max_age),

View file

@ -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)
{

View file

@ -13,8 +13,6 @@
#include <xo/object2/Array.hpp>
#include <xo/object2/List.hpp>
#include <xo/object2/Integer.hpp>
//#include "detail/ICollector_DX1Collector.hpp"
//#include "detail/IAllocator_DX1Collector.hpp"
#include <xo/alloc2/Allocator.hpp>
#include <xo/randomgen/xoshiro256.hpp>
#include <xo/randomgen/random_seed.hpp>

View file

@ -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));
}
}