Left: | ||
Right: |
LEFT | RIGHT |
---|---|
(no file at all) | |
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 #include "../../cmd/ld/textflag.h" | 6 #include "../../cmd/ld/textflag.h" |
7 | 7 |
8 // void runtime·asmstdcall(void *c); | 8 // void runtime·asmstdcall(void *c); |
9 TEXT runtime·asmstdcall(SB),NOSPLIT,$0 | 9 TEXT runtime·asmstdcall(SB),NOSPLIT,$0 |
10 MOVL c+0(FP), BX | 10 MOVL c+0(FP), BX |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
62 // faster get/set last error | 62 // faster get/set last error |
63 TEXT runtime·getlasterror(SB),NOSPLIT,$0 | 63 TEXT runtime·getlasterror(SB),NOSPLIT,$0 |
64 MOVL 0x34(FS), AX | 64 MOVL 0x34(FS), AX |
65 RET | 65 RET |
66 | 66 |
67 TEXT runtime·setlasterror(SB),NOSPLIT,$0 | 67 TEXT runtime·setlasterror(SB),NOSPLIT,$0 |
68 MOVL err+0(FP), AX | 68 MOVL err+0(FP), AX |
69 MOVL AX, 0x34(FS) | 69 MOVL AX, 0x34(FS) |
70 RET | 70 RET |
71 | 71 |
72 TEXT runtime·sigtramp(SB),NOSPLIT,$28 | 72 // Called by Windows as a Vectored Exception Handler (VEH). |
73 » // unwinding? | 73 // First argument is pointer to struct containing |
74 » MOVL» info+0(FP), CX | 74 // exception record and context pointers. |
75 » TESTL» $6, 4(CX)» » // exception flags | 75 // Return 0 for 'not handled', -1 for handled. |
76 » MOVL» $1, AX | 76 TEXT runtime·sigtramp(SB),NOSPLIT,$0-0 |
77 » JNZ» sigdone | 77 » MOVL» ptrs+0(FP), DI |
78 | 78 » SUBL» $28, SP |
79 » // copy arguments for call to sighandler | 79 » MOVL» 0(DI), BX // ExceptionRecord* |
brainman
2014/03/25 03:12:45
Should you be using BX here, if it is callee-saved
rsc
2014/03/25 14:58:05
Good point. Probably not. Perhaps that is causing
| |
80 » MOVL» CX, 0(SP) | 80 » MOVL» 4(DI), CX // Context* |
81 » MOVL» context+8(FP), CX | 81 |
82 » MOVL» CX, 4(SP) | 82 » // Only handle exception if executing instructions in Go binary |
83 | 83 » // (not Windows library code). Except don't - keep reading. |
84 » get_tls(CX) | 84 » //· |
85 | 85 » // This sounds like a good idea but the tracebacks that |
86 » // check that m exists | 86 » // Go provides are better than the Windows crash dialog, |
87 » MOVL» m(CX), AX | 87 » // especially if it's something that Go needs to do. |
88 » CMPL» AX, $0 | 88 » // So take all the exceptions, not just the ones at Go PCs. |
89 » JNE» 2(PC) | 89 » // If you re-enable this check by removing the JMP, you will |
90 » CALL» runtime·badsignal2(SB) | 90 » // need to arrange to handle exception 0x40010006 during |
91 | 91 » // non-Go code here. Right now that case is handled by sighandler |
92 » MOVL» g(CX), CX | 92 » // in os_windows_386.c. |
93 » MOVL» CX, 8(SP) | 93 » JMP skipcheckpc |
94 | 94 » MOVL» $0, AX |
95 » MOVL» 184(CX), DX // saved PC | |
96 » CMPL» DX, $text(SB) | |
97 » JB» vehret | |
98 » CMPL» DX, $etext(SB) | |
99 » JA» vehret | |
100 | |
101 skipcheckpc: | |
102 » // save callee-saved registers | |
95 MOVL BX, 12(SP) | 103 MOVL BX, 12(SP) |
96 MOVL BP, 16(SP) | 104 MOVL BP, 16(SP) |
97 MOVL SI, 20(SP) | 105 MOVL SI, 20(SP) |
98 MOVL DI, 24(SP) | 106 MOVL DI, 24(SP) |
99 | 107 |
108 // fetch g | |
109 get_tls(DX) | |
110 MOVL m(DX), AX | |
111 CMPL AX, $0 | |
112 JNE 2(PC) | |
113 CALL runtime·badsignal2(SB) | |
114 MOVL g(DX), DX | |
115 // call sighandler(ExceptionRecord*, Context*, G*) | |
116 MOVL BX, 0(SP) | |
117 MOVL CX, 4(SP) | |
118 MOVL DX, 8(SP) | |
100 CALL runtime·sighandler(SB) | 119 CALL runtime·sighandler(SB) |
101 » // AX is set to report result back to Windows | 120 |
102 | 121 » // restore callee-saved registers |
103 MOVL 24(SP), DI | 122 MOVL 24(SP), DI |
104 MOVL 20(SP), SI | 123 MOVL 20(SP), SI |
105 MOVL 16(SP), BP | 124 MOVL 16(SP), BP |
106 MOVL 12(SP), BX | 125 MOVL 12(SP), BX |
107 sigdone: | 126 |
108 » RET | 127 vehret: |
128 » ADDL» $28, SP | |
129 » // RET 4 (return and pop 4 bytes parameters) | |
130 » BYTE $0xC2; WORD $4 | |
131 » RET // unreached; make assembler happy | |
109 | 132 |
110 TEXT runtime·ctrlhandler(SB),NOSPLIT,$0 | 133 TEXT runtime·ctrlhandler(SB),NOSPLIT,$0 |
111 PUSHL $runtime·ctrlhandler1(SB) | 134 PUSHL $runtime·ctrlhandler1(SB) |
112 CALL runtime·externalthreadhandler(SB) | 135 CALL runtime·externalthreadhandler(SB) |
113 MOVL 4(SP), CX | 136 MOVL 4(SP), CX |
114 ADDL $12, SP | 137 ADDL $12, SP |
115 JMP CX | 138 JMP CX |
116 | 139 |
117 TEXT runtime·profileloop(SB),NOSPLIT,$0 | 140 TEXT runtime·profileloop(SB),NOSPLIT,$0 |
118 PUSHL $runtime·profileloop1(SB) | 141 PUSHL $runtime·profileloop1(SB) |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
174 ADDL $4, SP | 197 ADDL $4, SP |
175 | 198 |
176 // address to callback parameters into CX | 199 // address to callback parameters into CX |
177 LEAL 4(SP), CX | 200 LEAL 4(SP), CX |
178 | 201 |
179 // save registers as required for windows callback | 202 // save registers as required for windows callback |
180 PUSHL DI | 203 PUSHL DI |
181 PUSHL SI | 204 PUSHL SI |
182 PUSHL BP | 205 PUSHL BP |
183 PUSHL BX | 206 PUSHL BX |
184 | |
185 // set up SEH frame again | |
186 PUSHL $runtime·sigtramp(SB) | |
187 PUSHL 0(FS) | |
188 MOVL SP, 0(FS) | |
189 | 207 |
190 // determine index into runtime·cbctxts table | 208 // determine index into runtime·cbctxts table |
191 SUBL $runtime·callbackasm(SB), AX | 209 SUBL $runtime·callbackasm(SB), AX |
192 MOVL $0, DX | 210 MOVL $0, DX |
193 MOVL $5, BX // divide by 5 because each call instruction in runtime· callbacks is 5 bytes long | 211 MOVL $5, BX // divide by 5 because each call instruction in runtime· callbacks is 5 bytes long |
194 DIVL BX, | 212 DIVL BX, |
195 | 213 |
196 // find correspondent runtime·cbctxts table entry | 214 // find correspondent runtime·cbctxts table entry |
197 MOVL runtime·cbctxts(SB), BX | 215 MOVL runtime·cbctxts(SB), BX |
198 MOVL -4(BX)(AX*4), BX | 216 MOVL -4(BX)(AX*4), BX |
(...skipping 26 matching lines...) Expand all Loading... | |
225 // how to restore stack on return | 243 // how to restore stack on return |
226 POPL BX | 244 POPL BX |
227 | 245 |
228 // return value into AX (as per Windows spec) | 246 // return value into AX (as per Windows spec) |
229 // and restore previously preserved value | 247 // and restore previously preserved value |
230 MOVL -4(CX)(DX*1), AX | 248 MOVL -4(CX)(DX*1), AX |
231 POPL -4(CX)(DX*1) | 249 POPL -4(CX)(DX*1) |
232 | 250 |
233 MOVL BX, CX // cannot use BX anymore | 251 MOVL BX, CX // cannot use BX anymore |
234 | 252 |
235 // pop SEH frame | |
236 POPL 0(FS) | |
237 POPL BX | |
238 | |
239 // restore registers as required for windows callback | 253 // restore registers as required for windows callback |
240 POPL BX | 254 POPL BX |
241 POPL BP | 255 POPL BP |
242 POPL SI | 256 POPL SI |
243 POPL DI | 257 POPL DI |
244 | 258 |
245 // remove callback parameters before return (as per Windows spec) | 259 // remove callback parameters before return (as per Windows spec) |
246 POPL DX | 260 POPL DX |
247 ADDL CX, SP | 261 ADDL CX, SP |
248 PUSHL DX | 262 PUSHL DX |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
294 RET | 308 RET |
295 | 309 |
296 // setldt(int entry, int address, int limit) | 310 // setldt(int entry, int address, int limit) |
297 TEXT runtime·setldt(SB),NOSPLIT,$0 | 311 TEXT runtime·setldt(SB),NOSPLIT,$0 |
298 MOVL address+4(FP), CX | 312 MOVL address+4(FP), CX |
299 MOVL CX, 0x14(FS) | 313 MOVL CX, 0x14(FS) |
300 RET | 314 RET |
301 | 315 |
302 // void install_exception_handler() | 316 // void install_exception_handler() |
303 TEXT runtime·install_exception_handler(SB),NOSPLIT,$0 | 317 TEXT runtime·install_exception_handler(SB),NOSPLIT,$0 |
304 get_tls(CX) | |
305 MOVL m(CX), CX // m | |
306 | |
307 // Set up SEH frame | |
308 MOVL m_seh(CX), DX | |
309 MOVL $runtime·sigtramp(SB), AX | |
310 MOVL AX, seh_handler(DX) | |
311 MOVL 0(FS), AX | |
312 MOVL AX, seh_prev(DX) | |
313 | |
314 // Install it | |
315 MOVL DX, 0(FS) | |
316 | |
317 RET | 318 RET |
318 | 319 |
319 // void remove_exception_handler() | 320 // void remove_exception_handler() |
320 TEXT runtime·remove_exception_handler(SB),NOSPLIT,$0 | 321 TEXT runtime·remove_exception_handler(SB),NOSPLIT,$0 |
321 get_tls(CX) | |
322 MOVL m(CX), CX // m | |
323 | |
324 // Remove SEH frame | |
325 MOVL m_seh(CX), DX | |
326 MOVL seh_prev(DX), AX | |
327 MOVL AX, 0(FS) | |
328 | |
329 RET | 322 RET |
330 | 323 |
331 // Sleep duration is in 100ns units. | 324 // Sleep duration is in 100ns units. |
332 TEXT runtime·usleep1(SB),NOSPLIT,$0 | 325 TEXT runtime·usleep1(SB),NOSPLIT,$0 |
333 MOVL duration+0(FP), BX | 326 MOVL duration+0(FP), BX |
334 MOVL $runtime·usleep2(SB), AX // to hide from 8l | 327 MOVL $runtime·usleep2(SB), AX // to hide from 8l |
335 | 328 |
336 // Execute call on m->g0 stack, in case we are not actually | 329 // Execute call on m->g0 stack, in case we are not actually |
337 // calling a system call wrapper, like when running under WINE. | 330 // calling a system call wrapper, like when running under WINE. |
338 get_tls(CX) | 331 get_tls(CX) |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
383 MOVL BX, lo-8(SP) | 376 MOVL BX, lo-8(SP) |
384 LEAL lo-8(SP), BX | 377 LEAL lo-8(SP), BX |
385 MOVL BX, ptime-12(SP) | 378 MOVL BX, ptime-12(SP) |
386 MOVL $0, alertable-16(SP) | 379 MOVL $0, alertable-16(SP) |
387 MOVL $-1, handle-20(SP) | 380 MOVL $-1, handle-20(SP) |
388 MOVL SP, BP | 381 MOVL SP, BP |
389 MOVL runtime·NtWaitForSingleObject(SB), AX | 382 MOVL runtime·NtWaitForSingleObject(SB), AX |
390 CALL AX | 383 CALL AX |
391 MOVL BP, SP | 384 MOVL BP, SP |
392 RET | 385 RET |
393 | |
394 TEXT runtime·getseh(SB),NOSPLIT,$0 | |
395 MOVL 0(FS), AX | |
396 RET | |
397 | |
398 TEXT runtime·setseh(SB),NOSPLIT,$0 | |
399 MOVL seh+0(FP), AX | |
400 MOVL AX, 0(FS) | |
401 RET | |
402 | |
LEFT | RIGHT |