xo-alloc2: work on alloc iteration.
This commit is contained in:
parent
85204e9847
commit
d8ed0d6235
17 changed files with 216 additions and 29 deletions
|
|
@ -10,6 +10,7 @@
|
|||
#include "gc/generation.hpp"
|
||||
#include "gc/object_age.hpp"
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <xo/indentlog/scope.hpp>
|
||||
#include <cassert>
|
||||
#include <cstdint>
|
||||
|
||||
|
|
@ -207,10 +208,10 @@ namespace xo {
|
|||
}
|
||||
|
||||
AllocInfo
|
||||
DX1Collector::alloc_info(value_type mem) noexcept {
|
||||
DX1Collector::alloc_info(value_type mem) const noexcept {
|
||||
for (role ri : role::all()) {
|
||||
for (generation gj{0}; gj < config_.n_generation_; ++gj) {
|
||||
DArena * arena = this->get_space(ri, gj);
|
||||
const DArena * arena = this->get_space(ri, gj);
|
||||
|
||||
assert(arena);
|
||||
|
||||
|
|
@ -221,21 +222,29 @@ namespace xo {
|
|||
}
|
||||
|
||||
// deliberately attempt on nursery to-space, to capture error info + return sentinel
|
||||
return this->new_space()->alloc_info(mem);
|
||||
return this->get_space(role::to_space(), generation{0})->alloc_info(mem);
|
||||
}
|
||||
|
||||
DX1CollectorIterator
|
||||
DX1Collector::begin() const noexcept
|
||||
{
|
||||
scope log(XO_DEBUG(false));
|
||||
|
||||
const DArena * arena
|
||||
= get_space(role::to_space(),
|
||||
generation{0});
|
||||
|
||||
return DX1CollectorIterator(this,
|
||||
generation{0},
|
||||
generation{config_.n_generation_},
|
||||
DArenaIterator(),
|
||||
DArenaIterator());
|
||||
arena->begin(),
|
||||
arena->end());
|
||||
}
|
||||
|
||||
DX1CollectorIterator
|
||||
DX1Collector::end() const noexcept {
|
||||
scope log(XO_DEBUG(false));
|
||||
|
||||
generation gen_hi = generation{config_.n_generation_};
|
||||
|
||||
/** valid iterator for end points to end of last DArena.
|
||||
|
|
|
|||
|
|
@ -26,19 +26,39 @@ namespace xo {
|
|||
void
|
||||
DX1CollectorIterator::normalize() noexcept
|
||||
{
|
||||
scope log(XO_DEBUG(false),
|
||||
xtag("gen_ix", gen_ix_),
|
||||
xtag("gen_hi", gen_hi_),
|
||||
xtag("arena_ix.pos", arena_ix_.pos_),
|
||||
xtag("arena_hi.pos", arena_hi_.pos_));
|
||||
|
||||
/* normalize: find lowest generation with non-empty to-space */
|
||||
if (arena_ix_.pos_ == arena_hi_.pos_) {
|
||||
log && log(xtag("action", "look-lub-nonempty-gen"));
|
||||
|
||||
for (; gen_ix_ < gen_hi_; ++gen_ix_) {
|
||||
const DArena * arena
|
||||
= gc_->get_space(role::to_space(), gen_ix_);
|
||||
if (gen_ix_ < gen_hi_)
|
||||
++gen_ix_;
|
||||
|
||||
arena_ix_ = arena->begin();
|
||||
arena_hi_ = arena->end();
|
||||
for (; gen_ix_ < gen_hi_; ++gen_ix_) {
|
||||
const DArena * arena
|
||||
= gc_->get_space(role::to_space(), gen_ix_);
|
||||
|
||||
if (arena_ix_ != arena_hi_) {
|
||||
// normalization achieved!
|
||||
break;
|
||||
assert(arena);
|
||||
|
||||
arena_ix_ = arena->begin();
|
||||
arena_hi_ = arena->end();
|
||||
|
||||
if (arena_ix_ != arena_hi_) {
|
||||
// normalization achieved!
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
log && log(xtag("gen_ix", gen_ix_),
|
||||
xtag("arena_ix.pos", arena_ix_.pos_),
|
||||
xtag("arena_hi.pos", arena_hi_.pos_));
|
||||
} else {
|
||||
log && log(xtag("action", "noop"));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -81,9 +101,23 @@ namespace xo {
|
|||
void
|
||||
DX1CollectorIterator::next() noexcept
|
||||
{
|
||||
scope log(XO_DEBUG(false),
|
||||
xtag("arena_ix.arena", arena_ix_.arena_),
|
||||
xtag("arena_ix.pos", arena_ix_.pos_),
|
||||
xtag("arena_hi.arena", arena_hi_.arena_),
|
||||
xtag("arena_hi.pos", arena_hi_.pos_));
|
||||
|
||||
if (arena_ix_ != arena_hi_) {
|
||||
++arena_ix_;
|
||||
|
||||
log && log(xtag("++arena_ix.pos", arena_ix_.pos_));
|
||||
|
||||
this->normalize();
|
||||
|
||||
log && log(xtag("arena_ix.arena", arena_ix_.arena_),
|
||||
xtag("arena_ix.pos", arena_ix_.pos_));
|
||||
} else {
|
||||
log && log(xtag("action", "arena-at-end"));
|
||||
}
|
||||
}
|
||||
} /*namespace mm*/
|
||||
|
|
|
|||
|
|
@ -27,6 +27,14 @@ namespace xo {
|
|||
std::terminate();
|
||||
}
|
||||
|
||||
#ifdef NOPE
|
||||
vt<AAllocIterator>
|
||||
IAllocator_Any::begin(Copaque, DArena &) const noexcept
|
||||
{
|
||||
_fatal();
|
||||
}
|
||||
#endif
|
||||
|
||||
int32_t
|
||||
IAllocator_Any::s_typeseq = typeseq::id<DVariantPlaceholder>();
|
||||
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ namespace xo {
|
|||
}
|
||||
|
||||
AllocInfo
|
||||
IAllocator_DArena::alloc_info(DArena & s, value_type mem) noexcept
|
||||
IAllocator_DArena::alloc_info(const DArena & s, value_type mem) noexcept
|
||||
{
|
||||
return s.alloc_info(mem);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -86,7 +86,7 @@ namespace xo {
|
|||
}
|
||||
|
||||
AllocInfo
|
||||
IAllocator_DX1Collector::alloc_info(DX1Collector & d, value_type mem) noexcept
|
||||
IAllocator_DX1Collector::alloc_info(const DX1Collector & d, value_type mem) noexcept
|
||||
{
|
||||
return d.alloc_info(mem);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue