refactor: xo-gc: + GCObjectVisitor.generation_of()

Concession to narrow MutationLogStore to only use GCObjectVisitor
instead of assuming X1Collector.
This commit is contained in:
Roland Conybeare 2026-04-06 23:18:45 -04:00
commit b9e4a36d47
3 changed files with 13 additions and 4 deletions

View file

@ -48,6 +48,9 @@ namespace xo {
/** allocation metadata for gc-aware data at address @p gco.
@p gco must be the result of a call to collector's alloc() function **/
static AllocInfo alloc_info(const DX1Collector & self, void * addr);
/** generation to which pointer @p addr belongs, given role @p r;
sentinel if @p addr is not owned by collector **/
static Generation generation_of(const DX1Collector & self, role r, const void * addr) noexcept;
// non-const methods
/** allocate copy of source object at address @p src.

View file

@ -376,8 +376,8 @@ namespace xo {
/* here: mlog current */
Generation parent_gen_to = gc->generation_of(role::to_space(),
from_entry.parent());
Generation parent_gen_to = gc.generation_of(role::to_space(),
from_entry.parent());
if (parent_gen_to.is_sentinel()) {
void * parent_fr = *from_entry.p_data();
@ -393,8 +393,8 @@ namespace xo {
// TODO: method on AllocInfo to streamline this
void * parent_to = *(void **)parent_fr;
parent_gen_to = gc->generation_of(role::to_space(),
parent_to);
parent_gen_to = gc.generation_of(role::to_space(),
parent_to);
parent_info = gc.alloc_info((std::byte *)parent_to);
assert(!parent_gen_to.sentinel());

View file

@ -21,6 +21,12 @@ namespace xo {
return self.alloc_info(addr);
}
auto
IGCObjectVisitor_DX1Collector::generation_of(const DX1Collector & self, role r, const void * addr) noexcept -> Generation
{
return self.generation_of(r, addr);
}
auto
IGCObjectVisitor_DX1Collector::alloc_copy(DX1Collector & self, std::byte * src) -> void *
{