Wil Selwood [Mon, 26 Nov 2018 15:11:45 +0000 (15:11 +0000)]
unicode: improve generated comments for categories
The comments on the category range tables in the unicode package are fairly
redundent and require an external source to translate into human readable
category names.
This adds a look up table with the category descriptions and uses it if
available when generating the comments for the range tables.
Clément Chigot [Fri, 23 Nov 2018 13:20:19 +0000 (14:20 +0100)]
cmd: fix symbols addressing for aix/ppc64
This commit changes the code generated for addressing symbols on AIX
operating system.
On AIX, every symbol accesses must be done via another symbol near the TOC,
named TOC anchor or TOC entry. This TOC anchor is a pointer to the symbol
address.
During Progedit function, when a symbol access is detected, its instructions
are modified to create a load on its TOC anchor and retrieve the symbol.
Change-Id: I00cf8f49c13004bc99fa8af13d549a709320f797
Reviewed-on: https://go-review.googlesource.com/c/151039
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
This commit fixes and improves the generation of dynamic symbols for
XCOFF files.
This mainly adds for every dynamic symbols a new symbol named
s.Extname().
Change-Id: I5b788f076d9a05e5d42f08eb1a74fd3e3efa9a86
Reviewed-on: https://go-review.googlesource.com/c/151038
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
David Tolpin [Tue, 27 Nov 2018 00:17:32 +0000 (00:17 +0000)]
go/printer: print parenthesized declarations if len(d.Specs) > 1
Parenthesized declaration must be printed if len(d.Specs) > 1 even if d.Lparen==token.NoPos. This happens if the node tree is created programmatically. Otherwise, all but the first specifications just silently disappear from the output.
Change-Id: I17ab24bb1cd56fe1e611199698535ca60a97f5ea
GitHub-Last-Rev: 2f168dc7ad4a29149685efc70f180987523271e4
GitHub-Pull-Request: golang/go#28533
Reviewed-on: https://go-review.googlesource.com/c/146657
Run-TryBot: Robert Griesemer <gri@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Keith Randall [Mon, 29 Oct 2018 22:14:39 +0000 (15:14 -0700)]
cmd/compile: don't use CMOV ops to compute load addresses
We want to issue loads as soon as possible, especially when they
are going to miss in the cache. Using a conditional move (CMOV) here:
i := ...
if cond {
i++
}
... = a[i]
means that we have to wait for cond to be computed before the load
is issued. Without a CMOV, if the branch is predicted correctly the
load can be issued in parallel with computing cond.
Even if the branch is predicted incorrectly, maybe the speculative
load is close to the real load, and we get a prefetch for free.
In the worst case, when the prediction is wrong and the address is
way off, we only lose by the time difference between the CMOV
latency (~2 cycles) and the mispredict restart latency (~15 cycles).
We only squash CMOVs that affect load addresses. Results of CMOVs
that are used for other things (store addresses, store values) we
use as before.
Clément Chigot [Mon, 26 Nov 2018 15:11:18 +0000 (16:11 +0100)]
test: fix nilptr5 for AIX
This commit fixes a mistake made in CL 144538.
This nilcheck can be removed because OpPPC64LoweredMove will fault if
arg0 is nil, as it's used to store. Further information can be found in
cmd/compile/internal/ssa/nilcheck.go.
Change-Id: Ifec0080c00eb1f94a8c02f8bf60b93308e71b119
Reviewed-on: https://go-review.googlesource.com/c/151298
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Elias Naur [Tue, 27 Nov 2018 15:07:14 +0000 (16:07 +0100)]
cmd/link/internal/ld: omit deprecated linker argument for iOS builds
After CL 151139 introduced a plugin test, the macOS linker for iOS
outputs:
ld: warning: -flat_namespace is deprecated on iOS
Omit the -flat_namespace flag on iOS; plugins are not supported on
iOS, and unlikely to ever be.
Change-Id: I2d08f8b984efcfd442d572b4a0f3a2c95c551b9f
Reviewed-on: https://go-review.googlesource.com/c/151300
Run-TryBot: Elias Naur <elias.naur@gmail.com> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Bryan C. Mills [Wed, 10 Oct 2018 14:03:27 +0000 (10:03 -0400)]
cmd/go/internal/imports: resolve symlinks in ScanDir
We were using the mode reported by ReadDir to decide whether each
entry is a file, but in the case of symlinks that isn't sufficient: a
symlink could point to either a file or a directory, and if it is a
file we should treat it as such.
Brian Kessler [Wed, 14 Nov 2018 05:51:21 +0000 (22:51 -0700)]
math/bits: define Div to panic when y<=hi
Div panics when y<=hi because either the quotient overflows
the size of the output or division by zero occurs when y==0.
This provides a uniform behavior for all implementations.
Fixes #28316
Change-Id: If23aeb10e0709ee1a60b7d614afc9103d674a980
Reviewed-on: https://go-review.googlesource.com/c/149517 Reviewed-by: Robert Griesemer <gri@golang.org>
Brian Kessler [Wed, 24 Oct 2018 02:54:56 +0000 (20:54 -0600)]
cmd/compile: intrinsify math/bits.Div on amd64
Note that the intrinsic implementation panics separately for overflow and
divide by zero, which matches the behavior of the pure go implementation.
There is a modest performance improvement after intrinsic implementation.
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.
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>
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>
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>
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>
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.
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>
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>
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.
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.
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.
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.
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.
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.
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>
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>
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>
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).
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.
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.
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.
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.
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>
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.
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.
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>
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>
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>
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>
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>
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.
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.
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).
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.
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.
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>
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.
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.
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).
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.
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>
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>
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>
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.)
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.
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.
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
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'.
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.
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>
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.
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.
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)