diff --git a/idl/Collector.json5 b/idl/Collector.json5 index 6cc8243..19c4490 100644 --- a/idl/Collector.json5 +++ b/idl/Collector.json5 @@ -50,7 +50,7 @@ noexcept: true, attributes: [], }, - // size_type reserved(Generation g, role r) const noexcept + // size_type committed(Generation g, role r) const noexcept { name: "committed", doc: ["memory committed for this collector"], @@ -76,6 +76,22 @@ noexcept: true, attributes: [], }, + // int32_t locate() const noexcept + { + name: "locate_address", + doc: [ + "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" + ], + return_type: "std::int32_t", + args: [ + {type: "const void *", name: "addr"}, + ], + const: true, + noexcept: true, + attributes: [], + }, // bool contains(role r, const void * addr) const noexcept { name: "contains", diff --git a/include/xo/alloc2/gc/ACollector.hpp b/include/xo/alloc2/gc/ACollector.hpp index 432d382..e682222 100644 --- a/include/xo/alloc2/gc/ACollector.hpp +++ b/include/xo/alloc2/gc/ACollector.hpp @@ -65,6 +65,10 @@ public: 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; + /** 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 iff gc-aware object of type @p tseq is installed in this collector **/ diff --git a/include/xo/alloc2/gc/ICollector_Any.hpp b/include/xo/alloc2/gc/ICollector_Any.hpp index d578931..3847243 100644 --- a/include/xo/alloc2/gc/ICollector_Any.hpp +++ b/include/xo/alloc2/gc/ICollector_Any.hpp @@ -62,6 +62,7 @@ namespace mm { [[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 is_type_installed(Copaque, typeseq) const noexcept override { _fatal(); } [[noreturn]] bool report_statistics(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 77cde5f..4293817 100644 --- a/include/xo/alloc2/gc/ICollector_Xfer.hpp +++ b/include/xo/alloc2/gc/ICollector_Xfer.hpp @@ -55,6 +55,9 @@ namespace mm { 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 { return I::contains(_dcast(data), r, addr); } diff --git a/include/xo/alloc2/gc/RCollector.hpp b/include/xo/alloc2/gc/RCollector.hpp index be44e90..47dac46 100644 --- a/include/xo/alloc2/gc/RCollector.hpp +++ b/include/xo/alloc2/gc/RCollector.hpp @@ -88,6 +88,9 @@ public: 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 { return O::iface()->contains(O::data(), r, addr); }