diff options
| author | Randy Stauner <randy@r4s6.net> | 2026-01-08 10:01:43 -0700 |
|---|---|---|
| committer | Max Bernstein <tekknolagi@gmail.com> | 2026-01-12 16:50:48 -0500 |
| commit | d81a11d4e61f67b6fb0aaa44aaa7ead4022148dd (patch) | |
| tree | 7646c6af460c05376810bc87f7334bd9937ce9ba /test | |
| parent | 351616af8c92329e143db24969125ca62f8b6ffc (diff) | |
ZJIT: Snapshot FrameState with reordered args before direct send
You can see the reordered args in the new Snapshot right before the
DirectSend insn:
v14:Any = Snapshot FrameState { pc: 0x00, stack: [v6, v11, v13], locals: [] }
PatchPoint MethodRedefined(Object@0x00, a@0x00, cme:0x00)
PatchPoint NoSingletonClass(Object@0x00)
v22:HeapObject[class_exact*:Object@VALUE(0x00)] = GuardType v6, HeapObject[class_exact*:Object@VALUE(0x00)]
- v23:BasicObject = SendWithoutBlockDirect v22, :a (0x00), v13, v11
- v16:Any = Snapshot FrameState { pc: 0x00, stack: [v23], locals: [] }
+ v23:Any = Snapshot FrameState { pc: 0x00, stack: [v6, v13, v11], locals: [] }
+ v24:BasicObject = SendWithoutBlockDirect v22, :a (0x00), v13, v11
+ v16:Any = Snapshot FrameState { pc: 0x00, stack: [v24], locals: [] }
Diffstat (limited to 'test')
| -rw-r--r-- | test/ruby/test_zjit.rb | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb index 43db676d5d..cf3c46b3ed 100644 --- a/test/ruby/test_zjit.rb +++ b/test/ruby/test_zjit.rb @@ -383,6 +383,43 @@ class TestZJIT < Test::Unit::TestCase }, call_threshold: 2 end + def test_kwargs_with_exit_and_local_invalidation + assert_compiles ':ok', %q{ + def a(b:, c:) + if c == :b + return -> {} + end + Class # invalidate locals + + raise "c is :b!" if c == :b + end + + def test + # note opposite order of kwargs + a(c: :c, b: :b) + end + + 4.times { test } + :ok + }, call_threshold: 2 + end + + def test_kwargs_with_max_direct_send_arg_count + # Ensure that we only reorder the args when we _can_ use direct send (< 6 args). + assert_compiles '[[1, 2, 3, 4, 5, 6, 7, 8]]', %q{ + def kwargs(five, six, a:, b:, c:, d:, e:, f:) + [a, b, c, d, five, six, e, f] + end + + 5.times.flat_map do + [ + kwargs(5, 6, d: 4, c: 3, a: 1, b: 2, e: 7, f: 8), + kwargs(5, 6, d: 4, c: 3, b: 2, a: 1, e: 7, f: 8) + ] + end.uniq + }, call_threshold: 2 + end + def test_setlocal_on_eval assert_compiles '1', %q{ @b = binding |
