diff options
| author | Takashi Kokubun <takashikkbn@gmail.com> | 2024-02-12 09:56:44 -0800 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-02-12 12:56:44 -0500 |
| commit | e4d3e652ff41943c7f50d4552c1c98dfaa736cf9 (patch) | |
| tree | 417dc5dde586bafdc696f1fb58e7c41076768e92 | |
| parent | 94bc5ad30a15685c3c3b0bf19510cf6415ebb935 (diff) | |
YJIT: Prefer an overloaded cme if available (#9913)
YJIT: Prefer an overloaded cme if applicable
| -rw-r--r-- | vm_insnhelper.c | 4 | ||||
| -rw-r--r-- | vm_method.c | 4 | ||||
| -rw-r--r-- | yjit/src/codegen.rs | 4 | ||||
| -rw-r--r-- | yjit/src/cruby.rs | 4 |
4 files changed, 12 insertions, 4 deletions
diff --git a/vm_insnhelper.c b/vm_insnhelper.c index a742184278..aef71970f6 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2032,7 +2032,7 @@ vm_ccs_verify(struct rb_class_cc_entries *ccs, ID mid, VALUE klass) } #endif -static const rb_callable_method_entry_t *check_overloaded_cme(const rb_callable_method_entry_t *cme, const struct rb_callinfo * const ci); +const rb_callable_method_entry_t *rb_check_overloaded_cme(const rb_callable_method_entry_t *cme, const struct rb_callinfo * const ci); static const struct rb_callcache * vm_search_cc(const VALUE klass, const struct rb_callinfo * const ci) @@ -2118,7 +2118,7 @@ vm_search_cc(const VALUE klass, const struct rb_callinfo * const ci) } } - cme = check_overloaded_cme(cme, ci); + cme = rb_check_overloaded_cme(cme, ci); const struct rb_callcache *cc = vm_cc_new(klass, cme, vm_call_general, cc_type_normal); vm_ccs_push(klass, ccs, ci, cc); diff --git a/vm_method.c b/vm_method.c index a4d0a9f411..05c99b9905 100644 --- a/vm_method.c +++ b/vm_method.c @@ -1063,8 +1063,8 @@ get_overloaded_cme(const rb_callable_method_entry_t *cme) } } -static const rb_callable_method_entry_t * -check_overloaded_cme(const rb_callable_method_entry_t *cme, const struct rb_callinfo * const ci) +const rb_callable_method_entry_t * +rb_check_overloaded_cme(const rb_callable_method_entry_t *cme, const struct rb_callinfo * const ci) { if (UNLIKELY(cme->def->iseq_overload) && (vm_ci_flag(ci) & (VM_CALL_ARGS_SIMPLE)) && diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index ac8670fe40..421fa989e2 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -7679,6 +7679,10 @@ fn gen_send_general( return None; } + // Load an overloaded cme if applicable. See vm_search_cc(). + // It allows you to use a faster ISEQ if possible. + cme = unsafe { rb_check_overloaded_cme(cme, ci) }; + let visi = unsafe { METHOD_ENTRY_VISI(cme) }; match visi { METHOD_VISI_PUBLIC => { diff --git a/yjit/src/cruby.rs b/yjit/src/cruby.rs index 78cb2d65ea..fb98e3474b 100644 --- a/yjit/src/cruby.rs +++ b/yjit/src/cruby.rs @@ -112,6 +112,10 @@ pub use autogened::*; // Use bindgen for functions that are defined in headers or in yjit.c. #[cfg_attr(test, allow(unused))] // We don't link against C code when testing extern "C" { + pub fn rb_check_overloaded_cme( + me: *const rb_callable_method_entry_t, + ci: *const rb_callinfo, + ) -> *const rb_callable_method_entry_t; pub fn rb_hash_empty_p(hash: VALUE) -> VALUE; pub fn rb_vm_splat_array(flag: VALUE, ary: VALUE) -> VALUE; pub fn rb_vm_concat_array(ary1: VALUE, ary2st: VALUE) -> VALUE; |
