Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(37)

Side by Side Diff: src/pkg/runtime/sys_windows_386.s

Issue 10368043: code review 10368043: runtime: do not generate code during runtime in windows... (Closed)
Patch Set: diff -r 4f94a7de7c59 https://go.googlecode.com/hg/ Created 11 years, 9 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/pkg/runtime/runtime.h ('k') | src/pkg/runtime/sys_windows_amd64.s » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2009 The Go Authors. All rights reserved. 1 // Copyright 2009 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 #include "zasm_GOOS_GOARCH.h" 5 #include "zasm_GOOS_GOARCH.h"
6 6
7 // void runtime·asmstdcall(void *c); 7 // void runtime·asmstdcall(void *c);
8 TEXT runtime·asmstdcall(SB),7,$0 8 TEXT runtime·asmstdcall(SB),7,$0
9 MOVL c+0(FP), BX 9 MOVL c+0(FP), BX
10 10
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after
157 get_tls(CX) 157 get_tls(CX)
158 MOVL g(CX), CX 158 MOVL g(CX), CX
159 MOVL g_stackbase(CX), SP 159 MOVL g_stackbase(CX), SP
160 POPL 0x14(FS) 160 POPL 0x14(FS)
161 POPL DI 161 POPL DI
162 POPL SI 162 POPL SI
163 POPL BX 163 POPL BX
164 POPL BP 164 POPL BP
165 RET 165 RET
166 166
167 // Called from dynamic function created by ../thread.c compilecallback, 167 GLOBL runtime·cbctxts(SB), $4
168 // running on Windows stack (not Go stack). 168
169 // BX, BP, SI, DI registers and DF flag are preserved 169 TEXT runtime·callbackasm1+0(SB),7,$0
170 // as required by windows callback convention. 170 » MOVL» 0(SP), AX» // will use to find our callback context
171 // AX = address of go func we need to call 171
172 // DX = total size of arguments 172 » // remove return address from stack, we are not returning there
173 // 173 » ADDL» $4, SP
174 TEXT runtime·callbackasm+0(SB),7,$0 174
175 » // preserve whatever's at the memory location that 175 » // address to callback parameters into CX
176 » // the callback will use to store the return value 176 » LEAL» 4(SP), CX
177 » LEAL» 8(SP), CX
178 » PUSHL» 0(CX)(DX*1)
179 » ADDL» $4, DX» » » // extend argsize by size of return valu e
180 177
181 // save registers as required for windows callback 178 // save registers as required for windows callback
182 PUSHL DI 179 PUSHL DI
183 PUSHL SI 180 PUSHL SI
184 PUSHL BP 181 PUSHL BP
185 PUSHL BX 182 PUSHL BX
186 183
187 // set up SEH frame again 184 // set up SEH frame again
188 PUSHL $runtime·sigtramp(SB) 185 PUSHL $runtime·sigtramp(SB)
189 PUSHL 0(FS) 186 PUSHL 0(FS)
190 MOVL SP, 0(FS) 187 MOVL SP, 0(FS)
191 188
192 » // callback parameters 189 » // determine index into runtime·cbctxts table
193 » PUSHL» DX 190 » SUBL» $runtime·callbackasm(SB), AX
194 » PUSHL» CX 191 » MOVL» $0, DX
195 » PUSHL» AX 192 » MOVL» $5, BX» // divide by 5 because each call instruction in runtime· callbacks is 5 bytes long
193 » DIVL» BX,
196 194
195 // find correspondent runtime·cbctxts table entry
196 MOVL runtime·cbctxts(SB), BX
197 MOVL -4(BX)(AX*4), BX
198
199 // extract callback context
200 MOVL cbctxt_gobody(BX), AX
201 MOVL cbctxt_argsize(BX), DX
202
203 // preserve whatever's at the memory location that
204 // the callback will use to store the return value
205 PUSHL 0(CX)(DX*1)
206
207 // extend argsize by size of return value
208 ADDL $4, DX
209
210 // remember how to restore stack on return
211 MOVL cbctxt_restorestack(BX), BX
212 PUSHL BX
213
214 // call target Go function
215 PUSHL DX // argsize (including return value)
216 PUSHL CX // callback parameters
217 PUSHL AX // address of target Go function
197 CLD 218 CLD
198
199 CALL runtime·cgocallback_gofunc(SB) 219 CALL runtime·cgocallback_gofunc(SB)
200
201 POPL AX 220 POPL AX
202 POPL CX 221 POPL CX
203 POPL DX 222 POPL DX
204 223
224 // how to restore stack on return
225 POPL BX
226
227 // return value into AX (as per Windows spec)
228 // and restore previously preserved value
229 MOVL -4(CX)(DX*1), AX
230 POPL -4(CX)(DX*1)
231
232 MOVL BX, CX // cannot use BX anymore
233
205 // pop SEH frame 234 // pop SEH frame
206 POPL 0(FS) 235 POPL 0(FS)
207 POPL BX 236 POPL BX
208 237
209 // restore registers as required for windows callback 238 // restore registers as required for windows callback
210 POPL BX 239 POPL BX
211 POPL BP 240 POPL BP
212 POPL SI 241 POPL SI
213 POPL DI 242 POPL DI
214 243
244 // remove callback parameters before return (as per Windows spec)
245 POPL DX
246 ADDL CX, SP
247 PUSHL DX
248
215 CLD 249 CLD
216 250
217 MOVL -4(CX)(DX*1), AX
218 POPL -4(CX)(DX*1)
219 RET 251 RET
220 252
221 // void tstart(M *newm); 253 // void tstart(M *newm);
222 TEXT runtime·tstart(SB),7,$0 254 TEXT runtime·tstart(SB),7,$0
223 MOVL newm+4(SP), CX // m 255 MOVL newm+4(SP), CX // m
224 MOVL m_g0(CX), DX // g 256 MOVL m_g0(CX), DX // g
225 257
226 // Layout new m scheduler stack on os stack. 258 // Layout new m scheduler stack on os stack.
227 MOVL SP, AX 259 MOVL SP, AX
228 MOVL AX, g_stackbase(DX) 260 MOVL AX, g_stackbase(DX)
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
330 MOVL BP, SP 362 MOVL BP, SP
331 RET 363 RET
332 364
333 // This function requires 4 bytes of stack, 365 // This function requires 4 bytes of stack,
334 // to simulate what calling NtWaitForSingleObject will use. 366 // to simulate what calling NtWaitForSingleObject will use.
335 // (It is just a CALL to the system call dispatch.) 367 // (It is just a CALL to the system call dispatch.)
336 // If the linker okays the call to checkstack4 (a NOSPLIT function) 368 // If the linker okays the call to checkstack4 (a NOSPLIT function)
337 // then the call to NtWaitForSingleObject is okay too. 369 // then the call to NtWaitForSingleObject is okay too.
338 TEXT checkstack4<>(SB),7,$4 370 TEXT checkstack4<>(SB),7,$4
339 RET 371 RET
OLDNEW
« no previous file with comments | « src/pkg/runtime/runtime.h ('k') | src/pkg/runtime/sys_windows_amd64.s » ('j') | no next file with comments »

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b