]> Cypherpunks repositories - gostls13.git/log
gostls13.git
5 years agodoc/articles/race_detector: mention memory leak potential
Kevin Burke [Mon, 24 Feb 2020 04:45:51 +0000 (20:45 -0800)]
doc/articles/race_detector: mention memory leak potential

As far as I can tell, there is no public documentation on this topic,
which cost me several days of debugging.

I am possibly unusual in that I run binaries in production with the
race detector turned on, but I think that others who do the same may
want to be aware of the risk.

Updates #26813.
Updates #37233.

Change-Id: I1f8111bd01d0000596e6057b7cb5ed017d5dc655
Reviewed-on: https://go-review.googlesource.com/c/go/+/220586
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
5 years agocmd/link: stop requiring the math package on ARM
Cherry Zhang [Mon, 24 Feb 2020 22:10:50 +0000 (17:10 -0500)]
cmd/link: stop requiring the math package on ARM

It was needed for the old softfloat implementation, which has
long gone.

Change-Id: Ib8d53689209a3b003d62f84c7c6047d8ec5df859
Reviewed-on: https://go-review.googlesource.com/c/go/+/220719
Reviewed-by: Than McIntosh <thanm@google.com>
5 years agocmd/asm: add asimd instruction 'rev16' on arm64
Xiangdong Ji [Tue, 7 Jan 2020 11:09:33 +0000 (11:09 +0000)]
cmd/asm: add asimd instruction 'rev16' on arm64

Add support to the asimd instruction rev16 which reverses elements in
16-bit halfwords.

syntax:
VREV16 <Vn>.<T>, <Vd>.<T>
<T> should be either B8 or B16.

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

5 years agomath/big: initial vector arithmetic in riscv64 assembly
Joel Sing [Tue, 25 Feb 2020 16:09:59 +0000 (03:09 +1100)]
math/big: initial vector arithmetic in riscv64 assembly

Provide an assembly implementation of mulWW - for now all others run the
Go code.

Change-Id: Icb594c31048255f131bdea8d64f56784fc9db4d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/220919
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agomath: implement Sqrt in assembly for riscv64
Joel Sing [Tue, 25 Feb 2020 16:05:57 +0000 (03:05 +1100)]
math: implement Sqrt in assembly for riscv64

Change-Id: I9a5dc33271434e58335f5562a30cc131c6a8332c
Reviewed-on: https://go-review.googlesource.com/c/go/+/220918
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agodoc: add Go 1.14 to release history
Carlos Amedee [Tue, 25 Feb 2020 16:05:35 +0000 (11:05 -0500)]
doc: add Go 1.14 to release history

Change-Id: I02afbd08ce9e0cd2af8953693b9c3066f6465914
Reviewed-on: https://go-review.googlesource.com/c/go/+/220900
Run-TryBot: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
5 years agocmd/compile: use ellipses in RISCV64 rules
Josh Bleecher Snyder [Thu, 23 Jan 2020 22:28:04 +0000 (14:28 -0800)]
cmd/compile: use ellipses in RISCV64 rules

Also, explicitly zero AuxInt in some ops (like Div),
to make it clear why they do not use an ellipsis.

Passes toolstash-check -all.

Change-Id: Iefd8891fca5d7be8aa1bb91eb1fe2c99c8bf9c88
Reviewed-on: https://go-review.googlesource.com/c/go/+/217011
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agoRevert "cmd/compile: don't allow NaNs in floating-point constant ops"
Bryan C. Mills [Tue, 25 Feb 2020 14:36:38 +0000 (14:36 +0000)]
Revert "cmd/compile: don't allow NaNs in floating-point constant ops"

This reverts CL 213477.

Reason for revert: tests are failing on linux-mips*-rtrk builders.

Change-Id: I8168f7450890233f1bd7e53930b73693c26d4dc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/220897
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agoruntime: fix file permission
Meng Zhuo [Tue, 25 Feb 2020 14:07:40 +0000 (22:07 +0800)]
runtime: fix file permission

Remove executable flag of .s files.

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

5 years agoRevert "Revert "cmd/go/internal/modload: record the replacement for the module contai...
Bryan C. Mills [Tue, 25 Feb 2020 14:58:30 +0000 (14:58 +0000)]
Revert "Revert "cmd/go/internal/modload: record the replacement for the module containing package main in BuildInfo""

This reverts CL 220722.

Reason for revert: rolling forward with fix.

Fixes #37392

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

5 years agocmd/link: Revert -buildmode=pie to internal linking
Corne van der Plas [Tue, 19 Nov 2019 12:22:55 +0000 (13:22 +0100)]
cmd/link: Revert -buildmode=pie to internal linking

When internal linking was broken buildmode PIE is set to external
linking. Now internal linking is fixed, -buildmode=pie can default to
internal linking again.

Fixes #35545

Change-Id: Iaf86b3047eb76babebc1545a79125586a7a3980e
Reviewed-on: https://go-review.googlesource.com/c/go/+/207877
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/go: fix typo in comment
nu50218 [Tue, 25 Feb 2020 14:16:07 +0000 (14:16 +0000)]
cmd/go: fix typo in comment

fix CompiledGoFIles to CompiledGoFiles.

Change-Id: I1f21c2254e716197cb65a877ba7468e3d7009c6f
GitHub-Last-Rev: 177aa1a4962b3a70642c7761f9ab99723f22bc3e
GitHub-Pull-Request: golang/go#37440
Reviewed-on: https://go-review.googlesource.com/c/go/+/220879
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Toshihiro Shiino <shiino.toshihiro@gmail.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agosync: add new Map method LoadAndDelete
Changkun Ou [Fri, 8 Nov 2019 10:23:58 +0000 (11:23 +0100)]
sync: add new Map method LoadAndDelete

This CL implements a LoadAndDelete method in sync.Map. Benchmark:

name                                              time/op
LoadAndDeleteBalanced/*sync_test.RWMutexMap-12    98.8ns ± 1%
LoadAndDeleteBalanced/*sync.Map-12                10.3ns ±11%
LoadAndDeleteUnique/*sync_test.RWMutexMap-12      99.2ns ± 2%
LoadAndDeleteUnique/*sync.Map-12                  6.63ns ±10%
LoadAndDeleteCollision/*sync_test.DeepCopyMap-12   140ns ± 0%
LoadAndDeleteCollision/*sync_test.RWMutexMap-12   75.2ns ± 2%
LoadAndDeleteCollision/*sync.Map-12               5.21ns ± 5%

In addition, Delete is bounded and more efficient if many collisions:

DeleteCollision/*sync_test.DeepCopyMap-12   120ns ± 2%   125ns ± 1%   +3.80%  (p=0.000 n=10+9)
DeleteCollision/*sync_test.RWMutexMap-12   73.5ns ± 3%  79.5ns ± 1%   +8.03%  (p=0.000 n=10+9)
DeleteCollision/*sync.Map-12               97.8ns ± 3%   5.9ns ± 4%  -94.00%  (p=0.000 n=10+10)

Fixes #33762

Change-Id: Ic8469a7861d27ab0edeface0078aad8af9b26c2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/205899
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agoruntime: allow float syscall return values on windows amd64
Richard Wilkes [Mon, 24 Feb 2020 23:46:00 +0000 (23:46 +0000)]
runtime: allow float syscall return values on windows amd64

RELNOTE=yes
Fixes #37273

Change-Id: Iedb7eab185dfeccb1b26902ef36411d2c53ea3e0
GitHub-Last-Rev: bbe30ba45d4a1bd53757b5824ad28024d5e2b179
GitHub-Pull-Request: golang/go#37380
Reviewed-on: https://go-review.googlesource.com/c/go/+/220578
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
5 years agoRevert "reflect: when Converting between float32s, don't lose signal NaNs"
Keith Randall [Tue, 25 Feb 2020 05:57:22 +0000 (05:57 +0000)]
Revert "reflect: when Converting between float32s, don't lose signal NaNs"

This reverts commit 7485050c0f55492c0fdfc41f7564f3da37a1a308.

Reason for revert: Breaking some builders (387, mips, mips64)

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

5 years agotime: add basic YYYY/MM/DD example to time docs
Jean de Klerk [Mon, 24 Feb 2020 20:44:56 +0000 (13:44 -0700)]
time: add basic YYYY/MM/DD example to time docs

This is a _very_ common question [1]. Let's just make an example for it.

1: https://www.google.com/search?q=golang+yyyy-mm-dd&oq=golang+yyyy-mm-dd&aqs=chrome..69i57j0l4j69i64l3.6015j0j7&sourceid=chrome&ie=UTF-8

Change-Id: I32ae689b91018d326f31a2442a1beaf68dddf13c
Reviewed-on: https://go-review.googlesource.com/c/go/+/220595
Run-TryBot: Jean de Klerk <deklerk@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoreflect: when Converting between float32s, don't lose signal NaNs
Keith Randall [Mon, 6 Jan 2020 23:36:42 +0000 (15:36 -0800)]
reflect: when Converting between float32s, don't lose signal NaNs

When converting from float32->float64->float32, any signal NaNs
get converted to quiet NaNs. Avoid that so using reflect.Value.Convert
between two float32 types keeps the signal bit of NaNs.

Update #36400

Change-Id: Ic4dd04c4be7189d2171d12b7e4e8f7cf2fb22bb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/213497
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile: don't allow NaNs in floating-point constant ops
Keith Randall [Mon, 6 Jan 2020 19:23:08 +0000 (11:23 -0800)]
cmd/compile: don't allow NaNs in floating-point constant ops

We store 32-bit floating point constants in a 64-bit field, by
converting that 32-bit float to 64-bit float to store it, and convert
it back to use it.

That works for *almost* all floating-point constants. The exception is
signaling NaNs. The round trip described above means we can't represent
a 32-bit signaling NaN, because conversions strip the signaling bit.

To fix this issue, just forbid NaNs as floating-point constants in SSA
form. This shouldn't affect any real-world code, as people seldom
constant-propagate NaNs (except in test code).

Additionally, NaNs are somewhat underspecified (which of the many NaNs
do you get when dividing 0/0?), so when cross-compiling there's a
danger of using the compiler machine's NaN regime for some math, and
the target machine's NaN regime for other math. Better to use the
target machine's NaN regime always.

This has been a bug since 1.10, and there's an easy workaround
(declare a global varaible containing the signaling NaN pattern, and
use that as the argument to math.Float32frombits) so we'll fix it in
1.15.

Fixes #36400
Update #36399

Change-Id: Icf155e743281560eda2eed953d19a829552ccfda
Reviewed-on: https://go-review.googlesource.com/c/go/+/213477
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
5 years agocmd/link: improve gap detection in TestPIESize
Cherry Zhang [Mon, 24 Feb 2020 21:24:29 +0000 (16:24 -0500)]
cmd/link: improve gap detection in TestPIESize

In CL 210180 we detect gaps between PT_LOAD segments and subtract
them from size calculation. The code there only works when
PT_LOAD segments are next to each other. But it is possible that
there are other segments in between (e.g. a GNU_RELRO segment).
Relax the gap detection to count gaps between PT_LOAD segments
regardless of whether they are next to each other.

Updates #36023.
Updates #35545.

Change-Id: I8b94506359fa649a4478acc742d86d4b16022dbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/220654
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoos/exec: use environment variables for user token when present
Liam 'Auzzie' Haworth [Tue, 25 Feb 2020 00:11:28 +0000 (00:11 +0000)]
os/exec: use environment variables for user token when present

Builds upon the changes from #32000 which supported sourcing environment
variables for a new process from the environment of a Windows user token
when supplied.

But due to the logic of os/exec, the Env field of a process was
always non-nil when it reached that change.

This change moves the logic up to os/exec, specifically when
os.ProcAttr is being built for the os.StartProcess call, this
ensures that if a user token has been supplied and no Env slice has
been provided on the command it will be sourced from the user's
environment.

If no token is provided, or the program is compiled for any other
platform than Windows, the default environment will be sourced from
syscall.Environ().

Fixes #35314

Change-Id: I4c1722e90b91945eb6980d5c5928183269b50487
GitHub-Last-Rev: 32216b7291418f9285147a93ed6d0ba028f94ef2
GitHub-Pull-Request: golang/go#37402
Reviewed-on: https://go-review.googlesource.com/c/go/+/220587
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 agocmd/compile: delete stray file
Josh Bleecher Snyder [Mon, 24 Feb 2020 22:52:19 +0000 (14:52 -0800)]
cmd/compile: delete stray file

This found its way in accidentally.

Change-Id: I830f1e3ec4852a213901a679ad20094a6958cb07
Reviewed-on: https://go-review.googlesource.com/c/go/+/220680
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile: use ellipses in MIPS64 rules
Josh Bleecher Snyder [Thu, 23 Jan 2020 21:04:05 +0000 (13:04 -0800)]
cmd/compile: use ellipses in MIPS64 rules

Passes toolstash-check -all.

Change-Id: Ib9f2dc75e3063928ebe4aeb63e69fd79e439585d
Reviewed-on: https://go-review.googlesource.com/c/go/+/217008
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: use ellipses in S390X rules
Josh Bleecher Snyder [Thu, 23 Jan 2020 22:06:00 +0000 (14:06 -0800)]
cmd/compile: use ellipses in S390X rules

Also, explicitly zero AuxInt in some ops (like Div),
to make it clear why they do not use an ellipsis.

Passes toolstash-check -all.

Change-Id: I47b4ed745196ed734927dbb5923edec33ce286da
Reviewed-on: https://go-review.googlesource.com/c/go/+/217013
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@ibm.com>
5 years agocmd/compile: use ellipses in PPC64 rules
Josh Bleecher Snyder [Thu, 23 Jan 2020 21:33:11 +0000 (13:33 -0800)]
cmd/compile: use ellipses in PPC64 rules

Also, explicitly zero AuxInt in some ops (like Div),
to make it clear why they do not use an ellipsis.

Passes toolstash-check -all.

Change-Id: I2e234e7b779422f7577037813f277e7586061880
Reviewed-on: https://go-review.googlesource.com/c/go/+/217012
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: use ellipses in dec64 rules
Josh Bleecher Snyder [Thu, 23 Jan 2020 22:28:40 +0000 (14:28 -0800)]
cmd/compile: use ellipses in dec64 rules

Passes toolstash-check -all.

Change-Id: I1b56c3b00e7fb7875165b337a93d5fce158b9df0
Reviewed-on: https://go-review.googlesource.com/c/go/+/217010
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: use ellipses in wasm rules
Josh Bleecher Snyder [Thu, 23 Jan 2020 22:20:53 +0000 (14:20 -0800)]
cmd/compile: use ellipses in wasm rules

Also, explicitly zero AuxInt in some ops (like Div),
to make it clear why they do not use an ellipsis.

Passes toolstash-check -all.

Change-Id: I2294d10e47d904d03e489e6ca43d46679323f75d
Reviewed-on: https://go-review.googlesource.com/c/go/+/217009
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: use ellipses in MIPS rules
Josh Bleecher Snyder [Thu, 23 Jan 2020 20:03:26 +0000 (12:03 -0800)]
cmd/compile: use ellipses in MIPS rules

Passes toolstash-check -all.

Change-Id: I14db0acb9b531029c613fa31bc076928651b6448
Reviewed-on: https://go-review.googlesource.com/c/go/+/217007
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agoRevert "cmd/go/internal/modload: record the replacement for the module containing...
Andrew Bonventre [Mon, 24 Feb 2020 22:47:00 +0000 (22:47 +0000)]
Revert "cmd/go/internal/modload: record the replacement for the module containing package main in BuildInfo"

This reverts CL 220645 (commit e092fc352ad393a4d2f1f7fa641df2d23572ccff).

Reason for revert: Seems to have broken windows/amd64 longtest

Change-Id: Iffa8c882524250e5845514bc827fcd8927645a44
Reviewed-on: https://go-review.googlesource.com/c/go/+/220722
Run-TryBot: Andrew Bonventre <andybons@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/compile: use ellipses in ARM64 rules
Josh Bleecher Snyder [Thu, 23 Jan 2020 01:06:15 +0000 (17:06 -0800)]
cmd/compile: use ellipses in ARM64 rules

Also, explicitly zero AuxInt in some ops (like Div),
to make it clear why they do not use an ellipsis.

Passes toolstash-check -all.

Change-Id: Iea0e807949f0899c43d2d21b9551a2cf00a829b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/217006
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: use ellipses in ARM rules
Josh Bleecher Snyder [Thu, 23 Jan 2020 00:34:26 +0000 (16:34 -0800)]
cmd/compile: use ellipses in ARM rules

Passes toolstash-check -all.

Change-Id: I390789ca5bfe45967ed156590f2690c91d416187
Reviewed-on: https://go-review.googlesource.com/c/go/+/217005
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: use ellipses in 386 rules
Josh Bleecher Snyder [Wed, 22 Jan 2020 17:58:43 +0000 (09:58 -0800)]
cmd/compile: use ellipses in 386 rules

Passes toolstash-check -all.

Change-Id: I8ca47b7b7987cb81edaded23331f25c40a8e80dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/217004
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: use ADDQ instead of LEAQ when we can
Keith Randall [Sat, 30 Nov 2019 22:04:35 +0000 (14:04 -0800)]
cmd/compile: use ADDQ instead of LEAQ when we can

The address calculations in the example end up doing x << 4 + y + 0.
Before this CL we use a SHLQ+LEAQ. Since the constant offset is 0,
we can use SHLQ+ADDQ instead.

Change-Id: Ia048c4fdbb3a42121c7e1ab707961062e8247fca
Reviewed-on: https://go-review.googlesource.com/c/go/+/209959
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agoruntime/cgo: fix unsetenv wrapper
Keith Randall [Thu, 23 Jan 2020 04:48:21 +0000 (20:48 -0800)]
runtime/cgo: fix unsetenv wrapper

The wrapper takes a pointer to the argument, not the argument itself.

Fixes #36705

Change-Id: I566d4457d00bf5b84e4a8315a26516975f0d7e10
Reviewed-on: https://go-review.googlesource.com/c/go/+/215942
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agodoc/go1.14: document that freebsd/arm64 requires FreeBSD 12.0 or later
Tobias Klauser [Mon, 24 Feb 2020 20:08:27 +0000 (21:08 +0100)]
doc/go1.14: document that freebsd/arm64 requires FreeBSD 12.0 or later

Updates #24715
Updates #37345

Change-Id: I787a9b2ab1c68e1d379aac0a31bdf6217f04f911
Reviewed-on: https://go-review.googlesource.com/c/go/+/220426
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
5 years agomisc/cgo/testshared: explicitly set GOBIN (instead of unsetting it)
Bryan C. Mills [Mon, 24 Feb 2020 18:58:29 +0000 (13:58 -0500)]
misc/cgo/testshared: explicitly set GOBIN (instead of unsetting it)

If GOBIN is set in the GOENV file, then merely unsetting it in the
process environment is not sufficient. We can instead either set GOBIN
explicitly, or disable GOENV explicitly. For now, we (semi-arbitrary)
choose the former.

Fixes #37390

Change-Id: Iec54532c804b70546d695105cd89e9169eac5dbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/220652
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile: avoid memmove -> SSA move rewrite when size is negative
Keith Randall [Tue, 24 Dec 2019 02:16:22 +0000 (18:16 -0800)]
cmd/compile: avoid memmove -> SSA move rewrite when size is negative

We should panic in this situation. Rewriting to a SSA op just leads
to a compiler panic.

Fixes #36259

Change-Id: I6e0bccbed7dd0fdac7ebae76b98a211947947386
Reviewed-on: https://go-review.googlesource.com/c/go/+/212405
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
5 years agocmd/go/internal/modload: record the replacement for the module containing package...
Bryan C. Mills [Mon, 24 Feb 2020 16:27:38 +0000 (11:27 -0500)]
cmd/go/internal/modload: record the replacement for the module containing package main in BuildInfo

Fixes #37392

Change-Id: I2cb051e6f556b0af95e059611dda3f62e7c1f21a
Reviewed-on: https://go-review.googlesource.com/c/go/+/220645
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agocmd/compile: assign correct declaration line to DIE of captured vars
Alessandro Arzilli [Tue, 14 Jan 2020 07:57:03 +0000 (08:57 +0100)]
cmd/compile: assign correct declaration line to DIE of captured vars

Fixes the declaration line reported in the DW_AT_decl_line for
variables captured in a closure.

Fixes #36542

Change-Id: I228d32b57121fd62c4615c2ef71a6e8da616a1e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/214637
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Heschi Kreinick <heschi@google.com>

5 years agoruntime: special case interface hashing for pointers
Keith Randall [Thu, 13 Feb 2020 16:34:41 +0000 (08:34 -0800)]
runtime: special case interface hashing for pointers

Interfaces often contain pointers. Implement a fast path for this case.

name                   old time/op  new time/op  delta
MapInterfaceString-16  21.4ns ±19%  20.5ns ±10%     ~     (p=0.361 n=10+10)
MapInterfacePtr-16     25.8ns ± 8%  17.3ns ± 7%  -33.11%  (p=0.000 n=10+9)

Fixes #37086

Change-Id: Ice52820e6259a3edeafcbbbeb25b1e363bef00d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/219338
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agodoc/go1.14: remove draft notice
Dmitri Shuralyov [Mon, 24 Feb 2020 17:51:45 +0000 (12:51 -0500)]
doc/go1.14: remove draft notice

Use consistent indentation for one of the paragraphs.

Include issue number in the visible text, so it is easier to read.

Fixes #36878

Change-Id: Iab857b26b1d27b0137e981126207089db108d530
Reviewed-on: https://go-review.googlesource.com/c/go/+/220646
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/go/internal/modfetch: delete unused isVendoredPackage function
Bryan C. Mills [Mon, 24 Feb 2020 14:21:04 +0000 (09:21 -0500)]
cmd/go/internal/modfetch: delete unused isVendoredPackage function

This function is apparently unused since CL 204917.

Updates #35290
Updates #37397

Change-Id: Id7f5f5d5176fdbd1c5c6227e81d0854ceafc3f12
Reviewed-on: https://go-review.googlesource.com/c/go/+/220640
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
5 years agogo/types: report correct argument types for make() built-in calls
Robert Griesemer [Sun, 23 Feb 2020 21:36:46 +0000 (13:36 -0800)]
go/types: report correct argument types for make() built-in calls

Change Checker.index to return the type and constant index value
rather than just a boolean valid flag and the constant value.
While at it, rename some variables and simplify the control flow.

Adjust all uses of Checker.index to new signature. In code for
make() built-in, collect type information for signature reporting.

Fixes #37393.

Change-Id: Id70196faa9539ed5a0d6b59e0f3ea05e05f2f6a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/220585
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agoruntime: remove mcache field from m
Ian Lance Taylor [Mon, 4 Nov 2019 22:25:22 +0000 (14:25 -0800)]
runtime: remove mcache field from m

Having an mcache field in both m and p is confusing, so remove it from m.
Always use mcache field from p. Use new variable mcache0 during bootstrap.

Change-Id: If2cba9f8bb131d911d512b61fd883a86cf62cc98
Reviewed-on: https://go-review.googlesource.com/c/go/+/205239
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
5 years agoreflect: update Select to panic early on excessive input cases
Milan Patel [Sun, 23 Feb 2020 20:27:05 +0000 (15:27 -0500)]
reflect: update Select to panic early on excessive input cases

The runtime implementation of select has an upper limit on the number of
select cases that are supported in order to maintain low stack memory
usage. Rather than support an arbitrary number of select cases, we've
opted to panic early with a useful message pointing the user directly
at the problem.

Fixes #37350

Change-Id: Id129ba281ae120387e681ef96be8adcf89725840
Reviewed-on: https://go-review.googlesource.com/c/go/+/220583
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 agotest: clean up run.go
Dmitri Shuralyov [Sun, 9 Feb 2020 06:40:45 +0000 (01:40 -0500)]
test: clean up run.go

• Inline check function because it's more readable.
• Delete toolPath because it was unused.
• Use strings.TrimPrefix because it's simpler.
• Remove out variable because its value was unused.
• Rename serr to err because it's more consistent.

Change-Id: I084fb4f8b399578834d5eea29a673c386cf3a357
Reviewed-on: https://go-review.googlesource.com/c/go/+/218701
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Hajime Hoshi <hajimehoshi@gmail.com>
5 years agoruntime: remove unused _F_SETFL const on linux
Tobias Klauser [Mon, 20 Jan 2020 09:23:41 +0000 (10:23 +0100)]
runtime: remove unused _F_SETFL const on linux

This constant is only used on libc-based platforms (aix, darwin,
solaris).

Change-Id: Ic57d1fe3b1501c5b552eddb9aba11f1e02510082
Reviewed-on: https://go-review.googlesource.com/c/go/+/220421
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocrypto/cipher: require non-zero nonce size for AES-GCM
Katie Hockman [Fri, 7 Feb 2020 19:44:58 +0000 (14:44 -0500)]
crypto/cipher: require non-zero nonce size for AES-GCM

Also fix typo in crypto/cipher/gcm_test.go.

Fixes #37118

Change-Id: I8544d1eeeb1f0336cebb977b8c5bfa5e4c5ad8c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/218500
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
5 years agoencoding/json: limit max nesting depth
Jordan Liggitt [Tue, 8 Oct 2019 17:19:48 +0000 (13:19 -0400)]
encoding/json: limit max nesting depth

Limit the maximum nesting depth when parsing to protect against stack
overflow, permitted by https://tools.ietf.org/html/rfc7159#section-9

A nesting depth limit of 10,000 was chosen to be a conservative
balance between avoiding stack overflow and avoiding impacting
legitimate JSON documents.

10,000 is less than 1% of the experimental stack depth limit
with the default stack size:
* On 64-bit systems, the default stack limit is 1GB,
  which allows ~2,800,000 frames of recursive parsing
* On 32-bit systems, the default stack limit is 250MB,
  which allows ~1,100,000 frames of recursive parsing

Fixes #31789

Change-Id: I4f5a90e89dcb4ab1a957ad9d02e1fa0efafaccf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/199837
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
5 years agocmd/link: code cleanup in macho_combine_dwarf.go
Tamir Duberstein [Fri, 7 Feb 2020 20:27:55 +0000 (20:27 +0000)]
cmd/link: code cleanup in macho_combine_dwarf.go

- remove global variables
- add missing error checks
- add missing (*os.File).Close calls
- null-check text section correctly
- reduce some variable scopes
- use bytes.Buffer instead of appended slice
- reduce integer casting

Change-Id: Ib9ad41adefed4d61047f53e27046389182eef786
Reviewed-on: https://go-review.googlesource.com/c/go/+/218501
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
5 years agotext/template: make reflect.Value indirections more robust
Daniel Martí [Thu, 19 Dec 2019 14:13:59 +0000 (14:13 +0000)]
text/template: make reflect.Value indirections more robust

Always shadow or modify the original parameter name. With code like:

func index(item reflect.Value, ... {
v := indirectInterface(item)

It was possible to incorrectly use 'item' and 'v' later in the function,
which could result in subtle bugs. This is precisely the kind of mistake
that led to #36199.

Instead, don't keep both the old and new reflect.Value variables in
scope. Always shadow or modify the original variable.

While at it, simplify the signature of 'length', to receive a
reflect.Value directly and save a few redundant lines.

Change-Id: I01416636a9d49f81246d28b91aca6413b1ba1aa5
Reviewed-on: https://go-review.googlesource.com/c/go/+/212117
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Roberto Clapis <robclap8@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
5 years agosyscall: use dup3 in forkAndExecInChild1 if available
Tobias Klauser [Sun, 23 Feb 2020 17:14:34 +0000 (18:14 +0100)]
syscall: use dup3 in forkAndExecInChild1 if available

The dup3 syscall is available since Linux 2.6.27. Fall back to dup2 (if
available) if dup3 returns ENOSYS.

This allows to omit the additional fcntl call to mark the dup'ed fd as
close-on-exec.

Change-Id: If318b593edd783f2aa988534c6062498e7119ddb
Reviewed-on: https://go-review.googlesource.com/c/go/+/220422
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 agomisc/cgo: correct GOOS in skip message
Tobias Klauser [Thu, 30 Jan 2020 09:59:11 +0000 (10:59 +0100)]
misc/cgo: correct GOOS in skip message

Tests are skipped on linux/ppc64, not aix/ppc64.

Change-Id: I6b91b89f24d76b0f9be3eaf816f81ad4246e418f
Reviewed-on: https://go-review.googlesource.com/c/go/+/220423
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 agogo/types: report correct number of arguments for make() built-in calls
Robert Griesemer [Sun, 23 Feb 2020 21:08:29 +0000 (13:08 -0800)]
go/types: report correct number of arguments for make() built-in calls

Also: Added test cases for (separate) issue #37393.
      To be enabled when that issue is fixed.

Fixes #37349.
Updates #37393.

Change-Id: Ib78cb0614c0b396241af06a3aa5d37d8045c2f2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/220584
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agohash/maphash: add package-level example
Alberto Donizetti [Fri, 21 Feb 2020 10:48:13 +0000 (11:48 +0100)]
hash/maphash: add package-level example

Change-Id: I05c7ca644410822a527e94a7a8b883a0f8b0a4ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/220420
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
5 years agotime: add Ticker.Reset
Changkun Ou [Mon, 3 Feb 2020 13:42:32 +0000 (14:42 +0100)]
time: add Ticker.Reset

This CL implements Ticker.Reset method in time package.

Benchmark:
name                 time/op
TickerReset-12       6.41µs ±10%
TickerResetNaive-12  95.7µs ±12%

Fixes #33184

Change-Id: I4cbd31796efa012b2a297bb342158f11a4a31fef
Reviewed-on: https://go-review.googlesource.com/c/go/+/220424
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 agotesting: change benchmark example function
Masahiro Furudate [Thu, 20 Feb 2020 18:29:43 +0000 (03:29 +0900)]
testing: change benchmark example function

Change to rand.Int, a function that the compiler cannot reliably eliminate.
Fix output to actual benchmark values.

Fixes #37341

Change-Id: Ifb5bf49b826ae0bdb4bf9de5a472ad0eaa54569c
Reviewed-on: https://go-review.googlesource.com/c/go/+/220397
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agotime: don't get confused about day 31 when parsing 002
Ian Lance Taylor [Sun, 23 Feb 2020 16:04:13 +0000 (08:04 -0800)]
time: don't get confused about day 31 when parsing 002

The 002 parsing code had a bug that mishandled day 31.

Fixes #37387

Change-Id: Ia5a492a4ddd09a4bc232ce9582aead42d5099bdd
Reviewed-on: https://go-review.googlesource.com/c/go/+/220637
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
5 years agoRevert "time: add Ticker.Reset"
Andrew Bonventre [Sun, 23 Feb 2020 17:28:56 +0000 (17:28 +0000)]
Revert "time: add Ticker.Reset"

This reverts CL 217362 (6e5652bebede2d53484a872f6d1dfeb498b0b50c.)

Reason for revert: Causing failures on arm64 bots. See #33184 for more info

Change-Id: I72ba40047e4138767d95aaa68842893c3508c52f
Reviewed-on: https://go-review.googlesource.com/c/go/+/220638
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agomisc/cgo: enable testso and testsovar on mips64x
Tobias Klauser [Wed, 29 Jan 2020 23:25:19 +0000 (00:25 +0100)]
misc/cgo: enable testso and testsovar on mips64x

External linking on mips64 was implemented in CL 19803 and CL 19809

Updates #12560
Updates #14126

Change-Id: I2cc127d71173aade56ad181bdd947355a76b3e46
Reviewed-on: https://go-review.googlesource.com/c/go/+/217017
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agotime: add Ticker.Reset
Changkun Ou [Mon, 3 Feb 2020 13:42:32 +0000 (14:42 +0100)]
time: add Ticker.Reset

This CL implements Ticker.Reset method in time package.

Benchmark:
name                 time/op
TickerReset-12       6.41µs ±10%
TickerResetNaive-12  95.7µs ±12%

Fixes #33184

Change-Id: I12c651f81e452541bcbbc748b45f038aae1f8dae
Reviewed-on: https://go-review.googlesource.com/c/go/+/217362
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 agodoc: remove extra br tags
Sam Chen [Sat, 22 Feb 2020 11:42:19 +0000 (11:42 +0000)]
doc: remove extra br tags

Change-Id: I6db784c67dde058ddaae8d73b295ee02583a1ed4
GitHub-Last-Rev: fea8e66c8ac26809ad1d7f04462cdbde9a41020a
GitHub-Pull-Request: golang/go#37375
Reviewed-on: https://go-review.googlesource.com/c/go/+/220577
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile: consistently use OXXX for works relate to Op
Cuong Manh Le [Sat, 14 Dec 2019 19:08:41 +0000 (02:08 +0700)]
cmd/compile: consistently use OXXX for works relate to Op

Passes toolstash-check.

Change-Id: I8ff2a702c445e98c227913369c139a5ef4a04916
Reviewed-on: https://go-review.googlesource.com/c/go/+/211397
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agoencoding/json: fix broken link to json.org
Jon Johnson [Mon, 3 Feb 2020 18:15:41 +0000 (18:15 +0000)]
encoding/json: fix broken link to json.org

This updates the link to a newer image.

Change-Id: Ibdfe8c57d9217a325bcfde98cb6f952ca63d588a
GitHub-Last-Rev: f5970ba395781c0d299dfdaa1ed75e46125b8268
GitHub-Pull-Request: golang/go#36938
Reviewed-on: https://go-review.googlesource.com/c/go/+/217297
Reviewed-by: Toshihiro Shiino <shiino.toshihiro@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
5 years agosyscall: release a js.Func object in fsCall
Hajime Hoshi [Sun, 2 Feb 2020 05:55:29 +0000 (14:55 +0900)]
syscall: release a js.Func object in fsCall

(This is a reland of golang.org/cl/217417.)

A js.Func object in fsCall was created for each call but never
released. This CL fixes this.

Change-Id: Ifc0efb997c9b3e04641839691ccc04de61ef28d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/220537
Run-TryBot: Hajime Hoshi <hajimehoshi@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
5 years agocmd/compile: allow values with aux Sym to fault on nil args
Josh Bleecher Snyder [Fri, 24 Jan 2020 06:19:39 +0000 (22:19 -0800)]
cmd/compile: allow values with aux Sym to fault on nil args

And use this newfound power to more precisely describe some PPC64 ops.

Change-Id: Idb2b669d74fbab5f3508edf19f7e3347306b0daf
Reviewed-on: https://go-review.googlesource.com/c/go/+/217002
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
5 years agohash/maphash: don't discard data on random seed init
vovapi [Thu, 20 Feb 2020 19:29:22 +0000 (19:29 +0000)]
hash/maphash: don't discard data on random seed init

Hash initializes seed on the first usage of seed or state with initSeed.
initSeed uses SetSeed which discards accumulated data.
This causes hash to return different sums for the same data in the first use
and after reset.
This CL fixes this issue by separating the seed set from data discard.

Fixes #37315

Change-Id: Ic7020702c2ce822eb700af462e37efab12f72054
GitHub-Last-Rev: 48b2f963e86c1b37d49b838a050cc4128bb01266
GitHub-Pull-Request: golang/go#37328
Reviewed-on: https://go-review.googlesource.com/c/go/+/220259
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agoruntime: mark testCallersEqual as a test helper
Ian Lance Taylor [Tue, 7 Jan 2020 18:55:35 +0000 (10:55 -0800)]
runtime: mark testCallersEqual as a test helper

Change-Id: I25e6fb733618b0a7af8adc69be85f3503810acf4
Reviewed-on: https://go-review.googlesource.com/c/go/+/213658
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
5 years agotest: add test that gccgo fails to compile
Ian Lance Taylor [Thu, 9 Jan 2020 01:50:52 +0000 (17:50 -0800)]
test: add test that gccgo fails to compile

Change-Id: I14d31bb62fd0e26a84f8781644c40918404f5f3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/213899
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agotime: remove unnecessary trailing slash from "/etc/"
Ian Lance Taylor [Mon, 20 Jan 2020 20:05:08 +0000 (12:05 -0800)]
time: remove unnecessary trailing slash from "/etc/"

Fixes #36640

Change-Id: I2049b572347da1cb967f5a3f2bc342b310216435
Reviewed-on: https://go-review.googlesource.com/c/go/+/215519
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: really wait for goroutines in testSemaHandoff
Ian Lance Taylor [Thu, 13 Feb 2020 04:17:16 +0000 (20:17 -0800)]
runtime: really wait for goroutines in testSemaHandoff

The code has a comment saying that it waited for the goroutines,
but it didn't actually do so.

Change-Id: Icaeb40613711053a9f443cc34143835560427dda
Reviewed-on: https://go-review.googlesource.com/c/go/+/219277
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: allow print/println(f()) where f() is multi-value
Cuong Manh Le [Thu, 14 Nov 2019 03:00:33 +0000 (10:00 +0700)]
cmd/compile: allow print/println(f()) where f() is multi-value

Fixes #35576

Change-Id: Ia128f412120069e9f8813e9e910e62644f950bfb
Reviewed-on: https://go-review.googlesource.com/c/go/+/207118
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agocrypto/tls: update ExampleDial with a valid root
Johan Jansson [Wed, 1 Jan 2020 16:48:22 +0000 (18:48 +0200)]
crypto/tls: update ExampleDial with a valid root

When run as a separate program, the code in ExampleDial panicked due to
an expired certificate. Fixed this problem by replacing the expired
certificate with a valid one.

Also added a comment in the certificate to give a hint about why it
might fail in the future.

Fixes #35706

Change-Id: I3d300f7bccae050e4b73ded28b8029aa04b480bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/212601
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
5 years agocrypto/tls: clarify TLS 1.0/1.1 CertificateRequestInfo.SignatureSchemes
Filippo Valsorda [Thu, 21 Nov 2019 18:48:38 +0000 (13:48 -0500)]
crypto/tls: clarify TLS 1.0/1.1 CertificateRequestInfo.SignatureSchemes

This CL should not change the logic at all, but it took me a while to
figure out why we use these specific SignatureSchemes, so reformulate
the comment.

Change-Id: If519a58264209e6575417be07668e92ead0e772f
Reviewed-on: https://go-review.googlesource.com/c/go/+/208225
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
5 years agocmd/dist: test cgo internal linking PIE
Cherry Zhang [Sun, 9 Feb 2020 22:01:53 +0000 (17:01 -0500)]
cmd/dist: test cgo internal linking PIE

On platforms where internal linking PIE is supported, run
misc/cgo/test with that configuration.

Change-Id: Ia09631b07cc469c85818e1494093d802ea9d69a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/218838
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile/internal/syntax: better error when an assignment is used in value context
Robert Griesemer [Thu, 6 Feb 2020 23:32:40 +0000 (15:32 -0800)]
cmd/compile/internal/syntax: better error when an assignment is used in value context

The error message is now positioned at the statement position (which is
an identifing token, such as the '=' for assignments); and in case of
assignments it emphasizes the assignment by putting the Lhs and Rhs
in parentheses. Finally, the wording is changed from "use of * as value"
to the stronger "cannot use * as value" (for which there is precedent
elsewhere in the parser).

Fixes #36858.

Change-Id: Ic3f101bba50f58e3a1d9b29645066634631f2d61
Reviewed-on: https://go-review.googlesource.com/c/go/+/218337
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
5 years agocmd/link: also apply R_ADDR relocation statically when internal linking PIE
Cherry Zhang [Tue, 11 Feb 2020 23:26:38 +0000 (18:26 -0500)]
cmd/link: also apply R_ADDR relocation statically when internal linking PIE

When internal linking PIE, R_ADDR relocations cannot be resolved
statically so we generate dynamic relocations for it. We don't
apply the relocations statically, so the bytes in the file are
left unset (likely zero). This makes some tool that examines the
file statically, e.g. go version, to fail to find the referenced
addresses.

This CL makes the linker also apply the relocations to the file
content, so it holds the correct offsets and so can be examined
statically.

Fixes #37173.

Change-Id: Ia5c6b661f1a91a232843ca4224264bfd7a5509eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/219199
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agotest: close file in goFiles
Dmitri Shuralyov [Sun, 9 Feb 2020 00:43:58 +0000 (19:43 -0500)]
test: close file in goFiles

Brad's battery died on a plane and the file stayed open for 8 years
without anyone noticing. 😄

Someone noticed in https://github.com/gopherjs/gopherjs/pull/950.

Updates #2833

Change-Id: I46b28ac014a8c355be94e026615f119f96e5d51a
Reviewed-on: https://go-review.googlesource.com/c/go/+/218700
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
5 years agocmd/link: handle absolute address relocation in C objects for internal linking PIE
Cherry Zhang [Sun, 9 Feb 2020 22:00:27 +0000 (17:00 -0500)]
cmd/link: handle absolute address relocation in C objects for internal linking PIE

For an absolute address relocation in C objects (e.g.
R_X86_64_64), we turn it into an R_ADDR relocation and handle it
the same way. For internal linking PIE, this R_ADDR relocation
cannot be resolved statically. We need to generate a dynamic
relocation for it. This CL makes it so.

This fixes internal linking PIE on the dev.boringcrypto branch.
Test will be enabled in the next CL.

Change-Id: I9bdd6517ccd79cbbe9c64844a31536bf3da37616
Reviewed-on: https://go-review.googlesource.com/c/go/+/218837
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile: preserve shift boundedness information in dec64
Josh Bleecher Snyder [Fri, 24 Jan 2020 06:21:39 +0000 (22:21 -0800)]
cmd/compile: preserve shift boundedness information in dec64

For clarity. No differences to generated code.

Change-Id: Ie4360681caac091eb82c59fb06e35b725b1850dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/217003
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/link: generate relative relocs for PIE
Michael Pratt [Fri, 6 Dec 2019 22:25:51 +0000 (17:25 -0500)]
cmd/link: generate relative relocs for PIE

Go's PIE binaries have tons of relocations, all R_X86_64_64 [1] when
internally linked. R_X86_64_64 relocations require symbol lookup in the
dynamic linker, which can be quite slow. The simple Go HTTP server
in #36028 takes over 1s to complete dynamic linking!

The external linker generates R_X86_64_RELATIVE [2] relocations, which
are significantly more efficient. It turns out that generating these
relocations internally is quite simple, so lets do it.

Rather than referencing targ.Dynid in r_info and having the dynamic
linker do a symbol lookup and then add (final targ address) + r.Add, use
AddAddrPlus to generate another R_ADDR to have the linker compute (targ
address + r.Add). The dynamic linker is then only left with base address
+ r_addend.

Since we don't reference the symbol in the final relocation, Adddynsym
is no longer necessary, saving ~1MB (of ~9MB) from the binary size of
the example in #36028.

[1] R_AARCH64_ABS64 on arm64.
[2] R_AARCH64_RELATIVE on arm64.

Fixes #36028

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

5 years agocmd/go: print a "found" line for each package found instead of each module added
Bryan C. Mills [Fri, 14 Feb 2020 15:23:44 +0000 (10:23 -0500)]
cmd/go: print a "found" line for each package found instead of each module added

We currently print a "go: finding" line for each missing package
during import resolution. However, we are only printing a "go: found"
line for each module: if a given module provides multiple packages, we
don't indicate the module that we found for the second and later
packages.

Before this change:

$ GO111MODULE=on go get golang.org/x/tools/cmd/html2article@78f9822548c13e2c41cc8039d1492a111240db07
go: found golang.org/x/tools/cmd/html2article in golang.org/x/tools v0.0.0-20190214195451-78f9822548c1
go: finding module for package golang.org/x/net/html
go: finding module for package golang.org/x/net/html/atom
go: downloading golang.org/x/net v0.0.0-20200202094626-16171245cfb2
go: found golang.org/x/net/html in golang.org/x/net v0.0.0-20200202094626-16171245cfb2

After:

$ GO111MODULE=on go get golang.org/x/tools/cmd/html2article@78f9822548c13e2c41cc8039d1492a111240db07
go: found golang.org/x/tools/cmd/html2article in golang.org/x/tools v0.0.0-20190214195451-78f9822548c1
go: finding module for package golang.org/x/net/html/atom
go: finding module for package golang.org/x/net/html
go: found golang.org/x/net/html in golang.org/x/net v0.0.0-20200202094626-16171245cfb2
go: found golang.org/x/net/html/atom in golang.org/x/net v0.0.0-20200202094626-16171245cfb2

Updates #26152
Updates #33284

Change-Id: I221548749e36bfd6a79efe5edc3645dc5319fd6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/219437
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
5 years agocmd/compile: use shift boundedness when lowering shifts on 386
Josh Bleecher Snyder [Fri, 24 Jan 2020 05:47:42 +0000 (21:47 -0800)]
cmd/compile: use shift boundedness when lowering shifts on 386

Minor improvements to generated code.

file                                          before   after    Δ       %
runtime.s                                     451117   450977   -140    -0.031%
compress/bzip2.s                              10202    10194    -8      -0.078%
compress/lzw.s                                5924     5904     -20     -0.338%
compress/flate.s                              45053    45032    -21     -0.047%
net.s                                         236980   236970   -10     -0.004%
vendor/golang.org/x/crypto/cryptobyte.s       29450    29439    -11     -0.037%
crypto/x509.s                                 107854   107840   -14     -0.013%
cmd/vendor/golang.org/x/arch/arm64/arm64asm.s 102448   102434   -14     -0.014%
cmd/internal/obj/arm.s                        60536    60528    -8      -0.013%
cmd/vendor/golang.org/x/mod/sumdb/tlog.s      38273    38276    +3      +0.008%
net/http.s                                    462215   462201   -14     -0.003%
cmd/compile/internal/ssa.s                    3951732  3954683  +2951   +0.075%
total                                         16946051 16948745 +2694   +0.016%

Change-Id: I9f6df1a90a295dce6fe86c8eb7576a8c96f8bb0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/217000
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agoCONTRIBUTORS: second round of updates for Go 1.14
Dmitri Shuralyov [Fri, 21 Feb 2020 19:24:31 +0000 (14:24 -0500)]
CONTRIBUTORS: second round of updates for Go 1.14

This update was automatically generated using the updatecontrib command:

cd gotip
go run golang.org/x/build/cmd/updatecontrib

With minor manual changes based on publicly available information
to canonicalize letter case and formatting for a few names.

Actions taken (relative to CONTRIBUTORS at origin/master):

Added Aaron Bieber <deftly@gmail.com>
Added Adam Williams <pwnfactory@gmail.com>
Added Ayke van Laethem <aykevanlaethem@gmail.com>
Added Bradford Lamson-Scribner <brad.lamson@gmail.com>
Added Brian Falk <falk@logicparty.org>
Added Chen Zhihan <energiehund@gmail.com>
Added Christopher Loessl <cloessl+github@gmail.com>
Added Frederik Zipp <fzipp@gmx.de>
Added Fujimoto Kyosuke <kyoro.f@gmail.com>
Added GitHub User jopbrown (6345470) <msshane2008@gmail.com>
Added GitHub User yah01 (12216890) <kagaminehuan@gmail.com>
Added Hiromichi Ema <ema.hiro@gmail.com>
Added Jamal Carvalho <jamal.a.carvalho@gmail.com>
Added Jason Baker <jason-baker@users.noreply.github.com>
Added Kanta Ebihara <kantaebihara@gmail.com>
Added Kirill Tatchihin <kirabsuir@gmail.com>
Added Kévin Dunglas <dunglas@gmail.com>
Added Mariano Cano <mariano@smallstep.com>
Added Sergey Ivanov <ser1325@gmail.com>
Added Thomas Symborski <thomas.symborski@gmail.com>
Added Tomohiro Kusumoto <zabio1192@gmail.com>
Added Xingqang Bai <bxq2011hust@qq.com>
Used GitHub User jopbrown (6345470) form for jopbrown <msshane2008@gmail.com> https://github.com/golang/exp/commit/0405dc7 [exp]
Used GitHub User yah01 (12216890) form for yah01 <kagaminehuan@gmail.com> https://github.com/golang/go/commit/ee55dd6b64 [go]
Used GitHub name "Hiromichi Ema" for emahiro <ema.hiro@gmail.com> https://github.com/golang/tools/commit/b6336cbc [tools]
Used GitHub name "Jamal Carvalho" for Gopher <jamal.a.carvalho@gmail.com> https://github.com/golang/gddo/commit/31dd61d [gddo]
Used GitHub name "Xingqang Bai" for bxq2011hust <bxq2011hust@qq.com> https://github.com/golang/go/commit/79ccbe1b67 [go]

Updates #12042

Change-Id: I13f8ab37f8b38f8f5d0ff71c939ad39d0bc4f985
Reviewed-on: https://go-review.googlesource.com/c/go/+/220363
Reviewed-by: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>

5 years agocmd/go: add a regression test for package import cycles guarded by build tags
Bryan C. Mills [Mon, 3 Feb 2020 18:40:14 +0000 (13:40 -0500)]
cmd/go: add a regression test for package import cycles guarded by build tags

I've been thinking about the relationship between the package import
graph and the module import graph, and realized that the package
import graph is not always acyclic. (The package import graph must be
acyclic given a specific set of build tags, but the 'mod' subcommands
intentionally ignore build tags.)

I'm not sure whether we have any existing regression tests that cover
this sort of cycle, so I'm adding one now. Thankfully, it passes!

Updates #36460

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

5 years agocrypto/ecdsa: add SignASN1, VerifyASN1
Katie Hockman [Wed, 5 Feb 2020 20:19:41 +0000 (15:19 -0500)]
crypto/ecdsa: add SignASN1, VerifyASN1

Update the Example in the crypto/ecdsa package for signing
and verifying signatures to use these new functions.

This also changes (*PrivateKey).Sign to use
x/crypto/cryptobyte/asn1 instead of encoding/asn1
to marshal the signature.

Fixes #20544

Change-Id: I3423cfc4d7f9e1748fbed5a631438c8a3b280df4
Reviewed-on: https://go-review.googlesource.com/c/go/+/217940
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
5 years agonet/http/pprof: set content type for /debug/pprof
Hana (Hyang-Ah) Kim [Thu, 20 Feb 2020 22:25:33 +0000 (17:25 -0500)]
net/http/pprof: set content type for /debug/pprof

Fixes #37311

Change-Id: I9e1f37e991e5c203fe72061692f47584fbadfc58
Reviewed-on: https://go-review.googlesource.com/c/go/+/220324
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
5 years agodatabase/sql: add SetConnMaxIdleTime
Daniel Theophanes [Mon, 29 Oct 2018 16:09:21 +0000 (09:09 -0700)]
database/sql: add SetConnMaxIdleTime

Allow removing a connection from the connection pool after
it has been idle for a period of time, without regard to the
total lifespan of the connection.

Fixes #25232

Change-Id: Icff157b906769a2d2d45c67525e04a72feb8d832
Reviewed-on: https://go-review.googlesource.com/c/go/+/145758
Run-TryBot: Daniel Theophanes <kardianos@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
5 years agoio: check n in testReadAtLeast
Davor Kapsa [Sat, 25 Jan 2020 13:40:10 +0000 (14:40 +0100)]
io: check n in testReadAtLeast

Change-Id: I53859d4d3c729cce9f73b14dc2dd8571f7e7ffb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/216457
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agogo/constant: remove redundant octal & separator literals parsing
vovapi [Fri, 17 Jan 2020 16:38:39 +0000 (16:38 +0000)]
go/constant: remove redundant octal & separator literals parsing

Octal literals parsing was implemented in strconv in golang.org/cl/160244
and in math/big in golang.org/cl/165898.
Underscore separator parsing was implemented in strconv in golang.org/cl/160243
and in math/big golang.org/cl/166157.
Thus octal & underscore literal parsing in go/constant is removed as redundant.

This CL resolves TODO left by gri in golang.org/cl/160239 .

Change-Id: I311872dac49b1a13063e0abc1794001956620c5a
GitHub-Last-Rev: 264caf574e8dee8f1e36d9e62edb0ee3ff60d2d1
GitHub-Pull-Request: golang/go#36630
Reviewed-on: https://go-review.googlesource.com/c/go/+/215277
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agocontainer/list: remove temporary variable `n`
Joe Kyo [Wed, 13 Nov 2019 06:47:41 +0000 (00:47 -0600)]
container/list: remove temporary variable `n`

The variable `n` for saving the pointer of the next
element when insert new element into the list turns
out to be unnecessary.

Change-Id: I17b85fd8350738815c320a83945525b60c2f04c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/207037
Reviewed-by: Robert Griesemer <gri@golang.org>
5 years agocmd/compile: add a script to measure ssa/gen's coverage
Daniel Martí [Sat, 4 Jan 2020 10:45:38 +0000 (19:45 +0900)]
cmd/compile: add a script to measure ssa/gen's coverage

Since rulegen is only tested by inspecting and running its output code,
we have no good way to see if any chunks of its source are actually
being unused.

Code coverage only works as part of 'go test', since it needs to
instrument our code. Add a script that sets up a tiny test for that
purpose, with a quick example on how to use it.

We need to use a script, because there's no other way to make this work
without breaking 'go run *.go'. It's far more common to run the
generator than to obtain a coverage profile, so this solution seems like
the right tradeoff, and we don't break existing users.

The script isn't terribly portable, but that's okay for now.

At the time of wriging, coverage sits at 89.7%. I've manually skimmed
main.go and rulegen.go, and practically all unused code is either error
handling, or optional code like *genLog and "if false". A couple of
small exceptions stand out, though I'm not paying attention to them in
this CL.

While at it, inline a couple of tiny unusedInspector methods that were
only needed once or twice.

Change-Id: I78c5fb47c8536d70e546a437637d4428ec7adfaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/212760
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
5 years agocrypto/x509: correct error message for trailing issuer data
Alexander Rakoczy [Tue, 26 Nov 2019 18:45:15 +0000 (13:45 -0500)]
crypto/x509: correct error message for trailing issuer data

The error message for trailing data after the X.509 issuer should
correctly state "issuer" instead of "subject", which appears just above
this code.

Fixes #35841

Change-Id: Iea2605ce97f2b084eb78e88f2c27d7d43749d022
Reviewed-on: https://go-review.googlesource.com/c/go/+/208978
Run-TryBot: Alexander Rakoczy <alex@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
5 years agodoc/go1.14: document the change to json.Number decoding
Daniel Martí [Thu, 20 Feb 2020 20:44:18 +0000 (20:44 +0000)]
doc/go1.14: document the change to json.Number decoding

It might break a program if it was depending on undocumented behavior.
Give a proper heads up.

Fixes #37308.

Change-Id: Id65bc70def1138d5506b694329c52250b417ec6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/220418
Reviewed-by: Bryan C. Mills <bcmills@google.com>
5 years agonet/mail: skip empty entries in parseAddressList
Timmy Douglas [Sat, 1 Feb 2020 22:14:30 +0000 (22:14 +0000)]
net/mail: skip empty entries in parseAddressList

RFC 5322 has a section 4.4 where it says that address-list could
have "null" members: "That is, there could be two or more commas in
such a list with nothing in between them, or commas at the beginning
or end of the list." This change handles such a case so that mail
clients using this method on actual email messages get a reasonable
return value when they parse email.

Fixes #36959

Change-Id: I3ca240969935067262e3d751d376a06db1fef2a2
GitHub-Last-Rev: b96a9f2c075dfd67c3ff7b8ae0c12e12035f0da0
GitHub-Pull-Request: golang/go#36966
Reviewed-on: https://go-review.googlesource.com/c/go/+/217377
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
5 years agotesting: testing: add (*T).Deadline method for test timeout
Bryan C. Mills [Wed, 23 Oct 2019 14:54:09 +0000 (10:54 -0400)]
testing: testing: add (*T).Deadline method for test timeout

Fixes #28135

Change-Id: I62818595eaf4a59d8b5c26cd6848c08fec795ad1
Reviewed-on: https://go-review.googlesource.com/c/go/+/202758
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
5 years agocmd/compile: clarify division bounds check optimization
Josh Bleecher Snyder [Fri, 24 Jan 2020 06:18:30 +0000 (22:18 -0800)]
cmd/compile: clarify division bounds check optimization

The name of the function should mention division.
Eliminate double negatives from the comment describing it.

Change-Id: Icef1a5139b3a91b86acb930af97938f5160f7342
Reviewed-on: https://go-review.googlesource.com/c/go/+/217001
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
5 years agocmd/compile: coalesce some 386 shift lowering rules
Josh Bleecher Snyder [Fri, 24 Jan 2020 05:45:11 +0000 (21:45 -0800)]
cmd/compile: coalesce some 386 shift lowering rules

No changes to generated rule matching code.

Change-Id: I0009146a6be30e151a403c4801c03abf0646703d
Reviewed-on: https://go-review.googlesource.com/c/go/+/216999
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
5 years agocmd/compile: preserve shift boundness during wasm rewrite rules
Josh Bleecher Snyder [Fri, 24 Jan 2020 01:45:54 +0000 (17:45 -0800)]
cmd/compile: preserve shift boundness during wasm rewrite rules

Mostly for clarity. There are nominal improvements to the generated code:

file      before    after     Δ       %
addr2line 4742769   4742639   -130    -0.003%
api       6973284   6973209   -75     -0.001%
asm       5922230   5922127   -103    -0.002%
buildid   3117327   3117252   -75     -0.002%
cgo       5539274   5539199   -75     -0.001%
compile   27423605  27424940  +1335   +0.005%
cover     6096973   6096898   -75     -0.001%
dist      4121655   4121580   -75     -0.002%
doc       5386254   5386179   -75     -0.001%
fix       3755243   3755168   -75     -0.002%
link      7602682   7602607   -75     -0.001%
nm        4687186   4687056   -130    -0.003%
objdump   5184883   5184753   -130    -0.003%
pack      2511360   2511285   -75     -0.003%
pprof     16872050  16871832  -218    -0.001%
test2json 3060633   3060558   -75     -0.002%
trace     13170181  13170018  -163    -0.001%
vet       9865995   9865920   -75     -0.001%
total     151188868 151188504 -364    -0.000%

Change-Id: If765e3661549d183a2dbb44e83521c4a3f61d175
Reviewed-on: https://go-review.googlesource.com/c/go/+/216998
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
5 years agocmd/compile: add rule location to some rulegen logging
Josh Bleecher Snyder [Wed, 22 Jan 2020 17:59:24 +0000 (09:59 -0800)]
cmd/compile: add rule location to some rulegen logging

This requires threading location information through varCount.

This provides much more useful error messages.

Change-Id: If5ff942cbbbf386724eda15a523c181c137fac20
Reviewed-on: https://go-review.googlesource.com/c/go/+/216221
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
5 years agocmd/compile: remove chunking of rewrite rules
Josh Bleecher Snyder [Wed, 22 Jan 2020 04:53:30 +0000 (20:53 -0800)]
cmd/compile: remove chunking of rewrite rules

We added chunking of rewrite rules to speed up compiling package SSA.
This series of changes has significantly shrunk the number of
rewrite rules, and they are no longer being added nearly as fast.
Now that we are sharing v.Args across multiple rewrite rules,
there is additional benefit to having more rules in a single function.
Removing chunking now has an incidental impact on compiling package SSA,
marginally speeds up other compilation, shrinks the cmd/compile binary,
and simplifies the code.

name        old time/op       new time/op       delta
Template          211ms ± 2%        210ms ± 2%  -0.50%  (p=0.000 n=91+97)
Unicode          81.9ms ± 3%       81.8ms ± 3%    ~     (p=0.179 n=96+91)
GoTypes           731ms ± 2%        731ms ± 1%    ~     (p=0.442 n=94+96)
Compiler          3.43s ± 2%        3.41s ± 2%  -0.36%  (p=0.001 n=98+94)
SSA               8.30s ± 2%        8.32s ± 2%  +0.19%  (p=0.034 n=94+95)
Flate             135ms ± 2%        134ms ± 1%  -0.30%  (p=0.006 n=98+94)
GoParser          167ms ± 1%        167ms ± 1%  -0.22%  (p=0.001 n=92+94)
Reflect           453ms ± 2%        453ms ± 3%    ~     (p=0.306 n=98+97)
Tar               184ms ± 2%        183ms ± 2%  -0.31%  (p=0.012 n=94+94)
XML               249ms ± 2%        248ms ± 1%  -0.26%  (p=0.002 n=96+92)
[Geo mean]        419ms             418ms       -0.21%

name        old user-time/op  new user-time/op  delta
Template          273ms ± 2%        272ms ± 2%  -0.46%  (p=0.000 n=93+96)
Unicode           116ms ± 4%        117ms ± 4%    ~     (p=0.433 n=98+98)
GoTypes           977ms ± 2%        977ms ± 1%    ~     (p=0.971 n=92+99)
Compiler          4.56s ± 6%        4.53s ± 6%    ~     (p=0.081 n=100+100)
SSA               11.1s ± 2%        11.1s ± 2%    ~     (p=0.064 n=99+96)
Flate             167ms ± 2%        167ms ± 1%  -0.24%  (p=0.004 n=95+96)
GoParser          203ms ± 1%        203ms ± 2%  -0.14%  (p=0.049 n=96+97)
Reflect           595ms ± 2%        595ms ± 2%    ~     (p=0.544 n=95+92)
Tar               225ms ± 2%        224ms ± 2%    ~     (p=0.562 n=99+99)
XML               312ms ± 2%        311ms ± 1%    ~     (p=0.050 n=97+93)
[Geo mean]        543ms             542ms       -0.13%

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