]> Cypherpunks repositories - gostls13.git/log
gostls13.git
6 years agoruntime: fix runtime-gdb.py when switching sp value
Lynn Boger [Tue, 4 Dec 2018 20:15:27 +0000 (15:15 -0500)]
runtime: fix runtime-gdb.py when switching sp value

After a recent change to runtime-gdb_test.go the ppc64le builder
has had intermittent failures. The failures occur when trying to
invoke the goroutineCmd function to display the backtrace for
a selected goroutine. There is nothing wrong with the testcase
but it seems to intermittently leave goroutines in a state
where an error can occur.

The error message indicates that the problem occurs when trying
to change the sp back to the original after displaying the
stacktrace for the goroutine.

gdb.error: Attempt to assign to an unmodifiable value.

After some searching I found that this error message can happen
if the sp register is changed when on a frame that is not the
top-most frame. To fix the problem, frame 0 is selected before
changing the value of sp. This fixes the problem in my
reproducer environment, and hopefully will fix the problem on
the builder.

Updates #28679

Change-Id: I329bc95b30f8c95acfb161b0d9cfdcbd917a1954
Reviewed-on: https://go-review.googlesource.com/c/152540
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoruntime: enable preemption of mark termination goroutine
Michael Anthony Knyszek [Thu, 6 Dec 2018 21:51:51 +0000 (21:51 +0000)]
runtime: enable preemption of mark termination goroutine

A mark worker goroutine may attempt to preempt the mark termination
goroutine to scan its stack while the mark termination goroutine is
trying to preempt that worker to flush its work buffer, in rare
cases.

This change makes it so that, like a worker goroutine, the mark
termination goroutine stack is preemptible while it is on the
system stack, attempting to preempt others.

Fixes #28695.

Change-Id: I23bbb191f4fdad293e8a70befd51c9175f8a1171
Reviewed-on: https://go-review.googlesource.com/c/153077
Reviewed-by: Rick Hudson <rlh@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
6 years agodoc: mention the use of replacements to resolve imports for 1.12
Bryan C. Mills [Fri, 7 Dec 2018 15:14:42 +0000 (10:14 -0500)]
doc: mention the use of replacements to resolve imports for 1.12

Updates #26241

Change-Id: I8ffac13d9cc1ee4d4de8fcd2042a7fa60fca567b
Reviewed-on: https://go-review.googlesource.com/c/153157
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: announce the end of support for binary-only packages
Bryan C. Mills [Thu, 6 Dec 2018 14:03:59 +0000 (09:03 -0500)]
doc: announce the end of support for binary-only packages

Updates #28152

Change-Id: If859221afc683b392f649e79d7ff0a06125cbe10
Reviewed-on: https://go-review.googlesource.com/c/152918
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/internal/obj/s390x: don't crash on invalid instruction
Ian Lance Taylor [Fri, 7 Dec 2018 15:25:50 +0000 (07:25 -0800)]
cmd/internal/obj/s390x: don't crash on invalid instruction

I didn't bother with a test as there doesn't seem to be an existing
framework for testing assembler failures, and tests for invalid code
aren't all that interesting.

Fixes #26700

Change-Id: I719410d83527802a09b9d38625954fdb36a3c0f7
Reviewed-on: https://go-review.googlesource.com/c/153177
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agomath: document sign bit correspondence for floating-point/bits conversions
Robert Griesemer [Thu, 6 Dec 2018 21:32:50 +0000 (13:32 -0800)]
math: document sign bit correspondence for floating-point/bits conversions

Fixes #27736.

Change-Id: Ibda7da7ec6e731626fc43abf3e8c1190117f7885
Reviewed-on: https://go-review.googlesource.com/c/153057
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/cover: run tests in parallel, don't change source directory
Ian Lance Taylor [Thu, 6 Dec 2018 01:24:41 +0000 (17:24 -0800)]
cmd/cover: run tests in parallel, don't change source directory

This speeds up the cmd/cover testsuite by about 40% on my laptop.

Updates #26473
Updates #28386

Change-Id: I853b1b3b8c98dc89440f7b7bf5c0ade1d3d66802
Reviewed-on: https://go-review.googlesource.com/c/152817
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocrypto/x509: explicitly cast printf format argument
Tobias Klauser [Thu, 6 Dec 2018 19:58:26 +0000 (20:58 +0100)]
crypto/x509: explicitly cast printf format argument

After CL 128056 the build fails on darwin/386 with

  src/crypto/x509/root_cgo_darwin.go:218:55: warning: values of type 'SInt32' should not be used as format arguments; add an explicit cast to 'int' instead [-Wformat]
  go build crypto/x509: C compiler warning promoted to error on Go builders

Fix the warning by explicitly casting the argument to an int as
suggested by the warning.

Change-Id: Icb6bd622a543e9bc5f669fd3d7abd418b4a8e579
Reviewed-on: https://go-review.googlesource.com/c/152958
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go/internal/modload: use replacements to resolve missing imports
Bryan C. Mills [Wed, 5 Dec 2018 14:52:58 +0000 (09:52 -0500)]
cmd/go/internal/modload: use replacements to resolve missing imports

If the replacements specify one or more versions, we choose the latest
(for consistency with the QueryPackage path, with resolves the latest
version from upstream).

Otherwise, we synthesize a pseudo-version with a zero timestamp and an
appropriate major version.

Fixes #26241

RELNOTE=yes

Change-Id: I14b4c63858c8714cc3e1b05ac52c33de5a16dea9
Reviewed-on: https://go-review.googlesource.com/c/152739
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agoruntime: print pointers being put in checkPut
Austin Clements [Thu, 6 Dec 2018 18:54:07 +0000 (13:54 -0500)]
runtime: print pointers being put in checkPut

In order to further diagnose #27993, I need to see exactly what
pointers are being added to the gcWork buffer too late.

Change-Id: I8d92113426ffbc6e55d819c39e7ab5eafa68668d
Reviewed-on: https://go-review.googlesource.com/c/152957
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
6 years agocmd/go/internal/module: fix validation for module paths ending with /v
Bryan C. Mills [Wed, 5 Dec 2018 15:20:24 +0000 (10:20 -0500)]
cmd/go/internal/module: fix validation for module paths ending with /v

Unlike "/v1", "/v" is not likely to be mistaken for a semantic import path.

Change-Id: I024647d78c79c7761b98ddeccdc7e259ca94b568
Reviewed-on: https://go-review.googlesource.com/c/152738
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agodoc/go1.12: release notes for lib/time
Julie Qiu [Wed, 5 Dec 2018 21:36:18 +0000 (16:36 -0500)]
doc/go1.12: release notes for lib/time

Change-Id: Ic435090bda64d1061f2c3aac0aa94ed7a4800b0b
Reviewed-on: https://go-review.googlesource.com/c/152743
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/internal/objfile: provide consistent output in objdump on ppc64x
Lynn Boger [Wed, 5 Dec 2018 21:23:52 +0000 (16:23 -0500)]
cmd/internal/objfile: provide consistent output in objdump on ppc64x

This makes a change to disasm.go so it provides consistent output
with the recent updates to arch/ppc64.

Change-Id: I812e5da2423fd1a84406032fd91ddf9cc86b7c69
Reviewed-on: https://go-review.googlesource.com/c/152761
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agodoc: 1.12 release notes for cmd/go
Bryan C. Mills [Wed, 5 Dec 2018 21:33:56 +0000 (16:33 -0500)]
doc: 1.12 release notes for cmd/go

Change-Id: I1a0bedc9fbd42e138eb68af8365115339e377856
Reviewed-on: https://go-review.googlesource.com/c/152742
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agogo/types: better error messages for field lookup errors
Robert Griesemer [Thu, 6 Dec 2018 01:08:27 +0000 (17:08 -0800)]
go/types: better error messages for field lookup errors

- follow wording of cmd/compile more closely
- only print base of a package path to avoid overly long error messages

Fixes #26234.

Change-Id: I47a8c64b3adcf73980cd296a24cf8ac721e5df06
Reviewed-on: https://go-review.googlesource.com/c/152764
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
6 years agocmd/compile/internal/syntax: remove unused field in (scanner) source
Robert Griesemer [Wed, 5 Dec 2018 22:42:47 +0000 (14:42 -0800)]
cmd/compile/internal/syntax: remove unused field in (scanner) source

The source.offs field was intended for computing line offsets which
may allow a tiny optimization (see TODO in source.go). We haven't
done the optimization, so for now just remove the field to avoid
confusion. It's trivially added if needed.

While at it, also:

- Fix comment for ungetr2.
- Make sure sentinel is present even if reading from the io.Reader failed.

Change-Id: Ib056c6478030b3fe5fec29045362c8161ff3d19e
Reviewed-on: https://go-review.googlesource.com/c/152763
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agodoc/go1.12: add more release notes for various packages
Andrew Bonventre [Wed, 5 Dec 2018 18:22:44 +0000 (13:22 -0500)]
doc/go1.12: add more release notes for various packages

Change-Id: Ie11cf7d8204860f5a61ab650589d44072d6b131c
Reviewed-on: https://go-review.googlesource.com/c/152740
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocrypto/x509: re-enable TestSystemRoots
Filippo Valsorda [Mon, 6 Aug 2018 22:38:38 +0000 (18:38 -0400)]
crypto/x509: re-enable TestSystemRoots

Now that the cgo and no-cgo paths should be correct and equivalent,
re-enable the TestSystemRoots test without any margin of error (which
was tripping anyway when users had too many of a certain edge-case).

As a last quirk, the verify-cert invocation will validate certificates
that aren't roots, but are signed by valid roots. Ignore them.

Fixes #24652

Change-Id: I6a8ff3c2282136d7122a4e7e387eb8014da0d28a
Reviewed-on: https://go-review.googlesource.com/c/128117
TryBot-Result: Gobot Gobot <gobot@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
6 years agocrypto/x509: fix root CA extraction on macOS (no-cgo path)
Filippo Valsorda [Mon, 6 Aug 2018 22:38:18 +0000 (18:38 -0400)]
crypto/x509: fix root CA extraction on macOS (no-cgo path)

Certificates without any trust settings might still be in the keychain
(for example if they used to have some, or if they are intermediates for
offline verification), but they are not to be trusted. The only ones we
can trust unconditionally are the ones in the system roots store.

Moreover, the verify-cert invocation was not specifying the ssl policy,
defaulting instead to the basic one. We have no way of communicating
different usages in a CertPool, so stick to the WebPKI use-case as the
primary one for crypto/x509.

Updates #24652

Change-Id: Ife8b3d2f4026daa1223aa81fac44aeeb4f96528a
Reviewed-on: https://go-review.googlesource.com/c/128116
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@golang.org>
6 years agocrypto/x509: fix root CA extraction on macOS (cgo path)
Filippo Valsorda [Mon, 6 Aug 2018 19:41:34 +0000 (15:41 -0400)]
crypto/x509: fix root CA extraction on macOS (cgo path)

The cgo path was not taking policies into account, using the last
security setting in the array whatever it was. Also, it was not aware of
the defaults for empty security settings, and for security settings
without a result type. Finally, certificates restricted to a hostname
were considered roots.

The API docs for this code are partial and not very clear, so this is a
best effort, really.

Updates #24652

Change-Id: I8fa2fe4706f44f3d963b32e0615d149e997b537d
Reviewed-on: https://go-review.googlesource.com/c/128056
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@google.com>
Reviewed-by: Adam Langley <agl@golang.org>
6 years agodoc: 1.12 release notes for go/doc, go/token, and reflect packages
Katie Hockman [Tue, 4 Dec 2018 21:23:39 +0000 (16:23 -0500)]
doc: 1.12 release notes for go/doc, go/token, and reflect packages

Change-Id: I5f0ceeca2025cf19bcf610e150f7b7067fdd7397
Reviewed-on: https://go-review.googlesource.com/c/152637
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agodoc/go1.11: add note about go run supporting for go run pkg or go run .
komuW [Wed, 5 Dec 2018 05:39:18 +0000 (05:39 +0000)]
doc/go1.11: add note about go run supporting for go run pkg or go run .

Fixes golang/go#27047

Change-Id: I0dd40201fc03e87fbc674b47bdf9315f1783d6c2
GitHub-Last-Rev: f28ab6234ade814c4bc09e26417c424c843ad57b
GitHub-Pull-Request: golang/go#27048
Reviewed-on: https://go-review.googlesource.com/c/129696
Reviewed-by: komu wairagu <komuw05@gmail.com>
Reviewed-by: Andrew Bonventre <andybons@golang.org>
6 years agocmd/compile: omit write barriers for slice clears of go:notinheap pointers
Austin Clements [Wed, 5 Dec 2018 20:23:26 +0000 (15:23 -0500)]
cmd/compile: omit write barriers for slice clears of go:notinheap pointers

Currently,

  for i := range a {
    a[i] = nil
  }

will compile to have write barriers even if a is a slice of pointers
to go:notinheap types. This happens because the optimization that
transforms this into a memclr only asks it a's element type has
pointers, and not if it specifically has heap pointers.

Fix this by changing arrayClear to use HasHeapPointer instead of
types.Haspointers. We probably shouldn't have both of these functions,
since a pointer to a notinheap type is effectively a uintptr, but
that's not going to change in this CL.

Change-Id: I284b85bdec6ae1e641f894e8f577989facdb0cf1
Reviewed-on: https://go-review.googlesource.com/c/152723
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agocmd/compile: mark memclrHasPointers calls as write barriers
Austin Clements [Wed, 5 Dec 2018 20:21:17 +0000 (15:21 -0500)]
cmd/compile: mark memclrHasPointers calls as write barriers

There are two places where the compiler generates memclrHasPointers
calls. These are effectively write barriers, but the compiler doesn't
currently record them as such in the function. As a result code like

  for i := range a {
    a[i] = nil
  }

inserts a write barrier for the assignment to a[i], but the compiler
doesn't report this. Hence, it's not reported in the -d=wb output, and
it's not checked against //go:nowritebarrier annotations.

Change-Id: I40299ebc9824f05cf516cba494d4c086b80ffb53
Reviewed-on: https://go-review.googlesource.com/c/152722
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agocmd/vendor: update to golang.org/x/arch@5a4828b
Lynn Boger [Tue, 4 Dec 2018 15:29:23 +0000 (10:29 -0500)]
cmd/vendor: update to golang.org/x/arch@5a4828b

This updates master to fix the ppc64 objdump. There were many cases where
the Go objdump was generating opcodes that didn't exist in the Go assembler,
or generated operands in the wrong order. The goal is to generate a Go
objdump that is acceptable to the Go assembler, or as close as possible.

An additional change will be needed for the Go objdump tool to make
use of this.

Change-Id: Ie8d2d534e13b9a64852c99b4b864a9c08ed7e036
Reviewed-on: https://go-review.googlesource.com/c/152517
Reviewed-by: Carlos Eduardo Seo <cseo@linux.vnet.ibm.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: avoid multiple errors regarding misuse of ... in signatures
Robert Griesemer [Wed, 5 Dec 2018 17:52:59 +0000 (09:52 -0800)]
cmd/compile: avoid multiple errors regarding misuse of ... in signatures

Follow-up on #28450 (golang.org/cl/152417).

Updates #28450.
Fixes #29107.

Change-Id: Ib4b4fe582c35315a4f71cf6dbc7f7f2f24b37ec1
Reviewed-on: https://go-review.googlesource.com/c/152758
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agonet: skip TestVariousDeadlines on Plan 9
David du Colombier [Wed, 5 Dec 2018 19:59:42 +0000 (20:59 +0100)]
net: skip TestVariousDeadlines on Plan 9

This test is regularly failing on the plan9/386
builder running on GCE, but we haven't figured
out the issue yet.

Updates #26945.

Change-Id: I8cbe0df43c0757e7bc68e370311f4a28cd7b049b
Reviewed-on: https://go-review.googlesource.com/c/152721
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go/internal/modcmd: fix go mod edit -module replaces empty string
Baokun Lee [Mon, 19 Nov 2018 16:40:28 +0000 (00:40 +0800)]
cmd/go/internal/modcmd: fix go mod edit -module replaces empty string

Fixes golang/go#28820.

Change-Id: Id931617efcf161ec934eb6d44062ad95e8a6ab8d
Reviewed-on: https://go-review.googlesource.com/c/150277
Run-TryBot: Baokun Lee <nototon@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/link: close input files when copying to temporary directory
Ian Lance Taylor [Wed, 5 Dec 2018 17:52:19 +0000 (09:52 -0800)]
cmd/link: close input files when copying to temporary directory

Fixes #29110

Change-Id: I077d1a9caa7f4545de1418cec718c4a37ac36ef8
Reviewed-on: https://go-review.googlesource.com/c/152757
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agodoc/go1.12: add some package release notes
Andrew Bonventre [Tue, 4 Dec 2018 21:22:26 +0000 (16:22 -0500)]
doc/go1.12: add some package release notes

Change-Id: I845eab3c98a3d472c71310de4e0475045eb59d4e
Reviewed-on: https://go-review.googlesource.com/c/152619
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/go/internal/lockedfile: fix filelock.Unlock() called twice
Clément Chigot [Wed, 5 Dec 2018 13:15:37 +0000 (14:15 +0100)]
cmd/go/internal/lockedfile: fix filelock.Unlock() called twice

filelock.Unlock() was called twice for fcntl implementation if an error
occurs during file.{,R}Lock(): once in the error handler, once in
filelock.lock().

Change-Id: I5ad84e8ef6b5e51d79e0a7a0c51f465276cd0c57
Reviewed-on: https://go-review.googlesource.com/c/152717
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/cgo: reject names that are likely to be mangled C name
Hiroshi Ioka [Tue, 4 Dec 2018 23:01:07 +0000 (08:01 +0900)]
cmd/cgo: reject names that are likely to be mangled C name

Fixes #28721

Change-Id: I00356f3a9b0c2fb21dc9c2237dd5296fcb3b319b
Reviewed-on: https://go-review.googlesource.com/c/152657
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocrypto/elliptic: utilize faster z14 multiply/square instructions (when available)
bill_ofarrell [Wed, 31 Oct 2018 02:45:51 +0000 (22:45 -0400)]
crypto/elliptic: utilize faster z14 multiply/square instructions (when available)

In the s390x assembly implementation of NIST P-256 curve, utilize faster multiply/square
instructions introduced in the z14. These new instructions are designed for crypto
and are constant time. The algorithm is unchanged except for faster
multiplication when run on a z14 or later. On z13, the original mutiplication
(also constant time) is used.

P-256 performance is critical in many applications, such as Blockchain.

name            old time      new time     delta
BaseMultP256    24396 ns/op   21564 ns/op  1.13x
ScalarMultP256  87546 ns/op   72813 ns/op. 1.20x

Change-Id: I7e6d8b420fac56d5f9cc13c9423e2080df854bac
Reviewed-on: https://go-review.googlesource.com/c/146022
Reviewed-by: Michael Munday <mike.munday@ibm.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Michael Munday <mike.munday@ibm.com>

6 years agoruntime: correct isAbortPC check in isgoexception
Alex Brainman [Tue, 4 Dec 2018 01:05:11 +0000 (12:05 +1100)]
runtime: correct isAbortPC check in isgoexception

The expression passed into isAbortPC call was written specifically
for windows/amd64 and windows/386 runtime.abort implementation.
Adjust the code, so it also works for windows/arm.

Fixes #29050

Change-Id: I3dc8ddd08031f34115396429eff512827264826f
Reviewed-on: https://go-review.googlesource.com/c/152357
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agocmd/compile: improve error message for non-final variadic parameter
smasher164 [Tue, 4 Dec 2018 11:41:39 +0000 (06:41 -0500)]
cmd/compile: improve error message for non-final variadic parameter

Previously, when a function signature had defined a non-final variadic
parameter, the error message always referred to the type associated with that
parameter. However, if the offending parameter's name was part of an identifier
list with a variadic type, one could misinterpret the message, thinking the
problem had been with one of the other names in the identifer list.

    func bar(a, b ...int) {}
clear ~~~~~~~^       ^~~~~~~~ confusing

This change updates the error message and sets the column position to that of
the offending parameter's name, if it exists.

Fixes #28450.

Change-Id: I076f560925598ed90e218c25d70f9449ffd9b3ea
Reviewed-on: https://go-review.googlesource.com/c/152417
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agocmd/compile: fix unnamed parameter handling in escape analysis
Cherry Zhang [Tue, 4 Dec 2018 20:54:14 +0000 (15:54 -0500)]
cmd/compile: fix unnamed parameter handling in escape analysis

For recursive functions, the parameters were iterated using
fn.Name.Defn.Func.Dcl, which does not include unnamed/blank
parameters. This results in a mismatch in formal-actual
assignments, for example,

func f(_ T, x T)

f(a, b) should result in { _=a, x=b }, but the escape analysis
currently sees only { x=a } and drops b on the floor. This may
cause b to not escape when it should (or a escape when it should
not).

Fix this by using fntype.Params().FieldSlice() instead, which
does include unnamed parameters.

Also add a sanity check that ensures all the actual parameters
are consumed.

Fixes #29000

Change-Id: Icd86f2b5d71e7ebbab76e375b7702f62efcf59ae
Reviewed-on: https://go-review.googlesource.com/c/152617
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/go: revert multi-flag GOFLAGS doc example
Daniel Martí [Tue, 4 Dec 2018 16:25:39 +0000 (16:25 +0000)]
cmd/go: revert multi-flag GOFLAGS doc example

This partially reverts https://golang.org/cl/135035.

Reason for revert: multiple -ldflags=-foo flags simply override each
other, since that's the logic for per-package flags. The suggested
'GOFLAGS=-ldflags=-s -ldflags=-w' has never worked for 'go build', and
even breaks 'go test' and 'go vet'.

There should be a way to specify -ldflags='-w -s' via GOFLAGS, which is
being tracked in #29096. For now, just remove the incorrect suggestion.

Fixes #29053.

Change-Id: I9203056f7e5191e894bcd16595a92df2fb704ea7
Reviewed-on: https://go-review.googlesource.com/c/152479
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>

6 years agodoc/go1.12: flesh out net, etc
Brad Fitzpatrick [Tue, 4 Dec 2018 19:31:52 +0000 (19:31 +0000)]
doc/go1.12: flesh out net, etc

Change-Id: I081400286544d88eec83a8b332b9f7934fd76ae2
Reviewed-on: https://go-review.googlesource.com/c/152539
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agodoc: update 1.12 with latest relnote output
Andrew Bonventre [Tue, 4 Dec 2018 15:49:27 +0000 (10:49 -0500)]
doc: update 1.12 with latest relnote output

Change-Id: Iac0e6671902404a149dd382af37a2be002b1e50f
Reviewed-on: https://go-review.googlesource.com/c/152518
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agogo/types: use new importer.ForCompiler for gotype command
Robert Griesemer [Tue, 4 Dec 2018 18:17:33 +0000 (10:17 -0800)]
go/types: use new importer.ForCompiler for gotype command

This will produce better error messages (position information)
for errors referring to imported objects.

Change-Id: I24646ae803e6b8f78e9240310a858d4095e9463d
Reviewed-on: https://go-review.googlesource.com/c/152538
Reviewed-by: Alan Donovan <adonovan@google.com>
6 years agogo/importer: add ForCompiler, which accepts a token.FileSet
Alan Donovan [Fri, 2 Nov 2018 15:27:53 +0000 (11:27 -0400)]
go/importer: add ForCompiler, which accepts a token.FileSet

The importer.For function logically requires a FileSet, but did not
when it was first created because export data did not then record
position information. This change adds a new function, ForCompiler,
that has an additional FileSet parameter, and deprecates the For
function.

Before this change, cmd/vet would report confusing spurious
positions for token.Pos values produced by the importer.
The bug is essentially unfixable in cmd/vet.

This CL includes a test that the FileSet is correctly populated.

The changes to cmd/vendor will be applied upstream in a follow-up.

Fixes #28995

Change-Id: I9271bcb1f28e96845c913e15f0304bac93d4d4c4
Reviewed-on: https://go-review.googlesource.com/c/152258
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agogo/doc: tune factory method association logic
Agniva De Sarker [Wed, 10 Oct 2018 10:22:03 +0000 (15:52 +0530)]
go/doc: tune factory method association logic

Ignore predeclared types (such as error) in result parameter lists when determining
with which result type a method should be associated with. This change will again
associate common factory functions with the first result type even if there are more
than one result, as long as the others are predeclared types.

Fixes #27928

Change-Id: Ia2aeaed15fc4c8debdeeaf729cc7fbba1612cafb
Reviewed-on: https://go-review.googlesource.com/c/141617
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agogo/internal/gccgoimporter: skip /*nointerface*/ comment
Ian Lance Taylor [Tue, 4 Dec 2018 03:20:47 +0000 (19:20 -0800)]
go/internal/gccgoimporter: skip /*nointerface*/ comment

Support for methods marked with "//go:nointerface" was broken by CL
151557, based on CL 150061, which changed the scanner to stop skipping
comments.

Change-Id: I43d5e2cf51bed2dc4ed9d6136ca21aa1223e8df1
Reviewed-on: https://go-review.googlesource.com/c/152378
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
6 years agosyscall, cmd/go/internal/lockedfile: remove Flock syscall for aix/ppc64
Clément Chigot [Tue, 4 Dec 2018 08:03:32 +0000 (09:03 +0100)]
syscall, cmd/go/internal/lockedfile: remove Flock syscall for aix/ppc64

AIX doesn't provide flock() syscall, it was previously emulated by fcntl
calls. However, there are some differences between a flock() syscall and
a flock() using fcntl. Therefore, it's safer to remove it and just
provide FcntlFlock.

Thus, lockedfile implementation must be moved to use FcntlFlock on aix/ppc64.

Updates #29065.
Fixes #29084.

Change-Id: Ic48fd9f315f24c2acdf09b91d917da131a1f2dd5
Reviewed-on: https://go-review.googlesource.com/c/152397
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/go: add missing gccgo checks for buildmodeInit
Lynn Boger [Mon, 3 Dec 2018 22:02:20 +0000 (17:02 -0500)]
cmd/go: add missing gccgo checks for buildmodeInit

Some recent failures in gccgo on linux/ppc64 identified
an error in buildmodeInit when buildmode=c-archive.
A fix went into gofrontend, and this is the
corresponding change for master. This change also includes
two other updates related to gccgo in this function that
were in the file from gofrontend but missing from master.

Updates #29046

Change-Id: I9a894e7d728e31fb9e9344cd61d50408df7faf4a
Reviewed-on: https://go-review.googlesource.com/c/152160
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agonet/http/httputil: add tests for singleJoiningSlash.
Bobby DeSimone [Tue, 4 Dec 2018 00:56:04 +0000 (00:56 +0000)]
net/http/httputil: add tests for singleJoiningSlash.

These changes add tests for the unexported function singleJoiningSlash.

Change-Id: I107905aac4a3c2544be309098b67e970ea5b542c
GitHub-Last-Rev: ed6f86f619549f46ef53316b7febaac781b64e4b
GitHub-Pull-Request: golang/go#29088
Reviewed-on: https://go-review.googlesource.com/c/152337
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agodoc: release notes: "go tool vet" is no longer supported
Ian Lance Taylor [Mon, 3 Dec 2018 22:58:38 +0000 (14:58 -0800)]
doc: release notes: "go tool vet" is no longer supported

Updates #28869

Change-Id: Ie152bf959af2e9cd32b1ccc031e8208e64fbe3ce
Reviewed-on: https://go-review.googlesource.com/c/152161
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
6 years agoos: increase default write size for TestClosedPipeRaceWrite
Ian Lance Taylor [Mon, 3 Dec 2018 23:45:10 +0000 (15:45 -0800)]
os: increase default write size for TestClosedPipeRaceWrite

The original value of 65537 consistently caused the test to fail on
Solaris. The new value of 131073 consistently lets the test pass.

Change-Id: If1a76ab89aa8f661ea049113addd04b23a116534
Reviewed-on: https://go-review.googlesource.com/c/152164
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go: emit go list error for local non-existant packages
Jay Conrod [Wed, 28 Nov 2018 21:33:23 +0000 (16:33 -0500)]
cmd/go: emit go list error for local non-existant packages

In CL 129061, a check was added for patterns that reference
nonexistent local directories. While this prevented unnecessary
network lookups (fixing #26874), it caused "go list -e" to exit with
an error instead of listing packages with error messages.

This change avoids the network lookup and does not exit for these
kinds of packages. Errors are still reported by
internal/load.LoadImport for packages that don't exist.

Fixes #28023

Change-Id: I0a648269e437aed3a95bfb05461a397264f3793f
Reviewed-on: https://go-review.googlesource.com/c/151800
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agomisc/cgo/testcshared: skip TestGo2C2Go on Android
Ian Lance Taylor [Mon, 3 Dec 2018 23:12:54 +0000 (15:12 -0800)]
misc/cgo/testcshared: skip TestGo2C2Go on Android

Updates #29087

Change-Id: I0bab45818119176c2ba5de9c0e457b7717485d6f
Reviewed-on: https://go-review.googlesource.com/c/152162
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agogo/types: fix interface receiver type for incremental type-checking
Robert Griesemer [Mon, 3 Dec 2018 21:46:14 +0000 (13:46 -0800)]
go/types: fix interface receiver type for incremental type-checking

The type checker may be called incrementally (by repeatedly calling
Checker.Files), for instance when adding _test.go files to a set of
already checked files.

The existing code reset a cache of (already computed) interface
information with each Checker.Files call, causing interfaces to be
recomputed in some cases, albeit with different receiver information
(see comments in this CL for details).

Don't reset the interface cache to avoid this problem.

While adding a test case, also factor out some common testing logic.

Fixes #29029.

Change-Id: I2e2d6d6bb839b3a76522fbc4ba7355c71d3bb80b
Reviewed-on: https://go-review.googlesource.com/c/152259
Reviewed-by: Alan Donovan <adonovan@google.com>
6 years agonet/http/httputil: fix unannounced trailers when body is empty
SALLEYRON Julien [Mon, 3 Dec 2018 20:46:23 +0000 (20:46 +0000)]
net/http/httputil: fix unannounced trailers when body is empty

Fix unannounced trailers when body is empty and without announced trailers.

Fixes #29031

Change-Id: If49951a42fe56d4be4436a999627db4c2678659d
GitHub-Last-Rev: 3469adc8f5fd977438350274134950687853a468
GitHub-Pull-Request: golang/go#29032
Reviewed-on: https://go-review.googlesource.com/c/151898
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/vendor: update to golang.org/x/tools@e5f3ab76
Daniel Martí [Mon, 3 Dec 2018 21:03:02 +0000 (21:03 +0000)]
cmd/vendor: update to golang.org/x/tools@e5f3ab76

To pull in the fix for #28858, which we want to include for Go 1.12.

Fixes #28858.

Change-Id: Id4964cfd38e3d44d6317a2ee124fe2d35038b5fd
Reviewed-on: https://go-review.googlesource.com/c/152277
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
6 years agocmd/cgo: use a plausible position for typedef error messages
Ian Lance Taylor [Mon, 3 Dec 2018 18:53:10 +0000 (10:53 -0800)]
cmd/cgo: use a plausible position for typedef error messages

Fixes #28069

Change-Id: I7e0f96b8b6d123de283325fcb78ec76455050f6d
Reviewed-on: https://go-review.googlesource.com/c/152158
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agonet/http: document CanonicalHeaderKey from Header
Brad Fitzpatrick [Mon, 3 Dec 2018 17:01:18 +0000 (17:01 +0000)]
net/http: document CanonicalHeaderKey from Header

And remove some unnecessary textproto references. (The net/http
package's CanonicalHeaderKey just calls textproto's
CanonicalMIMEHeaderKey)

Fixes #28894

Change-Id: Ibd277893a168368c593147a2677ad6130870cb88
Reviewed-on: https://go-review.googlesource.com/c/152157
Reviewed-by: Ian Lance Taylor <iant@golang.org>
6 years agomisc/cgo/testcshared: don't run TestGo2C2Go on Darwin
Ian Lance Taylor [Mon, 3 Dec 2018 19:23:15 +0000 (11:23 -0800)]
misc/cgo/testcshared: don't run TestGo2C2Go on Darwin

Darwin doesn't support the multiple copies of the runtime package
implied by linking a c-shared library into a Go program.

Updates #29061

Change-Id: I6cf5d00babf82f1de05689c1345aaa5ae0b0659c
Reviewed-on: https://go-review.googlesource.com/c/152159
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/compile: fix static initializer
Keith Randall [Sat, 1 Dec 2018 21:21:04 +0000 (13:21 -0800)]
cmd/compile: fix static initializer

staticcopy of a struct or array should recursively call itself, not
staticassign.

This fixes an issue where a struct with a slice in it is copied during
static initialization. In this case, the backing array for the slice
is duplicated, and each copy of the slice refers to a different
backing array, which is incorrect.  That issue has existed since at
least Go 1.2.

I'm not sure why this was never noticed. It seems like a pretty
obvious bug if anyone modifies the resulting slice.

In any case, we started to notice when the optimization in CL 140301
landed.  Here is basically what happens in issue29013b.go:
1) The error above happens, so we get two backing stores for what
   should be the same slice.
2) The code for initializing those backing stores is reused.
   But not duplicated: they are the same Node structure.
3) The order pass allocates temporaries for the map operations.
   For the first instance, things work fine and two temporaries are
   allocated and stored in the OKEY nodes. For the second instance,
   the order pass decides new temporaries aren't needed, because
   the OKEY nodes already have temporaries in them.
   But the order pass also puts a VARKILL of the temporaries between
   the two instance initializations.
4) In this state, the code is technically incorrect. But before
   CL 140301 it happens to work because the temporaries are still
   correctly initialized when they are used for the second time. But then...
5) The new CL 140301 sees the VARKILLs and decides to reuse the
   temporary for instance 1 map 2 to initialize the instance 2 map 1
   map. Because the keys aren't re-initialized, instance 2 map 1
   gets the wrong key inserted into it.

Fixes #29013

Change-Id: I840ce1b297d119caa706acd90e1517a5e47e9848
Reviewed-on: https://go-review.googlesource.com/c/152081
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
6 years agonet: enable TCP keepalives by default
Carlo Alberto Ferraris [Sun, 15 Apr 2018 02:34:19 +0000 (11:34 +0900)]
net: enable TCP keepalives by default

This is just the first step in attempting to make all network connection have
timeouts as a "safe default". TCP keepalives only protect against certain
classes of network and host issues (e.g. server/OS crash), but do nothing
against application-level issues (e.g. an application that accepts connections
but then fails to serve requests).

The actual keep-alive duration (15s) is chosen to cause broken connections
to be closed after 2~3 minutes (depending on the OS, see #23549 for details).
We don't make the actual default value part of the public API for a number of
reasons:
- because it's not very useful by itself: as discussed in #23549 the actual
  "timeout" after which the connection is torn down is duration*(KEEPCNT+1),
  and we use the OS-wide value for KEEPCNT because there's currently no way
  to set it from Go.
- because it may change in the future: if users need to rely on a specific
  value they should explicitly set this value instead of relying on the default.

Fixes #23459

Change-Id: I348c03be97588d5001e6de0f377e7a93b51957fd
Reviewed-on: https://go-review.googlesource.com/c/107196
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agonet/http: add StatusTooEarly (425)
Leon Klingele [Mon, 3 Dec 2018 04:44:48 +0000 (04:44 +0000)]
net/http: add StatusTooEarly (425)

StatusTooEarly can be returned to indicate that a server is unwilling
to accept early data as introduced in TLS 1.3.
The status code was specified in RFC 8470, section 5.2.

Major supported browsers are:
- Firefox as of version 58
  https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/425#Browser_compatibility
- Chromium as of version 73.0.3628.1
  https://chromium.googlesource.com/chromium/src/+/58097ec3823e0f340ab5abfcaec1306e1d954c5a

Change-Id: I3f62f4193bae198994d08fde7e92e0ccd080e59a
GitHub-Last-Rev: fa885040eaf80e0e33b571567108d8a9ded67801
GitHub-Pull-Request: golang/go#29073
Reviewed-on: https://go-review.googlesource.com/c/152118
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: for location lists, handle case where prev block is not a pred
David Chase [Thu, 1 Nov 2018 19:26:02 +0000 (15:26 -0400)]
cmd/compile: for location lists, handle case where prev block is not a pred

Before this change, location list construction would extend
from the previous (in linear order) block, even if was not a
flow predecessor.  This can cause a debugger to tell lies.

Fix accounts for this in block merging code by (crudely)
"changing" all variables live from a previous block if it
is not also a predecessor.

Fixes #28486.

Change-Id: I11336b0b969f0cd09f40f4e5f2bdfdeb02f377a4
Reviewed-on: https://go-review.googlesource.com/c/146718
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
6 years agoall: use "reports whether" consistently instead of "returns whether"
Tobias Klauser [Thu, 22 Nov 2018 10:46:44 +0000 (11:46 +0100)]
all: use "reports whether" consistently instead of "returns whether"

Follow-up for CL 147037 and after Brad noticed the "returns whether"
pattern during the review of CL 150621.

Go documentation style for boolean funcs is to say:

    // Foo reports whether ...
    func Foo() bool

(rather than "returns whether")

Created with:

    $ perl -i -npe 's/returns whether/reports whether/' $(git grep -l "returns whether" | grep -v vendor)

Change-Id: I15fe9ff99180ad97750cd05a10eceafdb12dc0b4
Reviewed-on: https://go-review.googlesource.com/c/150918
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: add Buffer.Grow to TestIntendedInlining
Daniel Martí [Sat, 1 Dec 2018 16:28:27 +0000 (16:28 +0000)]
cmd/compile: add Buffer.Grow to TestIntendedInlining

golang.org/cl/151977 slightly decreased the cost of inlining an extra
call from 60 to 57, since it was a safe change that could help in some
scenarios.

One notable change spotted in that CL is that bytes.Buffer.Grow is now
inlinable, meaning that a fixedbugs test needed updating.

For consistency, add the test case to TestIntendedInlining too,
alongside other commonly used bytes.Buffer methods.

Change-Id: I4fb402fc684ef4c543fc65aea343ca1a4d73a189
Reviewed-on: https://go-review.googlesource.com/c/151979
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/compile: decrease inlining call cost from 60 to 57
David Chase [Fri, 30 Nov 2018 13:36:00 +0000 (08:36 -0500)]
cmd/compile: decrease inlining call cost from 60 to 57

A Go user made a well-documented request for a slightly
lower threshold.  I tested against a selection of other
people's benchmarks, and saw a tiny benefit (possibly noise)
at equally tiny cost, and no unpleasant surprises observed
in benchmarking.

I.e., might help, doesn't hurt, low risk, request was
delivered on a silver platter.

It did, however, change the behavior of one test because
now bytes.Buffer.Grow is eligible for inlining.

Updates #19348.

Change-Id: I85e3088a4911290872b8c6bda9601b5354c48695
Reviewed-on: https://go-review.googlesource.com/c/151977
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/cgo: use preprocessor macros to avoid prolog redefinitions
Ian Lance Taylor [Fri, 30 Nov 2018 22:21:33 +0000 (14:21 -0800)]
cmd/cgo: use preprocessor macros to avoid prolog redefinitions

Avoid redefinition errors when a Go file uses a cgo comment to
There is no particularly good reason to do this, but there is also no
particularly good reason that it should fail.

Fixes #27019

Change-Id: Icd6f8197a89be4ee6b03ddae675667998a8b4189
Reviewed-on: https://go-review.googlesource.com/c/152079
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agotest/codegen: add arithmetic tests for 386/amd64/arm/arm64
Ben Shi [Fri, 30 Nov 2018 09:30:36 +0000 (09:30 +0000)]
test/codegen: add arithmetic tests for 386/amd64/arm/arm64

This CL adds several test cases of arithmetic operations for
386/amd64/arm/arm64.

Change-Id: I362687c06249f31091458a1d8c45fc4d006b616a
Reviewed-on: https://go-review.googlesource.com/c/151897
Run-TryBot: Ben Shi <powerman1st@163.com>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agonet/http: update bundled x/net/http2
Brad Fitzpatrick [Sat, 1 Dec 2018 00:21:29 +0000 (00:21 +0000)]
net/http: update bundled x/net/http2

This updates x/net/http2 to x/net git rev 351d144f for:

   http2: revert Transport's strict interpretation of MAX_CONCURRENT_STREAMS
   https://golang.org/cl/151857

   http2: don't leak streams on broken body
   https://golang.org/cl/132715

   http2: remove support for Go 1.8 and earlier
   https://golang.org/cl/145677

   http2: reduce init-time work & allocations
   https://golang.org/cl/127664

And some CLs fixing typos.

Fixes #27044
Fixes #27208

Change-Id: I11cc32576c690199ceb4c0bd1448d01e3cab3097
Reviewed-on: https://go-review.googlesource.com/c/152080
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
6 years agosyscall: avoid "64"-postfixed libSystem syscalls on iOS
Elias Naur [Fri, 30 Nov 2018 11:25:18 +0000 (12:25 +0100)]
syscall: avoid "64"-postfixed libSystem syscalls on iOS

The stat(2) man page contain this comment about the 64-bit versions
of the system file functions:

"Platforms that were released after these updates only have the
newer variants available to them.  These platforms have the macro
_DARWIN_FEATURE_ONLY_64_BIT_INODE defined."

It turns out that on iOS the _DARWIN_FEATURE_ONLY_64_BIT_INODE is
defined and that even though the "64"-postfixed versions are
accessible they are deemed private. Apps that refer to private
API are not admissible on App Store, and after the Go runtime
started using libSystem instead of direct syscalls, the App Store
submission checks reject apps built with Go tip.

The fix is simple: use the non-postfixed versions on iOS.

getdirentries(2) is not changed; it is not available at all on iOS
and needs replacement.

Updates #28984

Change-Id: Icb8d44e271456acaa1913ba486fcf5b569722fa9
Reviewed-on: https://go-review.googlesource.com/c/151938
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
6 years agocmd/compile: fix constant index bounds check and error message
Robert Griesemer [Wed, 28 Nov 2018 22:34:45 +0000 (14:34 -0800)]
cmd/compile: fix constant index bounds check and error message

While here, rename nonnegintconst to indexconst (because that's
what it is) and add Fatalf calls where we are not expecting the
indexconst call to fail, and fixed wrong comparison in smallintconst.

Fixes #23781.

Change-Id: I86eb13081c450943b1806dfe3ae368872f76639a
Reviewed-on: https://go-review.googlesource.com/c/151599
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
6 years agoruntime: fix heap pointer invariant rules in HACKING.md
Michael Anthony Knyszek [Wed, 28 Nov 2018 18:52:35 +0000 (18:52 +0000)]
runtime: fix heap pointer invariant rules in HACKING.md

This change fixes an error in HACKING.md which claims all pointers
which live in unmanaged memory but point to the heap must be marked
as GC roots explicitly by runtime.markroot. This isn't technically
necessary if the pointer is accessible through a global variable.

Change-Id: I632b25272fdb2f789c5259dd1685d517f45fd435
Reviewed-on: https://go-review.googlesource.com/c/151539
Reviewed-by: Rick Hudson <rlh@golang.org>
6 years agogo/internal/gccgoimporter: fix test when using gccgo before GCC 7
Ian Lance Taylor [Fri, 30 Nov 2018 20:44:34 +0000 (12:44 -0800)]
go/internal/gccgoimporter: fix test when using gccgo before GCC 7

In TestObjImporter skip tests that use type aliases when using a
version of gccgo before GCC 7, since that is when type aliases were
added.

Fixes #29006

Change-Id: I676bae9f023931cf95ac9b4d4de893fe8517af9b
Reviewed-on: https://go-review.googlesource.com/c/152078
Reviewed-by: Than McIntosh <thanm@google.com>
6 years agogo/internal/gccgoimporter: fix test when using gccgo 4.7
Ian Lance Taylor [Fri, 30 Nov 2018 20:26:10 +0000 (12:26 -0800)]
go/internal/gccgoimporter: fix test when using gccgo 4.7

TestInstallationImporter checks that it can read the export data for a
list of known standard library packages. It was failing on the SmartOS
builder which has GCC 4.7 installed. Skip packages that did not exist
in GCC 4.7. Most packages are still there and the missing packages are
fairly simple, so this doesn't really affect test quality.

Updates #29006

Change-Id: If7ae6f83d51d40168a9692acb0b99c9bf21f2a4d
Reviewed-on: https://go-review.googlesource.com/c/152077
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agogo/internal/gccgoimporter: fix bug reading V1 export data
Than McIntosh [Fri, 30 Nov 2018 14:50:05 +0000 (09:50 -0500)]
go/internal/gccgoimporter: fix bug reading V1 export data

Fix a bug in the reading of elderly export data. In such export data
when reading type information it's possible to encounter a named type N1
defined as a typedef of some other named type N2 at a point when the
underying type of N1 has not yet been finalized. Handle this case by
generating a fixup, then process fixups at the end of parsing to
set the correct underlying type.

Fixes #29006.

Change-Id: I6a505c897bd95eb161ee04637bb6eebad9f20d52
Reviewed-on: https://go-review.googlesource.com/c/151997
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocrypto/tls: improve error message for unsupported certificates in TLS 1.3
Filippo Valsorda [Thu, 29 Nov 2018 07:30:26 +0000 (02:30 -0500)]
crypto/tls: improve error message for unsupported certificates in TLS 1.3

Fixes #28960

Change-Id: I0d049d4776dc42ef165a1da15f63de08677fbb85
Reviewed-on: https://go-review.googlesource.com/c/151661
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
6 years agocrypto/tls: fix client certificates support for legacy servers
Filippo Valsorda [Thu, 29 Nov 2018 06:38:07 +0000 (01:38 -0500)]
crypto/tls: fix client certificates support for legacy servers

signatureSchemesForCertificate was written to be used with TLS 1.3, but
ended up used for TLS 1.2 client certificates in a refactor. Since it
only supported TLS 1.3 signature algorithms, it would lead to no RSA
client certificates being sent to servers that didn't support RSA-PSS.

TestHandshakeClientCertRSAPKCS1v15 was testing *specifically* for this,
but alas the OpenSSL flag -verify accepts an empty certificates list as
valid, as opposed to -Verify...

Fixes #28925

Change-Id: I61afc02ca501d3d64ab4ad77bbb4cf10931e6f93
Reviewed-on: https://go-review.googlesource.com/c/151660
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Adam Langley <agl@golang.org>
6 years agonet: skip flaky TestLookupDotsWithRemoteSource on darwin
Andrew Bonventre [Thu, 29 Nov 2018 23:41:03 +0000 (18:41 -0500)]
net: skip flaky TestLookupDotsWithRemoteSource on darwin

Updates golang/go#27992

Change-Id: Ic327df7cc5002a3d537f9117559c25f30e1eab9c
Reviewed-on: https://go-review.googlesource.com/c/151799
Run-TryBot: Andrew Bonventre <andybons@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go/internal/modfetch: make directories read-only after renaming, not before
Bryan C. Mills [Thu, 29 Nov 2018 22:46:14 +0000 (17:46 -0500)]
cmd/go/internal/modfetch: make directories read-only after renaming, not before

The call to os.Rename was failing on the darwin builders, despite having passed in the TryBots.
(I tested this change by running 'go test cmd/go' manually on a darwin gomote.)

This fixes the builder failures after CL 146382.

Updates #26794
Fixes #29030

Change-Id: I3644773421789f65e56f183d077b4e4fd17b8325
Reviewed-on: https://go-review.googlesource.com/c/151798
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

6 years agocmd/go/internal/lockedfile/internal/filelock: fix test on iOS
Elias Naur [Fri, 30 Nov 2018 11:09:59 +0000 (12:09 +0100)]
cmd/go/internal/lockedfile/internal/filelock: fix test on iOS

Change-Id: I0390b382db0ca36de20af0ef15204c5bfc084d3d
Reviewed-on: https://go-review.googlesource.com/c/151937
Run-TryBot: Elias Naur <elias.naur@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agocmd/compile: eliminate write barriers when writing non-heap ptrs
Keith Randall [Tue, 27 Nov 2018 20:40:16 +0000 (12:40 -0800)]
cmd/compile: eliminate write barriers when writing non-heap ptrs

We don't need a write barrier if:
1) The location we're writing to doesn't hold a heap pointer, and
2) The value we're writing isn't a heap pointer.

The freshly returned value from runtime.newobject satisfies (1).
Pointers to globals, and the contents of the read-only data section satisfy (2).

This is particularly helpful for code like:
p := []string{"abc", "def", "ghi"}

Where the compiler generates:
   a := new([3]string)
   move(a, statictmp_)  // eliminates write barriers here
   p := a[:]

For big slice literals, this makes the code a smaller and faster to
compile.

Update #13554. Reduces the compile time by ~10% and RSS by ~30%.

Change-Id: Icab81db7591c8777f68e5d528abd48c7e44c87eb
Reviewed-on: https://go-review.googlesource.com/c/151498
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agoruntime: check more work flushing races
Austin Clements [Mon, 26 Nov 2018 19:41:23 +0000 (14:41 -0500)]
runtime: check more work flushing races

This adds several new checks to help debug #27993. It adds a mechanism
for freezing write barriers and gcWork puts during the mark completion
algorithm. This way, if we do detect mark completion, we can catch any
puts that happened during the completion algorithm. Based on build
dashboard failures, this seems to be the window of time when these are
happening.

This also double-checks that all work buffers are empty immediately
upon entering mark termination (much earlier than the current check).
This is unlikely to trigger based on the current failures, but is a
good safety net.

Change-Id: I03f56c48c4322069e28c50fbc3c15b2fee2130c2
Reviewed-on: https://go-review.googlesource.com/c/151797
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
6 years agocmd/cgo: use field alignment when setting field offset
Ian Lance Taylor [Tue, 20 Nov 2018 23:55:02 +0000 (15:55 -0800)]
cmd/cgo: use field alignment when setting field offset

The old code ignored the field alignment, and only looked at the field
offset: if the field offset required padding, cgo added padding. But
while that approach works for Go (at least with the gc toolchain) it
doesn't work for C code using packed structs. With a packed struct the
added padding may leave the struct at a misaligned position, and the
inserted alignment, which cgo is not considering, may introduce
additional, unexpected, padding. Padding that ignores alignment is not
a good idea when the struct is not packed, and Go structs are never
packed. So don't ignore alignment.

Fixes #28896

Change-Id: Ie50ea15fa6dc35557497097be9fecfecb11efd8a
Reviewed-on: https://go-review.googlesource.com/c/150602
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
6 years agogo/doc: convert to unicode quotes for ToText and Synopsis
Agniva De Sarker [Tue, 20 Nov 2018 05:43:03 +0000 (11:13 +0530)]
go/doc: convert to unicode quotes for ToText and Synopsis

We refactor the conversion of quotes to their unicode equivalent
to a separate function so that it can be called from ToText and Synopsis.

And we introduce a temp buffer to write the escaped HTML and convert
the unicode quotes back to html escaped entities. This simplifies the logic
and gets rid of the need to track the index of the escaped text.

Fixes #27759

Change-Id: I71cf47ddcd4c6794ccdf2898ac25539388b393c1
Reviewed-on: https://go-review.googlesource.com/c/150377
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
6 years agoruntime: node ordering in mTreap; adjust code to reflect description.
Gergely Brautigam [Wed, 28 Nov 2018 18:10:28 +0000 (18:10 +0000)]
runtime: node ordering in mTreap; adjust code to reflect description.

Adjust mTreap ordering logic to reflect the description of mTreap ordering.
Before it was using unsafe.Pointer in order to gather the base address of
a span. This has been changed to use base, which is the startAddress of a
span as the description is telling us in mgclarge.go.

Fixes: golang/go#28805
Change-Id: Ib3cd94a0757e23d135b5d41830f38fc08bcf16a3
GitHub-Last-Rev: 93f749b6700b1e179de16607a18395d5e162ecc1
GitHub-Pull-Request: golang/go#28973
Reviewed-on: https://go-review.googlesource.com/c/151499
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

6 years agocmd/doc: treat any non-empty GOMOD as module mode
Bryan C. Mills [Wed, 28 Nov 2018 21:22:05 +0000 (16:22 -0500)]
cmd/doc: treat any non-empty GOMOD as module mode

Previously, we were looking for the string go.mod specifically, but
the module-mode-outside-a-module logic added in CL 148517 sets GOMOD
to os.DevNull

Updates #28992

Change-Id: I62a4baaa911a495350294d78bae96be3fe4866cb
Reviewed-on: https://go-review.googlesource.com/c/151617
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go/internal/modfetch: document DownloadDir
Bryan C. Mills [Thu, 8 Nov 2018 15:23:53 +0000 (10:23 -0500)]
cmd/go/internal/modfetch: document DownloadDir

Change-Id: I4717964234fca0c8c5889ed710b66f39eb53a809
Reviewed-on: https://go-review.googlesource.com/c/151562
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go/testdata/mod: remove unused research.swtch.com/vgo-tour
Bryan C. Mills [Mon, 5 Nov 2018 15:49:22 +0000 (10:49 -0500)]
cmd/go/testdata/mod: remove unused research.swtch.com/vgo-tour

The test that used that module was removed in
https://golang.org/cl/128900.

Change-Id: Id96270a52398c8ccc09821efb2a6a6b4764f44d9
Reviewed-on: https://go-review.googlesource.com/c/151560
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go/internal/load: remove redundant assignment to BinDir
Bryan C. Mills [Thu, 8 Nov 2018 14:46:24 +0000 (09:46 -0500)]
cmd/go/internal/load: remove redundant assignment to BinDir

This assignment became a no-op in CL 36196, where both it and the
preceding assignment were changed to cfg.GOROOTbin (from gorootBin and
gobin respectively).

Change-Id: If74969c4cc3ffc5d8394ff9d8e8bcec9e0a4e3b0
Reviewed-on: https://go-review.googlesource.com/c/151561
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go/internal/modcmd: check for errors in Download
Bryan C. Mills [Wed, 28 Nov 2018 16:28:47 +0000 (11:28 -0500)]
cmd/go/internal/modcmd: check for errors in Download

Also test that Download restores deleted files.

Updates #27783

Change-Id: If50074dbcffd74ff08fbaa9ad8c314cfdce0b02d
Reviewed-on: https://go-review.googlesource.com/c/151559
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go: enable module mode without a main module when GO111MODULE=on
Bryan C. Mills [Thu, 8 Nov 2018 15:29:40 +0000 (10:29 -0500)]
cmd/go: enable module mode without a main module when GO111MODULE=on

This is as minimal a change as I could comfortably make to enable 'go
get' outside of a module for 1.12.

In general, commands invoked in module mode while outside of a module
operate as though they are in a module with an initially-empty go.mod
file. ('go env GOMOD' reports os.DevNull.)

Commands that operate on the current directory (such as 'go list' and
'go get -u' without arguments) fail: without a module definition, we
don't know the package path. Likewise, commands whose sole purpose is
to write files within the main module (such as 'go mod edit' and 'go
mod vendor') fail, since we don't know where to write their output.

Since the go.sum file for the main module is authoritative, we do not
check go.sum files when operating outside of a module. I plan to
revisit that when the tree opens for 1.13.

We may also want to revisit the behavior of 'go list': it would be
useful to be able to query individual packages (and dependencies of
those packages) within versioned modules, but today we only allow
versioned paths in conjunction with the '-m' flag.

Fixes #24250

RELNOTE=yes

Change-Id: I028c323ddea27693a92ad0aa4a6a55d5e3f43f2c
Reviewed-on: https://go-review.googlesource.com/c/148517
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go/internal/modfetch/codehost: add lockfiles for repos
Bryan C. Mills [Thu, 25 Oct 2018 20:42:26 +0000 (16:42 -0400)]
cmd/go/internal/modfetch/codehost: add lockfiles for repos

The lockfile guards calls that may change the repo's filesystem contents.

We don't know how robust VCS implementations are to running
simultaneous commands, and this way we don't need to care: only one
'go' command at a time will modify any given repository.

If we can guarantee that particular VCS implementations are robust
enough across all of the VCS tool versions we support, we may be able
to remove some of this locking to improve parallelism.

Updates #26794

Change-Id: I578524974f5015629239cef43d3793aee2b9075c
Reviewed-on: https://go-review.googlesource.com/c/146381
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go/internal/{modcmd,modload}: lock edits to go.mod
Bryan C. Mills [Tue, 23 Oct 2018 19:51:42 +0000 (15:51 -0400)]
cmd/go/internal/{modcmd,modload}: lock edits to go.mod

Use an arbitrary lockfile to serialize edits, and use atomic renames
to actually write the go.mod file so that we never drop version
requirements due to a command failing partway through a write.

Multiple invocations of the 'go' command may read the go.mod file
concurrently, and will see some consistent version even if some other
invocation changes it concurrently.

Multiple commands may attempt to write the go.mod file concurrently.
One writer will succeed and write a consistent, complete go.mod file.
The others will detect the changed contents and fail explicitly: it is
not, in general, possible to resolve two conflicting changes to module
requirements, so we surface the problem to the user rather than trying
to solve the problem heuristically.

Updates #26794

Change-Id: Ia1a06a01ef93fa9be664f560eb83bb86b0207443
Reviewed-on: https://go-review.googlesource.com/c/146380
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go/internal/modfetch: lock files and directories
Bryan C. Mills [Mon, 15 Oct 2018 19:52:01 +0000 (15:52 -0400)]
cmd/go/internal/modfetch: lock files and directories

We employ the following new locking mechanisms:

• Zip files and list files within the module cache are written using
  atomic renames of temporary files, so that GOPROXY servers reading
  from the cache will never serve incomplete content.

• A lock file for each module version guards downloading and extraction of
  (immutable) module contents.

• A lock file alongside each version list (named 'list.lock')
  guards updates to the list.

• A single lock file in the module cache guards updates to all go.sum
  files. The go.sum files themselves are written using an atomic
  rename to ensure that we never accidentally discard existing sums.

Updates #26794

RELNOTE=yes

Change-Id: I16ef8b06ee4bd7b94d0c0a6f5d17e1cecc379076
Reviewed-on: https://go-review.googlesource.com/c/146382
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go/internal/modfetch: make Repo.Zip write to an io.Writer instead of a temporary...
Bryan C. Mills [Tue, 27 Nov 2018 13:50:28 +0000 (08:50 -0500)]
cmd/go/internal/modfetch: make Repo.Zip write to an io.Writer instead of a temporary file

This will be used to eliminate a redundant copy in CL 145178.

(It also decouples two design points that were previously coupled: the
destination of the zip output and the program logic to write that
output.)

Updates #26794

Change-Id: I6cfd5a33c162c0016a1b83a278003684560a3772
Reviewed-on: https://go-review.googlesource.com/c/151341
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go/internal/{clean,test}: lock testexpire.txt
Bryan C. Mills [Tue, 23 Oct 2018 19:39:07 +0000 (15:39 -0400)]
cmd/go/internal/{clean,test}: lock testexpire.txt

Also check to make sure we don't overwrite a newer timestamp with an
older one.

testexpire.txt may be written concurrently, and a partially-written
timestamp may appear much older than the actual intended one. We don't
want to re-run tests that should still be cached.

Updates #26794

Change-Id: If56348e799f0e7be3c5bc91b4a336e23ad99f791
Reviewed-on: https://go-review.googlesource.com/c/146379
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go/internal/lockedfile: add package and support library
Bryan C. Mills [Tue, 16 Oct 2018 14:42:58 +0000 (10:42 -0400)]
cmd/go/internal/lockedfile: add package and support library

lockedfile.File passes through to os.File, with Open, Create, and OpenFile
functions that mimic the corresponding os functions but acquire locks
automatically, releasing them when the file is closed.

lockedfile.Sentinel is a simplified wrapper around lockedfile.OpenFile for the
common use-case of files that signal the status of idempotent tasks.

lockedfile.Mutex is a Mutex-like synchronization primitive implemented in terms
of file locks.

lockedfile.Read is like ioutil.Read, but obtains a read-lock.

lockedfile.Write is like ioutil.Write, but obtains a write-lock and can be used
for read-only files with idempotent contents.

Updates #26794

Change-Id: I50f7132c71d2727862eed54411f3f27e1af55cad
Reviewed-on: https://go-review.googlesource.com/c/145178
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agodoc: add relnotes for stack objects and mid-stack inlining
Keith Randall [Thu, 29 Nov 2018 17:47:11 +0000 (09:47 -0800)]
doc: add relnotes for stack objects and mid-stack inlining

Change-Id: Ief11612b67def93311707165910124d3ce28fb89
Reviewed-on: https://go-review.googlesource.com/c/151777
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
6 years agocmd/go/internal/cache: write shared mutable files atomically
Bryan C. Mills [Tue, 23 Oct 2018 18:48:59 +0000 (14:48 -0400)]
cmd/go/internal/cache: write shared mutable files atomically

Updates #26794

Change-Id: I2a50e3b756ff6a2bbaee4737ca7ed053b01c8d0e
Reviewed-on: https://go-review.googlesource.com/c/146378
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agocmd/go/internal/renameio: add package
Bryan C. Mills [Wed, 31 Oct 2018 19:42:44 +0000 (15:42 -0400)]
cmd/go/internal/renameio: add package

renameio.WriteFile writes files atomically by renaming temporary files.

See the subsequent changes for usage examples.

Updates #26794
Updates #22397

Change-Id: I4bfe3125a53f58060587f98afbb4260bb1cc3d32
Reviewed-on: https://go-review.googlesource.com/c/146377
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Giovanni Bajo <rasky@develer.com>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agovendor/golang_org/x: move to internal/x
Bryan C. Mills [Mon, 5 Nov 2018 20:01:53 +0000 (15:01 -0500)]
vendor/golang_org/x: move to internal/x

Packages in vendor/ directories have a "vendor/" path prefix in GOPATH
mode, but intentionally do not in module mode. Since the import path
is embedded in the compiled output, changing that path invalidates
cache entries and causes cmd/go to try to rebuild (and reinstall) the
vendored libraries, which will fail if the directory containing those
libraries is read-only.

If I understood correctly, this is the approach Russ suggested as an
alternative to https://golang.org/cl/136138.

Fixes #27285
Fixes #26988

Change-Id: I8a2507fa892b84cde0a803aaa79e460723da572b
Reviewed-on: https://go-review.googlesource.com/c/147443
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
6 years agogo/internal/gccgoimporter: additional V3 export data changes
Than McIntosh [Wed, 28 Nov 2018 15:50:54 +0000 (10:50 -0500)]
go/internal/gccgoimporter: additional V3 export data changes

This patch merges in support for reading the most recent
incarnation of V3 export data (initial inline function bodies),
from the importer portions of https://golang.org/cl/150061 and
https://golang.org/cl/150067.

Updates #28961.

Change-Id: I34e837acbf48b8fd1a4896a1a977d2241adfb28d
Reviewed-on: https://go-review.googlesource.com/c/151557
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
6 years agocmd/compile: begin OpArg and OpPhi location lists at block start
David Chase [Fri, 26 Oct 2018 16:00:07 +0000 (12:00 -0400)]
cmd/compile: begin OpArg and OpPhi location lists at block start

For the entry block, make the "first instruction" be truly
the first instruction.  This allows printing of incoming
parameters with Delve.

Also be sure Phis are marked as being at the start of their
block.  This is observed to move location list pointers,
and where moved, they become correct.

Leading zero-width instructions include LoweredGetClosurePtr.
Because this instruction is actually architecture-specific,
and it is now tested for in 3 different places, also created
Op.isLoweredGetClosurePtr() to reduce future surprises.

Change-Id: Ic043b7265835cf1790382a74334b5714ae4060af
Reviewed-on: https://go-review.googlesource.com/c/145179
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>