rt: Fix calculation of stack args location in x86_64/morestack.S

This commit is contained in:
Brian Anderson 2011-11-29 13:47:23 -08:00
parent 9675343dc9
commit afb8f01741
2 changed files with 49 additions and 3 deletions

View File

@ -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

View File

@ -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);
}