diff options
author | John Hawthorn <john@hawthorn.email> | 2023-04-12 16:22:22 -0700 |
---|---|---|
committer | John Hawthorn <john@hawthorn.email> | 2023-04-12 17:48:34 -0700 |
commit | 0ce2bdc76dd17aa3d42a352a6244c87a51e7606d (patch) | |
tree | dcac8e703e49e7dfe87dfb836acd8cb53814c1bd /bootstraptest | |
parent | c8d8207aea7085b611c5f27016f1e55b4396d759 (diff) |
YJIT: Fix missing argc check in known cfuncs
Previously we were missing a compile-time check that the known cfuncs
receive the correct number of arguments.
We noticied this because in particular when using ARGS_SPLAT, which also
wasn't checked, YJIT would crash on code which was otherwise correct
(didn't raise exceptions in the VM).
This still supports vararg (argc == -1) cfuncs. I added an additional
assertion that when we use the specialized codegen for one of these
known functions that the argc are popped off the stack correctly, which
should help ensure they're implemented correctly (previously the crash
was usually observed on a future `leave` insn).
[Bug #19595]
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/7697
Diffstat (limited to 'bootstraptest')
-rw-r--r-- | bootstraptest/test_yjit.rb | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/bootstraptest/test_yjit.rb b/bootstraptest/test_yjit.rb index 34cb87ed88..ed8bd94e7c 100644 --- a/bootstraptest/test_yjit.rb +++ b/bootstraptest/test_yjit.rb @@ -1227,6 +1227,38 @@ assert_equal '42', %q{ run } +# splatting an empty array on a specialized method +assert_equal 'ok', %q{ + def run + "ok".to_s(*[]) + end + + run + run +} + +# splatting an single element array on a specialized method +assert_equal '[1]', %q{ + def run + [].<<(*[1]) + end + + run + run +} + +# specialized method with wrong args +assert_equal 'ok', %q{ + def run(x) + "bad".to_s(123) if x + rescue + :ok + end + + run(false) + run(true) +} + # getinstancevariable on Symbol assert_equal '[nil, nil]', %q{ # @foo to exercise the getinstancevariable instruction |