xo-gc: utest: expand to multi-cycle utests

This commit is contained in:
Roland Conybeare 2026-04-12 19:42:02 -04:00
commit 7c150b7a92
6 changed files with 292 additions and 125 deletions

View file

@ -169,6 +169,11 @@ namespace xo {
void * from_src,
Generation upto);
/** allocate copy of @p src on behalf of a collection cycle.
* Entry point for DGCObjectStoreVisitor::alloc_copy()
**/
std::byte * alloc_copy(void * src) noexcept;
/** Cleanup at the end of a gc cycle.
* Reset from-space
* (current from-space is former to-space,

View file

@ -25,10 +25,11 @@ namespace xo {
* @p age collections. Equals the number of times object
* has been promoted.
*
* Must be consistent
* Must be consistent with promotion_threshold(g)
**/
Generation age2gen(object_age age) const noexcept {
return Generation(age % n_survive_threshold_);
return Generation(std::min(age / n_survive_threshold_,
n_generation_ - 1));
}
/** age threshold for promotion to generation @p g **/

View file

@ -16,7 +16,7 @@ namespace xo {
class X1VerifyStats {
public:
bool is_ok() const noexcept {
return (n_from_ == 0) && (n_fwd_ == 0) && (n_no_iface_ == 0);
return (n_from_ == 0) && (n_fwd_ == 0) && (n_age_bad_ == 0) && (n_no_iface_ == 0);
}
void clear() { *this = X1VerifyStats(); }
@ -30,6 +30,10 @@ namespace xo {
std::uint32_t n_to_ = 0;
/** counts forwarding object encountered in to-space scan. Fatal if non-zero **/
std::uint32_t n_fwd_ = 0;
/** counts objects in expected generation for age **/
std::uint32_t n_age_ok_ = 0;
/** counts objects in wrong generation for age **/
std::uint32_t n_age_bad_ = 0;
/** counts missing GCObject interface. Fatal if non-zero **/
std::uint32_t n_no_iface_ = 0;
/** live mlog entry refers to to-space, as expected **/