]> Cypherpunks repositories - gostls13.git/log
gostls13.git
4 years agoruntime: access the assist ratio atomically
Michael Anthony Knyszek [Thu, 23 Jul 2020 20:48:06 +0000 (20:48 +0000)]
runtime: access the assist ratio atomically

This change makes it so that the GC assist ratio (the pair of
gcControllerState fields assistBytesPerWork and assistWorkPerByte) is
updated atomically. Note that the pair of fields are not updated
together atomically, but that's OK. The code here was already racy for
some time and in practice the assist ratio moves very slowly.

The purpose of this change is so that we can document
gcController.revise to be safe for concurrent use, which will be useful
in further changes.

Change-Id: Ie25d630207c88e4f85f2b8953f6a0051ebf1b4ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/246963
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 years agoruntime: make next_gc atomically accessed
Michael Anthony Knyszek [Thu, 23 Jul 2020 20:24:56 +0000 (20:24 +0000)]
runtime: make next_gc atomically accessed

next_gc is mostly updated only during a STW, but may occasionally be
updated by calls to e.g. debug.SetGCPercent. In this case the update is
supposed to be protected by the heap lock, but in reality it's accessed
by gcController.revise which may be called without the heap lock held
(despite its documentation, which will be updated in a later change).

Change the synchronization policy on next_gc so that it's atomically
accessed when the world is not stopped to aid in making revise safe for
concurrent use.

Change-Id: I79657a72f91563f3241aaeda66e8a7757d399529
Reviewed-on: https://go-review.googlesource.com/c/go/+/246962
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 years agoruntime: load gcControllerState.scanWork atomically in revise
Michael Anthony Knyszek [Thu, 23 Jul 2020 20:17:40 +0000 (20:17 +0000)]
runtime: load gcControllerState.scanWork atomically in revise

gcControllerState.scanWork's docs state that it must be accessed
atomically during a GC cycle, but gcControllerState.revise does not do
this (even when called with the heap lock held).

This change makes it so that gcControllerState.revise accesses scanWork
atomically and explicitly.

Note that we don't update gcControllerState.revise's erroneous doc
comment here because this change isn't about revise's guarantees, just
about heap_scan. The comment is updated in a later change.

Change-Id: Iafc3ad214e517190bfd8a219896d23da19f7659d
Reviewed-on: https://go-review.googlesource.com/c/go/+/246961
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 years agoruntime: define and enforce synchronization on heap_scan
Michael Anthony Knyszek [Thu, 23 Jul 2020 20:13:49 +0000 (20:13 +0000)]
runtime: define and enforce synchronization on heap_scan

Currently heap_scan is mostly protected by the heap lock, but
gcControllerState.revise sometimes accesses it without a lock. In an
effort to make gcControllerState.revise callable from more contexts (and
have its synchronization guarantees actually respected), make heap_scan
atomically read from and written to, unless the world is stopped.

Note that we don't update gcControllerState.revise's erroneous doc
comment here because this change isn't about revise's guarantees, just
about heap_scan. The comment is updated in a later change.

Change-Id: Iddbbeb954767c704c2bd1d221f36e6c4fc9948a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/246960
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 years agocmd/go/internal/fsys: rewrite non-idiomatic if statements
Russ Cox [Fri, 23 Oct 2020 00:55:38 +0000 (20:55 -0400)]
cmd/go/internal/fsys: rewrite non-idiomatic if statements

https://golang.org/doc/effective_go.html#if

Change-Id: I4d868e05c7827638f45b3b06d8762f5a298d56f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/264537
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>
Reviewed-by: Michael Matloob <matloob@golang.org>
4 years agoruntime: fix sub-uintptr-sized Windows callback arguments
Austin Clements [Sat, 17 Oct 2020 22:42:03 +0000 (18:42 -0400)]
runtime: fix sub-uintptr-sized Windows callback arguments

The Windows callback support accepts Go functions with arguments that
are uintptr-sized or smaller. However, it doesn't implement smaller
arguments correctly. It assumes the Windows arguments layout is
equivalent to the Go argument layout. This is often true, but because
Windows C ABIs pad arguments to word size, while Go packs arguments,
the layout is different if there are multiple sub-word-size arguments
in a row. For example, a function with two uint16 arguments will have
a two-word C argument frame, but only a 4 byte Go argument frame.
There are also subtleties surrounding floating-point register
arguments that it doesn't handle correctly.

To fix this, when constructing a callback, we examine the Go
function's signature to construct a mapping between the C argument
frame and the Go argument frame. When the callback is invoked, we use
this mapping to build the Go argument frame and copy the result back.

This adds several test cases to TestStdcallAndCDeclCallbacks that
exercise more complex function signatures. These all fail with the
current code, but work with this CL.

In addition to fixing these callback types, this is also a step toward
the Go register ABI (#40724), which is going to make the ABI
translation more complex.

Change-Id: I19fb1681b659d9fd528ffd5e88912bebb95da052
Reviewed-on: https://go-review.googlesource.com/c/go/+/263271
Trust: Austin Clements <austin@google.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
4 years agoruntime: tidy Windows callback test
Austin Clements [Sat, 17 Oct 2020 02:22:20 +0000 (22:22 -0400)]
runtime: tidy Windows callback test

This simplifies the systematic test of Windows callbacks with
different signatures and prepares it for expanded coverage of function
signatures.

It now returns a result from the Go function and threads it back
through C. This simplifies things, but also previously the code could
have succeeded by simply not calling the callbacks at all (though
other tests would have caught that).

It bundles together the C function description and the Go function
it's intended to call. Now the test source generation and the test
running both loop over a single slice of test functions.

Since the C function and Go function are now bundled, it generates the
C function by reflectively inspecting the signature of the Go
function. For the moment, we keep the same test suite, which is
entirely functions with "uintptr" arguments, but we'll expand this
shortly.

It now use sub-tests. This way tests automatically get useful
diagnostic labels in failures and the tests don't have to catch panics
on their own.

It eliminates the DLL function argument. I honestly couldn't figure
out what the point of this was, and it added what appeared to be an
unnecessary loop level to the tests.

Change-Id: I120dfd4785057cc2c392bd2c821302f276bd128e
Reviewed-on: https://go-review.googlesource.com/c/go/+/263270
Trust: Austin Clements <austin@google.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
4 years agoruntime: tidy compileCallback
Austin Clements [Sat, 3 Oct 2020 23:52:08 +0000 (19:52 -0400)]
runtime: tidy compileCallback

This makes a few minor cleanups and simplifications to compileCallback.

Change-Id: Ibebf4b5ed66fb68bba7c84129c127cd4d8a691fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/263269
Trust: Austin Clements <austin@google.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
4 years agoruntime: tidy cgocallback
Austin Clements [Thu, 8 Oct 2020 02:53:52 +0000 (22:53 -0400)]
runtime: tidy cgocallback

On amd64 and 386, we have a very roundabout way of remembering that we
need to dropm on return that currently involves saving a zero to
needm's argument slot and later bringing it back. Just store the zero.

This also makes amd64 and 386 more consistent with cgocallback on all
other platforms: rather than saving the old M to the G stack, they now
save it to a named slot on the G0 stack.

The needm function no longer needs a dummy argument to get the SP, so
we drop that.

Change-Id: I7e84bb4a5ff9552de70dcf41d8accf02310535e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/263268
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime,cmd/cgo: simplify C -> Go call path
Austin Clements [Thu, 1 Oct 2020 21:22:38 +0000 (17:22 -0400)]
runtime,cmd/cgo: simplify C -> Go call path

This redesigns the way calls work from C to exported Go functions. It
removes several steps from the call path, makes cmd/cgo no longer
sensitive to the Go calling convention, and eliminates the use of
reflectcall from cgo.

In order to avoid generating a large amount of FFI glue between the C
and Go ABIs, the cgo tool has long depended on generating a C function
that marshals the arguments into a struct, and then the actual ABI
switch happens in functions with fixed signatures that simply take a
pointer to this struct. In a way, this CL simply pushes this idea
further.

Currently, the cgo tool generates this argument struct in the exact
layout of the Go stack frame and depends on reflectcall to unpack it
into the appropriate Go call (even though it's actually
reflectcall'ing a function generated by cgo).

In this CL, we decouple this struct from the Go stack layout. Instead,
cgo generates a Go function that takes the struct, unpacks it, and
calls the exported function. Since this generated function has a
generic signature (like the rest of the call path), we don't need
reflectcall and can instead depend on the Go compiler itself to
implement the call to the exported Go function.

One complication is that syscall.NewCallback on Windows, which
converts a Go function into a C function pointer, depends on
cgocallback's current dynamic calling approach since the signatures of
the callbacks aren't known statically. For this specific case, we
continue to depend on reflectcall. Really, the current approach makes
some overly simplistic assumptions about translating the C ABI to the
Go ABI. Now we're at least in a much better position to do a proper
ABI translation.

For comparison, the current cgo call path looks like:

    GoF (generated C function) ->
    crosscall2 (in cgo/asm_*.s) ->
    _cgoexp_GoF (generated Go function) ->
    cgocallback (in asm_*.s) ->
    cgocallback_gofunc (in asm_*.s) ->
    cgocallbackg (in cgocall.go) ->
    cgocallbackg1 (in cgocall.go) ->
    reflectcall (in asm_*.s) ->
    _cgoexpwrap_GoF (generated Go function) ->
    p.GoF

Now the call path looks like:

    GoF (generated C function) ->
    crosscall2 (in cgo/asm_*.s) ->
    cgocallback (in asm_*.s) ->
    cgocallbackg (in cgocall.go) ->
    cgocallbackg1 (in cgocall.go) ->
    _cgoexp_GoF (generated Go function) ->
    p.GoF

Notably:

1. We combine _cgoexp_GoF and _cgoexpwrap_GoF and move the combined
operation to the end of the sequence. This combined function also
handles reflectcall's previous role.

2. We combined cgocallback and cgocallback_gofunc since the only
purpose of having both was to convert a raw PC into a Go function
value. We instead construct the Go function value in cgocallbackg1.

3. cgocallbackg1 no longer reaches backwards through the stack to get
the arguments to cgocallback_gofunc. Instead, we just pass the
arguments down.

4. Currently, we need an explicit msanwrite to mark the results struct
as written because reflectcall doesn't do this. Now, the results are
written by regular Go assignments, so the Go compiler generates the
necessary MSAN annotations. This also means we no longer need to track
the size of the arguments frame.

Updates #40724, since now we don't need to teach cgo about the
register ABI or change how it uses reflectcall.

Change-Id: I7840489a2597962aeb670e0c1798a16a7359c94f
Reviewed-on: https://go-review.googlesource.com/c/go/+/258938
Trust: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/link: preserve alignment for stackmap symbols
Cherry Zhang [Sat, 24 Oct 2020 17:05:31 +0000 (13:05 -0400)]
cmd/link: preserve alignment for stackmap symbols

Stackmap symbols are content-addressable, so it may be dedup'd
with another symbol with same content. We want stackmap symbols
4-byte aligned. But if it dedup's with another symbol with larger
alignment, preserve that alignment.

Fixes #42071.

Change-Id: I1616dd2b0c175b2aac8f68782a5c7a62053c0b57
Reviewed-on: https://go-review.googlesource.com/c/go/+/264897
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agonet: prefer /etc/hosts over DNS when no /etc/nsswitch.conf is present
Natanael Copa [Fri, 16 Oct 2020 16:23:54 +0000 (16:23 +0000)]
net: prefer /etc/hosts over DNS when no /etc/nsswitch.conf is present

Do not mimic glibc behavior if /etc/nsswitch.conf is missing. This will
will likely be missing on musl libc systems and glibc systems will likely
always have it, resulting in localhost lookup being done over DNS rather
than from /etc/hosts.

Do what makes most sense rather than making any assumption about the
libc.

Fixes #35305

Change-Id: I20bd7e24131bba8eaa39a20c8950fe552364784d
GitHub-Last-Rev: 119409839d37c8c7268f5f6db19c1789d9d96074
GitHub-Pull-Request: golang/go#39685
Reviewed-on: https://go-review.googlesource.com/c/go/+/238629
Run-TryBot: Dan Peterson <dpiddy@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Peterson <dpiddy@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emmanuel@orijtech.com>

4 years agopath/filepath: allow EvalSymlinks to work on UNC share roots on Windows
Kevin Parsons [Tue, 20 Oct 2020 15:15:23 +0000 (15:15 +0000)]
path/filepath: allow EvalSymlinks to work on UNC share roots on Windows

Fixes #42079

Previously, EvalSymlinks returned an error when called with the root of
a UNC share (e.g. \\server\share). This was due to Windows's
FindFirstFile function not supporting a share root path.

To resolve this, now return early from toNorm in the case where the path
after the volume name is empty. Skipping the later path component
resolution shouldn't have any negative impact in this case, as if the
path is empty, there aren't any path components to resolve anyways.

The test case uses the localhost admin share (c$), as it should be
present in most situations. This allows testing without setting up an
external file share. However, this fix applies to all UNC share root
paths.

Change-Id: I05035bd86be93662d7bea34fab4b75fc8e918206
GitHub-Last-Rev: bd3db2cda65aae1cdf8d94b03bc7197dff68dc44
GitHub-Pull-Request: golang/go#42096
Reviewed-on: https://go-review.googlesource.com/c/go/+/263917
Trust: Alex Brainman <alex.brainman@gmail.com>
Trust: Giovanni Bajo <rasky@develer.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
4 years agolog/syslog: set local to true if network is any of "unix", or "unixgram"
imxyb [Sun, 25 Oct 2020 03:42:20 +0000 (03:42 +0000)]
log/syslog: set local to true if network is any of "unix", or "unixgram"

Fixes #41960

Change-Id: I0e0f0e11610dd2658a8f6b7e345a4aae2c19c85d
GitHub-Last-Rev: 8cac718e4854773ca411116043b4b832e0468f09
GitHub-Pull-Request: golang/go#42135
Reviewed-on: https://go-review.googlesource.com/c/go/+/264297
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>

4 years agocmd/dist: document why test fails on incomplete ports
Tobias Klauser [Sat, 24 Oct 2020 18:21:48 +0000 (20:21 +0200)]
cmd/dist: document why test fails on incomplete ports

It might not be obvious from reading the code why we consider the test
as failed on incomplete ports even though it passed. Add a comment
documenting this behavior, as suggested by Dmitri in CL 155839.

Change-Id: I3eb7db27d01d63db277172381e5fa51577dad941
Reviewed-on: https://go-review.googlesource.com/c/go/+/264682
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years agolib/time, time/tzdata: update tz data to 2020d
Tobias Klauser [Sat, 24 Oct 2020 18:14:33 +0000 (20:14 +0200)]
lib/time, time/tzdata: update tz data to 2020d

See http://mm.icann.org/pipermail/tz-announce/2020-October/000060.html
and http://mm.icann.org/pipermail/tz-announce/2020-October/000062.html
for a description of the changes.

Updates #22487

Change-Id: I4b2717d2d642284889345a0125eb6c614575c0ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/264681
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>
4 years agocmd/dist: add openbsd/mips64 as incomplete port
Joel Sing [Tue, 25 Aug 2020 07:52:46 +0000 (17:52 +1000)]
cmd/dist: add openbsd/mips64 as incomplete port

Update #40995

Change-Id: Id497f7688b00658b50feb7338157e0411b861910
Reviewed-on: https://go-review.googlesource.com/c/go/+/250578
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
4 years agocmd/compile: enforce strongly typed rules for ARM (read)
Constantin Konstantinidis [Thu, 24 Sep 2020 16:54:58 +0000 (18:54 +0200)]
cmd/compile: enforce strongly typed rules for ARM (read)

Add type casting to offset.
L246-L247
L1473-L1475

toolstash-check successful.

Change-Id: I816c7556609ca6dd67bff8007c2d006cab89ee2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/257639
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

4 years agocmd/internal/obj/riscv: support additional register to register moves
Joel Sing [Fri, 23 Oct 2020 16:53:53 +0000 (03:53 +1100)]
cmd/internal/obj/riscv: support additional register to register moves

Add support for signed and unsigned register to register moves of various
sizes. This makes it easier to handle zero and sign extension and will allow
for further changes that improve the compiler optimisations for riscv64.

While here, change the existing register to register moves from obj.Prog
rewriting to instruction generation.

Change-Id: Id21911019b76922367a134da13c3449a84a1fb08
Reviewed-on: https://go-review.googlesource.com/c/go/+/264657
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agodebug/dwarf: add support for DWARFv5 to (*Data).Ranges
Alessandro Arzilli [Thu, 4 Jun 2020 14:59:06 +0000 (16:59 +0200)]
debug/dwarf: add support for DWARFv5 to (*Data).Ranges

Updates the (*Data).Ranges method to work with DWARFv5 which uses the
new debug_rnglists section instead of debug_ranges.

This does not include supporting DW_FORM_rnglistx.

General support for DWARFv5 was added by CL 175138.

Change-Id: I01f919a865616a3ff12f5bf649c2c9abf89fcf52
Reviewed-on: https://go-review.googlesource.com/c/go/+/236657
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>

4 years agoruntime: dump the status of lockedg on error
Tiwei Bie [Thu, 15 Oct 2020 01:43:51 +0000 (01:43 +0000)]
runtime: dump the status of lockedg on error

The dumpgstatus() will dump current g's status anyway. When lockedg's
status is bad, it's more helpful to dump lockedg's status as well than
dumping current g's status twice.

Change-Id: If5248cb94b9cdcbf4ceea07562237e1d6ee28489
GitHub-Last-Rev: da814c51ff42f56fb28582f088f4d72b500061fe
GitHub-Pull-Request: golang/go#40248
Reviewed-on: https://go-review.googlesource.com/c/go/+/243097
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agosyscall: disable TestAllThreadsSyscall on linux-ppc64
Andrew G. Morgan [Fri, 23 Oct 2020 23:33:38 +0000 (16:33 -0700)]
syscall: disable TestAllThreadsSyscall on linux-ppc64

For some reason, currently unknown, this test case fails exclusively
on the linux-ppc64 platform. Until such time as it can be made to
work, we'll disable this test case on that platform.

The same issue causes TestSetuidEtc to fail too, so disable that
on this platform.

Updates #42178

Change-Id: Idd3f6c2ee9f2fba2eb8ce4de69de7f316858bb15
Reviewed-on: https://go-review.googlesource.com/c/go/+/264719
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agonet/http: fix typo in TestTransportReadToEndReusesConn
Keiichi Hirobe [Wed, 5 Aug 2020 16:57:11 +0000 (01:57 +0900)]
net/http: fix typo in TestTransportReadToEndReusesConn

The test sets a Content-Type where it looks like it wants a Content-Length. The test passes because the Content-Length header is automatically added anyway, but fix the typo and set Content-Length as intended.

Change-Id: Ic2af778f82c3e9d58e164892f6ac6ef5745f884f
Reviewed-on: https://go-review.googlesource.com/c/go/+/246977
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocrypto/x509: deprecate legacy PEM encryption
Filippo Valsorda [Thu, 22 Oct 2020 16:00:20 +0000 (18:00 +0200)]
crypto/x509: deprecate legacy PEM encryption

It's unfortunate that we don't implement PKCS#8 encryption (#8860)
so we can't recommend an alternative but PEM encryption is so broken
that it's worth deprecating outright.

Fixes #41949
Fixes #32777

Change-Id: Ieb46444662adec108d0de3550b693a50545c2344
Reviewed-on: https://go-review.googlesource.com/c/go/+/264159
Trust: Filippo Valsorda <filippo@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
4 years agocrypto/tls: add no-shared to openssl build instructions
Thom Wiggers [Tue, 29 Sep 2020 09:34:08 +0000 (09:34 +0000)]
crypto/tls: add no-shared to openssl build instructions

This prevents the custom-built version of openssl prefering the system
libraries over the ones compiled with the specified (weak crypto)
options necessary to generate the updates. This difference can lead to
confusing failures when updating the tests.

Fixes #31809

Change-Id: I2dd257f3121d6c6c62c6aeba52e1c74046b3c584
GitHub-Last-Rev: 6d4eeafadf0b4671b7e17c6810f1a66a9fda7d3c
GitHub-Pull-Request: golang/go#41630
Reviewed-on: https://go-review.googlesource.com/c/go/+/257517
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
4 years agoruntime: add tests for addrRanges.add
Michael Anthony Knyszek [Tue, 14 Jul 2020 21:41:12 +0000 (21:41 +0000)]
runtime: add tests for addrRanges.add

Change-Id: I249deb482df74068b0538e9d773b9a87bc5a6df3
Reviewed-on: https://go-review.googlesource.com/c/go/+/242681
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 years agoruntime: throw on zero-sized range passed to addrRanges.add
Michael Anthony Knyszek [Wed, 15 Jul 2020 18:56:39 +0000 (18:56 +0000)]
runtime: throw on zero-sized range passed to addrRanges.add

addrRanges represents a set of addresses. Currently, passing in a
zero-sized range will cause that range to be added to the list, even
though it doesn't represent any address (addrRanges.contains will still
always return false, and findSucc will give surprising results).

We could ignore this input, but it's almost always a bug for the calling
code to pass in a zero-sized range, so just throw.

Change-Id: I8ed09e15b79a3a33e2d0cf5ed55f9e497388e7a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/242817
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agoruntime: add tests for addrRanges.findSucc
Michael Anthony Knyszek [Tue, 14 Jul 2020 21:39:52 +0000 (21:39 +0000)]
runtime: add tests for addrRanges.findSucc

This change adds a test suite for addrRanges.findSucc so we can change
the implementation more safely.

For #40191.

Change-Id: I14a834b6d54836cbc676eb0edb292ba6176705cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/242678
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
4 years agolog: expose std via new Default function
Colin Arnott [Thu, 22 Oct 2020 22:16:01 +0000 (22:16 +0000)]
log: expose std via new Default function

To allow passing around the package level *Logger, it is now exposed to
callers of the Default function. We considered exposing std, however at
this time there is no need to allow callers to replace std only pass and
call methods directly.

Fixes #39057

Change-Id: I710b16a3aa5e4e878870561dbf59560f98d8d09a
Reviewed-on: https://go-review.googlesource.com/c/go/+/264460
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

4 years agoall: fix quoting for compress/bzip2 and time's godoc
subham sarkar [Wed, 14 Oct 2020 18:54:14 +0000 (00:24 +0530)]
all: fix quoting for compress/bzip2 and time's godoc

The existing usage of grave accent (`) and apostrophe (')
at some places made godoc to ignore them and show it as it is.
So, use both of the characters twice (consecutively) so that
godoc can convert it to {left,right} double quotation mark.

Fixes #41958

Change-Id: I64fd9b5fa34f416ad595009d09f5482e10bd8b4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/262397
Reviewed-by: Russ Cox <rsc@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

4 years agoruntime: drop redundant gcBlackenEnabled reset
Michael Pratt [Tue, 7 Jul 2020 21:55:40 +0000 (17:55 -0400)]
runtime: drop redundant gcBlackenEnabled reset

This reset of gcBlackenEnabled is a no-op because it was already reset
almost immediately before in gcMarkDone, which is the only caller of
gcMarkTermination.

Adjust the comment to clarify setGCPhase a bit more. We are coming from
_GCmark, so write barriers are already enabled.

Change-Id: Ieac2dadf33c3c5a44e8a25a499dea8cfe03b8d73
Reviewed-on: https://go-review.googlesource.com/c/go/+/241357
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agocmd/go: change error message for missing import with unused replacement
Jay Conrod [Fri, 16 Oct 2020 18:02:16 +0000 (14:02 -0400)]
cmd/go: change error message for missing import with unused replacement

In readonly mode, if a package is not provided by any module in the
build list, and there is an unused replacement that contains the
package, we now recommend a 'go get' command to add a requirement on
the highest replaced version.

Fixes #41416

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

4 years agocmd/go: save sums for zips needed to diagnose ambiguous imports
Jay Conrod [Thu, 15 Oct 2020 22:22:09 +0000 (18:22 -0400)]
cmd/go: save sums for zips needed to diagnose ambiguous imports

Previously, we would retain entries in go.sum for .mod files in the
module graph (reachable from the main module) and for .zip files
of modules providing packages.

This isn't quite enough: when we load a package, we need the content
of each module in the build list that *could* provide the package
(that is, each module whose path is a prefix of the package's path) so
we can diagnose ambiguous imports.

For #33008

Change-Id: I0b4d9d68c1f4ca382f0983a3a7e537764f35c3aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/262781
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>

4 years agocmd/go: don't fetch files missing sums in readonly mode
Jay Conrod [Tue, 13 Oct 2020 22:19:21 +0000 (18:19 -0400)]
cmd/go: don't fetch files missing sums in readonly mode

If the go command needs a .mod or .zip file in -mod=readonly mode
(now the default), and that file doesn't have a hash in the main
module's go.sum file, the go command will now report an error before
fetching the file, rather than at the end when failing to update
go.sum. The error says specifically which entry is missing.

If this error is encountered when loading the build list, it will
suggest 'go mod tidy'.

If this error is encountered when loading a specific package (an
import or command line argument), the error will mention that package
and will suggest 'go mod tidy' or 'go get -d'.

Fixes #41934
Fixes #41935

Change-Id: I96ec2ef9258bd4bade9915c43d47e6243c376a81
Reviewed-on: https://go-review.googlesource.com/c/go/+/262341
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>

4 years agocmd/go: in 'go mod init', suggest running 'go mod tidy'
Jay Conrod [Fri, 23 Oct 2020 15:10:10 +0000 (11:10 -0400)]
cmd/go: in 'go mod init', suggest running 'go mod tidy'

When 'go mod init' is run in an existing project, it may import
requirements from a vendor configuration file, but the requirements
may not be complete, and go.sum won't contain sums for module
zips. With -mod=readonly, the next build command is likely to fail.

'go mod init' will now suggest running 'go mod tidy' if there are .go
files or subdirectories in the current directory.

We could potentially run 'go mod tidy' automatically within
'go mod init', but it seems better to guide users to using 'go mod tidy'
as a separate command to fix missing dependencies.

For #41712
Updates #40278

Change-Id: Iaece607f291244588a732ef4c5d576108965ca91
Reviewed-on: https://go-review.googlesource.com/c/go/+/264622
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: refactor modload.InitMod
Jay Conrod [Thu, 22 Oct 2020 22:20:00 +0000 (18:20 -0400)]
cmd/go: refactor modload.InitMod

InitMod is split into two functions. LoadModFile parses an existing
go.mod file and loads the build list (or checks vendor/modules.txt for
consistency in vendor mode). CreateModFile creates a new go.mod file,
possibly inferring the module path and importing a vendor
configuration file.

Some logic is moved from runInit to CreateModFile. init-specific logic
is removed from other functions.

This CL shouldn't cause substantial differences in behavior, though
some error messages are slightly different.

For #41712

Change-Id: Ia684945cfcf5beca30bbb81e7144fc246c4f27ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/264621
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: don't import requirements into existing go.mod files
Jay Conrod [Thu, 22 Oct 2020 22:26:14 +0000 (18:26 -0400)]
cmd/go: don't import requirements into existing go.mod files

Previously, if a go.mod file was present, and it only contained a
module directive, any module-aware command would attempt to import
requirements from a vendor configuration file like Gopkg.lock.

This CL removes that functionality. It was undocumented and untested,
and it can cause problems with -mod=readonly. It should never come up
for go.mod files created with 'go mod init', since they have a "go"
directive.

For #40278

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

4 years agosyscall: support POSIX semantics for Linux syscalls
Andrew G. Morgan [Tue, 10 Dec 2019 05:50:16 +0000 (21:50 -0800)]
syscall: support POSIX semantics for Linux syscalls

This change adds two new methods for invoking system calls
under Linux: syscall.AllThreadsSyscall() and
syscall.AllThreadsSyscall6().

These system call wrappers ensure that all OSThreads mirror
a common system call. The wrappers serialize execution of the
runtime to ensure no race conditions where any Go code observes
a non-atomic OS state change. As such, the syscalls have
higher runtime overhead than regular system calls, and only
need to be used where such thread (or 'm' in the parlance
of the runtime sources) consistency is required.

The new support is used to enable these functions under Linux:

  syscall.Setegid(), syscall.Seteuid(), syscall.Setgroups(),
  syscall.Setgid(), syscall.Setregid(), syscall.Setreuid(),
  syscall.Setresgid(), syscall.Setresuid() and syscall.Setuid().

They work identically to their glibc counterparts.

Extensive discussion of the background issue addressed in this
patch can be found here:

   https://github.com/golang/go/issues/1435

In the case where cgo is used, the C runtime can launch pthreads that
are not managed by the Go runtime. As such, the added
syscall.AllThreadsSyscall*() return ENOTSUP when cgo is enabled.
However, for the 9 syscall.Set*() functions listed above, when cgo is
active, these functions redirect to invoke their C.set*() equivalents
in glibc, which wraps the raw system calls with a nptl:setxid fixup
mechanism. This achieves POSIX semantics for these functions in the
combined Go and C runtime.

As a side note, the glibc/nptl:setxid support (2019-11-30) does not
extend to all security related system calls under Linux so using
native Go (CGO_ENABLED=0) and these AllThreadsSyscall*()s, where
needed, will yield more well defined/consistent behavior over all
threads of a Go program. That is, using the
syscall.AllThreadsSyscall*() wrappers for things like setting state
through SYS_PRCTL and SYS_CAPSET etc.

Fixes #1435

Change-Id: Ib1a3e16b9180f64223196a32fc0f9dce14d9105c
Reviewed-on: https://go-review.googlesource.com/c/go/+/210639
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Trust: Ian Lance Taylor <iant@golang.org>
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/go: break after terminal loop condition
Mark Rushakoff [Thu, 8 Oct 2020 02:12:43 +0000 (02:12 +0000)]
cmd/go: break after terminal loop condition

After the first time needCostly is set to true, there is no need to
continue checking the remaining args.

Change-Id: I07171ce50d20e2a917117a0f84c442fe978cb274
GitHub-Last-Rev: 6d0c19341b7a85d507c3ec4967bab5f83b0fad8d
GitHub-Pull-Request: golang/go#41859
Reviewed-on: https://go-review.googlesource.com/c/go/+/260638
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agosync: document that Once must not be copied
Dmitri Shuralyov [Fri, 23 Oct 2020 03:46:19 +0000 (03:46 +0000)]
sync: document that Once must not be copied

Fixes #42160.

Change-Id: I9bf8b6f0bf1eccd3ab32cbd94c812f768746d291
Reviewed-on: https://go-review.googlesource.com/c/go/+/264557
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/go: replace some more stats with fsys.Stat
Michael Matloob [Thu, 22 Oct 2020 22:06:54 +0000 (18:06 -0400)]
cmd/go: replace some more stats with fsys.Stat

To support overlays

For #39958

Change-Id: I5ffd72aeb7f5f30f6c60f6334a01a0a1383c7945
Reviewed-on: https://go-review.googlesource.com/c/go/+/264478
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/compile: avoid generating CSEs; do all aggregates; maintain debug names
David Chase [Mon, 17 Aug 2020 20:57:22 +0000 (16:57 -0400)]
cmd/compile: avoid generating CSEs; do all aggregates; maintain debug names

This adds a pass to detect common selection operations,
to avoid generating duplicates.  Duplicate offsets are
also detected.

All aggregate types are now handled; there is some freedom in where
expand_calls is run, though it must run before softfloat.

Debug-name-maintenance is now incremental both in decompose builtin
and in expand_calls; it might be good to push this into all the
decompose passes.

(this is a smash of 5 CLs that rewrote some of the same code several
times to deal with phase-ordering problems, and included an abandoned
attempt.)

For #40724.

Change-Id: I2a0c32f20660bf8b99e2bcecd33545d97d2bd3c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/249458
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>
4 years agoruntime: rename pageAlloc receiver
Michael Pratt [Tue, 25 Aug 2020 16:34:02 +0000 (12:34 -0400)]
runtime: rename pageAlloc receiver

The history of pageAlloc using 's' as a receiver are lost to the depths
of time (perhaps it used to be called summary?), but it doesn't make
much sense anymore. Rename it to 'p'.

Generated with:

$ cd src/runtime
$ grep -R -b "func (s \*pageAlloc" . | awk -F : '{ print $1 ":#" $2+6 }' | xargs -n 1 -I {} env GOROOT=$(pwd)/../../ gorename -offset {} -to p -v
$ grep -R -b "func (s \*pageAlloc" . | awk -F : '{ print $1 ":#" $2+6 }' | xargs -n 1 -I {} env GOROOT=$(pwd)/../../ GOARCH=386 gorename -offset {} -to p -v
$ GOROOT=$(pwd)/../../ gorename -offset mpagecache.go:#2397 -to p -v

($2+6 to advance past "func (".)

Plus manual comment fixups.

Change-Id: I2d521a1cbf6ebe2ef6aae92e654bfc33c63d1aa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/250517
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agocmd/compile: intrinsify runtime/internal/atomic.{And,Or} on MIPS
Michael Pratt [Fri, 16 Oct 2020 20:49:56 +0000 (16:49 -0400)]
cmd/compile: intrinsify runtime/internal/atomic.{And,Or} on MIPS

This one is trivial, as there are already 32-bit AND and OR ops used to
implement the more complex 8-bit versions.

Change-Id: Ic48a53ea291d0067ebeab8e96c82e054daf20ae7
Reviewed-on: https://go-review.googlesource.com/c/go/+/263149
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime: drop unused work.ndone field
Michael Pratt [Thu, 9 Jul 2020 20:20:48 +0000 (16:20 -0400)]
runtime: drop unused work.ndone field

This field is unused since golang.org/cl/134785 and thus can be
trivially removed.

Change-Id: I1a87f8e78ffdf662440409404f0251c40bc56a4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/241741
Trust: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
4 years agocmd/link: use xcode strip for macho combine dwarf
Meng Zhuo [Fri, 16 Oct 2020 01:19:00 +0000 (09:19 +0800)]
cmd/link: use xcode strip for macho combine dwarf

The GNU strip will shrink text section while xcodetool strip don't.
We have to use xcodetool strip from system explicitly.

Fixes #41967

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

4 years agointernal/bytealg: improve mips64x equal on large size
Meng Zhuo [Thu, 22 Oct 2020 06:03:11 +0000 (14:03 +0800)]
internal/bytealg: improve mips64x equal on large size

name               old time/op    new time/op    delta
Equal/0              9.94ns ± 4%    9.12ns ± 5%     -8.26%  (p=0.000 n=10+10)
Equal/1              24.5ns ± 0%    27.2ns ± 1%    +11.22%  (p=0.000 n=9+10)
Equal/6              28.1ns ± 0%    32.1ns ± 1%    +14.20%  (p=0.000 n=8+10)
Equal/9              37.1ns ± 0%    37.8ns ± 1%     +1.95%  (p=0.000 n=8+9)
Equal/15             47.3ns ± 0%    44.3ns ± 0%     -6.34%  (p=0.000 n=9+10)
Equal/16             42.9ns ± 0%    24.6ns ± 0%    -42.66%  (p=0.000 n=10+7)
Equal/20             44.3ns ± 0%    57.4ns ± 0%    +29.57%  (p=0.000 n=9+10)
Equal/32             63.2ns ± 0%    35.8ns ± 0%    -43.35%  (p=0.000 n=10+10)
Equal/4K             6.49µs ± 0%    0.50µs ± 0%    -92.27%  (p=0.000 n=10+8)
Equal/4M             6.70ms ± 0%    0.48ms ± 0%    -92.78%  (p=0.000 n=8+10)
Equal/64M             110ms ± 0%       8ms ± 0%    -92.65%  (p=0.000 n=9+9)
CompareBytesEqual    36.6ns ± 0%    35.9ns ± 0%     -1.83%  (p=0.000 n=10+9)

name               old speed      new speed      delta
Equal/1            40.8MB/s ± 0%  36.7MB/s ± 0%    -10.16%  (p=0.000 n=10+10)
Equal/6             213MB/s ± 0%   187MB/s ± 1%    -12.32%  (p=0.000 n=10+10)
Equal/9             243MB/s ± 0%   238MB/s ± 1%     -1.94%  (p=0.000 n=9+10)
Equal/15            317MB/s ± 0%   339MB/s ± 0%     +6.86%  (p=0.000 n=9+9)
Equal/16            373MB/s ± 0%   651MB/s ± 0%    +74.70%  (p=0.000 n=8+10)
Equal/20            452MB/s ± 0%   348MB/s ± 0%    -22.90%  (p=0.000 n=8+10)
Equal/32            506MB/s ± 0%   893MB/s ± 0%    +76.53%  (p=0.000 n=10+9)
Equal/4K            631MB/s ± 0%  8166MB/s ± 0%  +1194.73%  (p=0.000 n=10+10)
Equal/4M            626MB/s ± 0%  8673MB/s ± 0%  +1284.94%  (p=0.000 n=8+10)
Equal/64M           608MB/s ± 0%  8277MB/s ± 0%  +1260.83%  (p=0.000 n=9+9)

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

4 years agocmd/compile: intrinsify runtime/internal/atomic.{And,Or} on S390X
Michael Pratt [Fri, 16 Oct 2020 21:29:00 +0000 (17:29 -0400)]
cmd/compile: intrinsify runtime/internal/atomic.{And,Or} on S390X

This is a simplification of LANfloor/LAOfloor since we have a whole
word.

Change-Id: I791641fb4068cad3f73660ce51699ed4653ae0e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/263151
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: intrinsify runtime/internal/atomic.{And,Or} on PPC64
Michael Pratt [Fri, 16 Oct 2020 21:07:14 +0000 (17:07 -0400)]
cmd/compile: intrinsify runtime/internal/atomic.{And,Or} on PPC64

This is a simple case of changing the operand size of the existing 8-bit
And/Or.

I've also updated a few operand descriptions that were out-of-sync with
the implementation.

Change-Id: I95ac4445d08f7958768aec9a233698a2d652a39a
Reviewed-on: https://go-review.googlesource.com/c/go/+/263150
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: intrinsify runtime/internal/atomic.{And,Or} on ARM64
Michael Pratt [Fri, 16 Oct 2020 20:34:52 +0000 (16:34 -0400)]
cmd/compile: intrinsify runtime/internal/atomic.{And,Or} on ARM64

These are identical to And8 and Or8, just using LDAXRW/STLXRW instead of
LDAXRB/STLXRB.

Change-Id: I5308832ae165064550bee4bb245809ab952f4cc8
Reviewed-on: https://go-review.googlesource.com/c/go/+/263148
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoio/fs, path, path/filepath, testing/fstest: validate patterns in Match, Glob
Russ Cox [Thu, 22 Oct 2020 16:11:29 +0000 (12:11 -0400)]
io/fs, path, path/filepath, testing/fstest: validate patterns in Match, Glob

According to #28614, proposal review agreed in December 2018 that
Match should return an error for failed matches where the unmatched
part of the pattern has a syntax error. (The failed match has to date
caused the scan of the pattern to stop early.)

This change implements that behavior: the match loop continues
scanning to the end of the pattern, even after a confirmed mismatch,
to check whether the pattern is even well-formed.

The change applies to both path.Match and filepath.Match.
Then filepath.Glob and fs.Glob make a single validity-checking
call to Match before beginning their usual processing.

Also update fstest.TestFS to check for correct validation in custom
Glob implementations.

Fixes #28614.

Change-Id: Ic1d35a4bb9c3565184ae83dbefc425c5c96318e7
Reviewed-on: https://go-review.googlesource.com/c/go/+/264397
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agoruntime: don't attempt to steal from idle Ps
Michael Pratt [Thu, 1 Oct 2020 19:21:37 +0000 (15:21 -0400)]
runtime: don't attempt to steal from idle Ps

Work stealing is a scalability bottleneck in the scheduler. Since each P
has a work queue, work stealing must look at every P to determine if
there is any work. The number of Ps scales linearly with GOMAXPROCS
(i.e., the number of Ps _is_ GOMAXPROCS), thus this work scales linearly
with GOMAXPROCS.

Work stealing is a later attempt by a P to find work before it goes
idle. Since the P has no work of its own, extra costs here tend not to
directly affect application-level benchmarks. Where they show up is
extra CPU usage by the process as a whole. These costs get particularly
expensive for applications that transition between blocked and running
frequently.

Long term, we need a more scalable approach in general, but for now we
can make a simple observation: idle Ps ([1]) cannot possibly have
anything in their runq, so we need not bother checking at all.

We track idle Ps via a new global bitmap, updated in pidleput/pidleget.
This is already a slow path (requires sched.lock), so we don't expect
high contention there.

Using a single bitmap avoids the need to touch every P to read p.status.
Currently, the bitmap approach is not significantly better than reading
p.status. However, in a future CL I'd like to apply a similiar
optimization to timers. Once done, findrunnable would not touch most Ps
at all (in mostly idle programs), which will avoid memory latency to
pull those Ps into cache.

When reading this bitmap, we are racing with Ps going in and out of
idle, so there are a few cases to consider:

1. _Prunning -> _Pidle: Running P goes idle after we check the bitmap.
In this case, we will try to steal (and find nothing) so there is no
harm.

2. _Pidle -> _Prunning while spinning: A P that starts running may queue
new work that we miss. This is OK: (a) that P cannot go back to sleep
without completing its work, and (b) more fundamentally, we will recheck
after we drop our P.

3. _Pidle -> _Prunning after spinning: After spinning, we really can
miss work from a newly woken P. (a) above still applies here as well,
but this is also the same delicate dance case described in findrunnable:
if nothing is spinning anymore, the other P will unpark a thread to run
the work it submits.

Benchmark results from WakeupParallel/syscall/pair/race/1ms (see
golang.org/cl/228577):

name                            old msec          new msec   delta
Perf-task-clock-8               250 ± 1%          247 ± 4%     ~     (p=0.690 n=5+5)
Perf-task-clock-16              258 ± 2%          259 ± 2%     ~     (p=0.841 n=5+5)
Perf-task-clock-32              284 ± 2%          270 ± 4%   -4.94%  (p=0.032 n=5+5)
Perf-task-clock-64              326 ± 3%          303 ± 2%   -6.92%  (p=0.008 n=5+5)
Perf-task-clock-128             407 ± 2%          363 ± 5%  -10.69%  (p=0.008 n=5+5)
Perf-task-clock-256             561 ± 1%          481 ± 1%  -14.20%  (p=0.016 n=4+5)
Perf-task-clock-512             840 ± 5%          683 ± 2%  -18.70%  (p=0.008 n=5+5)
Perf-task-clock-1024          1.38k ±14%        1.07k ± 2%  -21.85%  (p=0.008 n=5+5)

[1] "Idle Ps" here refers to _Pidle Ps in the sched.pidle list. In other
contexts, Ps may temporarily transition through _Pidle (e.g., in
handoffp); those Ps may have work.

Updates #28808
Updates #18237

Change-Id: Ieeb958bd72e7d8fb375b0b1f414e8d7378b14e29
Reviewed-on: https://go-review.googlesource.com/c/go/+/259578
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Trust: Michael Pratt <mpratt@google.com>

4 years agocmd/compile: intrinsify runtime/internal/atomic.{And,Or} on AMD64
Michael Pratt [Fri, 9 Oct 2020 16:41:50 +0000 (12:41 -0400)]
cmd/compile: intrinsify runtime/internal/atomic.{And,Or} on AMD64

These are identical to And8 and Or8, just using ANDL/ORL instead of
ANDB/ORB.

Change-Id: I99cf90a8b0b5f211fb23325dddd55821875f0c8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/263140
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoruntime/internal/atomic: add 32-bit And/Or
Michael Pratt [Thu, 8 Oct 2020 18:38:39 +0000 (14:38 -0400)]
runtime/internal/atomic: add 32-bit And/Or

These will be used in a following CL to perform larger bit clear and bit
set than And8/Or8.

Change-Id: I60f7b1099e29b69eb64add77564faee862880a8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/260977
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Michael Pratt <mpratt@google.com>

4 years agostrconv: add eiselLemire32
Nigel Tao [Thu, 22 Oct 2020 23:41:50 +0000 (10:41 +1100)]
strconv: add eiselLemire32

This does for ParseFloat(etc, 32) what commit a2eb53c571 did for
ParseFloat(etc, 64).

name              old time/op  new time/op  delta
Atof32Decimal-4   48.3ns ± 4%  48.8ns ± 2%     ~     (p=0.548 n=5+5)
Atof32Float-4     56.2ns ± 5%  54.7ns ± 3%     ~     (p=0.246 n=5+5)
Atof32FloatExp-4   104ns ± 0%    76ns ± 2%  -27.19%  (p=0.008 n=5+5)
Atof32Random-4     142ns ± 2%   109ns ± 1%  -23.07%  (p=0.008 n=5+5)

Change-Id: I6ee5a2f2d791d4fe3028f1d40aca96400120fda0
Reviewed-on: https://go-review.googlesource.com/c/go/+/264517
Trust: Nigel Tao <nigeltao@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/compile: add //go:embed support
Russ Cox [Sun, 19 Jul 2020 04:32:02 +0000 (00:32 -0400)]
cmd/compile: add //go:embed support

This commit contains the compiler support for //go:embed lines.
The go command passes to the compiler an "embed config"
that maps literal patterns like *.txt to the set of files to embed.
The compiler then lays out the content of those files as static data
in the form of an embed.Files or string or []byte in the final object file.

The test for this code is the end-to-end test hooking up the
embed, cmd/compile, and cmd/go changes, in the next CL.

For #41191.

Change-Id: I916e57f8cc65871dc0044c13d3f90c252a3fe1bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/243944
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoembed: implement FS
Russ Cox [Sun, 19 Jul 2020 03:50:48 +0000 (23:50 -0400)]
embed: implement FS

embed.FS is the implementation of embedded file trees, providing
an fs.FS for each embed.FS variable.

Tests are in a follow-up CL, in the package embed/internal/embedtest.
(They can only be written once the toolchain can initialize one of these,
which requires changes to cmd/compile and cmd/go.)

For #41191.

Change-Id: Ieb0ead1d305cdac3d5d4e11772dca75740a72730
Reviewed-on: https://go-review.googlesource.com/c/go/+/243942
Trust: Russ Cox <rsc@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/vendor: sync pprof@v0.0.0-20201007051231-1066cbb265c7
Hana [Wed, 7 Oct 2020 21:27:42 +0000 (17:27 -0400)]
cmd/vendor: sync pprof@v0.0.0-20201007051231-1066cbb265c7

This is a belated early sync for 1.16 dev cycle

For #36905

Change-Id: I387528ae897794841c0c78b0f0910fc5ce8599ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/260538
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years agostrconv: increase the Eisel-Lemire exp10 range
Nigel Tao [Thu, 22 Oct 2020 12:43:11 +0000 (23:43 +1100)]
strconv: increase the Eisel-Lemire exp10 range

This grows the exp10 range for which the Eisel-Lemire algorithm applies
from [-307, +288] to [-348, +347], roughly equivalent to the existing
powersOfTen table in extfloat.go (which uses a different algorithm).

name                  old time/op  new time/op  delta
Atof64Decimal-4       48.4ns ± 1%  48.7ns ± 3%   ~     (p=0.698 n=5+5)
Atof64Float-4         57.9ns ± 1%  58.1ns ± 2%   ~     (p=0.873 n=5+5)
Atof64FloatExp-4      71.8ns ± 2%  72.2ns ± 2%   ~     (p=0.730 n=5+5)
Atof64Big-4            165ns ± 1%   164ns ± 1%   ~     (p=0.635 n=5+5)
Atof64RandomBits-4     165ns ± 1%   165ns ± 6%   ~     (p=0.143 n=5+5)
Atof64RandomFloats-4   147ns ± 2%   147ns ± 1%   ~     (p=0.857 n=5+5)

Change-Id: Idf7dc5297db6db2bd9e0bd4cb0e55e021916fa43
Reviewed-on: https://go-review.googlesource.com/c/go/+/264139
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Nigel Tao <nigeltao@golang.org>

4 years agodoc/go1.16: document ASLR support for -buildmode=c-shared on windows
qmuntal [Wed, 21 Oct 2020 14:04:07 +0000 (16:04 +0200)]
doc/go1.16: document ASLR support for -buildmode=c-shared on windows

Change-Id: I89c61e444b3ab36f0081a5252d210cb265344122
Reviewed-on: https://go-review.googlesource.com/c/go/+/264157
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Trust: Alex Brainman <alex.brainman@gmail.com>

4 years agocmd/cgo: avoid exporting all symbols on windows buildmode=c-shared
Quim Muntal [Thu, 15 Oct 2020 21:12:49 +0000 (23:12 +0200)]
cmd/cgo: avoid exporting all symbols on windows buildmode=c-shared

Disable default symbol auto-export behaviour by marking exported
function with the __declspec(dllexport) attribute. Old behaviour can
still be used by setting -extldflags=-Wl,--export-all-symbols.

See https://sourceware.org/binutils/docs/ld/WIN32.html for more info.

This change cuts 50kb of a "hello world" dll.

Updates #6853
Fixes #30674

Change-Id: I9c7fb09c677cc760f24d0f7d199740ae73981413
Reviewed-on: https://go-review.googlesource.com/c/go/+/262797
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: Alex Brainman <alex.brainman@gmail.com>
Trust: Alex Brainman <alex.brainman@gmail.com>

4 years agostrconv: fix Eisel-Lemire for negative zero
Nigel Tao [Thu, 22 Oct 2020 12:59:00 +0000 (23:59 +1100)]
strconv: fix Eisel-Lemire for negative zero

This is somewhat academic (and no tests failed before this commit),
since func atof64 only calls func eiselLemire when func atof64exact
fails, and func atof64exact doesn't fail when parsing positive or
negative zeroes. But it's still worth fixing.

Change-Id: Ibe6ef4c8fd96827673b711d5456003fbc447e39c
Reviewed-on: https://go-review.googlesource.com/c/go/+/264140
Trust: Nigel Tao <nigeltao@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
4 years agocmd/go: support non-amd64 on script/toolexec.txt
Daniel Martí [Thu, 22 Oct 2020 18:32:47 +0000 (19:32 +0100)]
cmd/go: support non-amd64 on script/toolexec.txt

In https://golang.org/cl/263357, I wasn't thinking that the assembly
file without a GOARCH suffix would be built for all architectures. Only
build assembly for amd64, and update the stderr matching line.

I manually verified that this works on 386; since the only Go file in
that package is a stub, and no assembly files match GOARCH=386, no
assembly is built at all.

Change-Id: Ief3c6c9bdc223f342821b0ec27f00098fc25246a
Reviewed-on: https://go-review.googlesource.com/c/go/+/264457
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/internal/obj: use correct symbol size for Hashed64 classification
Cherry Zhang [Thu, 22 Oct 2020 14:05:44 +0000 (10:05 -0400)]
cmd/internal/obj: use correct symbol size for Hashed64 classification

Use sym.Size, instead of len(sym.P), to decide whether a
content-addressable symbol is "short" and hashed as Hashed64.
So we don't dedup a small symbol with a gigantic almost-zero
symbol.

Fixes #42140.

Change-Id: Ic65869e1eaf51947517b3ece49c8b0be1b94bb75
Reviewed-on: https://go-review.googlesource.com/c/go/+/264337
Trust: Cherry Zhang <cherryyz@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoall: add GOOS=ios GOARCH=amd64 target for the ios simulator
Elias Naur [Tue, 20 Oct 2020 09:01:46 +0000 (11:01 +0200)]
all: add GOOS=ios GOARCH=amd64 target for the ios simulator

The Go toolchain has supported the simulator for years, but always in
buildmode=c-archive which is intrinsically externally linked and PIE.

This CL moves that support from GOOS=darwin GOARCH=amd64 -tags=ios to
just GOOS=ios GOARCH=amd64 to match the change for iOS devices.

This change also forces external linking and defaults to buildmode=pie
to support Go binaries in the default buildmode to run on the simulator.

CL 255257 added the necessary support to the exec wrapper.

Updates #38485
Fixes #42100

Change-Id: I6e6ee0e8d421be53b31e3d403880e5b9b880d031
Reviewed-on: https://go-review.googlesource.com/c/go/+/263798
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Elias Naur <mail@eliasnaur.com>

4 years agoruntime: move s390x HWCap CPU feature detection to internal/cpu
Martin Möhrmann [Tue, 20 Oct 2020 12:21:07 +0000 (14:21 +0200)]
runtime: move s390x HWCap CPU feature detection to internal/cpu

Change-Id: I7d9e31c3b342731ddd7329962426fdfc80e9ed87
Reviewed-on: https://go-review.googlesource.com/c/go/+/263803
Trust: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
4 years agocmd/compile: remove go115flagallocdeadcode
Cherry Zhang [Thu, 22 Oct 2020 01:09:57 +0000 (21:09 -0400)]
cmd/compile: remove go115flagallocdeadcode

Change-Id: Iafd72fb06a491075f7f996a6684e0d495c96aee5
Reviewed-on: https://go-review.googlesource.com/c/go/+/264342
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: remove go115shortcircuitPhis
Cherry Zhang [Thu, 22 Oct 2020 01:08:39 +0000 (21:08 -0400)]
cmd/compile: remove go115shortcircuitPhis

Change-Id: Ib2697ebfcc14a01ab1f793cddcbf69180ffc49a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/264341
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: remove go115makeslicecopy
Cherry Zhang [Thu, 22 Oct 2020 01:06:44 +0000 (21:06 -0400)]
cmd/compile: remove go115makeslicecopy

Change-Id: I6fd65fe7c1046c3ba7d7ed0e67282f879c13e9e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/264340
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: define the AddrRange used for testing in terms of addrRange
Michael Anthony Knyszek [Tue, 14 Jul 2020 20:27:27 +0000 (20:27 +0000)]
runtime: define the AddrRange used for testing in terms of addrRange

Currently the AddrRange used for testing is defined separately from
addrRange in the runtime, making it difficult to test it as well as
addrRanges. Redefine AddrRange in terms of addrRange instead.

For #40191.

Change-Id: I3aa5b8df3e4c9a3c494b46ab802dd574b2488141
Reviewed-on: https://go-review.googlesource.com/c/go/+/242677
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/go: set TOOLEXEC_IMPORTPATH for -toolexec tools
Daniel Martí [Sat, 17 Oct 2020 19:03:19 +0000 (20:03 +0100)]
cmd/go: set TOOLEXEC_IMPORTPATH for -toolexec tools

This way, a -toolexec tool can tell precisely what package is being
built when it's run. This was very hard to do before, because the tool
had to piece together that information given the build action's
arguments or flags.

Since there wasn't a good set of tests for -toolexec, add one in the
form of a test script. It builds a simple set of packages with a variety
of build tools, to ensure that all the cases behave as expected.

Like other recent master changes, include the changelog item for this
user-facing change too.

Fixes #15677.

Change-Id: I0a5a1d9485840323ec138b2e64b7e7dd803fdf90
Reviewed-on: https://go-review.googlesource.com/c/go/+/263357
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>

4 years agocmd/go: use the last -linkmode flag to determine external linking
Xiangdong Ji [Sun, 18 Oct 2020 18:43:23 +0000 (11:43 -0700)]
cmd/go: use the last -linkmode flag to determine external linking

Current linkmode checking in determining package dependencies doesn't
take multiple -linkmode options into consideration, may lead to redundant
dependency on 'runtime/cgo'.

Fixes the problem and adds a testcase.

Change-Id: Iac5ea9fb3ca5ef931201afd0f3441f41f946c919
Reviewed-on: https://go-review.googlesource.com/c/go/+/263497
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd,cmd/vendor: pick up updates for golang.org/x/arch/ppc64
Lynn Boger [Mon, 12 Oct 2020 14:52:16 +0000 (10:52 -0400)]
cmd,cmd/vendor: pick up updates for golang.org/x/arch/ppc64

Bring in updates to golang.org/x/arch/ppc64 to add new
instructions from CLs 260617, 230957, 249158.

Used the directions found in README.vendor:

  cd $GOROOT/src/cmd
  go get -d golang.org/x/arch@latest
  go mod tidy
  go mod vendor

Change-Id: Ie8ceb9c804928b72b37fff5b63981c174fb86989
Reviewed-on: https://go-review.googlesource.com/c/go/+/264079
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>
4 years agoimports: make ScanDir ignore go files start with dot
Keyuan [Wed, 21 Oct 2020 02:47:29 +0000 (19:47 -0700)]
imports: make ScanDir ignore go files start with dot

Adding "." Prefix Check for go files.

Fixes #42047
Change-Id: Ifc42bf562f52fdd304f9828b06fc57888fcd8049
Reviewed-on: https://go-review.googlesource.com/c/go/+/264078
Reviewed-by: Bryan C. Mills <bcmills@google.com>
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>

4 years agocmd/go: when module enabled, `go clean` removes built binary
hitzhangjie [Wed, 21 Oct 2020 05:09:26 +0000 (05:09 +0000)]
cmd/go: when module enabled, `go clean` removes built binary

Now "go clean" can remove binary as expected, when module enabled and the module name isn't  "main" or the name of folder.

Fixes issue #41656

Change-Id: I54b9435ece045e03a12dc230efe84c8dd381a07c
GitHub-Last-Rev: f4ea2d8c765a6e3a2b89fe2c9fb5b2c80551efa5
GitHub-Pull-Request: golang/go#41999
Reviewed-on: https://go-review.googlesource.com/c/go/+/262677
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>

4 years agocmd/compile: make gc debug flags collector a struct
Alberto Donizetti [Mon, 19 Oct 2020 09:31:10 +0000 (11:31 +0200)]
cmd/compile: make gc debug flags collector a struct

gc debug flags are currently stored in a 256-long array, that is then
addressed using the ASCII numeric value of the flag itself (a quirk
inherited from the old C compiler). It is also a little wasteful,
since we only define 16 flags, and the other 240 array elements are
always empty.

This change makes Debug a struct, which also provides static checking
that we're not referencing flags that does not exist.

Change-Id: I2f0dfef2529325514b3398cf78635543cdf48fe0
Reviewed-on: https://go-review.googlesource.com/c/go/+/263539
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agogo/build: recognize and report //go:embed lines
Russ Cox [Mon, 19 Oct 2020 11:46:09 +0000 (07:46 -0400)]
go/build: recognize and report //go:embed lines

The code in this CL does the work of looking for the "embed" import
and then finding and recording the arguments to //go:embed lines
in Go source files. The go command will use this information to prepare
information about embedded files to pass to the compiler.

The tests of the Package fields end up being end-to-end via the
go command (added in the CL with the go command changes),
like all the other Package fields.

For #41191.

Change-Id: I0c87b71ca809c0031603cc403c030d3088299e6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/243941
Trust: Russ Cox <rsc@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agonet: add Example for Unix dialer with context
Kevin Burke [Sun, 18 Oct 2020 16:49:16 +0000 (09:49 -0700)]
net: add Example for Unix dialer with context

Showing users how to accomplish this more easily is a compromise
between doing nothing and adding a new API to the net package.

Fixes #38506.

Change-Id: I43f831cf94951c987cf3c8c1aa55f0012ee8034e
Reviewed-on: https://go-review.googlesource.com/c/go/+/263417
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>

4 years agoencoding/xml: fix reserved namespace check to be case-insensitive
Ian Lance Taylor [Tue, 20 Oct 2020 22:19:36 +0000 (15:19 -0700)]
encoding/xml: fix reserved namespace check to be case-insensitive

Fixes the check for the reserved namespace prefix
"xml" to be case insensitive, so as to match all variants of:

    (('X'|'x')('M'|'m')('L'|'l'))

as mandated by Section 2.3 of https://www.w3.org/TR/REC-xml/

This is a roll forward of CL 203417, which was rolled back by CL 240179.
We've decided that the roll back was incorrect, and any broken tests
should be fixed.

The original CL 203417 was by Tamás Gulácsi.

Fixes #35151
For #39876

Change-Id: I2e6daa7aeb252531fba0b8a56086613e13059528
Reviewed-on: https://go-review.googlesource.com/c/go/+/264024
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agoruntime/race: update race .syso files
Keith Randall [Wed, 21 Oct 2020 03:08:30 +0000 (20:08 -0700)]
runtime/race: update race .syso files

Fixes #39186

Change-Id: I624ab73b3083f190978c09716672ce1b712a5c81
Reviewed-on: https://go-review.googlesource.com/c/go/+/264082
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Keith Randall <khr@golang.org>

4 years agonet/http: test that ParseMultipartForm catches overflows
Emmanuel T Odeke [Tue, 20 Oct 2020 11:11:12 +0000 (04:11 -0700)]
net/http: test that ParseMultipartForm catches overflows

Tests that if the combination of:
* HTTP multipart file payload size
* ParseMultipartForm's maxMemory parameter
* the internal leeway buffer size of 10MiB

overflows, then we'll report an overflow instead of silently
passing.

Reapplies and fixes CL 254977, which was reverted in CL 263658.

The prior test lacked a res.Body.Close(), so fixed that and
added a leaked Transport check to verify correctness.

Updates 40430.

Change-Id: I3c0f7ef43d621f6eb00f07755f04f9f36c51f98f
Reviewed-on: https://go-review.googlesource.com/c/go/+/263817
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Damien Neil <dneil@google.com>

4 years agocmd/compile: use desired info when allocating registers for live values
eric fang [Mon, 19 Oct 2020 03:57:15 +0000 (03:57 +0000)]
cmd/compile: use desired info when allocating registers for live values

When allocting registers for live values, use desired register if available,
this is helpful for some cases, such as (*entry).delete, which can save a
few of copies.
Besides, this patch allows more debugging information to be printed out.

Test results of compilecmp on Linux/amd64:
name                      old time/op                 new time/op                 delta
Template                    326729362.060000ns +- 3%    329227238.775510ns +- 4%  +0.76%  (p=0.038 n=50+49)
Unicode                     157671860.391304ns +- 6%    156917927.320000ns +- 6%    ~     (p=0.291 n=46+50)
GoTypes                    1065591138.304348ns +- 2%   1063695977.434783ns +- 1%    ~     (p=0.208 n=46+46)
Compiler                   5053424790.760001ns +- 2%   5052729636.551020ns +- 3%    ~     (p=0.908 n=50+49)
SSA                       12392067635.866669ns +- 2%  12319786960.460005ns +- 2%  -0.58%  (p=0.008 n=45+50)
Flate                       212609767.340000ns +- 5%    213011228.085106ns +- 5%    ~     (p=0.685 n=50+47)
GoParser                    266870495.100000ns +- 4%    266962314.280000ns +- 3%    ~     (p=0.975 n=50+50)
Reflect                     660164306.551021ns +- 2%    658284470.729167ns +- 2%    ~     (p=0.069 n=49+48)
Tar                         292805895.720000ns +- 4%    292103626.954545ns +- 2%    ~     (p=0.321 n=50+44)
XML                         386294811.700000ns +- 4%    386665088.820000ns +- 4%    ~     (p=0.786 n=50+50)
LinkCompiler                548495788.659575ns +- 5%    549359489.102041ns +- 4%    ~     (p=0.855 n=47+49)
ExternalLinkCompiler       1810414270.280000ns +- 2%   1806872224.673470ns +- 2%    ~     (p=0.313 n=50+49)
LinkWithoutDebugCompiler    340888843.795918ns +- 5%    340341541.100000ns +- 6%    ~     (p=0.735 n=49+50)
[Geo mean]                   664550174.613777ns          664090221.153575ns       -0.07%

name                      old user-time/op            new user-time/op            delta
Template                    565202800.000000ns +-16%    595351040.000000ns +-16%  +5.33%  (p=0.001 n=50+50)
Unicode                     378444740.000000ns +-14%    373825183.673469ns +-17%    ~     (p=0.458 n=50+49)
GoTypes                    2052073341.463415ns +-12%   2059679864.864865ns +- 7%    ~     (p=0.381 n=41+37)
Compiler                   9913371980.000000ns +-20%   9848836720.000002ns +-19%    ~     (p=0.781 n=50+50)
SSA                       25013846224.489799ns +-17%  24571896183.673466ns +-17%    ~     (p=0.132 n=49+49)
Flate                       314422702.127660ns +-17%    314831666.666667ns +-11%    ~     (p=0.427 n=47+45)
GoParser                    419496060.000000ns +- 9%    417403460.000000ns +-11%    ~     (p=0.512 n=50+50)
Reflect                    1233632469.387755ns +-17%   1193061073.170732ns +-13%  -3.29%  (p=0.030 n=49+41)
Tar                         509855937.500000ns +-10%    508700740.000000ns +-14%    ~     (p=0.890 n=48+50)
XML                         703511425.531915ns +-12%    694007591.836735ns +-11%    ~     (p=0.164 n=47+49)
LinkCompiler                993137687.500000ns +- 6%    991914714.285714ns +- 8%    ~     (p=0.860 n=48+49)
ExternalLinkCompiler       2193851840.000001ns +- 3%   2186672183.673470ns +- 5%    ~     (p=0.320 n=50+49)
LinkWithoutDebugCompiler    420800875.000000ns +-10%    422062640.000000ns +- 9%    ~     (p=0.840 n=48+50)
[Geo mean]                  1145156131.480097ns         1142033233.550961ns       -0.27%

name                      old alloc/op                new alloc/op                delta
Template                                36.3MB +- 0%                36.3MB +- 0%    ~     (p=0.886 n=50+49)
Unicode                                 30.1MB +- 0%                30.1MB +- 0%    ~     (p=0.792 n=50+50)
GoTypes                                  118MB +- 0%                 118MB +- 0%    ~     (p=1.000 n=47+48)
Compiler                                 562MB +- 0%                 562MB +- 0%    ~     (p=0.205 n=50+49)
SSA                                     1.42GB +- 0%                1.42GB +- 0%  -0.12%  (p=0.000 n=50+50)
Flate                                   22.8MB +- 0%                22.8MB +- 0%    ~     (p=0.384 n=50+47)
GoParser                                28.0MB +- 0%                28.0MB +- 0%  -0.02%  (p=0.013 n=50+50)
Reflect                                 78.0MB +- 0%                78.0MB +- 0%    ~     (p=0.384 n=46+48)
Tar                                     34.1MB +- 0%                34.1MB +- 0%    ~     (p=0.072 n=50+50)
XML                                     43.1MB +- 0%                43.1MB +- 0%  -0.04%  (p=0.000 n=49+50)
LinkCompiler                            98.5MB +- 0%                98.5MB +- 0%  +0.01%  (p=0.012 n=50+43)
ExternalLinkCompiler                    89.6MB +- 0%                89.6MB +- 0%    ~     (p=0.762 n=50+50)
LinkWithoutDebugCompiler                56.9MB +- 0%                56.9MB +- 0%    ~     (p=0.268 n=49+48)
[Geo mean]                               77.7MB                      77.7MB       -0.01%

name                      old allocs/op               new allocs/op               delta
Template                                  367k +- 0%                  367k +- 0%  -0.01%  (p=0.002 n=50+49)
Unicode                                   345k +- 0%                  345k +- 0%    ~     (p=0.981 n=50+50)
GoTypes                                  1.28M +- 0%                 1.28M +- 0%  -0.00%  (p=0.002 n=49+50)
Compiler                                 5.39M +- 0%                 5.39M +- 0%  -0.00%  (p=0.000 n=50+50)
SSA                                      13.9M +- 0%                 13.9M +- 0%  +0.01%  (p=0.000 n=50+50)
Flate                                     230k +- 0%                  230k +- 0%    ~     (p=0.815 n=50+50)
GoParser                                  292k +- 0%                  292k +- 0%  -0.01%  (p=0.000 n=50+50)
Reflect                                   977k +- 0%                  977k +- 0%  -0.00%  (p=0.035 n=50+50)
Tar                                       343k +- 0%                  343k +- 0%  -0.01%  (p=0.008 n=48+50)
XML                                       418k +- 0%                  418k +- 0%  -0.01%  (p=0.000 n=50+50)
LinkCompiler                              516k +- 0%                  516k +- 0%  +0.01%  (p=0.002 n=50+48)
ExternalLinkCompiler                      570k +- 0%                  570k +- 0%    ~     (p=0.430 n=46+50)
LinkWithoutDebugCompiler                  169k +- 0%                  169k +- 0%    ~     (p=0.706 n=49+49)
[Geo mean]                                 672k                        672k       -0.00%

name                      old maxRSS/op               new maxRSS/op               delta
Template                                 34.3M +- 5%                 34.7M +- 4%  +1.24%  (p=0.004 n=50+50)
Unicode                                  36.2M +- 5%                 36.1M +- 8%    ~     (p=0.785 n=50+50)
GoTypes                                  75.7M +- 7%                 76.1M +- 6%    ~     (p=0.544 n=50+50)
Compiler                                  304M +- 7%                  304M +- 7%    ~     (p=0.744 n=50+50)
SSA                                       721M +- 6%                  723M +- 7%    ~     (p=0.724 n=49+50)
Flate                                    26.1M +- 3%                 26.1M +- 5%    ~     (p=0.649 n=48+49)
GoParser                                 29.3M +- 5%                 29.3M +- 4%    ~     (p=0.809 n=50+50)
Reflect                                  56.0M +- 6%                 56.3M +- 5%    ~     (p=0.350 n=50+50)
Tar                                      34.1M +- 3%                 33.9M +- 5%    ~     (p=0.121 n=49+50)
XML                                      39.6M +- 5%                 39.9M +- 4%    ~     (p=0.109 n=50+50)
LinkCompiler                              168M +- 1%                  168M +- 1%    ~     (p=0.578 n=49+48)
ExternalLinkCompiler                      179M +- 1%                  179M +- 2%    ~     (p=0.522 n=46+46)
LinkWithoutDebugCompiler                  137M +- 3%                  137M +- 3%    ~     (p=0.463 n=41+50)
[Geo mean]                                79.3M                       79.5M       +0.20%

name                      old text-bytes              new text-bytes              delta
HelloSize                                812kB +- 0%                 811kB +- 0%  -0.05%  (p=0.000 n=50+50)

name                      old data-bytes              new data-bytes              delta
HelloSize                               13.3kB +- 0%                13.3kB +- 0%    ~     (all equal)

name                      old bss-bytes               new bss-bytes               delta
HelloSize                                206kB +- 0%                 206kB +- 0%    ~     (all equal)

name                      old exe-bytes               new exe-bytes               delta
HelloSize                               1.21MB +- 0%                1.21MB +- 0%  +0.02%  (p=0.000 n=50+50)

file      before    after     Δ       %
addr2line 4052949   4052453   -496    -0.012%
api       4948171   4947163   -1008   -0.020%
asm       4888889   4888049   -840    -0.017%
buildid   2617545   2617673   +128    +0.005%
cgo       4521681   4516801   -4880   -0.108%
compile   19139091  19137683  -1408   -0.007%
cover     4843191   4840359   -2832   -0.058%
dist      3473677   3474717   +1040   +0.030%
doc       3821592   3821552   -40     -0.001%
fix       3220587   3220059   -528    -0.016%
link      6587368   6582696   -4672   -0.071%
nm        3999858   3999186   -672    -0.017%
objdump   4409161   4408217   -944    -0.021%
pack      2394038   2393846   -192    -0.008%
pprof     13601271  13602487  +1216   +0.009%
test2json 2645148   2644604   -544    -0.021%
trace     10357878  10356862  -1016   -0.010%
vet       6779482   6778706   -776    -0.011%
total     106301577 106283113 -18464  -0.017%

Change-Id: I63ac6e224e1a4756ddc1bfc4aabbaeb92d7d4273
Reviewed-on: https://go-review.googlesource.com/c/go/+/263599
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: eric fang <eric.fang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: optimize regalloc for phi value
erifan01 [Mon, 19 Oct 2020 03:20:24 +0000 (11:20 +0800)]
cmd/compile: optimize regalloc for phi value

When allocating registers for phi value, only the primary predecessor is considered.
Taking into account the allocation status of other predecessors can help reduce
unnecessary copy or spill operations. Many such cases can be found in the standard
library, such as runtime.wirep, moveByType, etc. The test results from benchstat
also show that this change helps reduce the file size.

name                      old time/op       new time/op       delta
Template                        328ms ± 5%        326ms ± 4%    ~     (p=0.254 n=50+47)
Unicode                         156ms ± 7%        158ms ±10%    ~     (p=0.412 n=49+49)
GoTypes                         1.07s ± 3%        1.07s ± 2%    ~     (p=0.664 n=48+49)
Compiler                        4.43s ± 3%        4.44s ± 3%    ~     (p=0.758 n=48+50)
SSA                             10.3s ± 2%        10.4s ± 2%  +0.43%  (p=0.017 n=50+46)
Flate                           208ms ± 9%        209ms ± 7%    ~     (p=0.920 n=49+46)
GoParser                        260ms ± 5%        262ms ± 4%    ~     (p=0.063 n=50+48)
Reflect                         687ms ± 3%        685ms ± 2%    ~     (p=0.459 n=50+48)
Tar                             293ms ± 4%        293ms ± 5%    ~     (p=0.695 n=49+48)
XML                             391ms ± 4%        389ms ± 3%    ~     (p=0.109 n=49+46)
LinkCompiler                    570ms ± 5%        563ms ± 5%  -1.10%  (p=0.006 n=46+47)
ExternalLinkCompiler            1.57s ± 3%        1.56s ± 3%    ~     (p=0.118 n=47+46)
LinkWithoutDebugCompiler        349ms ± 6%        349ms ± 5%    ~     (p=0.726 n=49+47)
[Geo mean]                      645ms             645ms       -0.05%

name                      old user-time/op  new user-time/op  delta
Template                        507ms ±14%        513ms ±14%    ~     (p=0.398 n=48+49)
Unicode                         345ms ±29%        345ms ±38%    ~     (p=0.521 n=47+49)
GoTypes                         1.95s ±16%        1.94s ±19%    ~     (p=0.324 n=50+50)
Compiler                        8.26s ±16%        8.22s ±14%    ~     (p=0.834 n=50+50)
SSA                             19.6s ± 8%        19.2s ±15%    ~     (p=0.056 n=50+50)
Flate                           293ms ± 9%        299ms ±12%    ~     (p=0.057 n=47+50)
GoParser                        388ms ± 9%        387ms ±14%    ~     (p=0.660 n=46+50)
Reflect                         1.15s ±28%        1.12s ±18%    ~     (p=0.648 n=49+48)
Tar                             456ms ±10%        476ms ±15%  +4.48%  (p=0.001 n=46+48)
XML                             648ms ±27%        634ms ±16%    ~     (p=0.685 n=50+46)
LinkCompiler                    1.00s ± 8%        1.00s ± 8%    ~     (p=0.638 n=50+50)
ExternalLinkCompiler            1.96s ± 5%        1.96s ± 5%    ~     (p=0.792 n=50+50)
LinkWithoutDebugCompiler        443ms ±10%        442ms ±11%    ~     (p=0.813 n=50+50)
[Geo mean]                      1.05s             1.05s       -0.09%

name                      old alloc/op      new alloc/op      delta
Template                       36.0MB ± 0%       36.0MB ± 0%    ~     (p=0.599 n=49+50)
Unicode                        29.8MB ± 0%       29.8MB ± 0%    ~     (p=0.739 n=50+50)
GoTypes                         118MB ± 0%        118MB ± 0%    ~     (p=0.436 n=50+50)
Compiler                        562MB ± 0%        562MB ± 0%    ~     (p=0.693 n=50+50)
SSA                            1.42GB ± 0%       1.42GB ± 0%  -0.10%  (p=0.000 n=50+49)
Flate                          22.5MB ± 0%       22.5MB ± 0%    ~     (p=0.429 n=48+49)
GoParser                       27.7MB ± 0%       27.7MB ± 0%    ~     (p=0.705 n=49+48)
Reflect                        77.7MB ± 0%       77.7MB ± 0%  -0.01%  (p=0.043 n=50+50)
Tar                            33.8MB ± 0%       33.8MB ± 0%    ~     (p=0.241 n=49+50)
XML                            42.8MB ± 0%       42.8MB ± 0%    ~     (p=0.677 n=47+49)
LinkCompiler                   98.3MB ± 0%       98.3MB ± 0%    ~     (p=0.157 n=50+50)
ExternalLinkCompiler           89.4MB ± 0%       89.4MB ± 0%    ~     (p=0.683 n=50+50)
LinkWithoutDebugCompiler       56.7MB ± 0%       56.7MB ± 0%    ~     (p=0.155 n=49+49)
[Geo mean]                     77.3MB            77.3MB       -0.01%

name                      old allocs/op     new allocs/op     delta
Template                         367k ± 0%         367k ± 0%    ~     (p=0.863 n=50+50)
Unicode                          345k ± 0%         345k ± 0%    ~     (p=0.744 n=49+49)
GoTypes                         1.28M ± 0%        1.28M ± 0%    ~     (p=0.957 n=48+50)
Compiler                        5.39M ± 0%        5.39M ± 0%  +0.00%  (p=0.012 n=50+49)
SSA                             13.9M ± 0%        13.9M ± 0%  +0.02%  (p=0.000 n=47+49)
Flate                            230k ± 0%         230k ± 0%  -0.01%  (p=0.007 n=47+49)
GoParser                         292k ± 0%         292k ± 0%    ~     (p=0.891 n=50+49)
Reflect                          977k ± 0%         977k ± 0%    ~     (p=0.274 n=50+50)
Tar                              343k ± 0%         343k ± 0%    ~     (p=0.942 n=50+50)
XML                              418k ± 0%         418k ± 0%    ~     (p=0.374 n=50+49)
LinkCompiler                     516k ± 0%         516k ± 0%    ~     (p=0.205 n=49+47)
ExternalLinkCompiler             570k ± 0%         570k ± 0%    ~     (p=0.783 n=49+47)
LinkWithoutDebugCompiler         169k ± 0%         169k ± 0%    ~     (p=0.233 n=50+46)
[Geo mean]                       672k              672k       +0.00%

name                      old maxRSS/op     new maxRSS/op     delta
Template                        34.5M ± 3%        34.4M ± 3%    ~     (p=0.566 n=49+48)
Unicode                         36.0M ± 6%        35.9M ± 6%    ~     (p=0.736 n=50+50)
GoTypes                         75.7M ± 7%        75.4M ± 5%    ~     (p=0.412 n=50+50)
Compiler                         314M ±10%         313M ± 8%    ~     (p=0.708 n=50+50)
SSA                              730M ± 6%         735M ± 6%    ~     (p=0.324 n=50+50)
Flate                           25.8M ± 5%        25.6M ± 6%    ~     (p=0.415 n=49+50)
GoParser                        28.5M ± 3%        28.5M ± 4%    ~     (p=0.977 n=46+50)
Reflect                         57.4M ± 4%        57.2M ± 3%    ~     (p=0.173 n=50+50)
Tar                             33.3M ± 3%        33.2M ± 4%    ~     (p=0.621 n=48+50)
XML                             39.6M ± 5%        39.6M ± 4%    ~     (p=0.997 n=50+50)
LinkCompiler                     168M ± 2%         167M ± 1%    ~     (p=0.072 n=49+45)
ExternalLinkCompiler             179M ± 1%         179M ± 1%    ~     (p=0.147 n=48+50)
LinkWithoutDebugCompiler         136M ± 1%         136M ± 1%    ~     (p=0.789 n=47+49)
[Geo mean]                      79.2M             79.1M       -0.12%

name                      old text-bytes    new text-bytes    delta
HelloSize                       812kB ± 0%        811kB ± 0%  -0.06%  (p=0.000 n=50+50)

name                      old data-bytes    new data-bytes    delta
HelloSize                      13.3kB ± 0%       13.3kB ± 0%    ~     (all equal)

name                      old bss-bytes     new bss-bytes     delta
HelloSize                       206kB ± 0%        206kB ± 0%    ~     (all equal)

name                      old exe-bytes     new exe-bytes     delta
HelloSize                      1.21MB ± 0%       1.21MB ± 0%  -0.03%  (p=0.000 n=50+50)

file      before    after     Δ       %
addr2line 4057421   4056237   -1184   -0.029%
api       4952451   4946715   -5736   -0.116%
asm       4888993   4888185   -808    -0.017%
buildid   2617705   2616441   -1264   -0.048%
cgo       4521849   4520681   -1168   -0.026%
compile   19143451  19141243  -2208   -0.012%
cover     4847391   4837151   -10240  -0.211%
dist      3473877   3472565   -1312   -0.038%
doc       3821496   3820432   -1064   -0.028%
fix       3220587   3220659   +72     +0.002%
link      6587504   6582576   -4928   -0.075%
nm        4000154   3998690   -1464   -0.037%
objdump   4409449   4407625   -1824   -0.041%
pack      2398086   2393110   -4976   -0.207%
pprof     13599060  13606111  +7051   +0.052%
test2json 2645148   2645692   +544    +0.021%
trace     10355281  10355862  +581    +0.006%
vet       6780026   6779666   -360    -0.005%
total     106319929 106289641 -30288  -0.028%

Change-Id: Ia5399286958c187c8664c769bbddf7bc4c1cae99
Reviewed-on: https://go-review.googlesource.com/c/go/+/263600
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: eric fang <eric.fang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoencoding/json: add "json: " prefix to SyntaxError messages
Kevin Burke [Mon, 19 Oct 2020 20:29:40 +0000 (13:29 -0700)]
encoding/json: add "json: " prefix to SyntaxError messages

The other named errors - UnmarshalTypeError, etc - in this package do
the same, so we should prepend the package prefix to error messages
for consistency.

Add a note to the release docs in case this is interpreted as
a breaking change.

Fixes #36221.

Change-Id: Ie24b532bbf9812e108c259fa377e2a6b64319ed4
Reviewed-on: https://go-review.googlesource.com/c/go/+/263619
Run-TryBot: Kevin Burke <kev@inburke.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Kevin Burke <kev@inburke.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
4 years agocmd/compile/internal/gc: fix comments
hk [Wed, 21 Oct 2020 16:18:34 +0000 (16:18 +0000)]
cmd/compile/internal/gc: fix comments

Change-Id: Id7b0ead39e961a16a85da3e308db10dd4f9b55c3
GitHub-Last-Rev: e640c4a61ade361ac17b7eb95d0ce8913d0b4d6f
GitHub-Pull-Request: golang/go#42120
Reviewed-on: https://go-review.googlesource.com/c/go/+/264080
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>

4 years agocrypto/x509: bypass signature verification in CreateCertificate when using MD5WithRSA
Roland Shoemaker [Tue, 20 Oct 2020 20:50:52 +0000 (13:50 -0700)]
crypto/x509: bypass signature verification in CreateCertificate when using MD5WithRSA

Bypasses the signature verification check we previously added if the
signature algorithm is MD5WithRSA, as we only support this algorithm
for signing and not verification.

Change-Id: Idba6dbba8b365d6199d467526746b88a5f734af1
Reviewed-on: https://go-review.googlesource.com/c/go/+/264019
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Roland Shoemaker <roland@golang.org>

4 years agocmd/compile,cmd/internal/obj/riscv: move g register on riscv64
Joel Sing [Tue, 19 May 2020 08:55:31 +0000 (18:55 +1000)]
cmd/compile,cmd/internal/obj/riscv: move g register on riscv64

The original riscv64 port used the thread pointer (TP aka X4) register for
the g pointer, however this register is also used when TLS support is
required, resulting in a conflict (for example, when a signal is received
we have no way of readily knowing if X4 contains a pointer to the TCB or
a pointer to a g).

In order to support cgo, free up the X4 register by moving g to X27.
This unfortunately means that the X4 register is unused in non-cgo mode,
however the alternative is to not support cgo on this platform.

Update #36641

Change-Id: Idcaf3e8ccbe42972a1b8943aeefde7149d9c960a
Reviewed-on: https://go-review.googlesource.com/c/go/+/263477
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/go/internal/fsys: use a root other than "." in Walk tests
Bryan C. Mills [Wed, 21 Oct 2020 14:07:02 +0000 (10:07 -0400)]
cmd/go/internal/fsys: use a root other than "." in Walk tests

Fixes #42115

Change-Id: Icf4c9eac5ed3295acbc8377c7a06f82c6bddc747
Reviewed-on: https://go-review.googlesource.com/c/go/+/264177
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/go: ignore GOFLAGS values without name in go env/bug
Obeyda Djeffal [Fri, 16 Oct 2020 15:34:15 +0000 (16:34 +0100)]
cmd/go: ignore GOFLAGS values without name in go env/bug

This happens with 'go env' and 'go bug'.

If GOFLAGS variable is set to something like '=value',
running `go env` panics with this error message:

    goroutine 1 [running]:
    cmd/go/internal/base.SetFromGOFLAGS(0xd96838)
        cmd/go/internal/base/goflags.go:101 +0x9a7
    main.main()
        cmd/go/main.go:188 +0x755

This happens when the 'name' of the flag is not
specified ('=' or '=value'), with any combination of other flags.
Other commands show this error message:
    go: parsing $GOFLAGS: non-flag

This happens only with 'env' and 'bug' because we have this:
https://go.googlesource.com/go/+/refs/heads/master/src/cmd/go/internal/base/goflags.go#40

New behaviour: ignore the bad flag, since we don't want to report
that with `go env` or `go bug`.

Fixes: #42013
Change-Id: I72602840ca00293d2a92ea28451b75b9799e3d6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/263098
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Matloob <matloob@golang.org>

4 years agocmd/compiler,cmd/go,sync: add internal {LoadAcq,StoreRel}64 on ppc64
Paul E. Murphy [Wed, 9 Sep 2020 22:24:23 +0000 (17:24 -0500)]
cmd/compiler,cmd/go,sync: add internal {LoadAcq,StoreRel}64 on ppc64

Add an internal atomic intrinsic for load with acquire semantics
(extending LoadAcq to 64b) and add LoadAcquintptr for internal
use within the sync package.  For other arches, this remaps to the
appropriate atomic.Load{,64} intrinsic which should not alter code
generation.

Similarly, add StoreRel{uintptr,64} for consistency, and inline.

Finally, add an exception to allow sync to directly use the
runtime/internal/atomic package which avoids more convoluted
workarounds (contributed by Lynn Boger).

In an extreme example, sync.(*Pool).pin consumes 20% of wall time
during fmt tests.  This is reduced to 5% on ppc64le/power9.

From the fmt benchmarks on ppc64le:

name                           old time/op  new time/op  delta
SprintfPadding                  468ns ± 0%   451ns ± 0%   -3.63%
SprintfEmpty                   73.3ns ± 0%  51.9ns ± 0%  -29.20%
SprintfString                   135ns ± 0%   122ns ± 0%   -9.63%
SprintfTruncateString           232ns ± 0%   214ns ± 0%   -7.76%
SprintfTruncateBytes            216ns ± 0%   202ns ± 0%   -6.48%
SprintfSlowParsingPath          162ns ± 0%   142ns ± 0%  -12.35%
SprintfQuoteString             1.00µs ± 0%  0.99µs ± 0%   -1.39%
SprintfInt                      117ns ± 0%   104ns ± 0%  -11.11%
SprintfIntInt                   190ns ± 0%   175ns ± 0%   -7.89%
SprintfPrefixedInt              232ns ± 0%   212ns ± 0%   -8.62%
SprintfFloat                    270ns ± 0%   255ns ± 0%   -5.56%
SprintfComplex                 1.01µs ± 0%  0.99µs ± 0%   -1.68%
SprintfBoolean                  127ns ± 0%   111ns ± 0%  -12.60%
SprintfHexString                220ns ± 0%   198ns ± 0%  -10.00%
SprintfHexBytes                 261ns ± 0%   252ns ± 0%   -3.45%
SprintfBytes                    600ns ± 0%   590ns ± 0%   -1.67%
SprintfStringer                 684ns ± 0%   658ns ± 0%   -3.80%
SprintfStructure               2.57µs ± 0%  2.57µs ± 0%   -0.12%
ManyArgs                        669ns ± 0%   646ns ± 0%   -3.44%
FprintInt                       140ns ± 0%   136ns ± 0%   -2.86%
FprintfBytes                    184ns ± 0%   181ns ± 0%   -1.63%
FprintIntNoAlloc                140ns ± 0%   136ns ± 0%   -2.86%
ScanInts                        929µs ± 0%   921µs ± 0%   -0.79%
ScanRecursiveInt                122ms ± 0%   121ms ± 0%   -0.11%
ScanRecursiveIntReaderWrapper   122ms ± 0%   122ms ± 0%   -0.18%

Change-Id: I4d66780261b57b06ef600229e475462e7313f0d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/253748
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agomisc/wasm: improve error message if javascript polyfills are required
Richard Musiol [Sun, 11 Oct 2020 08:23:45 +0000 (10:23 +0200)]
misc/wasm: improve error message if javascript polyfills are required

wasm_exec.js expects that either "require" is available or that the
globals "crypto", "TextEncoder" and "TextDecoder" are already defined.
Report a better error message if this is not the case, suggesting the
use of a polyfill.

Updates #41482

Change-Id: I5473cae15c98ae42e39f5928245b7762e7a5a8bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/261357
Trust: Richard Musiol <neelance@gmail.com>
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agomisc/wasm: make sure sp is unsigned
Richard Musiol [Sun, 11 Oct 2020 11:33:53 +0000 (13:33 +0200)]
misc/wasm: make sure sp is unsigned

An i32 passed from WebAssembly to JavaScript is always read as a signed
integer. Use the bitshift operator to turn it into an unsigned integer.

Fixes #40923

Change-Id: Ia91ed2145dd2fc3071e2fc22b86ebfcb3c1e9f4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/261358
Trust: Richard Musiol <neelance@gmail.com>
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/go: enable link syso test on linux/riscv64
Tobias Klauser [Tue, 20 Oct 2020 08:44:07 +0000 (10:44 +0200)]
cmd/go: enable link syso test on linux/riscv64

Now that external linking is supported on linux/riscv64 (CL 243517),
re-enable the test previously disabled by CL 216259.

Updates #36739

Change-Id: I611548c587ca50f8bfab72c903ab0432e2b54198
Reviewed-on: https://go-review.googlesource.com/c/go/+/263797
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
4 years agodoc/go1.16: document net TCP listener's backlog size update
Cuong Manh Le [Tue, 20 Oct 2020 02:51:23 +0000 (09:51 +0700)]
doc/go1.16: document net TCP listener's backlog size update

Updates #41470

Change-Id: Iebd3a339504aa7f8834853d6a740557fb3bce3ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/262938
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agocmd/go: fix TestScript/test_cache_inputs
Jay Conrod [Tue, 20 Oct 2020 22:18:21 +0000 (18:18 -0400)]
cmd/go: fix TestScript/test_cache_inputs

Small fix for a new failure in CL 263142

For #41190

Change-Id: I733bc1998d87b505b52d429916c45afe2968a709
Reviewed-on: https://go-review.googlesource.com/c/go/+/264057
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/compile: fix nodedump output for types of nodes
Dan Scales [Tue, 20 Oct 2020 22:03:33 +0000 (15:03 -0700)]
cmd/compile: fix nodedump output for types of nodes

The Dbg dumping of complex types was broken, because (I think) of a
recent change to handle recursive types correctly. Before this fix,
the Dump output of a closure node (where the last thing on the line is
the type of the node) was:

.   .   CLOSURE l(8) esc(h) tc(1) FUNC-@0

after this change it is:

.   .   CLOSURE l(8) esc(h) tc(1) FUNC-func(int) int

The problem is that that the 'mode == Fdbg' code was immediately
aborting the descent into tconv2, since it was calling down with the
same node that was just entered into the hash table.

Change-Id: Iee106b967cea1856dd92d4350681401dd34a23b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/264025
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: enforce strongly typed rules for ARM (to32)
Constantin Konstantinidis [Thu, 24 Sep 2020 19:44:32 +0000 (21:44 +0200)]
cmd/compile: enforce strongly typed rules for ARM (to32)

Type casting changed to 32 from 64.
L1055-L1056
L1193-L1194, L1197-L1198

toolstash-check successful.

Change-Id: Icdb9985673292294bc4549afaaa6cf4fcf92ffa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/257640
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agotesting: print cpu type as label for benchmarks
Martin Möhrmann [Tue, 20 Oct 2020 07:56:14 +0000 (09:56 +0200)]
testing: print cpu type as label for benchmarks

Supports 386 and amd64 architectures on all operating systems.

Example output:
$ go test -bench=.*
goos: darwin
goarch: amd64
pkg: strconv
cpu: Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz
BenchmarkAtof64Decimal-4         24431032         46.8 ns/op
...

As the displayed CPU information is only used for information
purposes it is lazily initialized when needed using the new
internal/sysinfo package.

This allows internal/cpu to stay without dependencies and avoid
initialization costs when the CPU information is not needed as
the new code to query the CPU name in internal/cpu can be
dead code eliminated if not used.

Fixes #39214

Change-Id: I77ae5c5d2fed6b28fa78dd45075f9f0a6a7f1bfd
Reviewed-on: https://go-review.googlesource.com/c/go/+/263804
Trust: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agogo/build: refactor per-file info & reader
Russ Cox [Mon, 19 Oct 2020 00:26:46 +0000 (20:26 -0400)]
go/build: refactor per-file info & reader

Make code cleaner and a bit more adaptable:
instead of an ever-growing list of arguments and results for readImports,
put everything in a fileInfo struct, and rename function to readGoInfo.
(Not a goInfo struct because it gets used for non-Go source files as well,
but that processing is much simpler.)

The refactoring simplifies the embed work in the next CL,
but this CL makes no semantic changes.

For #41191.

Change-Id: Id2de2a3b8d351adc1c919dcf79dfbe79fc3d5301
Reviewed-on: https://go-review.googlesource.com/c/go/+/243940
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>
4 years agoruntime: use GOTRACEBACK=system for TestCgoExecSignalMask
Ian Lance Taylor [Tue, 20 Oct 2020 19:54:20 +0000 (12:54 -0700)]
runtime: use GOTRACEBACK=system for TestCgoExecSignalMask

Try to get a bit more information to understand #42093.

For #42093

Change-Id: I818feb08d7561151d52eba3e88c418b55b9f9c1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/264018
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>