diff options
| author | Austin Clements <austin@google.com> | 2016-10-19 18:27:39 -0400 |
|---|---|---|
| committer | Austin Clements <austin@google.com> | 2016-10-24 02:23:16 +0000 |
| commit | bf9c71cb434a730679f54a3a87c2e9e36ec400d0 (patch) | |
| tree | f90242f9a099f13b49f131e714a6d15779804478 /src/runtime/asm_amd64.s | |
| parent | cdccd6a79c5391c21c8e7316e13f8b8d1697ea63 (diff) | |
| download | go-bf9c71cb434a730679f54a3a87c2e9e36ec400d0.tar.xz | |
runtime: make morestack less subtle
morestack writes the context pointer to gobuf.ctxt, but since
morestack is written in assembly (and has to be very careful with
state), it does *not* invoke the requisite write barrier for this
write. Instead, we patch this up later, in newstack, where we invoke
an explicit write barrier for ctxt.
This already requires some subtle reasoning, and it's going to get a
lot hairier with the hybrid barrier.
Fix this by simplifying the whole mechanism. Instead of writing
gobuf.ctxt in morestack, just pass the value of the context register
to newstack and let it write it to gobuf.ctxt. This is a normal Go
pointer write, so it gets the normal Go write barrier. No subtle
reasoning required.
Updates #17503.
Change-Id: Ia6bf8459bfefc6828f53682ade32c02412e4db63
Reviewed-on: https://go-review.googlesource.com/31550
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/runtime/asm_amd64.s')
| -rw-r--r-- | src/runtime/asm_amd64.s | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s index 34da3bda9f..398b14888f 100644 --- a/src/runtime/asm_amd64.s +++ b/src/runtime/asm_amd64.s @@ -358,15 +358,17 @@ TEXT runtime·morestack(SB),NOSPLIT,$0-0 MOVQ SI, (g_sched+gobuf_g)(SI) LEAQ 8(SP), AX // f's SP MOVQ AX, (g_sched+gobuf_sp)(SI) - MOVQ DX, (g_sched+gobuf_ctxt)(SI) MOVQ BP, (g_sched+gobuf_bp)(SI) + // newstack will fill gobuf.ctxt. // Call newstack on m->g0's stack. MOVQ m_g0(BX), BX MOVQ BX, g(CX) MOVQ (g_sched+gobuf_sp)(BX), SP + PUSHQ DX // ctxt argument CALL runtime·newstack(SB) MOVQ $0, 0x1003 // crash if newstack returns + POPQ DX // keep balance check happy RET // morestack but not preserving ctxt. |
