xo-procedure2 stack: + report-gc-object-ages() primitive

This commit is contained in:
Roland Conybeare 2026-03-30 14:51:51 -04:00
commit c91fc4fbed
5 changed files with 33 additions and 0 deletions

View file

@ -155,6 +155,26 @@
noexcept: true, noexcept: true,
attributes: [], attributes: [],
}, },
// bool report_object_ages(obj<AAllocator> report_mm, obj<AAllocator> error_mm, obj<AGCObject> * output);
{
name: "report_object_ages",
doc: [
"Report gc object ages, at discretion of collector implementation.",
"Creates array of dictionaries using memory from @p report_mm.",
"Each dictionary has keys n-live and bytes, indexed by object age.",
"If unable to comply (e.g. oom), return runtime error allocated from @p error_mm.",
"Avoiding obj<AGCObject> return type to avoid #include cycle",
],
return_type: "bool",
args: [
{type: "obj<AAllocator>", name: "report_mm"},
{type: "obj<AAllocator>", name: "error_mm"},
{type: "obj<AGCObject> *", name: "output"},
],
const: true,
noexcept: true,
attributes: [],
},
], ],
nonconst_methods: [ nonconst_methods: [
// bool install_type(const AGCObject & iface) // bool install_type(const AGCObject & iface)

View file

@ -83,6 +83,12 @@ Creates dictionary using memory from @p report_mm.
If unable to comply (e.g. oom), return runtime error allocated from @p error_mm. If unable to comply (e.g. oom), return runtime error allocated from @p error_mm.
Avoiding obj<AGCObject> return type to avoid #include cycle **/ Avoiding obj<AGCObject> return type to avoid #include cycle **/
virtual bool report_object_types(Copaque data, obj<AAllocator> report_mm, obj<AAllocator> error_mm, obj<AGCObject> * output) const noexcept = 0; virtual bool report_object_types(Copaque data, obj<AAllocator> report_mm, obj<AAllocator> error_mm, obj<AGCObject> * output) const noexcept = 0;
/** Report gc object ages, at discretion of collector implementation.
Creates array of dictionaries using memory from @p report_mm.
Each dictionary has keys n-live and bytes, indexed by object age.
If unable to comply (e.g. oom), return runtime error allocated from @p error_mm.
Avoiding obj<AGCObject> return type to avoid #include cycle **/
virtual bool report_object_ages(Copaque data, obj<AAllocator> report_mm, obj<AAllocator> error_mm, obj<AGCObject> * output) const noexcept = 0;
// nonconst methods // nonconst methods
/** install interface @p iface for representation with typeseq @p tseq /** install interface @p iface for representation with typeseq @p tseq

View file

@ -67,6 +67,7 @@ namespace mm {
[[noreturn]] bool is_type_installed(Copaque, typeseq) const noexcept override { _fatal(); } [[noreturn]] bool is_type_installed(Copaque, typeseq) const noexcept override { _fatal(); }
[[noreturn]] bool report_statistics(Copaque, obj<AAllocator>, obj<AAllocator>, obj<AGCObject> *) const noexcept override { _fatal(); } [[noreturn]] bool report_statistics(Copaque, obj<AAllocator>, obj<AAllocator>, obj<AGCObject> *) const noexcept override { _fatal(); }
[[noreturn]] bool report_object_types(Copaque, obj<AAllocator>, obj<AAllocator>, obj<AGCObject> *) const noexcept override { _fatal(); } [[noreturn]] bool report_object_types(Copaque, obj<AAllocator>, obj<AAllocator>, obj<AGCObject> *) const noexcept override { _fatal(); }
[[noreturn]] bool report_object_ages(Copaque, obj<AAllocator>, obj<AAllocator>, obj<AGCObject> *) const noexcept override { _fatal(); }
// nonconst methods // nonconst methods
[[noreturn]] bool install_type(Opaque, const AGCObject &) override; [[noreturn]] bool install_type(Opaque, const AGCObject &) override;

View file

@ -70,6 +70,9 @@ namespace mm {
bool report_object_types(Copaque data, obj<AAllocator> report_mm, obj<AAllocator> error_mm, obj<AGCObject> * output) const noexcept override { bool report_object_types(Copaque data, obj<AAllocator> report_mm, obj<AAllocator> error_mm, obj<AGCObject> * output) const noexcept override {
return I::report_object_types(_dcast(data), report_mm, error_mm, output); return I::report_object_types(_dcast(data), report_mm, error_mm, output);
} }
bool report_object_ages(Copaque data, obj<AAllocator> report_mm, obj<AAllocator> error_mm, obj<AGCObject> * output) const noexcept override {
return I::report_object_ages(_dcast(data), report_mm, error_mm, output);
}
// non-const methods // non-const methods
bool install_type(Opaque data, const AGCObject & iface) override { bool install_type(Opaque data, const AGCObject & iface) override {

View file

@ -103,6 +103,9 @@ public:
bool report_object_types(obj<AAllocator> report_mm, obj<AAllocator> error_mm, obj<AGCObject> * output) const noexcept { bool report_object_types(obj<AAllocator> report_mm, obj<AAllocator> error_mm, obj<AGCObject> * output) const noexcept {
return O::iface()->report_object_types(O::data(), report_mm, error_mm, output); return O::iface()->report_object_types(O::data(), report_mm, error_mm, output);
} }
bool report_object_ages(obj<AAllocator> report_mm, obj<AAllocator> error_mm, obj<AGCObject> * output) const noexcept {
return O::iface()->report_object_ages(O::data(), report_mm, error_mm, output);
}
// non-const methods (still const in router!) // non-const methods (still const in router!)
bool install_type(const AGCObject & iface) { bool install_type(const AGCObject & iface) {