xo-gc: utest w/ DInteger

This commit is contained in:
Roland Conybeare 2026-04-25 19:30:17 -04:00
commit 6de2e4e519
3 changed files with 96 additions and 3 deletions

View file

@ -8,6 +8,7 @@
#include <xo/gc/X1VerifyStats.hpp>
#include <xo/object2/ListOps.hpp>
#include <xo/object2/Boolean.hpp>
#include <xo/object2/Integer.hpp>
#include <xo/alloc2/Collector.hpp>
#include <xo/alloc2/Arena.hpp>
#include <xo/facet/TypeRegistry.hpp>
@ -21,6 +22,7 @@ namespace ut {
using xo::scm::ListOps;
using xo::scm::DList;
using xo::scm::DBoolean;
using xo::scm::DInteger;
using xo::mm::ACollector;
using xo::mm::DMockCollector;
using xo::mm::X1VerifyStats;
@ -236,6 +238,10 @@ namespace ut {
REQUIRE(p_gcos->install_type(impl_for<AGCObject,DBoolean>()));
REQUIRE(p_gcos->is_type_installed(typeseq::id<DBoolean>()));
}
{
REQUIRE(p_gcos->install_type(impl_for<AGCObject,DInteger>()));
REQUIRE(p_gcos->is_type_installed(typeseq::id<DInteger>()));
}
{
REQUIRE(p_gcos->install_type(impl_for<AGCObject,DList>()));
REQUIRE(p_gcos->is_type_installed(typeseq::id<DList>()));
@ -465,6 +471,19 @@ namespace ut {
xi2 = DBoolean::box(alloc2, value);
}
break;
case Step::Cmd::make_int:
{
int value = cmd.arg0_ix_;
is_alloc = true;
xi = DInteger::box(alloc, value);
alloc_z = sizeof(DInteger);
tseq = typeseq::id<DInteger>();
xi2 = DInteger::box(alloc2, value);
}
break;
case Step::Cmd::assign_head:
{
is_alloc = false;
@ -860,8 +879,9 @@ namespace ut {
{
// written out polymorphic comparison
// match DBoolean..
bool match_attempted = false;
// match DBoolean..
{
auto x1p_b = obj<AGCObject,DBoolean>::from(x1p_gco);
auto x2_b = obj<AGCObject,DBoolean>::from(x2_gco);
@ -873,6 +893,18 @@ namespace ut {
}
}
// match DInteger..
{
auto x1p_b = obj<AGCObject,DInteger>::from(x1p_gco);
auto x2_b = obj<AGCObject,DInteger>::from(x2_gco);
if (x1p_b && x2_b) {
match_attempted = true;
REQUIRE(x1p_b->value() == x2_b->value());
}
}
// match DList..
{
auto x1p_b = obj<AGCObject,DList>::from(x1p_gco);

View file

@ -29,6 +29,8 @@ namespace ut {
make_cons,
/** allocate a boolean **/
make_bool,
/** allocate an integer **/
make_int,
/** modify the head of a list x1_v[arg0_ix_]; replace with x1_v[arg1_ix_] **/
assign_head,
@ -41,7 +43,13 @@ namespace ut {
bool is_command() const { return cmd_ != Cmd::sentinel; }
Cmd cmd_;
/** arg0 object index (index into x1_v[]) **/
/** arg0 object index (index into x1_v[])
*
* when cmd_ is make_bool:
* 0 -> false, 1 -> true
* when cmd_ is make_int:
* value of integer
**/
uint32_t arg0_ix_;
/** arg1 object index (index into x1_v[]) **/
uint32_t arg1_ix_;

View file

@ -7,6 +7,7 @@
#include "MlsTestutil.hpp"
#include <xo/object2/List.hpp>
#include <xo/object2/Boolean.hpp>
#include <xo/object2/Integer.hpp>
#include <xo/gc/GCObjectStore.hpp>
#include <xo/gc/GCObjectStoreVisitor.hpp>
#include <xo/gc/MutationLogStore.hpp>
@ -20,6 +21,7 @@
namespace ut {
using xo::scm::DList;
using xo::scm::DBoolean;
using xo::scm::DInteger;
using xo::mm::MutationLogStore;
using xo::mm::MutationLogConfig;
using xo::mm::GCObjectStore;
@ -257,6 +259,49 @@ namespace ut {
// ----------------------------------------------------------------
static Step step_5[] = {
// ----- phase 0 -----
{Cmd::make_int, 99, 0}, // [0]: 99
{Cmd::make_nil, 0, 0}, // [1]: #nil
{Cmd::make_cons, 0, 1}, // [2]: cons([0],[1]) -> cons(99,#nil)
// 1st gc
// ----- phase 1 -----
{Cmd::make_int, 15, 0}, // [3]: 15
{Cmd::assign_head, 2, 3}, // set-car([2],[3]) -> set-car([2],15)
// 2nd gc. [1]..[2] promote to g1
// [3] in g0 so [2]->[3] requires mlog entry
// ----- phase 2 -----
{Cmd::make_int, 24, 0}, // [4]: 33
{Cmd::assign_head, 2, 4}, // set-car([2],[4]) -> set-car([2],33)
// ----- phase 3 -----
// ----- phase 4 -----
// ----- end -----
{Cmd::sentinel, 0, 0},
};
static Phase phase_5[] = {
//
// lo hi mlog_new_z_[]
// v v v
{ 0, 3, {0} }, // phase 0 gc
{ 3, 5, {1} }, // phase 1 gc. set-car makes 1x xage ptr
{ 5, 7, {2} }, // phase 2 gc. now src in g1, dest [3] in g0
{ 7, 7, {1} }, // phase 3 gc. new dest [4] in g0
{ 7, 7, {0} }, // phase 4 gc. now dest in g1
{ -1, -1, {0} },
};
static TestSequence seq_5 { step_5, phase_5 };
// ----------------------------------------------------------------
# define seq_nil TestSequence{}
# define nil nullptr
# define T true
@ -286,6 +331,7 @@ namespace ut {
Testcase(2, 1, 16 * 1024, 8 * 128, T, seq_2, 128, T, c_fixed, 3, 0, 0, 0, 0, F),
Testcase(2, 2, 16 * 1024, 8 * 128, T, seq_3, 128, T, c_fixed, 4, 0, 0, 0, 0, F),
Testcase(2, 2, 16 * 1024, 8 * 128, T, seq_4, 128, T, c_fixed, 4, 0, 0, 0, 0, F),
Testcase(2, 2, 16 * 1024, 8 * 128, T, seq_5, 128, T, c_fixed, 4, 0, 0, 0, 0, F),
};
# undef T
@ -403,12 +449,19 @@ namespace ut {
{
REQUIRE(gcos.is_type_installed(typeseq::id<DList>()) == false);
REQUIRE(gcos.is_type_installed(typeseq::id<DBoolean>()) == false);
REQUIRE(gcos.is_type_installed(typeseq::id<DInteger>()) == false);
GcosTestutil::gcos_install_test_types(tc.do_type_registration_, &gcos);
if (tc.do_type_registration_) {
REQUIRE(gcos.is_type_installed(typeseq::id<DList>()) == true);
REQUIRE(gcos.is_type_installed(typeseq::id<DBoolean>()) == true);
REQUIRE(gcos.is_type_installed(typeseq::id<DInteger>()) == true);
}
GcosTestutil::gcos_verify_arena_partitioning(tc.n_gen_, tc.gc_size_, gcos);
GcosTestutil::gcos_verify_vacant(tc.n_gen_, tc.gc_size_, gcos);
}
}
/** mutator/collector loop **/