]> Cypherpunks repositories - gostls13.git/log
gostls13.git
6 years agomath/big: implement Rat.SetUint64
Brian Kessler [Fri, 1 Feb 2019 05:28:21 +0000 (22:28 -0700)]
math/big: implement Rat.SetUint64

Implemented via the underlying Int.SetUint64.
Added tests for Rat.SetInt64 and Rat.SetUint64.

Fixes #29579

Change-Id: I03faaffc93e36873b202b58ae72b139dea5c40f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/160682
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agocmd/link/internal/ld: skip TLS section on Android
Elias Naur [Wed, 27 Mar 2019 13:25:24 +0000 (14:25 +0100)]
cmd/link/internal/ld: skip TLS section on Android

We don't use the TLS section on android, and dropping it avoids
complaints about underalignment from the Android Q linker.

Updates #29674

Change-Id: I91dabf2a58e6eb1783872639a6a144858db09cef
Reviewed-on: https://go-review.googlesource.com/c/go/+/169618
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agobytes: make TrimSpace return nil on all-space input
Ben Hoyt [Wed, 27 Mar 2019 11:36:27 +0000 (07:36 -0400)]
bytes: make TrimSpace return nil on all-space input

Issue #29122 introduced a subtle regression due to the way that
TrimFuncLeft is written: previously TrimSpace returned nil when given
an input of all whitespace, but with the #29122 changes it returned an
empty slice on all-space input.

This change adds a special case to the new, optimized TrimSpace to go
back to that behavior. While it is odd behavior and people shouldn't be
relying on these functions returning a nil slice in practice, it's not
worth the breakage of code that does.

This tweak doesn't change the TrimSpace benchmarks significantly.

Fixes #31038

Change-Id: Idb495d02b474054d2b2f593c2e318a7a6625688a
Reviewed-on: https://go-review.googlesource.com/c/go/+/169518
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agosort, internal/reflectlite: flesh out reflectlite enough for use by sort
Brad Fitzpatrick [Mon, 25 Mar 2019 17:39:11 +0000 (17:39 +0000)]
sort, internal/reflectlite: flesh out reflectlite enough for use by sort

Now the net package is back to no longer depending on unicode. And lock that in
with a test.

Fixes #30440

Change-Id: I18b89b02f7d96488783adc07308da990f505affd
Reviewed-on: https://go-review.googlesource.com/c/go/+/169137
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoos: document exit status range value
LE Manh Cuong [Tue, 26 Mar 2019 04:24:40 +0000 (11:24 +0700)]
os: document exit status range value

Fixes #30959

Change-Id: I9d30d79e2dbb3f8c8d6555f8c64862b133638d5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/169357
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agocmd/go/internal/{run,work,generate}: document file path location requirement
Agniva De Sarker [Thu, 15 Nov 2018 18:05:27 +0000 (23:35 +0530)]
cmd/go/internal/{run,work,generate}: document file path location requirement

Mention that .go files must be from a single directory
for them to be treated as a single package.

Fixes #21529

Change-Id: I79cb08b9f43888814b1249a7b50bc7bc70bc1c72
Reviewed-on: https://go-review.googlesource.com/c/go/+/149797
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
6 years agocontext: don't depend on fmt
Brad Fitzpatrick [Wed, 27 Feb 2019 20:08:36 +0000 (20:08 +0000)]
context: don't depend on fmt

So the net package doesn't indirectly depend on unicode tables.

But we're still not quite there, because a new test added in this CL
reveals that we still have a path to unicode via:

deps_test.go:570:
  TODO(issue 30440): policy violation: net => sort => reflect => unicode

Updates #30440

Change-Id: I710c2061dfbaa8e866c92e6c824bd8df35784165
Reviewed-on: https://go-review.googlesource.com/c/go/+/169080
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocrypto/x509: look for CAs at /etc/ssl/cert.pem for Alpine Linux
Felix Bünemann [Mon, 25 Mar 2019 23:12:21 +0000 (23:12 +0000)]
crypto/x509: look for CAs at /etc/ssl/cert.pem for Alpine Linux

Alpine Linux uses /etc/ssl/cert.pem as default ca-bundle which
is preinstalled since 3.7 and was installed as part of the libressl
package in 3.5 and 3.6.

The path /etc/ssl/certs/ca-certificates.crt is only valid if the full
ca-certificates package is installed by hand, which contains all
single CA certs and uses update-ca-certificates to bundle them.

The priority for /etc/ssl/certs/ca-certificates.crt should be kept
higher than /etc/ssl/cert.pem in case the user installed custom
CA certs.

Change-Id: I1c86a6ad84d8ee1163560655743a5ce9f2408af1
GitHub-Last-Rev: 0ba4d599e412640248d4e688537aaea4c43ecbcc
GitHub-Pull-Request: golang/go#31042
Reviewed-on: https://go-review.googlesource.com/c/go/+/169238
Reviewed-by: Filippo Valsorda <filippo@golang.org>
6 years agoruntime: improve sigtramp on aix/ppc64 to handle SIGPROF
Clément Chigot [Mon, 25 Mar 2019 09:26:44 +0000 (10:26 +0100)]
runtime: improve sigtramp on aix/ppc64 to handle SIGPROF

R14, R15 must be saved in sigtramp because they might be modified by Go
code when a SIGPROF occurs.

Fixes #28555

Change-Id: I573541f108d7d6aac8e60d33c649e5db943f3ef5
Reviewed-on: https://go-review.googlesource.com/c/go/+/169117
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/go/internal/load: always use DefaultExecName to determine binary name
Dmitri Shuralyov [Thu, 21 Mar 2019 18:00:46 +0000 (14:00 -0400)]
cmd/go/internal/load: always use DefaultExecName to determine binary name

It should produce equivalent results to split on the import path of the
package rather than its directory, in GOPATH mode. That means the common
code in DefaultExecName can be used.

We're in the middle of Go 1.12 cycle, so now is a good time to make it
happen for Go 1.13.

Modify isVersionElement to accept path elements like "v2", "v3", "v10",
rather than "/v2", "/v3", "/v10". Then use it in DefaultExecName instead
of the ad-hoc isVersion function. There is no change in behavior.

Add tests for DefaultExecName and isVersionElement.

Updates #26869

Change-Id: Ic6da2c92587459aa2b327385e994b72a6e183092
Reviewed-on: https://go-review.googlesource.com/c/go/+/168678
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agocmd/vet/all: don't use the x/tools vet in GOPATH
Brad Fitzpatrick [Mon, 25 Mar 2019 22:57:27 +0000 (22:57 +0000)]
cmd/vet/all: don't use the x/tools vet in GOPATH

Updates golang/go#31040

Change-Id: I76e3044b2cc992e63194654a825e70307075eff3
Reviewed-on: https://go-review.googlesource.com/c/go/+/169237
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
6 years agosyscall/js: improve type checks of js.Value's methods
Richard Musiol [Sun, 24 Mar 2019 23:31:41 +0000 (00:31 +0100)]
syscall/js: improve type checks of js.Value's methods

Add more explicit checks if the given js.Value is of the correct type
instead of erroring on the JavaScript layer.

Change-Id: I30b18a76820fb68f6ac279bb88a57456f5bab467
Reviewed-on: https://go-review.googlesource.com/c/go/+/168886
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd: update go.mod versions for vetall bug
Brad Fitzpatrick [Mon, 25 Mar 2019 22:57:27 +0000 (22:57 +0000)]
cmd: update go.mod versions for vetall bug

Updates golang/go#30971
Updates golang/go#31040

Change-Id: I305fbddb6f79cbe3d7e29225841309ab00b1e7dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/169239
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
6 years agoreflect: initialize ptrdata earlier in StructOf
Keith Randall [Tue, 26 Mar 2019 03:29:18 +0000 (20:29 -0700)]
reflect: initialize ptrdata earlier in StructOf

It needs to be set before addTypeBits is called.

Fixes #31043

Change-Id: I692b4047dc17bd68202d45da41dd55d432383e59
Reviewed-on: https://go-review.googlesource.com/c/go/+/169318
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoreflect: fix typeptrdata
Keith Randall [Tue, 26 Mar 2019 02:16:46 +0000 (19:16 -0700)]
reflect: fix typeptrdata

We can't use ptrdata inside of typeptrdata, because it won't be
properly initialized until typeptrdata returns.

Fixes #31039

Change-Id: Ib8c89191a7e4cce678a05d351bb6ded81ba23aae
Reviewed-on: https://go-review.googlesource.com/c/go/+/169317
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agocmd/compile: fix "append outside assignment" ICE
Matthew Dempsky [Mon, 25 Mar 2019 23:34:19 +0000 (16:34 -0700)]
cmd/compile: fix "append outside assignment" ICE

Some special-case code paths in order.go didn't expect OCALLFUNC to
have Ninit; in particular, OAS2FUNC and ODEFER/OGO failed to call
o.init on their child OCALLFUNC node. This resulted in not all of the
AST being properly ordered.

This was noticed because order is responsible for introducing an
invariant around how OAPPEND is used, which is enforced by walk.
However, there were perhaps simpler cases (e.g., simple order of
evaluation) that were being silently miscompiled.

Fixes #31010.

Change-Id: Ib928890ab5ec2aebd8e30a030bc2b404387f9123
Reviewed-on: https://go-review.googlesource.com/c/go/+/169257
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agomath: use Sincos instead of Sin and Cos in Jn and Yn
Neven Sajko [Mon, 25 Mar 2019 22:40:27 +0000 (22:40 +0000)]
math: use Sincos instead of Sin and Cos in Jn and Yn

Change-Id: I0da3857013f1d4e90820fb043314d78924113a27
GitHub-Last-Rev: 7c3d813c6e188a4afda54b736db14370e52b6f94
GitHub-Pull-Request: golang/go#31019
Reviewed-on: https://go-review.googlesource.com/c/go/+/169078
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agomath/big: accept non-decimal floats with Rat.SetString
Robert Griesemer [Mon, 18 Mar 2019 23:10:07 +0000 (16:10 -0700)]
math/big: accept non-decimal floats with Rat.SetString

This fixes an old oversight. Rat.SetString already permitted
fractions a/b where both a and b could independently specify
a base prefix. With this CL, it now also accepts non-decimal
floating-point numbers.

Fixes #29799.

Change-Id: I9cc65666a5cebb00f0202da2e4fc5654a02e3234
Reviewed-on: https://go-review.googlesource.com/c/go/+/168237
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
6 years agotesting: correct two spelling/grammar issues
Caleb Spare [Mon, 25 Mar 2019 20:27:34 +0000 (13:27 -0700)]
testing: correct two spelling/grammar issues

Change-Id: Ic7f7a34e12cc2845e0385a5a872e694d5dca7372
Reviewed-on: https://go-review.googlesource.com/c/go/+/169158
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/dist: move GOPATH setting from init to bootstrap
Brad Fitzpatrick [Mon, 25 Mar 2019 21:36:31 +0000 (21:36 +0000)]
cmd/dist: move GOPATH setting from init to bootstrap

CL 168697 unconditionally set GOPATH in dist, which broke the
misc-vet-vetall builder, because cmd/vet/all depends on GOPATH.

Fixes #30971

Change-Id: If6a58e054c6a4fedc2ea506a2c443348489c91f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/169217
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
6 years agofmt: fix spelling mistake in example
Rob Pike [Mon, 25 Mar 2019 20:16:53 +0000 (07:16 +1100)]
fmt: fix spelling mistake in example

Mea culpa. Beat Takeshi, sumimasen.

Fixes #31023.

Change-Id: Ie2f27a5867724a8a1b8c3082c3389c8fd6d1dee7
Reviewed-on: https://go-review.googlesource.com/c/go/+/168861
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoruntime: remove kindNoPointers
Keith Randall [Mon, 25 Mar 2019 19:34:27 +0000 (12:34 -0700)]
runtime: remove kindNoPointers

We already have the ptrdata field in a type, which encodes exactly
the same information that kindNoPointers does.

My problem with kindNoPointers is that it often leads to
double-negative code like:

   t.kind & kindNoPointers != 0

Much clearer is:

   t.ptrdata == 0

Update #27167

Change-Id: I92307d7f018a6bbe3daca4a4abb4225e359349b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/169157
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agonet: add missing period in conn.File documentation
Matt Layher [Mon, 25 Mar 2019 18:05:31 +0000 (14:05 -0400)]
net: add missing period in conn.File documentation

Change-Id: Ie873d7ed595c91cee4c1aa6c22fa44b61b6190ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/169138
Run-TryBot: Matt Layher <mdlayher@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/dist: set GOPATH to internal directory during build
Jay Conrod [Thu, 21 Mar 2019 19:18:04 +0000 (15:18 -0400)]
cmd/dist: set GOPATH to internal directory during build

Since GO111MODULE=on by default, the Go command needs a location for
the module cache, even though it doesn't need to be written when
building std and cmd. If GOROOT is checked out to $HOME/go, which is
also the default location for GOPATH, this causes unnecessary problems
late in the build.

With this change, dist sets GOPATH to $GOROOT/pkg/obj/go-path. This is
next to the temporary GOCACHE, $GOROOT/pkg/obj/go-build.

Fixes #30960

Change-Id: I60771ee7f7c67ced1d2dc7c66b5885703fad1b63
Reviewed-on: https://go-review.googlesource.com/c/go/+/168697
Run-TryBot: Jay Conrod <jayconrod@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: skip wb call in growslice when unnecessary
Josh Bleecher Snyder [Fri, 22 Mar 2019 21:51:33 +0000 (14:51 -0700)]
runtime: skip wb call in growslice when unnecessary

Instrumenting make.bash reveals that almost half (49.54%)
of the >16 million calls to growslice for
pointer-containing slices are
growing from an empty to a non-empty slice.

In that case, there is no need to call the write barrier,
which does some work before discovering that no pointers need shading.

Change-Id: Ide741468d8dee7ad43ea0bfbea6ccdf680030a0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/168959
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/compile: use existing instructions instead of nops for inline marks
Keith Randall [Tue, 15 Jan 2019 22:50:09 +0000 (14:50 -0800)]
cmd/compile: use existing instructions instead of nops for inline marks

Instead of always inserting a nop to use as the target of an inline
mark, see if we can instead find an instruction we're issuing anyway
with the correct line number, and use that instruction. That way, we
don't need to issue a nop.

Makes cmd/go 0.3% smaller.

Update #29571

Change-Id: If6cfc93ab3352ec2c6e0878f8074a3bf0786b2f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/158021
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agocontext: remove dependency on reflect
Michael Fraenkel [Wed, 27 Feb 2019 20:27:42 +0000 (15:27 -0500)]
context: remove dependency on reflect

Make context depend on reflectlite instead of reflect in effort to
eventually make net no longer depend on unicode tables.

With this CL we're down to just:

    net -> context -> fmt -> unicode tables

The next CL can remove context -> fmt.

Updates #30440

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

6 years agomath/rand: add example for Intn func
Vladimir Kovpak [Wed, 13 Mar 2019 09:39:21 +0000 (09:39 +0000)]
math/rand: add example for Intn func

Change-Id: I831ffb5c3fa2872d71def8d8461f0adbd4ae2c1a
GitHub-Last-Rev: 2adfcd2d5a592ef4c63da781240a391da89b5d9e
GitHub-Pull-Request: golang/go#30706
Reviewed-on: https://go-review.googlesource.com/c/go/+/166426
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodatabase/sql: add example for DB.Prepare and Tx.Prepare
Hasan Ozgan [Thu, 7 Feb 2019 23:22:54 +0000 (23:22 +0000)]
database/sql: add example for DB.Prepare and Tx.Prepare

Change-Id: Ib9272a7713ed7aaf8ad54c4827be8c095763e648
Reviewed-on: https://go-review.googlesource.com/c/go/+/161677
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agonet/http: reduce allocs on write cookie
sergey [Sun, 17 Feb 2019 18:29:39 +0000 (21:29 +0300)]
net/http: reduce allocs on write cookie

Pregrow buffer to reduce allocs on building cookie string.
We calc cookie name value and domain size (most distributed by value) and
add 110 extra characters allows to write most cookie attributes
without additional allocations in most cases.

name              old time/op    new time/op    delta
CookieString-4      1.65µs ± 3%    1.27µs ± 2%  -23.01%  (p=0.008 n=5+5)
ReadSetCookies-4    5.78µs ± 4%    5.67µs ± 3%     ~     (p=0.310 n=5+5)
ReadCookies-4       7.12µs ± 4%    7.04µs ± 3%     ~     (p=0.690 n=5+5)

name              old alloc/op   new alloc/op   delta
CookieString-4        360B ± 0%      144B ± 0%  -60.00%  (p=0.008 n=5+5)
ReadSetCookies-4      976B ± 0%      976B ± 0%     ~     (all equal)
ReadCookies-4       2.17kB ± 0%    2.17kB ± 0%     ~     (all equal)

name              old allocs/op  new allocs/op  delta
CookieString-4        5.00 ± 0%      1.00 ± 0%  -80.00%  (p=0.008 n=5+5)
ReadSetCookies-4      15.0 ± 0%      15.0 ± 0%     ~     (all equal)
ReadCookies-4         16.0 ± 0%      16.0 ± 0%     ~     (all equal)

Change-Id: I50defac954a135b785b3551342b00878429b3d7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/163017
Reviewed-by: Volker Dobler <dr.volker.dobler@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

6 years agotest: new test for issue 30908
Than McIntosh [Fri, 22 Mar 2019 18:57:32 +0000 (14:57 -0400)]
test: new test for issue 30908

New test case designed to mimic the code in issue 30908, which
features duplicate but non-indentical DWARF abstract subprogram DIEs.

Updates #30908.

Change-Id: Iacb4b53e6a988e46c801cdac236cef883c553f8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/168957
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
6 years agotest: support -ldflags for "rundir" tests, new -P option
Than McIntosh [Fri, 22 Mar 2019 19:24:36 +0000 (15:24 -0400)]
test: support -ldflags for "rundir" tests, new -P option

For "rundir" tests, allow users to add in linker flags as well as
compiler flags, e.g.

// rundir -m -ldflags -w

The directive above will pass "-m" to the compiler on each package compilation
and "-w" to the linker for the final link.

In addition, if "-P" is specified with 'rundir', then for each compile
pass in "-p <X>" to set the packagepath explicitly, which is closer to
how the compiler is run by 'go build'.

Change-Id: I04720011a89d1bd8dcb4f2ccb4af1d74f6a01da1
Reviewed-on: https://go-review.googlesource.com/c/go/+/168977
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/compile: better handling for PAUTOHEAP in DWARF inline gen
Than McIntosh [Fri, 22 Mar 2019 12:14:45 +0000 (08:14 -0400)]
cmd/compile: better handling for PAUTOHEAP in DWARF inline gen

When generating DWARF inline info records, the post-SSA code looks
through the original "pre-inline" dcl list for the function so as to
handle situations where formal params are promoted or optimized away.
This code was not properly handling the case where an output parameter
was promoted to the heap -- in this case the param node is converted
in place from class PPARAMOUT to class PAUTOHEAP. This caused
inconsistencies later on, since the variable entry in the abstract
subprogram DIE wound up as a local and not an output parameter.

Fixes #30908.

Change-Id: Ia70b89f0cf7f9b16246d95df17ad6e307228b8c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/168818
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agomisc/wasm: exit with code 1 if WebAssembly.instantiate fails
Richard Musiol [Sun, 24 Mar 2019 17:17:43 +0000 (18:17 +0100)]
misc/wasm: exit with code 1 if WebAssembly.instantiate fails

go_js_wasm_exec was returning with code 0 if WebAssembly.instantiate
failed. This made failing tests show as passed.

Change-Id: Icfb2f42e9f1c3c70ca4a130a61a63cb305edff32
Reviewed-on: https://go-review.googlesource.com/c/go/+/168885
Run-TryBot: Richard Musiol <neelance@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/link/internal/wasm: do not generate more than 100000 data segments
Richard Musiol [Sun, 24 Mar 2019 17:21:11 +0000 (18:21 +0100)]
cmd/link/internal/wasm: do not generate more than 100000 data segments

Some WebAssembly runtimes (e.g. Node.js) fail to load a wasm binary if
it has more than 100000 data segments. Do not skip zero regions any more
if the limit was reached.

Change-Id: I14c4c2aba142d1d2b887bce6d03b8c1c1746c5ec
Reviewed-on: https://go-review.googlesource.com/c/go/+/168884
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agopath/filepath: add examples for Base, Dir and IsAbs
Hasan Ozgan [Fri, 8 Feb 2019 00:50:51 +0000 (00:50 +0000)]
path/filepath: add examples for Base, Dir and IsAbs

Change-Id: I7a438409748f0f9d6517a7ea1cdee6512ce3ca8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/161678
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agolog: expose Writer() method of the standard logger
Petr Jediný [Sat, 23 Mar 2019 00:00:48 +0000 (00:00 +0000)]
log: expose Writer() method of the standard logger

The Go 1.12 introduced Writer() method for logger objects, but
it was not exposed as log package function for standard logger.
This commit adds such Writer() function.

Change-Id: Ia81b1524839fe05c152ecb5eaef047a076349fea
GitHub-Last-Rev: dc152ea641dd928178dbd921e2d0f6361661a0d6
GitHub-Pull-Request: golang/go#31009
Reviewed-on: https://go-review.googlesource.com/c/go/+/168920
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agonet/url: check for lowercase before uppercase in shouldEscape
sergey [Sun, 24 Mar 2019 16:33:19 +0000 (19:33 +0300)]
net/url: check for lowercase before uppercase in shouldEscape

Most chars in URLs are lowercase, so check that first.

Performance change:

String-4               7.62µs ± 1%    7.27µs ± 3%  -4.61%  (p=0.008 n=5+5)
QueryEscape/#00-4      92.6ns ± 3%    90.3ns ± 1%  -2.48%  (p=0.016 n=5+5)
QueryEscape/#01-4       515ns ± 4%     510ns ± 2%    ~     (p=0.683 n=5+5)
QueryEscape/#02-4       375ns ± 1%     343ns ± 1%  -8.52%  (p=0.008 n=5+5)
QueryEscape/#03-4       758ns ± 1%     699ns ± 1%  -7.83%  (p=0.008 n=5+5)
QueryEscape/#04-4      6.06µs ± 1%    5.74µs ± 1%  -5.38%  (p=0.008 n=5+5)
PathEscape/#00-4        140ns ± 1%     135ns ± 2%  -3.85%  (p=0.008 n=5+5)
PathEscape/#01-4        511ns ± 3%     507ns ± 3%    ~     (p=0.587 n=5+5)
PathEscape/#02-4        372ns ± 1%     342ns ± 2%  -8.22%  (p=0.008 n=5+5)
PathEscape/#03-4        747ns ± 1%     685ns ± 1%  -8.30%  (p=0.008 n=5+5)
PathEscape/#04-4       5.94µs ± 1%    5.64µs ± 3%  -4.98%  (p=0.008 n=5+5)
QueryUnescape/#00-4     111ns ± 4%     110ns ± 2%    ~     (p=0.952 n=5+5)
QueryUnescape/#01-4     390ns ± 0%     391ns ± 2%    ~     (p=0.714 n=5+5)
QueryUnescape/#02-4     297ns ± 5%     295ns ± 3%    ~     (p=0.524 n=5+5)
QueryUnescape/#03-4     543ns ± 3%     556ns ± 2%  +2.39%  (p=0.032 n=5+5)
QueryUnescape/#04-4    3.23µs ± 3%    3.22µs ± 2%    ~     (p=1.000 n=5+5)
PathUnescape/#00-4      111ns ± 1%     110ns ± 3%    ~     (p=0.881 n=5+5)
PathUnescape/#01-4      389ns ± 2%     386ns ± 2%    ~     (p=0.444 n=5+5)
PathUnescape/#02-4      297ns ± 1%     295ns ± 3%    ~     (p=0.738 n=5+5)
PathUnescape/#03-4      557ns ± 3%     553ns ± 2%    ~     (p=0.810 n=5+5)
PathUnescape/#04-4     2.94µs ± 2%    2.97µs ± 2%    ~     (p=0.222 n=5+5)

Change-Id: I7e6d64cd5f8f5218cb40f52f0015168a8674aabb
Reviewed-on: https://go-review.googlesource.com/c/go/+/168883
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go: keep WINDIR during TestScript
Alex Brainman [Sun, 24 Mar 2019 04:49:45 +0000 (15:49 +1100)]
cmd/go: keep WINDIR during TestScript

TestScript executes PowerShell. And PowerShell appears to require
WINDIR environment variable to exists on windows-arm.

So keep WINDIR environment variable when running PowerShell.

Fixes #30711

Change-Id: I14dde6614347325a8f3caf994ea8ab05294450a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/168859
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agotext/template: allow using -}} with many spaces
Daniel Martí [Wed, 20 Mar 2019 15:47:56 +0000 (15:47 +0000)]
text/template: allow using -}} with many spaces

lexSpace consumed all spaces, even if the last one was part of a right
delimiter like " -}}". Thus, "3  -}}" wouldn't lex as "3" and a right
delimiter, but as "3", "-", and "}}".

To fix that, make lexSpace stop if it encounters a right delimiter.

Fixes #30948.

Change-Id: I80a5546e5809e54f6823e2bf3a57a7e8808329be
Reviewed-on: https://go-review.googlesource.com/c/go/+/168457
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
6 years agocmd/go: add GOWASM environment variable
Richard Musiol [Sat, 23 Mar 2019 13:18:19 +0000 (14:18 +0100)]
cmd/go: add GOWASM environment variable

This change adds the environment variable GOWASM, which is a comma
separated list of experimental WebAssembly features that the compiled
WebAssembly binary is allowed to use. The default is to use no
experimental features. Initially there are no features avaiable.

More information about feature proposals can be found at
https://github.com/WebAssembly/proposals

Change-Id: I4c8dc534c99ecff8bb075dded0186ca8f8decaef
Reviewed-on: https://go-review.googlesource.com/c/go/+/168881
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agosrc/cmd/internal/obj/wasm: optimize blocks in wasm binary
Richard Musiol [Sun, 17 Mar 2019 12:45:46 +0000 (13:45 +0100)]
src/cmd/internal/obj/wasm: optimize blocks in wasm binary

This change optimizes the blocks in the wasm binary by generating the
entryPointLoop only if it is used and adding an unwindExit block to
be able to use the short BrIf instruction for unwinding the stack.
These changes were suggested by the wasm-opt tool and reduce the
wasm binary size of "hello world" by 1.5%.

Change-Id: Ie52db2fa2d9b8482f9a78b7c189231750811fe97
Reviewed-on: https://go-review.googlesource.com/c/go/+/167937
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/internal/obj/mips: add MADD/MSUB
Ben Shi [Fri, 15 Mar 2019 08:26:53 +0000 (08:26 +0000)]
cmd/internal/obj/mips: add MADD/MSUB

This CL implements MADD&MSUB, which are mips32r2 instructions.

Change-Id: I06fe51573569baf3b71536336b34b95ccd24750b
Reviewed-on: https://go-review.googlesource.com/c/go/+/167680
Run-TryBot: Ben Shi <powerman1st@163.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agotesting: fix fractional ns/op printing
Austin Clements [Fri, 22 Mar 2019 18:18:22 +0000 (14:18 -0400)]
testing: fix fractional ns/op printing

CL 166717 changed the way ns/op benchmark results were printed and
inadvertently rounded all ns/op results down to an integer, even if
they were small enough to print with digits after the decimal place.
For example, prior to this change, we got output like

    BenchmarkFast-8       380491575  3.12 ns/op

CL 166717 changed this to

    BenchmarkFast-8       380491575      3.00 ns/op

This had the further side-effect that ns/op values between 0 and 1
would not be printed at all because they would be rounded down to 0.

This CL fixes this by always recomputing the float64 value of ns/op
instead of using the int64 truncation from BenchmarkResult.NsPerOp.

Fixes #30997. Fixes #31005.

Change-Id: I21f73b9d5cc5ad41e7ff535675d07ca00051ecd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/168937
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agocmd/go: fix the default build output name for versioned binaries
Dmitri Shuralyov [Thu, 21 Mar 2019 17:31:32 +0000 (13:31 -0400)]
cmd/go: fix the default build output name for versioned binaries

This change is a re-apply of the reverted CL 140863 with changes to
address issue #30821. Specifically, path.Split continues to be used
to split the '/'-separated import path, rather than filepath.Split.

Document the algorithm for how the default executable name is determined
in DefaultExecName.

Rename a variable returned from os.Stat from bs to fi for consistency.

CL 140863 factored out the logic to determine the default executable
name from the Package.load method into a DefaultExecName function,
and started using it in more places to avoid having to re-implement
the logic everywhere it's needed. Most previous callers already computed
the default executable name based on the import path. The load.Package
method, before CL 140863, was the exception, in that it used the p.Dir
value in GOPATH mode instead. There was a NOTE(rsc) comment that it
should be equivalent to use import path, but it was too late in Go 1.11
cycle to risk implementing that change.

This is part 1, a more conservative change for backporting to Go 1.12.2,
and it keeps the original behavior of splitting on p.Dir in GOPATH mode.
Part 2 will address the NOTE(rsc) comment and modify behavior in
Package.load to always use DefaultExecName which splits the import path
rather than directory. It is intended to be included in Go 1.13.

Fixes #27283 (again)
Updates #26869
Fixes #30821

Change-Id: Ib1ebb95acba7c85c24e3a55c40cdf48405af34f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/167503
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
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>