]> Cypherpunks repositories - gostls13.git/log
gostls13.git
3 years agocmd/internal/obj/arm64: add checks for incorrect use of REGTMP register
fanzha02 [Tue, 24 Aug 2021 04:46:54 +0000 (12:46 +0800)]
cmd/internal/obj/arm64: add checks for incorrect use of REGTMP register

The current assembler uses REGTMP as a temporary destination register,
when optimizing one instruction into a multi-instruction sequence. But
in some cases, when the source register is REGTMP, this behavior is
incorrect.

For example:
  ADD $0x1234567, R27, R3

The current assembler encodes it into
  MOVD $17767, R27
  MOVK $(291<<16), R27
  ADD R27, R27, R3

It is illegal to overwrite R27. This CL adds the related checks.

Add test cases.

Change-Id: I0af373d9fd23d8f067c093778dd4cc76748faf38
Reviewed-on: https://go-review.googlesource.com/c/go/+/344689
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: fannie zhang <Fannie.Zhang@arm.com>

3 years agocmd/compile: remove 'ext' fields from unified IR reader/writer types
Matthew Dempsky [Wed, 8 Sep 2021 00:24:50 +0000 (17:24 -0700)]
cmd/compile: remove 'ext' fields from unified IR reader/writer types

This is a vestigial artifact of how I initially split apart the public
and private data for objects. But now objects are split into more
parts, and it's proven easier to just keep them as separate variables.
So it's time to cleanup the initial public/private code to follow the
same approach.

Change-Id: I3976b19fb433cbe21d299d3799ec616f9e59561e
Reviewed-on: https://go-review.googlesource.com/c/go/+/348412
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
3 years agocmd/compile: simplify value coding for unified IR
Matthew Dempsky [Tue, 7 Sep 2021 20:23:08 +0000 (13:23 -0700)]
cmd/compile: simplify value coding for unified IR

In indexed export, values are always exported along with their type
and are encoded in a type-sensitive manner, because this matches how
cmd/compile handled constants internally.

However, go/types intentionally differs from this, decoupling type
from value representation. As unified IR strives to be more
go/types-centric, it makes sense to embrace this and make values a
more first-class encoding.

Change-Id: If21d849c4f610358bd776d5665469d180bcd5f6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/348014
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
3 years agocmd/compile: extrapolate $GOROOT in unified IR
Matthew Dempsky [Wed, 8 Sep 2021 22:59:11 +0000 (15:59 -0700)]
cmd/compile: extrapolate $GOROOT in unified IR

This ensures that diagnostics for files within $GOROOT continue to be
reported using their full filepath, rather than the abbreviated
filepath. Notably, this is necessary for test/run.go, which has tests
that expect to see the full filepath.

Updates #48247.

Change-Id: I440e2c6dd6109ca059d81cee49e476bba805d703
Reviewed-on: https://go-review.googlesource.com/c/go/+/348670
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/types, types2: add Environment to Config
Robert Griesemer [Wed, 8 Sep 2021 23:03:57 +0000 (16:03 -0700)]
go/types, types2: add Environment to Config

Port to types2 and adjust compiler accordingly.

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

3 years agocmd/compile/internal/types2: spell out 'Type' in type parameter APIs
Robert Griesemer [Wed, 8 Sep 2021 22:22:20 +0000 (15:22 -0700)]
cmd/compile/internal/types2: spell out 'Type' in type parameter APIs

This is a port of CL 348376 with the necessary adjustments
in the compiler.

Change-Id: Ib11ee841b194746ff231ee493aa56bf9b3a4a67f
Reviewed-on: https://go-review.googlesource.com/c/go/+/348577
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile: add automated rewrite cycle detection
Josh Bleecher Snyder [Sun, 5 Sep 2021 02:29:08 +0000 (19:29 -0700)]
cmd/compile: add automated rewrite cycle detection

A common bug during development is to introduce rewrite rule cycles.
This is annoying because it takes a while to notice that
make.bash is a bit too slow this time, and to remember why.
And then you have to manually arrange to debug.

Make this all easier by automating it.
Detect cycles, and when we detect one, print the sequence
of rewrite rules that occur within a single cycle before crashing.

Change-Id: I8dadda13990ab925a81940d4833c9e5243368435
Reviewed-on: https://go-review.googlesource.com/c/go/+/347829
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/compile/internal/types2: temporarily pin the Checker to Interface during checking
Robert Griesemer [Wed, 8 Sep 2021 20:52:46 +0000 (13:52 -0700)]
cmd/compile/internal/types2: temporarily pin the Checker to Interface during checking

This is a clean port of CL 348371.

Change-Id: I3a61a5a8928279bc783ef16739f7607de3b6ecf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/348575
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: move NewTypeParam off of Checker
Robert Griesemer [Wed, 8 Sep 2021 20:45:16 +0000 (13:45 -0700)]
cmd/compile/internal/types2: move NewTypeParam off of Checker

This is a port of CL 347561.

A comment was corrected both in types2 and go/types, and the
compiler adjusted for the updated NewTypeParameter function.

Change-Id: I4381f0dd8e43228e1d037c5d997d421b7838f905
Reviewed-on: https://go-review.googlesource.com/c/go/+/348574
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: move typeHash to environment.go
Robert Griesemer [Wed, 8 Sep 2021 20:37:34 +0000 (13:37 -0700)]
cmd/compile/internal/types2: move typeHash to environment.go

This is a clean port of CL 347560.

Change-Id: I0d56f5a818df1a66e603415d5198d909b0aef228
Reviewed-on: https://go-review.googlesource.com/c/go/+/348573
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: implement deduplication of instances using the Environment
Robert Griesemer [Wed, 8 Sep 2021 20:30:36 +0000 (13:30 -0700)]
cmd/compile/internal/types2: implement deduplication of instances using the Environment

This is a port of CL 344390 with adjustments to names to make it
work for types2.

Change-Id: I05c33d9858f973adfbf48d8a1faaf377280f6985
Reviewed-on: https://go-review.googlesource.com/c/go/+/348572
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agogo/ast: rename MultiIndexExpr to IndexListExpr
Robert Findley [Wed, 8 Sep 2021 19:51:10 +0000 (15:51 -0400)]
go/ast: rename MultiIndexExpr to IndexListExpr

As discussed in #47781, IndexListExpr is one character shorter and has
the advantage of being next to IndexExpr in documentation.

Updates #47781

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

3 years agocmd/go: print offending -mod value in workspace mode
Michael Matloob [Fri, 3 Sep 2021 22:11:00 +0000 (18:11 -0400)]
cmd/go: print offending -mod value in workspace mode

Workspace mode only allows -mod to be set to 'readonly'. When returning
the error for other values of -mod, specify the the value in the error
so it's easier to see what's going on when the go command is invoked
through another tool.

For #45713, #48186

Change-Id: I3ba206a71c7a20c18aeccfa48f3c9dc935a180a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/347593
Trust: Michael Matloob <matloob@golang.org>
Trust: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
3 years agocmd/go: improve the creation and editing of go.work files
Michael Matloob [Fri, 3 Sep 2021 17:33:37 +0000 (13:33 -0400)]
cmd/go: improve the creation and editing of go.work files

This change changes go.work files so that directory paths are clearly
distinguished from module paths by either being rooted absolute paths or
starting with '.' or '..' path elements if they are relative paths.
go mod initwork now checks that the go.work file doesn't already exist
before creating it, and gomod initwork and gomod editwork look up the
module path corresponding to a directory and write it to the directory
directive's comment.

For #45713

Change-Id: I6983779059b7de6fc83d359280ceffb263f6b641
Reviewed-on: https://go-review.googlesource.com/c/go/+/347591
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agogo/types: temporarily pin the Checker to Interface during checking
Robert Findley [Wed, 8 Sep 2021 13:58:44 +0000 (09:58 -0400)]
go/types: temporarily pin the Checker to Interface during checking

While type checking expressions involving interface types, it is
possible that their type set is used before delayed actions are
processed. As a result, computeInterfaceTypeSet is called with a nil
checker, and errors in the interface type definition result in panics
(see #48234).

To avoid the panics, store a *Checker on Interface for use in between
checking of the interface type expression and processing of delayed
actions.

Fixes #48234

Change-Id: I5509bc1c01b55edac52446b9e075fbe8fcc01874
Reviewed-on: https://go-review.googlesource.com/c/go/+/348371
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: spell out 'Type' in type parameter APIs
Robert Findley [Wed, 8 Sep 2021 15:57:04 +0000 (11:57 -0400)]
go/types: spell out 'Type' in type parameter APIs

As discussed on the go/types proposal (#47916), we should spell out the
word 'Type', rather than using 'T'.

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

3 years agogo/ast: rename TParams fields to TypeParams
Robert Findley [Wed, 8 Sep 2021 15:46:58 +0000 (11:46 -0400)]
go/ast: rename TParams fields to TypeParams

As discussed in the ast proposal (#47781), there's not really a strong
reason to avoid spelling out 'Type'.

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

3 years agogo/types: move NewTypeParam off of Checker
Robert Findley [Fri, 3 Sep 2021 15:22:18 +0000 (11:22 -0400)]
go/types: move NewTypeParam off of Checker

This aligns with the API proposal.

Change-Id: I9967a317196392ffa5ddbe5391d7aba5f6e7bad2
Reviewed-on: https://go-review.googlesource.com/c/go/+/347561
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: move typeHash to environment.go
Robert Findley [Fri, 3 Sep 2021 15:17:37 +0000 (11:17 -0400)]
go/types: move typeHash to environment.go

This is a pure code move, with no other changes.

Change-Id: Id31f1f960d3208dc614556de89bf39b7ca77df3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/347560
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/types: implement deduplication of instances using the Environment
Robert Findley [Thu, 2 Sep 2021 22:39:58 +0000 (18:39 -0400)]
go/types: implement deduplication of instances using the Environment

Implement deduplication of type instances via the Environment by
recording a map of unique IDs for *Named types. This avoids an issue
with the existing type hash, where qualified names alone were not
sufficient to differentiate two *Named types that have the same fully
qualified name but which are distinct pointers. It also allows us to
drop the scope accounting for local types.

A subtle bug is also fixed in subst.go, where the instance t was passed
to typeHash rather than t.orig.

Change-Id: I85639ccc1c9bfee470babd2fc85375484c8ed0b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/344390
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agocmd/go/internal/modload: scan dependencies of root paths when raising version limits...
Bryan C. Mills [Thu, 2 Sep 2021 15:23:20 +0000 (11:23 -0400)]
cmd/go/internal/modload: scan dependencies of root paths when raising version limits in editRequirements

Fixes #47979

Change-Id: I1d9d854cda1378e20c70e6c6789b77e42e467ca7
Reviewed-on: https://go-review.googlesource.com/c/go/+/347290
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Jay Conrod <jayconrod@google.com>
3 years agocmd/compile/internal/types2: reduce number of delayed functions (optimization)
Robert Griesemer [Tue, 7 Sep 2021 22:13:24 +0000 (15:13 -0700)]
cmd/compile/internal/types2: reduce number of delayed functions (optimization)

Rather than create and delay execution of a closure for each type parameter
in a type parameter list, just create one per type parameter list.

While at it, inline the small amount of code for getting the type constraint
and remove the respective function.

Change-Id: I49a00ff0a7b7e43eb53992dd7dbfac25ff23b42c
Reviewed-on: https://go-review.googlesource.com/c/go/+/348018
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/compile/internal/types2: handle recursive type parameter constraints
Robert Griesemer [Tue, 7 Sep 2021 20:58:49 +0000 (13:58 -0700)]
cmd/compile/internal/types2: handle recursive type parameter constraints

Check type constraints after the respective type parameter list
has been associated with a parameterized type so that recursive
type parameter constraints "see" a parameterized type.

Fixes #45550.
Fixes #47796.

Change-Id: Iac74610ca017a78013820624230c857395506aff
Reviewed-on: https://go-review.googlesource.com/c/go/+/348090
Trust: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/pprof: update vendored github.com/google/pprof
Dmitri Shuralyov [Wed, 8 Sep 2021 14:51:06 +0000 (10:51 -0400)]
cmd/pprof: update vendored github.com/google/pprof

Pull in the latest published version of github.com/google/pprof
that is available at this time in the Go 1.18 development cycle.

Done with:

go get -d github.com/google/pprof@latest
go mod tidy
go mod vendor

For #36905.

Change-Id: Ib25aa38365ec70a0bed2a8a6527e5823ab9f9ded
Reviewed-on: https://go-review.googlesource.com/c/go/+/348410
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
3 years agotest/codegen: fix package name for test case
Michael Munday [Wed, 8 Sep 2021 14:14:53 +0000 (14:14 +0000)]
test/codegen: fix package name for test case

The codegen tests are currently skipped (see #48247). The test
added in CL 346050 did not compile because it was in the main
package but did not contain a main function. Changing the package
to 'codegen' fixes the issue.

Updates #48247.

Change-Id: I0a0eaca8e6a7d7b335606d2c76a204ac0c12e6d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/348392
Trust: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agotest/codegen: fix compilation of bitfield tests
Michael Munday [Wed, 8 Sep 2021 14:07:12 +0000 (14:07 +0000)]
test/codegen: fix compilation of bitfield tests

The codegen tests are currently skipped (see #48247) and the
bitfield tests do not actually compile due to a duplicate function
name (sbfiz5) added in CL 267602. Renaming the function fixes the
issue.

Updates #48247.

Change-Id: I626fd5ef13732dc358e73ace9ddcc4cbb6ae5b21
Reviewed-on: https://go-review.googlesource.com/c/go/+/348391
Trust: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agotest/codegen: remove broken riscv64 test
Michael Munday [Wed, 8 Sep 2021 13:57:07 +0000 (13:57 +0000)]
test/codegen: remove broken riscv64 test

This test is not executed by default (see #48247) and does not
actually pass. It was added in CL 346689. The code generation
changes made in that CL only change how instructions are assembled,
they do not actually affect the output of the compiler. This test
is unfortunately therefore invalid and will never pass.

Updates #48247.

Change-Id: I0c807e4a111336e5a097fe4e3af2805f9932a87f
Reviewed-on: https://go-review.googlesource.com/c/go/+/348390
Trust: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoall: update vendored golang.org/x/tools
Dmitri Shuralyov [Wed, 8 Sep 2021 13:58:45 +0000 (09:58 -0400)]
all: update vendored golang.org/x/tools

Now that issue #48124 is resolved, ran the
following commands inside the cmd module:

go get -d golang.org/x/tools@36045662144327e4475f9d356f49ab32ce730049  # main branch
go mod tidy
go mod vendor

For #36905.
Updates #48124.

Change-Id: I9dc736c2c5256f7d9e80fd9c52c6725ecf0b8001
Reviewed-on: https://go-review.googlesource.com/c/go/+/348409
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Alexander Rakoczy <alex@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alexander Rakoczy <alex@golang.org>
3 years agocmd/link: rework .TOC. handling for ppc64le
Paul E. Murphy [Tue, 23 Mar 2021 20:52:49 +0000 (15:52 -0500)]
cmd/link: rework .TOC. handling for ppc64le

Setup .TOC. to point to the same place for all objects. Today, the linker
assumes all call relocations can use the local function entry point of
imported object files. This requires a consistent pointer across all
objects.

This intentionally computes the .TOC. pointer in all linking configurations.
In some cases the .TOC. is not used today (e.g linking position-dependent go
only code). It is harmless and simple to compute in all cases, so just
do it for easier maintenance.

Notably, .TOC. is used in some cases when static linking is requested on
ppc64le/linux:

* Position-independent C code using a PC-rel relocation against .TOC.. cgo
  generated C object files are usually compiled PIC even if the go binary
  itself is not.

* Anything which causes PLT stub generation. The stubs always generate
  a .TOC. relative relocation.

* The race detector. Today, this links in an externally compiled archive which
  contains position-independent object files.

Similarly, position-independent linking is always punted to the external
linker on ppc64 today.

Updates #21961
Fixes #15409

Change-Id: Ifd8294b9249e16ba8b92eaf876d15d162f9c61fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/304458
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Lynn Boger <laboger@linux.vnet.ibm.com>

3 years agocmd/link/internal/riscv64,cmd/internal/obj/riscv: make error messages consistent
Joel Sing [Wed, 25 Aug 2021 15:15:23 +0000 (01:15 +1000)]
cmd/link/internal/riscv64,cmd/internal/obj/riscv: make error messages consistent

Be consistent with both style/wording and formatting of error messages.

Change-Id: I23013d904333a67a8f17dd364bb5015f54f419c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/345050
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/interna/obj/riscv: use obj.REG_NONE rather than 0
Joel Sing [Wed, 25 Aug 2021 10:08:37 +0000 (20:08 +1000)]
cmd/interna/obj/riscv: use obj.REG_NONE rather than 0

No functional change, but makes the code consistent and more readable.

Change-Id: I33db681fe0ed501842755f27b6e7843cdc8877cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/345049
Trust: Joel Sing <joel@sing.id.au>
Trust: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
3 years agocmd/internal/obj/riscv: simplify machine code output
Joel Sing [Mon, 23 Aug 2021 11:32:30 +0000 (21:32 +1000)]
cmd/internal/obj/riscv: simplify machine code output

Use cursym.WriteInt rather than building up a slice of bytes and then writing them
out via PutUint32. This also allows for variable instruction sizes, which will be
needed when support for compressed (2 byte length) instructions is added.

Change-Id: I17c9ffa52d27c91a24e161317e3db28e224804ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/344460
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/internal/obj/riscv: absorb rewriteMOV into instruction generation
Joel Sing [Sat, 21 Aug 2021 09:06:25 +0000 (09:06 +0000)]
cmd/internal/obj/riscv: absorb rewriteMOV into instruction generation

Replace the now poorly named rewriteMOV function with a markRelocs function,
absorbing the MOV validation into the instruction generation code.

Change-Id: I6ae94553f7f300862c40310343ef0be8f44a4b0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/344459
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/internal/obj/riscv: simplify rewriteMOV
Joel Sing [Sat, 21 Aug 2021 04:30:29 +0000 (04:30 +0000)]
cmd/internal/obj/riscv: simplify rewriteMOV

Rewrite and simplify the rewriteMOV function in preparation for eliminating it
entirely. Improve some error messages in the process.

Change-Id: Id9a77be5174d46cc23651930c2e9068ee6555690
Reviewed-on: https://go-review.googlesource.com/c/go/+/344458
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoreflect: add back signaling NaN test
Keith Randall [Tue, 7 Sep 2021 23:24:49 +0000 (16:24 -0700)]
reflect: add back signaling NaN test

I was a little too agressive in CL 258957 (removing 387 support) in
removing a signaling NaN test that should probably still exist.
I should have just removed the 387 skip, not the entire test.

Change-Id: I97ca53f190eb0de00e43b96629b2cae677e7dacb
Reviewed-on: https://go-review.googlesource.com/c/go/+/348209
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agoreflect: correct typoo in comment
Ian Lance Taylor [Tue, 7 Sep 2021 23:10:31 +0000 (16:10 -0700)]
reflect: correct typoo in comment

Change-Id: Ic3c69906a8afde63278f173df0427b1c460c9f3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/348189
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: add CONVIFACE nodes needed in generic code due to assignments
Dan Scales [Tue, 31 Aug 2021 15:01:44 +0000 (08:01 -0700)]
cmd/compile: add CONVIFACE nodes needed in generic code due to assignments

Added new function earlyTransformAssign() to add needed CONVIFACE nodes
due to assignments in generic functions.

Fixes #48049

Change-Id: I7cd9cee6ecf34ed2ef0743d1b17645b9f520fa00
Reviewed-on: https://go-review.googlesource.com/c/go/+/347914
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agoreflect: add test for passing float32 signaling NaNs
Keith Randall [Tue, 7 Sep 2021 22:13:51 +0000 (15:13 -0700)]
reflect: add test for passing float32 signaling NaNs

Update #40724

Change-Id: I110cdb7c4a2c5db6b85ca951143430555261abf3
Reviewed-on: https://go-review.googlesource.com/c/go/+/348017
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agoreflect: rename MapIter method receiver variable from it to iter
Josh Bleecher Snyder [Sat, 4 Sep 2021 21:55:57 +0000 (14:55 -0700)]
reflect: rename MapIter method receiver variable from it to iter

This is easier to use in documentation.
Adjust the existing documentation that worked around the unfortunate name.

Change-Id: Ia4b7793ab94dfd7fb3968ee983be56cc38c30ec3
Reviewed-on: https://go-review.googlesource.com/c/go/+/347769
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
3 years agoreflect: add MapIter.Reset
Josh Bleecher Snyder [Fri, 21 May 2021 16:43:58 +0000 (09:43 -0700)]
reflect: add MapIter.Reset

This allows callers to do (amortized) allocation-free iteration
over many maps.

Fixes #46293

Change-Id: I3aa6134dd00da35b508bd1e3b487332a871a3673
Reviewed-on: https://go-review.googlesource.com/c/go/+/321891
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/compile: remove now-unneeded SetHasTParam() for cached ptr element
Dan Scales [Tue, 7 Sep 2021 17:54:17 +0000 (10:54 -0700)]
cmd/compile: remove now-unneeded SetHasTParam() for cached ptr element

We had code in NewPtr() to set the HasTParam/HasShape flag as needed for
the cached ptr element if it wasn't set correctly based on its Elem.
This was causing the race mentioned in the issue.

But that setting code is no longer needed, as long as we call
SetRParams() soon after calling NewIncompleteNamedType(), before
creating/translating the underlying type (which we do). The
HasTParam/HasShape attribute can only come from setting of rparams or a
direct typeparam/shape somewhere in the underlying type, both of which
don't depend on recursion, etc. (as long as the rparams are set early).
Added a check that HasTParam/HasShape are set correctly for the cached
pointer/slice elems in NewPtr() and NewSlice().

Fixes #48191

Change-Id: Ide7d82efb77ae97901e75b2e6c65bd1bfc25e0ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/348089
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agoencoding/gob: optimize decoding of slice
korzhao [Fri, 3 Sep 2021 07:55:16 +0000 (15:55 +0800)]
encoding/gob: optimize decoding of slice

In CL 345572, we used the reflect.Value.SetLen method to avoid
extra memory allocation for reflect.Value.Slice.
This also applies to function decodeSlice

name                   old time/op    new time/op    delta
DecodeStringsSlice-12    96.5µs ±12%    63.0µs ± 8%  -34.68%  (p=0.000 n=9+10)

name                   old alloc/op   new alloc/op   delta
DecodeStringsSlice-12    89.3kB ± 0%    65.3kB ± 0%  -26.89%  (p=0.000 n=10+10)

name                   old allocs/op  new allocs/op  delta
DecodeStringsSlice-12     3.18k ± 0%     2.18k ± 0%  -31.47%  (p=0.000 n=10+10)

Change-Id: Ifdb43716cc90a265962dec022704a5571f447fd8
Reviewed-on: https://go-review.googlesource.com/c/go/+/347533
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Rob Pike <r@golang.org>
Trust: Joe Tsai <joetsai@digital-static.net>
Run-TryBot: Joe Tsai <joetsai@digital-static.net>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: make sure imported instantiated types have their methods created
Dan Scales [Mon, 6 Sep 2021 23:25:43 +0000 (16:25 -0700)]
cmd/compile: make sure imported instantiated types have their methods created

We should be putting a newly instantiated imported type in
Instantiate/doInst onto the instTypeList, so its methods/dictionaries
are instantiated. To do this, we needed a more general way to add a
type to instTypeList, so add NeedInstType(), analogous to
NeedRuntimeType(). This has the extra advantage that now all types
created by the type substituter are added to instTypeList without any
extra code, which was easy to forget. doInst() now correctly calls
NeedInstType().

This is a bit aggressive, since a fully instantiated type in a generic
function/method may never be used, if the generic method is never
instantiated in the local package. But it should be fairly uncommon for
a generic method to mention a fully instantiated type (but it does
happen in this bug).

Fixes both cases mentioned in the bug.

Fixed #48185

Change-Id: I19b5012dfac17e306c8005f8595a648b0ab280d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/347909
Trust: Dan Scales <danscales@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/compile: add prefetch intrinsic support
Ruslan Andreev [Tue, 15 Jun 2021 14:04:30 +0000 (14:04 +0000)]
cmd/compile: add prefetch intrinsic support

This CL provide new intrinsics to emit prefetch instructions for AMD64
and ARM64 platforms:
Prefetch - prefetches data from memory address to cache;
PrefetchStreamed - prefetches data from memory address, with a hint
that this data is being streamed.

This patch also provides prefetch calls pointed by RSC inside scanobject
and greyobject of GC mark logic.

Performance results provided by Michael:
https://perf.golang.org/search?q=upload:20210901.9

Benchmark parameters:
tree2 -heapsize=1000000000 -cpus=8
tree -n=18
parser
peano

Benchmarks AMD64 (Xeon - Cascade Lake):
name        old time/op  new time/op  delta
Tree2-8     36.1ms ± 6%  33.4ms ± 5%  -7.65%  (p=0.000 n=9+9)
Tree-8       326ms ± 1%   324ms ± 1%  -0.44%  (p=0.006 n=9+10)
Parser-8     2.75s ± 1%   2.71s ± 1%  -1.47%  (p=0.008 n=5+5)
Peano-8     63.1ms ± 1%  63.0ms ± 1%    ~     (p=0.730 n=9+9)
[Geo mean]   213ms        207ms       -2.45%

Benchmarks ARM64 (Kunpeng 920):
name        old time/op  new time/op  delta
Tree2-8     50.3ms ± 8%  44.1ms ± 5%  -12.24%  (p=0.000 n=10+9)
Tree-8       494ms ± 1%   493ms ± 1%     ~     (p=0.684 n=10+10)
Parser-8     3.99s ± 1%   3.93s ± 1%   -1.37%  (p=0.016 n=5+5)
Peano-8     84.4ms ± 0%  84.1ms ± 1%     ~     (p=0.068 n=8+10)
[Geo mean]   302ms        291ms        -3.67%

Change-Id: I43e10bc2f9512dc49d7631dd8843a79036fa43d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/328289
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: resolve TODO in inl.go
zikaeroh [Tue, 7 Sep 2021 07:38:40 +0000 (00:38 -0700)]
cmd/compile: resolve TODO in inl.go

If the condition is a bool constant, there's no need to walk both
branches.

Passes toolstash -cmp.

Change-Id: I4ee5e3553ce07c2213efba0d33d869b4a1b57783
Reviewed-on: https://go-review.googlesource.com/c/go/+/347911
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoencoding/gob: marshal maps using reflect.Value.MapRange
korzhao [Wed, 4 Aug 2021 02:47:57 +0000 (02:47 +0000)]
encoding/gob: marshal maps using reflect.Value.MapRange

golang.org/cl/33572 added a map iterator.

use the reflect.Value.MapRange to fix map keys that contain a NaN

Fixes #24075

Change-Id: I0214d6f26c2041797703e48eac16404f189d6982
GitHub-Last-Rev: 5c01e117f4451dbaec657d02d006905df1d0055d
GitHub-Pull-Request: golang/go#47476
Reviewed-on: https://go-review.googlesource.com/c/go/+/338609
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
3 years agocmd/compile: fix type substituter to copy Funarg value for structs
Dan Scales [Tue, 7 Sep 2021 14:46:27 +0000 (07:46 -0700)]
cmd/compile: fix type substituter to copy Funarg value for structs

We were missing copying the Funarg value when substituting for a struct
type.

Change-Id: Id0c2d9e55fb15987acb9edba6f74cf57cfd3417e
Reviewed-on: https://go-review.googlesource.com/c/go/+/347913
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>

3 years agocmd/compile: fix lazy loading in reader2
Matthew Dempsky [Tue, 7 Sep 2021 17:51:14 +0000 (10:51 -0700)]
cmd/compile: fix lazy loading in reader2

Calling reader2.obj fully loads the referenced object, which is
necessary in general; but for reading the package index, we just need
to setup the name->index mapping. This CL adds this, so that lazy
loading works as intended.

Change-Id: Ie51d59e2247d99b46f9dc69fba7ce89e2584b7c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/348011
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
3 years agogo/types: do not format TParams when hashing
Cuong Manh Le [Tue, 7 Sep 2021 17:33:32 +0000 (00:33 +0700)]
go/types: do not format TParams when hashing

This is a port of CL 347534 to go/types.

Change-Id: I2b15a29992c430e34592d110be16d7b2b10521a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/348029
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: fix deadlock in (*Named).load
Cuong Manh Le [Sun, 5 Sep 2021 13:50:54 +0000 (20:50 +0700)]
cmd/compile: fix deadlock in (*Named).load

For lazy import resolution, there's reentrancy issue with (*Named).load
method, when "t.resolve(t)" can lead us to the same named type, thus
(*Named).load is called recursively, causing the deadlock.

The main problem is that when instantinate a type, we calculate the type
hashing, including TParams. Calling t.TParams().Len() triggers the
reentrancy call to "(*Named).load".

To fix this, just not checking TParams().Len() if we are hashing.

Updates #48185

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

3 years agocmd/link: resolve magic value in gdbscript section generation
Vyacheslav Pachkov [Mon, 23 Aug 2021 08:40:32 +0000 (08:40 +0000)]
cmd/link: resolve magic value in gdbscript section generation

According to the .debug_gdb_scripts section specification
[https://sourceware.org/gdb/onlinedocs/gdb/dotdebug_005fgdb_005fscripts-section.html],
each entry begins with a non-null prefix byte that specifies the kind of entry.
This commit resolves a question about magic byte and replaces a
hardcoded value with a meaningful constant "GdbScriptPythonFileId"
inside writegdbscript function.

Change-Id: I456c742bcb539a5853b9e2a6811033f35c37e7d4
GitHub-Last-Rev: 2f1c4cb9eec582a6e381fa866738aa17278005c2
GitHub-Pull-Request: golang/go#47646
Reviewed-on: https://go-review.googlesource.com/c/go/+/341391
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
3 years agocmd/compile: simplify less with non-negative number and constant 0 or 1
wdvxdr [Mon, 30 Aug 2021 14:26:54 +0000 (22:26 +0800)]
cmd/compile: simplify less with non-negative number and constant 0 or 1

The most common cases:
len(s) > 0
len(s) < 1

and they can be simplified to:
len(s) != 0
len(s) == 0

Fixes #48054

Change-Id: I16e5b0cffcfab62a4acc2a09977a6cd3543dd000
Reviewed-on: https://go-review.googlesource.com/c/go/+/346050
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/compile: make sure that the names created for instantiated type are the same
korzhao [Mon, 6 Sep 2021 13:08:05 +0000 (21:08 +0800)]
cmd/compile: make sure that the names created for instantiated type are the same

Now we have two functions that create names for instantiated types.
They are inconsistent when dealing with byte/rune type.

This CL makes instTypeName2 reuse the code of typecheck.InstTypeName

Fixes #48198

Change-Id: I4c216b532cba6618ef9b63fd0b76e8f1c0ed7a75
Reviewed-on: https://go-review.googlesource.com/c/go/+/347491
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agosyscall: use dup3 in forkAndExecInChild1 on all Linux platforms
Tobias Klauser [Mon, 6 Sep 2021 17:02:34 +0000 (19:02 +0200)]
syscall: use dup3 in forkAndExecInChild1 on all Linux platforms

The minimum required Linux kernel version for Go 1.18 will be changed to
2.6.32, see #45964. The dup3 syscall was added in 2.6.27, so the
fallback to use the dup2 syscall in forkAndExecInChild1 on some
platforms can be removed.

For #45964

Change-Id: I8e04d7b5b2488990a061a080ed64ea303ad048b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/347350
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/internal/sys: fix placement of loong64 definition
WANG Xuerui [Mon, 6 Sep 2021 07:17:11 +0000 (15:17 +0800)]
cmd/internal/sys: fix placement of loong64 definition

In rebasing the patch series up to CL 339015, the branches were messed
up by me, and changes from v3 to v4 of CL 339009 was lost. Fix the
ordering to restore alphabetical order per original review.

Change-Id: I8e57c96e996c4f962cab684a9d305a8dbdeea43b
Reviewed-on: https://go-review.googlesource.com/c/go/+/347731
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Meng Zhuo <mzh@golangcn.org>

3 years agocmd/compile: fix delay transformation in *subster.node()
korzhao [Sun, 29 Aug 2021 06:36:20 +0000 (14:36 +0800)]
cmd/compile: fix delay transformation in *subster.node()

Add OCALL, OCALLFUNC, OCALLMETH, OCALLINTER, ODYNAMICDOTTYPE transformations to the CALL check switch statement.

Fixes #48042

Change-Id: Ied93efd979c5b2c56b72fad26fccfd9f887361d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/345949
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
3 years agocmd/internal/sys: declare loong64 arch
WANG Xuerui [Sun, 20 Jun 2021 04:59:45 +0000 (12:59 +0800)]
cmd/internal/sys: declare loong64 arch

Updates #46229

Change-Id: Icb736f2440443e9245872b091d13e5bdfb6cb01a
Reviewed-on: https://go-review.googlesource.com/c/go/+/339009
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Meng Zhuo <mzh@golangcn.org>
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/compile: merge sign extension and shift into SBFIZ
fanzha02 [Mon, 6 Sep 2021 03:15:30 +0000 (11:15 +0800)]
cmd/compile: merge sign extension and shift into SBFIZ

This patch adds some rules to rewrite "(LeftShift (SignExtend x) lc)"
expression as "SBFIZ".

Add the test cases.

Change-Id: I294c4ba09712eeb02c7a952447bb006780f1e60d
Reviewed-on: https://go-review.googlesource.com/c/go/+/267602
Trust: fannie zhang <Fannie.Zhang@arm.com>
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/compile: merge zero/sign extensions with UBFX/SBFX on arm64
fanzha02 [Mon, 6 Sep 2021 03:06:16 +0000 (11:06 +0800)]
cmd/compile: merge zero/sign extensions with UBFX/SBFX on arm64

The UBFX and SBFX already zero/sign extend the result. Further
zero/sign extensions are thus unnecessary as long as they leave
the top bits unaltered. This patch absorbs zero/sign extensions
into UBFX/SBFX.

Add the related test cases.

Change-Id: I7c4516c8b52d677f77bf3aaedab87c4a28056ec0
Reviewed-on: https://go-review.googlesource.com/c/go/+/265039
Trust: fannie zhang <Fannie.Zhang@arm.com>
Trust: Keith Randall <khr@golang.org>
Run-TryBot: fannie zhang <Fannie.Zhang@arm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agoreflect: improve panic when MapIter has no associated map Value
Josh Bleecher Snyder [Fri, 21 May 2021 16:35:46 +0000 (09:35 -0700)]
reflect: improve panic when MapIter has no associated map Value

it := new(reflect.MapIter)
it.Next()

This generates a nil pointer dereference panic from reflect.Value.pointer.
Generate a clearer panic.

For #46293

Change-Id: I32a22c797e1ba3a7b4e70b38ceb4dedb44d264fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/321890
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agoreflect: allocate hiter as part of MapIter
Josh Bleecher Snyder [Thu, 20 May 2021 16:57:04 +0000 (09:57 -0700)]
reflect: allocate hiter as part of MapIter

This reduces the number of allocations per
reflect map iteration from two to one.

For #46293

Change-Id: Ibcff5f42fc512e637b6e460bad4518e7ac83d4c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/321889
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agocmd/compile/internal/types2: detect constraint type inference cycles
Robert Griesemer [Thu, 2 Sep 2021 23:43:29 +0000 (16:43 -0700)]
cmd/compile/internal/types2: detect constraint type inference cycles

See the detailed explanations in the code.

Fixes #48136.

Change-Id: I1667aabfbbff97967913b080c77e7ec04ea82feb
Reviewed-on: https://go-review.googlesource.com/c/go/+/347300
Trust: Robert Griesemer <gri@golang.org>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agocmd/internal/obj/riscv: improve code generation for loading of constants
Joel Sing [Mon, 9 Aug 2021 08:14:04 +0000 (08:14 +0000)]
cmd/internal/obj/riscv: improve code generation for loading of constants

Loading of constants that are 12 bits or smaller is currently performed using a single
ADDIW instruction, while constants between 13 bits and 32 bits are loaded using a
LUI+ADDIW pair.

Instead, use a single ADDI instruction for the 12 bits or smaller case - this
translates to the LI pseudo-instruction, making objdump more readable and giving:

   11c7c:       fff00293                li      t0,-1
   11c80:       00000313                li      t1,0

Rather than:

   11c7c:       fff0029b                addiw   t0,zero,-1
   11c80:       0000031b                sext.w  t1,zero

In the case where a constant exceeds 12 bits, an LUI instruction is required,
however if the lower 12 bits are zero, the ADDIW instruction can be omitted.
The same applies to the case where immediate splitting is performed for other
immediate instructions.

This removes around 900 instructions from the Go binary.

Change-Id: Id6c77774b3b429fa525da018a6926b85df838a2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/344457
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/internal/obj/riscv: avoid obj.Prog rewriting for address to register loads
Joel Sing [Fri, 20 Aug 2021 17:04:35 +0000 (17:04 +0000)]
cmd/internal/obj/riscv: avoid obj.Prog rewriting for address to register loads

Rather than rewriting the obj.Prog for a MOV pseudo-instruction targeting
an address to register load, generate the appropriate machine instruction
sequence directly.

Change-Id: I507195b6d24ff3253eadcc807ddbe27dca97d220
Reviewed-on: https://go-review.googlesource.com/c/go/+/344456
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/internal/obj/riscv: avoid obj.Prog rewriting for immediate splitting
Joel Sing [Thu, 19 Aug 2021 08:35:12 +0000 (08:35 +0000)]
cmd/internal/obj/riscv: avoid obj.Prog rewriting for immediate splitting

Rather than rewriting the obj.Prog for a immediate instructions that need
splitting, generate the appropriate machine instruction sequence directly.

Change-Id: Ie90f0e2a98f97a29281e445c4c3b0c47b793ef4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/344453
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agodatabase/sql: improve the documentation of Conn.Raw
korzhao [Mon, 2 Aug 2021 16:53:25 +0000 (16:53 +0000)]
database/sql: improve the documentation of Conn.Raw

Fixes #47500

Change-Id: Ibd44e4db15ea45bb53a6651a6567edfe6104d3d6
GitHub-Last-Rev: 61b8abbc28908fc807af7188e19089ac454b4817
GitHub-Pull-Request: golang/go#47503
Reviewed-on: https://go-review.googlesource.com/c/go/+/338970
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Trust: Cherry Mui <cherryyz@google.com>

3 years agocmd/internal/obj/riscv: avoid obj.Prog rewriting for memory stores
Joel Sing [Tue, 17 Aug 2021 18:25:05 +0000 (18:25 +0000)]
cmd/internal/obj/riscv: avoid obj.Prog rewriting for memory stores

Rather than rewriting the obj.Prog for a MOV pseudo-instruction targeting
a register to memory stores, generate the appropriate machine instruction
sequence directly.

Change-Id: I6eac8637e1fcb48c04d9f331cac7ae5d8cc54092
Reviewed-on: https://go-review.googlesource.com/c/go/+/344455
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/internal/obj/riscv: avoid obj.Prog rewriting for memory loads
Joel Sing [Fri, 19 Mar 2021 14:09:59 +0000 (14:09 +0000)]
cmd/internal/obj/riscv: avoid obj.Prog rewriting for memory loads

Rather than rewriting the obj.Prog for a MOV pseudo-instruction targeting
a memory to register load, generate the appropriate machine instruction
sequence directly.

Change-Id: I4c7292ba00f576ec71d4842b6ff27a8ce6db0650
Reviewed-on: https://go-review.googlesource.com/c/go/+/344454
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agocmd/internal/obj/riscv: avoid obj.Prog rewriting for store instructions
Joel Sing [Thu, 19 Aug 2021 05:33:01 +0000 (05:33 +0000)]
cmd/internal/obj/riscv: avoid obj.Prog rewriting for store instructions

Rather than rewriting the obj.Prog for a store instruction, generate the
appropriate machine instruction sequence directly.

Change-Id: I026250ca3d249a1013243948a4e567b708b72d0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/344452
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/internal/obj/riscv: avoid obj.Prog rewriting for load instructions
Joel Sing [Wed, 18 Aug 2021 18:14:52 +0000 (18:14 +0000)]
cmd/internal/obj/riscv: avoid obj.Prog rewriting for load instructions

Rather than rewriting the obj.Prog for a load instruction, generate the
appropriate machine instruction sequence directly.

Change-Id: Iba656dbf2dff2bce02aa221d9a5cad7b7c4630d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/344451
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/internal/obj/riscv: avoid obj.Prog rewriting for constant loads
Joel Sing [Tue, 17 Aug 2021 18:45:11 +0000 (18:45 +0000)]
cmd/internal/obj/riscv: avoid obj.Prog rewriting for constant loads

Rather than rewriting the obj.Prog for a MOV pseudo-instruction targeting
a constant to register load, generate the appropriate machine instruction
sequence directly.

Change-Id: I38e62f282b39be2a0a241f32280d306558d49b44
Reviewed-on: https://go-review.googlesource.com/c/go/+/344450
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/link: make npkgsyms meaningful
Tao Qingyun [Thu, 1 Jul 2021 00:22:51 +0000 (00:22 +0000)]
cmd/link: make npkgsyms meaningful

npkgsyms always equals 1 currently.

Change-Id: Ie88bc273beaace12ec7432054ca7c151396e8e35
GitHub-Last-Rev: c5d3b12b88ddcdc6011f97787fd7c0e94c7df20e
GitHub-Pull-Request: golang/go#46988
Reviewed-on: https://go-review.googlesource.com/c/go/+/331929
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

3 years agoRevert "go/ast: clarify when Ident.Obj is nil"
Tim King [Fri, 3 Sep 2021 20:27:35 +0000 (20:27 +0000)]
Revert "go/ast: clarify when Ident.Obj is nil"

This reverts commit 52aef05498a9e84ede16fb7ce46a2a252af05479.

Reason for revert: After discussion on CL 347530, it is not clear this is an improvement to the documentation.

Updates #48141

Change-Id: I5f3d9995c5f5666b92602c4b8ec393673baa73fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/347592
Trust: Cherry Mui <cherryyz@google.com>
Trust: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
3 years agomisc/wasm: enable ECMAScript strict mode
rhysd [Tue, 13 Jul 2021 14:05:17 +0000 (23:05 +0900)]
misc/wasm: enable ECMAScript strict mode

Current wasm_exec.js does not enable ECMAScript strict mode. But it is
recommended to be enabled because it

1. eliminates some ECMAScript silent errors by changing them to throw
   errors
2. fixes mistakes that make it difficult for JavaScript engines to
   perform optimizations
3. prohibits some syntax likely to be defined in future versions of
   ECMAScript

This commit enables ECMAScript strict mode in wasm_exec.js following the
transition guide:

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Strict_mode/Transitioning_to_strict_mode

Fixes #47116

Change-Id: Ib8ffceee37e9127698fb51304241f1e429efe83e
Reviewed-on: https://go-review.googlesource.com/c/go/+/334269
Reviewed-by: Richard Musiol <neelance@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Richard Musiol <neelance@gmail.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agogo/ast: clarify when Ident.Obj is nil
Cuong Manh Le [Fri, 3 Sep 2021 04:18:16 +0000 (11:18 +0700)]
go/ast: clarify when Ident.Obj is nil

Fixes #48141

Change-Id: Id20b7801d31456ffd74301ed0fd84788b8982fb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/347530
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agocmd/internal/obj/riscv: factor out instructions for MOV pseudo-instructions
Joel Sing [Mon, 23 Aug 2021 15:01:06 +0000 (01:01 +1000)]
cmd/internal/obj/riscv: factor out instructions for MOV pseudo-instructions

This factors out the machine instruction generation for MOV pseudo-instructions,
which will simplify further changes.

Change-Id: Ic0d2c3ae9e0881f7894af50ed45e93b0e4961632
Reviewed-on: https://go-review.googlesource.com/c/go/+/344461
Trust: Joel Sing <joel@sing.id.au>
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
3 years agorefect: rename Ptr Kind to Pointer (but keep Ptr)
Brad Fitzpatrick [Wed, 11 Aug 2021 17:54:39 +0000 (10:54 -0700)]
refect: rename Ptr Kind to Pointer (but keep Ptr)

reflect.Ptr didn't match reflect.UnsafePointer or unsafe.Pointer
so rename it to reflect.Pointer. Keep reflect.Ptr for compatibility.

Likewise with PtrTo.

Change to use it in std will come in a subsequent CL.

Fixes #47651

Change-Id: I5d4abe2b2fe10948bd68bb12c557165bedffbcba
Reviewed-on: https://go-review.googlesource.com/c/go/+/341333
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Joe Tsai <joetsai@digital-static.net>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agoimage/draw: add RGBA64Image fast path
Nigel Tao [Thu, 5 Aug 2021 06:11:28 +0000 (16:11 +1000)]
image/draw: add RGBA64Image fast path

name               old time/op  new time/op  delta
GenericOver-4      15.0ms ± 1%   2.9ms ± 1%  -80.56%  (p=0.008 n=5+5)
GenericMaskOver-4  7.82ms ± 4%  1.69ms ± 2%  -78.38%  (p=0.008 n=5+5)
GenericSrc-4       6.13ms ± 3%  1.66ms ± 1%  -72.90%  (p=0.008 n=5+5)
GenericMaskSrc-4   11.5ms ± 1%   2.0ms ± 0%  -82.77%  (p=0.008 n=5+5)

Updates #44808.

Change-Id: I131cf6fad01708540390a8012d8f2a21e849fe9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/340049
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Nigel Tao <nigeltao@golang.org>

3 years agodebug/dwarf: check for DWARFv4 AttrDataBitOffset value
Joe Sylve [Thu, 2 Sep 2021 19:09:15 +0000 (19:09 +0000)]
debug/dwarf: check for DWARFv4 AttrDataBitOffset value

AttrBitOffset is deprecated (but reserved) in DWARFv4.  This fix adds
logic to check the new AttrDataBitOffset attribute if AttrBitOffset
attribute is not present.

Fixes #46784

Change-Id: I7406dcaa4c98e95df72361fd4462c39e6be8879d
GitHub-Last-Rev: 5aa10d04910a09538320b4de8fbd8a1f5fd8c17d
GitHub-Pull-Request: golang/go#46790
Reviewed-on: https://go-review.googlesource.com/c/go/+/328709
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Michael Knyszek <mknyszek@google.com>

3 years agocmd/compile: correct a comment in uint64Tofloat
Cherry Mui [Fri, 30 Jul 2021 17:12:27 +0000 (13:12 -0400)]
cmd/compile: correct a comment in uint64Tofloat

We only do z>>1 once (as it should be). Remove the extra one
in the comment.

Change-Id: I6fea05fe697de07e160bd686697377babcb3e4c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/347400
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
3 years agotest: only test -G=3 by default
Matthew Dempsky [Thu, 2 Sep 2021 19:14:47 +0000 (12:14 -0700)]
test: only test -G=3 by default

-G=0 is in maintenance mode, so limit testing it to the longtest
builders.

Change-Id: Ie8a01866b506183d0201f2a3730377cfa663da80
Reviewed-on: https://go-review.googlesource.com/c/go/+/347298
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agosrc: do not emit warning when GOROOT_BOOTSTRAP is unset
Cuong Manh Le [Thu, 2 Sep 2021 19:00:01 +0000 (02:00 +0700)]
src: do not emit warning when GOROOT_BOOTSTRAP is unset

Fixes #48155

Change-Id: I610a20d3af55035bb0b1047509361b204253801e
Reviewed-on: https://go-review.googlesource.com/c/go/+/347273
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
3 years agogo/types: systematic detection of missing instantiation
Robert Findley [Thu, 2 Sep 2021 14:50:42 +0000 (10:50 -0400)]
go/types: systematic detection of missing instantiation

This is a port of CL 346471 to go/types. Additionally, CheckExpr was
updated for the new API to explicitly allow generic expressions.

The error messages in issue39634.go2 are different because go/parser
produces an IndexExpr with BadExpr index value, for backward
compatibility.

Change-Id: I725926de183a016381513fe0e750d1280688ce29
Reviewed-on: https://go-review.googlesource.com/c/go/+/347391
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agonet/http: fix hang in probing for a zero-length request body
Damien Neil [Fri, 6 Aug 2021 02:26:21 +0000 (19:26 -0700)]
net/http: fix hang in probing for a zero-length request body

Fix a hang that occurs when making a request and all of the following apply:
* The request method is one of GET, HEAD, DELETE, OPTIONS, PROPFIND, or SEARCH.
* The Request.Body is non-nil.
* The content length is not set, or is set to -1.
* Transfer-Encoding: chunked is not set.
* The request body does not respond to a read within 200ms.

In this case, we give up on probing for a zero-length body and send the
request while the probe completes in the background. Fix a bug in the
io.Reader wrapping the in-flight probe: It should return io.EOF after
the probe completes, but does not.

Fixes #47568.

Change-Id: I7f9188c96e1210055df68424081af927006e4816
Reviewed-on: https://go-review.googlesource.com/c/go/+/340256
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ingo Oeser <nightlyone@googlemail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agonet/http: close request body after recovering from a handler panic
Damien Neil [Tue, 22 Jun 2021 03:23:36 +0000 (20:23 -0700)]
net/http: close request body after recovering from a handler panic

When recovering from a panic in a HTTP handler, close the request body
before closing the *conn, ensuring that the *conn's bufio.Reader is safe
to recycle.

Fixes #46866.

Change-Id: I3fe304592e3b423a0970727d68bc1229c3752939
Reviewed-on: https://go-review.googlesource.com/c/go/+/329922
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
3 years agoall: update vendored dependencies for Go 1.18
Dmitri Shuralyov [Thu, 2 Sep 2021 00:04:30 +0000 (20:04 -0400)]
all: update vendored dependencies for Go 1.18

Go 1.18 development is well underway. This is a time to update all
golang.org/x/... module versions that contribute packages to the std
and cmd modules in the standard library to latest master versions.

gotip $ updatestd -goroot=$(pwd) -branch=master
> go version
go version devel go1.18-2872496ba5 Wed Sep 1 23:41:53 2021 +0000 darwin/amd64
> go env GOROOT
/Users/dmitshur/gotip
> go version -m /Users/dmitshur/go/bin/bundle
/Users/dmitshur/go/bin/bundle: go1.17
path golang.org/x/tools/cmd/bundle
mod golang.org/x/tools v0.1.5 h1:ouewzE6p+/VEB31YYnTbEJdi8pFqKp4P4n85vwo3DHA=
dep golang.org/x/mod v0.4.2 h1:Gz96sIWK3OalVv/I/qNygP42zyoKp3xptRVCWRFEBvo=
dep golang.org/x/sys v0.0.0-20210510120138-977fb7262007 h1:gG67DSER+11cZvqIMb8S8bt0vZtiN6xWYARwirrOSfE=
dep golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 h1:go1bK/D/BFZV2I8cIQd1NKEZ+0owSTG1fDTci4IqFcE=

skipping github.com/chzyer/logex (out of scope, it's not a golang.org/x dependency)
skipping github.com/chzyer/readline (out of scope, it's not a golang.org/x dependency)
skipping github.com/chzyer/test (out of scope, it's not a golang.org/x dependency)
skipping github.com/google/pprof (out of scope, it's not a golang.org/x dependency)
skipping github.com/ianlancetaylor/demangle (out of scope, it's not a golang.org/x dependency)
skipping github.com/yuin/goldmark (out of scope, it's not a golang.org/x dependency)
skipping golang.org/x/tools (temporarily out of scope due to golang.org/issue/48124)
skipping rsc.io/pdf (out of scope, it's not a golang.org/x dependency)
updating module cmd in /Users/dmitshur/gotip/src/cmd
> go mod edit -go=1.18
> go get -d golang.org/x/arch@ebb09ed340f18f7e2a2200f1adf792992c448346 golang.org/x/crypto@32db794688a5a24a23a43f2a984cecd5b3d8da58 golang.org/x/mod@1b1db11ec8f43eeafa9418698423dc637655ff0c golang.org/x/net@e898025ed96aa6d08e98132b8dca210e9e7a0cd2 golang.org/x/sync@036812b2e83c0ddf193dd5a34e034151da389d09 golang.org/x/sys@f4d43177bf5e2ee98617956e417d0555d4b69c17 golang.org/x/term@6886f2dfbf5b25f595b4fe4279c49956e867c59b golang.org/x/text@383b2e75a7a4198c42f8f87833eefb772868a56f golang.org/x/xerrors@5ec99f83aff198f5fbd629d6c8d8eb38a04218ca
go get: upgraded golang.org/x/arch v0.0.0-20210502124803-cbf565b21d1e => v0.0.0-20210901143047-ebb09ed340f1
go get: upgraded golang.org/x/mod v0.5.1-0.20210827163434-4029241eb1d5 => v0.5.1-0.20210830214625-1b1db11ec8f4
go get: upgraded golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 => v0.0.0-20210825183410-e898025ed96a
go get: upgraded golang.org/x/term v0.0.0-20210503060354-a79de5458b56 => v0.0.0-20210615171337-6886f2dfbf5b
go get: upgraded golang.org/x/text v0.3.3 => v0.3.7
> go mod tidy
> go mod vendor

skipping golang.org/x/tools (temporarily out of scope due to golang.org/issue/48124)
updating module std in /Users/dmitshur/gotip/src
> go mod edit -go=1.18
> go get -d golang.org/x/crypto@32db794688a5a24a23a43f2a984cecd5b3d8da58 golang.org/x/net@e898025ed96aa6d08e98132b8dca210e9e7a0cd2 golang.org/x/sys@f4d43177bf5e2ee98617956e417d0555d4b69c17 golang.org/x/term@6886f2dfbf5b25f595b4fe4279c49956e867c59b golang.org/x/text@383b2e75a7a4198c42f8f87833eefb772868a56f
go get: upgraded golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1 => v0.0.0-20210615171337-6886f2dfbf5b
go get: upgraded golang.org/x/text v0.3.7-0.20210503195748-5c7c50ebbd4f => v0.3.7
> go mod tidy
> go mod vendor

updating bundles in /Users/dmitshur/gotip/src
> go generate -run=bundle std cmd

The x/tools module will be updated in a following CL,
after issue #48124 is resolved.

The module in GOROOT/src/crypto/ed25519/internal/edwards25519/field/_asm
directory is not updated in this CL.

For #36905.

Change-Id: I728000e8465c0fbf6976629e6da42cc4f9be20fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/347191
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

3 years agogo/internal/gcimporter: always call SetTParams, even if empty
Robert Findley [Thu, 2 Sep 2021 14:36:37 +0000 (10:36 -0400)]
go/internal/gcimporter: always call SetTParams, even if empty

This resolves an outstanding TODO to be consistent about calling
SetTParams.

Done in both go/internal/gcimporter and cmd/compile/internal/importer.

Change-Id: Ief642efe016f02bab1bab960f6731a0ac0a8ad28
Reviewed-on: https://go-review.googlesource.com/c/go/+/347389
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agoall: update vendored golang.org/x/crypto
Dmitri Shuralyov [Thu, 2 Sep 2021 15:27:12 +0000 (11:27 -0400)]
all: update vendored golang.org/x/crypto

Ran the following commands inside std and cmd modules:

go get -d golang.org/x/crypto@32db794688a5a24a23a43f2a984cecd5b3d8da58  # master
go mod tidy
go mod vendor

Also add the new golang.org/x/crypto/curve25519/internal/field package
(it was created in x/crypto CL 315269) to TestDependencies in go/build.
Position it next to its upstream copy, since its required dependencies
are expected to be identical.

For #36905.

Change-Id: I589499cd7176c9b4b8758e59025653d19b58130e
Reviewed-on: https://go-review.googlesource.com/c/go/+/347190
Trust: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
3 years agocmd/link: mark stacks as non-executable on freebsd
Keith Randall [Wed, 1 Sep 2021 15:33:42 +0000 (08:33 -0700)]
cmd/link: mark stacks as non-executable on freebsd

Fixes #48112

Change-Id: I673a5fe61171e5ba3d8ce58daac79391fb4758f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/346872
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>

3 years agoall: update vendored golang.org/x/sys
Dmitri Shuralyov [Wed, 1 Sep 2021 23:59:20 +0000 (19:59 -0400)]
all: update vendored golang.org/x/sys

Ran the following commands inside std and cmd modules:

go get -d golang.org/x/sys@f4d43177bf5e2ee98617956e417d0555d4b69c17  # master
go mod tidy
go mod vendor

Followed by the following command in std module:

go generate syscall internal/syscall/...

For #36905.

Change-Id: I53d6ba03246372b6f7abd5ac57dbb71715d6eb4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/347189
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>

3 years agocmd/link: avoid crash on undefined func sym with external linking
Than McIntosh [Thu, 26 Aug 2021 19:59:36 +0000 (15:59 -0400)]
cmd/link: avoid crash on undefined func sym with external linking

Fix a buglet in relocation processing that crops up with external
linking when you have an undefined function symbol that also has a
prototype (as if it were being defined in assembly src).

Fixes #47993.

Change-Id: Ib655492a63b205ffdc124cfd0cb7f7b731571821
Reviewed-on: https://go-review.googlesource.com/c/go/+/345473
Trust: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Jeremy Faller <jeremy@golang.org>
3 years agocmd/internal/obj/riscv: simplify addition with constant
Ben Shi [Thu, 2 Sep 2021 00:06:42 +0000 (00:06 +0000)]
cmd/internal/obj/riscv: simplify addition with constant

This CL simplifies riscv addition (add r, imm) to
(ADDI (ADDI r, imm/2), imm-imm/2) if imm is in specific ranges.
(-4096 <= imm <= -2049 or 2048 <= imm <= 4094)

There is little impact to the go1 benchmark, while the total
size of pkg/linux_riscv64 decreased by about 11KB.

Change-Id: I236eb8af3b83bb35ce9c0b318fc1d235e8ab9a4e
GitHub-Last-Rev: a2f56a07635344a40d6b8a9571f236743122be34
GitHub-Pull-Request: golang/go#48110
Reviewed-on: https://go-review.googlesource.com/c/go/+/346689
Run-TryBot: Ben Shi <powerman1st@163.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Michael Munday <mike.munday@lowrisc.org>

3 years agogo/internal/gcimporter: add import tests for type parameters
Robert Findley [Wed, 1 Sep 2021 20:51:17 +0000 (16:51 -0400)]
go/internal/gcimporter: add import tests for type parameters

Add a new test TestImportTypeparamTests that compiles and imports
packages contained in test/typeparam, and compares the resulting package
scope with the scope produced by type-checking directly.

In the process, fix a bug in go/types affecting embedded instances with
more than one type argument. This was uncovered by smoketest.go.

To enable this new test it was easiest to move gcimporter_test.go to an
external test, which required copying the pkgExts variable.

Fixes #48101

Change-Id: Ie4d981bf463e886a8d141809805d184dbbf64607
Reviewed-on: https://go-review.googlesource.com/c/go/+/347070
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agogo/internal/gcimporter: add support for importing parameterized types
Robert Findley [Wed, 1 Sep 2021 18:15:05 +0000 (14:15 -0400)]
go/internal/gcimporter: add support for importing parameterized types

Port the necessary logic to go/internal/gcimporter from
cmd/compile/internal/importer/iimport.go to support type parameters.

This is a partial port of several compiler CLs: at least CL 319930,
CL 322609, CL 323029, CL 338192, CL 340251, and CL 340989. Because these
ports were not interleaved with the corresponding go/types API changes,
it is easier to just take the latest importer logic.

Notably, the equivalent of types2.AsTypeParam is not used. It should be
unnecessary.

Updates #48101

Change-Id: I938bd8debc3f6a68a3ad8d44c61ef9c5038be7e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/347069
Trust: Robert Findley <rfindley@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
3 years agoruntime: do not alloc never used tail bytes in fixalloc
Hans [Mon, 2 Aug 2021 05:43:29 +0000 (05:43 +0000)]
runtime: do not alloc never used tail bytes in fixalloc

Currently, the '_FixAllocChunk % fixalloc.size' tail bytes
will never be used when allocing from persistentalloc.

Wasted bytes on darwin/amd64:
  _FixAllocChunk % mheap_.spanalloc.size             = 64
  _FixAllocChunk % mheap_.cachealloc.size            = 784
  _FixAllocChunk % mheap_.specialfinalizeralloc.size = 16
  _FixAllocChunk % mheap_.specialprofilealloc.size   = 16
  _FixAllocChunk % mheap_.specialReachableAlloc.size = 16
  _FixAllocChunk % mheap_.arenaHintAlloc.size        = 16

After this commit, fixalloc alloc '_FixAllocChunk / fixalloc.size'
objects exactly with zero waste. Sizeof(fixalloc{}) is unchanged.

Change-Id: Ifc551f5b7aa9d842fa559abbe532ffcfb4d3540c
GitHub-Last-Rev: e08b4c66b82bc7be9d14fb7eb7580504d777481e
GitHub-Pull-Request: golang/go#47439
Reviewed-on: https://go-review.googlesource.com/c/go/+/338090
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

3 years agoruntime: constify a test variable
Carlo Alberto Ferraris [Sun, 25 Jul 2021 23:15:15 +0000 (23:15 +0000)]
runtime: constify a test variable

Simple cleanup, no functionality change.

Change-Id: I8eceda4496a396e0117a0a601186c653982fb004
GitHub-Last-Rev: 58defc575e5834a3685bbb8179fdee4afa8d8fc7
GitHub-Pull-Request: golang/go#47389
Reviewed-on: https://go-review.googlesource.com/c/go/+/337289
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

3 years agoruntime: ensure the fixalloc object size is valid
Hans [Wed, 28 Jul 2021 05:57:25 +0000 (05:57 +0000)]
runtime: ensure the fixalloc object size is valid

Usually, fixalloc is used to allocate small, persistent and reuseable
objects. The size is typically between range [sizeof(mlink), _FixAllocChunk].

It's rare for being out of the range. But if it did happen, we got a
hard-to-discover memory corruption. This commit prevents that situation by limiting object's size.

Change-Id: If6ef8b0831596464e0f55d09f79094b79ae08c66
GitHub-Last-Rev: cb8b1b01bbf452195f4f098d53cca74affc496ff
GitHub-Pull-Request: golang/go#47395
Reviewed-on: https://go-review.googlesource.com/c/go/+/337429
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

3 years agoruntime: change 0 to pollNoError in netpollblock
Xargin [Wed, 28 Jul 2021 20:40:07 +0000 (20:40 +0000)]
runtime: change 0 to pollNoError in netpollblock

Change-Id: I95e91ff21420e396aef876e77bc4ccdc45ab40ca
GitHub-Last-Rev: 8e6bd3f002b1c29fed8ce1bd344f7727e8580555
GitHub-Pull-Request: golang/go#47372
Reviewed-on: https://go-review.googlesource.com/c/go/+/337249
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Cherry Mui <cherryyz@google.com>

3 years agocmd/compile: workaround inlining of closures with range statements
Leonard Wang [Sat, 28 Aug 2021 16:53:00 +0000 (00:53 +0800)]
cmd/compile: workaround inlining of closures with range statements

ORANGE is still not inlineable now. This CL is correct only when the range statement is statically dead, and thus not counted during the inline budget check.
If we support range statements in inlining closures in the future, may require additional processing.

Fixes #48033.

Change-Id: I28f5755c28cfa27e41daef9eff2ae332059909bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/345436
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
3 years agosyscall: drop fallback to accept in Accept on Linux
Tobias Klauser [Wed, 1 Sep 2021 13:50:27 +0000 (15:50 +0200)]
syscall: drop fallback to accept in Accept on Linux

The minimum required Linux kernel version for Go 1.18 will be changed to
2.6.32, see #45964. The current minimum required version is 2.6.23 and
accept4 was added in 2.6.28, so the fallback to accept in Accept on
Linux can be removed.

For #45964

Change-Id: I78fc4e5b58417bbc540912c9dbf1b1b3db888fea
Reviewed-on: https://go-review.googlesource.com/c/go/+/346849
Trust: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>