1
0
mirror of https://github.com/golang/go synced 2024-11-14 09:10:27 -07:00
Commit Graph

37149 Commits

Author SHA1 Message Date
Kunpei Sakai
260ae19c89 net/http: update bundled http2
Updates http2 to x/net/http2 git rev 5f9ae10 for:

    http2: terminate await request cancel goroutine on conn close
    https://golang.org/cl/108415

    http2: don't sniff Content-type in Server when X-Content-Type-Options:nosniff
    https://golang.org/cl/107295

    http2, http/httpguts: move ValidTrailerHeader to new common package http/httpguts
    https://golang.org/cl/104042

    all: remove "the" duplications
    https://golang.org/cl/94975

    http2: use RFC 723x as normative reference in docs
    https://golang.org/cl/94555

    all: use HTTPS for iana.org links
    https://golang.org/cl/89415

Fixes #24795
Fixes #24776
Updates #23908
Fixes #21974

Change-Id: I7985617a7dde56cc5ed8670d73b26f8307be83d6
Reviewed-on: https://go-review.googlesource.com/111655
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-06 13:53:47 +00:00
Martin Möhrmann
4ebc67d334 runtime: remove hmap field from maptypes
The hmap field in the maptype is only used by the runtime to check the sizes of
the hmap structure created by the compiler and runtime agree.

Comments are already present about the hmap structure definitions in the
compiler and runtime needing to be in sync.

Add a test that checks the runtimes hmap size is as expected to detect
when the compilers and runtimes hmap sizes diverge instead of checking
this at runtime when a map is created.

Change-Id: I974945ebfdb66883a896386a17bbcae62a18cf2a
Reviewed-on: https://go-review.googlesource.com/91796
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2018-05-06 05:46:06 +00:00
Martin Möhrmann
b9a59d9f2e cmd/compile: optimize len([]rune(string))
Adds a new runtime function to count runes in a string.
Modifies the compiler to detect the pattern len([]rune(string))
and replaces it with the new rune counting runtime function.

RuneCount/lenruneslice/ASCII                  27.8ns ± 2%  14.5ns ± 3%  -47.70%  (p=0.000 n=10+10)
RuneCount/lenruneslice/Japanese                126ns ± 2%    60ns ± 2%  -52.03%  (p=0.000 n=10+10)
RuneCount/lenruneslice/MixedLength             104ns ± 2%    50ns ± 1%  -51.71%  (p=0.000 n=10+9)

Fixes #24923

Change-Id: Ie9c7e7391a4e2cca675c5cdcc1e5ce7d523948b9
Reviewed-on: https://go-review.googlesource.com/108985
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2018-05-06 05:31:01 +00:00
Martin Möhrmann
a8a60ac2a7 cmd/compile: optimize append(x, make([]T, y)...) slice extension
Changes the compiler to recognize the slice extension pattern

  append(x, make([]T, y)...)

and replace it with growslice and an optional memclr to avoid an allocation for make([]T, y).

Memclr is not called in case growslice already allocated a new cleared backing array
when T contains pointers.

amd64:
name                      old time/op    new time/op    delta
ExtendSlice/IntSlice         103ns ± 4%      57ns ± 4%   -44.55%  (p=0.000 n=18+18)
ExtendSlice/PointerSlice     155ns ± 3%      77ns ± 3%   -49.93%  (p=0.000 n=20+20)
ExtendSlice/NoGrow          50.2ns ± 3%     5.2ns ± 2%   -89.67%  (p=0.000 n=18+18)

name                      old alloc/op   new alloc/op   delta
ExtendSlice/IntSlice         64.0B ± 0%     32.0B ± 0%   -50.00%  (p=0.000 n=20+20)
ExtendSlice/PointerSlice     64.0B ± 0%     32.0B ± 0%   -50.00%  (p=0.000 n=20+20)
ExtendSlice/NoGrow           32.0B ± 0%      0.0B       -100.00%  (p=0.000 n=20+20)

name                      old allocs/op  new allocs/op  delta
ExtendSlice/IntSlice          2.00 ± 0%      1.00 ± 0%   -50.00%  (p=0.000 n=20+20)
ExtendSlice/PointerSlice      2.00 ± 0%      1.00 ± 0%   -50.00%  (p=0.000 n=20+20)
ExtendSlice/NoGrow            1.00 ± 0%      0.00       -100.00%  (p=0.000 n=20+20)

Fixes #21266

Change-Id: Idc3077665f63cbe89762b590c5967a864fd1c07f
Reviewed-on: https://go-review.googlesource.com/109517
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2018-05-06 04:28:23 +00:00
Josh Bleecher Snyder
87412a1430 text/tabwriter: fix BenchmarkPyramid and BenchmarkRagged
These were added in CL 106979. They were wrong.

The correct impact of CL 106979 on these benchmarks is:

name            old time/op    new time/op    delta
Pyramid/10-8      6.22µs ± 1%    5.68µs ± 0%    -8.78%  (p=0.000 n=15+13)
Pyramid/100-8      275µs ± 1%     255µs ± 1%    -7.30%  (p=0.000 n=15+13)
Pyramid/1000-8    25.6ms ± 1%    24.8ms ± 1%    -2.88%  (p=0.000 n=15+14)
Ragged/10-8       8.98µs ± 1%    6.74µs ± 0%   -24.98%  (p=0.000 n=15+14)
Ragged/100-8      85.3µs ± 0%    57.5µs ± 1%   -32.51%  (p=0.000 n=13+15)
Ragged/1000-8      847µs ± 1%     561µs ± 1%   -33.85%  (p=0.000 n=14+15)

name            old alloc/op   new alloc/op   delta
Pyramid/10-8      4.74kB ± 0%    4.88kB ± 0%    +3.04%  (p=0.000 n=15+15)
Pyramid/100-8      379kB ± 0%     411kB ± 0%    +8.50%  (p=0.000 n=15+12)
Pyramid/1000-8    35.3MB ± 0%    41.6MB ± 0%   +17.68%  (p=0.000 n=15+15)
Ragged/10-8       4.82kB ± 0%    1.82kB ± 0%   -62.13%  (p=0.000 n=15+15)
Ragged/100-8      45.4kB ± 0%     1.8kB ± 0%   -95.98%  (p=0.000 n=15+15)
Ragged/1000-8      449kB ± 0%       2kB ± 0%   -99.59%  (p=0.000 n=15+15)

name            old allocs/op  new allocs/op  delta
Pyramid/10-8        50.0 ± 0%      35.0 ± 0%   -30.00%  (p=0.000 n=15+15)
Pyramid/100-8        704 ± 0%       231 ± 0%   -67.19%  (p=0.000 n=15+15)
Pyramid/1000-8     10.0k ± 0%      2.1k ± 0%   -79.52%  (p=0.000 n=15+15)
Ragged/10-8         60.0 ± 0%      19.0 ± 0%   -68.33%  (p=0.000 n=15+15)
Ragged/100-8         511 ± 0%        19 ± 0%   -96.28%  (p=0.000 n=15+15)
Ragged/1000-8      5.01k ± 0%     0.02k ± 0%   -99.62%  (p=0.000 n=15+15)


This is an improvement over what was originally reported,
except the increase in alloc/op for the Pyramid benchmarks.

Change-Id: Ib2617c1288ce35f2c78e0172533d231b86e48bc2
Reviewed-on: https://go-review.googlesource.com/111643
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-06 04:27:05 +00:00
Daniel Theophanes
5cf3e34f96 database/sql: make error prefixes consistent
Ensure all error prefixes in the "database/sql" package start with
"sql: ". Do not prefix errors for type conversions because they
are always embedded in another error message with a specific
context.

Fixes #25251

Change-Id: I349d9804f3bfda4eeb755b32b508ec5992c28e07
Reviewed-on: https://go-review.googlesource.com/111637
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-05 16:27:20 +00:00
Ian Lance Taylor
f7c767edc5 cmd/go: don't give an error for an attempt to recreate a symlink
When building for gccgo cmd/go uses symlinks for import maps.
In some cases, such as TestVendorTest, it generates the same symlink
multiple times. Don't give an error when this happens.

Change-Id: Iecc154ea1ac53d7c5427b36795881909c5cac7e3
Reviewed-on: https://go-review.googlesource.com/111636
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-05 00:54:52 +00:00
Ian Lance Taylor
2a7e19e038 cmd/go: quote parentheses when outputting command
A gccgo command line can contain parentheses, for -( and -).
Quote them when outputting a command line, so that `go build -x`
output is suitable for use as shell input.

Change-Id: I43194b87bf048e583c222b19ca4bcdcb1deca97a
Reviewed-on: https://go-review.googlesource.com/111635
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-05 00:53:45 +00:00
Daniel Martí
d0ed8d6ea1 cmd/vet: %T is a formatting directive too
Some warnings were being missed, because vet's regex that finds
formatting directives was missing the 'T' verb.

Fixes #24646.

Change-Id: I2f6f9ed19e7daf9a07175199f428a62e94799ea9
Reviewed-on: https://go-review.googlesource.com/111357
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
2018-05-04 23:25:17 +00:00
Alberto Donizetti
2aef675000 runtime: ignore sigaction error on Linux if it is for SIGRTMAX
The Go runtime registers a handler for every signal. This prevents Go
binaries from working on QEMU in user-emulation mode, since the hacky
way QEMU implements signals on Linux assumes that no-one uses signal
64 (SIGRTMAX).

In the past, we had a workaround in the runtime to prevent crashes on
start-up when running on QEMU:

  golang.org/cl/124900043
  golang.org/cl/16853

but it went lost during the 1.11 dev cycle. More precisely, the test
for SIGRTMAX was dropped in CL 18150 when we stopped testing the
result of sigaction in the Linux implementation of setsig. That change
was made to avoid a stack split overflow because code started calling
setsig from nosplit functions. Then in CL 99077 we started testing the
result of sigaction again, this time using systemstack to avoid to
stack split overflow. When this test was added back, we did not bring
back the test of SIGRTMAX.

As a result, Go1.10 binaries work on QEMU, while 1.11 binaries
immediately crash on startup.

This change restores the QEMU workaround.

Updates #24656

Change-Id: I46380b1e1b4bf47db7bc7b3d313f00c4e4c11ea3
Reviewed-on: https://go-review.googlesource.com/111176
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-04 18:46:33 +00:00
Brad Fitzpatrick
eed79f46c2 net/http: ignore case of basic auth scheme in Request.BasicAuth
RFC 2617, Section 1.2: "It uses an extensible, case-insensitive
token to identify the authentication scheme"

RFC 7617, Section 2: "Note that both scheme and parameter names are
matched case-insensitively."

Fixes #22736

Change-Id: I825d6dbd4fef0f1c6add89f0cbdb56a03eae9443
Reviewed-on: https://go-review.googlesource.com/111516
Reviewed-by: Dmitri Shuralyov <dmitri@shuralyov.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-04 18:40:56 +00:00
Dmitri Shuralyov
73e38303f3 net/http: write status code in Redirect when Content-Type header set
This is a followup to CL 110296. That change added a new behavior
to Redirect, where the short HTML body is not written if the
Content-Type header is already set. It was implemented by doing
an early return. That unintentionally prevented the correct status
code from being written, so it would always default to 200.
Existing tests didn't catch this because they don't check status code.

This change fixes that issue by removing the early return and
moving the code to write a short HTML body behind an if statement.
It adds written status code checks to Redirect tests.

It also tries to improve the documentation wording and code style
in TestRedirect_contentTypeAndBody.

Updates #25166.

Change-Id: Idce004baa88e278d098661c03c9523426c5eb898
Reviewed-on: https://go-review.googlesource.com/111517
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-04 18:01:10 +00:00
Richard Musiol
3b137dd2df cmd/compile: add wasm architecture
This commit adds the wasm architecture to the compile command.
A later commit will contain the corresponding linker changes.

Design doc: https://docs.google.com/document/d/131vjr4DH6JFnb-blm_uRdaC0_Nv3OUwjEY5qVCxCup4

The following files are generated:
- src/cmd/compile/internal/ssa/opGen.go
- src/cmd/compile/internal/ssa/rewriteWasm.go
- src/cmd/internal/obj/wasm/anames.go

Updates #18892

Change-Id: Ifb4a96a3e427aac2362a1c97967d5667450fba3b
Reviewed-on: https://go-review.googlesource.com/103295
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-05-04 17:56:12 +00:00
Yuval Pavel Zholkover
a9fc375258 runtime: fast clock_gettime on FreeBSD, always call getHPETTimecounter on systemstack
CL 108095 goes to some length inorder to keep the stack usage of getHPETTimecounter code paths bellow a limit
being checked by the linker analysis. That limit is spurious, when running on the system or signal stack.

In a similar scenario, cgocallback_gofunc performs an indirect call through AX to hide the call from the linker analysis.
Here instead, mark getHPETTimecounter //go:systemstack and call it appropriately.

Change-Id: I80bec5e4974eee3c564d94f6e1142f322df88b2f
Reviewed-on: https://go-review.googlesource.com/111495
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-04 17:34:20 +00:00
Richard Musiol
88d677be96 vendor: update golang.org/x/net/internal/nettest from upstream
Updates to x/net git rev 640f462 for CL 109995.

Change-Id: I081d4c2265c576d61833bdf31ef8e388588053d3
Reviewed-on: https://go-review.googlesource.com/111555
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-04 17:34:07 +00:00
Brad Fitzpatrick
8aa316c139 cmd/dist: fix computation of test timeout
When dist test was updated to run "go test" with multiple package
arguments at once, merging the logical test units into one execution,
the hack to give cmd/go twice as much time wasn't updated.

What was happening (even in the all.bash case) was that we were
merging together, say, "cmd/go" and "bytes", and because bar was
lexically earlier, the timeout calculation was based on package "byte",
even though we were actually running, say: "go test bytes cmd/go".

This explains why x/build/cmd/release was often flaky with its
all.bash, since cmd/go can't really finish in 3 minutes reliably
unless it's running by itself. If it has any competition, it runs
over.

Change-Id: I875c8c9e65940ce0ceff48215740dfadfaa89d3f
Reviewed-on: https://go-review.googlesource.com/111395
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
2018-05-04 17:01:04 +00:00
Elias Naur
bcdbd58ce4 cmd/link/internal/ld: skip DWARF combining for iOS binaries
The macOS and iOS external linker strips DWARF information from
binaries because it assumes the information will go into separate
DWARF information .dSYM files. To preserve the embedded debugging
information, the Go linker re-combines the separate DWARF
information into the unmapped __DWARF segment of the final
executable.

However, the iOS dyld linker does not allow unmapped segments, so
use the presence of the LC_VERSION_MIN_IPHONEOS linker command to
skip DWARF combining. Note that we can't use GOARCH for detection
since the iOS emulator runs on  GOARCH=386 and GOARCH=amd64 and we
will run into https://golang.org/issues/25148.

Updates #25148.

Change-Id: I29a1bc468fdee74ab3b27c46931501a0a8120c66
Reviewed-on: https://go-review.googlesource.com/111275
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
2018-05-04 15:39:02 +00:00
Lynn Boger
506d6a32ce cmd/go, cmd/link: provide meaningful error msg with ext linking on ppc64
linux/ppc64 uses the ppc64 v1 ABI which was never fully supported
by Go. (linux/ppc64le uses the ppc64 v2 ABI and that is fully
supported).

As a result if the external linker is used to build a program
on ppc64, there is a either a warning or error message that doesn't
clearly describe the problem. In the case of a warning,
a program is created that will most likely not execute since it is not
built as expected for the ppc64 dynamic linker (ld64.so.1).

To avoid confusion in these cases, error messages are now issued
if external linker is explicitly used to build the program. Note that most
buildmodes that require external linking were already flagging linux/ppc64
as unsupported except for c-archive, which has been added here.

This problem does not occur with gccgo since the ppc64 v1 ABI is
supported there.

Fixes #25079

Change-Id: I44d77a1eb9df750d499cd432b0ca4a97f0be88b2
Reviewed-on: https://go-review.googlesource.com/109915
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-04 15:05:41 +00:00
Zhou Peng
166c37a7d0 src/*.bash: remove some trailing whitespace
Change-Id: I11793daafdb69156b1dafaa80fe501fcaeeff202
Reviewed-on: https://go-review.googlesource.com/111435
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-04 14:47:49 +00:00
Elias Naur
51bda1ff08 compress/gzip: skip builder-only test on iOS
The new iOS test harness forwards environment variables to the
test program, which means that it runs builder-only tests that were
previously skipped because GO_BUILDER_NAME was missing.

Skip one such unblocked test, TestGZIPFilesHaveZeroMTimes, which
assumes a valid GOROOT.

Change-Id: I5daf0f4c1897afbeb8b1a380669a1d2aa47e764a
Reviewed-on: https://go-review.googlesource.com/111475
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-04 14:46:19 +00:00
Elias Naur
42219419ba net: skip unsupported tests on iOS
The new iOS test harness forwards environment variables, such that
tests that skipped on non-builders now run because GO_BUILDER_NAME
is set.

Skip the net tests that rely on resolv.conf being present.

Change-Id: I7875dc4252b2ab696c9aae13a9106ddf296ee8ec
Reviewed-on: https://go-review.googlesource.com/111476
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-04 14:46:05 +00:00
Elias Naur
164718ae2a misc/ios: improve detection of missing developer image
It turns out that a non-empty result from ideviceimagemounter does
not mean an image is mounted. Use ideviceimagemounter's xml output
mode to improve the check.

Also, iOS versions are reported as major.minor or major.minor.patch.
Developer images are only specific to major.minor version, so cut
off the patch number in the search, if present.

Change-Id: Ia182e6f4655b7e6aa6feb8005cd3b533535b73cd
Reviewed-on: https://go-review.googlesource.com/111235
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2018-05-04 05:47:22 +00:00
Martin Möhrmann
8c62fc0ca3 strings: fix encoding of \u0080 in map
Fix encoding of PAD (U+0080) which has the same value as utf8.RuneSelf
being incorrectly encoded as \x80 in strings.Map due to using <= instead
of a < comparison operator to check one byte encodings for utf8.

Fixes #25242

Change-Id: Ib6c7d1f425a7ba81e431b6d64009e713d94ea3bc
Reviewed-on: https://go-review.googlesource.com/111286
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-04 05:37:45 +00:00
Daniel Martí
98409a44d5 cmd/vet: better align print warnings with fmt
fmt's %d, %x, and %X all accept pointer arguments. However, in cmd/vet's
printVerbs table, they were defined as if they did not accept pointer
arguments.

This inconsistency with fmt did not manifest to users since the vet
codebase worked around it. In particular, pointer arguments were usually
allowed for verbs that accepted integers, as the *types.Pointer argument
type case read the following:

	t&(argInt|argPointer) != 0

As a result, using the %q verb with a pointer resulted in a bug in
cmd/vet:

	$ go run f.go
	%!q(*int=0xc000014140)
	$ go vet f.go
	[no warning]

As documented, fmt's %q verb only accepts runes (integers), strings, and
byte slices. It should not accept pointers, and it does not. But since
vet mixed integers and pointers, it wasn't properly warning about the
misuse of fmt.

This patch surfaced another bug with fmt.Printf("%p", nil):

	$ go run f.go
	%!p(<nil>)
	$ go vet f.go
	[no warning]

As documented, fmt's %p verb only accepts pointers, and untyped nil is
not a valid pointer. But vet did not warn about it, which is another
inconsistency with fmt's documented rules. Fix that too, with a test,
also getting rid of the TODO associated with the code.

As a result of those changes, fix a wrong use of the fmt format verbs in
the standard library, now correctly spotted by vet.

Fixes #25233.

Change-Id: Id0ad31fbc25adfe1c46c6b6879b8d02b23633b3a
Reviewed-on: https://go-review.googlesource.com/111284
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-05-04 02:57:37 +00:00
Brad Fitzpatrick
17fbb83693 cmd/go, cmd/compile: use Windows response files to avoid arg length limits
Fixes #18468

Change-Id: Ic88a8daf67db949e5b59f9aa466b37e7f7890713
Reviewed-on: https://go-review.googlesource.com/110395
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-04 01:01:50 +00:00
Ian Lance Taylor
498c803c19 cmd/go, go/build: add support for gccgo tooldir
The gccgo toolchain does not put tools (cgo, vet, etc.) in
$GOROOT/pkg/tool, but instead in a directory available at
runtime.GCCGOTOOLDIR.

Update the go/build package and the cmd/go tool to use this tool
directory when using gccgo.

Change-Id: Ib827336ff53601208300aceb77f76c2e1b069859
Reviewed-on: https://go-review.googlesource.com/111097
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-04 00:46:12 +00:00
Marvin Stenger
b44ca1f3b3 cmd/go: update alldocs.go
Ran go generate in order to update docs.

Change-Id: Ideb903427d153d0ff35e5164b7e79426b83b1afb
Reviewed-on: https://go-review.googlesource.com/111336
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 23:05:32 +00:00
Sam Whited
dc4b9cffde net/http: don't write redirect body if content-type is set
Fixes #25166

Change-Id: Id1fe18899579365519ac08ebedf74cd23c0fbd9f
Reviewed-on: https://go-review.googlesource.com/110296
Run-TryBot: Sam Whited <sam@samwhited.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 23:05:07 +00:00
Matthew Dempsky
6f7fa68b91 cmd: re-generate SymKind.String for SDWARFMISC
SDWARFMISC was added in golang.org/cl/93664.

Change-Id: Ifab0a5effd8e64a2b7916004aa35d51030f23d15
Reviewed-on: https://go-review.googlesource.com/111261
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-03 21:52:05 +00:00
Josh Bleecher Snyder
e3beabdb8f cmd/compile: regenerate ssa ops
Must have been missed in a previous CL.

Change-Id: I303736e82585be8d58b330235c76ed4b24a92952
Reviewed-on: https://go-review.googlesource.com/111259
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 21:42:18 +00:00
Cherry Zhang
14f929af91 runtime/internal/atomic: improve ARM atomics
This is a follow-up of CL 93637. There, when we redirect sync/atomic
to runtime/internal/atomic, a few good implementations of ARM atomics
were lost. This CL brings most of them back, with some improvements.

- Change atomic Store to a plain store with memory barrier, as we
  already changed atomic Load to plain load with memory barrier.

- Use native 64-bit atomics on ARMv7, jump to Go implementations
  on older machines. But drop the kernel helper. In particular,
  for Load64, just do loads, not using Cas on the address being
  load from, so it works also for read-only memory (since we have
  already fixed 32-bit Load).

Change-Id: I725cd65cf945ae5200db81a35be3f251c9f7af14
Reviewed-on: https://go-review.googlesource.com/111315
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-05-03 21:37:31 +00:00
Cherry Zhang
150b728675 runtime: use native CAS and memory barrier on ARMv7
This gets us around the kernel helpers on ARMv7.

It is slightly faster than using the kernel helper.

name           old time/op  new time/op  delta
AtomicLoad-4   72.5ns ± 0%  69.5ns ± 0%  -4.08%  (p=0.000 n=9+9)
AtomicStore-4  57.6ns ± 1%  54.4ns ± 0%  -5.58%  (p=0.000 n=10+9)
[Geo mean]     64.6ns       61.5ns       -4.83%

If performance is really critical, we can even do compiler intrinsics
on GOARM=7.

Fixes #23792.

Change-Id: I36497d880890b26bdf01e048b542bd5fd7b17d23
Reviewed-on: https://go-review.googlesource.com/94076
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-05-03 21:35:39 +00:00
Cherry Zhang
1b6fec862c sync/atomic: redirect many functions to runtime/internal/atomic
The implementation of atomics are inherently tricky. It would
be good to have them implemented in a single place, instead of
multiple copies.

Mostly a simple redirect.

On 386, some functions in sync/atomic have better implementations,
which are moved to runtime/internal/atomic.

On ARM, some functions in sync/atomic have better implementations.
They are dropped by this CL, but restored with an improved
version in a follow-up CL. On linux/arm, 64-bit CAS kernel helper
is dropped, as we're trying to move away from kernel helpers.

Fixes #23778.

Change-Id: Icb9e1039acc92adbb2a371c34baaf0b79551c3ea
Reviewed-on: https://go-review.googlesource.com/93637
Reviewed-by: Austin Clements <austin@google.com>
2018-05-03 21:35:01 +00:00
Josh Bleecher Snyder
4a1baf8bd1 cmd/compile: optimize a - b == 0 into a == b
These rules trigger 1141 times during make.bash.

Shrinks a few object files a tiny bit:

name        old object-bytes  new object-bytes  delta
Template          476kB ± 0%        476kB ± 0%  +0.00%  (p=0.008 n=5+5)
Unicode           218kB ± 0%        218kB ± 0%    ~     (all equal)
GoTypes          1.58MB ± 0%       1.58MB ± 0%    ~     (all equal)
Compiler         6.25MB ± 0%       6.25MB ± 0%  -0.00%  (p=0.008 n=5+5)
Flate             304kB ± 0%        304kB ± 0%  -0.01%  (p=0.008 n=5+5)
GoParser          370kB ± 0%        370kB ± 0%    ~     (all equal)
Reflect          1.27MB ± 0%       1.27MB ± 0%    ~     (all equal)
Tar               421kB ± 0%        421kB ± 0%  -0.05%  (p=0.008 n=5+5)
XML               518kB ± 0%        518kB ± 0%    ~     (all equal)

archive/tar benchmarks:

name             old time/op    new time/op    delta
/Writer/USTAR-8    3.97µs ± 1%    3.88µs ± 0%  -2.26%  (p=0.000 n=26+26)
/Writer/GNU-8      4.67µs ± 0%    4.54µs ± 1%  -2.72%  (p=0.000 n=28+27)
/Writer/PAX-8      8.20µs ± 0%    8.01µs ± 0%  -2.32%  (p=0.000 n=29+29)
/Reader/USTAR-8    3.61µs ± 0%    3.54µs ± 1%  -2.04%  (p=0.000 n=25+28)
/Reader/GNU-8      2.27µs ± 2%    2.17µs ± 0%  -4.08%  (p=0.000 n=30+28)
/Reader/PAX-8      7.75µs ± 0%    7.63µs ± 0%  -1.60%  (p=0.000 n=28+28)
[Geo mean]         4.61µs         4.50µs       -2.51%

Change-Id: Ib4dfade5069a7463ccaba073ea91c8213e9714a0
Reviewed-on: https://go-review.googlesource.com/110235
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ilya Tocar <ilya.tocar@intel.com>
Reviewed-by: Keith Randall <khr@golang.org>
2018-05-03 20:35:21 +00:00
Ben Shi
fc48dcb15f cmd/internal/obj/arm64: add more atomic instructions
More atomic instructions were introduced in ARMv8.1. And this CL
adds support for them and corresponding test cases.

LDADD Rs, (Rb), Rt: (Rb) -> Rt, Rs+(Rb) -> (Rb)
LDAND Rs, (Rb), Rt: (Rb) -> Rt, Rs&(Rb) -> (Rb)
LDEOR Rs, (Rb), Rt: (Rb) -> Rt, Rs^(Rb) -> (Rb)
LDOR  Rs, (Rb), Rt: (Rb) -> Rt, Rs|(Rb) -> (Rb)

Change-Id: Ifb9df86583c4dc54fb96274852c3b93a197045e4
Reviewed-on: https://go-review.googlesource.com/110535
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-03 20:27:05 +00:00
Marvin Stenger
3c0bf181b7 strconv: simplify and optimize Itoa(small)
Use substring of digits for values < 10.

name                 old time/op  new time/op  delta
FormatIntSmall/7-4   4.54ns ± 1%  3.70ns ± 1%  -18.41%  (p=0.000 n=18+17)
FormatIntSmall/42-4  4.54ns ± 1%  4.13ns ± 1%   -9.02%  (p=0.000 n=16+18)

Change-Id: I0b521b563c13ef88aa2701049fa4a43760e884af
Reviewed-on: https://go-review.googlesource.com/111285
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-03 18:07:02 +00:00
Richard Musiol
63756e0c8f crypto/rand, crypto/x509: add js/wasm architecture
This commit adds the js/wasm architecture to the crypto packages.

Updates #18892

Change-Id: Id41a9d54920746d5019cbeedcff1b83874f2ef73
Reviewed-on: https://go-review.googlesource.com/110095
Reviewed-by: Austin Clements <austin@google.com>
2018-05-03 18:00:24 +00:00
Richard Musiol
7b83636800 syscall/js: add package
This commit adds the syscall/js package, which is used by the wasm
architecture to access the WebAssembly host environment (and the
operating system through it). Currently, web browsers and Node.js
are supported hosts, which is why the API is based on JavaScript APIs.
There is no common API standardized in the WebAssembly ecosystem yet.

This package is experimental. Its current scope is only to allow
tests to run, but not yet to provide a comprehensive API for users.

Updates #18892

Change-Id: I236ea10a70d95cdd50562212f2c18c3db5009230
Reviewed-on: https://go-review.googlesource.com/109195
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 18:00:07 +00:00
Josh Bleecher Snyder
1e27e4807b cmd/compile: shrink liveness maps
The GC maps don't care about trailing non-pointers in args.
Work harder to eliminate them.

This should provide a slight speedup to everything that reads these
maps, mainly GC and stack copying.

The non-ptr-y runtime benchmarks happen to go from having a non-empty
args map to an empty args map, so they have a significant speedup.

name                old time/op  new time/op  delta
StackCopyPtr-8      80.2ms ± 4%  79.7ms ± 2%  -0.63%  (p=0.001 n=94+91)
StackCopy-8         63.3ms ± 3%  59.2ms ± 3%  -6.45%  (p=0.000 n=98+97)
StackCopyNoCache-8   107ms ± 3%    98ms ± 3%  -8.00%  (p=0.000 n=95+88)

It also shrinks object files a tiny bit:

name        old object-bytes  new object-bytes  delta
Template          476kB ± 0%        476kB ± 0%  -0.03%  (p=0.008 n=5+5)
Unicode           218kB ± 0%        218kB ± 0%  -0.09%  (p=0.008 n=5+5)
GoTypes          1.58MB ± 0%       1.58MB ± 0%  -0.03%  (p=0.008 n=5+5)
Compiler         6.25MB ± 0%       6.24MB ± 0%  -0.06%  (p=0.008 n=5+5)
SSA              15.9MB ± 0%       15.9MB ± 0%  -0.06%  (p=0.008 n=5+5)
Flate             304kB ± 0%        303kB ± 0%  -0.29%  (p=0.008 n=5+5)
GoParser          370kB ± 0%        370kB ± 0%  +0.02%  (p=0.008 n=5+5)
Reflect          1.27MB ± 0%       1.27MB ± 0%  -0.07%  (p=0.008 n=5+5)
Tar               421kB ± 0%        421kB ± 0%  -0.05%  (p=0.008 n=5+5)
XML               518kB ± 0%        517kB ± 0%  -0.06%  (p=0.008 n=5+5)
[Geo mean]        934kB             933kB       -0.07%

Note that some object files do grow;
this can happen because some maps that were
duplicates of each others must be stored separately.

Change-Id: Ie076891bd8e9d269ff2ff5435d5d25c721e0e31d
Reviewed-on: https://go-review.googlesource.com/104175
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
2018-05-03 17:31:29 +00:00
Josh Bleecher Snyder
4d7cf3fedb runtime: convert g.waitreason from string to uint8
Every time I poke at #14921, the g.waitreason string
pointer writes show up.

They're not particularly important performance-wise,
but it'd be nice to clear the noise away.

And it does open up a few extra bytes in the g struct
for some future use.

This is a re-roll of CL 99078, which was rolled
back because of failures on s390x.
Those failures were apparently due to an old version of gdb.

Change-Id: Icc2c12f449b2934063fd61e272e06237625ed589
Reviewed-on: https://go-review.googlesource.com/111256
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
2018-05-03 17:04:22 +00:00
Elias Naur
4704149e04 misc/ios: retry lldb launch if the iOS app is busy
Sometimes, a newly installed the test app is not ready to launch
or the reported app path is stale. Pause and retry the launch if
the lldb script did not run the program.

Change-Id: Ic7745d4b5a02f2e3cb8134341859039812f65a65
Reviewed-on: https://go-review.googlesource.com/111216
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 15:23:13 +00:00
Elias Naur
64f715beb6 misc/ios: clean up debugger instance on failure
Also replace repeated `or` clauses with the Python idiomatic list
operator `in`.

Change-Id: I4b178f93eb92996d8b5449ee5d252543624aed9e
Reviewed-on: https://go-review.googlesource.com/111215
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 15:15:27 +00:00
Elias Naur
8b9ecbf374 misc/ios: ensure deferred cleanup functions are run even on error
log.Fatal exits the process and doesn't allow deferred functions
to run. Extract log.Fatal calls to main where all deferred functions
have completed.

For the iOS builder.

Change-Id: Id1ef9955bed19944a819d6137a611d6ecbe624a6
Reviewed-on: https://go-review.googlesource.com/110955
Run-TryBot: Elias Naur <elias.naur@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 15:15:12 +00:00
Elias Naur
78cb5d7a68 misc/ios: retry app install
Sometimes ideviceinstaller fails to install the app. Retry a few
times before giving up.

For the iOS builder.

Change-Id: Ib066ffd4f97ae8d22c0fa9a78ea4d04f67c17410
Reviewed-on: https://go-review.googlesource.com/111055
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-03 07:45:46 +00:00
Antonin Amand
7b451dc715 archive/zip: avoid data descriptor when writing directories
Java fails to unzip archives created by archive/zip because directories are
written with the "data descriptor" flag (bit 3) set, but emits no such
descriptor. To fix this, we explicitly clear the flag.

Fixes #25215

Change-Id: Id3af4c7f863758197063df879717c1710f86c0e5
Reviewed-on: https://go-review.googlesource.com/110795
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-02 23:34:50 +00:00
Elias Naur
8cd0094b4e misc/ios: don't override TMPDIR on idevice
If TMPDIR is not set, the iOS runtime will automatically set TMPDIR
to a valid app temporary path.

For the iOS builders.

Change-Id: Ia82404059dcb10678f0a6e0c96d5efc79a5485fd
Reviewed-on: https://go-review.googlesource.com/110956
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-02 19:44:38 +00:00
Robert Griesemer
28b40f3528 go/types: add doc strings to various undocumented exported objects
Fixes #22747.

Change-Id: I498cb29f18bd9b59b13dc2ddc3a613cc12ac2a14
Reviewed-on: https://go-review.googlesource.com/110975
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2018-05-02 18:42:09 +00:00
Fangming.Fang
e8d417d272 runtime: enable memory sanitizer on arm64
Changes include:
1. open compilation option -msan for arm64
2. modify doc to explain -msan is also supported on linux/arm64
3. wrap msan lib API in msan_arm64.s
4. use libc for sigaction syscalls when cgo is enabled
5. use libc for mmap syscalls when cgo is enabled

Change-Id: I26ebe61ff7ce1906125f54a0182a720f9d58ec11
Reviewed-on: https://go-review.googlesource.com/109255
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-02 17:52:14 +00:00
Anmol Sethi
eff1e68528 testing: fix racey access to t.failed
We need to grab the mutex before we can access it.

Fixes #24438

Change-Id: Idd6130036691acec5bc5f8b40d6884f8db1d9d3c
Reviewed-on: https://go-review.googlesource.com/101283
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-02 17:51:26 +00:00
Robert Griesemer
0dcdbc772e go/types: fix internal documentation and strengthen assumptions
Imported (incl. dot-imported) objects are always in file scope,
never in package scope. Fix misleading comment.

Package-scope declared objects must have objMap entry by
construction (of that map). Remove unnecessary check and
corresponding misleading comment.

Found while investigating solutions for @23203.

Change-Id: Idadfdd1576681ae56e11daa27bdcee2c73733c41
Reviewed-on: https://go-review.googlesource.com/110916
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2018-05-02 17:36:17 +00:00