]> Cypherpunks repositories - gostls13.git/log
gostls13.git
6 years agomath/bits: panic when y<=hi in Div
Brian Kessler [Wed, 24 Oct 2018 02:20:44 +0000 (20:20 -0600)]
math/bits: panic when y<=hi in Div

Explicitly check for divide-by-zero/overflow and panic with the appropriate
runtime error.  The additional checks have basically no effect on performance
since the branch is easily predicted.

name     old time/op  new time/op  delta
Div-4    53.9ns ± 1%  53.0ns ± 1%  -1.59%  (p=0.016 n=4+5)
Div32-4  17.9ns ± 0%  18.4ns ± 0%  +2.56%  (p=0.008 n=5+5)
Div64-4  53.5ns ± 0%  53.3ns ± 0%    ~     (p=0.095 n=5+5)

Updates #28316

Change-Id: I36297ee9946cbbc57fefb44d1730283b049ecf57
Reviewed-on: https://go-review.googlesource.com/c/144377
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/compile: don't convert non-Go-constants to OLITERALs
Keith Randall [Mon, 26 Nov 2018 23:58:03 +0000 (15:58 -0800)]
cmd/compile: don't convert non-Go-constants to OLITERALs

Don't convert values that aren't Go constants, like
uintptr(unsafe.Pointer(nil)), to a literal constant. This avoids
assuming they are constants for things like indexing, array sizes,
case duplication, etc.

Also, nil is an allowed duplicate in switches. CTNILs aren't Go constants.

Fixes #28078
Fixes #28079

Change-Id: I9ab8af47098651ea09ef10481787eae2ae2fb445
Reviewed-on: https://go-review.googlesource.com/c/151320
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/link: fix XCOFF sections
Clément Chigot [Fri, 23 Nov 2018 10:17:36 +0000 (11:17 +0100)]
cmd/link: fix XCOFF sections

XCOFF files can't have multiples text or data sections. The name
of each type section must be .text, .data and .bss.

This commit also updates cmd/internal/objfile/xcoff.go to retrieve Go
sections using runtime symbols.

Change-Id: Ib6315f19dad2d154a4531fc6508e7cbd8bc94743
Reviewed-on: https://go-review.googlesource.com/c/151037
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoruntime: improve godoc formatting of memclrNoHeapPointers comment
Ian Lance Taylor [Mon, 26 Nov 2018 20:11:34 +0000 (12:11 -0800)]
runtime: improve godoc formatting of memclrNoHeapPointers comment

Fixes #28955

Change-Id: I738ad0c76f7bf8fc504a48cf55d3becd5ed7a9d6
Reviewed-on: https://go-review.googlesource.com/c/151337
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/link/internal/ld: remove R_ADDR relocations inside XCOFF text sections
Clément Chigot [Fri, 2 Nov 2018 12:50:59 +0000 (13:50 +0100)]
cmd/link/internal/ld: remove R_ADDR relocations inside XCOFF text sections

On XCOFF, it is forbidden relocation of a DATA pointer to a text
section. It happens when a RODATA symbol needs a DATA symbol's address.
This commit moves every RODATA symbols with a R_ADDR on a data symbol to
.data sections to avoid these relocations.

Change-Id: I7f34d8e0ebdc8352a74e6b40e4c893d8d9419f4d
Reviewed-on: https://go-review.googlesource.com/c/146977
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: initialize sparse slice literals dynamically
Keith Randall [Mon, 26 Nov 2018 22:33:32 +0000 (14:33 -0800)]
cmd/compile: initialize sparse slice literals dynamically

When a slice composite literal is sparse, initialize it dynamically
instead of statically.

s := []int{5:5, 20:20}

To initialize the backing store for s, use 2 constant writes instead
of copying from a static array with 21 entries.

This CL also fixes pathologies in the compiler when the slice is
*very* sparse.

Fixes #23780

Change-Id: Iae95c6e6f6a0e2994675cbc750d7a4dd6436b13b
Reviewed-on: https://go-review.googlesource.com/c/151319
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: don't constant-fold non-Go constants in the frontend
Keith Randall [Mon, 26 Nov 2018 20:59:54 +0000 (12:59 -0800)]
cmd/compile: don't constant-fold non-Go constants in the frontend

Abort evconst if its argument isn't a Go constant. The SSA backend
will do the optimizations in question later. They tend to be weird
cases, like uintptr(unsafe.Pointer(uintptr(1))).

Fix OADDSTR and OCOMPLEX cases in isGoConst.
OADDSTR has its arguments in n.List, not n.Left and n.Right.
OCOMPLEX might have a 2-result function as its arg in List[0]
(in which case it isn't a Go constant).

Fixes #24760

Change-Id: Iab312d994240d99b3f69bfb33a443607e872b01d
Reviewed-on: https://go-review.googlesource.com/c/151338
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: remove CLOBBERDEAD experiment
Keith Randall [Mon, 26 Nov 2018 18:28:44 +0000 (10:28 -0800)]
cmd/compile: remove CLOBBERDEAD experiment

This experiment is less effective and less needed since the
introduction of stack objects.

We can't clobber stack objects because we don't know statically
whether they are live or not.

We don't really need this experiment that much any more, as it was
primarily used to test the complicated ambiguously-live logic in the
liveness analysis, which has been removed in favor of stack objects.

It is also ~infeasible to maintain once we have safepoints everywhere.

Fixes #27326

Change-Id: I3bdde480b93dd508d048703055d4586b496176af
Reviewed-on: https://go-review.googlesource.com/c/151317
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agogo/internal/gccgoimporter: enhance for new export data, fix test issues
Than McIntosh [Fri, 16 Nov 2018 15:11:47 +0000 (10:11 -0500)]
go/internal/gccgoimporter: enhance for new export data, fix test issues

This patch merges in support for reading indexed type export data,
from the gofrontend CL https://golang.org/cl/143022 (which includes
a change in the export data version number from V2 to V3).

Also fixes the key tests to insure that they run both in gccgo builds
and main Go repo builds if "gccgo" is present (prior to this the tests
were not running in either scenario); this required fixing up some of
the expected results.

Fixes #28961.

Change-Id: I644d171f2a46be9160f89dada06ab3c20468bab7
Reviewed-on: https://go-review.googlesource.com/c/149957
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: allow bodyless function if it is linkname'd
Keith Randall [Mon, 26 Nov 2018 18:48:56 +0000 (10:48 -0800)]
cmd/compile: allow bodyless function if it is linkname'd

In assembly free packages (aka "complete" or "pure go"), allow
bodyless functions if they are linkname'd to something else.

Presumably the thing the function is linkname'd to has a definition.
If not, the linker will complain. And linkname is unsafe, so we expect
users to know what they are doing.

Note this handles only one direction, where the linkname directive
is in the local package. If the linkname directive is in the remote
package, this CL won't help. (See os/signal/sig.s for an example.)

Fixes #23311

Change-Id: I824361b4b582ee05976d94812e5b0e8b0f7a18a6
Reviewed-on: https://go-review.googlesource.com/c/151318
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agoruntime: windows/arm fix tracebacks printed from sigpanic
Jordan Rhee [Wed, 21 Nov 2018 22:04:29 +0000 (14:04 -0800)]
runtime: windows/arm fix tracebacks printed from sigpanic

The exception handler modifies the stack and continuation context so
it looks like the faulting code calls sigpanic() directly. The call was
not set up correctly on ARM, because it did not handle the link register
correctly. This change handles the link register correctly for ARM.

Updates #28854

Change-Id: I7ccf838adfc05cd968a5edd7d19ebba6a2478360
Reviewed-on: https://go-review.googlesource.com/c/150957
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: fix nilcheck for AIX
Clément Chigot [Tue, 16 Oct 2018 13:59:43 +0000 (15:59 +0200)]
cmd/compile: fix nilcheck for AIX

This commit adapts compile tool to create correct nilchecks for AIX.

AIX allows to load a nil pointer. Therefore, the default nilcheck
which issues a load must be replaced by a CMP instruction followed by a
store at 0x0 if the value is nil. The store will trigger a SIGSEGV as on
others OS.

The nilcheck algorithm must be adapted to do not remove nilcheck if it's
only a read. Stores are detected with v.Type.IsMemory().

Tests related to nilptr must be adapted to the previous changements.
nilptr.go cannot be used as it's because the AIX address space starts at
1<<32.

Change-Id: I9f5aaf0b7e185d736a9b119c0ed2fe4e5bd1e7af
Reviewed-on: https://go-review.googlesource.com/c/144538
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoruntime: handle 64bits addresses for AIX
Clément Chigot [Mon, 1 Oct 2018 07:58:40 +0000 (09:58 +0200)]
runtime: handle 64bits addresses for AIX

This commit allows the runtime to handle 64bits addresses returned by
mmap syscall on AIX.

Mmap syscall returns addresses on 59bits on AIX. But the Arena
implementation only allows addresses with less than 48 bits.
This commit increases the arena size up to 1<<60 for aix/ppc64.

Update: #25893

Change-Id: Iea72e8a944d10d4f00be915785e33ae82dd6329e
Reviewed-on: https://go-review.googlesource.com/c/138736
Reviewed-by: Austin Clements <austin@google.com>
6 years agofmt: update formatting example for maps
Rob Pike [Mon, 26 Nov 2018 04:58:56 +0000 (15:58 +1100)]
fmt: update formatting example for maps

Now that maps are printed in deterministic order, the map example
can have multiple keys without breaking the build.

Change-Id: Iccec0cd76a3d41c75d8d4eb768ec0ac09ad9f2ad
Reviewed-on: https://go-review.googlesource.com/c/151218
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>

6 years agodoc: improve the interface example in Effective Go
Rob Pike [Mon, 26 Nov 2018 03:51:08 +0000 (14:51 +1100)]
doc: improve the interface example in Effective Go

The String method is n-squared and overwrites its receiver.
Fix both issues, with only a slight loss of clarity.

Fixes #28773

Change-Id: I588f69d4cbd72931b28b984671512834473bd466
Reviewed-on: https://go-review.googlesource.com/c/151217
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodebug/pe: use kernel32.dll in TestImportTableInUnknownSection
Alex Brainman [Sat, 24 Nov 2018 05:54:01 +0000 (16:54 +1100)]
debug/pe: use kernel32.dll in TestImportTableInUnknownSection

TestImportTableInUnknownSection was introduced in CL 110555 to
test PE executable with import table located in section other than
".idata". We used atmfd.dll for that purpose, but it seems
atmfd.dll is not present on some systems.

Use kernel32.dll instead. kernel32.dll import table is located in
".rdata" section, so it should do the job. And every Windows
system has kernel32.dll file.

Also make TestImportTableInUnknownSection run on windows-arm,
since windows-arm should also have kernel32.dll file.

Updates #27904

Change-Id: Ie005ee10e46ae0c06e83929d581e89f86c051eea
Reviewed-on: https://go-review.googlesource.com/c/151137
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: decompose composite OpArg before decomposeUser
David Chase [Fri, 16 Nov 2018 21:20:28 +0000 (16:20 -0500)]
cmd/compile: decompose composite OpArg before decomposeUser

This makes it easier to track names of function arguments
for debugging purposes.

Change-Id: Ic34856fe0b910005e1c7bc051d769d489a4b158e
Reviewed-on: https://go-review.googlesource.com/c/150098
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/compile: make ssa blocks collapsable in ssa.html
Yury Smolsky [Thu, 25 Oct 2018 10:33:09 +0000 (13:33 +0300)]
cmd/compile: make ssa blocks collapsable in ssa.html

This CL adds a button that collapses values list of a block.
Button is displayed for every block with non-empty values.

Change-Id: I4b65af81e25349f38341df487d42698c9d006a00
Reviewed-on: https://go-review.googlesource.com/c/144557
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/go: more cross-package references from internal/syscall/unix
Austin Clements [Tue, 13 Nov 2018 23:38:49 +0000 (18:38 -0500)]
cmd/go: more cross-package references from internal/syscall/unix

On some platforms, assembly in internal/syscall/unix references
unexported runtime symbols. Catch these references so the compiler can
generate the necessary ABI wrappers.

Fixes #28769.
Updates #27539.

Change-Id: I118eebfb8b3d907b4c3562198e6afb49854f5827
Reviewed-on: https://go-review.googlesource.com/c/149817
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Clément Chigot <clement.chigot@atos.net>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/compile: use correct store types in softfloat
Cherry Zhang [Sat, 17 Nov 2018 03:53:04 +0000 (22:53 -0500)]
cmd/compile: use correct store types in softfloat

When using softfloat, floating point ops are rewritten to integer
ops. The types of store ops were not rewritten. This may lower
to floating point stores, which are problematic. This CL fixes
this by rewriting the store types as well.

This fixes test/fixedbugs/issue28688.go on Wasm. Softfloat mode
is not used by default on Wasm, and it is not needed as Wasm spec
supports floating points. But it is nice to have the correct
types.

Change-Id: Ib5e19e19fa9491b15c2f60320f8724cace5cefb5
Reviewed-on: https://go-review.googlesource.com/c/149965
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoos: return an error from UserHomeDir to match UserCacheDir
David Heuschmann [Tue, 20 Nov 2018 11:30:14 +0000 (12:30 +0100)]
os: return an error from UserHomeDir to match UserCacheDir

UserHomeDir used to return an empty string if the corresponding
environment variable was not set. Changed it to return an error if the
variable is not set, to have the same signature and behaviour as UserCacheDir.

Fixes #28562

Change-Id: I42c497e8011ecfbbadebe7de1751575273be221c
Reviewed-on: https://go-review.googlesource.com/c/150418
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/trace: revert internal/traceparser
Hana Kim [Mon, 19 Nov 2018 17:30:56 +0000 (12:30 -0500)]
cmd/trace: revert internal/traceparser

The performance improvement is not as big as we hoped.
Until the API is feature complete, we postpone the release
and avoid added complexity.

This change was prepared by reverting all the changes affected
src/cmd/trace and src/internal/traceparser packages after
golang.org/cl/137635, and then bringing back MMU computation
APIs (originally in src/internal/traceparser) to the
src/internal/trace package.

Revert "cmd/trace: use new traceparser to parse the raw trace files"
This reverts https://golang.org/cl/145457
  (commit 08816cb8d7ed16b9c804587ff02c1ad1c3af6cd5).

Revert "internal/traceparser: provide parser that uses less space and parses segments of runtime trace files"
This reverts https://golang.org/cl/137635
  (commit daaf361f74c3665bcb364356c5a9dd9f536c78c3).

Change-Id: Ic2a068a7dbaf4053cd9674ca7bde9c58e74385b4
Reviewed-on: https://go-review.googlesource.com/c/150517
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agoos: prevent RemoveAll to remove "." on Plan 9
David du Colombier [Wed, 21 Nov 2018 23:06:42 +0000 (00:06 +0100)]
os: prevent RemoveAll to remove "." on Plan 9

CL 150497 enabled TestRemoveAllDot on "noat" systems.

However, this test is failing on Plan 9 because the rmdir
system call allows to remove "." on Plan 9.

This change prevents the "noat" implementation of RemoveAll to
remove ".", so it remains consistent with the "at" implementation.

Fixes #28903.

Change-Id: Ifc8fe36bdd8053a4e416f0590663c844c97ce72a
Reviewed-on: https://go-review.googlesource.com/c/150621
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: for non-SSA-typed params, emit simple vars.
David Chase [Tue, 20 Nov 2018 21:33:33 +0000 (16:33 -0500)]
cmd/compile: for non-SSA-typed params, emit simple vars.

This case was missed entirely and caused such params to be
unprintable.  This change gives them stack addresses
for the entire function (which is correct).

Change-Id: Ia4f706450219e48bce65b6395d3d9792df142fb5
Reviewed-on: https://go-review.googlesource.com/c/150657
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
6 years agocmd/compile: fix TestFormats by using valid formats
Yury Smolsky [Wed, 21 Nov 2018 17:06:28 +0000 (19:06 +0200)]
cmd/compile: fix TestFormats by using valid formats

CL 142517 has used some formats incorrectly. This change fixes it
by using %v for errors and invoking Block.Kind.String().
Format map stays intact.

Updates #28177

Change-Id: If53b6cc54ba3c1ffc17b005225787e3b546de404
Reviewed-on: https://go-review.googlesource.com/c/150798
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
6 years agoruntime: debug code to catch bad gcWork.puts
Austin Clements [Mon, 19 Nov 2018 15:37:14 +0000 (10:37 -0500)]
runtime: debug code to catch bad gcWork.puts

This adds a debug check to throw immediately if any pointers are added
to the gcWork buffer after the mark completion barrier. The intent is
to catch the source of the cached GC work that occasionally produces
"P has cached GC work at end of mark termination" failures.

The result should be that we get "throwOnGCWork" throws instead of "P
has cached GC work at end of mark termination" throws, but with useful
stack traces.

This should be reverted before the release. I've been unable to
reproduce this issue locally, but this issue appears fairly regularly
on the builders, so the intent is to catch it on the builders.

This probably slows down the GC slightly.

For #27993.

Change-Id: I5035e14058ad313bfbd3d68c41ec05179147a85c
Reviewed-on: https://go-review.googlesource.com/c/149969
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoruntime: improve "P has cached GC work" debug info
Austin Clements [Mon, 19 Nov 2018 15:36:45 +0000 (10:36 -0500)]
runtime: improve "P has cached GC work" debug info

For #27993.

Change-Id: I20127e8a9844c2c488f38e1ab1f8f5a27a5df03e
Reviewed-on: https://go-review.googlesource.com/c/149968
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agonet/http: fix spelling mistake in a comment
haormj [Wed, 21 Nov 2018 12:18:56 +0000 (12:18 +0000)]
net/http: fix spelling mistake in a comment

Fixes #28904

Change-Id: I8d416c47479a266735a39c926fd2f0f2bb25d57b
GitHub-Last-Rev: 3a7865a5be27937833cf4f65c242c639e51665c4
GitHub-Pull-Request: golang/go#28907
Reviewed-on: https://go-review.googlesource.com/c/150737
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: add control flow graphs to ssa.html
Yury Smolsky [Tue, 16 Oct 2018 10:03:35 +0000 (13:03 +0300)]
cmd/compile: add control flow graphs to ssa.html

This CL adds CFGs to ssa.html.
It execs dot to generate SVG,
which then gets inlined into the html.
Some standard naming and javascript hacks
enable integration with the rest of ssa.html.
Clicking on blocks highlights the relevant
part of the CFG, and vice versa.

Sample output and screenshots can be seen in #28177.

CFGs can be turned on with the suffix mask:
:*            - dump CFG for every phase
:lower        - just the lower phase
:lower-layout - lower through layout
:w,x-y        - phases w and x through y

Calling dot after every pass is noticeably slow,
instead use the range of phases.

Dead blocks are not displayed on CFG.

User can zoom and pan individual CFG
when the automatic adjustment has failed.

Dot-related errors are reported
without bringing down the process.

Fixes #28177

Change-Id: Id52c42d86c4559ca737288aa10561b67a119c63d
Reviewed-on: https://go-review.googlesource.com/c/142517
Run-TryBot: Yury Smolsky <yury@smolsky.by>
Reviewed-by: David Chase <drchase@google.com>
6 years agoruntime: add arg maps for sync/atomic functions in ARM64 race mode
Cherry Zhang [Tue, 20 Nov 2018 15:20:06 +0000 (10:20 -0500)]
runtime: add arg maps for sync/atomic functions in ARM64 race mode

In race mode, these functions are defined and declared in
different packages, which therefore don't have implicit arg maps.
When they are defer'd, and the stack needs to move, the runtime
fails with missing stack maps. This CL adds arg maps (FUNCDATA)
to them.

Updates #28848

Change-Id: I0271563b7e78e7797ce2990c303dced957efaa86
Reviewed-on: https://go-review.googlesource.com/c/150457
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agomisc/wasm: add stub for fs.read on browsers
Richard Musiol [Tue, 20 Nov 2018 20:49:41 +0000 (21:49 +0100)]
misc/wasm: add stub for fs.read on browsers

Using fmt.Scanln in a browser environment caused a panic, since there
was no stub for fs.read. This commit adds a stub that returns ENOSYS.

Fixes #27773.

Change-Id: I79b019039e4bc90da51d71a4edddf3bd7809ff45
Reviewed-on: https://go-review.googlesource.com/c/150617
Run-TryBot: Richard Musiol <neelance@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agogo/doc: disable playground for examples that use syscall/js
Richard Musiol [Sat, 10 Nov 2018 14:31:32 +0000 (15:31 +0100)]
go/doc: disable playground for examples that use syscall/js

The playground is not using GOOS=js, so it is not able to use the
package syscall/js. Examples that depend on syscall/js should not
show a "Run" button.

Fixes #28526.

Change-Id: I8b2fcdd0c0ee517a5c3864bf459f813129542389
Reviewed-on: https://go-review.googlesource.com/c/148918
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agoos: return PathError on RemoveAll with trailing dots
Tobias Klauser [Sun, 18 Nov 2018 16:18:37 +0000 (17:18 +0100)]
os: return PathError on RemoveAll with trailing dots

Return a PathError instead of an unwrapped syscall.EINVAL if the path
ends with dots.

As suggested by Roger Peppe in CL 150158.

Change-Id: I4d82a6ff64a979b67a843a1cc4fea58ed9326aed
Reviewed-on: https://go-review.googlesource.com/c/150160
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 agoos: permit RemoveAll with paths that end in ".."
Ian Lance Taylor [Tue, 20 Nov 2018 18:15:14 +0000 (10:15 -0800)]
os: permit RemoveAll with paths that end in ".."

Prohibiting RemoveAll with paths that end in ".." was added with
CL 137442 in this release cycle, but it worked before and it should
continue to work.

Also run TestRemoveAllDot on all systems; the test is not specific to
the use of unlinkat and friends.

Change-Id: I277784c8915cd748fec318d2936062440d5d1fde
Reviewed-on: https://go-review.googlesource.com/c/150497
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
6 years agomime: remove allocation introduced in recent fix
Brad Fitzpatrick [Tue, 20 Nov 2018 18:35:56 +0000 (18:35 +0000)]
mime: remove allocation introduced in recent fix

CL 150417 was submitted before I could recommend this change to remove
an unnecessary allocation.

Updates #28849

Change-Id: I4cd655f62bb3d00eda6c997f074785385bceee0c
Reviewed-on: https://go-review.googlesource.com/c/150498
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 agosyscall: add dummy SIGTERM constant to js/wasm
Richard Musiol [Tue, 20 Nov 2018 15:37:50 +0000 (16:37 +0100)]
syscall: add dummy SIGTERM constant to js/wasm

The js/wasm architecture does not support signals at all, but there are
already some signal constants defined because of stdlib dependencies.
This change adds a dummy constant for syscall.SIGTERM as well, to make
js/wasm compatible with more existing Go code.

There is the Go proverb "Syscall must always be guarded with build
tags.", so code should not expect syscall.SIGTERM to exist. Still,
adding SIGTERM should do more good than harm.

Fixes #28719.

Change-Id: I3554b484f96a21427491c04eb1dd57e7af5bd62f
Reviewed-on: https://go-review.googlesource.com/c/150477
Run-TryBot: Richard Musiol <neelance@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agomisc/wasm: use temporary directory provided by Node.js
Richard Musiol [Tue, 20 Nov 2018 13:47:58 +0000 (14:47 +0100)]
misc/wasm: use temporary directory provided by Node.js

os.TempDir() did not return a proper directory on Windows with js/wasm,
because js/wasm only uses the Unix variant of TempDir.

This commit passes the temporary directory provided by Node.js to the
Go runtime by adding it as a default value for the TMPDIR environment
variable. It makes TempDir compatible with all platforms.

Fixes #27306.

Change-Id: I8b17e44cfb2ca41939ab2a4f918698fe330cb8bc
Reviewed-on: https://go-review.googlesource.com/c/150437
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/link, runtime: add initial cgo support for ppc64
majiang [Fri, 16 Nov 2018 15:39:59 +0000 (15:39 +0000)]
cmd/link, runtime: add initial cgo support for ppc64

We should be able to build docker after this get applied.

Updates #13192

Change-Id: I5378d3518fac52d6bd4c97828884c1b382b7ace5
GitHub-Last-Rev: 210b7bc2e172f641f1102982e04542bf73a1aa46
GitHub-Pull-Request: golang/go#28546
Reviewed-on: https://go-review.googlesource.com/c/146898
Reviewed-by: Jiang Ma <ma.jiang@zte.com.cn>
Reviewed-by: Clément Chigot <clement.chigot@atos.net>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agomime: correctly detect non-ASCII characters in FormatMediaType
David Heuschmann [Tue, 20 Nov 2018 10:11:59 +0000 (11:11 +0100)]
mime: correctly detect non-ASCII characters in FormatMediaType

FormatMediaType used rune&0x80==0 to check if parameter values consisted
of valid ascii charaters. Comparing strings using their runes instead of
their bytes leads to some non-ascii strings to pass as valid.

E.g. the rune for 'Ą' is 0x104, 0x104 & 0x80 => 0. Its byte
representation is 0xc4 0x84, both of which result in non zero values
when masked with 0x80

Fixes #28849

Change-Id: Ib9fb4968bcbbec0197d81136f380d40a2a56c14b
Reviewed-on: https://go-review.googlesource.com/c/150417
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 agosyscall/js: document ValueOf() panic
Markus [Sat, 17 Nov 2018 19:21:32 +0000 (19:21 +0000)]
syscall/js: document ValueOf() panic

ValueOf() panics if x is not one of the expected types.

Change-Id: I1105e46bd09a5ab13c162b77c1c50cc45bce27a2
GitHub-Last-Rev: 34a88ce8206954d94f0a884ab7f6494116c54a2d
GitHub-Pull-Request: golang/go#28846
Reviewed-on: https://go-review.googlesource.com/c/150138
Reviewed-by: Richard Musiol <neelance@gmail.com>
6 years agoregexp: use backquotes for all regular expression examples
Vladimir Kovpak [Tue, 20 Nov 2018 09:08:11 +0000 (09:08 +0000)]
regexp: use backquotes for all regular expression examples

This commit performs replace double quote to backquote,
so now all examples looks consistent.

Change-Id: I8cf760ce1bdeff9619a88e531161b9516385241b
GitHub-Last-Rev: e3e636cebbf41528b8a73f9a3fe5afa10876f964
GitHub-Pull-Request: golang/go#28879
Reviewed-on: https://go-review.googlesource.com/c/150397
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agodoc/go1.12: announce deprecation of support for FreeBSD 10.x
Tobias Klauser [Sun, 18 Nov 2018 13:52:22 +0000 (14:52 +0100)]
doc/go1.12: announce deprecation of support for FreeBSD 10.x

Fixes #27619

Change-Id: If18df696c0778efe894a4a249d4964db1b02e5d6
Reviewed-on: https://go-review.googlesource.com/c/150159
Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoencoding/pem: test getLine does not include trailing whitespace
Santhosh Kumar Tekuri [Tue, 6 Feb 2018 06:30:13 +0000 (12:00 +0530)]
encoding/pem: test getLine does not include trailing whitespace

Change-Id: I7a1046f5e0aedbbdd1106a616de410fe4e0cb7d8
Reviewed-on: https://go-review.googlesource.com/c/92295
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoregexp: add matching and finding examples
Vladimir Kovpak [Mon, 19 Nov 2018 22:11:33 +0000 (22:11 +0000)]
regexp: add matching and finding examples

This commit adds examples for Match, Find,
FindAllSubmatch, FindSubmatch and Match functions.

Change-Id: I2bdf8c3cee6e89d618109397378c1fc91aaf1dfb
GitHub-Last-Rev: 33f34b7adca2911a4fff9638c93e846fb0021465
GitHub-Pull-Request: golang/go#28837
Reviewed-on: https://go-review.googlesource.com/c/150020
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/link: directly get max pc value in findfunctab
Xia Bin [Mon, 19 Nov 2018 03:24:12 +0000 (11:24 +0800)]
cmd/link: directly get max pc value in findfunctab

Change-Id: I70afd2f7b6783926174c4e66565b711cffeb97c5
Reviewed-on: https://go-review.googlesource.com/c/150141
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: parse dot-separated identifiers in build metadata
Michael Ellis [Wed, 7 Nov 2018 23:14:20 +0000 (15:14 -0800)]
cmd/go: parse dot-separated identifiers in build metadata

Per https://semver.org/#spec-item-10, build metadata may include
a series of dot separated identifiers.

Fixes #28647

Change-Id: I98655c62584a822953df71fba32b4a2cafe7a04b
Reviewed-on: https://go-review.googlesource.com/c/148835
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/vendor: eliminate vet-lite
Alan Donovan [Mon, 19 Nov 2018 17:25:37 +0000 (12:25 -0500)]
cmd/vendor: eliminate vet-lite

cmd/vet, now simplified to a single function call is now authoritative,
not a copy of vet-lite.

The update-xtools.sh script now uses the imports of cmd/vet as the
roots for vendoring.

Change-Id: I4faef3fcf3db10b3a3930726e8d0720a3c8395da
Reviewed-on: https://go-review.googlesource.com/c/150297
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
6 years agocmd/go: improve go vet documentation
Alan Donovan [Fri, 2 Nov 2018 15:27:53 +0000 (11:27 -0400)]
cmd/go: improve go vet documentation

- restore and rework cmd/vet/doc.go, which was clobbered during the vet-lite switch.
- document go vet -vettool=prog flag and how to run an alternative checker.
- make 'go vet -help' show how to list vet tool's flags.  Example:

$ go vet -help
usage: go vet [-n] [-x] [-vettool prog] [build flags] [vet flags] [packages]
Run 'go help vet' for details.
Run 'go tool vet help' for the vet tool's flags.

$ go vet -vettool=~/bin/myvet -help
usage: go vet [-n] [-x] [-vettool prog] [build flags] [vet flags] [packages]
Run 'go help vet' for details.
Run '~/bin/myvet help' for the vet tool's flags.

Updates #28840

Change-Id: Ieb79dfe29e1df074f865bc9a9d47b44199675d7d
Reviewed-on: https://go-review.googlesource.com/c/147018
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/vendor: update to golang.org/x/tools@139d099f
Daniel Martí [Mon, 19 Nov 2018 14:18:04 +0000 (14:18 +0000)]
cmd/vendor: update to golang.org/x/tools@139d099f

Mainly to pull the fix for the regression in #28792.

Change-Id: If71ae783fd9a9e3935186b49fdf501ba098235a2
Reviewed-on: https://go-review.googlesource.com/c/150161
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
6 years agocmd/compile: bulk rename
Josh Bleecher Snyder [Sun, 18 Nov 2018 16:34:38 +0000 (08:34 -0800)]
cmd/compile: bulk rename

This change does a bulk rename of several identifiers in the compiler.
See #27167 and https://docs.google.com/document/d/19_ExiylD9MRfeAjKIfEsMU1_RGhuxB9sA0b5Zv7byVI/
for context and for discussion of these particular renames.

Commands run to generate this change:

gorename -from '"cmd/compile/internal/gc".OPROC' -to OGO
gorename -from '"cmd/compile/internal/gc".OCOM' -to OBITNOT
gorename -from '"cmd/compile/internal/gc".OMINUS' -to ONEG
gorename -from '"cmd/compile/internal/gc".OIND' -to ODEREF
gorename -from '"cmd/compile/internal/gc".OARRAYBYTESTR' -to OBYTES2STR
gorename -from '"cmd/compile/internal/gc".OARRAYBYTESTRTMP' -to OBYTES2STRTMP
gorename -from '"cmd/compile/internal/gc".OARRAYRUNESTR' -to ORUNES2STR
gorename -from '"cmd/compile/internal/gc".OSTRARRAYBYTE' -to OSTR2BYTES
gorename -from '"cmd/compile/internal/gc".OSTRARRAYBYTETMP' -to OSTR2BYTESTMP
gorename -from '"cmd/compile/internal/gc".OSTRARRAYRUNE' -to OSTR2RUNES

gorename -from '"cmd/compile/internal/gc".Etop' -to ctxStmt
gorename -from '"cmd/compile/internal/gc".Erv' -to ctxExpr
gorename -from '"cmd/compile/internal/gc".Ecall' -to ctxCallee
gorename -from '"cmd/compile/internal/gc".Efnstruct' -to ctxMultiOK
gorename -from '"cmd/compile/internal/gc".Easgn' -to ctxAssign
gorename -from '"cmd/compile/internal/gc".Ecomplit' -to ctxCompLit

Not altered: parameters and local variables (mostly in typecheck.go) named top,
which should probably now be called ctx (and which should probably have a named type).
Also not altered: Field called Top in gc.Func.

gorename -from '"cmd/compile/internal/gc".Node.Isddd' -to IsDDD
gorename -from '"cmd/compile/internal/gc".Node.SetIsddd' -to SetIsDDD
gorename -from '"cmd/compile/internal/gc".nodeIsddd' -to nodeIsDDD
gorename -from '"cmd/compile/internal/types".Field.Isddd' -to IsDDD
gorename -from '"cmd/compile/internal/types".Field.SetIsddd' -to SetIsDDD
gorename -from '"cmd/compile/internal/types".fieldIsddd' -to fieldIsDDD

Not altered: function gc.hasddd, params and local variables called isddd
Also not altered: fmt.go prints nodes using "isddd(%v)".

cd cmd/compile/internal/gc; go generate

I then manually found impacted comments using exact string match
and fixed them up by hand. The comment changes were trivial.

Passes toolstash-check.

Fixes #27167. If this experiment is deemed a success,
we will open a new tracking issue for renames to do
at the end of the 1.13 cycles.

Change-Id: I2dc541533d2ab0d06cb3d31d65df205ecfb151e8
Reviewed-on: https://go-review.googlesource.com/c/150140
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agocmd/go: packages that use SWIG depend on "unsafe"
Ian Lance Taylor [Fri, 16 Nov 2018 23:51:49 +0000 (15:51 -0800)]
cmd/go: packages that use SWIG depend on "unsafe"

Fixes #28834

Change-Id: I95d6874e62d36974415f43843881a4ae85b3c7ce
Reviewed-on: https://go-review.googlesource.com/c/149964
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agoos: make RemoveAll("") fail silently on unix
Tobias Klauser [Sat, 17 Nov 2018 13:09:24 +0000 (14:09 +0100)]
os: make RemoveAll("") fail silently on unix

CL 146020 changed the behavior of RemoveAll("") on unix systems using
the *at functions to return syscall.EINVAL instead of nil. Adjust the
*at implementation to retain this behavior as is the case on the *noat
systems.

Additionally, also make sure RemoveAll("") on systems not using the "at
functions (e.g. nacl and js/wasm) follow the same behavior (which wasn't
the case previously).

Fixes #28830

Change-Id: I8383c1423fefe871d18ff49134a1d23077ec6867
Reviewed-on: https://go-review.googlesource.com/c/150158
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: roger peppe <rogpeppe@gmail.com>
6 years agocrypto/hmac: rename CheckHMAC to ValidHMAC in package docs
sevki [Sat, 17 Nov 2018 21:28:08 +0000 (21:28 +0000)]
crypto/hmac: rename CheckHMAC to ValidHMAC in package docs

Procedure names should reflect what they do; function names
should reflect what they return. Functions are used in
expressions, often in things like if's, so they need
to read appropriately.

        if CheckHMAC(a, b, key)

is unhelpful because we can't deduce whether CheckHMAC
returns true on error or non­-error; instead

        if ValidHMAC(a, b, key)

makes the point clear and makes a future mistake
in using the routine less likely.

https://www.lysator.liu.se/c/pikestyle.html

Change-Id: I7c4b1981c90c8d7475ddd8ec18dee3db2e0f42df
GitHub-Last-Rev: 32199a418b5e5507259fa4b6715da8a9c185f90a
GitHub-Pull-Request: golang/go#28823
Reviewed-on: https://go-review.googlesource.com/c/149857
Reviewed-by: Filippo Valsorda <filippo@golang.org>
6 years agoruntime: don't use thread local storage before it is set up on iOS
Elias Naur [Sat, 17 Nov 2018 09:00:14 +0000 (10:00 +0100)]
runtime: don't use thread local storage before it is set up on iOS

CL 138675 added a call to runtime.save_g which uses thread local
storage to store g. On iOS however, that storage was not initialized
 yet. Move the call to below _cgo_init where it is set up.

Change-Id: I14538d3e7d56ff35a6fa02c47bca306d24c38010
Reviewed-on: https://go-review.googlesource.com/c/150157
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/vet: remove pkgfact analyzer, left in by mistake
Alan Donovan [Fri, 16 Nov 2018 21:51:33 +0000 (16:51 -0500)]
cmd/vet: remove pkgfact analyzer, left in by mistake

Also, document process for updating vendored x/tools.

Change-Id: I826744603ae0752e508a6db7334a2bf9adaf1289
Reviewed-on: https://go-review.googlesource.com/c/149963
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/cgo: recognized untyped Go constants as untyped constants
Ian Lance Taylor [Fri, 16 Nov 2018 02:41:03 +0000 (18:41 -0800)]
cmd/cgo: recognized untyped Go constants as untyped constants

Fixes #28772

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

6 years agocmd/asm: rename -symabis to -gensymabis
Austin Clements [Thu, 15 Nov 2018 20:23:48 +0000 (15:23 -0500)]
cmd/asm: rename -symabis to -gensymabis

Currently, both asm and compile have a -symabis flag, but in asm it's
a boolean flag that means to generate a symbol ABIs file and in the
compiler its a string flag giving the path of the symbol ABIs file to
consume. I'm worried about this false symmetry biting us in the
future, so rename asm's flag to -gensymabis.

Updates #27539.

Change-Id: I8b9c18a852d2838099718f8989813f19d82e7434
Reviewed-on: https://go-review.googlesource.com/c/149818
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/vet/all: remove skip when x/tools isn't in $GOPATH
Brad Fitzpatrick [Fri, 16 Nov 2018 16:28:49 +0000 (16:28 +0000)]
cmd/vet/all: remove skip when x/tools isn't in $GOPATH

Now that the build system has been updated to install x/tools in
$GOPATH (CL 149658), depend on it being there and don't ignore
failures to build the tool.

Update to CL 149097.

Change-Id: I72fde347217533697068b6a6773696cc2b83e9ed
Reviewed-on: https://go-review.googlesource.com/c/150017
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
6 years agocmd/vet: basic tests of go vet -json -c=N flags
Alan Donovan [Fri, 16 Nov 2018 19:43:23 +0000 (14:43 -0500)]
cmd/vet: basic tests of go vet -json -c=N flags

Change-Id: I787592a5d92ff9329ecdfcf879e491af66c8b749
Reviewed-on: https://go-review.googlesource.com/c/149962
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/vendor: update to golang.org/x/tools@8e5aba0a
Alan Donovan [Fri, 16 Nov 2018 19:23:15 +0000 (14:23 -0500)]
cmd/vendor: update to golang.org/x/tools@8e5aba0a

- Adds 'go vet -json' and 'go vet -c=1' flags
- Removes the pkgfact analyzer, included by mistake.

Change-Id: Id3f1879af479efc567ea0508a1de7a37db5bee89
Reviewed-on: https://go-review.googlesource.com/c/149961
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go: accept @hash/branch in mod download
marwan-at-work [Fri, 16 Nov 2018 02:04:44 +0000 (02:04 +0000)]
cmd/go: accept @hash/branch in mod download

Go get in mod-enabled packages lets you do go get "pkg@<hash>" or "pkg@<branch>".
Go internally will switch the hash or branch into a pseudo version.
Go mod download should do the same. The bug lay in the fact that the disk cache
was not being written when Go converted the hash/branch into a pseudo version.

Fixes #27947

Change-Id: I94c29a5c95f69ab18a9cd7a2ecade128047c5e36
GitHub-Last-Rev: 668634b3e70206c6eadabae5969fca1b03093b0d
GitHub-Pull-Request: golang/go#28042
Reviewed-on: https://go-review.googlesource.com/c/140257
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go: vet: provide package ID to the vet tool
Alan Donovan [Fri, 16 Nov 2018 18:27:55 +0000 (13:27 -0500)]
cmd/go: vet: provide package ID to the vet tool

This field, which matches the IDs used by go list, will enable all vet
drivers to produce JSON output in a consistent format (a map from
package ID to analysis name to result).

Change-Id: Icac703b944de55df42c996dc2f672005014ad57a
Reviewed-on: https://go-review.googlesource.com/c/149960
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agobuild: clear GO111MODULE during make.bash etc
Russ Cox [Fri, 16 Nov 2018 17:47:33 +0000 (12:47 -0500)]
build: clear GO111MODULE during make.bash etc

The standard build assumes the variable is unset.
Make it so, like we do for GOFLAGS, GOBIN, and so on.

Change-Id: I4ad5695f8021b08bd1a35dd99112970a813d247c
Reviewed-on: https://go-review.googlesource.com/c/149959
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/vet: reenable cgo test
Alan Donovan [Fri, 16 Nov 2018 15:43:21 +0000 (10:43 -0500)]
cmd/vet: reenable cgo test

The reason the 386 trybot was happy but 'GOARCH=386 go test cmd/vet'
was not is that CgoEnabled defaults to false in a cross build;
I have no idea why. Now we ask the go command for the effective
value so that the test works in both cases.

Also, remove stale comment.

Fixes #28829

Change-Id: I1210af34da6986f47924059de5c1f08b2824ace9
Reviewed-on: https://go-review.googlesource.com/c/149958
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/go_spec: tweak wording to avoid 'explicit assignment' misreading
Russ Cox [Tue, 13 Nov 2018 15:23:01 +0000 (10:23 -0500)]
doc/go_spec: tweak wording to avoid 'explicit assignment' misreading

This text changed in CL 139099 to add "explicit" in front of "conversion".
But now "explicit conversion or assignment" reads like it might mean
"explicit [conversion or assignment]" when what is meant is
"[explicit conversion] or assignment". To make clear that explicit does
not apply to assignment, use "assignment or explicit conversion".

Change-Id: I8ff7a5b3ecd9f562793502fa6808242f22264f28
Reviewed-on: https://go-review.googlesource.com/c/149340
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agocmd/go: fix experiment isolation in cache key
Russ Cox [Tue, 13 Nov 2018 15:09:22 +0000 (10:09 -0500)]
cmd/go: fix experiment isolation in cache key

In general we don't assume that the go command knows the
specific version of the compiler being used, including which
experiments the compiler was built with. Let the compiler tell us,
instead of importing cmd/internal/objabi from cmd/go.

Replacement for CL 128735.

Change-Id: Iaa07f46e19764d0fb14a1c89979bea7bb7139b9c
Reviewed-on: https://go-review.googlesource.com/c/149338
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go: fix detection of unexpected files in downloaded zips
Russ Cox [Tue, 13 Nov 2018 14:28:33 +0000 (09:28 -0500)]
cmd/go: fix detection of unexpected files in downloaded zips

A bug in the old code was indirectly causing a confusing print,
but CL 131635 fixed the print instead of the surrounding code.
Fix the surrounding code, restore the old print, and test that the
error is actually reported (it was being ignored in a direct go get
but displaying in go build).

Change-Id: I03c21380fce481060c443b0cc820f3617497fdd9
Reviewed-on: https://go-review.googlesource.com/c/149317
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/compile: provide updating mechanism for format test
Robert Griesemer [Tue, 13 Nov 2018 23:33:57 +0000 (15:33 -0800)]
cmd/compile: provide updating mechanism for format test

The compiler's Format test verifies that the correct format
strings for the given arguments are used in the compiler
sources. The format strings are fairly specialized which is
why we cannot use go vet; and the mapping is based on a
hard-wired map.

In the past, if that map got out of sync with the compiler
sources, it was necessary to manually update the map. This
change introduces an update mechanism which simply requires
the test to be run with the -u flag.

(Formerly, the -u flag was used to automatically rewrite
format strings; now we use -r for that.)

Change-Id: I9259566a6120a13cf34b143875975ada62697890
Reviewed-on: https://go-review.googlesource.com/c/149460
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agodatabase/sql: add examples for opening and testing a DB pool
Daniel Theophanes [Fri, 16 Mar 2018 17:57:44 +0000 (10:57 -0700)]
database/sql: add examples for opening and testing a DB pool

Show two larger application examples. One example that
could be used in a CLI, the other in a long running
service. These demonstarates different strategies for
handling DB.Ping errors in context.

Fixes #23738

Change-Id: Id01213caf1f47917239a7506b01d30e37db74d31
Reviewed-on: https://go-review.googlesource.com/c/101216
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agotesting: add example to package doc
Leigh McCulloch [Fri, 16 Nov 2018 02:20:58 +0000 (02:20 +0000)]
testing: add example to package doc

The package doc for the testing package doesn't have a simple
example demonstrating how to write a test with an expectation. The doc
has simple examples for benchmarks, examples, and skipping, and it would be
useful for people new to writing tests in Go.

Also moved the skip example further down because it references tests and
benchmarks but benchmarks haven't been discussed in detail until the
next section. Skip is also a less used feature and it seems misplaced to
sit so high up in the package documentation. As an example, Skip is used
570 times the Go code repository which is significantly less than Error
and Fatal that are used 23,303 times.

Also changed 'sample' to 'simple' in other places in the package documentation
to keep the language used consistent when describing the small examples.

Fixes #27839

Change-Id: Ie01a3751986ee61adf2a2f2eda59cc182342baa7
GitHub-Last-Rev: 7357bfdcd29ed1dc1719c9436b5d5420020610ee
GitHub-Pull-Request: golang/go#27840
Reviewed-on: https://go-review.googlesource.com/c/137175
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
6 years agonet/http: fix typo in the SameSite docs
mbj36 [Fri, 16 Nov 2018 16:38:39 +0000 (16:38 +0000)]
net/http: fix typo in the SameSite docs

Fixes #28244

Change-Id: I3ca36fd513f5543af0c8af254d267254c7d5e803
GitHub-Last-Rev: 83b16fac4e221a249ed036c034367d6f680ae578
GitHub-Pull-Request: golang/go#28302
Reviewed-on: https://go-review.googlesource.com/c/143480
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/vet: fix two failing test cases
Alan Donovan [Fri, 16 Nov 2018 14:23:46 +0000 (09:23 -0500)]
cmd/vet: fix two failing test cases

Select linux/arm64 for the asm test.

Disable the cgo test for now.
Will fix properly in a follow-up.
Filed Issue 28829 to track it.

Updates #28829

Change-Id: Ic05f619700b06e91c43f8c150b089b8e77d92c85
Reviewed-on: https://go-review.googlesource.com/c/149937
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agoreflect: add comment for String method of Kind struct
Vladimir Kovpak [Fri, 16 Nov 2018 14:23:17 +0000 (14:23 +0000)]
reflect: add comment for String method of Kind struct

On reflect documentation page only this function
doesn't have description, this commit add simple description.

Change-Id: Idcda89ddd1f6fdd1938c4030e89ebdc186255ce6
GitHub-Last-Rev: 1553b834bb4f7a49efc7ff81763a255bc51bbf17
GitHub-Pull-Request: golang/go#28818
Reviewed-on: https://go-review.googlesource.com/c/149721
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agomisc/cgo/testsanitizers: gofmt
Tobias Klauser [Fri, 16 Nov 2018 10:26:16 +0000 (11:26 +0100)]
misc/cgo/testsanitizers: gofmt

Change-Id: I4e7328bb89f504dbca3948b8565d22c44d41db3d
Reviewed-on: https://go-review.googlesource.com/c/149917
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/cgo: fix comment grammar
Ian Lance Taylor [Fri, 22 Jun 2018 17:13:33 +0000 (10:13 -0700)]
cmd/cgo: fix comment grammar

Change-Id: I9c881943685177ce14841da53ccaed301c4955dd
Reviewed-on: https://go-review.googlesource.com/c/149859
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
6 years agocmd/go: correctly suggest tidy instead of nonexistent fix for -fix
yuuji.yaginuma [Thu, 15 Nov 2018 23:24:51 +0000 (23:24 +0000)]
cmd/go: correctly suggest tidy instead of nonexistent fix for -fix

CL 129682 removed go mod fix but unfortunately
we hadn't updated the source code hence running
   go mod -fix
would suggest
   go mod fix
which is a nonexistent command.

This change fixes that to instead suggest
   go mod tidy

Change-Id: Ie0d7c90805034e9fe6df24afaa15340c44d4f426
GitHub-Last-Rev: 5ae1340954c5f6b8535f837755a7bd79ebc7109d
GitHub-Pull-Request: golang/go#28402
Reviewed-on: https://go-review.googlesource.com/c/144838
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/vet: switch to x/tools/go/analysis implementation
Alan Donovan [Wed, 14 Nov 2018 21:29:30 +0000 (16:29 -0500)]
cmd/vet: switch to x/tools/go/analysis implementation

This change deletes the legacy implementation of vet, replacing it
with a short main.go that merely selects the desired analyzers and
calls into the "unitchecker" implementation vendored from
golang.org/x/tools/go/analysis.

Unlike the full vet checker (x/tools/go/analysis/cmd/vet), the 'lite'
unitchecker cannot also be run standalone (as 'go tool vet' or
cmd/vet); it must be invoked by 'go vet'.
This design was chosen to avoid vendoring many
additional dependencies into GOROOT, in particular go/packages. If
go/packages should someday become part of the standard library, there
will be considerable opportunity for simplification.

This change also patches the vendored analysisflag package
(by adding patch.go) so that it fully supports the build
system's -V flag protocol.

Also:
- remove stale internal/unitchecker/ tree
  (belonged in https://go-review.googlesource.com/c/149778).
- move vet legacy flags (-all, -v, -source, -tags) into analysisflags
  as all drivers will need them, not just unitchecker.
  I will upstream this change.

A sampling of tests from the cmd/vet testsuite have been preserved as
a smoke test, to ensure that each analyzer is being run, and for
convenience when evaluating changes. Comprehensive tests for each
analyzer live upstream in x/tools. The tests have been heavily reduced
and reorganized so that they conform to the structure required by 'go
vet'.

Change-Id: I84b38caeef733e65deb95234b3b87b5f61046def
Reviewed-on: https://go-review.googlesource.com/c/149609
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agoruntime: eliminate mheap.busy* lists
Austin Clements [Thu, 27 Sep 2018 15:50:46 +0000 (11:50 -0400)]
runtime: eliminate mheap.busy* lists

The old whole-page reclaimer was the only thing that used the busy
span lists. Remove them so nothing uses them any more.

Change-Id: I4007dd2be08b9ef41bfdb0c387215c73c392cc4c
Reviewed-on: https://go-review.googlesource.com/c/138960
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
6 years agoruntime: implement efficient page reclaimer
Austin Clements [Thu, 27 Sep 2018 15:34:07 +0000 (11:34 -0400)]
runtime: implement efficient page reclaimer

When we attempt to allocate an N page span (either for a large
allocation or when an mcentral runs dry), we first try to sweep spans
to release N pages. Currently, this can be extremely expensive:
sweeping a span to emptiness is the hardest thing to ask for and the
sweeper generally doesn't know where to even look for potentially
fruitful results. Since this is on the critical path of many
allocations, this is unfortunate.

This CL changes how we reclaim empty spans. Instead of trying lots of
spans and hoping for the best, it uses the newly introduced span marks
to efficiently find empty spans. The span marks (and in-use bits) are
in a dense bitmap, so these spans can be found with an efficient
sequential memory scan. This approach can scan for unmarked spans at
about 300 GB/ms and can free unmarked spans at about 32 MB/ms. We
could probably significantly improve the rate at which is can free
unmarked spans, but that's a separate issue.

Like the current reclaimer, this is still linear in the number of
spans that are swept, but the constant factor is now so vanishingly
small that it doesn't matter.

The benchmark in #18155 demonstrates both significant page reclaiming
delays, and object reclaiming delays. With "-retain-count=20000000
-preallocate=true -loop-count=3", the benchmark demonstrates several
page reclaiming delays on the order of 40ms. After this change, the
page reclaims are insignificant. The longest sweeps are still ~150ms,
but are object reclaiming delays. We'll address those in the next
several CLs.

Updates #18155.

Fixes #21378 by completely replacing the logic that had that bug.

Change-Id: Iad80eec11d7fc262d02c8f0761ac6998425c4064
Reviewed-on: https://go-review.googlesource.com/c/138959
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
6 years agoruntime: mark span when marking any object on the span
Austin Clements [Wed, 26 Sep 2018 19:59:21 +0000 (15:59 -0400)]
runtime: mark span when marking any object on the span

This adds a mark bit for each span that is set if any objects on the
span are marked. This will be used for sweeping.

For #18155.

The impact of this is negligible for most benchmarks, and < 1% for
GC-heavy benchmarks.

name                       old time/op  new time/op  delta
Garbage/benchmem-MB=64-12  2.18ms ± 0%  2.20ms ± 1%  +0.88%  (p=0.000 n=16+18)

(https://perf.golang.org/search?q=upload:20180928.1)

name                      old time/op    new time/op    delta
BinaryTree17-12              2.68s ± 1%     2.68s ± 1%    ~     (p=0.707 n=17+19)
Fannkuch11-12                2.28s ± 0%     2.39s ± 0%  +4.95%  (p=0.000 n=19+18)
FmtFprintfEmpty-12          40.3ns ± 4%    39.4ns ± 2%  -2.27%  (p=0.000 n=17+18)
FmtFprintfString-12         67.9ns ± 1%    68.3ns ± 1%  +0.55%  (p=0.000 n=18+19)
FmtFprintfInt-12            75.7ns ± 1%    76.1ns ± 1%  +0.44%  (p=0.005 n=18+19)
FmtFprintfIntInt-12          123ns ± 1%     121ns ± 1%  -1.00%  (p=0.000 n=18+18)
FmtFprintfPrefixedInt-12     150ns ± 0%     148ns ± 0%  -1.33%  (p=0.000 n=16+13)
FmtFprintfFloat-12           208ns ± 0%     204ns ± 0%  -1.92%  (p=0.000 n=13+17)
FmtManyArgs-12               501ns ± 1%     498ns ± 0%  -0.55%  (p=0.000 n=19+17)
GobDecode-12                6.24ms ± 0%    6.25ms ± 1%    ~     (p=0.113 n=20+19)
GobEncode-12                5.33ms ± 0%    5.29ms ± 1%  -0.72%  (p=0.000 n=20+18)
Gzip-12                      220ms ± 1%     218ms ± 1%  -1.02%  (p=0.000 n=19+19)
Gunzip-12                   35.5ms ± 0%    35.7ms ± 0%  +0.45%  (p=0.000 n=16+18)
HTTPClientServer-12         77.9µs ± 1%    77.7µs ± 1%  -0.30%  (p=0.047 n=20+19)
JSONEncode-12               8.82ms ± 0%    8.93ms ± 0%  +1.20%  (p=0.000 n=18+17)
JSONDecode-12               47.3ms ± 0%    47.0ms ± 0%  -0.49%  (p=0.000 n=17+18)
Mandelbrot200-12            3.69ms ± 0%    3.68ms ± 0%  -0.25%  (p=0.000 n=19+18)
GoParse-12                  3.13ms ± 1%    3.13ms ± 1%    ~     (p=0.640 n=20+20)
RegexpMatchEasy0_32-12      76.2ns ± 1%    76.2ns ± 1%    ~     (p=0.818 n=20+19)
RegexpMatchEasy0_1K-12       226ns ± 0%     226ns ± 0%  -0.22%  (p=0.001 n=17+18)
RegexpMatchEasy1_32-12      71.9ns ± 1%    72.0ns ± 1%    ~     (p=0.653 n=18+18)
RegexpMatchEasy1_1K-12       355ns ± 1%     356ns ± 1%    ~     (p=0.160 n=18+19)
RegexpMatchMedium_32-12      106ns ± 1%     106ns ± 1%    ~     (p=0.325 n=17+20)
RegexpMatchMedium_1K-12     31.1µs ± 2%    31.2µs ± 0%  +0.59%  (p=0.007 n=19+15)
RegexpMatchHard_32-12       1.54µs ± 2%    1.53µs ± 2%  -0.78%  (p=0.021 n=17+18)
RegexpMatchHard_1K-12       46.0µs ± 1%    45.9µs ± 1%  -0.31%  (p=0.025 n=17+19)
Revcomp-12                   391ms ± 1%     394ms ± 2%  +0.80%  (p=0.000 n=17+19)
Template-12                 59.9ms ± 1%    59.9ms ± 1%    ~     (p=0.428 n=20+19)
TimeParse-12                 304ns ± 1%     312ns ± 0%  +2.88%  (p=0.000 n=20+17)
TimeFormat-12                318ns ± 0%     326ns ± 0%  +2.64%  (p=0.000 n=20+17)

(https://perf.golang.org/search?q=upload:20180928.2)

Change-Id: I336b9bf054113580a24103192904c8c76593e90e
Reviewed-on: https://go-review.googlesource.com/c/138958
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
6 years agoruntime: record in-use spans in a page-indexed bitmap
Austin Clements [Wed, 26 Sep 2018 20:32:52 +0000 (16:32 -0400)]
runtime: record in-use spans in a page-indexed bitmap

This adds a bitmap indexed by page number that marks the starts of
in-use spans. This will be used to quickly find in-use spans with no
marked objects for sweeping.

For #18155.

Change-Id: Icee56f029cde502447193e136fa54a74c74326dd
Reviewed-on: https://go-review.googlesource.com/c/138957
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
6 years agoruntime: track all heap arenas in a slice
Austin Clements [Wed, 26 Sep 2018 18:20:58 +0000 (14:20 -0400)]
runtime: track all heap arenas in a slice

Currently, there's no efficient way to iterate over the Go heap. We're
going to need this for fast free page sweeping, so this CL adds a
slice of all allocated heap arenas. This will also be useful for
generational GC.

For #18155.

Change-Id: I58d126cfb9c3f61b3125d80b74ccb1b2169efbcc
Reviewed-on: https://go-review.googlesource.com/c/138076
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rick Hudson <rlh@golang.org>
6 years agocmd/vet/all: use x/tools/go/analysis/cmd/vet not cmd/vet
Alan Donovan [Mon, 12 Nov 2018 20:48:46 +0000 (15:48 -0500)]
cmd/vet/all: use x/tools/go/analysis/cmd/vet not cmd/vet

cmd/vet/all applies vet to all packages in the standard tree.
It is run for every configuration using this command:
  GO_BUILDER_NAME=misc-vetall go tool dist test
by the misc-vetall builder (see chart at build.golang.org).

Ideally we would switch to 'go vet', but it effectively does a partial
build. This means that its analysis has accurate type information, so
it reports slightly fewer spurious diagnostics. However, it is more
than twice as slow.

Instead, cmd/vet/all builds and runs
golang.org/x/tools/go/analysis/cmd/vet, which uses x/tools/go/packages
to load the entire std lib from source. It takes about 4min to run all
OS/ARCH pairs. An important consequence is that golang.org/x/tools
must be on your $GOPATH to run cmd/vet/all. The test has been
temporarily modified to warn and skip if this is not the case.

This is a preparatory step for switching to the new
cmd/vet based on vet-lite.

Whitelist changes:
- The two "deadcode" diagnostics removed from the whitelist were due
  to if-conditions that could now be proven false.
- The asmdecl warnings are now printed with the log.Printf prefix,
  so they are discarded by the parser and needn't be whitelisted.

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

6 years agocmd/vendor: update to golang.org/x/tools@f62bfb54
Alan Donovan [Thu, 15 Nov 2018 17:15:18 +0000 (12:15 -0500)]
cmd/vendor: update to golang.org/x/tools@f62bfb54

Change-Id: I3b3035784ce89ba2ac5ab8f6448c45a3d38fa97d
Reviewed-on: https://go-review.googlesource.com/c/149778
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agox/net/route: use libc calls on Darwin
Keith Randall [Thu, 8 Nov 2018 05:25:42 +0000 (21:25 -0800)]
x/net/route: use libc calls on Darwin

Starting with 1.12, we must use syscall versions
of sysctl instead of the raw syscall.

An identical CL went into the source copy at golang.org/x/net/route.
This is just a cherry pick of that CL.
(CL: https://go-review.googlesource.com/c/net/+/148597)

Change-Id: I6286ab3e49f82512491afb5bcf349e89ab5645ab
Reviewed-on: https://go-review.googlesource.com/c/149637
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/link: fix isStmt DWARF info
Austin Clements [Wed, 14 Nov 2018 20:45:27 +0000 (15:45 -0500)]
cmd/link: fix isStmt DWARF info

When CL 147160 introduced function ABIs encoded as symbol versions in
the linker, it became slightly more complicated to look up derived
DWARF symbols. It fixed this by introducing a dwarfFuncSym function to
hide this logic, but missed one derived lookup that was done in the
object reader itself. As a result, we lost the isStmt tables from the
compiler, so every PC was marked as a statement in the DWARF info.

Fix this by moving this derived lookup out of the object reader and
into the DWARF code and calling dwarfFuncSym to get the correctly
versioned symbol.

Should fix the linux-amd64-longtest builder.

Updates #27539.

Change-Id: If40d5ba28bab1918ac4ad18fbb5103666b6d978b
Reviewed-on: https://go-review.googlesource.com/c/149605
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
6 years agointernal/cpu: move GODEBUGCPU options into GODEBUG
Martin Möhrmann [Wed, 14 Nov 2018 19:48:40 +0000 (20:48 +0100)]
internal/cpu: move GODEBUGCPU options into GODEBUG

Change internal/cpu feature configuration to use
GODEBUG=cpu.feature1=value,cpu.feature2=value...
instead of GODEBUGCPU=feature1=value,feature2=value... .

This is not a backwards compatibility breaking change
since GODEBUGCPU was introduced in go1.11 as an
undocumented compiler experiment.

Fixes #28757

Change-Id: Ib21b3fed2334baeeb061a722ab1eb513d1137e87
Reviewed-on: https://go-review.googlesource.com/c/149578
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/vendor/golang.org/x/tools: update to 7d6b83ca
Alan Donovan [Wed, 14 Nov 2018 19:58:27 +0000 (14:58 -0500)]
cmd/vendor/golang.org/x/tools: update to 7d6b83ca

Also, add a script for future updates.

Change-Id: I2565d1f26532b9dd7cf9d8ce198ba08fb3d53407
Reviewed-on: https://go-review.googlesource.com/c/149604
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
6 years agonet/http: make Transport respect {X-,}Idempotency-Key header
Brad Fitzpatrick [Mon, 5 Nov 2018 16:26:45 +0000 (16:26 +0000)]
net/http: make Transport respect {X-,}Idempotency-Key header

Fixes #19943

Change-Id: I5e0fefe44791d7b3556095d726c2a753ec551ef2
Reviewed-on: https://go-review.googlesource.com/c/147457
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
6 years agocmd/compile: assume unsafe pointer arithmetic generates non-nil results
Keith Randall [Tue, 30 Oct 2018 20:30:09 +0000 (13:30 -0700)]
cmd/compile: assume unsafe pointer arithmetic generates non-nil results

I've never seen a case where unsafe arithmetic is used to generate a nil.
(Something like var x uintptr; unsafe.Pointer(x - x).)
We can assume that if someone is doing arithmetic with pointers, the
result will be non-nil. Our unsafe rules already forbid this, although
we should be more explicit.

RELNOTE=It is invalid to convert a nil unsafe.Pointer to uintptr and back, with arithmetic.
(This was already invalid, but this statement has been added for clarification.)

Fixes #27180

Change-Id: I1880b7725a9fd99e4613799930fdad9aaa99e8f0
Reviewed-on: https://go-review.googlesource.com/c/146058
Reviewed-by: Austin Clements <austin@google.com>
6 years agocmd/go: allow the user to specify ar via an environment variable
Ali Rizvi-Santiago [Wed, 14 Nov 2018 20:16:14 +0000 (20:16 +0000)]
cmd/go: allow the user to specify ar via an environment variable

This allows one to customize which ar to use by fetching its path
from the environment. This way one can swap it out for a
different implementation.

Change-Id: I40d8cbd8a69e97b5254e66081d9bf0b726c10366
GitHub-Last-Rev: 4aa1d631eaca58be6c3a4be40f7404fa75a0db25
GitHub-Pull-Request: golang/go#28746
Reviewed-on: https://go-review.googlesource.com/c/149117
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agofmt: avoid allocation when formatting byte slice arguments with verb s
Martin Möhrmann [Sun, 28 Oct 2018 16:28:04 +0000 (17:28 +0100)]
fmt: avoid allocation when formatting byte slice arguments with verb s

fmtBytes is in the top 10 callers of runtime.slicebytetostring according
to Google wide profiling data.

Avoid the string conversion of the input byte slice in fmtBytes by calling
a newly added specialized fmtS function for byte slices.

Expand tests for verb s with widths to test strings and byte slice arguments.

SprintfTruncateString     157ns ± 4%     156ns ± 3%     ~     (p=0.122 n=20+20)
SprintfTruncateBytes      188ns ± 2%     155ns ± 3%  -18.00%  (p=0.000 n=20+19)

name                   old alloc/op   new alloc/op   delta
SprintfTruncateString     16.0B ± 0%     16.0B ± 0%     ~     (all equal)
SprintfTruncateBytes      64.0B ± 0%     16.0B ± 0%  -75.00%  (p=0.000 n=20+20)

name                   old allocs/op  new allocs/op  delta
SprintfTruncateString      1.00 ± 0%      1.00 ± 0%     ~     (all equal)
SprintfTruncateBytes       2.00 ± 0%      1.00 ± 0%  -50.00%  (p=0.000 n=20+20)

Change-Id: I461bf514d4232b39bd9c812f7faa4e5ef693a03b
Reviewed-on: https://go-review.googlesource.com/c/145284
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
6 years agoruntime: make processor capability variable naming platform specific
Martin Möhrmann [Tue, 6 Nov 2018 16:00:04 +0000 (17:00 +0100)]
runtime: make processor capability variable naming platform specific

The current support_XXX variables are specific for the
amd64 and 386 platforms.

Prefix processor capability variables by architecture to have a
consistent naming scheme and avoid reuse of the existing
variables for new platforms.

This also aligns naming of runtime variables closer with internal/cpu
processor capability variable names.

Change-Id: I3eabb29a03874678851376185d3a62e73c1aff1d
Reviewed-on: https://go-review.googlesource.com/c/91435
Run-TryBot: Martin Möhrmann <martisch@uos.de>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/go: don't panic when go run is passed ... under nonexistent dir
Mark Rushakoff [Wed, 14 Nov 2018 19:34:48 +0000 (19:34 +0000)]
cmd/go: don't panic when go run is passed ... under nonexistent dir

Given a nonexistent directory above a wildcard:

    go run ./nonexistent/...

Print this error instead of panicking:

    go run: no packages loaded from ./nonexistent/...

Fixes #28696.

Change-Id: Iaa3bc5c78b14ef858d931778e1bc55ca626c5571
GitHub-Last-Rev: bb1a80483ad26c8cf646cf0900d08cfe49aba535
GitHub-Pull-Request: golang/go#28703
Reviewed-on: https://go-review.googlesource.com/c/148821
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
6 years agocmd/compile/internal/gc: OMUL should be evaluated when using soft-float
Milan Knezevic [Fri, 9 Nov 2018 17:30:46 +0000 (18:30 +0100)]
cmd/compile/internal/gc: OMUL should be evaluated when using soft-float

When using soft-float, OMUL might be rewritten to function call
so we should ensure it was evaluated first.

Fixes #28688

Change-Id: I30b87501782fff62d35151f394a1c22b0d490c6c
Reviewed-on: https://go-review.googlesource.com/c/148837
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/go: fix TestScript/vet_asm for OS without amd64
Clément Chigot [Wed, 14 Nov 2018 14:25:59 +0000 (15:25 +0100)]
cmd/go: fix TestScript/vet_asm for OS without amd64

Add GOOS=linux to vet_asm script to avoid errors on OS not working on
amd64 architecture.

Change-Id: Ic3db43618008ae8e8bc08738c95c200dd4e916d7
Reviewed-on: https://go-review.googlesource.com/c/149577
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agotest: move empty header file in builddir, buildrundir to temp directory
Emmanuel T Odeke [Tue, 13 Nov 2018 23:13:42 +0000 (16:13 -0700)]
test: move empty header file in builddir, buildrundir to temp directory

Move the empty header file created by "builddir", "buildrundir"
directives to t.tempDir. The file was accidentally placed in the
same directory as the source code and this was a vestige of CL 146999.

Fixes #28781

Change-Id: I3d2ada5f9e8bf4ce4f015b9bd379b311592fe3ce
Reviewed-on: https://go-review.googlesource.com/c/149458
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/compile: by default accept any language
Ian Lance Taylor [Tue, 13 Nov 2018 23:36:02 +0000 (15:36 -0800)]
cmd/compile: by default accept any language

The bootstrap stage 1 compiler was defaulting to the language version
used by the bootstrap compiler itself, typically 1.4. Normally this
doesn't matter since the bootstrap code has to build with 1.4 anyhow,
but it broke the boringcrypto branch which uses cgo during the
bootstrap, as cgo now generates code that uses type aliases.

Change-Id: I8a8312bb9ca4befaf65c00a8d71a78566075c2f7
Reviewed-on: https://go-review.googlesource.com/c/149459
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
6 years agotest: fix ABI mismatch in fixedbugs/issue19507
Austin Clements [Tue, 13 Nov 2018 23:32:55 +0000 (18:32 -0500)]
test: fix ABI mismatch in fixedbugs/issue19507

Because run.go doesn't pass the package being compiled to the compiler
via the -p flag, it can't match up the main·f symbol from the
assembler with the "func f" stub in Go, so it doesn't produce the
correct assembly stub.

Fix this by removing the package prefix from the assembly definition.

Alternatively, we could make run.go pass -p to the compiler, but it's
nicer to remove these package prefixes anyway.

Should fix the linux-arm builder, which was broken by the introduction
of function ABIs in CL 147160.

Updates #27539.

Change-Id: Id62b7701e1108a21a5ad48ffdb5dad4356c273a6
Reviewed-on: https://go-review.googlesource.com/c/149483
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agoruntime: when using explicit argmap, also use arglen
Keith Randall [Mon, 12 Nov 2018 23:49:09 +0000 (15:49 -0800)]
runtime: when using explicit argmap, also use arglen

When we set an explicit argmap, we may want only a prefix of that
argmap.  Argmap is set when the function is reflect.makeFuncStub or
reflect.methodValueCall. In this case, arglen specifies how much of
the args section is actually live. (It could be either all the args +
results, or just the args.)

Fixes #28750

Change-Id: Idf060607f15a298ac591016994e58e22f7f92d83
Reviewed-on: https://go-review.googlesource.com/c/149217
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>