diff --git a/gc.c b/gc.c index e02f9b136f..9d59163ee0 100644 --- a/gc.c +++ b/gc.c @@ -3375,19 +3375,6 @@ rb_gc_latest_gc_info(VALUE key) return rb_gc_impl_latest_gc_info(rb_gc_get_objspace(), key); } -static VALUE -gc_latest_gc_info(rb_execution_context_t *ec, VALUE self, VALUE arg) -{ - if (NIL_P(arg)) { - arg = rb_hash_new(); - } - else if (!SYMBOL_P(arg) && !RB_TYPE_P(arg, T_HASH)) { - rb_raise(rb_eTypeError, "non-hash or symbol given"); - } - - return rb_gc_latest_gc_info(arg); -} - static VALUE gc_stat(rb_execution_context_t *ec, VALUE self, VALUE arg) // arg is (nil || hash || symbol) { diff --git a/gc.rb b/gc.rb index f2790ef85d..ce5f3ffff6 100644 --- a/gc.rb +++ b/gc.rb @@ -320,7 +320,15 @@ module GC # it is overwritten and returned. # This is intended to avoid probe effect. def self.latest_gc_info hash_or_key = nil - Primitive.gc_latest_gc_info hash_or_key + if hash_or_key == nil + hash_or_key = {} + elsif Primitive.cexpr!("RBOOL(!SYMBOL_P(hash_or_key) && !RB_TYPE_P(hash_or_key, T_HASH))") + raise TypeError, "non-hash or symbol given" + end + + Primitive.cstmt! %{ + return rb_gc_latest_gc_info(hash_or_key); + } end # call-seq: