summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_zjit.rb5
-rw-r--r--zjit/src/codegen.rs6
2 files changed, 10 insertions, 1 deletions
diff --git a/test/ruby/test_zjit.rb b/test/ruby/test_zjit.rb
index 1166533bd9..69c440f5f0 100644
--- a/test/ruby/test_zjit.rb
+++ b/test/ruby/test_zjit.rb
@@ -806,6 +806,11 @@ class TestZJIT < Test::Unit::TestCase
def a(n1,n2,n3,n4,n5,n6,n7,n8,n9) = n1+n9
a(2,0,0,0,0,0,0,0,-1)
}
+
+ assert_compiles '0', %q{
+ def a(n1,n2,n3,n4,n5,n6,n7,n8) = n8
+ a(1,1,1,1,1,1,1,0)
+ }
end
def test_opt_aref_with
diff --git a/zjit/src/codegen.rs b/zjit/src/codegen.rs
index 6ce3915978..54346e0778 100644
--- a/zjit/src/codegen.rs
+++ b/zjit/src/codegen.rs
@@ -898,6 +898,10 @@ fn gen_return(jit: &JITState, asm: &mut Assembler, val: lir::Opnd) -> Option<()>
asm.mov(CFP, incr_cfp);
asm.mov(Opnd::mem(64, EC, RUBY_OFFSET_EC_CFP), CFP);
+ // Order here is important. Because we're about to tear down the frame,
+ // we need to load the return value, which might be part of the frame.
+ asm.load_into(C_RET_OPND, val);
+
// Restore the C stack pointer bumped for basic block arguments
if jit.c_stack_bytes > 0 {
asm_comment!(asm, "restore C stack pointer");
@@ -908,7 +912,7 @@ fn gen_return(jit: &JITState, asm: &mut Assembler, val: lir::Opnd) -> Option<()>
asm.frame_teardown();
// Return from the function
- asm.cret(val);
+ asm.cret(C_RET_OPND);
Some(())
}