xo-gc: refactor: move some aux method impls to GCObjectStore
This commit is contained in:
parent
55c5838f4a
commit
08b313f25c
9 changed files with 131 additions and 34 deletions
|
|
@ -124,18 +124,13 @@ namespace xo {
|
|||
bool
|
||||
DX1Collector::contains(role r, const void * addr) const noexcept
|
||||
{
|
||||
return !(this->generation_of(r, addr).is_sentinel());
|
||||
return gco_store_.contains(r, addr);
|
||||
}
|
||||
|
||||
bool
|
||||
DX1Collector::contains_allocated(role r, const void * addr) const noexcept
|
||||
{
|
||||
Generation g = this->generation_of(r, addr);
|
||||
|
||||
if (g.is_sentinel())
|
||||
return false;
|
||||
|
||||
return this->get_space(r, g)->contains_allocated(addr);
|
||||
return gco_store_.contains_allocated(r, addr);
|
||||
}
|
||||
|
||||
Generation
|
||||
|
|
@ -212,16 +207,6 @@ namespace xo {
|
|||
DX1Collector::mutation_log_entries() const noexcept
|
||||
{
|
||||
return mlog_state_.mutation_log_entries();
|
||||
|
||||
#ifdef MOVED
|
||||
size_type z = 0;
|
||||
|
||||
for (Generation gj{0}; gj + 1 < config_.n_generation_; ++gj) {
|
||||
z += mlog_[role::to_space()][gj]->size();
|
||||
}
|
||||
|
||||
return z;
|
||||
#endif
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
|
@ -1397,19 +1382,11 @@ namespace xo {
|
|||
DX1Collector::check_move_policy(header_type alloc_hdr,
|
||||
void * object_data) const noexcept
|
||||
{
|
||||
(void)object_data;
|
||||
|
||||
// when gc is moving objects, to- and from- spaces have been
|
||||
// reversed: forwarding pointers are located in from-space and
|
||||
// refer to to-space.
|
||||
|
||||
object_age age = this->header2age(alloc_hdr);
|
||||
|
||||
Generation g = config_.age2gen(age);
|
||||
|
||||
assert(runstate_.is_running());
|
||||
|
||||
return (g < runstate_.gc_upto());
|
||||
return gco_store_.check_move_policy(runstate_.gc_upto(),
|
||||
alloc_hdr,
|
||||
object_data);
|
||||
}
|
||||
|
||||
auto
|
||||
|
|
|
|||
|
|
@ -133,10 +133,48 @@ namespace xo {
|
|||
}
|
||||
}
|
||||
|
||||
bool
|
||||
GCObjectStore::contains(role r, const void * addr) const noexcept
|
||||
{
|
||||
return !(this->generation_of(r, addr).is_sentinel());
|
||||
}
|
||||
|
||||
bool
|
||||
GCObjectStore::contains_allocated(role r, const void * addr) const noexcept
|
||||
{
|
||||
Generation g = this->generation_of(r, addr);
|
||||
|
||||
if (g.is_sentinel())
|
||||
return false;
|
||||
|
||||
return this->get_space(r, g)->contains_allocated(addr);
|
||||
}
|
||||
|
||||
bool
|
||||
GCObjectStore::check_move_policy(Generation upto,
|
||||
header_type alloc_hdr,
|
||||
void * object_data) const noexcept
|
||||
{
|
||||
(void)object_data;
|
||||
|
||||
// when gc is moving objects, to- and from- spaces have been
|
||||
// reversed: forwarding pointers are located in from-space and
|
||||
// refer to to-space.
|
||||
|
||||
object_age age = this->header2age(alloc_hdr);
|
||||
|
||||
Generation g = config_.age2gen(age);
|
||||
|
||||
//assert(runstate_.is_running());
|
||||
|
||||
return (g < upto);
|
||||
}
|
||||
|
||||
void
|
||||
GCObjectStore::swap_roles(Generation upto) noexcept
|
||||
{
|
||||
scope log(XO_DEBUG(config_.debug_flag_), xtag("upto", upto));
|
||||
scope log(XO_DEBUG(config_.debug_flag_),
|
||||
xtag("upto", upto));
|
||||
|
||||
for (Generation g = Generation{0}; g < upto; ++g) {
|
||||
log && log("swap roles", xtag("g", g));
|
||||
|
|
|
|||
|
|
@ -10,9 +10,11 @@ namespace xo {
|
|||
|
||||
GCObjectStoreConfig::GCObjectStoreConfig(const ArenaConfig & arena_cfg,
|
||||
std::uint32_t ngen,
|
||||
std::uint32_t nsurvive,
|
||||
bool debug_flag)
|
||||
: arena_config_{arena_cfg},
|
||||
n_generation_{ngen},
|
||||
n_survive_threshold_{nsurvive},
|
||||
debug_flag_{debug_flag}
|
||||
{}
|
||||
|
||||
|
|
|
|||
|
|
@ -9,11 +9,15 @@ namespace xo {
|
|||
namespace mm {
|
||||
|
||||
MutationLogConfig::MutationLogConfig(std::uint32_t ngen,
|
||||
#ifdef OBSOLETE
|
||||
std::uint32_t survive,
|
||||
#endif
|
||||
std::size_t mlog_z,
|
||||
bool debug_flag)
|
||||
: n_generation_{ngen},
|
||||
#ifdef OBSOLETE
|
||||
n_survive_threshold_{survive},
|
||||
#endif
|
||||
mutation_log_z_{mlog_z},
|
||||
debug_flag_{debug_flag}
|
||||
{}
|
||||
|
|
|
|||
|
|
@ -426,8 +426,8 @@ namespace xo {
|
|||
|
||||
bool need_mlog_entry
|
||||
= ((child_gen_to + 1 < config_.n_generation_)
|
||||
&& (config_.promotion_threshold(parent_gen_to)
|
||||
> config_.promotion_threshold(child_gen_to)));
|
||||
&& (gco_store.config().promotion_threshold(parent_gen_to)
|
||||
> gco_store.config().promotion_threshold(child_gen_to)));
|
||||
|
||||
if (need_mlog_entry) {
|
||||
// 1. P->C pointer is still cross-age (xage), and
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue