ruby-changes:71264
From: John <ko1@a...>
Date: Thu, 24 Feb 2022 12:57:57 +0900 (JST)
Subject: [ruby-changes:71264] 764e4fa850 (master): Never call kind_of with klass=0
https://git.ruby-lang.org/ruby.git/commit/?id=764e4fa850 From 764e4fa850de749790e5ed11c8a4ab86a4499ac0 Mon Sep 17 00:00:00 2001 From: John Hawthorn <john@h...> Date: Sat, 29 Jan 2022 21:27:53 -0800 Subject: Never call kind_of with klass=0 --- ext/objspace/objspace.c | 9 +-------- object.c | 2 ++ 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/ext/objspace/objspace.c b/ext/objspace/objspace.c index d33dfeb80a..bd80e540cf 100644 --- a/ext/objspace/objspace.c +++ b/ext/objspace/objspace.c @@ -61,14 +61,7 @@ total_i(VALUE v, void *ptr) https://github.com/ruby/ruby/blob/trunk/ext/objspace/objspace.c#L61 { struct total_data *data = (struct total_data *)ptr; - switch (BUILTIN_TYPE(v)) { - case T_NONE: - case T_IMEMO: - case T_ICLASS: - case T_NODE: - case T_ZOMBIE: - return; - default: + if (!rb_objspace_internal_object_p(v)) { if (data->klass == 0 || rb_obj_is_kind_of(v, data->klass)) { data->total += rb_obj_memsize_of(v); } diff --git a/object.c b/object.c index f056767f13..ff94469292 100644 --- a/object.c +++ b/object.c @@ -791,6 +791,8 @@ rb_obj_is_kind_of(VALUE obj, VALUE c) https://github.com/ruby/ruby/blob/trunk/object.c#L791 { VALUE cl = CLASS_OF(obj); + RUBY_ASSERT(cl); + // Note: YJIT needs this function to never allocate and never raise when // `c` is a class or a module. c = class_or_module_required(c); -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/