xo-gc: cosmetic: rename xo::mm::role -> xo::mm::Role

This commit is contained in:
Roland Conybeare 2026-04-06 23:33:05 -04:00
commit 10e61a1d78
23 changed files with 156 additions and 155 deletions

View file

@ -37,40 +37,40 @@
},
],
const_methods: [
// size_type allocated(Generation g, role r) const noexcept
// size_type allocated(Generation g, Role r) const noexcept
{
name: "allocated",
doc: ["memory in use for this collector"],
return_type: "size_type",
args: [
{type: "Generation", name: "g"},
{type: "role", name: "r"},
{type: "Role", name: "r"},
],
const: true,
noexcept: true,
attributes: [],
},
// size_type committed(Generation g, role r) const noexcept
// size_type committed(Generation g, Role r) const noexcept
{
name: "committed",
doc: ["memory committed for this collector"],
return_type: "size_type",
args: [
{type: "Generation", name: "g"},
{type: "role", name: "r"},
{type: "Role", name: "r"},
],
const: true,
noexcept: true,
attributes: [],
},
// size_type reserved(Generation g, role r) const noexcept
// size_type reserved(Generation g, Role r) const noexcept
{
name: "reserved",
doc: ["address space reserved for this collector"],
return_type: "size_type",
args: [
{type: "Generation", name: "g"},
{type: "role", name: "r"},
{type: "Role", name: "r"},
],
const: true,
noexcept: true,
@ -92,13 +92,13 @@
noexcept: true,
attributes: [],
},
// bool contains(role r, const void * addr) const noexcept
// bool contains(Role r, const void * addr) const noexcept
{
name: "contains",
doc: ["true if gc responsible for data at @p addr, and data belongs to role @p r"],
doc: ["true if gc responsible for data at @p addr, and data belongs to Role @p r"],
return_type: "bool",
args: [
{type: "role", name: "r"},
{type: "Role", name: "r"},
{type: "const void *", name: "addr"},
],
const: true,

View file

@ -51,7 +51,7 @@
noexcept: false,
attributes: [],
},
// Generation generation_of(role r, const void * addr) const noexcept;
// Generation generation_of(Role r, const void * addr) const noexcept;
{
name: "generation_of",
doc: [
@ -60,7 +60,7 @@
],
return_type: "Generation",
args: [
{type: "role", name: "r"},
{type: "Role", name: "r"},
{type: "const void *", name: "addr"},
],
const: true,

View file

@ -60,17 +60,17 @@ public:
/** destroy instance @p d; calls c++ dtor only for actual runtime type; does not recover memory **/
virtual void _drop(Opaque d) const noexcept = 0;
/** memory in use for this collector **/
virtual size_type allocated(Copaque data, Generation g, role r) const noexcept = 0;
virtual size_type allocated(Copaque data, Generation g, Role r) const noexcept = 0;
/** memory committed for this collector **/
virtual size_type committed(Copaque data, Generation g, role r) const noexcept = 0;
virtual size_type committed(Copaque data, Generation g, Role r) const noexcept = 0;
/** address space reserved for this collector **/
virtual size_type reserved(Copaque data, Generation g, role r) const noexcept = 0;
virtual size_type reserved(Copaque data, Generation g, Role r) const noexcept = 0;
/** Location of object in collector. -1 if not in collector memory.
Other negative values represent collector error states (good luck!).
Exact meaning of non-negative values up to collector implementation **/
virtual std::int32_t locate_address(Copaque data, const void * addr) const noexcept = 0;
/** true if gc responsible for data at @p addr, and data belongs to role @p r **/
virtual bool contains(Copaque data, role r, const void * addr) const noexcept = 0;
/** true if gc responsible for data at @p addr, and data belongs to Role @p r **/
virtual bool contains(Copaque data, Role r, const void * addr) const noexcept = 0;
/** true iff gc-aware object of type @p tseq is installed in this collector **/
virtual bool is_type_installed(Copaque data, typeseq tseq) const noexcept = 0;
/** Report gc statistics, at discretion of collector implementation.

View file

@ -63,7 +63,7 @@ public:
virtual AllocInfo alloc_info(Copaque data, void * addr) const = 0;
/** generation to which pointer @p addr belongs, given role @p r;
sentinel if @p addr is not owned by collector **/
virtual Generation generation_of(Copaque data, role r, const void * addr) const noexcept = 0;
virtual Generation generation_of(Copaque data, Role r, const void * addr) const noexcept = 0;
// nonconst methods
/** allocate copy of source object at address @p src.

View file

@ -59,11 +59,11 @@ namespace mm {
[[noreturn]] void _drop(Opaque) const noexcept override { _fatal(); }
// const methods
[[noreturn]] size_type allocated(Copaque, Generation, role) const noexcept override { _fatal(); }
[[noreturn]] size_type committed(Copaque, Generation, role) const noexcept override { _fatal(); }
[[noreturn]] size_type reserved(Copaque, Generation, role) const noexcept override { _fatal(); }
[[noreturn]] size_type allocated(Copaque, Generation, Role) const noexcept override { _fatal(); }
[[noreturn]] size_type committed(Copaque, Generation, Role) const noexcept override { _fatal(); }
[[noreturn]] size_type reserved(Copaque, Generation, Role) const noexcept override { _fatal(); }
[[noreturn]] std::int32_t locate_address(Copaque, const void *) const noexcept override { _fatal(); }
[[noreturn]] bool contains(Copaque, role, const void *) const noexcept override { _fatal(); }
[[noreturn]] bool contains(Copaque, Role, const void *) const noexcept override { _fatal(); }
[[noreturn]] bool is_type_installed(Copaque, typeseq) const noexcept override { _fatal(); }
[[noreturn]] bool report_statistics(Copaque, obj<AAllocator>, obj<AAllocator>, obj<AGCObject> *) const noexcept override { _fatal(); }
[[noreturn]] bool report_object_types(Copaque, obj<AAllocator>, obj<AAllocator>, obj<AGCObject> *) const noexcept override { _fatal(); }

View file

@ -46,19 +46,19 @@ namespace mm {
void _drop(Opaque d) const noexcept override { _dcast(d).~DRepr(); }
// const methods
size_type allocated(Copaque data, Generation g, role r) const noexcept override {
size_type allocated(Copaque data, Generation g, Role r) const noexcept override {
return I::allocated(_dcast(data), g, r);
}
size_type committed(Copaque data, Generation g, role r) const noexcept override {
size_type committed(Copaque data, Generation g, Role r) const noexcept override {
return I::committed(_dcast(data), g, r);
}
size_type reserved(Copaque data, Generation g, role r) const noexcept override {
size_type reserved(Copaque data, Generation g, Role r) const noexcept override {
return I::reserved(_dcast(data), g, r);
}
std::int32_t locate_address(Copaque data, const void * addr) const noexcept override {
return I::locate_address(_dcast(data), addr);
}
bool contains(Copaque data, role r, const void * addr) const noexcept override {
bool contains(Copaque data, Role r, const void * addr) const noexcept override {
return I::contains(_dcast(data), r, addr);
}
bool is_type_installed(Copaque data, typeseq tseq) const noexcept override {

View file

@ -59,7 +59,7 @@ namespace mm {
// const methods
[[noreturn]] AllocInfo alloc_info(Copaque, void *) const override { _fatal(); }
[[noreturn]] Generation generation_of(Copaque, role, const void *) const noexcept override { _fatal(); }
[[noreturn]] Generation generation_of(Copaque, Role, const void *) const noexcept override { _fatal(); }
// nonconst methods
[[noreturn]] void * alloc_copy(Opaque, std::byte *) const override;

View file

@ -48,7 +48,7 @@ namespace mm {
AllocInfo alloc_info(Copaque data, void * addr) const override {
return I::alloc_info(_dcast(data), addr);
}
Generation generation_of(Copaque data, role r, const void * addr) const noexcept override {
Generation generation_of(Copaque data, Role r, const void * addr) const noexcept override {
return I::generation_of(_dcast(data), r, addr);
}

View file

@ -95,19 +95,19 @@ public:
void _drop() const noexcept { O::iface()->_drop(O::data()); }
// const methods
size_type allocated(Generation g, role r) const noexcept {
size_type allocated(Generation g, Role r) const noexcept {
return O::iface()->allocated(O::data(), g, r);
}
size_type committed(Generation g, role r) const noexcept {
size_type committed(Generation g, Role r) const noexcept {
return O::iface()->committed(O::data(), g, r);
}
size_type reserved(Generation g, role r) const noexcept {
size_type reserved(Generation g, Role r) const noexcept {
return O::iface()->reserved(O::data(), g, r);
}
std::int32_t locate_address(const void * addr) const noexcept {
return O::iface()->locate_address(O::data(), addr);
}
bool contains(role r, const void * addr) const noexcept {
bool contains(Role r, const void * addr) const noexcept {
return O::iface()->contains(O::data(), r, addr);
}
bool is_type_installed(typeseq tseq) const noexcept {

View file

@ -91,7 +91,7 @@ public:
AllocInfo alloc_info(void * addr) const {
return O::iface()->alloc_info(O::data(), addr);
}
Generation generation_of(role r, const void * addr) const noexcept {
Generation generation_of(Role r, const void * addr) const noexcept {
return O::iface()->generation_of(O::data(), r, addr);
}

View file

@ -12,18 +12,19 @@ namespace xo {
namespace mm {
static constexpr uint32_t c_n_role = 2;
struct role {
class Role {
public:
using value_type = std::uint32_t;
explicit constexpr role(value_type x) : role_{x} {}
explicit constexpr Role(value_type x) : role_{x} {}
static constexpr role to_space() { return role{0}; }
static constexpr role from_space() { return role{1}; }
static constexpr Role to_space() { return Role{0}; }
static constexpr Role from_space() { return Role{1}; }
static constexpr std::array<role, c_n_role> all() { return {{to_space(), from_space()}}; }
static constexpr std::array<Role, c_n_role> all() { return {{to_space(), from_space()}}; }
static constexpr role begin() { return role{0}; }
static constexpr role end() { return role{2}; }
static constexpr Role begin() { return Role{0}; }
static constexpr Role end() { return Role{2}; }
operator value_type() const { return role_; }

View file

@ -118,34 +118,34 @@ namespace xo {
GCRunState runstate() const noexcept { return runstate_; }
const ObjectTypeTable * get_object_types() const noexcept { return gco_store_.get_object_types(); }
const RootSet * get_root_set() const noexcept { return &root_set_; }
const DArena * get_space(role r, Generation g) const noexcept { return gco_store_.get_space(r, g); }
DArena * get_space(role r, Generation g) noexcept { return gco_store_.get_space(r, g); }
DArena * from_space(Generation g) noexcept { return this->get_space(role::from_space(), g); }
DArena * to_space(Generation g) noexcept { return this->get_space(role::to_space(), g); }
const DArena * get_space(Role r, Generation g) const noexcept { return gco_store_.get_space(r, g); }
DArena * get_space(Role r, Generation g) noexcept { return gco_store_.get_space(r, g); }
DArena * from_space(Generation g) noexcept { return this->get_space(Role::from_space(), g); }
DArena * to_space(Generation g) noexcept { return this->get_space(Role::to_space(), g); }
DArena * new_space() noexcept { return this->to_space(Generation{0}); }
// ----- basic statistics -----
/** total reserved memory in bytes, across all {role, generation} **/
/** total reserved memory in bytes, across all {Role, generation} **/
size_type reserved() const noexcept;
/** total size in bytes (same as committed_total()) **/
size_type size_total() const noexcept;
/** total committed memory in bytes, across all {role, generation} **/
/** total committed memory in bytes, across all {Role, generation} **/
size_type committed() const noexcept;
/** total available memory in bytes, across all {role, generation} **/
/** total available memory in bytes, across all {Role, generation} **/
size_type available() const noexcept;
/** total allocated memory in bytes, across all {role, generation} **/
/** total allocated memory in bytes, across all {Role, generation} **/
size_type allocated() const noexcept;
/** total number of mutation log entries **/
size_type mutation_log_entries() const noexcept;
/** memory allocated for generation @p g in role @p r **/
size_type allocated(Generation g, role r) const noexcept;
/** memory committed for generation @p g in role @p r **/
size_type committed(Generation g, role r) const noexcept;
/** memory (virtual addresses) reserved for generation @p g in role @p r **/
size_type reserved(Generation g, role r) const noexcept;
/** memory allocated for generation @p g in Role @p r **/
size_type allocated(Generation g, Role r) const noexcept;
/** memory committed for generation @p g in Role @p r **/
size_type committed(Generation g, Role r) const noexcept;
/** memory (virtual addresses) reserved for generation @p g in Role @p r **/
size_type reserved(Generation g, Role r) const noexcept;
/** very similar to generation_of(), but satisfies ACollector api **/
std::int32_t locate_address(const void * addr) const noexcept;
@ -197,21 +197,21 @@ namespace xo {
void visit_pools(const MemorySizeVisitor & visitor) const;
/** true iff address @p addr allocated from this collector
* in role @p r (according to current GC state)
* in Role @p r (according to current GC state)
**/
bool contains(role r, const void * addr) const noexcept;
bool contains(Role r, const void * addr) const noexcept;
/** true iff address @p addr allocated from this collector and currently live
* in role @p r (according to current GC state)
* in Role @p r (according to current GC state)
*
* (i.e. in [lo,free) for an arena)
**/
bool contains_allocated(role r, const void * addr) const noexcept;
bool contains_allocated(Role r, const void * addr) const noexcept;
/** generation to which pointer @p addr belongs, given role @p r;
/** generation to which pointer @p addr belongs, given Role @p r;
* sentinel if not found in this collector
**/
Generation generation_of(role r, const void * addr) const noexcept;
Generation generation_of(Role r, const void * addr) const noexcept;
/** return details from last error (will be in gen0 to-space) **/
AllocError last_error() const noexcept;
@ -352,7 +352,7 @@ namespace xo {
/** aux init function: initialize @ref space_storage_[][] arenas **/
void _init_space(const X1CollectorConfig & cfg);
/** swap from- and to- roles for all generations < @p upto **/
/** swap from- and to- Roles for all generations < @p upto **/
void _swap_roles(Generation upto) noexcept;
/** copy roots + everything reachable from them, to to-space **/
void _copy_roots(Generation upto) noexcept;

View file

@ -33,10 +33,10 @@ namespace xo {
const GCObjectStoreConfig & config() const noexcept { return config_; }
const ObjectTypeTable * get_object_types() const noexcept { return &object_types_; }
const DArena * get_space(role r, Generation g) const noexcept { return space_[r][g]; }
DArena * get_space(role r, Generation g) noexcept { return space_[r][g]; }
DArena * from_space(Generation g) noexcept { return get_space(role::from_space(), g); }
DArena * to_space(Generation g) noexcept { return get_space(role::to_space(), g); }
const DArena * get_space(Role r, Generation g) const noexcept { return space_[r][g]; }
DArena * get_space(Role r, Generation g) noexcept { return space_[r][g]; }
DArena * from_space(Generation g) noexcept { return get_space(Role::from_space(), g); }
DArena * to_space(Generation g) noexcept { return get_space(Role::to_space(), g); }
DArena * new_space() noexcept { return to_space(Generation{0}); }
/** true iff type with id @p tseq has known metadata
@ -50,10 +50,10 @@ namespace xo {
**/
AGCObject * lookup_type(typeseq tseq) const noexcept;
/** generation to which pointer @p addr belongs, given role @p r;
/** generation to which pointer @p addr belongs, given Role @p r;
* sentinel if not found in this collector
**/
Generation generation_of(role r, const void * addr) const noexcept;
Generation generation_of(Role r, const void * addr) const noexcept;
/** get allocation size from header **/
std::size_t header2size(header_type hdr) const noexcept;
@ -72,16 +72,16 @@ namespace xo {
void visit_pools(const MemorySizeVisitor & visitor) const;
/** true iff address @p addr allocated from this collector
* in role @p r (according to current GC state)
* in Role @p r (according to current GC state)
**/
bool contains(role r, const void * addr) const noexcept;
bool contains(Role r, const void * addr) const noexcept;
/** true iff address @p addr allocated from this collector and currently live
* in role @p r (according to current GC state)
* in Role @p r (according to current GC state)
*
* (i.e. in [lo,free) for an arena)
**/
bool contains_allocated(role r, const void * addr) const noexcept;
bool contains_allocated(Role r, const void * addr) const noexcept;
/** Report per-age-bucket information as an array of dictionaries.
* Scans to-space to count per-age statistics.

View file

@ -48,17 +48,17 @@ namespace xo {
///@{
// const methods
/** memory in use for this collector **/
static size_type allocated(const DX1Collector & self, Generation g, role r) noexcept;
static size_type allocated(const DX1Collector & self, Generation g, Role r) noexcept;
/** memory committed for this collector **/
static size_type committed(const DX1Collector & self, Generation g, role r) noexcept;
static size_type committed(const DX1Collector & self, Generation g, Role r) noexcept;
/** address space reserved for this collector **/
static size_type reserved(const DX1Collector & self, Generation g, role r) noexcept;
static size_type reserved(const DX1Collector & self, Generation g, Role r) noexcept;
/** Location of object in collector. -1 if not in collector memory.
Other negative values represent collector error states (good luck!).
Exact meaning of non-negative values up to collector implementation **/
static std::int32_t locate_address(const DX1Collector & self, const void * addr) noexcept;
/** true if gc responsible for data at @p addr, and data belongs to role @p r **/
static bool contains(const DX1Collector & self, role r, const void * addr) noexcept;
/** true if gc responsible for data at @p addr, and data belongs to Role @p r **/
static bool contains(const DX1Collector & self, Role r, const void * addr) noexcept;
/** true iff gc-aware object of type @p tseq is installed in this collector **/
static bool is_type_installed(const DX1Collector & self, typeseq tseq) noexcept;
/** Report gc statistics, at discretion of collector implementation.

View file

@ -50,7 +50,7 @@ namespace xo {
static AllocInfo alloc_info(const DX1Collector & self, void * addr);
/** generation to which pointer @p addr belongs, given role @p r;
sentinel if @p addr is not owned by collector **/
static Generation generation_of(const DX1Collector & self, role r, const void * addr) noexcept;
static Generation generation_of(const DX1Collector & self, Role r, const void * addr) noexcept;
// non-const methods
/** allocate copy of source object at address @p src.

View file

@ -110,19 +110,19 @@ namespace xo {
}
bool
DX1Collector::contains(role r, const void * addr) const noexcept
DX1Collector::contains(Role r, const void * addr) const noexcept
{
return gco_store_.contains(r, addr);
}
bool
DX1Collector::contains_allocated(role r, const void * addr) const noexcept
DX1Collector::contains_allocated(Role r, const void * addr) const noexcept
{
return gco_store_.contains_allocated(r, addr);
}
Generation
DX1Collector::generation_of(role r, const void * addr) const noexcept
DX1Collector::generation_of(Role r, const void * addr) const noexcept
{
return gco_store_.generation_of(r, addr);
}
@ -134,7 +134,7 @@ namespace xo {
// need to adjust here if runtime errors
// encountered during gc.
return get_space(role::to_space(), Generation::nursery())->last_error_;
return get_space(Role::to_space(), Generation::nursery())->last_error_;
}
namespace {
@ -148,7 +148,7 @@ namespace xo {
size_t z3 = 0;
for (role ri : role::all()) {
for (Role ri : Role::all()) {
for (Generation gj{0}; gj < d.config_.n_generation_; ++gj) {
const DArena * arena = d.get_space(ri, gj);
@ -203,7 +203,7 @@ namespace xo {
stat_helper(const DX1Collector & d,
size_type (DArena::* getter)() const,
Generation g,
role r)
Role r)
{
const DArena * arena = d.get_space(r, g);
@ -215,19 +215,19 @@ namespace xo {
}
size_type
DX1Collector::allocated(Generation g, role r) const noexcept
DX1Collector::allocated(Generation g, Role r) const noexcept
{
return stat_helper(*this, &DArena::allocated, g, r);
}
size_type
DX1Collector::committed(Generation g, role r) const noexcept
DX1Collector::committed(Generation g, Role r) const noexcept
{
return stat_helper(*this, &DArena::committed, g, r);
}
size_type
DX1Collector::reserved(Generation g, role r) const noexcept
DX1Collector::reserved(Generation g, Role r) const noexcept
{
return stat_helper(*this, &DArena::reserved, g, r);
}
@ -237,12 +237,12 @@ namespace xo {
{
Generation g;
g = this->generation_of(role::to_space(), addr);
g = this->generation_of(Role::to_space(), addr);
if (!g.is_sentinel())
return g;
g = this->generation_of(role::from_space(), addr);
g = this->generation_of(Role::from_space(), addr);
if (!g.is_sentinel()) {
// use negative values for
@ -283,7 +283,7 @@ namespace xo {
// per-(generation,role) info
{
for (Generation gi{0}; gi < config_.n_generation_; ++gi) {
for (role rj : role::all()) {
for (Role rj : Role::all()) {
const DArena * arena = this->get_space(rj, gi);
DDictionary * arena_d = DDictionary::make(mm);
@ -510,8 +510,8 @@ namespace xo {
log && log("step 1 : swap from/to roles (now to-space is empty)");
this->_swap_roles(upto);
log && log(xtag("from_0", get_space(role::from_space(), Generation{0})->lo_),
xtag("to_0", get_space(role::to_space(), Generation{0})->lo_));
log && log(xtag("from_0", get_space(Role::from_space(), Generation{0})->lo_),
xtag("to_0", get_space(Role::to_space(), Generation{0})->lo_));
log && log("step 2a : copy roots");
this->_copy_roots(upto);
@ -632,12 +632,12 @@ namespace xo {
(void)iface;
(void)data;
Generation g1 = this->generation_of(role::to_space(), data);
Generation g1 = this->generation_of(Role::to_space(), data);
if (g1.is_sentinel()) {
assert(this->contains(role::to_space(), data) == false);
assert(this->contains(Role::to_space(), data) == false);
Generation g2 = this->generation_of(role::from_space(), data);
Generation g2 = this->generation_of(Role::from_space(), data);
if (!g2.is_sentinel()) {
// verify failure - live pointer still refers to from-space
@ -647,7 +647,7 @@ namespace xo {
++(verify_stats_.n_ext_);
}
} else {
assert(this->contains(role::to_space(), data));
assert(this->contains(Role::to_space(), data));
++(verify_stats_.n_to_);
}
@ -713,7 +713,7 @@ namespace xo {
scope log(XO_DEBUG(false));
const DArena * arena
= get_space(role::to_space(),
= get_space(Role::to_space(),
Generation{0});
return DX1CollectorIterator(this,
@ -735,7 +735,7 @@ namespace xo {
**/
const DArena * arena
= get_space(role::to_space(),
= get_space(Role::to_space(),
Generation(config_.n_generation_ - 1));
DArenaIterator arena_end = arena->end();
@ -748,7 +748,7 @@ namespace xo {
void
DX1Collector::clear() noexcept {
for (role ri : role::all()) {
for (Role ri : Role::all()) {
for (Generation gj{0}; gj < config_.n_generation_; ++gj) {
DArena * arena = this->get_space(ri, gj);

View file

@ -42,7 +42,7 @@ namespace xo {
for (; gen_ix_ < gen_hi_; ++gen_ix_) {
const DArena * arena
= gc_->get_space(role::to_space(), gen_ix_);
= gc_->get_space(Role::to_space(), gen_ix_);
assert(arena);

View file

@ -80,20 +80,20 @@ namespace xo {
= DArena::map(config_.arena_config_.with_name(std::string(buf)));
}
this->space_[role::to_space()][igen] = &space_storage_[0][igen];
this->space_[role::from_space()][igen] = &space_storage_[1][igen];
this->space_[Role::to_space()][igen] = &space_storage_[0][igen];
this->space_[Role::from_space()][igen] = &space_storage_[1][igen];
} else {
assert(false);
}
}
for (uint32_t igen = config_.n_generation_; igen < c_max_generation; ++igen) {
this->space_[role::to_space()][igen] = nullptr;
this->space_[role::from_space()][igen] = nullptr;
this->space_[Role::to_space()][igen] = nullptr;
this->space_[Role::from_space()][igen] = nullptr;
}
if (config_.n_generation_ == 2) {
assert(this->get_space(role::to_space(), Generation{2}) == nullptr);
assert(this->get_space(Role::to_space(), Generation{2}) == nullptr);
}
}
@ -149,7 +149,7 @@ namespace xo {
}
Generation
GCObjectStore::generation_of(role r, const void * addr) const noexcept
GCObjectStore::generation_of(Role r, const void * addr) const noexcept
{
for (Generation gi{0}; gi < config_.n_generation_; ++gi) {
const DArena * arena = this->get_space(r, gi);
@ -196,7 +196,7 @@ namespace xo {
AllocInfo
GCObjectStore::alloc_info(value_type mem) const noexcept {
for (role ri : role::all()) {
for (Role ri : Role::all()) {
for (Generation gj{0}; gj < config_.n_generation_; ++gj) {
const DArena * arena = this->get_space(ri, gj);
@ -209,7 +209,7 @@ namespace xo {
}
// deliberately attempt on nursery to-space, to capture error info + return sentinel
return this->get_space(role::to_space(), Generation{0})->alloc_info(mem);
return this->get_space(Role::to_space(), Generation{0})->alloc_info(mem);
}
void
@ -225,13 +225,13 @@ namespace xo {
}
bool
GCObjectStore::contains(role r, const void * addr) const noexcept
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
GCObjectStore::contains_allocated(Role r, const void * addr) const noexcept
{
Generation g = this->generation_of(r, addr);
@ -304,7 +304,7 @@ namespace xo {
// scan to-space, count objects by type
for (Generation g{0}; g < config_.n_generation_; ++g) {
const DArena * arena = this->get_space(role::to_space(), g);
const DArena * arena = this->get_space(Role::to_space(), g);
for (AllocInfo info : *arena) {
if (info.is_forwarding_tseq()) {
@ -392,7 +392,7 @@ namespace xo {
std::int64_t max_age_present = 0;
for (Generation g{0}; g < config_.n_generation_; ++g) {
const DArena * arena = this->get_space(role::to_space(), g);
const DArena * arena = this->get_space(Role::to_space(), g);
for (AllocInfo info : *arena) {
if (info.is_forwarding_tseq()) {
@ -485,7 +485,7 @@ namespace xo {
if (!object_data) {
/* trivial to forward nullptr */
return;
} else if (!this->contains(role::from_space(), object_data)) {
} else if (!this->contains(Role::from_space(), object_data)) {
/* *lhs_data either:
* 1. already in to-space
* 2. not in GC-allocated space at all
@ -648,7 +648,7 @@ namespace xo {
for (Generation g = Generation{0}; g < upto; ++g) {
log && log("swap roles", xtag("g", g));
std::swap(space_[role::to_space()][g], space_[role::from_space()][g]);
std::swap(space_[Role::to_space()][g], space_[Role::from_space()][g]);
}
}
@ -663,10 +663,10 @@ namespace xo {
//
for (Generation g = Generation{0}; g < upto; ++g) {
if (sanitize_flag) {
space_[role::from_space()][g]->scrub();
space_[Role::from_space()][g]->scrub();
}
space_[role::from_space()][g]->clear();
space_[Role::from_space()][g]->clear();
}
}
@ -687,7 +687,7 @@ namespace xo {
X1VerifyStats * p_verify_stats) noexcept
{
for (Generation g(0); g < config_.n_generation_; ++g) {
const DArena * space = this->get_space(role::to_space(), g);
const DArena * space = this->get_space(Role::to_space(), g);
for (const AllocInfo & info : *space) {
@ -762,7 +762,7 @@ namespace xo {
if (!from_src)
return nullptr;
bool src_in_from_space = this->contains(role::from_space(),
bool src_in_from_space = this->contains(Role::from_space(),
from_src.data());
if (src_in_from_space) {
@ -798,7 +798,7 @@ namespace xo {
if (!from_src)
return nullptr;
bool src_in_from_space = this->contains(role::from_space(), from_src);
bool src_in_from_space = this->contains(Role::from_space(), from_src);
if (!src_in_from_space)
return from_src;
@ -817,7 +817,7 @@ namespace xo {
AllocHeader hdr = info.header();
typeseq tseq(info.tseq());
assert(this->contains_allocated(role::from_space(), from_src));
assert(this->contains_allocated(Role::from_space(), from_src));
if (this->is_forwarding_header(hdr)) {
/* already forwarded - pickup destination

View file

@ -65,7 +65,7 @@ namespace xo {
bool
IAllocator_DX1Collector::contains(const DX1Collector & d, const void * addr) noexcept
{
return d.contains(role::to_space(), addr);
return d.contains(Role::to_space(), addr);
}
AllocError

View file

@ -73,7 +73,7 @@ namespace xo {
size_type z = 0;
for (Generation gj{0}; gj + 1 < config_.n_generation_; ++gj) {
z += mlog_[role::to_space()][gj]->size();
z += mlog_[Role::to_space()][gj]->size();
}
return z;
@ -95,15 +95,15 @@ namespace xo {
{
// 4. scan mutation logs
for (Generation g(0); g + 1 < config_.n_generation_; ++g) {
const DArena * space = gco_store->get_space(role::to_space(), g);
const DArena * from = gco_store->get_space(role::from_space(), g);
const DArena * space = gco_store->get_space(Role::to_space(), g);
const DArena * from = gco_store->get_space(Role::from_space(), g);
// mutation log for generation g records *incoming* pointers
// from more senior generations; includes objects from *this*
// generation that are older (track since source promotes before
// destination)
//
for (const MutationLogEntry & mrecd : *(mlog_[role::to_space()][g])) {
for (const MutationLogEntry & mrecd : *(mlog_[Role::to_space()][g])) {
// mutation log entries are only valid until the next assignment
// at the source location. Superseded entry may now point
// somewhere else. The snapshot member must however point
@ -159,7 +159,7 @@ namespace xo {
// 1. generation of lhs
// 2. generation of rhs
Generation src_g = gco_store->generation_of(role::to_space(), p_lhs);
Generation src_g = gco_store->generation_of(Role::to_space(), p_lhs);
if (src_g.is_sentinel()) {
// only need mlog entries for gc-owned pointers.
@ -167,7 +167,7 @@ namespace xo {
return;
}
Generation dest_g = gco_store->generation_of(role::to_space(), rhs.data());
Generation dest_g = gco_store->generation_of(Role::to_space(), rhs.data());
if (dest_g.is_sentinel()) {
// similarly, don't need mlog entry to non-gc-owned destination
@ -185,7 +185,7 @@ namespace xo {
// for pointers within the same generation, need to log
// if source is older than destination.
const DArena * arena = gco_store->get_space(role::to_space(), src_g);
const DArena * arena = gco_store->get_space(Role::to_space(), src_g);
const DArena::header_type * src_hdr = arena->obj2hdr(parent);
const DArena::header_type * dest_hdr = arena->obj2hdr(rhs.data());
@ -226,7 +226,7 @@ namespace xo {
// collection that moves destination generation around needs to also
// update pointers such as this one
//
MutationLog * mlog = this->mlog_[role::to_space()][dest_g];
MutationLog * mlog = this->mlog_[Role::to_space()][dest_g];
mlog->push_back(MutationLogEntry(parent, addr, rhs));
}
@ -239,7 +239,7 @@ namespace xo {
for (Generation g = Generation{0}; g < upto; ++g) {
log && log("swap roles", xtag("g", g));
std::swap(mlog_[role::to_space()][g], mlog_[role::from_space()][g]);
std::swap(mlog_[Role::to_space()][g], mlog_[Role::from_space()][g]);
}
}
@ -260,10 +260,10 @@ namespace xo {
child_gen + 2 < config_.n_generation_;
++child_gen) {
MutationLog * from_mlog = this->mlog_[role::from_space()][child_gen];
MutationLog * from_mlog = this->mlog_[Role::from_space()][child_gen];
if (!from_mlog->empty()) {
MutationLog * to_mlog = this->mlog_[role::to_space()][child_gen];
MutationLog * to_mlog = this->mlog_[Role::to_space()][child_gen];
MutationLog * triage_mlog = this->mlog_[c_n_role][child_gen];
auto stats = this->_forward_mutation_log_phase(gc,
@ -277,7 +277,7 @@ namespace xo {
// {from_mlog, triage_mlog} reverse roles
std::swap(this->mlog_[role::from_space()][child_gen],
std::swap(this->mlog_[Role::from_space()][child_gen],
this->mlog_[c_n_role][child_gen]);
work += stats.n_rescue_;
@ -376,7 +376,7 @@ namespace xo {
/* here: mlog current */
Generation parent_gen_to = gc.generation_of(role::to_space(),
Generation parent_gen_to = gc.generation_of(Role::to_space(),
from_entry.parent());
if (parent_gen_to.is_sentinel()) {
@ -393,7 +393,7 @@ namespace xo {
// TODO: method on AllocInfo to streamline this
void * parent_to = *(void **)parent_fr;
parent_gen_to = gc.generation_of(role::to_space(),
parent_gen_to = gc.generation_of(Role::to_space(),
parent_to);
parent_info = gc.alloc_info((std::byte *)parent_to);
@ -503,7 +503,7 @@ namespace xo {
MutationLog * keep_mlog)
{
Generation child_gen_to
= gco_store_->generation_of(role::to_space(), child_to);
= gco_store_->generation_of(Role::to_space(), child_to);
bool need_mlog_entry
= ((child_gen_to + 1 < config_.n_generation_)

View file

@ -16,19 +16,19 @@
namespace xo {
namespace mm {
auto
ICollector_DX1Collector::allocated(const DX1Collector & self, Generation g, role r) noexcept -> size_type
ICollector_DX1Collector::allocated(const DX1Collector & self, Generation g, Role r) noexcept -> size_type
{
return self.allocated(g, r);
}
auto
ICollector_DX1Collector::committed(const DX1Collector & self, Generation g, role r) noexcept -> size_type
ICollector_DX1Collector::committed(const DX1Collector & self, Generation g, Role r) noexcept -> size_type
{
return self.committed(g, r);
}
auto
ICollector_DX1Collector::reserved(const DX1Collector & self, Generation g, role r) noexcept -> size_type
ICollector_DX1Collector::reserved(const DX1Collector & self, Generation g, Role r) noexcept -> size_type
{
return self.reserved(g, r);
}
@ -40,7 +40,7 @@ namespace xo {
}
auto
ICollector_DX1Collector::contains(const DX1Collector & self, role r, const void * addr) noexcept -> bool
ICollector_DX1Collector::contains(const DX1Collector & self, Role r, const void * addr) noexcept -> bool
{
return self.contains(r, addr);
}

View file

@ -22,7 +22,7 @@ namespace xo {
}
auto
IGCObjectVisitor_DX1Collector::generation_of(const DX1Collector & self, role r, const void * addr) noexcept -> Generation
IGCObjectVisitor_DX1Collector::generation_of(const DX1Collector & self, Role r, const void * addr) noexcept -> Generation
{
return self.generation_of(r, addr);
}

View file

@ -47,7 +47,7 @@ namespace ut {
using xo::mm::DArena;
using xo::mm::ArenaConfig;
using xo::mm::Generation;
using xo::mm::role;
using xo::mm::Role;
using xo::mm::padding;
using xo::facet::obj;
using xo::facet::with_facet;
@ -145,7 +145,7 @@ namespace ut {
REQUIRE(roots->store()->reserved() >= cfg.object_roots_z_);
REQUIRE(roots->store()->reserved() < cfg.object_roots_z_ + roots->store()->page_z_);
const DArena * from_0 = gc.get_space(role::from_space(), Generation{0});
const DArena * from_0 = gc.get_space(Role::from_space(), Generation{0});
REQUIRE(from_0 != nullptr);
REQUIRE(from_0->reserved() >= tc.tenured_z_);
@ -153,29 +153,29 @@ namespace ut {
REQUIRE(from_0->reserved() % from_0->page_z_ == 0);
REQUIRE(from_0->allocated() == 0);
const DArena * from_1 = gc.get_space(role::from_space(), Generation{1});
const DArena * from_1 = gc.get_space(Role::from_space(), Generation{1});
REQUIRE(from_1 != nullptr);
REQUIRE(from_1->reserved() == from_0->reserved());
REQUIRE(from_1->allocated() == 0);
to_0 = gc.get_space(role::to_space(), Generation{0});
to_0 = gc.get_space(Role::to_space(), Generation{0});
REQUIRE(to_0 != nullptr);
REQUIRE(to_0->reserved() == from_0->reserved());
REQUIRE(to_0->allocated() == 0);
const DArena * to_1 = gc.get_space(role::to_space(), Generation{1});
const DArena * to_1 = gc.get_space(Role::to_space(), Generation{1});
REQUIRE(to_1 != nullptr);
REQUIRE(to_1->reserved() == to_0->reserved());
REQUIRE(to_1->allocated() == 0);
const DArena * from_2 = gc.get_space(role::from_space(), Generation{2});
const DArena * from_2 = gc.get_space(Role::from_space(), Generation{2});
REQUIRE(from_2 == nullptr);
const DArena * to_2 = gc.get_space(role::to_space(), Generation{2});
const DArena * to_2 = gc.get_space(Role::to_space(), Generation{2});
REQUIRE(to_2 == nullptr);
@ -224,7 +224,7 @@ namespace ut {
{
REQUIRE(x0_o.iface() != nullptr);
REQUIRE(x0_o.data() != nullptr);
REQUIRE(gc.contains(role::to_space(), x0_o.data()));
REQUIRE(gc.contains(Role::to_space(), x0_o.data()));
/* check alloc info for newly-allocated object */
AllocInfo info = gc.alloc_info((std::byte *)x0_o.data());
@ -238,7 +238,7 @@ namespace ut {
{
REQUIRE(n1_o.iface() != nullptr);
REQUIRE(n1_o.data() != nullptr);
REQUIRE(gc.contains(role::to_space(), n1_o.data()));
REQUIRE(gc.contains(Role::to_space(), n1_o.data()));
/* check alloc info for newly-allocated object */
AllocInfo info = gc.alloc_info((std::byte *)n1_o.data());
@ -252,7 +252,7 @@ namespace ut {
{
REQUIRE(l0_o.iface() != nullptr);
REQUIRE(l0_o.data() != nullptr);
REQUIRE(gc.contains(role::to_space(), l0_o.data()));
REQUIRE(gc.contains(Role::to_space(), l0_o.data()));
/* check alloc info for newly-allocated object */
AllocInfo info = gc.alloc_info((std::byte *)l0_o.data());
@ -271,16 +271,16 @@ namespace ut {
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(!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(), n1_o.data()));
REQUIRE(gc.contains(role::to_space(), n1_o.data()));
REQUIRE(!gc.contains(Role::from_space(), n1_o.data()));
REQUIRE(gc.contains(Role::to_space(), n1_o.data()));
REQUIRE(n1_o.data()->value() == 42);
REQUIRE(!gc.contains(role::from_space(), l0_o.data()));
REQUIRE(gc.contains(role::to_space(), l0_o.data()));
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());