1
0
mirror of https://github.com/golang/go synced 2024-11-05 18:16:10 -07:00
Commit Graph

36757 Commits

Author SHA1 Message Date
Josh Bleecher Snyder
5029c3671d cmd/compile: improve generated eq algs for structs containing strings
type T struct {
    s string
    i int
}

Prior to this change, we generated this equality algorithm for T:

func eqT(p, q *T) bool {
    return len(p.s) == len(q.s) &&
      runtime.memequal(p.s.ptr, q.s.ptr, len(p.s)) &&
      p.i == q.i
}

This change splits the two halves of the string equality,
so that we can do the cheap (length) half early and the expensive
(contents) half late. We now generate:

func eqT(p, q *T) bool {
    return len(p.s) == len(q.s) &&
      p.i == q.i &&
      runtime.memequal(p.s.ptr, q.s.ptr, len(p.s))
}

The generated code for these functions tends to be a bit shorter. Examples:

runtime
.eq."".Frame 274 -> 272  (-0.73%)
.eq."".funcinl 249 -> 247  (-0.80%)
.eq."".modulehash 207 -> 205  (-0.97%)

Change-Id: I4efac9f7d410f0a11a94dcee2bf9c0b49b60e301
Reviewed-on: https://go-review.googlesource.com/c/go/+/230205
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-27 17:19:16 +00:00
Josh Bleecher Snyder
daae72e88e cmd/compile: refactor out eqstring
Refactor out creating the two Nodes needed to check string equality.
Preliminary work to other optimizations.

Passes toolstash-check.

Change-Id: I72e824dac904e579b8ba9a3669a94fa1471112d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/230204
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-27 17:19:07 +00:00
Josh Bleecher Snyder
79648bde2d cmd/compile: make runtime calls last in eq algs
type T struct {
    f float64
    a [64]uint64
    g float64
}

Prior to this change, the generated equality algorithm for T was:

func eqT(p, q *T) bool {
    return p.f == q.f && runtime.memequal(p.a, q.a, 512) && p.g == q.g
}

In handwritten code, we would normally put the cheapest checks first.
This change takes a step in that direction. We now generate:

func eqT(p, q *T) bool {
    return p.f == q.f && p.g == q.g && runtime.memequal(p.a, q.a, 512)
}

For most types, this also generates considerably shorter code. Examples:

runtime
.eq."".mstats 406 -> 391  (-3.69%)
.eq.""._func 114 -> 101  (-11.40%)
.eq."".itab 115 -> 102  (-11.30%)
.eq."".scase 125 -> 116  (-7.20%)
.eq."".traceStack 119 -> 102  (-14.29%)
.eq."".gcControllerState 169 -> 161  (-4.73%)
.eq."".sweepdata 121 -> 112  (-7.44%)

However, for types in which we make unwise choices about inlining
memory-only comparisons (#38494), this generates longer code.

Example:

cmd/internal/obj
.eq."".objWriter 211 -> 214  (+1.42%)
.eq."".Addr 185 -> 187  (+1.08%)

Fortunately, such cases are not common.

Change-Id: I47a27da93c1f88ec71fa350c192f36b29548a217
Reviewed-on: https://go-review.googlesource.com/c/go/+/230203
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-27 17:19:01 +00:00
Daniel Martí
1cf357981e cmd/compile: remove If type in rulegen
We only generate if statements via CondBreak, which is nice as the
control flow is simple and easy to work with. It seems like the If type
was added but never used, so remove it to avoid confusion.

We had a TODO about replacing CondBreak with If instead. I gave that a
try, but it doesn't seem worth the effort. The code gets more complex
and we don't really win anything in return.

While at it, don't use op strings as format strings in exprf. This
doesn't cause any issue at the moment, but it's best to be explicit
about the operator not containing any formatting verbs.

Change-Id: Ib59ad72d3628bf91594efc609e222232ad1e8748
Reviewed-on: https://go-review.googlesource.com/c/go/+/230257
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-27 17:08:03 +00:00
Baokun Lee
20ed142861 cmd/go/internal/web: use url.Redacted
Updates #37873

Change-Id: I2228f31fc7bd7daef086cd05d365fa7c68e60a83
Reviewed-on: https://go-review.googlesource.com/c/go/+/223757
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-27 17:07:16 +00:00
Cuong Manh Le
f1a2a0e0bf cmd/compile: rewrite decArgs rules to use typed aux field
Passes toolstash-check.

Change-Id: I386fb9d52709c4844b313f59f62a4f47c10e490d
Reviewed-on: https://go-review.googlesource.com/c/go/+/230117
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-27 16:18:30 +00:00
Meng Zhuo
9b9556f660 cmd/link: use definition from debug/elf for ldelf
Change-Id: I92d0fb3a244d0151fcc4b25a20913ad69a89f198
Reviewed-on: https://go-review.googlesource.com/c/go/+/224977
Run-TryBot: Meng Zhuo <mengzhuo1203@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-04-27 15:53:46 +00:00
Alberto Donizetti
70d9b72a87 cmd/compile: convert more arm64 lowering rules to typed aux
Passes

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

Change-Id: Idc0ac2638c7a9b840ba2d6f4bba2e9c5df24c807
Reviewed-on: https://go-review.googlesource.com/c/go/+/230177
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-27 15:50:54 +00:00
Nigel Tao
bce1e25b71 image/png: fix some 32-bit int overflows
Fixes #38435

Change-Id: Ib9ae3cf7f338b2860a5688e448a125f257fe624e
Reviewed-on: https://go-review.googlesource.com/c/go/+/230219
Reviewed-by: Andrew Ekstedt <andrew.ekstedt@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
2020-04-27 11:55:27 +00:00
Michael Munday
b7a5e7ae92 cmd/compile: adopt strong aux typing for some s390x rules
Apply strong aux typing to lowering rules that do not require
modification beyond substituting -> for =>. Other lowering rules
and all the optimization rules will follow. I'm breaking it up
to allow toolstash-check to pass on the big CLs.

Passes toolstash-check -all.

Change-Id: I6f1340058a8eb5a1390411e59fcbea9d7f777e58
Reviewed-on: https://go-review.googlesource.com/c/go/+/229400
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-27 11:13:52 +00:00
Ruixin(Peter) Bao
925d6b31b0 cmd/compile: adopt strong aux typing for some s390x rules
Convert some Move and Zero Lowering rules to strongly-typed versions.

Passes toolstash-check.

Change-Id: Icaabe05e206d59798e5883a90e9a33bb30270b13
Reviewed-on: https://go-review.googlesource.com/c/go/+/229919
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-27 10:23:01 +00:00
Daniel Martí
6a569f243e cmd/compile: minor rulegen simplifications
The commuteDepth variable is no longer necessary; remove it.

Else branches after a log.Fatal call are unnecessary.

Also make the unbalanced return an integer, so we can differentiate
positive from negative cases. We only want to continue a rule with the
following lines if this balance is positive, for example.

While at it, make the balance loop stop when it goes negative, to not
let ")(" seem balanced.

Change-Id: I8aa313343ca5a2f07f638b62a0398fdf108fc9eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/228822
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2020-04-26 20:15:41 +00:00
Pierre Carru
8bcf2834af net/http/httputil: make Switching Protocol requests (e.g. Websockets) cancelable
Ensures that a canceled client request for Switching Protocols
(e.g. h2c, Websockets) will cause the underlying connection to
be terminated.

Adds a goroutine in handleUpgradeResponse in order to select on
the incoming client request's context and appropriately cancel it.

Fixes #35559

Change-Id: I1238e18fd4cce457f034f78d9cdce0e7f93b8bf6
GitHub-Last-Rev: 3629c78493
GitHub-Pull-Request: golang/go#38021
Reviewed-on: https://go-review.googlesource.com/c/go/+/224897
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-04-26 09:26:10 +00:00
Tyson Andre
09630172d4 net/http/httputil: fix typo in unit test name
Everywhere else is using "cancellation"

The reasoning is mentioned in 170060

> Though there is variation in the spelling of canceled,
> cancellation is always spelled with a double l.
>
> Reference: https://www.grammarly.com/blog/canceled-vs-cancelled/

Change-Id: Ifc97c6785afb401814af77c377c2e2745ce53c5a
GitHub-Last-Rev: 05edd7477d
GitHub-Pull-Request: golang/go#38662
Reviewed-on: https://go-review.googlesource.com/c/go/+/230200
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-25 23:15:50 +00:00
Tyson Andre
19648622d2 math/cmplx: fix typo in code comment
Everywhere else is using "cancellation" as of 2019

The reasoning is mentioned in 170060.

> Though there is variation in the spelling of canceled,
> cancellation is always spelled with a double l.
>
> Reference: https://www.grammarly.com/blog/canceled-vs-cancelled/

Change-Id: I933ea68d7251986ce582b92c33b7cb13cee1d207
GitHub-Last-Rev: fc3d5ada2b
GitHub-Pull-Request: golang/go#38661
Reviewed-on: https://go-review.googlesource.com/c/go/+/230199
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-25 21:06:35 +00:00
Brad Fitzpatrick
7ef28cbd12 testing: give short package variable a longer name
(Update to CL 229837)

Change-Id: Ieab46bd384f76f678ef0d6a38dc043bc4b0c458a
Reviewed-on: https://go-review.googlesource.com/c/go/+/230157
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-04-25 18:40:45 +00:00
Mukesh Sharma
a9f8f02f3c cmd/go/internal/cache: fix typing error in errVerifyMode
This change fixes the typing mistake in errVerifyMode error message in cache.

Change-Id: I10c405a06e3396f9932db72d9de418d7f8aa013c
GitHub-Last-Rev: 14ea7c693c
GitHub-Pull-Request: golang/go#38655
Reviewed-on: https://go-review.googlesource.com/c/go/+/230097
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-04-25 14:23:05 +00:00
Tobias Klauser
41e925bbcc testing: replace all GOOS-specific path separators in TempDir
For GOOS=windows the path separator characters '\' and ':' also need be
replaced.

Updates #38465

Change-Id: If7c8cf93058c87d7df6cda140e82fd76578fe699
Reviewed-on: https://go-review.googlesource.com/c/go/+/229837
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2020-04-25 10:38:47 +00:00
Josh Bleecher Snyder
49f10f3797 cmd/compile: convert another tranch of generic rules to typed aux
Passes toolstash-check.

Change-Id: I27c01f03c5303876bbf6878a81ffdc4e95de3e3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/230031
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-04-25 02:19:12 +00:00
Ian Lance Taylor
d422f54619 os, net: define and use os.ErrDeadlineExceeded
If an I/O operation fails because a deadline was exceeded,
return os.ErrDeadlineExceeded. We used to return poll.ErrTimeout,
an internal error, and told users to check the Timeout method.
However, there are other errors with a Timeout method that returns true,
notably syscall.ETIMEDOUT which is returned for a keep-alive timeout.
Checking errors.Is(err, os.ErrDeadlineExceeded) should permit code
to reliably tell why it failed.

This change does not affect the handling of net.Dialer.Deadline,
nor does it change the handling of net.DialContext when the context
deadline is exceeded. Those cases continue to return an error
reported as "i/o timeout" for which Timeout is true, but that error
is not os.ErrDeadlineExceeded.

Fixes #31449

Change-Id: I0323f42e944324c6f2578f00c3ac90c24fe81177
Reviewed-on: https://go-review.googlesource.com/c/go/+/228645
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
2020-04-25 00:26:48 +00:00
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
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
Gerrit Code Review
da33f9c78a Merge "cmd: merge branch 'dev.link' into master" 2020-04-24 17:13:12 +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
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
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
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