Slide 24
Slide 24 text
24
// void gogo(Gobuf*)
// restore state from Gobuf; longjmp
TEXT runtime·gogo(SB), NOSPLIT, $16-8
MOVQ buf+0(FP), BX
MOVQ gobuf_g(BX), DX
MOVQ 0(DX), CX
get_tls(CX)
MOVQ DX, g(CX)
MOVQ gobuf_sp(BX), SP
MOVQ gobuf_ret(BX), AX
MOVQ gobuf_ctxt(BX), DX
MOVQ gobuf_bp(BX), BP
MOVQ $0, gobuf_sp(BX)
MOVQ $0, gobuf_ret(BX)
MOVQ $0, gobuf_ctxt(BX)
MOVQ $0, gobuf_bp(BX)
MOVQ gobuf_pc(BX), BX
JMP BX
runtime.gogo
(gdb) i registers
rax 0x0 0 // <- gobuf.ret
rbx 0x4285c0 4359616 // <- gobuf.pc # runtime.main
rcx 0xc000030000 824633917440 // <- g
rdx 0x4c96c0 5019328 // <- gobuf.ctxt # runtime.mainPC
rsi 0x0 0
rdi 0x1 1
rbp 0x0 0x0 // <- gobuf.bp
rsp 0xc0000307d8 0xc0000307d8 // <- gobuf.sp
r8 0x1c6 454
r9 0x0 0
r10 0x8 8
r11 0x202 514
r12 0xffffffffffffffff -1
r13 0x2 2
r14 0x1 1
r15 0x400 1024
(snip)
• Code: runtime/asm_amd64.s
• JMP to BX register (= gobuf.pc = runtime.main)