Commit graph

52865 commits

Author SHA1 Message Date
Russ Cox f330a3a987 doc/go1.19: complete most remaining TODOs
The ones I left behind are almost entirely ones that I see pending CLs for.
Also make various fixes to existing text.

For #51400.

Change-Id: I555e0074c9df82b5bdb345e21a08c8757ca147b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/410814
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-06-08 15:30:59 +00:00
Tobias Klauser 2882786bf4 runtime: remove unused pipe and setNonblock on linux/loong64
CL 389354 removed the fallback to pipe on all platforms with pipe2. This
is the case for linux. Thus, pipe and setNonblock are no longer needed
on linux/loong64 too.

Change-Id: I089adf918d0fd8de5d4d61a893707a2660f89183
Reviewed-on: https://go-review.googlesource.com/c/go/+/410736
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-08 01:54:08 +00:00
Meng Zhuo decdd87bea doc/go1.19: mention riscv64 supported regabi
Change-Id: I715e53e4baf67f896fa9c240f7668ce11f7b33c3
Reviewed-on: https://go-review.googlesource.com/c/go/+/409195
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2022-06-08 00:55:30 +00:00
Dan Kortschak b72a6a7b86 os: document that Chdir affects fs.FS returned by DirFS with a relative path
Fixes #47214.

Change-Id: I6fdc1c4340c0943b825ac22e311179ad1cf30915
Reviewed-on: https://go-review.googlesource.com/c/go/+/410334
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-07 23:09:21 +00:00
Tobias Klauser 30b929b1ef syscall: remove unused accept on linux/loong64
accept is no longer used on Linux since CL 346849 changed Accept to use
accept4 only.

This follows CL 386415 which already removed accept on all other Linux
platforms before the linux/loong64 port was submitted.

For #45964

Change-Id: I26945ff780e71174a0b0c2f5313c4bc1e1cbf786
Reviewed-on: https://go-review.googlesource.com/c/go/+/410737
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-07 23:00:27 +00:00
Damien Neil a7551fe245 net: use synthetic network in TestDialParallel
TestDialParallel is testing the Happy Eyeballs algorithm implementation,
which dials IPv4 and IPv6 addresses in parallel with the preferred
address family getting a head start. This test doesn't care about
the actual network operations, just the handling of the parallel
connections.

Use testHookDialTCP to replace socket creation with a function that
returns successfully, with an error, or after context cancellation
as required.

Limit tests of elapsed times to a check that the fallback deadline
has been exceeded in cases where this is expected.

This should fix persistent test flakiness.

Fixes #52173.

Change-Id: Ic93f270fccb63b24a91105a4d541479fc33a2de4
Reviewed-on: https://go-review.googlesource.com/c/go/+/410754
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-07 22:24:02 +00:00
Cherry Mui 19d71acd97 doc/go1.19: document that the assembler requires -p
For #51400.

Change-Id: I50fb4313105ae6dbbbe2c98cbe4a8f8e2563eba9
Reviewed-on: https://go-review.googlesource.com/c/go/+/410824
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-07 22:00:00 +00:00
Cherry Mui d151134851 doc/go1.19: document linker CL that switches DWARF compressed section format
For #51400.
Updates #50796.

Change-Id: Ica6c700a5b54e4712b09c43d1d7a9c3bba408b8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/410823
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Fangrui Song <maskray@google.com>
2022-06-07 21:59:44 +00:00
Robert Griesemer 3507805bcd go/types, types2: better error message for invalid use of constraint type
Fixes #42881.

Change-Id: If800c5f90c0034d192bf8b6649e5cfda96df48cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/410954
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-06-07 21:37:21 +00:00
Robert Griesemer 269bf7e855 go/types, types2: better error message if type is not in type set
Fixes #40350.

Change-Id: Ia654d6b854971700ca618692a864265557122b23
Reviewed-on: https://go-review.googlesource.com/c/go/+/410876
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-06-07 21:37:18 +00:00
Robert Griesemer d4fb93be87 go/types, types2: use | rather than ∪ when printing term lists
With this change, the termlist String() function prints termlists
in the usual Go notation and thus we can use it in error reporting.
Preparation for fixing #40350.

For #40350.

Change-Id: Ia28318841305de234a71af3146ce0c59f5e601a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/410894
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-06-07 21:37:14 +00:00
Damien Neil 346698eea7 doc/go1.19: add release notes for net/http and net/url
For #51400

Change-Id: I6412132db79074eef7d2cb3d66456c48b0d745a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/408877
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2022-06-07 19:47:46 +00:00
Michael Pratt 7a82c6859f doc/go1.19: adjust runtime release notes
This addresses comments from CL 410356.

For #48409.
For #51400.

Change-Id: I03560e820a06c0745700ac997b02d13bc03adfc6
Reviewed-on: https://go-review.googlesource.com/c/go/+/410735
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Chris Hines <chris.cs.guy@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2022-06-07 18:47:45 +00:00
Michael Pratt f3e051a184 runtime: document GOMEMLIMIT in environment variables section
For #48409.

Change-Id: Ia6616a377bc4c871b7ffba6f5a59792a09b64809
Reviewed-on: https://go-review.googlesource.com/c/go/+/410734
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Chris Hines <chris.cs.guy@gmail.com>
Reviewed-by: Russ Cox <rsc@golang.org>
2022-06-07 18:47:38 +00:00
David Chase ef2567c7dd doc/go1.19: document loong64 port
Updates #46229
For #51400

Change-Id: Iedd5d3c4cd656b59ba2e1fe813851830849a8614
Reviewed-on: https://go-review.googlesource.com/c/go/+/410816
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2022-06-07 18:31:49 +00:00
Will Hawkins 69bb7c6ef5 sync/atomic: clarify that 8-byte alignment of variables is due to escape
For #53223.

Change-Id: I79e9b920488581a4d850e4051ee0dd600b5bbcb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/410102
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2022-06-07 17:44:51 +00:00
Austin Clements 81033fbd8e doc/go1.19: some platforms are still on TSAN v2
For #51400

Change-Id: Ie6d6ac773aa81b105e15ef7399374f574197d775
Reviewed-on: https://go-review.googlesource.com/c/go/+/410817
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-07 17:36:56 +00:00
Austin Clements 0c3a0543c2 doc/go1.19: compiler section is complete, modulo TODOs
For #51400

Change-Id: I964e52e0a36e7bbe77175670e93ce8c99e7dab6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/410367
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-07 16:59:48 +00:00
Austin Clements 835a946137 doc/go1.19: minor edits
For #51400

Change-Id: I57565c1d79e0c5487d39d46f556b247d35f05d3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/410674
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-06-07 16:57:52 +00:00
Robert Findley 429a4041eb doc/go1.19: complete TODOs for go/types
Fill in the details of outstanding TODO items for go/types changes.

For #51400

Change-Id: Ib40d75fa1018aa164022cb49b293795dd597d49d
Reviewed-on: https://go-review.googlesource.com/c/go/+/410815
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-06-07 16:39:37 +00:00
Roland Shoemaker d2630aa4b2 doc/go1.19: add various crypto release notes
For #51400

Change-Id: I908f53a54c6603e1bf2c9238cd51cf5c4a24407b
Reviewed-on: https://go-review.googlesource.com/c/go/+/410295
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tatiana Bradley <tatiana@golang.org>
2022-06-07 16:07:58 +00:00
Khaled Yakdan 77d9252ddf runtime: fix inline assembly trampoline for arm64
Use the program counter to compute the address of the first instruction
of the ret sled. The ret sled is located after 5 instructions from the
MOVD instruction saving the value of the program counter.

Change-Id: Ie7ae7a0807785d6fea035cf7a770dba7f37de0ec
GitHub-Last-Rev: 2719208c6a
GitHub-Pull-Request: golang/go#53039
Reviewed-on: https://go-review.googlesource.com/c/go/+/407895
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-06-07 14:47:46 +00:00
Motiejus Jakštys 38607c5538 cmd/link: specify -Wl,-z params as documented
Both GNU and LLVM linkers de facto accept `-zPARAM`, and Go sometimes
does it. Inconsistently: there are more uses of `-z PARAM` than
`-zPARAM`:

    $ git grep -E -- '-Wl,-z[^,]' master | wc -l
    4
    $ git grep -E -- '-Wl,-z,' master | wc -l
    7

However, not adding a space between `-z` and the param is not
documented:

llvm-13:

    $ man ld.lld-13 | grep -E -A1 -w -- "^ +-z"
         -z option
                 Linker option extensions.

gnu ld:

    $ man ld | grep -E -A1 -w -- "^ +-z"
           -z keyword
               The recognized keywords are:
    --
           -z defs
               Report unresolved symbol references from regular object files.  This is done even if the linker is creating a non-symbolic
    --
           -z muldefs
               Normally when a symbol is defined multiple times, the linker will report a fatal error. These options allow multiple definitions
    --
           -z
           --imagic

... and thus should be avoided.

`zig cc`, when used as the C compiler (`CC="zig cc" go build ...`), will
bark, because `zig cc` accepts only `-z PARAM`, as documented.

Closes ziglang/zig#11669

Change-Id: I758054ecaa3ce01a72600bf65d7f7b5c3ec46d09
GitHub-Last-Rev: e068e007da
GitHub-Pull-Request: golang/go#53030
Reviewed-on: https://go-review.googlesource.com/c/go/+/407834
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2022-06-07 14:45:47 +00:00
Russ Cox 95b68e1e02 doc/go1.19: delete boringcrypto TODO
Boringcrypto has never been officially supported and it remains unsupported.
It need not be mentioned in the release notes.

Change-Id: I24a08d424982615244d51c1d250035d85a602023
Reviewed-on: https://go-review.googlesource.com/c/go/+/410362
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-06-07 01:54:55 +00:00
Russ Cox a79623b019 doc/go1.19: add more TODOs from updated relnote
CL 410244 changes relnote to look for api file changes as well
as references to proposal issues, finding various things that
were missing from the release notes.

This CL adds the TODOs that the updated relnote found.

For #51400.

Change-Id: I512a9b8f1349a6c68c8a6979f55a07964d630175
Reviewed-on: https://go-review.googlesource.com/c/go/+/410361
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-06-07 01:54:47 +00:00
Michael Anthony Knyszek acfff42802 doc/go1.19: add release notes for the soft memory limit and idle GC
This change resolves some TODOs in the release notes, and while we're
here, also clarifies how CPU profile samples are represented in runtime
traces.

Change-Id: Idaa36ccf65b03fd5463b2d5da682d3fa578d2f46
Reviewed-on: https://go-review.googlesource.com/c/go/+/410356
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2022-06-06 21:01:07 +00:00
Russ Cox a71ca3dfbd runtime, sync, sync/atomic: document happens-before guarantees
A few of these are copied from the memory model doc.
Many are entirely new, following discussion on #47141.
See https://research.swtch.com/gomm for background.

The rule we are establishing is that each type that is meant
to help synchronize a Go program should document its
happens-before guarantees.

For #50859.

Change-Id: I947c40639b263abe67499fa74f68711a97873a39
Reviewed-on: https://go-review.googlesource.com/c/go/+/381316
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
2022-06-06 20:48:03 +00:00
Russ Cox 3651a6117e go/doc/comment: add heuristics for common badly formatted comments
In a set of 55M Go doc comments drawn from the latest version of
all public Go modules known to the module proxy in spring 2020,
the current Go 1.19 gofmt reformats about 1.57M of them.
Out of those 1.57M comments, inspection of random samples
shows that around 5% of the changed comments contain
unindented code snippets, multiline shell commands, or lists.
For example:

	// Here is a greeting:
	//
	// func main() {
	//	fmt.Println("hello, world")
	// }

	// Run this command:
	//
	// path/to/your/program -flag1=longargument1 \
	//	-flag2=longargument2 \
	//	-flag3

	// There are three possibilities:
	//
	// - Unindented code snippets (or JSON objects)
	//    in which the first and last line are unindented
	//    but end in { and start with }, respectively.
	// - Unindented multiline shell commands
	//    in which the lines end in \
	// - Unindented lists, in which wrapped lines are indented.

All three of these cases involve unindented lines next to indented
lines that would according to the usual rules begin a pre block.
Before this CL, they'd be reformatted to:

	// Here is a greeting:
	//
	// func main() {
	//
	//	fmt.Println("hello, world")
	//
	// }

	// Run this command:
	//
	// path/to/your/program -flag1=longargument1 \
	//
	//	-flag2=longargument2 \
	//	-flag3

	// There are three possibilities:
	//
	// - Unindented code snippets (or JSON objects)
	//
	//	in which the first and last line are unindented
	//	but end in { and start with }, respectively.
	//
	// - Unindented multiline shell commands
	//
	//	in which the lines end in \
	//
	// - Unindented lists, in which wrapped lines are indented.

The fact that they are not already in canonical format gives us
a signal that they might not mean what the usual rules would say.

This CL takes advantage of that opening to apply a few heuristics
to better handle these cases:

 1. If an indented code block immediately follows (without a blank line)
    an unindented line ending in { or \, include the unindented line
    in the code block.

 2. If an indented code block immediately precedes (without a blank line)
    an unindented line beginning with }, include the unindented line
    in the code block.

 3. If an indented line immediately follows (without a blank line)
    an unindented line that starts with a list marker, assume this is
    an unindented list with a wrapped indented line, and treat all
    adjacent unindented lines starting with list markers as part of
    the list, stopping at any surrounding blank lines.

This raises the fraction of “correctly” reformatted doc comments
in the corpus from approximately 87% to approximately 93%.

Change-Id: I7ac542eb085032d607a7caf3ba9020787b2978b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/410360
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2022-06-06 20:47:52 +00:00
Russ Cox 4c08260c51 doc/go_mem: update revision date
CL 381315 added major revisions but neglected to update the date.

For #50859.

Change-Id: I086a55f0c80579c479bca5268109c9f3ae680adf
Reviewed-on: https://go-review.googlesource.com/c/go/+/410675
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-06-06 20:47:51 +00:00
Austin Clements 7271a0a287 doc/go1.19: gc requires -p=importpath
For #51400

Change-Id: I07a805147a6aa0923331f3f940a9e6e5553cbea9
Reviewed-on: https://go-review.googlesource.com/c/go/+/410676
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-06-06 19:55:16 +00:00
Brad Fitzpatrick c1e2ecbaf9 doc/go1.19: document Resolver.PreferGo
Updates #51400

Change-Id: I61733574362d4cf3cb65122bd13361e5c0f6728c
Reviewed-on: https://go-review.googlesource.com/c/go/+/410375
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2022-06-06 19:53:39 +00:00
Michael Matloob 11195c60e6 cmd/go: use index to match packages in dependency modules
If we're trying to search in a module in the module cache, instead
iterate over the packages in the index.
Change-Id: Ia94cbe6e9690110c28b93dbb33810680e3010381
Reviewed-on: https://go-review.googlesource.com/c/go/+/403756
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Peter Weinberger <pjw@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-06 19:32:49 +00:00
Russ Cox ea5d7cbc26 all: boringcrypto post-merge cleanup
This CL addresses the comments on CL 403154.

For #51940.

Change-Id: I99bb3530916d469077bfbd53095bfcd1d2aa82ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/403976
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-06 19:10:07 +00:00
Russ Cox 6c7b223c2b go/doc/comment: do not turn `` into “
``` is Markdown, not Go doc comment, but some small fraction of users get confused.

In a set of 55M Go doc comments drawn from the latest version of
all public Go modules known to the module proxy in spring 2020,
the current Go 1.19 gofmt reformats about 1.57M of them.
Out of those 1.57M comments, 8k of them (about 0.5%) contain ```.

Instead of rewriting ``` to “`, leave it alone.

For #51082.

Change-Id: I1c8c88aac7ef75ec03e1a396b84ffe711c46f941
Reviewed-on: https://go-review.googlesource.com/c/go/+/410359
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2022-06-06 19:06:16 +00:00
Russ Cox ce757e94e0 go/doc/comment: add doc comment
A CL in the website repo will add go.dev/doc/comment.

One of the final steps for #51082.

Change-Id: I419b4f6dbb424a8a93a8d09db30f7321af9ae976
Reviewed-on: https://go-review.googlesource.com/c/go/+/410358
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-06-06 19:05:57 +00:00
Joel Sing 95547aee8c cmd/compile: cast riscv64 rewrite shifts to unsigned int
This appeases Go 1.4, making it possible to bootstrap GOARCH=riscv64 with
a Go 1.4 compiler.

Fixes #52583

Change-Id: Ib13c2afeb095b2bb1464dcd7f1502574209bc7ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/409974
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-06 19:03:15 +00:00
90364136+butterfly1924@users.noreply.github.com d43ddc1f3f strconv: fix typo in atof.go
strings for 'NaN' -> string for 'NaN'

Change-Id: Ia415644a1b651e6ef9996ad24dd9708a60e57dfc
GitHub-Last-Rev: 877f1c3eb1
GitHub-Pull-Request: golang/go#53246
Reviewed-on: https://go-review.googlesource.com/c/go/+/410494
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-06 18:50:50 +00:00
Than McIntosh 2fa45a4fcd cmd/link/internal/loadpe: handle _main reference properly
When building CGO internal linking on windows 386, make sure to avoid
rewriting references to "_main" to "main" when reading symbols during
host object loading; the main routine defined by the Go runtime is
still named "_main" (not "main"). If we don't do this, we wind up with
an SXREF symbol named "main", which can then cause the loader to pull
an actual "main" symbol out of a host archive, which is undesirable.

Updates #35006.

Change-Id: I3768e3617b560552f4522e9e72af879c6adf7705
Reviewed-on: https://go-review.googlesource.com/c/go/+/410124
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Auto-Submit: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-06 18:49:49 +00:00
Robert Griesemer fc97075949 go/types, types2: simplify implementation of validType (fix TODO)
Now that validType is using the correct type nest (CL 409694),
the top entry of the type nest corresponds to the instantiated
type. Thus we can use that type instance to look up the value
of type parameters, there's no need anymore to create an environment
to look up type arguments.

Remove the need to pass around the environment and remove all
associated types and functions.

Updates #52698.

Change-Id: Ie37eace88896386e667ef93c77a4fc3cd0be6eb9
Reviewed-on: https://go-review.googlesource.com/c/go/+/410294
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2022-06-06 18:37:38 +00:00
Robert Griesemer 07eca49055 go/types, types2: use type nest to detect type cycles (fix validType)
validType was using a global type info map to detect invalid recursive
types, which was incorrect. Instead, change the algorithm as follows:

- Rather than using a "seen" (or typeInfo) map which is cumbersome to
  update correctly, use the stack of embedding types (the type nest)
  to check whether a type is embedded within itself, directly or
  indirectly.

- Use Identical for type comparisons which correctly considers identity
  of instantiated generic types.

- As before, maintain the full path of types leading to a cycle. But
  unlike before, track the named types rather than their objects, for
  a smaller slice ([]*Named rather than []Object), and convert to an
  object list only when needed for error reporting.

- As an optimization, keep track of valid *Named types (Checker.valids).
  This prevents pathological cases from consuming excessive computation
  time.

- Add clarifying comments and document invariants.

Based on earlier insights by David Chase (see also CL 408818).

Fixes #52698.

Change-Id: I5e4598c58afcf4ab987a426c5c4b7b28bdfcf5ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/409694
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-06 18:24:19 +00:00
Robert Findley 770146d5a8 doc/go1.19: add TODOs for changes to go/types
Add TODO items for significant changes to go/types: the inclusion of
Origin methods for Var and Func, and a re-working of Named types to
ensure finiteness of reachable types via their API.

Updates #51400

Change-Id: I0f2a972023a5d5f995de3c33e9e2b0a4213e900a
Reviewed-on: https://go-review.googlesource.com/c/go/+/410614
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-06 16:26:54 +00:00
Alejandro Sáez 1b8ca75eaa runtime: fix breakpoint in ppc64x
Currently runtime.Breakpoint generates a SIGSEGV in ppc64.
The solution is an unconditional trap similar to what clang and gcc do. It is documented in the section C.6 of the ABI Book 3.

Fixes #52101

Change-Id: I071d2f2679b695ef268445b04c9222bd74e1f9af
GitHub-Last-Rev: fff4e5e8ff
GitHub-Pull-Request: golang/go#52102
Reviewed-on: https://go-review.googlesource.com/c/go/+/397554
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Paul Murphy <murp@ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-06-06 16:04:48 +00:00
Eli Bendersky 9ce28b518d text/template/parse: fix data race on lexer initialization
Before this change, `startParse` would write `lex.breakOK` and `lex.continueOK` when the lexer goroutine is already running, which is a potential race condition.

Makes `breakOK` and `continueOK` configuration flags passed when `lexer` is created, similarly to how `emitComment` works.

Fixes #53234

Change-Id: Ia65f6135509a758cd4c5a453b249a174f4fb3e21
Reviewed-on: https://go-review.googlesource.com/c/go/+/410414
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2022-06-06 15:54:07 +00:00
Robert Findley 47e34ca533 go/types, types2: ensure that named types never expand infinitely
During type-checking, newly created instances share a type checking
Context which de-duplicates identical instances. However, when
unexpanded types escape the type-checking pass or are created via calls
to Instantiate, they lack this shared context. As reported in #52728,
this may lead to infinitely many identical but distinct types that are
reachable via the API.

This CL introduces a new invariant that ensures we don't create such
infinitely expanding chains: instances created during expansion share a
context with the type that led to their creation. During expansion, the
expanding type passes its Context to any newly created instances.

This ensures that cycles will eventually terminate with a previously
seen instance. For example, if we have an instantiation chain
T1[P]->T2[P]->T3[P]->T1[P], by virtue of this Context passing the
expansion of T3[P] will find the instantiation T1[P].

In general, storing a Context in a Named type could lead to pinning
types in memory unnecessarily, but in this case the Context pins only
those types that are reachable from the original instance. This seems
like a reasonable compromise between lazy and eager expansion.

Our treatment of Context was a little haphazard: Checker.bestContext
made it easy to get a context at any point, but made it harder to reason
about which context is being used. To fix this, replace bestContext with
Checker.context, which returns the type-checking context and panics on a
nil receiver. Update all call-sites to verify that the Checker is
non-nil when context is called.

Also make it a panic to call subst with a nil context. Instead, update
subst to explicitly accept a local (=instance) context along with a
global context, and require that one of them is non-nil. Thread this
through to the call to Checker.instance, and handle context updating
there.

Fixes #52728

Change-Id: Ib7f26eb8c406290325bc3212fda25421a37a1e8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/404885
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
2022-06-06 15:42:19 +00:00
Robert Findley 02e69cfa96 go/types, types2: store Named instance information separately
Separate instance information into an instance struct, to reduce memory
footprint for non-instance Named types. This may induce a sense of
deja-vu: we had a similar construct in the past that was removed as
unnecessary. With additional new fields being added that only apply to
instances, having a separate struct makes sense again.

Updates #52728

Change-Id: I0bb5982d71c27e6b574bfb4f7b886a6aeb9c5390
Reviewed-on: https://go-review.googlesource.com/c/go/+/404884
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-06 15:21:40 +00:00
Robert Findley 1323b0e8f0 go/types, types2: eliminate methodList in favor of just using Named.mu
In order to clean up context after fully expanding a type (in subsequent
CLs), we must use a common mutex. Eliminate the lazy methodList type,
which keeps a sync.Once per method, in favor of Named.mu.

Updates #52728

Change-Id: I2d13319276df1330ee53046ef1823b0167a258d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/404883
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-06-06 15:18:33 +00:00
Robert Findley 846f971daa go/types, types2: remove Named.once in favor of monotonic state
Introduce a monotonic state variable to track the lifecycle of a named
type, replacing the existing sync.Once. Having a single guard for the
state of underlying and methods will allow for cleaning-up when the type
is fully expanded. In the future, this state may also be used for
detecting access to information such as underlying or methods before the
type is fully set-up, though that will require rethinking our
type-checking of invalid cyclic types.

Also remove support for type-type inference. If we ever support this
feature in the future (inference of missing type arguments for named
type instances), it will likely involve additional machinery that does
not yet exist. Remove the current partial support to simplify our
internal APIs. In particular, this means that Named.resolver is only
used for lazy loading. As a result, we can revert the lazy loader
signature to its previous form.

A lot of exposition is added for how Named types work. Along the way,
the terminology we use to describe them is refined.

Some microbenchmarks are added that were useful in evaluating the
tradeoffs between synchronization mechanisms.

Updates #52728

Change-Id: I4e147360bc6e5d8cd4f37e32e86fece0530a6480
Reviewed-on: https://go-review.googlesource.com/c/go/+/404875
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-06-06 15:15:21 +00:00
Stephen Eckels 66cbf67345 cmd/buildid: reject rewriting legacy buildids
This resolves legacy go binaries crashing the buildid tool when the -w flag is specified.

Fixes #50809

Change-Id: I55a866f285a3c2cebcf2cdbb9cc30e5078e1d18f
GitHub-Last-Rev: 7169a58fd7
GitHub-Pull-Request: golang/go#53163
Reviewed-on: https://go-review.googlesource.com/c/go/+/409535
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-06-06 14:30:53 +00:00
Ben Hoyt 47f806ce81 strconv: clarify ParseFloat accepts Go syntax for float literals
The documentation for strconv.ParseFloat mentions that it "accepts
decimal and hexadecimal floating-point number syntax", but it doesn't
specify what those formats entail. For example, "0x10" is not allowed;
you need an explicit exponent, as in "0x10p0".

This clarifies that ParseFloat accepts the Go syntax for floating-point
literals, and links to that spec section. I've also linked to the
relevant spec section for ParseInt's doc comment, which already said
"as defined by the Go syntax for integer literals".

Change-Id: Ib5d2b408bdd01ea0b9f69381a9dbe858f6d1d424
Reviewed-on: https://go-review.googlesource.com/c/go/+/410335
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-06-04 21:18:25 +00:00
Ikko Ashimine 2730c6af9f runtime: fix typo in libfuzzer_arm64.s
statment -> statement

Change-Id: Ia93a466fdc20157a7d6048903e359fe8717ecb8f
GitHub-Last-Rev: 0a9bc5cab0
GitHub-Pull-Request: golang/go#53231
Reviewed-on: https://go-review.googlesource.com/c/go/+/410374
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2022-06-04 21:17:14 +00:00