xo-gc: move header query aux method impls to GCObjectStore
This commit is contained in:
parent
9efb214bfd
commit
63e2fd6f3c
4 changed files with 57 additions and 17 deletions
|
|
@ -143,9 +143,9 @@ namespace xo {
|
|||
using GCMoveCheckpoint = std::array<std::byte *, c_max_generation>;
|
||||
using MutationLog = DArenaVector<MutationLogEntry>;
|
||||
using typeseq = xo::facet::typeseq;
|
||||
using size_type = DArena::size_type;
|
||||
using value_type = DArena::value_type;
|
||||
using header_type = DArena::header_type;
|
||||
using size_type = GCObjectStore::size_type;
|
||||
using value_type = GCObjectStore::value_type;
|
||||
using header_type = GCObjectStore::header_type;
|
||||
|
||||
/** hard max typeseq for collector-registered types **/
|
||||
static constexpr size_t c_max_typeseq = 4096;
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@
|
|||
#pragma once
|
||||
|
||||
#include "generation.hpp"
|
||||
#include "object_age.hpp"
|
||||
#include <xo/alloc2/role.hpp>
|
||||
#include <xo/arena/DArena.hpp>
|
||||
#include <xo/arena/ArenaConfig.hpp>
|
||||
|
|
@ -17,6 +18,11 @@ namespace xo {
|
|||
/** @brief container to hold gc-aware objects for X1 collector
|
||||
**/
|
||||
class GCObjectStore {
|
||||
public:
|
||||
using header_type = DArena::header_type;
|
||||
using value_type = DArena::value_type;
|
||||
using size_type = DArena::size_type;
|
||||
|
||||
public:
|
||||
GCObjectStore(const ArenaConfig & arena_cfg, uint32_t ngen, bool debug_flag);
|
||||
|
||||
|
|
@ -31,6 +37,16 @@ namespace xo {
|
|||
**/
|
||||
Generation generation_of(role r, const void * addr) const noexcept;
|
||||
|
||||
/** get allocation size from header **/
|
||||
std::size_t header2size(header_type hdr) const noexcept;
|
||||
/** get generation counter from alloc header **/
|
||||
object_age header2age(header_type hdr) const noexcept;
|
||||
/** get tseq from alloc header **/
|
||||
uint32_t header2tseq(header_type hdr) const noexcept;
|
||||
|
||||
/** true iff original alloc has been replaced by a forwarding pointer **/
|
||||
bool is_forwarding_header(header_type hdr) const noexcept;
|
||||
|
||||
/** Call @p visitor for each memory pool owned by this store **/
|
||||
void visit_pools(const MemorySizeVisitor & visitor) const;
|
||||
|
||||
|
|
|
|||
|
|
@ -534,34 +534,25 @@ namespace xo {
|
|||
size_type
|
||||
DX1Collector::header2size(header_type hdr) const noexcept
|
||||
{
|
||||
uint32_t z = config_.arena_config_.header_.size(hdr);
|
||||
|
||||
return z;
|
||||
return gco_store_.header2size(hdr);
|
||||
}
|
||||
|
||||
object_age
|
||||
DX1Collector::header2age(header_type hdr) const noexcept
|
||||
{
|
||||
uint32_t age = config_.arena_config_.header_.age(hdr);
|
||||
|
||||
assert(age < c_max_object_age);
|
||||
|
||||
return object_age(age);
|
||||
return gco_store_.header2age(hdr);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
DX1Collector::header2tseq(header_type hdr) const noexcept
|
||||
{
|
||||
uint32_t tseq = config_.arena_config_.header_.tseq(hdr);
|
||||
|
||||
return tseq;
|
||||
return gco_store_.header2tseq(hdr);
|
||||
}
|
||||
|
||||
bool
|
||||
DX1Collector::is_forwarding_header(header_type hdr) const noexcept
|
||||
{
|
||||
/** forwarding pointer encoded as sentinel tseq **/
|
||||
return config_.arena_config_.header_.is_forwarding_tseq(hdr);
|
||||
return gco_store_.is_forwarding_header(hdr);
|
||||
}
|
||||
|
||||
bool
|
||||
|
|
@ -1527,7 +1518,7 @@ namespace xo {
|
|||
|
||||
assert(src_hdr && dest_hdr);
|
||||
|
||||
if (header2age(*src_hdr) <= header2age(*dest_hdr)) {
|
||||
if (this->header2age(*src_hdr) <= this->header2age(*dest_hdr)) {
|
||||
// source and destination have the same age;
|
||||
// therefore are always collected on the same set of GC cycles
|
||||
// -> no need to remember separately.
|
||||
|
|
|
|||
|
|
@ -75,6 +75,39 @@ namespace xo {
|
|||
return Generation::sentinel();
|
||||
}
|
||||
|
||||
auto
|
||||
GCObjectStore::header2size(header_type hdr) const noexcept -> size_type
|
||||
{
|
||||
uint32_t z = arena_config_.header_.size(hdr);
|
||||
|
||||
return z;
|
||||
}
|
||||
|
||||
object_age
|
||||
GCObjectStore::header2age(header_type hdr) const noexcept
|
||||
{
|
||||
uint32_t age = arena_config_.header_.age(hdr);
|
||||
|
||||
assert(age < c_max_object_age);
|
||||
|
||||
return object_age(age);
|
||||
}
|
||||
|
||||
uint32_t
|
||||
GCObjectStore::header2tseq(header_type hdr) const noexcept
|
||||
{
|
||||
uint32_t tseq = arena_config_.header_.tseq(hdr);
|
||||
|
||||
return tseq;
|
||||
}
|
||||
|
||||
bool
|
||||
GCObjectStore::is_forwarding_header(header_type hdr) const noexcept
|
||||
{
|
||||
/** forwarding pointer encoded as sentinel tseq **/
|
||||
return arena_config_.header_.is_forwarding_tseq(hdr);
|
||||
}
|
||||
|
||||
void
|
||||
GCObjectStore::visit_pools(const MemorySizeVisitor & visitor) const
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue