From ff59211cfbc7f04754bc3388d9643aad2609f0e0 Mon Sep 17 00:00:00 2001 From: Luke Gruber Date: Fri, 25 Sep 2026 17:35:16 -0400 Subject: [PATCH] Add global argument to rb_gc_impl_start Also, raise NotImplementedError when user calls: ``` GC.stat(scope: :global) ``` So far, only Ruby's default GC implements this. This was introduced in ruby/ruby in: Commit: 60c206b683d5e55d0d8b90556c PR: https://github.com/ruby/ruby/pull/18976 --- gc/gc_impl.h | 2 +- gc/mmtk/mmtk.c | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/gc/gc_impl.h b/gc/gc_impl.h index 76634e6..7a6a999 100644 --- a/gc/gc_impl.h +++ b/gc/gc_impl.h @@ -63,7 +63,7 @@ GC_IMPL_FN void rb_gc_impl_shutdown_free_objects(void *objspace_ptr); GC_IMPL_FN void rb_gc_impl_objspace_free(void *objspace_ptr); GC_IMPL_FN void rb_gc_impl_ractor_cache_free(void *objspace_ptr, void *cache); // GC -GC_IMPL_FN void rb_gc_impl_start(void *objspace_ptr, bool full_mark, bool immediate_mark, bool immediate_sweep, bool compact); +GC_IMPL_FN void rb_gc_impl_start(void *objspace_ptr, bool full_mark, bool immediate_mark, bool immediate_sweep, bool compact, bool global); GC_IMPL_FN bool rb_gc_impl_during_gc_p(void *objspace_ptr); GC_IMPL_FN void rb_gc_impl_prepare_heap(void *objspace_ptr); GC_IMPL_FN void rb_gc_impl_gc_enable(void *objspace_ptr); diff --git a/gc/mmtk/mmtk.c b/gc/mmtk/mmtk.c index 6245dff..6fe01be 100644 --- a/gc/mmtk/mmtk.c +++ b/gc/mmtk/mmtk.c @@ -797,7 +797,7 @@ rb_gc_impl_shutdown_free_objects(void *objspace_ptr) // GC void -rb_gc_impl_start(void *objspace_ptr, bool full_mark, bool immediate_mark, bool immediate_sweep, bool compact) +rb_gc_impl_start(void *objspace_ptr, bool full_mark, bool immediate_mark, bool immediate_sweep, bool compact, bool global) { mmtk_handle_user_collection_request(rb_gc_get_ractor_newobj_cache(), true, full_mark); } @@ -1692,6 +1692,10 @@ setup_gc_stat_symbols(void) VALUE rb_gc_impl_stat(void *objspace_ptr, VALUE hash_or_sym) { + if (objspace_ptr == NULL) { + rb_notimplement(); + } + struct objspace *objspace = objspace_ptr; VALUE hash = Qnil, key = Qnil;