]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
5 years ago[dev.boringcrypto] all: merge master into dev.boringcrypto
Filippo Valsorda [Fri, 29 Jun 2018 17:16:42 +0000 (13:16 -0400)]
[dev.boringcrypto] all: merge master into dev.boringcrypto

Add a couple of skips for slow js/wasm tests.

Change-Id: Ic95256b1d3c6e5e2f0cc536fad51e914d31cda9e

5 years agocmd/compile: make OpAddr depend on VarDef in storeOrder
David Chase [Thu, 28 Jun 2018 20:22:21 +0000 (16:22 -0400)]
cmd/compile: make OpAddr depend on VarDef in storeOrder

Given a carefully constructed input, writebarrier would
split a block with the OpAddr in the first half and the
VarDef in the second half which ultimately leads to a
compiler crash because the scheduler is no longer able
to put them in the proper order.

To fix, recognize the implicit dependence of OpAddr on
the VarDef of the same symbol if any exists.

This fix was chosen over making OpAddr take a memory
operand to make the dependence explicit, because this
change is less invasive at this late part of the 1.11
release cycle.

Fixes #26105.

Change-Id: I9b65460673af3af41740ef877d2fca91acd336bc
Reviewed-on: https://go-review.googlesource.com/121436
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: check SSAability in handling of INDEX of 1-element array
Cherry Zhang [Fri, 29 Jun 2018 00:34:05 +0000 (20:34 -0400)]
cmd/compile: check SSAability in handling of INDEX of 1-element array

SSA can handle 1-element array, but only when the element type
is SSAable. When building SSA for INDEX of 1-element array, we
did not check the element type is SSAable. And when it's not,
it resulted in an unhandled SSA op.

Fixes #26120.

Change-Id: Id709996b5d9d90212f6c56d3f27eed320a4d8360
Reviewed-on: https://go-review.googlesource.com/121496
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
5 years agocmd/vet: don't run buildtag check when in vetxonly mode
Daniel Martí [Thu, 28 Jun 2018 16:18:01 +0000 (17:18 +0100)]
cmd/vet: don't run buildtag check when in vetxonly mode

The check was running in the loop that read source files in, much before
any of the other checks ran. Vetxonly makes vet exit early, but after
all the source files have been read.

To fix this, simply run the buildtag check along with all the other
checks that get run on specific syntax tree nodes.

Add a cmd/go test with go test -a, to ensure that the issue as reported
is fixed.

Fixes #26102.

Change-Id: If6e3b9418ffa8166c0f982668b0d10872283776a
Reviewed-on: https://go-review.googlesource.com/121395
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoreflect: remove struct tags from unexported types
Ian Lance Taylor [Thu, 28 Jun 2018 22:44:41 +0000 (15:44 -0700)]
reflect: remove struct tags from unexported types

Before CL 4281055 in 2011, the reflect package was quite different.
rtype, then called commonType, was embedded in exported structs with
names like StructType. In order to avoid accidental conversions
between pointers to these public structs, which sometimes had
identical fields, the embedded commonType fields were tagged.

In CL 4281055 the formerly public structs were unexported, and all
access was done through the Type interface. At that point the field
tags in the reflect structs were no longer useful.

In Go 1.8 the language was changed to ignore struct field tags when
converting between types. This made the field tags in the reflect
structs doubly useless.

This CL simply removes them.

Fixes #20914

Change-Id: I9af4d6d0709276a91a6b6ee5323cad9dcd0cd0a0
Reviewed-on: https://go-review.googlesource.com/121475
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/compile: don't crash in untyped expr to interface conversion
Robert Griesemer [Wed, 27 Jun 2018 22:38:29 +0000 (15:38 -0700)]
cmd/compile: don't crash in untyped expr to interface conversion

Fixes #24763.

Change-Id: Ibe534271d75b6961d00ebfd7d42c43a3ac650d79
Reviewed-on: https://go-review.googlesource.com/121335
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agonet/http: make Server.Shutdown treat new connections as idle after 5 seconds
Brad Fitzpatrick [Thu, 28 Jun 2018 21:01:45 +0000 (21:01 +0000)]
net/http: make Server.Shutdown treat new connections as idle after 5 seconds

The Server distinguishes "new" vs "idle" connections. A TCP connection
from which no bytes have yet been written is "new". A connection that
has previously served a request and is in "keep-alive" state while
waiting for a second or further request is "idle".

The graceful Server.Shutdown historically only shut down "idle"
connections, with the assumption that a "new" connection was about to
read its request and would then shut down on its own afterwards.

But apparently some clients spin up connections and don't end up using
them, so we have something that's "new" to us, but browsers or other
clients are treating as "idle" to them.

This CL tweaks our heuristic to treat a StateNew connection as
StateIdle if it's been stuck in StateNew for over 5 seconds.

Fixes #22682

Change-Id: I01ba59a6ab67755ca5ab567041b1f54aa7b7da6f
Reviewed-on: https://go-review.googlesource.com/121419
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/vet: fix ironic misuse of fmt.Sprintf
Russ Cox [Thu, 28 Jun 2018 04:05:46 +0000 (00:05 -0400)]
cmd/vet: fix ironic misuse of fmt.Sprintf

Move badf helper into top-level function so that prints from buildtag.go
are once again themselves printf-format-checked by vet.
Also, fix implementation, which was missing a ... in the Sprintf call and
produced messages like:

/Users/rsc/x_test.go:1: +build comment must appear before package clause and be followed by a blank line%!(EXTRA []interface {}=[])

These were introduced in CL 111415.

Change-Id: I000af3a4e01dc99fc79c9146aa68a71dace1460f
Reviewed-on: https://go-review.googlesource.com/121300
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
5 years agotext/template/parse: fix a comment around the assign operator
Andrew Braunstein [Thu, 28 Jun 2018 18:49:30 +0000 (18:49 +0000)]
text/template/parse: fix a comment around the assign operator

Fix a comment that misrepresented the Assign operator (=).

Rename: colon-equals -> equals.

Change-Id: I405b8acfb0bcd1b176a91a95f9bfb61a4e85815f
GitHub-Last-Rev: aec0bf594c63d7b015f88f97f9953ade976817a4
GitHub-Pull-Request: golang/go#26112
Reviewed-on: https://go-review.googlesource.com/121416
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/compile: mark CMOVLEQF, CMOVWEQF as cloberring AX
Ilya Tocar [Wed, 27 Jun 2018 22:37:38 +0000 (17:37 -0500)]
cmd/compile: mark CMOVLEQF, CMOVWEQF as cloberring AX

Code generation for OpAMD64CMOV[WLQ]EQF uses AX as a scratch register,
but only CMOVQEQF, correctly lets compiler know. Mark other 2 as
clobbering AX.

Fixes #26097

Change-Id: I2a65bd67bf18a540898b4a0ae6c8766e0b767b19
Reviewed-on: https://go-review.googlesource.com/121336
Run-TryBot: Ilya Tocar <ilya.tocar@intel.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Giovanni Bajo <rasky@develer.com>
5 years agosyscall/js: rename Callback.Close to Release and expose Callback.Value
Richard Musiol [Wed, 27 Jun 2018 18:19:30 +0000 (20:19 +0200)]
syscall/js: rename Callback.Close to Release and expose Callback.Value

This makes Callback more in line with TypedArray. The name "Release" is
better than "Close" because the function does not implement io.Closer.

Change-Id: I23829a14b1c969ceb04608afd9505fd5b4b0df2e
Reviewed-on: https://go-review.googlesource.com/121216
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agointernal/syscall/unix: add build constraint to nonblocking_js.go
Dmitri Shuralyov [Wed, 27 Jun 2018 19:37:19 +0000 (15:37 -0400)]
internal/syscall/unix: add build constraint to nonblocking_js.go

The intention was for this file to be constrained to both js and wasm,
but the build constraint was missing, causing it to be constrained only
to js because of the _js suffix in the filename.

Add a js,wasm build constraint. The js part is redundant, but specified
anyway to make it more visible and consistent with other similar files.

This issue was spotted while working on GopherJS, because it was causing
a conflict there (both nonblocking.go and nonblocking_js.go files were
being matched).

Change-Id: Ifc6843269e1108fe61b1723be25a12254e806fd4
Reviewed-on: https://go-review.googlesource.com/121275
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocrypto/x509: better debug output for verify-cert calls
Adam Shannon [Thu, 28 Jun 2018 02:40:22 +0000 (21:40 -0500)]
crypto/x509: better debug output for verify-cert calls

Now that pkix.Name offers String() we should use that as some CN's are blank.

Updates #24084

Change-Id: I268196f04b98c2bd4d5d0cf1fecd2c9bafeec0f1
Reviewed-on: https://go-review.googlesource.com/121357
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoRevert "crypto/elliptic: implement P256 for arm64"
Andrew Bonventre [Thu, 28 Jun 2018 01:41:22 +0000 (01:41 +0000)]
Revert "crypto/elliptic: implement P256 for arm64"

This reverts commit 0246915fbfcc41870173b7f016dc7fa9437bbc13.

Reason for revert: Broke darwin/arm64 builds.

Change-Id: Iead935d345c4776c0f823f4c152e02bdda308401
Reviewed-on: https://go-review.googlesource.com/121375
Reviewed-by: Andrew Bonventre <andybons@golang.org>
5 years agogo/doc: make examples that depend on top-level decls playable
Hiroshi Ioka [Wed, 13 Dec 2017 00:56:04 +0000 (09:56 +0900)]
go/doc: make examples that depend on top-level decls playable

Currently, the following example cannot run in playground:

    func a() {
        fmt.Println("A")
    }

    func ExampleA() {
        a()
    }

This CL solves it.

Fixes #23095

Change-Id: I5a492ff886a743f20cb4ae646e8453bde9c5f0da
Reviewed-on: https://go-review.googlesource.com/83615
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agocrypto/tls: add RSASSA-PSS support for handshake messages
Peter Wu [Wed, 22 Nov 2017 19:27:20 +0000 (19:27 +0000)]
crypto/tls: add RSASSA-PSS support for handshake messages

This adds support for RSASSA-PSS signatures in handshake messages as
required by TLS 1.3. Even if TLS 1.2 is negotiated, it must support PSS
when advertised in the Client Hello (this will be done later as the
testdata will change).

Updates #9671

Change-Id: I8006b92e017453ae408c153233ce5ccef99b5c3f
Reviewed-on: https://go-review.googlesource.com/79736
Reviewed-by: Filippo Valsorda <filippo@golang.org>
5 years agoos: when looping in RemoveAll, close and re-open directory
Ian Lance Taylor [Wed, 27 Jun 2018 18:05:09 +0000 (11:05 -0700)]
os: when looping in RemoveAll, close and re-open directory

On some systems removing files can cause a directory to be re-shuffled,
so simply continuing to read files can cause us to miss some.
Close and re-open the directory when looping, to avoid that.

Read more files each time through the loop, to reduce the chance of
having to re-open.

Fixes #20841

Change-Id: I98a14774ca63786ad05ba5000cbdb01ad2884332
Reviewed-on: https://go-review.googlesource.com/121255
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoreflect: prevent additional StructOf embedded method cases
Ian Lance Taylor [Wed, 27 Jun 2018 21:18:31 +0000 (14:18 -0700)]
reflect: prevent additional StructOf embedded method cases

The current implementation does not generate wrappers for methods of
embedded non-interface types. We can only skip the wrapper if
kindDirectIface of the generated struct type matches kindDirectIface
of the embedded type. Panic if that is not the case.

It would be better to actually generate wrappers, but that can be done
later.

Updates #15924
Fixes #24782

Change-Id: I01f5c76d9a07f44e1b04861bfe9f9916a04e65ca
Reviewed-on: https://go-review.googlesource.com/121316
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agonet: parse IPv6 address with zone using DefaultResolver.Lookup{Host,IPAddr}
Michael Fraenkel [Sun, 26 Nov 2017 13:22:22 +0000 (08:22 -0500)]
net: parse IPv6 address with zone using DefaultResolver.Lookup{Host,IPAddr}

Allow a zone to be included with the ip address that is parsed when
using DefaultResolver's LookupHost or LookupIPAddr

Fixes #20790
Fixes #20767

Change-Id: I4e0baf9ade6a095af10a1b85ca6216788ba680ae
Reviewed-on: https://go-review.googlesource.com/79935
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agosyscall/js: add TypedArrayOf
Richard Musiol [Wed, 27 Jun 2018 15:36:24 +0000 (17:36 +0200)]
syscall/js: add TypedArrayOf

The new function js.TypedArrayOf returns a JavaScript typed array for
a given slice.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Typed_arrays

This change also changes js.ValueOf to not accept a []byte any more.

Fixes #25532.

Change-Id: I8c7bc98ca4e21c3514d19eee7a1f92388d74ab2a
Reviewed-on: https://go-review.googlesource.com/121215
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agonet: make concurrent resolver lookups independent
Grégoire Delattre [Tue, 19 Dec 2017 18:42:12 +0000 (19:42 +0100)]
net: make concurrent resolver lookups independent

The current resolver uses a global lookupGroup which merges LookupIPAddr
calls together for lookups for the same hostname if used concurrently.
As a result only one of the resolvers is actually used to perform the
DNS lookup but the result is shared by all the resolvers.

This commit limits the scope of the lookupGroup to the resolver itself
allowing each resolver to make its own requests without sharing the
result with other resolvers.

Fixes #22908

Change-Id: Ibba896eebb05e59f18ce4132564ea1f2b4b6c6d9
Reviewed-on: https://go-review.googlesource.com/80775
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocrypto/elliptic: implement P256 for arm64
Vlad Krasnov [Fri, 9 Mar 2018 01:19:11 +0000 (01:19 +0000)]
crypto/elliptic: implement P256 for arm64

This patch ports the existing optimized P256 implementation to arm64.

name            old time/op    new time/op    delta
pkg:crypto/ecdsa goos:linux goarch:arm64
SignP256           539µs ±13%      43µs ± 2%  -91.95%  (p=0.000 n=20+20)
SignP384          13.2ms ± 1%    13.2ms ± 1%     ~     (p=0.739 n=10+10)
VerifyP256        1.57ms ± 0%    0.12ms ± 0%  -92.40%  (p=0.000 n=18+20)
KeyGeneration      391µs ± 0%      25µs ± 0%  -93.62%  (p=0.000 n=9+9)
pkg:crypto/elliptic goos:linux goarch:arm64
BaseMult          1.66ms ± 0%    1.65ms ± 1%     ~     (p=0.079 n=9+10)
BaseMultP256       389µs ± 0%      22µs ± 1%  -94.28%  (p=0.000 n=19+20)
ScalarMultP256    1.03ms ± 0%    0.09ms ± 0%  -91.25%  (p=0.000 n=19+20)

name            old alloc/op   new alloc/op   delta
pkg:crypto/ecdsa goos:linux goarch:arm64
SignP256          5.47kB ± 0%    3.20kB ± 0%  -41.50%  (p=0.000 n=20+20)
SignP384          2.32MB ± 0%    2.32MB ± 0%     ~     (p=0.739 n=10+10)
VerifyP256        7.65kB ± 4%    0.98kB ± 0%  -87.24%  (p=0.000 n=20+20)
KeyGeneration     1.41kB ± 0%    0.69kB ± 0%  -51.05%  (p=0.000 n=9+10)
pkg:crypto/elliptic goos:linux goarch:arm64
BaseMult            224B ± 0%      224B ± 0%     ~     (all equal)
BaseMultP256      1.12kB ± 0%    0.29kB ± 0%  -74.29%  (p=0.000 n=20+20)
ScalarMultP256    1.59kB ± 7%    0.26kB ± 0%  -83.91%  (p=0.000 n=20+20)

name            old allocs/op  new allocs/op  delta
pkg:crypto/ecdsa goos:linux goarch:arm64
SignP256            67.0 ± 0%      35.0 ± 0%  -47.76%  (p=0.000 n=20+20)
SignP384           17.5k ± 0%     17.5k ± 0%     ~     (p=0.725 n=10+10)
VerifyP256          97.2 ± 3%      17.0 ± 0%  -82.52%  (p=0.000 n=20+20)
KeyGeneration       21.0 ± 0%      13.0 ± 0%  -38.10%  (p=0.000 n=10+10)
pkg:crypto/elliptic goos:linux goarch:arm64
BaseMult            5.00 ± 0%      5.00 ± 0%     ~     (all equal)
BaseMultP256        16.0 ± 0%       6.0 ± 0%  -62.50%  (p=0.000 n=20+20)
ScalarMultP256      19.9 ± 6%       5.0 ± 0%  -74.87%  (p=0.000 n=20+20)

Fixes #22806

Change-Id: I0f187074f8c3069bf8692d59e2cf95bdc6061fe7
Reviewed-on: https://go-review.googlesource.com/99755
Run-TryBot: Vlad Krasnov <vlad@cloudflare.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brendan McMillion <brendan@cloudflare.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agonet/http/httptrace: add clarification never added to CL 67430
Brad Fitzpatrick [Wed, 27 Jun 2018 16:50:39 +0000 (16:50 +0000)]
net/http/httptrace: add clarification never added to CL 67430

Updates #19761

Change-Id: Iac3bd4c40002f8e348452b50bff54dee3210d447
Reviewed-on: https://go-review.googlesource.com/121236
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agomime/quotedprintable: accept bytes >= 0x80
Ian Lance Taylor [Wed, 27 Jun 2018 00:14:43 +0000 (17:14 -0700)]
mime/quotedprintable: accept bytes >= 0x80

RFC 2045 doesn't permit non-ASCII bytes, but some systems send them
anyhow. With this change, we accept them. This does make it harder to
validate quotedprintable data, but on balance this seems like the best
approach given the existence of systems that generate invalid data.

Fixes #22597

Change-Id: I9f80f90a60b76ada2b5dea658b8dc8aace56cdbd
Reviewed-on: https://go-review.googlesource.com/121095
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agonet: limit concurrent threads to limit on file descriptors
Ian Lance Taylor [Wed, 27 Jun 2018 14:08:41 +0000 (07:08 -0700)]
net: limit concurrent threads to limit on file descriptors

At least on Darwin, if getaddrinfo can't open a file descriptor it
returns EAI_NONAME ("no such host") rather than a meaningful error.
Limit the number of concurrent getaddrinfo calls to the number of file
descriptors we can open, to make that meaningless error less likely.

We don't apply the same limit to Go lookups, because for that we will
return a meaningful "too many open files" error.

Fixes #25694

Change-Id: I601857190aeb64f11e22b4a834c1c6a722a0788d
Reviewed-on: https://go-review.googlesource.com/121176
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agonet/http/httptrace: expose request headers for http/1.1
Meir Fischer [Sun, 8 Oct 2017 19:25:28 +0000 (15:25 -0400)]
net/http/httptrace: expose request headers for http/1.1

Some headers, which are set or modified by the http library,
are not written to the standard http.Request.Header and are
not included as part of http.Response.Request.Header.

Exposing all headers alleviates this problem.

This is not a complete solution to 19761 since it does not have http/2 support.

Updates #19761

Change-Id: Ie8d4f702f4f671666b120b332378644f094e288b
Reviewed-on: https://go-review.googlesource.com/67430
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/compile: fold offset into address on Wasm
Cherry Zhang [Sat, 23 Jun 2018 17:23:52 +0000 (13:23 -0400)]
cmd/compile: fold offset into address on Wasm

On Wasm, the offset was not folded into LoweredAddr, so it was
not rematerializeable. This led to the address-taken operation
in some cases generated too early, before the local variable
becoming live. The liveness code thinks the variable live when
the address is taken, then backs it up to live at function
entry, then complains about it, because nothing other than
arguments should be live on entry.

This CL folds the offset into the address operation, so it is
rematerializeable and so generated right before use, after the
variable actually becomes live.

It might be possible to relax the liveness code not to think a
variable live when its address being taken, but until the address
actually being used. But it would be quite complicated. As we're
late in Go 1.11 freeze, it would be better not to do it. Also,
I think the address operation is rematerializeable now on all
architectures, so this is probably less necessary.

This may also be a slight optimization, as the address+offset is
now rematerializeable, which can be generated on the Wasm stack,
without using any "registers" which are emulated by local
variables on Wasm. I don't know how to do benchmarks on Wasm. At
least, cmd/go binary size shrinks 9K.

Fixes #25966.

Change-Id: I01e5869515d6a3942fccdcb857f924a866876e57
Reviewed-on: https://go-review.googlesource.com/120599
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>
5 years agomisc/cgo/test: add retry loop around pthread_create in TestSigprocmask
Ian Lance Taylor [Wed, 27 Jun 2018 00:23:07 +0000 (17:23 -0700)]
misc/cgo/test: add retry loop around pthread_create in TestSigprocmask

This is the same retry loop we use in _cgo_try_pthread_create in runtime/cgo.

Fixes #25078

Change-Id: I7ef4d4fc7fb89cbfb674c4f93cbdd7a033dd8983
Reviewed-on: https://go-review.googlesource.com/121096
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agomisc/cgo/test: skip Test18146 in short mode
Ian Lance Taylor [Wed, 27 Jun 2018 00:52:34 +0000 (17:52 -0700)]
misc/cgo/test: skip Test18146 in short mode

Fixes #21219

Change-Id: I1a2ec1afe06586ed33a3a855b77536490cac3a38
Reviewed-on: https://go-review.googlesource.com/121115
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/link: document limitation of -X
LE Manh Cuong [Tue, 26 Jun 2018 06:48:05 +0000 (13:48 +0700)]
cmd/link: document limitation of -X

Fixes #26042

Change-Id: Ica16f14a65c03659a19926852cca5e554c99baf1
Reviewed-on: https://go-review.googlesource.com/120935
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agomime/multipart: restore 1.9 handling of missing/empty form-data file name
Ian Lance Taylor [Tue, 26 Jun 2018 22:57:35 +0000 (15:57 -0700)]
mime/multipart: restore 1.9 handling of missing/empty form-data file name

Revert the code changes of CL 96975 and CL 70931, but keep the tests,
appropriately modified for the code changes. This restores the 1.9
handling of form-data entries with missing or empty file names.

Changing the handling of this simply confused existing programs for no
useful benefit. Go back to the old behavior.

Updates #19183
Fixes #24041

Change-Id: I4ebc32433911e6360b9fd79d8f63a6d884822e0e
Reviewed-on: https://go-review.googlesource.com/121055
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agonet: improve ExampleUDPConn_WriteTo docs
Mikio Hara [Sun, 24 Jun 2018 17:08:52 +0000 (02:08 +0900)]
net: improve ExampleUDPConn_WriteTo docs

Also updates comment on isConnected field of netFD for clarification.

Change-Id: Icb1b0332e3b4c7802eae00ddc26cd5ba54c82dc2
Reviewed-on: https://go-review.googlesource.com/120955
Run-TryBot: Mikio Hara <mikioh.mikioh@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile: improve escape analysis explanation go1.11beta1
David Chase [Tue, 26 Jun 2018 16:00:25 +0000 (12:00 -0400)]
cmd/compile: improve escape analysis explanation

No code changes, only revised comments in an attempt to make
escape analysis slightly less confusing.

Updates #23109.

Change-Id: I5ee6cea0946ced63f6210ac4484a088bcdd862fb
Reviewed-on: https://go-review.googlesource.com/121001
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agoast: refer to "embedded" rather than "anonymous" fields in
Rowan Marshall [Fri, 22 Jun 2018 17:36:17 +0000 (18:36 +0100)]
ast: refer to "embedded" rather than "anonymous" fields in

documentation.

Fixes #25684.

Change-Id: I9d0e47dff2446c27a3df88fb9ccfefef7419470b
Reviewed-on: https://go-review.googlesource.com/120556
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agogo/types: rename NewInterface2 to NewInterfaceType
Robert Griesemer [Mon, 25 Jun 2018 23:21:59 +0000 (16:21 -0700)]
go/types: rename NewInterface2 to NewInterfaceType

NewInterface2 was introduced with https://go-review.googlesource.com/114317
which fixed #25301. Changed the name to NewInterfaceType to better match
Go naming styles, per discussion with @josharian, @iant, et al.

Change-Id: Ifa4708a5efd4f708295b33c3d20fdc5812e1b4fc
Reviewed-on: https://go-review.googlesource.com/120875
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agosyscall/js: use stable references to JavaScript values
Richard Musiol [Sun, 24 Jun 2018 15:23:38 +0000 (17:23 +0200)]
syscall/js: use stable references to JavaScript values

This commit changes how JavaScript values are referenced by Go code.
After this change, a JavaScript value is always represented by the same
ref, even if passed multiple times from JavaScript to Go. This allows
Go's == operator to work as expected on js.Value (strict equality).
Additionally, the performance of some operations of the syscall/js
package got improved by saving additional roundtrips to JavaScript code.

Fixes #25802.

Change-Id: Ide6ffe66c6aa1caf5327a2d3ddbe48fe7c180461
Reviewed-on: https://go-review.googlesource.com/120561
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agosyscall: fix typo in RawSyscall6 comment
Xargin [Tue, 26 Jun 2018 03:33:20 +0000 (03:33 +0000)]
syscall: fix typo in RawSyscall6 comment

Change-Id: I589a60459a3b0811da77d46428eca57c741b1184
GitHub-Last-Rev: f9ab775b9d7f869916af6de9abb7c1d5f0005f1b
GitHub-Pull-Request: golang/go#26063
Reviewed-on: https://go-review.googlesource.com/120917
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/cgo: mention character restrictions on #cgo lines
Ian Lance Taylor [Tue, 26 Jun 2018 13:40:26 +0000 (06:40 -0700)]
cmd/cgo: mention character restrictions on #cgo lines

Fixes #26025

Change-Id: I43b3c9019ca8d2844e4d664c2090e506b2171077
Reviewed-on: https://go-review.googlesource.com/120975
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agotime: run genzabbrs.go to update zoneinfo_abbrs_windows.go
Alberto Donizetti [Sun, 24 Jun 2018 12:23:28 +0000 (14:23 +0200)]
time: run genzabbrs.go to update zoneinfo_abbrs_windows.go

The abbreviations list in zoneinfo_abbrs_windows.go was last updated
in June 2017, and it's currently outdated. Update it.

Change-Id: Ie2bf4268787f5aefe98ee110c2c279451e18fd97
Reviewed-on: https://go-review.googlesource.com/120559
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
5 years agocmd/compile: map delete should clear value always
Vladimir Kuzmin [Thu, 21 Jun 2018 05:19:56 +0000 (22:19 -0700)]
cmd/compile: map delete should clear value always

Map delete must clear value every time because
newly added map optimizations of compound-assignment
operators (CL #91557) rely on this behavior of map delete.

It slows down map delete operation for non-reference types:

name                   old time/op    new time/op    delta
MapDelete/Int32/100      23.9ns ± 2%    27.8ns ± 4%  +16.04%  (p=0.000 n=20+20)
MapDelete/Int32/1000     21.5ns ± 2%    25.2ns ± 2%  +17.06%  (p=0.000 n=20+19)
MapDelete/Int32/10000    24.2ns ± 6%    27.2ns ± 5%  +12.39%  (p=0.000 n=19+19)
MapDelete/Int64/100      24.2ns ± 4%    27.7ns ± 2%  +14.55%  (p=0.000 n=20+20)
MapDelete/Int64/1000     22.1ns ± 2%    24.8ns ± 2%  +12.36%  (p=0.000 n=10+20)

Fixes #25936

Change-Id: I8499b790cb5bb019938161b3e50f3243d9bbb79c
Reviewed-on: https://go-review.googlesource.com/120255
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agocmd/dist: increase timeout scale to 3 for windows
Andrew [Mon, 25 Jun 2018 20:24:37 +0000 (20:24 +0000)]
cmd/dist: increase timeout scale to 3 for windows

cmd/go can sometimes take up to 400s on windows due
to various issues (disk I/O on builders being the
latest cause). Increase the timeout scale to account
for this.

Change-Id: I1fd4964472a70fb0f33cf6ed73298c034b9c1fb0
Reviewed-on: https://go-review.googlesource.com/120762
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/compile: avoid remainder in loopbce when increment=0
David Chase [Mon, 25 Jun 2018 19:26:45 +0000 (15:26 -0400)]
cmd/compile: avoid remainder in loopbce when increment=0

For non-unit increment, loopbce checks to see if the
increment evenly divides the difference between (constant)
loop start and end.  This test panics when the increment
is zero.

Fix: check for zero, if found, don't optimize the loop.

Also added missing copyright notice to loopbce.go.

Fixes #26043.

Change-Id: I5f460104879cacc94481949234c9ce8c519d6380
Reviewed-on: https://go-review.googlesource.com/120759
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/dist: enable more tests on js/wasm
Brad Fitzpatrick [Mon, 25 Jun 2018 19:05:25 +0000 (19:05 +0000)]
cmd/dist: enable more tests on js/wasm

Fixes #26050

Change-Id: I21697ac30eb3bc423263cba885bce5fea8f81d94
Reviewed-on: https://go-review.googlesource.com/120796
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
5 years agonet/http: document and test behavior of ServeMux with ports
Guilherme Goncalves [Sat, 23 Jun 2018 22:32:26 +0000 (22:32 +0000)]
net/http: document and test behavior of ServeMux with ports

Beginning on Go 1.9, ServeMux has been dropping the port number from the Host
header and in the path pattern. This commit explicitly mentions the change in
behavior and adds a simple test case to ensure consistency.

Fixes #23351.

Change-Id: I0270c8bd96cda92c13ac6437cdf66c2807b3042d
Reviewed-on: https://go-review.googlesource.com/120557
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agoruntime/trace: reword the trace package summary
Jeremy Jackins [Mon, 25 Jun 2018 19:04:31 +0000 (19:04 +0000)]
runtime/trace: reword the trace package summary

Reword the package summary to be a little easier to read.

Change-Id: I84a9301a02e228b46165410a429548b3774762d5
GitHub-Last-Rev: 1342c7219f0ed06144d3bca9acd77790707e4b77
GitHub-Pull-Request: golang/go#26052
Reviewed-on: https://go-review.googlesource.com/120795
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoos: have UserCacheDir return an error on failure
Andrew Bonventre [Mon, 25 Jun 2018 18:26:53 +0000 (14:26 -0400)]
os: have UserCacheDir return an error on failure

Previously, it would return an empty string if it
could not determine the user's cache directory.
Return an error instead.

Change-Id: I74f00b1ad3858efa3fe2700c599271ebfe5764b6
Reviewed-on: https://go-review.googlesource.com/120757
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agodoc/go1.11: add note about package versioning
Andrew Bonventre [Mon, 25 Jun 2018 17:48:59 +0000 (13:48 -0400)]
doc/go1.11: add note about package versioning

It will not be present in go1.11beta1 but will be present
in subsequent releases.

Change-Id: I298fb682945345bb4a34ec83802fd644f75bdd98
Reviewed-on: https://go-review.googlesource.com/120756
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agosyscall/js: turn constant package vars into functions
Richard Musiol [Mon, 25 Jun 2018 10:30:31 +0000 (12:30 +0200)]
syscall/js: turn constant package vars into functions

This is so the values can not be changed and the type is easy to see.

Requested on https://go-review.googlesource.com/c/go/+/120561.

Change-Id: If2ed48ca3ba8874074687bfb2375d2f5592e8e0d
Reviewed-on: https://go-review.googlesource.com/120564
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agosyscall.js: add Value.InstanceOf
Richard Musiol [Fri, 15 Jun 2018 08:45:04 +0000 (10:45 +0200)]
syscall.js: add Value.InstanceOf

Change-Id: Icf56188fdb2b8ce6789830a35608203fdb9a3df6
Reviewed-on: https://go-review.googlesource.com/120560
Reviewed-by: Paul Jolly <paul@myitcv.org.uk>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoruntime: respect timeout in semasleep on Darwin
Nikhil Benesch [Sat, 23 Jun 2018 05:15:19 +0000 (01:15 -0400)]
runtime: respect timeout in semasleep on Darwin

semasleep on Darwin was refactored in https://golang.org/cl/118736 to
use the pthread_cond_timedwait function from libc. The new code
incorrectly assumed that pthread_cond_timedwait took a timeout relative
to the current time, when it in fact it takes a timeout specified in
absolute time. semasleep thus specified a timeout well in the past,
causing it to immediately exceed the timeout and spin hot. This was the
source of a large performance hit to CockroachDB (#26019).

Adjust semasleep to instead call pthread_cond_timedwait_relative_np,
which properly interprets its timeout parameter as relative to the
current time.

pthread_cond_timedwait_relative_np is non-portable, but using
pthread_cond_timedwait correctly would require two calls to
gettimeofday: one in the runtime package to convert the relative timeout
to absolute time, then another in the pthread library to convert back to
a relative offset [0], as the Darwin kernel expects a relative offset.

[0]: https://opensource.apple.com/source/libpthread/libpthread-301.30.1/src/pthread_cond.c.auto.html

Fix #26019.

Change-Id: I1a8c2429f79513b43d2b256365cd9166d235af8b
Reviewed-on: https://go-review.googlesource.com/120635
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agodoc/contribute: fix typo and reword a few sentences
Alberto Donizetti [Wed, 20 Jun 2018 17:23:24 +0000 (19:23 +0200)]
doc/contribute: fix typo and reword a few sentences

This change fixes a typo in doc/contribute.html (afects -> affects)
and rewords a few slightly akward sentences.

Change-Id: I6bfbacba0de29464fce134b0fdaf3898a97b8d57
Reviewed-on: https://go-review.googlesource.com/120105
Reviewed-by: Rob Pike <r@golang.org>
5 years agocmd/link: never coalesce type descriptors when dynamically linking Go
Michael Hudson-Doyle [Wed, 20 Jun 2018 22:31:57 +0000 (10:31 +1200)]
cmd/link: never coalesce type descriptors when dynamically linking Go

Add a test by making misc/cgo/testshared/src/trivial.go marginally less
trivial.

Fixes #25970.

Change-Id: I8815d0c56b8850fcdbf9b45f8406f37bd21b6865
Reviewed-on: https://go-review.googlesource.com/120235
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoapi: promote next to go1.11
Andrew Bonventre [Fri, 22 Jun 2018 18:25:08 +0000 (14:25 -0400)]
api: promote next to go1.11

Change-Id: Ib8fa0a12363993033201ff707c315f4030811f89
Reviewed-on: https://go-review.googlesource.com/120595
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/link: support DWARF compression on Darwin
Heschi Kreinick [Wed, 20 Jun 2018 20:45:25 +0000 (16:45 -0400)]
cmd/link: support DWARF compression on Darwin

We want to compress DWARF even on macOS, but the native toolchain isn't
going to understand it. Add a flag that can be used to disable
compression, then add Darwin to the whitelist used during internal
linking.

Unlike GNU ld, the Darwin linker doesn't have a handy linker flag to do
compression. But since we're already doing surgery to put the DWARF in
the output executable in the first place, compressing it at the same
time isn't unduly difficult. This does have the slightly odd effect of
compressing some Apple proprietary debug sections, which absolutely
nothing will understand. Leaving them uncompressed didn't make much
sense, though, since I doubt they're useful without (say) __debug_info.

Updates #11799

Change-Id: Ie00b0215c630a798c59d009a641e2d13f0e7ea01
Reviewed-on: https://go-review.googlesource.com/120155
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
5 years agosyscall, internal/poll: fix build on js/wasm
Brad Fitzpatrick [Fri, 22 Jun 2018 17:45:30 +0000 (17:45 +0000)]
syscall, internal/poll: fix build on js/wasm

Fixes #26014

Change-Id: I9d92414a9181c5d189e3e266666950656bf00406
Reviewed-on: https://go-review.googlesource.com/120576
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/dist: skip non-std tests on js/wasm
Brad Fitzpatrick [Fri, 22 Jun 2018 17:36:12 +0000 (17:36 +0000)]
cmd/dist: skip non-std tests on js/wasm

After the std tests, most of the rest of the tests aren't applicable
to js/wasm. (anything with -cpu=>1, cgo, etc)

Skip them all for now. We can incrementally re-enable them over time
as the js/wasm port is fleshed out. But let's get the builder column
black again so we can enable trybots and keep it black.

Updates #26014
Updates #26015
Updates #18892

Change-Id: I8992ed3888f598fa42273ce8646a32d62ce45b1d
Reviewed-on: https://go-review.googlesource.com/120575
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
5 years agocmd/compile: fix compile failure for lazily resolved shadowed types
Matthew Dempsky [Thu, 21 Jun 2018 23:12:17 +0000 (16:12 -0700)]
cmd/compile: fix compile failure for lazily resolved shadowed types

If expanding an inline function body required lazily expanding a
package-scoped type whose identifier was shadowed within the function
body, the lazy expansion would instead overwrite the local symbol
definition instead of the package-scoped symbol. This was due to
importsym using s.Def instead of s.PkgDef.

Unfortunately, this is yet another consequence of the current awkward
scope handling code.

Passes toolstash-check.

Fixes #25984.

Change-Id: Ia7033e1749a883e6e979c854d4b12b0b28083dd8
Reviewed-on: https://go-review.googlesource.com/120456
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agocmd/compile: convert uint32 to int32 in ARM constant folding rules
Cherry Zhang [Thu, 21 Jun 2018 14:59:19 +0000 (10:59 -0400)]
cmd/compile: convert uint32 to int32 in ARM constant folding rules

MOVWconst's AuxInt is Int32. SSA check complains if the AuxInt
does not fit in int32. Convert uint32 to int32 to make it happy.

The generated code is unchanged. MOVW only cares low 32 bits.

Passes "toolstash -cmp" std cmd for ARM.

Fixes #25993.

Change-Id: I2b6532c9c285ea6d89652505fb7c553f85a98864
Reviewed-on: https://go-review.googlesource.com/120335
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agodoc/go1.11: clarify GOOS/GOARCH pair of WebAssembly port
Dmitri Shuralyov [Wed, 20 Jun 2018 17:15:44 +0000 (13:15 -0400)]
doc/go1.11: clarify GOOS/GOARCH pair of WebAssembly port

It's more common to specify GOOS/GOARCH values in that order,
rather than the inverse. Fix the order.

Updates #18892.

Change-Id: I8551508599e019f6617dc007397b562c9926418d
Reviewed-on: https://go-review.googlesource.com/120057
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agosync: fix deficiency in RWMutex race annotations
Dmitry Vyukov [Fri, 22 Jun 2018 09:00:13 +0000 (11:00 +0200)]
sync: fix deficiency in RWMutex race annotations

Remove unnecessary race.Release annotation from Unlock.

For RWMutex we want to establish the following happens-before (HB) edges:
1. Between Unlock and the subsequent Lock.
2. Between Unlock and the subsequent RLock.
3. Between batch of RUnlock's and the subsequent Lock.

1 is provided by Release(&rw.readerSem) in Unlock and Acquire(&rw.readerSem) in Lock.
2 is provided by Release(&rw.readerSem) in Unlock and Acquire(&rw.readerSem) in RLock.
3 is provided by ReleaseMerge(&rw.writerSem) in RUnlock in Acquire(&rw.writerSem) in Lock,
since we want to establish HB between a batch of RUnlock's this uses ReleaseMerge instead of Release.

Release(&rw.writerSem) in Unlock is simply not needed.

FWIW this is also how C++ tsan handles mutexes, not a proof but at least something.
Making 2 implementations consistent also simplifies any kind of reasoning against both of them.

Since this only affects performance, a reasonable test is not possible.
Everything should just continue to work but slightly faster.

Credit for discovering this goes to Jamie Liu.

Change-Id: Ice37d29ecb7a5faed3f7781c38dd32c7469b2735
Reviewed-on: https://go-review.googlesource.com/120495
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoos, net: avoid races between dup, set-blocking-mode, and closing
Ian Lance Taylor [Wed, 20 Jun 2018 02:50:03 +0000 (19:50 -0700)]
os, net: avoid races between dup, set-blocking-mode, and closing

Fixes #24481
Fixes #24483

Change-Id: Id7da498425a440c91582aa5480c253ae7a9c932c
Reviewed-on: https://go-review.googlesource.com/119955
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agonet/http: fix test assertion
Thomas Bruyelle [Fri, 22 Jun 2018 09:16:40 +0000 (11:16 +0200)]
net/http: fix test assertion

Logf doesn't make the test fail, so the test was always OK.

Change-Id: I7c10ee74ff7e5d28cbd3a35e185093cb9f349470
Reviewed-on: https://go-review.googlesource.com/120496
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoruntime: fix comments style typo
Zhou Peng [Fri, 22 Jun 2018 05:31:06 +0000 (05:31 +0000)]
runtime: fix comments style typo

Code comments should have a space between comments characters and
actual words.

Change-Id: I6274baf1fc09b37a32ec6c69ddbb8edca9eb5469
Reviewed-on: https://go-review.googlesource.com/120475
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agotext/template/parse: undo breaking API changes
Daniel Theophanes [Thu, 21 Jun 2018 17:41:26 +0000 (10:41 -0700)]
text/template/parse: undo breaking API changes

golang.org/cl/84480 altered the API for the parse package for
clarity and consistency. However, the changes also broke the
API for consumers of the package. This CL reverts the API
to the previous spelling, adding only a single new exported
symbol.

Fixes #25968

Change-Id: Ieb81054b61eeac7df3bc3864ef446df43c26b80f
Reviewed-on: https://go-review.googlesource.com/120355
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agoruntime: avoid recursive panic on bad lock count
Austin Clements [Thu, 21 Jun 2018 20:56:13 +0000 (16:56 -0400)]
runtime: avoid recursive panic on bad lock count

Currently, if lock or unlock calls throw because the g.m.lock count is
corrupted, we're unlikely to get a stack trace because startpanic_m
will itself attempt to acquire a lock, causing a recursive failure.

Avoid this by forcing the g.m.locks count to a sane value if it's
currently bad.

This might be enough to get a stack trace from #25128.

Change-Id: I52d7bd4717ffae94a821f4249585f3eb6cd5aa41
Reviewed-on: https://go-review.googlesource.com/120416
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile: fix recursive inimport handling
Matthew Dempsky [Thu, 21 Jun 2018 22:35:32 +0000 (15:35 -0700)]
cmd/compile: fix recursive inimport handling

expandDecl can be called recursively, so it's not an appropriate place
to clean inimport. Instead, move this up to resolve, along with an
appropriate recursion check.

Passes toolstash-check.

Change-Id: I138d37b057dcc6525c780b4b3fbaa5e97f99655b
Reviewed-on: https://go-review.googlesource.com/120455
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agoflag: add a Value example
Terin Stock [Wed, 20 Jun 2018 21:00:04 +0000 (14:00 -0700)]
flag: add a Value example

Change-Id: I579cc9f4f8e5be5fd6447a99614797ab7bc53611
Reviewed-on: https://go-review.googlesource.com/120175
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agomisc/wasm: fix permissions on wasm_exec.js
Paul Jolly [Thu, 21 Jun 2018 17:30:04 +0000 (18:30 +0100)]
misc/wasm: fix permissions on wasm_exec.js

Currently wasm_exec.js is executable (0755) yet has no interpreter.
Indeed wasm_exec.js is only ever used as an argument to Node or loaded
via a <script> tag in a browser-loaded HTML file.  Hence the execute
mode bits are superfluous and simply serve to clutter your PATH if
$GOROOT/misc/wasm is on your PATH (as is required if you want to run go
test syscall/js).

Change-Id: I279e2457094f8a12b9bf380ad7f1a9f47b22fc96
Reviewed-on: https://go-review.googlesource.com/120435
Run-TryBot: Paul Jolly <paul@myitcv.org.uk>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agointernal/poll: use more fine-grained locking in Splice
Andrei Tudor Călin [Thu, 21 Jun 2018 17:11:34 +0000 (19:11 +0200)]
internal/poll: use more fine-grained locking in Splice

The previous code acquired a read lock on src and a write lock on
dst for the entire duration of Splice. This resulted in deadlock,
in a situation akin to the following:

Splice is blocking, waiting to read from src.

The caller tries to close dst from another goroutine, but Close on
dst blocks in runtime.semacquire, because Splice is still holding a
write lock on it, and the Close didn't unblock any I/O.

The caller cannot unblock the read side of Splice through other means,
because they are stuck waiting in dst.Close().

Use more fine-grained locking instead: acquire the read lock on src
just before trying to splice from the source socket to the pipe,
and acquire the write lock on dst just before trying to splice from
the pipe to the destination socket.

Fixes #25985

Change-Id: I264c91c7a69bb6c5e28610e2bd801244804cf86d
Reviewed-on: https://go-review.googlesource.com/120317
Run-TryBot: Aram Hăvărneanu <aram@mgk.ro>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/go: re-enable a couple of tests of gccgo
Ian Lance Taylor [Thu, 21 Jun 2018 19:01:54 +0000 (12:01 -0700)]
cmd/go: re-enable a couple of tests of gccgo

Updates #22472

Change-Id: I526d131f2ef8e0200f7a5634c75b31e0ee083f93
Reviewed-on: https://go-review.googlesource.com/120375
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/compile: improve atomic add intrinsics with ARMv8.1 new instruction
Wei Xiao [Fri, 3 Nov 2017 02:05:28 +0000 (02:05 +0000)]
cmd/compile: improve atomic add intrinsics with ARMv8.1 new instruction

ARMv8.1 has added new instruction (LDADDAL) for atomic memory operations. This
CL improves existing atomic add intrinsics with the new instruction. Since the
new instruction is only guaranteed to be present after ARMv8.1, we guard its
usage with a conditional on CPU feature.

Performance result on ARMv8.1 machine:
name        old time/op  new time/op  delta
Xadd-224    1.05µs ± 6%  0.02µs ± 4%  -98.06%  (p=0.000 n=10+8)
Xadd64-224  1.05µs ± 3%  0.02µs ±13%  -98.10%  (p=0.000 n=9+10)
[Geo mean]  1.05µs       0.02µs       -98.08%

Performance result on ARMv8.0 machine:
name        old time/op  new time/op  delta
Xadd-46      538ns ± 1%   541ns ± 1%  +0.62%  (p=0.000 n=9+9)
Xadd64-46    505ns ± 1%   508ns ± 0%  +0.48%  (p=0.003 n=9+8)
[Geo mean]   521ns        524ns       +0.55%

Change-Id: If4b5d8d0e2d6f84fe1492a4f5de0789910ad0ee9
Reviewed-on: https://go-review.googlesource.com/81877
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agonet/http: avoid deferred unlock in ServeMux.shouldRedirect
Emmanuel T Odeke [Mon, 21 May 2018 19:57:53 +0000 (12:57 -0700)]
net/http: avoid deferred unlock in ServeMux.shouldRedirect

CL 96575 introduced concurrency protection for
ServeMux.shouldRedirect with a read lock and deferred unlock.
However, the change produced a noticeable regression.
Instead add the suffix "RLocked" to the function name to
declare that we should hold the read lock as a pre-requisite
before calling it, hence avoiding the defer altogether.

Benchmarks:
name                  old time/op    new time/op    delta
ServeMux-8              63.3µs ± 0%    54.6µs ± 0%  -13.74%  (p=0.000 n=9+9)
ServeMux_SkipServe-8    41.4µs ± 2%    32.7µs ± 1%  -21.05%  (p=0.000 n=10+10)

name                  old alloc/op   new alloc/op   delta
ServeMux-8              17.3kB ± 0%    17.3kB ± 0%     ~     (all equal)
ServeMux_SkipServe-8     0.00B          0.00B          ~     (all equal)

name                  old allocs/op  new allocs/op  delta
ServeMux-8                 360 ± 0%       360 ± 0%     ~     (all equal)
ServeMux_SkipServe-8      0.00           0.00          ~     (all equal)

Updates #25383
Updates #25482

Change-Id: I2ffa4eafe165faa961ce23bd29b5653a89facbc2
Reviewed-on: https://go-review.googlesource.com/113996
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agosyscall: check faccessat flags parameter on Linux
Tobias Klauser [Wed, 20 Jun 2018 13:41:37 +0000 (15:41 +0200)]
syscall: check faccessat flags parameter on Linux

Port CL 119495 from golang.org/x/sys/unix to the syscall package.

Currently Linux faccessat(2) syscall implementation doesn't support the
flags parameter. As per the discussion in #25845, permit the same flags
as glibc [1].

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/faccessat.c;h=ea42b2303ff4b2d2d6548ea04376fb265f773436;hb=HEAD

Updates #25845

Change-Id: I132b33275a9cc72b3a97acea5482806c7f47d7f7
Reviewed-on: https://go-review.googlesource.com/120015
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agomime: change *.js mime type to application/javascript, not x-javascript
Brad Fitzpatrick [Wed, 20 Jun 2018 18:25:54 +0000 (18:25 +0000)]
mime: change *.js mime type to application/javascript, not x-javascript

We delayed doing this for 4 years for fear that it might break something,
but it was standardized (RFC 4329) 12 years ago, and the default in Debian
and other places is correct:

   $ cat /etc/mime.types  | grep js$
   application/javascript                          js

Time for us to change too.

I doubt there will be problems, but we'll see during the Go 1.11 beta.

Fixes #7498

Change-Id: Iba0bf8a6e707a64dd63317e1c0d6dd9a18634527
Reviewed-on: https://go-review.googlesource.com/120058
Reviewed-by: Andrew Bonventre <andybons@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/go/internal: add a note about GOCACHE=off
Agniva De Sarker [Tue, 19 Jun 2018 14:57:08 +0000 (20:27 +0530)]
cmd/go/internal: add a note about GOCACHE=off

Fixes #25928

Change-Id: I1401ecc54af26eeeee648bb8eeb5d2d3566fa60c
Reviewed-on: https://go-review.googlesource.com/119695
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agodoc: fix spelling of G Suite
Stephen Lewis [Wed, 20 Jun 2018 18:38:19 +0000 (19:38 +0100)]
doc: fix spelling of G Suite

'G Suite' seems to be the preferred spelling according to
https://gsuite.google.com/

Change-Id: Ica60938cf942594157bba84ef205e1cdcb8c1b08
Reviewed-on: https://go-review.googlesource.com/120132
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
5 years agodoc: change git clone url
Wayne Ashley Berry [Thu, 7 Jun 2018 19:54:08 +0000 (20:54 +0100)]
doc: change git clone url

The git clone url should be a Gerrit host and not Github, otherwise the
codereview command will fail.

git-codereview: failed to load Gerrit origin: git origin must be a Gerrit host, not GitHub: https://github.com/golang/go

Change-Id: I62f62c86ee6dce0720a844fc56340135dfae8405
Reviewed-on: https://go-review.googlesource.com/117178
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocrypto/tls: consolidate signatures handling in SKE and CV
Peter Wu [Wed, 22 Nov 2017 18:25:20 +0000 (18:25 +0000)]
crypto/tls: consolidate signatures handling in SKE and CV

ServerKeyExchange and CertificateVerify can share the same logic for
picking a signature algorithm (based on the certificate public key and
advertised algorithms), selecting a hash algorithm (depending on TLS
version) and signature verification.

Refactor the code to achieve code reuse, have common error checking
(especially for intersecting supported signature algorithms) and to
prepare for addition of new signature algorithms. Code should be easier
to read since version-dependent logic is concentrated at one place.

Change-Id: I978dec3815d28e33c3cfbc85f0c704b1894c25a3
Reviewed-on: https://go-review.googlesource.com/79735
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agointernal/poll: better panic message for lock overflow
Ian Lance Taylor [Wed, 20 Jun 2018 03:43:24 +0000 (20:43 -0700)]
internal/poll: better panic message for lock overflow

Instead of "inconsistent poll.fdMutex", panic with
"too many concurrent operations on a single file or socket (max 1048575)".

Fixes #25558

Change-Id: I5cad3633aa539fb6f48cca236c6656c86acfb663
Reviewed-on: https://go-review.googlesource.com/119956
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Dmitry Vyukov <dvyukov@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
5 years agomake.bash: don't pass GOOS and GOARCH to cmd/go when finding GOROOT_BOOTSTRAP
LE Manh Cuong [Wed, 20 Jun 2018 04:22:37 +0000 (11:22 +0700)]
make.bash: don't pass GOOS and GOARCH to cmd/go when finding GOROOT_BOOTSTRAP

Fixes #25962

Change-Id: I10d41713f6aef100d7b2c8c976f22d1c8ac376d5
Reviewed-on: https://go-review.googlesource.com/119937
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocrypto/rand: make documentation consistent between package comment and Reader
Brad Fitzpatrick [Tue, 19 Jun 2018 21:55:01 +0000 (21:55 +0000)]
crypto/rand: make documentation consistent between package comment and Reader

Updates #25959

Change-Id: I9ae64b216ab5807718db0db98b32de1dc5fa4bec
Reviewed-on: https://go-review.googlesource.com/119875
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
5 years agocmd/go: remove inadvertent comment for vgo
Agniva De Sarker [Wed, 20 Jun 2018 06:05:20 +0000 (11:35 +0530)]
cmd/go: remove inadvertent comment for vgo

This change was introduced while adding the dark copy
of golang.org/x/vgo in CL 118095.

While the comment made sense in a separate vgo repo, when it is
merged with the main repo, this should not remain.

Found while running mkalldocs.sh in CL 119695.

Change-Id: I112a4629c415032bd29e165ac1c27a0f3cabeede
Reviewed-on: https://go-review.googlesource.com/119938
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agogo/internal/gccgoimporter: read export data from archives
Ian Lance Taylor [Tue, 19 Jun 2018 23:53:18 +0000 (16:53 -0700)]
go/internal/gccgoimporter: read export data from archives

When used with the go tool, gccgo will normally generate archive files.
This change teaches the gccgoimporter package how to read the export
data from an archive.

This is needed by, for example, cmd/vet, when typechecking packages.

Change-Id: I21267949a7808cd81c0042af425c774a4ff7d82f
Reviewed-on: https://go-review.googlesource.com/119895
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agomisc/cgo/test: avoid duplicate definition with gccgo
Ian Lance Taylor [Tue, 19 Jun 2018 23:55:19 +0000 (16:55 -0700)]
misc/cgo/test: avoid duplicate definition with gccgo

Current versions of gccgo issue a duplicate definition error when both
a definition and an empty declaration occur. Use build tags to avoid
that case for the issue9400 subdirectory.

Change-Id: I18517af87bab05e9ca43f2f295459cf34347c317
Reviewed-on: https://go-review.googlesource.com/119896
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoruntime: fix FreeBSDNumCPU test
David Carlier [Sun, 17 Jun 2018 17:27:13 +0000 (17:27 +0000)]
runtime: fix FreeBSDNumCPU test

num cpu unit test fixes for FreeBSD.
cpuset -g can possibly output more
data than expected.

Fixes #25924

Change-Id: Iec45a919df68648759331da7cd1fa3b9f3ca4241
GitHub-Last-Rev: 4cc275b519cda13189ec48b581ab9ce00cacd7f6
GitHub-Pull-Request: golang/go#25931
Reviewed-on: https://go-review.googlesource.com/119376
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agodebug/elf,macho,pe: support compressed DWARF
Heschi Kreinick [Tue, 19 Jun 2018 19:41:45 +0000 (15:41 -0400)]
debug/elf,macho,pe: support compressed DWARF

Since we're going to start compressing DWARF on Windows and maybe
Darwin, copy the ELF support for .zdebug sections to macho and pe. The
code is almost completely the same across the three.

While I was here I added support for compressed .debug_type sections,
which I presume were overlooked before.

Tests will come in a later CL once we can actually generate compressed
PE/Mach-O binaries, since there's no other good way to get test data.

Updates #25927, #11799

Change-Id: Ie920b6a16e9270bc3df214ce601a263837810376
Reviewed-on: https://go-review.googlesource.com/119815
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
5 years agocmd/link: enable DWARF compression on Windows
Heschi Kreinick [Tue, 19 Jun 2018 19:39:17 +0000 (15:39 -0400)]
cmd/link: enable DWARF compression on Windows

Simple follow-on to CL 118276. Everything worked except that the
compressed sections need to be aligned at PEFILEALIGN.

Fixes #25927
Updates #11799

Change-Id: Iec871defe30e3e66055d64a5ae77d5a7aca355f5
Reviewed-on: https://go-review.googlesource.com/119816
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
5 years agodoc: update "Mac OS X", "OS X" to macOS; bump up to 10.10
Dmitri Shuralyov [Tue, 19 Jun 2018 20:14:00 +0000 (16:14 -0400)]
doc: update "Mac OS X", "OS X" to macOS; bump up to 10.10

The name was "Mac OS X" during versions 10.0 to 10.7.
It was renamed to "OS X" starting from 10.8 until 10.11.
The current name is "macOS" starting with 10.12. [1]

Previous changes (e.g., CL 47252) updated "Mac OS X" to macOS
in some places, but not everywhere. This CL updates remaining
instances for consistency.

Only the pages that display current information were updated;
historical pages such as release notes for older Go releases,
past articles, blog posts, etc., were left in original form.

Rename the "#osx" anchor to "#macos" on /doc/install page,
along with the single reference to it on the same page.
Add an empty div with id="osx" to not break old links.

Update minimum macOS version from 10.8 to 10.10 per #23122.

[1]: https://en.wikipedia.org/wiki/macOS#History

Updates #23122.

Change-Id: I69fe4b85e83265b9d99f447e3cc5230dde094869
Reviewed-on: https://go-review.googlesource.com/119855
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocrypto: panic on illegal input and output overlap
Filippo Valsorda [Thu, 26 Apr 2018 21:35:01 +0000 (17:35 -0400)]
crypto: panic on illegal input and output overlap

Normalized all panic checks and added inexact aliasing panics across
Stream, Block, BlockMode and AEAD implementations.

Also, tweaked the aliasing docs of cipher.AEAD, as they did not account
for the append nature of the API.

Fixes #21624

Change-Id: I075c4415f59b3c06e3099bd9f76de6d12af086bf
Reviewed-on: https://go-review.googlesource.com/109697
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/compile: conditional on -race, disable inline of go:norace
David Chase [Fri, 15 Jun 2018 19:20:57 +0000 (15:20 -0400)]
cmd/compile: conditional on -race, disable inline of go:norace

Adds the appropriate check to inl.go.
Includes tests of both -race+go:norace and plain go:norace.

Fixes #24651.

Change-Id: Id806342430c20baf4679a985d12eea3b677092e0
Reviewed-on: https://go-review.googlesource.com/119195
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agocmd/compile: more accurate position for select case error message
Robert Griesemer [Tue, 19 Jun 2018 17:20:35 +0000 (10:20 -0700)]
cmd/compile: more accurate position for select case error message

Fixes #25958.

Change-Id: I1f4808a70c20334ecfc4eb1789f5389d94dcf00e
Reviewed-on: https://go-review.googlesource.com/119755
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoruntime: implement procyield properly for ppc64x
Carlos Eduardo Seo [Tue, 29 May 2018 19:00:38 +0000 (16:00 -0300)]
runtime: implement procyield properly for ppc64x

The procyield() function should yield the processor as in other
architectures. On ppc64x, this is achieved by setting the Program
Priority Register to 'low priority' prior to the spin loop, and
setting it back to 'medium-low priority' afterwards.

benchmark                          old ns/op     new ns/op     delta
BenchmarkMakeChan/Byte-8           87.7          86.6          -1.25%
BenchmarkMakeChan/Int-8            107           106           -0.93%
BenchmarkMakeChan/Ptr-8            201           204           +1.49%
BenchmarkMakeChan/Struct/0-8       78.2          79.7          +1.92%
BenchmarkMakeChan/Struct/32-8      196           200           +2.04%
BenchmarkMakeChan/Struct/40-8      236           230           -2.54%
BenchmarkChanNonblocking-8         8.64          8.85          +2.43%
BenchmarkChanUncontended-8         5577          5598          +0.38%
BenchmarkChanContended-8           66106         51529         -22.05%
BenchmarkChanSync-8                451           441           -2.22%
BenchmarkChanSyncWork-8            9155          9170          +0.16%
BenchmarkChanProdCons0-8           1585          1083          -31.67%
BenchmarkChanProdCons10-8          1094          838           -23.40%
BenchmarkChanProdCons100-8         831           657           -20.94%
BenchmarkChanProdConsWork0-8       1471          941           -36.03%
BenchmarkChanProdConsWork10-8      1033          721           -30.20%
BenchmarkChanProdConsWork100-8     730           511           -30.00%
BenchmarkChanCreation-8            135           128           -5.19%
BenchmarkChanSem-8                 602           463           -23.09%
BenchmarkChanPopular-8             3017466       2188441       -27.47%

Fixes #25625

Change-Id: Iacb1c888d3c066902152b8367500348fb631c5f9
Reviewed-on: https://go-review.googlesource.com/115376
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agocmd/compile: fix exporting of 'for' loops
Robert Griesemer [Mon, 18 Jun 2018 21:38:45 +0000 (14:38 -0700)]
cmd/compile: fix exporting of 'for' loops

The existing code for encoding 'for' loops in exported, inlineable
functions incorrectly assumed that the 'Right' field points to an
'expression' node. Adjusted the code to be able to handle any kind
of node. Made matching changes for the binary and indexed exporter.

This only shows up together with other pending compiler changes that
enable exporting of such functions which contain for loops.

No tests yet because we can't test this w/o those pending compiler
changes. Once those changes are in, this code will be tested implicitly.
However, the changes were tested manually together with the patches
described in the issue.

Fixes #25222.

Change-Id: I54babb87e5d665d2c1ef6116c1de1b8c50b1138e
Reviewed-on: https://go-review.googlesource.com/119595
Reviewed-by: David Chase <drchase@google.com>
6 years agoruntime: fix lldb test after DWARF compression
Heschi Kreinick [Mon, 18 Jun 2018 20:29:16 +0000 (16:29 -0400)]
runtime: fix lldb test after DWARF compression

Most (all?) released versions of lldb don't support compressed DWARF.
For now, skip the test if lldb can't find where to put the breakpoint.

This is the best I could think of -- there is no explicit error that I
can find that indicates it couldn't load the DWARF.

Fixes #25925.

Change-Id: Ib8fa486a04940cee5959ba7aab7bdbbaa3b2974e
Reviewed-on: https://go-review.googlesource.com/119535
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agoruntime: skip gdb tests on mips after DWARF compression
Heschi Kreinick [Mon, 18 Jun 2018 21:09:37 +0000 (17:09 -0400)]
runtime: skip gdb tests on mips after DWARF compression

DWARF compression appears to break GDB on mips for reasons unknown. Skip
the GDB tests there.

Fixes #25939.

Change-Id: Id76860d3a2ff8055999ac12ea891c37565bb6685
Reviewed-on: https://go-review.googlesource.com/119539
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agoruntime/pprof: fix incorrect assumption in TestMapping
Hana Kim [Mon, 18 Jun 2018 16:03:53 +0000 (12:03 -0400)]
runtime/pprof: fix incorrect assumption in TestMapping

TestMapping assumed that there was only one mapping entry corresponding
to /exe/main, but that is not always true.
This CL changes the test logic to examine whether all referenced mappings
are symbolized. Based on the result, the test determines whether the
corresponding mapping entries' HasFunctions fields to be true or false.

I initially attempted to create two mappings for referenced locations
(one for symbolized and another for unsymbolized) as described in the
TODO in proto.go as part of fixing this bug. But that change requires
non-trivial modification in the upstream profile package so I decided
to just fix the test for now.

Fixes #25891

Change-Id: Id27a5b07bb5b59e133755a0f863bf56c0a4f7f2b
Reviewed-on: https://go-review.googlesource.com/119455
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/cgo: avoid name confliction for C functions
Hiroshi Ioka [Sat, 6 Jan 2018 09:10:30 +0000 (18:10 +0900)]
cmd/cgo: avoid name confliction for C functions

Use more cryptic names for local variables inside C function wrappers.

Fixes #23356

Change-Id: Ia6a0218f27a13be14f589b1a0facc9683d22ff56
Reviewed-on: https://go-review.googlesource.com/86495
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/cover: fix off-by-one in test error message
Rob Pike [Mon, 18 Jun 2018 03:57:27 +0000 (13:57 +1000)]
cmd/cover: fix off-by-one in test error message

Drive-by after previous CL.

Change-Id: I87db65b65745a0d76500cce06ac276b0d7928404
Reviewed-on: https://go-review.googlesource.com/119395
Reviewed-by: Ralph Corderoy <ralph@inputplus.co.uk>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agodoc: update more stale pprof links
Mostyn Bramley-Moore [Sun, 17 Jun 2018 17:42:03 +0000 (19:42 +0200)]
doc: update more stale pprof links

Related to #25477.

Change-Id: I11261c6055b446ceca1b3acc538ab00fec4b47ca
Reviewed-on: https://go-review.googlesource.com/119321
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/dist: don't test Examples for js/wasm
Brad Fitzpatrick [Sun, 17 Jun 2018 20:30:27 +0000 (20:30 +0000)]
cmd/dist: don't test Examples for js/wasm

Fixes #25913

Change-Id: I4701ec94fa4b07211a8beed85c02ee5aa4fe3eb3
Reviewed-on: https://go-review.googlesource.com/119377
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Richard Musiol <neelance@gmail.com>