]> Cypherpunks repositories - gostls13.git/log
gostls13.git
6 years agoRevert "cmd/go: fix the default build output name for versioned binaries"
Dmitri Shuralyov [Wed, 20 Mar 2019 18:16:33 +0000 (18:16 +0000)]
Revert "cmd/go: fix the default build output name for versioned binaries"

This reverts CL 140863 (commit bf94fc3ae387fc09929443393741919fac6727af).

Reason for revert: There was a potential problem spotted in the original
fix, which resulted in it being rolled back from release-branch.go1.12
and not included in Go 1.12.1 release. We intend to improve the fix and
include it in Go 1.12.2 instead. To make the fix easier to backport,
revert this change before re-applying the improved fix (next commit).

Change-Id: If6c785f58482d2531b5927c5ea7002f548c21c7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/168402
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
6 years agocmd/link: add optional sanity checking for duplicate symbols
Than McIntosh [Thu, 21 Mar 2019 13:20:11 +0000 (09:20 -0400)]
cmd/link: add optional sanity checking for duplicate symbols

Introduce a new linker command line option "-strictdups", which
enables sanity checking of "ok to duplicate" symbols, especially
DWARF info symbols. Acceptable values are 0 (no checking) 1 (issue
warnings) and 2 (issue a fatal error checks fail).

Currently if we read a DWARF symbol (such as "go.info.PKG.FUNCTION")
from one object file, and then encounter the same symbol later on
while reading another object file, we simply discard the second one
and move on with the link, since the two should in theory be
identical.

If as a result of a compiler bug we wind up with symbols that are not
identical, this tends to (silently) result in incorrect DWARF
generation, which may or may not be discovered depending on who is
consuming the DWARF and what's being done with it.

When this option is turned on, at the point where a duplicate
symbol is detected in the object file reader, we check to make sure
that the length/contents of the symbol are the same as the previously
read symbol, and print a descriptive warning (or error) if not.

For the time being this can be used for one-off testing to find
problems; at some point it would be nice if we can enable it by
default.

Updates #30908.

Change-Id: I64c4e07c326b4572db674ff17c93307e2eec607c
Reviewed-on: https://go-review.googlesource.com/c/go/+/168410
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/compile: reduce rulegen's for loop verbosity
Daniel Martí [Wed, 13 Mar 2019 11:57:29 +0000 (11:57 +0000)]
cmd/compile: reduce rulegen's for loop verbosity

A lot of the naked for loops begin like:

for {
v := b.Control
if v.Op != OpConstBool {
break
}
...
return true
}

Instead, write them out in a more compact and readable way:

for v.Op == OpConstBool {
...
return true
}

This requires the addition of two bytes.Buffer writers, as this helps us
make a decision based on future pieces of generated code. This probably
makes rulegen slightly slower, but that's not noticeable; the code
generation still takes ~3.5s on my laptop, excluding build time.

The "v := b.Control" declaration can be moved to the top of each
function. Even though the rules can modify b.Control when firing, they
also make the function return, so v can't be used again.

While at it, remove three unnecessary lines from the top of each
rewriteBlock func.

In total, this results in ~4k lines removed from the generated code, and
a slight improvement in readability.

Change-Id: I317e4c6a4842c64df506f4513375475fad2aeec5
Reviewed-on: https://go-review.googlesource.com/c/go/+/167399
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoos,syscall: implement functions related to uid, gid and pid on js/wasm
Richard Musiol [Thu, 13 Dec 2018 20:56:45 +0000 (21:56 +0100)]
os,syscall: implement functions related to uid, gid and pid on js/wasm

This change implements the following functions on js/wasm:
- os.Chown
- os.Fchown
- os.Lchown
- syscall.Getuid
- syscall.Getgid
- syscall.Geteuid
- syscall.Getegid
- syscall.Getgroups
- syscall.Getpid
- syscall.Getppid
- syscall.Umask

Change-Id: Icdb0fafc02c9df6e9e3573542f8499c3464dc671
Reviewed-on: https://go-review.googlesource.com/c/go/+/154157
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: follow up intrinsifying math/bits.Add64 for arm64
erifan01 [Thu, 21 Mar 2019 03:24:47 +0000 (03:24 +0000)]
cmd/compile: follow up intrinsifying math/bits.Add64 for arm64

This CL deals with the additional comments of CL 159017.

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

6 years agosort: replace Errorf+FailNow with Fatalf
Iskander Sharipov [Fri, 22 Mar 2019 12:30:30 +0000 (15:30 +0300)]
sort: replace Errorf+FailNow with Fatalf

Change-Id: I4f8d0178e780b86d1f551b367e2ddac3789be5aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/168880
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd: enable -buildmode=pie on aix/ppc64
Clément Chigot [Fri, 22 Mar 2019 11:54:37 +0000 (12:54 +0100)]
cmd: enable -buildmode=pie on aix/ppc64

Change-Id: I939518462c931ba9feb125b2f299ef0706b124ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/168879
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile, misc/cgo: fix fortran tests on aix/ppc64
Clément Chigot [Fri, 22 Mar 2019 11:48:31 +0000 (12:48 +0100)]
cmd/compile, misc/cgo: fix fortran tests on aix/ppc64

Enable pattern lib.a/shared.so.X in cgo_import_dynamic as on AIX,
archive files (.a) often have shared objects (.so) inside them.

Change-Id: I21096c75eb7fbcc7064b0b832bfa8ed862142051
Reviewed-on: https://go-review.googlesource.com/c/go/+/168877
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agosyscall: fix returned values of Dup2 on aix/ppc64
Clément Chigot [Fri, 22 Mar 2019 11:52:54 +0000 (12:52 +0100)]
syscall: fix returned values of Dup2 on aix/ppc64

Change-Id: Ia78ea589cc6d58ff22f7d519399c06c5308419dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/168878
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>

6 years agoimage/png: add Fuzz function
Andrei Tudor Călin [Thu, 21 Mar 2019 15:04:25 +0000 (16:04 +0100)]
image/png: add Fuzz function

Add a Fuzz function to package png, under the gofuzz build
tag. This function is based on the png/png.go code, from
github.com/dvyukov/go-fuzz-corpus, modified to use direct
comparison of image bounds rather than reflect.DeepEqual.

Updates #30979
Updates #19109

Change-Id: Idb86e7ded0c2d78e6cadbeda84c7b1f35b8c579c
Reviewed-on: https://go-review.googlesource.com/c/go/+/168558
Reviewed-by: thepudds <thepudds1460@gmail.com>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>

6 years agomisc/cgo: gofmt testdata files
Tobias Klauser [Thu, 21 Mar 2019 12:30:25 +0000 (13:30 +0100)]
misc/cgo: gofmt testdata files

Change-Id: I64e05a1f768cb57194506021bb7fdca0ad19bf1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/168461
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: stop shadowing bool type in rewrite rules
Josh Bleecher Snyder [Thu, 21 Mar 2019 16:32:03 +0000 (09:32 -0700)]
cmd/compile: stop shadowing bool type in rewrite rules

This disrupts code instrumentation tools like go-fuzz.

Change-Id: I524f31316975096ca5e3b1203a82e91ed1b6097e
Reviewed-on: https://go-review.googlesource.com/c/go/+/168801
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/link/internal/wasm: optimize data section in wasm binary
Richard Musiol [Sun, 17 Mar 2019 14:51:30 +0000 (15:51 +0100)]
cmd/link/internal/wasm: optimize data section in wasm binary

This change optimizes the data section in the wasm binary by
omitting blocks of zeroes and instead emitting data segments
with offsets skipping the zeroes.

This optimization is inspired by the memory-packing pass of the
wasm-opt tool and reduces the wasm binary size of "hello world" by 14%.

Change-Id: Iba3043df05bf6aab4745c5f8015c0337fc218aff
Reviewed-on: https://go-review.googlesource.com/c/go/+/167801
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agoimage/gif: don't assume Encode src's origin is (0, 0)
Nigel Tao [Thu, 21 Mar 2019 04:08:41 +0000 (15:08 +1100)]
image/gif: don't assume Encode src's origin is (0, 0)

When gif.Encode is given an "m image.Image" argument that isn't an
*image.Paletted, it creates a temporary *image.Paletted (called pm) that
is intended to be a copy of this image, only with fewer colors.

That creation process, and specifically the opts.Drawer.Draw call that
does the copy, incorrectly assumed that m.Bounds().Min is the zero point
(0, 0). This commit fixes that.

Fixes #30887

Change-Id: Ie03bddec359e2dcc52f18451049452105514e179
Reviewed-on: https://go-review.googlesource.com/c/go/+/168418
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agocmd/compile: copy volatile values before emitting write barrier call
Cherry Zhang [Thu, 21 Mar 2019 17:40:28 +0000 (13:40 -0400)]
cmd/compile: copy volatile values before emitting write barrier call

It is possible that a "volatile" value (one that can be clobbered
by preparing args of a call) to be used in multiple write barrier
calls. We used to copy the volatile value right before each call.
But this doesn't work if the value is used the second time, after
the first call where it is already clobbered. Copy it before
emitting any call.

Fixes #30977.

Change-Id: Iedcc91ad848d5ded547bf37a8359c125d32e994c
Reviewed-on: https://go-review.googlesource.com/c/go/+/168677
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/link/internal/ld: don't leave files open in a loop
Elias Naur [Thu, 21 Mar 2019 15:41:48 +0000 (16:41 +0100)]
cmd/link/internal/ld: don't leave files open in a loop

Noticed by Ingo Oeser in his review of CL 168321.

Change-Id: I2f39db675a7c22b395062a11903657a9d0d1956d
Reviewed-on: https://go-review.googlesource.com/c/go/+/168560
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go/internal/modfetch: update comment referring to old Import function
Dmitri Shuralyov [Mon, 11 Mar 2019 13:15:38 +0000 (09:15 -0400)]
cmd/go/internal/modfetch: update comment referring to old Import function

The Import function was moved from modfetch/repo.go to modload/import.go
in vgo CL 122880, and its semantics have changed in vgo CL 123095 to do
more than just searching for a module. Both of these changes were ported
to cmd/go in CL 123576.

Delete the mention of the old Import function from the modfetch/repo.go
comment, since what it refers to does not exist anymore.

Change-Id: I6dc6984128152cf9611d30fbc4e6418e91a7641f
Reviewed-on: https://go-review.googlesource.com/c/go/+/166597
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agocmd/go/internal/modfetch: update TestCodeRepo for gopkg.in/yaml.v2
Alberto Donizetti [Thu, 21 Mar 2019 17:22:58 +0000 (18:22 +0100)]
cmd/go/internal/modfetch: update TestCodeRepo for gopkg.in/yaml.v2

New release, it broke again the longtest builder. Align the expected
data with the current release.

Making these tests independent of external repositories is #28856.

This fixes the longtest builder.

Updates #28856

Change-Id: I32d2f3325af828d26ab417a5e986e3aeefa1a897
Reviewed-on: https://go-review.googlesource.com/c/go/+/168561
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: regenerate rewrite rules
Josh Bleecher Snyder [Thu, 21 Mar 2019 16:16:56 +0000 (09:16 -0700)]
cmd/compile: regenerate rewrite rules

Change-Id: I7e921b7b4665ff76dc8bae493b2a49318690770b
Reviewed-on: https://go-review.googlesource.com/c/go/+/168637
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agomisc/ios: don't override GOCACHE on the device
Elias Naur [Thu, 21 Mar 2019 14:15:40 +0000 (15:15 +0100)]
misc/ios: don't override GOCACHE on the device

The iOS exec wrapper copies the environment variables to the binary
running on the device. However, some variables such as HOME, TMPDIR and
GOCACHE refer to directories that might not be valid on the device.

The wrapper already ignores HOME and TMPDIR, but after GO111MODULE
was flipped to on for the standard library, cmd/go tests started
failing without a valid and writable GOCACHE.

It took a while to reproduce because go test does not set an explicit
GOCACHE but cmd/dist test does.

Fixes #30914

Change-Id: If186cddc5cfd7ad39a0b3eb95f9c64a7d53a27e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/168557
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agomisc/android: pass on GOPROXY to device environment
Elias Naur [Tue, 19 Mar 2019 05:59:51 +0000 (06:59 +0100)]
misc/android: pass on GOPROXY to device environment

Android devices don't have git available, so many go tool commands
that fetch dependencies fail. Builders already have a GOPROXY
available, so pass that along to the device environment.

Updates #30885

Change-Id: Id0d2338932f0cd7de4d95d9e0ca9b79d29336ffe
Reviewed-on: https://go-review.googlesource.com/c/go/+/168118
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoos/exec: add Cmd.String
Josh Bleecher Snyder [Wed, 20 Mar 2019 21:09:51 +0000 (14:09 -0700)]
os/exec: add Cmd.String

The initial implementation is intentionally simple.
Let's see how far it gets us.

Fixes #30638

Change-Id: I240afae2b401744ab2ff2a69952c4eb0fd3feb56
Reviewed-on: https://go-review.googlesource.com/c/go/+/168518
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/link: skip TestBuildFortvOS if the SDK is missing
Elias Naur [Thu, 21 Mar 2019 12:42:53 +0000 (13:42 +0100)]
cmd/link: skip TestBuildFortvOS if the SDK is missing

While we're here, move the test from dwarf_test.go to link_test.go;
it doesn't have anything to do with DWARF.

Should fix the macOS builders with only the Xcode command line tools
installed.

Change-Id: Iaaba1b589f4d778705f7b627f78c2b12388e2b3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/168462
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
6 years agocmd/link/internal/ld: copy Mach-O platform version commands to go.o
Elias Naur [Tue, 19 Mar 2019 11:19:48 +0000 (13:19 +0200)]
cmd/link/internal/ld: copy Mach-O platform version commands to go.o

To build for watchOS and tvOS the Apple toolchain requires a Mach-O
load command that matches the platform for all object files in a build.
The go.o object file produced by the Go linker contains no such command.

The loader commands are mutually exclusive so we need to pick the
right one. Fortunately, cgo must be enabled for watchOS and tvOS to
be useful, so we can copy the first loader command we find in the object
files produced by the host compiler.

Add a test that builds a small program for tvOS to test both this CL
and the previous CL that added bitcode support.

Updates #22395

Change-Id: I7a47d19be9d80f0459dc358c600cddd9f236c444
Reviewed-on: https://go-review.googlesource.com/c/go/+/168321
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/link/internal/ld: extract Mach-O load command parsing
Elias Naur [Wed, 20 Mar 2019 19:10:38 +0000 (20:10 +0100)]
cmd/link/internal/ld: extract Mach-O load command parsing

We're going to need the ability to extract the LC_VERSION_MIN_* and
LC_BUILD_VERSION load commands. This CL adds peekMachoPlatform to do
that and in the process simplifies machoCombineDwarf.

While here, disable DWARF combining for Apple platforms other than
macOS (watchOS, tvOS, bridgeOS), not just iOS.

Updates #22395

Change-Id: I4862b0f15ccc87b7be1a6532b4d37b47c8f7f243
Reviewed-on: https://go-review.googlesource.com/c/go/+/168459
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/link/internal/ld: enable bitcode builds for iOS, tvOS, watchOS
Elias Naur [Sun, 17 Mar 2019 16:48:57 +0000 (17:48 +0100)]
cmd/link/internal/ld: enable bitcode builds for iOS, tvOS, watchOS

The Go toolchain cannot output bitcode, but there is a trick where
object code can be marked with an __asm section, persuading the
Apple toolchain to include our object code in bitcode builds.

This enables Go builds with bitcode enabled; the next CL adds
the necessary plumbing for building on tvOS and watchOS.

Thanks to Aman Gupta for the trick.

Test is added two CLs from here.

Fixes #22395 (at least until Apple tightens bitcode requirements.)

Change-Id: Ic1c1448c4d46222bb3dd097b1f4df80848051e5f
Reviewed-on: https://go-review.googlesource.com/c/go/+/168320
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agotesting: stop rounding b.N
Josh Bleecher Snyder [Tue, 12 Mar 2019 03:21:27 +0000 (20:21 -0700)]
testing: stop rounding b.N

The original goal of rounding to readable b.N
was to make it easier to eyeball times.
However, proper analysis requires tooling
(such as benchstat) anyway.

Instead, take b.N as it comes.
This will reduce the impact of external noise
such as GC on benchmarks.

This requires reworking our iteration estimates.
We used to calculate the estimated ns/op
and then divide our target ns by that estimate.
However, this order of operations was destructive
when the ns/op was very small; rounding could
hide almost an order of magnitude of variation.
Instead, multiply first, then divide.
Also, make n an int64 to avoid overflow.

Prior to this change, we attempted to cap b.N at 1e9.
Due to rounding up, it was possible to get b.N as high as 2e9.
This change consistently enforces the 1e9 cap.

This change also reduces the wall time required to run benchmarks.

Here's the impact of this change on the wall time to run
all benchmarks once with benchtime=1s on some std packages:

name           old time/op       new time/op       delta
bytes                 306s ± 1%         238s ± 1%  -22.24%  (p=0.000 n=10+10)
encoding/json         112s ± 8%          99s ± 7%  -11.64%  (p=0.000 n=10+10)
net/http             54.7s ± 7%        44.9s ± 4%  -17.94%  (p=0.000 n=10+9)
runtime               957s ± 1%         714s ± 0%  -25.38%  (p=0.000 n=10+9)
strings               262s ± 1%         201s ± 1%  -23.27%  (p=0.000 n=10+10)
[Geo mean]            216s              172s       -20.23%

Updates #24735

Change-Id: I7e38efb8e23c804046bf4fc065b3f5f3991d0a15
Reviewed-on: https://go-review.googlesource.com/c/go/+/112155
Reviewed-by: Austin Clements <austin@google.com>
6 years agocmd/compile/internal, cmd/internal/obj/ppc64: generate new count trailing zeros instr...
Carlos Eduardo Seo [Fri, 8 Feb 2019 18:18:12 +0000 (16:18 -0200)]
cmd/compile/internal, cmd/internal/obj/ppc64: generate new count trailing zeros instructions on POWER9

This change adds new POWER9 instructions for counting trailing zeros (CNTTZW/CNTTZD)
to the assembler and generates them in SSA when GOPPC64=power9.

name                 old time/op  new time/op  delta
TrailingZeros-160    1.59ns ±20%  1.45ns ±10%  -8.81%  (p=0.000 n=14+13)
TrailingZeros8-160   1.55ns ±23%  1.62ns ±44%    ~     (p=0.593 n=13+15)
TrailingZeros16-160  1.78ns ±23%  1.62ns ±38%  -9.31%  (p=0.003 n=14+14)
TrailingZeros32-160  1.64ns ±10%  1.49ns ± 9%  -9.15%  (p=0.000 n=13+14)
TrailingZeros64-160  1.53ns ± 6%  1.45ns ± 5%  -5.38%  (p=0.000 n=15+13)

Change-Id: I365e6ff79f3ce4d8ebe089a6a86b1771853eb596
Reviewed-on: https://go-review.googlesource.com/c/go/+/167517
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
6 years agocmd/compile: port callnew to ssa conversion
Josh Bleecher Snyder [Sun, 17 Mar 2019 14:14:12 +0000 (07:14 -0700)]
cmd/compile: port callnew to ssa conversion

This is part of a general effort to shrink walk.
In an ideal world, we'd have an SSA op for allocation,
but we don't yet have a good mechanism for introducing
function calling during SSA compilation.
In the meantime, SSA conversion is a better place for it.

This also makes it easier to introduce new optimizations;
instead of doing the typecheck walk dance,
we can simply write what we want the backend to do.

I introduced a new opcode in this change because:

(a) It avoids a class of bugs involving correctly detecting
    whether this ONEW is a "before walk" ONEW or an "after walk" ONEW.
    It also means that using ONEW or ONEWOBJ in the wrong context
    will generally result in a faster failure.
(b) Opcodes are cheap.
(c) It provides a better place to put documentation.

This change also is also marginally more performant:

name        old alloc/op      new alloc/op      delta
Template         39.1MB ± 0%       39.0MB ± 0%  -0.14%  (p=0.008 n=5+5)
Unicode          28.4MB ± 0%       28.4MB ± 0%    ~     (p=0.421 n=5+5)
GoTypes           132MB ± 0%        132MB ± 0%  -0.23%  (p=0.008 n=5+5)
Compiler          608MB ± 0%        607MB ± 0%  -0.25%  (p=0.008 n=5+5)
SSA              2.04GB ± 0%       2.04GB ± 0%  -0.01%  (p=0.008 n=5+5)
Flate            24.4MB ± 0%       24.3MB ± 0%  -0.13%  (p=0.008 n=5+5)
GoParser         29.3MB ± 0%       29.1MB ± 0%  -0.54%  (p=0.008 n=5+5)
Reflect          84.8MB ± 0%       84.7MB ± 0%  -0.21%  (p=0.008 n=5+5)
Tar              36.7MB ± 0%       36.6MB ± 0%  -0.10%  (p=0.008 n=5+5)
XML              48.7MB ± 0%       48.6MB ± 0%  -0.24%  (p=0.008 n=5+5)
[Geo mean]       85.0MB            84.8MB       -0.19%

name        old allocs/op     new allocs/op     delta
Template           383k ± 0%         382k ± 0%  -0.26%  (p=0.008 n=5+5)
Unicode            341k ± 0%         341k ± 0%    ~     (p=0.579 n=5+5)
GoTypes           1.37M ± 0%        1.36M ± 0%  -0.39%  (p=0.008 n=5+5)
Compiler          5.59M ± 0%        5.56M ± 0%  -0.49%  (p=0.008 n=5+5)
SSA               16.9M ± 0%        16.9M ± 0%  -0.03%  (p=0.008 n=5+5)
Flate              238k ± 0%         238k ± 0%  -0.23%  (p=0.008 n=5+5)
GoParser           306k ± 0%         303k ± 0%  -0.93%  (p=0.008 n=5+5)
Reflect            990k ± 0%         987k ± 0%  -0.33%  (p=0.008 n=5+5)
Tar                356k ± 0%         355k ± 0%  -0.20%  (p=0.008 n=5+5)
XML                444k ± 0%         442k ± 0%  -0.45%  (p=0.008 n=5+5)
[Geo mean]         848k              845k       -0.33%

Change-Id: I2c36003a7cbf71b53857b7de734852b698f49310
Reviewed-on: https://go-review.googlesource.com/c/go/+/167957
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agocmd: update vendored x/tools
Daniel Martí [Wed, 20 Mar 2019 16:17:56 +0000 (16:17 +0000)]
cmd: update vendored x/tools

This lets us get rid of a handful of cmd/vet/whitelist/all.txt entries,
since the stdmethods pass is now happy with the encoding/xml package.

Change-Id: I9de2190984dd00342903967262790c7f6b1f0a75
Reviewed-on: https://go-review.googlesource.com/c/go/+/168458
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoos: make errors.Is work with ErrPermission et al.
Damien Neil [Tue, 19 Feb 2019 21:03:55 +0000 (13:03 -0800)]
os: make errors.Is work with ErrPermission et al.

As proposed in Issue #29934, update errors produced by the os package to
work with errors.Is sentinel tests. For example,
errors.Is(err, os.ErrPermission) is equivalent to os.IsPermission(err)
with added unwrapping support.

Move the definition for os.ErrPermission and others into the syscall
package. Add an Is method to syscall.Errno and others. Add an Unwrap
method to os.PathError and others.

Updates #30322
Updates #29934

Change-Id: I95727d26c18a5354c720de316dff0bffc04dd926
Reviewed-on: https://go-review.googlesource.com/c/go/+/163058
Reviewed-by: Marcel van Lohuizen <mpvl@golang.org>
6 years agocmd/dist: enable cgo for aix/ppc64
Clément Chigot [Thu, 21 Feb 2019 09:58:42 +0000 (10:58 +0100)]
cmd/dist: enable cgo for aix/ppc64

Change-Id: I78be2b0b857d1ea2fb0b6906eb5afd796580f52d
Reviewed-on: https://go-review.googlesource.com/c/go/+/164019
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/dist, misc/cgo: enable tests for aix/ppc64
Clément Chigot [Thu, 21 Feb 2019 09:56:35 +0000 (10:56 +0100)]
cmd/dist, misc/cgo: enable tests for aix/ppc64

Some cgo tests aren't yet available on aix/ppc64.
-shared and -static don't work as expected and will be fixed latter.

Updates #30565

Change-Id: Ic59cabe685cb1cbdf89a8d1d1a1d2c4b0e8ef442
Reviewed-on: https://go-review.googlesource.com/c/go/+/164018
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/nm: fix cgo tests for aix/ppc64
Clément Chigot [Thu, 21 Feb 2019 09:50:29 +0000 (10:50 +0100)]
cmd/nm: fix cgo tests for aix/ppc64

This commit handles AIX cgo in cmd/nm tests.

Change-Id: I6753a0102e4f2c4c7bd4d7c999f62a0cb3d2183c
Reviewed-on: https://go-review.googlesource.com/c/go/+/164017
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoos: add PathError.Unwrap
Jonathan Amsterdam [Mon, 18 Mar 2019 12:06:49 +0000 (08:06 -0400)]
os: add PathError.Unwrap

Add an Unwrap method to PathError so it works with the errors.Is/As
functions.

Change-Id: Ia6171c0418584f3cd53ee99d97c687941a9e3109
Reviewed-on: https://go-review.googlesource.com/c/go/+/168097
Reviewed-by: Damien Neil <dneil@google.com>
6 years agoos: fix windows Lstat missing name for some files
LE Manh Cuong [Sun, 17 Mar 2019 04:56:29 +0000 (11:56 +0700)]
os: fix windows Lstat missing name for some files

On Windows, GetFileAttributesEx fails with ERROR_SHARING_VIOLATION for
some files, like c:\pagefile.sys. In this case,
newFileStatFromWin32finddata is used to fill file info, but it does not fill
name and path.

After getting file stat from newFileStatFromWin32finddata, just set file info
name and path before return fixes the issue.

Fixes #30883

Change-Id: I654e96c634e8a9bf5ce7e1aaa93968e88953620d
Reviewed-on: https://go-review.googlesource.com/c/go/+/167779
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
6 years agoruntime: disable event scanning error reporting on solaris
Mikio Hara [Tue, 19 Mar 2019 09:32:11 +0000 (18:32 +0900)]
runtime: disable event scanning error reporting on solaris

It seems like we need to pay special attention to capturing error
condition on the event port of SmartOS. The previous attempt CL 167777
works on Oracle Solaris but doesn't work on SmartOS for the uncertain
reason. It's better to disable the reporting for now.

Updates #30624.
Fixes #30840.

Change-Id: Ieca5dac4fceb7e8c9cb4db149bb4c2e79691588c
Reviewed-on: https://go-review.googlesource.com/c/go/+/167782
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: intrinsify math/bits.Add64 for arm64
erifan01 [Mon, 14 Jan 2019 09:36:18 +0000 (09:36 +0000)]
cmd/compile: intrinsify math/bits.Add64 for arm64

This CL instrinsifies Add64 with arm64 instruction sequence ADDS, ADCS
and ADC, and optimzes the case of carry chains.The CL also changes the
test code so that the intrinsic implementation can be tested.

Benchmarks:
name               old time/op       new time/op       delta
Add-224            2.500000ns +- 0%  2.090000ns +- 4%  -16.40%  (p=0.000 n=9+10)
Add32-224          2.500000ns +- 0%  2.500000ns +- 0%     ~     (all equal)
Add64-224          2.500000ns +- 0%  1.577778ns +- 2%  -36.89%  (p=0.000 n=10+9)
Add64multiple-224  6.000000ns +- 0%  2.000000ns +- 0%  -66.67%  (p=0.000 n=10+10)

Change-Id: I6ee91c9a85c16cc72ade5fd94868c579f16c7615
Reviewed-on: https://go-review.googlesource.com/c/go/+/159017
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/go: fix minor grammatical nit: command-line is an adjective...
Rob Pike [Wed, 20 Mar 2019 00:32:59 +0000 (11:32 +1100)]
cmd/go: fix minor grammatical nit: command-line is an adjective...

while command line is a noun.

Change-Id: I9dfc2f6841d1171854857a8daa785d55afe2c5f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/167783
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/internal/obj/x86: slightly optimize ADJSP encoding
Josh Bleecher Snyder [Tue, 19 Mar 2019 17:40:52 +0000 (10:40 -0700)]
cmd/internal/obj/x86: slightly optimize ADJSP encoding

This shaves a few bytes off here and there.

file    before    after     Δ       %
buildid 2865992   2861896   -4096   -0.143%
pprof   14744060  14739964  -4096   -0.028%
trace   11680644  11676548  -4096   -0.035%
vet     8448240   8444144   -4096   -0.048%

Change-Id: I799034afabc06a37b535301cd1380d63b4461095
Reviewed-on: https://go-review.googlesource.com/c/go/+/168343
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Martin Möhrmann <martisch@uos.de>
6 years agocmd/compile: slightly optimize adding 128
Josh Bleecher Snyder [Tue, 19 Mar 2019 19:26:22 +0000 (12:26 -0700)]
cmd/compile: slightly optimize adding 128

'SUBQ $-0x80, r' is shorter to encode than 'ADDQ $0x80, r',
and functionally equivalent. Use it instead.

Shaves off a few bytes here and there:

file    before    after     Δ       %
compile 25935856  25927664  -8192   -0.032%
nm      4251840   4247744   -4096   -0.096%

Change-Id: Ia9e02ea38cbded6a52a613b92e3a914f878d931e
Reviewed-on: https://go-review.googlesource.com/c/go/+/168344
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/internal/obj/x86: minor clean-up in span6
Josh Bleecher Snyder [Mon, 18 Mar 2019 14:33:43 +0000 (07:33 -0700)]
cmd/internal/obj/x86: minor clean-up in span6

* Reduce the scope of q.
* Remove duplicate handling of AADJSP.
* Move ab declaration closer to use.
* Collapse nested if statements.
* Change declaration of n for increased readability in context.
* Simplify AADJSP handling.

Passes toolstash-check.

Change-Id: I046369477db567f2f7c4a9c8d400ec9dd9c32f3f
Reviewed-on: https://go-review.googlesource.com/c/go/+/168342
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: fix ssa/debug_test.go reference file
David Chase [Tue, 19 Mar 2019 17:11:15 +0000 (17:11 +0000)]
cmd/compile: fix ssa/debug_test.go reference file

Behavior improved, file expects old worse behavior.
Update file to expect newer, better output.

Fixes #30912.

Change-Id: I410bdaacdb77a4620656753c8c0dc2d4d5378985
Reviewed-on: https://go-review.googlesource.com/c/go/+/168377
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
6 years agocmd/compile: move flagalloc op splitting to rewrite rules
Josh Bleecher Snyder [Sun, 10 Mar 2019 15:34:59 +0000 (08:34 -0700)]
cmd/compile: move flagalloc op splitting to rewrite rules

Flagalloc has the unenviable task of splitting
flag-generating ops that have been merged with loads
when the flags need to "spilled" (i.e. regenerated).
Since there weren't very many of them, there was a hard-coded list
of ops and bespoke code written to split them.

This change migrates load splitting into rewrite rules,
to make them easier to maintain.

Change-Id: I7750eafb888a802206c410f9c341b3133e7748b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/166978
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agointernal/bytealg: add assembly implementation of Count/CountString on arm
Tobias Klauser [Tue, 19 Mar 2019 13:54:40 +0000 (14:54 +0100)]
internal/bytealg: add assembly implementation of Count/CountString on arm

Simple single-byte loop count for now, to be further improved in future
CLs.

Benchmark on linux/arm:

name               old time/op    new time/op     delta
CountSingle/10-4      122ns ± 0%       87ns ± 1%  -28.41%  (p=0.000 n=7+10)
CountSingle/32-4      242ns ± 0%      174ns ± 1%  -28.25%  (p=0.000 n=10+10)
CountSingle/4K-4     24.2µs ± 1%     15.6µs ± 1%  -35.42%  (p=0.000 n=10+10)
CountSingle/4M-4     29.6ms ± 1%     21.3ms ± 1%  -28.09%  (p=0.000 n=10+9)
CountSingle/64M-4     562ms ± 0%      414ms ± 1%  -26.23%  (p=0.000 n=8+10)

name               old speed      new speed       delta
CountSingle/10-4   81.7MB/s ± 1%  114.5MB/s ± 1%  +40.07%  (p=0.000 n=10+10)
CountSingle/32-4    132MB/s ± 0%    184MB/s ± 1%  +39.39%  (p=0.000 n=10+9)
CountSingle/4K-4    170MB/s ± 1%    263MB/s ± 1%  +54.86%  (p=0.000 n=10+10)
CountSingle/4M-4    142MB/s ± 1%    197MB/s ± 1%  +39.07%  (p=0.000 n=10+9)
CountSingle/64M-4   119MB/s ± 0%    162MB/s ± 1%  +35.55%  (p=0.000 n=8+10)

Updates #29001

Change-Id: I42a268215a62044286ec32b548d8e4b86b9570ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/168319
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agotesting: add B.ReportMetric for custom benchmark metrics
Austin Clements [Mon, 11 Mar 2019 14:27:11 +0000 (10:27 -0400)]
testing: add B.ReportMetric for custom benchmark metrics

This adds a ReportMetric method to testing.B that lets the user report
custom benchmark metrics and override built-in metrics.

Fixes #26037.

Change-Id: I8236fbde3683fc27bbe45cbbedfd377b435edf64
Reviewed-on: https://go-review.googlesource.com/c/go/+/166717
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agonet/http: fix wrong mime rar signature
LE Manh Cuong [Tue, 19 Mar 2019 09:16:50 +0000 (16:16 +0700)]
net/http: fix wrong mime rar signature

MIME sniffing standard defines the RAR signature as 52 61 72 20 1A 07 00.

But this signature is wrong, the RARlab spec defines the 4th byte must
be 0x21 or "!", not 0x20 or " ". Checking a rar file also indicates that:

$ file abc.rar
abc.rar: RAR archive data, v1d, os: Win32
$ head -c 7 abc.rar | od -v -t x1
0000000 52 61 72 21 1a 07 00
0000007

There is also an issue to fix this problem in MIME standard.

See:
 - https://www.rarlab.com/technote.htm#rarsign
 - https://github.com/whatwg/mimesniff/issues/63

Fixes #30926

Change-Id: Id2e2de7ecbf7f44d37ebaf280efd05e4972c5078
Reviewed-on: https://go-review.googlesource.com/c/go/+/167781
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go/internal/work: whitelist tvOS and watchOS compiler flags
Elias Naur [Tue, 19 Mar 2019 13:52:10 +0000 (15:52 +0200)]
cmd/go/internal/work: whitelist tvOS and watchOS compiler flags

Updates #22395

Change-Id: I6c207934b32d38374875f756c4f8c6dfe38d8cb0
Reviewed-on: https://go-review.googlesource.com/c/go/+/168318
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/cgo: accept __uint8_t as the uint8_t type
Ian Lance Taylor [Tue, 19 Mar 2019 13:51:14 +0000 (06:51 -0700)]
cmd/cgo: accept __uint8_t as the uint8_t type

This works around the NetBSD <stdint.h> which defines the type using
"#define" rather than typedef.

Fixes #30918
Updates #29878

Change-Id: I8998eba52139366ae46762bdad5fcae85f9b4027
Reviewed-on: https://go-review.googlesource.com/c/go/+/168337
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go: avoid link error when -coverpkg covers main packages (more)
Jay Conrod [Mon, 18 Mar 2019 22:35:44 +0000 (18:35 -0400)]
cmd/go: avoid link error when -coverpkg covers main packages (more)

This fixes two problems missed in CL 164877.

First, p.Internal.BuildInfo is now part of the cache key. This is
important since p.Internal.BuildInfo causes the build action to
synthesize a new source file, which affects the output.

Second, recompileForTest is always called for test
packages. Previously, it was only called when there were internal test
sources, so the fix in CL 164877 did not apply to packages that only
had external tests.

Fixes #30374

Change-Id: Iac2d7e8914f0313f9ab4222299a866f67889eb2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/168200
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/internal/goobj: add XCOFF support to TestParseCGOArchive
Clément Chigot [Thu, 21 Feb 2019 09:49:22 +0000 (10:49 +0100)]
cmd/internal/goobj: add XCOFF support to TestParseCGOArchive

Change-Id: I9d14142977b4f2e8cb7ed33582249d0448bae023
Reviewed-on: https://go-review.googlesource.com/c/go/+/164016
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime/cgo: correct cgo_export directives in callbacks_aix.go
Clément Chigot [Tue, 19 Mar 2019 13:00:03 +0000 (14:00 +0100)]
runtime/cgo: correct cgo_export directives in callbacks_aix.go

This commit removes spaces which were wrongly added in
//go:cgo_export_static during CL 164010.

Change-Id: Iadd18efdde9ff32e907d793a72ef0f9efda35fe6
Reviewed-on: https://go-review.googlesource.com/c/go/+/168317
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: fix sigfwd for aix/ppc64
Clément Chigot [Thu, 21 Feb 2019 09:46:47 +0000 (10:46 +0100)]
runtime: fix sigfwd for aix/ppc64

This commit fixes runtime.sigfwd for aix/ppc64. fn is a function
descriptor and not a function. R2 must be saved and restored.

Change-Id: Ie506b0bdde562ca37202d19973ba1d537c3d64e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/164015
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime, internal/poll: report only critical event scanning error
Mikio Hara [Thu, 14 Mar 2019 20:10:08 +0000 (05:10 +0900)]
runtime, internal/poll: report only critical event scanning error

This change makes the runtime-integrated network poller report only
critical event scanning errors.

In the previous attempt, CL 166497, we treated any combination of error
events as event scanning errors and it caused false positives in event
waiters because platform-dependent event notification mechanisms allow
event originators to use various combination of events.

To avoid false positives, this change makes the poller treat an
individual error event as a critical event scanning error by the
convention of event notification mechanism implementations.

Updates #30624.
Fixes #30817.
Fixes #30840.

Change-Id: I906c9e83864527ff73f636fd02bab854d54684ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/167777
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: enable external linker tests for aix/ppc64
Clément Chigot [Thu, 21 Feb 2019 09:45:40 +0000 (10:45 +0100)]
runtime: enable external linker tests for aix/ppc64

Change-Id: Icc42843adb15c2aba1cfea854fad049c6704344b
Reviewed-on: https://go-review.googlesource.com/c/go/+/164014
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agointernal/poll, os: cancel pending I/O when closing pipes on Windows
Wèi Cōngruì [Mon, 4 Mar 2019 10:07:07 +0000 (10:07 +0000)]
internal/poll, os: cancel pending I/O when closing pipes on Windows

When closing a pipe, use CancelIoEx to cancel pending I/O.
This makes concurrent Read and Write calls return os.ErrClosed.

This change also enables some pipe tests on Windows.

Fixes #28477
Fixes #25835

Change-Id: If52bb7d80895763488a61632e4682a78336e8420
Reviewed-on: https://go-review.googlesource.com/c/go/+/164721
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: disable pprof test with cgo on aix/ppc64
Clément Chigot [Thu, 21 Feb 2019 09:14:46 +0000 (10:14 +0100)]
runtime: disable pprof test with cgo on aix/ppc64

This commit disables new cgo pprof tests and adds an handler in sigtramp
to refuse SIGPROF signal.

Updates #28555

Change-Id: I152a871f8636e93328d411329104c6f023bd1691
Reviewed-on: https://go-review.googlesource.com/c/go/+/164013
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agotime: optimize Sub
Michael Darakananda [Fri, 24 Aug 2018 07:27:35 +0000 (00:27 -0700)]
time: optimize Sub

This is primarily achieved by checking for arithmetic overflow
instead of using Add and Equal.

It's a decent performance improvement even though
the function still isn't inlined.

name   old time/op  new time/op  delta
Sub-6   242ns ± 0%   122ns ± 0%  -49.59%  (p=0.002 n=8+10)

Updates #17858.

Change-Id: I1469b618183c83ea8ea54d5ce277eb15f2ec0f11
Reviewed-on: https://go-review.googlesource.com/c/go/+/131196
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: fix TestSigStackSwapping on aix/ppc64
Clément Chigot [Wed, 20 Feb 2019 16:01:15 +0000 (17:01 +0100)]
runtime: fix TestSigStackSwapping on aix/ppc64

This commit fixes TestSigStackSwapping by increasing the signal stack
size. This is needed because SIGSTKSZ is too small when VMX is used on
AIX.

Change-Id: Ic2b5faa65745228d0768383b3d6ebd4b6f9f532c
Reviewed-on: https://go-review.googlesource.com/c/go/+/164012
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoos/user: allow build on aix/ppc64 with cgo
Clément Chigot [Wed, 27 Feb 2019 14:45:18 +0000 (15:45 +0100)]
os/user: allow build on aix/ppc64 with cgo

This commit adds C support for os/user package for aix/ppc64.

Updates #30563

Change-Id: Id07646998a7243b1335b85b5d4fe5bc4114e2a88
Reviewed-on: https://go-review.googlesource.com/c/go/+/164039
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agonet: allow build on aix/ppc64 with cgo
Clément Chigot [Wed, 27 Feb 2019 14:44:43 +0000 (15:44 +0100)]
net: allow build on aix/ppc64 with cgo

This commit adds C support for net package for aix/ppc64.

Change-Id: I704710991fc013c6ec3511671def6791df4854f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/164038
Run-TryBot: Mikio Hara <mikioh.public.networking@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Mikio Hara <mikioh.public.networking@gmail.com>
6 years agocmd, runtime: fix C trampolines on aix/ppc64
Clément Chigot [Wed, 20 Feb 2019 15:52:35 +0000 (16:52 +0100)]
cmd, runtime: fix C trampolines on aix/ppc64

C trampolines are made by fixup CSECTS which are added between two
symbols. If such CSECTS is added inside Go functions, all method
offsets stored in moduledatas will be wrong.
In order to prevent this, every C code is moved at the end of the
executable and long calls are created for GO functions called by C
code.
The main function can't longer be made in Go as AIX __start isn't using
a long call to branch on it. Therefore, a main is defined on
runtime/cgo.

Change-Id: I214b18decdb83107cf7325b298609eef9f9d1330
Reviewed-on: https://go-review.googlesource.com/c/go/+/164010
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: better write barrier removal when initializing new objects
Keith Randall [Sat, 5 Jan 2019 01:34:33 +0000 (17:34 -0800)]
cmd/compile: better write barrier removal when initializing new objects

When initializing a new object, we're often writing
1) to a location that doesn't have a pointer to a heap object
2) a pointer that doesn't point to a heap object

When both those conditions are true, we can avoid the write barrier.

This CL detects case 1 by looking for writes to known-zeroed
locations.  The results of runtime.newobject are zeroed, and we
perform a simple tracking of which parts of that object are written so
we can determine what part remains zero at each write.

This CL detects case 2 by looking for addresses of globals (including
the types and itabs which are used in interfaces) and for nil pointers.

Makes cmd/go 0.3% smaller. Some particular cases, like the slice
literal in #29573, can get much smaller.

TODO: we can remove actual zero writes also with this mechanism.

Update #29573

Change-Id: Ie74a3533775ea88da0495ba02458391e5db26cb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/156363
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/cgo: use C exact-width integer types to represent Go types
Philipp Stephani [Mon, 18 Mar 2019 20:13:17 +0000 (20:13 +0000)]
cmd/cgo: use C exact-width integer types to represent Go types

The exact-width integer types are required to use two’s complement
representation and may not have padding bits, cf. §7.20.1.1/1 in the C11
standard or https://en.cppreference.com/w/c/types/integer.  This ensures that
they have the same domain and representation as the corresponding Go types.

Fixes #29878

Change-Id: Ie8a51e91666dfd89731c7859abe47356c94ca1be
GitHub-Last-Rev: 546a2cc3f1e22dc282757f73c01c91b00899d911
GitHub-Pull-Request: golang/go#29907
Reviewed-on: https://go-review.googlesource.com/c/go/+/159258
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: rename init function from init.ializers back to init
Keith Randall [Mon, 18 Mar 2019 20:17:35 +0000 (13:17 -0700)]
cmd/compile: rename init function from init.ializers back to init

The name change init -> init.ializers was initially required for
initialization code.

With CL 161337 there's no wrapper code any more, there's a data
structure instead (named .inittask). So we can go back to just
plain init appearing in tracebacks.

RELNOTE=yes

Update #29919. Followon to CL 161337.

Change-Id: I5a4a49d286df24b53b2baa193dfda482f3ea82a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/167780
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agonet/http: Detect MIME type of v5 RAR archives
bakape [Mon, 18 Mar 2019 19:53:41 +0000 (19:53 +0000)]
net/http: Detect MIME type of v5 RAR archives

Change-Id: Id9dedc861523e2dafe0e67f70862973124fa07b3
GitHub-Last-Rev: b662561f1980dff9861dd8a738c75a03baa72681
GitHub-Pull-Request: golang/go#30909
Reviewed-on: https://go-review.googlesource.com/c/go/+/168039
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoruntime: fix registers for bounds check calling convention on arm
Keith Randall [Mon, 18 Mar 2019 19:49:49 +0000 (12:49 -0700)]
runtime: fix registers for bounds check calling convention on arm

Some of the registers in which indexes + length were supposed to
be passed were wrong.

Update #30116

Change-Id: I1089366b7429c1e0ecad9219b847db069ce6b5d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/168041
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: reorganize init functions
Keith Randall [Wed, 6 Feb 2019 00:22:38 +0000 (16:22 -0800)]
cmd/compile: reorganize init functions

Instead of writing an init function per package that does the same
thing for every package, just write that implementation once in the
runtime. Change the compiler to generate a data structure that encodes
the required initialization operations.

Reduces cmd/go binary size by 0.3%+.  Most of the init code is gone,
including all the corresponding stack map info. The .inittask
structures that replace them are quite a bit smaller.

Most usefully to me, there is no longer an init function in every -S output.
(There is an .inittask global there, but it's much less distracting.)

After this CL we could change the name of the "init.ializers" function
back to just "init".

Update #6853

R=go1.13

Change-Id: Iec82b205cc52fe3ade4d36406933c97dbc9c01b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/161337
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agocmd/dist: sort gohostos switch entries
Joel Sing [Sat, 15 Dec 2018 16:14:40 +0000 (03:14 +1100)]
cmd/dist: sort gohostos switch entries

Sort gohostos switch entries for readability/maintainability.

Change-Id: I565b0aee33e8463502faa68eaceea6f7dccca66b
Reviewed-on: https://go-review.googlesource.com/c/go/+/154379
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
6 years agocmd/compile: fix importing rewritten f(g()) calls
Matthew Dempsky [Mon, 18 Mar 2019 19:19:26 +0000 (12:19 -0700)]
cmd/compile: fix importing rewritten f(g()) calls

golang.org/cl/166983 started serializing the Ninit field of OCALL
nodes within function inline bodies (necessary to fix a regression in
building crypto/ecdsa with -gcflags=-l=4), but this means the Ninit
field needs to be typechecked when the imported function body is used.

It's unclear why this wasn't necessary for the crypto/ecdsa
regression.

Fixes #30907.

Change-Id: Id5f0bf3c4d17bbd6d5318913b859093c93a0a20c
Reviewed-on: https://go-review.googlesource.com/c/go/+/168199
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile,runtime: provide index information on bounds check failure
Keith Randall [Wed, 6 Feb 2019 22:12:36 +0000 (14:12 -0800)]
cmd/compile,runtime: provide index information on bounds check failure

A few examples (for accessing a slice of length 3):

   s[-1]    runtime error: index out of range [-1]
   s[3]     runtime error: index out of range [3] with length 3
   s[-1:0]  runtime error: slice bounds out of range [-1:]
   s[3:0]   runtime error: slice bounds out of range [3:0]
   s[3:-1]  runtime error: slice bounds out of range [:-1]
   s[3:4]   runtime error: slice bounds out of range [:4] with capacity 3
   s[0:3:4] runtime error: slice bounds out of range [::4] with capacity 3

Note that in cases where there are multiple things wrong with the
indexes (e.g. s[3:-1]), we report one of those errors kind of
arbitrarily, currently the rightmost one.

An exhaustive set of examples is in issue30116[u].out in the CL.

The message text has the same prefix as the old message text. That
leads to slightly awkward phrasing but hopefully minimizes the chance
that code depending on the error text will break.

Increases the size of the go binary by 0.5% (amd64). The panic functions
take arguments in registers in order to keep the size of the compiled code
as small as possible.

Fixes #30116

Change-Id: Idb99a827b7888822ca34c240eca87b7e44a04fdd
Reviewed-on: https://go-review.googlesource.com/c/go/+/161477
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
6 years agocmd/go: allow -o to point to a folder that writes multiple execs
Daniel Theophanes [Fri, 15 Mar 2019 06:42:57 +0000 (23:42 -0700)]
cmd/go: allow -o to point to a folder that writes multiple execs

If -o points to a directory that exists then allow multiple
executables to be written to that directory.

Fixes #14295

Change-Id: Ic951e637c70a2ada5e7534bae9a43901a39fe2c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/167679
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agoruntime: replace division by span element size by multiply and shifts
Martin Möhrmann [Wed, 7 Nov 2018 08:33:12 +0000 (09:33 +0100)]
runtime: replace division by span element size by multiply and shifts

Divisions are generally slow. The compiler can optimize a division
to use a sequence of faster multiplies and shifts (magic constants)
if the divisor is not know at compile time.

The value of the span element size in mcentral.grow is not known at
compile time but magic constants to compute n / span.elementsize
are already stored in class_to_divmagic and mspan.
They however need to be adjusted to work for
(0 <= n <= span.npages * pagesize) instead of
(0 <= n <  span.npages * pagesize).

Change-Id: Ieea59f1c94525a88d012f2557d43691967900deb
Reviewed-on: https://go-review.googlesource.com/c/go/+/148057
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoencoding/json: fix performance regression in the decoder
Daniel Martí [Sun, 17 Mar 2019 22:45:30 +0000 (22:45 +0000)]
encoding/json: fix performance regression in the decoder

In golang.org/cl/145218, a feature was added where the JSON decoder
would keep track of the entire path to a field when reporting an
UnmarshalTypeError.

However, we all failed to check if this affected the benchmarks - myself
included, as a reviewer. Below are the numbers comparing the CL's parent
with itself, once it was merged:

name           old time/op    new time/op    delta
CodeDecoder-8    12.9ms ± 1%    28.2ms ± 2%   +119.33%  (p=0.002 n=6+6)

name           old speed      new speed      delta
CodeDecoder-8   151MB/s ± 1%    69MB/s ± 3%    -54.40%  (p=0.002 n=6+6)

name           old alloc/op   new alloc/op   delta
CodeDecoder-8    2.74MB ± 0%  109.39MB ± 0%  +3891.83%  (p=0.002 n=6+6)

name           old allocs/op  new allocs/op  delta
CodeDecoder-8     77.5k ± 0%    168.5k ± 0%   +117.30%  (p=0.004 n=6+5)

The reason why the decoder got twice as slow is because it now allocated
~40x as many objects, which puts a lot of pressure on the garbage
collector.

The reason is that the CL concatenated strings every time a nested field
was decoded. In other words, practically every field generated garbage
when decoded. This is hugely wasteful, especially considering that the
vast majority of JSON decoding inputs won't return UnmarshalTypeError.

Instead, use a stack of fields, and make sure to always use the same
backing array, to ensure we only need to grow the slice to the maximum
depth once.

The original CL also introduced a bug. The field stack string wasn't
reset to its original state when reaching "d.opcode == scanEndObject",
so the last field in a decoded struct could leak. For example, an added
test decodes a list of structs, and encoding/json before this CL would
fail:

got:  cannot unmarshal string into Go struct field T.Ts.Y.Y.Y of type int
want: cannot unmarshal string into Go struct field T.Ts.Y of type int

To fix that, simply reset the stack after decoding every field, even if
it's the last.

Below is the original performance versus this CL. There's a tiny
performance hit, probably due to the append for every decoded field, but
at least we're back to the usual ~150MB/s.

name           old time/op    new time/op    delta
CodeDecoder-8    12.9ms ± 1%    13.0ms ± 1%  +1.25%  (p=0.009 n=6+6)

name           old speed      new speed      delta
CodeDecoder-8   151MB/s ± 1%   149MB/s ± 1%  -1.24%  (p=0.009 n=6+6)

name           old alloc/op   new alloc/op   delta
CodeDecoder-8    2.74MB ± 0%    2.74MB ± 0%  +0.00%  (p=0.002 n=6+6)

name           old allocs/op  new allocs/op  delta
CodeDecoder-8     77.5k ± 0%     77.5k ± 0%  +0.00%  (p=0.002 n=6+6)

Finally, make all of these benchmarks report allocs by default. The
decoder ones are pretty sensitive to generated garbage, so ReportAllocs
would have made the performance regression more obvious.

Change-Id: I67b50f86b2e72f55539429450c67bfb1a9464b67
Reviewed-on: https://go-review.googlesource.com/c/go/+/167978
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agointernal/bytealg: share code for IndexByte functions on arm
Tobias Klauser [Sun, 17 Mar 2019 21:39:42 +0000 (22:39 +0100)]
internal/bytealg: share code for IndexByte functions on arm

Move the shared code of IndexByte and IndexByteString into
indexbytebody. This will allow to implement optimizations (e.g.
for #29001) in a single function.

Change-Id: I1d550da8eb65f95e492a460a12058cc35b1162b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/167939
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoos: only fallback to root directory if $HOME fails for UserHomeDir
Elias Naur [Sun, 17 Mar 2019 15:01:27 +0000 (16:01 +0100)]
os: only fallback to root directory if $HOME fails for UserHomeDir

UserHomeDir always returns "/" for platforms where the home directory
is not always well defined. However, the user might set HOME before
running a Go program on those platforms and on at least iOS, HOME
is actually set to something useful (the root of the app specific
writable directory).

This CL changes UserHomeDir to use the root directory "/" only if
$HOME is empty.

Change-Id: Icaa01de53cd585d527d9a23b1629375d6b7f67e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/167802
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
6 years agointernal/bytealg: use word-wise comparison for Equal on arm
Tobias Klauser [Thu, 14 Mar 2019 10:35:53 +0000 (11:35 +0100)]
internal/bytealg: use word-wise comparison for Equal on arm

Follow CL 165338 and use word-wise comparison for aligned buffers in
Equal on arm, otherwise fall back to the current byte-wise comparison.

name                 old time/op    new time/op    delta
Equal/0-4              25.7ns ± 1%    23.5ns ± 1%    -8.78%  (p=0.000 n=10+10)
Equal/1-4              65.8ns ± 0%    60.1ns ± 1%    -8.69%  (p=0.000 n=10+9)
Equal/6-4              82.9ns ± 1%    86.7ns ± 0%    +4.59%  (p=0.000 n=10+10)
Equal/9-4              90.0ns ± 0%   101.0ns ± 0%   +12.18%  (p=0.000 n=9+10)
Equal/15-4              108ns ± 0%     119ns ± 0%   +10.19%  (p=0.000 n=8+8)
Equal/16-4              111ns ± 0%      82ns ± 0%   -26.37%  (p=0.000 n=8+10)
Equal/20-4              124ns ± 1%      87ns ± 1%   -29.94%  (p=0.000 n=9+10)
Equal/32-4              160ns ± 1%      97ns ± 1%   -39.40%  (p=0.000 n=10+10)
Equal/4K-4             14.0µs ± 0%     3.6µs ± 1%   -74.57%  (p=0.000 n=9+10)
Equal/4M-4             12.8ms ± 1%     3.2ms ± 0%   -74.93%  (p=0.000 n=9+9)
Equal/64M-4             204ms ± 1%      51ms ± 0%   -74.78%  (p=0.000 n=10+10)
EqualPort/1-4          47.0ns ± 1%    46.8ns ± 0%    -0.40%  (p=0.015 n=10+6)
EqualPort/6-4          82.6ns ± 1%    81.9ns ± 1%    -0.87%  (p=0.002 n=10+10)
EqualPort/32-4          232ns ± 0%     232ns ± 0%      ~     (p=0.496 n=8+10)
EqualPort/4K-4         29.0µs ± 1%    29.0µs ± 1%      ~     (p=0.604 n=9+10)
EqualPort/4M-4         24.0ms ± 1%    23.8ms ± 0%    -0.65%  (p=0.001 n=9+9)
EqualPort/64M-4         383ms ± 1%     382ms ± 0%      ~     (p=0.218 n=10+10)
CompareBytesEqual-4    61.2ns ± 1%    61.0ns ± 1%      ~     (p=0.539 n=10+10)

name                 old speed      new speed      delta
Equal/1-4            15.2MB/s ± 0%  16.6MB/s ± 1%    +9.52%  (p=0.000 n=10+9)
Equal/6-4            72.4MB/s ± 1%  69.2MB/s ± 0%    -4.40%  (p=0.000 n=10+10)
Equal/9-4             100MB/s ± 0%    89MB/s ± 0%   -11.40%  (p=0.000 n=9+10)
Equal/15-4            138MB/s ± 1%   125MB/s ± 1%    -9.41%  (p=0.000 n=10+10)
Equal/16-4            144MB/s ± 1%   196MB/s ± 0%   +36.41%  (p=0.000 n=10+10)
Equal/20-4            162MB/s ± 1%   231MB/s ± 1%   +42.98%  (p=0.000 n=9+10)
Equal/32-4            200MB/s ± 1%   331MB/s ± 1%   +65.64%  (p=0.000 n=10+10)
Equal/4K-4            292MB/s ± 0%  1149MB/s ± 1%  +293.19%  (p=0.000 n=9+10)
Equal/4M-4            328MB/s ± 1%  1307MB/s ± 0%  +298.87%  (p=0.000 n=9+9)
Equal/64M-4           329MB/s ± 1%  1306MB/s ± 0%  +296.56%  (p=0.000 n=10+10)
EqualPort/1-4        21.3MB/s ± 1%  21.4MB/s ± 0%    +0.42%  (p=0.002 n=10+9)
EqualPort/6-4        72.6MB/s ± 1%  73.2MB/s ± 1%    +0.87%  (p=0.003 n=10+10)
EqualPort/32-4        138MB/s ± 0%   138MB/s ± 0%      ~     (p=0.953 n=9+10)
EqualPort/4K-4        141MB/s ± 1%   141MB/s ± 1%      ~     (p=0.382 n=10+10)
EqualPort/4M-4        175MB/s ± 1%   176MB/s ± 0%    +0.65%  (p=0.001 n=9+9)
EqualPort/64M-4       175MB/s ± 1%   176MB/s ± 0%      ~     (p=0.225 n=10+10)

The 5-12% decrease in performance on Equal/{6,9,15} are due to the
benchmarks splitting the bytes buffer in half. The b argument to Equal
then ends up being unaligned and thus the fast word-wise compare doesn't
kick in.

Updates #29001

Change-Id: I73be501c18e67d211ed19da7771b4f254254e609
Reviewed-on: https://go-review.googlesource.com/c/go/+/167557
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/go,misc/ios: fix tests on iOS
Elias Naur [Sun, 17 Mar 2019 15:07:25 +0000 (16:07 +0100)]
cmd/go,misc/ios: fix tests on iOS

Now that modules are always on, cmd/go tests require a valid
GOCACHE. However, on iOS where the go tool is not available, the
cmd/go test driver ends up setting GOCACHE to the empty string.
Fix it by falling back to the builtin default cache directory.

The iOS exec wrapper passes the environment variables to the app
on the device, including $HOME used for the default cache directory.
Skip $HOME to let the device specific and writable $HOME be used
instead.

Should fix cmd/go on the iOS builders that broke when GO111MODULE
defaulted to on.

Change-Id: I0939f5b8aaa1d2db95e64c99f4130eee2d0b4d4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/167938
Run-TryBot: Elias Naur <mail@eliasnaur.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/dist: reenable testing of Examples for js/wasm
Richard Musiol [Sat, 16 Mar 2019 13:05:00 +0000 (14:05 +0100)]
cmd/dist: reenable testing of Examples for js/wasm

Testing Examples for js/wasm is supported as of ac56baa, so we can
reenable them.

This reverts CL 119377 (commit 9a91713).

Fixes #25933

Change-Id: I0f228a3ec385dbe9573d3c33e42dccd4488d7152
Reviewed-on: https://go-review.googlesource.com/c/go/+/167800
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go: skip broken TestScript/build_acl_windows on arm
Alex Brainman [Fri, 15 Mar 2019 22:47:17 +0000 (09:47 +1100)]
cmd/go: skip broken TestScript/build_acl_windows on arm

Updates #30711

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

6 years agocmd/go: list directories in module cache replacements
Jay Conrod [Tue, 5 Mar 2019 19:53:03 +0000 (14:53 -0500)]
cmd/go: list directories in module cache replacements

"go list" has allowed listing directory paths to packages in the
module cache since CL 126715. This is sometimes necessary for tools
gathering package information about source files in imported packages.

With this change, we only allow directories in the module cache for
modules in the build list after replacements are applied. Previously,
we ignored replacements when expanding file system path patterns while
constructing the build list.

Fixes #29548

Change-Id: Ic7f89122c4656c8967c14545cb7117f98e89e721
Reviewed-on: https://go-review.googlesource.com/c/go/+/165381
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go/internal/cache: remove log.txt from the cache directory
Bryan C. Mills [Fri, 15 Mar 2019 13:10:09 +0000 (09:10 -0400)]
cmd/go/internal/cache: remove log.txt from the cache directory

Also remove an existing log.txt in the cache directory during
'go clean -cache' if it exists.

Fixes #25323

Change-Id: I1c6e20554db0edc6d850a7b4379d71ef5844eaea
Reviewed-on: https://go-review.googlesource.com/c/go/+/167741
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agotest: new test for issue 30862
Than McIntosh [Fri, 15 Mar 2019 17:58:21 +0000 (13:58 -0400)]
test: new test for issue 30862

New test case, inspired by gccgo issue 30862.

Updates #30862.

Change-Id: I5e494b877e4fd142b8facb527471fe1fdef39c61
Reviewed-on: https://go-review.googlesource.com/c/go/+/167744
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/compile: eliminate unnecessary type conversions in TrailingZeros(16|8) for arm
Tobias Klauser [Fri, 15 Mar 2019 07:49:38 +0000 (08:49 +0100)]
cmd/compile: eliminate unnecessary type conversions in TrailingZeros(16|8) for arm

This follows CL 156999 which did the same for arm64.

name               old time/op  new time/op  delta
TrailingZeros-4    7.30ns ± 1%  7.30ns ± 0%     ~     (p=0.413 n=9+9)
TrailingZeros8-4   8.32ns ± 0%  7.17ns ± 0%  -13.77%  (p=0.000 n=10+9)
TrailingZeros16-4  8.30ns ± 0%  7.18ns ± 0%  -13.50%  (p=0.000 n=9+10)
TrailingZeros32-4  6.46ns ± 1%  6.47ns ± 1%     ~     (p=0.325 n=10+10)
TrailingZeros64-4  16.3ns ± 0%  16.2ns ± 0%   -0.61%  (p=0.000 n=7+10)

Change-Id: I7e9e1abf7e30d811aa474d272b2824ec7cbbaa98
Reviewed-on: https://go-review.googlesource.com/c/go/+/167797
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agoruntime: fix write barrier on wasm
Austin Clements [Fri, 15 Mar 2019 17:29:40 +0000 (13:29 -0400)]
runtime: fix write barrier on wasm

The current wasm write barrier implementation incorrectly implements
the "deletion" part of the barrier. It correctly greys the new value
of the pointer, but rather than also greying the old value of the
pointer, it greys the object containing the slot (which, since the old
value was just overwritten, is not going to contain the old value).

This can lead to unmarked, reachable objects.

Often, this is masked by other marking activity, but one specific
sequence that can lead to an unmarked object because of this bug is:

1. Initially, GC is off, object A is reachable from just one pointer
in the heap.

2. GC starts and scans the stack of goroutine G.

3. G copies the pointer to A on to its stack and overwrites the
pointer to A in the heap. (Now A is reachable only from G's stack.)

4. GC finishes while A is still reachable from G's stack.

With a functioning deletion barrier, step 3 causes A to be greyed.
Without a functioning deletion barrier, nothing causes A to be greyed,
so A will be freed even though it's still reachable from G's stack.

This CL fixes the wasm write barrier.

Fixes #30871.

Change-Id: I8a74ee517facd3aa9ad606e5424bcf8f0d78e754
Reviewed-on: https://go-review.googlesource.com/c/go/+/167743
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agodebug/dwarf: more graceful handling of unsupported types
Than McIntosh [Fri, 18 Jan 2019 20:16:11 +0000 (15:16 -0500)]
debug/dwarf: more graceful handling of unsupported types

Enhance the type decoder to do a better job handling unknown type
tags. DWARF has a number of type DIEs that this package doesn't handle
(things like "pointer to member" types in C++); avoid crashing for
such types, but instead return a placeholder "UnsupportedType" object
(this idea suggested by Austin). This provides a compromise between
implementing the entire kitchen sink and simply returning an error
outright on any unknown type DIE.

Fixes #29601.

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

6 years agomisc/android: copy go.mod and go.sum files
Elias Naur [Fri, 15 Mar 2019 17:13:38 +0000 (18:13 +0100)]
misc/android: copy go.mod and go.sum files

Fixes TestFindStdlib in x/tools on android.

Change-Id: I2da7c702164e23488c7f9574f636ac36f63ab421
Reviewed-on: https://go-review.googlesource.com/c/go/+/167799
Run-TryBot: Elias Naur <mail@eliasnaur.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agomath: fix math.Remainder(-x,x) (for Inf > x > 0)
David Chase [Wed, 13 Mar 2019 20:46:10 +0000 (16:46 -0400)]
math: fix math.Remainder(-x,x) (for Inf > x > 0)

Modify the |x| == |y| case to return -0 when x < 0.

Fixes #30814.

Change-Id: Ic4cd48001e0e894a12b5b813c6a1ddc3a055610b
Reviewed-on: https://go-review.googlesource.com/c/go/+/167479
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agobytes: add hard benchmarks for Index and Count
Tobias Klauser [Fri, 15 Mar 2019 10:29:03 +0000 (11:29 +0100)]
bytes: add hard benchmarks for Index and Count

Add Benchmark(Index|Count)Hard[1-3] in preparation for implementing
Index and Count in assembly on arm.

Updates #29001

Change-Id: I2a9701892190e8d91de069c2f5a7f5bd3544c6c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/167798
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/cover: add go.mod file in lineDupDir
Bryan C. Mills [Fri, 15 Mar 2019 12:32:16 +0000 (08:32 -0400)]
cmd/cover: add go.mod file in lineDupDir

This fixes TestFuncWithDuplicateLines (introduced in CL 167257)
in module mode.

Updates #30746
Updates #30228

Change-Id: I7b3e7192ae23f855c373e881389874ff6ffd49ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/167740
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agocmd/go: skip package loading if explicitly cleaning a cache
Bryan C. Mills [Thu, 14 Mar 2019 21:08:25 +0000 (17:08 -0400)]
cmd/go: skip package loading if explicitly cleaning a cache

Fixes #28680
Fixes #29925

Change-Id: I9f7effb3e7743b96b0b8a797d6e1044b39d9b86b
Reviewed-on: https://go-review.googlesource.com/c/go/+/167717
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agocmd/link: fix trampoline generation for aix/ppc64
Clément Chigot [Wed, 20 Feb 2019 15:48:43 +0000 (16:48 +0100)]
cmd/link: fix trampoline generation for aix/ppc64

This commit fixes trampoline generation on aix/ppc64 which must use TOC
symbols.
It also adds a size to runtime.text.X symbols to prevent ld from moving
them, like runtime.text.

Change-Id: Ida033ec20ad8d7b7fb3faeb0ec4fa7bc4ce86b7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/164009
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/cover: don't assume duplicate positions are in order
Ian Lance Taylor [Wed, 13 Mar 2019 02:10:43 +0000 (19:10 -0700)]
cmd/cover: don't assume duplicate positions are in order

Fixes #30746

Change-Id: I63f2d82f14eeaab6b14e956e21ddeec56fee025b
Reviewed-on: https://go-review.googlesource.com/c/go/+/167257
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agoos: consistently return PathError from RemoveAll
Baokun Lee [Fri, 1 Mar 2019 10:04:14 +0000 (18:04 +0800)]
os: consistently return PathError from RemoveAll

Fixes #30491

Change-Id: If4070e5d39d8649643d7e90f6f3eb499642e25ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/164720
Run-TryBot: Baokun Lee <nototon@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
6 years agoruntime: introduce and consistently use setNsec for timespec
Ian Lance Taylor [Thu, 14 Mar 2019 01:56:37 +0000 (18:56 -0700)]
runtime: introduce and consistently use setNsec for timespec

The general code for setting a timespec value sometimes used set_nsec
and sometimes used a combination of set_sec and set_nsec. Standardize
on a setNsec function that takes a number of nanoseconds and splits
them up to set the tv_sec and tv_nsec fields. Consistently mark
setNsec as go:nosplit, since it has to be that way on some systems
including Darwin and GNU/Linux. Consistently use timediv on 32-bit
systems to help stay within split-stack limits on processors that
don't have a 64-bit division instruction.

Change-Id: I6396bb7ddbef171a96876bdeaf7a1c585a6d725b
Reviewed-on: https://go-review.googlesource.com/c/go/+/167389
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: move Strongly Connected Components code into new file
Matthew Dempsky [Thu, 14 Mar 2019 20:54:05 +0000 (13:54 -0700)]
cmd/compile: move Strongly Connected Components code into new file

This logic is used by the current escape analysis pass, but otherwise
logically independent. Move (unchanged) into a separate file to make
that clearer, and to make it easier to replace esc.go later.

Updates #23109.

Change-Id: Iec8c0c47ea04c0008165791731c11d9104d5a474
Reviewed-on: https://go-review.googlesource.com/c/go/+/167715
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agocmd/compile: rewrite f(g()) for multi-value g() during typecheck
Matthew Dempsky [Wed, 12 Dec 2018 19:15:37 +0000 (11:15 -0800)]
cmd/compile: rewrite f(g()) for multi-value g() during typecheck

This is a re-attempt at CL 153841, which caused two regressions:

1. crypto/ecdsa failed to build with -gcflags=-l=4. This was because
when "t1, t2, ... := g(); f(t1, t2, ...)" was exported, we were losing
the first assignment from the call's Ninit field.

2. net/http/pprof failed to run with -gcflags=-N. This is due to a
conflict with CL 159717: as of that CL, package-scope initialization
statements are executed within the "init.ializer" function, rather
than the "init" function, and the generated temp variables need to be
moved accordingly too.

[Rest of description is as before.]

This CL moves order.go's copyRet logic for rewriting f(g()) into t1,
t2, ... := g(); f(t1, t2, ...) earlier into typecheck. This allows the
rest of the compiler to stop worrying about multi-value functions
appearing outside of OAS2FUNC nodes.

This changes compiler behavior in a few observable ways:

1. Typechecking error messages for builtin functions now use general
case error messages rather than unnecessarily differing ones.

2. Because f(g()) is rewritten before inlining, saved inline bodies
now see the rewritten form too. This could be addressed, but doesn't
seem worthwhile.

3. Most notably, this simplifies escape analysis and fixes a memory
corruption issue in esc.go. See #29197 for details.

Fixes #15992.
Fixes #29197.

Change-Id: I930b10f7e27af68a0944d6c9bfc8707c3fab27a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/166983
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agodoc: add minor revisions header for 1.12
Andrew Bonventre [Thu, 14 Mar 2019 20:44:38 +0000 (16:44 -0400)]
doc: add minor revisions header for 1.12

Change-Id: I0d4a55af0bee754ab1ee817780027e9f72475afb
Reviewed-on: https://go-review.googlesource.com/c/go/+/167711
Reviewed-by: Katie Hockman <katiehockman@google.com>
Reviewed-by: Katie Hockman <katie@golang.org>
6 years agomath, math/bits: add intrinsics for wasm
Richard Musiol [Tue, 5 Mar 2019 00:56:17 +0000 (01:56 +0100)]
math, math/bits: add intrinsics for wasm

This commit adds compiler intrinsics for the packages math and
math/bits on the wasm architecture for better performance.

benchmark                        old ns/op     new ns/op     delta
BenchmarkCeil                    8.31          3.21          -61.37%
BenchmarkCopysign                5.24          3.88          -25.95%
BenchmarkAbs                     5.42          3.34          -38.38%
BenchmarkFloor                   8.29          3.18          -61.64%
BenchmarkRoundToEven             9.76          3.26          -66.60%
BenchmarkSqrtLatency             8.13          4.88          -39.98%
BenchmarkSqrtPrime               5246          3535          -32.62%
BenchmarkTrunc                   8.29          3.15          -62.00%
BenchmarkLeadingZeros            13.0          4.23          -67.46%
BenchmarkLeadingZeros8           4.65          4.42          -4.95%
BenchmarkLeadingZeros16          7.60          4.38          -42.37%
BenchmarkLeadingZeros32          10.7          4.48          -58.13%
BenchmarkLeadingZeros64          12.9          4.31          -66.59%
BenchmarkTrailingZeros           6.52          4.04          -38.04%
BenchmarkTrailingZeros8          4.57          4.14          -9.41%
BenchmarkTrailingZeros16         6.69          4.16          -37.82%
BenchmarkTrailingZeros32         6.97          4.23          -39.31%
BenchmarkTrailingZeros64         6.59          4.00          -39.30%
BenchmarkOnesCount               7.93          3.30          -58.39%
BenchmarkOnesCount8              3.56          3.19          -10.39%
BenchmarkOnesCount16             4.85          3.19          -34.23%
BenchmarkOnesCount32             7.27          3.19          -56.12%
BenchmarkOnesCount64             8.08          3.28          -59.41%
BenchmarkRotateLeft              4.88          3.80          -22.13%
BenchmarkRotateLeft64            5.03          3.63          -27.83%

Change-Id: Ic1e0c2984878be8defb6eb7eb6ee63765c793222
Reviewed-on: https://go-review.googlesource.com/c/go/+/165177
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agotime: add methods to convert duration to microseconds and milliseconds
Derek Phan [Thu, 14 Mar 2019 00:55:05 +0000 (00:55 +0000)]
time: add methods to convert duration to microseconds and milliseconds

The return values are integers, as opposed to floats, since the fractionals can be derived from multiplying t.Seconds().

Fixes #28564

Change-Id: I3796227e1f64ead39ff0aacfbdce912d952f2994
GitHub-Last-Rev: b843ab740bf5a8216478322533521d6243fe1cb1
GitHub-Pull-Request: golang/go#30819
Reviewed-on: https://go-review.googlesource.com/c/go/+/167387
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>