xo-alloc / xo-object: utest coverage + assorted bugfixes

This commit is contained in:
Roland Conybeare 2025-08-07 18:32:14 -05:00
commit bd00826448
34 changed files with 1069 additions and 326 deletions

View file

@ -424,21 +424,23 @@ namespace xo {
void RandomMutationModel::generate_random_roots(GC * gc,
xoshiro256ss * p_rgen)
{
std::size_t w1_ix = (*p_rgen)() % n_;
{
root_v_.push_back(w2_.at(w1_ix));
for (std::size_t i = 1; i < r_; ++i) {
std::size_t w2_ix = (*p_rgen)() % (m_ + n_);
if (n_ > 0) {
std::size_t w1_ix = (*p_rgen)() % n_;
root_v_.push_back(w2_.at(w2_ix));
}
REQUIRE(root_v_.size() == r_);
for (auto & root : root_v_)
gc->add_gc_root(root.ptr_address());
if (r_ > 0)
root_v_.push_back(w2_.at(w1_ix));
}
for (std::size_t i = 1; i < r_; ++i) {
std::size_t w2_ix = (*p_rgen)() % (m_ + n_);
root_v_.push_back(w2_.at(w2_ix));
}
REQUIRE(root_v_.size() == r_);
for (auto & root : root_v_)
gc->add_gc_root(root.ptr_address());
}
void RandomMutationModel::generate_random_mutations(xoshiro256ss * p_rgen)
@ -547,6 +549,8 @@ namespace xo {
std::vector<testcase_stresstest> s_testcase_v =
{
// segfault with
/* nz: nursery size
* tz: tenured size
* m: #of random list cells to create
@ -556,7 +560,10 @@ namespace xo {
* k: #of random mutations to apply
*
* nz tz m n r rr k stats, debug */
testcase_stresstest(1024, 1024, 5, 1, 5, 2, 10, true, false),
testcase_stresstest( 16, 1024, 2, 0, 0, 0, 0, false, false),
testcase_stresstest( 32, 1024, 2, 1, 5, 0, 0, false, false),
testcase_stresstest( 64, 1024, 5, 2, 5, 2, 10, false, false),
// testcase_stresstest( 128, 1024, 5, 2, 5, 2, 10, true, true), // segfault bad list cell
testcase_stresstest(1024, 1024, 10, 10, 5, 2, 10, true, false)
};
} /*namespace*/
@ -600,12 +607,12 @@ namespace xo {
auto rgen = xoshiro256ss(seed);
REQUIRE(tc.m_ > 0);
REQUIRE(tc.n_ > 0);
REQUIRE(tc.r_ > 0);
//REQUIRE(tc.n_ > 0);
//REQUIRE(tc.r_ > 0);
RandomMutationModel data_model(tc.m_, tc.n_, tc.r_, tc.rr_, tc.k_);
for (std::size_t cycle = 0; cycle < 5; ++cycle) {
for (std::size_t cycle = 0; cycle < 3; ++cycle) {
INFO(xtag("cycle", cycle));
if (cycle == 0) {
@ -635,7 +642,7 @@ namespace xo {
gc->request_gc(generation::nursery);
/* collector cycle changed object addresses.
* build a new object model, and verify consistency with from_model
* build a new object model, and verify consiste1ncy with from_model
*/
ObjectGraphModel to_model;
to_model.from_root_vector(data_model.root_v_);