diff --git a/include/xo/gc/X1CollectorConfig.hpp b/include/xo/gc/X1CollectorConfig.hpp index 5bbc377..4b889ef 100644 --- a/include/xo/gc/X1CollectorConfig.hpp +++ b/include/xo/gc/X1CollectorConfig.hpp @@ -8,7 +8,6 @@ #include "GCObjectStoreConfig.hpp" #include "MutationLogConfig.hpp" #include "object_age.hpp" -//#include "Generation.hpp" #include #include #include diff --git a/utest/CMakeLists.txt b/utest/CMakeLists.txt index 0f3c967..5ffcac8 100644 --- a/utest/CMakeLists.txt +++ b/utest/CMakeLists.txt @@ -7,6 +7,7 @@ set(UTEST_SRCS Collector.test.cpp X1Collector.test.cpp DX1CollectorIterator.test.cpp + GCObjectStore.test.cpp Object2.test.cpp random_allocs.cpp ) diff --git a/utest/GCObjectStore.test.cpp b/utest/GCObjectStore.test.cpp new file mode 100644 index 0000000..399a7ae --- /dev/null +++ b/utest/GCObjectStore.test.cpp @@ -0,0 +1,94 @@ +/** @file GCObjectStore.test.cpp + * + * @author Roland Conybeare, Apr 2026 + **/ + +#include +#include +#include +#include +#include +#include + +namespace ut { + using xo::scm::DList; + using xo::scm::DInteger; + using xo::mm::GCObjectStoreConfig; + using xo::mm::GCObjectStore; + using xo::mm::AGCObject; + using xo::mm::ArenaConfig; + using xo::facet::typeseq; + using xo::facet::impl_for; + using xo::scope; + using std::size_t; + using std::uint32_t; + + namespace { + struct Testcase { + explicit Testcase(uint32_t n_gen, uint32_t n_survive, + size_t gc_z, uint32_t type_z) + : n_gen_{n_gen}, + n_survive_{n_survive}, + gc_size_{gc_z}, + object_type_z_{type_z} + {} + + /** number of generations in gco store **/ + uint32_t n_gen_ = 0; + /** object promotes on surviving this many gc cycles **/ + uint32_t n_survive_ = 0; + /** size of each generation's half-space, in bytes **/ + size_t gc_size_ = 0; + /** Storage for object type array, in bytes. + * (need to allow 1 pointer per type) + **/ + uint32_t object_type_z_ = 0; + + }; + + static std::vector s_testcase_v = { + /** n_gen, n_survive, gc_size, object_type_z **/ + Testcase(2, 4, 16 * 1024, 8 * 128), + }; + } + + TEST_CASE("GCObjectStore-1", "[GCObjectStore]") + { + constexpr bool c_debug_flag = false; + scope log(XO_DEBUG(c_debug_flag)); + + for (size_t i_tc = 0, n_tc = s_testcase_v.size(); i_tc < n_tc; ++i_tc) { + const Testcase & tc = s_testcase_v[i_tc]; + + /** config for each half-space **/ + ArenaConfig arena_config + = (ArenaConfig() + .with_name("arena-name-not-used") + .with_size(tc.gc_size_) + .with_store_header_flag(true)); + + GCObjectStoreConfig gcos_config(arena_config, + tc.n_gen_, + tc.n_survive_, + tc.object_type_z_, + c_debug_flag); + + // object type storage will be empty unless we install a type. + GCObjectStore gcos(gcos_config); + + REQUIRE(gcos.is_type_installed(typeseq::id()) == false); + + //REQUIRE(nullptr == gcos.lookup_type(typeseq::id())); + +#ifdef NOT_YET + + +// // Usual path would be via ACollector interface; that's inconvenient here +// +#endif + } + } + +} /*namespace ut*/ + +/* end GCObjectStore.test.cpp */ diff --git a/utest/Object2.test.cpp b/utest/Object2.test.cpp index fa0baec..4bda353 100644 --- a/utest/Object2.test.cpp +++ b/utest/Object2.test.cpp @@ -63,7 +63,7 @@ namespace ut { TEST_CASE("printable1", "[pp][x1][list]") { - constexpr bool c_debug_flag = true; + constexpr bool c_debug_flag = false; scope log(XO_DEBUG(c_debug_flag)); bool ok = SetupObject2::register_facets(); diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index bfea2eb..04e5c45 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -11,13 +11,13 @@ #include "DArray.hpp" #include -//#include "number/IGCObject_DFloat.hpp" -#include "number/IGCObject_DInteger.hpp" -#include "list/IGCObject_DList.hpp" +#include +#include +//#include "list/IGCObject_DList.hpp" -#include -#include #include +//#include +#include #include #include diff --git a/utest/gc_utest_main.cpp b/utest/gc_utest_main.cpp index 8c42600..cb1a31f 100644 --- a/utest/gc_utest_main.cpp +++ b/utest/gc_utest_main.cpp @@ -1,6 +1,32 @@ /* file gc_utest_main.cpp */ -#define CATCH_CONFIG_MAIN -#include "catch2/catch.hpp" +#include +#include + +#define CATCH_CONFIG_RUNNER +#include + +using xo::S_gc_tag; +using xo::InitSubsys; +using xo::InitEvidence; + +// ensure xo-gc properly initialized when Subsystem::initialize_all() runs +static InitEvidence s_init = (InitSubsys::require()); + +int +main(int argc, char* argv[]) +{ + using xo::Subsystem; + + // Your custom initialization code here + Subsystem::initialize_all(); + + // Run Catch2's test session + int result = Catch::Session().run(argc, argv); + + // cleanup here, if any + + return result; +} /* end gc_utest_main.cpp */