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

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

Issue 10368043: code review 10368043: runtime: do not generate code during runtime in windows... (Closed)
Patch Set: diff -r 7961b83d1d37 https://go.googlecode.com/hg/ Created 11 years, 10 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
OLDNEW
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 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 // maxargs should be divisible by 2, as Windows stack 7 // maxargs should be divisible by 2, as Windows stack
8 // must be kept 16-byte aligned on syscall entry. 8 // must be kept 16-byte aligned on syscall entry.
9 #define maxargs 16 9 #define maxargs 16
10 10
(...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after
189 get_tls(CX) 189 get_tls(CX)
190 MOVQ g(CX), CX 190 MOVQ g(CX), CX
191 MOVQ g_stackbase(CX), SP 191 MOVQ g_stackbase(CX), SP
192 POPQ 0x28(GS) 192 POPQ 0x28(GS)
193 POPQ DI 193 POPQ DI
194 POPQ SI 194 POPQ SI
195 POPQ BX 195 POPQ BX
196 POPQ BP 196 POPQ BP
197 RET 197 RET
198 198
199 // Continuation of thunk function created for each callback by ../thread.c compi lecallback, 199 GLOBL runtime·cbctxts(SB), $8
200 // runs on Windows stack (not Go stack). 200
201 // Thunk code designed to have minimal size for it is copied many (up to thousan ds) times. 201 TEXT runtime·callbackasm1(SB),7,$0
202 //
203 // thunk:
204 //» MOVQ» $fn, AX
205 //» PUSHQ» AX
206 //» MOVQ» $argsize, AX
207 //» PUSHQ» AX
208 //» MOVQ» $runtime·callbackasm, AX
209 //» JMP» AX
210 TEXT runtime·callbackasm(SB),7,$0
211 // Construct args vector for cgocallback(). 202 // Construct args vector for cgocallback().
212 // By windows/amd64 calling convention first 4 args are in CX, DX, R8, R 9 203 // By windows/amd64 calling convention first 4 args are in CX, DX, R8, R 9
213 // args from the 5th on are on the stack. 204 // args from the 5th on are on the stack.
214 // In any case, even if function has 0,1,2,3,4 args, there is reserved 205 // In any case, even if function has 0,1,2,3,4 args, there is reserved
215 // but uninitialized "shadow space" for the first 4 args. 206 // but uninitialized "shadow space" for the first 4 args.
216 // The values are in registers. 207 // The values are in registers.
217 » MOVQ» CX, (24+0)(SP) 208 » MOVQ» CX, (16+0)(SP)
218 » MOVQ» DX, (24+8)(SP) 209 » MOVQ» DX, (16+8)(SP)
219 » MOVQ» R8, (24+16)(SP) 210 » MOVQ» R8, (16+16)(SP)
220 » MOVQ» R9, (24+24)(SP) 211 » MOVQ» R9, (16+24)(SP)
221 » // 6l does not accept writing POPQs here issuing a warning "unbalanced P USH/POP" 212
222 » MOVQ» 0(SP), DX» // POPQ DX 213 » // remove return address from stack, we are not returning there
223 » MOVQ» 8(SP), AX» // POPQ AX 214 » MOVQ» 0(SP), AX
224 » ADDQ» $16, SP 215 » ADDQ» $8, SP
216
217 » // determine index into runtime·cbctxts table
218 » SUBQ» $runtime·callbackasm(SB), AX
219 » MOVQ» $0, DX
220 » MOVQ» $5, CX» // divide by 5 because each call instruction in runtime· callbacks is 5 bytes long
221 » DIVL» CX,
222 » SUBQ» $1, AX
223
224 » // find correspondent runtime·cbctxts table entry
225 » MOVQ» $8, DX
226 » MULL» DX
227 » ADDQ» runtime·cbctxts(SB), AX
228 » MOVQ» (AX), AX
minux1 2013/06/18 07:58:24 same
brainman 2013/06/19 07:11:25 Used SHLQ here.
229
230 » // extract callback context
231 » MOVQ» cbctxt_argsize(AX), DX
232 » MOVQ» cbctxt_gobody(AX), AX
225 233
226 // preserve whatever's at the memory location that 234 // preserve whatever's at the memory location that
227 // the callback will use to store the return value 235 // the callback will use to store the return value
228 LEAQ 8(SP), CX // args vector, skip return address 236 LEAQ 8(SP), CX // args vector, skip return address
229 PUSHQ 0(CX)(DX*1) // store 8 bytes from just after the args array 237 PUSHQ 0(CX)(DX*1) // store 8 bytes from just after the args array
230 ADDQ $8, DX // extend argsize by size of return value 238 ADDQ $8, DX // extend argsize by size of return value
231 239
232 // DI SI BP BX R12 R13 R14 R15 registers and DF flag are preserved 240 // DI SI BP BX R12 R13 R14 R15 registers and DF flag are preserved
233 // as required by windows callback convention. 241 // as required by windows callback convention.
234 // 6l does not allow writing many PUSHQs here issuing a warning "nosplit stack overflow"
235 // the warning has no sense as this code uses os thread stack
236 PUSHFQ 242 PUSHFQ
237 SUBQ $64, SP 243 SUBQ $64, SP
238 MOVQ DI, 56(SP) 244 MOVQ DI, 56(SP)
239 MOVQ SI, 48(SP) 245 MOVQ SI, 48(SP)
240 MOVQ BP, 40(SP) 246 MOVQ BP, 40(SP)
241 MOVQ BX, 32(SP) 247 MOVQ BX, 32(SP)
242 MOVQ R12, 24(SP) 248 MOVQ R12, 24(SP)
243 MOVQ R13, 16(SP) 249 MOVQ R13, 16(SP)
244 MOVQ R14, 8(SP) 250 MOVQ R14, 8(SP)
245 MOVQ R15, 0(SP) 251 MOVQ R15, 0(SP)
246 252
247 // prepare call stack. use SUBQ to hide from stack frame checks 253 // prepare call stack. use SUBQ to hide from stack frame checks
248 // cgocallback(Go func, void *frame, uintptr framesize) 254 // cgocallback(Go func, void *frame, uintptr framesize)
249 SUBQ $24, SP 255 SUBQ $24, SP
250 » MOVQ» DX, 16(SP)» // uintptr framesize 256 » MOVQ» DX, 16(SP)» // argsize (including return value)
251 » MOVQ» CX, 8(SP) // void *frame 257 » MOVQ» CX, 8(SP)» // callback parameters
252 » MOVQ» AX, 0(SP) // Go func 258 » MOVQ» AX, 0(SP)» // address of target Go function
253 CLD 259 CLD
254 » CALL runtime·cgocallback_gofunc(SB) 260 » CALL» runtime·cgocallback_gofunc(SB)
255 MOVQ 0(SP), AX 261 MOVQ 0(SP), AX
256 MOVQ 8(SP), CX 262 MOVQ 8(SP), CX
257 MOVQ 16(SP), DX 263 MOVQ 16(SP), DX
258 ADDQ $24, SP 264 ADDQ $24, SP
259 265
260 // restore registers as required for windows callback 266 // restore registers as required for windows callback
261 // 6l does not allow writing many POPs here issuing a warning "nosplit s tack overflow"
262 MOVQ 0(SP), R15 267 MOVQ 0(SP), R15
263 MOVQ 8(SP), R14 268 MOVQ 8(SP), R14
264 MOVQ 16(SP), R13 269 MOVQ 16(SP), R13
265 MOVQ 24(SP), R12 270 MOVQ 24(SP), R12
266 MOVQ 32(SP), BX 271 MOVQ 32(SP), BX
267 MOVQ 40(SP), BP 272 MOVQ 40(SP), BP
268 MOVQ 48(SP), SI 273 MOVQ 48(SP), SI
269 MOVQ 56(SP), DI 274 MOVQ 56(SP), DI
270 ADDQ $64, SP 275 ADDQ $64, SP
271 POPFQ 276 POPFQ
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 // Have 1us units; want negative 100ns units. 349 // Have 1us units; want negative 100ns units.
345 MOVL usec+0(FP), BX 350 MOVL usec+0(FP), BX
346 IMULQ $10, BX 351 IMULQ $10, BX
347 NEGQ BX 352 NEGQ BX
348 MOVQ SP, R8 // ptime 353 MOVQ SP, R8 // ptime
349 MOVQ BX, (R8) 354 MOVQ BX, (R8)
350 MOVQ $-1, CX // handle 355 MOVQ $-1, CX // handle
351 MOVQ $0, DX // alertable 356 MOVQ $0, DX // alertable
352 CALL AX 357 CALL AX
353 RET 358 RET
OLDNEW
« src/pkg/runtime/sys_windows_386.s ('K') | « src/pkg/runtime/sys_windows_386.s ('k') | no next file » | no next file with comments »

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