about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-11-29 13:47:23 -0800
committerBrian Anderson <banderson@mozilla.com>2011-11-29 13:47:54 -0800
commitafb8f0174170cb9f23ec0b8a93f4bb8dd4514603 (patch)
treee037e6b867954238a38cdc79333f90c42079f395 /src
parent9675343dc975a0159d5f7b52e4a7f72737f0549c (diff)
rt: Fix calculation of stack args location in x86_64/morestack.S
Diffstat (limited to 'src')
-rw-r--r--src/rt/arch/x86_64/morestack.S7
-rw-r--r--src/test/run-pass/morestack3.rs45
2 files changed, 49 insertions, 3 deletions
diff --git a/src/rt/arch/x86_64/morestack.S b/src/rt/arch/x86_64/morestack.S
index 25b3fa3ec69..7a17cb6744e 100644
--- a/src/rt/arch/x86_64/morestack.S
+++ b/src/rt/arch/x86_64/morestack.S
@@ -76,10 +76,11 @@ MORESTACK:
 	pushq	%r8
 	pushq	%r9
 
-	// Calculate the address of the stack arguments
+	// Calculate the address of the stack arguments.
+	// We have the base pointer, __morestack's return address,
+	// and __morestack's caller's return address to skip
 	movq %rbp, %rcx
-	addq $16, %rcx   // Add the saved %rbp, and return address
-	addq %r11, %rcx // Add the size of stack arguments
+	addq $24, %rcx  // Base pointer, return address x2
 
 	pushq %rbp // Save the Rust stack pointer
 	pushq %r11 // Size of stack arguments
diff --git a/src/test/run-pass/morestack3.rs b/src/test/run-pass/morestack3.rs
new file mode 100644
index 00000000000..dd679df0c5a
--- /dev/null
+++ b/src/test/run-pass/morestack3.rs
@@ -0,0 +1,45 @@
+// xfail-test
+// compile-flags:--stack-growth
+
+// Here we're testing that all of the argument registers, argument
+// stack slots, and return value are preserved across split stacks.
+fn getbig(a0: int,
+          a1: int,
+          a2: int,
+          a3: int,
+          a4: int,
+          a5: int,
+          a6: int,
+          a7: int,
+          a8: int,
+          a9: int) -> int {
+
+    assert a0 + 1 == a1;
+    assert a1 + 1 == a2;
+    assert a2 + 1 == a3;
+    assert a3 + 1 == a4;
+    assert a4 + 1 == a5;
+    assert a5 + 1 == a6;
+    assert a6 + 1 == a7;
+    assert a7 + 1 == a8;
+    assert a8 + 1 == a9;
+    if a0 != 0 {
+        let j = getbig(a0 - 1,
+                       a1 - 1,
+                       a2 - 1,
+                       a3 - 1,
+                       a4 - 1,
+                       a5 - 1,
+                       a6 - 1,
+                       a7 - 1,
+                       a8 - 1,
+                       a9 - 1);
+        assert j == a0 - 1;
+    }
+    ret a0;
+}
+
+fn main() {
+    let a = 1000000;
+    getbig(a, a+1, a+2, a+3, a+4, a+5, a+6, a+7, a+8, a+9);
+}
\ No newline at end of file