diff --git a/src/object2/DList.cpp b/src/object2/DList.cpp index d95f0bd..a30aef8 100644 --- a/src/object2/DList.cpp +++ b/src/object2/DList.cpp @@ -41,7 +41,7 @@ namespace xo { bool DList::is_empty() const noexcept { - return this != &s_null; + return this == &s_null; } auto diff --git a/src/object2/IGCObject_DList.cpp b/src/object2/IGCObject_DList.cpp index 2139d68..af7353f 100644 --- a/src/object2/IGCObject_DList.cpp +++ b/src/object2/IGCObject_DList.cpp @@ -4,6 +4,7 @@ **/ #include "IGCObject_DList.hpp" +#include namespace xo { using xo::mm::AGCObject; @@ -36,6 +37,8 @@ namespace xo { IGCObject_DList::forward_children(DList & src, obj gc) noexcept { + scope log(XO_DEBUG(true)); + gc.forward_inplace(src.head_.iface(), (void **)&(src.head_.data_)); auto iface = xo::facet::impl_for(); diff --git a/utest/X1Collector.test.cpp b/utest/X1Collector.test.cpp index b15a0c5..1174635 100644 --- a/utest/X1Collector.test.cpp +++ b/utest/X1Collector.test.cpp @@ -19,6 +19,9 @@ #include #include +#include +#include + #include namespace ut { @@ -39,6 +42,8 @@ namespace ut { using xo::mm::padding; using xo::facet::with_facet; using xo::facet::typeseq; + using xo::scope; + using xo::xtag; namespace { struct testcase_x1 { @@ -69,6 +74,9 @@ namespace ut { TEST_CASE("x1", "[gc][x1]") { + constexpr bool c_debug_flag = true; + scope log(XO_DEBUG(c_debug_flag)); + for (std::size_t i_tc = 0, n_tc = s_testcase_v.size(); i_tc < n_tc; ++i_tc) { try { const testcase_x1 & tc = s_testcase_v[i_tc]; @@ -82,6 +90,7 @@ namespace ut { .gc_trigger_v_{{ tc.incr_gc_threshold_, tc.full_gc_threshold_}}, + .debug_flag_ = c_debug_flag, }; DX1Collector gc(cfg); @@ -140,6 +149,8 @@ namespace ut { REQUIRE(gc.reserved_total() == otypes->reserved() + roots->reserved() + 4 * from_0->reserved()); + + log && log(xtag("from_0", from_0->lo_), xtag("to_0", to_0->lo_)); } /* attempt allocation */ @@ -197,11 +208,22 @@ namespace ut { } } - - /* no GC roots, so GC is trivial */ c_o.request_gc(generation{1}); + log && log(xtag("l0_o.data()", l0_o.data())); + log && log(xtag("l0_o.data()->head_.data()", l0_o.data()->head_.data())); + log && log(xtag("x0_o.data()", x0_o.data())); + + REQUIRE(!gc.contains(role::from_space(), x0_o.data())); + REQUIRE(gc.contains(role::to_space(), x0_o.data())); + REQUIRE(x0_o.data()->value() == 3.1415927); + REQUIRE(!gc.contains(role::from_space(), l0_o.data())); + REQUIRE(gc.contains(role::to_space(), l0_o.data())); + REQUIRE(l0_o.data()->is_empty() == false); + + REQUIRE((void*)l0_o.data()->head_.data() == (void*)x0_o.data()); + } catch (std::exception & ex) { std::cerr << "caught exception: " << ex.what() << std::endl; REQUIRE(false);