25
25
#endif
26
26
#endif
27
27
28
- // FIXME: Future LLVM patches remove these 8 alignment bytes from
29
- // the function prologue in order to match gcc's behavior
30
- #define ALIGNMENT 8
31
- #define RETURN_OFFSET 7
32
-
33
28
.globl UPCALL_NEW_STACK
34
29
.globl UPCALL_DEL_STACK
35
30
.globl RUST_GET_TASK
@@ -57,17 +52,17 @@ MORESTACK:
57
52
58
53
// FIXME (1226): main is compiled with the split-stack prologue,
59
54
// causing it to call __morestack, so we have to jump back out
60
- subl $20 ,%esp
55
+ subl $28 ,%esp
61
56
calll RUST_GET_TASK
62
57
testl %eax ,%eax
63
58
jz .L$bail
64
59
65
60
// The arguments to rust_new_stack2
66
- movl 32 (%esp ),%eax // Size of stack arguments
61
+ movl 40 (%esp ),%eax // Size of stack arguments
67
62
movl %eax ,16 (%esp )
68
- leal 40 +ALIGNMENT (%esp ),%eax // Address of stack arguments
63
+ leal 48 (%esp ),%eax // Address of stack arguments
69
64
movl %eax ,12 (%esp )
70
- movl 28 (%esp ),%eax // The amount of stack needed
65
+ movl 36 (%esp ),%eax // The amount of stack needed
71
66
movl %eax ,8 (%esp )
72
67
73
68
#ifdef __APPLE__
@@ -83,8 +78,8 @@ MORESTACK:
83
78
movl %eax ,(%esp )
84
79
call UPCALL_CALL_C
85
80
86
- movl 24 (%esp ),%edx // Grab the return pointer.
87
- addl $RETURN_OFFSET, %edx // Skip past the `add esp,4` and the `ret`.
81
+ movl 32 (%esp ),%edx // Grab the return pointer.
82
+ inc %edx // Skip past the ret instruction in the parent fn
88
83
89
84
movl %eax ,%esp // Switch stacks.
90
85
call *%edx // Re-enter the function that called us.
@@ -95,6 +90,8 @@ MORESTACK:
95
90
// Switch back to the rust stack
96
91
movl %ebp , %esp
97
92
93
+ subl $8 , %esp // Alignment
94
+
98
95
#ifdef __APPLE__
99
96
call 1f
100
97
1: popl %ebx
@@ -107,17 +104,17 @@ MORESTACK:
107
104
pushl $0
108
105
call UPCALL_CALL_C
109
106
110
- addl $8 ,%esp
107
+ addl $16 ,%esp
111
108
popl %ebp
112
109
retl $8
113
110
114
111
.L$bail:
115
- movl 24 (%esp ),%edx
116
- addl $RETURN_OFFSET, %edx
112
+ movl 32 (%esp ),%edx
113
+ inc %edx
117
114
118
- addl $20 , %esp
115
+ addl $28 , %esp
119
116
popl %ebp
120
- addl $4 +8 +ALIGNMENT ,%esp
117
+ addl $4 +8 ,%esp
121
118
122
119
jmpl *%edx
123
120
0 commit comments