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 ca79d06be4
3 changed files with 17 additions and 16 deletions

View file

@ -111,7 +111,7 @@ namespace xo {
{
scope log(XO_DEBUG(false), std::string_view(*var->name()));
auto gc = mm.try_to_facet<ACollector>();
//auto gc = mm.try_to_facet<ACollector>();
// It's possible there's already a global variable
// with the same name.
@ -136,7 +136,10 @@ namespace xo {
// replacing previous one
//
log && log("STUB: need write barrier");
(*vars_)[existing->path().j_slot()] = obj<AGCObject,DVariable>(var);
vars_->assign_at(mm,
existing->path().j_slot(),
obj<AGCObject,DVariable>(var));
//(*vars_)[existing->path().j_slot()] = obj<AGCObject,DVariable>(var);
} else {
log && log("variable is new");
@ -168,7 +171,7 @@ namespace xo {
// need slot# in .map_ for this unique symbol
(*var_map_)[var->name()] = binding.j_slot();
vars_->push_back(gc, obj<AGCObject,DVariable>(var));
vars_->push_back(mm, obj<AGCObject,DVariable>(var));
}
}
@ -194,7 +197,7 @@ namespace xo {
scope log(XO_DEBUG(true),
std::string_view(*tname->name()));
auto gc = mm.try_to_facet<ACollector>();
//auto gc = mm.try_to_facet<ACollector>();
auto ix = type_map_->find(tname->name());
@ -223,12 +226,12 @@ namespace xo {
(*type_map_)[tname->name()] = n;
log && log("STUB: need write barrier");
types_->push_back(gc, obj<AGCObject,DTypename>(tname));
types_->push_back(mm, obj<AGCObject,DTypename>(tname));
} else {
Binding::slot_type i_slot = ix->second;
log && log("STUB: need write barrier");
types_->assign_at(gc, i_slot,
types_->assign_at(mm, i_slot,
obj<AGCObject,DTypename>(tname));
}
}

View file

@ -70,8 +70,8 @@ namespace xo {
DVariable * var = DVariable::make(mm, name, typeref, binding);
auto gc = mm.try_to_facet<ACollector>();
vars_->push_back(gc, obj<AGCObject,DVariable>(var));
//auto gc = mm.try_to_facet<ACollector>();
vars_->push_back(mm, obj<AGCObject,DVariable>(var));
return binding;
}
@ -89,8 +89,8 @@ namespace xo {
} else {
obj<AGCObject> tname = DTypename::make(mm, name, type);
auto gc = mm.try_to_facet<ACollector>();
types_->push_back(gc, tname);
//auto gc = mm.try_to_facet<ACollector>();
types_->push_back(mm, tname);
}
}

View file

@ -5,8 +5,7 @@
#include "DSequenceExpr.hpp"
#include "detail/IExpression_DSequenceExpr.hpp"
#include <xo/object2/array/IGCObject_DArray.hpp>
#include <xo/object2/array/IPrintable_DArray.hpp>
#include <xo/object2/Array.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/alloc2/Allocator.hpp>
#include <xo/printable2/Printable.hpp>
@ -15,7 +14,6 @@
#include <xo/reflectutil/typeseq.hpp>
namespace xo {
using xo::mm::ACollector;
using xo::mm::AGCObject;
using xo::print::APrintable;
using xo::facet::FacetRegistry;
@ -75,7 +73,7 @@ namespace xo {
obj<AExpression> expr)
{
// null gc -> no write barrier
obj<ACollector> gc = mm.try_to_facet<ACollector>();
//obj<ACollector> gc = mm.try_to_facet<ACollector>();
if (expr_v_->size() == expr_v_->capacity()) {
/* reallocate+expand */
@ -84,7 +82,7 @@ namespace xo {
= DArray::_empty(mm, 2 * expr_v_->capacity());
for (size_type i = 0, z = expr_v_->size(); i < z; ++i) {
expr_2x_v->push_back(gc, (*expr_2x_v)[i]);
expr_2x_v->push_back(mm, (*expr_2x_v)[i]);
}
this->expr_v_ = expr_2x_v;
@ -92,7 +90,7 @@ namespace xo {
obj<AGCObject> expr_gco = expr.to_facet<AGCObject>();
this->expr_v_->push_back(gc, expr_gco);
this->expr_v_->push_back(mm, expr_gco);
}
void