diff --git a/idl/Collector.json5 b/idl/Collector.json5 index 9c4666e..99904f8 100644 --- a/idl/Collector.json5 +++ b/idl/Collector.json5 @@ -37,40 +37,40 @@ }, ], const_methods: [ - // size_type allocated(Generation g, role r) const noexcept + // size_type allocated(Generation g, Role r) const noexcept { name: "allocated", doc: ["memory in use for this collector"], return_type: "size_type", args: [ {type: "Generation", name: "g"}, - {type: "role", name: "r"}, + {type: "Role", name: "r"}, ], const: true, noexcept: true, attributes: [], }, - // size_type committed(Generation g, role r) const noexcept + // size_type committed(Generation g, Role r) const noexcept { name: "committed", doc: ["memory committed for this collector"], return_type: "size_type", args: [ {type: "Generation", name: "g"}, - {type: "role", name: "r"}, + {type: "Role", name: "r"}, ], const: true, noexcept: true, attributes: [], }, - // size_type reserved(Generation g, role r) const noexcept + // size_type reserved(Generation g, Role r) const noexcept { name: "reserved", doc: ["address space reserved for this collector"], return_type: "size_type", args: [ {type: "Generation", name: "g"}, - {type: "role", name: "r"}, + {type: "Role", name: "r"}, ], const: true, noexcept: true, @@ -92,13 +92,13 @@ noexcept: true, attributes: [], }, - // bool contains(role r, const void * addr) const noexcept + // bool contains(Role r, const void * addr) const noexcept { name: "contains", - doc: ["true if gc responsible for data at @p addr, and data belongs to role @p r"], + doc: ["true if gc responsible for data at @p addr, and data belongs to Role @p r"], return_type: "bool", args: [ - {type: "role", name: "r"}, + {type: "Role", name: "r"}, {type: "const void *", name: "addr"}, ], const: true, diff --git a/idl/GCObjectVisitor.json5 b/idl/GCObjectVisitor.json5 index 201623b..854287e 100644 --- a/idl/GCObjectVisitor.json5 +++ b/idl/GCObjectVisitor.json5 @@ -51,7 +51,7 @@ noexcept: false, attributes: [], }, - // Generation generation_of(role r, const void * addr) const noexcept; + // Generation generation_of(Role r, const void * addr) const noexcept; { name: "generation_of", doc: [ @@ -60,7 +60,7 @@ ], return_type: "Generation", args: [ - {type: "role", name: "r"}, + {type: "Role", name: "r"}, {type: "const void *", name: "addr"}, ], const: true, diff --git a/include/xo/alloc2/gc/ACollector.hpp b/include/xo/alloc2/gc/ACollector.hpp index c4af249..8d23384 100644 --- a/include/xo/alloc2/gc/ACollector.hpp +++ b/include/xo/alloc2/gc/ACollector.hpp @@ -60,17 +60,17 @@ public: /** destroy instance @p d; calls c++ dtor only for actual runtime type; does not recover memory **/ virtual void _drop(Opaque d) const noexcept = 0; /** memory in use for this collector **/ - virtual size_type allocated(Copaque data, Generation g, role r) const noexcept = 0; + virtual size_type allocated(Copaque data, Generation g, Role r) const noexcept = 0; /** memory committed for this collector **/ - virtual size_type committed(Copaque data, Generation g, role r) const noexcept = 0; + virtual size_type committed(Copaque data, Generation g, Role r) const noexcept = 0; /** address space reserved for this collector **/ - virtual size_type reserved(Copaque data, Generation g, role r) const noexcept = 0; + virtual size_type reserved(Copaque data, Generation g, Role r) const noexcept = 0; /** Location of object in collector. -1 if not in collector memory. Other negative values represent collector error states (good luck!). Exact meaning of non-negative values up to collector implementation **/ virtual std::int32_t locate_address(Copaque data, const void * addr) const noexcept = 0; - /** true if gc responsible for data at @p addr, and data belongs to role @p r **/ - virtual bool contains(Copaque data, role r, const void * addr) const noexcept = 0; + /** true if gc responsible for data at @p addr, and data belongs to Role @p r **/ + virtual bool contains(Copaque data, Role r, const void * addr) const noexcept = 0; /** true iff gc-aware object of type @p tseq is installed in this collector **/ virtual bool is_type_installed(Copaque data, typeseq tseq) const noexcept = 0; /** Report gc statistics, at discretion of collector implementation. diff --git a/include/xo/alloc2/gc/AGCObjectVisitor.hpp b/include/xo/alloc2/gc/AGCObjectVisitor.hpp index df5d1f4..a9d0093 100644 --- a/include/xo/alloc2/gc/AGCObjectVisitor.hpp +++ b/include/xo/alloc2/gc/AGCObjectVisitor.hpp @@ -63,7 +63,7 @@ public: 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; + 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. diff --git a/include/xo/alloc2/gc/ICollector_Any.hpp b/include/xo/alloc2/gc/ICollector_Any.hpp index 831aad4..0a14751 100644 --- a/include/xo/alloc2/gc/ICollector_Any.hpp +++ b/include/xo/alloc2/gc/ICollector_Any.hpp @@ -59,11 +59,11 @@ namespace mm { [[noreturn]] void _drop(Opaque) const noexcept override { _fatal(); } // const methods - [[noreturn]] size_type allocated(Copaque, Generation, role) const noexcept override { _fatal(); } - [[noreturn]] size_type committed(Copaque, Generation, role) const noexcept override { _fatal(); } - [[noreturn]] size_type reserved(Copaque, Generation, role) const noexcept override { _fatal(); } + [[noreturn]] size_type allocated(Copaque, Generation, Role) const noexcept override { _fatal(); } + [[noreturn]] size_type committed(Copaque, Generation, Role) const noexcept override { _fatal(); } + [[noreturn]] size_type reserved(Copaque, Generation, Role) const noexcept override { _fatal(); } [[noreturn]] std::int32_t locate_address(Copaque, const void *) const noexcept override { _fatal(); } - [[noreturn]] bool contains(Copaque, role, const void *) const noexcept override { _fatal(); } + [[noreturn]] bool contains(Copaque, Role, const void *) const noexcept override { _fatal(); } [[noreturn]] bool is_type_installed(Copaque, typeseq) const noexcept override { _fatal(); } [[noreturn]] bool report_statistics(Copaque, obj, obj, obj *) const noexcept override { _fatal(); } [[noreturn]] bool report_object_types(Copaque, obj, obj, obj *) const noexcept override { _fatal(); } diff --git a/include/xo/alloc2/gc/ICollector_Xfer.hpp b/include/xo/alloc2/gc/ICollector_Xfer.hpp index 8475c4b..1a36823 100644 --- a/include/xo/alloc2/gc/ICollector_Xfer.hpp +++ b/include/xo/alloc2/gc/ICollector_Xfer.hpp @@ -46,19 +46,19 @@ namespace mm { void _drop(Opaque d) const noexcept override { _dcast(d).~DRepr(); } // const methods - size_type allocated(Copaque data, Generation g, role r) const noexcept override { + size_type allocated(Copaque data, Generation g, Role r) const noexcept override { return I::allocated(_dcast(data), g, r); } - size_type committed(Copaque data, Generation g, role r) const noexcept override { + size_type committed(Copaque data, Generation g, Role r) const noexcept override { return I::committed(_dcast(data), g, r); } - size_type reserved(Copaque data, Generation g, role r) const noexcept override { + size_type reserved(Copaque data, Generation g, Role r) const noexcept override { return I::reserved(_dcast(data), g, r); } std::int32_t locate_address(Copaque data, const void * addr) const noexcept override { return I::locate_address(_dcast(data), addr); } - bool contains(Copaque data, role r, const void * addr) const noexcept override { + bool contains(Copaque data, Role r, const void * addr) const noexcept override { return I::contains(_dcast(data), r, addr); } bool is_type_installed(Copaque data, typeseq tseq) const noexcept override { diff --git a/include/xo/alloc2/gc/IGCObjectVisitor_Any.hpp b/include/xo/alloc2/gc/IGCObjectVisitor_Any.hpp index 7cb7f6d..53515e2 100644 --- a/include/xo/alloc2/gc/IGCObjectVisitor_Any.hpp +++ b/include/xo/alloc2/gc/IGCObjectVisitor_Any.hpp @@ -59,7 +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(); } + [[noreturn]] Generation generation_of(Copaque, Role, const void *) const noexcept override { _fatal(); } // nonconst methods [[noreturn]] void * alloc_copy(Opaque, std::byte *) const override; diff --git a/include/xo/alloc2/gc/IGCObjectVisitor_Xfer.hpp b/include/xo/alloc2/gc/IGCObjectVisitor_Xfer.hpp index c457c55..00ad359 100644 --- a/include/xo/alloc2/gc/IGCObjectVisitor_Xfer.hpp +++ b/include/xo/alloc2/gc/IGCObjectVisitor_Xfer.hpp @@ -48,7 +48,7 @@ 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 { + Generation generation_of(Copaque data, Role r, const void * addr) const noexcept override { return I::generation_of(_dcast(data), r, addr); } diff --git a/include/xo/alloc2/gc/RCollector.hpp b/include/xo/alloc2/gc/RCollector.hpp index efcbfc5..ac66a26 100644 --- a/include/xo/alloc2/gc/RCollector.hpp +++ b/include/xo/alloc2/gc/RCollector.hpp @@ -95,19 +95,19 @@ public: void _drop() const noexcept { O::iface()->_drop(O::data()); } // const methods - size_type allocated(Generation g, role r) const noexcept { + size_type allocated(Generation g, Role r) const noexcept { return O::iface()->allocated(O::data(), g, r); } - size_type committed(Generation g, role r) const noexcept { + size_type committed(Generation g, Role r) const noexcept { return O::iface()->committed(O::data(), g, r); } - size_type reserved(Generation g, role r) const noexcept { + size_type reserved(Generation g, Role r) const noexcept { return O::iface()->reserved(O::data(), g, r); } std::int32_t locate_address(const void * addr) const noexcept { return O::iface()->locate_address(O::data(), addr); } - bool contains(role r, const void * addr) const noexcept { + bool contains(Role r, const void * addr) const noexcept { return O::iface()->contains(O::data(), r, addr); } bool is_type_installed(typeseq tseq) const noexcept { diff --git a/include/xo/alloc2/gc/RGCObjectVisitor.hpp b/include/xo/alloc2/gc/RGCObjectVisitor.hpp index bba6756..8b7ab26 100644 --- a/include/xo/alloc2/gc/RGCObjectVisitor.hpp +++ b/include/xo/alloc2/gc/RGCObjectVisitor.hpp @@ -91,7 +91,7 @@ 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 { + Generation generation_of(Role r, const void * addr) const noexcept { return O::iface()->generation_of(O::data(), r, addr); } diff --git a/include/xo/alloc2/role.hpp b/include/xo/alloc2/role.hpp index 58fc72a..d2b7c2f 100644 --- a/include/xo/alloc2/role.hpp +++ b/include/xo/alloc2/role.hpp @@ -12,18 +12,19 @@ namespace xo { namespace mm { static constexpr uint32_t c_n_role = 2; - struct role { + class Role { + public: using value_type = std::uint32_t; - explicit constexpr role(value_type x) : role_{x} {} + explicit constexpr Role(value_type x) : role_{x} {} - static constexpr role to_space() { return role{0}; } - static constexpr role from_space() { return role{1}; } + static constexpr Role to_space() { return Role{0}; } + static constexpr Role from_space() { return Role{1}; } - static constexpr std::array all() { return {{to_space(), from_space()}}; } + static constexpr std::array all() { return {{to_space(), from_space()}}; } - static constexpr role begin() { return role{0}; } - static constexpr role end() { return role{2}; } + static constexpr Role begin() { return Role{0}; } + static constexpr Role end() { return Role{2}; } operator value_type() const { return role_; }