aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/asm_s390x.s
diff options
context:
space:
mode:
authorAustin Clements <austin@google.com>2016-10-19 15:49:31 -0400
committerAustin Clements <austin@google.com>2016-10-28 20:48:02 +0000
commit70c107c68dca7d57a24b35dd81420fb889aa1031 (patch)
tree3f913f89ecd72a10cda5ccd22fefdb6ab6808a93 /src/runtime/asm_s390x.s
parent8f81dfe8b47e975b90bb4a2f8dd314d32c633176 (diff)
downloadgo-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_s390x.s')
-rw-r--r--src/runtime/asm_s390x.s25
1 files changed, 21 insertions, 4 deletions
diff --git a/src/runtime/asm_s390x.s b/src/runtime/asm_s390x.s
index 1dcee7cf4e..614a799432 100644
--- a/src/runtime/asm_s390x.s
+++ b/src/runtime/asm_s390x.s
@@ -106,13 +106,27 @@ TEXT runtime·gosave(SB), NOSPLIT, $-8-8
MOVD g, gobuf_g(R3)
MOVD $0, gobuf_lr(R3)
MOVD $0, gobuf_ret(R3)
- MOVD $0, gobuf_ctxt(R3)
+ // Assert ctxt is zero. See func save.
+ MOVD gobuf_ctxt(R3), R3
+ CMPBEQ R3, $0, 2(PC)
+ BL 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
MOVD buf+0(FP), R5
+
+ // If ctxt is not nil, invoke deletion barrier before overwriting.
+ MOVD gobuf_ctxt(R5), R1
+ CMPBEQ R1, $0, nilctxt
+ MOVD $gobuf_ctxt(R5), R1
+ MOVD R1, 8(R15)
+ MOVD R0, 16(R15)
+ BL runtime·writebarrierptr_prewrite(SB)
+ MOVD buf+0(FP), R5
+
+nilctxt:
MOVD gobuf_g(R5), g // make sure g is not nil
BL runtime·save_g(SB)
@@ -447,13 +461,16 @@ TEXT runtime·jmpdefer(SB),NOSPLIT|NOFRAME,$0-16
MOVD 0(R12), R3
BR (R3)
-// Save state of caller into g->sched. Smashes R31.
+// Save state of caller into g->sched. Smashes R1.
TEXT gosave<>(SB),NOSPLIT|NOFRAME,$0
MOVD LR, (g_sched+gobuf_pc)(g)
MOVD R15, (g_sched+gobuf_sp)(g)
MOVD $0, (g_sched+gobuf_lr)(g)
MOVD $0, (g_sched+gobuf_ret)(g)
- MOVD $0, (g_sched+gobuf_ctxt)(g)
+ // Assert ctxt is zero. See func save.
+ MOVD (g_sched+gobuf_ctxt)(g), R1
+ CMPBEQ R1, $0, 2(PC)
+ BL runtime·badctxt(SB)
RET
// func asmcgocall(fn, arg unsafe.Pointer) int32