refactor: + narrower interface for gc pointer forwarding

add AGCObjectVisitor, instead of requiring ACollector.
This commit is contained in:
Roland Conybeare 2026-04-05 23:53:02 -04:00
commit 86f553408a
3 changed files with 10 additions and 8 deletions

View file

@ -8,5 +8,6 @@
#include "DX1Collector.hpp"
#include "detail/ICollector_DX1Collector.hpp"
#include "detail/IAllocator_DX1Collector.hpp"
#include "detail/IGCObjectVisitor_DX1Collector.hpp"
/* end X1Collector.hpp */

View file

@ -13,6 +13,7 @@
#include <xo/stringtable2/String.hpp>
#include <xo/alloc2/GCObject.hpp>
#include <xo/alloc2/GCObjectVisitor.hpp>
#include <xo/alloc2/Allocator.hpp>
#include <xo/alloc2/Arena.hpp>
#include "object_age.hpp"
@ -382,7 +383,7 @@ namespace xo {
// Add run state so DX1Collector can recognize forward_inplace()
// calls made for the purpose of checking child pointers.
auto self = this->ref<ACollector>();
auto self = this->ref<AGCObjectVisitor>();
GCRunState saved_runstate = runstate_;
{
@ -403,7 +404,7 @@ namespace xo {
// - X1Collector::forward_inplace() -> _verify_aux()
//
gco.forward_children(self);
gco.visit_gco_children(self);
}

View file

@ -498,7 +498,7 @@ namespace xo {
log && log("disposition: not in from-space. Don't forward, but check children");
obj<AGCObject> gco(lhs_iface, object_data);
gco.forward_children(gc->ref<ACollector>());
gco.visit_gco_children(gc->ref<AGCObjectVisitor>());
return;
}
@ -711,7 +711,7 @@ namespace xo {
// Nested control reenters
// X1Collector::forward_inplace() -> _verify_aux()
//
gco.forward_children(gc->ref<ACollector>());
gco.visit_gco_children(gc->ref<AGCObjectVisitor>());
} else {
++(p_verify_stats->n_no_iface_);
continue;
@ -771,12 +771,12 @@ namespace xo {
// we aren't moving from_src, it's not gc-owned.
// However weare moving all its gc-owned children
auto gc_obj = gc->ref<ACollector>();
auto gc_obj = gc->ref<AGCObjectVisitor>();
GCMoveCheckpoint gray_lo_v
= this->snap_move_checkpoint(upto);
from_src.forward_children(gc_obj);
from_src.visit_gco_children(gc_obj);
// For each generation g:
// traverse objects newer than gray_lo_v[g], to make sure children
@ -1005,9 +1005,9 @@ namespace xo {
assert(iface->_has_null_vptr() == false);
auto gc_gco = gc->ref<ACollector>();
auto gc_gco = gc->ref<AGCObjectVisitor>();
iface->forward_children(src, gc_gco);
iface->visit_gco_children(src, gc_gco);
gray_lo_v[g] = ((std::byte *)src) + z;