ruby-changes:71363
From: John <ko1@a...>
Date: Fri, 11 Mar 2022 04:07:03 +0900 (JST)
Subject: [ruby-changes:71363] 82dea29073 (master): Revert "Fast object is iclass checks"
https://git.ruby-lang.org/ruby.git/commit/?id=82dea29073 From 82dea29073d50304b6029b15d07666994533d8d1 Mon Sep 17 00:00:00 2001 From: John Hawthorn <john@h...> Date: Thu, 10 Mar 2022 11:06:29 -0800 Subject: Revert "Fast object is iclass checks" This reverts commit 1b15756d24c11ed6bfddb5ae53402a071a20ea97. --- object.c | 32 +++++++++----------------------- 1 file changed, 9 insertions(+), 23 deletions(-) diff --git a/object.c b/object.c index 2ed056b6b9..84acf0aada 100644 --- a/object.c +++ b/object.c @@ -817,32 +817,18 @@ rb_obj_is_kind_of(VALUE obj, VALUE c) https://github.com/ruby/ruby/blob/trunk/object.c#L817 // class without checking type and can return immediately. if (cl == c) return Qtrue; - // Note: YJIT needs this function to never allocate and never raise when - // `c` is a class or a module. - + // Fast path: Both are T_CLASS if (LIKELY(RB_TYPE_P(c, T_CLASS))) { - // Fast path: Both are T_CLASS return class_search_class_ancestor(cl, c); - } else if (RB_TYPE_P(c, T_ICLASS)) { - // First check if we inherit the includer - // If we do we can return true immediately - VALUE includer = RCLASS_INCLUDER(c); - RUBY_ASSERT(RB_TYPE_P(includer, T_CLASS)); - if (cl == includer) return Qtrue; - - if(class_search_class_ancestor(cl, includer)) - return Qtrue; - - // We don't include the ICLASS directly, but must check if we inherit - // the module via another include - return RBOOL(class_search_ancestor(cl, RCLASS_ORIGIN(c))); - } else if (RB_TYPE_P(c, T_MODULE)) { - // Slow path: check each ancestor in the linked list and its method table - return RBOOL(class_search_ancestor(cl, RCLASS_ORIGIN(c))); - } else { - rb_raise(rb_eTypeError, "class or module required"); - UNREACHABLE_RETURN(Qfalse); } + + // 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); + c = RCLASS_ORIGIN(c); + + // Slow path: check each ancestor in the linked list and its method table + return RBOOL(class_search_ancestor(cl, c)); } -- cgit v1.2.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/