]> git.lizzy.rs Git - rust.git/commitdiff
rt: Save and restore %rax/%eax in __morestack
authorBrian Anderson <banderson@mozilla.com>
Tue, 20 Dec 2011 00:16:00 +0000 (16:16 -0800)
committerBrian Anderson <banderson@mozilla.com>
Tue, 20 Dec 2011 02:16:21 +0000 (18:16 -0800)
This doesn't matter now since we use an out pointer for return
values but it's sure to show up mysteriously someday.

src/rt/arch/i386/morestack.S
src/rt/arch/x86_64/morestack.S

index c34d1a0fe88a4ddd179af3fb08735c161aaa4471..c4090df109d8e2920da376304e4d6ac20ae5c633 100644 (file)
@@ -198,11 +198,17 @@ MORESTACK:
        // Realign stack - remember that __morestack was called misaligned
        subl $12, %esp
 
+       // Save the return value of the function we allocated space for
+       movl %eax, (%esp)
+
        // Now that we're on the return path we want to avoid
        // stomping on %eax. FIXME: Need to save and restore %eax to
        // actually preserve it across the call to delete the stack
        call UPCALL_DEL_STACK
 
+       // And restore it
+       movl (%esp), %eax
+
        addl $12,%esp
 
        popl %ebp
index 93ce0e4c698b7393832083e839821a9c869a5548..f4d897f1cf4a8c13e931f9bfe19d05dc606b961b 100644 (file)
@@ -100,8 +100,8 @@ MORESTACK:
        // Switch back to the rust stack
        movq %rbp, %rsp
 
-       // Align the stack again
-       pushq $0
+       // Save the return value
+       pushq %rax
 
        // FIXME: Should preserve %rax here
 #ifdef __APPLE__
@@ -111,7 +111,7 @@ MORESTACK:
        call UPCALL_DEL_STACK@PLT
 #endif
 
-       addq $8, %rsp
+       popq %rax // Restore the return value
        popq %rbp
        // FIXME: I don't think these rules are necessary
        // since the unwinder should never encounter an instruction