gc.c: add optional GC statistics counters

Add gc_total_count, minor_gc_count, major_gc_count (uint32_t) to
mrb_gc, guarded by MRB_GC_STATS. Zero cost when disabled.

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-03-10 16:08:35 +09:00
parent 78658d67e1
commit 52fb294172
2 changed files with 20 additions and 0 deletions
+6
View File
@@ -64,6 +64,12 @@ typedef struct mrb_gc {
int arena_capa; /* size of protection array */
#endif
int arena_idx;
#ifdef MRB_GC_STATS
uint32_t gc_total_count; /* total GC invocations */
uint32_t minor_gc_count; /* minor GC count */
uint32_t major_gc_count; /* major GC count */
#endif
} mrb_gc;
MRB_API mrb_bool mrb_object_dead_p(mrb_state *mrb, struct RBasic *object);