Commit graph

48499 commits

Author SHA1 Message Date
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
Cuong Manh Le
785a8f677f cmd/compile: better error message for invalid untyped operation
For typed vs un-typed operation, the compiler do the conversion
un-conditionally, so if the operation is invalid, the error report is
pointed to the conversion, instead of the invalid operation itself.

To fix this, only do the conversion when the operations are valid
for both types.

Fixes #46749

Change-Id: Ib71c7bcd3ed5454e6df55b6a8db4e0f189259ba7
Reviewed-on: https://go-review.googlesource.com/c/go/+/328050
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:05:23 +00:00
Rahul Bajaj
a752bc0746 syscall: fix TestGroupCleanupUserNamespace test failure on Fedora
Fixes #46752

Change-Id: I2eaa9d15fac4e859e18191fcf1372e5be94899df
GitHub-Last-Rev: 8a2672d8dc
GitHub-Pull-Request: golang/go#46753
Reviewed-on: https://go-review.googlesource.com/c/go/+/328109
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2021-06-16 04:45:46 +00:00
Matthew Dempsky
cf1ae5fc36 [dev.typeparams] cmd/compile: add -d=unified flag to enable unified IR
This CL adds a new -d=unified debug flag, which controls whether
unified IR mode is used.

Change-Id: Iaa5f3cc0a24b9881aeec5317cd6b462b4a7b6fc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/327054
Trust: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-15 22:29:54 +00:00
Filippo Valsorda
d77f4c0c5c net/http: improve some server docs
Change-Id: I04662a08e07c49f629f9067a89bf453e697d44dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/327813
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2021-06-15 20:59:42 +00:00
Matthew Dempsky
79cd1687e6 [dev.typeparams] cmd/compile: unified IR construction
This CL adds a new unified IR construction mode to the frontend.  It's
purely additive, and all files include "UNREVIEWED" at the top, like
how types2 was initially imported. The next CL adds a -d=unified flag
to actually enable unified IR mode.

See below for more details, but some highlights:

1. It adds ~6kloc (excluding enum listings and stringer output), but I
estimate it will allow removing ~14kloc (see CL 324670, including its
commit message);

2. When enabled by default, it passes more tests than -G=3 does (see
CL 325213 and CL 324673);

3. Without requiring any new code, it supports inlining of more code
than the current inliner (see CL 324574; contrast CL 283112 and CL
266203, which added support for inlining function literals and type
switches, respectively);

4. Aside from dictionaries (which I intend to add still), its support
for generics is more complete (e.g., it fully supports local types,
including local generic types within generic functions and
instantiating generic types with local types; see
test/typeparam/nested.go);

5. It supports lazy loading of types and objects for types2 type
checking;

6. It supports re-exporting of types, objects, and inline bodies
without needing to parse them into IR;

7. The new export data format has extensive support for debugging with
"sync" markers, so mistakes during development are easier to catch;

8. When compiling with -d=inlfuncswithclosures=0, it enables "quirks
mode" where it generates output that passes toolstash -cmp.

--

The new unified IR pipeline combines noding, stenciling, inlining, and
import/export into a single, shared code path. Previously, IR trees
went through multiple phases of copying during compilation:

1. "Noding": the syntax AST is copied into the initial IR form. To
support generics, there's now also "irgen", which implements the same
idea, but takes advantage of types2 type-checking results to more
directly construct IR.

2. "Stenciling": generic IR forms are copied into instantiated IR
forms, substituting type parameters as appropriate.

3. "Inlining": the inliner made backup copies of inlinable functions,
and then copied them again when inlining into a call site, with some
modifications (e.g., updating position information, rewriting variable
references, changing "return" statements into "goto").

4. "Importing/exporting": the exporter wrote out the IR as saved by
the inliner, and then the importer read it back as to be used by the
inliner again. Normal functions are imported/exported "desugared",
while generic functions are imported/exported in source form.

These passes are all conceptually the same thing: make a copy of a
function body, maybe with some minor changes/substitutions. However,
they're all completely separate implementations that frequently run
into the same issues because IR has many nuanced corner cases.

For example, inlining currently doesn't support local defined types,
"range" loops, or labeled "for"/"switch" statements, because these
require special handling around Sym references. We've recently
extended the inliner to support new features like inlining type
switches and function literals, and they've had issues. The exporter
only knows how to export from IR form, so when re-exporting inlinable
functions (e.g., methods on imported types that are exposed via
exported APIs), these functions may need to be imported as IR for the
sole purpose of being immediately exported back out again.

By unifying all of these modes of copying into a single code path that
cleanly separates concerns, we eliminate many of these possible
issues. Some recent examples:

1. Issues #45743 and #46472 were issues where type switches were
mishandled by inlining and stenciling, respectively; but neither of
these affected unified IR, because it constructs type switches using
the exact same code as for normal functions.

2. CL 325409 fixes an issue in stenciling with implicit conversion of
values of type-parameter type to variables of interface type, but this
issue did not affect unified IR.

Change-Id: I5a05991fe16d68bb0f712503e034cb9f2d19e296
Reviewed-on: https://go-review.googlesource.com/c/go/+/324573
Trust: Matthew Dempsky <mdempsky@google.com>
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@golang.org>
2021-06-15 20:35:54 +00:00
unbyte
219fe9d547 cmd/go: ignore UTF8 BOM when reading source code
Fix the problem that UTF8 BOM can cause the parsing of import path and directives to fail.

Fixes #46198
Fixes #46290
Fixes #35726

Change-Id: I2d9995ee82b094bcfa5583f0cb4e8547cb973077
GitHub-Last-Rev: 98abf91377
GitHub-Pull-Request: golang/go#46643
Reviewed-on: https://go-review.googlesource.com/c/go/+/325990
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Trust: Bryan C. Mills <bcmills@google.com>
Trust: Robert Findley <rfindley@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-15 18:42:11 +00:00
Than McIntosh
723f199edd cmd/link: set correct flags in .dynamic for PIE buildmode
For internal linking, when generating a PIE binary, set the proper
.dynamic section flags to mark the binary as position-independent.

Fixes #46747.

Change-Id: I2b899148c6d06f92c9d12257a9761278b4236dfc
Reviewed-on: https://go-review.googlesource.com/c/go/+/328089
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Trust: Than McIntosh <thanm@google.com>
2021-06-15 18:09:44 +00:00
Damien Neil
4d2d89ff42 cmd/go, go/build: update docs to use //go:build syntax
Fixes #46124.

Change-Id: I6b8179032102a14befc37719f64ddace98397c97
Reviewed-on: https://go-review.googlesource.com/c/go/+/326931
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
2021-06-15 18:05:29 +00:00
Michael Matloob
033d885315 doc/go1.17: document go run pkg@version
Fixes #46687

Change-Id: I6c311f15d3871a9824306b901fa0b81818ed2df8
Reviewed-on: https://go-review.googlesource.com/c/go/+/326870
Trust: Michael Matloob <matloob@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-06-15 17:05:31 +00:00
Jason A. Donenfeld
ea8612ef42 syscall: disable c-shared test when no cgo, for windows/arm
The windows/arm port does not yet support cgo, so disable a test that
requires it. This fixes a regression from CL 327969, which added support
for arm64, but errantly dropped the t.Skip for both arm and arm64,
rather than just for arm64. With this commit, we make the test specific
to cgo, rather than the architecture.

Change-Id: Ibe1166c1965e007c7af899b07ded65f2a2633ddd
Reviewed-on: https://go-review.googlesource.com/c/go/+/327970
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-06-15 16:53:28 +00:00
cuishuang
abc56fd1a0 internal/bytealg: remove duplicate go:build line
Change-Id: I6b71bf468b9544820829f02e320673f5edd785fa
GitHub-Last-Rev: 8082ac5fba
GitHub-Pull-Request: golang/go#46683
Reviewed-on: https://go-review.googlesource.com/c/go/+/326730
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Tobias Klauser <tobias.klauser@gmail.com>
2021-06-15 10:13:08 +00:00
Jason A. Donenfeld
4061d3463b syscall: rewrite handle inheritance test to use C rather than Powershell
In CL 327210, we disabled this test on arm platforms, because the
powershell shipped with those systems isn't native, which means it'd
refuse to load native DLLs. This commit rewrites the test to simply not
use Powershell, and instead compiles a trivial C program that tests for
the same thing. Reverting CL 316269 makes this test fail, as desired,
while applying it makes this test succeed.

Fixes #46701

Change-Id: If39612c57bf74c63adf58e2c49b5cb739b461fe5
Reviewed-on: https://go-review.googlesource.com/c/go/+/327969
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2021-06-15 10:11:46 +00:00
Joe Tsai
cf4e3e3d3b reflect: explain why convertible or comparable types may still panic
Conversions of slices to arrays may panic since the slice is too short.
Comparibility of interfaces may panic since the underlying value is incomparable.

This is a follow-up to CL 301652

Change-Id: Ia5d84a6e556a7b82c39add4be93ed7463e63cc8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/327589
Trust: Joe Tsai <joetsai@digital-static.net>
Trust: Joe Tsai <thebrokentoaster@gmail.com>
Run-TryBot: Joe Tsai <thebrokentoaster@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Katie Hockman <katie@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2021-06-15 00:14:03 +00:00
Josh Bleecher Snyder
7841cb14d9 doc/go1.17: assorted fixes
Change-Id: I64235ad920240de9e2414b9ee6f4cfc4006b2862
Reviewed-on: https://go-review.googlesource.com/c/go/+/327709
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-06-14 22:42:48 +00:00
Victor Michel
8a5a6f46dc debug/elf: don't apply DWARF relocations for ET_EXEC binaries
Some ET_EXEC binaries might have relocations for non-loadable sections
like .debug_info. These relocations must not be applied, because:
* They may be incorrect
* The correct relocations were already applied at link time

Binaries in Linux Kernel debug packages like Fedora/Centos kernel-debuginfo
are such examples. Relocations for .debug_* sections are included in the
final binaries because they are compiled with --emit-relocs, but the resulting
relocations are incorrect and shouldn't be used when reading DWARF sections.

Fixes #46673

Change-Id: I2b4214f1584bfc243446d0eaee41512657325b95
GitHub-Last-Rev: 8350fad059
GitHub-Pull-Request: golang/go#46698
Reviewed-on: https://go-review.googlesource.com/c/go/+/327009
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-06-14 22:13:47 +00:00
Eric Wang
9d13f8d43e runtime: update the variable name in comment
The comment use allg to refer to allgs in code. Update the comment to
use the same variable name.

Change-Id: Id059fce7846776737fb038b86bcf8765a4a7c9c0
GitHub-Last-Rev: 234fb0a208
GitHub-Pull-Request: golang/go#46723
Reviewed-on: https://go-review.googlesource.com/c/go/+/327629
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
2021-06-14 22:09:35 +00:00
Ian Lance Taylor
0fd20ed5b6 reflect: use same conversion panic in reflect and runtime
Consistently say "pointer to array", not "array pointer".

Fixes #46743

Change-Id: I2388ec5c16f96e82a3a383b9b462b350686ddc5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/327870
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-14 21:46:05 +00:00
Jason A. Donenfeld
6bbb0a9d4a cmd/internal/sys: mark windows/arm64 as c-shared-capable
The platform supports c-shared now, so flip this on. I've given this a
small smoke test using [1], and it was able to pass packets and
generally function well. Since [1] uses quite a bit of Go functionality
under the hood, I think it's a decent test that a lot of things that
should be working are working. So this commit enables it.

[1] https://git.zx2c4.com/wireguard-windows/about/embeddable-dll-service/README.md

Updates #46502.

Change-Id: I5c771d033bd20e5ce472c315d7c207bbc1020b4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/326310
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Trust: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-06-14 20:36:54 +00:00
Matthew Dempsky
ea438bda85 [dev.typeparams] all: merge master (fdab5be) into dev.typeparams
Two non-conflict changes included because they're needed for all.bash:

1. Bump internal/goversion.Version to 18. This will happen eventually
anyway (dev.typeparams will not be merged back to Go 1.17), and is
needed for cmd/api to allow new API additions.

2. Add fixedbugs/issue46725.go (new test added on master) to the list
of known failures for -G=3. This test exercises a bug that was fixed
in typecheck, but -G=3 mode has duplicated that code and will need to
be fixed as well. That's outside of the scope of a merge.

Conflicts:

- src/runtime/traceback.go

  Nearby lines were removed on both master and dev.typeparams.

Merge List:

+ 2021-06-14 fdab5be159 doc/go1.17: further revise OpenBSD release notes
+ 2021-06-14 326ea438bb cmd/compile: rewrite a, b = f() to use temporaries when type not identical
+ 2021-06-14 3249b645c9 cmd/compile: factor out rewrite multi-valued f()
+ 2021-06-13 14305bf0b9 misc/cgo: generate Windows import libraries for clang
+ 2021-06-13 24cff0f044 cmd/go, misc/cgo: skip test if no .edata
+ 2021-06-13 67b1b6a2e3 cmd/compile: allow ir.OSLICE2ARRPTR in mayCall
+ 2021-06-12 1ed0d129e9 runtime: testprogcgo: don't call exported Go functions directly from Go
+ 2021-06-12 9d46ee5ac4 reflect: handle stack-to-register translation in callMethod
+ 2021-06-11 e552a6d312 cmd/go: remove hint when no module is suggested
+ 2021-06-11 16b5d766d8 syscall: do not load native libraries on non-native powershell on arm
+ 2021-06-11 77aa209b38 runtime: loop on EINTR in macOS sigNoteSleep
+ 2021-06-11 e2dc6dd5c9 doc/go1.17: clean up formatting of gofmt section
+ 2021-06-11 2f1128461d cmd/go: match Windows paths in TestScript/mod_invalid_version
+ 2021-06-11 2721da2608 doc/go1.17: fix formatting near httptest
+ 2021-06-10 770f1de8c5 net/http: remove test-only private key from production binaries
+ 2021-06-10 8d11b1d117 cmd/go: report the imports of CompiledGoFiles in ImportMap
+ 2021-06-10 dc00dc6c6b crypto/tls: let HTTP/1.1 clients connect to servers with NextProtos "h2"
+ 2021-06-09 27f83723e9 api: promote next to go1.17
+ 2021-06-09 182157c81a doc/go1.17: remove lingering TODO
+ 2021-06-09 a5bc060b42 doc/go1.17: document strconv changes for Go 1.17
+ 2021-06-09 1402b27d46 strconv: document parsing of leading +/-
+ 2021-06-09 df35ade067 doc/go1.17: document //go:build lines
+ 2021-06-09 e4e7807d24 net/http: add AllowQuerySemicolons
+ 2021-06-09 ec3026d032 doc/go1.17: remove TODO for ports section
+ 2021-06-09 e6dda19888 net/url: reject query values with semicolons
+ 2021-06-09 139e935d3c math/big: comment division
+ 2021-06-09 aa5540cd82 cmd/compile: make map.zero symbol content-addressable
+ 2021-06-09 07ca28d529 cmd/link: fix bug in -strictdups checking of BSS symbols
+ 2021-06-08 bcecae2af6 doc/go1.17: mention new possibility of type conversion panicking
+ 2021-06-08 63dcab2e91 doc/go1.17: mention new vet checks sigchanyzer and stdmethods.
+ 2021-06-08 6551763a60 doc/go1.17: mention block profile bias fix
+ 2021-06-08 cb80937bf6 Revert "doc/go1.17: mention block profile bias fix"
+ 2021-06-08 d3e3d03666 net: reject leading zeros in IP address parsers
+ 2021-06-08 da4a640141 doc/go1.17: revise OpenBSD release notes
+ 2021-06-08 689f4c7415 doc/go1.17: mention block profile bias fix
+ 2021-06-08 9afe071c60 doc/go1.17: remove TODO for Tools section
+ 2021-06-08 f753d7223e doc/go1.17: resolve TODO for cmd/cover
+ 2021-06-08 9498b0155d cmd/go: in Go 1.17+ modules, add indirect go.mod dependencies separately from direct ones
+ 2021-06-08 949f00cebe doc/go1.17: add release notes for crypto packages
+ 2021-06-08 0fb3e2c184 doc/go1.17: add a release note for the '-compat' flag to 'go mod tidy'
+ 2021-06-08 2169deb352 cmd/compile: use t.AllMethods when sorting typesByString
+ 2021-06-08 c20bcb6488 runtime: remove out-of-date comments about frame skipping
+ 2021-06-07 39c39ae52f doc: document Go 1.17 language changes
+ 2021-06-07 dc8b558951 cmd/dist: pass -Wno-lto-type-mismatch in swig_callback_lto
+ 2021-06-07 909dd5e010 strconv: ParseFloat: always return ErrSyntax for bad syntax

Change-Id: Iffdf379d0275bbd12d50149ce38634773ced481d
2021-06-14 13:24:47 -07:00
Cherry Mui
d4f34f8c63 doc/go1.17: reword "results" in stack trace printing
"Results" may sound like the results from the previous sentence.
Reword to "function return values" for clarity.

Suggested by Tobias Kohlbau.

Change-Id: Ie78df36b5b191b06e98b802f9a46db6d067a8ea0
Reviewed-on: https://go-review.googlesource.com/c/go/+/327774
Trust: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Tobias Kohlbau <tobias@kohlbau.de>
2021-06-14 19:26:24 +00:00
Joel Sing
fdab5be159 doc/go1.17: further revise OpenBSD release notes
Simplify and remove forward-compatibility reference, as OpenBSD 6.9 has
already been released (1st of May 2021).

Updates #44513

Change-Id: I0a1abbb397f31d15c80a970edaa9723f894cafa9
Reviewed-on: https://go-review.googlesource.com/c/go/+/327652
Trust: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-06-14 15:30:14 +00:00
Cuong Manh Le
326ea438bb cmd/compile: rewrite a, b = f() to use temporaries when type not identical
If any of the LHS expressions of an OAS2FUNC are not identical to the
respective function call results, escape analysis mishandles the
implicit conversion, causes memory corruption.

Instead, we should insert autotmps like we already do for f(g()) calls
and return g() statements.

Fixes #46725

Change-Id: I71a08da0bf1a03d09a023da5b6f78fb37a4a4690
Reviewed-on: https://go-review.googlesource.com/c/go/+/327651
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-14 07:12:37 +00:00