1
0
mirror of https://github.com/golang/go synced 2024-10-05 09:21:22 -06:00
go/src/cmd
Josh Bleecher Snyder f03c9202c4 cmd/gc: optimize memclr of slices and arrays
Recognize loops of the form

for i := range a {
	a[i] = zero
}

in which the evaluation of a is free from side effects.
Replace these loops with calls to memclr.
This occurs in the stdlib in 18 places.

The motivating example is clearing a byte slice:

benchmark                old ns/op     new ns/op     delta
BenchmarkGoMemclr5       3.31          3.26          -1.51%
BenchmarkGoMemclr16      13.7          3.28          -76.06%
BenchmarkGoMemclr64      50.8          4.14          -91.85%
BenchmarkGoMemclr256     157           6.02          -96.17%

Update #5373.

Change-Id: I99d3e6f5f268e8c6499b7e661df46403e5eb83e4
Reviewed-on: https://go-review.googlesource.com/2520
Reviewed-by: Keith Randall <khr@golang.org>
2015-01-09 22:35:25 +00:00
..
5a [dev.power64] cmd/5a, cmd/6a, cmd/8a, cmd/9a: make labels function-scoped 2014-10-28 21:50:16 -04:00
5g runtime: make stack frames fixed size by modifying goproc/deferproc. 2014-12-23 01:08:29 +00:00
5l cmd/ld: support for relocation variants 2015-01-07 20:35:37 +00:00
6a [dev.power64] cmd/5a, cmd/6a, cmd/8a, cmd/9a: make labels function-scoped 2014-10-28 21:50:16 -04:00
6g cmd/6g, cmd/8g, liblink: improve handling of float constants 2015-01-07 22:26:55 +00:00
6l cmd/ld: support for relocation variants 2015-01-07 20:35:37 +00:00
8a runtime: faster aeshash implementation 2014-12-11 05:23:00 +00:00
8g cmd/6g, cmd/8g, liblink: improve handling of float constants 2015-01-07 22:26:55 +00:00
8l cmd/ld: support for relocation variants 2015-01-07 20:35:37 +00:00
9a all: power64 is now ppc64 2014-12-05 19:13:20 -05:00
9g cmd/9g: don't use R13 2015-01-07 20:36:08 +00:00
9l cmd/9g: don't use R13 2015-01-07 20:36:08 +00:00
addr2line cmd/addr2line, cmd/nm: factor object reading into cmd/internal/objfile 2014-08-07 12:33:06 -04:00
api cmd/api: work around Windows rename issue on the builders 2014-12-23 04:55:44 +00:00
cc [dev.cc] all: merge dev.power64 (7667e41f3ced) into dev.cc 2014-11-14 12:10:52 -05:00
cgo cmd/cgo, go/build: finish a cleanup TODO 2015-01-08 00:59:37 +00:00
dist cmd/dist: fatal shouldn't print errstr on Plan 9 2014-12-23 10:28:17 +00:00
fix build: adjustments for move from src/pkg to src 2014-09-08 00:06:45 -04:00
gc cmd/gc: optimize memclr of slices and arrays 2015-01-09 22:35:25 +00:00
go cmd/go: document import path checking 2015-01-08 23:24:59 +00:00
gofmt go/format, cmd/gofmt: added missing comments, minor internal cleanup 2014-09-30 12:26:38 -07:00
internal all: power64 is now ppc64 2014-12-05 19:13:20 -05:00
ld runtime: faster version of findfunc 2015-01-07 21:24:21 +00:00
link debug/goobj: move to cmd/internal/goobj 2014-11-16 20:52:45 -05:00
nm build: adjustments for move from src/pkg to src 2014-09-08 00:06:45 -04:00
objdump cmd/objdump: Fix error logging 2014-12-09 00:27:39 +00:00
pack cmd/pack: address go vet reports 2014-12-28 07:08:02 +00:00
pprof cmd/pprof: remove -show_bytes from command line help 2014-12-11 15:23:18 +00:00
yacc cmd/yacc: Prevent index out of range. Fixes #9099. 2014-12-18 16:11:50 +00:00