Skip to content

Commit 46ef870

Browse files
committed
fix YJIT calls
1 parent 7146e52 commit 46ef870

3 files changed

Lines changed: 41 additions & 20 deletions

File tree

bootstraptest/test_yjit.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4766,6 +4766,22 @@ def delegator(...)
47664766
delegator
47674767
}
47684768

4769+
assert_equal 'ok', %q{
4770+
def ok
4771+
:ok
4772+
end
4773+
4774+
def delegator(...)
4775+
ok(...)
4776+
end
4777+
4778+
def caller
4779+
send(:delegator)
4780+
end
4781+
4782+
caller
4783+
}
4784+
47694785
assert_equal '[:ok, :ok, :ok]', %q{
47704786
def identity(x) = x
47714787
def foo(x, _) = x

yjit/src/codegen.rs

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -6991,6 +6991,10 @@ fn gen_send_iseq(
69916991
}
69926992
exit_if_doing_kw_and_opts_missing(asm, doing_kw_call, opts_missing)?;
69936993
exit_if_has_rest_and_optional_and_block(asm, iseq_has_rest, opt_num, iseq, block_arg)?;
6994+
if forwarding_call && flags & VM_CALL_OPT_SEND != 0 {
6995+
gen_counter_incr(asm, Counter::send_iseq_send_forwarding);
6996+
return None;
6997+
}
69946998
let block_arg_type = exit_if_unsupported_block_arg_type(jit, asm, block_arg)?;
69956999

69967000
// Bail if we can't drop extra arguments for a yield by just popping them
@@ -7500,33 +7504,33 @@ fn gen_send_iseq(
75007504
}
75017505

75027506
if !forwarding_call {
7503-
// Nil-initialize missing optional parameters
7504-
nil_fill(
7505-
"nil-initialize missing optionals",
7506-
{
7507-
let begin = -argc + required_num + opts_filled;
7508-
let end = -argc + required_num + opt_num;
7509-
7510-
begin..end
7511-
},
7512-
asm
7513-
);
7514-
// Nil-initialize the block parameter. It's the last parameter local
7515-
if iseq_has_block_param {
7516-
let block_param = asm.ctx.sp_opnd(-argc + num_params - 1);
7517-
asm.store(block_param, Qnil.into());
7518-
}
7519-
// Nil-initialize non-parameter locals
7520-
nil_fill(
7521-
"nil-initialize locals",
7507+
// Nil-initialize missing optional parameters
7508+
nil_fill(
7509+
"nil-initialize missing optionals",
7510+
{
7511+
let begin = -argc + required_num + opts_filled;
7512+
let end = -argc + required_num + opt_num;
7513+
7514+
begin..end
7515+
},
7516+
asm
7517+
);
7518+
// Nil-initialize the block parameter. It's the last parameter local
7519+
if iseq_has_block_param {
7520+
let block_param = asm.ctx.sp_opnd(-argc + num_params - 1);
7521+
asm.store(block_param, Qnil.into());
7522+
}
7523+
// Nil-initialize non-parameter locals
7524+
nil_fill(
7525+
"nil-initialize locals",
75227526
{
75237527
let begin = -argc + num_params;
75247528
let end = -argc + num_locals;
75257529

75267530
begin..end
75277531
},
75287532
asm
7529-
);
7533+
);
75307534
}
75317535

75327536
if forwarding_call {

yjit/src/stats.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -384,6 +384,7 @@ make_counters! {
384384
send_iseq_has_no_kw,
385385
send_iseq_accepts_no_kwarg,
386386
send_iseq_materialized_block,
387+
send_iseq_send_forwarding,
387388
send_iseq_splat_not_array,
388389
send_iseq_splat_with_kw,
389390
send_iseq_missing_optional_kw,

0 commit comments

Comments
 (0)