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 | 6 |
7 TEXT _rt0_amd64(SB),7,$-8 | 7 TEXT _rt0_amd64(SB),7,$-8 |
8 // copy arguments forward on an even stack | 8 // copy arguments forward on an even stack |
9 MOVQ 0(DI), AX // argc | 9 MOVQ 0(DI), AX // argc |
10 LEAQ 8(DI), BX // argv | 10 LEAQ 8(DI), BX // argv |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
114 MOVQ 16(SP), AX // return 2nd arg | 114 MOVQ 16(SP), AX // return 2nd arg |
115 MOVQ 8(SP), BX // gobuf | 115 MOVQ 8(SP), BX // gobuf |
116 MOVQ gobuf_g(BX), DX | 116 MOVQ gobuf_g(BX), DX |
117 MOVQ 0(DX), CX // make sure g != nil | 117 MOVQ 0(DX), CX // make sure g != nil |
118 get_tls(CX) | 118 get_tls(CX) |
119 MOVQ DX, g(CX) | 119 MOVQ DX, g(CX) |
120 MOVQ gobuf_sp(BX), SP // restore SP | 120 MOVQ gobuf_sp(BX), SP // restore SP |
121 MOVQ gobuf_pc(BX), BX | 121 MOVQ gobuf_pc(BX), BX |
122 JMP BX | 122 JMP BX |
123 | 123 |
124 // void gogocall(Gobuf*, void (*fn)(void)) | 124 // void gogocall(Gobuf*, void (*fn)(void), uintptr r0) |
125 // restore state from Gobuf but then call fn. | 125 // restore state from Gobuf but then call fn. |
126 // (call fn, returning to state in Gobuf) | 126 // (call fn, returning to state in Gobuf) |
127 TEXT runtime·gogocall(SB), 7, $0 | 127 TEXT runtime·gogocall(SB), 7, $0 |
| 128 MOVQ 24(SP), DX // context |
128 MOVQ 16(SP), AX // fn | 129 MOVQ 16(SP), AX // fn |
129 MOVQ 8(SP), BX // gobuf | 130 MOVQ 8(SP), BX // gobuf |
130 » MOVQ» gobuf_g(BX), DX | 131 » MOVQ» gobuf_g(BX), DI |
131 » get_tls(CX) | 132 » get_tls(CX) |
132 » MOVQ» DX, g(CX) | 133 » MOVQ» DI, g(CX) |
133 » MOVQ» 0(DX), CX» // make sure g != nil | 134 » MOVQ» 0(DI), CX» // make sure g != nil |
134 MOVQ gobuf_sp(BX), SP // restore SP | 135 MOVQ gobuf_sp(BX), SP // restore SP |
135 MOVQ gobuf_pc(BX), BX | 136 MOVQ gobuf_pc(BX), BX |
136 PUSHQ BX | 137 PUSHQ BX |
137 JMP AX | 138 JMP AX |
138 POPQ BX // not reached | 139 POPQ BX // not reached |
139 | 140 |
140 // void gogocallfn(Gobuf*, FuncVal*) | 141 // void gogocallfn(Gobuf*, FuncVal*) |
141 // restore state from Gobuf but then call fn. | 142 // restore state from Gobuf but then call fn. |
142 // (call fn, returning to state in Gobuf) | 143 // (call fn, returning to state in Gobuf) |
143 TEXT runtime·gogocallfn(SB), 7, $0 | 144 TEXT runtime·gogocallfn(SB), 7, $0 |
144 » MOVQ» 16(SP), AX» » // fn | 145 » MOVQ» 16(SP), DX» » // fn |
145 MOVQ 8(SP), BX // gobuf | 146 MOVQ 8(SP), BX // gobuf |
146 » MOVQ» gobuf_g(BX), DX | 147 » MOVQ» gobuf_g(BX), AX |
147 » get_tls(CX) | 148 » get_tls(CX) |
148 » MOVQ» DX, g(CX) | 149 » MOVQ» AX, g(CX) |
149 » MOVQ» 0(DX), CX» // make sure g != nil | 150 » MOVQ» 0(AX), CX» // make sure g != nil |
150 MOVQ gobuf_sp(BX), SP // restore SP | 151 MOVQ gobuf_sp(BX), SP // restore SP |
151 MOVQ gobuf_pc(BX), BX | 152 MOVQ gobuf_pc(BX), BX |
152 PUSHQ BX | 153 PUSHQ BX |
153 » MOVQ» 0(AX), BX | 154 » MOVQ» 0(DX), BX |
154 JMP BX | 155 JMP BX |
155 POPQ BX // not reached | 156 POPQ BX // not reached |
156 | 157 |
157 // void mcall(void (*fn)(G*)) | 158 // void mcall(void (*fn)(G*)) |
158 // Switch to m->g0's stack, call fn(g). | 159 // Switch to m->g0's stack, call fn(g). |
159 // Fn must never return. It should gogo(&g->sched) | 160 // Fn must never return. It should gogo(&g->sched) |
160 // to keep running g. | 161 // to keep running g. |
161 TEXT runtime·mcall(SB), 7, $0 | 162 TEXT runtime·mcall(SB), 7, $0 |
162 MOVQ fn+0(FP), DI | 163 MOVQ fn+0(FP), DI |
163 ········ | 164 ········ |
(...skipping 24 matching lines...) Expand all Loading... |
188 */ | 189 */ |
189 | 190 |
190 // Called during function prolog when more stack is needed. | 191 // Called during function prolog when more stack is needed. |
191 // Caller has already done get_tls(CX); MOVQ m(CX), BX. | 192 // Caller has already done get_tls(CX); MOVQ m(CX), BX. |
192 TEXT runtime·morestack(SB),7,$0 | 193 TEXT runtime·morestack(SB),7,$0 |
193 // Cannot grow scheduler stack (m->g0). | 194 // Cannot grow scheduler stack (m->g0). |
194 MOVQ m_g0(BX), SI | 195 MOVQ m_g0(BX), SI |
195 CMPQ g(CX), SI | 196 CMPQ g(CX), SI |
196 JNE 2(PC) | 197 JNE 2(PC) |
197 INT $3 | 198 INT $3 |
| 199 ········ |
| 200 MOVQ DX, m_cret(BX) |
198 | 201 |
199 // Called from f. | 202 // Called from f. |
200 // Set m->morebuf to f's caller. | 203 // Set m->morebuf to f's caller. |
201 MOVQ 8(SP), AX // f's caller's PC | 204 MOVQ 8(SP), AX // f's caller's PC |
202 MOVQ AX, (m_morebuf+gobuf_pc)(BX) | 205 MOVQ AX, (m_morebuf+gobuf_pc)(BX) |
203 LEAQ 16(SP), AX // f's caller's SP | 206 LEAQ 16(SP), AX // f's caller's SP |
204 MOVQ AX, (m_morebuf+gobuf_sp)(BX) | 207 MOVQ AX, (m_morebuf+gobuf_sp)(BX) |
205 MOVQ AX, m_moreargp(BX) | 208 MOVQ AX, m_moreargp(BX) |
206 get_tls(CX) | 209 get_tls(CX) |
207 MOVQ g(CX), SI | 210 MOVQ g(CX), SI |
(...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 MOVQ 16(SP), AX | 467 MOVQ 16(SP), AX |
465 XCHGQ AX, 0(BX) | 468 XCHGQ AX, 0(BX) |
466 RET | 469 RET |
467 | 470 |
468 // void jmpdefer(fn, sp); | 471 // void jmpdefer(fn, sp); |
469 // called from deferreturn. | 472 // called from deferreturn. |
470 // 1. pop the caller | 473 // 1. pop the caller |
471 // 2. sub 5 bytes from the callers return | 474 // 2. sub 5 bytes from the callers return |
472 // 3. jmp to the argument | 475 // 3. jmp to the argument |
473 TEXT runtime·jmpdefer(SB), 7, $0 | 476 TEXT runtime·jmpdefer(SB), 7, $0 |
474 » MOVQ» 8(SP), AX» // fn | 477 » MOVQ» 8(SP), DX» // fn |
475 MOVQ 16(SP), BX // caller sp | 478 MOVQ 16(SP), BX // caller sp |
476 LEAQ -8(BX), SP // caller sp after CALL | 479 LEAQ -8(BX), SP // caller sp after CALL |
477 SUBQ $5, (SP) // return to CALL again | 480 SUBQ $5, (SP) // return to CALL again |
478 » MOVQ» 0(AX), BX | 481 » MOVQ» 0(DX), BX |
479 JMP BX // but first run the deferred function | 482 JMP BX // but first run the deferred function |
480 | 483 |
481 // Dummy function to use in saved gobuf.PC, | 484 // Dummy function to use in saved gobuf.PC, |
482 // to match SP pointing at a return address. | 485 // to match SP pointing at a return address. |
483 // The gobuf.PC is unused by the contortions here | 486 // The gobuf.PC is unused by the contortions here |
484 // but setting it to return will make the traceback code work. | 487 // but setting it to return will make the traceback code work. |
485 TEXT return<>(SB),7,$0 | 488 TEXT return<>(SB),7,$0 |
486 RET | 489 RET |
487 | 490 |
488 // asmcgocall(void(*fn)(void*), void *arg) | 491 // asmcgocall(void(*fn)(void*), void *arg) |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
699 TEXT runtime·stackguard(SB),7,$0 | 702 TEXT runtime·stackguard(SB),7,$0 |
700 MOVQ SP, DX | 703 MOVQ SP, DX |
701 MOVQ DX, sp+0(FP) | 704 MOVQ DX, sp+0(FP) |
702 get_tls(CX) | 705 get_tls(CX) |
703 MOVQ g(CX), BX | 706 MOVQ g(CX), BX |
704 MOVQ g_stackguard(BX), DX | 707 MOVQ g_stackguard(BX), DX |
705 MOVQ DX, guard+8(FP) | 708 MOVQ DX, guard+8(FP) |
706 RET | 709 RET |
707 | 710 |
708 GLOBL runtime·tls0(SB), $64 | 711 GLOBL runtime·tls0(SB), $64 |
LEFT | RIGHT |