diff options
author | Austin Clements <austin@google.com> | 2016-10-19 15:49:31 -0400 |
---|---|---|
committer | Austin Clements <austin@google.com> | 2016-10-28 20:48:02 +0000 |
commit | 70c107c68dca7d57a24b35dd81420fb889aa1031 (patch) | |
tree | 3f913f89ecd72a10cda5ccd22fefdb6ab6808a93 /src/runtime/asm_mips64x.s | |
parent | 8f81dfe8b47e975b90bb4a2f8dd314d32c633176 (diff) | |
download | go-70c107c68dca7d57a24b35dd81420fb889aa1031.tar.gz go-70c107c68dca7d57a24b35dd81420fb889aa1031.zip |
runtime: add deletion barriers on gobuf.ctxt
gobuf.ctxt is set to nil from many places in assembly code and these
assignments require write barriers with the hybrid barrier.
Conveniently, in most of these places ctxt should already be nil, in
which case we don't need the barrier. This commit changes these places
to assert that ctxt is already nil.
gogo is more complicated, since ctxt may not already be nil. For gogo,
we manually perform the write barrier if ctxt is not nil.
Updates #17503.
Change-Id: I9d75e27c75a1b7f8b715ad112fc5d45ffa856d30
Reviewed-on: https://go-review.googlesource.com/31764
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/runtime/asm_mips64x.s')
-rw-r--r-- | src/runtime/asm_mips64x.s | 25 |
1 files changed, 21 insertions, 4 deletions
diff --git a/src/runtime/asm_mips64x.s b/src/runtime/asm_mips64x.s index 4666741f28..c2d991d36d 100644 --- a/src/runtime/asm_mips64x.s +++ b/src/runtime/asm_mips64x.s @@ -98,13 +98,27 @@ TEXT runtime·gosave(SB), NOSPLIT, $-8-8 MOVV g, gobuf_g(R1) MOVV R0, gobuf_lr(R1) MOVV R0, gobuf_ret(R1) - MOVV R0, gobuf_ctxt(R1) + // Assert ctxt is zero. See func save. + MOVV gobuf_ctxt(R1), R1 + BEQ R1, 2(PC) + JAL runtime·badctxt(SB) RET // void gogo(Gobuf*) // restore state from Gobuf; longjmp -TEXT runtime·gogo(SB), NOSPLIT, $-8-8 +TEXT runtime·gogo(SB), NOSPLIT, $16-8 MOVV buf+0(FP), R3 + + // If ctxt is not nil, invoke deletion barrier before overwriting. + MOVV gobuf_ctxt(R3), R1 + BEQ R1, nilctxt + MOVV $gobuf_ctxt(R3), R1 + MOVV R1, 8(R29) + MOVV R0, 16(R29) + JAL runtime·writebarrierptr_prewrite(SB) + MOVV buf+0(FP), R3 + +nilctxt: MOVV gobuf_g(R3), g // make sure g is not nil JAL runtime·save_g(SB) @@ -429,13 +443,16 @@ TEXT runtime·jmpdefer(SB), NOSPLIT, $-8-16 MOVV 0(REGCTXT), R4 JMP (R4) -// Save state of caller into g->sched. Smashes R31. +// Save state of caller into g->sched. Smashes R1. TEXT gosave<>(SB),NOSPLIT,$-8 MOVV R31, (g_sched+gobuf_pc)(g) MOVV R29, (g_sched+gobuf_sp)(g) MOVV R0, (g_sched+gobuf_lr)(g) MOVV R0, (g_sched+gobuf_ret)(g) - MOVV R0, (g_sched+gobuf_ctxt)(g) + // Assert ctxt is zero. See func save. + MOVV (g_sched+gobuf_ctxt)(g), R1 + BEQ R1, 2(PC) + JAL runtime·badctxt(SB) RET // func asmcgocall(fn, arg unsafe.Pointer) int32 |