Skip to content

Commit 6d33103

Browse files
committed
---
yaml --- r: 6563 b: refs/heads/master c: 292663b h: refs/heads/master i: 6561: 07ee463 6559: 8d67489 v: v3
1 parent 073c176 commit 6d33103

File tree

3 files changed

+64
-22
lines changed

3 files changed

+64
-22
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
---
2-
refs/heads/master: c254936f326061e98414a668d2fd8a7bee01bbb7
2+
refs/heads/master: 292663b8ef3f688e90bd5a8bd49f46288639b158

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

Lines changed: 54 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -5,18 +5,24 @@
55
// LLVM generates a call to this to allocate more stack space in a function
66
// prolog when we run out.
77

8-
#if defined(__APPLE__) || defined(_WIN32)
9-
#define UPCALL_NEW_STACK _upcall_new_stack
10-
#define UPCALL_DEL_STACK _upcall_del_stack
11-
#define RUST_GET_TASK _rust_get_task
12-
#define UPCALL_CALL_C _upcall_call_shim_on_c_stack
8+
#if defined(__APPLE__)
9+
#define RUST_GET_TASK L_rust_get_task$stub
10+
#define UPCALL_CALL_C L_upcall_call_shim_on_c_stack$stub
1311
#define MORESTACK ___morestack
1412
#else
13+
#if defined(__linux__)
1514
#define UPCALL_NEW_STACK upcall_new_stack
1615
#define UPCALL_DEL_STACK upcall_del_stack
1716
#define RUST_GET_TASK rust_get_task
1817
#define UPCALL_CALL_C upcall_call_shim_on_c_stack
1918
#define MORESTACK __morestack
19+
#else
20+
#define UPCALL_NEW_STACK _upcall_new_stack
21+
#define UPCALL_DEL_STACK _upcall_del_stack
22+
#define RUST_GET_TASK _rust_get_task
23+
#define UPCALL_CALL_C _upcall_call_shim_on_c_stack
24+
#define MORESTACK __morestack
25+
#endif
2026
#endif
2127

2228
// FIXME: Future LLVM patches remove these 8 alignment bytes from
@@ -43,33 +49,41 @@
4349
.type MORESTACK,@function
4450
#endif
4551

46-
#if defined(__linux__)
52+
#if defined(__linux__) || defined(__APPLE__)
4753
MORESTACK:
4854

4955
pushl %ebp
5056
movl %esp, %ebp
5157

5258
// FIXME (1226): main is compiled with the split-stack prologue,
5359
// causing it to call __morestack, so we have to jump back out
54-
subl $24,%esp
60+
subl $20,%esp
5561
calll RUST_GET_TASK
5662
testl %eax,%eax
5763
jz .L$bail
5864

5965
// The arguments to rust_new_stack2
60-
movl 36(%esp),%eax // Size of stack arguments
66+
movl 32(%esp),%eax // Size of stack arguments
6167
movl %eax,16(%esp)
62-
leal 44+ALIGNMENT(%esp),%eax // Address of stack arguments
68+
leal 40+ALIGNMENT(%esp),%eax // Address of stack arguments
6369
movl %eax,12(%esp)
64-
movl 32(%esp),%eax // The amount of stack needed
70+
movl 28(%esp),%eax // The amount of stack needed
6571
movl %eax,8(%esp)
6672

73+
#ifdef __APPLE__
74+
call 1f
75+
1: popl %ebx
76+
movl L_upcall_new_stack$non_lazy_ptr-1b(%ebx),%ecx
77+
movl %ecx, 4(%esp)
78+
#else
6779
movl $UPCALL_NEW_STACK,4(%esp)
80+
#endif
81+
6882
leal 8(%esp), %eax
6983
movl %eax,(%esp)
7084
call UPCALL_CALL_C
7185

72-
movl 28(%esp),%edx // Grab the return pointer.
86+
movl 24(%esp),%edx // Grab the return pointer.
7387
addl $RETURN_OFFSET,%edx // Skip past the `add esp,4` and the `ret`.
7488

7589
movl %eax,%esp // Switch stacks.
@@ -81,7 +95,15 @@ MORESTACK:
8195
// Switch back to the rust stack
8296
movl %ebp, %esp
8397

98+
#ifdef __APPLE__
99+
call 1f
100+
1: popl %ebx
101+
movl L_upcall_del_stack$non_lazy_ptr-1b(%ebx),%ecx
102+
pushl %ecx
103+
#else
84104
pushl $UPCALL_DEL_STACK
105+
#endif
106+
85107
pushl $0
86108
call UPCALL_CALL_C
87109

@@ -90,10 +112,10 @@ MORESTACK:
90112
retl $8
91113

92114
.L$bail:
93-
movl 28(%esp),%edx
115+
movl 24(%esp),%edx
94116
addl $RETURN_OFFSET,%edx
95117

96-
addl $24, %esp
118+
addl $20, %esp
97119
popl %ebp
98120
addl $4+8+ALIGNMENT,%esp
99121

@@ -107,13 +129,25 @@ MORESTACK:
107129

108130
#ifdef __APPLE__
109131

110-
.section __IMPORT,__pointers,non_lazy_symbol_pointers
111-
rust_new_stack_sym:
112-
.indirect_symbol RUST_NEW_STACK
113-
.long 0
114-
rust_del_stack_sym:
115-
.indirect_symbol RUST_DEL_STACK
116-
.long 0
132+
.section __IMPORT,__pointers,non_lazy_symbol_pointers
133+
L_upcall_new_stack$non_lazy_ptr:
134+
.indirect_symbol _upcall_new_stack
135+
.long 0
136+
L_upcall_del_stack$non_lazy_ptr:
137+
.indirect_symbol _upcall_del_stack
138+
.long 0
139+
140+
.section __IMPORT,__jump_table,symbol_stubs,pure_instructions+self_modifying_code,5
141+
142+
// Linker will replace the hlts (the ascii) with jmp
143+
L_rust_get_task$stub:
144+
.indirect_symbol _rust_get_task
145+
.ascii "\364\364\364\364\364"
146+
147+
L_upcall_call_shim_on_c_stack$stub:
148+
.indirect_symbol _upcall_call_shim_on_c_stack
149+
.ascii "\364\364\364\364\364"
117150

151+
.subsections_via_symbols
118152
#endif
119153

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

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,14 @@ RECORD_SP:
1414
movl %eax, %gs:48
1515
ret
1616
#else
17+
#if defined(__APPLE__)
1718
RECORD_SP:
19+
movl $0x48+90*4, %eax
20+
movl 4(%esp), %ecx
21+
movl %ecx, %gs:(%eax)
1822
ret
19-
#endif
23+
#else
24+
RECORD_SP:
25+
ret
26+
#endif
27+
#endif

0 commit comments

Comments
 (0)