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: Rest and block_arg support #7557

Merged
merged 2 commits into from Mar 17, 2023
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
21 changes: 21 additions & 0 deletions bootstraptest/test_yjit.rb
Expand Up @@ -3662,3 +3662,24 @@ def bar(x, *rest)
end
send(:bar, 1, 2, 3)
}

# Rest with block
# Simplified code from railsbench
assert_equal '[{"/a"=>"b", :as=>:c, :via=>:post}, [], nil]', %q{
def match(path, *rest, &block)
[path, rest, block]
end

def map_method(method, args, &block)
options = args.last
args.pop
options[:via] = method
match(*args, options, &block)
end

def post(*args, &block)
map_method(:post, args, &block)
end

post "/a" => "b", as: :c
}
9 changes: 2 additions & 7 deletions yjit/src/codegen.rs
Expand Up @@ -5172,9 +5172,9 @@ fn move_rest_args_to_stack(array: Opnd, num_args: u32, ctx: &mut Context, asm: &

let array_len_opnd = get_array_len(asm, array);

asm.comment("Side exit if length doesn't not equal remaining args");
asm.comment("Side exit if length is less than required");
asm.cmp(array_len_opnd, num_args.into());
asm.jbe(counted_exit!(ocb, side_exit, send_splatarray_length_not_equal));
asm.jl(counted_exit!(ocb, side_exit, send_iseq_has_rest_and_splat_not_equal));

asm.comment("Push arguments from array");

Expand Down Expand Up @@ -5404,11 +5404,6 @@ fn gen_send_iseq(
return CantCompile;
}

if iseq_has_rest && unsafe { get_iseq_flags_has_block(iseq) } {
gen_counter_incr!(asm, send_iseq_has_rest_and_block);
return CantCompile;
}

if iseq_has_rest && unsafe { get_iseq_flags_has_kw(iseq) } {
gen_counter_incr!(asm, send_iseq_has_rest_and_kw);
return CantCompile;
Expand Down
3 changes: 1 addition & 2 deletions yjit/src/stats.rs
Expand Up @@ -253,11 +253,10 @@ make_counters! {
send_send_getter,
send_send_builtin,
send_iseq_has_rest_and_captured,
send_iseq_has_rest_and_splat_fewer,
send_iseq_has_rest_and_send,
send_iseq_has_rest_and_block,
send_iseq_has_rest_and_kw,
send_iseq_has_rest_and_optional,
send_iseq_has_rest_and_splat_not_equal,
send_is_a_class_mismatch,
send_instance_of_class_mismatch,

Expand Down