go/src
Josh Bleecher Snyder 9e619739fd cmd/compile: copy all fields during SubstAny
Consider these functions:

func f(a any) int
func g(a any) int

Prior to this change, since f and g have identical signatures,
they would share a single generated func type.

types.SubstAny makes a shallow type copy, even after instantiation,
f and g share a single generated Result type.
So if you instantiate f with any=T, call dowidth,
instantiate g with any=U, and call dowidth,
and if sizeof(T) != sizeof(U),
then the Offset of the result for f is now wrong.

I don't believe this happens at all right now, but it bit me hard when
experimenting with some other compiler changes.
And it's hard to debug. It results in rare stack corruption, causing
problems far from the actual source of the problem.

To fix this, change SubstAny to make deep copies of TSTRUCTs.

name        old alloc/op      new alloc/op      delta
Template         35.3MB ± 0%       35.4MB ± 0%  +0.23%  (p=0.008 n=5+5)
Unicode          29.1MB ± 0%       29.1MB ± 0%  +0.16%  (p=0.008 n=5+5)
GoTypes           122MB ± 0%        122MB ± 0%  +0.16%  (p=0.008 n=5+5)
Compiler          513MB ± 0%        514MB ± 0%  +0.19%  (p=0.008 n=5+5)
SSA              1.94GB ± 0%       1.94GB ± 0%  +0.01%  (p=0.008 n=5+5)
Flate            24.2MB ± 0%       24.2MB ± 0%  +0.08%  (p=0.008 n=5+5)
GoParser         28.5MB ± 0%       28.5MB ± 0%  +0.24%  (p=0.008 n=5+5)
Reflect          86.2MB ± 0%       86.3MB ± 0%  +0.09%  (p=0.008 n=5+5)
Tar              34.9MB ± 0%       34.9MB ± 0%  +0.13%  (p=0.008 n=5+5)
XML              47.0MB ± 0%       47.1MB ± 0%  +0.18%  (p=0.008 n=5+5)
[Geo mean]       80.9MB            81.0MB       +0.15%

name        old allocs/op     new allocs/op     delta
Template           348k ± 0%         349k ± 0%  +0.38%  (p=0.008 n=5+5)
Unicode            340k ± 0%         340k ± 0%  +0.21%  (p=0.008 n=5+5)
GoTypes           1.27M ± 0%        1.28M ± 0%  +0.27%  (p=0.008 n=5+5)
Compiler          4.90M ± 0%        4.92M ± 0%  +0.36%  (p=0.008 n=5+5)
SSA               15.3M ± 0%        15.3M ± 0%  +0.03%  (p=0.008 n=5+5)
Flate              232k ± 0%         233k ± 0%  +0.14%  (p=0.008 n=5+5)
GoParser           291k ± 0%         292k ± 0%  +0.42%  (p=0.008 n=5+5)
Reflect           1.05M ± 0%        1.05M ± 0%  +0.14%  (p=0.008 n=5+5)
Tar                343k ± 0%         344k ± 0%  +0.22%  (p=0.008 n=5+5)
XML                428k ± 0%         430k ± 0%  +0.36%  (p=0.008 n=5+5)
[Geo mean]         807k              809k       +0.25%

Change-Id: I62134db642206cded01920dc1d8a7da61f7ca0ac
Reviewed-on: https://go-review.googlesource.com/c/147038
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-11-05 23:12:50 +00:00
..
archive all: fix a bunch of misspellings 2018-10-08 03:12:03 +00:00
bufio bufio: suggest io.ReadFull at (*Reader).Read 2018-10-30 13:03:46 +00:00
builtin builtin: document when len and cap are constant 2018-09-18 21:52:11 +00:00
bytes bytes, strings: fix Reader.UnreadRune returning without error on a zero Reader 2018-10-29 20:07:25 +00:00
cmd cmd/compile: copy all fields during SubstAny 2018-11-05 23:12:50 +00:00
compress all: fix a bunch of misspellings 2018-10-06 15:40:03 +00:00
container container/list: combining insert and remove operations while moving elements within a list. 2018-10-26 20:47:01 +00:00
context context: avoid duplicate removeChild 2018-10-03 15:26:10 +00:00
crypto all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
database/sql all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
debug all: skip unsupported tests on AIX 2018-11-02 16:12:08 +00:00
encoding all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
errors
expvar expvar: add Map.Delete 2018-10-04 01:16:52 +00:00
flag flag: return a consistent parse error if the flag value is invalid 2018-10-19 03:48:38 +00:00
fmt fmt: print maps in key-sorted order 2018-10-18 21:12:24 +00:00
go go/doc: inspect function signature for building playground examples 2018-11-05 22:36:24 +00:00
hash hash/crc64: use t.Fatalf in TestGolden 2018-10-25 06:32:12 +00:00
html all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
image jpeg: simplify 'x = x op ...' to 'x op= ...' 2018-10-13 11:18:56 +00:00
index/suffixarray
internal internal/trace: support for mutator utilization distributions 2018-11-05 19:10:27 +00:00
io io: export StringWriter 2018-10-03 20:13:35 +00:00
log log: add Logger.Writer method 2018-10-25 23:23:57 +00:00
math all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
mime mime: add AIX operating system 2018-10-10 15:19:38 +00:00
net net/http: speed up ServeMux matching 2018-11-02 23:22:57 +00:00
os all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
path all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
plugin plugin: remove unused func 2018-08-22 16:29:03 +00:00
reflect all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
regexp all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
runtime runtime: clean up MSpan* MCache* MCentral* in docs 2018-11-05 22:56:22 +00:00
sort
strconv strconv: add comment explaining bounded shift in formatBits 2018-10-15 21:45:52 +00:00
strings strings: lower running time of TestCompareStrings 2018-11-04 18:55:55 +00:00
sync all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
syscall all: use "reports whether" consistently in the few places that didn't 2018-11-02 22:47:58 +00:00
testdata Revert "compress: move benchmark text from src/testdata to src/compress/testdata" 2018-10-01 16:16:21 +00:00
testing testing: implement -benchtime=100x 2018-10-12 17:48:31 +00:00
text text/template/parse: simplify Tree.pipeline 2018-10-29 12:20:11 +00:00
time all: fix tests for older versions of AIX 7.2 2018-11-02 13:44:27 +00:00
unicode
unsafe unsafe: document that Alignof, Offsetof, and Sizeof return a constant 2018-10-11 02:32:20 +00:00
vendor/golang_org/x crypto/tls: implement TLS 1.3 cryptographic computations 2018-11-02 21:54:52 +00:00
Make.dist
all.bash
all.bat
all.rc
androidtest.bash
bootstrap.bash
buildall.bash
clean.bash
clean.bat
clean.rc
cmp.bash
iostest.bash
make.bash
make.bat src/make.bat: add missing go.exe extension 2018-08-25 22:42:46 +00:00
make.rc
naclmake.bash all: use consistent shebang line across all shell scripts 2018-08-22 16:41:11 +00:00
nacltest.bash all: use consistent shebang line across all shell scripts 2018-08-22 16:41:11 +00:00
race.bash
race.bat cmd/dist: fix compilation on windows 2018-08-25 22:39:17 +00:00
run.bash
run.bat
run.rc