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
|
|
@ -4,11 +4,9 @@
|
||||||
output_hpp_dir: "include/xo/alloc2",
|
output_hpp_dir: "include/xo/alloc2",
|
||||||
output_impl_subdir: "gc",
|
output_impl_subdir: "gc",
|
||||||
includes: [
|
includes: [
|
||||||
|
"<xo/alloc2/Generation.hpp>",
|
||||||
|
"<xo/alloc2/role.hpp>",
|
||||||
"<xo/arena/AllocInfo.hpp>",
|
"<xo/arena/AllocInfo.hpp>",
|
||||||
// "<xo/alloc2/Allocator.hpp>",
|
|
||||||
// "<xo/alloc2/Collector.hpp>",
|
|
||||||
// "<cstdint>",
|
|
||||||
// "<cstddef>",
|
|
||||||
],
|
],
|
||||||
// extra includes in GCObject.hpp, if any
|
// extra includes in GCObject.hpp, if any
|
||||||
user_hpp_includes: [
|
user_hpp_includes: [
|
||||||
|
|
@ -38,7 +36,7 @@
|
||||||
// },
|
// },
|
||||||
],
|
],
|
||||||
const_methods: [
|
const_methods: [
|
||||||
// AllocInfo alloc_info(void * gco);
|
// AllocInfo alloc_info(void * gco) const noexcept;
|
||||||
{
|
{
|
||||||
name: "alloc_info",
|
name: "alloc_info",
|
||||||
doc: [
|
doc: [
|
||||||
|
|
@ -53,7 +51,22 @@
|
||||||
noexcept: false,
|
noexcept: false,
|
||||||
attributes: [],
|
attributes: [],
|
||||||
},
|
},
|
||||||
// Generation generation_of(...);
|
// Generation generation_of(role r, const void * addr) const noexcept;
|
||||||
|
{
|
||||||
|
name: "generation_of",
|
||||||
|
doc: [
|
||||||
|
"generation to which pointer @p addr belongs, given role @p r;",
|
||||||
|
"sentinel if @p addr is not owned by collector",
|
||||||
|
],
|
||||||
|
return_type: "Generation",
|
||||||
|
args: [
|
||||||
|
{type: "role", name: "r"},
|
||||||
|
{type: "const void *", name: "addr"},
|
||||||
|
],
|
||||||
|
const: true,
|
||||||
|
noexcept: true,
|
||||||
|
attributes: [],
|
||||||
|
},
|
||||||
],
|
],
|
||||||
nonconst_methods: [
|
nonconst_methods: [
|
||||||
// void alloc_copy(void * src)
|
// void alloc_copy(void * src)
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,8 @@ namespace xo {
|
||||||
/** @class generation
|
/** @class generation
|
||||||
* @brief type-safe generation number
|
* @brief type-safe generation number
|
||||||
**/
|
**/
|
||||||
struct Generation {
|
class Generation {
|
||||||
|
public:
|
||||||
using value_type = std::uint32_t;
|
using value_type = std::uint32_t;
|
||||||
|
|
||||||
constexpr Generation() = default;
|
constexpr Generation() = default;
|
||||||
|
|
|
||||||
|
|
@ -14,6 +14,8 @@
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
// includes (via {facet_includes})
|
// includes (via {facet_includes})
|
||||||
|
#include <xo/alloc2/Generation.hpp>
|
||||||
|
#include <xo/alloc2/role.hpp>
|
||||||
#include <xo/arena/AllocInfo.hpp>
|
#include <xo/arena/AllocInfo.hpp>
|
||||||
#include <xo/facet/obj.hpp>
|
#include <xo/facet/obj.hpp>
|
||||||
#include <xo/facet/facet_implementation.hpp>
|
#include <xo/facet/facet_implementation.hpp>
|
||||||
|
|
@ -22,6 +24,7 @@
|
||||||
// see GCObject.hpp, also in xo-alloc2/
|
// see GCObject.hpp, also in xo-alloc2/
|
||||||
namespace xo { namespace mm { class AGCObject; }}
|
namespace xo { namespace mm { class AGCObject; }}
|
||||||
namespace xo { namespace mm { class AllocInfo; }}
|
namespace xo { namespace mm { class AllocInfo; }}
|
||||||
|
namespace xo { namespace mm { class Generation; }}
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
namespace mm {
|
namespace mm {
|
||||||
|
|
@ -58,6 +61,9 @@ public:
|
||||||
/** allocation metadata for gc-aware data at address @p gco.
|
/** allocation metadata for gc-aware data at address @p gco.
|
||||||
@p gco must be the result of a call to collector's alloc() function **/
|
@p gco must be the result of a call to collector's alloc() function **/
|
||||||
virtual AllocInfo alloc_info(Copaque data, void * addr) const = 0;
|
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
|
// nonconst methods
|
||||||
/** allocate copy of source object at address @p src.
|
/** allocate copy of source object at address @p src.
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,7 @@ namespace mm {
|
||||||
|
|
||||||
// const methods
|
// const methods
|
||||||
[[noreturn]] AllocInfo alloc_info(Copaque, void *) const override { _fatal(); }
|
[[noreturn]] AllocInfo alloc_info(Copaque, void *) const override { _fatal(); }
|
||||||
|
[[noreturn]] Generation generation_of(Copaque, role, const void *) const noexcept override { _fatal(); }
|
||||||
|
|
||||||
// nonconst methods
|
// nonconst methods
|
||||||
[[noreturn]] void * alloc_copy(Opaque, std::byte *) const override;
|
[[noreturn]] void * alloc_copy(Opaque, std::byte *) const override;
|
||||||
|
|
|
||||||
|
|
@ -13,6 +13,8 @@
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
|
#include <xo/alloc2/Generation.hpp>
|
||||||
|
#include <xo/alloc2/role.hpp>
|
||||||
#include <xo/arena/AllocInfo.hpp>
|
#include <xo/arena/AllocInfo.hpp>
|
||||||
|
|
||||||
namespace xo {
|
namespace xo {
|
||||||
|
|
@ -46,6 +48,9 @@ namespace mm {
|
||||||
AllocInfo alloc_info(Copaque data, void * addr) const override {
|
AllocInfo alloc_info(Copaque data, void * addr) const override {
|
||||||
return I::alloc_info(_dcast(data), addr);
|
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
|
// non-const methods
|
||||||
void * alloc_copy(Opaque data, std::byte * src) const override {
|
void * alloc_copy(Opaque data, std::byte * src) const override {
|
||||||
|
|
|
||||||
|
|
@ -91,6 +91,9 @@ public:
|
||||||
AllocInfo alloc_info(void * addr) const {
|
AllocInfo alloc_info(void * addr) const {
|
||||||
return O::iface()->alloc_info(O::data(), addr);
|
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!)
|
// non-const methods (still const in router!)
|
||||||
void * alloc_copy(std::byte * src) {
|
void * alloc_copy(std::byte * src) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue