]> Cypherpunks repositories - gostls13.git/commit
cmd/compile: don't write back unchanged slice results
authorKeith Randall <khr@golang.org>
Mon, 21 Mar 2016 17:22:03 +0000 (10:22 -0700)
committerKeith Randall <khr@golang.org>
Mon, 21 Mar 2016 23:40:18 +0000 (23:40 +0000)
commitd4663e13536d7d43666e53ae21114008cb65d790
tree3fbb2710583fdfd00684aa8e2d17f4edb358039b
parent9549c06ce6e379de4554a911ffe8470af8d70daa
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>
src/cmd/compile/internal/gc/ssa.go
src/cmd/compile/internal/gc/ssa_test.go
src/cmd/compile/internal/gc/testdata/slice.go [new file with mode: 0644]
src/cmd/compile/internal/gc/walk.go
test/writebarrier.go