]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
4 years ago[dev.link] all: merge branch 'master' into dev.link
Cherry Zhang [Mon, 20 Apr 2020 15:57:20 +0000 (11:57 -0400)]
[dev.link] all: merge branch 'master' into dev.link

Clean merge.

Change-Id: I514936d6d2a30c6f801686801209759d15ce06bd

4 years agoruntime/pprof: speed up CPU profiling shutdown
Josh Bleecher Snyder [Wed, 1 Jan 2020 05:24:20 +0000 (21:24 -0800)]
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>
4 years agocmd/compile: delete gdata
Josh Bleecher Snyder [Sat, 11 Apr 2020 13:52:09 +0000 (06:52 -0700)]
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>
4 years agocmd/compile: simplify slicebytes
Josh Bleecher Snyder [Sat, 11 Apr 2020 04:33:27 +0000 (21:33 -0700)]
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>
4 years ago[dev.link] cmd/link: use function address directly in pclntab generation
Cherry Zhang [Thu, 16 Apr 2020 02:23:41 +0000 (22:23 -0400)]
[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>
4 years ago[dev.link] cmd/link: remove buffered file I/O from OutBuf
Jeremy Faller [Fri, 17 Apr 2020 20:07:45 +0000 (16:07 -0400)]
[dev.link] cmd/link: remove buffered file I/O from OutBuf

Recreation of CL 228317.

The problem with that original CL was a late requested change,
reordering reloc and asmb, resulting in symbols having stale pointers to
their data. I've fixed this by preallocating the heap variable in OutBuf
for platforms w/o mmap.

Change-Id: Icdb392ac2c8d6518830f4c84cf422e78b8ab68c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/228782
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile: remove useless nil check in symfmt
Cuong Manh Le [Mon, 20 Apr 2020 04:09:16 +0000 (11:09 +0700)]
cmd/compile: remove useless nil check in symfmt

This is followup of CL 228861, which remove another un-necessary nil
check for s.Pkg.

Passes toolstash-check.

Change-Id: Ide750beddd2594199af21b56ec6af734dfa55b9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/228862
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: remove nil check for p in isReflectPkg
Cuong Manh Le [Mon, 20 Apr 2020 03:55:02 +0000 (10:55 +0700)]
cmd/compile: remove nil check for p in isReflectPkg

CL 228859 refactored detecting reflect package logic in to isReflectPkg
function. The function has un-necessary nil check for p, so remove that
check.

Passes toolstash-check.

Change-Id: I2f3f1ac967fe8d176dda3f3b4698ded08602e2fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/228861
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agoall.rc: pass arguments to make.rc
Cherry Zhang [Mon, 20 Apr 2020 01:12:04 +0000 (21:12 -0400)]
all.rc: pass arguments to make.rc

all.bash passes argument to make.bash. Do the same for all.rc.

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

4 years agocmd/compile: refactor detecting package reflect logic
Cuong Manh Le [Sun, 19 Apr 2020 15:18:15 +0000 (22:18 +0700)]
cmd/compile: refactor detecting package reflect logic

Passes toolstash-check.

Change-Id: Ie4b1f61528bb183dc66bb6955851a47b2641549c
Reviewed-on: https://go-review.googlesource.com/c/go/+/228859
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: speed up compiling with -S
Josh Bleecher Snyder [Sun, 26 Jan 2020 17:59:25 +0000 (09:59 -0800)]
cmd/compile: speed up compiling with -S

Compiling with -S was not implemented with performance in mind.
It allocates profligately. Compiling with -S is ~58% slower,
allocates ~47% more memory, and does ~183% more allocations.

compilecmp now uses -S to do finer-grained comparisons between
compiler versions, so I now care about its performance.

This change picks some of the lowest hanging fruit,
mostly by modifying printing routines to print directly to a writer,
rather than constructing a string first.

I have confirmed that compiling std+cmd with "-gcflags=all=-S -p=1"
and CGO_ENABLED=0 yields identical results before/after this change.
(-p=1 makes package compilation order deterministic. CGO_ENABLED=0
prevents cgo temp workdirs from showing up in filenames.)

Using the -S flag, the compiler performance impact is:

name        old time/op       new time/op       delta
Template          344ms ± 2%        301ms ± 2%  -12.45%  (p=0.000 n=22+24)
Unicode           136ms ± 3%        121ms ± 3%  -11.40%  (p=0.000 n=24+25)
GoTypes           1.24s ± 5%        1.09s ± 3%  -12.58%  (p=0.000 n=25+25)
Compiler          5.66s ± 4%        5.06s ± 2%  -10.56%  (p=0.000 n=25+20)
SSA               19.9s ± 3%        17.2s ± 4%  -13.64%  (p=0.000 n=25+25)
Flate             212ms ± 2%        188ms ± 2%  -11.33%  (p=0.000 n=25+24)
GoParser          278ms ± 3%        242ms ± 1%  -12.84%  (p=0.000 n=23+24)
Reflect           743ms ± 3%        657ms ± 5%  -11.56%  (p=0.000 n=24+25)
Tar               295ms ± 2%        263ms ± 2%  -10.78%  (p=0.000 n=25+25)
XML               409ms ± 2%        360ms ± 3%  -12.03%  (p=0.000 n=24+25)
[Geo mean]        714ms             629ms       -11.92%

name        old user-time/op  new user-time/op  delta
Template          430ms ± 5%        388ms ± 3%   -9.76%  (p=0.000 n=21+24)
Unicode           202ms ±12%        171ms ± 5%  -15.21%  (p=0.000 n=25+23)
GoTypes           1.58s ± 3%        1.42s ± 3%   -9.58%  (p=0.000 n=24+24)
Compiler          7.42s ± 3%        6.68s ± 8%   -9.93%  (p=0.000 n=25+25)
SSA               26.9s ± 3%        22.9s ± 3%  -14.85%  (p=0.000 n=25+25)
Flate             260ms ± 6%        234ms ± 3%   -9.69%  (p=0.000 n=23+25)
GoParser          354ms ± 1%        296ms ± 3%  -16.46%  (p=0.000 n=23+25)
Reflect           953ms ± 2%        865ms ± 4%   -9.14%  (p=0.000 n=24+24)
Tar               380ms ± 2%        348ms ± 2%   -8.28%  (p=0.000 n=25+22)
XML               530ms ± 3%        451ms ± 3%  -15.01%  (p=0.000 n=24+23)
[Geo mean]        929ms             819ms       -11.84%

name        old alloc/op      new alloc/op      delta
Template         54.1MB ± 0%       44.3MB ± 0%  -18.24%  (p=0.000 n=24+24)
Unicode          33.5MB ± 0%       30.6MB ± 0%   -8.57%  (p=0.000 n=25+25)
GoTypes           189MB ± 0%        152MB ± 0%  -19.55%  (p=0.000 n=25+23)
Compiler          875MB ± 0%        703MB ± 0%  -19.70%  (p=0.000 n=25+25)
SSA              3.19GB ± 0%       2.51GB ± 0%  -21.50%  (p=0.000 n=25+25)
Flate            32.9MB ± 0%       27.3MB ± 0%  -17.04%  (p=0.000 n=25+25)
GoParser         43.9MB ± 0%       35.1MB ± 0%  -20.19%  (p=0.000 n=25+25)
Reflect           117MB ± 0%         96MB ± 0%  -18.22%  (p=0.000 n=24+23)
Tar              48.6MB ± 0%       40.6MB ± 0%  -16.39%  (p=0.000 n=25+24)
XML              65.7MB ± 0%       53.9MB ± 0%  -17.93%  (p=0.000 n=25+23)
[Geo mean]        118MB              97MB       -17.80%

name        old allocs/op     new allocs/op     delta
Template          1.07M ± 0%        0.60M ± 0%  -43.90%  (p=0.000 n=25+24)
Unicode            539k ± 0%         398k ± 0%  -26.20%  (p=0.000 n=23+25)
GoTypes           3.97M ± 0%        2.19M ± 0%  -44.90%  (p=0.000 n=25+24)
Compiler          17.6M ± 0%         9.5M ± 0%  -46.39%  (p=0.000 n=22+23)
SSA               66.1M ± 0%        34.1M ± 0%  -48.41%  (p=0.000 n=25+22)
Flate              629k ± 0%         365k ± 0%  -41.95%  (p=0.000 n=25+25)
GoParser           929k ± 0%         500k ± 0%  -46.11%  (p=0.000 n=25+25)
Reflect           2.49M ± 0%        1.47M ± 0%  -41.00%  (p=0.000 n=24+25)
Tar                919k ± 0%         534k ± 0%  -41.94%  (p=0.000 n=25+24)
XML               1.28M ± 0%        0.71M ± 0%  -44.72%  (p=0.000 n=25+24)
[Geo mean]        2.32M             1.33M       -42.82%

This change also speeds up cmd/objdump a modest amount, ~4%.

Change-Id: I7c7aa2b365688bc44b3ef6e1d03bcf934699cabc
Reviewed-on: https://go-review.googlesource.com/c/go/+/216857
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agodebug/pe: improve testpoint error message
Than McIntosh [Fri, 17 Apr 2020 20:20:53 +0000 (16:20 -0400)]
debug/pe: improve testpoint error message

A DWARF testpoint was calling t.Fatal() but should have been calling
t.Fatalf(); switch it to the correct method.

Change-Id: I996a1041adea4299cda85c147a35b513a219b970
Reviewed-on: https://go-review.googlesource.com/c/go/+/228790
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>
4 years agocmd/compile: rewrite integer range rules to use typed aux fields
Cuong Manh Le [Fri, 17 Apr 2020 18:30:04 +0000 (01:30 +0700)]
cmd/compile: rewrite integer range rules to use typed aux fields

Passes toolstash-check.

Change-Id: I2752e4df211294112d502a59c3b9988e00d25aae
Reviewed-on: https://go-review.googlesource.com/c/go/+/228857
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agotest: remove duplicate code from makechan/makemap
alex-semenyuk [Sat, 18 Apr 2020 20:50:34 +0000 (20:50 +0000)]
test: remove duplicate code from makechan/makemap

Change-Id: Ib9bcfaa12d42bf9d2045aef035080b1a990a8b98
GitHub-Last-Rev: bee77a8970b8c4483a8106598721472623cf8ec2
GitHub-Pull-Request: golang/go#38047
Reviewed-on: https://go-review.googlesource.com/c/go/+/225219
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: switch to typed aux for 386 lowering rules
Alberto Donizetti [Fri, 17 Apr 2020 21:00:35 +0000 (23:00 +0200)]
cmd/compile: switch to typed aux for 386 lowering rules

Convert all the 386 lowering rules to the typed aux form.

Passes

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

Change-Id: I15256f20bc4442391755e6fffb8206dcaab94830
Reviewed-on: https://go-review.googlesource.com/c/go/+/228818
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/link: check for reflect.Value.MethodByName explicitly
Cherry Zhang [Sun, 19 Apr 2020 03:08:36 +0000 (23:08 -0400)]
cmd/link: check for reflect.Value.MethodByName explicitly

Currently we only check for reflect.Value.Method. And
reflect.Value.MethodByName is covered since it calls
reflect.Value.Method internally. But it is brittle to rely on
implementation detail of the reflect package. Check for
MethodByName explicitly.

Change-Id: Ifa8920e997524003dade03abc4fb3c4e64723643
Reviewed-on: https://go-review.googlesource.com/c/go/+/228881
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: when marking REFLECTMETHOD, check for reflect package itself
Cherry Zhang [Sat, 18 Apr 2020 21:47:54 +0000 (17:47 -0400)]
cmd/compile: when marking REFLECTMETHOD, check for reflect package itself

reflect.Type.Method (and MethodByName) can be used to obtain a
reference of a method by reflection. The linker needs to know
if reflect.Type.Method is called, and retain all exported methods
accordingly. This is handled by the compiler, which marks the
caller of reflect.Type.Method with REFLECTMETHOD attribute. The
current code failed to handle the reflect package itself, so the
method wrapper reflect.Type.Method is not marked. This CL fixes
it.

Fixes #38515.

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

4 years agocmd/link: add a test that reflect.Value.Call does not bring methods live
Cherry Zhang [Sat, 18 Apr 2020 05:38:31 +0000 (01:38 -0400)]
cmd/link: add a test that reflect.Value.Call does not bring methods live

reflect.Value.Call, if reachable, used to bring all exported
methods live. CL 228792 fixes this, removing the check of
reflect.Value.Call. This CL adds a test.

Updates #38505.

Change-Id: Ib4cab3c3c86c9c9702d041266e59b159d0ff0a97
Reviewed-on: https://go-review.googlesource.com/c/go/+/228878
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agocmd/compile: use exported field names in rulegen
Daniel Martí [Sat, 18 Apr 2020 13:38:09 +0000 (14:38 +0100)]
cmd/compile: use exported field names in rulegen

The types used while generating code, such as Rule and File, have been
exported for a while. This is harmless for a main package, and lets us
easily differentiate types from variables and functions, as well as use
names like "If" since "if" is a keyword.

However, the fields remained unexported. This was a bit inconsistent,
and also meant that we couldn't use some intuitive names like If.else.
Export them.

Besides the capitalization, the only change is that the If type now has
the fields Then and Else, instead of stmt and alt.

Change-Id: I426ff140c6ca186fec394f17b29165861da5fd98
Reviewed-on: https://go-review.googlesource.com/c/go/+/228821
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agoos/exec: build TestExtraFiles subprocess without cgo
Ian Lance Taylor [Fri, 17 Apr 2020 01:19:59 +0000 (18:19 -0700)]
os/exec: build TestExtraFiles subprocess without cgo

Fixes #25628

Change-Id: I8b69e59f9c0123c4f65b5931d7c6d7ecc1c720e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/228639
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/link: update comment for deadcode
Cherry Zhang [Sat, 18 Apr 2020 05:13:39 +0000 (01:13 -0400)]
cmd/link: update comment for deadcode

Update the comment to be in sync with the code.

Change-Id: I19586767a37347c4da1b4d3f7c6dc6cc2292a90f
Reviewed-on: https://go-review.googlesource.com/c/go/+/228877
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agocmd/link: stop checking reflect.Value.Call in deadcode pass
Cherry Zhang [Sat, 18 Apr 2020 00:41:59 +0000 (20:41 -0400)]
cmd/link: stop checking reflect.Value.Call in deadcode pass

In the linker's deadcode pass, we need to keep a method live if
it can be reached through reflection. We do this by marking all
exported method live if reflect.Value.Method or
reflect.Type.Method is used. Currently we also check for
reflect.Value.Call, which is unnecessary because in order to call
a method through reflection, the method must be obtained through
reflect.Value.Method or reflect.Type.Method, which we already
check.

Per discussion in https://groups.google.com/d/msg/golang-dev/eG9It63-Bxg/_bnoVy-eAwAJ
Thanks Brad, Russ, and Ian for bringing this up.

Change-Id: I8e9529a224bb898dbf5752674cc9d155db386c14
Reviewed-on: https://go-review.googlesource.com/c/go/+/228792
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
4 years agoregexp/syntax: fix comment on p.literal and simplify
Russ Cox [Sat, 7 Mar 2020 14:35:12 +0000 (09:35 -0500)]
regexp/syntax: fix comment on p.literal and simplify

p.literal's doc comment said it returned a value but it doesn't.
While we're here, p.newLiteral is only called from p.literal,
so simplify the code by merging the two.

Change-Id: Ia357937a99f4e7473f0f1ec837113a39eaeb83d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/222659
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/doc: don't print package clauses on error
Rob Pike [Fri, 3 Apr 2020 02:57:01 +0000 (13:57 +1100)]
cmd/doc: don't print package clauses on error

Everybody was deferring a flush when main already
did that, so drop all that nonsense. (Flush was doing
the package clause stuff.) But then make sure we do
get a package clause when there is correctly no output,
as for an empty package. Do that by triggering a
package clause in allDoc and packageDoc.

Slightly tricky but way less intricate than before.

Fixes #37969.

Change-Id: Ia86828436e6c4ab46e6fdaf2c550047f37f353f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/226998
Reviewed-by: Russ Cox <rsc@golang.org>
4 years agocmd/go: convert TestCaseCollisions to the script framework
Michael Matloob [Fri, 17 Apr 2020 17:32:20 +0000 (13:32 -0400)]
cmd/go: convert TestCaseCollisions to the script framework

I'm planning to modify this test in a follow-up CL, so we might
as well convert it to a script test. I don't think there's an easy
way to detect whether we have a case-insensitive file system, without
adding a new condition to the script framework, so the test is just
guessing that darwin and windows could have case-insensitive file systems.

Change-Id: I48bb36f86f19898618681515ac448c3bb4735857
Reviewed-on: https://go-review.googlesource.com/c/go/+/228783
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agoruntime: explictly state lock ordering direction
Michael Pratt [Fri, 17 Apr 2020 19:25:03 +0000 (15:25 -0400)]
runtime: explictly state lock ordering direction

At least as far as I can tell, this file never explicitly states whether
locks with higher or lower rank should be taken first. It is implied in
some comments, and clear from the code, of course.

Add an explicit comment to make things more clear and hopefully reduce
new locks being adding in the wrong spot.

Change-Id: I17c6fd5fc216954e5f3550cf91f17e25139f1587
Reviewed-on: https://go-review.googlesource.com/c/go/+/228785
Reviewed-by: Dan Scales <danscales@google.com>
4 years agonet/http/pprof: support the "seconds" param for block, mutex profiles
Hana Kim [Wed, 11 Dec 2019 23:47:05 +0000 (18:47 -0500)]
net/http/pprof: support the "seconds" param for block, mutex profiles

When the seconds param is given, the block and mutex profile endpoints
report the difference between two measurements collected the given
seconds apart. Historically, the block and mutex profiles have reported
the cumulative counts since the process start, and it turned out they
are more useful when interpreted along with the time duration.

Note: cpu profile and trace endpoints already accept the "seconds"
parameter. With this CL, the block and mutex profile endpoints will
accept the "seconds" parameter. Providing the "seconds" parameter
to other types of profiles is an error.

This change moves runtime/pprof/internal/profile to internal/profile and
adds part of merge logic from github.com/google/pprof/profile/merge.go to
internal/profile, in order to allow both net/http/pprof and runtime/pprof
to access it.

Fixes #23401

Change-Id: Ie2486f1a63eb8ff210d7d3bc2de683e9335fd5cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/147598
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agocrypto/x509: clarify MarshalPKIXPublicKey and ParsePKIXPublicKey docs
Katie Hockman [Fri, 17 Apr 2020 16:21:24 +0000 (12:21 -0400)]
crypto/x509: clarify MarshalPKIXPublicKey and ParsePKIXPublicKey docs

Fixes #35313

Change-Id: I7be3c40f338de6b1808358ea01e729db8b533ce5
Reviewed-on: https://go-review.googlesource.com/c/go/+/228778
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
4 years agocmd/compile: remove superfluous SetBounded call
Josh Bleecher Snyder [Fri, 17 Apr 2020 05:05:35 +0000 (22:05 -0700)]
cmd/compile: remove superfluous SetBounded call

The call does nothing when applied to an OLSH node.
It would be unnecessary anyway, since we're shifting by a small constant.

Passes toolstash-check.

Change-Id: If858711f1704f44637fa0f6a4c66cbaad6db24b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/228699
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
4 years agocmd/compile: make some s390x rules use strongly typed aux values
Michael Munday [Thu, 16 Apr 2020 10:40:09 +0000 (11:40 +0100)]
cmd/compile: make some s390x rules use strongly typed aux values

This first pass makes the rules using the condition code mask
(CCMask) and rotate parameters (RotateParams) aux values strongly
typed. This required adding strongly typed aux handling to the
block rulegen.

More CLs like this to follow, but this is probably the most
complex.

Passes toolstash-check -all.

Change-Id: Ie513b07d527f0c1b398d7748331442dcb5f7b17d
Reviewed-on: https://go-review.googlesource.com/c/go/+/228518
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoRevert "[dev.link] cmd/link: remove buffered file I/O from OutBuf"
Jeremy Faller [Thu, 16 Apr 2020 23:33:11 +0000 (23:33 +0000)]
Revert "[dev.link] cmd/link: remove buffered file I/O from OutBuf"

This reverts commit b2def42d9efcf4540656e26632b744f8e7436814.

Reason for revert: trybots failing

Change-Id: I920be6d8de158b1e513154ac0eb0c8fa0cffa9f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/228657
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agotest: add copyright notice to typecheck.go
Russ Cox [Fri, 17 Apr 2020 00:33:02 +0000 (20:33 -0400)]
test: add copyright notice to typecheck.go

Also gofmt.

Change-Id: I36ac990965250867574f8e2318b65b87a0beda04
Reviewed-on: https://go-review.googlesource.com/c/go/+/228697
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agotest: add test for nil check / bounds check compiler confusion
Josh Bleecher Snyder [Fri, 17 Apr 2020 01:26:12 +0000 (18:26 -0700)]
test: add test for nil check / bounds check compiler confusion

This test started failing at CL 228106 and was fixed by CL 228677.

Fixes #38496

Change-Id: I2dadcd99227347e8d28179039f5f345e728c4595
Reviewed-on: https://go-review.googlesource.com/c/go/+/228698
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: fix misassumption about n.Left.Bounded()
Matthew Dempsky [Thu, 16 Apr 2020 23:49:10 +0000 (16:49 -0700)]
cmd/compile: fix misassumption about n.Left.Bounded()

n.Bounded() is overloaded for multiple meanings based on n.Op. We
can't safely use n.Left.Bounded() without checking n.Left.Op.

Change-Id: I71fe4faa24798dfe3a5705fa3419a35ef93b0ce2
Reviewed-on: https://go-review.googlesource.com/c/go/+/228677
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
4 years agoruntime: use mcache0 if no P in profilealloc
Ian Lance Taylor [Wed, 15 Apr 2020 22:39:53 +0000 (15:39 -0700)]
runtime: use mcache0 if no P in profilealloc

A case that I missed in CL 205239: profilealloc can be called at
program startup if GOMAXPROCS is large enough.

Fixes #38474

Change-Id: I2f089fc6ec00c376680e1c0b8a2557b62789dd7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/228420
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 years agocmd/compile: remove totype0 type-constructor helpers
Matthew Dempsky [Thu, 16 Apr 2020 20:40:24 +0000 (13:40 -0700)]
cmd/compile: remove totype0 type-constructor helpers

These were originally introduced for the binary export format, which
required forward references to arbitrary types and later filling them
in. They're no longer needed since we switched to the indexed export
format, which only requires forward references to declared types.

Passes toolstash-check.

Change-Id: I696dc9029ec7652d01ff49fb98e658a9ed510979
Reviewed-on: https://go-review.googlesource.com/c/go/+/228579
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years ago[dev.link] cmd/link: remove buffered file I/O from OutBuf
Jeremy Faller [Wed, 15 Apr 2020 17:23:29 +0000 (13:23 -0400)]
[dev.link] cmd/link: remove buffered file I/O from OutBuf

Change-Id: I72b1e57631fe4a31597fd0452ee1beb14378febb
Reviewed-on: https://go-review.googlesource.com/c/go/+/228317
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years ago[dev.link] cmd/link: allow OutBufs to work outside mmapped area
Jeremy Faller [Mon, 13 Apr 2020 19:37:06 +0000 (15:37 -0400)]
[dev.link] cmd/link: allow OutBufs to work outside mmapped area

Asmb                      9.76ms ±13%    9.91ms ±16%     ~     (p=0.912 n=10+10)
Munmap                    16.0ms ± 8%    18.0ms ±53%     ~     (p=0.203 n=8+10)
Asmb2                     2.30ms ± 6%    2.21ms ±14%     ~     (p=0.095 n=10+9)

Future changes will add fallocate on supported platforms, and eliminate
Msync.

Change-Id: I6fc35fb2739c8530c8732c3ad13c99e6004de04a
Reviewed-on: https://go-review.googlesource.com/c/go/+/228197
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>
4 years agonet/url: add URL.RawFragment, URL.EscapedFragment
Russ Cox [Wed, 8 Apr 2020 19:00:41 +0000 (15:00 -0400)]
net/url: add URL.RawFragment, URL.EscapedFragment

These are analogous to URL.RawPath and URL.EscapedPath
and allow users fine-grained control over how the fragment
section of the URL is escaped. Some tools care about / vs %2f,
same problem as in paths.

Fixes #37776.

Change-Id: Ie6f556d86bdff750c47fe65398cbafd834152b47
Reviewed-on: https://go-review.googlesource.com/c/go/+/227645
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agohtml/template,text/template: switch to Unicode escapes for JSON compatibility
empijei [Fri, 27 Mar 2020 18:27:55 +0000 (19:27 +0100)]
html/template,text/template: switch to Unicode escapes for JSON compatibility

The existing implementation is not compatible with JSON
escape as it uses hex escaping.
Unicode escape, instead, is valid for both JSON and JS.
This fix avoids creating a separate escaping context for
scripts of type "application/ld+json" and it is more
future-proof in case more JSON+JS contexts get added
to the platform (e.g. import maps).

Fixes #33671
Fixes #37634

Change-Id: Id6f6524b4abc52e81d9d744d46bbe5bf2e081543
Reviewed-on: https://go-review.googlesource.com/c/go/+/226097
Reviewed-by: Carl Johnson <me@carlmjohnson.net>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agogo/types: add detail to missing method error messages
Rebecca Stambler [Wed, 15 Apr 2020 22:31:29 +0000 (18:31 -0400)]
go/types: add detail to missing method error messages

When a concrete type doesn't exactly implement an interface, the error
messages produced by go/types are often unhelpful. The compiler shows
the expected signature versus the one found, which is useful, so add
this behavior here.

Fixes golang/go#38475

Change-Id: I8b780b7e1f1f433a0efe670de3b1437053f42fba
Reviewed-on: https://go-review.googlesource.com/c/go/+/228457
Run-TryBot: Rebecca Stambler <rstambler@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years ago[dev.link] cmd/link: set direct fn address in dwarf gen where possible
Than McIntosh [Thu, 16 Apr 2020 12:29:43 +0000 (08:29 -0400)]
[dev.link] cmd/link: set direct fn address in dwarf gen where possible

If we are internal linking a static executable, and address assignment
has happened, then when emitting some parts of DWARF we can just emit
a function address directly instead of generating a relocation. For
external linking or other build modes, we are generating a relocatable
binary so we still need to emit relocations.

This CL inspired by Cherry's similar CL for pclntab at
https://go-review.googlesource.com/c/go/+/228478.

Change-Id: Ib03fbe2dd72d0ba746bf46015e0f2d6c3f3d53ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/228537
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: clean up now unused pushCallSupported
Joel Sing [Thu, 16 Apr 2020 05:33:53 +0000 (15:33 +1000)]
runtime: clean up now unused pushCallSupported

All platforms now support pushCall, hence remove the now unnecessary
pushCallSupported flag/guard.

Change-Id: I99e4be73839da68a742f3c239bae9ce2f8764624
Reviewed-on: https://go-review.googlesource.com/c/go/+/228497
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years ago[dev.link] cmd/link: add a test for trampoline insertion
Cherry Zhang [Fri, 10 Apr 2020 18:58:54 +0000 (14:58 -0400)]
[dev.link] cmd/link: add a test for trampoline insertion

Now that we have converted pclntab pass to using the loader,
trampoline insertion should work again. Add a test.

Change-Id: Ia9a0485456ac75cc6e706218a359f109cd8fce43
Reviewed-on: https://go-review.googlesource.com/c/go/+/228141
Reviewed-by: Than McIntosh <thanm@google.com>
4 years ago[dev.link] cmd/link: clear lib.Textp2 after use
Cherry Zhang [Thu, 16 Apr 2020 05:01:33 +0000 (01:01 -0400)]
[dev.link] cmd/link: clear lib.Textp2 after use

lib.Textp2 is used to assemble the global Textp2. It is not used
after that point. Free some memory.

Slightly reduces allocation: for linking cmd/compile,
Linksetup_GC     1.10MB ± 0%    0.84MB ± 0%  -23.43%  (p=0.008 n=5+5)

Change-Id: Iec4572e282655306d5ff3e490f8855d479e45acf
Reviewed-on: https://go-review.googlesource.com/c/go/+/228481
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years ago[dev.link] cmd/internal/goobj2: regenerate builtin list
Cherry Zhang [Thu, 16 Apr 2020 04:03:34 +0000 (00:03 -0400)]
[dev.link] cmd/internal/goobj2: regenerate builtin list

Change-Id: I340a237e0f3c4bd6c1481519e3072aeca9c0b79f
Reviewed-on: https://go-review.googlesource.com/c/go/+/228480
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years ago[dev.link] cmd/link: fix trampoline generation on AIX
Cherry Zhang [Thu, 16 Apr 2020 03:11:52 +0000 (23:11 -0400)]
[dev.link] cmd/link: fix trampoline generation on AIX

The addend should be applied to the target symbol, not the TOC
symbol.

Change-Id: I0a14873cdcafc4ede401878882646dade9cd8e3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/228479
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years ago[dev.link] cmd/link: fix buglet in dodata
Cherry Zhang [Thu, 16 Apr 2020 01:55:35 +0000 (21:55 -0400)]
[dev.link] cmd/link: fix buglet in dodata

Fix AIX build.

Change-Id: I5c0f1390a62c684bb0b162c3309902566cc6b025
Reviewed-on: https://go-review.googlesource.com/c/go/+/228477
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoruntime: tidy Context allocation
Austin Clements [Tue, 19 Nov 2019 19:48:17 +0000 (14:48 -0500)]
runtime: tidy Context allocation

The Context object we pass to GetThreadContext on Windows must be 16
byte-aligned. We also can't allocate in the contexts where we create
these, so they must be stack-allocated. There's no great way to do
this, but this CL makes the code at least a little clearer, and makes
profilem and preemptM more consistent with each other.

Change-Id: I5ec47a27d7580ed6003030bf953e668e8cae2cef
Reviewed-on: https://go-review.googlesource.com/c/go/+/207967
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
4 years agoruntime: add async preemption support on riscv64
Quey-Liang Kao [Wed, 15 Apr 2020 13:23:52 +0000 (13:23 +0000)]
runtime: add async preemption support on riscv64

This CL adds support of call injection and async preemption on
riscv64. We also clobbered REG_TMP for the injected call. Unsafe
points related to REG_TMP access have been marked in previous commits.

Fixes #36711.

Change-Id: I1a1df5b7fc23eaafc34a6a6448fcc3c91054496e
GitHub-Last-Rev: f6110d470713be70d960fd3e984fea89bb371719
GitHub-Pull-Request: golang/go#38146
Reviewed-on: https://go-review.googlesource.com/c/go/+/226206
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: make AlgKind a stringer
Josh Bleecher Snyder [Tue, 14 Apr 2020 22:16:09 +0000 (15:16 -0700)]
cmd/compile: make AlgKind a stringer

Change-Id: I4a4b866d9233b8369e5ca913a9dd576b323b8f3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/228421
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>
4 years agoruntime: prevent preemption while releasing worldsema in gcStart
Michael Anthony Knyszek [Wed, 15 Apr 2020 18:01:00 +0000 (18:01 +0000)]
runtime: prevent preemption while releasing worldsema in gcStart

Currently, as a result of us releasing worldsema now to allow STW events
during a mark phase, we release worldsema between starting the world and
having the goroutine block in STW mode. This inserts preemption points
which, if followed through, could lead to a deadlock. Specifically,
because user goroutine scheduling is disabled in STW mode, the goroutine
will block before properly releasing worldsema.

The fix here is to prevent preemption while releasing the worldsema.

Fixes #38404.
Updates #19812.

Change-Id: I8ed5b3aa108ab2e4680c38e77b0584fb75690e3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/228337
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agogo/doc: fix detection of whole file examples
Gregory Petrosyan [Sat, 4 Apr 2020 15:27:23 +0000 (15:27 +0000)]
go/doc: fix detection of whole file examples

After CL 211357 (commit 499dc1c),
hasTests and numDecl were not updated properly for function
declarations with parameters, which affected the whole file
example detection logic. This caused examples like

package foo_test

func Foo(x int) {
}

func Example() {
fmt.Println("Hello, world!")
// Output: Hello, world!
}

to not be detected as whole file ones.

Change-Id: I9ebd47e52d7ee9d91eb6f8e0257511de69b2a402
GitHub-Last-Rev: cc71c31124f6e3514f4e33ac7b169eca74c8bcb7
GitHub-Pull-Request: golang/go#37730
Reviewed-on: https://go-review.googlesource.com/c/go/+/222477
Reviewed-by: Agniva De Sarker <agniva.quicksilver@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agoos/signal: special-case test settle time on the solaris-amd64-oraclerel builder
Bryan C. Mills [Wed, 15 Apr 2020 14:56:22 +0000 (10:56 -0400)]
os/signal: special-case test settle time on the solaris-amd64-oraclerel builder

This is an attempt to distinguish between a dropped signal and
general builder slowness.

The previous attempt (increasing the settle time to 250ms) still
resulted in a timeout:
https://build.golang.org/log/dd62939f6d3b512fe3e6147074a9c6db1144113f

For #33174

Change-Id: I79027e91ba651f9f889985975f38c7b01d82f634
Reviewed-on: https://go-review.googlesource.com/c/go/+/228266
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocrypto/tls: help linker remove code when only Client or Server is used
Brad Fitzpatrick [Wed, 15 Apr 2020 16:06:34 +0000 (09:06 -0700)]
crypto/tls: help linker remove code when only Client or Server is used

This saves 166 KiB for a tls.Dial hello world program (5382441 to
5212356 to bytes), by permitting the linker to remove TLS server code.

Change-Id: I16610b836bb0802b7d84995ff881d79ec03b6a84
Reviewed-on: https://go-review.googlesource.com/c/go/+/228111
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agocmd/compile: split up the addressing mode on OpAMD64CMP*loadidx* always
David Chase [Mon, 13 Apr 2020 16:49:59 +0000 (12:49 -0400)]
cmd/compile: split up the addressing mode on OpAMD64CMP*loadidx* always

Benchmarking suggests that the combo instruction is notably slower,
at least in the places where we measure.

Updates #37955

Change-Id: I829f1975dd6edf38163128ba51d84604055512f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/228157
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years ago[dev.link] cmd/link/internal/loader: remove some unused types
Than McIntosh [Wed, 15 Apr 2020 17:46:25 +0000 (13:46 -0400)]
[dev.link] cmd/link/internal/loader: remove some unused types

The types funcAllocInfo and funcInfoSym are no longer referenced.

Fixes #38456.

Change-Id: Icd32445f6027429f4a2781554d2086790ebe5daf
Reviewed-on: https://go-review.googlesource.com/c/go/+/228318
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agomath/big: remove Direct Sqrt computation
Alberto Donizetti [Wed, 15 Apr 2020 08:50:30 +0000 (10:50 +0200)]
math/big: remove Direct Sqrt computation

The Float.Sqrt method switches (for performance reasons) between
direct (uses Quo) and inverse (doesn't) computation, depending on the
precision, with threshold 128.

Unfortunately the implementation of recursive division in CL 172018
made Quo slightly slower exactly in the range around and below the
threshold Sqrt is using, so this strategy is no longer profitable.

The new division algorithm allocates more, and this has increased the
amount of allocations performed by Sqrt when using the direct method;
on low precisions the computation is fast, so additional allocations
have an negative impact on performance.

Interestingly, only using the inverse method doesn't just reverse the
effects of the Quo algorithm change, but it seems to make performances
better overall for small precisions:

name                 old time/op    new time/op    delta
FloatSqrt/64-4          643ns ± 1%     635ns ± 1%   -1.24%  (p=0.000 n=10+10)
FloatSqrt/128-4        1.44µs ± 1%    1.02µs ± 1%  -29.25%  (p=0.000 n=10+10)
FloatSqrt/256-4        1.49µs ± 1%    1.49µs ± 1%     ~     (p=0.752 n=10+10)
FloatSqrt/1000-4       3.71µs ± 1%    3.74µs ± 1%   +0.87%  (p=0.001 n=10+10)
FloatSqrt/10000-4      35.3µs ± 1%    35.6µs ± 1%   +0.82%  (p=0.002 n=10+9)
FloatSqrt/100000-4      844µs ± 1%     844µs ± 0%     ~     (p=0.549 n=10+9)
FloatSqrt/1000000-4    69.5ms ± 0%    69.6ms ± 0%     ~     (p=0.222 n=9+9)

name                 old alloc/op   new alloc/op   delta
FloatSqrt/64-4           280B ± 0%      200B ± 0%  -28.57%  (p=0.000 n=10+10)
FloatSqrt/128-4          504B ± 0%      248B ± 0%  -50.79%  (p=0.000 n=10+10)
FloatSqrt/256-4          344B ± 0%      344B ± 0%     ~     (all equal)
FloatSqrt/1000-4       1.30kB ± 0%    1.30kB ± 0%     ~     (all equal)
FloatSqrt/10000-4      13.5kB ± 0%    13.5kB ± 0%     ~     (p=0.237 n=10+10)
FloatSqrt/100000-4      123kB ± 0%     123kB ± 0%     ~     (p=0.247 n=10+10)
FloatSqrt/1000000-4    1.83MB ± 1%    1.83MB ± 3%     ~     (p=0.779 n=8+10)

name                 old allocs/op  new allocs/op  delta
FloatSqrt/64-4           8.00 ± 0%      5.00 ± 0%  -37.50%  (p=0.000 n=10+10)
FloatSqrt/128-4          11.0 ± 0%       5.0 ± 0%  -54.55%  (p=0.000 n=10+10)
FloatSqrt/256-4          5.00 ± 0%      5.00 ± 0%     ~     (all equal)
FloatSqrt/1000-4         6.00 ± 0%      6.00 ± 0%     ~     (all equal)
FloatSqrt/10000-4        6.00 ± 0%      6.00 ± 0%     ~     (all equal)
FloatSqrt/100000-4       6.00 ± 0%      6.00 ± 0%     ~     (all equal)
FloatSqrt/1000000-4      10.3 ±13%      10.3 ±13%     ~     (p=1.000 n=10+10)

For example, 1.02µs for FloatSqrt/128 is actually better than what I
was getting on the same machine before the Quo changes.

The .8% slowdown on /1000 and /10000 appears to be real and it is
quite baffling (that codepath was not touched at all); it may be
caused by code alignment changes.

Change-Id: Ib03761cdc1055674bc7526d4f3a23d7a25094029
Reviewed-on: https://go-review.googlesource.com/c/go/+/228062
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agotext/template: avoid a global map to help the linker's deadcode elimination
Brad Fitzpatrick [Fri, 6 Dec 2019 18:19:03 +0000 (18:19 +0000)]
text/template: avoid a global map to help the linker's deadcode elimination

Fixes #36021
Updates #2559
Updates #26775

Change-Id: I2e6708691311035b63866f25d5b4b3977a118290
Reviewed-on: https://go-review.googlesource.com/c/go/+/210284
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agocmd/internal/obj/ppc64: add support for PCALIGN 32
Lynn Boger [Tue, 14 Apr 2020 19:32:29 +0000 (15:32 -0400)]
cmd/internal/obj/ppc64: add support for PCALIGN 32

This adds support support for the PCALIGN value 32. When this
directive occurs code will be aligned to 32 bytes unless
too many NOPs are needed, and then will fall back to 16
byte alignment.

On Linux the function's alignment is promoted from 16 to 32
in functions where PCALIGN 32 appears. On AIX the function's
alignment is left at 16 due to complexity with modifying its
alignment, which means code will be aligned to at least 16,
possibly 32 at times, which is still good.

Test was updated to accept new value.

Change-Id: I28e72d5f30ca472ed9ba736ddeabfea192d11797
Reviewed-on: https://go-review.googlesource.com/c/go/+/228258
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years ago[dev.link] cmd/link: begin splitting up dodata()
Than McIntosh [Tue, 14 Apr 2020 19:14:54 +0000 (15:14 -0400)]
[dev.link] cmd/link: begin splitting up dodata()

Begin refactoring dodata to try to convert it from a single giant blob
to something more hierarchical, with descriptive function names for
sub-parts.

Add a state object to hold things like "data" and "dataMaxAlign"
arrays that are used throughout dodata. Extract out the code that
allocates data symbols to sections into a separate method (this
method is still too big, probably needs to be refactored again).

No change in functionality.

Change-Id: I7b52dc2aff0356e7d4b5d6f629d907fd37d3082c
Reviewed-on: https://go-review.googlesource.com/c/go/+/228259
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agomath/big: add test that linker is able to remove unused code
Brad Fitzpatrick [Tue, 14 Apr 2020 21:00:42 +0000 (14:00 -0700)]
math/big: add test that linker is able to remove unused code

(Follow-up to CL 228108.)

Change-Id: Ia6d119ee19c7aa923cdeead06d3cee87a1751105
Reviewed-on: https://go-review.googlesource.com/c/go/+/228109
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agomath/big: fix typo in documentation for Int.Exp
Hanjun Kim [Sun, 12 Apr 2020 13:41:46 +0000 (13:41 +0000)]
math/big: fix typo in documentation for Int.Exp

Fixes #38304

Also change `If m > 0, y < 0, ...` to `If m != 0, y < 0, ...` since `Exp` will return `nil`
whatever `m`'s sign is.

Change-Id: I17d7337ccd1404318cea5d42a8de904ad185fd00
GitHub-Last-Rev: 23995103000505dbf35aa29a717470c4da638fda
GitHub-Pull-Request: golang/go#38390
Reviewed-on: https://go-review.googlesource.com/c/go/+/228000
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agoos/exec: create extra threads when starting a subprocess
Ian Lance Taylor [Mon, 13 Apr 2020 22:04:20 +0000 (15:04 -0700)]
os/exec: create extra threads when starting a subprocess

TestExtraFiles seems to be flaky on GNU/Linux systems when using cgo
because creating a new thread will call malloc which can create a new
arena which can open a file to see how many processors there are.
Try to avoid the flake by creating several new threads at process
startup time.

For #25628

Change-Id: Ie781acdbba475d993c39782fe172cf7f29a05b24
Reviewed-on: https://go-review.googlesource.com/c/go/+/228099
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agomath/big: don't use Float in init to help linker discard 162 KiB
Brad Fitzpatrick [Tue, 14 Apr 2020 19:30:47 +0000 (12:30 -0700)]
math/big: don't use Float in init to help linker discard 162 KiB

Removes 162 KiB from binaries that don't use math/big.Float:

-rwxr-xr-x 1 bradfitz bradfitz 1916590 Apr 14 12:21 x.after
-rwxr-xr-x 1 bradfitz bradfitz 2082575 Apr 14 12:21 x.before

No change in deps (this package already used sync).

No change in benchmarks:

name                 old time/op    new time/op    delta
FloatSqrt/64-8         1.06µs ±10%    1.03µs ± 6%   ~     (p=0.133 n=10+9)
FloatSqrt/128-8        2.26µs ± 9%    2.28µs ± 9%   ~     (p=0.460 n=10+8)
FloatSqrt/256-8        2.29µs ± 5%    2.31µs ± 3%   ~     (p=0.214 n=9+9)
FloatSqrt/1000-8       5.82µs ± 3%    5.87µs ± 7%   ~     (p=0.666 n=9+9)
FloatSqrt/10000-8      56.4µs ± 5%    57.0µs ± 6%   ~     (p=0.436 n=10+10)
FloatSqrt/100000-8     1.34ms ± 8%    1.31ms ± 3%   ~     (p=0.447 n=10+9)
FloatSqrt/1000000-8     106ms ± 5%     107ms ± 7%   ~     (p=0.315 n=10+10)

name                 old alloc/op   new alloc/op   delta
FloatSqrt/64-8           280B ± 0%      280B ± 0%   ~     (all equal)
FloatSqrt/128-8          504B ± 0%      504B ± 0%   ~     (all equal)
FloatSqrt/256-8          344B ± 0%      344B ± 0%   ~     (all equal)
FloatSqrt/1000-8       1.30kB ± 0%    1.30kB ± 0%   ~     (all equal)
FloatSqrt/10000-8      13.5kB ± 0%    13.5kB ± 0%   ~     (p=0.403 n=10+10)
FloatSqrt/100000-8      123kB ± 0%     123kB ± 0%   ~     (p=0.393 n=10+10)
FloatSqrt/1000000-8    1.84MB ± 7%    1.84MB ± 5%   ~     (p=0.739 n=10+10)

name                 old allocs/op  new allocs/op  delta
FloatSqrt/64-8           8.00 ± 0%      8.00 ± 0%   ~     (all equal)
FloatSqrt/128-8          11.0 ± 0%      11.0 ± 0%   ~     (all equal)
FloatSqrt/256-8          5.00 ± 0%      5.00 ± 0%   ~     (all equal)
FloatSqrt/1000-8         6.00 ± 0%      6.00 ± 0%   ~     (all equal)
FloatSqrt/10000-8        6.00 ± 0%      6.00 ± 0%   ~     (all equal)
FloatSqrt/100000-8       6.00 ± 0%      6.00 ± 0%   ~     (all equal)
FloatSqrt/1000000-8      10.9 ±10%      10.8 ±17%   ~     (p=0.974 n=10+10)

Change-Id: I3337f1f531bf7b4fae192b9d90cd24ff2be14fea
Reviewed-on: https://go-review.googlesource.com/c/go/+/228108
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years ago[dev.link] cmd/link: hoist dwarfGenerateDebugSyms out of dodata()
Than McIntosh [Mon, 13 Apr 2020 19:38:03 +0000 (15:38 -0400)]
[dev.link] cmd/link: hoist dwarfGenerateDebugSyms out of dodata()

Hoist dwarfGenerateDebugSyms call up out of dodata to before
loadlibfull. This required a couple of small tweaks to the
loader and to loadlibfull.

Change-Id: I48ffb450d2e48b9e55775b73a6debcd27dbb7b9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/228221
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agotime/tzdata: new package
Ian Lance Taylor [Mon, 13 Apr 2020 23:48:23 +0000 (16:48 -0700)]
time/tzdata: new package

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

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

This is a roll forward of CL 224588 which was rolled back due to
test failures. In this version, the test is in the time package,
not the time/tzdata package. That lets us compare the zip file
to the time/tzdata package, ensuring that we are looking at similar
versions of tzdata information.

Fixes #21881
Fixes #38013
Fixes #38017

Change-Id: I916d9d8473abe201b897cdc2bbd9168df4ad671c
Reviewed-on: https://go-review.googlesource.com/c/go/+/228101
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years agocmd/compile: error if register is reused when setting edge state
Michael Munday [Tue, 14 Apr 2020 09:12:32 +0000 (10:12 +0100)]
cmd/compile: error if register is reused when setting edge state

When setting the edge state in register allocation we should only
be setting each register once. It is not possible for a register
to hold multiple values at once.

This CL converts the runtime error seen in #38195 into an internal
compiler error (ICE). It is better for the compiler to fail than
generate an incorrect program.

The bug reported in #38195 is now exposed as:

./parserc.go:459:11: internal compiler error: 'yaml_parser_parse_node': R5 is already set (v1074/v1241)

[stack trace]

Updates #38195.

Change-Id: Id95842fd850b95494cbd472b6fd5a55513ecacec
Reviewed-on: https://go-review.googlesource.com/c/go/+/228060
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: fix deallocation of live value copies in regalloc
Michael Munday [Tue, 14 Apr 2020 14:46:26 +0000 (15:46 +0100)]
cmd/compile: fix deallocation of live value copies in regalloc

When deallocating the input register to a phi so that the phi
itself could be allocated to that register the code was also
deallocating all copies of that phi input value. Those copies
of the value could still be live and if they were the register
allocator could reuse them incorrectly to hold speculative
copies of other phi inputs. This causes strange bugs.

No test because this is a very obscure scenario that is hard
to replicate but CL 228060 adds an assertion to the compiler
that does trigger when running the std tests on linux/s390x
without this CL applied. Hopefully that assertion will prevent
future regressions.

Fixes #38195.

Change-Id: Id975dadedd731c7bb21933b9ea6b17daaa5c9e1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/228061
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: fix incorrect block for s390x Select1 op
Michael Munday [Sun, 12 Apr 2020 09:45:24 +0000 (10:45 +0100)]
cmd/compile: fix incorrect block for s390x Select1 op

When inserting Select0 and Select1 ops we need to ensure that they
live in the same block as their argument. This is because they need
to be scheduled immediately after their argument for register and
flag allocation to work correctly.

Fixes #38356.

Change-Id: Iba384dbe87010f1c7c4ce909f08011e5f1de7fd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/227879
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/cgo: use consistent tag for a particular struct
Ian Lance Taylor [Tue, 14 Apr 2020 00:47:47 +0000 (17:47 -0700)]
cmd/cgo: use consistent tag for a particular struct

For #31891
Fixes #38408

Change-Id: Ie7498c2cab728ae798e66e7168425e16b063520e
Reviewed-on: https://go-review.googlesource.com/c/go/+/228102
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
4 years agocmd/internal/obj/riscv: gofmt
Tobias Klauser [Tue, 14 Apr 2020 07:55:08 +0000 (09:55 +0200)]
cmd/internal/obj/riscv: gofmt

gofmt the changes from CL 226397

Change-Id: Ibb252ddb8164573af15fc882ac48b5c01dd87cf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/228059
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
4 years agocmd/compile: make type switch case positions consistent
Josh Bleecher Snyder [Tue, 14 Apr 2020 06:28:32 +0000 (23:28 -0700)]
cmd/compile: make type switch case positions consistent

CL 228106 moved the position at which we
checked whether a type switch variable had a particular type
from the type switch to the case statement, but only for
single, concrete types. This is a better position,
so this change changes the rest.

Change-Id: I601d4a5c4a0d9400e7804b9f1e729af948349a8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/228220
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>
4 years agocmd/compile: make ifaceData accept a position
Josh Bleecher Snyder [Tue, 14 Apr 2020 06:29:17 +0000 (23:29 -0700)]
cmd/compile: make ifaceData accept a position

This lets us provide a better position in its use in swt.go.

Change-Id: I7c0da6bd0adea81acfc9a591e6a01b241a5e0942
Reviewed-on: https://go-review.googlesource.com/c/go/+/228219
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
4 years agostd,cmd: update golang.org/x/crypto to v0.0.0-20200414155820-4f8f47aa7992
Hana (Hyang-Ah) Kim [Tue, 14 Apr 2020 16:15:52 +0000 (12:15 -0400)]
std,cmd: update golang.org/x/crypto to v0.0.0-20200414155820-4f8f47aa7992

That includes https://golang.org/cl/228223

Also, update src/vendor/golang.org/x/crypto to match vendored
golang.org/x/crypto version.
Otherwise cmd/internal/goobj.TestDependencyVersionsConsistent
fails.

Fixes #27147

Change-Id: I4a3f1502fdee887762b10348811a08850a15a47a
Reviewed-on: https://go-review.googlesource.com/c/go/+/228226
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
4 years agoMerge "cmd: merge branch 'dev.link' into master"
Gerrit Code Review [Tue, 14 Apr 2020 17:35:25 +0000 (17:35 +0000)]
Merge "cmd: merge branch 'dev.link' into master"

4 years agocmd/compile: improve generated code for concrete cases in type switches
Josh Bleecher Snyder [Mon, 13 Apr 2020 00:34:33 +0000 (17:34 -0700)]
cmd/compile: improve generated code for concrete cases in type switches

Consider

switch x:= x.(type) {
case int:
  // int stmts
case error:
  // error stmts
}

Prior to this change, we lowered this roughly as:

if x, ok := x.(int); ok {
  // int stmts
} else if x, ok := x.(error); ok {
  // error stmts
}

x, ok := x.(error) is implemented with a call to runtime.assertE2I2 or runtime.assertI2I2.

x, ok := x.(int) generates inline code that checks whether x has type int,
and populates x and ok as appropriate. We then immediately branch again on ok.
The shortcircuit pass in the SSA backend is designed to recognize situations
like this, in which we are immediately branching on a bool value
that we just calculated with a branch.

However, the shortcircuit pass has limitations when the intermediate state has phis.
In this case, the phi value is x (the int).
CL 222923 improved the situation, but many cases are still unhandled.
I have further improvements in progress, which is how I found this particular problem,
but they are expensive, and may or may not see the light of day.

In the common case of a lone concrete type in a type switch case,
it is easier and cheaper to simply lower a different way, roughly:

if _, ok := x.(int); ok {
  x := x.(int)
  // int stmts
}

Instead of using a type assertion, though, we extract the value of x
from the interface directly.

This removes the need to track x (the int) across the branch on ok,
which removes the phi, which lets the shortcircuit pass do its job.

Benchmarks for encoding/binary show improvements, as well as some
wild swings on the super fast benchmarks (alignment effects?):

name                      old time/op    new time/op    delta
ReadSlice1000Int32s-8       5.25µs ± 2%    4.87µs ± 3%   -7.11%  (p=0.000 n=44+49)
ReadStruct-8                 451ns ± 2%     417ns ± 2%   -7.39%  (p=0.000 n=45+46)
WriteStruct-8                412ns ± 2%     405ns ± 3%   -1.58%  (p=0.000 n=46+48)
ReadInts-8                   296ns ± 8%     275ns ± 3%   -7.23%  (p=0.000 n=48+50)
WriteInts-8                  324ns ± 1%     318ns ± 2%   -1.67%  (p=0.000 n=44+49)
WriteSlice1000Int32s-8      5.21µs ± 2%    4.92µs ± 1%   -5.67%  (p=0.000 n=46+44)
PutUint16-8                 0.58ns ± 2%    0.59ns ± 2%   +0.63%  (p=0.000 n=49+49)
PutUint32-8                 0.87ns ± 1%    0.58ns ± 1%  -33.10%  (p=0.000 n=46+44)
PutUint64-8                 0.66ns ± 2%    0.87ns ± 2%  +33.07%  (p=0.000 n=47+48)
LittleEndianPutUint16-8     0.86ns ± 2%    0.87ns ± 2%   +0.55%  (p=0.003 n=47+50)
LittleEndianPutUint32-8     0.87ns ± 1%    0.87ns ± 1%     ~     (p=0.547 n=45+47)
LittleEndianPutUint64-8     0.87ns ± 2%    0.87ns ± 1%     ~     (p=0.451 n=46+47)
ReadFloats-8                79.8ns ± 5%    75.9ns ± 2%   -4.83%  (p=0.000 n=50+47)
WriteFloats-8               89.3ns ± 1%    88.9ns ± 1%   -0.48%  (p=0.000 n=46+44)
ReadSlice1000Float32s-8     5.51µs ± 1%    4.87µs ± 2%  -11.74%  (p=0.000 n=47+46)
WriteSlice1000Float32s-8    5.51µs ± 1%    4.93µs ± 1%  -10.60%  (p=0.000 n=48+47)
PutUvarint32-8              25.9ns ± 2%    24.0ns ± 2%   -7.02%  (p=0.000 n=48+50)
PutUvarint64-8              75.1ns ± 1%    61.5ns ± 2%  -18.12%  (p=0.000 n=45+47)
[Geo mean]                  57.3ns         54.3ns        -5.33%

Despite the rarity of type switches, this generates noticeably smaller binaries.

file      before    after     Δ       %
addr2line 4413296   4409200   -4096   -0.093%
api       5982648   5962168   -20480  -0.342%
cgo       4854168   4833688   -20480  -0.422%
compile   19694784  19682560  -12224  -0.062%
cover     5278008   5265720   -12288  -0.233%
doc       4694824   4682536   -12288  -0.262%
fix       3411336   3394952   -16384  -0.480%
link      6721496   6717400   -4096   -0.061%
nm        4371152   4358864   -12288  -0.281%
objdump   4760960   4752768   -8192   -0.172%
pprof     14810820  14790340  -20480  -0.138%
trace     11681076  11668788  -12288  -0.105%
vet       8285464   8244504   -40960  -0.494%
total     115824120 115627576 -196544 -0.170%

Compiler performance is marginally improved (note that go/types has many type switches):

name        old alloc/op      new alloc/op      delta
Template         35.0MB ± 0%       35.0MB ± 0%  +0.09%  (p=0.008 n=5+5)
Unicode          28.5MB ± 0%       28.5MB ± 0%    ~     (p=0.548 n=5+5)
GoTypes           114MB ± 0%        114MB ± 0%  -0.76%  (p=0.008 n=5+5)
Compiler          541MB ± 0%        541MB ± 0%  -0.03%  (p=0.008 n=5+5)
SSA              1.17GB ± 0%       1.17GB ± 0%    ~     (p=0.841 n=5+5)
Flate            21.9MB ± 0%       21.9MB ± 0%    ~     (p=0.421 n=5+5)
GoParser         26.9MB ± 0%       26.9MB ± 0%    ~     (p=0.222 n=5+5)
Reflect          74.6MB ± 0%       74.6MB ± 0%    ~     (p=1.000 n=5+5)
Tar              32.9MB ± 0%       32.8MB ± 0%    ~     (p=0.056 n=5+5)
XML              42.4MB ± 0%       42.1MB ± 0%  -0.77%  (p=0.008 n=5+5)
[Geo mean]       73.2MB            73.1MB       -0.15%

name        old allocs/op     new allocs/op     delta
Template           377k ± 0%         377k ± 0%  +0.06%  (p=0.008 n=5+5)
Unicode            354k ± 0%         354k ± 0%    ~     (p=0.095 n=5+5)
GoTypes           1.31M ± 0%        1.30M ± 0%  -0.73%  (p=0.008 n=5+5)
Compiler          5.44M ± 0%        5.44M ± 0%  -0.04%  (p=0.008 n=5+5)
SSA               11.7M ± 0%        11.7M ± 0%    ~     (p=1.000 n=5+5)
Flate              239k ± 0%         239k ± 0%    ~     (p=1.000 n=5+5)
GoParser           302k ± 0%         302k ± 0%  -0.04%  (p=0.008 n=5+5)
Reflect            977k ± 0%         977k ± 0%    ~     (p=0.690 n=5+5)
Tar                346k ± 0%         346k ± 0%    ~     (p=0.889 n=5+5)
XML                431k ± 0%         430k ± 0%  -0.25%  (p=0.008 n=5+5)
[Geo mean]         806k              806k       -0.10%

For packages with many type switches, this considerably shrinks function text size.
Some examples:

file                                                           before   after    Δ       %
encoding/binary.s                                              30726    29504    -1222   -3.977%
go/printer.s                                                   77597    76005    -1592   -2.052%
cmd/vendor/golang.org/x/tools/go/ast/astutil.s                 65704    63318    -2386   -3.631%
cmd/vendor/golang.org/x/tools/go/analysis/passes/unreachable.s 8047     7714     -333    -4.138%

Text size regressions are rare.

Change-Id: Ic10982bbb04876250eaa5bfee97990141ae5fc28
Reviewed-on: https://go-review.googlesource.com/c/go/+/228106
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: Keith Randall <khr@golang.org>
4 years agocmd: merge branch 'dev.link' into master
Cherry Zhang [Tue, 14 Apr 2020 17:04:35 +0000 (13:04 -0400)]
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, as we already merged master branch to
dev.link first.

Change-Id: I1fef2b1d94bd2410001142da8991544da5ee896d

4 years ago[dev.link] cmd/oldlink: update with recent change
Cherry Zhang [Tue, 14 Apr 2020 16:35:54 +0000 (12:35 -0400)]
[dev.link] cmd/oldlink: update with recent change

Port CL 227864 to cmd/oldlink.

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

4 years agocmd/compile: mark static arrays when initialize map literal as noalg
Cuong Manh Le [Tue, 14 Apr 2020 16:01:18 +0000 (23:01 +0700)]
cmd/compile: mark static arrays when initialize map literal as noalg

Same thing as CL 228222 does with static slice.

file      before    after     Δ       %
go        15228932  15228756  -176    -0.001%
addr2line 4429680   4429616   -64     -0.001%
api       5999032   5994904   -4128   -0.069%
asm       5087928   5087864   -64     -0.001%
compile   19727984  19723792  -4192   -0.021%
cover     5290296   5290184   -112    -0.002%
dist      3711816   3711784   -32     -0.001%
doc       4711208   4711176   -32     -0.001%
nm        4379344   4379264   -80     -0.002%
objdump   4773248   4773168   -80     -0.002%
pprof     14856148  14855764  -384    -0.003%
trace     11718212  11718020  -192    -0.002%
vet       8305944   8301768   -4176   -0.050%
total     131377612 131363900 -13712  -0.010%

Change-Id: I5ec00580b1509486c13aca43ad8f5cc7c450b62e
Reviewed-on: https://go-review.googlesource.com/c/go/+/227812
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

4 years agocmd/compile: mark static slice backing arrays as noalg
Josh Bleecher Snyder [Tue, 14 Apr 2020 15:16:51 +0000 (08:16 -0700)]
cmd/compile: mark static slice backing arrays as noalg

file      before    after     Δ       %
addr2line 4413296   4404160   -9136   -0.207%
api       5982648   5978232   -4416   -0.074%
asm       5075640   5057656   -17984  -0.354%
buildid   2886200   2881304   -4896   -0.170%
cgo       4854168   4844936   -9232   -0.190%
compile   19694784  19680752  -14032  -0.071%
cover     5278008   5269256   -8752   -0.166%
dist      3699528   3690984   -8544   -0.231%
doc       4694824   4690408   -4416   -0.094%
fix       3411336   3411048   -288    -0.008%
link      6721496   6703320   -18176  -0.270%
nm        4371152   4357904   -13248  -0.303%
objdump   4760960   4747680   -13280  -0.279%
pack      2340824   2336520   -4304   -0.184%
pprof     14810820  14801188  -9632   -0.065%
test2json 2861896   2857528   -4368   -0.153%
trace     11681076  11676228  -4848   -0.042%
vet       8285464   8276184   -9280   -0.112%
total     115824120 115665288 -158832 -0.137%

Change-Id: I66e1985c3a81cd9b2aa72cb4b4a8aa1781e473b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/228222
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>
4 years ago[dev.link] all: merge branch 'master' into dev.link
Cherry Zhang [Tue, 14 Apr 2020 16:08:07 +0000 (12:08 -0400)]
[dev.link] all: merge branch 'master' into dev.link

Change-Id: I31a52b1840ea773d23f5cc60484131ddf898b841

4 years ago[dev.link] cmd/link: remove some globals from symtab.go
Jeremy Faller [Fri, 10 Apr 2020 18:53:01 +0000 (14:53 -0400)]
[dev.link] cmd/link: remove some globals from symtab.go

Change-Id: Ia2540779c1bf01248591568e1ddef1eef6edc20e
Reviewed-on: https://go-review.googlesource.com/c/go/+/227917
Run-TryBot: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile: remove "special return in disguise" case
Cuong Manh Le [Sun, 12 Apr 2020 16:38:36 +0000 (23:38 +0700)]
cmd/compile: remove "special return in disguise" case

ascompatee does not generate 'x = x' during return, so we don't have to
check for samelist and disguising special return anymore.

While at it, also remove samelist, as this is the only place it's used.

Passes toolstash-check.

Change-Id: I41c7b077d562aadb5916a61e2ab6229bae3cdef4
Reviewed-on: https://go-review.googlesource.com/c/go/+/227807
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agogo/types: use same local variable consistently (minor cleanup)
Robert Griesemer [Tue, 14 Apr 2020 04:57:41 +0000 (21:57 -0700)]
go/types: use same local variable consistently (minor cleanup)

Currently this CL has no effect because V == x.typ in the affected
code. But if we should ever manipulate V (e.g., to support some form
of lazy evaluation of the type), not using V consistently would
lead to a subtle bug.

Change-Id: I465e72d18bbd2b6cd8fcbd746e0d28d14f758c03
Reviewed-on: https://go-review.googlesource.com/c/go/+/228105
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agotime: quote original value in errors returned by ParseDuration
Obeyda Djeffal [Sat, 11 Apr 2020 22:21:22 +0000 (23:21 +0100)]
time: quote original value in errors returned by ParseDuration

Quote original values passed as substring of ParseError.Message.
Improves the user experience of ParseDuration by making it
quote its original argument, for example:

   _, err := time.ParseDuration("for breakfast")
 will now produce an error, which when printed out is:

  time: invalid duration "for breakfast"
 instead of:

  time: invalid duration for breakfast

Adapt test cases for format.Parse and format.ParseDuration.

Fixes #38295

Change-Id: Ife322c8f3c859e1e4e8dd546d4cf0d519b4bfa81
Reviewed-on: https://go-review.googlesource.com/c/go/+/227878
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoRevert "time/tzdata: new package"
Ian Lance Taylor [Mon, 13 Apr 2020 23:26:39 +0000 (23:26 +0000)]
Revert "time/tzdata: new package"

This reverts CL 224588.

Reason for revert: Test failing on secondary platforms.

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

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

Updates #36417

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

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

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

Fix boringcrypto build.

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

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

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

For #31915.
Updates #19013.

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

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

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

Fixes #21881
Fixes #38013
Fixes #38017

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

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

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

Add a regression test for this case.

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

Updates #29737

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

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

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

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

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

Fixes #26676

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

Add ExampleIs to illustrate how errors.Is works.

Updates #31716.
Updates #38369.

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

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

Change-Id: Ie012d2a5680525b88e244a3380d72bc4f61da8e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/228058
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years ago[dev.link] cmd/link: remove symbol.FuncInfo
Cherry Zhang [Sun, 12 Apr 2020 16:52:16 +0000 (12:52 -0400)]
[dev.link] cmd/link: remove symbol.FuncInfo

It is no longer used. The only remaining use is in generating
Plan 9 debug info, which is already not supported.

Change-Id: Ia023d6f2fa7d57b97ba861ce464e2eec8ac2d1f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/228142
Reviewed-by: Than McIntosh <thanm@google.com>
4 years ago[dev.link] cmd/link: stop populating lib/unit.Textp
Cherry Zhang [Fri, 10 Apr 2020 23:13:01 +0000 (19:13 -0400)]
[dev.link] cmd/link: stop populating lib/unit.Textp

lib.Textp was used for text address assignment and trampoline
insertion. Now that it has been converted to using the loader,
no need to populate lib.Textp.

Port the logic of canonicalizing dupok symbol's package to the
loader.

unit.Textp was used for DWARF generation, which has also been
converted to using the loader.

Change-Id: I22d4dd30a52a29dd5b1b7b795d43a19f6215e4ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/228140
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocrypto/tls: failed tls.Conn.Write returns a permanent error
Katie Hockman [Fri, 10 Apr 2020 14:06:29 +0000 (10:06 -0400)]
crypto/tls: failed tls.Conn.Write returns a permanent error

Fixes #29971

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