1
0
mirror of https://github.com/golang/go synced 2024-09-30 22:18:32 -06:00
Commit Graph

36849 Commits

Author SHA1 Message Date
Josh Bleecher Snyder
396833caef cmd/compile: avoid double-zeroing
This triggers in 131 functions in std+cmd.
In those functions, it often helps considerably
(2-10% text size reduction).

Noticed while working on #38554.

Change-Id: Id0dbb8e7cb21d469ec08ec3d5be9beb9e8291e9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/229707
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 23:58:38 +00:00
Josh Bleecher Snyder
4a7e363288 cmd/compile: optimize Move with all-zero ro sym src to Zero
We set up static symbols during walk that
we later make copies of to initialize local variables.
It is difficult to ascertain at that time exactly
when copying a symbol is profitable vs locally
initializing an autotmp.

During SSA, we are much better placed to optimize.
This change recognizes when we are copying from a
global readonly all-zero symbol and replaces it with
direct zeroing.

This often allows the all-zero symbol to be
deadcode eliminated at link time.
This is not ideal--it makes for large object files,
and longer link times--but it is the cleanest fix I could find.

This makes the final binary for the program in #38554
shrink from >500mb to ~2.2mb.

It also shrinks the standard binaries:

file      before    after     Δ       %
addr2line 4412496   4404304   -8192   -0.186%
buildid   2893816   2889720   -4096   -0.142%
cgo       4841048   4832856   -8192   -0.169%
compile   19926480  19922432  -4048   -0.020%
cover     5281816   5277720   -4096   -0.078%
link      6734648   6730552   -4096   -0.061%
nm        4366240   4358048   -8192   -0.188%
objdump   4755968   4747776   -8192   -0.172%
pprof     14653060  14612100  -40960  -0.280%
trace     11805940  11777268  -28672  -0.243%
vet       7185560   7181416   -4144   -0.058%
total     113588440 113465560 -122880 -0.108%

And not just by removing unnecessary symbols;
the program text shrinks a bit as well.

Fixes #38554

Change-Id: I8381ae6084ae145a5e0cd9410c451e52c0dc51c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/229704
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 23:58:10 +00:00
Josh Bleecher Snyder
b3e8a00060 cmd/compile: move duffcopy auxint calculation out of rewrite rules
Package amd64 is a more natural home for it.
It also makes it easier to see how many bytes
are being copied in ssa.html.

Passes toolstash-check.

Change-Id: I5ecf0f0f18e8db2faa2caf7a05028c310952bd94
Reviewed-on: https://go-review.googlesource.com/c/go/+/229703
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 23:56:54 +00:00
Josh Bleecher Snyder
b0a8754475 cmd/compile: convert race cleanup rule to typed aux
Passes toolstash-check.

Change-Id: I3005210cc156d01a6ac1ccaafb4311c607681bf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/229691
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 23:12:43 +00:00
Josh Bleecher Snyder
32467e677f cmd/compile: convert Move and Zero optimizations to typed aux
Passes toolstash-check.

Change-Id: I9bd722ce19b2ef39931658a02663aeb7db575939
Reviewed-on: https://go-review.googlesource.com/c/go/+/229690
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 23:12:34 +00:00
Josh Bleecher Snyder
6b5ab20b65 cmd/compile: convert devirtualization rule to typed aux
Passes toolstash-check.

Change-Id: Iebcdc35f1a2112d5384c70eb3fdbd92ebb3d248e
Reviewed-on: https://go-review.googlesource.com/c/go/+/229689
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 23:12:23 +00:00
Josh Bleecher Snyder
4799955004 cmd/compile: convert inlineable memmove rules to typed aux
Passes toolstash-check.

Change-Id: I0190c5403040f930895a083181da2092a5c297e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/229688
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 23:07:11 +00:00
Josh Bleecher Snyder
1c5453510c cmd/compile: convert pointer and address comparisons to typed aux
Passes toolstash-check.

Change-Id: Id4c4d341e5733673eb8a899e881d70b193f76580
Reviewed-on: https://go-review.googlesource.com/c/go/+/229687
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 23:06:59 +00:00
Josh Bleecher Snyder
47b5efad5d cmd/compile: convert nilcheck elim rules to typed aux
Passes toolstash-check.

Change-Id: Ic7efb0e4778844366f581c6310a1a2f3bfc1868a
Reviewed-on: https://go-review.googlesource.com/c/go/+/229686
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 23:06:48 +00:00
Josh Bleecher Snyder
b6f6259f2d cmd/compile: convert floating point optimizations to typed aux
Passes toolstash-check.

Change-Id: I1318ede351da4cf769f7b9d87b275720fc278159
Reviewed-on: https://go-review.googlesource.com/c/go/+/229685
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 23:06:39 +00:00
Josh Bleecher Snyder
79bb41aed6 cmd/compile: convert reassociation optimizations to typed aux, part two
Passes toolstash-check.

Change-Id: Ia8fad6973983eebe6d78d9dd8de8c99b8edcecdb
Reviewed-on: https://go-review.googlesource.com/c/go/+/229684
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 23:06:28 +00:00
Josh Bleecher Snyder
052b3c99b2 cmd/compile: convert reassociation optimizations to typed aux
Passes toolstash-check.

Change-Id: I85a161c4e1c29e06e3f7e6ad4a59ff8cc51c7296
Reviewed-on: https://go-review.googlesource.com/c/go/+/229683
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 23:06:17 +00:00
Cherry Zhang
1d083eba5b [dev.link] cmd/link: fix minor error on error reporting
Correctly propagate ... arguments. (Maybe vet should warn on it?)

Reviewed-on: https://go-review.googlesource.com/c/go/+/230017
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>

Change-Id: Ife56dc2321847cdaf0caea3142c2c7dad8b5924d
Reviewed-on: https://go-review.googlesource.com/c/go/+/230027
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-24 22:56:40 +00:00
Than McIntosh
42cca1a7fe [dev.link] cmd/link: create symbol updated lazily in amd64 adddynrel
Tweak the code in the amd64 version of adddynrel to avoid creating a
symbol updated for the symbol being processed until it's clear we need
to alter its relocations. This should help performance for the
PIE+internal linking scenario.

Reviewed-on: https://go-review.googlesource.com/c/go/+/229866
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>

Change-Id: Id25adfd81a5bbd2dde0f80a83b976397ba6abfb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/230026
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-24 22:56:22 +00:00
Ian Lance Taylor
1cc46d3a25 runtime: sleep in TestSegv program to let signal be delivered
Since we're sleeping rather than waiting for the goroutines,
let the goroutines run forever.

Fixes #38595

Change-Id: I4cd611fd7565f6e8d91e50c9273d91c514825314
Reviewed-on: https://go-review.googlesource.com/c/go/+/229484
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-04-24 22:23:04 +00:00
Alberto Donizetti
c53d1236df cmd/compile: use typed aux for first half of arm64 lowering
Passes

  GOARCH=arm64 gotip build -toolexec 'toolstash -cmp' -a std

Change-Id: Icb530d8d128d9938ab44a9c716c8dd09a34ededf
Reviewed-on: https://go-review.googlesource.com/c/go/+/229937
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 22:19:29 +00:00
Heschi Kreinick
d8d3542815 internal/goversion: revert "update to 1.15"
This reverts CL 230024, commit 5e10ba9969.

Reason for revert: breaks cmd/go TestScript/mod_retention

Change-Id: I2044beff3008156dd11d7bd8154a6208ae692c57
Reviewed-on: https://go-review.googlesource.com/c/go/+/230029
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-24 22:01:49 +00:00
Heschi Kreinick
5e10ba9969 internal/goversion: update to 1.15
Tests tagged +build go1.15 are currently not running. They should.

Change-Id: Ib97ec57a7a35cea65e2d14fb2b067e5fe49ee284
Reviewed-on: https://go-review.googlesource.com/c/go/+/230024
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-24 21:19:50 +00:00
Josh Bleecher Snyder
80ced39396 cmd/compile: add more non-ID comparisons to schedule
These comparisons are fairly arbitrary,
but they should be more stable in the face
of other compiler changes than value ID.

This reduces the number of value ID
comparisons in schedule while running
make.bash from 542,442 to 99,703.

There are lots of changes to generated code
from this change, but they appear to
be overall neutral.

It is possible to further reduce the
number of comparisons in schedule;
I have changes locally that reduce the
number to about 25,000 during make.bash.
However, the changes are increasingly
complex and arcane, and reduce in much less
code churn. Given that the goal is stability,
that suggests that this is a reasonable
place to stop, at least for now.

Change-Id: Ie3a75f84fd3f3fdb102fcd0b29299950ea66b827
Reviewed-on: https://go-review.googlesource.com/c/go/+/229799
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 21:13:36 +00:00
Josh Bleecher Snyder
943a0d02d1 cmd/compile: add Value.Uses comparison during scheduling
Falling back to comparing Value.ID during scheduling
is undesirable: Not only are we simply hoping for a good
outcome, but the decision we make will be easily perturbed
by other compiler changes, leading to random fluctuations.

This change adds another decision point to the scheduler
by scheduling Values with many uses earlier.
Values with fewer uses are less likely to be spilled for
other reasons, so we should issue them as late as possible
in the hope of avoiding a spill.

This reduces the number of Value ID comparisons
in schedule while running make.bash
from 1,000,844 to 542,442.

As you would expect, this changes a lot of functions,
but the overall trend is positive:

file    before    after     Δ       %
api     5237184   5233088   -4096   -0.078%
compile 19926480  19918288  -8192   -0.041%
cover   5281816   5277720   -4096   -0.078%
dist    3711608   3707512   -4096   -0.110%
total   113588440 113567960 -20480  -0.018%

Change-Id: Ic99ebc4c614d4ae3807ce44473ec6b04684388ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/229798
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 21:12:21 +00:00
Rebecca Stambler
512277dc19 go/types: improve error message for pointer receiver errors
The compiler produces high quality error messages when an interface is
implemented by *T, rather than T. This change improves the analogous
error messages in go/types, from "missing method X" to "missing method
X (X has pointer receiver)".

I am open to improving this message further - I didn't copy the compiler
error message exactly because, at one of the call sites of
(*check).missingMethod, we no longer have access to the name of the
interface.

Fixes golang/go#36336

Change-Id: Ic4fc38b13fff9e5d9a69cc750c21e0b0c34d85a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/229801
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-04-24 18:49:16 +00:00
Cherry Zhang
027055240f [dev.link] cmd/link: check fingerprint for index consistency
Previous CL introduced index fingerprint in the object files.
This CL implements the second part: checking fingerprint
consistency in the linker when packages are loaded.

Change-Id: I05dd4c4045a65adfd95e77b625d6c75a7a70e4f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/229618
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-24 17:48:07 +00:00
Cherry Zhang
e08f10b8b5 [dev.link] cmd/internal/goobj2: add index fingerprint to object file
The new object files use indices for symbol references, instead
of names. Fundamental to the design, it requires that the
importing and imported packages have consistent view of symbol
indices. The Go command should already ensure this, when using
"go build". But in case it goes wrong, it could lead to obscure
errors like run-time crashes. It would be better to check the
index consistency at build time.

To do that, we add a fingerprint to each object file, which is
a hash of symbol indices. In the object file it records the
fingerprints of all imported packages, as well as its own
fingerprint. At link time, the linker checks that a package's
fingerprint matches the fingerprint recorded in the importing
packages, and issue an error if they don't match.

This CL does the first part: introducing the fingerprint in the
object file, and propagating fingerprints through
importing/exporting by the compiler. It is not yet used by the
linker. Next CL will do.

Change-Id: I0aa372da652e4afb11f2867cb71689a3e3f9966e
Reviewed-on: https://go-review.googlesource.com/c/go/+/229617
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-24 17:47:14 +00:00
Cherry Zhang
880ef2da7b [dev.link] cmd/link: panic if HeadType is not set
In the code there are conditions like !ctxt.IsDarwin(). This will
accidentally be true if HeadType is not yet set. Panic when
HeadType is not set, to catch errors.

Change-Id: Ic891123f27f0276fff5a4b5d29e5b1f7ebbb94ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/229869
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-24 17:22:57 +00:00
Gerrit Code Review
da33f9c78a Merge "cmd: merge branch 'dev.link' into master" 2020-04-24 17:13:12 +00:00
Cherry Zhang
f2d8da1a35 [dev.link] cmd/link: set HeadType early
So we can use it to set per-OS flags.

Also set flagnewDoData after archinit, where IsELF is set.

This should correct the logic of setting flagnewDoData.

Change-Id: I18c7252f141aa35119005c252becc9d7cb74f2f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/229867
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-24 16:58:37 +00:00
Josh Bleecher Snyder
67a8660b5a cmd/compile: CSE the RHS of rewrite rules
Keep track of all expressions encountered while
generating a rewrite result, and re-use them whenever possible.
Named expressions may still be used for clarity when desired.

Change-Id: I640dca108763eb8baeff8f9a4169300af3445b82
Reviewed-on: https://go-review.googlesource.com/c/go/+/229800
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2020-04-24 16:44:20 +00:00
Than McIntosh
f790533d9f [dev.link] cmd/link: support new dodata for elf/386
Add elf/386 arch support for the new dodata() phase.

Change-Id: I78341dfe70a90719d95c0044183980f348a3369f
Reviewed-on: https://go-review.googlesource.com/c/go/+/229797
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-24 15:49:51 +00:00
Ruixin(Peter) Bao
3a37fd4010 math/big: rewrite subVW to use fast path on s390x
This CL replaces the original subVW implementation with a implementation
that uses a similar idea as CL 164968.

When we know the borrow bit is zero, we can copy the rest of words as
they will not be updated. Also, since we are copying vector of a words,
a faster implementation of copy is written in this CL to copy a word or
multiple words at a time.

Benchmarks:
name             old time/op    new time/op     delta
SubVW/1-18         4.43ns ± 0%     3.82ns ± 0%   -13.85%  (p=0.000 n=20+20)
SubVW/2-18         5.39ns ± 0%     4.25ns ± 0%   -21.23%  (p=0.000 n=20+20)
SubVW/3-18         6.29ns ± 0%     4.65ns ± 0%   -26.07%  (p=0.000 n=16+19)
SubVW/4-18         6.08ns ± 2%     4.84ns ± 0%   -20.43%  (p=0.000 n=20+20)
SubVW/5-18         7.06ns ± 1%     4.93ns ± 0%   -30.18%  (p=0.000 n=20+20)
SubVW/10-18        10.3ns ± 2%      7.2ns ± 0%   -30.35%  (p=0.000 n=20+19)
SubVW/100-18       48.0ns ± 4%     17.6ns ± 0%   -63.32%  (p=0.000 n=18+19)
SubVW/1000-18       448ns ±10%      236ns ± 1%   -47.24%  (p=0.000 n=20+20)
SubVW/10000-18     4.83µs ± 5%     2.96µs ± 0%   -38.73%  (p=0.000 n=20+19)
SubVW/100000-18    46.6µs ± 3%     30.6µs ± 1%   -34.30%  (p=0.000 n=20+20)
[Geo mean]         56.3ns          37.0ns        -34.24%

name             old speed      new speed       delta
SubVW/1-18       1.80GB/s ± 0%   2.10GB/s ± 0%   +16.16%  (p=0.000 n=20+20)
SubVW/2-18       2.97GB/s ± 0%   3.77GB/s ± 0%   +26.95%  (p=0.000 n=20+20)
SubVW/3-18       3.82GB/s ± 0%   5.16GB/s ± 0%   +35.26%  (p=0.000 n=20+19)
SubVW/4-18       5.26GB/s ± 1%   6.61GB/s ± 0%   +25.59%  (p=0.000 n=20+20)
SubVW/5-18       5.67GB/s ± 1%   8.11GB/s ± 0%   +43.12%  (p=0.000 n=20+20)
SubVW/10-18      7.79GB/s ± 2%  11.17GB/s ± 0%   +43.52%  (p=0.000 n=20+19)
SubVW/100-18     16.7GB/s ± 4%   45.5GB/s ± 0%  +172.61%  (p=0.000 n=18+20)
SubVW/1000-18    17.9GB/s ± 9%   33.9GB/s ± 1%   +89.25%  (p=0.000 n=20+20)
SubVW/10000-18   16.6GB/s ± 5%   27.0GB/s ± 0%   +63.08%  (p=0.000 n=20+19)
SubVW/100000-18  17.2GB/s ± 2%   26.1GB/s ± 1%   +52.18%  (p=0.000 n=20+20)
[Geo mean]       7.25GB/s       11.03GB/s        +52.01%

Change-Id: I32e99cbab3260054a96231d02b87049c833ab77e
Reviewed-on: https://go-review.googlesource.com/c/go/+/227297
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-24 14:50:59 +00:00
Cherry Zhang
3b32a44699 [dev.link] cmd/link: remove -a flag
It doesn't do what it says. It has been like that since Go 1.4.
The current ouput is pretty useless. Remove it.

Change-Id: Id9b4ba04139aaf7ea59acbd51428b1c992115389
Reviewed-on: https://go-review.googlesource.com/c/go/+/229859
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-24 14:50:46 +00:00
Cherry Zhang
a02349bc9d cmd: merge branch 'dev.link' into master
In the dev.link branch we continued developing the new object
file format support and the linker improvements described in
https://golang.org/s/better-linker . Since the last merge, more
progress has been made to improve the new linker.

This is a clean merge.

Change-Id: I57c510b651a39354d78478a9a4499f770eef2eb1
2020-04-24 10:30:33 -04:00
Than McIntosh
941de9760b [dev.link] cmd/link: begin converting dodata() to loader APIs
This patch begins the work of converting the linker's dodata phase to
work with loader APIs. Passes all.bash on linux/amd64, but hasn't been
tested on anything else (more arch-specific code needs to be written).
Use of the new dodata() phase is currently gated by a temporary
command line flag ("-newdodata"), and there is code in the linker's
main routine to insure that we only use the new version for the right
GOOS/GOARCH (currently restricted to ELF + AMD64).

Change-Id: Ied3966677d2a450bc3e0990e0f519b3fceaab806
Reviewed-on: https://go-review.googlesource.com/c/go/+/229706
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-24 14:09:38 +00:00
Than McIntosh
3d1007d28e [dev.link] cmd/link: move more error handling into loader
Move the guts of ctxt.Errorf into loader.Loader, so that we can make
calls to it from functions that have a "*loader.Loader" available but
not a "ctxt *Link". This is needed to start converting hooks like
"adddynrel" in the arch-specific portions of the linker to use loader
APIs.

Change-Id: Ieedd4583b66504be0e77d7f3fbadafe0d2307a69
Reviewed-on: https://go-review.googlesource.com/c/go/+/229497
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-24 13:41:49 +00:00
Than McIntosh
442fd182fb [dev.link] cmd/link/internal/loader: add SetRelocType symbolbuilder method
Clients may need to invoke the loader.Reloc2.SetType method to reset
the type of a relocation from external flavor to internal flavor,
meaning that the external type add-in needs to be zeroed (this is
needed when adding dynsym entries).

Add a new SymbolBuider method to support mutating the type of a reloc
for an external symbol, so that the external type can be changed as
well (Reloc2 doesn't have access to that). Also add similar methods
for updating target symbol and addend, so as to have a consistent
interface for ext reloc mutation.

Change-Id: I8e26cdae0a0f353019acba5f9c8a0506e3970266
Reviewed-on: https://go-review.googlesource.com/c/go/+/229604
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-24 13:41:32 +00:00
Than McIntosh
adea6a90e3 [dev.link] cmd/link/internal/loader: fix buglet in section handling
Allow for the possibility that a client could call newExtSym(), then
ask for the section of the new sym before SetSectSym is called on it
(check in SymSect for this case).

Change-Id: I7bd78e7b3b7618943705b616f62ea78c4a1b68d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/229603
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-24 13:41:20 +00:00
Ruixin(Peter) Bao
ee8972cd12 math/big: rewrite addVW to use fast path on s390x
Rewrite addVW to use a fast path and remove the original
vector and non vector implementation of addVW in assembly. This CL uses
a similar idea as CL 164968, where we copy the rest of words when we
know carry bit is zero.

In addition, since we are copying vector of words, a faster
implementation of copy is written in this CL to copy a word or multiple
words at a time.

Benchmarks:
name             old time/op    new time/op     delta
AddVW/1-18         4.56ns ± 0%     4.01ns ± 6%   -12.14%  (p=0.000 n=18+20)
AddVW/2-18         5.54ns ± 0%     4.42ns ± 5%   -20.20%  (p=0.000 n=18+20)
AddVW/3-18         6.55ns ± 0%     4.61ns ± 0%   -29.62%  (p=0.000 n=16+18)
AddVW/4-18         6.11ns ± 2%     5.12ns ± 6%   -16.19%  (p=0.000 n=20+20)
AddVW/5-18         7.32ns ± 4%     5.14ns ± 0%   -29.77%  (p=0.000 n=20+19)
AddVW/10-18        10.6ns ± 2%      7.2ns ± 1%   -31.47%  (p=0.000 n=20+20)
AddVW/100-18       49.6ns ± 2%     18.0ns ± 0%   -63.63%  (p=0.000 n=20+20)
AddVW/1000-18       465ns ± 3%      244ns ± 0%   -47.54%  (p=0.000 n=20+20)
AddVW/10000-18     4.99µs ± 4%     2.97µs ± 0%   -40.54%  (p=0.000 n=20+20)
AddVW/100000-18    48.3µs ± 3%     30.8µs ± 1%   -36.29%  (p=0.000 n=20+20)
[Geo mean]         58.1ns          38.0ns        -34.57%

name             old speed      new speed       delta
AddVW/1-18       1.76GB/s ± 0%   2.00GB/s ± 6%   +14.04%  (p=0.000 n=20+20)
AddVW/2-18       2.89GB/s ± 0%   3.63GB/s ± 5%   +25.55%  (p=0.000 n=18+20)
AddVW/3-18       3.66GB/s ± 0%   5.21GB/s ± 0%   +42.25%  (p=0.000 n=18+19)
AddVW/4-18       5.24GB/s ± 2%   6.27GB/s ± 6%   +19.61%  (p=0.000 n=20+20)
AddVW/5-18       5.47GB/s ± 4%   7.78GB/s ± 0%   +42.28%  (p=0.000 n=20+18)
AddVW/10-18      7.55GB/s ± 2%  11.04GB/s ± 1%   +46.09%  (p=0.000 n=20+20)
AddVW/100-18     16.1GB/s ± 2%   44.3GB/s ± 0%  +174.77%  (p=0.000 n=20+20)
AddVW/1000-18    17.2GB/s ± 3%   32.8GB/s ± 1%   +90.58%  (p=0.000 n=20+20)
AddVW/10000-18   16.0GB/s ± 4%   26.9GB/s ± 0%   +68.11%  (p=0.000 n=20+20)
AddVW/100000-18  16.6GB/s ± 3%   26.0GB/s ± 1%   +56.94%  (p=0.000 n=20+20)
[Geo mean]       7.03GB/s       10.75GB/s        +52.93%

Change-Id: Idbb73f3178311bd2b18a93bdc1e48f26869d2f6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/209679
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-24 13:26:34 +00:00
Richard Musiol
82f29898ea cmd/compile: rewrite Wasm rules to use typed aux fields
Passes toolstash-check -all.

Change-Id: Ib731a59eadfffa81914848005b0f757649affa6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/228819
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 08:21:27 +00:00
Alberto Donizetti
e47a17aeee cmd/compile: convert remaining mips rules to typed aux
Passes

  GOARCH=mips gotip build -toolexec 'toolstash -cmp' -a std
  GOARCH=mipsle gotip build -toolexec 'toolstash -cmp' -a std

Change-Id: I35df0522e299aa755491cd25f47f1f1bf447848c
Reviewed-on: https://go-review.googlesource.com/c/go/+/229637
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-24 07:22:41 +00:00
Brad Fitzpatrick
619c7a48a3 crypto/x509: add x509omitbundledroots build tag to not embed roots
On darwin/arm64, the copy of the system roots takes 256 KiB of disk
and 560 KiB of memory after parsing them (which is retained forever in
a package global by x509/root.go). In constrained environments like
iOS NetworkExtensions where total disk+RAM is capped at 15 MiB, these
certs take 5.3% of the total allowed memory.

It turns out you can get down from 816 KiB to 110 KiB by instead
storing compressed x509 certs in the binary and lazily inflating just
the needed certs at runtime as a function of the certs presented to
you by the server, then building a custom root CertPool in the
crypto/tls.Config.VerifyPeerCertificate hook.

This then saves 706 KiB.

Arguably that should be the default Go behavior, but involves
cooperation between x509 and tls, and adds a dependency to
compress/gzip. Also, it may not be the right trade-off for everybody,
as it involves burning more CPU on new TLS connections. Most iOS apps
don't run in a NetworkExtension context limiting them to 15 MiB.

The build tag is chosen to match the existing "nethttpomithttp2".

Change-Id: I7b1c845de08b22674f81dd546e7fadc7dda68bd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/229762
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-04-24 05:30:31 +00:00
Bradford Lamson-Scribner
d0ea533c54 cmd/compile: fix misalignment in sources column of generated ssa.html
Fix regression where line numbers in the sources column of generated
ssa.html output became misaligned with the source code. This was due
to some new margins applied to certain h2 elements during the work
to combine identical columns.

Fixes #38612

Change-Id: I067ccbfa30d5de5be29aab9863bc1e21f6ded128
Reviewed-on: https://go-review.googlesource.com/c/go/+/229766
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-24 02:13:27 +00:00
David Chase
f5fcc9b8e0 cmd/internal/obj: add IsAsm flag
This allows more exciting changes to compiler-generated assembly
language that might not be correct for tricky hand-crafted
assembly (e.g., nop padding breaking tables of call or branch
instructions).

Updates #35881

Change-Id: I842b811796076c160180a364564f2844604df3fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/229708
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-24 01:48:48 +00:00
Praveen Kumar
6677a2a1fc strings: remove an obsolete doc note for FieldsFunc
Fixes #38630

Change-Id: I0b2b693dd88821dcfc035cf552b687565bb55ef6
GitHub-Last-Rev: 291b1b4dcf
GitHub-Pull-Request: golang/go#38631
Reviewed-on: https://go-review.googlesource.com/c/go/+/229763
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-04-23 22:10:10 +00:00
Matthew Dempsky
080a3ee8b2 cmd/compile: remove ODDDARG
No longer needed after the last CL. Separate commit because
renumbering Ops causes toolstash to complain.

Change-Id: I6223a790cc341f8184eccb503f95a1dfc32a81e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/229760
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23 22:02:26 +00:00
Matthew Dempsky
a44d06d3b4 cmd/compile: use fixVariadicCall in escape analysis
This CL uses fixVariadicCall before escape analyzing function calls.
This has a number of benefits, though also some minor obstacles:

Most notably, it allows us to remove ODDDARG along with the logic
involved in setting it up, manipulating EscHoles, and later copying
its escape analysis flags to the actual slice argument. Instead, we
uniformly handle all variadic calls the same way. (E.g., issue31573.go
is updated because now f() and f(nil...) are handled identically.)

It also allows us to simplify handling of builtins and generic
function calls. Previously handling of calls was hairy enough to
require multiple dispatches on n.Op, whereas now the logic is uniform
enough that we can easily handle it with a single dispatch.

The downside is handling //go:uintptrescapes is now somewhat clumsy.
(It used to be clumsy, but it still is, too.) The proper fix here is
probably to stop using escape analysis tags for //go:uintptrescapes
and unsafe-uintptr, and have an earlier pass responsible for them.

Finally, note that while we now call fixVariadicCall in Escape, we
still have to call it in Order, because we don't (yet) run Escape on
all compiler-generated functions. In particular, the generated "init"
function for initializing package-level variables can contain calls to
variadic functions and isn't escape analyzed.

Passes toolstash-check -race.

Change-Id: I4cdb92a393ac487910aeee58a5cb8c1500eef881
Reviewed-on: https://go-review.googlesource.com/c/go/+/229759
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-04-23 22:02:12 +00:00
Matthew Dempsky
83d25c61e4 go/types: add UsesCgo config to support _cgo_gotypes.go
This CL adds a UsesCgo config setting to go/types to specify that the
_cgo_gotypes.go file generated by cmd/cgo has been provided as a
source file. The type checker then internally resolves C.bar qualified
identifiers to _Cfoo_bar as appropriate.

It also adds support to srcimporter to automatically run cgo.
Unfortunately, this functionality is not compatible with overriding
OpenFile, because cmd/cgo and gcc will directly open files.

Updates #16623.
Updates #35721.

Change-Id: I1e1965fe41b765b7a9da3431f2a86cc16025dee2
Reviewed-on: https://go-review.googlesource.com/c/go/+/33677
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-04-23 20:45:57 +00:00
Lynn Boger
0ef3ebcc83 cmd/compile: clean up PPC64.rules typed aux changes
This adds a few minor changes from the first review.

Passes toolstash-check

Change-Id: I00f6f1b0235d0a8c686aa8793d0473b8fc6b1495
Reviewed-on: https://go-review.googlesource.com/c/go/+/229699
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-23 20:40:40 +00:00
Josh Bleecher Snyder
6303c34d7f cmd/compile: remove dead values after flagalloc
Fix a longstanding TODO.

Provides widespread, minor improvements.
Negligible compiler cost.

Because the freeze nears, put in a safety flag to easily disable.

Change-Id: I338812181ab6d806fecf22afd3c3502e2c94f7a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/229600
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-23 19:40:07 +00:00
Josh Bleecher Snyder
e0915dea09 cmd/compile: splitload (CMPconst [0] x) into (TEST x x) on amd64
Provides minor widespread benefit to generated code.

Removes one source of random fluctuation when changing
other aspects of the compiler.

Change-Id: I16db6f5e240a97d27f05dc1ba5b8b729af3adb12
Reviewed-on: https://go-review.googlesource.com/c/go/+/229702
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23 19:39:25 +00:00
Josh Bleecher Snyder
d9d88dd27f cmd/compile: allow named values on RHS of rewrite rules
Fixes #38621

Change-Id: Idbffdcc70903290dc58e5abb4867718bd5449fe1
Reviewed-on: https://go-review.googlesource.com/c/go/+/229701
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-23 19:39:12 +00:00
Lynn Boger
91b9c2f350 cmd/asm,cmd/internal/obj/ppc64: update instructions and tests
This change adds some instructions that were missing from the
ppc64 assembler, mostly power9 but a few others from earlier.

Tests in cmd/asm for ppc64 were updated: ppc64.s includes the
new instructions, and ppc64enc.s now includes not only the
new instructions but most ppc64 opcodes to provide a more
complete test of the ppc64 assembler.

The ppc64 instruction set is used for linux/ppc64le,
linux/ppc64, and aix/ppc64.

Change-Id: I8695f89dbca06174847963f4ef869f2e584d5bbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/229479
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-23 19:28:16 +00:00
Dan Scales
939379ffb6 runtime: fix TestDeferWithRepeatedRepanics and TestIssue37688 to be less chatty
Converted some Println() statements (used to make sure that certain variables were
kept alive and not optimized out) to assignments into global variables, so the
tests don't produce extraneous output when there is a failure.

Fixes #38594

Change-Id: I7eb41bb02b2b1e78afd7849676b5c85bc11c759c
Reviewed-on: https://go-review.googlesource.com/c/go/+/229538
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-23 18:33:44 +00:00
Matthew Dempsky
681ba43077 cmd/compile: move fixVariadicCall from walk to order
This CL moves fixVariadicCall from mid-Walk of function calls to
early-Order, in preparation for moving it even earlier in the future.

Notably, rewriting variadic calls this early introduces two
compilation output changes:

1. Previously, Order visited the ODDDARG before the rest of the
arguments list, whereas the natural time to visit it is at the end of
the list (as we visit arguments left-to-right, and the ... argument is
the rightmost one). Changing this ordering permutes the autotmp
allocation order, which in turn permutes autotmp naming and stack
offsets.

2. Previously, Walk separately walked all of the variadic arguments
before walking the entire slice literal, whereas the more natural
thing to do is just walk the entire slice literal. This triggers
slightly different code paths for composite literal construction in
some cases.

Neither of these have semantic impact. They simply mean we're now
compiling f(a,b,c) the same way as we were already compiling
f([]T{a,b,c}...).

Change-Id: I40ccc5725697a116370111ebe746b2639562fe87
Reviewed-on: https://go-review.googlesource.com/c/go/+/229601
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-04-23 18:29:42 +00:00
Keith Randall
0d19b91b40 cmd/go: use response files when command line would be too long
Fixes #37768

Change-Id: I799a8da632890ad7595697d461c90e3c4c065d95
Reviewed-on: https://go-review.googlesource.com/c/go/+/229317
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-04-23 18:20:07 +00:00
Josh Bleecher Snyder
bf5b83a835 cmd/compile: convert splitload rules to typed aux
Passes toolstash-check -all.

Change-Id: Ia441582f7f67184eb831e184f9c3c0e3c11001bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/229698
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-23 17:52:48 +00:00
Josh Bleecher Snyder
e7c1873691 cmd/compile: optimize x & 1 != 0 to x & 1 on amd64
Triggers a handful of times in std+cmd.

Change-Id: I9bb8ce9a5f8bae2547cb61157cd8f256e1b63e76
Reviewed-on: https://go-review.googlesource.com/c/go/+/229602
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-23 17:52:28 +00:00
Cuong Manh Le
917aa72c14 cmd/compile: rewrite dec rules to use typed aux field
Passes toolstash-check -all.

Change-Id: Ia73233c2269017a5802df821ea2ca138c16a94ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/229519
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
2020-04-23 17:25:43 +00:00
Cuong Manh Le
7f0c479fff cmd/compile: rewrite dec64 rules to use typed aux field
Passes toolstash-check -all.

Change-Id: If9dd6c2155374eb9ef47639201ec90109a9e314c
Reviewed-on: https://go-review.googlesource.com/c/go/+/229518
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
2020-04-23 17:25:31 +00:00
Cherry Zhang
67bf856b96 [dev.link] all: merge branch 'master' into dev.link
Change-Id: Ia6426e8494244fde7e81a7c932c8e3c865676d3d
2020-04-23 11:47:20 -04:00
Cherry Zhang
dee3e3aebd [dev.link] cmd/link: clean up some tests
Use a separate directory for TestBuildFortvOS test files.

Remove a bad comment in TestTrampoline.

Change-Id: I2dc07ae575ec3f73fb7cea26743094b11a41b464
Reviewed-on: https://go-review.googlesource.com/c/go/+/229619
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-23 15:31:01 +00:00
Johan Jansson
c8dea8198e cmd/go: allow generate to process invalid packages
Allow go generate to process packages that contain invalid code. Ignore
errors when loading the package, but process only files which have a
valid package clause. Set $GOPACKAGE individually for each file, based
on the package clause.

Add test script for go generate and invalid packages.

Fixes #36422

Change-Id: I91ea088346a1548ccd6678b4595a527b948331ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/229097
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23 15:19:53 +00:00
Josh Bleecher Snyder
e354309e1e cmd/compile: add ssa.Block.truncateValues
It is a common operation.

Passes toolstash-check.

Change-Id: Icc34600b0f79d0ecb19f257e3c7f23b6f01a26ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/229599
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-23 14:59:55 +00:00
Josh Bleecher Snyder
806318d6ad cmd/compile: simplify zcse
Minor refactoring.

Passes toolstash-check.

Change-Id: I91e981bf369d4b719163107644fa58f583356c25
Reviewed-on: https://go-review.googlesource.com/c/go/+/229598
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-23 14:59:41 +00:00
witchard
708ac9aacb cmd/go/internal/modget: improve GOINSECURE docs
Recommend use of GOINSECURE over -insecure flang and clarify that GOINSECURE
environment variable does not also imply GONOSUMDB.

Updates #37519 by adding documentation as discussed.

Change-Id: Ia8ab6b3ed1aa559343b72e4ca76c372ee6bf1941
GitHub-Last-Rev: 8d86991f0c
GitHub-Pull-Request: golang/go#38572
Reviewed-on: https://go-review.googlesource.com/c/go/+/229223
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23 13:46:00 +00:00
Cuong Manh Le
e43239aabe cmd/compile: pre-alloc enough room for Escape.walkAll
Slightly reduce allocs, passes toolstash-check.

name          old time/op       new time/op       delta
Template            181ms ± 4%        174ms ± 0%  -3.59%  (p=0.008 n=5+5)

name          old user-time/op  new user-time/op  delta
Template            249ms ± 3%        240ms ± 2%  -3.59%  (p=0.016 n=5+5)

name          old alloc/op      new alloc/op      delta
Template           35.0MB ± 0%       34.9MB ± 0%  -0.09%  (p=0.008 n=5+5)
Unicode            28.6MB ± 0%       28.6MB ± 0%    ~     (p=0.421 n=5+5)
GoTypes             114MB ± 0%        114MB ± 0%  -0.10%  (p=0.008 n=5+5)
Compiler            542MB ± 0%        541MB ± 0%  -0.13%  (p=0.008 n=5+5)
SSA                1.21GB ± 0%       1.21GB ± 0%  -0.10%  (p=0.008 n=5+5)
Flate              22.0MB ± 0%       22.0MB ± 0%  -0.05%  (p=0.016 n=5+5)
GoParser           27.1MB ± 0%       27.0MB ± 0%  -0.05%  (p=0.008 n=5+5)
Reflect            74.8MB ± 0%       74.8MB ± 0%  -0.11%  (p=0.008 n=5+5)
Tar                33.0MB ± 0%       32.9MB ± 0%  -0.07%  (p=0.008 n=5+5)
XML                42.1MB ± 0%       42.1MB ± 0%  -0.07%  (p=0.008 n=5+5)
LinkCompiler        222MB ± 0%        222MB ± 0%    ~     (p=0.690 n=5+5)
[Geo mean]         81.3MB            81.2MB       -0.07%

name          old allocs/op     new allocs/op     delta
Template             347k ± 0%         347k ± 0%  -0.16%  (p=0.008 n=5+5)
Unicode              334k ± 0%         334k ± 0%  -0.03%  (p=0.016 n=5+5)
GoTypes             1.20M ± 0%        1.20M ± 0%  -0.12%  (p=0.008 n=5+5)
Compiler            5.13M ± 0%        5.12M ± 0%  -0.11%  (p=0.008 n=5+5)
SSA                 11.7M ± 0%        11.7M ± 0%  -0.13%  (p=0.008 n=5+5)
Flate                221k ± 0%         221k ± 0%  -0.18%  (p=0.008 n=5+5)
GoParser             280k ± 0%         280k ± 0%  -0.06%  (p=0.008 n=5+5)
Reflect              902k ± 0%         900k ± 0%  -0.28%  (p=0.008 n=5+5)
Tar                  323k ± 0%         322k ± 0%  -0.18%  (p=0.008 n=5+5)
XML                  401k ± 0%         401k ± 0%  -0.10%  (p=0.008 n=5+5)
LinkCompiler         735k ± 0%         735k ± 0%    ~     (p=0.841 n=5+5)
[Geo mean]           753k              752k       -0.12%

Change-Id: I647bd7752f28b74e6f400fa16cb69632f5c952b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/229517
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-04-23 07:33:21 +00:00
Matthew Dempsky
9f4dd09bf5 cmd/compile: refactor variadac call desugaring
In mid-Walk, we rewrite calls to variadic functions to use explicit
slice literals; e.g., rewriting f(a,b,c) into f([]T{a,b,c}...).
However, it would be useful to do that rewrite much earlier in the
compiler, so that other compiler passes can be simplified.

This CL refactors the rewrite logic into a new fixVariadicCall
function, which subsequent CLs can more easily move into earlier
compiler passes.

Passes toolstash-check -race.

Change-Id: I408e655f2d3aa00446a2e6accf8765abc3b16a8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/229486
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2020-04-23 06:24:40 +00:00
Andrei Tudor Călin
952f7de3b4 testing: make TempDir work for subtests
ioutil.TempDir doesn't like path separators in its pattern. Modify
(*common).TempDir to replace path separators with underscores before
using the test name as a pattern for ioutil.TempDir.

Fixes #38465.

Change-Id: I9e8ae48b99648b2bf9f561762e845165aff01972
Reviewed-on: https://go-review.googlesource.com/c/go/+/229399
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-23 01:34:16 +00:00
Matthew Dempsky
f049d911e9 cmd/compile: be stricter about recognizing safety rule #4
unsafe.Pointer safety rule #4 says "The compiler handles a Pointer
converted to a uintptr in the argument list of a call". Within escape
analysis, we've always required this be a single conversion
unsafe.Pointer->uintptr conversion, but the corresponding logic in
order is somewhat laxer, allowing arbitrary chains of OCONVNOPs from
unsafe.Pointer to uintptr.

This CL changes order to be stricter to match escape analysis.

Passes toolstash-check.

Change-Id: Iadd210d2123accb2020f5728ea2a47814f703352
Reviewed-on: https://go-review.googlesource.com/c/go/+/229578
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-23 00:08:35 +00:00
Jeremy Faller
7466cad9c4 [dev.link] cmd/link: only allow heap area to grow to 10MB
With CL 228782, we've removed file I/O, but we're growing the memory too
much. This change will periodically flush the heap area to the mmapped
area (if possible).

Change-Id: I1622c738ee5a1a6d02bff5abb0a5751caf8095c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/229439
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-22 22:12:42 +00:00
Daniel Theophanes
ed7888aea6 database/sql: de-flake TestTxCannotCommitAfterRollback
Do not cancel rows during test. Only cancel the Tx.
Correct the referenced issue number on the test.

Fixes #38597

Change-Id: I0e8ba1bf2a8ba638d121c9c6938501fec1d5e961
Reviewed-on: https://go-review.googlesource.com/c/go/+/229478
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-22 22:10:09 +00:00
Kirill Korotaev
9a93baf4d7 encoding/base64: improve performance up to 20% total
Improve base64 encoding/decoding performance by
suppressing compiler boundary checks on decode.

name                 old speed      new speed      delta
EncodeToString-8      570MB/s ± 1%   573MB/s ± 1%     ~     (p=0.421 n=5+5)
DecodeString/2-8     88.6MB/s ± 3%  91.6MB/s ± 2%   +3.37%  (p=0.016 n=5+5)
DecodeString/4-8      162MB/s ± 1%   168MB/s ± 0%   +4.12%  (p=0.008 n=5+5)
DecodeString/8-8      203MB/s ± 0%   214MB/s ± 0%   +5.18%  (p=0.008 n=5+5)
DecodeString/64-8     471MB/s ± 1%   520MB/s ± 1%  +10.50%  (p=0.008 n=5+5)
DecodeString/8192-8   757MB/s ± 0%   895MB/s ± 1%  +18.29%  (p=0.008 n=5+5)

Change-Id: I135243c11aa4c974a4a4e95c5c2abb0635d52c8c
GitHub-Last-Rev: 2c87abcb28
GitHub-Pull-Request: golang/go#36910
Reviewed-on: https://go-review.googlesource.com/c/go/+/217117
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-22 21:36:41 +00:00
Hana (Hyang-Ah) Kim
0ee4b13830 net/http/pprof: allow "seconds" parameters to most profiles
golang.org/cl/147598 added the support for delta computation for mutex
and block profiles. In fact, this delta computation makes sense for
other types of profiles.

For example, /debug/pprof/allocs?seconds=x will provide how much allocation
was made during the specified period. /debug/pprof/goroutine?seconds=x will
provide the changes in the list of goroutines. This also makes sense for
custom profiles.

Update #23401
Update google/pprof#526

Change-Id: I45e9073eb001ea5b3f3d16e5a57f635193610656
Reviewed-on: https://go-review.googlesource.com/c/go/+/229537
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-04-22 21:08:58 +00:00
Hana (Hyang-Ah) Kim
3e342e8719 net/http/pprof: make TestDeltaProfile less flaky by retrying
In some slow environment, the goroutine for mutexHog2 may not run
within 1secs. So, try with increasing seconds parameters,
and declare failure if it still fails with the longest duration
parameter (32sec).

Also, relax the test condition - previously we expected the
profile's duration is within 0.5~2sec. But obviously, in some
slow environment, that's not even guaranteed. Just check we get
non-zero duration in the result.

Update #38544

Change-Id: Ia9b0d51429a2093e6c9eb92cf463ff6952ef3e10
Reviewed-on: https://go-review.googlesource.com/c/go/+/229498
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-22 21:08:29 +00:00
Lynn Boger
4a5d6916ed cmd/compile: update PPC64.rules to use typed aux values
Passes toolstash-check.

Change-Id: I874f8b834ef2f94daa971ecef2dbe4e14daf4213
Reviewed-on: https://go-review.googlesource.com/c/go/+/229305
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-22 20:56:14 +00:00
Michael Munday
ab7a65f283 cmd/compile: clean up codegen for branch-on-carry on s390x
This CL optimizes code that uses a carry from a function such as
bits.Add64 as the condition in an if statement. For example:

    x, c := bits.Add64(a, b, 0)
    if c != 0 {
        panic("overflow")
    }

Rather than converting the carry into a 0 or a 1 value and using
that as an input to a comparison instruction the carry flag is now
used as the input to a conditional branch directly. This typically
removes an ADD LOGICAL WITH CARRY instruction when user code is
doing overflow detection and is closer to the code that a user
would expect to generate.

Change-Id: I950431270955ab72f1b5c6db873b6abe769be0da
Reviewed-on: https://go-review.googlesource.com/c/go/+/219757
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-22 20:11:06 +00:00
Than McIntosh
00723603eb [dev.link] cmd/link/internal/loader: fix AttrSubSymbol
The code that runs as a part of loadlibfull converts the linker's
outer/sub state and sets the sym.Symbol AttrSubSymbol if a symbol has
both A) an outer sym, and B) is listed as a sub-symbol by some other
symbol.

Make sure that we have the same logic in the original loader method,
since we need to use it as part of dodata() prior to loadlibfull.

Change-Id: I200adab741d778a6ba821419e8ea131ad19375bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/229440
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-22 19:37:28 +00:00
Than McIntosh
25992d025f [dev.link] cmd/link/internal/loader: preprocess numeric constants earlier
Change the timing for preprocessing of integer/floating point constant
symbols so that we populate them with content at an earlier stage.
This is needed to allow them can be picked up by the loader-API
version of dodata().

Change-Id: Icf09f4f4b318b4f77e11d4a0f0a9cbecd76a1d6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/229438
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-22 18:12:02 +00:00
Alberto Donizetti
81df5e69fc cmd/compile: switch to typed aux for mips lowering rules
This covers most of the lowering rules.

Passes

  GOARCH=mips gotip build -toolexec 'toolstash -cmp' -a std
  GOARCH=mipsle gotip build -toolexec 'toolstash -cmp' -a std

Change-Id: I9d00aaebecb36622e3bdaf556e5a9377670bf86b
Reviewed-on: https://go-review.googlesource.com/c/go/+/229102
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-22 17:30:07 +00:00
Than McIntosh
45bd3b1bc4 [dev.link] cmd/link: create loader-specific version of GCProg
Create a new version of the GCProg type + methods that use loader APIs
instead of sym.Symbol.

This code isn't actually used just yet, but will be needed once the
wavefront reaches dodata() and we need to convert that phase.

Change-Id: I087521832015818204fe5c2ac99c7bd3f61b2bf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/229037
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-22 16:47:33 +00:00
Katie Hockman
141b11d5a1 crypto/x509: disallow setting MaxPathLen without IsCA
Fixes #38216

Change-Id: I3222abe2153abb4cbfa65a4825c153ce128f56a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/228777
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-04-22 16:45:05 +00:00
Colin
12579009b3 database/sql: count connections expired in foreground with MaxLifetimeClosed
Previously the connection pool would only count connections
expired in the background connectionCleaner goroutine towards the
MaxLifetimeClosed stat.

This change increments the stat correctly when checking for
expiry in when acquiring and releasing a connection.

Fixes #38058

Change-Id: Id707ddd40a42a4c38658d5f2931da131647d6c29
GitHub-Last-Rev: 0f205ede43
GitHub-Pull-Request: golang/go#38263
Reviewed-on: https://go-review.googlesource.com/c/go/+/227278
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2020-04-22 16:19:35 +00:00
Alberto Donizetti
0a00926481 runtime: fix bad link to issue tracker in test
Change-Id: Ie88ff3f0493f4119be25476a20038877e879c485
Reviewed-on: https://go-review.googlesource.com/c/go/+/229397
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-04-22 16:03:11 +00:00
David Finkel
38c2c12bc1 runtime/pprof: plumb labels for goroutine profiles
Goroutines are directly associated with labels. It's relatively easy to
plumb those through without creating goroutine-locals in the wild.

This is accomplished by splitting out most of the code from the public
`runtime.GoroutineProfile` into a new unexported
`runtime.goroutineProfileWithLabels`, which then has a thin wrapper
linked into the `runtime/pprof` package as
`runtime_goroutineProfileWithLabels`. (mirroring the way labels get
associated with the `g` for a goroutine in the first place)

Per-#6104, OS-thread creation profiles are a bit useless, as `M`s tend
to be created be created by a background goroutine. As such, I decided
not to add support for capturing the labels at `M`-creation-time, since
the stack-traces seem to always come out `nil` for my simple test
binaries.

This change currently provides labels for debug=0 and debug=1, as
debug=2 is currently entirely generated by the runtime package and I
don't see a clean way of getting the `labelMap` type handled properly
within the `runtime` package.

Update the comment added in cl/131275 to mention goroutine support for
labels.

Updates #23458

Change-Id: Ia4b558893d7d10156b77121cd9b70c4ccd9e1889
Reviewed-on: https://go-review.googlesource.com/c/go/+/189318
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-04-22 16:01:25 +00:00
Ruixin(Peter) Bao
0329c915a0 math/big: clean up whitespace in arith_s390x.s file
This CL looks big but it only does formatting changes to arith_s390x.s.
The file was formatted using asmfmt(https://github.com/klauspost/asmfmt)
, so there should not be any functional impact. I verified that the
generated assembly of big.test file is identical.

Change-Id: I8b4035ef082a4d0357881869327e25253f2d8be1
Reviewed-on: https://go-review.googlesource.com/c/go/+/229302
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-22 15:40:55 +00:00
Cherry Zhang
d8ab10525e [dev.link] cmd/link, cmd/oldlink: remove more darwin/386 and darwin/arm code
Updates #37610, #37611.

Change-Id: I0a497af03e24ddea40ed3e342f3a9362bf21ac0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/229323
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2020-04-22 15:27:18 +00:00
Cherry Zhang
c33b7c7592 [dev.link] cmd/internal/goobj: add index to symbol name for indexed symbols
With old object files, when objdump an object file which, for
example, contains a call of fmt.Fprintf, it shows a symbol
reference like

	R_CALL:fmt.Fprintf

With new object files, as the symbol reference is indexed, the
reference becomes

	R_CALL:fmt.#33

The object file does not contain information of what symbol #33
in the fmt package is.

To make this more useful, print the index when dumping the symbol
definitions. This way, when dumping the fmt package, e.g.
"go tool nm fmt.a", it will print

   6c705 T fmt.Fprintf#33

So we can find out what symbol #33 actually is.

Change-Id: I320776597d28615ce18dd0617c352d2b8180db49
Reviewed-on: https://go-review.googlesource.com/c/go/+/229246
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-22 15:14:44 +00:00
Cherry Zhang
245a2f5780 [dev.link] cmd/link: delete ctxt.Reachparent
It is no longer needed as we have converted the fieldtrack pass
to using the loader.

Also free loader.Reachparent after we are done with it.

Change-Id: Ibc4b29f282e1e4aea363a1b549755e31f84b0295
Reviewed-on: https://go-review.googlesource.com/c/go/+/229322
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-22 14:57:26 +00:00
Cherry Zhang
9570fc8f71 [dev.link] cmd/link: reduce memory usage for storing symbol section information
Currently, we use a dense array to store symbol's sections. The
array element is a *sym.Section, which takes 8 bytes per symbol
on a 64-bit machine. And the array is created upfront.

To reduce memory usage, use a 16-bit index for sections, so we
store 2 bytes per symbol. The array is pointerless, reducing GC
work. Also create the array lazily.

This reduces some memory usage: linking cmd/compile,

name           old alloc/op   new alloc/op   delta
Loadlib_GC       42.1MB ± 0%    36.2MB ± 0%      -14.01%  (p=0.008 n=5+5)

name           old live-B     new live-B     delta
Loadlib_GC        16.8M ± 0%     15.4M ± 0%       -8.36%  (p=0.008 n=5+5)
Archive_GC        98.2M ± 0%     97.2M ± 0%       -1.02%  (p=0.008 n=5+5) # at the end

Change-Id: If8c41eded8859660bca648c5e6fdf5830810fbf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/229306
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-22 14:40:35 +00:00
Martin Möhrmann
e93d5b5e05 unicode/utf8: optimize Valid and ValidString for ASCII checks
Add a fastpath that uses 32bit loads and compares to check
8 ASCII characters per loop iteration.

This avoids the overhead of comparing and branching
for every byte individually.

Combining two 32bit loads into an uint32 allows the same
code to be used for 32bit and 64bit platforms.

amd64 (Intel i7-3520M):
name                         old time/op  new time/op  delta
ValidTenASCIIChars           15.6ns ± 4%   8.5ns ±14%  -45.27%  (p=0.000 n=10+10)
ValidTenJapaneseChars        50.0ns ± 2%  52.7ns ±15%     ~     (p=0.469 n=10+10)
ValidStringTenASCIIChars     13.5ns ± 1%   7.9ns ± 5%  -41.56%  (p=0.000 n=10+10)
ValidStringTenJapaneseChars  46.3ns ± 2%  45.8ns ± 2%     ~     (p=0.085 n=10+10)

arm (Raspberry Pi 3):
name                         old time/op  new time/op  delta
ValidTenASCIIChars           87.5ns ± 0%  58.5ns ± 0%  -33.11%  (p=0.000 n=9+10)
ValidTenJapaneseChars         359ns ± 0%   384ns ± 0%   +6.96%  (p=0.000 n=10+9)
ValidStringTenASCIIChars     87.5ns ± 0%  57.5ns ± 0%  -34.31%  (p=0.000 n=10+10)
ValidStringTenJapaneseChars   356ns ± 0%   377ns ± 0%   +5.90%  (p=0.000 n=10+10)

Change-Id: I9da942bddb250ee1f0ef7aabb4a8cb48edd9053e
Reviewed-on: https://go-review.googlesource.com/c/go/+/228823
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-22 14:14:34 +00:00
Ruixin(Peter) Bao
a45ea55da7 cmd/internal: allow ADDE to work with memory location on s390x
Originally on s390x, ADDE does not work when adding numbers from a memory location.
For example: ADDE (R3), R4 will result in a failure.

Since ADDC, ADD and ADDW already supports adding from memory location,
let's support that for ADDE as well.

Change-Id: I7cbe112ea154733a621b948c6a21bbee63fb0c62
Reviewed-on: https://go-review.googlesource.com/c/go/+/229304
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-22 11:37:03 +00:00
Cuong Manh Le
79395c55e2 cmd/compile: remove ntz function
Use ntzX variants instead.

Passes toolstash-check -a.

Change-Id: I7a627f46f75c3d339034bd3e81c190cea5409c88
Reviewed-on: https://go-review.googlesource.com/c/go/+/229140
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-22 08:04:58 +00:00
Ian Lance Taylor
b71eafbcec time: use extended time format past end of zone transitions
This gives us better expected information for daylight savings time
transitions in year 2038 and beyond.

Fixes #36654

Change-Id: I5a39aed3c40b184e1d7bb7d6ce3aff5307c4c146
Reviewed-on: https://go-review.googlesource.com/c/go/+/215539
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-22 04:08:24 +00:00
Koichi Shiraishi
24a1c8f605 reflect: fix typo on resolveReflectName function documentation
Change-Id: I250de9db4e8aca6e1069d05c73051571f1712091
Reviewed-on: https://go-review.googlesource.com/c/go/+/229141
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-22 02:44:15 +00:00
Ian Lance Taylor
e5bd6e1c79 runtime: crash on SI_USER SigPanic signal
Clean up the code a little bit to make it clearer:

Don't check throwsplit for a SI_USER signal.

If throwsplit is set for a SigPanic signal, always throw;
discard any other flags.

Fixes #36420

Change-Id: Ic9dcd1108603d241f71c040504dfdc6e528f9767
Reviewed-on: https://go-review.googlesource.com/c/go/+/228900
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2020-04-22 00:01:14 +00:00
Brad Fitzpatrick
5a75f7c0b0 net/http: fix Server.Shutdown race where it could miss an active connection
Wait for Listeners to drop to zero too, not just conns.

Fixes #33313

Change-Id: I09350ae38087990d368dcf9302fbde3e95c02fcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/213442
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hasit Bhatt <hasit.p.bhatt@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-21 23:23:30 +00:00
Michael Anthony Knyszek
eacdf76b93 runtime: add bitmap-based markrootSpans implementation
Currently markrootSpans, the scanning routine which scans span specials
(particularly finalizers) as roots, uses sweepSpans to shard work and
find spans to mark.

However, as part of a future CL to change span ownership and how
mcentral works, we want to avoid having markrootSpans use the sweep bufs
to find specials, so in this change we introduce a new mechanism.

Much like for the page reclaimer, we set up a per-page bitmap where the
first page for a span is marked if the span contains any specials, and
unmarked if it has no specials. This bitmap is updated by addspecial,
removespecial, and during sweeping.

markrootSpans then shards this bitmap into mark work and markers iterate
over the bitmap looking for spans with specials to mark. Unlike the page
reclaimer, we don't need to use the pageInUse bits because having a
special implies that a span is in-use.

While in terms of computational complexity this design is technically
worse, because it needs to iterate over the mapped heap, in practice
this iteration is very fast (we can skip over large swathes of the heap
very quickly) and we only look at spans that have any specials at all,
rather than having to touch each span.

This new implementation of markrootSpans is behind a feature flag called
go115NewMarkrootSpans.

Updates #37487.

Change-Id: I8ea07b6c11059f6d412fe419e0ab512d989377b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/221178
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2020-04-21 22:50:51 +00:00
Matthew Dempsky
2a2423bd05 cmd/compile: more precise analysis of method values
Previously for a method value "x.M", we always flowed x directly to
the heap, which led to the receiver argument generally needing to be
heap allocated.

This CL changes it to flow x to the closure and M's receiver
parameter. This allows receiver arguments to be stack allocated as
long as (1) the closure never escapes, *and* (2) method doesn't leak
its receiver parameter.

Within the standard library, this allows a handful of objects to be
stack allocated instead. Listed here are diagnostics that were
previously emitted by "go build -gcflags=-m std cmd" that are no
longer emitted:

archive/tar/writer.go:118:6: moved to heap: f
archive/tar/writer.go:208:6: moved to heap: f
archive/tar/writer.go:248:6: moved to heap: f
cmd/compile/internal/gc/initorder.go:252:2: moved to heap: d
cmd/compile/internal/gc/initorder.go:75:2: moved to heap: s
cmd/go/internal/generate/generate.go:206:7: &Generator literal escapes to heap
cmd/internal/obj/arm64/asm7.go:910:2: moved to heap: c
cmd/internal/obj/mips/asm0.go:415:2: moved to heap: c
cmd/internal/obj/pcln.go:294:22: new(pcinlineState) escapes to heap
cmd/internal/obj/s390x/asmz.go:459:2: moved to heap: c
crypto/tls/handshake_server.go:56:2: moved to heap: hs

Thanks to Cuong Manh Le for help coming up with this solution.

Fixes #27557.

Change-Id: I8c85d671d07fb9b53e11d2dd05949a34dbbd7e17
Reviewed-on: https://go-review.googlesource.com/c/go/+/228263
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-21 20:49:34 +00:00
Matthew Dempsky
1811533695 cmd/compile: refactor Escape.tagHole
This CL refactors tagHole to handle all three call situations (unknown
function; known function in same analysis batch; known function in
previous analysis batch). This will make it somewhat easier to reuse
in a followup CL.

Passes toolstash-check.

Change-Id: I764d047a333dfc593d721a881361683e94b485df
Reviewed-on: https://go-review.googlesource.com/c/go/+/229059
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-21 20:48:43 +00:00
Michael Pratt
300ff5d8ac runtime: allow proflock and mheap.speciallock above globalAlloc.mutex
During schedinit, these may occur in:

mProf_Malloc
  stkbucket
    newBucket
      persistentalloc
        persistentalloc1

mProf_Malloc
  setprofilebucket
    fixalloc.alloc
      persistentalloc
        persistentalloc1

These seem to be legitimate lock orderings.

Additionally, mheap.speciallock had a defined rank, but it was never
actually used. That is fixed now.

Updates #38474

Change-Id: I0f6e981852eac66dafb72159f426476509620a65
Reviewed-on: https://go-review.googlesource.com/c/go/+/228786
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2020-04-21 20:22:06 +00:00
Michael Munday
e464d7d797 cmd/compile: optimize comparisons with immediates on s390x
When generating code for unsigned equals (==) and not equals (!=)
comparisons we currently, on s390x, always use signed comparisons.

This mostly works well, however signed comparisons on s390x sign
extend their immediates and unsigned comparisons zero extend them.
For compare-and-branch instructions which can only have 8-bit
immediates this significantly changes the range of immediate values
we can represent: [-128, 127] for signed comparisons and [0, 255]
for unsigned comparisons.

When generating equals and not equals checks we don't neet to worry
about whether the comparison is signed or unsigned. This CL
therefore adds rules to allow us to switch signedness for such
comparisons if it means that it brings a constant into range for an
8-bit immediate.

For example, a signed equals with an integer in the range [128, 255]
will now be implemented using an unsigned compare-and-branch
instruction rather than separate compare and branch instructions.

As part of this change I've also added support for adding a name
to block control values using the same `x:(...)` syntax we use for
value rules.

Triggers 792 times when compiling cmd and std.

Change-Id: I77fa80a128f0a8ce51a2888d1e384bd5e9b61a77
Reviewed-on: https://go-review.googlesource.com/c/go/+/228642
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-21 19:23:51 +00:00
Josh Bleecher Snyder
099c6116cc Revert "runtime/pprof: speed up CPU profiling shutdown"
This reverts commit 1f0738c157.

Reason for revert: This May have caused issue 38567.

Change-Id: I2afa6a9d42cb29cfad09e706fb465c57e3774abd
Reviewed-on: https://go-review.googlesource.com/c/go/+/229301
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-04-21 19:17:57 +00:00
Cuong Manh Le
05db7de1c1 cmd/compile: remove unused nlo function
Change-Id: I858d666d491f649f78581a43437408ffab33863b
Reviewed-on: https://go-review.googlesource.com/c/go/+/229139
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
2020-04-21 18:41:44 +00:00
Cuong Manh Le
65c9b57566 cmd/compile: remove nlz function
Use nlzX variants instead. While at it, also remove tests involve
nlz/nlo/nto/log2, since when we are calling directly "math/bits"
functions.

Passes toolstash-check.

Change-Id: I83899741a29e05bc2c19d73652961ac795001781
Reviewed-on: https://go-review.googlesource.com/c/go/+/229138
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-21 18:15:14 +00:00
Alberto Donizetti
a95bf77e1a cmd/compile: convert last 386 rules to typed aux
Passes

  GOARCH=386 gotip build -toolexec 'toolstash -cmp' -a std

Change-Id: I4d1ca83d37ab9f628fc3f1261fe40b81e59137ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/229100
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-21 17:18:24 +00:00
Jay Conrod
65f46486a1 cmd/go/internal/load: load imports for all package data errors
go/build.Import can return errors for many different reasons like
inconsistent package clauses or errors parsing build constraints.
It will still return a *build.Package with imports from files it was
able to process. Package.load should load these imports, even after an
unknown error.

There is already a special case for scanner.ErrorList (parse
error). This CL expands that behavior for all errors.

Fixes #38568

Change-Id: I871827299c556f1a9a5b12e7755b221e9d8c6e0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/229243
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-04-21 17:11:39 +00:00
Russ Cox
768201729d cmd/compile: detect and diagnose invalid //go: directive placement
Thie CL changes cmd/compile/internal/syntax to give the gc half of
the compiler more control over pragma handling, so that it can prepare
better errors, diagnose misuse, and so on. Before, the API between
the two was hard-coded as a uint16. Now it is an interface{}.
This should set us up better for future directives.

In addition to the split, this CL emits a "misplaced compiler directive"
error for any directive that is in a place where it has no effect.
I've certainly been confused in the past by adding comments
that were doing nothing and not realizing it. This should help
avoid that kind of confusion.

The rule, now applied consistently, is that a //go: directive
must appear on a line by itself immediately before the declaration
specifier it means to apply to. See cmd/compile/doc.go for
precise text and test/directive.go for examples.

This may cause some code to stop compiling, but that code
was broken. For example, this code formerly applied the
//go:noinline to f (not c) but now will fail to compile:

	//go:noinline
	const c = 1

	func f() {}

Change-Id: Ieba9b8d90a27cfab25de79d2790a895cefe5296f
Reviewed-on: https://go-review.googlesource.com/c/go/+/228578
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-04-21 16:47:01 +00:00
Than McIntosh
7a22f11e96 [dev.link] cmd/link: separate out DWARF processing from dodata's allocateSections
Split out DWARF symbol-to-section assignment into its own separate
helper routine, to improve readability. No change in functionality.

Change-Id: Ic2e4f4d99afbff65161cbb8bd63e866ea555f322
Reviewed-on: https://go-review.googlesource.com/c/go/+/228957
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-21 16:30:47 +00:00
Than McIntosh
87b43088cd [dev.link] cmd/link: refactor section creation in dodata
Additional cleanups and refactorings in the allocateSections portion
of dodata. Introduce some new helper routines to be used for common
cases in creating sections and assigning symbols, with a goal of
reducing duplicated code blocks and having more readable code.

No change in functionality.

Change-Id: I1b020b3ee993674329b2bebfd7c35995e3a2c043
Reviewed-on: https://go-review.googlesource.com/c/go/+/228883
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-21 16:26:42 +00:00
BurtonQin
4f27e1d7aa cmd/go/internal/modfetch: add Unlock before return in checkModSum
In cmd/go/internal/modfetch/fetch.go,
`checkModSum()` forgets Unlock before return, which may lead to deadlock.
876c1feb7d/src/cmd/go/internal/modfetch/fetch.go (L514-L520)
The fix is to add `goSum.mu.Unlock()` before return.

Change-Id: I855b1c1bc00aeada2c1e84aabb5328f02823007d
GitHub-Last-Rev: afeb3763dd
GitHub-Pull-Request: golang/go#38563
Reviewed-on: https://go-review.googlesource.com/c/go/+/229219
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
2020-04-21 15:37:29 +00:00
Rohith Ravi
af55060b39 cmd/trace: fix the broken link in region pages and improve UX
The trace tool had a broken link due to a parameter encoding error,
which has been corrected.

In addition:

- the user regions page has been enhanced to include links to
pprof style profiles for region specific io, block, syscall and
schedwait profiles.

- sortable table headers have a pointer cursor to indicate they're
clickable.

Fixes #38518

Change-Id: I26cd5157bd9753750f5f53ea03aac5d2d41b021c
Reviewed-on: https://go-review.googlesource.com/c/go/+/228899
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-04-21 14:57:43 +00:00
Cherry Zhang
47cac82e36 [dev.link] cmd/link: convert symtab pass to new style
This is more or less a direct translation, to get things going.
There are more things we can do to make it better, especially on
the handling of container symbols.

Change-Id: I11a0087e402be8d42b9d06869385ead531755272
Reviewed-on: https://go-review.googlesource.com/c/go/+/229125
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-21 14:29:02 +00:00
Richard Miller
664d270727 os: correct bad PathError message from FileOpen with O_CREATE on Plan 9
On Plan 9, FileOpen with flag O_CREATE & ~O_TRUNC is done in two
steps.  First, syscall.Open is attempted, to avoid truncation when opening
an existing file.  If that fails because the file doesn't exist,
syscall.Create is used to create a new file.  If the Create fails,
for example because we are racing with another process to create a
ModeExclusive file, the PathError returned from FileOpen should reflect
the result of the Create, not the "does not exist" error from the initial
Open attempt.

Fixes #38540

Change-Id: I90c95a301de417ecdf79cd52748591edb1dbf528
Reviewed-on: https://go-review.googlesource.com/c/go/+/229099
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
2020-04-21 11:41:40 +00:00
alex-semenyuk
876c1feb7d test/codegen, runtime/pprof, runtime: apply fmt
Change-Id: Ife4e065246729319c39e57a4fbd8e6f7b37724e1
GitHub-Last-Rev: e71803eaeb
GitHub-Pull-Request: golang/go#38527
Reviewed-on: https://go-review.googlesource.com/c/go/+/228901
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2020-04-21 09:07:42 +00:00
Alberto Donizetti
17fbc818ff cmd/compile: switch to typed aux for 386 optimization rules
Convert first section of 386 optimization rules to the typed aux form.

Adds addOffset{32,64} functions that returns ValAndOffs and a
ValAndOff.canAdd32 function that takes an int32.

Passes

  GOARCH=386 gotip build -toolexec 'toolstash -cmp' -a std

Change-Id: I69d2a8ace6936d5e8ba6ba047183002bf07dd5be
Reviewed-on: https://go-review.googlesource.com/c/go/+/228825
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-21 08:08:49 +00:00
Josh Bleecher Snyder
4974ac6874 cmd/compile: use cheaper implementation of oneBit
This is the second attempt. The first attempt was CL 229127,
which got rolled back by CL 229177, because it caused
an infinite loop during compilation on some platforms.
I didn't notice that the trybots hadn't completed when I submitted; mea culpa.

The bug was that we were checking x&(x-1)==0, which is also true of 0,
which does not have exactly one bit set.
This caused an infinite rewrite rule loop.

Updates #38547

file    before    after     Δ       %
compile 19678112  19669808  -8304   -0.042%
total   113143160 113134856 -8304   -0.007%

Change-Id: I417a4f806e1ba61277e31bab2e57dd3f1ac7e835
Reviewed-on: https://go-review.googlesource.com/c/go/+/229197
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
2020-04-21 05:56:02 +00:00
Matthew Dempsky
0eb694e9c2 reflect: disallow invoking methods on unexported embedded fields
Given:

    type u struct{}
    func (u) M() {}

    type t struct { u; u2 u }

    var v = reflect.ValueOf(t{})

Package reflect allows:

    v.Method(0)          // v.M
    v.Field(0).Method(0) // v.u.M

but panics from:

    v.Field(1).Method(0) // v.u2.M

because u2 is not an exported field. However, u is not an exported
field either, so this is inconsistent.

It seems like this behavior originates from #12367, where it was
decided to allow traversing unexported embedded fields to be able to
access their exported fields, since package reflect doesn't provide an
alternative way to access promoted fields directly.

But extending that logic to promoted *methods* was inappropriate,
because package reflect's normal method handling logic already handles
promoted methods correctly. This CL corrects that mistake.

Fixes #38521.

Change-Id: If65008965f35927b4e7927cddf8614695288eb19
Reviewed-on: https://go-review.googlesource.com/c/go/+/228902
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-21 05:41:33 +00:00
Josh Bleecher Snyder
9255163091 Revert "cmd/compile: use cheaper implementation of oneBit"
This reverts commit 066c47ca5f.

Reason for revert: This appears to have broken a bunch of builders.

Change-Id: I68b4decf3c1892766e195d8eb018844cdff69443
Reviewed-on: https://go-review.googlesource.com/c/go/+/229177
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2020-04-21 04:28:59 +00:00
Ian Lance Taylor
f6b30e53bb reflect: return user-visible method name in panic string
This was accidentally broken in CL 166462, which introduce another
function in the panicking path without adjusting the argument to
runtime.Caller.

Change-Id: Ib6f9ed8673fefd458c7a4e3a918c45c5b31ca552
Reviewed-on: https://go-review.googlesource.com/c/go/+/229082
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-04-21 04:14:15 +00:00
Cuong Manh Le
7f8fda3c0b cmd/compile: use proper magnitude for (x>>c) & uppermask = 0
This is followup of CL 228860, which rewrite shift rules to use typed
aux. That CL introduced nlz* functions, to refactor left shift rules.
While at it, we realize there's a bug in old rules with both right/left
shift rules, but only fix for left shift rules only.

This CL fixes the bug for right shift rules.

Passes toolstash-check.

Change-Id: Id8f2158b1b66c9e87f3fdeaa7ae3e35dc0666f8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/229137
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-21 03:45:26 +00:00
Cuong Manh Le
0f14c2a042 cmd/compile: rewrite shift rules to use typed aux fields
Passes toolstash-check.

Change-Id: I02e78591fe46e19a43dc36913baef0338a014a3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/228860
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-21 03:13:22 +00:00
Josh Bleecher Snyder
066c47ca5f cmd/compile: use cheaper implementation of oneBit
Updates #38547

file    before    after     Δ       %       
compile 19678112  19669808  -8304   -0.042% 
total   113143160 113134856 -8304   -0.007% 

Change-Id: I5f8afe17401dbdb7c7b3d66d95fe40821c499a92
Reviewed-on: https://go-review.googlesource.com/c/go/+/229127
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-21 00:38:53 +00:00
Josh Bleecher Snyder
50b11318fe cmd/compile: use oneBit instead of isPowerOfTwo in bit optimization
This optimization works on any integer with exactly one bit set.
This is identical to being a power of two, except in the
most negative number. Use oneBit instead.

The rule now triggers in a few more places in std+cmd,
in packages encoding/asn1, crypto/elliptic, and
vendor/golang.org/x/crypto/cryptobyte.

This change obviates the need for CL 222479
by doing this optimization consistently in the compiler.

Change-Id: I983c6235290fdc634fda5e11b10f1f8ce041272f
Reviewed-on: https://go-review.googlesource.com/c/go/+/229124
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-21 00:38:34 +00:00
Josh Bleecher Snyder
12665b9a06 cmd/compile: convert two generic rules to be typed
Prelude to changing the rules.

Passes toolstash-check.

Change-Id: I22fead7f74d2cf97bb3fbeb22741125b42914c43
Reviewed-on: https://go-review.googlesource.com/c/go/+/229123
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-21 00:38:14 +00:00
Robert Griesemer
eec981e622 go/types: remove duplicate assert call (minor cleanup)
Change-Id: I6051b3305f8ee02bec4ff3dc7ec2217daed38d72
Reviewed-on: https://go-review.googlesource.com/c/go/+/228903
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-21 00:09:00 +00:00
David Finkel
1cca496c5e Revert "Revert "cmd/compile: adjust RISCV64 rewrite rules to use typed aux fields""
This reverts commit 98c32670fd454939794504225dca1d4ec55045d5.

Rolling-forward with trivial format-string fix

cmd/compile: adjust RISCV64 rewrite rules to use typed aux fields

Also add a typed version of mergeSym to rewrite.go to assist with a few
rules that used mergeSym in the untyped-form.

Remove a few extra int32 overflow checks that no longer make sense, as
adding two int8s or int16s should never overflow an int32.

Passes toolstash-check -all.

Original review: https://go-review.googlesource.com/c/go/+/228882

Change-Id: Ib63db4ee1687446f0f3d9f11575a40dd85cbce55
Reviewed-on: https://go-review.googlesource.com/c/go/+/229126
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-20 23:30:29 +00:00
David Carter
f38fad4aaa cmd/cover: add <title> tag to <head> for coverage report HTML template
Adds a missing <title> tag to the HTML template to make it
more compliant as <title> tags are generally required for valid
HTML documents.

Change-Id: I1ab2a6ee221c8a79d3cc13d9ac6110f6f4963914
GitHub-Last-Rev: 6d519dc9dd
GitHub-Pull-Request: golang/go#38313
Reviewed-on: https://go-review.googlesource.com/c/go/+/227547
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-20 22:48:51 +00:00
Ian Lance Taylor
2edd351b92 runtime: skip TestBigGOMAXPROCS if it runs out of memory
Fixes #38541

Change-Id: I0e9ea5865628d953c32f3a5d4b3ccf1c1d0b081e
Reviewed-on: https://go-review.googlesource.com/c/go/+/229077
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-20 22:42:49 +00:00
Than McIntosh
0cffc95109 Revert "cmd/compile: adjust RISCV64 rewrite rules to use typed aux fields"
This reverts commit 7004be998b.

Reason for revert: causing failures on many builders

Change-Id: I9216bd5409bb6814bac18a6a13ef5115db01b5fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/229120
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-20 22:38:59 +00:00
Bryan C. Mills
75e79adaf9 cmd/api: limit concurrent 'go list' calls to GOMAXPROCS
Each invocation of 'go list' may consume a significant quantity of
system resources, including buffers for reading files and RAM for the
runtime's memory footprint.
Very small builders may even hit swap as a result of that load,
further exacerbating resource contention.

To avoid overloading small builders, restrict 'go list' calls to
runtime.GOMAXPROCS as it is set at the first call to loadImports.

This also somewhat improves running time even on larger machines: on
my workstation, this change reduces the wall time for 'go test
cmd/api' by around 100ms.

Updates #38537

Change-Id: I968e0f961a8f1d84c27e1ab8b621b9670dcfd448
Reviewed-on: https://go-review.googlesource.com/c/go/+/228998
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-20 21:23:00 +00:00
Brad Fitzpatrick
40a144b94f crypto/tls: add Dialer
Fixes #18482

Change-Id: I99d65dc5d824c00093ea61e7445fc121314af87f
Reviewed-on: https://go-review.googlesource.com/c/go/+/214977
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-20 20:33:36 +00:00
David Finkel
7004be998b cmd/compile: adjust RISCV64 rewrite rules to use typed aux fields
Also add a typed version of mergeSym to rewrite.go to assist with a few
rules that used mergeSym in the untyped-form.

Remove a few extra int32 overflow checks that no longer make sense, as
adding two int8s or int16s should never overflow an int32.

Passes toolstash-check -all.

Change-Id: I72ddd2b0d9001faa87ad0ab54f500057164661b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/228882
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-20 20:22:51 +00:00
Josh Bleecher Snyder
0239a5c478 cmd/compile: use fuse to implement shortcircuit loop
The rewrite loop in shortcircuit is identical to the one in fuse.
That's not surprising; shortcircuit is fuse-like.

Take advantage of that by merging the two loops.

Passes toolstash-check.

Change-Id: I642cb39a23d2ac8964ed577678f062fce721439c
Reviewed-on: https://go-review.googlesource.com/c/go/+/229003
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-20 19:36:50 +00:00
Than McIntosh
5cccd7a724 [dev.link] cmd/link: refactor symbol to section assignment in allocateSections
Create a couple of helper routines to aid in assigning symbols to
sections in dodata's allocateSections, then replace loops over symbol
lists with calls to the helpers, to reduce the amount of duplicate
code.

This patch also decouples gcprog/gcdata generation from
symbol-to-section assignment (previously intertwined), as an aid to
making the code less complicated.

No change in functionality.

Change-Id: If126579486bce458f697e32bad556df453df53e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/228781
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-20 19:26:32 +00:00
Than McIntosh
c32b590264 [dev.link] cmd/link: revise representation of dwarfp
Change linker DWARF generation to move away from emitting a single
giant list of DWARF symbols, and instead emit a list of descriptors,
with each descriptor holding the symbols for a specific DWARF section.

While placing all DWARF symbols in a single lists does come in handy
in certain instances, it also creates a lot of confusion and weird
code in other cases, specifically where we want to perform operations
on a section-by-section basis (resulting in code that tries to
re-discover section boundaries by walking/inspecting the list).

Change-Id: I4dac81bd38cba903c9fd7004d613597e76dfb77a
Reviewed-on: https://go-review.googlesource.com/c/go/+/228780
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-20 19:25:18 +00:00
Than McIntosh
817bd10cae [dev.link] cmd/link: continue refactoring dodata
Move more items into the dodata state object (including the "datsize"
variable used in allocateSections) and the Link ctxt pointer), so as
to prepare for follow-on refactorings. No change in functionality.

Change-Id: Ie2b1651c1ac9b89deb3f7692227dcd931240afa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/228779
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-20 19:19:20 +00:00
Daniel Theophanes
c9af5523f3 database/sql: on Tx rollback, retain connection if driver can reset session
Previously the Tx would drop the connection after rolling back from
a context cancel. Now if the driver can reset the session,
keep the connection.

Change-Id: Ie6a3124275632787629844d91a06bb2e70cc060b
Reviewed-on: https://go-review.googlesource.com/c/go/+/216241
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-20 18:47:26 +00:00
Jeremy Faller
8ab37b1baf [dev.link] cmd/link: fallocate space, and remove all msync calls
The fallocate calls will lower the chances of SIGBUS in the linker, but
it might still happen on other unsupported platforms and filesystems.

Darwin cmd/compile stats:

Munmap                    16.0ms ± 8%     0.8ms ± 3%   -95.19%  (p=0.000 n=8+10)
TotalTime                  484ms ± 2%     462ms ± 2%    -4.52%  (p=0.000 n=10+9)

Updates #37310

Change-Id: I41c6e490adec26fa1ebee49a5b268828f5ba05e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/228385
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-20 18:32:58 +00:00
Jeremy Faller
7d4c455a80 [dev.link] cmd/link: rename deadcode2 to deadcode
deadcode's been completely replaced. Make its death official.

Change-Id: I85f1e3968463f216b8bce2fb7217c3b51641939f
Reviewed-on: https://go-review.googlesource.com/c/go/+/229002
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-20 18:29:24 +00:00
Cherry Zhang
6290a54365 [dev.link] cmd/link: don't write text address directly if using plugins
When using plugins, on darwin we do weird things with
runtime.etext symbol, assigning a value for it, then clear it,
reassign a different value. This breaks the logic of writing text
address directly.

I think we should remove the weird thing with runtime.etext, if
possible. But for now, disable the optimization (this is not a
common case anyway).

Fix darwin-nocgo build.

Change-Id: Iab6a9f8519115226a5bbaaafe4a93f17042a928a
Reviewed-on: https://go-review.googlesource.com/c/go/+/229057
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-20 18:26:46 +00:00
Daniel Theophanes
d8f0a229b5 database/sql: prevent Tx statement from committing after rollback
It was possible for a Tx that was aborted for rollback
asynchronously to execute a query after the rollback had completed
on the database, which often would auto commit the query outside
of the transaction.

By W-locking the tx.closemu prior to issuing the rollback
connection it ensures any Tx query either fails or finishes
on the Tx, and never after the Tx has rolled back.

Fixes #34775
Fixes #32942

Change-Id: I017b7932082f2f4ead70bae08b61ed9068ac1d01
Reviewed-on: https://go-review.googlesource.com/c/go/+/216240
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-04-20 17:45:50 +00:00
Daniel Theophanes
b2cff7e091 database/sql: check conn expiry when returning to pool, not when handing it out
With the original connection reuse strategy, it was possible that
when a new connection was requested, the pool would wait for an
an existing connection to return for re-use in a full connection
pool, and then it would check if the returned connection was expired.
If the returned connection expired while awaiting re-use, it would
return an error to the location requestiong the new connection.
The existing call sites requesting a new connection was often the last
attempt at returning a connection for a query. This would then
result in a failed query.

This change ensures that we perform the expiry check right
before a connection is inserted back in to the connection pool
for while requesting a new connection. If requesting a new connection
it will no longer fail due to the connection expiring.

Fixes #32530

Change-Id: If16379befe0e14d90160219c0c9396243fe062f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/216197
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-04-20 17:41:27 +00:00
Josh Bleecher Snyder
f8ff12d480 cmd/compile: use dereference boundedness hint in ssa.addr
Follow-up to (and similar to) CL 228885.
Triggers a handful of times in std+cmd.

Change-Id: Ie04057ca3974ef9eef669335e326a5ed4b7472cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/228999
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-20 17:27:11 +00:00
Cherry Zhang
dce26bdbc1 [dev.link] cmd/oldlink: update with recent linker changes
Port CL 228792, CL 228877, and CL 228881 to old linker.

Change-Id: Id3fdc413a9f7b38887ae8cc7bca5904933be93de
Reviewed-on: https://go-review.googlesource.com/c/go/+/229001
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
2020-04-20 16:51:00 +00:00
Josh Bleecher Snyder
4e550bdacd cmd/compile: simplify state.addr
OADDR nodes can't be bounded.
All calls to state.addr thus pass false.
Remove the argument.

Passes toolstash-check.

Change-Id: I9a3fcf37f63b2b5094e043d39ab3b857b5090e91
Reviewed-on: https://go-review.googlesource.com/c/go/+/228788
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-04-20 16:38:31 +00:00
Josh Bleecher Snyder
e8518731be cmd/compile: use dereference boundedness hint during ssa conversion
This has a minor positive effect on generated code,
particularly code using type switches.

Change-Id: I7269769ab0d861ef6fc9e6d7809ffc3573c68340
Reviewed-on: https://go-review.googlesource.com/c/go/+/228885
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-04-20 16:36:22 +00:00
Josh Bleecher Snyder
5abf5f831e cmd/compile: clarify Node.NonNil and Node.Bounded
Node.NonNil and Node.Bounded were a bit muddled. This led to #38496.
This change clarifies and documents them.

It also corrects one misuse.
However, since ssa conversion doesn't make full use of the bounded hint,
this correction doesn't change any generated code.
The next change will fix that.

Passes toolstash-check.

Change-Id: I2bcd487a0a4aef5d7f6090e653974fce0dce3b8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/228787
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-04-20 16:35:40 +00:00
Cherry Zhang
7658648871 [dev.link] all: merge branch 'master' into dev.link
Clean merge.

Change-Id: I514936d6d2a30c6f801686801209759d15ce06bd
2020-04-20 11:57:20 -04:00
Josh Bleecher Snyder
1f0738c157 runtime/pprof: speed up CPU profiling shutdown
The core CPU profiling loop contains a 100ms sleep.
This is important to reduce overhead.

However, it means that it takes 200ms to shutting down a program
with CPU profiling enabled. When trying to collect many samples
by running a short-lived program many times, this adds up.

This change cuts the shutdown penalty in half by skipping
the sleep whenever possible.

Change-Id: Ic3177f8e1a2d331fe1a1ecd7c8c06f50beb42535
Reviewed-on: https://go-review.googlesource.com/c/go/+/228886
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2020-04-20 15:52:05 +00:00
Josh Bleecher Snyder
12d1c9b863 cmd/compile: delete gdata
All callers to gdata knew the kind of node they were working with,
so all calls to gdata have been replaced with more specific calls.

Some OADDR nodes were constructed solely for the purpose of
passing them to gdata for unwrapping. In those cases, we can now
cut to the chase.

Passes toolstash-check.

Change-Id: Iacc1abefd7f748cb269661a03768d3367319b0b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/228888
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-04-20 15:37:49 +00:00
Josh Bleecher Snyder
ed5233166f cmd/compile: simplify slicebytes
Use slicesym to implement. Remove len param.

Passes toolstash-check.

Change-Id: Ia6d4fb2a3b476eceeba60979b4dd82b634b43939
Reviewed-on: https://go-review.googlesource.com/c/go/+/228887
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-04-20 15:35:23 +00:00
Cherry Zhang
c364079a53 [dev.link] cmd/link: use function address directly in pclntab generation
If we are internal linking a static executable, in pclntab
generation, the function addresses are known, so we can just use
them directly instead of emitting relocations.

For external linking or other build modes,  we are generating a
relocatable binary so we still need to emit relocations.

Reduce some allocations: for linking cmd/compile,

name           old alloc/op   new alloc/op   delta
Pclntab_GC       38.8MB ± 0%    36.4MB ± 0%   -6.19%  (p=0.008 n=5+5)

TODO: can we also do this in DWARF generation?

Change-Id: I43920d930ab1da97c205871027e01844a07a5e60
Reviewed-on: https://go-review.googlesource.com/c/go/+/228478
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2020-04-20 14:20:16 +00:00