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

This commit is contained in:
Roland Conybeare 2026-03-30 14:51:51 -04:00
commit a9be64edb7
3 changed files with 37 additions and 0 deletions

View file

@ -27,6 +27,10 @@ namespace xo {
static DPrimitive_gco_0 * make_report_gc_object_types_pm(obj<AAllocator> mm,
StringTable * stbl);
/** create primitive: report gc object-age statistics **/
static DPrimitive_gco_0 * make_report_gc_object_ages_pm(obj<AAllocator> mm,
StringTable * stbl);
/** create primitive: report gc location of a value **/
static DPrimitive_gco_1_gco * make_gc_location_of_pm(obj<AAllocator> mm,
StringTable * stbl);

View file

@ -78,6 +78,34 @@ namespace xo {
}
// ----- report-gc-object-ages -----
obj<AGCObject>
xfer_report_gc_object_ages(obj<ARuntimeContext> rcx)
{
if (rcx.collector()) {
obj<AGCObject> stats;
bool ok = rcx.collector().report_object_ages(rcx.allocator(), rcx.error_allocator(), &stats);
if (ok && stats)
return stats;
}
return DBoolean::box(rcx.allocator(), false);
}
DPrimitive_gco_0 *
GcPrimitives::make_report_gc_object_ages_pm(obj<AAllocator> mm,
StringTable * stbl)
{
(void)stbl;
auto any_ty = DAtomicType::make(mm, Metatype::t_any());
auto pm_ty = obj<AType,DFunctionType>(DFunctionType::_make(mm, any_ty));
return DPrimitive_gco_0::_make(mm, "report-gc-object-ages", pm_ty, &xfer_report_gc_object_ages);
}
// ----- gc-location-of -----
obj<AGCObject>

View file

@ -142,6 +142,11 @@ namespace xo {
GcPrimitives::make_report_gc_object_types_pm(mm, stbl),
flags & InstallFlags::f_generalpurpose));
ok = ok & (PrimitiveRegistry::install_aux
(sink,
GcPrimitives::make_report_gc_object_ages_pm(mm, stbl),
flags & InstallFlags::f_generalpurpose));
ok = ok & (PrimitiveRegistry::install_aux
(sink,
GcPrimitives::make_gc_location_of_pm(mm, stbl),