xo-object: generative GC utest + reinstate coverage build

This commit is contained in:
Roland Conybeare 2025-08-06 09:30:37 -05:00
commit fc9180363d
6 changed files with 34 additions and 6 deletions

View file

@ -218,6 +218,7 @@ namespace xo {
public:
/** create new GC instance with configuration @p config **/
explicit GC(const Config & config);
virtual ~GC();
/** create GC allocator.
*

View file

@ -56,6 +56,8 @@ namespace xo {
if (lo_ <= x && x < limit_) {
this->free_ptr_ = x;
if (this->checkpoint_ > free_ptr_)
this->checkpoint_ = free_ptr_;
} else {
throw std::runtime_error(tostr("LinearAllog::set_free_ptr(x): expected lo <= x < limit",
xtag("lo", lo_), xtag("x", x), xtag("limit", limit_)));
@ -102,8 +104,7 @@ namespace xo {
void
ArenaAlloc::clear()
{
this->checkpoint_ = lo_;
this->free_ptr_ = lo_;
this->set_free_ptr(lo_);
this->limit_ = hi_ - redline_z_;
}
@ -133,14 +134,14 @@ namespace xo {
std::byte * retval = this->free_ptr_;
this->free_ptr_ += z1;
log && log(xtag("self", name_), xtag("z0", z0), xtag("+pad", dz), xtag("z1", z1));
if (free_ptr_ > limit_) {
if (free_ptr_ + z1 > limit_) {
return nullptr;
}
this->free_ptr_ += z1;
return retval;
}

View file

@ -26,23 +26,29 @@ namespace xo {
return dest_.ptr();
}
// LCOV_EXCL_START
std::size_t
Forwarding1::_shallow_size() const {
assert(false);
return 0;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
Object *
Forwarding1::_shallow_copy() const {
assert(false);
return nullptr;
}
// LCOV_EXCL_STOP
// LCOV_EXCL_START
std::size_t
Forwarding1::_forward_children() {
assert(false);
return 0;
}
// LCOV_EXCL_STOP
} /*namespace obj*/
} /*namespace xo*/

View file

@ -141,6 +141,21 @@ namespace xo {
this->checkpoint();
}
GC::~GC() {
/* hygiene */
this->clear();
nursery_[role2int(role::from_space)].reset();
nursery_[role2int(role::to_space) ].reset();
tenured_[role2int(role::from_space)].reset();
tenured_[role2int(role::to_space) ].reset();
mutation_log_[role2int(role::from_space)].reset();
mutation_log_[role2int(role::to_space) ].reset();
defer_mutation_log_.reset();
}
up<GC>
GC::make(const Config & config)
{
@ -245,8 +260,10 @@ namespace xo {
return nursery_[role2int(role::to_space)]->free_ptr();
case generation::tenured:
return tenured_[role2int(role::to_space)]->free_ptr();
// LCOV_EXCL_START
case generation::N:
assert(false);
// LCOV_EXCL_STOP
}
return nullptr;
@ -647,7 +664,7 @@ namespace xo {
Object * parent_to = from_entry.parent_destination();
log(xtag("parent_to", (void*)parent_to));
log && log(xtag("parent_to", (void*)parent_to));
assert(tospace_generation_of(parent_to) == generation_result::tenured);

View file

@ -47,12 +47,14 @@ namespace xo {
*lhs = rhs;
}
// LCOV_EXCL_START
std::byte *
IAlloc::alloc_gc_copy(std::size_t /*z*/, const void * /*src*/)
{
assert(false);
return nullptr;
}
// LCOV_EXCL_STOP
} /*namespace gc*/
} /*namespace xo*/

View file

@ -5,6 +5,7 @@
set(UTEST_EXE utest.alloc)
set(UTEST_SRCS
alloc_utest_main.cpp
IAlloc.test.cpp
ArenaAlloc.test.cpp
GC.test.cpp)