diff --git a/xo-gc/cmake/xo-bootstrap-macros.cmake b/xo-gc/cmake/xo-bootstrap-macros.cmake index aba31169..592272c0 100644 --- a/xo-gc/cmake/xo-bootstrap-macros.cmake +++ b/xo-gc/cmake/xo-bootstrap-macros.cmake @@ -19,7 +19,13 @@ endif() message(STATUS "XO_CMAKE_CONFIG_EXECUTABLE=${XO_CMAKE_CONFIG_EXECUTABLE}") -if (NOT XO_SUBMODULE_BUILD) +if (XO_SUBMODULE_BUILD) + if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix)) + # local version of xo-cmake macros + set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/xo-cmake/cmake") + message(STATUS "CMAKE_MODULE_PATH=${CMAKE_MODULE_PATH}") + endif() +else() if (("${CMAKE_MODULE_PATH}" STREQUAL "") OR ("${CMAKE_MODULE_PATH}" STREQUAL prefix)) # default to typical install location for xo-project-macros execute_process(COMMAND ${XO_CMAKE_CONFIG_EXECUTABLE} --cmake-module-path OUTPUT_VARIABLE CMAKE_MODULE_PATH) diff --git a/xo-gc/src/gc/DX1Collector.cpp b/xo-gc/src/gc/DX1Collector.cpp index 643187ed..a0a4ddc8 100644 --- a/xo-gc/src/gc/DX1Collector.cpp +++ b/xo-gc/src/gc/DX1Collector.cpp @@ -168,6 +168,7 @@ namespace xo { return accumulate_total_aux(*this, &DArena::reserved); } + // editor bait: size() size_type DX1Collector::size_total() const noexcept { @@ -411,7 +412,8 @@ namespace xo { X1VerifyStats post = verify_stats_; // assert fail -> root contains ptr to from-space - assert(pre.n_from_ == post.n_from_); + if (pre.n_from_ != post.n_from_) + assert(false); ++verify_stats_.n_gc_root_; } @@ -535,7 +537,8 @@ namespace xo { log && log("step 5b : verify"); bool ok = this->verify_ok(); - log && log(xtag("n-gc-root", verify_stats_.n_gc_root_), + log && log(xtag("ok", ok), + xtag("n-gc-root", verify_stats_.n_gc_root_), xtag("n-ext", verify_stats_.n_ext_), xtag("n-from", verify_stats_.n_from_), xtag("n-to", verify_stats_.n_to_), @@ -546,7 +549,8 @@ namespace xo { xtag("n-mlog-from", verify_stats_.n_mlog_from_), xtag("n-mlog-wild", verify_stats_.n_mlog_wild_)); - assert(ok); + if (!ok) + assert(false); } } diff --git a/xo-gc/src/gc/GCObjectStore.cpp b/xo-gc/src/gc/GCObjectStore.cpp index b6f0b6e8..65849820 100644 --- a/xo-gc/src/gc/GCObjectStore.cpp +++ b/xo-gc/src/gc/GCObjectStore.cpp @@ -393,7 +393,8 @@ namespace xo { if (recd) { bool ok = final_stats_v->push_back(mm, recd); - assert(ok); + if (!ok) + assert(false); } } @@ -427,7 +428,8 @@ namespace xo { uint32_t age = info.age(); - assert(age < hard_n_age); + if (age >= hard_n_age) + assert(false); soft_max_age = std::max(soft_max_age, age); } diff --git a/xo-gc/src/gc/MutationLogStore.cpp b/xo-gc/src/gc/MutationLogStore.cpp index 7c1a8d78..63b8aaa6 100644 --- a/xo-gc/src/gc/MutationLogStore.cpp +++ b/xo-gc/src/gc/MutationLogStore.cpp @@ -444,9 +444,12 @@ namespace xo { log && log("parent not in to-space -> must be in from-space"); +# ifndef NDEBUG Generation parent_gen_from = gc.generation_of(Role::from_space(), from_entry.parent()); - assert(!parent_gen_from.is_sentinel()); + if (!parent_gen_from.is_sentinel()) + assert(false); +# endif if (from_entry.is_superseded()) { log && log("entry superseded -> discard"); diff --git a/xo-gc/utest/Collector.test.cpp b/xo-gc/utest/Collector.test.cpp index 26d1416e..3e94bd13 100644 --- a/xo-gc/utest/Collector.test.cpp +++ b/xo-gc/utest/Collector.test.cpp @@ -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(&gc_); + // auto-install object types CollectorTypeRegistry::instance().install_types(gc); } @@ -381,14 +385,15 @@ namespace xo { static std::vector s_testcase_v = { /** - * debug_flag - * object_type_z | - * gc_halfspace_z | | - * n_survive | | | - * n_gen | | | | - * v v v v v + * debug_flag + * 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)); { 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); diff --git a/xo-gc/utest/MockCollector.test.cpp b/xo-gc/utest/MockCollector.test.cpp index 9092d2b1..d45e42ab 100644 --- a/xo-gc/utest/MockCollector.test.cpp +++ b/xo-gc/utest/MockCollector.test.cpp @@ -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") diff --git a/xo-gc/utest/X1Collector.test.cpp b/xo-gc/utest/X1Collector.test.cpp index 481d1195..9fefcf75 100644 --- a/xo-gc/utest/X1Collector.test.cpp +++ b/xo-gc/utest/X1Collector.test.cpp @@ -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(gc_o, 3.1415927);