1
0
mirror of https://github.com/golang/go synced 2024-11-23 09:00:04 -07:00
Commit Graph

49332 Commits

Author SHA1 Message Date
Robert Findley
08588e6036 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>
2021-09-02 16:26:26 +00:00
Dmitri Shuralyov
d01388b04f 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>
2021-09-02 16:15:00 +00:00
Keith Randall
782aa42255 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>
2021-09-02 15:14:50 +00:00
Dmitri Shuralyov
d8b156773c 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>
2021-09-02 15:05:39 +00:00
Than McIntosh
014a9720f9 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>
2021-09-02 14:44:50 +00:00
Ben Shi
37d4532867 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: a2f56a0763
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>
2021-09-02 14:35:10 +00:00
Robert Findley
4fb79569d2 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>
2021-09-02 14:05:36 +00:00
Robert Findley
b8420baf46 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>
2021-09-02 14:02:42 +00:00
Hans
4591f49938 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: e08b4c66b8
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>
2021-09-02 13:53:25 +00:00
Carlo Alberto Ferraris
a35c5c98c0 runtime: constify a test variable
Simple cleanup, no functionality change.

Change-Id: I8eceda4496a396e0117a0a601186c653982fb004
GitHub-Last-Rev: 58defc575e
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>
2021-09-02 13:52:06 +00:00
Hans
90ed541149 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: cb8b1b01bb
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>
2021-09-02 13:45:48 +00:00
Xargin
69107e73ce runtime: change 0 to pollNoError in netpollblock
Change-Id: I95e91ff21420e396aef876e77bc4ccdc45ab40ca
GitHub-Last-Rev: 8e6bd3f002
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>
2021-09-02 13:44:36 +00:00
Leonard Wang
08e2519ded 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>
2021-09-02 12:49:05 +00:00
Tobias Klauser
6705191e02 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>
2021-09-02 09:25:10 +00:00
Tobias Klauser
17e9d148d3 syscall: drop fallback to utimes in UtimesNano 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
utimensat was added in 2.6.22, so the fallback isn't even necessary for
the current minimum supported version. Remove the fallback to utimes.

For #45964

Change-Id: I5536f6ea7a34944dd9165f1533c10692171fb0c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/346790
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>
2021-09-02 09:24:59 +00:00
Tobias Klauser
d13d62c49a os, syscall: remove fallback to pipe syscall on Linux
The minimum required Linux kernel version for Go 1.18 will be changed to
2.6.32, see #45964. The pipe2 syscall was added in 2.6.27, so the
fallback to use the pipe syscall in os.Pipe and syscall.forkExecPipe on
Linux can be removed.

For #45964

Change-Id: I033a534f2b39e9bafc9980c9ce980e92f1e3a136
Reviewed-on: https://go-review.googlesource.com/c/go/+/346789
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>
2021-09-02 09:24:44 +00:00
Cuong Manh Le
840b4292c9 src: emit warning when make.bash run with invalid GOROOT_BOOTSTRAP
When setting an invalid GOROOT_BOOTSTRAP, make.bash try looking at env to
find a valid go command and use that GOROOT instead. It's better if the
script emit a warning, instead of silently change the GOROOT_BOOTSTRAP.

Change-Id: I6038093d5e8c072da27bcae44b125f6774f809a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/326030
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>
2021-09-02 07:31:53 +00:00
Cuong Manh Le
1ae7ddc235 test: always run test in unified IR mode regardless of explicit -G flag
Currently, if a test explicitly specify -G flag, if that flag conflict
with compiler default -G flag, the test will be skipped. That's the
reason CL 346469 haven't fixed the unified IR stuff, but still make the
unified builder passed.

This CL makes run.go always run the test in unified IR mode, regardless
of the explicit -G flag specified.

Updates #48094

Change-Id: I959ecaff6aca07844f0ffcf36caa60cf0747e8ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/347271
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-09-02 06:44:04 +00:00
Cuong Manh Le
3db4888a05 cmd/compile: use types2.Unsafe to represent package unsafe in gcimports
Followup todo in CL 346769.

Change-Id: I6c870014523426d65d135da999f97a818a997237
Reviewed-on: https://go-review.googlesource.com/c/go/+/347270
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>
2021-09-02 06:43:58 +00:00
Cuong Manh Le
9afbf82667 cmd/compile: allow objStub from unsafe package
CL 346469 added support for unsafe.Sizeof and friends to operate on
generic parameters for compiler importer/exporter. This CL adds support
for unified IR.

Updates #48094

Change-Id: I63af1a7c3478f59b03ecc23229ac2254d3457868
Reviewed-on: https://go-review.googlesource.com/c/go/+/346769
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: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-09-02 06:43:50 +00:00
Meng Zhuo
1bd35fab05 runtime: use vDSO clock_gettime on linux/riscv64
Speed up nanotime1 and walltime on riscv64 with vDSO, just like the
other vDSO-enabled targets.

name          old time/op  new time/op  delta
Now           1.53µs ± 1%  1.05µs ± 3%  -31.74%  (p=0.000 n=10+10)
NowUnixNano   1.54µs ± 0%  1.05µs ± 2%  -31.91%  (p=0.000 n=9+10)
NowUnixMilli  1.56µs ± 1%  1.06µs ± 1%  -31.73%  (p=0.000 n=10+10)
NowUnixMicro  1.56µs ± 1%  1.05µs ± 1%  -32.80%  (p=0.000 n=9+10)

Change-Id: I69b3fe3cc57685a826c53b366c0992e8048399bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/328509
Trust: Meng Zhuo <mzh@golangcn.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-02 01:23:38 +00:00
Robert Griesemer
df4c625d88 cmd/compile: disable type list syntax for the compiler
Add (temporary) syntax.AllowTypeLists mode to control the
acceptance of type lists; the compiler doesn't set it,
but existing syntax and types2 tests do so that the code
remains exercised while it exists.

Adjust various tests to use the type set notation.

Change-Id: I798e607912552db6bfe38a7cd4324b74c6bf4d95
Reviewed-on: https://go-review.googlesource.com/c/go/+/347249
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-02 01:06:17 +00:00
Robert Griesemer
2872496ba5 cmd/compile/internal/types2: systematic detection of missing instantiation
When type-checking expressions, detection of uninstantiated generic
functions and types was somewhat ad-hoc.

Add an extra parameter "allowGenerics" to rawExpr. If not set, the
result operand cannot be generic.

The only place where rawExpr is called with allowGenerics != false
is from exprOrType, which passes an allowGenerics parameter through.

The only place where exprOrType is called with allowGenerics == true
is when handling index expressions and calls. Make sure that we only
accept generic operands where expected, and check the other branches.

As a result, a recently added varType call (CL 345970) can be removed
again.

This also fixes a bug where an error for a conversion to generic
type was reported after the conversion (i.e., with the converted
value, rather than the generic type). Added a test case for that.

For #48048.

Change-Id: I8576326f5fcfb58d78b3ce8572068aa32e66c568
Reviewed-on: https://go-review.googlesource.com/c/go/+/346471
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-09-01 23:41:53 +00:00
Damien Neil
0bfd6fcea6 all: update golang.org/x/net to pull in CL 346890
For #42777.

Change-Id: I963db8c666e8bcf0fc4f390b359db6408a0f792b
Reviewed-on: https://go-review.googlesource.com/c/go/+/347010
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-01 22:28:21 +00:00
Matthew Dempsky
88859f3cd8 cmd/compile: optimize unified IR handling of imported functions
This CL skips reading of imported function bodies except from the
local package or for inlining. Previously, we wasted a bunch of CPU
and memory by reading in normal function bodies for all imported
functions and methods.

Change-Id: I0b3df3f4a3e2819117dac11a1f9e4526288c14d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/347030
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>
2021-09-01 21:38:48 +00:00
Matthew Dempsky
50f38d0405 cmd/compile: emit unified IR wrappers after inlining
This CL delays unified IR's wrapper generation to after inlining.

Change-Id: Idfe496663489d6b797a647eb17200c6322d0334a
Reviewed-on: https://go-review.googlesource.com/c/go/+/347029
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>
2021-09-01 21:38:43 +00:00
Leonard Wang
5e0f8edbdc cmd/compile: remove useless fcount
Change-Id: Ibc23b43dc9a7fabb27d7991977b283459f3deae3
Reviewed-on: https://go-review.googlesource.com/c/go/+/333009
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>
2021-09-01 21:26:54 +00:00
Michael Munday
ea51e223c2 cmd/{asm,compile}: add fused multiply-add support on riscv64
Add support to the assembler for F[N]M{ADD,SUB}[SD] instructions.
Argument order is:

  OP RS1, RS2, RS3, RD

Also, add support for the FMA intrinsic to the compiler. Automatic
FMA matching is left to a future CL.

Change-Id: I47166c7393b2ab6bfc2e42aa8c1a8997c3a071b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/293030
Trust: Michael Munday <mike.munday@lowrisc.org>
Run-TryBot: Michael Munday <mike.munday@lowrisc.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
2021-09-01 21:17:04 +00:00
Cuong Manh Le
711e1c8224 cmd/compile: fix irgen mis-handling invalid function declaration
In -G=3 mode, irgen use its own generated IR, which is mis-handling of
bodyless function and declared function with //go:noescape pragma.

Fix this by adopting the same logic in noder.funcDecl, which minor
change in linkname detection.

Fixes #48097

Change-Id: Ibef921c1f75e071ca61685e0cb4543f2ee5efc7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/346470
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-09-01 19:51:25 +00:00
seifchen
592ee433f5 spec: adjust example for consistency
Change-Id: I5ff9078907b78f31aec42abf749a193b15bc5109
GitHub-Last-Rev: 1f96d84f20
GitHub-Pull-Request: golang/go#47732
Reviewed-on: https://go-review.googlesource.com/c/go/+/342789
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Cherry Mui <cherryyz@google.com>
2021-09-01 19:23:15 +00:00
Matthew Dempsky
6c5f028242 cmd/compile/internal/pkginit: separate "init" and "inittask" logic
This CL splits the creation of the "init" function responsible for
executing package-scope variable initialization statemens from the
creation of the "inittask" record that tells the runtime how to
sequence all program-wide package initialization.

Longer term, this is desirable because sorting variable initialization
is already handled by types2 (with Info.InitOrder), so we might as
well reuse that.

As a more immediate impetus, for unified IR, I want to defer method
wrapper generation until after inlining (to know which wrappers are
needed). But the staticinit optimization used to decide whether to
emit the inittask calls into reflectdata, which in turn tries to
generate its own method wrappers. So separating the work allows to
create the "init" function early and then emit "inittask" after
inlining is done.

Change-Id: Ice1d421f92feecaaeafdf7da6b9647c0f27e3571
Reviewed-on: https://go-review.googlesource.com/c/go/+/346629
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>
2021-09-01 18:16:17 +00:00
Paul E. Murphy
8f397bc118 cmd/internal/obj/ppc64: improve long conditional branch fixup
Improve the code which fixes up conditional branches which exceed the
range of a single instruction by inserting one extra jump when
possible instead of two.

Change-Id: Ib0eb5b0f47f7d0e0ccd55471307a5f73fbda88a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/342930
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-09-01 17:25:30 +00:00
korzhao
5670ff4ae5 cmd/compile: fix conversions from TypeParam to interface
If the TypeParam has all the methods of an interface, allow conversions from TypeParam to interface

Fixes #47708

Change-Id: I40a82a31f6ea9354130dbe3bcfc83537094bf12c
Reviewed-on: https://go-review.googlesource.com/c/go/+/342509
Reviewed-by: Dan Scales <danscales@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
Trust: Keith Randall <khr@golang.org>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-09-01 16:45:26 +00:00
Joel Sing
717f337d1d cmd/asm: adjust riscv64 test data to avoid churn
Rather than jumping and branching to a label (the offset for which changes
when instructions are added or removed), use PC-relative offsets. This
reduces unnecessary churn in the instruction encodings.

Change-Id: I6816ce939eeabdf828039f59f4f29260eb1ac8da
Reviewed-on: https://go-review.googlesource.com/c/go/+/344449
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Munday <mike.munday@lowrisc.org>
2021-09-01 07:10:24 +00:00
Joel Sing
5a687eeaf1 cmd/asm,cmd/internal/obj/riscv: add more error tests for riscv64 assembly
Add more error tests for riscv64 assembly. Also avoid a panic when one of
these error conditions is hit.

Change-Id: If5d913894facbd67f7d014eab745da77c8c66ab0
Reviewed-on: https://go-review.googlesource.com/c/go/+/344228
Trust: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
2021-09-01 06:18:05 +00:00
Keith Randall
faf9c7d8fe cmd/compile: assign results of transformAssign back to source location
Otherwise the modifications of transformAssign are dropped on the floor.

Change-Id: Id40782564952ed53f9ade1dba4e85290c8522abc
Reviewed-on: https://go-review.googlesource.com/c/go/+/346590
Trust: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-09-01 03:50:19 +00:00
Dan Scales
2dd7b770de cmd/compile: fix missing case for shape double-check function
Missing case types.TUNSAFEPTR in parameterizedBy().

Also realized there was the same missing case in the type substituter
(*Tsubster).Typ().

Fixes #48103

Change-Id: If71f1a6ef80932f0e2120d4c18b39a30189fd8fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/346669
Reviewed-by: Keith Randall <khr@golang.org>
Trust: Dan Scales <danscales@google.com>
2021-09-01 02:51:18 +00:00
Cuong Manh Le
62ba72b353 cmd/compile: fix method expression lookup during import
CL 309831 fixed importing of method expressions, by re-using the same
code already have for ODOTMETH. But that code does not work with
embedded field.

To fix this, we need to calculate all methods of the receiver base type
of method expression, before looking up the selection.

Fixes #48088

Change-Id: Ia244d36a3ed0f989735eb57becdfa70a81912f57
Reviewed-on: https://go-review.googlesource.com/c/go/+/346489
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>
2021-09-01 02:16:30 +00:00
Robert Findley
f4e24599dd go/types: disallow aliases for generic types
This is a port of CL 346294 to go/types.

Change-Id: Ib70541a92e352c8df8123c8b82bb4eeedce3b89f
Reviewed-on: https://go-review.googlesource.com/c/go/+/346560
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>
2021-09-01 00:37:28 +00:00
Robert Findley
36ac2214fa go/types: remove superfluous ordinaryType calls
This is a port of CL 346291 to go/types.

Change-Id: I8f864aca5cdb4037bc27a81cde1597430b9a48db
Reviewed-on: https://go-review.googlesource.com/c/go/+/346559
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>
2021-09-01 00:37:23 +00:00
Robert Findley
1a9807906d go/types: more systematic error handling in typeWriter
This is a port of CL 346009 to go/types. An unnecessary break statement
was removed from both the port and types2.

Change-Id: I2cc1328a61100d4b01a2d26ac7bac9044440d579
Reviewed-on: https://go-review.googlesource.com/c/go/+/346558
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>
2021-09-01 00:37:16 +00:00
Robert Findley
5cd1b847dc go/types: eliminate typeHashing global variable
This is a port of CL 345929 to go/types. It is also a step toward making
instantiation concurrency-safe.

Also fix some whitespace in instantiate.go.

Updates #47910

Change-Id: Icdeb227cb83eee15da6db90daab294c8c55db601
Reviewed-on: https://go-review.googlesource.com/c/go/+/346557
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>
2021-09-01 00:36:05 +00:00
Robert Findley
0df6df17e1 go/types: generalize instanceHash to accept any type, rename to typeHash
This is a port of CL 345791 to go/types.

Change-Id: I673c22ad8b668f07aae4117555b1c0efb273fb78
Reviewed-on: https://go-review.googlesource.com/c/go/+/346556
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>
2021-09-01 00:35:54 +00:00
Robert Findley
3c8c9e1e44 go/types: don't print instance markers for type hashes
This is a port of CL 345891 to go/types.

Change-Id: I5abcb9c9c5110923a743f0c47d9b34b2baabab68
Reviewed-on: https://go-review.googlesource.com/c/go/+/346555
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>
2021-08-31 23:46:12 +00:00
Robert Findley
2d98a4b4bc go/types: use a typeWriter to write types (cleanup)
This is a port of CL 345890 to go/types.

Change-Id: I98162deaf044b2194b05dc51e6948e227216fc4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/346554
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>
2021-08-31 23:45:48 +00:00
Robert Findley
b2f09cd717 go/types: do not declare new methods on instantiated types
This is a port of CL 345472 to go/types.

Change-Id: I0e2a88909ecebe9dea3325244153f5c74e4c3ce7
Reviewed-on: https://go-review.googlesource.com/c/go/+/346553
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>
2021-08-31 22:47:49 +00:00
Robert Findley
5e9ba0b1bd go/types: implement TypeList.String (debugging support)
This is a port of CL 345471 to go/types.

Change-Id: Icad5fb8b3b4375182f420a51c80607b88696561e
Reviewed-on: https://go-review.googlesource.com/c/go/+/346552
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>
2021-08-31 22:45:42 +00:00
Robert Findley
580987cd58 go/types: remove need for the instance struct
This is a port of CL 345177 to go/types.

Change-Id: I79fcfbf5b28e9a7a2e66c81bc831e164a8da8bbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/346551
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>
2021-08-31 22:45:26 +00:00
Robert Findley
d15a75e070 go/types: address some TODOs (cleanup)
This is a port of CL 345176 to go/types, though not all TODOs were
present in go/types.

A TODO that still needs to be resolved was added back to types2.

Change-Id: Icf79483c92d0bc1248de772c7044620f0f0a5c58
Reviewed-on: https://go-review.googlesource.com/c/go/+/346550
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>
2021-08-31 22:39:00 +00:00
Keith Randall
1f83a8c16c cmd/compile: use the zero value for results of impossible indexing
type A [0]int
var a A
x := a[i]

Use the zero value for x instead of the "impossible" value. That lets
us at least compile code like this with -B, even though it can't
possibly run correctly.

Fixes #48092

Change-Id: Idad5cfab49e05f375c069b05addceed68a15299f
Reviewed-on: https://go-review.googlesource.com/c/go/+/346589
Trust: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-08-31 21:49:48 +00:00