1
0
mirror of https://github.com/golang/go synced 2024-11-18 02:24:45 -07:00
Commit Graph

44613 Commits

Author SHA1 Message Date
Egon Elbre
d7a6a44deb doc/asm: add BP is callee-save paragraph
Change-Id: Id38e639c66a42acf0b1c4488cdfd0b7b6cf71c78
Reviewed-on: https://go-review.googlesource.com/c/go/+/250397
Reviewed-by: Keith Randall <khr@golang.org>
2020-09-01 14:54:08 +00:00
Heisenberg
4d89b3231d runtime: remove remnants of signal stack workaround
Updates #35979

Change-Id: Ic3a6e1b5e9d544979a3c8d909a36a55efa3b9c9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/251757
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2020-09-01 13:23:55 +00:00
Paul Forgey
5f5a55679c net/http: refactor ResponseWriter.ReadFrom to permit splice on Linux
Rather than probe and guess if sendfile will work inside ResponseWriter.ReadFrom(src),
this change fixes the underlying issue of starting to respond before src is readable
We'll no longer send a status OK if a header has not yet been written and reading
from src is destined to fail. This small change implicitly takes care of the need for
the server to sniff the response body to determine the Content-Type.

This allows splice to work on Linux when src is a socket or any non-regular file that's spliceable.

The extra read of 512 bytes may raise an objection, and that's fair, but
we're already swapping some syscall prep work for another and a read of
512 probably will not impact the overall performance. For shorter
bodies, there's likely less setup time. A little initial slop is not too
unusual in zero copy network code, and sometimes actually helps.

Fixes #40888

Change-Id: I4a8e2ad0ace1318bae66dae5671d06ea6d4838ed
GitHub-Last-Rev: 097364ea86
GitHub-Pull-Request: golang/go#40903
Reviewed-on: https://go-review.googlesource.com/c/go/+/249238
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-09-01 00:55:12 +00:00
Victor Michel
e01a226fad debug/elf: support relocations relative to sections with non-zero addresses
commit 72ec930fa7 added basic support for
relocations, but assumed that the symbol value would be 0, likely because
.debug_info always has address == 0 in the ELF section headers.

CL 195679 added further support for relocations, but explicitly encoded
the original assumption that section addresses would be 0.

This change removes that assumption: all relocations will now be
properly computed based on the target symbol value even when that symbol
is a section with a non-zero address.

Typically, sections that are part of a LOAD program segment have
non-zero addresses. For example, .debug_ranges relocations could be
relative to .text, which usually has an address > 0.

Fixes #40879

Change-Id: Ib0a616bb8b05d6c96d179b03ca33a10946fc5d59
GitHub-Last-Rev: 4200de7326
GitHub-Pull-Request: golang/go#41038
Reviewed-on: https://go-review.googlesource.com/c/go/+/250559
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-08-31 18:42:38 +00:00
David Finkel
f0c7e3e946 cmd/compile: adjust some AMD64 rewrite rules to use typed aux fields
Remove an extra int32-representable check when deciding to use an int32
constant as an immediate value.

Comment out a broken optimization that relies on MaxUint32 being
representable by a signed int32. It never triggers and when fixed, the
signedness of the auxint prevents other optimization passes from
handling it properly, thus causing segfaults in the runtime.

Remove a couple offset representable in 32-bits checks on 32-bit aux
vals.

toolstash-check clean

Change-Id: I148b53403fde523c90d692cb90e412460664b439
Reviewed-on: https://go-review.googlesource.com/c/go/+/230458
Reviewed-by: Keith Randall <khr@golang.org>
2020-08-31 18:22:08 +00:00
Keith Randall
9e70564f63 cmd/compile,cmd/asm: simplify recording of branch targets, take 2
We currently use two fields to store the targets of branches.
Some phases use p.To.Val, some use p.Pcond. Rewrite so that
every branch instruction uses p.To.Val.
p.From.Val is also used in rare instances.
Introduce a Pool link for use by arm/arm64, instead of
repurposing Pcond.

This is a cleanup CL in preparation for some stack frame CLs.

Change-Id: If8239177e4b1ea2bccd0608eb39553d23210d405
Reviewed-on: https://go-review.googlesource.com/c/go/+/251437
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-08-31 17:36:08 +00:00
Ian Lance Taylor
ba0fab3cb7 debug/elf: run relocation tests in parallel
Also don't restart DWARF reading from beginning when we are testing
multiple entries.

Also reformat relocationTests slice to use indexed literals.

Change-Id: Ia5f17214483394d0ef033be516df61f0bdc521b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/251637
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
2020-08-30 03:53:59 +00:00
Shinnosuke Sawada
4fc3896e79 database/sql: shortestIdleTimeLocked correct min comparison
When zero or less, maxIdleTime and maxLifetime means unlimited.
Helper function shortestIdleTimeLocked must not return the
minimum of the two until both are verified to be greater
then zero.

Fixes #40841

Change-Id: I1130332baf4ad259cd90c10f4221f5def8510655
Reviewed-on: https://go-review.googlesource.com/c/go/+/248817
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
2020-08-29 09:20:35 +00:00
Cuong Manh Le
27a30186ab cmd/compile,runtime: skip zero'ing order array for select statements
The order array was zero initialized by the compiler, but ends up being
overwritten by the runtime anyway.

So let the runtime takes full responsibility for initializing, save us
one instruction per select.

Fixes #40399

Change-Id: Iec1eca27ad7180d4fcb3cc9ef97348206b7fe6b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/251517
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-08-29 08:02:52 +00:00
Ian Lance Taylor
49bae98495 test: add test that gccgo failed to compile
For #38125

Change-Id: Id6ef10d74f0f9dbad2851531e0fe019cd145cf7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/251168
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-08-28 23:43:22 +00:00
Ariel Mashraki
c8ea03828b text/template: add CommentNode to template parse tree
Fixes #34652

Change-Id: Icf6e3eda593fed826736f34f95a9d66f5450cc98
Reviewed-on: https://go-review.googlesource.com/c/go/+/229398
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-08-28 21:45:12 +00:00
zdjones
a58a8d2e97 test: document specifying individual test files as operands
The current command will run this entire set of tests, which takes a
noticeable amount of time. Contributors may wish to run only a subset of
these tests to save time/compute (e.g. when iterating on a CL that
failed tests in that subset). Listing file(s) as operands to the command
will run only those tests.

Change-Id: I1874c43681a594190bc40b61cee0b8d321be73f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/242997
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2020-08-28 21:23:32 +00:00
Ian Lance Taylor
54e18f1c2a testing: run a Cleanup registered by a Cleanup
Fixes #41085

Change-Id: Ieafc60cbc8e09f1935d38b1767b084d78dae5cb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/251457
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-28 20:01:41 +00:00
Rob Findley
45e12e95e6 go/types: add tests for conversion of non-constant untyped values
This was fixed by CL 242084. Retroactively add some tests that would
have failed before the fix.

Also, remove some existing duplicate tests.

Change-Id: I95f7a215d4a9651ded6d739f89c574f33f573c60
Reviewed-on: https://go-review.googlesource.com/c/go/+/251397
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-28 18:29:14 +00:00
Rob Findley
42e09dc1ba go/types: factor out usage of implicit type
There was some duplication of logic interpreting the implicit type of
an operand in assignableTo and convertUntyped. Factor out this logic to
a new 'implicitType' function, which returns the implicit type of an
untyped operand when used in a context where a target type is expected.
I believe this resolves some comments about code duplication. There is
other similar code in assignable, assignableTo, and convertUntypes, but
I found it to to be sufficiently semantically distinct to not warrant
factoring out.

Change-Id: I199298a2e58fcf05344318fca0226b460c57867d
Reviewed-on: https://go-review.googlesource.com/c/go/+/242084
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-28 16:45:21 +00:00
Xiangdong Ji
ae7b6a3b77 math/big: tune addVW/subVW performance on arm64
Add an optimization for addVW and subVW over large-sized vectors, it switches
from add/sub with carry to copy the rest of the vector when we are done with
carries. Consistent performance improvement are observed on various arm64
machines.

Add additional tests and benchmarks to increase the test coverage.
TestFunVWExt:
  Testing with various types of input vector, using the result from go-version
  addVW/subVW as golden reference.
BenchmarkAddVWext and BenchmarkSubVWext:
  Benchmarking using input vector having all 1s or all 0s, for evaluating the
  overhead of worst case.

1. Perf. comparison over randomly generated input vectors:

Server 1:
name             old time/op    new time/op    delta
AddVW/1            12.3ns ± 3%    12.0ns ± 0%    -2.60%  (p=0.001 n=10+8)
AddVW/2            12.5ns ± 2%    12.3ns ± 0%    -1.84%  (p=0.001 n=10+8)
AddVW/3            12.6ns ± 2%    12.3ns ± 0%    -1.91%  (p=0.009 n=10+10)
AddVW/4            13.1ns ± 3%    12.7ns ± 0%    -2.98%  (p=0.006 n=10+8)
AddVW/5            14.4ns ± 1%    13.9ns ± 0%    -3.81%  (p=0.000 n=10+10)
AddVW/10           11.7ns ± 0%    11.7ns ± 0%      ~     (all equal)
AddVW/100          47.8ns ± 0%    29.9ns ± 2%   -37.38%  (p=0.000 n=10+9)
AddVW/1000          446ns ± 0%     207ns ± 0%   -53.59%  (p=0.000 n=10+10)
AddVW/10000        4.35µs ± 1%    2.92µs ± 0%   -32.85%  (p=0.000 n=10+10)
AddVW/100000       43.6µs ± 0%    29.7µs ± 0%   -31.92%  (p=0.000 n=8+10)
SubVW/1            12.6ns ± 0%    12.3ns ± 2%    -2.22%  (p=0.000 n=7+10)
SubVW/2            12.7ns ± 0%    12.6ns ± 1%    -0.39%  (p=0.046 n=8+10)
SubVW/3            12.7ns ± 1%    12.6ns ± 1%      ~     (p=0.410 n=10+10)
SubVW/4            13.3ns ± 3%    13.1ns ± 3%      ~     (p=0.072 n=10+10)
SubVW/5            14.2ns ± 0%    14.1ns ± 1%    -0.63%  (p=0.046 n=8+10)
SubVW/10           11.7ns ± 0%    11.7ns ± 0%      ~     (all equal)
SubVW/100          47.8ns ± 0%    33.1ns ±19%   -30.71%  (p=0.000 n=10+10)
SubVW/1000          446ns ± 0%     207ns ± 0%   -53.59%  (p=0.000 n=10+10)
SubVW/10000        4.33µs ± 1%    2.92µs ± 0%   -32.66%  (p=0.000 n=10+6)
SubVW/100000       43.4µs ± 0%    29.6µs ± 0%   -31.90%  (p=0.000 n=10+9)

Server 2:
name             old time/op    new time/op    delta
AddVW/1            5.49ns ± 0%    5.53ns ± 2%     ~     (p=1.000 n=9+10)
AddVW/2            5.96ns ± 2%    5.92ns ± 1%   -0.69%  (p=0.039 n=10+10)
AddVW/3            6.72ns ± 0%    6.73ns ± 0%     ~     (p=0.078 n=10+10)
AddVW/4            7.07ns ± 0%    6.75ns ± 2%   -4.55%  (p=0.000 n=10+10)
AddVW/5            8.14ns ± 0%    8.17ns ± 0%   +0.46%  (p=0.003 n=8+8)
AddVW/10           10.0ns ± 0%    10.1ns ± 1%   +0.70%  (p=0.003 n=10+10)
AddVW/100          43.0ns ± 0%    33.5ns ± 0%  -22.09%  (p=0.000 n=9+9)
AddVW/1000          394ns ± 0%     278ns ± 0%  -29.44%  (p=0.000 n=10+10)
AddVW/10000        4.18µs ± 0%    3.14µs ± 0%  -24.81%  (p=0.000 n=8+8)
AddVW/100000       68.3µs ± 3%    62.1µs ± 5%   -9.13%  (p=0.000 n=10+10)
SubVW/1            5.37ns ± 2%    5.42ns ± 1%     ~     (p=0.990 n=10+10)
SubVW/2            5.89ns ± 0%    5.92ns ± 1%   +0.58%  (p=0.000 n=8+10)
SubVW/3            6.64ns ± 1%    6.82ns ± 3%   +2.63%  (p=0.000 n=9+10)
SubVW/4            7.17ns ± 0%    6.69ns ± 2%   -6.74%  (p=0.000 n=10+9)
SubVW/5            8.22ns ± 0%    8.18ns ± 0%   -0.46%  (p=0.001 n=8+9)
SubVW/10           10.0ns ± 1%    10.1ns ± 1%     ~     (p=0.341 n=10+10)
SubVW/100          43.0ns ± 0%    33.5ns ± 0%  -22.09%  (p=0.000 n=7+10)
SubVW/1000          394ns ± 0%     278ns ± 0%  -29.44%  (p=0.000 n=10+10)
SubVW/10000        4.18µs ± 0%    3.15µs ± 0%  -24.62%  (p=0.000 n=9+9)
SubVW/100000       67.7µs ± 4%    62.4µs ± 2%   -7.92%  (p=0.000 n=10+10)

2. Perf. comparison over input vectors of all 1s or all 0s

Server 1:
name             old time/op    new time/op    delta
AddVWext/1         12.6ns ± 0%    12.0ns ± 0%    -4.76%  (p=0.000 n=6+10)
AddVWext/2         12.7ns ± 0%    12.4ns ± 1%    -2.52%  (p=0.000 n=10+10)
AddVWext/3         12.7ns ± 0%    12.4ns ± 0%    -2.36%  (p=0.000 n=9+7)
AddVWext/4         13.2ns ± 4%    12.7ns ± 0%    -3.71%  (p=0.001 n=10+9)
AddVWext/5         14.6ns ± 0%    13.9ns ± 0%    -4.79%  (p=0.000 n=10+8)
AddVWext/10        11.7ns ± 0%    11.7ns ± 0%      ~     (all equal)
AddVWext/100       47.8ns ± 0%    47.4ns ± 0%    -0.84%  (p=0.000 n=10+10)
AddVWext/1000       446ns ± 0%     399ns ± 0%   -10.54%  (p=0.000 n=10+10)
AddVWext/10000     4.34µs ± 1%    3.90µs ± 0%   -10.12%  (p=0.000 n=10+10)
AddVWext/100000    43.9µs ± 1%    39.4µs ± 0%   -10.18%  (p=0.000 n=10+10)
SubVWext/1         12.6ns ± 0%    12.3ns ± 2%    -2.70%  (p=0.000 n=7+10)
SubVWext/2         12.6ns ± 1%    12.6ns ± 2%      ~     (p=0.234 n=10+10)
SubVWext/3         12.7ns ± 0%    12.6ns ± 2%    -0.71%  (p=0.033 n=10+10)
SubVWext/4         13.4ns ± 0%    13.1ns ± 3%    -2.01%  (p=0.006 n=8+10)
SubVWext/5         14.2ns ± 0%    14.1ns ± 1%    -0.85%  (p=0.003 n=10+10)
SubVWext/10        11.7ns ± 0%    11.7ns ± 0%      ~     (all equal)
SubVWext/100       47.8ns ± 0%    47.4ns ± 0%    -0.84%  (p=0.000 n=10+10)
SubVWext/1000       446ns ± 0%     399ns ± 0%   -10.54%  (p=0.000 n=10+10)
SubVWext/10000     4.33µs ± 1%    3.90µs ± 0%   -10.02%  (p=0.000 n=10+10)
SubVWext/100000    43.5µs ± 0%    39.5µs ± 1%    -9.16%  (p=0.000 n=7+10)

Server 2:
name             old time/op    new time/op    delta
AddVWext/1         5.48ns ± 0%    5.43ns ± 1%   -0.97%  (p=0.000 n=9+9)
AddVWext/2         5.99ns ± 2%    5.93ns ± 1%     ~     (p=0.054 n=10+10)
AddVWext/3         6.74ns ± 0%    6.79ns ± 1%   +0.80%  (p=0.000 n=9+10)
AddVWext/4         7.18ns ± 0%    7.21ns ± 1%   +0.36%  (p=0.034 n=9+10)
AddVWext/5         7.93ns ± 3%    8.18ns ± 0%   +3.18%  (p=0.000 n=10+8)
AddVWext/10        10.0ns ± 0%    10.1ns ± 1%   +0.60%  (p=0.011 n=10+10)
AddVWext/100       43.0ns ± 0%    47.7ns ± 0%  +10.93%  (p=0.000 n=9+10)
AddVWext/1000       394ns ± 0%     399ns ± 0%   +1.27%  (p=0.000 n=10+10)
AddVWext/10000     4.18µs ± 0%    4.50µs ± 0%   +7.73%  (p=0.000 n=9+10)
AddVWext/100000    67.6µs ± 2%    68.4µs ± 3%     ~     (p=0.139 n=9+8)
SubVWext/1         5.46ns ± 1%    5.43ns ± 0%   -0.55%  (p=0.002 n=9+9)
SubVWext/2         5.89ns ± 0%    5.93ns ± 1%   +0.68%  (p=0.000 n=8+10)
SubVWext/3         6.72ns ± 1%    6.79ns ± 1%   +1.07%  (p=0.000 n=10+10)
SubVWext/4         6.98ns ± 1%    7.21ns ± 0%   +3.25%  (p=0.000 n=10+10)
SubVWext/5         8.22ns ± 0%    7.99ns ± 3%   -2.83%  (p=0.000 n=8+10)
SubVWext/10        10.0ns ± 1%    10.1ns ± 1%     ~     (p=0.239 n=10+10)
SubVWext/100       43.0ns ± 0%    47.7ns ± 0%  +10.93%  (p=0.000 n=8+10)
SubVWext/1000       394ns ± 0%     399ns ± 0%   +1.27%  (p=0.000 n=10+10)
SubVWext/10000     4.18µs ± 0%    4.51µs ± 0%   +7.86%  (p=0.000 n=8+8)
SubVWext/100000    68.3µs ± 2%    68.0µs ± 3%     ~     (p=0.515 n=10+8)

Change-Id: I134a5194b8a2deaaebbaa2b771baf72846971d58
Reviewed-on: https://go-review.googlesource.com/c/go/+/229739
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-08-28 16:40:41 +00:00
Xiangdong Ji
55cf84b077 cmd/compile: Install testcases for flag constant Ops
Flag constant Ops on arm and arm64 are under refactoring, this change adds
a couple of testcases that verify the behavior of 'noov' branches.

Updates #39505
Updates #38740
Updates #39303
Change-Id: I493344b52276900cd296c32da494d72932dfc9be
Reviewed-on: https://go-review.googlesource.com/c/go/+/238677
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-08-28 16:40:32 +00:00
Xiangdong Ji
5d0b35ca98 cmd/asm: Always use go-style arrangement specifiers on ARM64
Fixing several error message and comment texts of the ARM64 assembler
to use arrangement specifiers of Go's assembly style.

Change-Id: Icdbb14fba7aaede40d57d0d754795b050366a1ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/237859
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-08-28 16:40:13 +00:00
surechen
bd6dfe9a3e math/big: add a comment for SetMantExp
Change-Id: I9ff5d1767cf70648c2251268e5e815944a7cb371
Reviewed-on: https://go-review.googlesource.com/c/go/+/233737
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-28 16:25:32 +00:00
Santiago De la Cruz
3b6c812f3d doc: add linux/riscv64 valid combination
Mention valid combination GOOS=linux and GOARCH=riscv64
in the "Installing Go from source" document.

Updates #27532

Change-Id: I8c1406087132f5c82a2eee5dbcda95d53c64d263
GitHub-Last-Rev: ee74ff9517
GitHub-Pull-Request: golang/go#41063
Reviewed-on: https://go-review.googlesource.com/c/go/+/250997
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2020-08-28 08:12:25 +00:00
Bryan C. Mills
18ea6f597c testing: restore os.Exit(0) after every call to (*M).Run
cmd/go.TestScript/test_main_twice demonstrates a program that invokes
(*M).Run twice in a row. If we only restore os.Exit(0) in m.afterOnce,
we will fail to restore it after the second run and fail the test
process despite both runs passing.

Updates #29062
Updates #23129

Change-Id: Id22ec68f1708e4583c8dda14a8ba0efae7178b85
Reviewed-on: https://go-review.googlesource.com/c/go/+/251262
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-08-28 02:46:19 +00:00
Keith Randall
26ad27bb02 Revert "cmd/compile,cmd/asm: simplify recording of branch targets"
This reverts CL 243318.

Reason for revert: Seems to be crashing some builders.

Change-Id: I2ffc59bc5535be60b884b281c8d0eff4647dc756
Reviewed-on: https://go-review.googlesource.com/c/go/+/251169
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-28 02:10:13 +00:00
Keith Randall
42fd1306ce cmd/compile: clean up equality generation
We're using sort.SliceStable, so no need to keep track of indexes as well.

Use a more robust test for whether a node is a call.

Add a test that we're actually reordering comparisons. This test fails
without the alg.go changes in this CL because eqstring uses OCALLFUNC
instead of OCALL for its data comparisons.

Update #8606

Change-Id: Ieeec33434c72e3aa328deb11cc415cfda05632e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/237921
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2020-08-27 23:25:58 +00:00
Ian Lance Taylor
4f76fe8675 cmd/go, testing, os: fail test that calls os.Exit(0)
This catches cases where a test calls code that calls os.Exit(0),
thereby skipping all subsequent tests.

Fixes #29062

Change-Id: If9478972f40189e27623557e7141469ca4234d89
Reviewed-on: https://go-review.googlesource.com/c/go/+/250977
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-27 23:19:15 +00:00
Keith Randall
cdc635547f cmd/compile: invalidate zero-use values during rewrite
This helps remove uses that aren't needed any more.
That in turn helps other rules with Uses==1 conditions fire.

Update #39918

Change-Id: I68635b675472f1d59e59604e4d34b949a0016533
Reviewed-on: https://go-review.googlesource.com/c/go/+/249463
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2020-08-27 22:56:29 +00:00
Keith Randall
8247da3662 cmd/compile,cmd/asm: simplify recording of branch targets
We currently use two fields to store the targets of branches.
Some phases use p.To.Val, some use p.Pcond. Rewrite so that
every branch instruction uses p.To.Val.
p.From.Val is also used in rare instances.
Introduce a Pool link for use by arm/arm64, instead of
repurposing Pcond.

This is a cleanup CL in preparation for some stack frame CLs.

Change-Id: I9055bf0a1d986aff421e47951a1dedc301c846f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/243318
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2020-08-27 22:35:45 +00:00
Keith Randall
5c2c6d3fbf runtime: framepointers are no longer an experiment - hard code them
I think they are no longer experimental status. Might as well promote
them to permanent.

Change-Id: Id1259601b3dd2061dd60df86ee48080bfb575d2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/249857
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2020-08-27 21:15:47 +00:00
Benjamin Barenblat
29634436fd cmd/cgo: ensure GCC does not use ANSI escape sequences in errors
cgo parses GCC’s error messages to classify C identifiers referenced
from Go programs (are they integer constants? type names?). If GCC tries
to colorize its errors, cgo can’t figure out what GCC is saying. GCC
avoids escape sequences in this scenario by default, but the default
behavior can be overridden in at least two places:

  - The user can set `CGO_COPTS=-fdiagnostics-color`.

  - Whoever compiled GCC can configure GCC itself to always colorize
    output.

The most reliable way to ensure that GCC doesn’t colorize output is to
append `-fdiagnostics-color=never` to the GCC command line; do so.

Fixes #40415

Change-Id: Id4bdf8d92fac8b038340b4264f726e8fe38875b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/248398
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2020-08-27 21:13:46 +00:00
Paul E. Murphy
7615b20d06 cmd/compile: generate subfic on ppc64
This merges an lis + subf into subfic, and for 32b constants
lwa + subf into oris + ori + subf.

The carry bit is no longer used in code generation, therefore
I think we can clobber it as needed.  Note, lowered borrow/carry
arithmetic is self-contained and thus is not affected.

A few extra rules are added to ensure early transformations to
SUBFCconst don't trip up earlier rules, fold constant operations,
or otherwise simplify lowering.  Likewise, tests are added to
ensure all rules are hit.  Generic constant folding catches
trivial cases, however some lowering rules insert arithmetic
which can introduce new opportunities (e.g BitLen or Slicemask).

I couldn't find a specific benchmark to demonstrate noteworthy
improvements, but this is generating subfic in many of the default
bent test binaries, so we are at least saving a little code space.

Change-Id: Iad7c6e5767eaa9dc24dc1c989bd1c8cfe1982012
Reviewed-on: https://go-review.googlesource.com/c/go/+/249461
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
2020-08-27 20:10:15 +00:00
Michael Pratt
2013f70256 runtime: add lock partial order edge (fin -> wbufSpans)
runfinq may have write barriers, thus it may need to take wbufSpans on
any write.

Fixes #41021

Change-Id: Ib69e20994b5d7d1526ad53d6ddb5e2e83bf2ed00
Reviewed-on: https://go-review.googlesource.com/c/go/+/250464
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2020-08-27 19:42:42 +00:00
Bryan C. Mills
a98fe2632c cmd/go/internal/modload: address issues missed in CL 244774
For #36460

Change-Id: I5e9a42d64e36679b881e96145833e66cf77b98a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/250338
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-08-27 19:38:43 +00:00
Rob Findley
234e37bcda go/types: remove need to enumerate fixedbugs test files
This is a port of CL 244628, updated to move some existing regression
tests into the fixedbugs directory, and to use subtests. Also,
'TestFixed' is renamed to 'TestFixedBugs'.

Change-Id: I43aac3f75f2bd850567d08e8b008d91aeb717064
Reviewed-on: https://go-review.googlesource.com/c/go/+/247904
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-27 18:34:42 +00:00
Rob Findley
ac2a1f8796 go/types: clean up test support code and remove global variables
This is a straightforward port of CL 244627.

Change-Id: Ide980957430b35e22a6e22818b0ce9de410988af
Reviewed-on: https://go-review.googlesource.com/c/go/+/247902
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-27 18:33:37 +00:00
Bryan C. Mills
c00b708169 cmd/go/internal/modfetch: do not use mangled version strings to construct module.VersionErrors
Better still would be to avoid passing around module.Version instances
with invalid Version strings in the first place, so that any time we
see a module.Version we know that it is actually a version of a module
(and not a structurally-similar datum with something else tacked on to
one of the fields). But that's a bigger cleanup for which I don't
currently have enough bandwidth.

Fixes #41060

Change-Id: I32fba5619105cbf67dd03691064c82b8ebb3ce18
Reviewed-on: https://go-review.googlesource.com/c/go/+/250951
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-08-27 18:28:53 +00:00
Rob Findley
3b20d484fb go/types: fix missing Importer for TestBenchmark
TestBenchmark is broken due to lack of a Config.Importer, but
unfortunately fails silently due to an unchecked error.

Fix the importer and check the error. Also improve the output to include
allocation stats.

Finally, don't run TestBenchmark on go/types by default. If the
benchmark is being used during a refactoring of go/types itself, results
for go/types will not be comparable.

Change-Id: Ib6bdb6807403b3ec99762f535e2496c94bd9b6e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/249517
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2020-08-27 17:57:10 +00:00
Michael Munday
17ae587383 cmd/compile: use addressing modes pass on s390x
Add s390x support to the addressing modes pass. This significantly
reduces the number of rules we need to have to handle indexed
addressing modes on s390x.

There are some changes introduced with the new approach. Notably
pointer calculations of the form '(ADD x (ADDconst y [c]))' won't
get fully merged into address fields right now, the constant offset
will remain separate. That is a relatively minor issue though.

file      before    after     Δ       %
addr2line 4120904   4120960   +56     +0.001%
api       4944005   4948765   +4760   +0.096%
asm       4977431   4984335   +6904   +0.139%
buildid   2683760   2683504   -256    -0.010%
cgo       4557976   4558408   +432    +0.009%
compile   19103577  18916634  -186943 -0.979%
cover     4883694   4885054   +1360   +0.028%
dist      3545177   3553689   +8512   +0.240%
doc       3921766   3921518   -248    -0.006%
fix       3295254   3302182   +6928   +0.210%
link      6539222   6540286   +1064   +0.016%
nm        4105085   4107757   +2672   +0.065%
objdump   4546015   4545439   -576    -0.013%
pack      2416661   2415485   -1176   -0.049%
pprof     13267433  13265489  -1944   -0.015%
test2json 2762180   2761996   -184    -0.007%
trace     10145090  10135626  -9464   -0.093%
vet       6772946   6771738   -1208   -0.018%
total     106588176 106418865 -169311 -0.159%

Fixes #37891.

Change-Id: If60d51f31eb2806b011432a6519951b8668cb42f
Reviewed-on: https://go-review.googlesource.com/c/go/+/250958
Run-TryBot: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2020-08-27 17:56:04 +00:00
Rob Findley
73a5c37241 go/types: add untyped test cases for AssignableTo API
The AssignableTo API is specifically for non-constant values, but is
currently called by gopls for constant completions. Add a test to ensure
that we handle this edge case correctly.

Change-Id: I83115cbca2443a783df1c3090b5741260dffb78e
Reviewed-on: https://go-review.googlesource.com/c/go/+/250258
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-27 16:05:57 +00:00
Rob Findley
346efc2850 go/types: better error when converting untyped values in assignments
The error returned by convertUntyped is 'cannot convert _ to _', which
can be misleading in contexts where an explicit conversion would be
allowed.

Arguably the error message from convertUntyped should just be 'cannot
use _ as _', as 'convert' has an explicit meaning within the spec.
Making that change caused a large number of test failures, so for now we
just fix this for assignments by interpreting the error.

For #22070

Change-Id: I4eed6f39d1a991e8df7e035ec301d28a05150eb5
Reviewed-on: https://go-review.googlesource.com/c/go/+/242083
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2020-08-27 16:05:08 +00:00
Ian Lance Taylor
3e636ab9ad net/mail: return error on empty address list
This restores the handling accidentally changed in CL 217377.

Fixes #40803
For #36959

Change-Id: If77fbc0c2a1dde4799f760affdfb8dde9bcaf458
Reviewed-on: https://go-review.googlesource.com/c/go/+/248598
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Jeremy Fishman <jfishman@cloudflare.com>
2020-08-27 14:30:30 +00:00
Paul E. Murphy
2aba467933 cmd/compile: remove unused carry related ssa ops in ppc64
The intermediate SSA opcodes* are no longer generated during the
lowering pass.  The shifting rules have been improved using ISEL.
Therefore, we can remove them and the rules which expand them.

* The removed opcodes are:

  LoweredAdd64Carry
  ADDconstForCarry
  MaskIfNotCarry
  FlagCarryClear
  FlagCarrySet

Change-Id: I1ebe2726ed988f29ed4800c8f57b428f7a214cd0
Reviewed-on: https://go-review.googlesource.com/c/go/+/249462
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2020-08-27 13:07:57 +00:00
ShihCheng Tu
47b4509977 doc/go1.14: document json.Umarshal map key support of TextUnmarshaler
Document that json.Unmarshal supports map keys whose underlying
types implement encoding.TextUnmarshaler.

Fixes #38801

Change-Id: Icb9414e9067517531ba0da910bd4a2bb3daace65
Reviewed-on: https://go-review.googlesource.com/c/go/+/237857
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2020-08-27 09:47:26 +00:00
Ian Lance Taylor
e9ad52e46d net: export ErrClosed
This permits programs to reliably detect whether they are using a
closed network connection.

Fixes #4373

Change-Id: Ib4ce8cc82bbb134c4689f0ebc8b9b11bb8b32a22
Reviewed-on: https://go-review.googlesource.com/c/go/+/250357
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: Russ Cox <rsc@golang.org>
2020-08-26 22:48:00 +00:00
Michael Matloob
694fc8e76b cmd/go/internal/modload: reject some bad module paths
This change rejects module paths that don't conform to
the new checkModulePathLax function, when loading a go.mod
file. The change uses the checkModulePathLax function instead of
CheckPath because there are still many users who are using
unpublished modules with unpublishable paths, and we don't
want to break them all.

Next, before this change, when go mod init is run in GOPATH,
it would try to use the location of the directory within GOPATH
to infer the module path. After this change, it will only use
that inferred module path if it conforms to module.CheckPath.

Change-Id: Idb36d1655cc76aae82671e87ba634609503ad1a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/211597
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-26 21:35:30 +00:00
Jay Conrod
008048c5f4 doc: add module retraction to release notes
For #24031

Change-Id: I9bd0905e9aacee4bec3463b7d91f6f0929744752
Reviewed-on: https://go-review.googlesource.com/c/go/+/228384
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-26 21:17:33 +00:00
Jay Conrod
32c09aeb1d cmd/go: improve 'go get' handling of retracted versions
'go get' will now warn about retracted versions in the build list,
after updating go.mod. The warning instructs users to run
'go get module@latest' to upgrade or downgrade away from the retracted
version.

'go get' now allows users to explicitly request a specific retracted
version.

For #24031

Change-Id: I15fda918dc84258fb35b615dcd33b0f499481bd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/228383
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-26 21:17:11 +00:00
Jay Conrod
eb3e27ac1a cmd/go: add -retracted flag to 'go list'
The -retracted flag causes 'go list' to load information about
retracted module module versions.

When -retracted is used with -f or -json, the Retracted field is set
to a string containing the reason for the retraction on retracted
module versions. The string is based on comments on the retract
directive. This field is also populated when the -u flag is used.

When -retracted is used with -versions, retracted versions are shown.
Normally, they are omitted.

For #24031

Change-Id: Ic13d516eddffb1b8404e21034f78cecc9896d1b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/228382
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-26 21:17:01 +00:00
Jay Conrod
0bbd386e8b cmd/go: add -retract and -dropretract flags to 'go mod edit'
'go mod edit' can now add and remove 'retract' directives from go.mod
files.

Also, retractions are now included in the 'go mod edit -json' output.

For #24031

Change-Id: Ife7915e259fa508626d6ec5f786b5c860b489599
Reviewed-on: https://go-review.googlesource.com/c/go/+/228381
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-26 21:12:55 +00:00
Jay Conrod
c769f034d7 cmd/go/internal/modload: support go.mod retract directive
The go command now recognizes 'retract' directives in go.mod. A
retract directive may be used by a module author to indicate a
version should not be used. The go command will not automatically
upgrade to a retracted version. Retracted versions will not be
considered when resolving version queries like "latest" that don't
refer to a specific version.

Internally, when the go command resolves a version query, it will find
the highest release version (or pre-release if no release is
available), then it will load retractions from the go.mod file for
that version. Comments on retractions are treated as a rationale and
may appear in error messages. Retractions are only loaded when a query
is resolved, so this should have no impact on performance for most
builds, except when go.mod is incomplete.

For #24031

Change-Id: I17d643b9e03a3445676dbf1a5a351090c6ff6914
Reviewed-on: https://go-review.googlesource.com/c/go/+/228380
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-26 21:12:37 +00:00
Jay Conrod
db821b54d1 cmd/go/internal/modload: refactor version filtering for exclude
Query and other functions now accept an "allowed" function that
returns an error (previously, the function returned a bool). If the
error is equivalent to ErrDisallowed, it indicates the version is
excluded (or, in a future CL, retracted). This provides predicates a
chance to explain why a version is not allowed.

When a query refers to a specific revision (by version, branch, tag,
or commit name), most callers will not use the Allowed predicate. This
allows commands like 'go list -m' and 'go mod download' to handle
disallowed versions when explicitly requested. 'go get' will reject
excluded versions though.

When a query does not refer to a specific revision (for example,
"latest"), disallowed versions will not be considered.

When an "allowed" predicate returns an error not equivalent to
ErrDisallowed, it may be ignored or returned, depending on the
case. This never happens for excluded versions, but it may happen for
retractions (in a future CL). This indicates a list of retractions
could not be loaded. This frequently happens when offline, and it
shouldn't cause a fatal or warning in most cases.

For #24031

Change-Id: I4df6fb6bd60e3e0259e5b3b4bf71a307b4b32298
Reviewed-on: https://go-review.googlesource.com/c/go/+/228379
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2020-08-26 21:12:19 +00:00
Jay Conrod
bf869c65d1 cmd/go: update vendored golang.org/x/mod
This CL vendors go.mod parser changes for the retract directive.

For #24031

Change-Id: Ief19b0eca4c7956eceadc893bb209da7e9ecf22c
Reviewed-on: https://go-review.googlesource.com/c/go/+/228377
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2020-08-26 21:11:51 +00:00