diff options
author | Keith Randall <khr@golang.org> | 2016-03-21 10:22:03 -0700 |
---|---|---|
committer | Keith Randall <khr@golang.org> | 2016-03-21 23:40:18 +0000 |
commit | d4663e13536d7d43666e53ae21114008cb65d790 (patch) | |
tree | 3fbb2710583fdfd00684aa8e2d17f4edb358039b /test/writebarrier.go | |
parent | 9549c06ce6e379de4554a911ffe8470af8d70daa (diff) | |
download | go-d4663e13536d7d43666e53ae21114008cb65d790.tar.gz go-d4663e13536d7d43666e53ae21114008cb65d790.zip |
cmd/compile: don't write back unchanged slice results
Don't write back parts of a slicing operation if they
are unchanged from the source of the slice. For example:
x.s = x.s[0:5] // don't write back pointer or cap
x.s = x.s[:5] // don't write back pointer or cap
x.s = x.s[:5:7] // don't write back pointer
There is more to be done here, for example:
x.s = x.s[:len(x.s):7] // don't write back ptr or len
This CL can't handle that one yet.
Fixes #14855
Change-Id: Id1e1a4fa7f3076dc1a76924a7f1cd791b81909bb
Reviewed-on: https://go-review.googlesource.com/20954
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Diffstat (limited to 'test/writebarrier.go')
-rw-r--r-- | test/writebarrier.go | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/test/writebarrier.go b/test/writebarrier.go index 75107287b4..44e42f0883 100644 --- a/test/writebarrier.go +++ b/test/writebarrier.go @@ -176,8 +176,9 @@ type T18 struct { func f18(p *T18, x *[]int) { p.a = p.a[:5] // no barrier - p.a = p.a[3:5] // no barrier - p.a = p.a[1:2:3] // no barrier - p.s = p.s[8:9] // no barrier - *x = (*x)[3:5] // no barrier + *x = (*x)[0:5] // no barrier + p.a = p.a[3:5] // ERROR "write barrier" + p.a = p.a[1:2:3] // ERROR "write barrier" + p.s = p.s[8:9] // ERROR "write barrier" + *x = (*x)[3:5] // ERROR "write barrier" } |