diff --git a/include/xo/gc/GCObjectStore.hpp b/include/xo/gc/GCObjectStore.hpp index 1191e17..a329275 100644 --- a/include/xo/gc/GCObjectStore.hpp +++ b/include/xo/gc/GCObjectStore.hpp @@ -13,7 +13,6 @@ namespace xo { namespace mm { - class DX1Collector; class X1VerifyStats; /** @brief container to hold gc-aware objects for X1 collector @@ -122,7 +121,7 @@ namespace xo { * to call AGCObject visitor method (forward_children()) on each * object stored here. **/ - void verify_ok(DX1Collector * gc, + void verify_ok(obj gc, X1VerifyStats * p_verify_stats) noexcept; /** Register object type with this collector. @@ -143,7 +142,7 @@ namespace xo { * Require: runstate_.is_running() **/ - void * deep_move_root(DX1Collector * gc, + void * deep_move_root(obj gc, obj from_src, Generation upto); @@ -152,7 +151,7 @@ namespace xo { * * NOTE: load-bearing for MutationLogStore **/ - void * deep_move_interior(DX1Collector * gc, + void * deep_move_interior(obj gc, void * from_src, Generation upto); @@ -163,10 +162,10 @@ namespace xo { * * Replace original with forwarding pointer to new location **/ - void forward_inplace_aux(DX1Collector * gc, - AGCObject * lhs_iface, - void ** lhs_data, - Generation upto); + void forward_inplace_aux(obj gc, + AGCObject * lhs_iface, + void ** lhs_data, + Generation upto); /** Cleanup at the end of a gc cycle. * Reset from-space @@ -198,7 +197,7 @@ namespace xo { * Move object subgraph @p from_src on behalf of @p gc collection cycle, * covering generations in [0 ,.., upto). **/ - void * _deep_move_gc_owned(DX1Collector * gc, + void * _deep_move_gc_owned(obj gc, void * from_src, Generation upto); @@ -208,7 +207,7 @@ namespace xo { * 1. Breadth-first implementation, bad for memory locality * 2. Need @p gc for per-object-type forward_children api **/ - void _forward_children_until_fixpoint(DX1Collector * gc, + void _forward_children_until_fixpoint(obj gc, Generation upto, GCMoveCheckpoint gray_lo_v); @@ -216,7 +215,7 @@ namespace xo { * evacuate object @p from_src, with gc-object interface @p iface. * Shallow: does not traverse children **/ - void * _shallow_move(DX1Collector * gc, + void * _shallow_move(obj gc, AGCObject * iface, void * from_src); diff --git a/src/gc/DX1Collector.cpp b/src/gc/DX1Collector.cpp index a74b7f0..d6d889f 100644 --- a/src/gc/DX1Collector.cpp +++ b/src/gc/DX1Collector.cpp @@ -417,7 +417,7 @@ namespace xo { } // 3. scan to-space for each generation - gco_store_.verify_ok(this, &(this->verify_stats_)); + gco_store_.verify_ok(this->ref(), &(this->verify_stats_)); // 4. scan mutation logs mlog_store_.verify_ok(&gco_store_, @@ -576,7 +576,7 @@ namespace xo { xtag("slot.root()", slot.root()), xtag("slot.root()->data_", slot.root()->data_)); - void * root_to = gco_store_.deep_move_root(this, *slot.root(), upto); + void * root_to = gco_store_.deep_move_root(this->ref(), *slot.root(), upto); slot.root()->reset_opaque(root_to); @@ -596,7 +596,7 @@ namespace xo { if (runstate_.is_running()) { // called during collection phase - gco_store_.forward_inplace_aux(this, lhs_iface, lhs_data, upto); + gco_store_.forward_inplace_aux(this->ref(), lhs_iface, lhs_data, upto); } else if (runstate_.is_verify()) { // called during verify_ok this->_verify_aux(lhs_iface, *lhs_data); @@ -611,8 +611,10 @@ namespace xo { void ** lhs_data) { if (runstate_.is_running()) { + Generation upto = runstate_.gc_upto(); + // called during collection phase - this->forward_inplace(lhs_iface, lhs_data); + gco_store_.forward_inplace_aux(this->ref(), lhs_iface, lhs_data, upto); } else if (runstate_.is_verify()) { // called during verify_ok this->_verify_aux(lhs_iface, *lhs_data); diff --git a/src/gc/GCObjectStore.cpp b/src/gc/GCObjectStore.cpp index a3070af..a1cceaa 100644 --- a/src/gc/GCObjectStore.cpp +++ b/src/gc/GCObjectStore.cpp @@ -4,7 +4,7 @@ **/ #include "GCObjectStore.hpp" -#include "X1Collector.hpp" +#include "X1VerifyStats.hpp" #include #include @@ -454,7 +454,7 @@ namespace xo { } void - GCObjectStore::forward_inplace_aux(DX1Collector * x1gc, + GCObjectStore::forward_inplace_aux(obj gc, AGCObject * lhs_iface, void ** lhs_data, Generation upto) @@ -465,7 +465,7 @@ namespace xo { xtag("lhs_data", lhs_data), xtag("*lhs_data", lhs_data ? *lhs_data : nullptr)); - /* coordinates with DX1Collector::_deep_move() */ + /* coordinates with _deep_move() */ /* * lhs obj @@ -498,7 +498,7 @@ namespace xo { log && log("disposition: not in from-space. Don't forward, but check children"); obj gco(lhs_iface, object_data); - gco.visit_gco_children(x1gc->ref()); + gco.visit_gco_children(gc); return; } @@ -609,7 +609,7 @@ namespace xo { * +----------+ */ - *lhs_data = this->_shallow_move(x1gc, lhs_iface, *lhs_data); + *lhs_data = this->_shallow_move(gc, lhs_iface, *lhs_data); /* * lhs obj (from-space) @@ -683,7 +683,7 @@ namespace xo { } void - GCObjectStore::verify_ok(DX1Collector * gc, + GCObjectStore::verify_ok(obj gc, X1VerifyStats * p_verify_stats) noexcept { for (Generation g(0); g < config_.n_generation_; ++g) { @@ -711,7 +711,7 @@ namespace xo { // Nested control reenters // X1Collector::forward_inplace() -> _verify_aux() // - gco.visit_gco_children(gc->ref()); + gco.visit_gco_children(gc); } else { ++(p_verify_stats->n_no_iface_); continue; @@ -746,7 +746,7 @@ namespace xo { } void * - GCObjectStore::deep_move_root(DX1Collector * gc, + GCObjectStore::deep_move_root(obj gc, obj from_src, Generation upto) { @@ -771,12 +771,10 @@ namespace xo { // we aren't moving from_src, it's not gc-owned. // However weare moving all its gc-owned children - auto gc_obj = gc->ref(); - GCMoveCheckpoint gray_lo_v = this->snap_move_checkpoint(upto); - from_src.visit_gco_children(gc_obj); + from_src.visit_gco_children(gc); // For each generation g: // traverse objects newer than gray_lo_v[g], to make sure children @@ -791,7 +789,7 @@ namespace xo { } void * - GCObjectStore::deep_move_interior(DX1Collector * gc, + GCObjectStore::deep_move_interior(obj gc, void * from_src, Generation upto) { @@ -809,7 +807,7 @@ namespace xo { } void * - GCObjectStore::_deep_move_gc_owned(DX1Collector * gc, + GCObjectStore::_deep_move_gc_owned(obj gc, void * from_src, Generation upto) { @@ -860,7 +858,7 @@ namespace xo { } /*_deep_move_gc_owned*/ void * - GCObjectStore::_shallow_move(DX1Collector * x1gc, + GCObjectStore::_shallow_move(obj gc, AGCObject * iface, void * from_src) { @@ -870,7 +868,7 @@ namespace xo { //obj gc_gco(gc); - void * to_dest = iface->gco_shallow_move(from_src, x1gc->ref()); + void * to_dest = iface->gco_shallow_move(from_src, gc); log && log(xtag("from_src", from_src), xtag("to_dest", to_dest)); log && log(xtag("tseq", info.tseq()), @@ -903,7 +901,7 @@ namespace xo { } /*_shallow_move*/ void - GCObjectStore::_forward_children_until_fixpoint(DX1Collector * gc, + GCObjectStore::_forward_children_until_fixpoint(obj gc, Generation upto, GCMoveCheckpoint gray_lo_v) { @@ -1005,9 +1003,7 @@ namespace xo { assert(iface->_has_null_vptr() == false); - auto gc_gco = gc->ref(); - - iface->visit_gco_children(src, gc_gco); + iface->visit_gco_children(src, gc); gray_lo_v[g] = ((std::byte *)src) + z; diff --git a/src/gc/MutationLogStore.cpp b/src/gc/MutationLogStore.cpp index 20d5254..9cf7e9b 100644 --- a/src/gc/MutationLogStore.cpp +++ b/src/gc/MutationLogStore.cpp @@ -4,7 +4,7 @@ **/ #include "MutationLogStore.hpp" -#include "DX1Collector.hpp" +#include "X1Collector.hpp" // temporary namespace xo { namespace mm { @@ -439,17 +439,17 @@ namespace xo { } return counters; - } + } /*forward_mutation_log_phase*/ MutationLogStatistics - MutationLogStore::_preserve_child_of_live_parent(DX1Collector * gc, + MutationLogStore::_preserve_child_of_live_parent(DX1Collector * x1gc, Generation upto, Generation parent_gen, const MutationLogEntry & from_entry, MutationLog * keep_mlog) { void * child_fr = *from_entry.p_data(); - AllocInfo child_info = gc->alloc_info((std::byte *)(child_fr)); + AllocInfo child_info = x1gc->alloc_info((std::byte *)(child_fr)); MutationLogStatistics counters; @@ -464,6 +464,8 @@ namespace xo { // or already evacuated. // (+ remember this need not be 1st pass over mlog entries) + GCObjectStore & gco_store = x1gc->gco_store(); + if (child_info.is_forwarding_tseq()) { // [MLOG1] @@ -479,9 +481,7 @@ namespace xo { ++counters.n_rescue_; - GCObjectStore & gco_store = gc->gco_store(); - - child_to = gco_store.deep_move_interior(gc, child_fr, upto); + child_to = gco_store.deep_move_interior(x1gc->ref(), child_fr, upto); // update child pointer in parent object *from_entry.p_data() = child_to; @@ -489,7 +489,7 @@ namespace xo { // child_to generation in {gen, gen+1} - this->_check_keep_mutation_aux(gc->gco_store(), + this->_check_keep_mutation_aux(gco_store, from_entry, parent_gen, child_to, keep_mlog); return counters;