Skip to content

Commit 04d43e1

Browse files
authored
ZJIT: Give up JIT-to-JIT calls for 6+ args (ruby#13939)
1 parent d1f38ce commit 04d43e1

File tree

2 files changed

+18
-0
lines changed

2 files changed

+18
-0
lines changed

test/ruby/test_zjit.rb

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,21 @@ def test3 = baz(4, 1)
133133
}
134134
end
135135

136+
def test_send_with_six_args
137+
assert_compiles '[1, 2, 3, 4, 5, 6]', %q{
138+
def foo(a1, a2, a3, a4, a5, a6)
139+
[a1, a2, a3, a4, a5, a6]
140+
end
141+
142+
def test
143+
foo(1, 2, 3, 4, 5, 6)
144+
end
145+
146+
test # profile send
147+
test
148+
}, call_threshold: 2
149+
end
150+
136151
def test_invokebuiltin
137152
omit 'Test fails at the moment due to not handling optional parameters'
138153
assert_compiles '["."]', %q{

zjit/src/codegen.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,9 @@ fn gen_insn(cb: &mut CodeBlock, jit: &mut JITState, asm: &mut Assembler, functio
291291
Insn::IfTrue { val, target } => return gen_if_true(jit, asm, opnd!(val), target),
292292
Insn::IfFalse { val, target } => return gen_if_false(jit, asm, opnd!(val), target),
293293
Insn::SendWithoutBlock { call_info, cd, state, self_val, args, .. } => gen_send_without_block(jit, asm, call_info, *cd, &function.frame_state(*state), opnd!(self_val), opnds!(args))?,
294+
// Give up SendWithoutBlockDirect for 6+ args since asm.ccall() doesn't support it.
295+
Insn::SendWithoutBlockDirect { call_info, cd, state, self_val, args, .. } if args.len() + 1 > C_ARG_OPNDS.len() => // +1 for self
296+
gen_send_without_block(jit, asm, call_info, *cd, &function.frame_state(*state), opnd!(self_val), opnds!(args))?,
294297
Insn::SendWithoutBlockDirect { cme, iseq, self_val, args, state, .. } => gen_send_without_block_direct(cb, jit, asm, *cme, *iseq, opnd!(self_val), opnds!(args), &function.frame_state(*state))?,
295298
Insn::InvokeBuiltin { bf, args, state } => gen_invokebuiltin(asm, &function.frame_state(*state), bf, opnds!(args))?,
296299
Insn::Return { val } => return Some(gen_return(jit, asm, opnd!(val))?),

0 commit comments

Comments
 (0)