aboutsummaryrefslogtreecommitdiffstats
path: root/vm_method.c
diff options
context:
space:
mode:
authorJohn Hawthorn <john@hawthorn.email>2022-09-14 13:15:55 -0700
committerGitHub <noreply@github.com>2022-09-14 16:15:55 -0400
commitf98d6d3f389e8e46775c5895ddc1a3eec4544533 (patch)
tree1267208755ae53ad583c71a81826772ed31ebcdd /vm_method.c
parentd5cdc2edd02eb6990d045c932aaedb60213143e1 (diff)
downloadruby-f98d6d3f389e8e46775c5895ddc1a3eec4544533.tar.gz
YJIT: Implement specialized respond_to? (#6363)
* Add rb_callable_method_entry_or_negative * YJIT: Implement specialized respond_to? This implements a specialized respond_to? in YJIT. * Update yjit/src/codegen.rs Co-authored-by: Maxime Chevalier-Boisvert <maximechevalierb@gmail.com>
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/vm_method.c b/vm_method.c
index e88a30c5f3..fbe62ecd4c 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -1347,7 +1347,7 @@ negative_cme(ID mid)
}
static const rb_callable_method_entry_t *
-callable_method_entry(VALUE klass, ID mid, VALUE *defined_class_ptr)
+callable_method_entry_or_negative(VALUE klass, ID mid, VALUE *defined_class_ptr)
{
const rb_callable_method_entry_t *cme;
@@ -1376,6 +1376,20 @@ callable_method_entry(VALUE klass, ID mid, VALUE *defined_class_ptr)
}
RB_VM_LOCK_LEAVE();
+ return cme;
+}
+
+// This is exposed for YJIT so that we can make assumptions that methods are
+// not defined.
+const rb_callable_method_entry_t *
+rb_callable_method_entry_or_negative(VALUE klass, ID mid) {
+ return callable_method_entry_or_negative(klass, mid, NULL);
+}
+
+static const rb_callable_method_entry_t *
+callable_method_entry(VALUE klass, ID mid, VALUE *defined_class_ptr) {
+ const rb_callable_method_entry_t *cme;
+ cme = callable_method_entry_or_negative(klass, mid, defined_class_ptr);
return !UNDEFINED_METHOD_ENTRY_P(cme) ? cme : NULL;
}