From b9bef61d32dfb36d5c388f9db31d7560f66f3a9e Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Fri, 19 Jan 2024 16:35:33 -0500 Subject: [PATCH] YJIT: Drop bogus checks for ruby2_keywords These checks don't correspond to anything that ruby2_keywords actually does, so YJIT was refusing to compile things needlessly. About 16% of fallback reasons in `lobsters` was due to the ISeq one. As for the correct logic, we already handle the tagging part with exit_if_supplying_kw_and_has_no_kw() and have a dynamic guard for the splat logic. --- yjit/src/codegen.rs | 27 --------------------------- yjit/src/stats.rs | 2 -- 2 files changed, 29 deletions(-) diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index b50cd101634f8e..00ba65313e7643 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -5555,18 +5555,6 @@ fn gen_send_cfunc( return None; } - // In order to handle backwards compatibility between ruby 3 and 2 - // ruby2_keywords was introduced. It is called only on methods - // with splat and changes they way they handle them. - // We are just going to not compile these. - // https://docs.ruby-lang.org/en/3.2/Module.html#method-i-ruby2_keywords - if unsafe { - get_iseq_flags_ruby2_keywords(jit.iseq) && flags & VM_CALL_ARGS_SPLAT != 0 - } { - gen_counter_incr(asm, Counter::send_args_splat_cfunc_ruby2_keywords); - return None; - } - let kw_arg = unsafe { vm_ci_kwarg(ci) }; let kw_arg_num = if kw_arg.is_null() { 0 @@ -6152,7 +6140,6 @@ fn gen_send_iseq( exit_if_has_post(asm, iseq)?; exit_if_has_kwrest(asm, iseq)?; exit_if_kw_splat(asm, flags)?; - exit_if_splat_and_ruby2_keywords(asm, jit, flags)?; exit_if_has_rest_and_captured(asm, iseq_has_rest, captured_opnd)?; exit_if_has_rest_and_supplying_kws(asm, iseq_has_rest, iseq, supplying_kws)?; exit_if_supplying_kw_and_has_no_kw(asm, supplying_kws, iseq)?; @@ -6968,20 +6955,6 @@ fn exit_if_kw_splat(asm: &mut Assembler, flags: u32) -> Option<()> { exit_if(asm, flags & VM_CALL_KW_SPLAT != 0, Counter::send_iseq_kw_splat) } -#[must_use] -fn exit_if_splat_and_ruby2_keywords(asm: &mut Assembler, jit: &mut JITState, flags: u32) -> Option<()> { - // In order to handle backwards compatibility between ruby 3 and 2 - // ruby2_keywords was introduced. It is called only on methods - // with splat and changes they way they handle them. - // We are just going to not compile these. - // https://www.rubydoc.info/stdlib/core/Proc:ruby2_keywords - exit_if( - asm, - unsafe { get_iseq_flags_ruby2_keywords(jit.iseq) } && flags & VM_CALL_ARGS_SPLAT != 0, - Counter::send_iseq_ruby2_keywords, - ) -} - #[must_use] fn exit_if_has_rest_and_captured(asm: &mut Assembler, iseq_has_rest: bool, captured_opnd: Option) -> Option<()> { exit_if(asm, iseq_has_rest && captured_opnd.is_some(), Counter::send_iseq_has_rest_and_captured) diff --git a/yjit/src/stats.rs b/yjit/src/stats.rs index 1dd5f57b2bb16f..9da89fdafc747c 100644 --- a/yjit/src/stats.rs +++ b/yjit/src/stats.rs @@ -358,10 +358,8 @@ make_counters! { send_args_splat_opt_call, send_args_splat_cfunc_var_args, send_args_splat_cfunc_zuper, - send_args_splat_cfunc_ruby2_keywords, send_iseq_splat_arity_error, send_splat_too_long, - send_iseq_ruby2_keywords, send_send_not_imm, send_send_wrong_args, send_send_null_mid,