diff options
-rw-r--r-- | test/ruby/test_yjit.rb | 14 | ||||
-rw-r--r-- | yjit_codegen.c | 2 |
2 files changed, 15 insertions, 1 deletions
diff --git a/test/ruby/test_yjit.rb b/test/ruby/test_yjit.rb index ccd0e6bae0..587e6d3f1d 100644 --- a/test/ruby/test_yjit.rb +++ b/test/ruby/test_yjit.rb @@ -217,6 +217,20 @@ class TestYJIT < Test::Unit::TestCase RUBY 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 assert_compiles(<<~'RUBY', insns: %i[opt_le opt_minus opt_plus opt_send_without_block], result: 34) def fib(n) diff --git a/yjit_codegen.c b/yjit_codegen.c index 77a0e02de4..d75a4bd20c 100644 --- a/yjit_codegen.c +++ b/yjit_codegen.c @@ -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 - 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); return YJIT_CANT_COMPILE; } |