]> Cypherpunks repositories - gostls13.git/log
gostls13.git
4 years ago[dev.typeparams] cmd/compile/internal/types2: review of initorder.go
Robert Griesemer [Tue, 27 Oct 2020 18:26:54 +0000 (11:26 -0700)]
[dev.typeparams] cmd/compile/internal/types2: review of initorder.go

Difference: errorf now accepts any value that implements
the poser interface in place of a position argument. All
types2 Objects implement poser.

type poser interface {
Pos() syntax.Pos
}

f=initorder.go; diff $f ../../../../go/types/$f
5c5
< package types2
---
> package types
154c154
<  check.errorf(obj, "initialization cycle for %s", obj.Name())
---
>  check.errorf(obj.Pos(), "initialization cycle for %s", obj.Name())
157c157
<  check.errorf(obj, "\t%s refers to", obj.Name()) // secondary error, \t indented
---
>  check.errorf(obj.Pos(), "\t%s refers to", obj.Name()) // secondary error, \t indented
161c161
<  check.errorf(obj, "\t%s", obj.Name())
---
>  check.errorf(obj.Pos(), "\t%s", obj.Name())

Change-Id: Id85074fd15a04bb4ff6e8b68a44be6ac5919c71a
Reviewed-on: https://go-review.googlesource.com/c/go/+/265678
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years ago[dev.typeparams] cmd/compile/internal/types2: review of package.go
Robert Griesemer [Tue, 27 Oct 2020 18:19:47 +0000 (11:19 -0700)]
[dev.typeparams] cmd/compile/internal/types2: review of package.go

f=package.go; diff $f ../../../../go/types/$f
5c5
< package types2
---
> package types
8a9
>  "go/token"
25c26
<  scope := NewScope(Universe, nopos, nopos, fmt.Sprintf("package %q", path))
---
>  scope := NewScope(Universe, token.NoPos, token.NoPos, fmt.Sprintf("package %q", path))

Change-Id: I3a34b39e337c2d0224445e5dc5fbd4a6a53f0363
Reviewed-on: https://go-review.googlesource.com/c/go/+/265677
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
4 years ago[dev.typeparams] cmd/compile: enable type-checking of generic code
Robert Griesemer [Thu, 22 Oct 2020 22:32:05 +0000 (15:32 -0700)]
[dev.typeparams] cmd/compile: enable type-checking of generic code

This change makes a first connection between the compiler and types2.
When the -G flag is provided, the compiler accepts code using type
parameters; with this change generic code is also type-checked (but
then compilation ends).

Change-Id: I0fa6f6213267a458a6b33afe8ff26869fd838a63
Reviewed-on: https://go-review.googlesource.com/c/go/+/264303
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.typeparams] merge master into dev.typeparams
Rob Findley [Fri, 23 Oct 2020 13:25:24 +0000 (09:25 -0400)]
[dev.typeparams] merge master into dev.typeparams

On top of the merge, the following fixes were applied:
 + Debug["G"] changed to Debug.G, following golang.org/cl/263539.
 + issue42058a.go and issue42058b.go were skipped in
   types2/stdlib_test.go. go/types does not produce errors related to
   channel element size.

Change-Id: I59fc84e12a2d728ef789fdc616f7afe80e451283

4 years agogo/ast: import AST changes supporting typeparams from dev.go2go
Rob Findley [Wed, 21 Oct 2020 18:36:21 +0000 (14:36 -0400)]
go/ast: import AST changes supporting typeparams from dev.go2go

Minimal changes are made to existing types in go/ast to support type
parameters. Namely:
 + FieldList is overloaded to hold type parameter lists. In this case,
   the field name becomes the type identifier, and the field type
   becomes the constraint.
 + FuncType and TypeSpec gain a TParams FieldList.
 + CallExpr gains a 'Brackets' flag, signaling that it uses '[]' rather
   than '()', representing a generic type expression with type
   parameters.

Modifications from dev.go2go: the 'UseBrackets' field was removed from
ast.File, as this support is no longer necessary.

Change-Id: I21fd7390f1800dece3c14e6ec015fb2419e9fc52
Reviewed-on: https://go-review.googlesource.com/c/go/+/264181
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Trust: Robert Findley <rfindley@google.com>

4 years agoall: add GOOS=ios GOARCH=amd64 target for the ios simulator
Elias Naur [Tue, 20 Oct 2020 09:01:46 +0000 (11:01 +0200)]
all: add GOOS=ios GOARCH=amd64 target for the ios simulator

The Go toolchain has supported the simulator for years, but always in
buildmode=c-archive which is intrinsically externally linked and PIE.

This CL moves that support from GOOS=darwin GOARCH=amd64 -tags=ios to
just GOOS=ios GOARCH=amd64 to match the change for iOS devices.

This change also forces external linking and defaults to buildmode=pie
to support Go binaries in the default buildmode to run on the simulator.

CL 255257 added the necessary support to the exec wrapper.

Updates #38485
Fixes #42100

Change-Id: I6e6ee0e8d421be53b31e3d403880e5b9b880d031
Reviewed-on: https://go-review.googlesource.com/c/go/+/263798
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Elias Naur <mail@eliasnaur.com>

4 years agoruntime: move s390x HWCap CPU feature detection to internal/cpu
Martin Möhrmann [Tue, 20 Oct 2020 12:21:07 +0000 (14:21 +0200)]
runtime: move s390x HWCap CPU feature detection to internal/cpu

Change-Id: I7d9e31c3b342731ddd7329962426fdfc80e9ed87
Reviewed-on: https://go-review.googlesource.com/c/go/+/263803
Trust: Martin Möhrmann <moehrmann@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
4 years agocmd/compile: remove go115flagallocdeadcode
Cherry Zhang [Thu, 22 Oct 2020 01:09:57 +0000 (21:09 -0400)]
cmd/compile: remove go115flagallocdeadcode

Change-Id: Iafd72fb06a491075f7f996a6684e0d495c96aee5
Reviewed-on: https://go-review.googlesource.com/c/go/+/264342
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: remove go115shortcircuitPhis
Cherry Zhang [Thu, 22 Oct 2020 01:08:39 +0000 (21:08 -0400)]
cmd/compile: remove go115shortcircuitPhis

Change-Id: Ib2697ebfcc14a01ab1f793cddcbf69180ffc49a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/264341
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: remove go115makeslicecopy
Cherry Zhang [Thu, 22 Oct 2020 01:06:44 +0000 (21:06 -0400)]
cmd/compile: remove go115makeslicecopy

Change-Id: I6fd65fe7c1046c3ba7d7ed0e67282f879c13e9e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/264340
Trust: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoruntime: define the AddrRange used for testing in terms of addrRange
Michael Anthony Knyszek [Tue, 14 Jul 2020 20:27:27 +0000 (20:27 +0000)]
runtime: define the AddrRange used for testing in terms of addrRange

Currently the AddrRange used for testing is defined separately from
addrRange in the runtime, making it difficult to test it as well as
addrRanges. Redefine AddrRange in terms of addrRange instead.

For #40191.

Change-Id: I3aa5b8df3e4c9a3c494b46ab802dd574b2488141
Reviewed-on: https://go-review.googlesource.com/c/go/+/242677
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
4 years agocmd/go: set TOOLEXEC_IMPORTPATH for -toolexec tools
Daniel Martí [Sat, 17 Oct 2020 19:03:19 +0000 (20:03 +0100)]
cmd/go: set TOOLEXEC_IMPORTPATH for -toolexec tools

This way, a -toolexec tool can tell precisely what package is being
built when it's run. This was very hard to do before, because the tool
had to piece together that information given the build action's
arguments or flags.

Since there wasn't a good set of tests for -toolexec, add one in the
form of a test script. It builds a simple set of packages with a variety
of build tools, to ensure that all the cases behave as expected.

Like other recent master changes, include the changelog item for this
user-facing change too.

Fixes #15677.

Change-Id: I0a5a1d9485840323ec138b2e64b7e7dd803fdf90
Reviewed-on: https://go-review.googlesource.com/c/go/+/263357
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>

4 years agocmd/go: use the last -linkmode flag to determine external linking
Xiangdong Ji [Sun, 18 Oct 2020 18:43:23 +0000 (11:43 -0700)]
cmd/go: use the last -linkmode flag to determine external linking

Current linkmode checking in determining package dependencies doesn't
take multiple -linkmode options into consideration, may lead to redundant
dependency on 'runtime/cgo'.

Fixes the problem and adds a testcase.

Change-Id: Iac5ea9fb3ca5ef931201afd0f3441f41f946c919
Reviewed-on: https://go-review.googlesource.com/c/go/+/263497
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd,cmd/vendor: pick up updates for golang.org/x/arch/ppc64
Lynn Boger [Mon, 12 Oct 2020 14:52:16 +0000 (10:52 -0400)]
cmd,cmd/vendor: pick up updates for golang.org/x/arch/ppc64

Bring in updates to golang.org/x/arch/ppc64 to add new
instructions from CLs 260617, 230957, 249158.

Used the directions found in README.vendor:

  cd $GOROOT/src/cmd
  go get -d golang.org/x/arch@latest
  go mod tidy
  go mod vendor

Change-Id: Ie8ceb9c804928b72b37fff5b63981c174fb86989
Reviewed-on: https://go-review.googlesource.com/c/go/+/264079
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agoimports: make ScanDir ignore go files start with dot
Keyuan [Wed, 21 Oct 2020 02:47:29 +0000 (19:47 -0700)]
imports: make ScanDir ignore go files start with dot

Adding "." Prefix Check for go files.

Fixes #42047
Change-Id: Ifc42bf562f52fdd304f9828b06fc57888fcd8049
Reviewed-on: https://go-review.googlesource.com/c/go/+/264078
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>

4 years agocmd/go: when module enabled, `go clean` removes built binary
hitzhangjie [Wed, 21 Oct 2020 05:09:26 +0000 (05:09 +0000)]
cmd/go: when module enabled, `go clean` removes built binary

Now "go clean" can remove binary as expected, when module enabled and the module name isn't  "main" or the name of folder.

Fixes issue #41656

Change-Id: I54b9435ece045e03a12dc230efe84c8dd381a07c
GitHub-Last-Rev: f4ea2d8c765a6e3a2b89fe2c9fb5b2c80551efa5
GitHub-Pull-Request: golang/go#41999
Reviewed-on: https://go-review.googlesource.com/c/go/+/262677
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Trust: Bryan C. Mills <bcmills@google.com>

4 years agocmd/compile: make gc debug flags collector a struct
Alberto Donizetti [Mon, 19 Oct 2020 09:31:10 +0000 (11:31 +0200)]
cmd/compile: make gc debug flags collector a struct

gc debug flags are currently stored in a 256-long array, that is then
addressed using the ASCII numeric value of the flag itself (a quirk
inherited from the old C compiler). It is also a little wasteful,
since we only define 16 flags, and the other 240 array elements are
always empty.

This change makes Debug a struct, which also provides static checking
that we're not referencing flags that does not exist.

Change-Id: I2f0dfef2529325514b3398cf78635543cdf48fe0
Reviewed-on: https://go-review.googlesource.com/c/go/+/263539
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Run-TryBot: Alberto Donizetti <alb.donizetti@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agogo/build: recognize and report //go:embed lines
Russ Cox [Mon, 19 Oct 2020 11:46:09 +0000 (07:46 -0400)]
go/build: recognize and report //go:embed lines

The code in this CL does the work of looking for the "embed" import
and then finding and recording the arguments to //go:embed lines
in Go source files. The go command will use this information to prepare
information about embedded files to pass to the compiler.

The tests of the Package fields end up being end-to-end via the
go command (added in the CL with the go command changes),
like all the other Package fields.

For #41191.

Change-Id: I0c87b71ca809c0031603cc403c030d3088299e6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/243941
Trust: Russ Cox <rsc@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agonet: add Example for Unix dialer with context
Kevin Burke [Sun, 18 Oct 2020 16:49:16 +0000 (09:49 -0700)]
net: add Example for Unix dialer with context

Showing users how to accomplish this more easily is a compromise
between doing nothing and adding a new API to the net package.

Fixes #38506.

Change-Id: I43f831cf94951c987cf3c8c1aa55f0012ee8034e
Reviewed-on: https://go-review.googlesource.com/c/go/+/263417
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>

4 years agoencoding/xml: fix reserved namespace check to be case-insensitive
Ian Lance Taylor [Tue, 20 Oct 2020 22:19:36 +0000 (15:19 -0700)]
encoding/xml: fix reserved namespace check to be case-insensitive

Fixes the check for the reserved namespace prefix
"xml" to be case insensitive, so as to match all variants of:

    (('X'|'x')('M'|'m')('L'|'l'))

as mandated by Section 2.3 of https://www.w3.org/TR/REC-xml/

This is a roll forward of CL 203417, which was rolled back by CL 240179.
We've decided that the roll back was incorrect, and any broken tests
should be fixed.

The original CL 203417 was by Tamás Gulácsi.

Fixes #35151
For #39876

Change-Id: I2e6daa7aeb252531fba0b8a56086613e13059528
Reviewed-on: https://go-review.googlesource.com/c/go/+/264024
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agoruntime/race: update race .syso files
Keith Randall [Wed, 21 Oct 2020 03:08:30 +0000 (20:08 -0700)]
runtime/race: update race .syso files

Fixes #39186

Change-Id: I624ab73b3083f190978c09716672ce1b712a5c81
Reviewed-on: https://go-review.googlesource.com/c/go/+/264082
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Keith Randall <khr@golang.org>

4 years agonet/http: test that ParseMultipartForm catches overflows
Emmanuel T Odeke [Tue, 20 Oct 2020 11:11:12 +0000 (04:11 -0700)]
net/http: test that ParseMultipartForm catches overflows

Tests that if the combination of:
* HTTP multipart file payload size
* ParseMultipartForm's maxMemory parameter
* the internal leeway buffer size of 10MiB

overflows, then we'll report an overflow instead of silently
passing.

Reapplies and fixes CL 254977, which was reverted in CL 263658.

The prior test lacked a res.Body.Close(), so fixed that and
added a leaked Transport check to verify correctness.

Updates 40430.

Change-Id: I3c0f7ef43d621f6eb00f07755f04f9f36c51f98f
Reviewed-on: https://go-review.googlesource.com/c/go/+/263817
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Damien Neil <dneil@google.com>

4 years agocmd/compile: use desired info when allocating registers for live values
eric fang [Mon, 19 Oct 2020 03:57:15 +0000 (03:57 +0000)]
cmd/compile: use desired info when allocating registers for live values

When allocting registers for live values, use desired register if available,
this is helpful for some cases, such as (*entry).delete, which can save a
few of copies.
Besides, this patch allows more debugging information to be printed out.

Test results of compilecmp on Linux/amd64:
name                      old time/op                 new time/op                 delta
Template                    326729362.060000ns +- 3%    329227238.775510ns +- 4%  +0.76%  (p=0.038 n=50+49)
Unicode                     157671860.391304ns +- 6%    156917927.320000ns +- 6%    ~     (p=0.291 n=46+50)
GoTypes                    1065591138.304348ns +- 2%   1063695977.434783ns +- 1%    ~     (p=0.208 n=46+46)
Compiler                   5053424790.760001ns +- 2%   5052729636.551020ns +- 3%    ~     (p=0.908 n=50+49)
SSA                       12392067635.866669ns +- 2%  12319786960.460005ns +- 2%  -0.58%  (p=0.008 n=45+50)
Flate                       212609767.340000ns +- 5%    213011228.085106ns +- 5%    ~     (p=0.685 n=50+47)
GoParser                    266870495.100000ns +- 4%    266962314.280000ns +- 3%    ~     (p=0.975 n=50+50)
Reflect                     660164306.551021ns +- 2%    658284470.729167ns +- 2%    ~     (p=0.069 n=49+48)
Tar                         292805895.720000ns +- 4%    292103626.954545ns +- 2%    ~     (p=0.321 n=50+44)
XML                         386294811.700000ns +- 4%    386665088.820000ns +- 4%    ~     (p=0.786 n=50+50)
LinkCompiler                548495788.659575ns +- 5%    549359489.102041ns +- 4%    ~     (p=0.855 n=47+49)
ExternalLinkCompiler       1810414270.280000ns +- 2%   1806872224.673470ns +- 2%    ~     (p=0.313 n=50+49)
LinkWithoutDebugCompiler    340888843.795918ns +- 5%    340341541.100000ns +- 6%    ~     (p=0.735 n=49+50)
[Geo mean]                   664550174.613777ns          664090221.153575ns       -0.07%

name                      old user-time/op            new user-time/op            delta
Template                    565202800.000000ns +-16%    595351040.000000ns +-16%  +5.33%  (p=0.001 n=50+50)
Unicode                     378444740.000000ns +-14%    373825183.673469ns +-17%    ~     (p=0.458 n=50+49)
GoTypes                    2052073341.463415ns +-12%   2059679864.864865ns +- 7%    ~     (p=0.381 n=41+37)
Compiler                   9913371980.000000ns +-20%   9848836720.000002ns +-19%    ~     (p=0.781 n=50+50)
SSA                       25013846224.489799ns +-17%  24571896183.673466ns +-17%    ~     (p=0.132 n=49+49)
Flate                       314422702.127660ns +-17%    314831666.666667ns +-11%    ~     (p=0.427 n=47+45)
GoParser                    419496060.000000ns +- 9%    417403460.000000ns +-11%    ~     (p=0.512 n=50+50)
Reflect                    1233632469.387755ns +-17%   1193061073.170732ns +-13%  -3.29%  (p=0.030 n=49+41)
Tar                         509855937.500000ns +-10%    508700740.000000ns +-14%    ~     (p=0.890 n=48+50)
XML                         703511425.531915ns +-12%    694007591.836735ns +-11%    ~     (p=0.164 n=47+49)
LinkCompiler                993137687.500000ns +- 6%    991914714.285714ns +- 8%    ~     (p=0.860 n=48+49)
ExternalLinkCompiler       2193851840.000001ns +- 3%   2186672183.673470ns +- 5%    ~     (p=0.320 n=50+49)
LinkWithoutDebugCompiler    420800875.000000ns +-10%    422062640.000000ns +- 9%    ~     (p=0.840 n=48+50)
[Geo mean]                  1145156131.480097ns         1142033233.550961ns       -0.27%

name                      old alloc/op                new alloc/op                delta
Template                                36.3MB +- 0%                36.3MB +- 0%    ~     (p=0.886 n=50+49)
Unicode                                 30.1MB +- 0%                30.1MB +- 0%    ~     (p=0.792 n=50+50)
GoTypes                                  118MB +- 0%                 118MB +- 0%    ~     (p=1.000 n=47+48)
Compiler                                 562MB +- 0%                 562MB +- 0%    ~     (p=0.205 n=50+49)
SSA                                     1.42GB +- 0%                1.42GB +- 0%  -0.12%  (p=0.000 n=50+50)
Flate                                   22.8MB +- 0%                22.8MB +- 0%    ~     (p=0.384 n=50+47)
GoParser                                28.0MB +- 0%                28.0MB +- 0%  -0.02%  (p=0.013 n=50+50)
Reflect                                 78.0MB +- 0%                78.0MB +- 0%    ~     (p=0.384 n=46+48)
Tar                                     34.1MB +- 0%                34.1MB +- 0%    ~     (p=0.072 n=50+50)
XML                                     43.1MB +- 0%                43.1MB +- 0%  -0.04%  (p=0.000 n=49+50)
LinkCompiler                            98.5MB +- 0%                98.5MB +- 0%  +0.01%  (p=0.012 n=50+43)
ExternalLinkCompiler                    89.6MB +- 0%                89.6MB +- 0%    ~     (p=0.762 n=50+50)
LinkWithoutDebugCompiler                56.9MB +- 0%                56.9MB +- 0%    ~     (p=0.268 n=49+48)
[Geo mean]                               77.7MB                      77.7MB       -0.01%

name                      old allocs/op               new allocs/op               delta
Template                                  367k +- 0%                  367k +- 0%  -0.01%  (p=0.002 n=50+49)
Unicode                                   345k +- 0%                  345k +- 0%    ~     (p=0.981 n=50+50)
GoTypes                                  1.28M +- 0%                 1.28M +- 0%  -0.00%  (p=0.002 n=49+50)
Compiler                                 5.39M +- 0%                 5.39M +- 0%  -0.00%  (p=0.000 n=50+50)
SSA                                      13.9M +- 0%                 13.9M +- 0%  +0.01%  (p=0.000 n=50+50)
Flate                                     230k +- 0%                  230k +- 0%    ~     (p=0.815 n=50+50)
GoParser                                  292k +- 0%                  292k +- 0%  -0.01%  (p=0.000 n=50+50)
Reflect                                   977k +- 0%                  977k +- 0%  -0.00%  (p=0.035 n=50+50)
Tar                                       343k +- 0%                  343k +- 0%  -0.01%  (p=0.008 n=48+50)
XML                                       418k +- 0%                  418k +- 0%  -0.01%  (p=0.000 n=50+50)
LinkCompiler                              516k +- 0%                  516k +- 0%  +0.01%  (p=0.002 n=50+48)
ExternalLinkCompiler                      570k +- 0%                  570k +- 0%    ~     (p=0.430 n=46+50)
LinkWithoutDebugCompiler                  169k +- 0%                  169k +- 0%    ~     (p=0.706 n=49+49)
[Geo mean]                                 672k                        672k       -0.00%

name                      old maxRSS/op               new maxRSS/op               delta
Template                                 34.3M +- 5%                 34.7M +- 4%  +1.24%  (p=0.004 n=50+50)
Unicode                                  36.2M +- 5%                 36.1M +- 8%    ~     (p=0.785 n=50+50)
GoTypes                                  75.7M +- 7%                 76.1M +- 6%    ~     (p=0.544 n=50+50)
Compiler                                  304M +- 7%                  304M +- 7%    ~     (p=0.744 n=50+50)
SSA                                       721M +- 6%                  723M +- 7%    ~     (p=0.724 n=49+50)
Flate                                    26.1M +- 3%                 26.1M +- 5%    ~     (p=0.649 n=48+49)
GoParser                                 29.3M +- 5%                 29.3M +- 4%    ~     (p=0.809 n=50+50)
Reflect                                  56.0M +- 6%                 56.3M +- 5%    ~     (p=0.350 n=50+50)
Tar                                      34.1M +- 3%                 33.9M +- 5%    ~     (p=0.121 n=49+50)
XML                                      39.6M +- 5%                 39.9M +- 4%    ~     (p=0.109 n=50+50)
LinkCompiler                              168M +- 1%                  168M +- 1%    ~     (p=0.578 n=49+48)
ExternalLinkCompiler                      179M +- 1%                  179M +- 2%    ~     (p=0.522 n=46+46)
LinkWithoutDebugCompiler                  137M +- 3%                  137M +- 3%    ~     (p=0.463 n=41+50)
[Geo mean]                                79.3M                       79.5M       +0.20%

name                      old text-bytes              new text-bytes              delta
HelloSize                                812kB +- 0%                 811kB +- 0%  -0.05%  (p=0.000 n=50+50)

name                      old data-bytes              new data-bytes              delta
HelloSize                               13.3kB +- 0%                13.3kB +- 0%    ~     (all equal)

name                      old bss-bytes               new bss-bytes               delta
HelloSize                                206kB +- 0%                 206kB +- 0%    ~     (all equal)

name                      old exe-bytes               new exe-bytes               delta
HelloSize                               1.21MB +- 0%                1.21MB +- 0%  +0.02%  (p=0.000 n=50+50)

file      before    after     Δ       %
addr2line 4052949   4052453   -496    -0.012%
api       4948171   4947163   -1008   -0.020%
asm       4888889   4888049   -840    -0.017%
buildid   2617545   2617673   +128    +0.005%
cgo       4521681   4516801   -4880   -0.108%
compile   19139091  19137683  -1408   -0.007%
cover     4843191   4840359   -2832   -0.058%
dist      3473677   3474717   +1040   +0.030%
doc       3821592   3821552   -40     -0.001%
fix       3220587   3220059   -528    -0.016%
link      6587368   6582696   -4672   -0.071%
nm        3999858   3999186   -672    -0.017%
objdump   4409161   4408217   -944    -0.021%
pack      2394038   2393846   -192    -0.008%
pprof     13601271  13602487  +1216   +0.009%
test2json 2645148   2644604   -544    -0.021%
trace     10357878  10356862  -1016   -0.010%
vet       6779482   6778706   -776    -0.011%
total     106301577 106283113 -18464  -0.017%

Change-Id: I63ac6e224e1a4756ddc1bfc4aabbaeb92d7d4273
Reviewed-on: https://go-review.googlesource.com/c/go/+/263599
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: eric fang <eric.fang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/compile: optimize regalloc for phi value
erifan01 [Mon, 19 Oct 2020 03:20:24 +0000 (11:20 +0800)]
cmd/compile: optimize regalloc for phi value

When allocating registers for phi value, only the primary predecessor is considered.
Taking into account the allocation status of other predecessors can help reduce
unnecessary copy or spill operations. Many such cases can be found in the standard
library, such as runtime.wirep, moveByType, etc. The test results from benchstat
also show that this change helps reduce the file size.

name                      old time/op       new time/op       delta
Template                        328ms ± 5%        326ms ± 4%    ~     (p=0.254 n=50+47)
Unicode                         156ms ± 7%        158ms ±10%    ~     (p=0.412 n=49+49)
GoTypes                         1.07s ± 3%        1.07s ± 2%    ~     (p=0.664 n=48+49)
Compiler                        4.43s ± 3%        4.44s ± 3%    ~     (p=0.758 n=48+50)
SSA                             10.3s ± 2%        10.4s ± 2%  +0.43%  (p=0.017 n=50+46)
Flate                           208ms ± 9%        209ms ± 7%    ~     (p=0.920 n=49+46)
GoParser                        260ms ± 5%        262ms ± 4%    ~     (p=0.063 n=50+48)
Reflect                         687ms ± 3%        685ms ± 2%    ~     (p=0.459 n=50+48)
Tar                             293ms ± 4%        293ms ± 5%    ~     (p=0.695 n=49+48)
XML                             391ms ± 4%        389ms ± 3%    ~     (p=0.109 n=49+46)
LinkCompiler                    570ms ± 5%        563ms ± 5%  -1.10%  (p=0.006 n=46+47)
ExternalLinkCompiler            1.57s ± 3%        1.56s ± 3%    ~     (p=0.118 n=47+46)
LinkWithoutDebugCompiler        349ms ± 6%        349ms ± 5%    ~     (p=0.726 n=49+47)
[Geo mean]                      645ms             645ms       -0.05%

name                      old user-time/op  new user-time/op  delta
Template                        507ms ±14%        513ms ±14%    ~     (p=0.398 n=48+49)
Unicode                         345ms ±29%        345ms ±38%    ~     (p=0.521 n=47+49)
GoTypes                         1.95s ±16%        1.94s ±19%    ~     (p=0.324 n=50+50)
Compiler                        8.26s ±16%        8.22s ±14%    ~     (p=0.834 n=50+50)
SSA                             19.6s ± 8%        19.2s ±15%    ~     (p=0.056 n=50+50)
Flate                           293ms ± 9%        299ms ±12%    ~     (p=0.057 n=47+50)
GoParser                        388ms ± 9%        387ms ±14%    ~     (p=0.660 n=46+50)
Reflect                         1.15s ±28%        1.12s ±18%    ~     (p=0.648 n=49+48)
Tar                             456ms ±10%        476ms ±15%  +4.48%  (p=0.001 n=46+48)
XML                             648ms ±27%        634ms ±16%    ~     (p=0.685 n=50+46)
LinkCompiler                    1.00s ± 8%        1.00s ± 8%    ~     (p=0.638 n=50+50)
ExternalLinkCompiler            1.96s ± 5%        1.96s ± 5%    ~     (p=0.792 n=50+50)
LinkWithoutDebugCompiler        443ms ±10%        442ms ±11%    ~     (p=0.813 n=50+50)
[Geo mean]                      1.05s             1.05s       -0.09%

name                      old alloc/op      new alloc/op      delta
Template                       36.0MB ± 0%       36.0MB ± 0%    ~     (p=0.599 n=49+50)
Unicode                        29.8MB ± 0%       29.8MB ± 0%    ~     (p=0.739 n=50+50)
GoTypes                         118MB ± 0%        118MB ± 0%    ~     (p=0.436 n=50+50)
Compiler                        562MB ± 0%        562MB ± 0%    ~     (p=0.693 n=50+50)
SSA                            1.42GB ± 0%       1.42GB ± 0%  -0.10%  (p=0.000 n=50+49)
Flate                          22.5MB ± 0%       22.5MB ± 0%    ~     (p=0.429 n=48+49)
GoParser                       27.7MB ± 0%       27.7MB ± 0%    ~     (p=0.705 n=49+48)
Reflect                        77.7MB ± 0%       77.7MB ± 0%  -0.01%  (p=0.043 n=50+50)
Tar                            33.8MB ± 0%       33.8MB ± 0%    ~     (p=0.241 n=49+50)
XML                            42.8MB ± 0%       42.8MB ± 0%    ~     (p=0.677 n=47+49)
LinkCompiler                   98.3MB ± 0%       98.3MB ± 0%    ~     (p=0.157 n=50+50)
ExternalLinkCompiler           89.4MB ± 0%       89.4MB ± 0%    ~     (p=0.683 n=50+50)
LinkWithoutDebugCompiler       56.7MB ± 0%       56.7MB ± 0%    ~     (p=0.155 n=49+49)
[Geo mean]                     77.3MB            77.3MB       -0.01%

name                      old allocs/op     new allocs/op     delta
Template                         367k ± 0%         367k ± 0%    ~     (p=0.863 n=50+50)
Unicode                          345k ± 0%         345k ± 0%    ~     (p=0.744 n=49+49)
GoTypes                         1.28M ± 0%        1.28M ± 0%    ~     (p=0.957 n=48+50)
Compiler                        5.39M ± 0%        5.39M ± 0%  +0.00%  (p=0.012 n=50+49)
SSA                             13.9M ± 0%        13.9M ± 0%  +0.02%  (p=0.000 n=47+49)
Flate                            230k ± 0%         230k ± 0%  -0.01%  (p=0.007 n=47+49)
GoParser                         292k ± 0%         292k ± 0%    ~     (p=0.891 n=50+49)
Reflect                          977k ± 0%         977k ± 0%    ~     (p=0.274 n=50+50)
Tar                              343k ± 0%         343k ± 0%    ~     (p=0.942 n=50+50)
XML                              418k ± 0%         418k ± 0%    ~     (p=0.374 n=50+49)
LinkCompiler                     516k ± 0%         516k ± 0%    ~     (p=0.205 n=49+47)
ExternalLinkCompiler             570k ± 0%         570k ± 0%    ~     (p=0.783 n=49+47)
LinkWithoutDebugCompiler         169k ± 0%         169k ± 0%    ~     (p=0.233 n=50+46)
[Geo mean]                       672k              672k       +0.00%

name                      old maxRSS/op     new maxRSS/op     delta
Template                        34.5M ± 3%        34.4M ± 3%    ~     (p=0.566 n=49+48)
Unicode                         36.0M ± 6%        35.9M ± 6%    ~     (p=0.736 n=50+50)
GoTypes                         75.7M ± 7%        75.4M ± 5%    ~     (p=0.412 n=50+50)
Compiler                         314M ±10%         313M ± 8%    ~     (p=0.708 n=50+50)
SSA                              730M ± 6%         735M ± 6%    ~     (p=0.324 n=50+50)
Flate                           25.8M ± 5%        25.6M ± 6%    ~     (p=0.415 n=49+50)
GoParser                        28.5M ± 3%        28.5M ± 4%    ~     (p=0.977 n=46+50)
Reflect                         57.4M ± 4%        57.2M ± 3%    ~     (p=0.173 n=50+50)
Tar                             33.3M ± 3%        33.2M ± 4%    ~     (p=0.621 n=48+50)
XML                             39.6M ± 5%        39.6M ± 4%    ~     (p=0.997 n=50+50)
LinkCompiler                     168M ± 2%         167M ± 1%    ~     (p=0.072 n=49+45)
ExternalLinkCompiler             179M ± 1%         179M ± 1%    ~     (p=0.147 n=48+50)
LinkWithoutDebugCompiler         136M ± 1%         136M ± 1%    ~     (p=0.789 n=47+49)
[Geo mean]                      79.2M             79.1M       -0.12%

name                      old text-bytes    new text-bytes    delta
HelloSize                       812kB ± 0%        811kB ± 0%  -0.06%  (p=0.000 n=50+50)

name                      old data-bytes    new data-bytes    delta
HelloSize                      13.3kB ± 0%       13.3kB ± 0%    ~     (all equal)

name                      old bss-bytes     new bss-bytes     delta
HelloSize                       206kB ± 0%        206kB ± 0%    ~     (all equal)

name                      old exe-bytes     new exe-bytes     delta
HelloSize                      1.21MB ± 0%       1.21MB ± 0%  -0.03%  (p=0.000 n=50+50)

file      before    after     Δ       %
addr2line 4057421   4056237   -1184   -0.029%
api       4952451   4946715   -5736   -0.116%
asm       4888993   4888185   -808    -0.017%
buildid   2617705   2616441   -1264   -0.048%
cgo       4521849   4520681   -1168   -0.026%
compile   19143451  19141243  -2208   -0.012%
cover     4847391   4837151   -10240  -0.211%
dist      3473877   3472565   -1312   -0.038%
doc       3821496   3820432   -1064   -0.028%
fix       3220587   3220659   +72     +0.002%
link      6587504   6582576   -4928   -0.075%
nm        4000154   3998690   -1464   -0.037%
objdump   4409449   4407625   -1824   -0.041%
pack      2398086   2393110   -4976   -0.207%
pprof     13599060  13606111  +7051   +0.052%
test2json 2645148   2645692   +544    +0.021%
trace     10355281  10355862  +581    +0.006%
vet       6780026   6779666   -360    -0.005%
total     106319929 106289641 -30288  -0.028%

Change-Id: Ia5399286958c187c8664c769bbddf7bc4c1cae99
Reviewed-on: https://go-review.googlesource.com/c/go/+/263600
Run-TryBot: eric fang <eric.fang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: eric fang <eric.fang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agoencoding/json: add "json: " prefix to SyntaxError messages
Kevin Burke [Mon, 19 Oct 2020 20:29:40 +0000 (13:29 -0700)]
encoding/json: add "json: " prefix to SyntaxError messages

The other named errors - UnmarshalTypeError, etc - in this package do
the same, so we should prepend the package prefix to error messages
for consistency.

Add a note to the release docs in case this is interpreted as
a breaking change.

Fixes #36221.

Change-Id: Ie24b532bbf9812e108c259fa377e2a6b64319ed4
Reviewed-on: https://go-review.googlesource.com/c/go/+/263619
Run-TryBot: Kevin Burke <kev@inburke.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Kevin Burke <kev@inburke.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
4 years agocmd/compile/internal/gc: fix comments
hk [Wed, 21 Oct 2020 16:18:34 +0000 (16:18 +0000)]
cmd/compile/internal/gc: fix comments

Change-Id: Id7b0ead39e961a16a85da3e308db10dd4f9b55c3
GitHub-Last-Rev: e640c4a61ade361ac17b7eb95d0ce8913d0b4d6f
GitHub-Pull-Request: golang/go#42120
Reviewed-on: https://go-review.googlesource.com/c/go/+/264080
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>

4 years agocrypto/x509: bypass signature verification in CreateCertificate when using MD5WithRSA
Roland Shoemaker [Tue, 20 Oct 2020 20:50:52 +0000 (13:50 -0700)]
crypto/x509: bypass signature verification in CreateCertificate when using MD5WithRSA

Bypasses the signature verification check we previously added if the
signature algorithm is MD5WithRSA, as we only support this algorithm
for signing and not verification.

Change-Id: Idba6dbba8b365d6199d467526746b88a5f734af1
Reviewed-on: https://go-review.googlesource.com/c/go/+/264019
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Trust: Roland Shoemaker <roland@golang.org>

4 years agocmd/compile,cmd/internal/obj/riscv: move g register on riscv64
Joel Sing [Tue, 19 May 2020 08:55:31 +0000 (18:55 +1000)]
cmd/compile,cmd/internal/obj/riscv: move g register on riscv64

The original riscv64 port used the thread pointer (TP aka X4) register for
the g pointer, however this register is also used when TLS support is
required, resulting in a conflict (for example, when a signal is received
we have no way of readily knowing if X4 contains a pointer to the TCB or
a pointer to a g).

In order to support cgo, free up the X4 register by moving g to X27.
This unfortunately means that the X4 register is unused in non-cgo mode,
however the alternative is to not support cgo on this platform.

Update #36641

Change-Id: Idcaf3e8ccbe42972a1b8943aeefde7149d9c960a
Reviewed-on: https://go-review.googlesource.com/c/go/+/263477
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/go/internal/fsys: use a root other than "." in Walk tests
Bryan C. Mills [Wed, 21 Oct 2020 14:07:02 +0000 (10:07 -0400)]
cmd/go/internal/fsys: use a root other than "." in Walk tests

Fixes #42115

Change-Id: Icf4c9eac5ed3295acbc8377c7a06f82c6bddc747
Reviewed-on: https://go-review.googlesource.com/c/go/+/264177
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: David du Colombier <0intro@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/go: ignore GOFLAGS values without name in go env/bug
Obeyda Djeffal [Fri, 16 Oct 2020 15:34:15 +0000 (16:34 +0100)]
cmd/go: ignore GOFLAGS values without name in go env/bug

This happens with 'go env' and 'go bug'.

If GOFLAGS variable is set to something like '=value',
running `go env` panics with this error message:

    goroutine 1 [running]:
    cmd/go/internal/base.SetFromGOFLAGS(0xd96838)
        cmd/go/internal/base/goflags.go:101 +0x9a7
    main.main()
        cmd/go/main.go:188 +0x755

This happens when the 'name' of the flag is not
specified ('=' or '=value'), with any combination of other flags.
Other commands show this error message:
    go: parsing $GOFLAGS: non-flag

This happens only with 'env' and 'bug' because we have this:
https://go.googlesource.com/go/+/refs/heads/master/src/cmd/go/internal/base/goflags.go#40

New behaviour: ignore the bad flag, since we don't want to report
that with `go env` or `go bug`.

Fixes: #42013
Change-Id: I72602840ca00293d2a92ea28451b75b9799e3d6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/263098
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Michael Matloob <matloob@golang.org>

4 years agocmd/compiler,cmd/go,sync: add internal {LoadAcq,StoreRel}64 on ppc64
Paul E. Murphy [Wed, 9 Sep 2020 22:24:23 +0000 (17:24 -0500)]
cmd/compiler,cmd/go,sync: add internal {LoadAcq,StoreRel}64 on ppc64

Add an internal atomic intrinsic for load with acquire semantics
(extending LoadAcq to 64b) and add LoadAcquintptr for internal
use within the sync package.  For other arches, this remaps to the
appropriate atomic.Load{,64} intrinsic which should not alter code
generation.

Similarly, add StoreRel{uintptr,64} for consistency, and inline.

Finally, add an exception to allow sync to directly use the
runtime/internal/atomic package which avoids more convoluted
workarounds (contributed by Lynn Boger).

In an extreme example, sync.(*Pool).pin consumes 20% of wall time
during fmt tests.  This is reduced to 5% on ppc64le/power9.

From the fmt benchmarks on ppc64le:

name                           old time/op  new time/op  delta
SprintfPadding                  468ns ± 0%   451ns ± 0%   -3.63%
SprintfEmpty                   73.3ns ± 0%  51.9ns ± 0%  -29.20%
SprintfString                   135ns ± 0%   122ns ± 0%   -9.63%
SprintfTruncateString           232ns ± 0%   214ns ± 0%   -7.76%
SprintfTruncateBytes            216ns ± 0%   202ns ± 0%   -6.48%
SprintfSlowParsingPath          162ns ± 0%   142ns ± 0%  -12.35%
SprintfQuoteString             1.00µs ± 0%  0.99µs ± 0%   -1.39%
SprintfInt                      117ns ± 0%   104ns ± 0%  -11.11%
SprintfIntInt                   190ns ± 0%   175ns ± 0%   -7.89%
SprintfPrefixedInt              232ns ± 0%   212ns ± 0%   -8.62%
SprintfFloat                    270ns ± 0%   255ns ± 0%   -5.56%
SprintfComplex                 1.01µs ± 0%  0.99µs ± 0%   -1.68%
SprintfBoolean                  127ns ± 0%   111ns ± 0%  -12.60%
SprintfHexString                220ns ± 0%   198ns ± 0%  -10.00%
SprintfHexBytes                 261ns ± 0%   252ns ± 0%   -3.45%
SprintfBytes                    600ns ± 0%   590ns ± 0%   -1.67%
SprintfStringer                 684ns ± 0%   658ns ± 0%   -3.80%
SprintfStructure               2.57µs ± 0%  2.57µs ± 0%   -0.12%
ManyArgs                        669ns ± 0%   646ns ± 0%   -3.44%
FprintInt                       140ns ± 0%   136ns ± 0%   -2.86%
FprintfBytes                    184ns ± 0%   181ns ± 0%   -1.63%
FprintIntNoAlloc                140ns ± 0%   136ns ± 0%   -2.86%
ScanInts                        929µs ± 0%   921µs ± 0%   -0.79%
ScanRecursiveInt                122ms ± 0%   121ms ± 0%   -0.11%
ScanRecursiveIntReaderWrapper   122ms ± 0%   122ms ± 0%   -0.18%

Change-Id: I4d66780261b57b06ef600229e475462e7313f0d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/253748
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agomisc/wasm: improve error message if javascript polyfills are required
Richard Musiol [Sun, 11 Oct 2020 08:23:45 +0000 (10:23 +0200)]
misc/wasm: improve error message if javascript polyfills are required

wasm_exec.js expects that either "require" is available or that the
globals "crypto", "TextEncoder" and "TextDecoder" are already defined.
Report a better error message if this is not the case, suggesting the
use of a polyfill.

Updates #41482

Change-Id: I5473cae15c98ae42e39f5928245b7762e7a5a8bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/261357
Trust: Richard Musiol <neelance@gmail.com>
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agomisc/wasm: make sure sp is unsigned
Richard Musiol [Sun, 11 Oct 2020 11:33:53 +0000 (13:33 +0200)]
misc/wasm: make sure sp is unsigned

An i32 passed from WebAssembly to JavaScript is always read as a signed
integer. Use the bitshift operator to turn it into an unsigned integer.

Fixes #40923

Change-Id: Ia91ed2145dd2fc3071e2fc22b86ebfcb3c1e9f4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/261358
Trust: Richard Musiol <neelance@gmail.com>
Run-TryBot: Richard Musiol <neelance@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/go: enable link syso test on linux/riscv64
Tobias Klauser [Tue, 20 Oct 2020 08:44:07 +0000 (10:44 +0200)]
cmd/go: enable link syso test on linux/riscv64

Now that external linking is supported on linux/riscv64 (CL 243517),
re-enable the test previously disabled by CL 216259.

Updates #36739

Change-Id: I611548c587ca50f8bfab72c903ab0432e2b54198
Reviewed-on: https://go-review.googlesource.com/c/go/+/263797
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
4 years ago[dev.typeparams] cmd/compile/internal/types2: add *.go2 (generic) tests
Robert Griesemer [Tue, 20 Oct 2020 04:41:37 +0000 (21:41 -0700)]
[dev.typeparams] cmd/compile/internal/types2: add *.go2 (generic) tests

Change-Id: I33453736ac05cd7c2e666b280974719c734701fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/263632
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agodoc/go1.16: document net TCP listener's backlog size update
Cuong Manh Le [Tue, 20 Oct 2020 02:51:23 +0000 (09:51 +0700)]
doc/go1.16: document net TCP listener's backlog size update

Updates #41470

Change-Id: Iebd3a339504aa7f8834853d6a740557fb3bce3ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/262938
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Emmanuel Odeke <emm.odeke@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years ago[dev.typeparams] cmd/compile/internal/types2: add some more tests
Robert Griesemer [Tue, 20 Oct 2020 04:49:57 +0000 (21:49 -0700)]
[dev.typeparams] cmd/compile/internal/types2: add some more tests

Change-Id: I36fce5462d11dd2e8fc9a619118c6a63eed4980a
Reviewed-on: https://go-review.googlesource.com/c/go/+/263633
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.typeparams] cmd/compile/internal/types2: adjust tests, enable Testdata tests
Robert Griesemer [Tue, 20 Oct 2020 04:38:31 +0000 (21:38 -0700)]
[dev.typeparams] cmd/compile/internal/types2: adjust tests, enable Testdata tests

Types2 uses a different test runner and has fewer/better
errors in some cases (error messages match the compiler).
Adjust the tests and enable them.

Change-Id: I74877f54a81a3918a80774452cef5bcaad8a98e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/263631
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.typeparams] cmd/compile/internal/types2: add testdata directory
Robert Griesemer [Tue, 20 Oct 2020 04:10:37 +0000 (21:10 -0700)]
[dev.typeparams] cmd/compile/internal/types2: add testdata directory

Exact copy of src/go/types/testdata. Testdata tests still disabled.

Change-Id: Idff5fff7f1adcfd626f700b1f21f5a14ce1a74f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/263630
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years ago[dev.typeparams] cmd/compile/internal/importer, types2: initial check-in of types2...
Robert Griesemer [Mon, 19 Oct 2020 22:28:22 +0000 (15:28 -0700)]
[dev.typeparams] cmd/compile/internal/importer, types2: initial check-in of types2 and importer

This is a copy of the importer and types2 (unreviewed) prototype version
excluding the testdata directory containing tests (see below). Each file
is marked with the comment

// UNREVIEWED

on the first line. The plan is to check in this code wholesale (it runs and
passes all tests) and then review the code file-by-file via subsequent CLs
and remove the "// UNREVIEWED" comments as we review the files.

Since most tests are unchanged from the original go/types, the next CL will
commit those tests as they don't need to be reviewed again. (Eventually we
may want to factor them out and share them from a single place, e.g. the
test directory.)

The existing file fmtmap_test.go was updated.

Change-Id: I9bd0ad1a7e7188b501423483a44d18e623c0fe71
Reviewed-on: https://go-review.googlesource.com/c/go/+/263624
Trust: Robert Griesemer <gri@golang.org>
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/go: fix TestScript/test_cache_inputs
Jay Conrod [Tue, 20 Oct 2020 22:18:21 +0000 (18:18 -0400)]
cmd/go: fix TestScript/test_cache_inputs

Small fix for a new failure in CL 263142

For #41190

Change-Id: I733bc1998d87b505b52d429916c45afe2968a709
Reviewed-on: https://go-review.googlesource.com/c/go/+/264057
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Jay Conrod <jayconrod@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/compile: fix nodedump output for types of nodes
Dan Scales [Tue, 20 Oct 2020 22:03:33 +0000 (15:03 -0700)]
cmd/compile: fix nodedump output for types of nodes

The Dbg dumping of complex types was broken, because (I think) of a
recent change to handle recursive types correctly. Before this fix,
the Dump output of a closure node (where the last thing on the line is
the type of the node) was:

.   .   CLOSURE l(8) esc(h) tc(1) FUNC-@0

after this change it is:

.   .   CLOSURE l(8) esc(h) tc(1) FUNC-func(int) int

The problem is that that the 'mode == Fdbg' code was immediately
aborting the descent into tconv2, since it was calling down with the
same node that was just entered into the hash table.

Change-Id: Iee106b967cea1856dd92d4350681401dd34a23b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/264025
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agocmd/compile: enforce strongly typed rules for ARM (to32)
Constantin Konstantinidis [Thu, 24 Sep 2020 19:44:32 +0000 (21:44 +0200)]
cmd/compile: enforce strongly typed rules for ARM (to32)

Type casting changed to 32 from 64.
L1055-L1056
L1193-L1194, L1197-L1198

toolstash-check successful.

Change-Id: Icdb9985673292294bc4549afaaa6cf4fcf92ffa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/257640
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agotesting: print cpu type as label for benchmarks
Martin Möhrmann [Tue, 20 Oct 2020 07:56:14 +0000 (09:56 +0200)]
testing: print cpu type as label for benchmarks

Supports 386 and amd64 architectures on all operating systems.

Example output:
$ go test -bench=.*
goos: darwin
goarch: amd64
pkg: strconv
cpu: Intel(R) Core(TM) i7-3520M CPU @ 2.90GHz
BenchmarkAtof64Decimal-4         24431032         46.8 ns/op
...

As the displayed CPU information is only used for information
purposes it is lazily initialized when needed using the new
internal/sysinfo package.

This allows internal/cpu to stay without dependencies and avoid
initialization costs when the CPU information is not needed as
the new code to query the CPU name in internal/cpu can be
dead code eliminated if not used.

Fixes #39214

Change-Id: I77ae5c5d2fed6b28fa78dd45075f9f0a6a7f1bfd
Reviewed-on: https://go-review.googlesource.com/c/go/+/263804
Trust: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
4 years agogo/build: refactor per-file info & reader
Russ Cox [Mon, 19 Oct 2020 00:26:46 +0000 (20:26 -0400)]
go/build: refactor per-file info & reader

Make code cleaner and a bit more adaptable:
instead of an ever-growing list of arguments and results for readImports,
put everything in a fileInfo struct, and rename function to readGoInfo.
(Not a goInfo struct because it gets used for non-Go source files as well,
but that processing is much simpler.)

The refactoring simplifies the embed work in the next CL,
but this CL makes no semantic changes.

For #41191.

Change-Id: Id2de2a3b8d351adc1c919dcf79dfbe79fc3d5301
Reviewed-on: https://go-review.googlesource.com/c/go/+/243940
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agoruntime: use GOTRACEBACK=system for TestCgoExecSignalMask
Ian Lance Taylor [Tue, 20 Oct 2020 19:54:20 +0000 (12:54 -0700)]
runtime: use GOTRACEBACK=system for TestCgoExecSignalMask

Try to get a bit more information to understand #42093.

For #42093

Change-Id: I818feb08d7561151d52eba3e88c418b55b9f9c1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/264018
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/go: support overlays for synthesized packages.
Michael Matloob [Thu, 15 Oct 2020 15:45:32 +0000 (11:45 -0400)]
cmd/go: support overlays for synthesized packages.

The main missing piece here was supporting Stat in the overlay
filesystem, in the parts of the package code that determines whether
an command line argument is a file on disk or a directory.  so this
change adds a Stat function to the fsys package. It's implemented the
same way as the already existing fsys.lstat function, but instead of
os.Lstat, it calls os.Stat on disk files.

Then, the change changes parts of the package code to use the overlay
Stat instead of the os package's Stat.

For #39958

Change-Id: I8e478ae386f05b48d7dd71bd7e47584f090623df
Reviewed-on: https://go-review.googlesource.com/c/go/+/262617
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agocmd/internal/obj: reject too large symbols
Cherry Zhang [Mon, 19 Oct 2020 14:40:24 +0000 (10:40 -0400)]
cmd/internal/obj: reject too large symbols

We never supported symbol larger than 2GB (issue #9862), so the
object file uses 32-bit for symbol sizes. Check and reject too
large symbol before truncating its size.

Fixes #42054.

Change-Id: I0d1d585ebdba9556f2fd3a97043bd4296d5cc9e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/263641
Trust: Cherry Zhang <cherryyz@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocmd/go/internal/modload: remove printStackInDie functionality
Jay Conrod [Mon, 19 Oct 2020 18:02:14 +0000 (14:02 -0400)]
cmd/go/internal/modload: remove printStackInDie functionality

Previously, when running cmd/go tests, if the module root directory is
requested when modules are explicitly disabled, we printed a stack
trace in addition to the error message that's normally printed. The
stack trace isn't that useful, and it makes the actual error hard to
find.

Change-Id: I8230d668f3f16659f08d0d685124c41b4055c5b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/263659
Trust: Jay Conrod <jayconrod@google.com>
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agoall: update references to symbols moved from io/ioutil to io
Russ Cox [Fri, 16 Oct 2020 04:49:02 +0000 (00:49 -0400)]
all: update references to symbols moved from io/ioutil to io

The old ioutil references are still valid, but update our code
to reflect best practices and get used to the new locations.

Code compiled with the bootstrap toolchain
(cmd/asm, cmd/dist, cmd/compile, debug/elf)
must remain Go 1.4-compatible and is excluded.
Also excluded vendored code.

For #41190.

Change-Id: I6d86f2bf7bc37a9d904b6cee3fe0c7af6d94d5b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/263142
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agoio: adopt Discard, NopCloser, ReadAll from io/ioutil
Russ Cox [Fri, 16 Oct 2020 04:41:03 +0000 (00:41 -0400)]
io: adopt Discard, NopCloser, ReadAll from io/ioutil

As proposed and approved in #40025, Discard, NopCloser, and ReadAll
do not really fit into io/ioutil, which exists mainly to hold things that
would cause an import cycle if implemented in io itself, which is to say
things that import "os".

These three do not import "os" - they are generic io helpers like
many of the things in io itself, so it makes sense for them to be there.

Fixes #40025.

Change-Id: I77f47e9b2a72839edf7446997936631980047b67
Reviewed-on: https://go-review.googlesource.com/c/go/+/263141
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agonet/http: add FS to convert fs.FS to FileSystem
Russ Cox [Tue, 7 Jul 2020 13:51:45 +0000 (09:51 -0400)]
net/http: add FS to convert fs.FS to FileSystem

Two different functions in the http API expect a FileSystem:
http.FileSystem and http.NewFileTransport.
Add a general converter http.FS to turn an fs.FS into an http.FileSystem
for use with either of these functions.

(The original plan was to add http.HandlerFS taking an fs.FS directly,
but that doesn't help with NewFileTransport.)

For #41190.

Change-Id: I5f242eafe9b963f4387419a2615bdb487c358f16
Reviewed-on: https://go-review.googlesource.com/c/go/+/243939
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agohtml/template, text/template: add ParseFS
Russ Cox [Mon, 6 Jul 2020 15:28:52 +0000 (11:28 -0400)]
html/template, text/template: add ParseFS

Now templates can be parsed not just from operating system files
but from arbitrary file systems, including zip files.

For #41190.

Change-Id: I2172001388ddb1f13defa6c5e644e8ec8703ee80
Reviewed-on: https://go-review.googlesource.com/c/go/+/243938
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agoarchive/zip: make Reader implement fs.FS
Russ Cox [Mon, 6 Jul 2020 15:56:19 +0000 (11:56 -0400)]
archive/zip: make Reader implement fs.FS

Now a zip.Reader (an open zip file) can be passed to code
that accepts a file system, such as (soon) template parsing.

For #41190.

Change-Id: If51b12e39db3ccc27f643c2453d3300a38035360
Reviewed-on: https://go-review.googlesource.com/c/go/+/243937
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agoio/fs: add Glob and GlobFS
Russ Cox [Mon, 6 Jul 2020 15:27:12 +0000 (11:27 -0400)]
io/fs: add Glob and GlobFS

Add Glob helper function, GlobFS interface, and test.
Add Glob method to fstest.MapFS.
Add testing of Glob method to fstest.TestFS.

For #41190.

Change-Id: If89dd7f63e310ba5ca2651340267a9ff39fcc0c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/243915
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agoio/fs: add ReadDir and ReadDirFS
Russ Cox [Mon, 6 Jul 2020 15:26:56 +0000 (11:26 -0400)]
io/fs: add ReadDir and ReadDirFS

Add ReadDir helper function, ReadDirFS interface, and test.
Add ReadDir method to fstest.MapFS.
Add testing of ReadDir method to fstest.TestFS.

For #41190.

Change-Id: Ib860770ec7433ba77b29e626682b238f1b3bf54f
Reviewed-on: https://go-review.googlesource.com/c/go/+/243914
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agoio/fs: add Stat and StatFS
Russ Cox [Mon, 6 Jul 2020 15:26:45 +0000 (11:26 -0400)]
io/fs: add Stat and StatFS

Add Stat helper function, StatFS interface, and test.
Add Stat method to fstest.MapFS.
Add testing of Stat method to fstest.TestFS.

For #41190.

Change-Id: Icf8b6eb1c3fa6f93a9be8405ec5a9468fb1da97b
Reviewed-on: https://go-review.googlesource.com/c/go/+/243913
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agoio/fs: add ReadFile and ReadFileFS
Russ Cox [Mon, 6 Jul 2020 15:26:26 +0000 (11:26 -0400)]
io/fs: add ReadFile and ReadFileFS

Add ReadFile helper function, ReadFileFS interface, and test.
Add ReadFile method to fstest.MapFS.
Add testing of ReadFile method to fstest.TestFS.

For #41190.

Change-Id: I5b6a41e2e582824e570463b698b635abaa436c32
Reviewed-on: https://go-review.googlesource.com/c/go/+/243912
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agoos: add DirFS
Russ Cox [Mon, 6 Jul 2020 15:27:38 +0000 (11:27 -0400)]
os: add DirFS

It will inevitably be important to be able to pass an operating system
directory to code written to expect an fs.FS.

os.DirFS provides the conversion.

For #41190.

Change-Id: Id1a8fcbe4c7a30de2c47dea0504e9481a88b1b39
Reviewed-on: https://go-review.googlesource.com/c/go/+/243911
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agotesting/fstest: new package for testing file system code
Russ Cox [Mon, 6 Jul 2020 14:58:05 +0000 (10:58 -0400)]
testing/fstest: new package for testing file system code

This change adds basic test helpers for file system code.

The type MapFS is a simple map-based file system for use when
exercising general file system code.

The func TestFS tests a file system implementation.

For #41190.

Change-Id: I5a2036f57e733915ad508651ad7317749794423c
Reviewed-on: https://go-review.googlesource.com/c/go/+/243910
Trust: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agocmd/asm: rename "compiling runtime" flag
Than McIntosh [Tue, 20 Oct 2020 13:06:42 +0000 (09:06 -0400)]
cmd/asm: rename "compiling runtime" flag

Rename the assembler "-compilingRuntime" flag to "-compiling-runtime",
to be more consistent with the flag style of other Go commands.

Change-Id: I8cc5cbf0b9b34d1dd4e9fa499d3fec8c1ef10b6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/263857
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/go/internal/renameio: include ios in the darwin test-flake mitigation
Bryan C. Mills [Tue, 20 Oct 2020 00:45:01 +0000 (20:45 -0400)]
cmd/go/internal/renameio: include ios in the darwin test-flake mitigation

Because the "ios" build constraint implies "darwin", it is already
included in the general "darwin" flakiness workaround in
cmd/go/internal/robustio. We just need to relax the renameio test
to avoid false-positives there.

I do not expect this change to drive the rate of false-positives down
to zero, but it should at least reduce noise on the build dashboard.

For #42066

Change-Id: Ia33dbd33295fce5b3261b4831f2807ce29b82e65
Reviewed-on: https://go-review.googlesource.com/c/go/+/263777
Trust: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years agoruntime: fix scavenging tests for pallocChunkBytes huge pages and larger
Michael Anthony Knyszek [Tue, 20 Oct 2020 12:57:14 +0000 (12:57 +0000)]
runtime: fix scavenging tests for pallocChunkBytes huge pages and larger

Currently the scavenging tests implicitly assume that the system huge
page size is always strictly less than 4 MiB, or pallocChunkBytes. This
leads to failures on systems with huge pages of this size, and larger.

Filter out those tests on such platforms and add a test for the 4 MiB
case. The scavenger is already equipped to handle this case.

Huge page sizes > 4 MiB are effectively ignored, so also add a test case
to ensure that happens.

Unfortunately we can't actually run these tests in our CI because they
require the platform to provide the right huge page size, but we really
should just parameterize this value so we can test it (there's a TODO
about this already).

Fixes #42053.

Change-Id: Ia576cbf67e178a14a178a893967efbed27d6eb17
Reviewed-on: https://go-review.googlesource.com/c/go/+/263837
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>

4 years agocmd/go: add BuildID to list -json -export
Daniel Martí [Mon, 19 Oct 2020 14:06:02 +0000 (15:06 +0100)]
cmd/go: add BuildID to list -json -export

That is, the following two pieces of shell code are now equivalent:

$ go tool buildid $(go list -export -f {{.Export}} strings)
v_0VqA6yzwuMg2dn4u57/PXcIR2Pb8Mi9yRdcdkwe

$ go list -export -f {{.BuildID}} strings
v_0VqA6yzwuMg2dn4u57/PXcIR2Pb8Mi9yRdcdkwe

This does not expose any information that wasn't available before, but
makes this workflow simpler and faster. In the first example, we have to
execute two programs, and 'go tool buildid' has to re-open the export
data file to read the build ID.

With the new mechanism, 'go list -export' already has the build ID
ready, so we can simply print it out. Moreover, when listing lots of
related packages like './...', we can now obtain all their build IDs at
once.

Fixes #37281.

Change-Id: I8e2f65a08391b3df1a628c6e06e708b8c8cb7865
Reviewed-on: https://go-review.googlesource.com/c/go/+/263542
Trust: Daniel Martí <mvdan@mvdan.cc>
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Jay Conrod <jayconrod@google.com>
4 years agonet/http/cgi: preserve env vars on illumos
Tobias Klauser [Tue, 20 Oct 2020 11:36:57 +0000 (13:36 +0200)]
net/http/cgi: preserve env vars on illumos

Preserve the same environment variables as on solaris.

Spotted while reviewing CL 263577.

Change-Id: Id479dcf83d6231e9ef1fd2404b400d10082e1d0b
Reviewed-on: https://go-review.googlesource.com/c/go/+/263802
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agointernal/cpu: make architectures without initialization work explicit
Martin Möhrmann [Tue, 20 Oct 2020 09:06:02 +0000 (11:06 +0200)]
internal/cpu: make architectures without initialization work explicit

When cpu_no_init.go was created most architectures did not have
code in the doinit function. Currently only mips(le), riscv64 and
wasm do not have empty doinit functions.

Keeping cpu_no_init.go around does not reduce the work to satisfy
the build process when adding support for new architectures.

To support a new architecture a new file or build directive has to
be added to an existing file at any rate to define the constant
CacheLinePadSize. A new empty doinit can then be created in the
new file or the existing doinit can be reused when adding the
additional build directive.

Change-Id: I58a97f8cdf1cf1be85c37f4550c40750358aa031
Reviewed-on: https://go-review.googlesource.com/c/go/+/263801
Trust: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
4 years agointernal/cpu: consolidate arm64 feature detection
Martin Möhrmann [Tue, 13 Oct 2020 20:30:23 +0000 (22:30 +0200)]
internal/cpu: consolidate arm64 feature detection

Move code to detect and mask arm64 CPU features from
runtime to internal/cpu.

Change-Id: Ib784e2ff056e8def125d68827b852f07a3eff0db
Reviewed-on: https://go-review.googlesource.com/c/go/+/261878
Trust: Martin Möhrmann <moehrmann@google.com>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
4 years agonet/http/cgi: preserve LD_LIBRARY_PATH on NetBSD, too
Nikhil Benesch [Mon, 19 Oct 2020 01:55:55 +0000 (21:55 -0400)]
net/http/cgi: preserve LD_LIBRARY_PATH on NetBSD, too

This makes the behavior of the cgi package on NetBSD consistent with its
behavior on the other BSDs. It is also necessary for the test suite to
pass on NetBSD with gccgo (see CL 261137).

Change-Id: I531a6e0954f895a921204dcc61e3f3e90860a23d
Reviewed-on: https://go-review.googlesource.com/c/go/+/263577
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Trust: Benny Siegert <bsiegert@gmail.com>

4 years agosyscall, cmd/go/internal/modload: add and use Access on aix
Tobias Klauser [Mon, 19 Oct 2020 10:01:23 +0000 (12:01 +0200)]
syscall, cmd/go/internal/modload: add and use Access on aix

Implement Access using Faccessat on aix following golang.org/x/sys/unix
CL 262897 and switch cmd/go/internal/modload to use it to implement
hasWritePerm.

Change-Id: I682e44737ac2bac5a203ac1c9ddd277810454426
Reviewed-on: https://go-review.googlesource.com/c/go/+/263540
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agoio/fs: add FS, File, ReadDirFile; move DirEntry from os
Russ Cox [Mon, 6 Jul 2020 13:56:43 +0000 (09:56 -0400)]
io/fs: add FS, File, ReadDirFile; move DirEntry from os

These are the core interfaces for the io/fs design.
See #41190 and https://golang.org/s/draft-iofs-design for details.

DirEntry was left behind in the previous move from os
but is needed for ReadDirFile, so it moves in this commit.

Also apply a couple comment changes suggested in
the review of CL 261540.

For #41190.

Change-Id: I087741545139ed30b9ba5db728a0bad71129500b
Reviewed-on: https://go-review.googlesource.com/c/go/+/243908
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agotesting/iotest: add TestReader to test readers
Russ Cox [Sun, 19 Jul 2020 02:26:00 +0000 (22:26 -0400)]
testing/iotest: add TestReader to test readers

There are many reader behaviors that are subtle and
worth testing, and it's nice to have one complete tester
instead of many incomplete ones.

For #41190, which will use this as part of a larger
file system implementation tester.

Change-Id: Ib4cc7fae94b0d9b45dfacadc52baa77ad3761322
Reviewed-on: https://go-review.googlesource.com/c/go/+/243909
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agoall: update references to symbols moved from os to io/fs
Russ Cox [Tue, 7 Jul 2020 17:49:21 +0000 (13:49 -0400)]
all: update references to symbols moved from os to io/fs

The old os references are still valid, but update our code
to reflect best practices and get used to the new locations.

Code compiled with the bootstrap toolchain
(cmd/asm, cmd/dist, cmd/compile, debug/elf)
must remain Go 1.4-compatible and is excluded.

For #41190.

Change-Id: I8f9526977867c10a221e2f392f78d7dec073f1bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/243907
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years agoio/fs: move FileInfo, FileMode, PathError, ErrInvalid, ... from os to io/fs
Russ Cox [Mon, 6 Jul 2020 13:49:20 +0000 (09:49 -0400)]
io/fs: move FileInfo, FileMode, PathError, ErrInvalid, ... from os to io/fs

First step of creating the new io/fs package.

For #41190.

Change-Id: I1339b1abdd533b0f1deab283628088b2f706fb5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/243906
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Run-TryBot: Emmanuel Odeke <emm.odeke@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agocmd/link: support cgo internal/linking on darwin/arm64
Cherry Zhang [Thu, 15 Oct 2020 01:15:37 +0000 (21:15 -0400)]
cmd/link: support cgo internal/linking on darwin/arm64

Cgo programs work as well. Still not enabled by default for now.

Enable internal linking tests.

Updates #38485.

Change-Id: I8324a5c263fba221eb4e67d71207ca84fa241e6c
Reviewed-on: https://go-review.googlesource.com/c/go/+/263637
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/compile: use type position for error message in align.go
Cuong Manh Le [Mon, 19 Oct 2020 11:32:15 +0000 (18:32 +0700)]
cmd/compile: use type position for error message in align.go

This helps the compiler reports the right place where the type declared,
instead of relying on global lineno, which maybe set to wrong value at
the time the error is reported.

Fixes #42058

Change-Id: I06d34aa9b0236d122f4a0d72e66675ded022baac
Reviewed-on: https://go-review.googlesource.com/c/go/+/263597
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agoapi: update next.txt
Russ Cox [Fri, 16 Oct 2020 03:34:41 +0000 (23:34 -0400)]
api: update next.txt

A bunch of new API hasn't been added yet and is cluttering all.bash output.

Change-Id: Ic7f255cce8c162716b9a1144f78b5f9ce6220b33
Reviewed-on: https://go-review.googlesource.com/c/go/+/262878
Trust: Russ Cox <rsc@golang.org>
Trust: Rob Pike <r@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Emmanuel Odeke <emm.odeke@gmail.com>
4 years agoos: use keyed literals for PathError
Russ Cox [Fri, 3 Jul 2020 16:25:49 +0000 (12:25 -0400)]
os: use keyed literals for PathError

Necessary to move PathError to io/fs.

For #41190.

Change-Id: I05e87675f38a22f0570d4366b751b6169f7a1b13
Reviewed-on: https://go-review.googlesource.com/c/go/+/243900
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
4 years agoos: add File.ReadDir method and DirEntry type
Russ Cox [Fri, 9 Oct 2020 15:49:59 +0000 (11:49 -0400)]
os: add File.ReadDir method and DirEntry type

ReadDir provides a portable, efficient way to read a directory
and discover the type of directory entries.
This enables a more efficient file system walk, yet to be added.

See #41467 for the proposal review for the API.

Fixes #41467.

Change-Id: I461a526793ae46df48821aa448b04f1705546739
Reviewed-on: https://go-review.googlesource.com/c/go/+/261540
Trust: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
4 years ago[dev.typeparams] cmd/compile/internal/syntax: add utility functions for testing
Robert Griesemer [Mon, 19 Oct 2020 22:47:40 +0000 (15:47 -0700)]
[dev.typeparams] cmd/compile/internal/syntax: add utility functions for testing

Preparation step for types2 package.

Change-Id: I8f9557b1a48ad570ba38aac7b720e639218dc6a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/263623
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile: allowing inlining of functions with OCALLPART
Dan Scales [Mon, 19 Oct 2020 20:09:55 +0000 (13:09 -0700)]
cmd/compile:  allowing inlining of functions with OCALLPART

OCALLPART is exported in its original form, which is as an OXDOT.

The body of the method value wrapper created in makepartialcall() was
not being typechecked, and that was causing a problem during escape
analysis, so I added code to typecheck the body.

The go executable got slightly bigger with this change (13598111 ->
13598905), because of extra exported methods with OCALLPART (I
believe), while the text size got slightly smaller (9686964 ->
9686643).

This is mainly part of the work to make sure all function bodies can
be exported (for purposes of generics), but might as well fix the
OCALLPART inlining bug as well.

Fixes #18493

Change-Id: If7aa055ff78ed7a6330c6a1e22f836ec567d04fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/263620
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agoruntime: add lock rank partial-order edge between fin and mheap
Michael Anthony Knyszek [Mon, 19 Oct 2020 17:55:55 +0000 (17:55 +0000)]
runtime: add lock rank partial-order edge between fin and mheap

finlock may be held across a write barrier, which could then acquire the
mheap lock. Notably, this occurs in the mp.unlockf write in gopark where
finlock is held by the finalizer goroutines and is going to sleep.

Fixes #42062.

Change-Id: Icf76637ae6fc12795436272633dca3d473780875
Reviewed-on: https://go-review.googlesource.com/c/go/+/263678
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
4 years ago[dev.typeparams] cmd/compile/internal/syntax: add Pos method
Robert Griesemer [Mon, 19 Oct 2020 22:24:39 +0000 (15:24 -0700)]
[dev.typeparams] cmd/compile/internal/syntax: add Pos method

Allows syntax.Pos values to implement

interface {
Pos() Pos
}

Preparation step for types2 package.

Change-Id: Ib0f4d7695a3d066983567d680fc3b9256a31c31d
Reviewed-on: https://go-review.googlesource.com/c/go/+/263622
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
4 years agocmd/compile/internal/gc: use plural nouns in comments
hk [Mon, 19 Oct 2020 12:11:13 +0000 (12:11 +0000)]
cmd/compile/internal/gc: use plural nouns in comments

Change-Id: I99a5b5b88495cfaef16d41ee4b962c5d0b3488aa
GitHub-Last-Rev: fa0d895b3a87e45f499f02651a5f0e4946124765
GitHub-Pull-Request: golang/go#42059
Reviewed-on: https://go-review.googlesource.com/c/go/+/263617
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Keith Randall <khr@golang.org>
Trust: Robert Griesemer <gri@golang.org>

4 years agocmd/compile: fix ICE in reporting of invalid recursive types
Matthew Dempsky [Mon, 19 Oct 2020 21:14:40 +0000 (14:14 -0700)]
cmd/compile: fix ICE in reporting of invalid recursive types

asNode(t.Nod).Name.Param will be nil for builtin types (i.e., the
universal predeclared types and unsafe.Pointer). These types can't be
part of a cycle anyway, so we can just skip them.

Fixes #42075.

Change-Id: Ic7a44de65c6bfd16936545dee25e36de8850acf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/263717
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
4 years agoRevert "net/http: test that ParseMultipartForm returns an error for int overflow"
Bryan C. Mills [Mon, 19 Oct 2020 18:03:51 +0000 (18:03 +0000)]
Revert "net/http: test that ParseMultipartForm returns an error for int overflow"

This reverts CL 254977.

Reason for revert: introduced test failures on longtest builders.

Change-Id: I75e868245f980189ad85dd4103d9178989e06ecf
Reviewed-on: https://go-review.googlesource.com/c/go/+/263658
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
4 years agocmd/dist,cmd/go: broaden use of asm macro GOEXPERIMENT_REGABI
Than McIntosh [Wed, 14 Oct 2020 12:06:54 +0000 (08:06 -0400)]
cmd/dist,cmd/go: broaden use of asm macro GOEXPERIMENT_REGABI

This extends a change made in https://golang.org/cl/252258 to the go
command (to define an asm macro when GOEXPERIMENT=regabi is in
effect); we need this same macro during the bootstrap build in order
to build the runtime correctly.

In addition, expand the set of packages where the macro is applied to
{runtime, reflect, syscall, runtime/internal/*}, and move the logic
for deciding when something is a "runtime package" out of the
assembler and into cmd/{go,dist}, introducing a new assembler command
line flag instead.

Updates #27539, #40724.

Change-Id: Ifcc7f029f56873584de1e543c55b0d3e54ad6c49
Reviewed-on: https://go-review.googlesource.com/c/go/+/262317
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocompress/flate: fix corrupted output
Klaus Post [Sat, 17 Oct 2020 15:19:53 +0000 (15:19 +0000)]
compress/flate: fix corrupted output

The fastest compression mode can pick up a false match for every 2GB
of input data resulting in incorrectly decompressed data.

Since matches are allowed to be up to and including at maxMatchOffset
we must offset the buffer by an additional element to prevent the first
4 bytes to match after an out-of-reach value after shiftOffsets has
been called.

We offset by `maxMatchOffset + 1` so offset 0 in the table will now
fail the `if offset > maxMatchOffset` in all cases.

Fixes #41420

Change-Id: If1fbe01728e132b8a207e3f3f439edd832dcc710
GitHub-Last-Rev: 50fabab0da874c37543b139459a810e12e83cee2
GitHub-Pull-Request: golang/go#41477
Reviewed-on: https://go-review.googlesource.com/c/go/+/255879
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Joe Tsai <thebrokentoaster@gmail.com>
Trust: Matthew Dempsky <mdempsky@google.com>

4 years agocmd/link: run generator functions along with symbol writing
Cherry Zhang [Sat, 17 Oct 2020 18:00:35 +0000 (14:00 -0400)]
cmd/link: run generator functions along with symbol writing

Like we do for applying relocations, for generator symbols, run
the generator function along with symbol writing. This will
probably have better locality and parallelism.

Linking cmd/compile,

Asmb          29.9ms ± 5%    19.1ms ±12%  -36.18%  (p=0.000 n=10+9)
TotalTime      351ms ± 3%     339ms ± 2%   -3.51%  (p=0.000 n=11+10)

Change-Id: I9cda6718bf70b3bcf1b7a501a845d6136234d2ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/263640
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agocmd/link: fix TestDWARFiOS
Cherry Zhang [Sat, 17 Oct 2020 01:42:01 +0000 (21:42 -0400)]
cmd/link: fix TestDWARFiOS

Use GOOS=ios.

Run "xcodebuild -showsdks" correctly.

Wrap testDWARF in subtests, as it calls t.Parallel, otherwise
the two calls of testDWARF will cause t.Parallel being called
twice, which panics.

Updates #38485.

Change-Id: I614c8daa99c83cbfd05a4cfa041968d49279f16a
Reviewed-on: https://go-review.googlesource.com/c/go/+/263639
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoruntime: define ios/arm64 entry points
Cherry Zhang [Sat, 17 Oct 2020 01:39:36 +0000 (21:39 -0400)]
runtime: define ios/arm64 entry points

Updates #38485.

Change-Id: I030346c7f0c3ce89209588525b210284fdea4efd
Reviewed-on: https://go-review.googlesource.com/c/go/+/263638
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoRevert "cmd/link: put C static symbols in the symbol table"
Cherry Zhang [Mon, 19 Oct 2020 18:16:31 +0000 (18:16 +0000)]
Revert "cmd/link: put C static symbols in the symbol table"

This reverts CL 263259.

Reason for revert: break AIX builder.

Change-Id: I3abb0b1f509961a06f1567d8c87679b0ca5782d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/263660
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
4 years agocmd/compile/internal/gc: remove an unused method
hk [Mon, 19 Oct 2020 12:13:25 +0000 (12:13 +0000)]
cmd/compile/internal/gc: remove an unused method

Change-Id: Ib496d1e9a47d2cf69509ffd0009038b7d34a0149
GitHub-Last-Rev: 5b5589dd03e1d781e4cedc643d5e8a7f8bda2139
GitHub-Pull-Request: golang/go#42060
Reviewed-on: https://go-review.googlesource.com/c/go/+/263618
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agonet/http: test that ParseMultipartForm returns an error for int overflow
avivklas [Tue, 15 Sep 2020 05:48:44 +0000 (08:48 +0300)]
net/http: test that ParseMultipartForm returns an error for int overflow

ParseMultipartForm has been changed to return an error if maxMemory
parameter + 10MB causes int overflows. This adds a test for the new
behaviour.

For #40430

Change-Id: I4f66ce8a9382940182011d22a84ee52b1d1364cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/254977
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>

4 years agonet/http/httputil: copy response header back to http.ResponseWriter in ReverseProxy...
Aofei Sheng [Sat, 26 Sep 2020 05:21:41 +0000 (13:21 +0800)]
net/http/httputil: copy response header back to http.ResponseWriter in ReverseProxy.handleUpgradeResponse

Fixes: #41634
Change-Id: Ib78cc37a4d2ca0753d567eafb616238e4103484e
Reviewed-on: https://go-review.googlesource.com/c/go/+/257777
Reviewed-by: Damien Neil <dneil@google.com>
Trust: Damien Neil <dneil@google.com>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

4 years agocrypto/hmac: panic if reusing hash.Hash values
Katie Hockman [Tue, 13 Oct 2020 20:33:46 +0000 (16:33 -0400)]
crypto/hmac: panic if reusing hash.Hash values

Also put Reset in the correct place for the other
benchmarks.

name           old time/op    new time/op    delta
NewWriteSum-8    1.01µs ± 0%    1.01µs ± 1%   ~     (p=0.945 n=9+9)

name           old speed      new speed      delta
NewWriteSum-8  31.7MB/s ± 0%  31.6MB/s ± 1%   ~     (p=0.948 n=9+9)

name           old alloc/op   new alloc/op   delta
NewWriteSum-8      544B ± 0%      544B ± 0%   ~     (all equal)

name           old allocs/op  new allocs/op  delta
NewWriteSum-8      7.00 ± 0%      7.00 ± 0%   ~     (all equal)

Fixes #41089

Change-Id: I3dae660adbe4993963130bf3c2636bd53899164b
Reviewed-on: https://go-review.googlesource.com/c/go/+/261960
Trust: Katie Hockman <katie@golang.org>
Trust: Roland Shoemaker <roland@golang.org>
Run-TryBot: Katie Hockman <katie@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
4 years agointernal/bytealg: add assembly implementation of Count/CountString for riscv64
Tobias Klauser [Mon, 19 Oct 2020 09:09:10 +0000 (11:09 +0200)]
internal/bytealg: add assembly implementation of Count/CountString for riscv64

Simple single-byte loop count for now, to be further improved in future
CLs.

Benchmark on linux/riscv64 (HiFive Unleashed):

name               old time/op    new time/op     delta
CountSingle/10-4      190ns ± 1%      145ns ± 1%  -23.66%  (p=0.000 n=10+9)
CountSingle/32-4      422ns ± 1%      268ns ± 0%  -36.43%  (p=0.000 n=10+7)
CountSingle/4K-4     43.3µs ± 0%     23.8µs ± 0%  -45.09%  (p=0.000 n=8+10)
CountSingle/4M-4     54.2ms ± 1%     33.3ms ± 1%  -38.48%  (p=0.000 n=10+10)
CountSingle/64M-4     1.52s ± 1%      1.20s ± 1%  -21.20%  (p=0.000 n=9+9)

name               old speed      new speed       delta
CountSingle/10-4   52.7MB/s ± 1%   69.1MB/s ± 1%  +31.03%  (p=0.000 n=10+9)
CountSingle/32-4   75.9MB/s ± 1%  119.5MB/s ± 0%  +57.34%  (p=0.000 n=10+8)
CountSingle/4K-4   94.6MB/s ± 0%  172.2MB/s ± 0%  +82.10%  (p=0.000 n=8+10)
CountSingle/4M-4   77.4MB/s ± 1%  125.8MB/s ± 1%  +62.54%  (p=0.000 n=10+10)
CountSingle/64M-4  44.2MB/s ± 1%   56.1MB/s ± 1%  +26.91%  (p=0.000 n=9+9)

Change-Id: I2a6bd50d22d5f598517bb3c5a50066c54280cac5
Reviewed-on: https://go-review.googlesource.com/c/go/+/263541
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
4 years agocmd/link: put C static symbols in the symbol table
Cherry Zhang [Fri, 16 Oct 2020 21:37:52 +0000 (17:37 -0400)]
cmd/link: put C static symbols in the symbol table

We don't put Go static symbols in the symbol table, as they are
always compiler-generated (there is no way to define a static
symbol in user code in Go). We retain static symbols in assembly
code, as it may be user-defined. Also retain static symbols in C.

Change-Id: Ie0425bb4df33f183857b1fd5ba4b2bdfdc497571
Reviewed-on: https://go-review.googlesource.com/c/go/+/263259
Trust: Cherry Zhang <cherryyz@google.com>
Run-TryBot: Cherry Zhang <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
4 years agoRevert "test: add regression test from #41474"
Alberto Donizetti [Sun, 18 Oct 2020 20:21:03 +0000 (20:21 +0000)]
Revert "test: add regression test from #41474"

This reverts CL 263097.

Reason for revert: broke the noopt builder.

Change-Id: Ie36d2c3ed9449b4425732072db624c8e18f965f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/263537
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Alberto Donizetti <alb.donizetti@gmail.com>

4 years agocmd: go get golang.org/x/tools@d1624618 && go mod vendor
Than McIntosh [Wed, 14 Oct 2020 12:14:44 +0000 (08:14 -0400)]
cmd: go get golang.org/x/tools@d1624618 && go mod vendor

This brings in CL 262197, which enables handling of ABI selector
syntax in the asmdecl checker.

Updates #27539, #40724.

Change-Id: I088f5eeacb3588ed49c4aa2277641049bf5b9083
Reviewed-on: https://go-review.googlesource.com/c/go/+/262318
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Than McIntosh <thanm@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
4 years agocmd/asm: allow def/ref of func ABI when compiling runtime
Than McIntosh [Wed, 7 Oct 2020 16:31:05 +0000 (12:31 -0400)]
cmd/asm: allow def/ref of func ABI when compiling runtime

Function symbols defined and referenced by assembly source currently
always default to ABI0; this patch adds preliminary support for
accepting an explicit ABI selector clause for func defs/refs. This
functionality is currently only enabled when compiling runtime-related
packages (runtime, syscall, reflect). Examples:

  TEXT ·DefinedAbi0Symbol<ABI0>(SB),NOSPLIT,$0
        RET

  TEXT ·DefinedAbi1Symbol<ABIInternal>(SB),NOSPLIT,$0
        CALL    ·AbiZerolSym<ABI0>(SB)
...
        JMP     ·AbiInternalSym<ABIInternal>(SB)
        RET

Also included is a small change to the code in the compiler that reads
the symabis file emitted by the assembler.

New behavior is currently gated under GOEXPERIMENT=regabi.

Updates #27539, #40724.

Change-Id: Ia22221fe26df0fa002191cfb13bdfaaa38d7df38
Reviewed-on: https://go-review.googlesource.com/c/go/+/260477
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Zhang <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>