From 7b6e07ea93cfc42bfb8bdf875555d2c8c7d5e507 Mon Sep 17 00:00:00 2001 From: Peter Zhu Date: Tue, 18 Feb 2025 12:58:40 -0500 Subject: Add rb_gc_object_metadata API This function replaces the internal rb_obj_gc_flags API. rb_gc_object_metadata returns an array of name and value pairs, with the last element having 0 for the name. --- ext/objspace/objspace_dump.c | 29 +++++++++++++++++------------ gc.c | 13 ++++++------- gc/default/default.c | 41 +++++++++++++++++++++++++++-------------- gc/gc_impl.h | 10 +++++++++- internal/gc.h | 10 ++++++++-- 5 files changed, 67 insertions(+), 36 deletions(-) diff --git a/ext/objspace/objspace_dump.c b/ext/objspace/objspace_dump.c index 2b98214f69..139612526f 100644 --- a/ext/objspace/objspace_dump.c +++ b/ext/objspace/objspace_dump.c @@ -385,8 +385,6 @@ dump_object(VALUE obj, struct dump_config *dc) size_t memsize; struct allocation_info *ainfo = objspace_lookup_allocation_info(obj); rb_io_t *fptr; - ID flags[RB_OBJ_GC_FLAGS_MAX]; - size_t n, i; ID mid; if (SPECIAL_CONST_P(obj)) { @@ -643,14 +641,24 @@ dump_object(VALUE obj, struct dump_config *dc) dump_append_lu(dc, RB_NUM2ULONG(rb_obj_id(obj))); } - if ((n = rb_obj_gc_flags(obj, flags, sizeof(flags))) > 0) { - dump_append(dc, ", \"flags\":{"); - for (i=0; i