Radu Berinde [Sun, 28 Aug 2016 18:36:06 +0000 (14:36 -0400)]
hash/crc32: cleanup code and improve tests
Major reorganization of the crc32 code:
- The arch-specific files now implement a well-defined interface
(documented in crc32.go). They no longer have the responsibility of
initializing and falling back to a non-accelerated implementation;
instead, that happens in the higher level code.
- The non-accelerated algorithms are moved to a separate file with no
dependencies on other code.
- The "cutoff" optimization for slicing-by-8 is moved inside the
algorithm itself (as opposed to every callsite).
Tests are significantly improved:
- direct tests for the non-accelerated algorithms.
- "cross-check" tests for arch-specific implementations (all archs).
- tests for misaligned buffers for both IEEE and Castagnoli.
Fixes #16909.
Change-Id: I9b6dd83b7a57cd615eae901c0a6d61c6b8091c74
Reviewed-on: https://go-review.googlesource.com/27935 Reviewed-by: Keith Randall <khr@golang.org>
Alex Brainman [Wed, 10 Aug 2016 01:06:46 +0000 (11:06 +1000)]
cmd/link, cmd/go: delay linking of mingwex and mingw32 until very end
cmd/go links mingwex and mingw32 libraries to every package it builds.
This breaks when 2 different packages call same gcc standard library
function pow. gcc linker appends pow implementation to the compiled
package, and names that function "pow". But when these 2 compiled
packages are linked together into the final executable, linker
complains, because it finds two "pow" functions with the same name.
This CL stops linking of mingwex and mingw32 during package build -
that leaves pow function reference unresolved. pow reference gets
resolved as final executable is built, by having both internal and
external linker use mingwex and mingw32 libraries.
Fixes #8756
Change-Id: I50ddc79529ea5463c67118d668488345ecf069bc
Reviewed-on: https://go-review.googlesource.com/26670
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Kevin Burke [Tue, 12 Jul 2016 23:54:36 +0000 (16:54 -0700)]
crypto/sha256: add examples for New, Sum256
The goal for these examples is to show how to mirror the
functionality of the sha256sum Unix utility, a common checksumming
tool, using the Go standard library.
Add a newline at the end of the input, so users will get the same
output if they type `echo 'hello world' | sha256sum`, since the
builtin shell echo appends a newline by default. Also use hex output
(instead of the shorter base64) since this is the default output
encoding for shasum/sha256sum.
Bryan Alexander [Sun, 28 Aug 2016 19:11:31 +0000 (14:11 -0500)]
crypto/x509: Fix bug in UnknownAuthorityError.Error
Fix bug in UnknownAuthorityError.Error that would never allow Org
Name to be inserted into error message if the Common Name was empty.
Create tests for all three paths in UnknownAuthorityError.Error
Cherry Zhang [Tue, 30 Aug 2016 18:46:25 +0000 (14:46 -0400)]
cmd/compile, runtime, etc: get rid of constant FP registers
On ARM64, MIPS64, and PPC64, some floating point registers were
reserved for constants 0, 1, 2, 0.5, etc. This CL removes them.
On ARM64, they are never used. On MIPS64 and PPC64, the only use
case is a multiplication-by-2 in the old backend of the compiler,
which is replaced with an addition.
Keith Randall [Tue, 30 Aug 2016 18:08:47 +0000 (11:08 -0700)]
all: use testing.GoToolPath instead of "go"
This change makes sure that tests are run with the correct
version of the go tool. The correct version is the one that
we invoked with "go test", not the one that is first in our path.
Matthew Dempsky [Mon, 29 Aug 2016 20:29:46 +0000 (13:29 -0700)]
reflect: cleanup wording for type identity/equality
Use terms like "equal" and "identical types" to match the Go spec,
rather than inventing a new explanation. See also discussion on
golang.org/cl/27170.
Updates #16348.
Change-Id: I0fe0bd01c0d1da3c8937a579c2ba44cf1eb16b71
Reviewed-on: https://go-review.googlesource.com/28054 Reviewed-by: Rob Pike <r@golang.org>
cmd/compile: recognize integer ranges in switch statements
Consider a switch statement like:
switch x {
case 1:
// ...
case 2, 3, 4, 5, 6:
// ...
case 5:
// ...
}
Prior to this CL, the generated code treated
2, 3, 4, 5, and 6 independently in a binary search.
With this CL, the generated code checks whether
2 <= x && x <= 6.
walkinrange then optimizes that range check
into a single unsigned comparison.
Experiments suggest that the best min range size
is 2, using binary size as a proxy for optimization.
Matthew Dempsky [Tue, 30 Aug 2016 18:15:38 +0000 (11:15 -0700)]
cmd/compile: get rid of ugly {Recvs,Params,Results}P methods
These were a hack abstraction for before FuncType existed.
The result value from calling FuncType() could be saved, but this
maintains the current idiom of consistently using t.FuncType().foo
everywhere in case we choose to evolve the API further.
Hiroshi Ioka [Fri, 19 Aug 2016 00:37:19 +0000 (09:37 +0900)]
path/filepath: handle ".." in normalizing a path on Windows
Current code assumes there are not ".." in the Clean(path).
That's not true. Clean doesn't handle leading "..", so we need to stop
normalization if we see "..".
Fixes #16793
Change-Id: I0a7901bedac17f1210b134d593ebd9f5e8483775
Reviewed-on: https://go-review.googlesource.com/27410 Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Brad Fitzpatrick [Tue, 30 Aug 2016 04:08:10 +0000 (04:08 +0000)]
net/http: fix ordering & data race in TestTransportEventTrace_h2
Ordering fix: this CL swaps the order of the log write and the channel close
in WroteRequest. I could reproduce the bug by putting a sleep between the two
when the channel close was first. It needs to happen after the log.
Data race: use the log buffer's mutex when reading too. Not really
important once the ordering fix above is fixed (since nobody is
concurrently writing anymore), but for consistency.
Fixes #16414
Change-Id: If6657884e67be90b4455c8f5a6f7bc6981999ee4
Reviewed-on: https://go-review.googlesource.com/28078
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org>
Martin Möhrmann [Fri, 26 Aug 2016 13:00:46 +0000 (15:00 +0200)]
cmd/compile: improve string iteration performance
Generate a for loop for ranging over strings that only needs to call
the runtime function charntorune for non ASCII characters.
This provides faster iteration over ASCII characters and slightly
faster iteration for other characters.
The runtime function charntorune is changed to take an index from where
to start decoding and returns the index after the last byte belonging
to the decoded rune.
All call sites of charntorune in the runtime are replaced by a for loop
that will be transformed by the compiler instead of calling the charntorune
function directly.
go binary size decreases by 80 bytes.
godoc binary size increases by around 4 kilobytes.
Robert Griesemer [Tue, 30 Aug 2016 00:56:15 +0000 (17:56 -0700)]
cmd/compile: make internal objects directly print to printer
Internal objects that satisfy the Printable interface can print
directly to a printer w/o going through the conversion to a string
first.
Made printer.f understand and special-case %v so that Printable
objects use the printer directly.
This is work in progress and we may end up doing something else
eventually (perhaps using fmt.Formatter) - or even undo these
changes if this exploration doesn't get us to a significantly
better place.
Allocations numbers relative to commit c85b77c (still up, but
reduced from most recent change):
Sam Whited [Wed, 2 Mar 2016 06:00:23 +0000 (00:00 -0600)]
time: Add Until helper function
Adds an Until() function that returns the duration until the given time.
This compliments the existing Since() function and makes writing
expressions that have expiration times more readable; for example:
Brad Fitzpatrick [Mon, 29 Aug 2016 21:27:40 +0000 (21:27 +0000)]
os: don't let File.Readdir return an empty slice and nil error
In the case of a file being deleted while Readdir was running, it was
possible for File.Readdir to return an empty slice and a nil error,
counter to its documentation.
Fixes #16919
Change-Id: If0e42882eea52fbf5530317a1895f3829ea8e67b
Reviewed-on: https://go-review.googlesource.com/28056 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Carlos Eduardo Seo [Fri, 29 Jul 2016 17:02:26 +0000 (14:02 -0300)]
runtime: insufficient padding in the `p` structure
The current padding in the 'p' struct is hardcoded at 64 bytes. It should be the
cache line size. On ppc64x, the current value is only okay because sys.CacheLineSize
is wrong at 64 bytes. This change fixes that by making the padding equal to the
cache line size. It also fixes the cache line size for ppc64/ppc64le to 128 bytes.
Fixes #16477
Change-Id: Ib7ec5195685116eb11ba312a064f41920373d4a3
Reviewed-on: https://go-review.googlesource.com/25370 Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Michael Munday <munday@ca.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Ian Lance Taylor [Mon, 11 Jul 2016 00:51:27 +0000 (17:51 -0700)]
cmd/go: for -msan build runtime/cgo with -fsanitize=memory
The go tool used to avoid passing -fsanitize=memory when building
runtime/cgo. That was originally to avoid an msan error, but that error
was fixed anyhow for issue #13815. And building runtime/cgo with
-fsanitize=memory corrects the handling of the context traceback
function when the traceback function itself is built with
-fsanitize=memory.
Change-Id: I4bf5c3d21de6b2eb540600435ae47f5820d17464
Reviewed-on: https://go-review.googlesource.com/24855
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Ethan Miller [Fri, 12 Aug 2016 18:45:50 +0000 (13:45 -0500)]
math/big: add assembly implementation of arith for ppc64{le}
The existing implementation used a pure go implementation, leading to slow
cryptographic performance.
Implemented mulWW, subVV, mulAddVWW, addMulVVW, and bitLen for
ppc64{le}.
Implemented divWW for ppc64le only, as the DIVDEU instruction is only
available on Power8 or newer.
Martin Möhrmann [Thu, 25 Aug 2016 12:17:52 +0000 (14:17 +0200)]
cmd/compile: generate makeslice calls with int arguments
Where possible generate calls to runtime makeslice with int arguments
during compile time instead of makeslice with int64 arguments.
This eliminates converting arguments for calls to makeslice with
int64 arguments for platforms where int64 values do not fit into
arguments of type int.
godoc 386 binary shrinks by approximately 12 kilobyte.
amd64:
name old time/op new time/op delta
MakeSlice-2 29.8ns ± 1% 29.8ns ± 1% ~ (p=1.000 n=24+24)
386:
name old time/op new time/op delta
MakeSlice-2 52.3ns ± 0% 45.9ns ± 0% -12.17% (p=0.000 n=25+22)
Emmanuel Odeke [Mon, 29 Aug 2016 00:04:46 +0000 (17:04 -0700)]
all: fix obsolete inferno-os links
Fixes #16911.
Fix obsolete inferno-os links, since code.google.com shutdown.
This CL points to the right files by replacing
http://code.google.com/p/inferno-os/source/browse
with
https://bitbucket.org/inferno-os/inferno-os/src/default
To implement the change I wrote and ran this script in the root:
$ grep -Rn 'http://code.google.com/p/inferno-os/source/browse' * \
| cut -d":" -f1 | while read F;do perl -pi -e \
's/http:\/\/code.google.com\/p\/inferno-os\/source\/browse/https:\/\/bitbucket.org\/inferno-os\/inferno-os\/src\/default/g'
$F;done
I excluded any cmd/vendor changes from the commit.
Change-Id: Iaaf828ac8f6fc949019fd01832989d00b29b6749
Reviewed-on: https://go-review.googlesource.com/27994 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Giovanni Bajo [Wed, 17 Aug 2016 15:31:12 +0000 (17:31 +0200)]
doc: improve issue template
The previous template used an ordered list, but the formatting always
breaks when users paste quoted snippets of code or command outputs.
It is also harder to visually parse because items in ordered lists
are only indented but not highlighted in any way.
Alex Brainman [Fri, 26 Aug 2016 06:57:00 +0000 (16:57 +1000)]
time: always use $GOROOT/lib/time/zoneinfo.zip with genzabbrs.go
genzabbrs.go uses whatever zoneinfo database available on the system.
This makes genzabbrs.go output change from system to system. Adjust
go:generate line to always use $GOROOT/lib/time/zoneinfo.zip, so it
does not matter who runs the command.
Also move go:generate line into zoneinfo.go, so it can be run
on Unix (see #16368 for details).
Fixes #15802.
Change-Id: I8ae4818aaf40795364e180d7bb4326ad7c07c370
Reviewed-on: https://go-review.googlesource.com/27832 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Normally this is enabled by a developer debugging TLS based
applications, especially HTTP/2, by setting the KeyLogWriter
to an open file. The keys negotiated in handshake are then
logged and can be used to decrypt TLS sessions e.g. in Wireshark.
Applications may choose to add support similar to NSS where this
is enabled by environment variable, but no such mechanism is
built in to Go. Instead each application must explicitly enable.
Robert Griesemer [Thu, 25 Aug 2016 04:47:58 +0000 (21:47 -0700)]
cmd/compile: introduce printer for internal formatting; use in jconv
Starting point for uniform use of printer in fmt.go.
It provides a hook to store additional state (and
remove global variables) and should also be more
efficient and cleaner than the mix of string concatenation
and bytes.Buffer use we have now.
Change-Id: I72de14b01850cca32d407a1cb16c894179ea8848
Reviewed-on: https://go-review.googlesource.com/27916 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Robert Griesemer [Fri, 26 Aug 2016 20:06:59 +0000 (13:06 -0700)]
cmd/compile: reintroduce support for version 0 export format
The Go1.7 export format didn't encode the field package for
blank struct fields (#15514). Re-introduce support for that
format so we can read it w/o error.
For #16881.
Change-Id: Ib131d41aac56dbf970aab15ae7e75ef3944b412d
Reviewed-on: https://go-review.googlesource.com/27912 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
David Crawshaw [Fri, 26 Aug 2016 02:19:16 +0000 (22:19 -0400)]
runtime: have typelinksinit work forwards
For reasons I have forgotten typelinksinit processed modules backwards.
(I suspect this was an attempt to process types in the executing
binary first.)
It does not appear to be necessary, and it is not the order we want
when a module can be loaded at an arbitrary point during a program's
execution as a plugin. So reverse the order.
While here, make it safe to call typelinksinit multiple times.
Change-Id: Ie10587c55c8e5efa0542981efb6eb3c12dd59e8c
Reviewed-on: https://go-review.googlesource.com/27822 Reviewed-by: Ian Lance Taylor <iant@golang.org>
David Crawshaw [Fri, 26 Aug 2016 01:06:10 +0000 (21:06 -0400)]
cmd/link: make DynlinkingGo a method
This will allow it to depend on whether plugin.Open is a symbol to be
linked in.
Change-Id: Ie9aa4216f2510fe8b10bc4665c8b19622b7122ea
Reviewed-on: https://go-review.googlesource.com/27819 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
David Crawshaw [Thu, 25 Aug 2016 18:31:50 +0000 (14:31 -0400)]
cmd/compile: qualify unexported fields of unnamed types
The compiler was canonicalizing unnamed types of the form
struct { i int }
across packages, even though an unexported field i should not be
accessible from other packages.
The fix requires both qualifying the field name in the string used by
the compiler to distinguish the type, and ensuring the struct's pkgpath
is set in the rtype version of the data when the type being written is
not part of the localpkg.
Fixes #16616
Change-Id: Ibab160b8b5936dfa47b17dbfd48964a65586785b
Reviewed-on: https://go-review.googlesource.com/27791
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Robert Griesemer <gri@golang.org>
Hiroshi Ioka [Fri, 26 Aug 2016 08:44:30 +0000 (17:44 +0900)]
os: fix build error on plan9
https://go-review.googlesource.com/#/c/27580 added the test.
However the test use syscall.ELOOP which is not defined on plan9.
Move test code from "os_test.go" to "os_windows_test.go" to prevent
build error.
Change-Id: Ie7f05bfb9ab229e06a8e82a4b3b8a7ca82d4663b
Reviewed-on: https://go-review.googlesource.com/27833
TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: David du Colombier <0intro@gmail.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Hiroshi Ioka [Thu, 18 Aug 2016 07:10:28 +0000 (16:10 +0900)]
os: prevent infinite symlink loop of Stat on Windows
The Windows version of Stat calls Readlink iteratively until
reaching a non-symlink file.
If the given file is a circular symlink, It never stops.
This CL defines the maximum number of symlink loop count.
If the loop count will exceed that number, Stat will return error.
Robert Griesemer [Thu, 25 Aug 2016 23:53:10 +0000 (16:53 -0700)]
cmd/compile: fail gracefully on export format skew
Import errors due to unexpected format are virtually
always due to version skew. Don't panic but report a
good error message (incl. hint that the imported package
needs to be reinstalled) if not in debugFormat mode.
Recognize export data format version and store it so
it can be used to automatically handle minor version
differences. We did this before, but not very well.
No export data format changes.
Manually tested with corrupted export data.
For #16881.
Change-Id: I53ba98ef747b1c81033a914bb61ee52991f35a90
Reviewed-on: https://go-review.googlesource.com/27814 Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Keith Randall [Tue, 23 Aug 2016 23:49:28 +0000 (16:49 -0700)]
cmd/compile: inline atomics from runtime/internal/atomic on amd64
Inline atomic reads and writes on amd64. There's no reason
to pay the overhead of a call for these.
To keep atomic loads from being reordered, we make them
return a <value,memory> tuple.
Change the meaning of resultInArg0 for tuple-generating ops
to mean the first part of the result tuple, not the second.
This means we can always put the store part of the tuple last,
matching how arguments are laid out. This requires reordering
the outputs of add32carry and sub32carry and their descendents
in various architectures.
benchmark old ns/op new ns/op delta
BenchmarkAtomicLoad64-8 2.09 0.26 -87.56%
BenchmarkAtomicStore64-8 7.54 5.72 -24.14%
Add missing function prototypes.
Fix function prototypes.
Use FP references instead of SP references.
Fix variable names.
Update comments.
Clean up whitespace. (Not for vet.)
Joe Tsai [Sat, 20 Aug 2016 08:46:32 +0000 (01:46 -0700)]
archive/tar: isolate regular and sparse file handling as methods
Factor out the regular file handling logic into handleRegularFile
from nextHeader. We will need to reuse this logic when fixing #15573
in a future CL.
Factor out the sparse file handling logic into handleSparseFile.
Currently this logic is split between nextHeader (for GNU sparse
files) and Next (for PAX sparse files). Instead, we move this
related code into a single method.
There is no overall logic change. Thus, no unit tests.