summaryrefslogtreecommitdiff
path: root/yjit/src/invariants.rs
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 /yjit/src/invariants.rs
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 'yjit/src/invariants.rs')
-rw-r--r--yjit/src/invariants.rs19
1 files changed, 19 insertions, 0 deletions
diff --git a/yjit/src/invariants.rs b/yjit/src/invariants.rs
index 4ed21118cc..ee79b2938a 100644
--- a/yjit/src/invariants.rs
+++ b/yjit/src/invariants.rs
@@ -154,6 +154,25 @@ pub fn assume_method_lookup_stable(
.insert(block);
}
+// Checks rb_method_basic_definition_p and registers the current block for invalidation if method
+// lookup changes.
+// A "basic method" is one defined during VM boot, so we can use this to check assumptions based on
+// default behavior.
+pub fn assume_method_basic_definition(
+ jit: &mut JITState,
+ ocb: &mut OutlinedCb,
+ klass: VALUE,
+ mid: ID
+ ) -> bool {
+ if unsafe { rb_method_basic_definition_p(klass, mid) } != 0 {
+ let mut cme = unsafe { rb_callable_method_entry(klass, mid) };
+ assume_method_lookup_stable(jit, ocb, klass, cme);
+ true
+ } else {
+ false
+ }
+}
+
/// Tracks that a block is assuming it is operating in single-ractor mode.
#[must_use]
pub fn assume_single_ractor_mode(jit: &mut JITState, ocb: &mut OutlinedCb) -> bool {