]> Cypherpunks repositories - gostls13.git/log
gostls13.git
5 years agosyscall/js: improve documentation of js.FuncOf
Torben Schinke [Sun, 1 Mar 2020 20:07:46 +0000 (20:07 +0000)]
syscall/js: improve documentation of js.FuncOf

The existing documentation is improved to be more
explicit about the lifecycle and its consequences.

Fixes #34324

Change-Id: I9969afc69f6eeb7812c11fe821a842794df5aa5b
GitHub-Last-Rev: 246a4991660927f88f48290580e96b15c16663c1
GitHub-Pull-Request: golang/go#34551
Reviewed-on: https://go-review.googlesource.com/c/go/+/197458
Reviewed-by: Richard Musiol <neelance@gmail.com>
5 years agosyscall: fix Fchdir on js/wasm
Richard Musiol [Sun, 1 Mar 2020 16:01:58 +0000 (17:01 +0100)]
syscall: fix Fchdir on js/wasm

NodeJS does not support fchdir so it has to be emulated with chdir by
saving the path when opening a directory.

However, if the path opened is relative, saving this path is not
sufficient, because after changing the working directory the path
does not resolve correctly any more, thus a subsequent fd.Chdir() fails.

This change fixes the issue by resolving a relative path when
opening the directory and saving the absolute path instead.

Fixes #37448

Change-Id: Id6bc8c4232b0019fc11e850599a526336608ce54
Reviewed-on: https://go-review.googlesource.com/c/go/+/221717
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
5 years agocmd/compile: add specialized AddArgN functions for rewrite rules
Josh Bleecher Snyder [Wed, 26 Feb 2020 19:29:34 +0000 (11:29 -0800)]
cmd/compile: add specialized AddArgN functions for rewrite rules

This shrinks the compiler without impacting performance.
(The performance-sensitive part of rewrite rules is the non-match case.)
Passes toolstash-check -all.

Executable size:

file    before    after     Δ       %
compile 20356168  20163960  -192208 -0.944%
total   115599376 115407168 -192208 -0.166%

Text size:

file                       before   after    Δ       %
cmd/compile/internal/ssa.s 3928309  3778774  -149535 -3.807%
total                      18862943 18713408 -149535 -0.793%

Memory allocated compiling package SSA:

SSA               12.7M ± 0%        12.5M ± 0%  -1.74%  (p=0.008 n=5+5)

Compiler speed impact:

name        old time/op       new time/op       delta
Template          211ms ± 1%        211ms ± 2%    ~     (p=0.832 n=49+49)
Unicode          82.8ms ± 2%       83.2ms ± 2%  +0.44%  (p=0.022 n=46+49)
GoTypes           726ms ± 1%        728ms ± 2%    ~     (p=0.076 n=46+48)
Compiler          3.39s ± 2%        3.40s ± 2%    ~     (p=0.633 n=48+49)
SSA               7.71s ± 1%        7.65s ± 1%  -0.78%  (p=0.000 n=45+44)
Flate             134ms ± 1%        134ms ± 1%    ~     (p=0.195 n=50+49)
GoParser          167ms ± 1%        167ms ± 1%    ~     (p=0.390 n=47+47)
Reflect           453ms ± 3%        452ms ± 2%    ~     (p=0.492 n=48+49)
Tar               184ms ± 3%        184ms ± 2%    ~     (p=0.862 n=50+48)
XML               248ms ± 2%        248ms ± 2%    ~     (p=0.096 n=49+47)
[Geo mean]        415ms             415ms       -0.03%

name        old user-time/op  new user-time/op  delta
Template          273ms ± 1%        273ms ± 2%    ~     (p=0.711 n=48+48)
Unicode           117ms ± 6%        117ms ± 5%    ~     (p=0.633 n=50+50)
GoTypes           972ms ± 2%        974ms ± 1%  +0.29%  (p=0.016 n=47+49)
Compiler          4.46s ± 6%        4.51s ± 6%    ~     (p=0.093 n=50+50)
SSA               10.4s ± 1%        10.3s ± 2%  -0.94%  (p=0.000 n=45+50)
Flate             166ms ± 2%        167ms ± 2%    ~     (p=0.148 n=49+48)
GoParser          202ms ± 1%        202ms ± 2%  -0.28%  (p=0.014 n=47+49)
Reflect           594ms ± 2%        594ms ± 2%    ~     (p=0.717 n=48+49)
Tar               224ms ± 2%        224ms ± 2%    ~     (p=0.805 n=50+49)
XML               311ms ± 1%        310ms ± 1%    ~     (p=0.177 n=49+48)
[Geo mean]        537ms             537ms       +0.01%

Change-Id: I562b9f349b34ddcff01771769e6dbbc80604da7a
Reviewed-on: https://go-review.googlesource.com/c/go/+/221237
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agoruntime: deflake CGO traceback tests
Mark Pulford [Thu, 13 Feb 2020 21:34:31 +0000 (08:34 +1100)]
runtime: deflake CGO traceback tests

The CGO traceback function is called whenever CGO code is executing and
a signal is received. This occurs much more frequently now SIGURG
is used for preemption.

Disable signal preemption to significantly increase the likelihood that
a signal results in a profile sample during the test.

Updates #37201

Change-Id: Icb1a33ab0754d1a74882a4ee265b4026abe30bdc
Reviewed-on: https://go-review.googlesource.com/c/go/+/219417
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile: add a dark mode to ssa html generation which can be toggled
Bradford Lamson-Scribner [Thu, 20 Feb 2020 16:07:48 +0000 (09:07 -0700)]
cmd/compile: add a dark mode to ssa html generation which can be toggled

add a tag that when clicked, toggles a dark mode. It keeps intact
the grayed out dead values/blocks, all the highlight colors, and ensures
text is always readable.

Fixes #34325

Change-Id: I4af1e4b5f4a5b63e54c992e90f8474cc51c63465
Reviewed-on: https://go-review.googlesource.com/c/go/+/220260
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/go, cmd/link: implement -buildmode=pie on windows
Alex Brainman [Tue, 25 Feb 2020 07:42:24 +0000 (18:42 +1100)]
cmd/go, cmd/link: implement -buildmode=pie on windows

This CL implements windows version of -buildmode=pie code in both
cmd/go and cmd/link.

Windows executables built with -buildmode=pie set (unlike the one
built with -buildmode=exe) will have extra .reloc PE section, and
will have no IMAGE_FILE_RELOCS_STRIPPED flag set. They will also
have IMAGE_DLLCHARACTERISTICS_DYNAMIC_BASE flag set, and
IMAGE_DLLCHARACTERISTICS_HIGH_ENTROPY_VA flag set for windows/amd64.

Both cgo and non-cgo versions are implemented. And TestBuildmodePIE
is extended to test both cgo and non-cgo versions on windows and
linux.

This CL used some code from CLs 152759 and 203602.

RELNOTE=yes

Fixes #27144
Updates #35192

Change-Id: I1249e4ffbd79bd4277efefb56db321c390c0f76f
Reviewed-on: https://go-review.googlesource.com/c/go/+/214397
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agotime: optimize Time.ISOWeek
Shuo [Sun, 1 Mar 2020 02:32:32 +0000 (02:32 +0000)]
time: optimize Time.ISOWeek

name       old time/op  new time/op  delta
ISOWeek-4  57.7ns ± 5%  27.9ns ±10%  -51.54%  (p=0.000 n=48+49)

Fixes #37534

Change-Id: Ic4673ced44a4b0190018e87207743ed9500fb1e0
GitHub-Last-Rev: a376c57e83a99f8e8fde297335caa85215e7aead
GitHub-Pull-Request: golang/go#36316
Reviewed-on: https://go-review.googlesource.com/c/go/+/212837
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoruntime/pprof/internal/profile: make error message readable
Ian Lance Taylor [Thu, 27 Feb 2020 19:24:24 +0000 (11:24 -0800)]
runtime/pprof/internal/profile: make error message readable

The error message for an unrecognized type in decodeField was using
string(i) for an int type i. It was recently changed (by  me) to
string(rune(i)), but that just avoided a vet warning without fixing
the problem. This CL fixes the problem by using fmt.Errorf.

We also change the message to "unknown wire type" to match the master
copy of this code in github.com/google/pprof/profile/proto.go.

Updates #32479

Change-Id: Ia91ea6d5edbd7cd946225d1ee96bb7623b52bb44
Reviewed-on: https://go-review.googlesource.com/c/go/+/221384
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
5 years agoruntime: don't invoke t.Fatal* in goroutine in TestLibraryCtrlHandler
Emmanuel T Odeke [Sat, 29 Feb 2020 10:32:21 +0000 (02:32 -0800)]
runtime: don't invoke t.Fatal* in goroutine in TestLibraryCtrlHandler

Change-Id: I8bb06c360cab3e5a74b0b0f98bb25cca4741d66d
Reviewed-on: https://go-review.googlesource.com/c/go/+/221605
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agonet/textproto: pass missing argument to fmt.Sprintf
Ian Lance Taylor [Thu, 27 Feb 2020 02:34:25 +0000 (18:34 -0800)]
net/textproto: pass missing argument to fmt.Sprintf

The vet tool didn't catch this because the fmt.Sprintf format argument
was written as an expression.

Fixes #37467

Change-Id: I72c20ba45e3f42c195fa5e68adcdb9837c7d7ad5
Reviewed-on: https://go-review.googlesource.com/c/go/+/221297
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
5 years agocmd/compile: lower float to uint conversions on s390x
Ruixin(Peter) Bao [Tue, 26 Nov 2019 15:52:43 +0000 (10:52 -0500)]
cmd/compile: lower float to uint conversions on s390x

Add rules for lowering float <-> unsigned int on s390x.

During compilation,
Cvt64Uto64F rule triggers around 80 times,
Cvt64Fto64U rule triggers around 20 times,
Cvt64Uto32F rule triggers around 5 times.

Change-Id: If4c9d128b9132fce8c0bea9abc09cb43a5df7989
Reviewed-on: https://go-review.googlesource.com/c/go/+/209177
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/compile: add more amd64 constant simplifications
Josh Bleecher Snyder [Fri, 28 Feb 2020 02:56:28 +0000 (18:56 -0800)]
cmd/compile: add more amd64 constant simplifications

More minor optimization opportunities from CL 220499.

Change-Id: Ic4f34c41ed8ab0fce227ac194731c1be12c602db
Reviewed-on: https://go-review.googlesource.com/c/go/+/221608
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agocmd/compile: constant fold SSA bool to int conversions
Josh Bleecher Snyder [Sat, 29 Feb 2020 15:07:56 +0000 (07:07 -0800)]
cmd/compile: constant fold SSA bool to int conversions

Shaves off a few instructions here and there.

file                        before   after    Δ       %
go/types.s                  322118   321851   -267    -0.083%
go/internal/gcimporter.s    34937    34909    -28     -0.080%
go/internal/gccgoimporter.s 56493    56474    -19     -0.034%
cmd/compile/internal/ssa.s  3926994  3927177  +183    +0.005%
total                       18862670 18862539 -131    -0.001%

Change-Id: I724f32317b946b5138224808f85709d9c097a247
Reviewed-on: https://go-review.googlesource.com/c/go/+/221428
Reviewed-by: Keith Randall <khr@golang.org>
5 years agocmd/compile: use correct types in phiopt
Josh Bleecher Snyder [Sat, 29 Feb 2020 01:04:16 +0000 (17:04 -0800)]
cmd/compile: use correct types in phiopt

We try to preserve type correctness of generic ops.
phiopt modified a bool to be an int without a conversion.
Add a conversion. There are a few random fluctations in the
generated code as a result, but nothing noteworthy or systematic.

no binary size changes

file                        before   after    Δ       %
math.s                      35966    35961    -5      -0.014%
debug/dwarf.s               108141   108147   +6      +0.006%
crypto/dsa.s                6047     6044     -3      -0.050%
image/png.s                 42882    42885    +3      +0.007%
go/parser.s                 80281    80278    -3      -0.004%
cmd/internal/obj.s          115116   115113   -3      -0.003%
go/types.s                  322130   322118   -12     -0.004%
cmd/internal/obj/arm64.s    151679   151685   +6      +0.004%
go/internal/gccgoimporter.s 56487    56493    +6      +0.011%
cmd/test2json.s             1650     1647     -3      -0.182%
cmd/link/internal/loadelf.s 35442    35443    +1      +0.003%
cmd/go/internal/work.s      305039   305035   -4      -0.001%
cmd/link/internal/ld.s      544835   544834   -1      -0.000%
net/http.s                  558777   558774   -3      -0.001%
cmd/compile/internal/ssa.s  3926551  3926994  +443    +0.011%
cmd/compile/internal/gc.s   1552320  1552321  +1      +0.000%
total                       18862241 18862670 +429    +0.002%

Change-Id: I4289e773be6be534ea3f907d68f614441b8f9b46
Reviewed-on: https://go-review.googlesource.com/c/go/+/221607
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agoruntime: do not exit(2) if a Go built DLL receives a signal
martin [Fri, 13 Dec 2019 00:03:04 +0000 (16:03 -0800)]
runtime: do not exit(2) if a Go built DLL receives a signal

Fixes #35965

Change-Id: I172501fc0b29595e59b058f6e30f31efe5f6d1f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/211139
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
5 years agointernal/cpu: add MIPS64x feature detection
Meng Zhuo [Fri, 28 Feb 2020 12:14:18 +0000 (20:14 +0800)]
internal/cpu: add MIPS64x feature detection

Change-Id: Iacdad1758aa15e4703fccef38c08ecb338b95fd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/200579
Run-TryBot: Meng Zhuo <mengzhuo1203@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agocmd/go: avoid matching wildcards rooted outside of available modules
Bryan C. Mills [Fri, 28 Feb 2020 20:03:54 +0000 (15:03 -0500)]
cmd/go: avoid matching wildcards rooted outside of available modules

To avoid confusion, also distinguish between packages and dirs in
search.Match results.

No test because this is technically only a performance optimization:
it would be very difficult to write such a test so that it would not
be flaky. (However, tested the change manually.)

Fixes #37521

Change-Id: I17b443699ce6a8f3a63805a7ef0be806f695a4b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/221544
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agodoc: update Effective Go with 1.14 language changes
Felix Cornelius [Fri, 28 Feb 2020 20:15:02 +0000 (20:15 +0000)]
doc: update Effective Go with 1.14 language changes

Fixes #37560

Change-Id: Iccb8e53254c45d203c1b42ea9b4d8509b93dd7a9
GitHub-Last-Rev: 5972b67e5d7b3b36ce1854ee9365197e78f654cd
GitHub-Pull-Request: golang/go#37563
Reviewed-on: https://go-review.googlesource.com/c/go/+/221429
Reviewed-by: Rob Pike <r@golang.org>
5 years agocmd/go: rationalize errors in internal/load and internal/modload
Bryan C. Mills [Mon, 8 Jul 2019 22:13:23 +0000 (18:13 -0400)]
cmd/go: rationalize errors in internal/load and internal/modload

This change is a non-minimal fix for #32917, but incidentally fixes
several other bugs and makes the error messages much more ergonomic.

Updates #32917
Updates #27122
Updates #28459
Updates #29280
Updates #30590
Updates #37214
Updates #36173
Updates #36587
Fixes #36008
Fixes #30992

Change-Id: Iedb26d2e0963697c130df5d0f72e7f83ec2dcf06
Reviewed-on: https://go-review.googlesource.com/c/go/+/185345
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go/internal/search: consolidate package-pattern predicates into Match methods
Bryan C. Mills [Thu, 27 Feb 2020 20:52:32 +0000 (15:52 -0500)]
cmd/go/internal/search: consolidate package-pattern predicates into Match methods

This change consolidates predicates currently scattered throughout
various parts of the package and module loader into methods on the
search.Match type.

That not only makes them more concise, but also encourages
consistency, both in the code and in reasoning about the kinds of
patterns that need to be handled. (For example, the IsLocal predicate
was previously two different calls, either of which could be easily
forgotten at a given call site.)

Factored out from CL 185344 and CL 185345.

Updates #32917

Change-Id: Ifa450ffaf6101f673e0ed69ced001a487d6f9335
Reviewed-on: https://go-review.googlesource.com/c/go/+/221458
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go/internal/search: record errors in the Match struct
Bryan C. Mills [Mon, 8 Jul 2019 22:11:23 +0000 (18:11 -0400)]
cmd/go/internal/search: record errors in the Match struct

Previously, we would either invoke base.Fatalf (which is too aggressive),
or log.Print (which is too passive).

Updates #32917

Change-Id: I5475e873e76948de7df65dca08bc0ce67a7fc827
Reviewed-on: https://go-review.googlesource.com/c/go/+/185344
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go/internal/modload: make AmbiguousImportError an ImportPathError
Michael Matloob [Thu, 27 Feb 2020 21:18:56 +0000 (16:18 -0500)]
cmd/go/internal/modload: make AmbiguousImportError an ImportPathError

AmbiguousImportErrors will now be formatted like other ImportPathErrors:
this means that now the ambiguously imported package won't be printed
twice. Whereas the error message looked like the following:

can't load package: package example.com/m/importy: ambiguous import: found package example.com/m/importy in multiple directories:
$WORK/importy
$WORK/vendor/example.com/m/importy

It now looks like this:

can't load package: ambiguous import: found package example.com/m/importy in multiple directories:
$WORK/importy
$WORK/vendor/example.com/m/importy

Change-Id: I52a2074a6b3f5eb7d78d331d0852b7ea6b3735e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/221457
Run-TryBot: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agonet: report port number correctly in Plan 9 error
Ian Lance Taylor [Thu, 27 Feb 2020 15:36:39 +0000 (07:36 -0800)]
net: report port number correctly in Plan 9 error

The code was incorrectly using a string conversion of a numeric port
to display the port number.

No test because as far as I can tell this code is only executed if
there is some error in a /net file.

Updates #32479

Change-Id: I0b8deebbf3c0b7cb1e1eee0fd059505f3f4c1623
Reviewed-on: https://go-review.googlesource.com/c/go/+/221377
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/compile: add dedicated ARM64BitField aux type
Josh Bleecher Snyder [Tue, 18 Feb 2020 01:47:34 +0000 (17:47 -0800)]
cmd/compile: add dedicated ARM64BitField aux type

The goal here is improved AuxInt printing in ssa.html.
Instead of displaying an inscrutable encoded integer,
it displays something like

v25 (28) = UBFX <int> [lsb=4,width=8] v52

which is much nicer for debugging.

Change-Id: I40713ff7f4a857c4557486cdf73c2dff137511ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/221420
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: improve SignExt32to64 on riscv64
Joel Sing [Tue, 25 Feb 2020 17:00:10 +0000 (04:00 +1100)]
cmd/compile: improve SignExt32to64 on riscv64

SignExt32to64 can be implemented with a single ADDIW instruction, rather than
the two shifts that are in use currently.

Change-Id: Ie1bbaef4018f1ba5162773fc64fa5a887457cfc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/220922
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/gofmt, go/format: sync internal.go
Dmitri Shuralyov [Fri, 28 Feb 2020 03:53:18 +0000 (22:53 -0500)]
cmd/gofmt, go/format: sync internal.go

Apply CL 40930 to src/cmd/gofmt/internal.go to bring
it into sync with src/go/format/internal.go.

Also revert '\n' back to "\n\n" in one of the comments,
because the previous text was more accurate.
Gofmt replaces the "; " part of "package p; func _() {"
input with two newline characters, not one.

Updates #11844

Change-Id: I6bb8155a931b793311991d3cd8e006a2931b167a
Reviewed-on: https://go-review.googlesource.com/c/go/+/221497
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agocmd/compile: add ellipsis rule diagnostics to rulegen
Josh Bleecher Snyder [Thu, 23 Jan 2020 22:33:26 +0000 (14:33 -0800)]
cmd/compile: add ellipsis rule diagnostics to rulegen

These detect opportunities to convert a rule to use an ellipsis,
and provide better error messages when something goes wrong.

This change was used to generate all the preceding changes
converting rules to use ellipses. This change is at the end of those
changes rather than the beginning in order to avoid log spam during rule
generation (say during a git bisection).

The preceding changes collectively shrink the cmd/compile binary by ~2.2%.

Part of this detection is also warning when the presence of an
unmentioned aux or auxint could cause conversion to an ellipsis
rule to change the sematics of the rule.

For example:

(Div64 x y) -> (DIV x y)

looks like a promising rule for an ellipsis. However, Div64 has an auxint,
and (on most platforms) DIV does not. An ellipsis rule would keep the
auxint intact, rather than zeroing it, which can infere with CSE.
So this change flags this rule as doing implicit zeroing;
it should be replaced by

(Div64 [a] x y) -> (DIV x y)

which makes it clear that the auxint is being zeroed.

This detection is not foolproof, but it currently has no false positives.
If false positives arise in the future, we will need to gate the output.

Change-Id: Ie21f284579e5d6e75aa304d0deb024d41ede528b
Reviewed-on: https://go-review.googlesource.com/c/go/+/217014
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
5 years agocmd/go: version command should error when given bad args
Daniel Martí [Thu, 27 Feb 2020 16:19:06 +0000 (16:19 +0000)]
cmd/go: version command should error when given bad args

For example, 'go version -m' happily gives you Go's own version, even
though the -m flag only makes sense when grabbing the version of a
binary on disk.

Similarly, if any of the directly named files can't be found, the tool
would succeed. That's acceptable if an error is encountered while
walking a large directory, but not when locating a path directly given
by the user.

These added test cases run even in short mode, as 'go build' is not
needed for them.

Change-Id: I7bb40b72853799e31d9f86cc5e999c8d57813eef
Reviewed-on: https://go-review.googlesource.com/c/go/+/221397
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agocmd/compile: optimize unsigned comparisons to 0/1 on amd64
Josh Bleecher Snyder [Wed, 1 Jan 2020 07:12:33 +0000 (23:12 -0800)]
cmd/compile: optimize unsigned comparisons to 0/1 on amd64

Plus a bonus optimization I noticed while working on this.

There are no functions (besides the rewrite rules) whose text size
increases as a result of this change.

Updates #21439

The following per-package text size stats were generated by parsing the
output of compiling with -S and summing the function size reported on the
STEXT line. This gives a far more accurate picture of the impact
on generated code than merely looking at the object file size changes
or the resulting binary size changes. The latter are below, for reference.

file                                          before  after   Δ       %
runtime.s                                     477257  476417  -840    -0.176%
math.s                                        35985   35976   -9      -0.025%
vendor/golang.org/x/net/dns/dnsmessage.s      87314   87232   -82     -0.094%
debug/dwarf.s                                 108444  108432  -12     -0.011%
regexp.s                                      64535   64467   -68     -0.105%
internal/xcoff.s                              23175   22945   -230    -0.992%
cmd/vendor/golang.org/x/arch/arm/armasm.s     45263   45260   -3      -0.007%
cmd/vendor/golang.org/x/arch/arm64/arm64asm.s 118140  118135  -5      -0.004%
cmd/internal/obj/arm64.s                      151502  151498  -4      -0.003%
cmd/compile/internal/ssa.s                    6061483 6063120 +1637   +0.027%
total                                         9321728 9322112 +384    +0.004%

file      before    after     Δ       %
go        15188916  15184820  -4096   -0.027%
addr2line 4315984   4311888   -4096   -0.095%
cgo       4836088   4831992   -4096   -0.085%
compile   24506008  24493720  -12288  -0.050%
doc       4680952   4676856   -4096   -0.088%
link      6605336   6601240   -4096   -0.062%
pprof     14776756  14772660  -4096   -0.028%
total     135250956 135214092 -36864  -0.027%

Change-Id: I1243a098a08db452f7d1eb0998e241c9b199e2b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/213058
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agoflag: update comment to refer to Output, not out
Ian Lance Taylor [Thu, 27 Feb 2020 19:11:48 +0000 (11:11 -0800)]
flag: update comment to refer to Output, not out

The out method was renamed to Output in CL 70391 for #17628 and #21888.

Fixes #37514

Change-Id: I99be47b5030ccbbf10a056df9fcc3c97cb99b015
Reviewed-on: https://go-review.googlesource.com/c/go/+/221383
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
5 years agonet/textproto: close channel to signal pipeline event completion
Tim Cooper [Thu, 27 Feb 2020 18:26:36 +0000 (12:26 -0600)]
net/textproto: close channel to signal pipeline event completion

Change-Id: I7e4827b3428b48c67060789a528586a8907ca3db
Reviewed-on: https://go-review.googlesource.com/c/go/+/221418
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/go/testdata/script: fix path separator in test to be os-independent
Michael Matloob [Thu, 27 Feb 2020 22:24:48 +0000 (17:24 -0500)]
cmd/go/testdata/script: fix path separator in test to be os-independent

Use ${:} instead of : so to be Windows-friendly.

Change-Id: I5e660af49b0a2ac2da868583cbcb55cf8bf89b68
Reviewed-on: https://go-review.googlesource.com/c/go/+/221461
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/go: roll forward "convert TestShadowingLogic to the script framework"
Michael Matloob [Thu, 20 Feb 2020 00:35:58 +0000 (00:35 +0000)]
cmd/go: roll forward "convert TestShadowingLogic to the script framework"

This rolls forward the change golang.org/cl/214431, which was reverted
in golang.org/cl/220217. The cl was broken because
TestVersionControlErrorMessageIncludesCorrectDirectory, which is going
to be removed in golang.org/cl/214429 hadn't been submitted yet.

Original change description:

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I87b3f9acb8575fbcbd58d454b5f9bac4923429b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/220178
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agocmd/go: convert testCDAndGOPATHAreDifferent to the script framework
Michael Matloob [Mon, 13 Jan 2020 20:24:56 +0000 (15:24 -0500)]
cmd/go: convert testCDAndGOPATHAreDifferent to the script framework

This is a bit complex. There's a driver program to run go with modifications
to the GOPATH used to test Windows.

Also remove the cd method on testgoData, because this was the last function
that used it.

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I3e8e27f37fd3701bd36b6365b128dd73b69181c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/214578
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go: convert TestLegacyModGet to the script framework
Michael Matloob [Thu, 9 Jan 2020 23:05:38 +0000 (18:05 -0500)]
cmd/go: convert TestLegacyModGet to the script framework

I think this test needs to be split up eventually. It's one of
the longest tests.

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: If2168fac040d78fd0ec3dcbdef2affd2a8f48f6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/214158
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go: convert TestLinkXImportPathEscape to the script framework
Michael Matloob [Mon, 13 Jan 2020 20:39:20 +0000 (15:39 -0500)]
cmd/go: convert TestLinkXImportPathEscape to the script framework

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: Ib386838081abad8bc6b01c1f0a4656553d0b6ff3
Reviewed-on: https://go-review.googlesource.com/c/go/+/214579
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go: convert some tests in vendor_test to the script framework
Michael Matloob [Mon, 6 Jan 2020 20:33:38 +0000 (15:33 -0500)]
cmd/go: convert some tests in vendor_test to the script framework

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I601e0fcee32b8c5bf2107b520d1dfbe12a19ad3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/213223
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go: convert TestGoBuildGOPATHOrder to the script framework
Michael Matloob [Mon, 13 Jan 2020 18:51:14 +0000 (13:51 -0500)]
cmd/go: convert TestGoBuildGOPATHOrder to the script framework

It looks like TestGoBuildGOPATHOrderBroken has been fixed so I've converted
that too, without the skip.

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I7ee77f22fb888811c175bcdc5eb814c80fbec420
Reviewed-on: https://go-review.googlesource.com/c/go/+/214432
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go: convert more tests to the script framework
Michael Matloob [Mon, 13 Jan 2020 16:30:52 +0000 (11:30 -0500)]
cmd/go: convert more tests to the script framework

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I394844da1ffc0dcde7f5862c41ed8efa7c5ca088
Reviewed-on: https://go-review.googlesource.com/c/go/+/214429
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go: convert TestGoTestRaceInstallsCgo to script framework
Michael Matloob [Mon, 13 Jan 2020 16:11:06 +0000 (11:11 -0500)]
cmd/go: convert TestGoTestRaceInstallsCgo to script framework

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I9a99aa5d37300c83a2f95fb906949cb4c1d5356f
Reviewed-on: https://go-review.googlesource.com/c/go/+/214426
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go: convert TestGoBuildARM to the script framework
Michael Matloob [Mon, 13 Jan 2020 15:54:34 +0000 (10:54 -0500)]
cmd/go: convert TestGoBuildARM to the script framework

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: If1e591f28d6399a07b37ed7f4a1419bf7cd915eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/214425
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go: convert TestGoTestBuildsAnXtestContainingOnly... to the script framework
Michael Matloob [Mon, 13 Jan 2020 15:43:09 +0000 (10:43 -0500)]
cmd/go: convert TestGoTestBuildsAnXtestContainingOnly... to the script framework

The name of the test is too long to fit on the first line. It's
TestGoTestBuildsAnXtestContainingOnlyNonRunnableExamples.

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I490748271b10a85cbe1d34f9dbecb86ccf0101a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/214423
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/go: convert TestPackageNotStaleWithTrailingSlash to script framework
Michael Matloob [Fri, 10 Jan 2020 23:15:38 +0000 (18:15 -0500)]
cmd/go: convert TestPackageNotStaleWithTrailingSlash to script framework

Part of converting all tests to script framework to improve
test parallelism.

Updates #36320
Updates #17751

Change-Id: I1020feaa4ddb40ff52c46728bc4973cea4c7b066
Reviewed-on: https://go-review.googlesource.com/c/go/+/214391
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/compile: ignore div/mod in prove on non-x86 architectures
Josh Bleecher Snyder [Mon, 24 Feb 2020 21:53:53 +0000 (13:53 -0800)]
cmd/compile: ignore div/mod in prove on non-x86 architectures

Instead of writing AuxInt during prove and then zeroing it during lower,
just don't write it in the first place.

Passes toolstash-check -all.

Change-Id: Iea4b555029a9d69332e835536f9cf3a42b8223db
Reviewed-on: https://go-review.googlesource.com/c/go/+/220682
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: document Move's type
Josh Bleecher Snyder [Tue, 25 Feb 2020 00:16:27 +0000 (16:16 -0800)]
cmd/compile: document Move's type

Fixes #37381

Change-Id: I8abf07d6342c10fc8d52e11c6a70fb0ec09220d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/220683
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/go/internal/modload: make PackageNotInModuleError reasonable for the Target module
Bryan C. Mills [Wed, 3 Jul 2019 21:12:32 +0000 (17:12 -0400)]
cmd/go/internal/modload: make PackageNotInModuleError reasonable for the Target module

Updates #28459
Updates #32917

Change-Id: Iced562cb7c2e0ac075d8345f1e4ad3b073842dcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/185343
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/compile: make inlining intrinsics cost one
Josh Bleecher Snyder [Fri, 14 Feb 2020 19:42:58 +0000 (11:42 -0800)]
cmd/compile: make inlining intrinsics cost one

We were assigning a cost of 2 for intrinsics:
One when we recognized an intrinsic,
and one for the OCALLFUNC node.

I believe that the intent was that intrinsics should
cost 1, since they are typically an arithmetic op,
and because they tend to occur in performance-sensitive code.
(Not that any of this is particularly principled right now.)

Stop charging when we recognize an intrinsic;
let the OCALLFUNC node cover the cost.

This has a negligible impact on std+cmd.

Change-Id: Ie6ae5c18da3ae7e40aec425aed95c6999c2831a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/221357
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agocmd/compile: check rune type bounds as int32, not uint32
Ian Lance Taylor [Thu, 27 Feb 2020 19:08:30 +0000 (11:08 -0800)]
cmd/compile: check rune type bounds as int32, not uint32

Also, avoid string(i) where i has type int.

Updates #32479

Change-Id: If3c6edc8523860082726e034ef9e887b5f7fabd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/221382
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agoall: fix incorrect channel and API usage in some unit tests
Ziheng Liu [Thu, 13 Feb 2020 21:20:30 +0000 (16:20 -0500)]
all: fix incorrect channel and API usage in some unit tests

This CL changes some unit test functions, making sure that these tests (and goroutines spawned during test) won't block.
Since they are just test functions, I use one CL to fix them all. I hope this won't cause trouble to reviewers and can save time for us.
There are three main categories of incorrect logic fixed by this CL:
1. Use testing.Fatal()/Fatalf() in spawned goroutines, which is forbidden by Go's document.
2. Channels are used in such a way that, when errors or timeout happen, the test will be blocked and never return.
3. Channels are used in such a way that, when errors or timeout happen, the test can return but some spawned goroutines will be leaked, occupying resource until all other tests return and the process is killed.

Change-Id: I3df931ec380794a0cf1404e632c1dd57c65d63e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/219380
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile: handle more cases in isNonNegative
Josh Bleecher Snyder [Fri, 20 Dec 2019 21:42:39 +0000 (13:42 -0800)]
cmd/compile: handle more cases in isNonNegative

The gains from this aren't particularly impressive.
Still, it is cheap and easy, and
it will keep me from wondering about whether it
might help to add X every time I look at this function.

This updated function is pretty exhaustive;
I examined every op encountered in a call to isNonNegative
when compiling all the stuff hanging around in my GOPATH,
for both 386 and amd64.

(32 bit architectures were somewhat neglected before.)

Object file size impact, 64 bit:

file                       before    after     Δ       %
archive/zip.a              359352    359284    -68     -0.019%
cmd/compile/internal/ssa.a 30715960  30717526  +1566   +0.005%
cmd/internal/obj/arm64.a   2972532   2972440   -92     -0.003%
cmd/internal/obj/riscv.a   297714    297672    -42     -0.014%
debug/dwarf.a              656336    655346    -990    -0.151%
debug/gosym.a              183352    183122    -230    -0.125%
encoding/gob.a             901130    900798    -332    -0.037%
image/gif.a                171884    171890    +6      +0.003%
internal/trace.a           506930    507270    +340    +0.067%
math.a                     233506    233490    -16     -0.007%
reflect.a                  1431740   1431476   -264    -0.018%
runtime.a                  3854480   3854332   -148    -0.004%
unicode/utf16.a            8920      8980      +60     +0.673%
total                      133000610 133000400 -210    -0.000%

Object file size impact, 32 bit:

file                                          before    after     Δ       %
archive/zip.a                                 330794    329640    -1154   -0.349%
cmd/compile/internal/gc.a                     8090204   8090026   -178    -0.002%
cmd/compile/internal/ssa.a                    29392460  29393890  +1430   +0.005%
cmd/internal/goobj2.a                         189512    189492    -20     -0.011%
cmd/internal/obj/arm64.a                      2444942   2444860   -82     -0.003%
cmd/internal/obj/riscv.a                      272848    272806    -42     -0.015%
cmd/link/internal/loader.a                    388548    388544    -4      -0.001%
cmd/link/internal/loadpe.a                    158776    158684    -92     -0.058%
cmd/vendor/golang.org/x/arch/ppc64/ppc64asm.a 511824    511316    -508    -0.099%
cmd/vendor/golang.org/x/arch/x86/x86asm.a     512812    512704    -108    -0.021%
cmd/vendor/golang.org/x/sys/unix.a            942422    942218    -204    -0.022%
compress/bzip2.a                              88768     88680     -88     -0.099%
crypto/tls.a                                  1655542   1655396   -146    -0.009%
debug/dwarf.a                                 608520    605822    -2698   -0.443%
debug/gosym.a                                 168282    168276    -6      -0.004%
debug/pe.a                                    173146    173108    -38     -0.022%
encoding/gob.a                                797978    797724    -254    -0.032%
encoding/hex.a                                44080     44020     -60     -0.136%
image/gif.a                                   152142    152148    +6      +0.004%
internal/xcoff.a                              186480    185834    -646    -0.346%
math.a                                        257866    257854    -12     -0.005%
net/http.a                                    3588246   3588150   -96     -0.003%
net/textproto.a                               162384    162120    -264    -0.163%
reflect.a                                     1316204   1316058   -146    -0.011%
regexp.a                                      373346    373248    -98     -0.026%
runtime/pprof.a                               345318    345088    -230    -0.067%
runtime.a                                     3513902   3513714   -188    -0.005%
syscall.a                                     781406    781018    -388    -0.050%
time.a                                        483814    483750    -64     -0.013%
unicode/utf16.a                               8394      8364      -30     -0.357%
vendor/golang.org/x/crypto/cryptobyte.a       287100    286706    -394    -0.137%
vendor/golang.org/x/net/route.a               175042    174724    -318    -0.182%
total                                         121677354 121670234 -7120   -0.006%

Change-Id: Ie672752feb5e94dd151836f852181980710e820d
Reviewed-on: https://go-review.googlesource.com/c/go/+/212777
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agonet: fix typo in unexported variable name
Mark Rushakoff [Thu, 27 Feb 2020 05:21:22 +0000 (05:21 +0000)]
net: fix typo in unexported variable name

Change-Id: Idf64716ef8cc3ceee2fc94462cba33ba60049f7b
GitHub-Last-Rev: ba550c5d136688e5aeaf3c9d4713b7f29bd17492
GitHub-Pull-Request: golang/go#36237
Reviewed-on: https://go-review.googlesource.com/c/go/+/212300
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
5 years agoruntime: don't panic on racy use of timers
Ian Lance Taylor [Wed, 26 Feb 2020 04:23:15 +0000 (20:23 -0800)]
runtime: don't panic on racy use of timers

If we see a racy use of timers, as in concurrent calls to Timer.Reset,
do the operations in an unpredictable order, rather than crashing.

Fixes #37400

Change-Id: Idbac295df2dfd551b6d762909d5040fc532c1b34
Reviewed-on: https://go-review.googlesource.com/c/go/+/221077
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
5 years agocmd/dist: enable cgo and PIE tests on android/arm64
Cherry Zhang [Wed, 26 Feb 2020 15:24:39 +0000 (10:24 -0500)]
cmd/dist: enable cgo and PIE tests on android/arm64

Now that android/arm64 supports internal linking PIE, enable the
test. While here, I realized that some cgo tests are also not
enabled on android/arm64. Enable them as well. Let's see if it
works.

Change-Id: Ibf186fe402ebf0bbec82873fd56d0eb752b48180
Reviewed-on: https://go-review.googlesource.com/c/go/+/221099
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/link: reenable internal linking PIE on linux/amd64 and linux/arm64
Cherry Zhang [Wed, 26 Feb 2020 15:08:30 +0000 (10:08 -0500)]
cmd/link: reenable internal linking PIE on linux/amd64 and linux/arm64

It was enabled in CL 207877, but then accidentally disabled in
CL 207299 due to a bad rebase. Reenable.

Change-Id: I147bf724a4263d4aae54576a36cc7e1cad5e8a2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/221098
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoio/ioutil: reject path separators in TempDir, TempFile pattern
Constantin Konstantinidis [Wed, 25 Dec 2019 16:24:07 +0000 (17:24 +0100)]
io/ioutil: reject path separators in TempDir, TempFile pattern

Fixes #33920

Change-Id: I2351a1caa80c086ff5a8e02aad70d996be7aac35
Reviewed-on: https://go-review.googlesource.com/c/go/+/212597
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agobuild: in clean.bash, look for 'go' in GOROOT/bin instead of GOBIN
Nikson Kanti Paul [Tue, 21 Jan 2020 00:50:27 +0000 (01:50 +0100)]
build: in clean.bash, look for 'go' in GOROOT/bin instead of GOBIN

Updates #14340
Updates #32674
Fixes #36659

Change-Id: I5bfaba4e53dab894d113dd5065794d66f1a25f2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/215478
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agocmd/compile: use immediates for MOVO of readonly sym
Josh Bleecher Snyder [Sun, 23 Feb 2020 06:05:05 +0000 (22:05 -0800)]
cmd/compile: use immediates for MOVO of readonly sym

file      before    after     Δ       %
addr2line 4307760   4303616   -4144   -0.096%
api       5968600   5968568   -32     -0.001%
asm       5109928   5122120   +12192  +0.239%
buildid   2843752   2839608   -4144   -0.146%
cgo       4823768   4819624   -4144   -0.086%
compile   20687848  20691800  +3952   +0.019%
cover     5259896   5255752   -4144   -0.079%
dist      3665176   3661032   -4144   -0.113%
doc       4668648   4668600   -48     -0.001%
fix       3368792   3368744   -48     -0.001%
link      6613328   6609200   -4128   -0.062%
nm        4253312   4253280   -32     -0.001%
objdump   4655360   4655312   -48     -0.001%
pack      2294312   2294280   -32     -0.001%
pprof     14747332  14747284  -48     -0.000%
test2json 2819416   2815272   -4144   -0.147%
trace     11669436  11665292  -4144   -0.036%
vet       8274184   8270040   -4144   -0.050%
total     116030848 116009424 -21424  -0.018%

Change-Id: Ice37222c4d76540b3591459f605321cbf142872d
Reviewed-on: https://go-review.googlesource.com/c/go/+/220690
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agocmd/compile: mark Lsyms as readonly earlier
Josh Bleecher Snyder [Mon, 17 Feb 2020 01:00:52 +0000 (17:00 -0800)]
cmd/compile: mark Lsyms as readonly earlier

The SSA backend has rules to read the contents of readonly Lsyms.
However, this rule was failing to trigger for many readonly Lsyms.
This is because the readonly attribute that was set on the Node.Name
was not propagated to its Lsym until the dump globals phase, after SSA runs.

To work around this phase ordering problem, introduce Node.SetReadonly,
which sets Node.Name.Readonly and also configures the Lsym
enough that SSA can use it.

This change also fixes a latent problem in the rewrite rule function,
namely that reads past the end of lsym.P were treated as entirely zero,
instead of merely requiring padding with trailing zeros.

This change also adds an amd64 rule needed to fully optimize
the results of this change. It would be better not to need this,
but the zero extension that should handle this for us
gets optimized away too soon (see #36897 for a similar problem).
I have not investigated whether other platforms also need new
rules to take full advantage of the new optimizations.

Compiled code for (interface{})(true) on amd64 goes from:

LEAQ type.bool(SB), AX
MOVBLZX ""..stmp_0(SB), BX
LEAQ runtime.staticbytes(SB), CX
ADDQ CX, BX

to

LEAQ type.bool(SB), AX
LEAQ runtime.staticbytes+1(SB), BX

Prior to this change, the readonly symbol rewrite rules
fired a total of 884 times during make.bash.
Afterwards they fire 1807 times.

file    before    after     Δ       %
cgo     4827832   4823736   -4096   -0.085%
compile 24907768  24895656  -12112  -0.049%
fix     3376952   3368760   -8192   -0.243%
pprof   14751700  14747604  -4096   -0.028%
total   120343528 120315032 -28496  -0.024%

Change-Id: I59ea52138276c37840f69e30fb109fd376d579ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/220499
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agocmd/compile: make clobber variadic
Josh Bleecher Snyder [Tue, 25 Feb 2020 01:30:44 +0000 (17:30 -0800)]
cmd/compile: make clobber variadic

There are often many values to clobber.
Allow passing them all in at once.
The goal is increased rule readability.
As a bonus, it shrinks cmd/compile by ~97k, almost half a percent.
Package SSA requires 1.2% less memory to compile.

The single-line changes were make via regex,
and the remaining multi-line clobbers were manually combined.

Passes toolstash-check -all.

Change-Id: Ib310e9265d3616211f8192c9040b4c8933824d19
Reviewed-on: https://go-review.googlesource.com/c/go/+/220691
Reviewed-by: Michael Munday <mike.munday@ibm.com>
5 years agocmd/link/internal/ld: bump NetBSD ABI version to 7.0
Tobias Klauser [Tue, 25 Feb 2020 09:18:55 +0000 (10:18 +0100)]
cmd/link/internal/ld: bump NetBSD ABI version to 7.0

According to https://golang.org/wiki/NetBSD, NetBSD 7.0 is supported as
of Go 1.3 (with Go 1.5 recommended). NetBSD 6.0 was last supported in Go
1.9.7. Thus, bump the minimal ABI version to NetBSD 7.0

Suggested by Benny Siegert in CL 212461.

Change-Id: I11dd14c6b835ac9fc156880b2551f71893c7f267
Reviewed-on: https://go-review.googlesource.com/c/go/+/220428
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: constant fold SHLxconst of a constant on amd64
Josh Bleecher Snyder [Sun, 23 Feb 2020 05:47:49 +0000 (21:47 -0800)]
cmd/compile: constant fold SHLxconst of a constant on amd64

These rules fire in particular when comparing to a constant
string of length two. They should trigger even more after CL 220499.

file    before    after     Δ       %
compile 20639976  20635880  -4096   -0.020%
total   116003456 115999360 -4096   -0.004%

Change-Id: I21c1c02cf32d710d7a4eb12efab00f02796ccb84
Reviewed-on: https://go-review.googlesource.com/c/go/+/220694
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agocmd/compile: merge const into storeidx on amd64
Josh Bleecher Snyder [Sun, 23 Feb 2020 04:05:12 +0000 (20:05 -0800)]
cmd/compile: merge const into storeidx on amd64

file    before    after     Δ       %
compile 20652264  20639976  -12288  -0.059%
trace   11673532  11669436  -4096   -0.035%
total   116019840 116003456 -16384  -0.014%

Change-Id: Id0522e08f10e77c885fba1d0d9b65f8981a647ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/220693
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agobytes: deflake TestGrow by using testing.AllocsPerRun
HowJMay [Wed, 26 Feb 2020 18:19:18 +0000 (18:19 +0000)]
bytes: deflake TestGrow by using testing.AllocsPerRun

Fixes #36695

Change-Id: I4392246015252018b49f321a5a839cc68cc611d7
GitHub-Last-Rev: c2fb1f7ddbe9b80059eed69f31781abe0a1db185
GitHub-Pull-Request: golang/go#36732
Reviewed-on: https://go-review.googlesource.com/c/go/+/216237
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/compile: simplify Slicemask on riscv64
Joel Sing [Tue, 25 Feb 2020 17:01:29 +0000 (04:01 +1100)]
cmd/compile: simplify Slicemask on riscv64

Slicemask can be performed with three immediate instructions, rather than the
six currently in use.

Change-Id: I3f8ca2d5affd1403db8fa79b356f248e6e9332c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/220923
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: improve Eq32/Neq32 on riscv64
Joel Sing [Tue, 25 Feb 2020 16:58:59 +0000 (03:58 +1100)]
cmd/compile: improve Eq32/Neq32 on riscv64

Use SUBW to perform a 32-bit subtraction, rather than zero extending from
32 to 64 bits. This reduces Eq32 and Neq32 to two instructions, rather than
the four instructions required previously.

Change-Id: Ib2798324881e9db842c864e91a0c1b1e48c4b67b
Reviewed-on: https://go-review.googlesource.com/c/go/+/220921
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agoencoding/json: consolidate the isSpace function
codesoap [Wed, 26 Feb 2020 17:36:01 +0000 (17:36 +0000)]
encoding/json: consolidate the isSpace function

The new code is easier to read, and practically equivalent in terms of
performance.

name                  old time/op    new time/op    delta
CodeUnmarshal-2          166ms ± 1%     166ms ± 1%    ~     (p=0.863 n=11+10)
CodeUnmarshalReuse-2     139ms ± 1%     139ms ± 1%    ~     (p=0.050 n=10+12)
UnmarshalString-2       1.08µs ± 1%    1.07µs ± 1%  -0.64%  (p=0.001 n=10+11)
UnmarshalFloat64-2      1.01µs ± 1%    1.01µs ± 1%    ~     (p=0.280 n=12+11)
UnmarshalInt64-2         850ns ± 0%     851ns ± 0%    ~     (p=0.455 n=11+12)

name                  old speed      new speed      delta
CodeUnmarshal-2       11.7MB/s ± 1%  11.7MB/s ± 1%    ~     (p=0.904 n=11+10)
CodeUnmarshalReuse-2  14.0MB/s ± 1%  14.0MB/s ± 1%  +0.40%  (p=0.041 n=10+12)

name                  old alloc/op   new alloc/op   delta
CodeUnmarshal-2         3.28MB ± 0%    3.28MB ± 0%    ~     (p=0.907 n=10+11)
CodeUnmarshalReuse-2    2.19MB ± 0%    2.19MB ± 0%    ~     (p=0.306 n=12+12)
UnmarshalString-2         192B ± 0%      192B ± 0%    ~     (all equal)
UnmarshalFloat64-2        180B ± 0%      180B ± 0%    ~     (all equal)
UnmarshalInt64-2          176B ± 0%      176B ± 0%    ~     (all equal)

name                  old allocs/op  new allocs/op  delta
CodeUnmarshal-2          92.7k ± 0%     92.7k ± 0%    ~     (all equal)
CodeUnmarshalReuse-2     80.4k ± 0%     80.4k ± 0%    ~     (all equal)
UnmarshalString-2         2.00 ± 0%      2.00 ± 0%    ~     (all equal)
UnmarshalFloat64-2        2.00 ± 0%      2.00 ± 0%    ~     (all equal)
UnmarshalInt64-2          1.00 ± 0%      1.00 ± 0%    ~     (all equal)

Change-Id: I6d5a48c624d436551409a17c21542e26d29e26b3
GitHub-Last-Rev: 7d81961688b5ee3a7e4718188c0eaf3413521f97
GitHub-Pull-Request: golang/go#37385
Reviewed-on: https://go-review.googlesource.com/c/go/+/220581
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Joe Tsai <joetsai@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocrypto/tls: use new ecdsa.VerifyASN1 API
Katie Hockman [Mon, 24 Feb 2020 22:23:19 +0000 (17:23 -0500)]
crypto/tls: use new ecdsa.VerifyASN1 API

Change-Id: I2a233190bda78ca022ff4074b4553788847d7583
Reviewed-on: https://go-review.googlesource.com/c/go/+/220720
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
5 years agotest: re-enable open-coded defer test on riscv64
Joel Sing [Tue, 25 Feb 2020 16:17:01 +0000 (03:17 +1100)]
test: re-enable open-coded defer test on riscv64

Open-coded defers were fixed and re-enabled on riscv64, however this test was
inadvertantly left disabled.

Updates #36786

Change-Id: I128fc84baa3d51f50d173e19e52051dc4d9a07c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/220920
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/go: escape $WORK in ccompile when -n is set
GrigoriyMikhalkin [Wed, 26 Feb 2020 15:02:36 +0000 (15:02 +0000)]
cmd/go: escape $WORK in ccompile when -n is set

Fixes #37012

Change-Id: I169807788c022042a2b5cf04f67ae41a7325fbcf
GitHub-Last-Rev: 9e77301c7ab3125a6f21f2c9cd998503976a5d5d
GitHub-Pull-Request: golang/go#37289
Reviewed-on: https://go-review.googlesource.com/c/go/+/219919
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocrypto/x509: use new ecdsa.VerifyASN1 API
Katie Hockman [Mon, 24 Feb 2020 22:25:08 +0000 (17:25 -0500)]
crypto/x509: use new ecdsa.VerifyASN1 API

Change-Id: Ia4f77d2965e34454e8dd3f2d8bf9c4f3065a9fbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/220721
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
5 years agocmd/go/internal/modfetch: retry rename for unzipped directories
Jay Conrod [Tue, 25 Feb 2020 19:54:18 +0000 (14:54 -0500)]
cmd/go/internal/modfetch: retry rename for unzipped directories

No test because this is difficult to reproduce, and such a test would
always be flaky.

Updates #36568

Change-Id: I8170410a7729ecc6f90baf8005444d6b1241185e
Reviewed-on: https://go-review.googlesource.com/c/go/+/220978
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
5 years agocmd/compile: output cost while inlining function with Debug['m'] > 1
TennyZhuang [Wed, 29 Jan 2020 03:47:49 +0000 (11:47 +0800)]
cmd/compile: output cost while inlining function with Debug['m'] > 1

The existing implementation outputs inline cost iff function cannot be inlined with Debug['m'] > 1, the cost info is also useful if the function is inlineable.

Fixes #36780

Change-Id: Ic96f6baf96aee25fb4b33d31d4d644dc2310e536
Reviewed-on: https://go-review.googlesource.com/c/go/+/216778
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
5 years agocmd/vendor: create modules.txt even for unused deps
Joshua Crowgey [Thu, 13 Feb 2020 06:02:10 +0000 (06:02 +0000)]
cmd/vendor: create modules.txt even for unused deps

`go mod vendor`  should create vendor/modules.txt even when the only deps
in go.mod are unused.

Fixes: #36580
Change-Id: I92a746d3f013bc2bdc3d2cec6e14b16f606c2edd
GitHub-Last-Rev: ea39a1c62294f42e5e5aab049f466189de0fd42d
GitHub-Pull-Request: golang/go#36920
Reviewed-on: https://go-review.googlesource.com/c/go/+/217135
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agocmd/compile: remove Greater* and Geq* generic integer ops
Michael Munday [Thu, 20 Feb 2020 17:46:08 +0000 (17:46 +0000)]
cmd/compile: remove Greater* and Geq* generic integer ops

The generic Greater and Geq ops can always be replaced with the Less and
Leq ops. This CL therefore removes them. This simplifies the compiler since
it reduces the number of operations that need handling in both code and in
rewrite rules. This will be especially true when adding control flow
optimizations such as the integer-in-range optimizations in CL 165998.

Change-Id: If0648b2b19998ac1bddccbf251283f3be4ec3040
Reviewed-on: https://go-review.googlesource.com/c/go/+/220417
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agocmd/compile: canonicalize comparison argument order
Michael Munday [Sun, 23 Feb 2020 22:08:24 +0000 (22:08 +0000)]
cmd/compile: canonicalize comparison argument order

Ensure that any comparison between two values has the same argument
order. This helps ensure that they can be eliminated during the
lowered CSE pass which will be particularly important if we eliminate
the Greater and Geq ops (see #37316).

Example:

  CMP R0, R1
  BLT L1
  CMP R1, R0 // different order, cannot eliminate
  BEQ L2

  CMP R0, R1
  BLT L1
  CMP R0, R1 // same order, can eliminate
  BEQ L2

This does have some drawbacks. Notably comparisons might 'flip'
direction in the assembly output after even small changes to the
code or compiler. It should help make optimizations more reliable
however.

compilecmp master -> HEAD
master (218f4572f5): text/template: make reflect.Value indirections more robust
HEAD (f1661fef3e): cmd/compile: canonicalize comparison argument order
platform: linux/amd64

file      before    after     Δ       %
api       6063927   6068023   +4096   +0.068%
asm       5191757   5183565   -8192   -0.158%
cgo       4893518   4901710   +8192   +0.167%
cover     5330345   5326249   -4096   -0.077%
fix       3417778   3421874   +4096   +0.120%
pprof     14889456  14885360  -4096   -0.028%
test2json 2848138   2844042   -4096   -0.144%
trace     11746239  11733951  -12288  -0.105%
total     132739173 132722789 -16384  -0.012%

Change-Id: I11736b3fe2a4553f6fc65018f475e88217fa22f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/220425
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agocmd/link: default to internal linking for android/arm64
Elias Naur [Fri, 15 Nov 2019 23:30:19 +0000 (18:30 -0500)]
cmd/link: default to internal linking for android/arm64

The bootstrapping process (make.bash) on all other platforms use
internal linking. This change brings android/arm64 in line, fixing the
scary warning on our self-hosted Corellium builders:

warning: unable to find runtime/cgo.a

The linkmode default is changed to internal for all Android programs,
but in practice that won't matter outside our builders: using Go with
Android apps requires buildmode=c-shared which uses linkmode external.

Fixes #31343
Updates #31819

Change-Id: I3b3ada5ed69a7989e6d8e5960bbebf5e1c22aada
Reviewed-on: https://go-review.googlesource.com/c/go/+/207299
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agofmt: do not remove trailing zeros for %g and %G with #(sharp) flag
yah01 [Wed, 26 Feb 2020 08:17:14 +0000 (08:17 +0000)]
fmt: do not remove trailing zeros for %g and %G with #(sharp) flag

Fixes #36562

Change-Id: Id98ae9f7362cfb825b306c36649d505692d6d60e
GitHub-Last-Rev: 405d51b12eb04da8cc3559c92f1546e69a8c1a19
GitHub-Pull-Request: golang/go#36588
Reviewed-on: https://go-review.googlesource.com/c/go/+/215001
Reviewed-by: Rob Pike <r@golang.org>
5 years agocrypto/x509: load roots from colon separated SSL_CERT_DIR in loadSystemRoots
Emmanuel T Odeke [Mon, 4 Nov 2019 17:19:59 +0000 (09:19 -0800)]
crypto/x509: load roots from colon separated SSL_CERT_DIR in loadSystemRoots

"SSL_CERT_DIR" is meant to hold more than one directory, when a colon
is used as a delimiter. However, we assumed it'd be a single directory
for all root certificates.
OpenSSL and BoringSSL properly respected the colon separated
"SSL_CERT_DIR", as per:
* OpenSSL https://github.com/openssl/openssl/blob/12a765a5235f181c2f4992b615eb5f892c368e88/crypto/x509/by_dir.c#L153-L209
* BoringSSL https://github.com/google/boringssl/blob/3ba9586bc081f67903c89917f23e74a0662ba953/crypto/x509/by_dir.c#L194-L247

This change adds that parity to loadSystemRoots.

RELNOTE=yes

Fixes #35325

Change-Id: I0d554a00ccc34300a7f0529aa741ee7e2d5762f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/205237
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoall: avoid string(i) where i has type int
Ian Lance Taylor [Tue, 25 Feb 2020 02:35:17 +0000 (18:35 -0800)]
all: avoid string(i) where i has type int

Instead use string(r) where r has type rune.

This is in preparation for a vet warning for string(i).

Updates #32479

Change-Id: Ic205269bba1bd41723950219ecfb67ce17a7aa79
Reviewed-on: https://go-review.googlesource.com/c/go/+/220844
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Akhil Indurti <aindurti@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Toshihiro Shiino <shiino.toshihiro@gmail.com>
5 years agoruntime: guard VZEROUPPER on CPU feature
Cherry Zhang [Wed, 26 Feb 2020 01:30:37 +0000 (20:30 -0500)]
runtime: guard VZEROUPPER on CPU feature

In CL 219131 we inserted a VZEROUPPER instruction on darwin/amd64.
The instruction is not available on pre-AVX machines. Guard it
with CPU feature.

Fixes #37459.

Change-Id: I9a064df277d091be4ee594eda5c7fd8ee323102b
Reviewed-on: https://go-review.googlesource.com/c/go/+/221057
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agoruntime: reorder race detector calls in slicecopy
Keith Randall [Sun, 16 Feb 2020 03:23:07 +0000 (19:23 -0800)]
runtime: reorder race detector calls in slicecopy

In rare circumstances, this helps report a race which would
otherwise go undetected.

Fixes #36794

Change-Id: I8a3c9bd6fc34efa51516393f7ee72531c34fb073
Reviewed-on: https://go-review.googlesource.com/c/go/+/220685
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
5 years agocmd/go: emit an error for extraneous files in GOROOT/src in module mode
Michael Matloob [Fri, 24 Jan 2020 22:21:48 +0000 (17:21 -0500)]
cmd/go: emit an error for extraneous files in GOROOT/src in module mode

If there's a go file immediately in GOROOT/src, it was probably
accidentally added by the user. Since that package shouldn't
exist, return an error if a user tries to list it. We're only making
this change for GOPATH mode because we don't want to break cases
where users have been doing this historically, but want to fix
this case for the future.

This also leaves open the weird cases where files are placed directly
in vendor directories.

Fixes #36587

Change-Id: I9738e47b1e89fd5048cbb8dd28e44648834b8ea7
Reviewed-on: https://go-review.googlesource.com/c/go/+/216381
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agomime: fix ExtensionsByType bug when there are duplicates
Brad Fitzpatrick [Tue, 14 Jan 2020 18:15:25 +0000 (18:15 +0000)]
mime: fix ExtensionsByType bug when there are duplicates

Also, sort them so the results aren't random.

Thanks to @junedev for the bug report & repro.

Fixes #36524

Change-Id: Ic9197ebeceddfb3d0aee895d8fc12ce4d205b164
Reviewed-on: https://go-review.googlesource.com/c/go/+/214680
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agomisc/wasm: avoid implicit boolean to number conversion
Brad Fitzpatrick [Wed, 15 Jan 2020 20:26:56 +0000 (20:26 +0000)]
misc/wasm: avoid implicit boolean to number conversion

Fixes #36561

Change-Id: I20cbf95ef4fd7c5c255a93ed3ec3e027a0ce2bc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/214944
Reviewed-by: Richard Musiol <neelance@gmail.com>
5 years agocmd/go/internal/{test,vet}: use a standard flag.FlagSet to parse flags
Bryan C. Mills [Wed, 11 Dec 2019 14:12:25 +0000 (09:12 -0500)]
cmd/go/internal/{test,vet}: use a standard flag.FlagSet to parse flags

This removes much of the complexity of the implementation and use of
the cmd/go/internal/cmdflag package, and makes the behavior of GOFLAGS
in 'go test' and 'go vet' more consistent with other subcommands.

Some of the complexity reduction has been offset by code comments and
bug fixes, particularly for the handling of GOPATH arguments and flag
terminators ('--').

Fixes #32471
Fixes #18682

Change-Id: I1f6e46a7c679062e1e409e44a2b9f03b9172883b
Reviewed-on: https://go-review.googlesource.com/c/go/+/211358
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agodoc/go1.14: add link to module migration guide
Alexander Rakoczy [Tue, 25 Feb 2020 18:44:18 +0000 (13:44 -0500)]
doc/go1.14: add link to module migration guide

Adding a link to this guide will provide more value to instructing Go
users to migrate to modules.

Updates #36878

Change-Id: Ie6ab45efcd35cc5e5ba5adc16ba0ca4cca4292bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/220906
Run-TryBot: Alexander Rakoczy <alex@golang.org>
Reviewed-by: thepudds <thepudds1460@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agodoc/articles/race_detector: mention memory leak potential
Kevin Burke [Mon, 24 Feb 2020 04:45:51 +0000 (20:45 -0800)]
doc/articles/race_detector: mention memory leak potential

As far as I can tell, there is no public documentation on this topic,
which cost me several days of debugging.

I am possibly unusual in that I run binaries in production with the
race detector turned on, but I think that others who do the same may
want to be aware of the risk.

Updates #26813.
Updates #37233.

Change-Id: I1f8111bd01d0000596e6057b7cb5ed017d5dc655
Reviewed-on: https://go-review.googlesource.com/c/go/+/220586
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
5 years agocmd/link: stop requiring the math package on ARM
Cherry Zhang [Mon, 24 Feb 2020 22:10:50 +0000 (17:10 -0500)]
cmd/link: stop requiring the math package on ARM

It was needed for the old softfloat implementation, which has
long gone.

Change-Id: Ib8d53689209a3b003d62f84c7c6047d8ec5df859
Reviewed-on: https://go-review.googlesource.com/c/go/+/220719
Reviewed-by: Than McIntosh <thanm@google.com>
5 years agocmd/asm: add asimd instruction 'rev16' on arm64
Xiangdong Ji [Tue, 7 Jan 2020 11:09:33 +0000 (11:09 +0000)]
cmd/asm: add asimd instruction 'rev16' on arm64

Add support to the asimd instruction rev16 which reverses elements in
16-bit halfwords.

syntax:
VREV16 <Vn>.<T>, <Vd>.<T>
<T> should be either B8 or B16.

Change-Id: I7a7b8e772589c51ca9eb6dca98bab1aac863c6c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/213738
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agomath/big: initial vector arithmetic in riscv64 assembly
Joel Sing [Tue, 25 Feb 2020 16:09:59 +0000 (03:09 +1100)]
math/big: initial vector arithmetic in riscv64 assembly

Provide an assembly implementation of mulWW - for now all others run the
Go code.

Change-Id: Icb594c31048255f131bdea8d64f56784fc9db4d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/220919
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agomath: implement Sqrt in assembly for riscv64
Joel Sing [Tue, 25 Feb 2020 16:05:57 +0000 (03:05 +1100)]
math: implement Sqrt in assembly for riscv64

Change-Id: I9a5dc33271434e58335f5562a30cc131c6a8332c
Reviewed-on: https://go-review.googlesource.com/c/go/+/220918
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agodoc: add Go 1.14 to release history
Carlos Amedee [Tue, 25 Feb 2020 16:05:35 +0000 (11:05 -0500)]
doc: add Go 1.14 to release history

Change-Id: I02afbd08ce9e0cd2af8953693b9c3066f6465914
Reviewed-on: https://go-review.googlesource.com/c/go/+/220900
Run-TryBot: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
5 years agocmd/compile: use ellipses in RISCV64 rules
Josh Bleecher Snyder [Thu, 23 Jan 2020 22:28:04 +0000 (14:28 -0800)]
cmd/compile: use ellipses in RISCV64 rules

Also, explicitly zero AuxInt in some ops (like Div),
to make it clear why they do not use an ellipsis.

Passes toolstash-check -all.

Change-Id: Iefd8891fca5d7be8aa1bb91eb1fe2c99c8bf9c88
Reviewed-on: https://go-review.googlesource.com/c/go/+/217011
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agoRevert "cmd/compile: don't allow NaNs in floating-point constant ops"
Bryan C. Mills [Tue, 25 Feb 2020 14:36:38 +0000 (14:36 +0000)]
Revert "cmd/compile: don't allow NaNs in floating-point constant ops"

This reverts CL 213477.

Reason for revert: tests are failing on linux-mips*-rtrk builders.

Change-Id: I8168f7450890233f1bd7e53930b73693c26d4dc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/220897
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agoruntime: fix file permission
Meng Zhuo [Tue, 25 Feb 2020 14:07:40 +0000 (22:07 +0800)]
runtime: fix file permission

Remove executable flag of .s files.

Change-Id: I8ba0c758b3650238643da50fbfe8f6cd07458f1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/220878
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agoRevert "Revert "cmd/go/internal/modload: record the replacement for the module contai...
Bryan C. Mills [Tue, 25 Feb 2020 14:58:30 +0000 (14:58 +0000)]
Revert "Revert "cmd/go/internal/modload: record the replacement for the module containing package main in BuildInfo""

This reverts CL 220722.

Reason for revert: rolling forward with fix.

Fixes #37392

Change-Id: Iba8b0c645267777fbb7019976292d691a10b906a
Reviewed-on: https://go-review.googlesource.com/c/go/+/220898
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/link: Revert -buildmode=pie to internal linking
Corne van der Plas [Tue, 19 Nov 2019 12:22:55 +0000 (13:22 +0100)]
cmd/link: Revert -buildmode=pie to internal linking

When internal linking was broken buildmode PIE is set to external
linking. Now internal linking is fixed, -buildmode=pie can default to
internal linking again.

Fixes #35545

Change-Id: Iaf86b3047eb76babebc1545a79125586a7a3980e
Reviewed-on: https://go-review.googlesource.com/c/go/+/207877
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/go: fix typo in comment
nu50218 [Tue, 25 Feb 2020 14:16:07 +0000 (14:16 +0000)]
cmd/go: fix typo in comment

fix CompiledGoFIles to CompiledGoFiles.

Change-Id: I1f21c2254e716197cb65a877ba7468e3d7009c6f
GitHub-Last-Rev: 177aa1a4962b3a70642c7761f9ab99723f22bc3e
GitHub-Pull-Request: golang/go#37440
Reviewed-on: https://go-review.googlesource.com/c/go/+/220879
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Toshihiro Shiino <shiino.toshihiro@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agosync: add new Map method LoadAndDelete
Changkun Ou [Fri, 8 Nov 2019 10:23:58 +0000 (11:23 +0100)]
sync: add new Map method LoadAndDelete

This CL implements a LoadAndDelete method in sync.Map. Benchmark:

name                                              time/op
LoadAndDeleteBalanced/*sync_test.RWMutexMap-12    98.8ns ± 1%
LoadAndDeleteBalanced/*sync.Map-12                10.3ns ±11%
LoadAndDeleteUnique/*sync_test.RWMutexMap-12      99.2ns ± 2%
LoadAndDeleteUnique/*sync.Map-12                  6.63ns ±10%
LoadAndDeleteCollision/*sync_test.DeepCopyMap-12   140ns ± 0%
LoadAndDeleteCollision/*sync_test.RWMutexMap-12   75.2ns ± 2%
LoadAndDeleteCollision/*sync.Map-12               5.21ns ± 5%

In addition, Delete is bounded and more efficient if many collisions:

DeleteCollision/*sync_test.DeepCopyMap-12   120ns ± 2%   125ns ± 1%   +3.80%  (p=0.000 n=10+9)
DeleteCollision/*sync_test.RWMutexMap-12   73.5ns ± 3%  79.5ns ± 1%   +8.03%  (p=0.000 n=10+9)
DeleteCollision/*sync.Map-12               97.8ns ± 3%   5.9ns ± 4%  -94.00%  (p=0.000 n=10+10)

Fixes #33762

Change-Id: Ic8469a7861d27ab0edeface0078aad8af9b26c2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/205899
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agoruntime: allow float syscall return values on windows amd64
Richard Wilkes [Mon, 24 Feb 2020 23:46:00 +0000 (23:46 +0000)]
runtime: allow float syscall return values on windows amd64

RELNOTE=yes
Fixes #37273

Change-Id: Iedb7eab185dfeccb1b26902ef36411d2c53ea3e0
GitHub-Last-Rev: bbe30ba45d4a1bd53757b5824ad28024d5e2b179
GitHub-Pull-Request: golang/go#37380
Reviewed-on: https://go-review.googlesource.com/c/go/+/220578
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>