xo-gc: move DX1Collector.generation_of() impl -> GCObjectStore

This commit is contained in:
Roland Conybeare 2026-04-02 20:28:07 -04:00
commit 9efb214bfd
3 changed files with 19 additions and 8 deletions

View file

@ -26,6 +26,11 @@ namespace xo {
DArena * to_space(Generation g) noexcept { return get_space(role::to_space(), g); }
DArena * new_space() noexcept { return to_space(Generation{0}); }
/** generation to which pointer @p addr belongs, given role @p r;
* sentinel if not found in this collector
**/
Generation generation_of(role r, const void * addr) const noexcept;
/** Call @p visitor for each memory pool owned by this store **/
void visit_pools(const MemorySizeVisitor & visitor) const;

View file

@ -145,14 +145,7 @@ namespace xo {
Generation
DX1Collector::generation_of(role r, const void * addr) const noexcept
{
for (Generation gi{0}; gi < config_.n_generation_; ++gi) {
const DArena * arena = this->get_space(r, gi);
if (arena->contains(addr))
return gi;
}
return Generation::sentinel();
return gco_store_.generation_of(r, addr);
}
AllocError

View file

@ -62,6 +62,19 @@ namespace xo {
}
}
Generation
GCObjectStore::generation_of(role r, const void * addr) const noexcept
{
for (Generation gi{0}; gi < n_generation_; ++gi) {
const DArena * arena = this->get_space(r, gi);
if (arena->contains(addr))
return gi;
}
return Generation::sentinel();
}
void
GCObjectStore::visit_pools(const MemorySizeVisitor & visitor) const
{