Skip to content

Commit 014babc

Browse files
committed
---
yaml --- r: 6527 b: refs/heads/master c: e6ef4d9 h: refs/heads/master i: 6525: f126039 6523: d42f07e 6519: 7ff72f1 6511: 67d88f5 6495: 10400e1 6463: a26430f 6399: eaaa939 v: v3
1 parent 927c8f6 commit 014babc

File tree

6 files changed

+10
-43
lines changed

6 files changed

+10
-43
lines changed

[refs]

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: 408d4ec0ef40a2ce650fab8d730a79f08d35054a
2+
refs/heads/master: e6ef4d929ca01bdbedc4056cc33f1770e71d87ee

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

+4-14
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,12 @@
88
#if defined(__APPLE__) || defined(_WIN32)
99
#define RUST_NEW_STACK2 _rust_new_stack2
1010
#define RUST_DEL_STACK _rust_del_stack
11-
#define RUST_GET_PREV_STACK _rust_get_prev_stack
1211
#define RUST_GET_TASK _rust_get_task
1312
#define UPCALL_CALL_C _upcall_call_shim_on_c_stack
1413
#define MORESTACK ___morestack
1514
#else
1615
#define RUST_NEW_STACK2 rust_new_stack2
1716
#define RUST_DEL_STACK rust_del_stack
18-
#define RUST_GET_PREV_STACK rust_get_prev_stack
1917
#define RUST_GET_TASK rust_get_task
2018
#define UPCALL_CALL_C upcall_call_shim_on_c_stack
2119
#define MORESTACK __morestack
@@ -59,7 +57,6 @@ MORESTACK:
5957
jz .L$bail
6058

6159
// The arguments to rust_new_stack2
62-
movl %esp, 20(%esp) // Save the stack pointer
6360
movl 36(%esp),%eax // Size of stack arguments
6461
movl %eax,16(%esp)
6562
leal 44+ALIGNMENT(%esp),%eax // Address of stack arguments
@@ -81,21 +78,14 @@ MORESTACK:
8178
// Now the function that called us has returned, so we need to delete the
8279
// old stack space.
8380

84-
// NB: This is assuming we already have at least 2 words
85-
// pushed onto the C stack. This is always true because
86-
// Rust functions have implicit arguments.
87-
movl $RUST_GET_PREV_STACK,4(%esp)
88-
movl $0, (%esp)
89-
call UPCALL_CALL_C
90-
9181
// Switch back to the rust stack
92-
movl %eax, %esp
82+
movl %ebp, %esp
9383

94-
movl $RUST_DEL_STACK,4(%esp)
95-
movl $0, (%esp)
84+
pushl $RUST_DEL_STACK
85+
pushl $0
9686
call UPCALL_CALL_C
9787

98-
addl $24,%esp
88+
addl $8,%esp
9989
popl %ebp
10090
retl $8
10191

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

+3-14
Original file line numberDiff line numberDiff line change
@@ -9,14 +9,12 @@
99
#define RUST_NEW_STACK2 _rust_new_stack2
1010
#define RUST_DEL_STACK _rust_del_stack
1111
#define RUST_DEL_STACK _rust_del_stack
12-
#define RUST_GET_PREV_STACK _rust_get_prev_stack
1312
#define UPCALL_CALL_C _upcall_call_shim_on_c_stack
1413
#define MORESTACK ___morestack
1514
#else
1615
#define RUST_NEW_STACK2 rust_new_stack2
1716
#define RUST_DEL_STACK rust_del_stack
1817
#define RUST_DEL_STACK rust_del_stack
19-
#define RUST_GET_PREV_STACK rust_get_prev_stack
2018
#define UPCALL_CALL_C upcall_call_shim_on_c_stack
2119
#define MORESTACK __morestack
2220
#endif
@@ -63,9 +61,6 @@ MORESTACK:
6361
movq %rsp, %rbp
6462
.cfi_def_cfa_register %rbp
6563

66-
// Alignment
67-
pushq $0
68-
6964
// FIXME: libgcc also saves rax. not sure if we need to
7065

7166
// Save argument registers
@@ -82,7 +77,6 @@ MORESTACK:
8277
movq %rbp, %rcx
8378
addq $24, %rcx // Base pointer, return address x2
8479

85-
pushq %rbp // Save the Rust stack pointer
8680
pushq %r11 // Size of stack arguments
8781
pushq %rcx // Address of stack arguments
8882
pushq %r10 // The amount of stack needed
@@ -92,7 +86,7 @@ MORESTACK:
9286
call UPCALL_CALL_C@PLT
9387

9488
// Pop the new_stack_args struct
95-
addq $32, %rsp
89+
addq $24, %rsp
9690

9791
// Pop the saved arguments
9892
popq %r9
@@ -108,13 +102,8 @@ MORESTACK:
108102

109103
call *%r10 // Reenter the caller function
110104

111-
leaq RUST_GET_PREV_STACK@PLT(%rip), %rsi
112-
movq $0, %rdi
113-
call UPCALL_CALL_C@PLT
114-
115-
// Switch back to the rust stack, positioned
116-
// where we pushed %ebp
117-
movq %rax, %rsp
105+
// Switch back to the rust stack
106+
movq %rbp, %rsp
118107

119108
// Align the stack again
120109
pushq $0

trunk/src/rt/rust_task.cpp

+2-12
Original file line numberDiff line numberDiff line change
@@ -67,14 +67,11 @@ record_sp(void *limit);
6767

6868
// Entry points for `__morestack` (see arch/*/morestack.S).
6969
extern "C" void *
70-
rust_new_stack(size_t stk_sz, void *args_addr, size_t args_sz,
71-
uintptr_t current_sp) {
70+
rust_new_stack(size_t stk_sz, void *args_addr, size_t args_sz) {
7271
rust_task *task = rust_scheduler::get_task();
7372

7473
stk_seg *stk_seg = new_stk(task->sched, task, stk_sz + args_sz);
7574

76-
// Save the previous stack pointer so it can be restored later
77-
stk_seg->return_sp = current_sp;
7875
uint8_t *new_sp = (uint8_t*)stk_seg->limit;
7976
size_t sizeof_retaddr = sizeof(void*);
8077
// Make enough room on the new stack to hold the old stack pointer
@@ -90,15 +87,14 @@ struct rust_new_stack2_args {
9087
size_t stk_sz;
9188
void *args_addr;
9289
size_t args_sz;
93-
uintptr_t current_sp;
9490
};
9591

9692
// A new stack function suitable for calling through
9793
// upcall_call_shim_on_c_stack
9894
extern "C" void *
9995
rust_new_stack2(struct rust_new_stack2_args *args) {
10096
return rust_new_stack(args->stk_sz, args->args_addr,
101-
args->args_sz, args->current_sp);
97+
args->args_sz);
10298
}
10399

104100
extern "C" void
@@ -108,12 +104,6 @@ rust_del_stack() {
108104
record_sp(task->stk->data + RED_ZONE_SIZE);
109105
}
110106

111-
extern "C" uintptr_t
112-
rust_get_prev_stack() {
113-
rust_task *task = rust_scheduler::get_task();
114-
return task->stk->return_sp;
115-
}
116-
117107
extern "C" rust_task *
118108
rust_get_task() {
119109
return rust_scheduler::get_task();

trunk/src/rt/rust_task.h

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ struct rust_box;
2626
struct stk_seg {
2727
stk_seg *next;
2828
uintptr_t limit;
29-
uintptr_t return_sp;
3029
unsigned int valgrind_id;
3130
#ifndef _LP64
3231
uint32_t pad;

trunk/src/rt/rustrt.def.in

-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ refcount
3030
rust_del_stack
3131
rust_file_is_dir
3232
rust_getcwd
33-
rust_get_prev_stack
3433
rust_get_stdin
3534
rust_get_stdout
3635
rust_get_stderr

0 commit comments

Comments
 (0)