diff --git a/include/xo/gc/DX1Collector.hpp b/include/xo/gc/DX1Collector.hpp index 32e4030..b3d1ba7 100644 --- a/include/xo/gc/DX1Collector.hpp +++ b/include/xo/gc/DX1Collector.hpp @@ -280,7 +280,7 @@ namespace xo { /** evacuate object with type @p iface at address @p from_src * to to-space. Return new to-space location. **/ - void * shallow_move(const AGCObject * iface, void * from_src); + void * _shallow_move(const AGCObject * iface, void * from_src); /** true iff {alloc_hdr, object_data} should move for * currently-running collection. diff --git a/include/xo/gc/GCObjectStore.hpp b/include/xo/gc/GCObjectStore.hpp index 7c4a6cf..7cb4e71 100644 --- a/include/xo/gc/GCObjectStore.hpp +++ b/include/xo/gc/GCObjectStore.hpp @@ -108,6 +108,14 @@ namespace xo { **/ bool install_type(const AGCObject & meta) noexcept; + /** during a gc cycle: + * evacuate object @p from_src, with gc-object interface @p iface. + * Shallow: does not traverse children + **/ + void * _shallow_move(obj mm, + const AGCObject * iface, + void * from_src); + /** traverse objects allocated after @p ckp, to make sure their children * are forwarded. Repeat until traverse doesn't find any unforwarded children. * diff --git a/src/gc/DX1Collector.cpp b/src/gc/DX1Collector.cpp index b1001f0..fc4acdc 100644 --- a/src/gc/DX1Collector.cpp +++ b/src/gc/DX1Collector.cpp @@ -868,7 +868,7 @@ namespace xo { void * DX1Collector::deep_move_interior(void * from_src, - Generation upto) + Generation upto) { scope log(XO_DEBUG(config_.debug_flag_)); @@ -935,7 +935,7 @@ namespace xo { assert(iface->_has_null_vptr() == false); - void * to_dest = this->shallow_move(iface, from_src); + void * to_dest = this->_shallow_move(iface, from_src); this->_forward_children_until_fixpoint(upto, gray_lo_v); @@ -1261,7 +1261,7 @@ namespace xo { * +----------+ */ - *lhs_data = this->shallow_move(lhs_iface, *lhs_data); + *lhs_data = this->_shallow_move(lhs_iface, *lhs_data); /* * lhs obj (from-space) @@ -1321,42 +1321,11 @@ namespace xo { } void * - DX1Collector::shallow_move(const AGCObject * iface, void * from_src) + DX1Collector::_shallow_move(const AGCObject * iface, void * from_src) { - scope log(XO_DEBUG(config_.debug_flag_)); - - AllocInfo info = this->alloc_info((std::byte *)from_src); obj alloc(this); - void * to_dest = iface->shallow_copy(from_src, alloc); - - log && log(xtag("from_src", from_src), xtag("to_dest", to_dest)); - log && log(xtag("tseq", info.tseq()), - xtag("tname", TypeRegistry::id2name(typeseq(info.tseq()))), - xtag("age", info.age()), xtag("size", info.size())); - - if (config_.sanitize_flag_) { - AllocInfo info_copy = this->alloc_info((std::byte *)to_dest); - - log && log(xtag("age2", info_copy.age()), xtag("size2", info_copy.size())); - - assert((info_copy.age() == config_.arena_config_.header_.max_age()) - || (info_copy.age() == info.age() + 1)); - } - - if(to_dest == from_src) { - assert(false); - } else { - *(const_cast(info.p_header_)) - = AllocHeader(config_ - .arena_config_ - .header_ - .mark_forwarding_tseq(*info.p_header_)); - - *(void **)from_src = to_dest; - } - - return to_dest; + return gco_store_._shallow_move(alloc, iface, from_src); } bool diff --git a/src/gc/GCObjectStore.cpp b/src/gc/GCObjectStore.cpp index 2b11882..13475dd 100644 --- a/src/gc/GCObjectStore.cpp +++ b/src/gc/GCObjectStore.cpp @@ -438,6 +438,49 @@ namespace xo { return true; } + void * + GCObjectStore::_shallow_move(obj mm, + const AGCObject * iface, + void * from_src) + { + scope log(XO_DEBUG(config_.debug_flag_)); + + AllocInfo info = this->alloc_info((std::byte *)from_src); + + //obj gc_gco(gc); + + void * to_dest = iface->shallow_copy(from_src, mm); + + log && log(xtag("from_src", from_src), xtag("to_dest", to_dest)); + log && log(xtag("tseq", info.tseq()), + xtag("tname", TypeRegistry::id2name(typeseq(info.tseq()))), + xtag("age", info.age()), + xtag("size", info.size())); + + if (config_.debug_flag_) { + AllocInfo info_copy = this->alloc_info((std::byte *)to_dest); + + log && log(xtag("age2", info_copy.age()), xtag("size2", info_copy.size())); + + assert((info_copy.age() == config_.arena_config_.header_.max_age()) + || (info_copy.age() == info.age() + 1)); + } + + if(to_dest == from_src) { + assert(false); + } else { + *(const_cast(info.p_header_)) + = AllocHeader(config_ + .arena_config_ + .header_ + .mark_forwarding_tseq(*info.p_header_)); + + *(void **)from_src = to_dest; + } + + return to_dest; + } /*shallow_move*/ + #ifdef MARKED void GCObjectStore::_forward_children_until_fixpoint(DX1Collector * gc,