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

48569 Commits

Author SHA1 Message Date
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
Cuong Manh Le
3249b645c9 cmd/compile: factor out rewrite multi-valued f()
So next CL can reuse code to rewrite OAS2FUNC.

Passes toolstash -cmp.

For #46725

Change-Id: I1113ed615b6d6b9494dd87000ce342d7a46d9e7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/327650
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:21 +00:00
Jason A. Donenfeld
14305bf0b9 misc/cgo: generate Windows import libraries for clang
LLD won't import a .dll directly and instead requires an import library.
So generate these using -out-implib, the same way as was done in CL
312046, where it makes sense, and elsewhere build the import library
using a def file. We can't use -out-implib all the time, because the
output file gets overwritten each time the linker is called, rather than
merged.

Updates #46502.

Change-Id: Iefe54cb6c576004b83b1039ba673881b8640423d
Reviewed-on: https://go-review.googlesource.com/c/go/+/327211
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-06-13 23:53:43 +00:00
Jason A. Donenfeld
24cff0f044 cmd/go, misc/cgo: skip test if no .edata
Clang does not produce binaries with an .edata section, even when it
exports symbols properly, so just skip this binutils-specific test for
that case. Later we can rewrite these tests entirely to do something
more robust.

Updates #46719.

Change-Id: I864b3c2d91e66800c55454ae11d4ab1623693d14
Reviewed-on: https://go-review.googlesource.com/c/go/+/327549
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-06-13 08:17:17 +00:00
Cuong Manh Le
67b1b6a2e3 cmd/compile: allow ir.OSLICE2ARRPTR in mayCall
CL 301650 adds conversion from slice to array ptr. The conversion
expression may appear as argument to a function call, so it will be
tested by mayCall. But ir.OSLICE2ARRPTR  op is not handled by mayCall,
causes the compiler crashes.

Updates #395
Fixes #46720

Change-Id: I39e1b3e38e224a31f3dec46dbbdc855ff3b2c6a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/327649
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Trust: Josh Bleecher Snyder <josharian@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-13 05:50:15 +00:00
Matthew Dempsky
8eeaf961c5 [dev.typeparams] cmd/compile: move //go:embed -lang check to noder
User errors should be reported in noder and/or typecheck, we already
know the -lang flag's value during noding, and checking it then works
better for unified IR.

The "multiple files for type" and "cannot apply to var of type" errors
should also be moved to typecheck, but then they'd have to be
duplicated for -G=3 mode (because it avoids typecheck). So those are
left behind for now.

Change-Id: I7caf16163c9faf975784acacdb8147514d2e698e
Reviewed-on: https://go-review.googlesource.com/c/go/+/327609
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-13 03:10:49 +00:00
Ian Lance Taylor
1ed0d129e9 runtime: testprogcgo: don't call exported Go functions directly from Go
Instead route through a C function, to avoid declaration conflicts
between the declaration needed in the cgo comment and the declaration
generated by cgo in _cgo_export.h.

This is not something user code will ever do, so no need to make it
work in cgo.

Fixes #46502

Change-Id: I1bfffdc76ef8ea63e3829871298d0774157957a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/327309
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Jason A. Donenfeld <Jason@zx2c4.com>
2021-06-12 16:07:12 +00:00
Matthew Dempsky
f1b1c2f67f [dev.typeparams] cmd/compile: simplify NewClosureFunc
I initially made NewClosureFunc take an "outerfn *Func" parameter
because I was planning on having it handle closure naming, until
remembering that naming needs to wait until typecheck for noder.

We don't actually need the *Func yet, just to know whether it's
non-nil. So change the parameter to a bool, which simplifies callers a
little.

Change-Id: Ie83ee4a1ed0571ac6d3879ffd8474c6c3c1a9ff9
Reviewed-on: https://go-review.googlesource.com/c/go/+/327450
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-12 15:17:14 +00:00
Matthew Dempsky
db7c868307 [dev.typeparams] test: add string quoting support to test/run.go
This CL copies go/build's splitQuoted function (used for parsing #cgo
directives within `import "C"` preambles) to parse test recipe
commands. In particular, this now allows writing "build" and "run"
tests that use -gcflags to pass multiple compiler flags.

Change-Id: I0d18a9c13a4ce24bbdfa1da8662c0498c93a6762
Reviewed-on: https://go-review.googlesource.com/c/go/+/327275
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-12 14:36:25 +00:00
Matthew Dempsky
0132b91127 [dev.typeparams] cmd/compile: refactor closure construction
typecheck.tcClosure is complicated with many code flows because all of
its callers setup the closure funcs in slightly different ways. E.g.,
it's non-obvious who's responsible for setting the underlying func's
Sym or adding it to target.Decls, or how to write new code that
constructs a closure without interfering with existing code.

This CL refactors everything to use three common functions in package
ir: NewClosureFunc (which handle creating the Func, Name, and
ClosureExpr and wiring them together), NameClosure (which generates
and assigns its unique Sym), and UseClosure (which handles adding the
Func to target.Decls).

Most IR builders can actually name the closure right away, but the
legacy noder+typecheck path may not yet know the name of the enclosing
function. In particular, for methods declared with aliased receiver
parameters, we need to wait until after typechecking top-level
declarations to know the method's true name. So they're left anonymous
until typecheck.

UseClosure does relatively little work today, but it serves as a
useful spot to check that the code setting up closures got it right.
It may also eventually serve as an optimization point for early
lifting of trivial closures, which may or may not ultimately be
beneficial.

Change-Id: I7da1e93c70d268f575b12d6aaeb2336eb910a6f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/327051
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-12 13:53:19 +00:00
Matthew Dempsky
8f00eb0099 [dev.typeparams] cmd/compile: avoid ir.DeepCopy in noder.constDecl
Instead of using ir.DeepCopy to copy the IR from the previous constant
declaration, just call exprList again and then fix up the position
information. This is equivalent in practice, but has cleaner semantics
for tricky corner cases like constant declarations that contain
function literals.

In particular, this refactoring is necessary for the next CL that
cleans up function literal construction, because it adds extra
consistency checks that weren't satisfied by DeepCopy'd OCLOSUREs.

Change-Id: I0372bde5d6613695ee572cc8bf8fb4ff9aef4cb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/327449
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-12 13:53:06 +00:00
Michael Anthony Knyszek
9d46ee5ac4 reflect: handle stack-to-register translation in callMethod
callMethod previously assumed erroneously that between the "value" and
"method" ABIs (that is, the ABI the caller is following to call this
method value and the actual ABI of the method), it could never happen
that an argument passed on the stack in the former could be passed in
registers in the latter. The cited reason was that the latter always
uses strictly more registers.

However, there are situations where the value ABI could pass a value on
the stack, but later is passed in a register. For instance, if the
receiver pushes a value passed in registers that uses multiple registers
to be passed on the stack, later arguments which were passed on the
stack may now be passed in registers.

This change fixes callMethod to no longer makes this assumption, and
handles the stack-to-register translation explicitly.

Fixes #46696.

Change-Id: I7100a664d97bbe401302cc893b3a98b28cdcdfc0
Reviewed-on: https://go-review.googlesource.com/c/go/+/327089
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-12 00:12:55 +00:00
Matthew Dempsky
2954f11ead [dev.typeparams] cmd/compile: scaffolding for export data experiments
This CL adds a simple framework for augmenting the current export data
format by writing out additional data *after* the existing data, with
an extra header before it that current readers ignore.

In particular, this is used by unified IR to be able to experiment and
iterate on export data designs without having to keep the
go/internal/gcimporter and x/tools/go/gcexportdata importers in
sync. Instead, they simply continue reading the existing data written
out by typecheck/iexport.go.

Change-Id: I883211c2892e2c7dec758b85ff6bc31b244440a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/327169
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-06-12 00:11:57 +00:00
Constantin Konstantinidis
e552a6d312 cmd/go: remove hint when no module is suggested
Fixes #46528

Change-Id: I2453d321ece878ea7823865758aa4a16b3ed7fe8
Reviewed-on: https://go-review.googlesource.com/c/go/+/325430
Reviewed-by: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Trust: Heschi Kreinick <heschi@google.com>
Trust: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-11 21:43:54 +00:00
Cherry Mui
c93d5d1a52 [dev.typeparams] all: always enable regabig on AMD64
Always enable regabig on AMD64, which enables the G register and
the X15 zero register. Remove the fallback path.

Also remove the regabig GOEXPERIMENT. On AMD64 it is always
enabled (this CL). Other architectures already have a G register,
except for 386, where there are too few registers and it is
unlikely that we will reserve one. (If we really do, we can just
add a new experiment).

Change-Id: I229cac0060f48fe58c9fdaabd38d6fa16b8a0855
Reviewed-on: https://go-review.googlesource.com/c/go/+/327272
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-11 20:52:41 +00:00
Jason A. Donenfeld
16b5d766d8 syscall: do not load native libraries on non-native powershell on arm
The powershell that currently ships on ARM Windows isn't native, so it
won't load native DLLs. So just skip the tests for now, and reenable it
if this ever changes.

Updates #46701.

Change-Id: I2559fdf13cb65d3ecdc4c6f6df7dec1b490b9651
Reviewed-on: https://go-review.googlesource.com/c/go/+/327210
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Trust: Jason A. Donenfeld <Jason@zx2c4.com>
Run-TryBot: Jason A. Donenfeld <Jason@zx2c4.com>
2021-06-11 20:31:30 +00:00
Cherry Mui
2fe324858b [dev.typeparams] internal/buildcfg: always enable regabiwrappers on AMD64
Always enable regabiwrappers on AMD64. GOEXPERIMENT=none will not
turn it off.

Change-Id: I0aa208c02157661ac3676b753bcfbfa050b99e41
Reviewed-on: https://go-review.googlesource.com/c/go/+/327271
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-11 19:54:25 +00:00
Ian Lance Taylor
77aa209b38 runtime: loop on EINTR in macOS sigNoteSleep
Fixes #46466

Change-Id: I8fb15d0c8ef7ef6e6fc1b9e0e033d213255fe0df
Reviewed-on: https://go-review.googlesource.com/c/go/+/326778
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2021-06-11 19:00:10 +00:00
Cherry Mui
e0e9fb8aff [dev.typeparams] runtime: simplify defer record allocation
Now that deferred functions are always argumentless and defer
records are no longer with arguments, defer record can be fixed
size (just the _defer struct). This allows us to simplify the
allocation of defer records, specifically, remove the defer
classes and the pools of different sized defers.

Change-Id: Icc4b16afc23b38262ca9dd1f7369ad40874cf701
Reviewed-on: https://go-review.googlesource.com/c/go/+/326062
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-11 18:33:07 +00:00
Cherry Mui
4468e1cfb9 [dev.typeparams] runtime: allow newproc split stack
newproc was not allowed to split stack because it had a special
stack layout, where the go'd function's arguments were passed on
stack but not included in the signature (therefore the stack map).
Now it no longer has argument, so it does not need to be nosplit.

Change-Id: I6f39730fb1595c4b0438c74118fef418fe1c082b
Reviewed-on: https://go-review.googlesource.com/c/go/+/325919
Trust: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-11 18:32:42 +00:00
Matthew Dempsky
ef6c5be160 [dev.typeparams] cmd/compile: fix wrapper generation for imported generics
This CL fixes reflectdata.methodWrapper to compile wrapper functions
for method expressions involving imported, instantiated interface
types. CL 322193 fixed a similar issue for generating wrappers for
imported, instantiated concrete types, but missed this case.

This is necessary to fix CL 326169's test case 10. However, that test
case is not included currently, because -G=3 mode crashes on method
expressions involving *any* instantiated interface type. Adding a test
will have to wait until either this issue is fixed in -G=3 mode, or
unified IR is merged.

Updates #46704.

Change-Id: Ib02d3c20e7c69d16288f1286cd1c98e7cbbba114
Reviewed-on: https://go-review.googlesource.com/c/go/+/327055
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dan Scales <danscales@google.com>
Trust: Dan Scales <danscales@google.com>
Trust: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-11 17:18:40 +00:00
Brad Fitzpatrick
e2dc6dd5c9 doc/go1.17: clean up formatting of gofmt section
It was the only h3 in <code>, and it lacked <p> around its content.

It looked like it was part of the prior section:

    https://tip.golang.org/doc/go1.17#gofmt

Change-Id: I7e9ef70e9a03474225833f44420aabd70dab3cd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/326774
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Trust: Brad Fitzpatrick <bradfitz@golang.org>
2021-06-11 16:09:15 +00:00
Bryan C. Mills
2f1128461d cmd/go: match Windows paths in TestScript/mod_invalid_version
Fixes #46691

Change-Id: I3bef9a773be640bed96eb2dc395cb11671a0767a
Reviewed-on: https://go-review.googlesource.com/c/go/+/326869
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2021-06-11 14:50:38 +00:00
Matthew Dempsky
4a735ce068 [dev.typeparams] cmd/compile: add "check" field to noder.gcimports
The unified IR importer needs access to the *types2.Checker instance
to lazily construct objects and types. Eventually, maybe the
types2.Importer API can be extended to add the Checker as another
parameter (or more likely something like an ImportConfig struct), but
right now we can handle this ourselves as long as we forgo the
types2.(*Config).Check convenience wrapper.

Updates #46449.

Change-Id: I89c41d5d47c224a58841247cd236cd9f701a23a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/327053
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-11 14:48:07 +00:00
Rhys Hiltner
2721da2608 doc/go1.17: fix formatting near httptest
Change-Id: Ic1a0add3a1e137ca5cd0f3e9ce3266191b0b55cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/326777
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2021-06-11 14:48:06 +00:00
Matthew Dempsky
61888d47c4 [dev.typeparams] cmd/compile: allow embedding Type.Vargen into Sym.Name
Unified IR currently works by hoisting local type definitions to
package scope, which requires giving them a unique name. Its current
solution is to directly embed the ·N suffix in Sym.Name, rather than
set Type.Vargen. This CL extends types/fmt.go to support trimming this
suffix again when appropriate.

Longer term, I want to revisit this hack, but this seemed like the
least invasive solution while also handling generics and local types.

Change-Id: If99fcdcc1e19e37d5887de3b021c256a3fe46b98
Reviewed-on: https://go-review.googlesource.com/c/go/+/327052
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-11 14:47:33 +00:00
Matthew Dempsky
62e32dd386 [dev.typeparams] cmd/compile: extract SetBaseTypeIndex function
The unified IR importer requires a way to set symbol indices for
imported types, so provide an exported API for this.

Change-Id: I2f088628f56d5b9f1097196dc1aa23f0a8b8d496
Reviewed-on: https://go-review.googlesource.com/c/go/+/327050
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-11 14:46:45 +00:00
Matthew Dempsky
18788245ea [dev.typeparams] cmd/compile: add ir.TypeNodeAt
This CL adds a variant of ir.TypeNode that allows specifying position
information. This shouldn't normally be needed/used, but it's
occasionally helpful for writing code that passes toolstash -cmp.

Change-Id: I2be5da0339fd1ec2bee01d6c5310bd2ef58c46b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/327049
Trust: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2021-06-11 14:46:12 +00:00
Damien Neil
770f1de8c5 net/http: remove test-only private key from production binaries
The net/http/internal package contains a PEM-encoded private key used in
tests. This key is initialized at init time, which prevents it from
being stripped by the linker in non-test binaries.

Move the certificate and key to a new net/http/internal/testcert
package to ensure it is only included in binaries that reference it.

Fixes #46677.

Change-Id: Ie98bda529169314cc791063e7ce4d99ef99113c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/326771
Trust: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
2021-06-10 20:20:58 +00:00
Bryan C. Mills
8d11b1d117 cmd/go: report the imports of CompiledGoFiles in ImportMap
Ideally we should encode the load.PackageInternal data in a way that
doesn't rely on 1:1 correlations of slices, but this is a minimal fix
to unblock Go 1.17.

Fixes #46462

Change-Id: I6e029c69f757aadc54d4be02c01d6b294c217542
Reviewed-on: https://go-review.googlesource.com/c/go/+/326610
Trust: Bryan C. Mills <bcmills@google.com>
Run-TryBot: Bryan C. Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
2021-06-10 19:59:02 +00:00
Filippo Valsorda
dc00dc6c6b crypto/tls: let HTTP/1.1 clients connect to servers with NextProtos "h2"
Fixes #46310

Change-Id: Idd5e30f05c439f736ae6f3904cbb9cc2ba772315
Reviewed-on: https://go-review.googlesource.com/c/go/+/325432
Trust: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2021-06-10 12:41:37 +00:00