From b8e7ff8b7aacfe5ca26ee48caed9e738403a5f09 Mon Sep 17 00:00:00 2001 From: Roland Conybeare Date: Sun, 29 Mar 2026 17:19:23 -0400 Subject: [PATCH] xo-gc stack: + gc-report-object-types() primitive --- idl/Collector.json5 | 19 +++++++++++++++++++ include/xo/alloc2/gc/ACollector.hpp | 5 +++++ include/xo/alloc2/gc/ICollector_Any.hpp | 1 + include/xo/alloc2/gc/ICollector_Xfer.hpp | 3 +++ include/xo/alloc2/gc/RCollector.hpp | 3 +++ 5 files changed, 31 insertions(+) diff --git a/idl/Collector.json5 b/idl/Collector.json5 index e7e53a0f..6cc82433 100644 --- a/idl/Collector.json5 +++ b/idl/Collector.json5 @@ -120,6 +120,25 @@ noexcept: true, attributes: [], }, + // bool report_types(obj report_mm, obj error_mm, obj * output); + { + name: "report_object_types", + doc: [ + "Report gc object types, at discretion of collector implementation.", + "Creates dictionary using memory from @p report_mm.", + "If unable to comply (e.g. oom), return runtime error allocated from @p error_mm.", + "Avoiding obj return type to avoid #include cycle" + ], + return_type: "bool", + args: [ + {type: "obj", name: "report_mm"}, + {type: "obj", name: "error_mm"}, + {type: "obj *", name: "output"}, + ], + const: true, + noexcept: true, + attributes: [], + }, ], nonconst_methods: [ // bool install_type(const AGCObject & iface) diff --git a/include/xo/alloc2/gc/ACollector.hpp b/include/xo/alloc2/gc/ACollector.hpp index f156a4e4..432d3820 100644 --- a/include/xo/alloc2/gc/ACollector.hpp +++ b/include/xo/alloc2/gc/ACollector.hpp @@ -74,6 +74,11 @@ Creates dictionary using memory from @p report_mm. If unable to comply (e.g. oom), return runtime error allocated from @p error_mm. Avoiding obj return type to avoid #include cycle **/ virtual bool report_statistics(Copaque data, obj report_mm, obj error_mm, obj * output) const noexcept = 0; + /** Report gc object types, at discretion of collector implementation. +Creates dictionary using memory from @p report_mm. +If unable to comply (e.g. oom), return runtime error allocated from @p error_mm. +Avoiding obj return type to avoid #include cycle **/ + virtual bool report_object_types(Copaque data, obj report_mm, obj error_mm, obj * output) const noexcept = 0; // nonconst methods /** install interface @p iface for representation with typeseq @p tseq diff --git a/include/xo/alloc2/gc/ICollector_Any.hpp b/include/xo/alloc2/gc/ICollector_Any.hpp index 34f90356..d5789310 100644 --- a/include/xo/alloc2/gc/ICollector_Any.hpp +++ b/include/xo/alloc2/gc/ICollector_Any.hpp @@ -65,6 +65,7 @@ namespace mm { [[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(); } // nonconst methods [[noreturn]] bool install_type(Opaque, const AGCObject &) override; diff --git a/include/xo/alloc2/gc/ICollector_Xfer.hpp b/include/xo/alloc2/gc/ICollector_Xfer.hpp index 2df60064..77cde5fc 100644 --- a/include/xo/alloc2/gc/ICollector_Xfer.hpp +++ b/include/xo/alloc2/gc/ICollector_Xfer.hpp @@ -64,6 +64,9 @@ namespace mm { bool report_statistics(Copaque data, obj report_mm, obj error_mm, obj * output) const noexcept override { return I::report_statistics(_dcast(data), report_mm, error_mm, output); } + bool report_object_types(Copaque data, obj report_mm, obj error_mm, obj * output) const noexcept override { + return I::report_object_types(_dcast(data), report_mm, error_mm, output); + } // non-const methods bool install_type(Opaque data, const AGCObject & iface) override { diff --git a/include/xo/alloc2/gc/RCollector.hpp b/include/xo/alloc2/gc/RCollector.hpp index ad514854..be44e90e 100644 --- a/include/xo/alloc2/gc/RCollector.hpp +++ b/include/xo/alloc2/gc/RCollector.hpp @@ -97,6 +97,9 @@ public: bool report_statistics(obj report_mm, obj error_mm, obj * output) const noexcept { return O::iface()->report_statistics(O::data(), report_mm, error_mm, output); } + bool report_object_types(obj report_mm, obj error_mm, obj * output) const noexcept { + return O::iface()->report_object_types(O::data(), report_mm, error_mm, output); + } // non-const methods (still const in router!) bool install_type(const AGCObject & iface) {