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

48521 Commits

Author SHA1 Message Date
Cuong Manh Le
3f7f72a258 [dev.typeparams] cmd/compile: fold reader checking type params logic to separate method
So making it less verbose and clearer to the reader what that check means.

Change-Id: I41587aab399e63600356c5cecec64978048bed36
Reviewed-on: https://go-review.googlesource.com/c/go/+/329571
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-06-21 04:53:09 +00:00
Cuong Manh Le
d24c90a153 [dev.typeparams] cmd/compile: explain how pkgReader.typIdx handles alias cyclic
Change-Id: Ib9357c21bb010abf0d5fd17c3bee3197854c3a8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/329570
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-06-20 06:27:46 +00:00
Matthew Dempsky
3f7a3133da [dev.typeparams] cmd/compile: add "toolstash -cmp"-like test of -d=unified
This CL adds a longtest test to make sure -d=unified=1 produces output
identical to -d=unified=0.

Change-Id: I2c5d38f67dbc8fecd8332a91ba7cae22225b090c
Reviewed-on: https://go-review.googlesource.com/c/go/+/329429
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-06-18 23:20:30 +00:00
Dan Scales
e9c01f9804 [dev.typeparams] cmd/compile: add missing copy of Field.Embedded in type substituter.
Change-Id: I876933370a6bcb6586eda9d8fc28a081bf31b1cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/328511
Run-TryBot: Dan Scales <danscales@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Trust: Dan Scales <danscales@google.com>
2021-06-18 16:33:06 +00:00
Cuong Manh Le
6fa0437958 [dev.typeparams] cmd/compile: add documentation for unified IR pipeline
While at it, also rename "useUnifiedIR" to "unified", to be consistent
with "-d=unified" and "GOEXPERIMENT=unified".

Change-Id: I48ffdb4b36368343893b74f174608f5f59278249
Reviewed-on: https://go-review.googlesource.com/c/go/+/328989
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-06-18 09:24:03 +00:00
Matthew Dempsky
54fe57bc22 [dev.typeparams] cmd/compile: record writer's stack at export data sync points
This CL extends the unified export data format's existing sync
mechanism to save writer stacks, controlled by the -d=syncframes debug
flag. This allows readers to provide more details when reporting
desync errors, which should simplify development of the data format
and the various reader/writer implementations.

For example, CL 328051 updated reader and writer, but missed making a
similar change to the linker (fix in CL 328054). Re-reviewing the CL
in isolation after the failure, it was not immediately obvious what
was going wrong. But the pair of stack traces below identifies exactly
what happened: it should have updated linker.relocFuncExt to write out
the new sync marker too.

```
data sync error: package "internal/abi", section 6, index 4, offset 536

found UseReloc, written at:
	/home/mdempsky/wd/go/src/cmd/compile/internal/noder/encoder.go:221: (*encoder).reloc +0x44
	/home/mdempsky/wd/go/src/cmd/compile/internal/noder/linker.go:214: (*linker).relocFuncExt +0x580
	/home/mdempsky/wd/go/src/cmd/compile/internal/noder/linker.go:233: (*linker).relocTypeExt +0x234
	/home/mdempsky/wd/go/src/cmd/compile/internal/noder/linker.go:161: (*linker).relocObj +0x2198
	/home/mdempsky/wd/go/src/cmd/compile/internal/noder/linker.go:64: (*linker).relocIdx +0x196

expected ImplicitTypes, reading at:
	/home/mdempsky/wd/go/src/cmd/compile/internal/noder/reader.go:796: (*reader).implicitTypes +0x36
	/home/mdempsky/wd/go/src/cmd/compile/internal/noder/reader.go:810: (*reader).addBody +0x81
	/home/mdempsky/wd/go/src/cmd/compile/internal/noder/reader.go:727: (*reader).funcExt +0x542
	/home/mdempsky/wd/go/src/cmd/compile/internal/noder/reader.go:651: (*reader).method +0x324
	/home/mdempsky/wd/go/src/cmd/compile/internal/noder/reader.go:557: (*pkgReader).objIdx +0x2704
```

Change-Id: I911193edd2a965f81b7459f15fb613a773584685
Reviewed-on: https://go-review.googlesource.com/c/go/+/328909
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-18 06:33:12 +00:00
Michael Anthony Knyszek
78aa251ace [dev.typeparams] cmd/go: include new internal packages in TestNewReleaseRebuildsStalePackagesInGOPATH
CL 328336 introduced two new packages that the runtime and other
low-level packages depend on. Include them as targets to copy in this
test with other such packages.

Fixes the dev.typeparams longtest builders.

Change-Id: Ia886f0264962a68acd06ebca002eef8515f06487
Reviewed-on: https://go-review.googlesource.com/c/go/+/329251
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-18 04:55:13 +00:00
Cuong Manh Le
2a7900762c [dev.typeparams] go/types: report better error for invalid untyped operation
This is port of CL 328053 for types2 to go/type.

The change is identical, but for some tweaks to the error positions in
tests.

Updates #46749

Change-Id: I8d34c5b1669e59e4ec7d91f81dcf655b2bfd89a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/328869
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>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-18 02:07:04 +00:00
Robert Griesemer
90096f445e [dev.typeparams] cmd/compile/internal/syntax: convert (most) parser tests to new type set syntax
Left a couple of tests with old notation so that we keep testing it
while the notation is still supported.

Change-Id: Ia6a3e7911af87eaccc7b06189c10f79789575a98
Reviewed-on: https://go-review.googlesource.com/c/go/+/328256
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-18 01:06:13 +00:00
Matthew Dempsky
feec53c4e5 [dev.typeparams] cmd/compile: skip types2 GC test during bootstrapping
Unified includes a check to make sure that types2 memory has been
garbage collected, but it relies on precise finalization, which we
provide (for dynamically allocated objects, at least) but isn't
guaranteed by the Go spec. In particular, Go 1.4 doesn't provide this.

The check is strictly unnecessary and only exists to make sure we
don't regress and start holding onto types2 memory accidentally. So
just disable the check during bootstrap builds.

Change-Id: Ie54fe53b2edba02c0b0b1e5ae39d81be8a0ace8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/329269
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-17 23:14:04 +00:00
Michael Anthony Knyszek
fb84d213a8 [dev.typeparams] reflect: support big endian architectures in callMethod
Currently, callMethod has some ABI translation code that is not agnostic
of endianness. This change rectifies that by adding a method to
internal/abi.RegArgs for safely returning an offset into a register slot
that's endianness-dependent.

No tests for this because it's just best-effort. There's no actual way
to test this because we don't support a register ABI on any big endian
architectures yet.

Change-Id: Ic68d9ee1bfdea0fc2992d467d749e2b083e92de3
Reviewed-on: https://go-review.googlesource.com/c/go/+/328348
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-06-17 21:30:24 +00:00
Michael Anthony Knyszek
9f50d9a0b4 [dev.typeparams] internal/reflectlite: remove unused ptrSize
Change-Id: Ia0da5e5d1e8d20327690cb53c9df067401f3428c
Reviewed-on: https://go-review.googlesource.com/c/go/+/328812
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-17 21:29:40 +00:00
Michael Anthony Knyszek
890a8407a9 [dev.typeparams] internal/reflectlite: use goarch.PtrSize instead of the duplicated ptrSize [generated]
[git-generate]
cd src/internal/reflectlite
gofmt -w -r "ptrSize -> goarch.PtrSize" .
goimports -w *.go

Change-Id: I6a55f2aa035ed863785856ddd4fcc519dec15ac9
Reviewed-on: https://go-review.googlesource.com/c/go/+/328347
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-17 21:29:35 +00:00
Michael Anthony Knyszek
bfd9b63f12 [dev.typeparams] reflect: delete unused ptrSize and PtrSize
Change-Id: I522263eb5112b78639340b83d92e80a13f738bd4
Reviewed-on: https://go-review.googlesource.com/c/go/+/328811
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-17 21:29:28 +00:00
Michael Anthony Knyszek
95c104ee61 [dev.typeparams] reflect: use goarch.PtrSize instead of the duplicated ptrSize [generated]
[git-generate]
cd src/reflect
gofmt -w -r "PtrSize -> goarch.PtrSize" .
gofmt -w -r "ptrSize -> goarch.PtrSize" .
goimports -w *.go

Change-Id: Ib534bb0ecde10d93f45365ab4f8efd620d6d2ef3
Reviewed-on: https://go-review.googlesource.com/c/go/+/328346
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-17 21:29:22 +00:00
Michael Anthony Knyszek
2e600fb8b3 [dev.typeparams] runtime/internal/sys: remove unused Goarch* and Goos* constants
Change-Id: Ibc8381662242c6754f34edce9c0ad81681f55940
Reviewed-on: https://go-review.googlesource.com/c/go/+/329192
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-17 21:29:15 +00:00
Michael Anthony Knyszek
46e1e74a86 [dev.typeparams] runtime: replace Goarch* constants with internal/goarch versions [generated]
[git-generate]
cd src/runtime
gofmt -w -r "sys.Goarch386         -> goarch.Is386" .
gofmt -w -r "sys.GoarchAmd64       -> goarch.IsAmd64" .
gofmt -w -r "sys.GoarchAmd64p32    -> goarch.IsAmd64p32" .
gofmt -w -r "sys.GoarchArm         -> goarch.IsArm" .
gofmt -w -r "sys.GoarchArmbe       -> goarch.IsArmbe" .
gofmt -w -r "sys.GoarchArm64       -> goarch.IsArm64" .
gofmt -w -r "sys.GoarchArm64be     -> goarch.IsArm64be" .
gofmt -w -r "sys.GoarchPpc64       -> goarch.IsPpc64" .
gofmt -w -r "sys.GoarchPpc64le     -> goarch.IsPpc64le" .
gofmt -w -r "sys.GoarchMips        -> goarch.IsMips" .
gofmt -w -r "sys.GoarchMipsle      -> goarch.IsMipsle" .
gofmt -w -r "sys.GoarchMips64      -> goarch.IsMips64" .
gofmt -w -r "sys.GoarchMips64le    -> goarch.IsMips64le" .
gofmt -w -r "sys.GoarchMips64p32   -> goarch.IsMips64p32" .
gofmt -w -r "sys.GoarchMips64p32le -> goarch.IsMips64p32le" .
gofmt -w -r "sys.GoarchPpc         -> goarch.IsPpc" .
gofmt -w -r "sys.GoarchRiscv       -> goarch.IsRiscv" .
gofmt -w -r "sys.GoarchRiscv64     -> goarch.IsRiscv64" .
gofmt -w -r "sys.GoarchS390        -> goarch.IsS390" .
gofmt -w -r "sys.GoarchS390x       -> goarch.IsS390x" .
gofmt -w -r "sys.GoarchSparc       -> goarch.IsSparc" .
gofmt -w -r "sys.GoarchSparc64     -> goarch.IsSparc64" .
gofmt -w -r "sys.GoarchWasm        -> goarch.IsWasm" .
goimports -w *.go

Change-Id: I9d88e1284efabaeb0ee3733cba6286247d078c85
Reviewed-on: https://go-review.googlesource.com/c/go/+/328345
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-17 21:29:09 +00:00
Michael Anthony Knyszek
7b0e9cae66 [dev.typeparams] runtime: replace Goos* constants with internal/goos versions [generated]
[git-generate]
cd src/runtime
gofmt -w -r "sys.GoosAix       -> goos.IsAix" .
gofmt -w -r "sys.GoosAndroid   -> goos.IsAndroid" .
gofmt -w -r "sys.GoosDarwin    -> goos.IsDarwin" .
gofmt -w -r "sys.GoosDragonfly -> goos.IsDragonfly" .
gofmt -w -r "sys.GoosFreebsd   -> goos.IsFreebsd" .
gofmt -w -r "sys.GoosHurd      -> goos.IsHurd" .
gofmt -w -r "sys.GoosIllumos   -> goos.IsIllumos" .
gofmt -w -r "sys.GoosIos       -> goos.IsIos" .
gofmt -w -r "sys.GoosJs        -> goos.IsJs" .
gofmt -w -r "sys.GoosLinux     -> goos.IsLinux" .
gofmt -w -r "sys.GoosNacl      -> goos.IsNacl" .
gofmt -w -r "sys.GoosNetbsd    -> goos.IsNetbsd" .
gofmt -w -r "sys.GoosOpenbsd   -> goos.IsOpenbsd" .
gofmt -w -r "sys.GoosPlan9     -> goos.IsPlan9" .
gofmt -w -r "sys.GoosSolaris   -> goos.IsSolaris" .
gofmt -w -r "sys.GoosWindows   -> goos.IsWindows" .
gofmt -w -r "sys.GoosZos       -> goos.IsZos" .
goimports -w *.go

Change-Id: I42bed2907317ed409812e5a3e2897c88a5d36f24
Reviewed-on: https://go-review.googlesource.com/c/go/+/328344
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-17 21:29:02 +00:00
Michael Anthony Knyszek
81a6a4354b [dev.typeparams] internal/goarch,internal/goos: rename Goos and Goarch constants
Lots of constants in these packages start with Goarch and Goos, which is
redundant. Instead, add the "Is" prefix to make the constant clearer,
and to differentiate from the arch family constants.

Change-Id: Id92c1d3e911296a72949f8c9d649f142e7dc9d17
Reviewed-on: https://go-review.googlesource.com/c/go/+/328343
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-17 21:28:55 +00:00
Michael Anthony Knyszek
33d1b82d16 [dev.typeparams] runtime/internal/sys: replace ArchFamily and constants with goarch
Refactoring with rf

    rf 'ex . {
      import "internal/goarch"
      import "runtime/internal/sys"
      sys.ArchFamily -> goarch.ArchFamily
      sys.AMD64 -> goarch.AMD64
      sys.ARM -> goarch.ARM
      sys.ARM64 -> goarch.ARM64
      sys.I386 -> goarch.I386
      sys.MIPS -> goarch.MIPS
      sys.MIPS64 -> goarch.MIPS64
      sys.PPC64 -> goarch.PPC64
      sys.RISCV64 -> goarch.RISCV64
      sys.S390X -> goarch.S390X
      sys.WASM -> goarch.WASM
    }'

Change-Id: I0cc29ed3fdcf9ff39aa901d8bc92270996f0821c
Reviewed-on: https://go-review.googlesource.com/c/go/+/328341
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-17 20:56:29 +00:00
Michael Anthony Knyszek
85b12a8563 [dev.typeparams] runtime,runtime/internal/sys: remove unused BigEndian
Change-Id: I1209904326b1563e12d9c7d19a12a10c72d1dbcb
Reviewed-on: https://go-review.googlesource.com/c/go/+/329191
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-17 20:42:41 +00:00
Michael Anthony Knyszek
9a93072a07 [dev.typeparams] runtime/internal/sys: replace BigEndian with goarch.BigEndian [generated]
[git-generate]
cd src/runtime/internal/atomic
gofmt -w -r "sys.BigEndian -> goarch.BigEndian" .
goimports -w *.go
cd ../..
gofmt -w -r "sys.BigEndian -> goarch.BigEndian" .
goimports -w *.go

Change-Id: Iad35d2b367d8defb081a77ca837e7a7c805c2b7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/329190
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-17 20:42:35 +00:00
Michael Anthony Knyszek
9c58e399a4 [dev.typeparams] runtime: fix import sort order [generated]
[git-generate]
cd src/runtime
goimports -w *.go

Change-Id: I1387af0f2fd1a213dc2f4c122e83a8db0fcb15f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/329189
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-17 20:42:23 +00:00
Michael Anthony Knyszek
671954e72e [dev.typeparams] runtime/internal/sys: replace GOOS with goos.GOOS
Refactoring done by rf tool:

    rf 'ex . {
	import "internal/goos"
	import "runtime/internal/sys"
	sys.GOOS -> goos.GOOS
    }'

Change-Id: I4b4aadff8640731ce4cb9bdad9954c267eb484c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/328339
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-17 20:42:08 +00:00
Michael Anthony Knyszek
5c028751bd [dev.typeparams] runtime/internal/sys: replace uses of GOARCH with goarch.GOARCH
Refactoring performed by the rf tool:

    rf 'ex . {
	import "internal/goarch"
	import "runtime/internal/sys"
	sys.GOARCH -> goarch.GOARCH
    }'

Change-Id: I4b0246bf4e734f08313c6fff7b547db362057714
Reviewed-on: https://go-review.googlesource.com/c/go/+/328338
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-17 20:42:01 +00:00
Michael Anthony Knyszek
6d89c90fb1 [dev.typeparams] runtime/internal/sys: remove unused PtrSize
Change-Id: I01e079b95f71b01edaf049d49a0993a7ed39c7bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/328810
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-17 18:54:59 +00:00
Michael Anthony Knyszek
6d85891b29 [dev.typeparams] runtime: replace uses of runtime/internal/sys.PtrSize with internal/goarch.PtrSize [generated]
[git-generate]
cd src/runtime/internal/math
gofmt -w -r "sys.PtrSize -> goarch.PtrSize" .
goimports -w *.go
cd ../..
gofmt -w -r "sys.PtrSize -> goarch.PtrSize" .
goimports -w *.go

Change-Id: I43491cdd54d2e06d4d04152b3d213851b7d6d423
Reviewed-on: https://go-review.googlesource.com/c/go/+/328337
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-17 18:54:48 +00:00
Michael Anthony Knyszek
122f5e16d6 [dev.typeparams] internal/goarch,internal/goos: explode runtime/internal/sys into pieces
This change extracts the GOOS and GOARCH specific constants from
runtime/internal/sys into packages that are available to the entire
standard library.

This change does not yet update the runtime and associated packages to
use them, and instead adds constants to runtime/internal/sys to forward
the constants defined by these new packages.

Change-Id: I14d574b8d7bfe599ad25da29dc1b39716e35a734
Reviewed-on: https://go-review.googlesource.com/c/go/+/328336
Trust: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-17 18:54:38 +00:00
Matthew Dempsky
804ecc2581 [dev.typeparams] all: add GOEXPERIMENT=unified knob
Setting `-gcflags=all=-d=unified` works for normal builds/tests, but
seems to have trouble with the test/run.go regress tests. So add a
GOEXPERIMENT knob to allow another way to turn on unified IR
construction, which plays better with all.bash.

While here, update two existing test expectations that currently fail
during GOEXPERIMENT=unified ./all.bash:

1. misc/cgo/errors/testdata/err2.go is testing column positions, and
types2 gets one case slightly better, and another case slightly
worse. For now, the test case is updated to accept both.

2. fixedbugs/issue42284.go is added to the list of known failures,
because it fails for unified IR. (It's an escape analysis test, and
escape analysis is working as expected; but unified is formatting an
imported constant value differently than the test's regexp expects.)

Updates #46786.

Change-Id: I40a4a70fa1b85ac87fcc85a43687f5d81e011ec0
Reviewed-on: https://go-review.googlesource.com/c/go/+/328215
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-06-17 09:09:02 +00:00
Cuong Manh Le
b14fd720a8 [dev.typeparams] cmd/compile: make types2 report better error for invalid untyped operation
This ports the fix in CL 328050 for typecheck to types2.

The fix is not identical, due to code structure differences between
typecheck and types2, but the idea is the same. We only do the untyped
conversion when both operands can be mixed.

Updates #46749

Change-Id: Ib2c63ba0d5dd8bf02318b1bfdfe51dcaeeeb7f82
Reviewed-on: https://go-review.googlesource.com/c/go/+/328053
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>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-17 02:30:22 +00:00
Rob Findley
8115ae198d [dev.typeparams] go/types: disallow ~T where T is a defined type or an interface
This is a straightforward port of CL 324570 to go/types.

Change-Id: I1395775a1d21a903a57e0cefc4e240cfa2bb8e97
Reviewed-on: https://go-review.googlesource.com/c/go/+/326684
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-06-17 02:15:03 +00:00
Rob Findley
6237e441bc [dev.typeparams] go/types: disallow type list handling
This is a port of CL 324571 to go/types, though type list handling is
guarded by a const rather than a config option.

Change-Id: I91c940fead048980603e0bb56fcc896dbef4f94c
Reviewed-on: https://go-review.googlesource.com/c/go/+/326683
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-06-17 02:14:52 +00:00
Rob Findley
6e50f4f111 [dev.typeparams] go/types: convert testdata/check tests to type set syntax
This is a port of CL 324569 to go/types, with some error positions
adjusted: go/types puts errors related to terms on the '~', not type
name.

Change-Id: I92e8443ce27a5ecae0e3e0dac4811eaf3eee07ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/326682
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-17 02:14:13 +00:00
Rob Findley
b6fc4d01a8 [dev.typeparams] go/types: convert testdata/fixedbugs tests to type set sytax
This is a port of CL 324530 to go/types. One error position in
issue39634.go2 was adjusted by a character, to account for go/types'
positioning.

Change-Id: Ie06974ea9ee81d3ae66ef58dba522936ab4ce2d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/326681
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-06-17 02:10:00 +00:00
Rob Findley
795f4475e5 [dev.typeparams] go/types: convert testdata/examples tests to type set sytax
This is a straightforward port of CL 324529 to go/types.

Change-Id: I788b1ac3d4e40060038a134c525c81624add8e81
Reviewed-on: https://go-review.googlesource.com/c/go/+/326680
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-06-17 02:09:33 +00:00
Rob Findley
8e14a9cf04 [dev.typeparams] go/types: eliminate need for unpack and asUnion functions
This is a straightforward port of CL 323355 to go/types, adjusted for
the different error reporting API in go/types.

Change-Id: I0f9d7ca0e0959e1e214ecd61eb85cc311e6409a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/326679
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-06-17 02:08:57 +00:00
Rob Findley
aecfd5c29e [dev.typeparams] go/types: clean up type set/union intersection
This is a straightforward port of CL 323354 to go/types.

Change-Id: I53512540cc35df6e88b2b66e144e1be7ccc9a6f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/326678
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-06-17 02:08:29 +00:00
Rob Findley
c7a460526e [dev.typeparams] go/types: replace Sum type with Union type
This is a straightforward port of CL 323274 to go/types.

Change-Id: Ica769d90fd482703f260f105199d2f2229498e95
Reviewed-on: https://go-review.googlesource.com/c/go/+/326677
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-06-17 02:08:15 +00:00
Rob Findley
e7451f6616 [dev.typeparams] go/types: accept embedded interface elements
This is a port of CL 321689 to go/types. It differs from that CL in the
uses of the position, AST and error APIs, and in not factoring out an
unimplemented() helper (this helper didn't already exist in go/types, so
it seemed cleaner to defer adding it).

Change-Id: I577a57297caf35eb7a23f63f3f52037a7bb528ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/326069
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-17 02:08:05 +00:00
Rob Findley
54f854fb41 [dev.typeparams] go/parser: accept embedded type literals
This is an approximate port of CL 321109 to go/parser, though go/parser
does not have the same internal APIs as cmd/compile/internal/syntax, so
this CL required some refactoring.

Change-Id: I146ef530c969d61bab99f98f4de94b862e103ddc
Reviewed-on: https://go-review.googlesource.com/c/go/+/325703
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-06-17 02:06:15 +00:00
Rob Findley
ab4b3c4b15 [dev.typeparams] go/parser: accept "~" and "|" interface elements
This is a port of CL 307371 to go/parser, adding support for the new
embedded type expressions. As in that CL, type lists continue to be
accepted.

This CL also revealed a pre-existing bug related to embedded instances:
the parser was failing to parse embedded instances with multiple type
arguments, due to not consuming the initial ','. This is fixed, and
along the way TestErrors is modified to use subtests.

Several missing tests cases were added to exprstring_test.go. These must
have been missed in an earlier CL.

Change-Id: I452769536998cddb1618bebdba675fc09d48a12f
Reviewed-on: https://go-review.googlesource.com/c/go/+/325690
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-06-17 02:06:03 +00:00
Rob Findley
7c5d7a4caf [dev.typeparams] go/token, go/scanner: add the "~" operator
This is an approximate port of CL 307370 to go/token and go/scanner.

Change-Id: I5b789408f825f7e39f569322cb67802117b9d734
Reviewed-on: https://go-review.googlesource.com/c/go/+/324992
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-06-17 02:05:54 +00:00
Rob Findley
ad59efb027 [dev.typeparams] go/ast: remove the typeparams build constraint
This CL removes the typeparams build constraint guarding changes to the
go/ast and go/types APIs. Notably it does not remove all indirection
added to hide the type parameter API: the go/internal/typeparams
package is not yet deleted, nor have go/parser or go/types been updated
to access type parameter data directly. This will be done in a follow-up
CL; the intent of this CL is to make it easier to support the new type
set syntax, and to experiment with different AST APIs.

Change-Id: I13ea0285752991b87b3aead1d1371e1f3f817b1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/325689
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-06-17 02:05:42 +00:00
Matthew Dempsky
1ba2074440 [dev.typeparams] cmd/compile/internal/types2: support local defined types
This CL changes types2's instance hashing logic to include position
information for function-scope defined types as disambiguation. This
isn't ideal, but it worked for getting nested.go passing.

Updates #46592.

Change-Id: Id83ba0001f44af69b81260306cc8b05e44fc4f09
Reviewed-on: https://go-review.googlesource.com/c/go/+/327170
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2021-06-16 21:38:50 +00:00
Matthew Dempsky
dd95a4e3db [dev.typeparams] cmd/compile: simplify SSA devirtualization
This CL implements a few improvements to SSA devirtualization to make
it simpler and more general:

1. Change reflectdata.ITabAddr to now immediately generate the wrapper
functions and write out the itab symbol data. Previously, these were
each handled by separate phases later on.

2. Removes the hack in typecheck where we marked itabs that we
expected to need later. Instead, the calls to ITabAddr in walk now
handle generating the wrappers.

3. Changes the SSA interface call devirtualization algorithm to just
use the itab symbol data (namely, its relocations) to figure out what
pointer is available in memory at the given offset. This decouples it
somewhat from reflectdata.

Change-Id: I8fe06922af8f8a1e7c93f5aff2b60ff59b8e7114
Reviewed-on: https://go-review.googlesource.com/c/go/+/327871
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-06-16 20:57:38 +00:00
Matthew Dempsky
132ea56d29 [dev.typeparams] cmd/compile: fix crawling of embeddable types
In reflectdata, we have a hack to only apply inlining for (*T).M
wrappers generated around T.M. This was a hack because I didn't
understand at the time why other cases were failing.

But I understand now: during export, we generally skip exporting the
inline bodies for unexported methods (unless they're reachable through
some other exported method). But it doesn't take into account that
embedding a type requires generating wrappers for promoted methods,
including imported, unexported methods.

For example:

	package a
	type T struct{}
	func (T) m() {} // previously omitted by exported

	package b
	import "./a"
	type U struct { a.T } // needs U.m -> T.m wrapper

This CL adds extra logic to the crawler to recognize that T is an
exported type directly reachable by the user, so *all* of its methods
need to be re-exported.

This finally allows simplifying reflectdata.methodWrapper to always
call inline.InlineCalls.

Change-Id: I25031d41fd6b6cd69d31c6a864b5329cdb5780e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/327872
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-06-16 17:32:49 +00:00
Cuong Manh Le
8f95eaddd3 [dev.typeparams] cmd/compile: fix missing sync implicit types
CL 328051 introduced new syncImplicitTypes, but forgot to add a sync
after syncAddBody in linker.relocFuncExt, cause the compiler crashes
when reading in package data.

Adding missing w.sync(syncImplicitTypes) call fixes this.

While at it, also run go generate to update code generated for
syncImplicitTypes, which is also missed in CL 328051.

Change-Id: Ic65092f69f8d8e63de15989c7f15b6e5633d8f9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/328054
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-16 16:30:37 +00:00
Cherry Mui
a4121d7dd6 [dev.typeparams] Revert "[dev.typeparams] runtime: make deferproc take a func() argument"
Temprary revert CL 325918.

Delve relies on the _defer.fn.fn field to get defer frames.
CL 325918 changes the type of _defer.fn to func(), which no
longer has an fn field.

Change-Id: If6c71b15a27bac579593f5273c9a49715e6e35b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/327775
Trust: Cherry Mui <cherryyz@google.com>
Trust: Dan Scales <danscales@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Dan Scales <danscales@google.com>
2021-06-16 15:27:43 +00:00
Cuong Manh Le
4d6f9d60cf [dev.typeparams] all: merge master (785a8f6) into dev.typeparams
- test/run.go

  CL 328050 added fixedbugs/issue46749.go to -G=3 excluded files list

Merge List:

+ 2021-06-16 785a8f677f cmd/compile: better error message for invalid untyped operation
+ 2021-06-16 a752bc0746 syscall: fix TestGroupCleanupUserNamespace test failure on Fedora
+ 2021-06-15 d77f4c0c5c net/http: improve some server docs
+ 2021-06-15 219fe9d547 cmd/go: ignore UTF8 BOM when reading source code
+ 2021-06-15 723f199edd cmd/link: set correct flags in .dynamic for PIE buildmode
+ 2021-06-15 4d2d89ff42 cmd/go, go/build: update docs to use //go:build syntax
+ 2021-06-15 033d885315 doc/go1.17: document go run pkg@version
+ 2021-06-15 ea8612ef42 syscall: disable c-shared test when no cgo, for windows/arm
+ 2021-06-15 abc56fd1a0 internal/bytealg: remove duplicate go:build line
+ 2021-06-15 4061d3463b syscall: rewrite handle inheritance test to use C rather than Powershell
+ 2021-06-15 cf4e3e3d3b reflect: explain why convertible or comparable types may still panic
+ 2021-06-14 7841cb14d9 doc/go1.17: assorted fixes
+ 2021-06-14 8a5a6f46dc debug/elf: don't apply DWARF relocations for ET_EXEC binaries
+ 2021-06-14 9d13f8d43e runtime: update the variable name in comment
+ 2021-06-14 0fd20ed5b6 reflect: use same conversion panic in reflect and runtime
+ 2021-06-14 6bbb0a9d4a cmd/internal/sys: mark windows/arm64 as c-shared-capable
+ 2021-06-14 d4f34f8c63 doc/go1.17: reword "results" in stack trace printing

Change-Id: I60d1f67c4d48cd4093c350fc89bd60c454d23944
2021-06-16 14:59:13 +07:00
Cuong Manh Le
ee0420d3b5 [dev.typeparams] cmd/compile: factor out implicit/explicit handling
The logic for handling them must keep in sync between reader/writer, so
factoring them out from addBody make it's easier to refer later.

Change-Id: I26447065867d79f4f47cc678a398b9e7bf5d2403
Reviewed-on: https://go-review.googlesource.com/c/go/+/328051
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-06-16 06:10:32 +00:00