Skip to content

Commit bedcaad

Browse files
committed
rt: Give upcall_del_stack the same convention as other upcalls
1 parent 55a2fd1 commit bedcaad

File tree

3 files changed

+17
-24
lines changed

3 files changed

+17
-24
lines changed

src/rt/arch/i386/morestack.S

Lines changed: 9 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868

6969
#if defined(__APPLE__)
7070
#define RUST_GET_TASK L_rust_get_task$stub
71+
#define UPCALL_DEL_STACK L_upcall_del_stack$stub
7172
#define UPCALL_CALL_C L_upcall_call_shim_on_c_stack$stub
7273
#define MORESTACK ___morestack
7374
#else
@@ -87,8 +88,8 @@
8788
#endif
8889

8990
.globl UPCALL_NEW_STACK
90-
.globl UPCALL_DEL_STACK
9191
#ifndef __APPLE__
92+
.globl UPCALL_DEL_STACK
9293
.globl RUST_GET_TASK
9394
.globl UPCALL_CALL_C_STACK
9495
#endif
@@ -213,24 +214,13 @@ MORESTACK:
213214
// Switch back to the rust stack
214215
movl %ebp, %esp
215216

216-
// Remember that __morestack is called misaligned so %ebp
217-
// is not aligned to a 16-byte boundary, these 4 bytes realign.
218-
subl $4, %esp
217+
// Realign stack - remember that __morestack was called misaligned
218+
subl $12, %esp
219219

220220
// Now that we're on the return path we want to avoid
221221
// stomping on %eax. FIXME: Need to save and restore %eax to
222222
// actually preserve it across the call to delete the stack
223-
#ifdef __APPLE__
224-
call 1f
225-
1: popl %ecx
226-
movl L_upcall_del_stack$non_lazy_ptr-1b(%ecx),%ecx
227-
pushl %ecx
228-
#else
229-
pushl $UPCALL_DEL_STACK
230-
#endif
231-
232-
pushl $0
233-
call UPCALL_CALL_C
223+
call UPCALL_DEL_STACK
234224

235225
addl $12,%esp
236226

@@ -267,9 +257,6 @@ MORESTACK:
267257
L_upcall_new_stack$non_lazy_ptr:
268258
.indirect_symbol _upcall_new_stack
269259
.long 0
270-
L_upcall_del_stack$non_lazy_ptr:
271-
.indirect_symbol _upcall_del_stack
272-
.long 0
273260

274261
.section __IMPORT,__jump_table,symbol_stubs,pure_instructions+self_modifying_code,5
275262

@@ -278,6 +265,10 @@ L_rust_get_task$stub:
278265
.indirect_symbol _rust_get_task
279266
.ascii "\364\364\364\364\364"
280267

268+
L_upcall_del_stack$stub:
269+
.indirect_symbol _upcall_del_stack
270+
.ascii "\364\364\364\364\364"
271+
281272
L_upcall_call_shim_on_c_stack$stub:
282273
.indirect_symbol _upcall_call_shim_on_c_stack
283274
.ascii "\364\364\364\364\364"

src/rt/arch/x86_64/morestack.S

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -117,13 +117,11 @@ MORESTACK:
117117
pushq $0
118118

119119
// FIXME: Should preserve %rax here
120-
movq UPCALL_DEL_STACK@GOTPCREL(%rip), %rsi
121-
movq $0, %rdi
122120
#ifdef __APPLE__
123-
call UPCALL_CALL_C
121+
call UPCALL_DEL_STACK
124122
#endif
125123
#ifdef __linux__
126-
call UPCALL_CALL_C@PLT
124+
call UPCALL_DEL_STACK@PLT
127125
#endif
128126

129127
addq $8, %rsp

src/rt/rust_upcall.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -614,13 +614,17 @@ upcall_new_stack(struct rust_new_stack2_args *args) {
614614
args->args_sz);
615615
}
616616

617-
// FIXME: As above
618617
extern "C" CDECL void
619-
upcall_del_stack() {
618+
upcall_s_del_stack() {
620619
rust_task *task = rust_scheduler::get_task();
621620
task->del_stack();
622621
}
623622

623+
extern "C" CDECL void
624+
upcall_del_stack() {
625+
UPCALL_SWITCH_STACK(NULL, upcall_s_del_stack);
626+
}
627+
624628
// Landing pads need to call this to insert the
625629
// correct limit into TLS.
626630
// NB: This must run on the Rust stack because it

0 commit comments

Comments
 (0)