Brian Kessler [Wed, 6 Dec 2017 16:53:14 +0000 (09:53 -0700)]
math/big: implement Atkin's ModSqrt for 5 mod 8 primes
For primes congruent to 5 mod 8 there is a simple deterministic
method for calculating the modular square root due to Atkin,
using one exponentiation and 4 multiplications.
A. Atkin. Probabilistic primality testing, summary by F. Morain.
Research Report 1779, INRIA, pages 159–163, 1992.
This increases the speed of modular square roots for these primes
considerably.
name old time/op new time/op delta
ModSqrt231_5Mod8-4 1.03ms ± 2% 0.36ms ± 5% -65.06% (p=0.008 n=5+5)
Change-Id: I024f6e514bbca8d634218983117db2afffe615fe
Reviewed-on: https://go-review.googlesource.com/99615 Reviewed-by: Robert Griesemer <gri@golang.org>
In https://go-review.googlesource.com/c/go/+/114317 (fix for #25301)
the constructor types.NewInterface was replaced with NewInterface2.
The new constructor aggressively verified that embedded interfaces
had an underlying type of interface type; the old code didn't do
any verification. During importing, defined types may be not yet
fully set up, and testing their underlying types will fail in those
cases.
This change only verifies embedded types that are not defined types
and thus restores behavior for defined types to how it was before
the fix for #25301.
Fixes #25596.
Fixes #25615.
Change-Id: Ifd694413656ec0b780fe4f37acaa9e6ba6077271
Reviewed-on: https://go-review.googlesource.com/115155
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Alan Donovan <adonovan@google.com>
Change-Id: I829399194299d2e6d5e754b60e8f72b321b5da90
Reviewed-on: https://go-review.googlesource.com/115040 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Brad Fitzpatrick [Tue, 29 May 2018 22:08:32 +0000 (22:08 +0000)]
net/http/httputil: pass through any "TE: trailers" header to backend
Fixes #21096
Change-Id: I2a4688a79bdaa25b4e8ef38e3390d93d3d0bce04
Reviewed-on: https://go-review.googlesource.com/115135 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Robert Griesemer [Tue, 29 May 2018 20:13:24 +0000 (13:13 -0700)]
go/types: add struct field with invalid type if field has errors
This ensures that all struct fields are present and thus the struct
has the original number of fields even if some fields have type
errors. (This only applies as long as the field names themselves
don't conflict.)
Fixes #25627.
Change-Id: I2414b1f432ce139b3cd2776ff0d46d8dcf38b650
Reviewed-on: https://go-review.googlesource.com/115115 Reviewed-by: Alan Donovan <adonovan@google.com>
Brad Fitzpatrick [Tue, 29 May 2018 19:45:34 +0000 (19:45 +0000)]
net/http: document how Hijack and Request.Context interact
Fixes #22347
Change-Id: If86aa5d54cfd7a7c32d630fb2bf4f47e057dbfb2
Reviewed-on: https://go-review.googlesource.com/115039 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Sat, 26 May 2018 18:29:55 +0000 (11:29 -0700)]
runtime: wrap darwin libc calls to keep profiler happy
The profiler reports "ExternalCode" when a profiler interrupt happens
while in libc code. Instead, keep track of the most recent Go frame
for the profiler to use.
There is a test for this using time.Now (runtime.TestTimePprof),
which will work once time.Now is moved to using libc (my next CL).
Change-Id: I940ea83edada482a482e2ab103d3a65589979464
Reviewed-on: https://go-review.googlesource.com/114798
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Daniel Martí [Fri, 4 May 2018 04:22:53 +0000 (11:22 +0700)]
cmd/vet: avoid false positives with non-comments
vet's buildtag check looks for malformed build tag comments. Since these
can appear in Go files as well as non-Go files (such as assembly files),
it must read the file line by line instead of using go/token or go/ast
directly.
However, this method runs into false positives if there are any lines in
the code that look like comments, but are not. For example:
$ cat f.go
package main
const foo = `
//+build ignore
`
$ go vet f.go
./f.go:3: +build comment must appear before package clause and be followed by a blank line
This bug has been popping up more frequently since vet started being run
with go test, so it is important to make the check as precise as
possible.
To avoid the false positive, when checking a Go file, cross-check that a
line that looks like a comment actually corresponds to a comment in the
go/ast syntax tree. Since vet already obtains the syntax trees for all
the Go files, it checks, this change means very little extra work for
the check.
While at it, add a badf helper function to simplify the code that
reports warnings in the buildtag check.
Fixes #13533.
Change-Id: I484a16da01363b409ec418c313634171bf85250b
Reviewed-on: https://go-review.googlesource.com/111415
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Keith Randall [Tue, 29 May 2018 16:30:12 +0000 (09:30 -0700)]
cmd/compile: reject large argument areas
Extend stack frame limit of 1GB to include large argument/return areas.
Argument/return areas are part of the parent frame, not the frame itself,
so they need to be handled separately.
Ian Lance Taylor [Tue, 29 May 2018 13:40:56 +0000 (06:40 -0700)]
cmd/cgo: use standard generated code comment
Change cgo to follow https://golang.org/s/generatedcode.
For the C code we continue to use /* */ comments, so they don't follow
the format exactly. It doesn't really matter since the format is only
for Go code anyhow. This CL changes the C code to be similar for
consistency.
Change-Id: I04880d87e317a1140ec12da6ec5e788991719760
Reviewed-on: https://go-review.googlesource.com/114936 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Yury Smolsky [Tue, 22 May 2018 19:37:40 +0000 (22:37 +0300)]
cmd/vet: eliminate use of Perl in tests
This change uses errorCheck and wantedErrors functions copied from
the test/run.go to eliminate use of the test/errchk perl script.
Tests' error messages that contained full filenames were changed to
have base filenames because the errorCheck function processes output
from "go vet" in the same way.
David Symonds [Mon, 28 May 2018 03:03:08 +0000 (13:03 +1000)]
cmd/cover: fix sorting of profile segment boundaries
If a span of coverable code is empty (e.g. an empty select clause)
then there will be two Boundary values with the same offset. In that
case, the starting Boundary needs to come first so that the generated
HTML output will open the <span> tag before it tries to close it.
Change-Id: Ib44a8b7c36ae57757c18b6cceb7a88ffa4e95394
Reviewed-on: https://go-review.googlesource.com/114855 Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Ian Lance Taylor [Fri, 25 May 2018 21:27:29 +0000 (14:27 -0700)]
cmd/go: don't generate output for "go build -o /dev/null x.go"
We look for "-o /dev/null", and, if found, pretend that there was no
"-o" option and don't generate an action to create the final executable.
We look for "go build x.go", and, if found, and if -o was not used,
pretend that the user specified "-o x".
Unfortunately, we were doing those in the wrong order, so that "go
build -o /dev/null x.go" would first clear the "-o" option and then
set it to "-o x".
This CL flips the order so that the right thing happens.
Fixes #25579
Change-Id: Ic9556ac0a57f7b45b685951bc96ba5ea4633b860
Reviewed-on: https://go-review.googlesource.com/114715
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Yuval Pavel Zholkover [Sat, 26 May 2018 16:25:31 +0000 (19:25 +0300)]
runtime: use the correct AT_HWCAP auxv constant on freebsd
In golang.org/cl/102355 I mistakenly used 26 instead of 25 as the AT_HWCAP value.
26 is AT_HWCAP2. While experimenting with FreeBSD-11.2-BETA3 (where both values are
being supplied in the auxv), the AT_HWCAP2 value read is 0 which triggers the error again:
runtime: this CPU has no floating point hardware, so it cannot run this GOARM=7 binary. Recompile using GOARM=5.
Yury Smolsky [Sat, 26 May 2018 09:57:50 +0000 (12:57 +0300)]
test: eliminate use of Perl in test/fixedbugs/bug248.go
This change enables bug248 to be tested with Go code.
For that, it adds a flag -1 to error check and run directory
with one package failing compilation prior the last package
which should be run.
Specifically, the "p" package in bug1.go file was renamed into "q"
to compile them in separate steps,
bug2.go and bug3.go files were reordered,
bug2.go was changed into non-main package.
Alex Brainman [Tue, 24 Apr 2018 23:15:25 +0000 (09:15 +1000)]
cmd/go/internal/load: use lowercase package directory comparisons on Windows
go build
command is short for
go build .
and it builds . package. When command above is executed from
directory inside of GOPATH, it uses GOPATH to calculate package
source directory. So . package uses GOPATH as part of package
source directory.
On the other hand
go build -ldflags=abc
only passes flag to the linker for packages that are listed
on the command line. The command above assumes . package again,
and that package source path is compared with current directory.
Current code compares result of os.Getwd with what GOPATH
environment variable contains. But these values might differ
in letter case on Windows. For example, one might return
c:\gopath\..., while the other might contain C:\GOPATH.
Than McIntosh [Wed, 23 May 2018 19:31:52 +0000 (15:31 -0400)]
cmd/compile: fix DWARF inline debug issue with dead local vars
Fix a problem in DWARF inline debug generation relating to handling of
statically unreachable local variables. For a function such as:
const always = true
func HasDeadLocal() int {
if always {
return 9
}
x := new(Something)
...
return x.y
}
the variable "x" is placed onto the Dcl list for the function during
parsing, but the actual declaration node is deleted later on when
gc.Main invokes "deadcode". Later in the compile the DWARF code emits
an abstract function with "x" (since "x" was on the Dcl list at the
point of the inline), but the export data emitted does not contain
"x". This then creates clashing/inconsistant DWARF abstract function
DIEs later on if HasDeadLocal is inlined in somewhere else.
As a fix, the inliner now pruned away variables such as "x" when
creating a copy of the Dcl list as part of the inlining; this means
that both the export data generator and the DWARF emitter wind up
seeing a consistent picture.
Tobias Klauser [Fri, 25 May 2018 06:30:26 +0000 (08:30 +0200)]
cmd/vendor/golang.org/x: pick up fixes for broken android and linux tests
While fixing some failing tests, CL 114416 also picked up the newly
added TestXattr from golang.org/x/sys/unix which fails on android. Pick
up CL 114535 to fix it as well.
Also pick up CL 114616 to fix TestStatx occasionally failing on linux.
Ian Lance Taylor [Fri, 18 May 2018 13:18:34 +0000 (09:18 -0400)]
cmd/go, cmd/vet, go/internal/gccgoimport: make vet work with gccgo
When using gccgo/GoLLVM, there is no package file for a standard
library package. Since it is impossible for the go tool to rebuild the
package, and since the package file exists only in the form of a .gox
file, this seems like the best choice. Unfortunately it was confusing
vet, which wanted to see a real file. This caused vet to report errors
about missing package files for standard library packages. The
gccgoimporter knows how to correctly handle this case. Fix this by
1) telling vet which packages are standard;
2) letting vet skip those packages;
3) letting the gccgoimporter handle this case.
As a separate required fix, gccgo/GoLLVM has no runtime/cgo package,
so don't try to depend on it (as it happens, this fixes #25324).
The result is that the cmd/go vet tests pass when using -compiler=gccgo.
Fixes #25324
Change-Id: Iba8f948fe944da5dc674f580bd3321929ee50fa0
Reviewed-on: https://go-review.googlesource.com/113716
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Bryan C. Mills <bcmills@google.com> Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Tobias Klauser [Thu, 24 May 2018 07:02:31 +0000 (09:02 +0200)]
cmd/vendor/golang.org/x: pick up upstream fixes for broken android and iOS tests
Pick up the changes from CL 114395, CL 114396 and CL 114415.
By re-running govendor in the latest version, some files from
golang.org/x/sys/unix which are ignored for the build also got removed
from the vendored copy.
Hana Kim [Thu, 24 May 2018 19:15:45 +0000 (15:15 -0400)]
runtime/pprof: allow tests to run multiple times
TestMutexProfile and TestEmptyCallStack couldn't run multiple times
because they mutate state in runtime (mutex profile counters and
a user-defined profile type) and test whether the state
matches what it is supposed to be after the very first run.
We fix TestMutexProfile by relaxing the expected state condition.
We fix TestEmptyCallStack by creating a new profile with a different
name every time the test runs.
For #25520
Change-Id: I8e50cd9526eb650c8989457495ff90a24ce07863
Reviewed-on: https://go-review.googlesource.com/114495
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Brad Fitzpatrick [Wed, 23 May 2018 22:30:41 +0000 (22:30 +0000)]
net/http: conservatively flush Transport request headers by default
This changes the http.Transport to flush the bufio.Writer between
writing the request headers and the body.
That wasn't done in the past to minimize the number of TCP packets on
the wire, but that's just an optimization, and it causes problems when
servers are waiting for the headers and the client is blocked on
something before reading the body.
Instead, only do the don't-flush optimization if we know we're not
going to block, whitelisting a set of common in-memory Request.Body
types. (the same set of types special-cased by http.NewRequest)
Fixes #22088
Change-Id: I7717750aa6df32dd3eb92d181b45bc7af24b1144
Reviewed-on: https://go-review.googlesource.com/114316
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Andrew Bonventre <andybons@golang.org>
Reason for revert: It breaks the dragonfly trybot, in which there are sometimes (non-deterministically) Events with the same timestamp that have to occur in a specific order.
Richard Musiol [Thu, 24 May 2018 02:11:05 +0000 (04:11 +0200)]
cmd/compile: fix write barrier control value on wasm
This commit fixes a regression with wasm caused by a367f44c18.
It adds optimizations to the lowering rules of wasm to ensure
that the lowered version of the code generated for write barriers
is simple enough so it can be processed by Liveness.markUnsafePoints.
Robert Griesemer [Wed, 23 May 2018 23:35:56 +0000 (16:35 -0700)]
go/types: permit embedding of non-defined interfaces via alias type names
Embedded interfaces in interfaces must take the form of a (possibly
qualified) type name. Before alias types, a type name always denoted
a defined (formerly "named") type. The introduction of alias types
enabled embedding of non-defined types via alias type names, as in:
type T interface { E }
type E interface { m() }
Both cmd/compile and gccgo accept this kind of code, and the spec does
not prohibit it. There may be code in the wild that makes use of this.
go/types was written under the assumption that embedded interfaces
were always defined types; and that assumption was even reflected in
the go/types API.
This change removes this restriction in the implementation (which
happens to make it simpler), and in the API (by adding additional
functions and deprecating the corresponding older versions).
It also replaces uses of NewInterface and Embedded (old API) by
NewInterface2 and EmbeddedType (new API) in dependent packages
(importers).
The old API remains in place for backward compatibility and is marked
as deprecated.
Fixes #25301.
Change-Id: I272acd498754179efaf0590ca49d3eb4eee4348e
Reviewed-on: https://go-review.googlesource.com/114317 Reviewed-by: Alan Donovan <adonovan@google.com>
Austin Clements [Wed, 23 May 2018 18:01:21 +0000 (14:01 -0400)]
runtime: fix preemption deadlocks in TestDebugCall*
TestDebugCall* uses atomic spin loops and hence can deadlock if the
garbage collector is enabled (because of #10958; ironically,
implementing debugger call injection is closely related to fixing this
exact issue, but we're not there yet).
Fix this by disabling the garbage collector during these tests.
Updates #25519 (might fix it, though I suspect not)
Heschi Kreinick [Tue, 22 May 2018 22:08:12 +0000 (18:08 -0400)]
cmd/compile: fix debug info generation for loads from Phis
Apparently a LoadReg can take a Phi as its argument. The Phi has names
in the NamedValue table, so just read the Load's names from the Phi.
The example given, XORKeyStream in chacha20, is pretty complicated so I
didn't try to actually debug it and verify that the results are right.
But the debug logging looks reasonable, with the right names in the right
registers at the right times.
Heschi Kreinick [Tue, 22 May 2018 22:00:39 +0000 (18:00 -0400)]
cmd/compile: clean up debug info generation logging
Remove the unexpected function, which is a lot less relevant now that
the generation basically can't detect invalid states, and make sure no
logging appears without -d locationlists=2.
Anit Gandhi [Wed, 23 May 2018 22:03:08 +0000 (22:03 +0000)]
crypto/{aes,internal/cipherhw,tls}: use common internal/cpu in place of cipherhw
When the internal/cpu package was introduced, the AES package still used
the custom crypto/internal/cipherhw package for amd64 and s390x. This
change removes that package entirely in favor of directly referencing the
cpu feature flags set and exposed by the internal/cpu package. In
addition, 5 new flags have been added to the internal/cpu s390x struct
for detecting various cipher message (KM) features.
Richard Musiol [Thu, 8 Mar 2018 23:14:58 +0000 (00:14 +0100)]
cmd/compile: add wasm stack optimization
Go's SSA instructions only operate on registers. For example, an add
instruction would read two registers, do the addition and then write
to a register. WebAssembly's instructions, on the other hand, operate
on the stack. The add instruction first pops two values from the stack,
does the addition, then pushes the result to the stack. To fulfill
Go's semantics, one needs to map Go's single add instruction to
4 WebAssembly instructions:
- Push the value of local variable A to the stack
- Push the value of local variable B to the stack
- Do addition
- Write value from stack to local variable C
Now consider that B was set to the constant 42 before the addition:
- Push constant 42 to the stack
- Write value from stack to local variable B
This works, but is inefficient. Instead, the stack is used directly
by inlining instructions if possible. With inlining it becomes:
- Push the value of local variable A to the stack (add)
- Push constant 42 to the stack (constant)
- Do addition (add)
- Write value from stack to local variable C (add)
Note that the two SSA instructions can not be generated sequentially
anymore, because their WebAssembly instructions are interleaved.
Alexander Döring [Fri, 11 May 2018 18:06:53 +0000 (20:06 +0200)]
math/big: specialize Karatsuba implementation for squaring
Currently we use three different algorithms for squaring:
1. basic multiplication for small numbers
2. basic squaring for medium numbers
3. Karatsuba multiplication for large numbers
Change 3. to a version of Karatsuba multiplication specialized
for x == y.
Increasing the performance of 3. lets us lower the threshold
between 2. and 3.
Adapt TestCalibrate to the change that 3. isn't independent
of the threshold between 1. and 2. any more.
Hana (Hyang-Ah) Kim [Wed, 9 May 2018 16:01:15 +0000 (00:01 +0800)]
cmd/pprof: add readline support similar to upstream
The upstream pprof implements the readline feature using
the github.com/chzyer/readline package in its pprof.go main.
It would be ideal to use the same readline support package as
the upstream for better user experience and code maintenance.
However, bringing in third-party packages requires more work
than I envisioned (e.g. clean up the vendored code to meet the
expected standard - iow don't break builders).
As a result, this change implements the similar feature
for the pprof command included in the go distribution
(cmd/pprof/pprof.go) using golang.org/x/crypto/ssh/terminal
for now.
Auto-completion is not yet supported (same in the upstream).
The feature is enabled only in linux, windows, darwin, and
only when terminal support is available.
This change brings in new vendored packages,
golang.org/x/crypto/ssh/terminal and
golang.org/x/sys/{unix,windows}.
For #14041
Change-Id: If4a790796acf2ab20f7e81268b9d9354c5a5cd2b
Reviewed-on: https://go-review.googlesource.com/112436
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Richard Musiol [Sun, 20 May 2018 19:33:52 +0000 (21:33 +0200)]
syscall: partially revert "enable some nacl code to be shared with js/wasm"
This partially reverts commit 3bdbb5df7692142c13cf93f6d80b2a907e3f396b.
The latest CL of js/wasm's file system support does not use
file descriptor mapping any more.
Adam Medzinski [Fri, 18 May 2018 14:54:30 +0000 (16:54 +0200)]
net: add example for net.UDPConn.WriteTo function
The current documentation of the WriteTo function is very poor and it
is difficult to deduce how to use it correctly. A good example will
make things much easier.
Elias Naur [Wed, 23 May 2018 14:31:36 +0000 (16:31 +0200)]
misc/android: forward SIGQUIT to the process running on the device
When a test binary runs for too long, the go command sends it a
SIGQUIT to force a backtrace dump. On Android, the exec wrapper
will instead receive the signal and dump its backtrace.
Forward SIGQUIT signals from the wrapper to the wrapped process
to gain useful backtraces.
Inspired by issuse 25519; this CL would have revealed the hanging
test directly in the builder log.
David Chase [Tue, 22 May 2018 18:45:27 +0000 (14:45 -0400)]
cmd/compile: grow stack before test() to avoid gdb misbehavior
While next-ing over a call in gdb, if execution of that call
causes a goroutine's stack to grow (i.e., be moved), gdb loses
track and runs ahead to the next breakpoint, or to the end of
the program, whichever comes first.
Prevent this by preemptively growing the stack so that
ssa/debug_test.go will reliably measure what is intended,
the goodness of line number placement and variable printing.
Ian Gudger [Fri, 18 May 2018 19:43:13 +0000 (12:43 -0700)]
net: fix DNS NXDOMAIN performance regression
golang.org/cl/37879 unintentionally changed the way NXDOMAIN errors were
handled. Before that change, resolution would fail on the first NXDOMAIN
error and return to the user. After that change, the next server would
be consulted and resolution would fail only after all servers had been
consulted. This change restores the old behavior.
Peter Weinberger [Mon, 21 May 2018 14:45:59 +0000 (10:45 -0400)]
internal/trace: change Less to make sorting events deterministice
The existing code just used timestamps. The new code uses more fields
when timestamps are equal.
Revised to shorten code per reviewer comments.
Change-Id: Ibd0824d0acd7644484d536b1a754a0da156fac3d
Reviewed-on: https://go-review.googlesource.com/113721 Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Tobias Klauser [Wed, 23 May 2018 12:04:48 +0000 (14:04 +0200)]
debug/pe: gofmt
CL 110555 introduced some changes which were not properly gofmt'ed.
Because the CL was sent via Github the gofmt checks usually performed by
git-codereview didn't catch this (see #24946).
Ben Burkert [Tue, 22 May 2018 02:28:19 +0000 (19:28 -0700)]
internal/poll: disable splice on old linux versions
The splice syscall is buggy prior to linux 2.6.29. Instead of returning
0 when reading a closed socket, it returns EAGAIN. While it is possible
to detect this (HAProxy falls back to recv), it is simpiler to avoid
using splice all together. the "fcntl(fd, F_GETPIPE_SZ)" syscall is used
detect buggy versions of splice as the syscall returns EINVAL on
versions prior to 2.6.35.
Austin Clements [Tue, 22 May 2018 21:27:54 +0000 (17:27 -0400)]
cmd/compile: ignore g register in liveness analysis
In rare circumstances that we don't yet fully understand, the g
register can be spilled to the stack and then reloaded. If this
happens, liveness analysis sees a pointer load into a
non-general-purpose register and panics.
We should fix the root cause of this, but fix the build for now by
ignoring pointer loads into the g register.
David Chase [Fri, 18 May 2018 21:43:11 +0000 (17:43 -0400)]
cmd/compile: common up code in fuse for joining blocks
There's semantically-but-not-literally equivalent code in
two cases for joining blocks' value lists in ssa/fuse.go.
It can be made literally equivalent, then commoned up.
Currently liveness analysis is a significant source of allocations in
the compiler. This CL mitigates this by moving the main sources of
allocation to the ssa.Cache, allowing them to be reused between
different liveness runs.
Compared to just before "cmd/internal/obj: consolidate emitting entry
stack map", the cumulative effect of adding stack maps everywhere and
register maps, plus these optimizations, is:
Currently liveness information is kept in a map keyed by *ssa.Value.
This made sense when liveness information was sparse, but now we have
liveness for nearly every ssa.Value. There's a fair amount of memory
and CPU overhead to this map now.
This CL replaces this map with a slice indexed by value ID.
The per-Value slice of liveness maps is currently one of the largest
sources of allocation in the compiler. On cmd/compile/internal/ssa,
it's 5% of overall allocation, or 75MB in total. Enabling liveness
maps everywhere significantly increased this allocation footprint,
which in turn slowed down the compiler.
Improve this by compacting the liveness maps after every block is
processed. There are typically very few distinct liveness maps, so
compacting the maps after every block, rather than at the end of the
function, can significantly reduce these allocations.
This moves the bvec hash table logic out of Liveness.compact and into
a bvecSet type. Furthermore, the bvecSet type has the ability to grow
dynamically, which the current implementation doesn't. In addition to
making the code cleaner, this will make it possible to incrementally
compact liveness bitmaps.
cmd/compile: single pass over Blocks in Liveness.epilogue
Currently Liveness.epilogue makes three passes over the Blocks, but
there's no need to do this. Combine them into a single pass. This
eliminates the need for blockEffects.lastbitmapindex, but, more
importantly, will let us incrementally compact the liveness bitmaps
and significantly reduce allocatons in Liveness.epilogue.
Passes toolstash -cmp.
Updates #24543.
Change-Id: I27802bcd00d23aa122a7ec16cdfd739ae12dd7aa
Reviewed-on: https://go-review.googlesource.com/110175
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com>
Hana Kim [Tue, 22 May 2018 17:41:04 +0000 (13:41 -0400)]
cmd/vendor/README: temporary instruction for update
Until vgo sorts out and cleans up the vendoring process.
Ran govendor to update packages the cmd/pprof depends on
which resulted in deletion of some of unnecessary files.
Change-Id: Idfba53e94414e90a5e280222750a6df77e979a16
Reviewed-on: https://go-review.googlesource.com/114079
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com> Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
David Chase [Mon, 21 May 2018 17:11:50 +0000 (13:11 -0400)]
cmd/link: revert DWARF version to 2 for .debug_lines
On OSX 10.12 and earlier, paired with XCode 9.0,
specifying DWARF version 3 causes dsymutil to misbehave.
Version 2 appears to be good enough to allow processing
of the prologue_end opcode on (at least one version of)
Linux and OSX 10.13.
Austin Clements [Tue, 22 May 2018 17:49:50 +0000 (13:49 -0400)]
runtime: fix defer matching of leaf functions on LR machines
Traceback matches the defer stack with the function call stack using
the SP recorded in defer frames when the defer frame is created.
However, on LR machines this is ambiguous: if function A pushes a
defer and then calls function B, where B is a leaf function with a
zero-sized frame, then both A and B have the same SP and will *both*
match the defer on the defer stack. Since traceback unwinds through B
first, it will incorrectly match up the defer with B's frame instead
of A's frame.
Where this goes particularly wrong is if function B causes a signal
that turns into a panic (e.g., a nil pointer dereference). In order to
handle the fact that we may not have a liveness map at the location
that caused the signal and injected a sigpanic call, traceback has
logic to unwind the panicking frame's continuation PC to the PC where
the most recent defer was pushed (this is safe because the frame is
dead other than any defers it pushed). However, if traceback
mis-matches the defer stack, it winds up reporting the B's
continuation PC is in A. If the runtime then uses this continuation PC
to look up PCDATA in B, it will panic because the PC is out of range
for B. This failure mode can be seen in
sync/atomic/atomic_test.go:TestNilDeref. An example failure is:
https://build.golang.org/log/8e07a762487839252af902355f6b1379dbd463c5
This CL fixes all of this by recognizing that a function that pushes a
defer must also have a non-zero-sized frame and using this fact to
refine the defer matching logic.
Fixes the build for arm64, mips, mipsle, ppc64, ppc64le, and s390x.
Martin Möhrmann [Fri, 26 Jan 2018 11:14:27 +0000 (12:14 +0100)]
internal/cpu: add experiment to disable CPU features with GODEBUGCPU
Needs the go compiler to be build with GOEXPERIMENT=debugcpu to be active.
The GODEBUGCPU environment variable can be used to disable usage of
specific processor features in the Go standard library.
This is useful for testing and benchmarking different code paths that
are guarded by internal/cpu variable checks.
Use of processor features can not be enabled through GODEBUGCPU.
To disable usage of AVX and SSE41 cpu features on GOARCH amd64 use:
GODEBUGCPU=avx=0,sse41=0
The special "all" option can be used to disable all options:
GODEBUGCPU=all=0
Martin Sucha [Sun, 20 May 2018 19:01:31 +0000 (21:01 +0200)]
crypto/x509: reformat template members in docs
It's easier to skim a list of items visually when the
items are each on a separate line. Separate lines also
help reduce diff size when items are added/removed.
The list is indented so that it's displayed preformatted
in HTML output as godoc doesn't support formatting lists
natively yet (see #7873).
Alberto Donizetti [Mon, 21 May 2018 11:21:26 +0000 (13:21 +0200)]
log/syslog: skip tests that depend on daemon on builders
Some functions in log/syslog depend on syslogd running. Instead of
treating errors caused by the daemon not running as test failures,
ignore them and skip the test.
dchenk [Tue, 22 May 2018 04:36:53 +0000 (21:36 -0700)]
encoding/base32: remove redundant conditional
Immediately following the conditional block removed here is a loop
which checks exactly what the conditional already checked, so the
entire conditional is redundant.
This adds a mechanism for debuggers to safely inject calls to Go
functions on amd64. Debuggers must participate in a protocol with the
runtime, and need to know how to lay out a call frame, but the runtime
support takes care of the details of handling live pointers in
registers, stack growth, and detecting the trickier conditions when it
is unsafe to inject a user function call.
Austin Clements [Tue, 27 Mar 2018 19:50:45 +0000 (15:50 -0400)]
cmd/compile, cmd/internal/obj: record register maps in binary
This adds FUNCDATA and PCDATA that records the register maps much like
the existing live arguments maps and live locals maps. The register
map is indexed independently from the argument and locals maps since
changes in register liveness tend not to correlate with changes to
argument and local liveness.
This is the final CL toward adding safe-points everywhere. The
following CLs will optimize liveness analysis to bring down the cost.
The effect of this CL is:
name old exe-bytes new exe-bytes delta
HelloSize 1.47M ± 0% 1.51M ± 0% +2.79% (p=0.000 n=10+10)
Compared to just before "cmd/internal/obj: consolidate emitting entry
stack map", the cumulative effect of adding stack maps everywhere and
register maps is:
Austin Clements [Tue, 27 Feb 2018 01:56:58 +0000 (20:56 -0500)]
cmd/compile: compute register liveness maps
This extends the liveness analysis to track registers containing live
pointers. We do this by tracking bitmaps for live pointer registers
in parallel with bitmaps for stack variables.
This does not yet do anything with these liveness maps, though they do
appear in the debug output for -live=2.