mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Allow calling variadic cfuncs with many args
We have a check to ensure we don't have to push args on the stack to call a cfunc with many args. However we never need to use the stack for variadic cfuncs, so we shouldn't care about the number of arguments.
This commit is contained in:
parent
922aed92b5
commit
ce02aefabb
2 changed files with 15 additions and 1 deletions
|
@ -217,6 +217,20 @@ class TestYJIT < Test::Unit::TestCase
|
||||||
RUBY
|
RUBY
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# Tests calling a variadic cfunc with many args
|
||||||
|
def test_build_large_struct
|
||||||
|
assert_compiles(<<~RUBY, insns: %i[opt_send_without_block], min_calls: 2)
|
||||||
|
::Foo = Struct.new(:a, :b, :c, :d, :e, :f, :g, :h)
|
||||||
|
|
||||||
|
def build_foo
|
||||||
|
::Foo.new(:a, :b, :c, :d, :e, :f, :g, :h)
|
||||||
|
end
|
||||||
|
|
||||||
|
build_foo
|
||||||
|
build_foo
|
||||||
|
RUBY
|
||||||
|
end
|
||||||
|
|
||||||
def test_fib_recursion
|
def test_fib_recursion
|
||||||
assert_compiles(<<~'RUBY', insns: %i[opt_le opt_minus opt_plus opt_send_without_block], result: 34)
|
assert_compiles(<<~'RUBY', insns: %i[opt_le opt_minus opt_plus opt_send_without_block], result: 34)
|
||||||
def fib(n)
|
def fib(n)
|
||||||
|
|
|
@ -2864,7 +2864,7 @@ gen_send_cfunc(jitstate_t *jit, ctx_t *ctx, const struct rb_callinfo *ci, const
|
||||||
}
|
}
|
||||||
|
|
||||||
// Don't JIT functions that need C stack arguments for now
|
// Don't JIT functions that need C stack arguments for now
|
||||||
if (argc + 1 > NUM_C_ARG_REGS) {
|
if (cfunc->argc >= 0 && argc + 1 > NUM_C_ARG_REGS) {
|
||||||
GEN_COUNTER_INC(cb, send_cfunc_toomany_args);
|
GEN_COUNTER_INC(cb, send_cfunc_toomany_args);
|
||||||
return YJIT_CANT_COMPILE;
|
return YJIT_CANT_COMPILE;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue