Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

YJIT: No need to reject splat+zsuper #9840

Merged
merged 1 commit into from
Feb 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
12 changes: 12 additions & 0 deletions bootstraptest/test_yjit.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2444,6 +2444,18 @@ def foo
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)
Expand Down
19 changes: 0 additions & 19 deletions yjit/src/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)?;
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 0 additions & 2 deletions yjit/src/stats.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down