about summary refs log tree commit diff
path: root/src/rt
diff options
context:
space:
mode:
authorBrian Anderson <banderson@mozilla.com>2011-11-30 17:08:06 -0800
committerBrian Anderson <banderson@mozilla.com>2011-11-30 20:31:33 -0800
commite6ef4d929ca01bdbedc4056cc33f1770e71d87ee (patch)
treedd694a48debb4f149e4ddef41881dad6ee478812 /src/rt
parent408d4ec0ef40a2ce650fab8d730a79f08d35054a (diff)
downloadrust-e6ef4d929ca01bdbedc4056cc33f1770e71d87ee.tar.gz
rust-e6ef4d929ca01bdbedc4056cc33f1770e71d87ee.zip
rt: Remove the stack pointer field of stk_seg
Diffstat (limited to 'src/rt')
-rw-r--r--src/rt/arch/i386/morestack.S18
-rw-r--r--src/rt/arch/x86_64/morestack.S17
-rw-r--r--src/rt/rust_task.cpp14
-rw-r--r--src/rt/rust_task.h1
-rw-r--r--src/rt/rustrt.def.in1
5 files changed, 9 insertions, 42 deletions
diff --git a/src/rt/arch/i386/morestack.S b/src/rt/arch/i386/morestack.S
index d739f820422..2805fc2b10e 100644
--- a/src/rt/arch/i386/morestack.S
+++ b/src/rt/arch/i386/morestack.S
@@ -8,14 +8,12 @@
 #if defined(__APPLE__) || defined(_WIN32)
 #define RUST_NEW_STACK2         _rust_new_stack2
 #define RUST_DEL_STACK          _rust_del_stack
-#define RUST_GET_PREV_STACK     _rust_get_prev_stack
 #define RUST_GET_TASK           _rust_get_task
 #define UPCALL_CALL_C           _upcall_call_shim_on_c_stack
 #define MORESTACK               ___morestack
 #else
 #define RUST_NEW_STACK2         rust_new_stack2
 #define RUST_DEL_STACK          rust_del_stack
-#define RUST_GET_PREV_STACK     rust_get_prev_stack
 #define RUST_GET_TASK           rust_get_task
 #define UPCALL_CALL_C           upcall_call_shim_on_c_stack
 #define MORESTACK               __morestack
@@ -59,7 +57,6 @@ MORESTACK:
 	jz .L$bail
 
 	// The arguments to rust_new_stack2
-	movl %esp, 20(%esp) // Save the stack pointer
 	movl 36(%esp),%eax  // Size of stack arguments
 	movl %eax,16(%esp)
 	leal 44+ALIGNMENT(%esp),%eax // Address of stack arguments
@@ -81,21 +78,14 @@ MORESTACK:
 	// Now the function that called us has returned, so we need to delete the
 	// old stack space.
 
-	// NB: This is assuming we already have at least 2 words
-	// pushed onto the C stack. This is always true because
-	// Rust functions have implicit arguments.
-	movl $RUST_GET_PREV_STACK,4(%esp)
-	movl $0, (%esp)
-	call UPCALL_CALL_C
-
 	// Switch back to the rust stack
-	movl %eax, %esp
+	movl %ebp, %esp
 
-	movl $RUST_DEL_STACK,4(%esp)
-	movl $0, (%esp)
+	pushl $RUST_DEL_STACK
+	pushl $0
 	call UPCALL_CALL_C
 
-	addl $24,%esp
+	addl $8,%esp
 	popl %ebp
 	retl $8
 
diff --git a/src/rt/arch/x86_64/morestack.S b/src/rt/arch/x86_64/morestack.S
index cabed0c9114..d8070cfd9f0 100644
--- a/src/rt/arch/x86_64/morestack.S
+++ b/src/rt/arch/x86_64/morestack.S
@@ -9,14 +9,12 @@
 #define RUST_NEW_STACK2     _rust_new_stack2
 #define RUST_DEL_STACK      _rust_del_stack
 #define RUST_DEL_STACK      _rust_del_stack
-#define RUST_GET_PREV_STACK _rust_get_prev_stack
 #define UPCALL_CALL_C       _upcall_call_shim_on_c_stack
 #define MORESTACK           ___morestack
 #else
 #define RUST_NEW_STACK2     rust_new_stack2
 #define RUST_DEL_STACK      rust_del_stack
 #define RUST_DEL_STACK      rust_del_stack
-#define RUST_GET_PREV_STACK rust_get_prev_stack
 #define UPCALL_CALL_C       upcall_call_shim_on_c_stack
 #define MORESTACK           __morestack
 #endif
@@ -63,9 +61,6 @@ MORESTACK:
 	movq %rsp, %rbp
 	.cfi_def_cfa_register %rbp
 
-	// Alignment
-	pushq $0
-
 	// FIXME: libgcc also saves rax. not sure if we need to
 
 	// Save argument registers
@@ -82,7 +77,6 @@ MORESTACK:
 	movq %rbp, %rcx
 	addq $24, %rcx  // Base pointer, return address x2
 
-	pushq %rbp // Save the Rust stack pointer
 	pushq %r11 // Size of stack arguments
 	pushq %rcx // Address of stack arguments
 	pushq %r10 // The amount of stack needed
@@ -92,7 +86,7 @@ MORESTACK:
 	call UPCALL_CALL_C@PLT
 
 	// Pop the new_stack_args struct
-	addq $32, %rsp
+	addq $24, %rsp
 
 	// Pop the saved arguments
 	popq %r9
@@ -108,13 +102,8 @@ MORESTACK:
 
         call *%r10              // Reenter the caller function
 
-	leaq RUST_GET_PREV_STACK@PLT(%rip), %rsi
-	movq $0, %rdi
-	call UPCALL_CALL_C@PLT
-
-	// Switch back to the rust stack, positioned
-	// where we pushed %ebp
-	movq %rax, %rsp
+	// Switch back to the rust stack
+	movq %rbp, %rsp
 
 	// Align the stack again
 	pushq $0
diff --git a/src/rt/rust_task.cpp b/src/rt/rust_task.cpp
index 6c79ef3264a..7210fe3956c 100644
--- a/src/rt/rust_task.cpp
+++ b/src/rt/rust_task.cpp
@@ -67,14 +67,11 @@ record_sp(void *limit);
 
 // Entry points for `__morestack` (see arch/*/morestack.S).
 extern "C" void *
-rust_new_stack(size_t stk_sz, void *args_addr, size_t args_sz,
-               uintptr_t current_sp) {
+rust_new_stack(size_t stk_sz, void *args_addr, size_t args_sz) {
     rust_task *task = rust_scheduler::get_task();
 
     stk_seg *stk_seg = new_stk(task->sched, task, stk_sz + args_sz);
 
-    // Save the previous stack pointer so it can be restored later
-    stk_seg->return_sp = current_sp;
     uint8_t *new_sp = (uint8_t*)stk_seg->limit;
     size_t sizeof_retaddr = sizeof(void*);
     // Make enough room on the new stack to hold the old stack pointer
@@ -90,7 +87,6 @@ struct rust_new_stack2_args {
   size_t stk_sz;
   void *args_addr;
   size_t args_sz;
-  uintptr_t current_sp;
 };
 
 // A new stack function suitable for calling through
@@ -98,7 +94,7 @@ struct rust_new_stack2_args {
 extern "C" void *
 rust_new_stack2(struct rust_new_stack2_args *args) {
     return rust_new_stack(args->stk_sz, args->args_addr,
-                          args->args_sz, args->current_sp);
+                          args->args_sz);
 }
 
 extern "C" void
@@ -108,12 +104,6 @@ rust_del_stack() {
     record_sp(task->stk->data + RED_ZONE_SIZE);
 }
 
-extern "C" uintptr_t
-rust_get_prev_stack() {
-    rust_task *task = rust_scheduler::get_task();
-    return task->stk->return_sp;
-}
-
 extern "C" rust_task *
 rust_get_task() {
     return rust_scheduler::get_task();
diff --git a/src/rt/rust_task.h b/src/rt/rust_task.h
index bda51937ce1..a6d68331fda 100644
--- a/src/rt/rust_task.h
+++ b/src/rt/rust_task.h
@@ -26,7 +26,6 @@ struct rust_box;
 struct stk_seg {
     stk_seg *next;
     uintptr_t limit;
-    uintptr_t return_sp;
     unsigned int valgrind_id;
 #ifndef _LP64
     uint32_t pad;
diff --git a/src/rt/rustrt.def.in b/src/rt/rustrt.def.in
index a62c7ab06f5..68d791f162d 100644
--- a/src/rt/rustrt.def.in
+++ b/src/rt/rustrt.def.in
@@ -30,7 +30,6 @@ refcount
 rust_del_stack
 rust_file_is_dir
 rust_getcwd
-rust_get_prev_stack
 rust_get_stdin
 rust_get_stdout
 rust_get_stderr