From 2d149ced0d732ccfdb9214e3a2404c9b31bbed37 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 12 Apr 2026 15:42:49 -0400 Subject: [PATCH] xo-gc: tidy: + Generation methods .g0(), .g1() Use in GCObjectStore.test.cpp --- xo-alloc2/include/xo/alloc2/Generation.hpp | 2 ++ xo-gc/utest/GCObjectStore.test.cpp | 13 +++---------- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/xo-alloc2/include/xo/alloc2/Generation.hpp b/xo-alloc2/include/xo/alloc2/Generation.hpp index a311c606..0eb24074 100644 --- a/xo-alloc2/include/xo/alloc2/Generation.hpp +++ b/xo-alloc2/include/xo/alloc2/Generation.hpp @@ -24,6 +24,8 @@ namespace xo { explicit constexpr Generation(value_type x) : value_{x} {} static Generation nursery() { return Generation{0}; } + static Generation g0() { return Generation{0}; } + static Generation g1() { return Generation{1}; } static Generation sentinel() { return Generation(c_max_generation); } bool is_sentinel() const noexcept { return value_ == c_max_generation; } diff --git a/xo-gc/utest/GCObjectStore.test.cpp b/xo-gc/utest/GCObjectStore.test.cpp index 8e1ae05c..a6ab049c 100644 --- a/xo-gc/utest/GCObjectStore.test.cpp +++ b/xo-gc/utest/GCObjectStore.test.cpp @@ -812,10 +812,6 @@ namespace ut { // object type storage will be empty unless we install a type. GCObjectStore gcos(fixture.gcos_config_, &verify_stats); - Generation g0{0}; - Generation g1{1}; - Generation gn{tc.n_gen_}; - REQUIRE(gcos.is_type_installed(typeseq::id()) == false); REQUIRE(gcos.is_type_installed(typeseq::id()) == false); @@ -823,9 +819,6 @@ namespace ut { gcos_verify_arena_partitioning(tc, gcos); gcos_verify_vacant(tc, gcos); - // allocator api - auto alloc = obj(gcos.new_space()); - // create object(s). // details depend on test case @@ -845,11 +838,11 @@ namespace ut { gcos_verify_gen0_only_allocated(tc, gcos, x1_v); // swap_roles [but only for generation < g1, i.e. g0 - gcos.swap_roles(g1); + gcos.swap_roles(Generation::g1()); gcos_verify_gen0_fromspace_only_allocated(tc, gcos, x1_v); - gcos_move_roots_and_verify(tc, &gcos, g1, x1_v, x2_v, tc.debug_flag_); + gcos_move_roots_and_verify(tc, &gcos, Generation::g1(), x1_v, x2_v, tc.debug_flag_); // Things to test: // - deep_move_interior() // used from MutationLogStore @@ -861,7 +854,7 @@ namespace ut { // swaps to- and from- spaces again // Now from-space will be empty, all live objects in to-space - gcos.cleanup_phase(g1, sanitize_flag); + gcos.cleanup_phase(Generation::g1(), sanitize_flag); } {