Skip to content

Commit

Permalink
RJIT: Fix arguments for shift_stack
Browse files Browse the repository at this point in the history
  • Loading branch information
k0kubun committed Apr 4, 2023
1 parent 1d529f3 commit 6ab86e4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 14 deletions.
36 changes: 25 additions & 11 deletions bootstraptest/test_rjit.rb
Original file line number Diff line number Diff line change
@@ -1,16 +1,30 @@
assert_equal 'true', %q{
def nil_nil = nil == nil
nil_nil
# VM_CALL_OPT_SEND + VM_METHOD_TYPE_ATTRSET
assert_equal '1', %q{
class Foo
attr_writer :foo
def bar
send(:foo=, 1)
end
end
Foo.new.bar
}

assert_equal 'true', %q{
def lt(a, b) = a < b
lt(1, 2)
lt('a', 'b')
# VM_CALL_OPT_SEND + OPTIMIZED_METHOD_TYPE_CALL
assert_equal 'foo', %q{
def bar(&foo)
foo.send(:call)
end
bar { :foo }
}

assert_equal '3', %q{
def foo = 2
def bar = 1 + foo + nil.to_i
bar
# VM_CALL_OPT_SEND + OPTIMIZED_METHOD_TYPE_STRUCT_AREF
assert_equal 'bar', %q{
def bar(foo)
foo.send(:bar)
end
bar(Struct.new(:bar).new(:bar))
}
6 changes: 3 additions & 3 deletions lib/ruby_vm/rjit/insn_compiler.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5128,7 +5128,7 @@ def jit_call_attrset(jit, ctx, asm, cme, calling, comptime_recv, recv_opnd)

# This is a .send call and we need to adjust the stack
if flags & C::VM_CALL_OPT_SEND != 0
handle_opt_send_shift_stack(ctx, asm, argc, send_shift:)
handle_opt_send_shift_stack(asm, argc, ctx, send_shift:)
end

# Save the PC and SP because the callee may allocate
Expand Down Expand Up @@ -5316,7 +5316,7 @@ def jit_call_opt_call(jit, ctx, asm, cme, flags, argc, block_handler, known_recv

# If this is a .send call we need to adjust the stack
if flags & C::VM_CALL_OPT_SEND != 0
handle_opt_send_shift_stack(ctx, asm, argc, send_shift:)
handle_opt_send_shift_stack(asm, argc, ctx, send_shift:)
end

# About to reset the SP, need to load this here
Expand Down Expand Up @@ -5363,7 +5363,7 @@ def jit_call_opt_struct_aref(jit, ctx, asm, cme, flags, argc, block_handler, kno

# This is a .send call and we need to adjust the stack
if flags & C::VM_CALL_OPT_SEND != 0
handle_opt_send_shift_stack(ctx, asm, argc, send_shift:)
handle_opt_send_shift_stack(asm, argc, ctx, send_shift:)
end

# All structs from the same Struct class should have the same
Expand Down

0 comments on commit 6ab86e4

Please sign in to comment.