xo-alloc2: + Allocator::alloc_info()
Also extend unit test
This commit is contained in:
parent
e369bc93f4
commit
ef8ec32a2d
15 changed files with 156 additions and 40 deletions
|
|
@ -247,6 +247,34 @@ namespace xo {
|
|||
return (header_type *)((byte *)obj - sizeof(header_type));
|
||||
}
|
||||
|
||||
AllocInfo
|
||||
DArena::alloc_info(value_type mem) noexcept
|
||||
{
|
||||
if (!config_.store_header_flag_) [[unlikely]] {
|
||||
++(error_count_);
|
||||
last_error_ = AllocatorError(error::alloc_info_disabled,
|
||||
error_count_,
|
||||
0 /*add_commit_z*/,
|
||||
committed_z_,
|
||||
this->reserved());
|
||||
|
||||
return AllocInfo::error_not_configured(&config_.header_);
|
||||
}
|
||||
|
||||
byte * header_mem = mem - sizeof(AllocHeader);
|
||||
|
||||
if (!this->contains(header_mem)) {
|
||||
++(error_count_);
|
||||
last_error_ = AllocatorError(error::alloc_info_address,
|
||||
error_count_,
|
||||
0 /*add_commit_z*/,
|
||||
committed_z_,
|
||||
this->reserved());
|
||||
}
|
||||
|
||||
return AllocInfo(&config_.header_, (AllocHeader *)header_mem);
|
||||
}
|
||||
|
||||
void
|
||||
DArena::clear() noexcept
|
||||
{
|
||||
|
|
|
|||
|
|
@ -239,6 +239,24 @@ namespace xo {
|
|||
return false;
|
||||
}
|
||||
|
||||
AllocInfo
|
||||
DX1Collector::alloc_info(value_type mem) noexcept {
|
||||
for (role ri : role::all()) {
|
||||
for (generation gj{0}; gj < config_.n_generation_; ++gj) {
|
||||
DArena * arena = this->get_space(ri, gj);
|
||||
|
||||
assert(arena);
|
||||
|
||||
if (arena->contains(mem)) {
|
||||
return arena->alloc_info(mem);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// deliberately attempt on nursery to-space, to capture error info + return sentinel
|
||||
return this->new_space()->alloc_info(mem);
|
||||
}
|
||||
|
||||
void
|
||||
DX1Collector::reverse_roles(generation g) noexcept {
|
||||
assert(g < config_.n_generation_);
|
||||
|
|
|
|||
|
|
@ -59,6 +59,36 @@ namespace xo {
|
|||
return s.last_error_;
|
||||
}
|
||||
|
||||
AllocInfo
|
||||
IAllocator_DArena::alloc_info(DArena & s, value_type mem) noexcept
|
||||
{
|
||||
return s.alloc_info(mem);
|
||||
|
||||
if (!s.config_.store_header_flag_) [[unlikely]] {
|
||||
++(s.error_count_);
|
||||
s.last_error_ = AllocatorError(error::alloc_info_disabled,
|
||||
s.error_count_,
|
||||
0 /*add_commit_z*/,
|
||||
s.committed_z_,
|
||||
reserved(s));
|
||||
|
||||
return AllocInfo::error_not_configured(&s.config_.header_);
|
||||
}
|
||||
|
||||
byte * header_mem = mem - sizeof(AllocHeader);
|
||||
|
||||
if (!s.contains(header_mem)) {
|
||||
++(s.error_count_);
|
||||
s.last_error_ = AllocatorError(error::alloc_info_address,
|
||||
s.error_count_,
|
||||
0 /*add_commit_z*/,
|
||||
s.committed_z_,
|
||||
reserved(s));
|
||||
}
|
||||
|
||||
return AllocInfo(&s.config_.header_, (AllocHeader*)header_mem);
|
||||
}
|
||||
|
||||
bool
|
||||
IAllocator_DArena::expand(DArena & s, size_t target_z) noexcept
|
||||
{
|
||||
|
|
|
|||
|
|
@ -85,6 +85,12 @@ namespace xo {
|
|||
return d.expand(z);
|
||||
}
|
||||
|
||||
AllocInfo
|
||||
IAllocator_DX1Collector::alloc_info(DX1Collector & d, value_type mem) noexcept
|
||||
{
|
||||
return d.alloc_info(mem);
|
||||
}
|
||||
|
||||
void
|
||||
IAllocator_DX1Collector::clear(DX1Collector & d)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue