]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
3 years agolib/time, time, time/tzdata: use slim tz data format
Tobias Klauser [Tue, 13 Oct 2020 15:07:34 +0000 (17:07 +0200)]
lib/time, time, time/tzdata: use slim tz data format

Follow-up for CL 261363 which had to retain the fat tz data format due
to failing test.

The reason for the failed tests was that when caching location data, the
extended time format past the end of zone transitions was not
considered. The respective change was introduced in (*Location).lookup
by CL 215539.

This slims down zoneinfo.zip (and thus also the embedded copy in
time/tzdata) by ~350KB.

Change-Id: I412f79de98ba45358b8696aca784999b3479135e
Reviewed-on: https://go-review.googlesource.com/c/go/+/261877
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agosyscall: remove stray TODO comment
Tobias Klauser [Tue, 13 Oct 2020 08:18:35 +0000 (10:18 +0200)]
syscall: remove stray TODO comment

This was addressed by CL 2816 and the same comment was deleted from
asm_linux_386.s.

Change-Id: Icc797993161d67e7c4f4cdb11c2b96ac88e00dd9
Reviewed-on: https://go-review.googlesource.com/c/go/+/261458
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: rename strlit, Bool, and Int64 *Node accessors
Alberto Donizetti [Mon, 12 Oct 2020 13:02:59 +0000 (15:02 +0200)]
cmd/compile: rename strlit, Bool, and Int64 *Node accessors

The Node type has shortcuts to access bool and int Values:

  func (n *Node) Int64() int64
    for n.Val().U.(*Mpint).Int64()

  func (n *Node) Bool() bool
    for n.Val().U.(bool)

I was convinced we didn't have one for string literal nodes, until I
noticed that we do, it's just called strlit, it's not a method, and
it's later in the file:

  func strlit(n *Node) string

This change, for consistency:
- Renames strlit to StringVal and makes it a *Node method
- Renames Bool and Int64 to BoolVal and Int64Val
- Moves StringVal near the other two

Change-Id: I18e635384c35eb3a238fd52b1ccd322b1a74d733
Reviewed-on: https://go-review.googlesource.com/c/go/+/261361
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agoruntime: implement GODEBUG=inittrace=1 support
Martin Möhrmann [Mon, 14 Sep 2020 14:55:34 +0000 (16:55 +0200)]
runtime: implement GODEBUG=inittrace=1 support

Setting inittrace=1 causes the runtime to emit a single line to standard error for
each package with init work, summarizing the execution time and memory allocation.

The emitted debug information for init functions can be used to find bottlenecks
or regressions in Go startup performance.

Packages with no init function work (user defined or compiler generated) are omitted.

Tracing plugin inits is not supported as they can execute concurrently. This would
make the implementation of tracing more complex while adding support for a very rare
use case. Plugin inits can be traced separately by testing a main package importing
the plugins package imports explicitly.

$ GODEBUG=inittrace=1 go test
init internal/bytealg @0.008 ms, 0 ms clock, 0 bytes, 0 allocs
init runtime @0.059 ms, 0.026 ms clock, 0 bytes, 0 allocs
init math @0.19 ms, 0.001 ms clock, 0 bytes, 0 allocs
init errors @0.22 ms, 0.004 ms clock, 0 bytes, 0 allocs
init strconv @0.24 ms, 0.002 ms clock, 32 bytes, 2 allocs
init sync @0.28 ms, 0.003 ms clock, 16 bytes, 1 allocs
init unicode @0.44 ms, 0.11 ms clock, 23328 bytes, 24 allocs
...

Inspired by stapelberg@google.com who instrumented doInit
in a prototype to measure init times with GDB.

Fixes #41378

Change-Id: Ic37c6a0cfc95488de9e737f5e346b8dbb39174e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/254659
Trust: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/link: support PIE internal linking on darwin/amd64
Cherry Zhang [Sun, 11 Oct 2020 19:48:22 +0000 (15:48 -0400)]
cmd/link: support PIE internal linking on darwin/amd64

This CL adds support of PIE internal linking on darwin/amd64.

This is also preparation for supporting internal linking on
darwin/arm64 (macOS), which requires PIE for everything.

Updates #38485.

Change-Id: I2ed58583dcc102f5e0521982491fc7ba6f2754ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/261642
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/internal/obj: remove LSym.RefIdx
Cherry Zhang [Tue, 13 Oct 2020 22:28:25 +0000 (18:28 -0400)]
cmd/internal/obj: remove LSym.RefIdx

LSym.RefIdx was for the old object files. I should have deleted
it when I deleted old object file code.

Change-Id: I8294f43a1e7ba45b1d75e84cc83cbaf2cb32f025
Reviewed-on: https://go-review.googlesource.com/c/go/+/262077
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
3 years agotest: add test that fails with gofrontend
Ian Lance Taylor [Tue, 13 Oct 2020 00:19:49 +0000 (17:19 -0700)]
test: add test that fails with gofrontend

The gofrontend code doesn't correctly handle inlining a function that
refers to a constant with methods.

For #35739

Change-Id: I6bd0b5cd4272dbe9969634b4821e668acacfdcf9
Reviewed-on: https://go-review.googlesource.com/c/go/+/261662
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agocmd/compile: fix and improve alias detection
Matthew Dempsky [Mon, 12 Oct 2020 21:02:36 +0000 (14:02 -0700)]
cmd/compile: fix and improve alias detection

"aliased" is the function responsible for detecting whether we can
turn "a, b = x, y" into just "a = x; b = y", or we need to pre-compute
y and save it in a temporary variable because it might depend on a.

It currently has two issues:

1. It suboptimally treats assignments to blank as writes to heap
   memory. Users generally won't write "_, b = x, y" directly, but it
   comes up a lot in generated code within the compiler.

   This CL changes it to ignore blank assignments.

2. When deciding whether the assigned variable might be referenced by
   pointers, it mistakenly checks Class() and Name.Addrtaken() on "n"
   (the *value* expression being assigned) rather than "a" (the
   destination expression).

   It doesn't appear to result in correctness issues (i.e.,
   incorrectly reporting no aliasing when there is potential aliasing),
   due to all the (overly conservative) rewrite passes before code
   reaches here. But it generates unnecessary code and could have
   correctness issues if we improve those other passes to be more
   aggressive.

   This CL fixes the misuse of "n" for "a" by renaming the variables
   to "r" and "l", respectively, to make their meaning clearer.

Improving these two cases shaves 4.6kB of text from cmd/go, and 93kB
from k8s.io/kubernetes/cmd/kubelet:

       text    data     bss     dec     hex filename
    9732136  290072  231552 10253760  9c75c0 go.before
    9727542  290072  231552 10249166  9c63ce go.after
    97977637 1007051  301344 99286032 5eafc10 kubelet.before
    97884549 1007051  301344 99192944 5e99070 kubelet.after

While here, this CL also collapses "memwrite" and "varwrite" into a
single variable. Logically, they're detecting the same thing: are we
assigning to a memory location that a pointer might alias. There's no
need for two variables.

Updates #6853.
Updates #23017.

Change-Id: I5a307b8e20bcd2196e85c55eb025d3f01e303008
Reviewed-on: https://go-review.googlesource.com/c/go/+/261677
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/go/internal/modfetch: remove error return from Lookup
Bryan C. Mills [Fri, 2 Oct 2020 20:25:17 +0000 (16:25 -0400)]
cmd/go/internal/modfetch: remove error return from Lookup

We generally don't care about errors in resolving a repo if the result
we're looking for is already in the module cache. Moreover, we can
avoid some expense in initializing the repo if all of the methods we
plan to call on it hit in the cache — especially when using
GOPROXY=direct.

This also incidentally fixes a possible (but rare) bug in Download:
we had forgotten to reset the downloaded file in case the Zip method
returned an error after writing a nonzero number of bytes.

For #37438

Change-Id: Ib64f10f763f6d1936536b8e1f7d31ed1b463e955
Reviewed-on: https://go-review.googlesource.com/c/go/+/259158
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/go: adjust ImportMissingError when module lookup is disabled
Bryan C. Mills [Tue, 29 Sep 2020 21:45:02 +0000 (17:45 -0400)]
cmd/go: adjust ImportMissingError when module lookup is disabled

Previously, ImportMissingError said
"cannot find module providing package …"
even when we didn't even attempt to find such a module.

Now, we write "no module requirement provides package …"
when we did not attempt to identify a suitable module,
and suggest either 'go mod tidy' or 'go get -d' as appropriate.

Fixes #41576

Change-Id: I979bb999da4066828c54d99a310ea66bb31032ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/258298
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agofmt: explain how Formatter interface affects verbs and flags
Bryan Boreham [Mon, 12 Oct 2020 14:29:28 +0000 (14:29 +0000)]
fmt: explain how Formatter interface affects verbs and flags

Formatter is mentioned further down, but it's helpful
to add it amongst the verbs and flags.

Background: I spent a while puzzling how "%+v" prints
a stack trace for github.com/pkg/errors when this isn't
documented under 'flags'.

Change-Id: Ic70145902a36780147dedca568b3cf482974fc38
GitHub-Last-Rev: 6571b499f211a2266812af66dd3b88dff602cabf
GitHub-Pull-Request: golang/go#39860
Reviewed-on: https://go-review.googlesource.com/c/go/+/240000
Reviewed-by: Rob Pike <r@golang.org>
Trust: Rob Pike <r@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>

3 years agoruntime: remove unused alg constants
Martin Möhrmann [Tue, 13 Oct 2020 06:26:36 +0000 (08:26 +0200)]
runtime: remove unused alg constants

CL 191198 removed algarray from the runtime
which used these constants as indices.

Change-Id: Ia669cf410372ef5113dadccd115a39ff8d47e5c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/261364
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Martin Möhrmann <moehrmann@google.com>

3 years agointernal/cpu: remove unused arm64 capabilities
Martin Möhrmann [Tue, 13 Oct 2020 06:32:41 +0000 (08:32 +0200)]
internal/cpu: remove unused arm64 capabilities

Change-Id: I038b0fe165931b8ec3ef59f08dc73c8128d56572
Reviewed-on: https://go-review.googlesource.com/c/go/+/261365
Trust: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agoio: add ErrBadWriteCount
Tao Qingyun [Tue, 13 Oct 2020 05:56:48 +0000 (05:56 +0000)]
io: add ErrBadWriteCount

Fixes #39978

Change-Id: Ib41459861ba9f7cf0bf1fc95b1479c358c4bdbd8
GitHub-Last-Rev: 19cbb1461ca04a8eb64f0c4f354d8fb81a70d4f3
GitHub-Pull-Request: golang/go#39989
Reviewed-on: https://go-review.googlesource.com/c/go/+/240740
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/go/internal/fsys: skip symlink test on Plan 9
Fazlul Shahriar [Tue, 13 Oct 2020 15:36:11 +0000 (11:36 -0400)]
cmd/go/internal/fsys: skip symlink test on Plan 9

Fixes #41950
Fixes #41954

Change-Id: I95d97f076fa928f3638309b78748d7ccc7277b14
Reviewed-on: https://go-review.googlesource.com/c/go/+/261897
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/link: update plt size appropriately on ppc64
Lynn Boger [Tue, 13 Oct 2020 13:15:52 +0000 (09:15 -0400)]
cmd/link: update plt size appropriately on ppc64

When attempting to enable internal linking with cgo on ppc64
it was discovered that the plt size was not being updated
after adding entries to it, which resulted in this error:

  .plt: initialize bounds (16 < 24)

This changes fixes that problem.

Updates #21961

Change-Id: Ie17539c329f5a4802e5defd93852dcdde19ded8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/261837
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agocmd/link: set runtime.text to the address of the first function
Cherry Zhang [Mon, 12 Oct 2020 22:00:25 +0000 (18:00 -0400)]
cmd/link: set runtime.text to the address of the first function

In CL 240065 we changed it to set to FlagTextAddr. Normally it
is the address of the first function, except on plan9/amd64
where, as FlagTextAddr is not aligned, it is rounded up. Set it
to the actual text start address.

Fixes #41137.

Change-Id: I1bba67f5eb4e24d9f745a11350fc999ff48bff45
Reviewed-on: https://go-review.googlesource.com/c/go/+/261644
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agolib/time, time/tzdata: update tz data to 2020b
Tobias Klauser [Mon, 12 Oct 2020 13:49:59 +0000 (15:49 +0200)]
lib/time, time/tzdata: update tz data to 2020b

Set ZFLAGS="-b fat" as the default was changed to '-b slim', see
http://mm.icann.org/pipermail/tz-announce/2020-October/000059.html
This will make sure that backwards-compatibibilty data is still emitted.

Updates #22487

Change-Id: I310a1b3a91e435673d1df41fbf8bb76abce1f94d
Reviewed-on: https://go-review.googlesource.com/c/go/+/261363
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agointernal/bytealg: fix typo in IndexRabinKarp{,Bytes} godoc
Tobias Klauser [Mon, 12 Oct 2020 09:19:41 +0000 (11:19 +0200)]
internal/bytealg: fix typo in IndexRabinKarp{,Bytes} godoc

Change-Id: I09ba19e19b195e345a0fe29d542e0d86529b0d31
Reviewed-on: https://go-review.googlesource.com/c/go/+/261359
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agogo/build: reject //go:build without // +build
Russ Cox [Fri, 22 May 2020 18:46:52 +0000 (14:46 -0400)]
go/build: reject //go:build without // +build

We are converting from using error-prone ad-hoc syntax // +build lines
to less error-prone, standard boolean syntax //go:build lines.
The timeline is:

Go 1.16: prepare for transition
 - Builds still use // +build for file selection.
 - Source files may not contain //go:build without // +build.
 - Builds fail when a source file contains //go:build lines without // +build lines. <<<

Go 1.17: start transition
 - Builds prefer //go:build for file selection, falling back to // +build
   for files containing only // +build.
 - Source files may contain //go:build without // +build (but they won't build with Go 1.16).
 - Gofmt moves //go:build and // +build lines to proper file locations.
 - Gofmt introduces //go:build lines into files with only // +build lines.
 - Go vet rejects files with mismatched //go:build and // +build lines.

Go 1.18: complete transition
 - Go fix removes // +build lines, leaving behind equivalent // +build lines.

This CL provides part of the <<< marked line above in the Go 1.16 step:
rejecting files containing //go:build but not // +build.

For #41184.

Change-Id: I29b8a789ab1526ab5057f613d5533bd2060ba9cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/240600
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/asm: reject misplaced go:build comments
Russ Cox [Mon, 29 Jun 2020 21:08:49 +0000 (17:08 -0400)]
cmd/asm: reject misplaced go:build comments

We are converting from using error-prone ad-hoc syntax // +build lines
to less error-prone, standard boolean syntax //go:build lines.
The timeline is:

Go 1.16: prepare for transition
 - Builds still use // +build for file selection.
 - Source files may not contain //go:build without // +build.
 - Builds fail when a source file contains //go:build lines without // +build lines. <<<

Go 1.17: start transition
 - Builds prefer //go:build for file selection, falling back to // +build
   for files containing only // +build.
 - Source files may contain //go:build without // +build (but they won't build with Go 1.16).
 - Gofmt moves //go:build and // +build lines to proper file locations.
 - Gofmt introduces //go:build lines into files with only // +build lines.
 - Go vet rejects files with mismatched //go:build and // +build lines.

Go 1.18: complete transition
 - Go fix removes // +build lines, leaving behind equivalent // +build lines.

This CL provides part of the <<< marked line above in the Go 1.16 step:
rejecting files containing //go:build but not // +build.

Reject any //go:build comments found after actual assembler code
(include #include etc directives), because the go command itself
doesn't read that far.

For #41184.

Change-Id: Ib460bfd380cce4239993980dd208afd07deff3f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/240602
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: reject misplaced go:build comments
Russ Cox [Fri, 22 May 2020 19:22:52 +0000 (15:22 -0400)]
cmd/compile: reject misplaced go:build comments

We are converting from using error-prone ad-hoc syntax // +build lines
to less error-prone, standard boolean syntax //go:build lines.
The timeline is:

Go 1.16: prepare for transition
 - Builds still use // +build for file selection.
 - Source files may not contain //go:build without // +build.
 - Builds fail when a source file contains //go:build lines without // +build lines. <<<

Go 1.17: start transition
 - Builds prefer //go:build for file selection, falling back to // +build
   for files containing only // +build.
 - Source files may contain //go:build without // +build (but they won't build with Go 1.16).
 - Gofmt moves //go:build and // +build lines to proper file locations.
 - Gofmt introduces //go:build lines into files with only // +build lines.
 - Go vet rejects files with mismatched //go:build and // +build lines.

Go 1.18: complete transition
 - Go fix removes // +build lines, leaving behind equivalent // +build lines.

This CL provides part of the <<< marked line above in the Go 1.16 step:
rejecting files containing //go:build but not // +build.
The standard go command checks only consider the top of the file.
This compiler check, along with a separate go vet check for ignored files,
handles the remainder of the file.

For #41184.

Change-Id: I014006eebfc84ab5943de18bc90449e534f150a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/240601
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agopath: avoid import of strings
Russ Cox [Tue, 14 Jul 2020 02:24:52 +0000 (22:24 -0400)]
path: avoid import of strings

Pushing path lower in the hierarchy, to allow path < io/fs < os
in the io/fs prototype. But this change is worth doing even if io/fs
is not accepted.

Change-Id: Id51b3a638167ca005dadfb9b730287e518ec12a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/243904
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
3 years agosyscall: remove dependency on io
Russ Cox [Sun, 5 Jul 2020 20:34:27 +0000 (16:34 -0400)]
syscall: remove dependency on io

Keep syscall and io separated; neither should depend on the other.

Change-Id: Icdd61bd0c05d874cabd7b5ae6631dd09dec90112
Reviewed-on: https://go-review.googlesource.com/c/go/+/243902
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
3 years agohash/crc32: fix race between lazy Castagnoli init and Update/Write
Russ Cox [Mon, 12 Oct 2020 19:41:14 +0000 (15:41 -0400)]
hash/crc32: fix race between lazy Castagnoli init and Update/Write

The switch on tab is checking tab == castagnoliTable,
but castagnoliTable can change value during a concurrent
call to MakeTable.

Fixes #41911.

Change-Id: I6124dcdbf33e17fe302baa3e1aa03202dec61b4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/261639
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: add generic optimization patterns for late-expanded calls.
David Chase [Thu, 13 Aug 2020 03:47:57 +0000 (23:47 -0400)]
cmd/compile: add generic optimization patterns for late-expanded calls.

Repeats existing patterns for old calls, so that these will apply
during the optimization phases that precede call expansion.

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

3 years agocmd/go: don't always link in cgo for PIE
Cherry Zhang [Sun, 11 Oct 2020 20:27:25 +0000 (16:27 -0400)]
cmd/go: don't always link in cgo for PIE

Internal linking for PIE is now supported and enabled by default
on some platforms, for which cgo is not needed. Don't always
bring in cgo.

Change-Id: I043ed436f0e6a3acbcc53ec543f06e193d614b36
Reviewed-on: https://go-review.googlesource.com/c/go/+/261498
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agotime: add ios build constraint to zoneinfo_ios.go
Tobias Klauser [Mon, 12 Oct 2020 13:47:39 +0000 (15:47 +0200)]
time: add ios build constraint to zoneinfo_ios.go

This allows to build the time package using a Go version which doesn't
know GOOS=ios yet.

Change-Id: Ib1b00687432f3309bac8fd8bf5c02b9c62f049a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/261362
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agonet/http/httputil: flush ReverseProxy immediately if Content-Length is -1
Ignacio Hagopian [Thu, 8 Oct 2020 20:32:50 +0000 (20:32 +0000)]
net/http/httputil: flush ReverseProxy immediately if Content-Length is -1

Finish up a prior TODO by making ReverseProxy flush immediately
if Content-Length is -1, which is a case that can occur if for
example we have a streamed response, or chunked encoding, or when
the body's length wasn't known.

Fixes #41642

Change-Id: I30babaaf3e14837b99e3ecdc562a0a0e50c579bf
GitHub-Last-Rev: efc019a9fe361082d40bee77317018c3b80451a3
GitHub-Pull-Request: golang/go#41858
Reviewed-on: https://go-review.googlesource.com/c/go/+/260637
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
3 years agocmd/link: remove residual darwin/386 code
Cherry Zhang [Mon, 12 Oct 2020 19:48:53 +0000 (15:48 -0400)]
cmd/link: remove residual darwin/386 code

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

3 years agocmd/go: support walking through overlay directories
Michael Matloob [Tue, 6 Oct 2020 17:16:46 +0000 (13:16 -0400)]
cmd/go: support walking through overlay directories

Change-Id: I7d9d75aa1dbc34fec5073ca36091c626b9dd4920
Reviewed-on: https://go-review.googlesource.com/c/go/+/261537
Trust: Michael Matloob <matloob@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/link: always mark runtime.buildVersion and runtime.modinfo reachable
Cherry Zhang [Mon, 12 Oct 2020 19:37:21 +0000 (15:37 -0400)]
cmd/link: always mark runtime.buildVersion and runtime.modinfo reachable

runtime.buildVersion and runtime.modinfo are referenced in the
.go.buildinfo section, therefore reachable. They should normally
be reachable from the runtime. Just make it explicit, in case.

Change-Id: I60ff3132e0bbb690f4a3cba8bb18735921fbe951
Reviewed-on: https://go-review.googlesource.com/c/go/+/261637
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/build: clean up ctxt.shouldBuild, tests
Russ Cox [Fri, 22 May 2020 18:40:50 +0000 (14:40 -0400)]
go/build: clean up ctxt.shouldBuild, tests

Make ctxt.shouldBuild return multiple values
instead of modifying *sawBinaryOnly in place.
Also give it a table-driven test.

Cleanup in preparation for boolean expressions,
but nice even if those don't end up happening.

Change-Id: Ibb78b0080070deafac7299a6de87ab8bebeb702d
Reviewed-on: https://go-review.googlesource.com/c/go/+/240598
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/fix: print warning to stderr, show provenance
Russ Cox [Mon, 29 Jun 2020 18:20:04 +0000 (14:20 -0400)]
cmd/fix: print warning to stderr, show provenance

This cgo warning shows up when running "go test" in cmd/fix:

warning: no cgo types: exit status 1

(It may show up at other times too.)

Warnings belong on standard error, and while we're here,
make it say where it came from.

Change-Id: I3eaba592a219cc6abf2d584762374f9d6ec5135e
Reviewed-on: https://go-review.googlesource.com/c/go/+/240597
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/fix: rename confusing boolean
Russ Cox [Mon, 29 Jun 2020 18:10:24 +0000 (14:10 -0400)]
cmd/fix: rename confusing boolean

("truth" says nothing about what is true.
This boolean tracks whether the file was fixed.)

Change-Id: I29bb80c4fad3ca7f2ae96e50e16f6cde484b374f
Reviewed-on: https://go-review.googlesource.com/c/go/+/240556
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/fix: always format source file before fixing
Russ Cox [Mon, 29 Jun 2020 14:44:56 +0000 (10:44 -0400)]
cmd/fix: always format source file before fixing

This makes the changes to the file easier to explain.
Not all the changes may come from the fixers directly,
if the file is not gofmt-ed already.

Change-Id: I81776da446a34a1239a3130317d2aae1437d61a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/240555
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/go: add IgnoredOtherFiles to go list; pass IgnoredFiles to vet
Russ Cox [Mon, 29 Jun 2020 14:39:30 +0000 (10:39 -0400)]
cmd/go: add IgnoredOtherFiles to go list; pass IgnoredFiles to vet

Show constraint-ignored non-.go files in go list, as Package.IgnoredOtherFiles
(same as go/build's IgnoredOtherFiles).

Pass full list of ignored files to vet, to help buildtag checker.

For #41184.

Change-Id: I749868de9082cbbc1efbc59370783c8c82fe735f
Reviewed-on: https://go-review.googlesource.com/c/go/+/240553
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/go: remove Package.constraintIgnoredGoFiles
Russ Cox [Mon, 29 Jun 2020 14:38:06 +0000 (10:38 -0400)]
cmd/go: remove Package.constraintIgnoredGoFiles

Now all of IgnoredGoFiles is constraint-ignored Go files.

Change-Id: I03001796c290708ab835526250c619dd667a8607
Reviewed-on: https://go-review.googlesource.com/c/go/+/240552
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agogo/build: add Package.IgnoredOtherFiles
Russ Cox [Mon, 29 Jun 2020 14:31:03 +0000 (10:31 -0400)]
go/build: add Package.IgnoredOtherFiles

Just like it is useful to report ignored .go files,
it is also useful to report ignored non-.go files.

Also, remove _* and .* files from IgnoredGoFiles.
The fact that they were there at all was a mistake.
This list is for files being ignored due to build constraints.

Change-Id: Ie08252dde9f56bda08647e7ebeab7906e9271c54
Reviewed-on: https://go-review.googlesource.com/c/go/+/240551
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/compile/internal/syntax: provide BadExpr where needed, call correct error handler
Robert Griesemer [Sat, 10 Oct 2020 00:42:41 +0000 (17:42 -0700)]
cmd/compile/internal/syntax: provide BadExpr where needed, call correct error handler

- For "if" statements without a condition, provide a BadExpr rather than nil
  (clients expect IfStmt.Cond != nil since the parser is taking care of
  reporting a missing condition).

- For 3-index slice expressions, also provide BadExpr where an index is
  required but missing.

- Declare a parser-local error method to hide the embedded error method
  so we don't use it by mistake.

Accidentally found while adjusting prototype parser to work for generics.

Change-Id: Iacc211cc60869be05efe9ae630d65dff1dac00a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/261218
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agocmd/go: disable automatic go vet -unreachable during go test of std
Russ Cox [Mon, 22 Jun 2020 18:45:35 +0000 (14:45 -0400)]
cmd/go: disable automatic go vet -unreachable during go test of std

go test runs a limited number of vet checks by default.
In the standard library, we run more, both to get additional checking
for the standard library and to get experience with whether to enable
any others by default.

One that experience has shown us should not be enabled by default
is go vet -unreachable. When you are testing, it is common to want to
put an early return or a panic into code to bypass a section of code.
That often causes unreachable code. It's incredibly frustrating if the
result is an "unreachable code" error that keeps your test from completing.

Change-Id: Ib194e87759eb65f5a193d771a9880b38d2fd3ba9
Reviewed-on: https://go-review.googlesource.com/c/go/+/240550
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/link: only dynamically export necessary symbols on darwin
Cherry Zhang [Sat, 10 Oct 2020 15:22:14 +0000 (11:22 -0400)]
cmd/link: only dynamically export necessary symbols on darwin

Currently on darwin, when a symbol needs to be exported, we
export it both statically and dynamically. The dynamic export is
unnecessary for some symbols. Only export the necessary ones.

For special runtime C symbols (e.g. crosscall2), they used to be
exported dynamically, and we had a special case for pclntab to
not include those symbols (otherwise, when the dynamic linker
dedup them, the pclntab entries end up pointing out of the
module's address space). This CL changes it to not export those
symbols, and remove the special case.

Change-Id: I2ab40630742d48a09b86ee150aa5f1f7002b134d
Reviewed-on: https://go-review.googlesource.com/c/go/+/261497
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agonet/http: deflake TestTransportPersistConnLeak on macOS
Russ Cox [Mon, 12 Oct 2020 15:56:15 +0000 (11:56 -0400)]
net/http: deflake TestTransportPersistConnLeak on macOS

On a loaded system, sometimes connections don't work out.
Ignore those in TestTransportPersistConnLeak to avoid flakes.

For #33585.

Change-Id: Ic07057532dc0ea5115d6ec49c3c29099a9382295
Reviewed-on: https://go-review.googlesource.com/c/go/+/261538
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Russ Cox <rsc@golang.org>

3 years agohash/maphash: adjust package comment
Russ Cox [Fri, 18 Sep 2020 16:30:10 +0000 (12:30 -0400)]
hash/maphash: adjust package comment

Add note about using per-use seeds.

Delete "collision-resistant but" in:
> The hash functions are collision-resistant but not cryptographically secure.

"Collision-resistant" has a precise cryptographic meaning that is
incompatible with "not cryptographically secure".
All that is really meant by it here here is "it's a good hash function",
which should be established already.

Also delete:
> The hash value of a given byte sequence is consistent within a
> single process, but will be different in different processes.

This was added for its final clause in response to #37040,
but "The hash value of a given byte sequence" is by design not a
concept in this package. Only "... of a given seed and byte sequence".
And seeds cannot be shared between processes, so again by design
you can't even set up the appropriate first half of the sentence
to say the second half.

Change-Id: I2c02bee0e804ef3b120cb4752bf89e60f3f5ff5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/255968
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agotext/template: allow newlines inside action delimiters
Russ Cox [Thu, 10 Sep 2020 22:53:26 +0000 (18:53 -0400)]
text/template: allow newlines inside action delimiters

This allows multiline constructs like:

{{"hello" |
  printf}}

Now that unclosed actions can span multiple lines,
track and report the start of the action when reporting errors.

Also clean up a few "unexpected <error message>" to be just "<error message>".

Fixes #29770.

Change-Id: I54c6c016029a8328b7902a4b6d85eab713ec3285
Reviewed-on: https://go-review.googlesource.com/c/go/+/254257
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
3 years agonet: remove dependency on math/rand
Russ Cox [Tue, 7 Jul 2020 13:07:16 +0000 (09:07 -0400)]
net: remove dependency on math/rand

Like we did for sync, let the runtime give net random numbers,
to avoid forcing an import of math/rand for DNS.

Change-Id: Iab3e64121d687d288a3961a8ccbcebe589047253
Reviewed-on: https://go-review.googlesource.com/c/go/+/241258
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: use Bool accessor in place of Val.U.(bool)
Alberto Donizetti [Mon, 12 Oct 2020 12:35:24 +0000 (14:35 +0200)]
cmd/compile: use Bool accessor in place of Val.U.(bool)

We have a Bool() accessor for the value in boolean nodes, that we use
elsewhere for n.Val().U.(bool), use it here too. Noticed while reading
the code.

Change-Id: Ie42e014970099a05fe9f02f378af77b63e7e6b13
Reviewed-on: https://go-review.googlesource.com/c/go/+/261360
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agossa: comment Sdom() with the form "Sdom..."
soolaugust [Mon, 12 Oct 2020 07:13:18 +0000 (07:13 +0000)]
ssa: comment Sdom() with the form "Sdom..."

Change-Id: I7ddb3d178e5437a7c3d8e94a089ac7a476a7dc85
GitHub-Last-Rev: bc27289128079f294ec149ccc4539ad29b859c9f
GitHub-Pull-Request: golang/go#41925
Reviewed-on: https://go-review.googlesource.com/c/go/+/261437
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agonet/http: deep copy Request.TransferEncoding
dqu123 [Sat, 10 Oct 2020 20:25:07 +0000 (16:25 -0400)]
net/http: deep copy Request.TransferEncoding

The existing implementation in Request.Clone() assigns the wrong
pointer to r2.TransferEncoding.

Fixes #41907

Change-Id: I7f220a41b1b46a55d1a1005e47c6dd69478cb025
Reviewed-on: https://go-review.googlesource.com/c/go/+/261258
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>

3 years agoos: call f.Close before t.Fatal to avoid vet unreachable code warnings
gzdaijie [Mon, 12 Oct 2020 05:39:16 +0000 (05:39 +0000)]
os: call f.Close before t.Fatal to avoid vet unreachable code warnings

Change-Id: Ic3f756ecf9b4fad8fb8c259e7dad6df894863b0e
GitHub-Last-Rev: 303e524029289fb4c0cb114dad7cb03c4fce9637
GitHub-Pull-Request: golang/go#41900
Reviewed-on: https://go-review.googlesource.com/c/go/+/261217
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>

3 years agocmd/compile/internal/gc: fix wrong function name in the comment
hk [Sun, 11 Oct 2020 03:44:09 +0000 (03:44 +0000)]
cmd/compile/internal/gc: fix wrong function name in the comment

Change-Id: I2fc5cff7495b5db4eb8f286a5335787241f1a850
GitHub-Last-Rev: 1d226f14c8edbcb189fd1a37b11a82b9642f19ab
GitHub-Pull-Request: golang/go#41917
Reviewed-on: https://go-review.googlesource.com/c/go/+/261317
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Robert Griesemer <gri@golang.org>

3 years agocmd/asm: Add SHA3 hardware instructions for ARM64
Meng Zhuo [Fri, 12 Jun 2020 16:06:49 +0000 (00:06 +0800)]
cmd/asm: Add SHA3 hardware instructions for ARM64

Armv8.2-SHA introduced four SHA3-related instructions

EOR3 <Vd>.16B, <Vn>.16B, <Vm>.16B, <Va>.16B
RAX1 <Vd>.2D, <Vn>.2D, <Vm>.2D
XAR <Vd>.2D, <Vn>.2D, <Vm>.2D, #<imm6>
BCAX <Vd>.16B, <Vn>.16B, <Vm>.16B, <Va>.16B

We convert them into Go asm style as:

VEOR3 <Va>.B16, <Vm>.B16, <Vn>.B16, <Vd>.B16
VRAX1 <Vm>.D2, <Vn>.D2, <Vd>.D2
VXAR $imm6, <Vm>.D2, <Vn>.D2, <Vd>.D2
VBCAX <Va>.B16, <Vm>.B16, <Vn>.B16, <Vd>.B16

Armv8 Reference Manual:
* EOR3 (Three-way Exclusive OR) on C7.2.42
* RAX1 (Rotate and Exclusive OR) on C7.2.217
* XAR (Exclusive OR and Rotate) on C7.2.401
* BCAX (Bit Clear and Exclusive OR) on C7.2.12

Change-Id: I9a5d1b5ad508ed8fd5289d535906c54d9a63ca5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/180757
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>

3 years agocmd/compile: remove NewPtr/NewSlice calls with untyped string
Cuong Manh Le [Fri, 9 Oct 2020 16:26:30 +0000 (23:26 +0700)]
cmd/compile: remove NewPtr/NewSlice calls with untyped string

This is follow up of CL 260699, NewPtr/NewSlice should not be called
with untyped string.

No significal change in performance.

name          old time/op       new time/op       delta
Template            167ms ± 5%        168ms ± 6%    ~     (p=0.549 n=9+10)
Unicode            73.9ms ±21%       69.5ms ± 5%    ~     (p=0.182 n=10+9)
GoTypes             611ms ± 4%        603ms ± 2%    ~     (p=0.356 n=10+9)
Compiler            3.07s ± 4%        3.05s ± 2%    ~     (p=0.356 n=9+10)
SSA                 7.61s ± 3%        7.49s ± 1%  -1.67%  (p=0.017 n=10+9)
Flate               114ms ±10%        110ms ±12%    ~     (p=0.165 n=10+10)
GoParser            148ms ±23%        138ms ±13%    ~     (p=0.436 n=9+9)
Reflect             377ms ± 9%        364ms ± 8%    ~     (p=0.105 n=10+10)
Tar                 149ms ±12%        151ms ±12%    ~     (p=0.315 n=10+10)
XML                 201ms ± 3%        206ms ± 8%    ~     (p=0.237 n=8+10)
LinkCompiler        308ms ± 3%        325ms ± 9%  +5.38%  (p=0.017 n=9+10)
[Geo mean]          352ms             348ms       -1.19%

Passes toolstash-check.

Change-Id: I1ca8e9635f1926e53e457bc06648fa08a5473bf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/260859
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agocmd/go: ignore retracted versions when converting revisions to versions
Jay Conrod [Fri, 9 Oct 2020 19:16:13 +0000 (15:16 -0400)]
cmd/go: ignore retracted versions when converting revisions to versions

When a module author retracts a version, the go command should act as
if it doesn't exist unless it's specifically requested.

When converting a revision to a version, we should ignore tags for
retracted versions. For example, if the tag v1.0.0 is retracted, and
branch B points to the same revision, we should convert B to a
pseudo-version, not v1.0.0. Similarly, if B points to a commit after
v1.0.0, we should not use v1.0.0 as the base; we can use an earlier
non-retracted tag or no base.

Fixes #41700

Change-Id: Ia596b05b0780e5acfe6616a04e94d24bd342fbae
Reviewed-on: https://go-review.googlesource.com/c/go/+/261079
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>

3 years agocmd/compile: drop SSA atomics TODO
Michael Pratt [Fri, 9 Oct 2020 16:44:07 +0000 (12:44 -0400)]
cmd/compile: drop SSA atomics TODO

These ops have been used for sync/atomic since golang.org/cl/28076.

Change-Id: Ic1445c073273f6b191b97018e8eb6f7ad9c48922
Reviewed-on: https://go-review.googlesource.com/c/go/+/261077
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/compile: late call expansion for rtcall
David Chase [Wed, 12 Aug 2020 19:46:19 +0000 (15:46 -0400)]
cmd/compile: late call expansion for rtcall

Change-Id: I0708c9d649d8a579857330b68d9fbcbbeced29e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/248189
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agocmd/compile: enable late expansion in openDeferExit
David Chase [Wed, 12 Aug 2020 16:58:07 +0000 (12:58 -0400)]
cmd/compile: enable late expansion in openDeferExit

Change-Id: I4ce9e914d22b519b00d7e19d93091f6ac0b60938
Reviewed-on: https://go-review.googlesource.com/c/go/+/248188
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agocmd/compile: enable late call lowering for "callDeferStack"
David Chase [Tue, 11 Aug 2020 16:52:01 +0000 (12:52 -0400)]
cmd/compile: enable late call lowering for "callDeferStack"

Change-Id: I773fce43d43f6e19180531e7bd1cc50bd8f31f75
Reviewed-on: https://go-review.googlesource.com/c/go/+/248187
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agocmd/compile: some minor cleanups
David Chase [Mon, 10 Aug 2020 17:33:15 +0000 (13:33 -0400)]
cmd/compile: some minor cleanups

Change-Id: Icdf3320814ad4a86a5ae532f4fcb899da3f46ae3
Reviewed-on: https://go-review.googlesource.com/c/go/+/248186
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agonet/http/pprof: remove html/template dependency
Egon Elbre [Wed, 23 Sep 2020 11:06:28 +0000 (14:06 +0300)]
net/http/pprof: remove html/template dependency

html/template indirectly uses reflect MethodByName, this causes linker
to use conservative mode resulting in larger binaries. The template here
is trivial and can be replaced by string manipulation.

This reduces a binary using only net/http/pprof by ~2.5MB.

Fixes #41569

Change-Id: I240e1daa6376182ff4961997ee3ec7b96cb07be8
Reviewed-on: https://go-review.googlesource.com/c/go/+/256900
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Hajime Hoshi <hajimehoshi@gmail.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>

3 years agodoc: update install docs for 387->softfloat transition
Keith Randall [Thu, 8 Oct 2020 15:42:11 +0000 (08:42 -0700)]
doc: update install docs for 387->softfloat transition

Fixes #41861

Change-Id: I7aa9370c7762986ee07ba6ff7f6ebda067559f06
Reviewed-on: https://go-review.googlesource.com/c/go/+/260757
Trust: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/compile: split exported/non-exported methods for interface type
Cuong Manh Le [Fri, 2 Oct 2020 18:23:47 +0000 (01:23 +0700)]
cmd/compile: split exported/non-exported methods for interface type

Currently, mhdr/methods is emitted with the same len/cap. There's no way
to distinguish between exported and non-exported methods statically.

This CL splits mhdr/methods into two parts, use "len" for number of
exported methods, and "cap" for all methods. This fixes the bug in
issue #22075, which intends to return the number of exported methods but
currently return all methods.

Note that with this encoding, we still can access either
all/exported-only/non-exported-only methods:

mhdr[:cap(mhdr)]          // all methods
mhdr                      // exported methods
mhdr[len(mhdr):cap(mhdr)] // non-exported methods

Thank to Matthew Dempsky (@mdempsky) for suggesting this encoding.

Fixes #22075

Change-Id: If662adb03ccff27407d55a5578a0ed05a15e7cdd
Reviewed-on: https://go-review.googlesource.com/c/go/+/259237
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agoall: enable more tests on macOS/ARM64
Cherry Zhang [Wed, 7 Oct 2020 22:29:51 +0000 (18:29 -0400)]
all: enable more tests on macOS/ARM64

On macOS, we can do "go build", can exec, and have the source
tree available, so we can enable more tests.

Skip ones that don't work. Most of them are due to that it
requires external linking (for now) and some tests don't work
with external linking (e.g. runtime deadlock detection). For
them, helper functions CanInternalLink/MustInternalLink are
introduced. I still want to have internal linking implemented,
but it is still a good idea to identify which tests don't work
with external linking.

Updates #38485.

Change-Id: I6b14697573cf3f371daf54b9ddd792acf232f2f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/260719
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agosyscall: support ptrace on macOS/ARM64
Cherry Zhang [Wed, 7 Oct 2020 22:26:26 +0000 (18:26 -0400)]
syscall: support ptrace on macOS/ARM64

Updates #38485.

Change-Id: I853966d934a8ee05cf62c7321f3e6271811d47b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/260718
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agosyscall: restore EscapeArg behavior for empty string
Ian Lance Taylor [Wed, 7 Oct 2020 18:15:01 +0000 (11:15 -0700)]
syscall: restore EscapeArg behavior for empty string

Accidentally broken by CL 259978.

For #41825

Change-Id: Id663514e6eefa325faccdb66493d0bb2b3281046
Reviewed-on: https://go-review.googlesource.com/c/go/+/260397
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agocmd/compile: fix incorrect comparison folding
Keith Randall [Thu, 8 Oct 2020 18:18:02 +0000 (11:18 -0700)]
cmd/compile: fix incorrect comparison folding

We lost a sign extension that was necessary. The nonnegative comparison
didn't have the correct extension on it. If the larger constant is
positive, but its shorter sign extension is negative, the rule breaks.

Fixes #41872

Change-Id: I6592ef103f840fbb786bf8cb94fd8804c760c976
Reviewed-on: https://go-review.googlesource.com/c/go/+/260701
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alberto Donizetti <alb.donizetti@gmail.com>
3 years agocmd/compile: rename types.IdealFoo to types.UntypedFoo
Cuong Manh Le [Thu, 8 Oct 2020 13:33:36 +0000 (20:33 +0700)]
cmd/compile: rename types.IdealFoo to types.UntypedFoo

To be consistent with go/types.

Passes toolstash-check.

Change-Id: I5e02f529064a904310a164f8765082aa533cc799
Reviewed-on: https://go-review.googlesource.com/c/go/+/260699
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agocmd/compile: use types.IdealFoo directly in predecl
Cuong Manh Le [Thu, 8 Oct 2020 12:51:57 +0000 (19:51 +0700)]
cmd/compile: use types.IdealFoo directly in predecl

Instead of using untype(Ctype) to get corresponding untyped type.

Passes toolstash-check.

Change-Id: I311fe6c94b1f8eb2e1615101a379cd06dcab835b
Reviewed-on: https://go-review.googlesource.com/c/go/+/260698
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agonet/http: make SameSiteDefaultMode behavior match the specification
Roberto Clapis [Tue, 22 Sep 2020 15:57:06 +0000 (17:57 +0200)]
net/http: make SameSiteDefaultMode behavior match the specification

The current specification does not foresee a SameSite attribute without
a value. While the existing implementation would serialize SameSite in a
way that would likely be ignored by well-impelemented clients, it is
better to not rely on this kind of quirks.

Specification: https://tools.ietf.org/html/draft-ietf-httpbis-rfc6265bis-05#section-4.1.1

Fixes #36990

Change-Id: Ie51152741d7e84bab64d3e4e4f780286932acbde
Reviewed-on: https://go-review.googlesource.com/c/go/+/256498
Trust: Roberto Clapis <roberto@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
3 years agocmd/cgo: add more architectures to size maps
Ian Lance Taylor [Wed, 7 Oct 2020 23:37:05 +0000 (16:37 -0700)]
cmd/cgo: add more architectures to size maps

This brings over the architectures that the gofrontend knows about.
This permits using the main cgo tool for those architectures,
as cgo can be used with -godefs without gc support.
This will help add golang.org/x/sys/unix support for other architectures.

For #37443

Change-Id: I63632b9c5139e71b9ccab8edcc7acdb464229b74
Reviewed-on: https://go-review.googlesource.com/c/go/+/260657
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/vendor,cmd/pprof: sync pprof@1a94d8640e99
Hana (Hyang-Ah) Kim [Fri, 14 Aug 2020 16:27:26 +0000 (12:27 -0400)]
cmd/vendor,cmd/pprof: sync pprof@1a94d8640e99

Updated cmd/pprof.objTool.Disasm to accept
an additional bool param introduced in
https://github.com/google/pprof/pull/520 to support
intel syntax in the assembly report.

Returns an error if the intelSyntax param is set. We use
src/cmd/internal/objfile to disassemble and print assembly
so I am not sure if it is relevant, and if so, how.

Fixes #38802
Updates #36905

Change-Id: Iae2b4322404f232196705f05210f00e2495588d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/248499
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agocmd/internal/obj/arm64: only emit R_CALLIND relocations on calls
Cherry Zhang [Wed, 7 Oct 2020 18:39:47 +0000 (14:39 -0400)]
cmd/internal/obj/arm64: only emit R_CALLIND relocations on calls

Don't emit it for jumps. In particular, not for the return
instruction, which is JMP (LR).

Reduce some binary size and linker resources.

Change-Id: Idb3242b86c5a137597fb8accb8aadfe0244c14cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/260341
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocrypto/x509: use macOS/AMD64 implementation on macOS/ARM64
Cherry Zhang [Wed, 7 Oct 2020 01:13:16 +0000 (21:13 -0400)]
crypto/x509: use macOS/AMD64 implementation on macOS/ARM64

Updates #38485.

Change-Id: I0582a53171ce803ca1b0237cfa9bc022fc1da6f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/260340
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agotime: enable system zoneinfo on macOS/ARM64
Cherry Zhang [Wed, 7 Oct 2020 00:36:52 +0000 (20:36 -0400)]
time: enable system zoneinfo on macOS/ARM64

Updates #38485.

Change-Id: I4a8b509dc4ad03706235289fbe8c2a675453c871
Reviewed-on: https://go-review.googlesource.com/c/go/+/260339
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agodoc/go1.16: document GO386=387 and GO386=softfloat
Dmitri Shuralyov [Wed, 7 Oct 2020 17:42:49 +0000 (13:42 -0400)]
doc/go1.16: document GO386=387 and GO386=softfloat

Also add a few more TODOs as found by the relnote command.
It's an incomplete list due to #41849.

For #40700.

Change-Id: Id17a9be86d3338e1fcb281d26e7298ff26e92864
Reviewed-on: https://go-review.googlesource.com/c/go/+/260337
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

3 years agonet/http/pprof: use Request.Context, not the deprecated CloseNotifier
Ayan George [Tue, 6 Oct 2020 18:40:40 +0000 (18:40 +0000)]
net/http/pprof: use Request.Context, not the deprecated CloseNotifier

Prior to this commit, the profiling code had a sleep() function that
waits and unblocks on either time.After() or a channel provided by an
http.CloseNotifier derived from a supplied http.ResponseWriter.

According to the documentation, http.CloseNotifier is deprecated:

  Deprecated: the CloseNotifier interface predates Go's context package.
  New code should use Request.Context instead.

This patch does just that -- sleep() now takes an *http.Request and uses
http.Request.Context() to signal when a request has been cancelled.

Change-Id: I98702314addf494f5743a4f99172dc607389dbb8
GitHub-Last-Rev: c1e37a03ca28417ed5833618d3eeddb2eecccd09
GitHub-Pull-Request: golang/go#41756
Reviewed-on: https://go-review.googlesource.com/c/go/+/259157
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agosyscall: rewrite Windows makeCmdLine to use []byte
Ian Lance Taylor [Tue, 6 Oct 2020 23:31:00 +0000 (16:31 -0700)]
syscall: rewrite Windows makeCmdLine to use []byte

It's faster to append to a []byte and only convert to string at the
end then it is to build up a string by concatenating characters.

Fixes #41825

Change-Id: I45ddf77dcc62726c919f0533c95d483cee8ba366
Reviewed-on: https://go-review.googlesource.com/c/go/+/259978
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
3 years agocmd/compile: store call args in the call block
Cherry Zhang [Wed, 7 Oct 2020 15:32:43 +0000 (11:32 -0400)]
cmd/compile: store call args in the call block

We already do this for OpStore, but we didn't do this for OpMove.
Do the same, to ensure that no two memories are live at the same
time.

Fixes #41846.

Change-Id: Iad77ff031b3c4459d1217e0b04aeb0e692eb474d
Reviewed-on: https://go-review.googlesource.com/c/go/+/260237
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
3 years agocmd/go: env -w validates GOTMPDIR value
Eugene Kalinin [Mon, 24 Aug 2020 22:49:39 +0000 (01:49 +0300)]
cmd/go: env -w validates GOTMPDIR value

This change makes go env -w check if GOTMPDIR is an absolute path.

If GOTMPDIR is not an absolute and not existing path there will be an
error at every `work.Builder.Init()`. If `go env` has `-u/-w` as
argument `work.Builder.Init()` is not called.

`go env -w GOTMPDIR=` work in the same way as `go env -u GOTMPDIR`.

Fixes #40932

Change-Id: I6b0662302eeace7f20460b6d26c6e59af1111da2
Reviewed-on: https://go-review.googlesource.com/c/go/+/250198
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>

3 years agoruntime: restore SSE guard in asyncPreempt on 386
Cherry Zhang [Wed, 7 Oct 2020 02:07:15 +0000 (22:07 -0400)]
runtime: restore SSE guard in asyncPreempt on 386

So we don't use SSE instructions under GO386=softfloat.

Change-Id: I8ecc92340ee567f84a22501df2543ec041d25ef2
Reviewed-on: https://go-review.googlesource.com/c/go/+/260137
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agointernal/reflectlite: include Kind in ValueError message
Ori Rawlings [Fri, 29 May 2020 03:41:38 +0000 (22:41 -0500)]
internal/reflectlite: include Kind in ValueError message

The implementation has been ported from reflect, but to avoid
introducing a dependency on strconv, Kind.String() falls back to
"invalid" if the Kind is unknown rather than "kind" + strconv.Itoa(int(k))

Fixes #39286

Change-Id: I82277242a6c41d0146dabd9d20339fe72d562500
Reviewed-on: https://go-review.googlesource.com/c/go/+/235522
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

3 years agocmd/link: support C-shared buildmode on macOS/ARM64
Cherry Zhang [Sun, 4 Oct 2020 03:58:29 +0000 (23:58 -0400)]
cmd/link: support C-shared buildmode on macOS/ARM64

It just works, after the plugin work.

Updates #38485.

Change-Id: I55aa11b380a33a729fccb731b77f48bc7d0dea2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/259443
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/link: support PIE on macOS/ARM64
Cherry Zhang [Sun, 4 Oct 2020 03:36:58 +0000 (23:36 -0400)]
cmd/link: support PIE on macOS/ARM64

On macOS/ARM64 everything must be PIE, and we already build PIE
in exe buildmode. Support PIE buildmode as well.

Updates #38485.

Change-Id: I10b68c2f6eb77714e31c26116c61a0e28bf9a358
Reviewed-on: https://go-review.googlesource.com/c/go/+/259442
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/link: support plugin on macOS/ARM64
Cherry Zhang [Sat, 3 Oct 2020 20:26:37 +0000 (16:26 -0400)]
cmd/link: support plugin on macOS/ARM64

Updates #38485.

Change-Id: I8295f7fad55b1f9701162f9d2902b3499137c64d
Reviewed-on: https://go-review.googlesource.com/c/go/+/259441
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agoruntime/cgo: only build xx_cgo_panicmem on iOS
Cherry Zhang [Sat, 3 Oct 2020 20:18:43 +0000 (16:18 -0400)]
runtime/cgo: only build xx_cgo_panicmem on iOS

On iOS, when running under lldb, we install xx_cgo_panicmem as
EXC_BAD_ACCESS handler so we can get a proper Go panic for
SIGSEGV. Only build it on iOS.

Updates #38485.

Change-Id: I801c477439e05920a4bb8fdf5eae6f4923ab8274
Reviewed-on: https://go-review.googlesource.com/c/go/+/259440
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agoall: implement GO386=softfloat
Keith Randall [Tue, 6 Oct 2020 21:42:15 +0000 (14:42 -0700)]
all: implement GO386=softfloat

Backstop support for non-sse2 chips now that 387 is gone.

RELNOTE=yes

Change-Id: Ib10e69c4a3654c15a03568f93393437e1939e013
Reviewed-on: https://go-review.googlesource.com/c/go/+/260017
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agonet/http: add Transport.GetProxyConnectHeader
Brad Fitzpatrick [Tue, 6 Oct 2020 17:53:11 +0000 (10:53 -0700)]
net/http: add Transport.GetProxyConnectHeader

Fixes golang/go#41048

Change-Id: I38e01605bffb6f85100c098051b0c416dd77f261
Reviewed-on: https://go-review.googlesource.com/c/go/+/259917
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
3 years agoall: enable more tests on macOS/ARM64
Cherry Zhang [Thu, 17 Sep 2020 19:02:26 +0000 (15:02 -0400)]
all: enable more tests on macOS/ARM64

Updates #38485.

Change-Id: Iac96f5ffe88521fcb11eab306d0df6463bdce046
Reviewed-on: https://go-review.googlesource.com/c/go/+/256920
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocmd/dist: enable more tests on macOS/ARM64
Cherry Zhang [Thu, 17 Sep 2020 16:39:43 +0000 (12:39 -0400)]
cmd/dist: enable more tests on macOS/ARM64

Unlike iOS, macOS ARM64 is more of a fully featured OS. Enable
more tests.

Updates #38485.

Change-Id: I2e2240c848d21996db2b950a4a6856987f7a652c
Reviewed-on: https://go-review.googlesource.com/c/go/+/256919
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agoruntime: enable more address bits on macOS/ARM64
Cherry Zhang [Thu, 17 Sep 2020 14:53:10 +0000 (10:53 -0400)]
runtime: enable more address bits on macOS/ARM64

Apparently macOS/ARM64 has 47-bit addresses, instead of 33-bit as
on ios/ARM64. Enable more address bits.

Updates #38485.

Change-Id: I8aa64ba22a3933e3d9c4fffd17d902b5f31c30e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/256918
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
3 years agoruntime: use sigaltstack on macOS/ARM64
Cherry Zhang [Sat, 12 Sep 2020 16:33:24 +0000 (12:33 -0400)]
runtime: use sigaltstack on macOS/ARM64

Currently we don't use sigaltstack on darwin/arm64, as is not
supported on iOS. However, it is supported on macOS. Use it.
(iOS remains unchanged.)

Change-Id: Icc154c5e2edf2dbdc8ca68741ad9157fc15a72ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/256917
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agocompress/flate: remove unneeded zeroing of bytes array in (*huffmanBitWriter).reset
Dan Scales [Wed, 30 Sep 2020 23:34:47 +0000 (16:34 -0700)]
compress/flate: remove unneeded zeroing of bytes array in (*huffmanBitWriter).reset

There is no correctness reason to zero out the w.bytes array in (w
*huffmanBitWriter).reset, since w.nbytes is correctly set to zero. The elements of
the bytes array are always written sequentially, with nbytes indicating how many
elements have been written, and are only read up to the current value of nybytes.

We have a pprof profile of a web server that compresses its request/responses, and
the zeroing in reset() is taking up 2.6% of the CPU time of the server (and could
be causing more slowdowns elsewhere due to its effects on the cache). This
overhead may be showing up especially because there are many request/responses
that are all fairly small.

I'm not sure if the zeroing of the bytes array was intended as extra protection of
data across reset uses in the same program, but no protection is needed as long as
the huffman_bit_writer code remains correct.

Change-Id: I67f2b2f56cff9dcc38d8fc0aea885bb010aeedbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/258577
Run-TryBot: Dan Scales <danscales@google.com>
Run-TryBot: Joe Tsai <joetsai@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Klaus Post <klauspost@gmail.com>
Reviewed-by: Joe Tsai <joetsai@google.com>
Trust: Joe Tsai <joetsai@google.com>
Trust: Dan Scales <danscales@google.com>

3 years agocmd/compile,cmd/internal/obj/ppc64: use mulli where possible
Lynn Boger [Fri, 2 Oct 2020 21:51:13 +0000 (17:51 -0400)]
cmd/compile,cmd/internal/obj/ppc64: use mulli where possible

This adds support to allow the use of mulli when one of the multiply
operands is a constant that fits in 16 bits.

This especially helps in the case where this instruction appears in
a loop since the load of the constant is not being moved out of the loop.

Some improvements seen in compress/flate on power9:

Decode/Digits/Huffman/1e4         259µs ± 0%     261µs ± 0%   +0.57%  (p=1.000 n=1+1)
Decode/Digits/Huffman/1e5        2.43ms ± 0%    2.45ms ± 0%   +0.79%  (p=1.000 n=1+1)
Decode/Digits/Huffman/1e6        23.9ms ± 0%    24.2ms ± 0%   +0.86%  (p=1.000 n=1+1)
Decode/Digits/Speed/1e4           278µs ± 0%     279µs ± 0%   +0.34%  (p=1.000 n=1+1)
Decode/Digits/Speed/1e5          2.80ms ± 0%    2.81ms ± 0%   +0.29%  (p=1.000 n=1+1)
Decode/Digits/Speed/1e6          28.0ms ± 0%    28.1ms ± 0%   +0.28%  (p=1.000 n=1+1)
Decode/Digits/Default/1e4         278µs ± 0%     278µs ± 0%   +0.28%  (p=1.000 n=1+1)
Decode/Digits/Default/1e5        2.68ms ± 0%    2.69ms ± 0%   +0.19%  (p=1.000 n=1+1)
Decode/Digits/Default/1e6        26.6ms ± 0%    26.6ms ± 0%   +0.21%  (p=1.000 n=1+1)
Decode/Digits/Compression/1e4     278µs ± 0%     278µs ± 0%   +0.00%  (p=1.000 n=1+1)
Decode/Digits/Compression/1e5    2.68ms ± 0%    2.69ms ± 0%   +0.21%  (p=1.000 n=1+1)
Decode/Digits/Compression/1e6    26.6ms ± 0%    26.6ms ± 0%   +0.07%  (p=1.000 n=1+1)
Decode/Newton/Huffman/1e4         322µs ± 0%     312µs ± 0%   -2.84%  (p=1.000 n=1+1)
Decode/Newton/Huffman/1e5        3.11ms ± 0%    2.91ms ± 0%   -6.41%  (p=1.000 n=1+1)
Decode/Newton/Huffman/1e6        31.4ms ± 0%    29.3ms ± 0%   -6.85%  (p=1.000 n=1+1)
Decode/Newton/Speed/1e4           282µs ± 0%     269µs ± 0%   -4.69%  (p=1.000 n=1+1)
Decode/Newton/Speed/1e5          2.29ms ± 0%    2.20ms ± 0%   -4.13%  (p=1.000 n=1+1)
Decode/Newton/Speed/1e6          22.7ms ± 0%    21.3ms ± 0%   -6.06%  (p=1.000 n=1+1)
Decode/Newton/Default/1e4         254µs ± 0%     237µs ± 0%   -6.60%  (p=1.000 n=1+1)
Decode/Newton/Default/1e5        1.86ms ± 0%    1.75ms ± 0%   -5.99%  (p=1.000 n=1+1)
Decode/Newton/Default/1e6        18.1ms ± 0%    17.4ms ± 0%   -4.10%  (p=1.000 n=1+1)
Decode/Newton/Compression/1e4     254µs ± 0%     244µs ± 0%   -3.91%  (p=1.000 n=1+1)
Decode/Newton/Compression/1e5    1.85ms ± 0%    1.79ms ± 0%   -3.10%  (p=1.000 n=1+1)
Decode/Newton/Compression/1e6    18.0ms ± 0%    17.3ms ± 0%   -3.88%  (p=1.000 n=1+1)

Change-Id: I840320fab1c4bf64c76b001c2651ab79f23df4eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/259444
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@gmail.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>

3 years agocmd/go/internal/get: improve -insecure deprecation docs
witchard [Fri, 25 Sep 2020 14:09:42 +0000 (14:09 +0000)]
cmd/go/internal/get: improve -insecure deprecation docs

Updates #37519

Change-Id: I212607f1839b729d7da24b1258e56997b13ad830
GitHub-Last-Rev: db6d3c835bdf867a0b18f115276210e3a05902ed
GitHub-Pull-Request: golang/go#41613
Reviewed-on: https://go-review.googlesource.com/c/go/+/257157
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/go: add basic support for overlays
Michael Matloob [Tue, 11 Aug 2020 16:57:01 +0000 (12:57 -0400)]
cmd/go: add basic support for overlays

This CL adds basic support for listing packages with overlays.
The new cmd/go/internal/fs package adds an abstraction for communicating
with the file system that will open files according to their overlaid paths,
and provides functions to override those in the build context to open
overlaid files. There is also some support for executing builds on packages
with overlays. In cmd/go/internal/work.(*Builder).build, paths are mapped
to their overlaid paths before they are given as arguments to tools.

For #39958

Change-Id: I5ec0eb9ebbca303e2f1e7dbe22ec32613bc1fd17
Reviewed-on: https://go-review.googlesource.com/c/go/+/253747
Trust: Michael Matloob <matloob@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/compile: correct leaf type when "selecting" singleton register-sized struct
David Chase [Fri, 2 Oct 2020 18:53:48 +0000 (14:53 -0400)]
cmd/compile: correct leaf type when "selecting" singleton register-sized struct

Two part fix:
1) bring the type "correction" forward from a later CL in the expand calls series
2) when a leaf-selwect is rewritten in place, update the type (it might have been
   changed by the type correction in 1).

Fixes #41736.

Change-Id: Id097efd10481bf0ad92aaead81a7207221c144b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/259203
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agocrypto/tls: fix typo in spelling of permanentError
Luca Spiller [Tue, 6 Oct 2020 08:12:45 +0000 (08:12 +0000)]
crypto/tls: fix typo in spelling of permanentError

Change-Id: I819c121ff388460ec348af773ef94b44416a2ea9
GitHub-Last-Rev: 98dd8fb25cecb73e88d107e0a35e3e63a53dfd09
GitHub-Pull-Request: golang/go#41785
Reviewed-on: https://go-review.googlesource.com/c/go/+/259517
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>

3 years agodoc: fix typo in contribute.html
Alberto Donizetti [Thu, 1 Oct 2020 12:00:48 +0000 (14:00 +0200)]
doc: fix typo in contribute.html

Change-Id: Ica27c4a9e4c364d94250aebfc4c2b59cff7f4a8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/258679
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
3 years agocmd/compile: avoid applying ARM CMP->CMN rewrite in unsigned context
David Chase [Mon, 5 Oct 2020 16:07:00 +0000 (12:07 -0400)]
cmd/compile: avoid applying ARM CMP->CMN rewrite in unsigned context

Fixes #41780.

Change-Id: I1dc7c19a9f057650905da3a96214c2ff4abb51be
Reviewed-on: https://go-review.googlesource.com/c/go/+/259450
Trust: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
3 years agoreflect: support multiple keys in struct tags
Alexey Vilenskiy [Fri, 14 Aug 2020 08:37:31 +0000 (11:37 +0300)]
reflect: support multiple keys in struct tags

Fixes #40281

Change-Id: Ie624bce3a78a06d7ed71bba1f501e66802dffd13
Reviewed-on: https://go-review.googlesource.com/c/go/+/248341
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>