refactor: xo-gc: + GCObjectVisitor.generation_of()
Concession to narrow MutationLogStore to only use GCObjectVisitor instead of assuming X1Collector.
This commit is contained in:
parent
60dfeaaaaf
commit
b794f225b2
6 changed files with 36 additions and 7 deletions
|
|
@ -16,7 +16,8 @@ namespace xo {
|
|||
/** @class generation
|
||||
* @brief type-safe generation number
|
||||
**/
|
||||
struct Generation {
|
||||
class Generation {
|
||||
public:
|
||||
using value_type = std::uint32_t;
|
||||
|
||||
constexpr Generation() = default;
|
||||
|
|
|
|||
|
|
@ -14,6 +14,8 @@
|
|||
#pragma once
|
||||
|
||||
// includes (via {facet_includes})
|
||||
#include <xo/alloc2/Generation.hpp>
|
||||
#include <xo/alloc2/role.hpp>
|
||||
#include <xo/arena/AllocInfo.hpp>
|
||||
#include <xo/facet/obj.hpp>
|
||||
#include <xo/facet/facet_implementation.hpp>
|
||||
|
|
@ -22,6 +24,7 @@
|
|||
// see GCObject.hpp, also in xo-alloc2/
|
||||
namespace xo { namespace mm { class AGCObject; }}
|
||||
namespace xo { namespace mm { class AllocInfo; }}
|
||||
namespace xo { namespace mm { class Generation; }}
|
||||
|
||||
namespace xo {
|
||||
namespace mm {
|
||||
|
|
@ -58,6 +61,9 @@ public:
|
|||
/** allocation metadata for gc-aware data at address @p gco.
|
||||
@p gco must be the result of a call to collector's alloc() function **/
|
||||
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;
|
||||
|
||||
// nonconst methods
|
||||
/** allocate copy of source object at address @p src.
|
||||
|
|
|
|||
|
|
@ -59,6 +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(); }
|
||||
|
||||
// nonconst methods
|
||||
[[noreturn]] void * alloc_copy(Opaque, std::byte *) const override;
|
||||
|
|
|
|||
|
|
@ -13,6 +13,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include <xo/alloc2/Generation.hpp>
|
||||
#include <xo/alloc2/role.hpp>
|
||||
#include <xo/arena/AllocInfo.hpp>
|
||||
|
||||
namespace xo {
|
||||
|
|
@ -46,6 +48,9 @@ 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 {
|
||||
return I::generation_of(_dcast(data), r, addr);
|
||||
}
|
||||
|
||||
// non-const methods
|
||||
void * alloc_copy(Opaque data, std::byte * src) const override {
|
||||
|
|
|
|||
|
|
@ -91,6 +91,9 @@ 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 {
|
||||
return O::iface()->generation_of(O::data(), r, addr);
|
||||
}
|
||||
|
||||
// non-const methods (still const in router!)
|
||||
void * alloc_copy(std::byte * src) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue