xo-alloc2: refactor - explicit AllocHeader class
This commit is contained in:
parent
a757904dcc
commit
e369bc93f4
10 changed files with 251 additions and 37 deletions
|
|
@ -8,6 +8,7 @@
|
|||
#include "arena/ArenaConfig.hpp"
|
||||
#include "arena/DArena.hpp"
|
||||
#include "gc/generation.hpp"
|
||||
#include "gc/object_age.hpp"
|
||||
#include "gc/role.hpp"
|
||||
#include <memory>
|
||||
#include <array>
|
||||
|
|
@ -40,6 +41,7 @@ namespace xo {
|
|||
struct CollectorConfig {
|
||||
using size_type = std::size_t;
|
||||
|
||||
#ifdef OBSOLETE // get from arena_config_.header_
|
||||
/*
|
||||
* alloc header
|
||||
* TTTTTTTTTTTTGGGGGZZZZZZZZZZZZ
|
||||
|
|
@ -63,6 +65,11 @@ namespace xo {
|
|||
constexpr std::uint64_t tseq_shift() const;
|
||||
constexpr std::uint64_t tseq_mask_unshifted() const;
|
||||
constexpr std::uint64_t tseq_mask_shifted() const;
|
||||
#endif
|
||||
|
||||
generation age2gen(object_age age) const noexcept {
|
||||
return generation(age % n_survive_threshold_);
|
||||
}
|
||||
|
||||
public:
|
||||
// ----- Instance Variables -----
|
||||
|
|
@ -175,7 +182,7 @@ namespace xo {
|
|||
/** get allocation size from header **/
|
||||
std::size_t header2size(header_type hdr) const noexcept;
|
||||
/** get generation counter from alloc header **/
|
||||
generation header2gen(header_type hdr) const noexcept;
|
||||
object_age header2age(header_type hdr) const noexcept;
|
||||
/** get tseq from alloc header **/
|
||||
uint32_t header2tseq(header_type hdr) const noexcept;
|
||||
|
||||
|
|
|
|||
32
xo-alloc2/include/xo/alloc2/gc/object_age.hpp
Normal file
32
xo-alloc2/include/xo/alloc2/gc/object_age.hpp
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/** @file object_age.hpp
|
||||
*
|
||||
* @author Roland Conybeare, Dec 2025
|
||||
**/
|
||||
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
|
||||
namespace xo {
|
||||
namespace mm {
|
||||
/** hard maximum remembered object age **/
|
||||
static constexpr uint32_t c_max_object_age = 127;
|
||||
|
||||
/** @class object_age
|
||||
* @brief type-safe object age
|
||||
*
|
||||
* Object age measured in number of garbage collections survived.
|
||||
**/
|
||||
struct object_age {
|
||||
using value_type = std::uint32_t;
|
||||
|
||||
explicit object_age(value_type x) : value_{x} {}
|
||||
|
||||
operator value_type() const { return value_; }
|
||||
|
||||
std::uint32_t value_;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/* end object_age.hpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue