1
0
mirror of https://github.com/golang/go synced 2024-11-13 15:50:22 -07:00
Commit Graph

40562 Commits

Author SHA1 Message Date
Ian Lance Taylor
1531192272 runtime: remove VDSO fallback test and benchmarks
These tests assume that it is OK to switch between time implementations,
but the clock_gettime call uses CLOCK_MONOTONIC and the fallback call,
gettimeofday, uses CLOCK_REALTIME. Disabling the clock_gettime call means
that calls to nanotime will start returning very different values.
This breaks the new timer code, which assumes that nanotime will return
a consistently increasing value.

This test is not very useful in any case as it doesn't check the results.

Removing this file also removes BenchmarkTimeNow, which is a duplicate
of BenchmarkNow in the time package.

Updates #27707
Fixes #32109

Change-Id: I6a884af07f75822d724193c5eed94742f524f07d
Reviewed-on: https://go-review.googlesource.com/c/go/+/174679
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-27 17:58:39 +00:00
Agniva De Sarker
d97bd5d07a cmd/doc: display a proper error when no packages are found
Fixes #32044

Change-Id: Ia220dbbe4d6851befe28dd2d4b8a1a7bc2757460
Reviewed-on: https://go-review.googlesource.com/c/go/+/178878
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2019-05-25 22:38:01 +00:00
Than McIntosh
a3863fc18a cmd/link: fix incorrect constant for macho-o load command
The constant defined in macho.go for LC_LOAD_WEAK_DYLIB was
not correct, was 0x18 should have been 0x80000018. Switch
to the correct definition.

Fixes #32233.

Change-Id: I9fb660a3cfd5e8c451a64947258f7ead76d98c79
Reviewed-on: https://go-review.googlesource.com/c/go/+/178723
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
2019-05-25 12:54:34 +00:00
Russ Cox
385b2e0cac cmd/go: respect default proxy setting, add direct fallback
Getenv("GOPROXY") says what the environment variable is
(including looking in the go env file), but it doesn't include
the default setting. This code needs to use cfg.GOPROXY
to get the actual default. Fix and test that.

Also, we forgot to include the fallback to direct for when
the proxy serves a 404. Add and test that too.

Also add HTTP fetch information to -x build flag output.
(It does not belong in the -v output, despite the GOPATH go get
command doing this.)

Change-Id: Ieab7ef13cda3e1ad041dbe04921af206e2232c9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/178720
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2019-05-24 21:34:53 +00:00
Bryan C. Mills
c7385e2704 cmd/go: when resolving packages, try all module paths before falling back to the next proxy
Since we're mucking with error-propagation in modload.Query* anyway,
simplify the classification logic. Ensure that “module not found”
errors are reported as such in various places, since non-“not found”
errors terminate the module search.

Fixes #31785

Change-Id: Ie3ca5f4eec10a5f2a6037ec7e1c2cf47bd37a232
Reviewed-on: https://go-review.googlesource.com/c/go/+/177958
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2019-05-24 21:34:43 +00:00
Cherry Zhang
496b8dbbfc cmd, runtime: remove PC_F & PC_B globals on Wasm
Following the previous CL, this removes more global variables on
Wasm.

PC_B is used mostly for intra-function jumps, and for a function
telling its callee where to start or resume. This usage can be
served by a parameter. The top level loop (wasm_pc_f_loop) uses
PC_B for resuming a function. This value is either set by gogo,
or loaded from the Go stack at function return. Instead of
loading PC_B at each function return, we could make gogo stores
PC_B at the same stack location, and let the top level loop do
the load. This way, we don't need to use global PC_B to
communicate with the top level loop, and we can replace global
PC_B with a parameter.

PC_F is similar. It is even more so in that the only reader is
the top level loop. Let the top level loop read it from the stack,
and we can get rid of PC_F entirely.

PC_F and PC_B are used less entensively as SP, so this CL has
smaller performance gain.

Running on Chrome 74.0.3729.108 on Linux/AMD64,

name                   old time/op    new time/op    delta
BinaryTree17              16.6s ± 0%     16.2s ± 1%   -2.59%  (p=0.016 n=4+5)
Fannkuch11                11.1s ± 1%     10.8s ± 0%   -2.65%  (p=0.008 n=5+5)
FmtFprintfEmpty           231ns ± 1%     217ns ± 0%   -6.06%  (p=0.008 n=5+5)
FmtFprintfString          407ns ± 3%     375ns ± 2%   -7.81%  (p=0.008 n=5+5)
FmtFprintfInt             466ns ± 2%     430ns ± 0%   -7.79%  (p=0.016 n=5+4)
FmtFprintfIntInt          719ns ± 2%     673ns ± 2%   -6.37%  (p=0.008 n=5+5)
FmtFprintfPrefixedInt     706ns ± 1%     676ns ± 3%   -4.31%  (p=0.008 n=5+5)
FmtFprintfFloat          1.01µs ± 1%    0.97µs ± 1%   -4.30%  (p=0.008 n=5+5)
FmtManyArgs              2.67µs ± 1%    2.51µs ± 1%   -5.95%  (p=0.008 n=5+5)
GobDecode                30.7ms ± 9%    31.3ms ±34%     ~     (p=0.222 n=5+5)
GobEncode                24.2ms ±23%    20.2ms ± 0%  -16.36%  (p=0.016 n=5+4)
Gzip                      852ms ± 0%     823ms ± 0%   -3.38%  (p=0.016 n=4+5)
Gunzip                    160ms ± 1%     151ms ± 1%   -5.37%  (p=0.008 n=5+5)
JSONEncode               35.7ms ± 1%    34.3ms ± 1%   -3.81%  (p=0.008 n=5+5)
JSONDecode                247ms ± 8%     254ms ± 7%     ~     (p=0.548 n=5+5)
Mandelbrot200            5.39ms ± 0%    5.41ms ± 0%   +0.42%  (p=0.008 n=5+5)
GoParse                  18.5ms ± 1%    18.3ms ± 2%     ~     (p=0.343 n=4+4)
RegexpMatchEasy0_32       424ns ± 2%     397ns ± 0%   -6.23%  (p=0.008 n=5+5)
RegexpMatchEasy0_1K      2.88µs ± 0%    2.86µs ± 1%     ~     (p=0.079 n=5+5)
RegexpMatchEasy1_32       395ns ± 2%     370ns ± 1%   -6.23%  (p=0.008 n=5+5)
RegexpMatchEasy1_1K      3.26µs ± 0%    3.19µs ± 1%   -2.06%  (p=0.008 n=5+5)
RegexpMatchMedium_32      564ns ± 1%     532ns ± 0%   -5.71%  (p=0.008 n=5+5)
RegexpMatchMedium_1K      146µs ± 2%     140µs ± 1%   -4.62%  (p=0.008 n=5+5)
RegexpMatchHard_32       8.47µs ± 1%    7.91µs ± 1%   -6.65%  (p=0.008 n=5+5)
RegexpMatchHard_1K        253µs ± 1%     236µs ± 2%   -6.66%  (p=0.008 n=5+5)
Revcomp                   1.78s ± 4%     1.76s ± 5%     ~     (p=1.000 n=5+5)
Template                  292ms ±29%     269ms ± 5%     ~     (p=0.690 n=5+5)
TimeParse                1.61µs ± 4%    1.54µs ± 1%   -4.42%  (p=0.008 n=5+5)
TimeFormat               1.66µs ± 3%    1.58µs ± 1%   -5.22%  (p=0.008 n=5+5)
[Geo mean]                232µs          221µs        -4.54%

name                   old speed      new speed      delta
GobDecode              25.0MB/s ± 8%  25.1MB/s ±27%     ~     (p=0.222 n=5+5)
GobEncode              32.8MB/s ±21%  38.0MB/s ± 0%  +15.84%  (p=0.016 n=5+4)
Gzip                   22.8MB/s ± 0%  23.6MB/s ± 0%   +3.49%  (p=0.016 n=4+5)
Gunzip                  121MB/s ± 1%   128MB/s ± 1%   +5.68%  (p=0.008 n=5+5)
JSONEncode             54.4MB/s ± 1%  56.5MB/s ± 1%   +3.97%  (p=0.008 n=5+5)
JSONDecode             7.88MB/s ± 8%  7.65MB/s ± 8%     ~     (p=0.548 n=5+5)
GoParse                3.07MB/s ± 8%  3.00MB/s ±22%     ~     (p=0.579 n=5+5)
RegexpMatchEasy0_32    75.6MB/s ± 2%  80.5MB/s ± 0%   +6.58%  (p=0.008 n=5+5)
RegexpMatchEasy0_1K     356MB/s ± 0%   358MB/s ± 1%     ~     (p=0.095 n=5+5)
RegexpMatchEasy1_32    81.1MB/s ± 2%  86.5MB/s ± 1%   +6.69%  (p=0.008 n=5+5)
RegexpMatchEasy1_1K     314MB/s ± 0%   320MB/s ± 0%   +2.10%  (p=0.008 n=5+5)
RegexpMatchMedium_32   1.77MB/s ± 1%  1.88MB/s ± 0%   +6.09%  (p=0.016 n=5+4)
RegexpMatchMedium_1K   6.99MB/s ± 2%  7.33MB/s ± 1%   +4.83%  (p=0.008 n=5+5)
RegexpMatchHard_32     3.78MB/s ± 1%  4.04MB/s ± 1%   +7.04%  (p=0.008 n=5+5)
RegexpMatchHard_1K     4.04MB/s ± 1%  4.33MB/s ± 2%   +7.17%  (p=0.008 n=5+5)
Revcomp                 143MB/s ± 4%   145MB/s ± 5%     ~     (p=1.000 n=5+5)
Template               6.77MB/s ±24%  7.22MB/s ± 5%     ~     (p=0.690 n=5+5)
[Geo mean]             24.4MB/s       25.4MB/s        +4.18%

Change-Id: Ib80716e62992aec28b2c4a96af280c278f83aa49
Reviewed-on: https://go-review.googlesource.com/c/go/+/173980
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
2019-05-24 17:41:56 +00:00
Michael Anthony Knyszek
7ed7669c0d runtime: ensure mheap lock stack growth invariant is maintained
Currently there's an invariant in the runtime wherein the heap lock
can only be acquired on the system stack, otherwise a self-deadlock
could occur if the stack grows while the lock is held.

This invariant is upheld and documented in a number of situations (e.g.
allocManual, freeManual) but there are other places where the invariant
is either not maintained at all which risks self-deadlock (e.g.
setGCPercent, gcResetMarkState, allocmcache) or is maintained but
undocumented (e.g. gcSweep, readGCStats_m).

This change adds go:systemstack to any function that acquires the heap
lock or adds a systemstack(func() { ... }) around the critical section,
where appropriate. It also documents the invariant on (*mheap).lock
directly and updates repetitive documentation to refer to that comment.

Fixes #32105.

Change-Id: I702b1290709c118b837389c78efde25c51a2cafb
Reviewed-on: https://go-review.googlesource.com/c/go/+/177857
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2019-05-24 15:34:57 +00:00
Martin Sucha
db3255536c strings: clarify example of ContainsAny
I have seen code that literally copied the example like this:

    if strings.ContainsAny(s, "1 & 2 & 3") {

The developer apparently thought that this is the way to
specify multiple characters and I noticed this pattern
being used in the example. Let's update the example so
that it's clear how multiple Unicode code points should
be specified.

Change-Id: Id4d780555e521af62fb787a7950be1e60848cd95
Reviewed-on: https://go-review.googlesource.com/c/go/+/178737
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-24 15:23:08 +00:00
Leon Klingele
cd0f5f39b7 image/draw: change argument type to be consistent with other args
Change-Id: Ic5b01c0a6912d87e812331d6525939df8f525cca
GitHub-Last-Rev: b6ffefcf8f
GitHub-Pull-Request: golang/go#29993
Reviewed-on: https://go-review.googlesource.com/c/go/+/160417
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-24 15:22:14 +00:00
Hana (Hyang-Ah) Kim
46fd677069 cmd/vendor: sync github.com/google/pprof@v0.0.0-20190515194954-54271f7e092f
Change-Id: If001d8f7e657e01711653827a170904932839e34
Reviewed-on: https://go-review.googlesource.com/c/go/+/178721
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-24 15:18:01 +00:00
Leon Klingele
fc58acbe5c compress/gzip: add missing error check in test
Change-Id: Ib7be503a46f3609ea29464569e57e1f620e97a53
GitHub-Last-Rev: a43cffe45f
GitHub-Pull-Request: golang/go#30007
Reviewed-on: https://go-review.googlesource.com/c/go/+/160431
Run-TryBot: Leon Klingele <git@leonklingele.de>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-24 14:55:39 +00:00
Richard Musiol
c468ad0417 syscall/js: replace TypedArrayOf with CopyBytesToGo/CopyBytesToJS
The typed arrays returned by TypedArrayOf were backed by WebAssembly
memory. They became invalid each time we grow the WebAssembly memory.
This made them very error prone and hard to use correctly.

This change removes TypedArrayOf completely and instead introduces
CopyBytesToGo and CopyBytesToJS for copying bytes between a byte
slice and an Uint8Array. This breaking change is still allowed for
the syscall/js package.

Fixes #31980.
Fixes #31812.

Change-Id: I14c76fdd60b48dd517c1593972a56d04965cb272
Reviewed-on: https://go-review.googlesource.com/c/go/+/177537
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-24 09:38:37 +00:00
bill_ofarrell
7e5bc4775f crypto/ecdsa: implement ecdsa on s390x for P256/P384/P521 using KDSA instruction
Utilize KDSA when available. This guarantees constant time operation on all three curves mentioned,
and is faster than conventional assembly. The IBM Z model(s) that support KDSA as used in this CL
are not yet publicly available, and so we are unable to release performance data at this time.

Change-Id: I85360dcf90fe42d2bf32afe3f638e282de10a518
Reviewed-on: https://go-review.googlesource.com/c/go/+/174437
Run-TryBot: Michael Munday <mike.munday@ibm.com>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
2019-05-24 08:16:32 +00:00
Brad Fitzpatrick
b84e0bc61a SECURITY.md: add security file
This is now recognized and recommended by GitHub.

Fixes #32201

Change-Id: Iafb5ef1b2bee5f021a711b0b758aaf6a74758c5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/178697
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-23 21:22:44 +00:00
Brad Fitzpatrick
ef2f41785b test: skip a test on failing test on nacl/386
This test was designed for #15609 and didn't consider nacl. It's not
worth adding new +build-guarded assembly files in issue15609.dir for
nacl, especially as nacl is going away.

Fixes #32206

Change-Id: Ic5bd48b4f790a1f7019100b8a72d4688df75512f
Reviewed-on: https://go-review.googlesource.com/c/go/+/178698
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-23 20:48:20 +00:00
Michael McLoughlin
3ce865d7a0 crypto/sha*: replace putUint{32,64} helpers
Replaces putUint{32,64} functions in crypto/sha* packages with the
equivalent functions encoding/binary.BigEndian.PutUint{32,64}.

Change-Id: I9208d2125202ea9c97777560e6917d21893aced0
Reviewed-on: https://go-review.googlesource.com/c/go/+/156117
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-23 16:16:26 +00:00
Leon Klingele
2500ac20c0 image: add missing error check in test
Change-Id: Ia42a4a658e4207cc1f036f2faeac011e71edad77
GitHub-Last-Rev: b384f81799
GitHub-Pull-Request: golang/go#30012
Reviewed-on: https://go-review.googlesource.com/c/go/+/160436
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-23 15:51:48 +00:00
andrius4669
0ac4ea79f7 mime: encode CTL and non-US-ASCII characters in FormatMediaType
Encodes non-WSP CTL and non-US-ASCII UTF-8 characters using syntax specified in RFC 2231.

Fixes #7668
Fixes #9624

Change-Id: I433f167c5bdd84a7f811ac0410b08b10790e0d9f
GitHub-Last-Rev: 9c77146760
GitHub-Pull-Request: golang/go#29328
Reviewed-on: https://go-review.googlesource.com/c/go/+/154760
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-23 15:45:00 +00:00
Caleb Spare
05092163bb strconv: fix rounding in FormatFloat fallback path
Float formatting uses a multiprecision fallback path where Grisu3
algorithm fails. This has a bug during the rounding phase: the
difference between the decimal value and the upper bound is examined
byte-by-byte and doesn't properly handle the case where the first
divergence has a difference of 1.

For instance (using an example from #29491), for the number
498484681984085570, roundShortest examines the three decimal values:

lower: 498484681984085536
d:     498484681984085568
upper: 498484681984085600

After examining the 16th digit, we know that rounding d up will fall
within the bounds unless all remaining digits of d are 9 and all
remaining digits of upper are 0:

d:     ...855xx
upper: ...856xx

However, the loop forgets that d and upper have already diverged and
then on the next iteration sees that the 17th digit of d is actually
lower than the 17th digit of upper and decides that we still can't round
up:

d:     ...8556x
upper: ...8560x

Thus the original value is incorrectly rounded down to
498484681984085560 instead of the closer (and equally short)
498484681984085570.

Thanks to Brian Kessler for diagnosing this bug.

Fix it by remembering when we've seen divergence in previous digits.

This CL also fixes another bug in the same loop: for some inputs, the
decimal value d or the lower bound may have fewer digits than the upper
bound, yet the iteration through the digits starts at i=0 for each of
them. For instance, given the float64 value 1e23, we have

d:      99999999999999991611392
upper: 100000000000000000000000

but the loop starts by comparing '9' to '1' rather than '0' to '1'.

I haven't found any cases where this second bug causes incorrect output
because when the digit comparison fails on the first loop iteration the
upper bound always has more nonzero digits (i.e., the expression
'i+1 < upper.nd' is always true).

Fixes #29491

Change-Id: I58856a7a2e47935ec2f233d9f717ef15c78bb2d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/157697
Run-TryBot: Caleb Spare <cespare@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rémy Oudompheng <remyoudompheng@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-23 15:41:19 +00:00
Russ Cox
f8a5ba2a38 cmd/go: default to GOPROXY=https://proxy.golang.org and GOSUMDB=sum.golang.org
This CL changes the default module download and module verification mechanisms
to use the Go module mirror and Go checksum database run by Google.
See https://proxy.golang.org/privacy for the services' privacy policy.
(Today, that URL is a redirect to Google's standard privacy policy,
which covers these services as well. If we publish a more specific
privacy policy just for these services, that URL will be updated to
display or redirect to it.)

See 'go help modules' and 'go help modules-auth' for details (added in this CL).

To disable the mirror and checksum database for non-public modules:

	go env -w GONOPROXY=*.private.net,your.com/*
	go env -w GONOSUMDB=*.private.net,your.com/*

(If you are using a private module proxy then you'd only do the second.)

If you run into problems with the behavior of the go command when using
the Go module mirror or the Go checksum database, please file issues at
https://golang.org/issue/new, so that we can address them for the
Go 1.13 release.

For #25530.

This CL also documents GONOPROXY.
Fixes #32056.

Change-Id: I2fde82e071742272b0842efd9580df1a56947fec
Reviewed-on: https://go-review.googlesource.com/c/go/+/178179
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-05-23 14:36:02 +00:00
Mickey Reiss
4fbb4e74aa bufio: Fix typo in scan.go documentation
Apologies for the the nitpicky PR. I believe there is a minor typo in the documentation of `MaxScanTokenSize`, which confused me for a moment when I went to search for the referenced method, `Scan.Buffer`. Thanks!

Change-Id: I5d21e77276285206497fe75291001032c255cace
GitHub-Last-Rev: 635e35c019
GitHub-Pull-Request: golang/go#32193
Reviewed-on: https://go-review.googlesource.com/c/go/+/178637
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-23 13:55:55 +00:00
Agniva De Sarker
65ef999d52 cmd/doc: stop showing interface methods while matching symbols
Fixes #31961

Change-Id: I9db9ecfd2f8ca7cf51df4413a6e0d66de5da7043
Reviewed-on: https://go-review.googlesource.com/c/go/+/178457
Run-TryBot: Agniva De Sarker <agniva.quicksilver@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2019-05-23 09:19:03 +00:00
Ariel Mashraki
e2970a4591 text/template: add a slice function to the predefined global functions
The new slice function returns the result of slicing its first argument by
the following arguments. Thus {{slice x 1 3}} is, in Go syntax, x[1:3].
Each sliced item must be a string, slice, or array.

Closed #30153

RELNOTE=yes

Change-Id: I63188c422848cee3d383a64dc4d046e3a1767c63
Reviewed-on: https://go-review.googlesource.com/c/go/+/161762
Reviewed-by: Rob Pike <r@golang.org>
2019-05-23 08:01:24 +00:00
Martin Möhrmann
6f51082da7 fmt: always clear wrapErrs
Like panicking and erroring - wrapErrs should always be reset to
the default false. wrapErrs should only be true when set by Errorf.

Change-Id: I4d51cc2f0905109e232b0983dc5331bd34f138bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/178517
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2019-05-23 06:16:38 +00:00
LE Manh Cuong
3e9d8e2e1b test/fixedbugs: fix some tests will not be run
Currently, some tests under test/fixedbugs never run:

	$ for d in test/fixedbugs/*.dir; do
	  ! test -f "${d%.dir}.go" && echo "$d"
	done
	test/fixedbugs/issue15071.dir
	test/fixedbugs/issue15609.dir
	test/fixedbugs/issue29612.dir

Because they missed the corresponding ".go" file, so "go run run.go"
will skip them.

Add missing ".go" files for those tests to make sure they will be
collected and run.

While at it, add another action "runindir", which does "go run ."
inside the t.goDirName then check the output.

Change-Id: I88000b3663a6a615d90c1cf11844ea0377403e3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/177798
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-23 01:39:41 +00:00
Brad Fitzpatrick
7a567a631f cmd/dist: support using cross-compiled std test binaries for slow builders
We want the builders to be able to cross-compile test binaries for a
few of the super slow builders that require either slow hardware or
slow full CPU emulation.

Updates golang/go#31217

Change-Id: I8d33b18efaf788f6f131354b2917ac9738ca975e
Reviewed-on: https://go-review.googlesource.com/c/go/+/178399
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-23 01:38:26 +00:00
Leon Klingele
d307bd4ede encoding/gob: properly ignore errors
Change-Id: I8827cef0f57459384329c50c51795350da0ede4b
GitHub-Last-Rev: c9ad9e12b5
GitHub-Pull-Request: golang/go#30010
Reviewed-on: https://go-review.googlesource.com/c/go/+/160434
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-05-22 20:42:35 +00:00
kawakami
983986f23d image/gif: fix transparency loss when encoding a wrapped *image.Paletted
This keeps transparency of a wrapped image.Image even after it is encoded.

Fixes #30995

Change-Id: I1f7ac98b1741f83ed740f6eda6c36b7e9b16e5af
Reviewed-on: https://go-review.googlesource.com/c/go/+/177377
Reviewed-by: Hayato Kawakami <kawakami.ozone@gmail.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-22 20:41:27 +00:00
Matthew Dempsky
94a9dad8fd cmd/compile: fix capture-by-reference of return parameters
As an optimization, function literals capture variables by value when
they're not assigned and their address has not been taken. Because
result parameters are implicitly assigned through return statements
(which do not otherwise set the "assigned" flag), result parameters
are explicitly handled to always capture by reference.

However, the logic was slightly mistaken because it was only checking
if the variable in the immediately enclosing context was a return
parameter, whereas in a multiply-nested function literal it would
itself be another closure variable (PAUTOHEAP) rather than a return
parameter (PPARAMOUT).

The fix is to simply test the outermost variable, like the rest of the
if statement's tests were already doing.

Fixes #32175.

Change-Id: Ibadde033ff89a1b47584b3f56c0014d8e5a74512
Reviewed-on: https://go-review.googlesource.com/c/go/+/178541
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2019-05-22 18:43:09 +00:00
Agniva De Sarker
a326bc6df2 net/url: clarify that RawPath is optionally set
Fixes #29662

Change-Id: I38b52b96712e44a323333da17dbbc883516773b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/177900
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-22 17:22:46 +00:00
Filippo Valsorda
42bb476893 crypto/x509: include roots with empty or multiple policies on macOS
To a fifth reading of the relevant docs, it looks like

1) a constraint dictionary with no policy applies to all of them;
2) multiple applying constraint dictionaries should have their results OR'd;
3) untrusted certificates in the keychain should be used for chain building.

This fixes 1), approximates 2) and punts on 3).

Fixes #30672
Fixes #30471

Change-Id: Ibbaabf0b77d267377c0b5de07abca3445c2c2302
Reviewed-on: https://go-review.googlesource.com/c/go/+/178539
Reviewed-by: Adam Langley <agl@golang.org>
2019-05-22 16:23:17 +00:00
Filippo Valsorda
2326a66878 crypto/x509: fix and cleanup loadSystemRoots on macOS
Note how untrustedData is never NULL, so loadSystemRoots was checking
the wrong thing.

Also, renamed the C function to CopyPEMRoots to follow the
CoreFoundation naming convention on ownership.

Finally, redirect all debug output to standard error.

Change-Id: Ie80abefadf8974a75c0646aa02fcfcebcbe3bde8
Reviewed-on: https://go-review.googlesource.com/c/go/+/178538
Reviewed-by: Adam Langley <agl@golang.org>
2019-05-22 16:20:11 +00:00
Filippo Valsorda
a3d4655c24 crypto/x509: fix value ownership in isSSLPolicy on macOS
CFDictionaryGetValueIfPresent does not take ownership of the value, so
releasing the properties dictionary before passing the value to CFEqual
can crash. Not really clear why this works most of the time.

See https://developer.apple.com/library/archive/documentation/CoreFoundation/Conceptual/CFMemoryMgmt/Concepts/Ownership.html

Fixes #28092
Hopefully fixes #30763

Change-Id: I5ee7ca276b753a48abc3aedfb78b8af68b448dd4
Reviewed-on: https://go-review.googlesource.com/c/go/+/178537
Reviewed-by: Adam Langley <agl@golang.org>
2019-05-22 16:12:45 +00:00
Russ Cox
06b0babf31 all: shorten some tests
Shorten some of the longest tests that run during all.bash.
Removes 7r 50u 21s from all.bash.

After this change, all.bash is under 5 minutes again on my laptop.

For #26473.

Change-Id: Ie0460aa935808d65460408feaed210fbaa1d5d79
Reviewed-on: https://go-review.googlesource.com/c/go/+/177559
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-22 12:54:00 +00:00
Russ Cox
b0e238add5 misc/cgo/test: consolidate tests into fewer cgo source files
Each different file that does import "C" must be compiled
and analyzed separately by cgo. Having fewer files import "C"
reduces the cost of building the test. This is especially important
because this test is built and run four different times (with different
settings) during all.bash.

go test -c in this directory used to take over 20 seconds on my laptop.
Now it takes under 5 seconds.

Removes 23.4r 29.0u 21.5s from all.bash.

For #26473.

Change-Id: Ie7cb7b0d9d6138ebd2eb548d0d8ea6e409ae10b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/177558
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-22 12:52:33 +00:00
Keith Randall
6105e8b419 runtime: revert init order changes
First, remove the randomization of initialization order.

Then, revert to source code order instead of sorted package path order.

This restores the behavior that was in 1.12.

A larger change which will implement the suggestion in #31636 will
wait for 1.14. It's too complicated for 1.13 at this point (it has
tricky interactions with plugins).

Fixes #31636

Change-Id: I35b48e8cc21cf9f93c0973edd9193d2eac197628
Reviewed-on: https://go-review.googlesource.com/c/go/+/178297
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-22 11:07:00 +00:00
Keegan Carruthers-Smith
648c7b592a regexp/syntax: exclude full range from String negation case
If the char class is 0x0-0x10ffff we mistakenly would String that to `[^]`,
which is not a valid regex.

Fixes #31807

Change-Id: I9ceeaddc28b67b8e1de12b6703bcb124cc784556
Reviewed-on: https://go-review.googlesource.com/c/go/+/175679
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-22 04:43:25 +00:00
Damien Neil
24b43013a1 errors: remove mention of Wrapper interface
The Wrapper type no longer exists.

Change-Id: I21051f26c6722a957295819f2f385f2bbd0db355
Reviewed-on: https://go-review.googlesource.com/c/go/+/177618
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-22 02:10:36 +00:00
Filippo Valsorda
41329c07f9 math/bits: document that Add, Sub, Mul, RotateLeft, ReverseBytes are constant time
Fixes #31267

Change-Id: I91e4aa8cf9d797689cb9612d0fe3bf1bb3ad15a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/178177
Reviewed-by: Keith Randall <khr@golang.org>
2019-05-21 20:15:52 +00:00
Russ Cox
02fe6ba958 all: remove PEM-encoded private keys from tests
Gerrit is complaining about pushes that affect these files
and forcing people to use -o nokeycheck, which defeats
the point of the check. Hide the keys from this kind of scan
by marking them explicitly as testing keys.

This is a little annoying but better than training everyone
who ever edits one of these test files to reflexively override
the Gerrit check.

The only remaining keys explicitly marked as private instead
of testing are in examples, and there's not much to do
about those. Hopefully they are not edited as much.

Change-Id: I4431592b5266cb39fe6a80b40e742d97da803a0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/178178
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-21 20:03:55 +00:00
Russ Cox
798e0b38ed misc/cgo/errors: consolidate test work
Build a single binary containing all the TestPointerChecks
instead of building many small binaries,
each with its own cgo+compile+link invocation.
This cuts 'go test -run=TestPointerChecks'
from 6.7r 35.5u 26.1s to 2.1r 2.1u 1.4s.

Move as many cgo checks as possible into fewer test files
for TestReportsTypeErrors too.
This cuts 'go test -run=TestReportsTypeErrors'
from 2.1r 6.7u 6.7s to 1.5r 2.5u 2.5s.

After this change, all.bash runs in ~4:30 on my laptop.

For #26473.

Change-Id: I3787448b03689a1f62dd810957ab6013bb75582f
Reviewed-on: https://go-review.googlesource.com/c/go/+/177599
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-21 18:15:05 +00:00
Russ Cox
b864818494 cmd/api: read std package info once, not per goos-goarch-cgo
Cuts api test time from 12.7r 26.2u 14.2s to 7.5r 12.1u 2.2s.

After this change, all.bash runs in ~4:36 on my laptop.

For #26473.

Change-Id: I4211e6afcd7ab61a4ed2c9a2aa5ac1ea04982695
Reviewed-on: https://go-review.googlesource.com/c/go/+/177597
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-21 18:14:40 +00:00
LE Manh Cuong
2d357d8da8 cmd/compile: fix typecheck type alias makes wrong export symbol metadata
typecheck type alias always replaces the original definition of the symbol.
This is wrong behavior because if the symbol's definition is replaced by a
local type alias, it ends up being written to compiled file as an alias,
instead of the original type.

To fix, only replace the definition of symbol with global type alias.

Fixes #31959

Change-Id: Id85a15e8a9d6a4b06727e655a95dc81e63df633a
Reviewed-on: https://go-review.googlesource.com/c/go/+/177378
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-05-21 17:44:21 +00:00
Caleb Spare
1d1ba85d99 cmd/go: teach the build cache about -trimpath
Fixes #31896

Change-Id: I228a809568cd37c599987f9f1e99df5c229e6c9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/176112
Run-TryBot: Caleb Spare <cespare@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-05-21 16:00:24 +00:00
LE Manh Cuong
d0aca5759e cmd/compile: fix doc typo in ssa.go
Change-Id: Ie299a5eca6f6a7c5a37c00ff0de7ce322450375b
Reviewed-on: https://go-review.googlesource.com/c/go/+/178123
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-21 14:19:32 +00:00
Eduard Urbach
9b2bd2f715 mime: add .webp for builtin
This change modifies Go to include image/webp as a built-in mime type for the .webp file extension.

Change-Id: Id46d34fac8cc859ddd69aa8669294815654214f8
GitHub-Last-Rev: f191e1c325
GitHub-Pull-Request: golang/go#32157
Reviewed-on: https://go-review.googlesource.com/c/go/+/178317
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-21 14:05:00 +00:00
Russ Cox
4f248e988a test: skip cross-arch codegen tests in all.bash
The test/codegen tests check all architectures
mentioned in the test file, but this requires
building at least the runtime for that architecture.
This CL changes the test to only check the local
architecture, leaving checking of other architectures
to the relevant builders, as usual.

This cuts 'go run run.go codegen' by 12r 78u 21s.

After this change, all.bash runs in ~4:40 on my laptop.

For #26473.

Change-Id: Ia0354d1aff2df2949f838528c8171410bc42dc8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/177577
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2019-05-21 12:10:31 +00:00
LE Manh Cuong
2d7cb295fd cmd/compile: clarify the difference between types.Sym and obj.LSym
Both types.Sym and obj.LSym have the field Name, and that field is
widely used in compiler source. It can lead to confusion that when to
use which one.

So, adding documentation for clarifying the difference between them,
eliminate the confusion, or at least, make the code which use them
clearer for the reader.

See https://github.com/golang/go/issues/31252#issuecomment-481929174

Change-Id: I31f7fc6e4de4cf68f67ab2e3a385a7f451c796f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/175019
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2019-05-21 03:03:01 +00:00
Jay Conrod
ab724d43ef cmd/go: make 'go get -t' consider test dependencies in module mode
Fixes #32037

Change-Id: I696fe2029e383746252f37fe8d30df71b5ac8a6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/177677
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2019-05-20 20:58:14 +00:00
adarsh ravichandran
776e1709e5 math/bits: add example for OnesCount function
Change-Id: Id87db9bed5e8715d554c1bf95c063d7d0a03c3e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/178117
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2019-05-20 18:16:09 +00:00