summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hawthorn <[email protected]>2022-03-10 11:06:29 -0800
committerJohn Hawthorn <[email protected]>2022-03-10 11:06:42 -0800
commit82dea29073d50304b6029b15d07666994533d8d1 ()
tree5e050d1443910e23466cf237f15e387cb339863f
parentedc8576a65b7082597d45a694434261ec3ac0d9e (diff)
Revert "Fast object is iclass checks"
This reverts commit 1b15756d24c11ed6bfddb5ae53402a071a20ea97.
Notes: Merged: https://.com/ruby/ruby/pull/5639
-rw-r--r--object.c32
1 files changed, 9 insertions, 23 deletions
@@ -817,32 +817,18 @@ rb_obj_is_kind_of(VALUE obj, VALUE c)
// 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.
-
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);
}
}