xo-gc: utest: fix test regressions
All checks were successful
CI / smoke-test (push) Successful in 2m23s

This commit is contained in:
Roland Conybeare 2026-05-29 09:04:48 -04:00
commit d66affcd1e
4 changed files with 28 additions and 16 deletions

View file

@ -168,6 +168,7 @@ namespace xo {
return accumulate_total_aux(*this, &DArena::reserved);
}
// editor bait: size()
size_type
DX1Collector::size_total() const noexcept
{

View file

@ -325,11 +325,12 @@ namespace xo {
namespace {
class Testcase {
public:
Testcase(uint32_t ng, uint32_t ns, size_t gcz, uint32_t otz, bool dbg_flag)
Testcase(uint32_t ng, uint32_t ns, size_t gcz, uint32_t otz, uint32_t xotz, bool dbg_flag)
: n_gen_{ng},
n_survive_{ns},
gc_halfspace_z_{gcz},
object_type_z_{otz},
expect_object_type_z_{xotz},
debug_flag_{dbg_flag}
{}
@ -340,7 +341,7 @@ namespace xo {
uint32_t n_survive_ = 0;
/** size of each generations' half-space, in bytes **/
size_t gc_halfspace_z_ = 0;
/** storage for object type array, in bytes
/** storage for object-type array, in bytes
* one 8-byte facet pointer per type
**/
uint32_t object_type_z_;
@ -348,6 +349,8 @@ namespace xo {
/** size for error output arena **/
size_t error_size_ = 0;
#endif
/** expected size of object-type array, in bytes, after orderly init **/
uint32_t expect_object_type_z_ = 0;
/** true to enable debug output for this test case **/
bool debug_flag_ = false;
};
@ -372,6 +375,7 @@ namespace xo {
{
auto gc = obj<ACollector,DX1Collector>(&gc_);
// auto-install object types
CollectorTypeRegistry::instance().install_types(gc);
}
@ -382,13 +386,14 @@ namespace xo {
static std::vector<Testcase> s_testcase_v = {
/**
* debug_flag
* object_type_z |
* gc_halfspace_z | |
* n_survive | | |
* n_gen | | | |
* v v v v v
* expect_object_type_z |
* object_type_z | |
* gc_halfspace_z | | |
* n_survive | | | |
* n_gen | | | | |
* v v v v v v
**/
Testcase(1, 2, 16 * 1024, 128, T),
Testcase(1, 2, 16 * 1024, 128, 96, T),
};
# undef T
@ -443,7 +448,9 @@ namespace xo {
Generation g0 = Generation::g0();
REQUIRE(mm.allocated() == tc.object_type_z_);
// mm.allocated includes: { object-types, roots(=0), arenas(=0) }
//
REQUIRE(mm.allocated() == tc.expect_object_type_z_);
REQUIRE(gc.allocated(g0, Role::to_space()) == 0);
REQUIRE(gc.allocated(g0, Role::from_space()) == 0);
@ -478,7 +485,9 @@ namespace xo {
+ sizeof(DArray) + sizeof(obj<AGCObject>));
{
REQUIRE(z == 80);
REQUIRE(mm.allocated() == tc.object_type_z_ + z);
// cf earlier assertion on mm.allocated();
// now adding cost of 3 specific objects
REQUIRE(mm.allocated() == tc.expect_object_type_z_ + z);
REQUIRE(gc.allocated(g0, Role::to_space()) == z);
REQUIRE(gc.allocated(g1, Role::to_space()) == 0);
REQUIRE(gc.allocated(g0, Role::from_space()) == 0);
@ -494,7 +503,7 @@ namespace xo {
REQUIRE(mm->contains(Role::from_space(), l1.data()));
REQUIRE(!mm->contains_allocated(Role::from_space(), l1.data()));
REQUIRE(mm.allocated() == tc.object_type_z_ + z);
REQUIRE(mm.allocated() == tc.expect_object_type_z_ + z);
REQUIRE(gc.allocated(g0, Role::to_space()) == z);
REQUIRE(gc.allocated(g1, Role::to_space()) == 0);
REQUIRE(gc.allocated(g0, Role::from_space()) == 0);

View file

@ -39,7 +39,7 @@ namespace ut {
constexpr uint32_t c_space_z = 64*1024;
constexpr uint32_t c_n_gen = 1;
constexpr uint32_t c_n_survive = 0;
constexpr uint32_t c_n_survive = 1;
X1VerifyStats verify_stats;
GCObjectStoreConfig gcos_config{ArenaConfig()
.with_name("gcos-arena-name-notused")

View file

@ -273,11 +273,13 @@ namespace ut {
REQUIRE(ok);
REQUIRE(gc_o.name() == cfg.name_);
// nothing committed yet (?)
REQUIRE(gc_o.size() == cfg.object_types_z_);
// nothing committed yet, execept object types.
// committed memory will fit on 1 page
REQUIRE(gc_o.size() == getpagesize());
// no-op
REQUIRE(gc_o.expand(0));
REQUIRE(gc_o.size() == cfg.object_types_z_);
// committed memory will still fit on 1 page,
REQUIRE(gc_o.size() == getpagesize());
// x0_o will be added as gc root. x0_o_orig will not
auto x0_o = DFloat::box<AGCObject>(gc_o, 3.1415927);