]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
4 years agoRevert "time/tzdata: new package"
Ian Lance Taylor [Mon, 13 Apr 2020 23:26:39 +0000 (23:26 +0000)]
Revert "time/tzdata: new package"

This reverts CL 224588.

Reason for revert: Test failing on secondary platforms.

Change-Id: Ic15fdc73a0d2b860e776733abb82c58809e13160
Reviewed-on: https://go-review.googlesource.com/c/go/+/228200
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoio: simplify Examples
Eric [Mon, 13 Apr 2020 21:28:47 +0000 (21:28 +0000)]
io: simplify Examples

- CopyN: 5 creates ambiguity with respect to whitespace and upperbound
- TeeReader less boilerplate and displays a common usage of it
- SectionReader_* all sections unified to 5:17 for clarity
- SectionReader_Seek uses io.Copy to stdout like other examples
- Seeker_Seek remove useless prints
- Pipe print reader like other examples

Updates #36417

Change-Id: Ibd01761d5a5786cdb1ea934f7a98f8302430c8a5
GitHub-Last-Rev: 4c17f9a8e32d89743b7eaec7c52032256972cc0a
GitHub-Pull-Request: golang/go#38379
Reviewed-on: https://go-review.googlesource.com/c/go/+/227868
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/link: don't split container symbols when write blocks
Cherry Zhang [Sat, 11 Apr 2020 02:11:51 +0000 (22:11 -0400)]
cmd/link: don't split container symbols when write blocks

We split the output into blocks and write them in parallel. The
block boundary is placed at symbol boundary. In the case of outer
symbols and sub symbols, currently we may split an outer symbol
into two blocks. This will be bad, as the two blocks will have
overlapping address range, since outer symbol and its sub symbols
occupies the same address range.

Make sure we place block boundary only at top-level symbol
boundaries.

Fix boringcrypto build.

Change-Id: I56811d3969c65c6be97672d8e1f1ea36b2447465
Reviewed-on: https://go-review.googlesource.com/c/go/+/227957
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
(cherry picked from commit 636fa3148fe149923839a86e648dd87dc4d1537a)
Reviewed-on: https://go-review.googlesource.com/c/go/+/228138

4 years agocmd/compile: debug rewrite
Cherry Zhang [Fri, 24 Jan 2020 15:43:09 +0000 (10:43 -0500)]
cmd/compile: debug rewrite

If -d=ssa/PASS/debug=N is specified (N >= 2) for a rewrite pass
(e.g. lower), when a Value (or Block) is rewritten, print the
Value (or Block) before and after.

For #31915.
Updates #19013.

Change-Id: I80eadd44302ae736bc7daed0ef68529ab7a16776
Reviewed-on: https://go-review.googlesource.com/c/go/+/176718
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agotime/tzdata: new package
Ian Lance Taylor [Sun, 22 Mar 2020 01:28:16 +0000 (18:28 -0700)]
time/tzdata: new package

Importing the time/tzdata package will embed a copy of the IANA
timezone database into the program. This will let the program work
correctly when the timezone database is not available on the system.
It will increase the size of the binary by about 800K.

You can also build a program with -tags timetzdata to embed the
timezone database in the program being built.

Fixes #21881
Fixes #38013
Fixes #38017

Change-Id: Iffddee72a8f46c95fee3bcde43c142d6899d9246
Reviewed-on: https://go-review.googlesource.com/c/go/+/224588
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
4 years agocrypto/x509: fix test to prevent Gerrit keycheck errors
Katie Hockman [Mon, 13 Apr 2020 19:47:53 +0000 (15:47 -0400)]
crypto/x509: fix test to prevent Gerrit keycheck errors

Change-Id: I9e6a11c7d8c61d0182467438b35eb6756db7aa89
Reviewed-on: https://go-review.googlesource.com/c/go/+/228198
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
4 years agoruntime/pprof: clarify recursive inline heuristic
Michael Pratt [Tue, 7 Apr 2020 19:17:25 +0000 (15:17 -0400)]
runtime/pprof: clarify recursive inline heuristic

Following CL 226818, the compiler will allow inlining a single cycle in
an inline chain. Immediately-recursive functions are still disallowed,
which is what this heuristic refers to.

Add a regression test for this case.

Note that in addition to this check, if the compiler were to inline
multiple cycles via a loop (i.e., rather than appending duplicate code),
much more work would be required here to handle a single address
appearing in multiple different inline frames.

Updates #29737

Change-Id: I88de15cfbeabb9c04381e1c12cc36778623132a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/227346
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
4 years agoruntime/pprof: try to use real stack in TestTryAdd
Michael Pratt [Tue, 7 Apr 2020 16:12:44 +0000 (12:12 -0400)]
runtime/pprof: try to use real stack in TestTryAdd

TestTryAdd is particularly brittle because it tests some real cases by
constructing fake sample stack frames. If those frames don't correctly
represent what the runtime would generate then they may fail to catch
regressions.

Instead, call runtime.Callers at the bottom of real function calls to
generate real frames as a base for truncation, etc in tests. Several of
these tests still have to fake parts of the frames to test the right
thing, but this is a bit less fragile.

This change is equivalent to the original
0dfb0513ec6a0e97db166bd91a2dc0a1ceb154f7 (golang.org/cl/227484), except
that the test skips if the test functions aren't inline (e.g., noopt
builders).

Change-Id: Ie9e32b5660cfe28a924f9cfcddcd887ea2effd66
Reviewed-on: https://go-review.googlesource.com/c/go/+/227922
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocrypto/x509: generate SubjectKeyId for CAs
Katie Hockman [Fri, 3 Apr 2020 15:58:12 +0000 (11:58 -0400)]
crypto/x509: generate SubjectKeyId for CAs

Fixes #26676

Change-Id: I5bc91d4a8161bc6ff25effcf93f551f735fef115
Reviewed-on: https://go-review.googlesource.com/c/go/+/227098
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
4 years agoerrors: add example for Is
Jonathan Amsterdam [Sun, 12 Apr 2020 14:00:27 +0000 (10:00 -0400)]
errors: add example for Is

Add ExampleIs to illustrate how errors.Is works.

Updates #31716.
Updates #38369.

Change-Id: I1b9a6667614635aa3a5ed8b2c108d8eb6f35748b
Reviewed-on: https://go-review.googlesource.com/c/go/+/228038
Reviewed-by: Damien Neil <dneil@google.com>
4 years agocmd/cgo: fix parameter name in godoc comment for badPointerTypedef
Tobias Klauser [Mon, 13 Apr 2020 17:40:11 +0000 (19:40 +0200)]
cmd/cgo: fix parameter name in godoc comment for badPointerTypedef

The parameter name is dt, not t. Also, line-wrap the godoc comment.

Change-Id: Ie012d2a5680525b88e244a3380d72bc4f61da8e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/228058
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocrypto/tls: failed tls.Conn.Write returns a permanent error
Katie Hockman [Fri, 10 Apr 2020 14:06:29 +0000 (10:06 -0400)]
crypto/tls: failed tls.Conn.Write returns a permanent error

Fixes #29971

Change-Id: I2f1653640c88fafe0ec17a75dcf41d5896c4cb8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/227840
Run-TryBot: Katie Hockman <katie@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agoRevert "cmd/internal/obj/ppc64: add support for pcalign 32 on ppc64x"
Bryan C. Mills [Mon, 13 Apr 2020 14:56:32 +0000 (14:56 +0000)]
Revert "cmd/internal/obj/ppc64: add support for pcalign 32 on ppc64x"

This reverts CL 227775.

Reason for revert: broke aix-ppc64 builder (https://build.golang.org/log/cf3b4f9fd09ee81f422a4b58488b9d0a2692c949).

Change-Id: I2095bb2aadb5a4064eb89ad353012503faf15709
Reviewed-on: https://go-review.googlesource.com/c/go/+/228143
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: update TestIntendedInlining for riscv64
Joel Sing [Mon, 13 Apr 2020 16:36:36 +0000 (02:36 +1000)]
cmd/compile: update TestIntendedInlining for riscv64

Mark nextFreeFast as not inline, as it is too expensive to inline on riscv64.
Also remove riscv64 from non-atomic inline architectures, as we now have
atomic intrisics.

Updates #22239

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

4 years agocmd/trace: use the focustask mode for user task/region trace views
Hana (Hyang-Ah) Kim [Fri, 10 Apr 2020 18:56:59 +0000 (14:56 -0400)]
cmd/trace: use the focustask mode for user task/region trace views

The taskid mode is based on the goroutine-oriented trace view,
which displays each goroutine as a separate row. This is good when
inspecting the interaction and timeline among related goroutines,
and the user region information (associated with each goroutine)
in detail, but when many goroutines are involved, this mode does
not scale.

The focustask mode is based on the default trace view with the
user task hierarchy at the top. Each row is a P and there are only
a handful number of Ps in most cases, so browsers can handle
this mode more gracefully. But, I had difficulty in displaying
the user region information (because a goroutine can start/stop/
migrate across Ps, and visualizing the stack of regions nicely
was complicated). It may be doable, but it's a work.

This CL surfaces the hidden focustask mode. Moreover, use it
as the default user task view mode. The taskid mode can be still
accessible through 'goroutine view' links.

Unlike taskid-based user annotation view that extends goroutine-based
trace view, the focustask view

Change-Id: Ib691a5e1dd14695fa70a0ae67bff62817025e8c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/227921
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: ensure ... rules have compatible aux and auxint types
Keith Randall [Mon, 13 Apr 2020 03:05:14 +0000 (20:05 -0700)]
cmd/compile: ensure ... rules have compatible aux and auxint types

Otherwise, just copying the aux and auxint fields doesn't make much sense.
(Although there's no bug - it just means it isn't typechecked correctly.)

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

4 years agocmd/compile: convert more AMD64.rules lines to typed aux mode
Keith Randall [Mon, 13 Apr 2020 00:11:25 +0000 (17:11 -0700)]
cmd/compile: convert more AMD64.rules lines to typed aux mode

Change-Id: Idded860128b1a23680520d8c2b9f6d8620dcfcc7
Reviewed-on: https://go-review.googlesource.com/c/go/+/228077
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agointernal/cpu: unify HWCap/HWCap2 comments
Tobias Klauser [Mon, 13 Apr 2020 10:11:23 +0000 (12:11 +0200)]
internal/cpu: unify HWCap/HWCap2 comments

HWCap and HWCap2 are no longer linknamed into package runtime. Also,
merge two sentences both starting with "These are..." and don't mention
any file name where archauxv is defined, as it become outdated if
support for a new $GOOS/$GOARCH combination is added. This is e.g.
already the case for arm64, where archauxv is also defined for
freebsd/arm64.

Change-Id: I9314a66633736b12e777869a832d8b79d442a6f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/228057
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/link: fix spelling error
Kevin Burke [Mon, 13 Apr 2020 01:57:26 +0000 (18:57 -0700)]
cmd/link: fix spelling error

Change-Id: I6e730a99342563a97c3b1556893c8daaf5b6ec90
Reviewed-on: https://go-review.googlesource.com/c/go/+/228097
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agodoc/debugging_with_gdb: fix the link of delve
chainhelen [Sun, 12 Apr 2020 08:38:21 +0000 (08:38 +0000)]
doc/debugging_with_gdb: fix the link of delve

The repository of delve has already switched from the personal
account github.com/derekparker/delve to the organization account
github.com/go-delve/delve. According to go-delve/delve#1456.

Change-Id: Ie64f72c2808a8aca5059a75e2c2f11d8691e66b3
GitHub-Last-Rev: f90120c3b33f2134a572a62aaf291aa2abe58749
GitHub-Pull-Request: golang/go#38387
Reviewed-on: https://go-review.googlesource.com/c/go/+/227999
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: run TestLogOpt for riscv64 on amd64
Joel Sing [Sun, 12 Apr 2020 16:47:11 +0000 (02:47 +1000)]
cmd/compile: run TestLogOpt for riscv64 on amd64

Run TestLogOpt for riscv64 on amd64, as is done for other architectures.
This would have caught the test failure on riscv64 introduced in
47ade08141b23cfeafed92943e16012d5dc5eb8b.

Change-Id: If29dea2ef383b087154d046728f6d1c96811f5a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/227806
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agocmd/compile: rewrite some AMD64 rules to use typed aux fields
Keith Randall [Sun, 12 Apr 2020 02:51:09 +0000 (19:51 -0700)]
cmd/compile: rewrite some AMD64 rules to use typed aux fields

Surprisingly many rules needed no modification.

Use wrapper functions for aux like we did for auxint.
Simplifies things a bit.

Change-Id: I2e852e77f1585dcb306a976ab9335f1ac5b4a770
Reviewed-on: https://go-review.googlesource.com/c/go/+/227961
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
4 years agocmd/compile: move more generic rewrites to the typed version
Keith Randall [Sat, 11 Apr 2020 17:32:21 +0000 (10:32 -0700)]
cmd/compile: move more generic rewrites to the typed version

Change-Id: I22d0644710d12c7efc509fd2a15789e2e073e6a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/227869
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
4 years agocmd/compile: log large copies on riscv64
Joel Sing [Sun, 12 Apr 2020 15:39:45 +0000 (01:39 +1000)]
cmd/compile: log large copies on riscv64

Log large copies in the riscv64 compiler.

This was missed in 47ade08141b23cfeafed92943e16012d5dc5eb8b, resulting in
the new test added to cmd/compile/internal/logopt failing on riscv64.

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

4 years agocmd/compile: enable Sqrt as a compiler intrinsic on riscv64
Joel Sing [Sun, 12 Apr 2020 15:45:12 +0000 (01:45 +1000)]
cmd/compile: enable Sqrt as a compiler intrinsic on riscv64

Change-Id: I829a02ced9aa73b45079e67194186116b39504b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/227805
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agoruntime/race: rebuild netbsd .syso
Keith Randall [Sat, 11 Apr 2020 15:51:21 +0000 (08:51 -0700)]
runtime/race: rebuild netbsd .syso

Fixes #14481
Fixes #37355

Change-Id: Idfceaf0e64d340b7304ce9562549a82ebfc27e3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/227867
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
4 years agodoc/go1.15, net/url: document new method URL.Redacted
Emmanuel T Odeke [Sat, 11 Apr 2020 22:38:51 +0000 (15:38 -0700)]
doc/go1.15, net/url: document new method URL.Redacted

Adds an entry in the Go1.15 release notes, but also
adds an example test for URL.Redacted.

Follow-up of CL 207082.

Updates #37419

Change-Id: Ibf81989778907511a3a3a3e4a03d1802b5dd9762
Reviewed-on: https://go-review.googlesource.com/c/go/+/227997
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agostrconv: add comment re extFloat errorscale
Nigel Tao [Fri, 10 Apr 2020 01:01:14 +0000 (11:01 +1000)]
strconv: add comment re extFloat errorscale

Change-Id: I6f006ba72e1711ba2a24cd71552855ad88284eec
Reviewed-on: https://go-review.googlesource.com/c/go/+/227797
Reviewed-by: Rémy Oudompheng <remyoudompheng@gmail.com>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
4 years agocmd/compile: guard against invalid phis in shortcircuit
Josh Bleecher Snyder [Wed, 11 Mar 2020 21:49:37 +0000 (14:49 -0700)]
cmd/compile: guard against invalid phis in shortcircuit

In the review of CL 222923, Keith expressed concern
that we could end up with invalid phis.

We have some code to handle this, but on further reflection,
I think it might not handle some cases in which phis get moved.

I can't create a failing case, but guard against it nevertheless.

Change-Id: Ib3a07ac1d36a674c72dcb9cc9261ccfcb716b5a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/227697
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: correct comment for len check when make slice
Cuong Manh Le [Sat, 11 Apr 2020 14:49:10 +0000 (21:49 +0700)]
cmd/compile: correct comment for len check when make slice

CL 226737 optimizes len check when make slice. The comment that cap is
constrainted to [0, 2^31) is not quite true, it's 31 or 63 depends on
whether it's 32/64-bit systems.

Change-Id: I6f54e41827ffe4d0b67a44975da3ce07b2fabbad
Reviewed-on: https://go-review.googlesource.com/c/go/+/227803
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: move some generic rules to strongly typed
Keith Randall [Sat, 11 Apr 2020 04:38:49 +0000 (21:38 -0700)]
cmd/compile: move some generic rules to strongly typed

Move a lot of the constant folding rules to use strongly
typed AuxInt fields.

We need more than a cast to convert AuxInt to, e.g., float32.
Make conversion functions for converting back and forth.

Change-Id: Ia3d95ee3583ee2179a10938e20210a7617358c88
Reviewed-on: https://go-review.googlesource.com/c/go/+/227866
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Giovanni Bajo <rasky@develer.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
4 years agocmd/link: turn ASLR off for netbsd+race
Keith Randall [Fri, 10 Apr 2020 21:07:13 +0000 (14:07 -0700)]
cmd/link: turn ASLR off for netbsd+race

The race detector can't handle ASLR (adddress space layout randomization).
On some platforms it can re-exec the binary with ASLR off. But not NetBSD.
For NetBSD we have to introduce a special ELF header note that tells
the kernel not to use ASLR.

This works fine for internal linking. For external linking it also works,
but "readelf -n" shows multiple notes in the resulting binary. Maybe the
last one wins? Not sure, but it appears to work.

Change-Id: I5fe6dd861e42a8293f64d0dacb166631ea670fcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/227864
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
4 years agoRevert "cmd/compile: make logopt test skip if cannot create scratch directory"
Alex Brainman [Sat, 11 Apr 2020 03:33:21 +0000 (03:33 +0000)]
Revert "cmd/compile: make logopt test skip if cannot create scratch directory"

This reverts commit 98534812bdcdd22b13469ea587e310187876b7d2.

Reason for revert: The change does not really fixes issue #38251. CL 227497 is real fix.

Change-Id: I9f556005baf1de968f059fb8dad89dae05330aa6
Reviewed-on: https://go-review.googlesource.com/c/go/+/227802
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agocmd/compile: add explanations to escape-analysis JSON/LSP logging
David Chase [Mon, 11 Nov 2019 18:18:38 +0000 (13:18 -0500)]
cmd/compile: add explanations to escape-analysis JSON/LSP logging

For 1.15.

From the test:

{"range":{"start":{"line":7,"character":13},"end":{...},"severity":3,"code":"leaks","source":"go compiler","message":"parameter z leaks to ~r2 with derefs=0","relatedInformation":[
{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow:    flow: y = z:"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow:      from y = \u003cN\u003e (assign-pair)"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow:    flow: ~r1 = y:"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":4,"character":11},"end":{...}},"message":"inlineLoc"},

{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow:      from y.b (dot of pointer)"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":4,"character":11},"end":{...}},"message":"inlineLoc"},

{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow:      from \u0026y.b (address-of)"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":4,"character":9},"end":...}},"message":"inlineLoc"},

{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":13},"end":{...}},"message":"escflow:      from ~r1 = \u003cN\u003e (assign-pair)"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":3},"end":...}},"message":"escflow:    flow: ~r2 = ~r1:"},
{"location":{"uri":"file://T/file.go","range":{"start":{"line":9,"character":3},"end":...}},"message":"escflow:      from return (*int)(~r1) (return)"}]}

Change-Id: Idf02438801f63e487c35a928cf5a0b6d3cc48674
Reviewed-on: https://go-review.googlesource.com/c/go/+/206658
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: change gc logging to report inline failure instead of success
David Chase [Wed, 4 Mar 2020 21:33:54 +0000 (16:33 -0500)]
cmd/compile: change gc logging to report inline failure instead of success

I've been experimenting with this, success is the wrong thing to report
even though it seems to log much less.

Change-Id: I7c25a45d2f41e82b6c8dd8b0a56ba848c63fb21a
Reviewed-on: https://go-review.googlesource.com/c/go/+/223298
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: prevent constant folding of +/- when result is NaN
Keith Randall [Fri, 10 Apr 2020 16:43:22 +0000 (09:43 -0700)]
cmd/compile: prevent constant folding of +/- when result is NaN

Missed as part of CL 221790. It isn't just * and / that can make NaNs.

Update #36400
Fixes #38359

Change-Id: I3fa562f772fe03b510793a6dc0cf6189c0c3e652
Reviewed-on: https://go-review.googlesource.com/c/go/+/227860
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
4 years agocmd/internal/obj/ppc64: add support for pcalign 32 on ppc64x
Lynn Boger [Tue, 31 Mar 2020 14:08:29 +0000 (10:08 -0400)]
cmd/internal/obj/ppc64: add support for pcalign 32 on ppc64x

Previous PCALIGN support on ppc64x only accepted 8 and 16 byte
alignment since the default function alignment was 16. Now that
the function's alignment can be set to a larger value when needed,
PCALIGN can accept 32. When this happens then the function's
alignment will be changed to 32.

Test has been updated to recognized this new value.

Change-Id: If82c3cd50d7c686fcf8a9e819708b15660cdfa63
Reviewed-on: https://go-review.googlesource.com/c/go/+/227775
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agotest: add test case that gccgo failed to compile
Ian Lance Taylor [Fri, 10 Apr 2020 00:34:07 +0000 (17:34 -0700)]
test: add test case that gccgo failed to compile

Change-Id: I08ca5f77b7352fe3ced1fbe3d027d6f5b4828e35
Reviewed-on: https://go-review.googlesource.com/c/go/+/227783
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile: use a Sym type instead of interface{} for symbolic offsets
Keith Randall [Fri, 10 Apr 2020 03:28:55 +0000 (20:28 -0700)]
cmd/compile: use a Sym type instead of interface{} for symbolic offsets

Will help with strongly typed rewrite rules.

Change-Id: Ifbf316a49f4081322b3b8f13bc962713437d9aba
Reviewed-on: https://go-review.googlesource.com/c/go/+/227785
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
4 years agoregexp: add (*Regexp).SubexpIndex
Sylvain Zimmer [Mon, 29 Jul 2019 01:15:36 +0000 (03:15 +0200)]
regexp: add (*Regexp).SubexpIndex

SubexpIndex returns the index of the first subexpression with the given name,
or -1 if there is no subexpression with that name.

Fixes #32420

Change-Id: Ie1f9d22d50fb84e18added80a9d9a9f6dca8ffc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/187919
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
4 years agoruntime: replace the type of netpollWakeSig from a uintptr to a uint32
Andy Pan [Fri, 10 Apr 2020 02:45:58 +0000 (10:45 +0800)]
runtime: replace the type of netpollWakeSig from a uintptr to a uint32

There's no need for netpollWakeSig to use a uintptr type, a uint32 is enough.

Relevant CL: CL 212737

Change-Id: Ide24478b217a02bad62f7e000a9680c26a8c5366
Reviewed-on: https://go-review.googlesource.com/c/go/+/227798
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoos/exec: extend grace period in TestExtraFiles to 20% of overall deadline
Bryan C. Mills [Thu, 9 Apr 2020 15:09:00 +0000 (11:09 -0400)]
os/exec: extend grace period in TestExtraFiles to 20% of overall deadline

Updates #25628

Change-Id: I938a7646521b34779a3a57833e7ce9d508b58faf
Reviewed-on: https://go-review.googlesource.com/c/go/+/227765
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: start implementing strongly typed aux and auxint fields
Keith Randall [Thu, 19 Mar 2020 23:25:08 +0000 (16:25 -0700)]
cmd/compile: start implementing strongly typed aux and auxint fields

Right now the Aux and AuxInt fields of ssa.Values are typed as
interface{} and int64, respectively. Each rule that uses these values
must cast them to the type they actually are (*obj.LSym, or int32, or
ValAndOff, etc.), use them, and then cast them back to interface{} or
int64.

We know for each opcode what the types of the Aux and AuxInt fields
should be. So let's modify the rule generator to declare the types to
be what we know they should be, autoconverting to and from the generic
types for us. That way we can make the rules more type safe.

It's difficult to make a single CL for this, so I've coopted the "=>"
token to indicate a rule that is strongly typed. "->" rules are
processed as before. That will let us migrate a few rules at a time in
separate CLs.  Hopefully we can reach a state where all rules are
strongly typed and we can drop the distinction.

This CL changes just a few rules to get a feel for what this
transition would look like.

I've decided not to put explicit types in the rules. I think it
makes the rules somewhat clearer, but definitely more verbose.
In particular, the passthrough rules that don't modify the fields
in question are verbose for no real reason.

Change-Id: I63a1b789ac5702e7caf7934cd49f784235d1d73d
Reviewed-on: https://go-review.googlesource.com/c/go/+/190197
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agocmd/compile: use isel with variable shifts on ppc64x
Lynn Boger [Wed, 1 Apr 2020 14:30:05 +0000 (10:30 -0400)]
cmd/compile: use isel with variable shifts on ppc64x

This changes the code generated for variable length shift
counts to use isel instead of instructions that set and
read the carry flag.

This reduces the generated code for shifts like this
by 1 instruction and avoids the use of instructions to
set and read the carry flag.

This sequence can be found in strconv with these results
on power9:

Atof64Decimal                          71.6ns ± 0%  68.3ns ± 0%   -4.61%
Atof64Float                            95.3ns ± 0%  90.9ns ± 0%   -4.62%
Atof64FloatExp                          153ns ± 0%   149ns ± 0%   -2.61%
Atof64Big                               234ns ± 0%   232ns ± 0%   -0.85%
Atof64RandomBits                        348ns ± 0%   369ns ± 0%   +6.03%
Atof64RandomFloats                      262ns ± 0%   262ns ± 0%     ~
Atof32Decimal                          72.0ns ± 0%  68.2ns ± 0%   -5.28%
Atof32Float                            92.1ns ± 0%  87.1ns ± 0%   -5.43%
Atof32FloatExp                          159ns ± 0%   158ns ± 0%   -0.63%
Atof32Random                            194ns ± 0%   191ns ± 0%   -1.55%

Some tests in codegen/shift.go are enabled to verify the
expected instructions are generated.

Change-Id: I968715d10ada405a8c46132bf19b8ed9b85796d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/227337
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agotest: deflaking measures for runtime gdb test
Than McIntosh [Fri, 13 Mar 2020 15:09:05 +0000 (11:09 -0400)]
test: deflaking measures for runtime gdb test

Tweak the runtime's GDB python test to try to reduce flake failures.

Background: the intent of the testpoint in question is to make sure
that python-supported commands like "info goroutines" or "goroutine 1
backtrace" work properly. The Go code being run under the debugger as
part of the test is single-threaded, but the test is written assuming
that in addition to the primary goroutine there will be other
background goroutines available (owned by the runtime). The flakiness
seems to crop up the most when requesting a backtrace for one of these
background goroutines; the speculation is that if we catch a
runtime-owned goroutine in an odd state, this could interfere with the
test.

The change in this patch is to explicitly start an additional
goroutine from the main thread, so that when the debugger stops the
main thread we can be sure that there is some other non-main goroutine
in a known state.

This change authored by Josh Bleecher Snyder <josharian@gmail.com>.

Updates #24616.

Change-Id: I45682323d5898e5187c0adada7c5d117e92f403b
Reviewed-on: https://go-review.googlesource.com/c/go/+/226558
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/oldlink: delete darwin/386 host object loading support
Cherry Zhang [Thu, 9 Apr 2020 15:35:24 +0000 (11:35 -0400)]
cmd/oldlink: delete darwin/386 host object loading support

In Go 1.15, the darwin/386 port is gone.

Updates #37610.

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

4 years agocmd/internal/obj/ppc64: leverage AND operation to calculate remainder
Andy Pan [Sun, 5 Apr 2020 14:21:11 +0000 (22:21 +0800)]
cmd/internal/obj/ppc64: leverage AND operation to calculate remainder

Change-Id: I03e2a573eb778591071db4f783585a5d71a14c03
Reviewed-on: https://go-review.googlesource.com/c/go/+/227005
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
4 years agonet: convert many Close tests to use parallel subtests
Bryan C. Mills [Wed, 8 Apr 2020 16:51:50 +0000 (12:51 -0400)]
net: convert many Close tests to use parallel subtests

Also set a deadline in TestCloseWrite so that we can more easily
determine which kind of connection is getting stuck on the
darwin-arm64-corellium builder (#34837).

Change-Id: I8ccacbf436e8e493fb2298a79b17e0af8fc6eb81
Reviewed-on: https://go-review.googlesource.com/c/go/+/227588
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: do not allocate bucket for non-escaping map
Cuong Manh Le [Tue, 7 Apr 2020 20:08:21 +0000 (03:08 +0700)]
cmd/compile: do not allocate bucket for non-escaping map

For map with hint larger than BUCKETSIZE, makemap ignore allocated
bucket and allocate buckets itself. So do not allocate bucket in
this case, save us the cost of zeroing+assignment to the bucket.

name                            old time/op    new time/op    delta
NewEmptyMap-12                    3.89ns ± 4%    3.88ns ± 2%    ~     (p=0.939 n=19+20)
NewSmallMap-12                    23.3ns ± 3%    23.1ns ± 2%    ~     (p=0.307 n=18+17)
NewEmptyMapHintLessThan8-12       6.43ns ± 3%    6.31ns ± 2%  -1.72%  (p=0.000 n=19+18)
NewEmptyMapHintGreaterThan8-12     159ns ± 2%     150ns ± 1%  -5.79%  (p=0.000 n=20+18)

Benchmark run with commit ab7c174 reverted, see #38314.

Fixes #20184

Change-Id: Ic021f57454c3a0dd50601d73bbd77b8faf8d93b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/227458
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoencoding/xml: fix reserved namespace check to be case-insensitive
Tamás Gulácsi [Fri, 25 Oct 2019 11:48:02 +0000 (13:48 +0200)]
encoding/xml: fix reserved namespace check to be case-insensitive

Fixes the check for the reserved namespace prefix
"xml" to be case insensitive, so as to match all variants of:

    (('X'|'x')('M'|'m')('L'|'l'))

as mandated by Section 2.3 of https://www.w3.org/TR/REC-xml/

Fixes #35151.

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

4 years agocmd/compile: remove gdata layer in slicesym
Josh Bleecher Snyder [Wed, 8 Apr 2020 20:51:25 +0000 (13:51 -0700)]
cmd/compile: remove gdata layer in slicesym

The previous change moved code around to create slicesym.
This change simplifies slicesym and its callsites
by accepting an int64 for lencap instead of a node,
and by removing all the calls to gdata.
It also stops modifying n,
which avoids the need to make a copy of it.

Passes toolstash-check.

Change-Id: I4d25454d11b4bb8941000244443e3c99eef4bdd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/227550
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: refactor static slice symbol creation
Josh Bleecher Snyder [Wed, 8 Apr 2020 20:41:59 +0000 (13:41 -0700)]
cmd/compile: refactor static slice symbol creation

This change mostly moves code around to unify it.
A subsequent change will simplify and improve slicesym.

Passes toolstash-check.

Change-Id: I84a877ea747febb2b571d4089ba6d905b51b27ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/227549
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: clean up slice and string offsets/sizes
Josh Bleecher Snyder [Wed, 8 Apr 2020 19:36:35 +0000 (12:36 -0700)]
cmd/compile: clean up slice and string offsets/sizes

Minor cleanup:

* Modernize comments.
* Change from int to int64 to avoid conversions.
* Use idiomatic names.

Passes toolstash-check.

Change-Id: I93560c81926c0f4e00f33129cb4846b53bea99e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/227548
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: use math/bits for bvec
Josh Bleecher Snyder [Tue, 28 May 2019 17:35:26 +0000 (10:35 -0700)]
cmd/compile: use math/bits for bvec

And delete some dead code.

Minor cleanup. Passes toolstash-check.

Change-Id: Ia3c77c6bf14942654d00d125a6221e63a442f3c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/227317
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: use optimized slice zeroing in deadcode
Josh Bleecher Snyder [Tue, 28 May 2019 21:29:28 +0000 (14:29 -0700)]
cmd/compile: use optimized slice zeroing in deadcode

Minor cleanup. Passes toolstash-check.

Change-Id: I97a027c4ca49ded593e9c7989e9e091ab9336fa3
Reviewed-on: https://go-review.googlesource.com/c/go/+/227318
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile,runtime: pass only ptr and len to some runtime calls
Josh Bleecher Snyder [Sat, 1 Feb 2020 05:01:55 +0000 (21:01 -0800)]
cmd/compile,runtime: pass only ptr and len to some runtime calls

Some runtime calls accept a slice, but only use ptr and len.
This change modifies most such routines to accept only ptr and len.

After this change, the only runtime calls that accept an unnecessary
cap arg are concatstrings and slicerunetostring.
Neither is particularly common, and both are complicated to modify.

Negligible compiler performance impact. Shrinks binaries a little.
There are only a few regressions; the one I investigated was
due to register allocation fluctuation.

Passes 'go test -race std cmd', modulo #38265 and #38266.
Wow, does that take a long time to run.

Updates #36890

file      before    after     Δ       %
compile   19655024  19655152  +128    +0.001%
cover     5244840   5236648   -8192   -0.156%
dist      3662376   3658280   -4096   -0.112%
link      6680056   6675960   -4096   -0.061%
pprof     14789844  14777556  -12288  -0.083%
test2json 2824744   2820648   -4096   -0.145%
trace     11647876  11639684  -8192   -0.070%
vet       8260472   8256376   -4096   -0.050%
total     115163736 115118808 -44928  -0.039%

Change-Id: Idb29fa6a81d6a82bfd3b65740b98cf3275ca0a78
Reviewed-on: https://go-review.googlesource.com/c/go/+/227163
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: handle some additional phis in shortcircuit
Josh Bleecher Snyder [Wed, 11 Mar 2020 12:39:08 +0000 (05:39 -0700)]
cmd/compile: handle some additional phis in shortcircuit

Prior to this change, the shortcircuit pass could only
handle blocks containing only a single phi control value,
possibly wrapped in some OpNot and OpCopy values.

This change partially lifts this limitation.
It handles some cases in which the block contains other phi values.
This appears to happen most commonly in cases in which
the conditionals being checked involve the memory state,
in which case there is a phi memory value in the block.

The general idea here is to use the information we have about
the CFG to (1) move the other phi values into other blocks
and/or (2) rewrite uses of the other phi values in other blocks.

For example, consider this CFG:

p   q
 \ /
  b
 / \
t   u

And consider a phi value v in block b.
We'll write v = Phi(p: x, q: y) to say that v has value x corresponding
to inbound block p, and value y for block q.

We will rewrite this CFG to:

p    q
|   /
|  b
|/  \
t    u

What should we do with v?

Any uses of v in u can be replaced with y. Why?
If we are in block u, we came from b, and before that from q.
If prior to b we came from p, then we would have gone to t, not u.
Since we came from q, we know that v took the value y.

Uses of v in t are a bit more complicated.
It is going to end up being a phi value: Phi(p: ?, b: ?).

Suppose, after the rewrite, we came from block p.
Then, before the rewrite, we would have gone to b,
where v would have the value x.
So we have Phi(p: x, b: ?).

Suppose, after the rewrite, we came from block b.
Then we must have come from block q.
If we come from block q, v has value y.
So we have Phi(p: x, b: y).
Uses of v in t can thus be replaced with a new phi value,
with the same values as v, but with altered predecessors.

Similar reasoning can be employed to rewrite or replace
other uses of v elsewhere in the CFG, so that v itself can be eliminated,
and the CFG rewrite can proceed.

This change sets up the infrastructure for such optimizations
and adds a few cheap ones. All optimizations in this change depend
only on the shape of the CFG; future changes may also depend on where
v's uses are. That analysis is more powerful but more expensive,
and should be done incrementally.

The use of closures here is perhaps a bit unusual,
but during development it proved critical to having readable code.
We must decide early on whether we can safely do the CFG modifications,
and then later fix up the phis if so.
Safely storing state and decisions across these two phases is hard to do readably.
Closures solve the problem neatly.

I manually instrumented the code paths in shortcircuitPhiPlan.
During make.bash there are nearly 6000 invocations.
The least-visited code path gets run 85 times,
so all the code in this CL is reasonably well-exercised.

Here is a concrete example of code improved by this change:

func f(e interface{}) int {
if x, ok := e.(int); ok {
return x
}
return 0
}

Omitting PCDATA, FUNCDATA, and the like, it used to compile to:

"".f STEXT nosplit size=50 args=0x18 locals=0x0
0x0000 00000 (x.go:4) LEAQ type.int(SB), AX
0x0007 00007 (x.go:4) MOVQ "".e+8(SP), CX
0x000c 00012 (x.go:4) CMPQ AX, CX
0x000f 00015 (x.go:4) JNE 43
0x0011 00017 (x.go:4) MOVQ "".e+16(SP), AX
0x0016 00022 (x.go:4) MOVQ (AX), AX
0x0019 00025 (x.go:4) JNE 33
0x001b 00027 (x.go:5) MOVQ AX, "".~r1+24(SP)
0x0020 00032 (x.go:5) RET
0x0021 00033 (x.go:7) MOVQ $0, "".~r1+24(SP)
0x002a 00042 (x.go:7) RET
0x002b 00043 (x.go:7) MOVL $0, AX
0x0030 00048 (x.go:4) JMP 25

Afterwards, it compiles to:

"".f STEXT nosplit size=41 args=0x18 locals=0x0
0x0000 00000 (x.go:4) LEAQ type.int(SB), AX
0x0007 00007 (x.go:4) MOVQ "".e+8(SP), CX
0x000c 00012 (x.go:4) CMPQ AX, CX
0x000f 00015 (x.go:4) JNE 31
0x0011 00017 (x.go:4) MOVQ "".e+16(SP), AX
0x0016 00022 (x.go:4) MOVQ (AX), AX
0x0019 00025 (x.go:5) MOVQ AX, "".~r1+24(SP)
0x001e 00030 (x.go:5) RET
0x001f 00031 (x.go:7) MOVQ $0, "".~r1+24(SP)
0x0028 00040 (x.go:7) RET

Note that there is now only a single JNE and a single RET $0 path.

Updates #37608

Has a minor good effect on compilation speed and memory use.

Provides widespread improvements to generated code.
The rare, minor regressions I have investigated are due to
register allocation fluctuations.

file      before    after     Δ       %
addr2line 4376080   4371984   -4096   -0.094%
api       5945400   5933112   -12288  -0.207%
asm       5034312   5030216   -4096   -0.081%
buildid   2844952   2840856   -4096   -0.144%
cgo       4812872   4804680   -8192   -0.170%
compile   19622064  19610368  -11696  -0.060%
cover     5236648   5232552   -4096   -0.078%
dist      3658312   3654216   -4096   -0.112%
doc       4653512   4649416   -4096   -0.088%
fix       3370072   3365976   -4096   -0.122%
link      6671864   6667768   -4096   -0.061%
pprof     14781652  14761172  -20480  -0.139%
trace     11639684  11627396  -12288  -0.106%
vet       8252280   8231800   -20480  -0.248%
total     115052984 114934792 -118192 -0.103%

file                                                                     before   after    Δ       %
internal/cpu.s                                                           3298     3296     -2      -0.061%
internal/bytealg.s                                                       1730     1737     +7      +0.405%
cmd/vendor/golang.org/x/mod/semver.s                                     7332     7283     -49     -0.668%
image/color.s                                                            8248     8156     -92     -1.115%
math.s                                                                   35966    35956    -10     -0.028%
math/cmplx.s                                                             6596     6575     -21     -0.318%
runtime.s                                                                480566   480053   -513    -0.107%
sync.s                                                                   16408    16385    -23     -0.140%
math/rand.s                                                              10447    10406    -41     -0.392%
internal/reflectlite.s                                                   28408    28366    -42     -0.148%
errors.s                                                                 2736     2701     -35     -1.279%
sort.s                                                                   17031    17036    +5      +0.029%
io.s                                                                     16993    16964    -29     -0.171%
container/heap.s                                                         2006     1997     -9      -0.449%
text/tabwriter.s                                                         9570     9552     -18     -0.188%
bytes.s                                                                  31823    31594    -229    -0.720%
strconv.s                                                                52760    52717    -43     -0.082%
vendor/golang.org/x/text/transform.s                                     16713    16706    -7      -0.042%
strings.s                                                                42590    42563    -27     -0.063%
bufio.s                                                                  22883    22785    -98     -0.428%
encoding/base32.s                                                        9586     9531     -55     -0.574%
syscall.s                                                                82237    82243    +6      +0.007%
image.s                                                                  37465    37452    -13     -0.035%
regexp/syntax.s                                                          82827    82769    -58     -0.070%
image/draw.s                                                             18698    18584    -114    -0.610%
image/jpeg.s                                                             36560    36549    -11     -0.030%
time.s                                                                   82557    82526    -31     -0.038%
context.s                                                                10863    10820    -43     -0.396%
regexp.s                                                                 64114    64049    -65     -0.101%
os.s                                                                     51751    51524    -227    -0.439%
reflect.s                                                                168240   168049   -191    -0.114%
cmd/go/internal/lockedfile/internal/filelock.s                           2317     2290     -27     -1.165%
path/filepath.s                                                          17831    17766    -65     -0.365%
io/ioutil.s                                                              6994     6990     -4      -0.057%
encoding/binary.s                                                        30791    30726    -65     -0.211%
cmd/vendor/golang.org/x/sys/unix.s                                       78055    78033    -22     -0.028%
encoding/pem.s                                                           9280     9247     -33     -0.356%
crypto/cipher.s                                                          20376    20374    -2      -0.010%
os/exec.s                                                                29229    29140    -89     -0.304%
internal/goroot.s                                                        4588     4579     -9      -0.196%
cmd/internal/browser.s                                                   2246     2240     -6      -0.267%
cmd/vendor/golang.org/x/crypto/ssh/terminal.s                            27183    27149    -34     -0.125%
fmt.s                                                                    76625    76484    -141    -0.184%
encoding/hex.s                                                           6154     6152     -2      -0.032%
compress/lzw.s                                                           7063     7059     -4      -0.057%
database/sql/driver.s                                                    18875    18862    -13     -0.069%
debug/plan9obj.s                                                         8268     8266     -2      -0.024%
net/url.s                                                                29724    29719    -5      -0.017%
encoding/csv.s                                                           12872    12856    -16     -0.124%
debug/gosym.s                                                            25303    25268    -35     -0.138%
compress/flate.s                                                         50952    51019    +67     +0.131%
compress/zlib.s                                                          7277     7266     -11     -0.151%
archive/zip.s                                                            42155    42111    -44     -0.104%
debug/dwarf.s                                                            107632   107541   -91     -0.085%
database/sql.s                                                           98373    98028    -345    -0.351%
os/user.s                                                                14722    14708    -14     -0.095%
encoding/json.s                                                          105836   105711   -125    -0.118%
debug/macho.s                                                            32598    32560    -38     -0.117%
encoding/gob.s                                                           136478   135755   -723    -0.530%
debug/pe.s                                                               31160    30869    -291    -0.934%
debug/elf.s                                                              63495    63302    -193    -0.304%
vendor/golang.org/x/text/unicode/bidi.s                                  27220    27217    -3      -0.011%
vendor/golang.org/x/text/secure/bidirule.s                               3363     3352     -11     -0.327%
go/token.s                                                               12036    12035    -1      -0.008%
flag.s                                                                   22277    22256    -21     -0.094%
mime.s                                                                   39696    39509    -187    -0.471%
go/scanner.s                                                             19033    19020    -13     -0.068%
archive/tar.s                                                            70936    70581    -355    -0.500%
internal/xcoff.s                                                         22823    22820    -3      -0.013%
text/scanner.s                                                           11631    11629    -2      -0.017%
encoding/xml.s                                                           110534   110408   -126    -0.114%
math/big.s                                                               183636   183545   -91     -0.050%
image/gif.s                                                              27376    27343    -33     -0.121%
crypto/dsa.s                                                             6029     5969     -60     -0.995%
image/png.s                                                              42947    42939    -8      -0.019%
crypto/rand.s                                                            6866     6854     -12     -0.175%
vendor/golang.org/x/text/unicode/norm.s                                  66394    66354    -40     -0.060%
runtime/trace.s                                                          2603     2521     -82     -3.150%
crypto/ed25519.s                                                         6321     6300     -21     -0.332%
text/template/parse.s                                                    93910    93844    -66     -0.070%
crypto/rsa.s                                                             31460    31369    -91     -0.289%
encoding/asn1.s                                                          57021    57023    +2      +0.004%
crypto/elliptic.s                                                        51382    51363    -19     -0.037%
crypto/x509/pkix.s                                                       10386    10342    -44     -0.424%
vendor/golang.org/x/net/idna.s                                           24482    24466    -16     -0.065%
vendor/golang.org/x/crypto/cryptobyte.s                                  33479    33280    -199    -0.594%
crypto/ecdsa.s                                                           11936    11883    -53     -0.444%
go/constant.s                                                            43670    42663    -1007   -2.306%
go/ast.s                                                                 80383    80191    -192    -0.239%
testing.s                                                                68069    68057    -12     -0.018%
runtime/pprof.s                                                          59613    59603    -10     -0.017%
testing/iotest.s                                                         4895     4891     -4      -0.082%
internal/trace.s                                                         78136    78089    -47     -0.060%
cmd/internal/goobj2.s                                                    13158    13154    -4      -0.030%
cmd/internal/src.s                                                       17661    17657    -4      -0.023%
go/parser.s                                                              79046    78880    -166    -0.210%
cmd/internal/objabi.s                                                    16367    16343    -24     -0.147%
text/template.s                                                          94899    94486    -413    -0.435%
go/printer.s                                                             77267    76992    -275    -0.356%
cmd/internal/goobj.s                                                     25988    25947    -41     -0.158%
runtime/pprof/internal/profile.s                                         102066   101933   -133    -0.130%
go/format.s                                                              5419     5371     -48     -0.886%
cmd/vendor/golang.org/x/arch/ppc64/ppc64asm.s                            37181    37149    -32     -0.086%
go/doc.s                                                                 74533    74132    -401    -0.538%
html/template.s                                                          88743    88389    -354    -0.399%
cmd/asm/internal/lex.s                                                   24881    24872    -9      -0.036%
cmd/internal/buildid.s                                                   18263    18256    -7      -0.038%
cmd/vendor/golang.org/x/arch/x86/x86asm.s                                80036    79980    -56     -0.070%
go/build.s                                                               68905    68737    -168    -0.244%
cmd/cover.s                                                              46070    45950    -120    -0.260%
cmd/internal/obj.s                                                       117001   116991   -10     -0.009%
cmd/doc.s                                                                62700    62419    -281    -0.448%
cmd/internal/obj/arm.s                                                   66745    66687    -58     -0.087%
cmd/compile/internal/syntax.s                                            145406   145062   -344    -0.237%
cmd/internal/obj/wasm.s                                                  44049    44027    -22     -0.050%
net.s                                                                    291835   291020   -815    -0.279%
cmd/dist.s                                                               209020   208807   -213    -0.102%
cmd/cgo.s                                                                241564   241102   -462    -0.191%
vendor/golang.org/x/net/http/httpproxy.s                                 9407     9399     -8      -0.085%
log/syslog.s                                                             7921     7909     -12     -0.151%
go/types.s                                                               319325   317513   -1812   -0.567%
vendor/golang.org/x/net/http/httpguts.s                                  3834     3825     -9      -0.235%
mime/multipart.s                                                         21414    21343    -71     -0.332%
cmd/internal/obj/ppc64.s                                                 119949   119938   -11     -0.009%
cmd/compile/internal/logopt.s                                            10158    10118    -40     -0.394%
vendor/golang.org/x/net/nettest.s                                        28012    27991    -21     -0.075%
go/internal/srcimporter.s                                                6405     6380     -25     -0.390%
go/internal/gcimporter.s                                                 34525    34493    -32     -0.093%
net/mail.s                                                               23937    23720    -217    -0.907%
go/internal/gccgoimporter.s                                              56095    56038    -57     -0.102%
cmd/compile/internal/types.s                                             47247    47207    -40     -0.085%
cmd/api.s                                                                39582    39558    -24     -0.061%
cmd/go/internal/base.s                                                   12572    12551    -21     -0.167%
cmd/vendor/golang.org/x/xerrors.s                                        17846    17814    -32     -0.179%
cmd/vendor/golang.org/x/mod/sumdb/note.s                                 18142    18070    -72     -0.397%
cmd/go/internal/search.s                                                 19994    19876    -118    -0.590%
cmd/go/internal/imports.s                                                16457    16428    -29     -0.176%
cmd/vendor/golang.org/x/mod/module.s                                     17838    17759    -79     -0.443%
cmd/go/internal/cache.s                                                  30551    30514    -37     -0.121%
cmd/vendor/golang.org/x/mod/sumdb/tlog.s                                 36356    36321    -35     -0.096%
cmd/internal/test2json.s                                                 9452     9408     -44     -0.466%
cmd/go/internal/mvs.s                                                    25136    25092    -44     -0.175%
cmd/go/internal/txtar.s                                                  3488     3461     -27     -0.774%
cmd/vendor/golang.org/x/mod/zip.s                                        18811    18800    -11     -0.058%
cmd/go/internal/version.s                                                11213    11171    -42     -0.375%
cmd/link/internal/benchmark.s                                            4941     4949     +8      +0.162%
cmd/internal/obj/s390x.s                                                 126865   126849   -16     -0.013%
cmd/gofmt.s                                                              30684    30596    -88     -0.287%
cmd/fix.s                                                                87450    86906    -544    -0.622%
cmd/internal/obj/x86.s                                                   88578    88556    -22     -0.025%
cmd/vendor/golang.org/x/mod/modfile.s                                    72450    72363    -87     -0.120%
cmd/oldlink/internal/loader.s                                            16743    16741    -2      -0.012%
cmd/pack.s                                                               14863    14861    -2      -0.013%
cmd/go/internal/load.s                                                   106742   106568   -174    -0.163%
cmd/oldlink/internal/objfile.s                                           21787    21780    -7      -0.032%
cmd/oldlink/internal/loadmacho.s                                         29309    29317    +8      +0.027%
cmd/oldlink/internal/loadelf.s                                           35013    35021    +8      +0.023%
cmd/asm/internal/asm.s                                                   68550    68538    -12     -0.018%
cmd/link/internal/loader.s                                               94765    94564    -201    -0.212%
cmd/link/internal/loadelf.s                                              35663    35667    +4      +0.011%
cmd/link/internal/loadmacho.s                                            29501    29509    +8      +0.027%
cmd/vendor/golang.org/x/tools/go/analysis.s                              4983     4976     -7      -0.140%
cmd/vendor/golang.org/x/tools/go/analysis/internal/analysisflags.s       16771    16709    -62     -0.370%
cmd/vendor/golang.org/x/tools/go/types/objectpath.s                      18481    18456    -25     -0.135%
cmd/vendor/golang.org/x/tools/go/analysis/passes/internal/analysisutil.s 2100     2085     -15     -0.714%
cmd/vendor/github.com/google/pprof/profile.s                             150141   149620   -521    -0.347%
cmd/vendor/github.com/google/pprof/internal/measurement.s                10420    10404    -16     -0.154%
cmd/vendor/golang.org/x/tools/go/analysis/passes/asmdecl.s               36814    36755    -59     -0.160%
cmd/vendor/golang.org/x/tools/go/analysis/passes/bools.s                 6688     6673     -15     -0.224%
cmd/vendor/golang.org/x/tools/go/analysis/passes/cgocall.s               9856     9784     -72     -0.731%
cmd/vendor/golang.org/x/tools/go/analysis/passes/composite.s             3011     2979     -32     -1.063%
cmd/vendor/golang.org/x/tools/go/analysis/passes/copylock.s              9737     9682     -55     -0.565%
cmd/vendor/golang.org/x/tools/go/cfg.s                                   30738    30725    -13     -0.042%
cmd/vendor/github.com/ianlancetaylor/demangle.s                          175195   174513   -682    -0.389%
cmd/vendor/golang.org/x/tools/go/analysis/passes/httpresponse.s          3625     3520     -105    -2.897%
cmd/vendor/golang.org/x/tools/go/analysis/passes/loopclosure.s           2987     2971     -16     -0.536%
cmd/vendor/golang.org/x/tools/go/analysis/passes/shift.s                 4372     4340     -32     -0.732%
cmd/vendor/golang.org/x/tools/go/analysis/passes/stdmethods.s            8634     8611     -23     -0.266%
cmd/vendor/golang.org/x/tools/go/analysis/passes/tests.s                 6189     6164     -25     -0.404%
cmd/vendor/golang.org/x/tools/go/analysis/passes/structtag.s             8089     8073     -16     -0.198%
cmd/vendor/golang.org/x/tools/go/analysis/passes/unsafeptr.s             2208     2177     -31     -1.404%
cmd/vendor/golang.org/x/tools/go/analysis/passes/unreachable.s           8050     8047     -3      -0.037%
cmd/vendor/golang.org/x/tools/go/analysis/passes/unusedresult.s          3665     3629     -36     -0.982%
cmd/vendor/golang.org/x/tools/go/ast/astutil.s                           65773    65680    -93     -0.141%
cmd/vendor/golang.org/x/tools/go/analysis/unitchecker.s                  13328    13286    -42     -0.315%
cmd/vendor/golang.org/x/tools/go/types/typeutil.s                        12263    12162    -101    -0.824%
cmd/vendor/golang.org/x/tools/go/analysis/passes/errorsas.s              1459     1421     -38     -2.605%
cmd/vendor/golang.org/x/tools/go/analysis/passes/ctrlflow.s              5208     5191     -17     -0.326%
cmd/vendor/golang.org/x/tools/go/analysis/passes/unmarshal.s             1801     1782     -19     -1.055%
cmd/vendor/golang.org/x/tools/go/analysis/passes/lostcancel.s            9569     9528     -41     -0.428%
cmd/go/internal/work.s                                                   304928   304756   -172    -0.056%
crypto/x509.s                                                            147340   147139   -201    -0.136%
cmd/vendor/golang.org/x/tools/go/analysis/passes/printf.s                34287    34019    -268    -0.782%
crypto/tls.s                                                             311603   310644   -959    -0.308%
cmd/oldlink/internal/ld.s                                                533115   532651   -464    -0.087%
cmd/oldlink/internal/wasm.s                                              16484    16458    -26     -0.158%
cmd/oldlink/internal/x86.s                                               18832    18830    -2      -0.011%
cmd/link/internal/ld.s                                                   548200   547626   -574    -0.105%
cmd/link/internal/wasm.s                                                 16760    16734    -26     -0.155%
cmd/link/internal/arm64.s                                                20850    20840    -10     -0.048%
cmd/link/internal/x86.s                                                  17437    17435    -2      -0.011%
net/http.s                                                               556647   555519   -1128   -0.203%
net/http/cookiejar.s                                                     15849    15833    -16     -0.101%
expvar.s                                                                 9521     9508     -13     -0.137%
net/http/httptest.s                                                      16471    16452    -19     -0.115%
cmd/vendor/github.com/google/pprof/internal/plugin.s                     4266     4264     -2      -0.047%
net/http/cgi.s                                                           23448    23428    -20     -0.085%
cmd/go/internal/web.s                                                    16472    16428    -44     -0.267%
net/http/httputil.s                                                      39672    39670    -2      -0.005%
net/rpc.s                                                                33989    33965    -24     -0.071%
net/http/fcgi.s                                                          19167    19162    -5      -0.026%
cmd/vendor/github.com/google/pprof/internal/symbolz.s                    5861     5857     -4      -0.068%
cmd/vendor/github.com/google/pprof/internal/binutils.s                   35842    35823    -19     -0.053%
cmd/vendor/github.com/google/pprof/internal/symbolizer.s                 11449    11404    -45     -0.393%
cmd/go/internal/get.s                                                    62726    62582    -144    -0.230%
cmd/vendor/github.com/google/pprof/internal/report.s                     80032    80022    -10     -0.012%
cmd/go/internal/modfetch/codehost.s                                      89005    88871    -134    -0.151%
cmd/trace.s                                                              116607   116496   -111    -0.095%
cmd/vendor/github.com/google/pprof/internal/driver.s                     143234   143207   -27     -0.019%
cmd/vendor/github.com/google/pprof/driver.s                              9000     8998     -2      -0.022%
cmd/go/internal/modfetch.s                                               126300   125726   -574    -0.454%
cmd/pprof.s                                                              12317    12312    -5      -0.041%
cmd/go/internal/modconv.s                                                17878    17861    -17     -0.095%
cmd/go/internal/modload.s                                                150261   149763   -498    -0.331%
cmd/go/internal/clean.s                                                  11122    11091    -31     -0.279%
cmd/go/internal/help.s                                                   6523     6521     -2      -0.031%
cmd/go/internal/generate.s                                               11627    11614    -13     -0.112%
cmd/go/internal/envcmd.s                                                 22034    21986    -48     -0.218%
cmd/go/internal/modget.s                                                 38478    38398    -80     -0.208%
cmd/go/internal/modcmd.s                                                 46430    46229    -201    -0.433%
cmd/go/internal/test.s                                                   64399    64374    -25     -0.039%
cmd/compile/internal/ssa.s                                               3615264  3608276  -6988   -0.193%
cmd/compile/internal/gc.s                                                1538865  1537625  -1240   -0.081%
cmd/compile/internal/amd64.s                                             33593    33574    -19     -0.057%
cmd/compile/internal/x86.s                                               30871    30852    -19     -0.062%
total                                                                    19343565 19311284 -32281  -0.167%

Change-Id: Ib030eb79458827a5a5b6d0d2f98765f8325a4d7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/222923
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: simplify typedmemmovepartial
Ian Lance Taylor [Wed, 8 Apr 2020 04:39:39 +0000 (21:39 -0700)]
runtime: simplify typedmemmovepartial

The offset is always a multiple of the pointer size.

Change-Id: I790e087e89a081044a3ec35d99880533a4c929bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/227540
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
4 years agoos/signal: increase settle time in tests
Bryan C. Mills [Wed, 8 Apr 2020 20:28:33 +0000 (16:28 -0400)]
os/signal: increase settle time in tests

I noticed a timeout in TestIgnore in
https://build.golang.org/log/52d83a72f3a5ea9a16eb5d670c729694144f9624,
which suggests that the settle time is currently set too low.

I've also added a check for the same GO_TEST_TIMEOUT_SCALE used in
TestTerminalSignal, so that if this builder remains too slow we can
increase the builder's scale factor rather than the test's baseline
running time.

Updates #33174

Change-Id: I18b10eaa3bb5ae2f604300aedaaf6f79ee7ad567
Reviewed-on: https://go-review.googlesource.com/c/go/+/227649
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoos/exec: use subprocess deadline in TestExtraFiles
Ian Lance Taylor [Tue, 7 Apr 2020 23:39:42 +0000 (16:39 -0700)]
os/exec: use subprocess deadline in TestExtraFiles

Try to get some output even if the subprocess hangs.

For #25628

Change-Id: I4cc0a8f2c52b03a322b8fd0a620cba37b06ff10a
Reviewed-on: https://go-review.googlesource.com/c/go/+/227517
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agonet/url: add URL.Redacted to return a password scrubbed string
nrxr [Wed, 8 Apr 2020 10:21:40 +0000 (10:21 +0000)]
net/url: add URL.Redacted to return a password scrubbed string

Returning an URL.String() without the password is very useful for
situations where the URL is supposed to be logged and the password is
not useful to be shown.

This method re-uses URL.String() but with the password scrubbed and
substituted for a "xxxxx" in order to make it obvious that there was a
password. If the URL had no password then no "xxxxx" will be shown.

Fixes #34855

Change-Id: I7f17d81aa09a7963d2731d16fe15c6ae8e2285fc
GitHub-Last-Rev: 46d06dbc4f9e30a57667bb8d0627bc1abed83bdc
GitHub-Pull-Request: golang/go#35578
Reviewed-on: https://go-review.googlesource.com/c/go/+/207082
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agocmd/compile: allow floating point Ops to produce flags on s390x
Ruixin(Peter) Bao [Thu, 21 Nov 2019 15:44:23 +0000 (10:44 -0500)]
cmd/compile: allow floating point Ops to produce flags on s390x

On s390x, some floating point arithmetic instructions (FSUB, FADD)  generate flag.
This patch allows those related SSA ops to return a tuple, where the second argument of
the tuple is the generated flag. We can use the flag and remove the
subsequent comparison instruction (e.g: LTDBR).

This CL also reduces the .text section for math.test binary by 0.4KB.

Benchmarks:
name                    old time/op  new time/op  delta
Acos-18                 12.1ns ± 0%  12.1ns ± 0%     ~     (all equal)
Acosh-18                18.5ns ± 0%  18.5ns ± 0%     ~     (all equal)
Asin-18                 13.1ns ± 0%  13.1ns ± 0%     ~     (all equal)
Asinh-18                19.4ns ± 0%  19.5ns ± 1%     ~     (p=0.444 n=5+5)
Atan-18                 10.0ns ± 0%  10.0ns ± 0%     ~     (all equal)
Atanh-18                19.1ns ± 1%  19.2ns ± 2%     ~     (p=0.841 n=5+5)
Atan2-18                16.4ns ± 0%  16.4ns ± 0%     ~     (all equal)
Cbrt-18                 14.8ns ± 0%  14.8ns ± 0%     ~     (all equal)
Ceil-18                 0.78ns ± 0%  0.78ns ± 0%     ~     (all equal)
Copysign-18             0.80ns ± 0%  0.80ns ± 0%     ~     (all equal)
Cos-18                  7.19ns ± 0%  7.19ns ± 0%     ~     (p=0.556 n=4+5)
Cosh-18                 12.4ns ± 0%  12.4ns ± 0%     ~     (all equal)
Erf-18                  10.8ns ± 0%  10.8ns ± 0%     ~     (all equal)
Erfc-18                 11.0ns ± 0%  11.0ns ± 0%     ~     (all equal)
Erfinv-18               23.0ns ±16%  26.8ns ± 1%  +16.90%  (p=0.008 n=5+5)
Erfcinv-18              23.3ns ±15%  26.1ns ± 7%     ~     (p=0.087 n=5+5)
Exp-18                  8.67ns ± 0%  8.67ns ± 0%     ~     (p=1.000 n=4+4)
ExpGo-18                50.8ns ± 3%  52.4ns ± 2%     ~     (p=0.063 n=5+5)
Expm1-18                9.49ns ± 1%  9.47ns ± 0%     ~     (p=1.000 n=5+5)
Exp2-18                 52.7ns ± 1%  50.5ns ± 3%   -4.10%  (p=0.024 n=5+5)
Exp2Go-18               50.6ns ± 1%  48.4ns ± 3%   -4.39%  (p=0.008 n=5+5)
Abs-18                  0.67ns ± 0%  0.67ns ± 0%     ~     (p=0.444 n=5+5)
Dim-18                  1.02ns ± 0%  1.03ns ± 0%   +0.98%  (p=0.008 n=5+5)
Floor-18                0.78ns ± 0%  0.78ns ± 0%     ~     (all equal)
Max-18                  3.09ns ± 1%  3.05ns ± 0%   -1.42%  (p=0.008 n=5+5)
Min-18                  3.32ns ± 1%  3.30ns ± 0%   -0.72%  (p=0.016 n=5+4)
Mod-18                  62.3ns ± 1%  65.8ns ± 3%   +5.55%  (p=0.008 n=5+5)
Frexp-18                5.05ns ± 2%  4.98ns ± 0%     ~     (p=0.683 n=5+5)
Gamma-18                24.4ns ± 0%  24.1ns ± 0%   -1.23%  (p=0.008 n=5+5)
Hypot-18                10.3ns ± 0%  10.3ns ± 0%     ~     (all equal)
HypotGo-18              10.2ns ± 0%  10.2ns ± 0%     ~     (all equal)
Ilogb-18                3.56ns ± 1%  3.54ns ± 0%     ~     (p=0.595 n=5+5)
J0-18                    113ns ± 0%   108ns ± 1%   -4.42%  (p=0.016 n=4+5)
J1-18                    115ns ± 0%   109ns ± 1%   -4.87%  (p=0.016 n=4+5)
Jn-18                    240ns ± 0%   230ns ± 2%   -4.41%  (p=0.008 n=5+5)
Ldexp-18                6.19ns ± 0%  6.19ns ± 0%     ~     (p=0.444 n=5+5)
Lgamma-18               32.2ns ± 0%  32.2ns ± 0%     ~     (all equal)
Log-18                  13.1ns ± 0%  13.1ns ± 0%     ~     (all equal)
Logb-18                 4.23ns ± 0%  4.22ns ± 0%     ~     (p=0.444 n=5+5)
Log1p-18                12.7ns ± 0%  12.7ns ± 0%     ~     (all equal)
Log10-18                18.1ns ± 0%  18.2ns ± 0%     ~     (p=0.167 n=5+5)
Log2-18                 14.0ns ± 0%  14.0ns ± 0%     ~     (all equal)
Modf-18                 10.4ns ± 0%  10.5ns ± 0%   +0.96%  (p=0.016 n=4+5)
Nextafter32-18          11.3ns ± 0%  11.3ns ± 0%     ~     (all equal)
Nextafter64-18          4.01ns ± 1%  3.97ns ± 0%     ~     (p=0.333 n=5+4)
PowInt-18               32.7ns ± 0%  32.7ns ± 0%     ~     (all equal)
PowFrac-18              33.2ns ± 0%  33.1ns ± 0%     ~     (p=0.095 n=4+5)
Pow10Pos-18             1.58ns ± 0%  1.58ns ± 0%     ~     (all equal)
Pow10Neg-18             5.81ns ± 0%  5.81ns ± 0%     ~     (all equal)
Round-18                0.78ns ± 0%  0.78ns ± 0%     ~     (all equal)
RoundToEven-18          0.78ns ± 0%  0.78ns ± 0%     ~     (all equal)
Remainder-18            40.6ns ± 0%  40.7ns ± 0%     ~     (p=0.238 n=5+4)
Signbit-18              1.57ns ± 0%  1.57ns ± 0%     ~     (all equal)
Sin-18                  6.75ns ± 0%  6.74ns ± 0%     ~     (p=0.333 n=5+4)
Sincos-18               29.5ns ± 0%  29.5ns ± 0%     ~     (all equal)
Sinh-18                 14.4ns ± 0%  14.4ns ± 0%     ~     (all equal)
SqrtIndirect-18         3.97ns ± 0%  4.15ns ± 0%   +4.59%  (p=0.008 n=5+5)
SqrtLatency-18          8.01ns ± 0%  8.01ns ± 0%     ~     (all equal)
SqrtIndirectLatency-18  11.6ns ± 0%  11.6ns ± 0%     ~     (all equal)
SqrtGoLatency-18        44.7ns ± 0%  45.0ns ± 0%   +0.67%  (p=0.008 n=5+5)
SqrtPrime-18            1.26µs ± 0%  1.27µs ± 0%   +0.63%  (p=0.029 n=4+4)
Tan-18                  11.1ns ± 0%  11.1ns ± 0%     ~     (all equal)
Tanh-18                 15.8ns ± 0%  15.8ns ± 0%     ~     (all equal)
Trunc-18                0.78ns ± 0%  0.78ns ± 0%     ~     (all equal)
Y0-18                    113ns ± 2%   108ns ± 3%   -5.11%  (p=0.008 n=5+5)
Y1-18                    112ns ± 3%   107ns ± 0%   -4.29%  (p=0.000 n=5+4)
Yn-18                    229ns ± 0%   220ns ± 1%   -3.76%  (p=0.016 n=4+5)
Float64bits-18          1.09ns ± 0%  1.09ns ± 0%     ~     (all equal)
Float64frombits-18      0.55ns ± 0%  0.55ns ± 0%     ~     (all equal)
Float32bits-18          0.96ns ±16%  0.86ns ± 0%     ~     (p=0.563 n=5+5)
Float32frombits-18      1.03ns ±28%  0.84ns ± 0%     ~     (p=0.167 n=5+5)
FMA-18                  1.60ns ± 0%  1.60ns ± 0%     ~     (all equal)
[Geo mean]              10.0ns        9.9ns        -0.41%
Change-Id: Ief7e63ea5a8ba404b0a4696e12b9b7e0b05a9a03
Reviewed-on: https://go-review.googlesource.com/c/go/+/209160
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: simplify s390x 'operation with memory operand' rules
Michael Munday [Mon, 6 Apr 2020 22:42:55 +0000 (23:42 +0100)]
cmd/compile: simplify s390x 'operation with memory operand' rules

The generated code remains exactly the same.

Change-Id: Id70af46b6c3c18153789961e5589eab717c3316e
Reviewed-on: https://go-review.googlesource.com/c/go/+/227164
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agomath/big: correct off-by-one access in divBasic
Rémy Oudompheng [Thu, 5 Mar 2020 06:59:00 +0000 (07:59 +0100)]
math/big: correct off-by-one access in divBasic

The divBasic function computes the quotient of big nats u/v word by word.
It estimates each word qhat by performing a long division (top 2 words of u
divided by top word of v), looks at the next word to correct the estimate,
then perform a full multiplication (qhat*v) to catch any inaccuracy in the
estimate.

In the latter case, "negative" values appear temporarily and carries
must be carefully managed, and the recursive division refactoring
introduced a case where qhat*v has the same length as v, triggering an
out-of-bounds write in the case it happens when computing the top word
of the quotient.

Fixes #37499

Change-Id: I15089da4a4027beda43af497bf6de261eb792f94
Reviewed-on: https://go-review.googlesource.com/c/go/+/221980
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agoruntime: add a couple of writeBarrier.needed checks
Ian Lance Taylor [Wed, 8 Apr 2020 04:47:13 +0000 (21:47 -0700)]
runtime: add a couple of writeBarrier.needed checks

Make typedmemmove, typedmemclr, typedmemclrpartial look more like other
callers of bulkBarrierPreWrite.

Change-Id: Ic47030d88bf07d290f91198b7810ffc16d9769e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/227541
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocrypto/x509: tidy darwin/arm64 build tags
Austin Clements [Wed, 8 Apr 2020 16:16:38 +0000 (12:16 -0400)]
crypto/x509: tidy darwin/arm64 build tags

The cgo build tag is not necessary for root_darwin_arm64.go. We can't
build for darwin/arm64 without cgo, and even if we did 1) this code
would work fine 2) the no-cgo code that shells out to
/usr/bin/security would not work.

(Suggested by Filippo.)

Change-Id: I98cac2ea96ec5ac1ae60b7e32d195d5e86e2bd66
Reviewed-on: https://go-review.googlesource.com/c/go/+/227583
Reviewed-by: Filippo Valsorda <filippo@golang.org>
4 years agocmd/compile/internal/ssa: skip TestNexting
Bryan C. Mills [Wed, 8 Apr 2020 15:57:53 +0000 (11:57 -0400)]
cmd/compile/internal/ssa: skip TestNexting

This test is currently flaky in the builders.
Skip it while we investigate.

For #37404

Change-Id: I53721d383a4cafbe8d031ed25a3b1be2ae8b4285
Reviewed-on: https://go-review.googlesource.com/c/go/+/227587
Reviewed-by: David Chase <drchase@google.com>
4 years agoall: remove scattered remnants of darwin/386
Austin Clements [Mon, 6 Apr 2020 20:16:48 +0000 (16:16 -0400)]
all: remove scattered remnants of darwin/386

This removes all conditions and conditional code (that I could find)
that depended on darwin/386.

Fixes #37610.

Change-Id: I630d9ea13613fb7c0bcdb981e8367facff250ba0
Reviewed-on: https://go-review.googlesource.com/c/go/+/227582
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoall: remove darwin/386 build-tags and files
Austin Clements [Mon, 6 Apr 2020 17:43:17 +0000 (13:43 -0400)]
all: remove darwin/386 build-tags and files

This removes all files that are only used on darwin/386 and cleans up
build tags in files that are still used on other platforms.

Updates #37610.

Change-Id: If246642476c12d15f59a474e2b91a29c0c02fe75
Reviewed-on: https://go-review.googlesource.com/c/go/+/227581
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoall: remove scattered remnants of darwin/arm
Austin Clements [Fri, 3 Apr 2020 16:22:27 +0000 (12:22 -0400)]
all: remove scattered remnants of darwin/arm

This removes all conditions and conditional code (that I could find)
that depended on darwin/arm.

Fixes #35439 (since that only happened on darwin/arm)
Fixes #37611.

Change-Id: Ia4c32a5a4368ed75231075832b0b5bfb1ad11986
Reviewed-on: https://go-review.googlesource.com/c/go/+/227198
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoall: remove darwin/arm build-tags and files
Austin Clements [Fri, 3 Apr 2020 15:58:51 +0000 (11:58 -0400)]
all: remove darwin/arm build-tags and files

This removes all files that are only used on darwin/arm and cleans up
build tags in files that are still used on other platforms.

Updates #37611.

Change-Id: Ic9490cf0edfc157c6276a7ca950c1768b34a998f
Reviewed-on: https://go-review.googlesource.com/c/go/+/227197
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agodoc: remove darwin/386, darwin/arm from ports list
Austin Clements [Fri, 3 Apr 2020 13:23:19 +0000 (09:23 -0400)]
doc: remove darwin/386, darwin/arm from ports list

Updates #37611.

Change-Id: I7ae5a61d2e2189fd48ac3548e370e0de1dd79832
Reviewed-on: https://go-review.googlesource.com/c/go/+/227343
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoRevert "runtime/pprof: try to use real stack in TestTryAdd"
Bryan C. Mills [Wed, 8 Apr 2020 15:52:01 +0000 (15:52 +0000)]
Revert "runtime/pprof: try to use real stack in TestTryAdd"

This reverts CL 227484.

Reason for revert: failing on linux-amd64-noopt builder.

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

4 years agocmd/go: allow configuring module cache directory with GOMODCACHE
Michael Matloob [Fri, 14 Feb 2020 22:44:00 +0000 (17:44 -0500)]
cmd/go: allow configuring module cache directory with GOMODCACHE

Adds a GOMODCACHE environment variable that's used by cmd/go to determine the
location of the module cache. The default value of GOMODCACHE will be
GOPATH[0]/pkg/mod, the default location of the module cache before this change.

Replace the cmd/go/internal/modfetch.PkgMod variable which previously held the
location of the module cache with the new cmd/go/internal/cfg.GOMODCACHE
variable, for consistency with many of the other environment variables that
affect the behavior of cmd/go.  (Most of the changes in this CL are due to
moving/renaming the variable.)

The value of cfg.GOMODCACHE is now set using a variable initializer. It was
previously set in cmd/go/internal/modload.Init.

The location of GOPATH/pkg/sumdb is unchanged by this CL. While it was
previously determined using the value of PkgMod, it now is determined
independently dirctly from the value of GOPATH[0].

Fixes #34527

Change-Id: Id4d31d217b3507d6057c8ef7c52af1a0606603e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/219538
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agoruntime: skip TestPingPongHog in race mode
Josh Bleecher Snyder [Mon, 6 Apr 2020 16:07:03 +0000 (09:07 -0700)]
runtime: skip TestPingPongHog in race mode

TestPingPongHog tests properties of the scheduler.
But the race detector intentionally does randomized scheduling,
so the test is not applicable.

Fixes #38266

Change-Id: Ib06aa317b2776cb1faa641c4e038e2599cf70b2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/227344
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agonet/textproto, sync: unlock mutexes appropriately before panics
BurtonQin [Wed, 8 Apr 2020 16:03:18 +0000 (16:03 +0000)]
net/textproto, sync: unlock mutexes appropriately before panics

Ensure mutexes are unlocked right before panics, where defers aren’t easily usable.

Change-Id: I67c9870e7a626f590a8de8df6c8341c5483918dc
GitHub-Last-Rev: bb8ffe538b3956892b55884fd64eadfce326f7b0
GitHub-Pull-Request: golang/go#37143
Reviewed-on: https://go-review.googlesource.com/c/go/+/218717
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agoruntime/race: update ppc64 .syso file
Keith Randall [Tue, 7 Apr 2020 19:03:31 +0000 (12:03 -0700)]
runtime/race: update ppc64 .syso file

Update #14881
Update #37355

Change-Id: I5edd53b7532836cfe6037fb668b1b8fe8f7a32f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/227443
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
4 years agoruntime/pprof: try to use real stack in TestTryAdd
Michael Pratt [Tue, 7 Apr 2020 16:12:44 +0000 (12:12 -0400)]
runtime/pprof: try to use real stack in TestTryAdd

TestTryAdd is particularly brittle because it tests some real cases by
constructing fake sample stack frames. If those frames don't correctly
represent what the runtime would generate then they may fail to catch
regressions.

Instead, call runtime.Callers at the bottom of real function calls to
generate real frames as a base for truncation, etc in tests. Several of
these tests still have to fake parts of the frames to test the right
thing, but this is a bit less fragile.

Change-Id: I62522a9ded5544b06d1bf28550af5400f3af667b
Reviewed-on: https://go-review.googlesource.com/c/go/+/227484
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
4 years agoruntime: only check for pointers up to ptrdata, not size
Ian Lance Taylor [Fri, 3 Apr 2020 00:14:25 +0000 (17:14 -0700)]
runtime: only check for pointers up to ptrdata, not size

Change-Id: I166cf253b7f2483d652c98d2fba36c380e2f3347
Reviewed-on: https://go-review.googlesource.com/c/go/+/227177
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: fix infinite callstack of cgo on arm64
Xiangdong Ji [Fri, 27 Mar 2020 11:04:21 +0000 (11:04 +0000)]
runtime: fix infinite callstack of cgo on arm64

This change adds CFA information to the assembly function 'crosscall1'
and reorgnizes its code to establish well-formed prologue and epilogue.
It will fix an infinite callstack issue when debugging cgo program with
GDB on arm64.

Brief root cause analysis:

GDB's aarch64 unwinder parses prologue to determine current frame's size
and previous PC&SP if CFA information is not available.

The unwinder parses the prologue of 'crosscall1' to determine a frame size
of 0x10, then turns to its next frame trying to compute its previous PC&SP
as they are not saved on current frame's stack as per its 'traditional frame
unwind' rules, which ends up getting an endless frame chain like:
    [callee]  : pc:<pc0>, sp:<sp0>
    crosscall1: pc:<pc1>, sp:<sp0>+0x10
    [caller]  : pc:<pc1>, sp:<sp0>+0x10+0x10
    [caller]  : pc:<pc1>, sp:<sp0>+0x10+0x10+0x10
    ...
GDB fails to detect the 'caller' frame is same as 'crosscall1' and terminate
unwinding since SP increases everytime.

Fixes #37238
Change-Id: Ia6bd8555828541a3a61f7dc9b94dfa00775ec52a
Reviewed-on: https://go-review.googlesource.com/c/go/+/226999
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoruntime: static lock ranking for the runtime (enabled by GOEXPERIMENT)
Dan Scales [Thu, 14 Nov 2019 01:34:47 +0000 (17:34 -0800)]
runtime:  static lock ranking for the runtime (enabled by GOEXPERIMENT)

I took some of the infrastructure from Austin's lock logging CR
https://go-review.googlesource.com/c/go/+/192704 (with deadlock
detection from the logs), and developed a setup to give static lock
ranking for runtime locks.

Static lock ranking establishes a documented total ordering among locks,
and then reports an error if the total order is violated. This can
happen if a deadlock happens (by acquiring a sequence of locks in
different orders), or if just one side of a possible deadlock happens.
Lock ordering deadlocks cannot happen as long as the lock ordering is
followed.

Along the way, I found a deadlock involving the new timer code, which Ian fixed
via https://go-review.googlesource.com/c/go/+/207348, as well as two other
potential deadlocks.

See the constants at the top of runtime/lockrank.go to show the static
lock ranking that I ended up with, along with some comments. This is
great documentation of the current intended lock ordering when acquiring
multiple locks in the runtime.

I also added an array lockPartialOrder[] which shows and enforces the
current partial ordering among locks (which is embedded within the total
ordering). This is more specific about the dependencies among locks.

I don't try to check the ranking within a lock class with multiple locks
that can be acquired at the same time (i.e. check the ranking when
multiple hchan locks are acquired).

Currently, I am doing a lockInit() call to set the lock rank of most
locks. Any lock that is not otherwise initialized is assumed to be a
leaf lock (a very high rank lock), so that eliminates the need to do
anything for a bunch of locks (including all architecture-dependent
locks). For two locks, root.lock and notifyList.lock (only in the
runtime/sema.go file), it is not as easy to do lock initialization, so
instead, I am passing the lock rank with the lock calls.

For Windows compilation, I needed to increase the StackGuard size from
896 to 928 because of the new lock-rank checking functions.

Checking of the static lock ranking is enabled by setting
GOEXPERIMENT=staticlockranking before doing a run.

To make sure that the static lock ranking code has no overhead in memory
or CPU when not enabled by GOEXPERIMENT, I changed 'go build/install' so
that it defines a build tag (with the same name) whenever any experiment
has been baked into the toolchain (by checking Expstring()). This allows
me to avoid increasing the size of the 'mutex' type when static lock
ranking is not enabled.

Fixes #38029

Change-Id: I154217ff307c47051f8dae9c2a03b53081acd83a
Reviewed-on: https://go-review.googlesource.com/c/go/+/207619
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: delete the floating point Greater and Geq ops
Michael Munday [Fri, 6 Mar 2020 22:20:45 +0000 (22:20 +0000)]
cmd/compile: delete the floating point Greater and Geq ops

Extend CL 220417 (which removed the integer Greater and Geq ops) to
floating point comparisons. Greater and Geq can always be
implemented using Less and Leq.

Fixes #37316.

Change-Id: Ieaddb4877dd0ff9037a1dd11d0a9a9e45ced71e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/222397
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: use MOVBQZX for OpAMD64LoweredHasCPUFeature
Josh Bleecher Snyder [Sun, 5 Apr 2020 02:22:28 +0000 (19:22 -0700)]
cmd/compile: use MOVBQZX for OpAMD64LoweredHasCPUFeature

In the commit message of CL 212360, I wrote:

> This new intrinsic ... generates MOVB+TESTB+NE.
> (It is possible that MOVBQZX+TESTQ+NE would be better.)

I should have tested. MOVBQZX+TESTQ+NE does in fact appear to be better.

For the benchmark in #36196, on my machine:

name      old time/op  new time/op  delta
FMA-8     0.86ns ± 6%  0.70ns ± 5%  -18.79%  (p=0.000 n=98+97)
NonFMA-8  0.61ns ± 5%  0.60ns ± 4%   -0.74%  (p=0.001 n=100+97)

Interestingly, these are both considerably faster than
the measurements I took a couple of months ago (1.4ns/2ns).
It appears that CL 219131 (clearing VZEROUPPER in asyncPreempt) helped a lot.
And FMA is now once again slower than NonFMA, although this change
helps it regain some ground.

Updates #15808
Updates #36351
Updates #36196

Change-Id: I8a326289a963b1939aaa7eaa2fab2ec536467c7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/227238
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile/internal/logopt: preserve env while running command
Egon Elbre [Tue, 7 Apr 2020 12:52:05 +0000 (15:52 +0300)]
cmd/compile/internal/logopt: preserve env while running command

The test was not preserving temporary directory flags leading to a
failure on windows with:

    mkdir C:\WINDOWS\go-build315158903: Access is denied.

Fixes #38251

Change-Id: I6ee31b31e84b7f6e75ea6ee0f3b8c094835bf5d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/227497
Reviewed-by: David Chase <drchase@google.com>
4 years agocmd/internal: add MVCIN instruction to s390x assembler
Ruixin(Peter) Bao [Tue, 7 Apr 2020 13:20:08 +0000 (09:20 -0400)]
cmd/internal: add MVCIN instruction to s390x assembler

On s390x, we already have MVCIN opcode in asmz.go,
but we did not use it. This CL uses that opcode and adds MVCIN
instruction.

MVCIN instruction can be used to move data from one storage location
to another while reversing the order of bytes within the field. This
could be useful when transforming data from little-endian to big-endian.

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

4 years agocmd/go: report scan error position in 'go list -e'
Jay Conrod [Wed, 11 Dec 2019 18:16:35 +0000 (13:16 -0500)]
cmd/go: report scan error position in 'go list -e'

This CL extracts some error handling code into a common method for
presenting errors encountered when loading package data.

Fixes #36087
Fixes #36762

Change-Id: I87c8d41e3cc6e6afa152d9c067bc60923bf19fbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/210938
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/link: remove darwin/arm test
Cherry Zhang [Mon, 6 Apr 2020 15:39:44 +0000 (11:39 -0400)]
cmd/link: remove darwin/arm test

The darwin/arm port is removed in Go 1.15. Setting GOOS=darwin
GOARCH=arm will fail, therefore "go test cmd/link" on macOS will
fail (in non -short mode). Remove this test point.

Updates #37611.

Change-Id: Ia9531c4b4a6692a0c49153517af9fdddd1f3e0bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/227341
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: lay out exit post-dominated blocks at the end
Josh Bleecher Snyder [Sat, 4 Apr 2020 01:23:04 +0000 (18:23 -0700)]
cmd/compile: lay out exit post-dominated blocks at the end

Complete a long-standing TODO in the code.

Exit blocks are cold code, so we lay them out at the end of the function.
Blocks that are post-dominated by exit blocks are also ipso facto exit blocks.
Treat them as such.

Implement using a simple loop, because there are generally very few exit blocks.

In addition to improved instruction cache, this empirically yields
better register allocation.

Binary size impact:

file    before    after     Δ       %
cgo     4812872   4808776   -4096   -0.085%
fix     3370072   3365976   -4096   -0.122%
vet     8252280   8248184   -4096   -0.050%
total   115052984 115040696 -12288  -0.011%

This also appears to improve compiler performance
(-0.15% geomean time/op, -1.20% geomean user time/op),
but that could just be alignment effects.
Compiler benchmarking hasn't been super reliably recently,
and there's no particular reason to think this should
speed up the compiler that much.

Change-Id: I3d262c4f5cb80626a67a5c17285e2fa09f423c00
Reviewed-on: https://go-review.googlesource.com/c/go/+/227217
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
4 years agocmd/link: fix data race in testDWARF
Cherry Zhang [Mon, 6 Apr 2020 15:41:23 +0000 (11:41 -0400)]
cmd/link: fix data race in testDWARF

Multiple instances of testDWARF run in parallel, with a shared
backing store of the env input slice. Do modification of the
environment locally, instead of on the shared slice.

Fixes #38265.

Change-Id: I22a7194c8cd55ba22c9d6c47ac47bf7e710a7027
Reviewed-on: https://go-review.googlesource.com/c/go/+/227342
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/go: report 'go get' errors for absolute paths outside module root
Jay Conrod [Wed, 1 Apr 2020 17:08:41 +0000 (13:08 -0400)]
cmd/go: report 'go get' errors for absolute paths outside module root

'go get' will now check absolute paths without wildcards the same way
it checks relative paths. modload.DirImportPath may be used for both
without converting path separators.

Fixes #38038

Change-Id: I453299898ece58f3b5002a5e80021d6bfe815fdd
Reviewed-on: https://go-review.googlesource.com/c/go/+/226857
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agocmd/compile: make logopt test skip if cannot create scratch directory
David Chase [Mon, 6 Apr 2020 15:12:26 +0000 (11:12 -0400)]
cmd/compile: make logopt test skip if cannot create scratch directory

Fixes #38251.

Change-Id: Ic635843fb503484a1c9a230b0cca571393d3da5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/227339
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
4 years agocmd/compile: print block auxint value in HTML output
Michael Munday [Sat, 4 Apr 2020 21:51:15 +0000 (22:51 +0100)]
cmd/compile: print block auxint value in HTML output

The auxint value was being printed in LongString() but not LongHTML().

Fixes #38250.

Change-Id: I28e819feef8710f912bee424d1b900eb07f3abb8
Reviewed-on: https://go-review.googlesource.com/c/go/+/227160
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: improve lowered moves and zeros for ppc64le
Lynn Boger [Mon, 30 Mar 2020 19:23:19 +0000 (15:23 -0400)]
cmd/compile: improve lowered moves and zeros for ppc64le

This change includes the following:
- Generate LXV/STXV sequences instead of LXVD2X/STXVD2X on power9.
These instructions do not require an index register, which
allows more loads and stores within a loop without initializing
multiple index registers. The LoweredQuadXXX generate LXV/STXV.
- Create LoweredMoveXXXShort and LoweredZeroXXXShort for short
moves that don't generate loops, and therefore don't clobber the
address registers or flags.
- Use registers other than R3 and R4 to avoid conflicting with
registers that have already been allocated to avoid unnecessary
register moves.
- Eliminate the use of R14 as scratch register and use R31
instead.
- Add PCALIGN when the LoweredMoveXXX or LoweredZeroXXX generates a
loop with more than 3 iterations.

This performance opportunity was noticed in github.com/golang/snappy
benchmarks. Results on power9:

WordsDecode1e1    54.1ns ± 0%    53.8ns ± 0%   -0.51%  (p=0.029 n=4+4)
WordsDecode1e2     287ns ± 0%     282ns ± 1%   -1.83%  (p=0.029 n=4+4)
WordsDecode1e3    3.98µs ± 0%    3.64µs ± 0%   -8.52%  (p=0.029 n=4+4)
WordsDecode1e4    66.9µs ± 0%    67.0µs ± 0%   +0.20%  (p=0.029 n=4+4)
WordsDecode1e5     723µs ± 0%     723µs ± 0%   -0.01%  (p=0.200 n=4+4)
WordsDecode1e6    7.21ms ± 0%    7.21ms ± 0%   -0.02%  (p=1.000 n=4+4)
WordsEncode1e1    29.9ns ± 0%    29.4ns ± 0%   -1.51%  (p=0.029 n=4+4)
WordsEncode1e2    2.12µs ± 0%    1.75µs ± 0%  -17.70%  (p=0.029 n=4+4)
WordsEncode1e3    11.7µs ± 0%    11.2µs ± 0%   -4.61%  (p=0.029 n=4+4)
WordsEncode1e4     119µs ± 0%     120µs ± 0%   +0.36%  (p=0.029 n=4+4)
WordsEncode1e5    1.21ms ± 0%    1.22ms ± 0%   +0.41%  (p=0.029 n=4+4)
WordsEncode1e6    12.0ms ± 0%    12.0ms ± 0%   +0.57%  (p=0.029 n=4+4)
RandomEncode       286µs ± 0%     203µs ± 0%  -28.82%  (p=0.029 n=4+4)
ExtendMatch       47.4µs ± 0%    47.0µs ± 0%   -0.85%  (p=0.029 n=4+4)

Change-Id: Iecad3a39ae55280286e42760a5c9d5c1168f5858
Reviewed-on: https://go-review.googlesource.com/c/go/+/226539
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agotime, runtime: only call resetTimer from (*Timer).Reset
Ian Lance Taylor [Fri, 3 Apr 2020 19:52:17 +0000 (12:52 -0700)]
time, runtime: only call resetTimer from (*Timer).Reset

Previously we stopped the timer and then reset it. With the current
timer implementation that is no longer required.

Change-Id: Ie7aba61ad53ce835f6fcd0b6bce7fe0a15b10e24
Reviewed-on: https://go-review.googlesource.com/c/go/+/227180
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agocmd/compile: restore missing columns in ssa.html
Bradford Lamson-Scribner [Sun, 5 Apr 2020 22:12:05 +0000 (16:12 -0600)]
cmd/compile: restore missing columns in ssa.html

If the final pass(es) are identical during ssa.html generation,
they are persisted in-memory as "pendingPhases" but never get
written as a column in the html. This change flushes those
in-memory phases.

Fixes #38242

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

4 years agoA+C: add Andy Pan (individual CLA)
Andy Pan [Sun, 5 Apr 2020 08:51:10 +0000 (16:51 +0800)]
A+C: add Andy Pan (individual CLA)

https://go-review.googlesource.com/q/author:panjf2000%2540gmail.com

Change-Id: I05c73d848b8f40dc864a18c733ca3f47b1eab54d
Reviewed-on: https://go-review.googlesource.com/c/go/+/227004
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: refactor around HTMLWriter removing logger in favor of Func
Bradford Lamson-Scribner [Sun, 5 Apr 2020 18:44:02 +0000 (12:44 -0600)]
cmd/compile: refactor around HTMLWriter removing logger in favor of Func

Replace HTMLWriter's Logger field with a *Func. Implement Fatalf method
for HTMLWriter which gets the Frontend() from the Func and calls down
into it's Fatalf method, passing the msg and args along. Replace
remaining calls to the old Logger with calls to logging methods on
the Func.

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

4 years agocmd/compile: enable -d=checkptr even on windows
Alex Brainman [Sat, 4 Apr 2020 07:36:58 +0000 (18:36 +1100)]
cmd/compile: enable -d=checkptr even on windows

CL 201783 enable -d=checkptr when -race or -msan is specified
everywhere but windows.

But, now that all unsafe pointer conversions in the standard
library are fixed, enable -d=checkptr even on windows.

Updates #34964
Updates #34972

Change-Id: Id912fa83b0d5b46c6f1c134c742fd94d2d185835
Reviewed-on: https://go-review.googlesource.com/c/go/+/227003
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agocmd/dist: remove darwin/386, darwin/arm as valid ports
Brad Fitzpatrick [Fri, 3 Apr 2020 05:44:25 +0000 (22:44 -0700)]
cmd/dist: remove darwin/386, darwin/arm as valid ports

This only removes the ability to build it, and removes it as a
src/buildall.bash target (which uses go tool dist list).

Now:

$ go tool dist list | grep ^darwin
darwin/amd64
darwin/arm64

After this, remaining is removing leftover port--specific code in the
tree.

Updates #37610
Updates #37611

Change-Id: I00f03b2355c2e152f75e57abd3063be243529d2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/226985
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
4 years agocmd/compile: add intrinsic HasCPUFeature for checking cpu features
Josh Bleecher Snyder [Thu, 19 Dec 2019 18:58:28 +0000 (10:58 -0800)]
cmd/compile: add intrinsic HasCPUFeature for checking cpu features

Before using some CPU instructions, we must check for their presence.
We use global variables in the runtime package to record features.

Prior to this CL, we issued a regular memory load for these features.
The downside to this is that, because it is a regular memory load,
it cannot be hoisted out of loops or otherwise reordered with other loads.

This CL introduces a new intrinsic just for checking cpu features.
It still ends up resulting in a memory load, but that memory load can
now be floated to the entry block and rematerialized as needed.

One downside is that the regular load could be combined with the comparison
into a CMPBconstload+NE. This new intrinsic cannot; it generates MOVB+TESTB+NE.
(It is possible that MOVBQZX+TESTQ+NE would be better.)

This CL does only amd64. It is easy to extend to other architectures.

For the benchmark in #36196, on my machine, this offers a mild speedup.

name      old time/op  new time/op  delta
FMA-8     1.39ns ± 6%  1.29ns ± 9%  -7.19%  (p=0.000 n=97+96)
NonFMA-8  2.03ns ±11%  2.04ns ±12%    ~     (p=0.618 n=99+98)

Updates #15808
Updates #36196

Change-Id: I75e2fcfcf5a6df1bdb80657a7143bed69fca6deb
Reviewed-on: https://go-review.googlesource.com/c/go/+/212360
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Giovanni Bajo <rasky@develer.com>