RJIT: Fix arguments for shift_stack

This commit is contained in:
Takashi Kokubun 2023-04-03 21:22:02 -07:00
parent 1d529f382c
commit 6ab86e4626
2 changed files with 28 additions and 14 deletions

View File

@ -1,16 +1,30 @@
assert_equal 'true', %q{ # VM_CALL_OPT_SEND + VM_METHOD_TYPE_ATTRSET
def nil_nil = nil == nil assert_equal '1', %q{
nil_nil class Foo
attr_writer :foo
def bar
send(:foo=, 1)
end
end
Foo.new.bar
} }
assert_equal 'true', %q{ # VM_CALL_OPT_SEND + OPTIMIZED_METHOD_TYPE_CALL
def lt(a, b) = a < b assert_equal 'foo', %q{
lt(1, 2) def bar(&foo)
lt('a', 'b') foo.send(:call)
end
bar { :foo }
} }
assert_equal '3', %q{ # VM_CALL_OPT_SEND + OPTIMIZED_METHOD_TYPE_STRUCT_AREF
def foo = 2 assert_equal 'bar', %q{
def bar = 1 + foo + nil.to_i def bar(foo)
bar foo.send(:bar)
end
bar(Struct.new(:bar).new(:bar))
} }

View File

@ -5128,7 +5128,7 @@ module RubyVM::RJIT
# This is a .send call and we need to adjust the stack # This is a .send call and we need to adjust the stack
if flags & C::VM_CALL_OPT_SEND != 0 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 end
# Save the PC and SP because the callee may allocate # Save the PC and SP because the callee may allocate
@ -5316,7 +5316,7 @@ module RubyVM::RJIT
# If this is a .send call we need to adjust the stack # If this is a .send call we need to adjust the stack
if flags & C::VM_CALL_OPT_SEND != 0 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 end
# About to reset the SP, need to load this here # About to reset the SP, need to load this here
@ -5363,7 +5363,7 @@ module RubyVM::RJIT
# This is a .send call and we need to adjust the stack # This is a .send call and we need to adjust the stack
if flags & C::VM_CALL_OPT_SEND != 0 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 end
# All structs from the same Struct class should have the same # All structs from the same Struct class should have the same