diff --git a/xo-alloc2/include/xo/alloc2/Allocator.hpp b/xo-alloc2/include/xo/alloc2/Allocator.hpp index 63ffdb2e..096b7b8d 100644 --- a/xo-alloc2/include/xo/alloc2/Allocator.hpp +++ b/xo-alloc2/include/xo/alloc2/Allocator.hpp @@ -10,4 +10,6 @@ #include "alloc/IAllocator_Xfer.hpp" #include "alloc/RAllocator.hpp" +#include "alloc/RAllocator_aux.hpp" + /* end Allocator.hpp */ diff --git a/xo-alloc2/include/xo/alloc2/Allocator_basic.hpp b/xo-alloc2/include/xo/alloc2/Allocator_basic.hpp new file mode 100644 index 00000000..df998cd5 --- /dev/null +++ b/xo-alloc2/include/xo/alloc2/Allocator_basic.hpp @@ -0,0 +1,15 @@ +/** @file Allocator_basic.hpp + * + * @author Roland Conybeare, Dec 2025 + **/ + +#pragma once + +#include "alloc/AAllocator.hpp" +#include "alloc/IAllocator_Any.hpp" +#include "alloc/IAllocator_Xfer.hpp" +#include "alloc/RAllocator.hpp" + +//#include "alloc/RAllocator_aux.hpp" + +/* end Allocator_basic.hpp */ diff --git a/xo-alloc2/include/xo/alloc2/alloc/AAllocator.hpp b/xo-alloc2/include/xo/alloc2/alloc/AAllocator.hpp index 2fd71285..fdf57831 100644 --- a/xo-alloc2/include/xo/alloc2/alloc/AAllocator.hpp +++ b/xo-alloc2/include/xo/alloc2/alloc/AAllocator.hpp @@ -20,8 +20,8 @@ namespace xo { using Copaque = const void *; using Opaque = void *; - // see DArena.hpp - struct DArena; + class AGCObject; // see AGCObject.hpp + struct DArena; // see DArena.hpp /** @class AAllocator * @brief Abstract facet for allocation @@ -34,6 +34,7 @@ namespace xo { public: /** @defgroup mm-allocator-type-traits allocator type traits **/ ///@{ + using AGCObject = xo::mm::AGCObject; /** memory size report **/ using MemorySizeInfo = xo::mm::MemorySizeInfo; /** type used for allocation amounts **/ @@ -155,6 +156,28 @@ namespace xo { virtual value_type alloc_copy(Opaque d, value_type src) const = 0; /** reset allocator @p d to empty state. **/ virtual void clear(Opaque d) const = 0; + /** assign helper for allocator that may require a write barrier + * (for example Collector). Using obj here causes + * include cycle, use spelled out form instead; + * + * For: + * obj lhs_ = rhs + * with allocator d, that owns some allocaiton p, would use + * mm.barrier_assign_aux(d, p, + * lhs_.iface(), lhs_.opaque_data_addr(), + * rhs.iface(), rhs.opaque_data()); + * when lhs has known data type: + * DRepr * lhs_ = rhs.data(); + * use + * mm.barrier_assign_aux(d, p, + * nullptr, lhs_.opaque_data_addr(), + * rhs.iface(), rhs.opaque_data()); + * barrier needs to be able to construct complete fop for rhs + * to administrate write barrier. + **/ + virtual void barrier_assign_aux(Opaque d, void * parent, + AGCObject * lhs_iface, void ** lhs_data, + AGCObject * rhs_iface, void * rhs_data) const = 0; ///@} }; /*AAllocator*/ diff --git a/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Any.hpp b/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Any.hpp index fa8c14ab..0aafca45 100644 --- a/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Any.hpp +++ b/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Any.hpp @@ -60,6 +60,10 @@ namespace xo { [[noreturn]] value_type sub_alloc(Opaque, std::size_t, bool) const override { _fatal(); } [[noreturn]] value_type alloc_copy(Opaque, value_type) const override { _fatal(); } [[noreturn]] void clear(Opaque) const override { _fatal(); } + [[noreturn]] void barrier_assign_aux(Opaque, + void *, + AGCObject *, void **, + AGCObject *, void *) const override { _fatal(); } private: [[noreturn]] static void _fatal(); diff --git a/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Xfer.hpp b/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Xfer.hpp index e5b539a1..3343559b 100644 --- a/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Xfer.hpp +++ b/xo-alloc2/include/xo/alloc2/alloc/IAllocator_Xfer.hpp @@ -78,6 +78,10 @@ namespace xo { value_type alloc_copy(Opaque d, value_type src) const override { return I::alloc_copy(_dcast(d), src); } void clear(Opaque d) const override { return I::clear(_dcast(d)); } + void barrier_assign_aux(Opaque d, + void * parent, + AGCObject * lhs_iface, void ** lhs_data, + AGCObject * rhs_iface, void * rhs_data) const override { I::barrier_assign_aux(_dcast(d), parent, lhs_iface, lhs_data, rhs_iface, rhs_data); } ///@} private: diff --git a/xo-alloc2/include/xo/alloc2/alloc/RAllocator.hpp b/xo-alloc2/include/xo/alloc2/alloc/RAllocator.hpp index 1d04d9cb..e9fa633c 100644 --- a/xo-alloc2/include/xo/alloc2/alloc/RAllocator.hpp +++ b/xo-alloc2/include/xo/alloc2/alloc/RAllocator.hpp @@ -5,7 +5,7 @@ #pragma once -#include "AAllocator.hpp" +#include "Allocator_basic.hpp" // omits RAllocator_aux #include "AllocIterator.hpp" #include #include @@ -66,13 +66,30 @@ namespace xo { AllocInfo alloc_info(value_type mem) const noexcept { return O::iface()->alloc_info(O::data(), mem); } range_type alloc_range(DArena & mm) const noexcept { return O::iface()->alloc_range(O::data(), mm); } + bool expand(size_type z) { return O::iface()->expand(O::data(), z); } value_type alloc(typeseq t, size_type z) noexcept { return O::iface()->alloc(O::data(), t, z); } value_type super_alloc(typeseq t, size_type z) noexcept { return O::iface()->super_alloc(O::data(), t, z); } value_type sub_alloc(size_type z, bool complete_flag) noexcept { return O::iface()->sub_alloc(O::data(), z, complete_flag); } value_type alloc_copy(value_type src) noexcept { return O::iface()->alloc_copy(O::data(), src); } - bool expand(size_type z) { return O::iface()->expand(O::data(), z); } + void clear() { O::iface()->clear(O::data()); } + void barrier_assign_aux(void * parent, + AGCObject * lhs_iface, void ** lhs_data, + AGCObject * rhs_iface, void * rhs_data) noexcept { O::iface()->barrier_assign_aux(O::data(), parent, + lhs_iface, lhs_data, + rhs_iface, rhs_data); } + + void barrier_assign(void * parent, + obj * p_lhs, + obj rhs) noexcept; +#ifdef NOT_YET + this->barrier_assign_aux(parent, + p_lhs->iface(), + p_lhs->opaque_data_addr(), + rhs.iface(), + rhs.opaque_data()); +#endif static bool _valid; }; diff --git a/xo-alloc2/include/xo/alloc2/alloc/RAllocator_aux.hpp b/xo-alloc2/include/xo/alloc2/alloc/RAllocator_aux.hpp new file mode 100644 index 00000000..2b296a90 --- /dev/null +++ b/xo-alloc2/include/xo/alloc2/alloc/RAllocator_aux.hpp @@ -0,0 +1,34 @@ +/** @file RAllocator_aux.hpp + * + * Out-of-line definitions for RAllocator template methods + * that depend on RGCObject (avoiding #include cycle in RAllocator.hpp) + * + * Would aspire to Include via user_hpp_includes in Allocator.json5, + * if/when that exists + * + * @author Roland Conybeare + **/ + +#pragma once + +#include "RAllocator.hpp" +#include "GCObject.hpp" + +namespace xo { + namespace mm { + + template + void + RAllocator::barrier_assign(void * parent, + obj * p_lhs, + obj rhs) noexcept + { + (void)parent; + (void)p_lhs; + (void)rhs; + } + + } /*namespace mm*/ +} /*namespace xo*/ + +/* end RAllocator_aux.hpp */ diff --git a/xo-alloc2/include/xo/alloc2/arena/IAllocator_DArena.hpp b/xo-alloc2/include/xo/alloc2/arena/IAllocator_DArena.hpp index 81e92211..0512cd57 100644 --- a/xo-alloc2/include/xo/alloc2/arena/IAllocator_DArena.hpp +++ b/xo-alloc2/include/xo/alloc2/arena/IAllocator_DArena.hpp @@ -75,6 +75,11 @@ namespace xo { /** allocate copy of @p src in arena @p d. **/ static value_type alloc_copy(DArena & d, value_type src); static void clear(DArena &); + /** perform assignment {*lhs_iface, *lhs_data} = {*rhs_iface, rhs_data} **/ + static void barrier_assign_aux(DArena &, + void * parent, + AGCObject * lhs_iface, void ** lhs_data, + AGCObject * rhs_iface, void * rhs_data); static void destruct_data(DArena &); }; diff --git a/xo-alloc2/include/xo/alloc2/gc/ACollector.hpp b/xo-alloc2/include/xo/alloc2/gc/ACollector.hpp index 2765c6b2..2daab3ca 100644 --- a/xo-alloc2/include/xo/alloc2/gc/ACollector.hpp +++ b/xo-alloc2/include/xo/alloc2/gc/ACollector.hpp @@ -14,7 +14,7 @@ #pragma once // includes (via {facet_includes}) -#include +#include #include #include #include diff --git a/xo-alloc2/include/xo/alloc2/gc/AGCObject.hpp b/xo-alloc2/include/xo/alloc2/gc/AGCObject.hpp index fbb5f613..dc6e79dd 100644 --- a/xo-alloc2/include/xo/alloc2/gc/AGCObject.hpp +++ b/xo-alloc2/include/xo/alloc2/gc/AGCObject.hpp @@ -14,7 +14,7 @@ #pragma once // includes (via {facet_includes}) -#include +#include #include #include #include diff --git a/xo-alloc2/include/xo/alloc2/gc/ICollector_Xfer.hpp b/xo-alloc2/include/xo/alloc2/gc/ICollector_Xfer.hpp index 50802f9d..77975287 100644 --- a/xo-alloc2/include/xo/alloc2/gc/ICollector_Xfer.hpp +++ b/xo-alloc2/include/xo/alloc2/gc/ICollector_Xfer.hpp @@ -13,7 +13,7 @@ #pragma once -#include +#include #include #include diff --git a/xo-alloc2/include/xo/alloc2/gc/IGCObject_Xfer.hpp b/xo-alloc2/include/xo/alloc2/gc/IGCObject_Xfer.hpp index c5a0a6b8..bceec9a2 100644 --- a/xo-alloc2/include/xo/alloc2/gc/IGCObject_Xfer.hpp +++ b/xo-alloc2/include/xo/alloc2/gc/IGCObject_Xfer.hpp @@ -13,7 +13,7 @@ #pragma once -#include +#include #include #include #include diff --git a/xo-alloc2/include/xo/alloc2/gc/RCollector.hpp b/xo-alloc2/include/xo/alloc2/gc/RCollector.hpp index 3f647159..b7c54d44 100644 --- a/xo-alloc2/include/xo/alloc2/gc/RCollector.hpp +++ b/xo-alloc2/include/xo/alloc2/gc/RCollector.hpp @@ -52,7 +52,7 @@ public: void * alloc_copy_for(const T * src) noexcept { return O::iface()->alloc_copy(O::data(), (std::byte *)const_cast(src)); } - + /** convenience template for move-constructible T (this is common) **/ template T * std_move_for(T * src) noexcept { @@ -62,28 +62,28 @@ public: } return nullptr; } - + /** forward faceted object pointer in place. Defined in GCObject.hpp to avoid #include cycle **/ template void forward_inplace(obj * p_obj); - + /** another convenience template for forwarding. * Defined in RGCObject.hpp to avoid #include cycle. **/ template void forward_inplace(DRepr ** pp_repr); - + /** convenience template where pointer requires pivot **/ template requires (!std::is_same_v) void forward_pivot_inplace(obj * p_obj); - + /** add root @p p_root **/ template void add_gc_root(obj * p_root) { O::iface()->add_gc_root_poly(O::data(), (obj *)p_root); } - + /** remove root @p p_root **/ template void remove_gc_root(obj * p_root) { diff --git a/xo-alloc2/include/xo/alloc2/visitor/AResourceVisitor.hpp b/xo-alloc2/include/xo/alloc2/visitor/AResourceVisitor.hpp index 64d9b136..16a9b0b4 100644 --- a/xo-alloc2/include/xo/alloc2/visitor/AResourceVisitor.hpp +++ b/xo-alloc2/include/xo/alloc2/visitor/AResourceVisitor.hpp @@ -14,7 +14,7 @@ #pragma once // includes (via {facet_includes}) -#include "Allocator.hpp" +#include "Allocator_basic.hpp" #include #include #include diff --git a/xo-alloc2/src/alloc2/IAllocator_DArena.cpp b/xo-alloc2/src/alloc2/IAllocator_DArena.cpp index bffbd38a..4d9a0a43 100644 --- a/xo-alloc2/src/alloc2/IAllocator_DArena.cpp +++ b/xo-alloc2/src/alloc2/IAllocator_DArena.cpp @@ -4,6 +4,7 @@ **/ #include "AllocIterator.hpp" +#include "GCObject.hpp" #include "arena/IAllocator_DArena.hpp" #include "arena/IAllocIterator_DArenaIterator.hpp" // for alloc_range #include @@ -154,6 +155,31 @@ namespace xo { //s.checkpoint_ = s.lo_; } + void + IAllocator_DArena::barrier_assign_aux(DArena & s, + void * parent, + AGCObject * lhs_iface, void ** lhs_data, + AGCObject * rhs_iface, void * rhs_data) + { + (void)s; + (void)parent; + + // usually would expect this to just forward to DArena. + // That's problematic in this case, because DArena is at lower level + // relative to obj; + // recall that DArena is used in the implementation of xo-facet/ + // + // In any case, for DArena no write barrier is applied. + // Instead just perform the fop assignment + + // replacing vtable pointer here + if (lhs_iface) { + ::memcpy((void *)lhs_iface, (void *)rhs_iface, sizeof(AGCObject)); + } + + *lhs_data = rhs_data; + } + void IAllocator_DArena::destruct_data(DArena & s) { diff --git a/xo-alloc2/utest/DArenaIterator.test.cpp b/xo-alloc2/utest/DArenaIterator.test.cpp index 7d26e623..2c7503c5 100644 --- a/xo-alloc2/utest/DArenaIterator.test.cpp +++ b/xo-alloc2/utest/DArenaIterator.test.cpp @@ -5,7 +5,8 @@ #include "Allocator.hpp" #include "AllocIterator.hpp" -#include "arena/IAllocator_DArena.hpp" +#include "Arena.hpp" +//#include "arena/IAllocator_DArena.hpp" #include "arena/IAllocIterator_DArenaIterator.hpp" #include "padding.hpp" #include diff --git a/xo-alloc2/utest/arena.test.cpp b/xo-alloc2/utest/arena.test.cpp index e9358a10..47ff4548 100644 --- a/xo-alloc2/utest/arena.test.cpp +++ b/xo-alloc2/utest/arena.test.cpp @@ -4,8 +4,8 @@ **/ #include "xo/alloc2/Allocator.hpp" -#include "xo/alloc2/alloc/IAllocator_Xfer.hpp" -#include "xo/alloc2/arena/IAllocator_DArena.hpp" +#include "xo/alloc2/Arena.hpp" +//#include "xo/alloc2/arena/IAllocator_DArena.hpp" #include "xo/arena/print.hpp" #include "xo/arena/padding.hpp" #include diff --git a/xo-expression2/src/expression2/DGlobalSymtab.cpp b/xo-expression2/src/expression2/DGlobalSymtab.cpp index d927288a..30878f4d 100644 --- a/xo-expression2/src/expression2/DGlobalSymtab.cpp +++ b/xo-expression2/src/expression2/DGlobalSymtab.cpp @@ -111,7 +111,7 @@ namespace xo { { scope log(XO_DEBUG(false), std::string_view(*var->name())); - auto gc = mm.try_to_facet(); + //auto gc = mm.try_to_facet(); // 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(var); + vars_->assign_at(mm, + existing->path().j_slot(), + obj(var)); + //(*vars_)[existing->path().j_slot()] = obj(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(var)); + vars_->push_back(mm, obj(var)); } } @@ -194,7 +197,7 @@ namespace xo { scope log(XO_DEBUG(true), std::string_view(*tname->name())); - auto gc = mm.try_to_facet(); + //auto gc = mm.try_to_facet(); 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(tname)); + types_->push_back(mm, obj(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(tname)); } } diff --git a/xo-expression2/src/expression2/DLocalSymtab.cpp b/xo-expression2/src/expression2/DLocalSymtab.cpp index c5bf6e1e..c8b5b1fd 100644 --- a/xo-expression2/src/expression2/DLocalSymtab.cpp +++ b/xo-expression2/src/expression2/DLocalSymtab.cpp @@ -70,8 +70,8 @@ namespace xo { DVariable * var = DVariable::make(mm, name, typeref, binding); - auto gc = mm.try_to_facet(); - vars_->push_back(gc, obj(var)); + //auto gc = mm.try_to_facet(); + vars_->push_back(mm, obj(var)); return binding; } @@ -89,8 +89,8 @@ namespace xo { } else { obj tname = DTypename::make(mm, name, type); - auto gc = mm.try_to_facet(); - types_->push_back(gc, tname); + //auto gc = mm.try_to_facet(); + types_->push_back(mm, tname); } } diff --git a/xo-expression2/src/expression2/DSequenceExpr.cpp b/xo-expression2/src/expression2/DSequenceExpr.cpp index bfece9e6..bdff6270 100644 --- a/xo-expression2/src/expression2/DSequenceExpr.cpp +++ b/xo-expression2/src/expression2/DSequenceExpr.cpp @@ -5,8 +5,7 @@ #include "DSequenceExpr.hpp" #include "detail/IExpression_DSequenceExpr.hpp" -#include -#include +#include #include #include #include @@ -15,7 +14,6 @@ #include 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 expr) { // null gc -> no write barrier - obj gc = mm.try_to_facet(); + //obj gc = mm.try_to_facet(); 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 expr_gco = expr.to_facet(); - this->expr_v_->push_back(gc, expr_gco); + this->expr_v_->push_back(mm, expr_gco); } void diff --git a/xo-facet/include/xo/facet/OObject.hpp b/xo-facet/include/xo/facet/OObject.hpp index 39682863..458bdd15 100644 --- a/xo-facet/include/xo/facet/OObject.hpp +++ b/xo-facet/include/xo/facet/OObject.hpp @@ -168,6 +168,7 @@ namespace xo { DataPtr data() const { return data_; } Opaque opaque_data() const { return data_; } + Opaque * opaque_data_addr() { return (Opaque *)&data_; } void reset() { data_ = nullptr; } void reset_opaque(Opaque data) { data_ = (DataPtr)data; } diff --git a/xo-gc/include/xo/gc/DX1Collector.hpp b/xo-gc/include/xo/gc/DX1Collector.hpp index a582ed87..84e04c5c 100644 --- a/xo-gc/include/xo/gc/DX1Collector.hpp +++ b/xo-gc/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/xo-gc/include/xo/gc/detail/IAllocator_DX1Collector.hpp b/xo-gc/include/xo/gc/detail/IAllocator_DX1Collector.hpp index ca529990..f61d9fa9 100644 --- a/xo-gc/include/xo/gc/detail/IAllocator_DX1Collector.hpp +++ b/xo-gc/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/xo-gc/src/gc/DX1Collector.cpp b/xo-gc/src/gc/DX1Collector.cpp index 239f999e..af7adff9 100644 --- a/xo-gc/src/gc/DX1Collector.cpp +++ b/xo-gc/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/xo-gc/src/gc/GCObjectStore.cpp b/xo-gc/src/gc/GCObjectStore.cpp index 0dc5ed38..3be25127 100644 --- a/xo-gc/src/gc/GCObjectStore.cpp +++ b/xo-gc/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/xo-gc/src/gc/IAllocator_DX1Collector.cpp b/xo-gc/src/gc/IAllocator_DX1Collector.cpp index c0c93d6c..cf307e0f 100644 --- a/xo-gc/src/gc/IAllocator_DX1Collector.cpp +++ b/xo-gc/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/xo-gc/utest/Collector.test.cpp b/xo-gc/utest/Collector.test.cpp index 94baeb58..117f4ebb 100644 --- a/xo-gc/utest/Collector.test.cpp +++ b/xo-gc/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/xo-gc/utest/GcosTestutil.cpp b/xo-gc/utest/GcosTestutil.cpp index 27e09b96..220be254 100644 --- a/xo-gc/utest/GcosTestutil.cpp +++ b/xo-gc/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)); } } diff --git a/xo-interpreter2/include/xo/interpreter2/DLocalEnv.hpp b/xo-interpreter2/include/xo/interpreter2/DLocalEnv.hpp index 4cbe3f7d..a9253bbc 100644 --- a/xo-interpreter2/include/xo/interpreter2/DLocalEnv.hpp +++ b/xo-interpreter2/include/xo/interpreter2/DLocalEnv.hpp @@ -16,6 +16,7 @@ namespace xo { class DLocalEnv { public: using DArray = xo::scm::DArray; + using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using VisitReason = xo::mm::VisitReason; @@ -49,7 +50,7 @@ namespace xo { obj lookup_value(Binding ix) const noexcept; /** assign value associated with binding @p ix to @p x **/ - void assign_value(Binding ix, obj x); + void assign_value(obj mm, Binding ix, obj x); ///@} /** @defgroup scm-localenv-gcobject-facet **/ diff --git a/xo-interpreter2/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp b/xo-interpreter2/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp index 907e3fb2..f45f9d0b 100644 --- a/xo-interpreter2/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp +++ b/xo-interpreter2/include/xo/interpreter2/sequence/IGCObject_DVsmSeqContFrame.hpp @@ -67,4 +67,4 @@ when @p fn invokes garbage collector reentry point **/ } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/xo-interpreter2/src/interpreter2/DLocalEnv.cpp b/xo-interpreter2/src/interpreter2/DLocalEnv.cpp index 0e805d1b..6877f971 100644 --- a/xo-interpreter2/src/interpreter2/DLocalEnv.cpp +++ b/xo-interpreter2/src/interpreter2/DLocalEnv.cpp @@ -63,7 +63,9 @@ namespace xo { } void - DLocalEnv::assign_value(Binding ix, obj x) + DLocalEnv::assign_value(obj mm, + Binding ix, + obj x) { scope log(XO_DEBUG(true)); @@ -79,8 +81,7 @@ namespace xo { auto j = ix.j_slot(); if (j < static_cast(env->n_vars())) { - log && log("STUB: need write barrier for GC here"); - (*(env->args_))[j] = x; + env->args_->assign_at(mm, j, x); } else { assert(false); } diff --git a/xo-interpreter2/src/interpreter2/DVirtualSchematikaMachine.cpp b/xo-interpreter2/src/interpreter2/DVirtualSchematikaMachine.cpp index fc64e2e8..c8604e50 100644 --- a/xo-interpreter2/src/interpreter2/DVirtualSchematikaMachine.cpp +++ b/xo-interpreter2/src/interpreter2/DVirtualSchematikaMachine.cpp @@ -821,9 +821,9 @@ namespace xo { log && log(xtag("i_arg", i_arg), xtag("n_arg", args->size()), xtag("cap", args->capacity())); - auto gc = mm_.to_op().to_facet(); + //auto gc = mm_.to_op().to_facet(); - args->push_back(gc, value); + args->push_back(mm_.to_op(), value); i_arg = evalargs_frame->increment_arg(); diff --git a/xo-object2/include/xo/object2/DArray.hpp b/xo-object2/include/xo/object2/DArray.hpp index de65d1d2..2dc8e931 100644 --- a/xo-object2/include/xo/object2/DArray.hpp +++ b/xo-object2/include/xo/object2/DArray.hpp @@ -6,7 +6,6 @@ #pragma once #include -//#include #include #include #include @@ -20,7 +19,7 @@ namespace xo { namespace detail { /** null base case **/ static inline bool do_array_push_back(DArray *, - obj) + obj) { return true; } @@ -28,7 +27,7 @@ namespace xo { template requires (std::convertible_to>) static bool do_array_push_back(DArray * lhs, - obj gc, + obj mm, A arg1, Rest... rest); } @@ -49,7 +48,7 @@ namespace xo { /** type for array size **/ using size_type = std::uint32_t; using AAllocator = xo::mm::AAllocator; - using ACollector = xo::mm::ACollector; + //using ACollector = xo::mm::ACollector; using AGCObject = xo::mm::AGCObject; /** gc-centric object visitor **/ using AGCObjectVisitor = xo::mm::AGCObjectVisitor; @@ -114,8 +113,6 @@ namespace xo { obj at(size_type index) const; const obj & operator[](size_type index) const noexcept { return elts_[index]; } - // TODO: nuke this or provide LValue shim. need write barrier! - obj & operator[](size_type index) noexcept { return elts_[index]; } ///@} /** @defgroup darray-iterators iterators **/ @@ -128,17 +125,17 @@ namespace xo { /** store @p elt at position @p index. * true on success, false otherwise **/ - bool assign_at(obj gc, size_type index, obj elt) noexcept; + bool assign_at(obj mm, size_type index, obj elt) noexcept; /** append @p elt at the end of array. * true on success, false otherwise. * on failure array is unaltered **/ - bool push_back(obj gc, obj elt) noexcept; + bool push_back(obj mm, obj elt) noexcept; template requires (std::convertible_to> && ...) - bool push_back_all(obj gc, Args... args) noexcept; + bool push_back_all(obj mm, Args... args) noexcept; /** store last element in array into @p elt and decrement array size. * true on success; false on failure (implies array was empty) @@ -206,10 +203,10 @@ namespace xo { DArray * DArray::array(obj mm, Args... args) { - obj gc = mm.try_to_facet(); + //obj gc = mm.try_to_facet(); DArray * result = _empty(mm, sizeof...(args)); if (result) { - detail::do_array_push_back(result, gc, args...); + detail::do_array_push_back(result, mm, args...); } return result; } @@ -218,20 +215,20 @@ namespace xo { template requires (std::convertible_to>) static bool do_array_push_back(DArray * lhs, - obj gc, + obj mm, A arg1, Rest... rest) { - return (lhs->push_back(gc, arg1) - && do_array_push_back(lhs, gc, rest...)); + return (lhs->push_back(mm, arg1) + && do_array_push_back(lhs, mm, rest...)); } } template requires (std::convertible_to> && ...) bool - DArray::push_back_all(obj gc, Args... args) noexcept { - return detail::do_array_push_back(this, gc, args...); + DArray::push_back_all(obj mm, Args... args) noexcept { + return detail::do_array_push_back(this, mm, args...); } } /*namespace scm*/ diff --git a/xo-object2/include/xo/object2/DBoolean.hpp b/xo-object2/include/xo/object2/DBoolean.hpp index 904503c3..7be4c073 100644 --- a/xo-object2/include/xo/object2/DBoolean.hpp +++ b/xo-object2/include/xo/object2/DBoolean.hpp @@ -5,7 +5,6 @@ #pragma once -//#include #include #include #include @@ -16,7 +15,6 @@ namespace xo { namespace scm { struct DBoolean { using AAllocator = xo::mm::AAllocator; - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; using VisitReason = xo::mm::VisitReason; diff --git a/xo-object2/include/xo/object2/DDictionary.hpp b/xo-object2/include/xo/object2/DDictionary.hpp index 972c71b2..3fad8ece 100644 --- a/xo-object2/include/xo/object2/DDictionary.hpp +++ b/xo-object2/include/xo/object2/DDictionary.hpp @@ -9,7 +9,6 @@ #include "DString.hpp" #include #include -#include #include #include #include @@ -34,8 +33,6 @@ namespace xo { using size_type = std::uint32_t; /** xo allocator facet **/ using AAllocator = xo::mm::AAllocator; - /** garbage collector facet **/ - using ACollector = xo::mm::ACollector; /** gc-centric object visitor **/ using AGCObjectVisitor = xo::mm::AGCObjectVisitor; /** gc-aware object facet **/ @@ -144,12 +141,12 @@ namespace xo { * * @return true if key-value pair updated; false if key not found **/ - bool try_update(obj gc, const pair_type & kvpair); + bool try_update(obj mm, const pair_type & kvpair); /** update key-value pair for existing @p key to map to @p value. * false if @p key not already present. **/ - bool try_update_cstr(obj gc, const char * key, obj value); + bool try_update_cstr(obj gc, const char * key, obj value); /** convenience method: * try_upsert pair (k, @p value), after boxing c-style string @p key with @p mm to get k @@ -167,7 +164,7 @@ namespace xo { * * False if dictionary already at capacity **/ - bool try_upsert(obj gc, const pair_type & kvpair); + bool try_upsert(obj gc, const pair_type & kvpair); /** upsert key-value pair @p kvpair into dictionary. * If at capacity, expand capacity, getting new memory from @p mm. @@ -217,7 +214,7 @@ namespace xo { /** append {key, value} pair @p kv_pair to this dictionary * Require: @p kv_pair.first not already present in @ref keys_ **/ - bool _append_kv_aux(obj gc, const pair_type & kv_pair); + bool _append_kv_aux(obj mm, const pair_type & kv_pair); ///@} private: diff --git a/xo-object2/include/xo/object2/DInteger.hpp b/xo-object2/include/xo/object2/DInteger.hpp index ddcd9ba1..8bf881a9 100644 --- a/xo-object2/include/xo/object2/DInteger.hpp +++ b/xo-object2/include/xo/object2/DInteger.hpp @@ -5,7 +5,6 @@ #pragma once -//#include #include #include #include @@ -16,7 +15,6 @@ namespace xo { namespace scm { struct DInteger { using AAllocator = xo::mm::AAllocator; - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using AGCObject = xo::mm::AGCObject; using VisitReason = xo::mm::VisitReason; diff --git a/xo-object2/include/xo/object2/DList.hpp b/xo-object2/include/xo/object2/DList.hpp index a862f186..b5c340c8 100644 --- a/xo-object2/include/xo/object2/DList.hpp +++ b/xo-object2/include/xo/object2/DList.hpp @@ -64,7 +64,8 @@ namespace xo { obj at(size_type ix) const; /** assign head **/ - void assign_head(obj gc, obj h); + void assign_head(obj mm, obj h); + void assign_head_gc(obj gc, obj h); /** assign rest-pointer. Caller responsible for preserving acyclic property! **/ void _assign_rest(DList * r); diff --git a/xo-object2/src/object2/DArray.cpp b/xo-object2/src/object2/DArray.cpp index 1910e8e9..44b5a83e 100644 --- a/xo-object2/src/object2/DArray.cpp +++ b/xo-object2/src/object2/DArray.cpp @@ -75,20 +75,23 @@ namespace xo { } bool - DArray::assign_at(obj gc, size_type ix, obj x) noexcept + DArray::assign_at(obj mm, size_type ix, obj x) noexcept { if (ix >= size_) return false; scope log(XO_DEBUG(true), "need write barrier"); - mm_do_assign(gc, this, &elts_[ix], x); + mm.barrier_assign_aux(this, + elts_[ix].iface(), elts_[ix].opaque_data_addr(), + x.iface(), x.opaque_data()); + // mm_do_assign(gc, this, &elts_[ix], x); return true; } bool - DArray::push_back(obj gc, obj elt) noexcept + DArray::push_back(obj mm, obj elt) noexcept { if (size_ >= capacity_) { return false; @@ -98,7 +101,11 @@ namespace xo { void * mem = &(elts_[size_]); new (mem) obj(); - mm_do_assign(gc, this, &(elts_[size_]), elt); + mm.barrier_assign_aux(this, + elts_[size_].iface(), elts_[size_].opaque_data_addr(), + elt.iface(), elt.opaque_data()); + + //mm_do_assign(gc, this, &(elts_[size_]), elt); ++(this->size_); diff --git a/xo-object2/src/object2/DDictionary.cpp b/xo-object2/src/object2/DDictionary.cpp index 43a4e1cd..2f52cae3 100644 --- a/xo-object2/src/object2/DDictionary.cpp +++ b/xo-object2/src/object2/DDictionary.cpp @@ -108,7 +108,7 @@ namespace xo { } bool - DDictionary::try_update(obj gc, const pair_type & kv_pair) + DDictionary::try_update(obj mm, const pair_type & kv_pair) { for (size_type i = 0, n = keys_->size(); i < n; ++i) { auto key_i = obj::from((*keys_)[i]); @@ -116,7 +116,7 @@ namespace xo { assert(key_i); if (*(key_i.data()) == *(kv_pair.first)) { - values_->assign_at(gc, i, kv_pair.second); + values_->assign_at(mm, i, kv_pair.second); return true; } } @@ -125,7 +125,7 @@ namespace xo { } bool - DDictionary::try_update_cstr(obj gc, const char * key, obj value) + DDictionary::try_update_cstr(obj mm, const char * key, obj value) { for (size_type i = 0, n = keys_->size(); i < n; ++i) { auto key_i = obj::from((*keys_)[i]); @@ -133,7 +133,7 @@ namespace xo { assert(key_i); if (strcmp(key, key_i->data()) == 0) { - values_->assign_at(gc, i, value); + values_->assign_at(mm, i, value); return true; } @@ -148,8 +148,8 @@ namespace xo { const DString * k1 = DString::from_cstr(mm, key_cstr); if (k1) { - obj gc = mm.try_to_facet(); - return this->try_upsert(gc, std::make_pair(k1, value)); + //obj gc = mm.try_to_facet(); + return this->try_upsert(mm, std::make_pair(k1, value)); } return false; @@ -167,23 +167,23 @@ namespace xo { } bool - DDictionary::try_upsert(obj gc, const pair_type & kv_pair) + DDictionary::try_upsert(obj mm, const pair_type & kv_pair) { - if (this->try_update(gc, kv_pair)) + if (this->try_update(mm, kv_pair)) return true; if (keys_->size() == keys_->capacity()) return false; - return this->_append_kv_aux(gc, kv_pair); + return this->_append_kv_aux(mm, kv_pair); } bool DDictionary::upsert(obj mm, const pair_type & kv_pair) { - obj gc = mm.try_to_facet(); + //obj gc = mm.try_to_facet(); - if (this->try_update(gc, kv_pair)) + if (this->try_update(mm, kv_pair)) return true; // key not present -> must expand {key array, value array} @@ -204,19 +204,19 @@ namespace xo { } } - return this->_append_kv_aux(gc, kv_pair); + return this->_append_kv_aux(mm, kv_pair); } bool - DDictionary::_append_kv_aux(obj gc, const pair_type & kv_pair) + DDictionary::_append_kv_aux(obj mm, const pair_type & kv_pair) { DString * key = const_cast(kv_pair.first); bool ok - = keys_->push_back(gc, obj(key)); + = keys_->push_back(mm, obj(key)); if (ok) { - ok = values_->push_back(gc, kv_pair.second); + ok = values_->push_back(mm, kv_pair.second); if (!ok) { // since we couldn't insert value, also drop key diff --git a/xo-object2/src/object2/DList.cpp b/xo-object2/src/object2/DList.cpp index 7208bb9f..0b694aac 100644 --- a/xo-object2/src/object2/DList.cpp +++ b/xo-object2/src/object2/DList.cpp @@ -120,7 +120,20 @@ namespace xo { } void - DList::assign_head(obj gc, obj rhs) + DList::assign_head(obj mm, obj rhs) + { + scope log(XO_DEBUG(true), xtag("mm.data", mm.data_)); + + mm.barrier_assign_aux(this, + head_.iface(), head_.opaque_data_addr(), + rhs.iface(), rhs.opaque_data()); + + //mm_do_assign(gc, this, &head_, rhs); + } + + // vestigial. used in MockCollector + void + DList::assign_head_gc(obj gc, obj rhs) { scope log(XO_DEBUG(true), xtag("gc.data", gc.data_)); diff --git a/xo-object2/utest/DArray.test.cpp b/xo-object2/utest/DArray.test.cpp index af26c719..89353608 100644 --- a/xo-object2/utest/DArray.test.cpp +++ b/xo-object2/utest/DArray.test.cpp @@ -30,12 +30,12 @@ namespace xo { REQUIRE(arr.size() == 0); REQUIRE(arr.capacity() == 0); - REQUIRE(arr.is_empty());; + REQUIRE(arr.is_empty()); - // null_gc: for no memory barrier - obj null_gc; + // null_mm: for no memory barrier + obj null_mm; - REQUIRE(arr.push_back(null_gc, ListOps::nil()) == false); + REQUIRE(arr.push_back(null_mm, ListOps::nil()) == false); } TEST_CASE("DArray-empty", "[object2][DArray]") @@ -61,7 +61,7 @@ namespace xo { .size_ = 4*1024 }; DArena arena = DArena::map(cfg); auto alloc = with_facet::mkobj(&arena); - obj null_gc; + obj null_mm; DArray * arr = DArray::_empty(alloc, 16); REQUIRE(arr != nullptr); @@ -70,7 +70,7 @@ namespace xo { obj elt = DInteger::box(alloc, 42); - bool ok = arr->push_back(null_gc, elt); + bool ok = arr->push_back(null_mm, elt); REQUIRE(ok == true); REQUIRE(arr->is_empty() == false); @@ -84,7 +84,7 @@ namespace xo { .size_ = 4*1024 }; DArena arena = DArena::map(cfg); auto alloc = with_facet::mkobj(&arena); - obj null_gc; + obj null_mm; DArray * arr = DArray::_empty(alloc, 4); REQUIRE(arr != nullptr); @@ -96,7 +96,7 @@ namespace xo { REQUIRE(arr->size() == i); obj elt = DInteger::box(alloc, 100 + i); - bool ok = arr->push_back(null_gc, elt); + bool ok = arr->push_back(null_mm, elt); REQUIRE(ok == true); REQUIRE(arr->capacity() == 4); @@ -113,7 +113,7 @@ namespace xo { auto alloc = with_facet::mkobj(&arena); DArray * arr = DArray::_empty(alloc, 2); - obj null_gc; + obj null_mm; REQUIRE(arr != nullptr); REQUIRE(arr->capacity() == 2); @@ -123,11 +123,11 @@ namespace xo { obj e2 = DInteger::box(alloc, 2); obj e3 = DInteger::box(alloc, 3); - REQUIRE(arr->push_back(null_gc, e1) == true); + REQUIRE(arr->push_back(null_mm, e1) == true); REQUIRE(arr->size() == 1); - REQUIRE(arr->push_back(null_gc, e2) == true); + REQUIRE(arr->push_back(null_mm, e2) == true); REQUIRE(arr->size() == 2); - REQUIRE(arr->push_back(null_gc, e3) == false); + REQUIRE(arr->push_back(null_mm, e3) == false); REQUIRE(arr->size() == 2); REQUIRE(arr->capacity() == 2); } @@ -140,7 +140,7 @@ namespace xo { auto alloc = with_facet::mkobj(&arena); DArray * arr = DArray::_empty(alloc, 4); - obj null_gc; + obj null_mm; REQUIRE(arr != nullptr); REQUIRE(arr->size() == 0); @@ -150,9 +150,9 @@ namespace xo { obj e1 = DInteger::box(alloc, 200); obj e2 = DInteger::box(alloc, 300); - arr->push_back(null_gc, e0); - arr->push_back(null_gc, e1); - arr->push_back(null_gc, e2); + arr->push_back(null_mm, e0); + arr->push_back(null_mm, e1); + arr->push_back(null_mm, e2); REQUIRE(arr->size() == 3); diff --git a/xo-procedure2/src/procedure2/ObjectPrimitives.cpp b/xo-procedure2/src/procedure2/ObjectPrimitives.cpp index 36dd2a37..367a0bc4 100644 --- a/xo-procedure2/src/procedure2/ObjectPrimitives.cpp +++ b/xo-procedure2/src/procedure2/ObjectPrimitives.cpp @@ -133,7 +133,7 @@ namespace xo { assert(!cell->is_empty()); if (!cell->is_empty()) { - cell->assign_head(rcx.collector(), dest); + cell->assign_head(rcx.allocator(), dest); } return cell; diff --git a/xo-reader2/src/reader2/DApplySsm.cpp b/xo-reader2/src/reader2/DApplySsm.cpp index 5c4802cc..ee043ddd 100644 --- a/xo-reader2/src/reader2/DApplySsm.cpp +++ b/xo-reader2/src/reader2/DApplySsm.cpp @@ -233,7 +233,7 @@ namespace xo { assert(expr_gco); obj mm(&(p_psm->parser_alloc())); - auto gc = obj(mm).try_to_facet(); + //auto gc = obj(mm).try_to_facet(); if (args_expr_v_->size() == args_expr_v_->capacity()) { // need to expand .args_expr_v_ capacity. @@ -243,14 +243,14 @@ namespace xo { DArray * argv_2x = DArray::_empty(mm, 2 * args_expr_v_->capacity()); for (DArray::size_type i = 0, n = args_expr_v_->size(); i < n; ++i) { - argv_2x->push_back(gc, (*args_expr_v_)[i]); + argv_2x->push_back(mm, (*args_expr_v_)[i]); } this->args_expr_v_ = argv_2x; } if (args_expr_v_->size() < args_expr_v_->capacity()) - args_expr_v_->push_back(gc, expr_gco); + args_expr_v_->push_back(mm, expr_gco); if (tk.tk_type() == tokentype::tk_rightparen) { obj apply_ex = this->assemble_expr(p_psm->expr_alloc()); diff --git a/xo-reader2/src/reader2/DExpectFormalArglistSsm.cpp b/xo-reader2/src/reader2/DExpectFormalArglistSsm.cpp index 18531816..3d86158c 100644 --- a/xo-reader2/src/reader2/DExpectFormalArglistSsm.cpp +++ b/xo-reader2/src/reader2/DExpectFormalArglistSsm.cpp @@ -201,20 +201,20 @@ namespace xo { obj mm(&parser_alloc); DArray * argl_2x = DArray::_empty(mm, 2 * argl_->capacity()); - auto gc = obj(mm).try_to_facet(); + //auto gc = obj(mm).try_to_facet(); for (DArray::size_type i = 0, n = argl_->size(); i < n; ++i) { // TODO: prefer non-bounds-checked access here - argl_2x->push_back(gc, argl_->at(i)); + argl_2x->push_back(mm, argl_->at(i)); } // update in place this->argl_ = argl_2x; } - auto gc = expr_alloc.try_to_facet(); + //auto gc = expr_alloc.try_to_facet(); - this->argl_->push_back(gc, var_o); + this->argl_->push_back(expr_alloc, var_o); } void diff --git a/xo-reader2/src/reader2/DExpectQArraySsm.cpp b/xo-reader2/src/reader2/DExpectQArraySsm.cpp index 1d09b154..eda20eb2 100644 --- a/xo-reader2/src/reader2/DExpectQArraySsm.cpp +++ b/xo-reader2/src/reader2/DExpectQArraySsm.cpp @@ -178,7 +178,7 @@ namespace xo { DExpectQArraySsm::on_quoted_literal(obj lit, ParserStateMachine * p_psm) { - auto gc = p_psm->expr_alloc().try_to_facet(); + //auto gc = p_psm->expr_alloc().try_to_facet(); if(state_.code() == QArrayXst::code::qarray_1a) { // append lit at the end of array_ @@ -195,7 +195,7 @@ namespace xo { 2 * array_->capacity()); } - bool ok = array_->push_back(gc, lit); + bool ok = array_->push_back(p_psm->expr_alloc(), lit); assert(ok); } diff --git a/xo-reader2/src/reader2/DGlobalEnv.cpp b/xo-reader2/src/reader2/DGlobalEnv.cpp index 2fc2e881..c1caf833 100644 --- a/xo-reader2/src/reader2/DGlobalEnv.cpp +++ b/xo-reader2/src/reader2/DGlobalEnv.cpp @@ -8,6 +8,7 @@ #include namespace xo { + using xo::mm::ACollector; using xo::mm::AAllocator; using xo::mm::AGCObject; @@ -84,8 +85,11 @@ namespace xo { values_->resize(ix.j_slot() + 1); } - log && log("STUB: need write barrier for GC here"); - (*values_)[ix.j_slot()] = x; + //auto gc = mm.try_to_facet(); + + values_->assign_at(mm, + ix.j_slot(), + x); } DVariable * diff --git a/xo-stringtable2/include/xo/stringtable2/DString.hpp b/xo-stringtable2/include/xo/stringtable2/DString.hpp index 73e165de..2d05bcf1 100644 --- a/xo-stringtable2/include/xo/stringtable2/DString.hpp +++ b/xo-stringtable2/include/xo/stringtable2/DString.hpp @@ -6,7 +6,6 @@ #pragma once #include -//#include #include #include #include @@ -16,8 +15,6 @@ //#include namespace xo { - namespace mm { class ACollector; } - namespace scm { /** @class DString * @brief String implementation with gc hooks @@ -46,8 +43,6 @@ namespace xo { using const_iterator = const char *; /** xo allocator **/ using AAllocator = xo::mm::AAllocator; - /** garbage collector **/ - //using ACollector = xo::mm::ACollector; /** object visitor (garbage collector proxy) **/ using AGCObjectVisitor = xo::mm::AGCObjectVisitor; /** visitor hint **/ diff --git a/xo-stringtable2/include/xo/stringtable2/string/IGCObject_DString.hpp b/xo-stringtable2/include/xo/stringtable2/string/IGCObject_DString.hpp index e9c15f43..3f8ec159 100644 --- a/xo-stringtable2/include/xo/stringtable2/string/IGCObject_DString.hpp +++ b/xo-stringtable2/include/xo/stringtable2/string/IGCObject_DString.hpp @@ -43,7 +43,7 @@ namespace xo { ///@{ using size_type = xo::mm::AGCObject::size_type; using AAllocator = xo::mm::AGCObject::AAllocator; - using ACollector = xo::mm::AGCObject::ACollector; + //using ACollector = xo::mm::AGCObject::ACollector; using AGCObjectVisitor = xo::mm::AGCObject::AGCObjectVisitor; using VisitReason = xo::mm::AGCObject::VisitReason; using Copaque = xo::mm::AGCObject::Copaque; @@ -67,4 +67,4 @@ when @p fn invokes garbage collector reentry point **/ } /*namespace scm*/ } /*namespace xo*/ -/* end */ \ No newline at end of file +/* end */ diff --git a/xo-stringtable2/utest/DString.test.cpp b/xo-stringtable2/utest/DString.test.cpp index 9a7e1168..1f095b0a 100644 --- a/xo-stringtable2/utest/DString.test.cpp +++ b/xo-stringtable2/utest/DString.test.cpp @@ -6,7 +6,8 @@ #include "init_stringtable2.hpp" #include "StringOps.hpp" #include -#include +#include +//#include #include #include #include diff --git a/xo-type/include/xo/type/DArrayType.hpp b/xo-type/include/xo/type/DArrayType.hpp index e9b93aa3..9ded76db 100644 --- a/xo-type/include/xo/type/DArrayType.hpp +++ b/xo-type/include/xo/type/DArrayType.hpp @@ -7,7 +7,6 @@ #include "Type.hpp" #include "Metatype.hpp" -//#include #include #include @@ -19,7 +18,6 @@ namespace xo { **/ class DArrayType { public: - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; diff --git a/xo-type/include/xo/type/DAtomicType.hpp b/xo-type/include/xo/type/DAtomicType.hpp index df09e4dc..8dfaaaa3 100644 --- a/xo-type/include/xo/type/DAtomicType.hpp +++ b/xo-type/include/xo/type/DAtomicType.hpp @@ -7,7 +7,6 @@ #include "Type.hpp" #include "Metatype.hpp" -//#include #include #include @@ -22,7 +21,6 @@ namespace xo { **/ class DAtomicType { public: - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; diff --git a/xo-type/include/xo/type/DListType.hpp b/xo-type/include/xo/type/DListType.hpp index fcb4735a..a34af57d 100644 --- a/xo-type/include/xo/type/DListType.hpp +++ b/xo-type/include/xo/type/DListType.hpp @@ -8,7 +8,6 @@ #include "Type.hpp" #include "Metatype.hpp" #include -//#include #include #include @@ -24,7 +23,6 @@ namespace xo { class DListType { public: using TypeDescr = xo::reflect::TypeDescr; - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; diff --git a/xo-type/include/xo/type/typevar/DTypeVarRef.hpp b/xo-type/include/xo/type/typevar/DTypeVarRef.hpp index 3c60b05a..36a86a70 100644 --- a/xo-type/include/xo/type/typevar/DTypeVarRef.hpp +++ b/xo-type/include/xo/type/typevar/DTypeVarRef.hpp @@ -7,7 +7,6 @@ #include "Type.hpp" #include "Metatype.hpp" -//#include #include #include @@ -22,7 +21,6 @@ namespace xo { **/ class DTypeVarRef { public: - //using ACollector = xo::mm::ACollector; using AGCObjectVisitor = xo::mm::AGCObjectVisitor; using VisitReason = xo::mm::VisitReason; using AAllocator = xo::mm::AAllocator; diff --git a/xo-type/src/type/DArrayType.cpp b/xo-type/src/type/DArrayType.cpp index a46752bc..6fad352d 100644 --- a/xo-type/src/type/DArrayType.cpp +++ b/xo-type/src/type/DArrayType.cpp @@ -7,7 +7,6 @@ #include "ArrayType.hpp" #include "TypeDescr.hpp" #include -#include #include #include