@@ -84,56 +84,56 @@ pub unsafe extern "C" fn __rust_probestack() {
8484
8585 core:: arch:: naked_asm!(
8686 "
87- .cfi_startproc
88- pushq %rbp
89- .cfi_adjust_cfa_offset 8
90- .cfi_offset %rbp, -16
91- movq %rsp, %rbp
92- .cfi_def_cfa_register %rbp
93-
94- mov %rax,%r11 // duplicate %rax as we're clobbering %r11
95-
96- // Main loop, taken in one page increments. We're decrementing rsp by
97- // a page each time until there's less than a page remaining. We're
98- // guaranteed that this function isn't called unless there's more than a
99- // page needed.
100- //
101- // Note that we're also testing against `8(%rsp)` to account for the 8
102- // bytes pushed on the stack orginally with our return address. Using
103- // `8(%rsp)` simulates us testing the stack pointer in the caller's
104- // context.
105-
106- // It's usually called when %rax >= 0x1000, but that's not always true.
107- // Dynamic stack allocation, which is needed to implement unsized
108- // rvalues, triggers stackprobe even if %rax < 0x1000.
109- // Thus we have to check %r11 first to avoid segfault.
110- cmp $0x1000,%r11
111- jna 3f
112- 2:
113- sub $0x1000,%rsp
114- test %rsp,8(%rsp)
115- sub $0x1000,%r11
116- cmp $0x1000,%r11
117- ja 2b
118-
119- 3:
120- // Finish up the last remaining stack space requested, getting the last
121- // bits out of r11
122- sub %r11,%rsp
123- test %rsp,8(%rsp)
124-
125- // Restore the stack pointer to what it previously was when entering
126- // this function. The caller will readjust the stack pointer after we
127- // return.
128- add %rax,%rsp
129-
130- leave
131- .cfi_def_cfa_register %rsp
132- .cfi_adjust_cfa_offset -8
87+ .cfi_startproc
88+ pushq %rbp
89+ .cfi_adjust_cfa_offset 8
90+ .cfi_offset %rbp, -16
91+ movq %rsp, %rbp
92+ .cfi_def_cfa_register %rbp
93+
94+ mov %rax,%r11 // duplicate %rax as we're clobbering %r11
95+
96+ // Main loop, taken in one page increments. We're decrementing rsp by
97+ // a page each time until there's less than a page remaining. We're
98+ // guaranteed that this function isn't called unless there's more than a
99+ // page needed.
100+ //
101+ // Note that we're also testing against `8(%rsp)` to account for the 8
102+ // bytes pushed on the stack orginally with our return address. Using
103+ // `8(%rsp)` simulates us testing the stack pointer in the caller's
104+ // context.
105+
106+ // It's usually called when %rax >= 0x1000, but that's not always true.
107+ // Dynamic stack allocation, which is needed to implement unsized
108+ // rvalues, triggers stackprobe even if %rax < 0x1000.
109+ // Thus we have to check %r11 first to avoid segfault.
110+ cmp $0x1000,%r11
111+ jna 3f
112+ 2:
113+ sub $0x1000,%rsp
114+ test %rsp,8(%rsp)
115+ sub $0x1000,%r11
116+ cmp $0x1000,%r11
117+ ja 2b
118+
119+ 3:
120+ // Finish up the last remaining stack space requested, getting the last
121+ // bits out of r11
122+ sub %r11,%rsp
123+ test %rsp,8(%rsp)
124+
125+ // Restore the stack pointer to what it previously was when entering
126+ // this function. The caller will readjust the stack pointer after we
127+ // return.
128+ add %rax,%rsp
129+
130+ leave
131+ .cfi_def_cfa_register %rsp
132+ .cfi_adjust_cfa_offset -8
133133 " ,
134134 ret!( ) ,
135135 "
136- .cfi_endproc
136+ .cfi_endproc
137137 " ,
138138 options( att_syntax)
139139 )
@@ -153,35 +153,35 @@ pub unsafe extern "C" fn __rust_probestack() {
153153pub unsafe extern "C" fn __rust_probestack ( ) {
154154 core:: arch:: naked_asm!(
155155 "
156- .cfi_startproc
157- push %ebp
158- .cfi_adjust_cfa_offset 4
159- .cfi_offset %ebp, -8
160- mov %esp, %ebp
161- .cfi_def_cfa_register %ebp
162- push %ecx
163- mov %eax,%ecx
164-
165- cmp $0x1000,%ecx
166- jna 3f
167- 2:
168- sub $0x1000,%esp
169- test %esp,8(%esp)
170- sub $0x1000,%ecx
171- cmp $0x1000,%ecx
172- ja 2b
173-
174- 3:
175- sub %ecx,%esp
176- test %esp,8(%esp)
177-
178- add %eax,%esp
179- pop %ecx
180- leave
181- .cfi_def_cfa_register %esp
182- .cfi_adjust_cfa_offset -4
183- ret
184- .cfi_endproc
156+ .cfi_startproc
157+ push %ebp
158+ .cfi_adjust_cfa_offset 4
159+ .cfi_offset %ebp, -8
160+ mov %esp, %ebp
161+ .cfi_def_cfa_register %ebp
162+ push %ecx
163+ mov %eax,%ecx
164+
165+ cmp $0x1000,%ecx
166+ jna 3f
167+ 2:
168+ sub $0x1000,%esp
169+ test %esp,8(%esp)
170+ sub $0x1000,%ecx
171+ cmp $0x1000,%ecx
172+ ja 2b
173+
174+ 3:
175+ sub %ecx,%esp
176+ test %esp,8(%esp)
177+
178+ add %eax,%esp
179+ pop %ecx
180+ leave
181+ .cfi_def_cfa_register %esp
182+ .cfi_adjust_cfa_offset -4
183+ ret
184+ .cfi_endproc
185185 " ,
186186 options( att_syntax)
187187 )
@@ -206,40 +206,40 @@ pub unsafe extern "C" fn __rust_probestack() {
206206pub unsafe extern "C" fn __rust_probestack ( ) {
207207 core:: arch:: naked_asm!(
208208 "
209- .cfi_startproc
210- push %ebp
211- .cfi_adjust_cfa_offset 4
212- .cfi_offset %ebp, -8
213- mov %esp, %ebp
214- .cfi_def_cfa_register %ebp
215- push %ecx
216- push %edx
217- mov %eax,%ecx
218-
219- cmp $0x1000,%ecx
220- jna 3f
221- 2:
222- sub $0x1000,%esp
223- test %esp,8(%esp)
224- sub $0x1000,%ecx
225- cmp $0x1000,%ecx
226- ja 2b
227-
228- 3:
229- sub %ecx,%esp
230- test %esp,8(%esp)
231- mov 4(%ebp),%edx
232- mov %edx, 12(%esp)
233- add %eax,%esp
234- pop %edx
235- pop %ecx
236- leave
237-
238- sub %eax, %esp
239- .cfi_def_cfa_register %esp
240- .cfi_adjust_cfa_offset -4
241- ret
242- .cfi_endproc
209+ .cfi_startproc
210+ push %ebp
211+ .cfi_adjust_cfa_offset 4
212+ .cfi_offset %ebp, -8
213+ mov %esp, %ebp
214+ .cfi_def_cfa_register %ebp
215+ push %ecx
216+ push %edx
217+ mov %eax,%ecx
218+
219+ cmp $0x1000,%ecx
220+ jna 3f
221+ 2:
222+ sub $0x1000,%esp
223+ test %esp,8(%esp)
224+ sub $0x1000,%ecx
225+ cmp $0x1000,%ecx
226+ ja 2b
227+
228+ 3:
229+ sub %ecx,%esp
230+ test %esp,8(%esp)
231+ mov 4(%ebp),%edx
232+ mov %edx, 12(%esp)
233+ add %eax,%esp
234+ pop %edx
235+ pop %ecx
236+ leave
237+
238+ sub %eax, %esp
239+ .cfi_def_cfa_register %esp
240+ .cfi_adjust_cfa_offset -4
241+ ret
242+ .cfi_endproc
243243 " ,
244244 options( att_syntax)
245245 )
0 commit comments