From bae3e5b29aa53120194791f73c9a085df3658e90 Mon Sep 17 00:00:00 2001 From: Alan Wu Date: Mon, 5 Feb 2024 14:10:12 -0500 Subject: [PATCH] YJIT: No need to reject splat+zsuper There is nothing special about argument handling when it comes to zsuper if you look around in the VM. Everything passes removing these fallback reasons. It was ~16% on `railsbench`. --- bootstraptest/test_yjit.rb | 12 ++++++++++++ yjit/src/codegen.rs | 19 ------------------- yjit/src/stats.rs | 2 -- 3 files changed, 12 insertions(+), 21 deletions(-) diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index 58977b3e55..786d2cc7dd 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -2444,6 +2444,18 @@ assert_equal '[0, 2]', %q{ B.new.foo } +# invokesuper zsuper in a bmethod +assert_equal 'ok', %q{ + class Foo + define_method(:itself) { super } + end + begin + Foo.new.itself + rescue RuntimeError + :ok + end +} + # Call to fixnum assert_equal '[true, false]', %q{ def is_odd(obj) diff --git a/yjit/src/codegen.rs b/yjit/src/codegen.rs index 935ce1fcd8..d7de29c5d3 100644 --- a/yjit/src/codegen.rs +++ b/yjit/src/codegen.rs @@ -5887,15 +5887,6 @@ fn gen_send_cfunc( return None; } - if flags & VM_CALL_ARGS_SPLAT != 0 && flags & VM_CALL_ZSUPER != 0 { - // zsuper methods are super calls without any arguments. - // They are also marked as splat, but don't actually have an array - // they pull arguments from, instead we need to change to call - // a different method with the current stack. - gen_counter_incr(asm, Counter::send_args_splat_cfunc_zuper); - return None; - } - let kw_arg = unsafe { vm_ci_kwarg(ci) }; let kw_arg_num = if kw_arg.is_null() { 0 @@ -6425,7 +6416,6 @@ fn gen_send_iseq( 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)?; exit_if_supplying_kws_and_accept_no_kwargs(asm, supplying_kws, iseq)?; - exit_if_splat_and_zsuper(asm, flags)?; exit_if_doing_kw_and_splat(asm, doing_kw_call, flags)?; exit_if_wrong_number_arguments(asm, arg_setup_block, opts_filled, flags, opt_num, iseq_has_rest)?; exit_if_doing_kw_and_opts_missing(asm, doing_kw_call, opts_missing)?; @@ -7327,15 +7317,6 @@ fn exit_if_supplying_kws_and_accept_no_kwargs(asm: &mut Assembler, supplying_kws ) } -#[must_use] -fn exit_if_splat_and_zsuper(asm: &mut Assembler, flags: u32) -> Option<()> { - // zsuper methods are super calls without any arguments. - // They are also marked as splat, but don't actually have an array - // they pull arguments from, instead we need to change to call - // a different method with the current stack. - exit_if(asm, flags & VM_CALL_ARGS_SPLAT != 0 && flags & VM_CALL_ZSUPER != 0, Counter::send_iseq_zsuper) -} - #[must_use] fn exit_if_doing_kw_and_splat(asm: &mut Assembler, doing_kw_call: bool, flags: u32) -> Option<()> { exit_if(asm, doing_kw_call && flags & VM_CALL_ARGS_SPLAT != 0, Counter::send_iseq_splat_with_kw) diff --git a/yjit/src/stats.rs b/yjit/src/stats.rs index 19e452be16..625d2291ca 100644 --- a/yjit/src/stats.rs +++ b/yjit/src/stats.rs @@ -321,7 +321,6 @@ make_counters! { send_kw_splat, send_singleton_class, send_args_splat_super, - send_iseq_zsuper, send_block_arg, send_ivar_set_method, send_zsuper_method, @@ -378,7 +377,6 @@ make_counters! { send_args_splat_aset, send_args_splat_opt_call, send_args_splat_cfunc_var_args, - send_args_splat_cfunc_zuper, send_iseq_splat_arity_error, send_splat_too_long, send_send_not_imm,