aboutsummaryrefslogtreecommitdiff
path: root/test/codegen
diff options
context:
space:
mode:
authorKeith Randall <khr@golang.org>2023-08-18 12:44:37 -0700
committerKeith Randall <khr@golang.org>2023-08-23 00:16:06 +0000
commit556e9c5f3e28d0398001384508a3c51143adcff8 (patch)
tree8ecb874c690d0f9e9eefba1c15a1332c43a078b4 /test/codegen
parent0163b3b32cad2ed3331e2b197c68387f12246cd8 (diff)
downloadgo-556e9c5f3e28d0398001384508a3c51143adcff8.tar.xz
cmd/compile: allow non-pointer writes in the middle of a write barrier
This lets us combine more write barriers, getting rid of some of the test+branch and gcWriteBarrier* calls. With the new write barriers, it's easy to add a few non-pointer writes to the set of values written. We allow up to 2 non-pointer writes between pointer writes. This is enough for, for example, adjacent slice fields. Fixes #62126 Change-Id: I872d0fa9cc4eb855e270ffc0223b39fde1723c4b Reviewed-on: https://go-review.googlesource.com/c/go/+/521498 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@google.com>
Diffstat (limited to 'test/codegen')
-rw-r--r--test/codegen/writebarrier.go55
1 files changed, 55 insertions, 0 deletions
diff --git a/test/codegen/writebarrier.go b/test/codegen/writebarrier.go
new file mode 100644
index 0000000000..cfcfe15a40
--- /dev/null
+++ b/test/codegen/writebarrier.go
@@ -0,0 +1,55 @@
+// asmcheck
+
+// Copyright 2023 The Go Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style
+// license that can be found in the LICENSE file.
+
+package codegen
+
+func combine2string(p *[2]string, a, b string) {
+ // amd64:`.*runtime[.]gcWriteBarrier4\(SB\)`
+ // arm64:`.*runtime[.]gcWriteBarrier4\(SB\)`
+ p[0] = a
+ // amd64:-`.*runtime[.]gcWriteBarrier`
+ // arm64:-`.*runtime[.]gcWriteBarrier`
+ p[1] = b
+}
+
+func combine4string(p *[4]string, a, b, c, d string) {
+ // amd64:`.*runtime[.]gcWriteBarrier8\(SB\)`
+ // arm64:`.*runtime[.]gcWriteBarrier8\(SB\)`
+ p[0] = a
+ // amd64:-`.*runtime[.]gcWriteBarrier`
+ // arm64:-`.*runtime[.]gcWriteBarrier`
+ p[1] = b
+ // amd64:-`.*runtime[.]gcWriteBarrier`
+ // arm64:-`.*runtime[.]gcWriteBarrier`
+ p[2] = c
+ // amd64:-`.*runtime[.]gcWriteBarrier`
+ // arm64:-`.*runtime[.]gcWriteBarrier`
+ p[3] = d
+}
+
+func combine2slice(p *[2][]byte, a, b []byte) {
+ // amd64:`.*runtime[.]gcWriteBarrier4\(SB\)`
+ // arm64:`.*runtime[.]gcWriteBarrier4\(SB\)`
+ p[0] = a
+ // amd64:-`.*runtime[.]gcWriteBarrier`
+ // arm64:-`.*runtime[.]gcWriteBarrier`
+ p[1] = b
+}
+
+func combine4slice(p *[4][]byte, a, b, c, d []byte) {
+ // amd64:`.*runtime[.]gcWriteBarrier8\(SB\)`
+ // arm64:`.*runtime[.]gcWriteBarrier8\(SB\)`
+ p[0] = a
+ // amd64:-`.*runtime[.]gcWriteBarrier`
+ // arm64:-`.*runtime[.]gcWriteBarrier`
+ p[1] = b
+ // amd64:-`.*runtime[.]gcWriteBarrier`
+ // arm64:-`.*runtime[.]gcWriteBarrier`
+ p[2] = c
+ // amd64:-`.*runtime[.]gcWriteBarrier`
+ // arm64:-`.*runtime[.]gcWriteBarrier`
+ p[3] = d
+}