Khaled Yakdan [Mon, 23 May 2022 23:20:00 +0000 (23:20 +0000)]
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: 2719208c6a3b049e0f394e5311ce3282b58f8516
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>
$ 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: e068e007da9f2b0441ee0aa8b198a7ba3cd93ed3
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>
Russ Cox [Sat, 4 Jun 2022 18:33:41 +0000 (14:33 -0400)]
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.
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>
Russ Cox [Fri, 3 Jun 2022 16:44:58 +0000 (12:44 -0400)]
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>
Michael Matloob [Tue, 3 May 2022 17:17:08 +0000 (13:17 -0400)]
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>
Russ Cox [Fri, 3 Jun 2022 13:18:57 +0000 (09:18 -0400)]
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>
90364136+butterfly1924@users.noreply.github.com [Mon, 6 Jun 2022 05:10:38 +0000 (05:10 +0000)]
strconv: fix typo in atof.go
strings for 'NaN' -> string for 'NaN'
Change-Id: Ia415644a1b651e6ef9996ad24dd9708a60e57dfc
GitHub-Last-Rev: 877f1c3eb1dc885915ae75385c5d38ee6f5fd9b1
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>
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>
Robert Griesemer [Fri, 3 Jun 2022 03:40:17 +0000 (20:40 -0700)]
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>
Robert Griesemer [Wed, 1 Jun 2022 03:59:55 +0000 (20:59 -0700)]
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>
Robert Findley [Mon, 6 Jun 2022 15:48:29 +0000 (11:48 -0400)]
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>
Alejandro Sáez [Mon, 23 May 2022 12:07:47 +0000 (12:07 +0000)]
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: fff4e5e8ffe23bf0cef135b22abd2cc0a3838613
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>
Eli Bendersky [Sat, 4 Jun 2022 16:43:40 +0000 (09:43 -0700)]
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>
Robert Findley [Sun, 8 May 2022 01:22:17 +0000 (21:22 -0400)]
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>
Robert Findley [Sat, 7 May 2022 23:26:35 +0000 (19:26 -0400)]
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>
Robert Findley [Sat, 7 May 2022 22:59:14 +0000 (18:59 -0400)]
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>
Robert Findley [Sun, 15 May 2022 23:31:42 +0000 (19:31 -0400)]
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>
Stephen Eckels [Sat, 4 Jun 2022 20:39:36 +0000 (20:39 +0000)]
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: 7169a58fd7ba17fdeb8037cef3f50080169dc137
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>
Ben Hoyt [Sat, 4 Jun 2022 06:31:40 +0000 (18:31 +1200)]
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>
Ikko Ashimine [Sat, 4 Jun 2022 03:41:06 +0000 (03:41 +0000)]
runtime: fix typo in libfuzzer_arm64.s
statment -> statement
Change-Id: Ia93a466fdc20157a7d6048903e359fe8717ecb8f
GitHub-Last-Rev: 0a9bc5cab0ec2ac8d76ede3722c8813372ac771e
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>
Change-Id: Id3b1f44de5aa47372d59696523b4379e1fbfc11c
GitHub-Last-Rev: 571d01f8052cef27bd5f91a5e95c0735ddf2e327
GitHub-Pull-Request: golang/go#53235
Reviewed-on: https://go-review.googlesource.com/c/go/+/410415 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Russ Cox [Wed, 26 Jan 2022 21:42:05 +0000 (16:42 -0500)]
doc: update Go memory model
Following discussion on #47141, make the following changes:
- Document Go's overall approach.
- Document that multiword races can cause crashes.
- Document happens-before for runtime.SetFinalizer.
- Document (or link to) happens-before for more sync types.
- Document happens-before for sync/atomic.
- Document disallowed compiler optimizations.
See also https://research.swtch.com/gomm for background.
Fixes #50859.
Change-Id: I17d837756a77f4d8569f263489c2c45de20a8778
Reviewed-on: https://go-review.googlesource.com/c/go/+/381315 Reviewed-by: Ian Lance Taylor <iant@google.com>
Russ Cox [Fri, 3 Jun 2022 20:00:16 +0000 (16:00 -0400)]
io: revert: add an Err field to LimitedReader
We are having a hard time deciding the exact semantics
of the Err field, and we need to ship the beta.
So revert the Err field change; it can wait for Go 1.20.
For #51115.
This reverts CL 396215.
Change-Id: I7719386567d3da10a614058a11f19dbccf304b4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/410133
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Michael Anthony Knyszek [Thu, 2 Jun 2022 21:26:49 +0000 (21:26 +0000)]
runtime: track total idle time for GC CPU limiter
Currently the GC CPU limiter only tracks idle GC work time. However, in
very undersubscribed situations, it's possible that all this extra idle
time prevents the enabling of the limiter, since it all gets account for
as mutator time. Fix this by tracking all idle time via pidleget and
pidleput. To support this, pidleget and pidleput also accept and return
"now" parameters like the timer code.
While we're here, let's clean up some incorrect assumptions that some of
the scheduling code makes about "now."
Fixes #52890.
Change-Id: I4a97893d2e5ad1e8c821f8773c2a1d449267c951
Reviewed-on: https://go-review.googlesource.com/c/go/+/410122 Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Michael Anthony Knyszek [Thu, 2 Jun 2022 19:06:27 +0000 (19:06 +0000)]
runtime: only use CPU time from the current window in the GC CPU limiter
Currently the GC CPU limiter consumes CPU time from a few pools, but
because the events that flush to those pools may overlap, rather than be
strictly contained within, the update window for the GC CPU limiter, the
limiter's accounting is ultimately sloppy.
This sloppiness complicates accounting for idle time more completely,
and makes reasoning about the transient behavior of the GC CPU limiter
much more difficult.
To remedy this, this CL adds a field to the P struct that tracks the
start time of any in-flight event the limiter might care about, along
with information about the nature of that event. This timestamp is
managed atomically so that the GC CPU limiter can come in and perform a
read of the partial CPU time consumed by a given event. The limiter also
updates the timestamp so that only what's left over is flushed by the
event itself when it completes.
The end result of this change is that, since the GC CPU limiter is aware
of all past completed events, and all in-flight events, it can much more
accurately collect the CPU time of events since the last update. There's
still the possibility for skew, but any leftover time will be captured
in the following update, and the magnitude of this leftover time is
effectively bounded by the update period of the GC CPU limiter, which is
much easier to consider.
One caveat of managing this timestamp-type combo atomically is that they
need to be packed in 64 bits. So, this CL gives up the top 3 bits of the
timestamp and places the type information there. What this means is we
effectively have only a 61-bit resolution timestamp. This is fine when
the top 3 bits are the same between calls to nanotime, but becomes a
problem on boundaries when those 3 bits change. These cases may cause
hiccups in the GC CPU limiter by not accounting for some source of CPU
time correctly, but with 61 bits of resolution this should be extremely
rare. The rate of update is on the order of milliseconds, so at worst
the runtime will be off of any given measurement by only a few
CPU-milliseconds (and this is directly bounded by the rate of update).
We're probably more inaccurate from the fact that we don't measure real
CPU time but only approximate it.
For #52890.
Change-Id: I347f30ac9e2ba6061806c21dfe0193ef2ab3bbe9
Reviewed-on: https://go-review.googlesource.com/c/go/+/410120 Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Michael Anthony Knyszek [Fri, 3 Jun 2022 19:15:24 +0000 (19:15 +0000)]
cmd/compile/internal/escape: escape values with >PtrSize alignment
After CL 381317 there exist values that may have an alignment greater
than the pointer size for that platform. Specifically, atomic.{Ui|I}nt64
may be aligned to 8 bytes on a 32-bit platform. If such a value, or
a container for the value, gets stack-allocated, it's possible that it
won't be aligned correctly, because the maximum alignment we enforce on
stacks is governed by the pointer size. Changing that would be a
significant undertaking, so just escape these values to the heap
instead, where we're sure they'll actually be aligned correctly.
Change is by rsc@, I'm just shepherding it through code review.
For #50860.
Change-Id: I51669561c0a13ecb84f821020e144c58cb528418
Reviewed-on: https://go-review.googlesource.com/c/go/+/410131
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Michael Matloob [Tue, 5 Apr 2022 22:47:23 +0000 (18:47 -0400)]
cmd/go: changes to use modindex
This CL makes the changes to actually use the module index when loading
packages and instead of scanning their directories to see if they
contain go files or to extract imports.
Change-Id: I70106181cf64d6fd5a416644ba518b6b90030e0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/403778 Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Michael Matloob [Tue, 5 Apr 2022 22:47:23 +0000 (18:47 -0400)]
cmd/go: add functions to read index file
The data read is used for three primary functions: ImportPackage,
IsDirWithGoFiles and ScanDir. Functions are also provided to get this
information from the intermediate package representation to cache
the information from reads for non-indexed packages.
eric fang [Thu, 2 Jun 2022 06:54:50 +0000 (06:54 +0000)]
cmd/link: fix TestLargeText
Do not need to add single quotes '' when passing the parameter value of
the -ldflags option, otherwise the following error will be reported:
invalid value "'-linkmode=external'" for flag -ldflags: parameter may
not start with quote character.
Change-Id: I322fa7079ac24c8a68d9cb0872b0a20dbc4893d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/410074 Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
Ian Lance Taylor [Thu, 2 Jun 2022 16:58:42 +0000 (09:58 -0700)]
archive/zip: use bufio.Reset rather than NewReader
A clean up for CL 408734, suggested by Joe Tsai.
Change-Id: Ida9db0b8d31785d5640938c286c9c6c82c27f457
Reviewed-on: https://go-review.googlesource.com/c/go/+/410154
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Christian Stewart [Wed, 1 Jun 2022 20:52:12 +0000 (20:52 +0000)]
cmd/dist: use gohostarch for ssa rewrite check
Fix a build failure when bootstrapping the Go compiler with go-bootstrap 1.4
while the environment contains GOARCH=riscv64.
Building Go toolchain1 using go-1.4-bootstrap-20171003.
src/cmd/compile/internal/ssa/rewriteRISCV64.go:4814
invalid operation: y << x (shift count type int64, must be unsigned integer)
Ian Lance Taylor [Wed, 25 May 2022 21:12:29 +0000 (14:12 -0700)]
archive/zip: if non-zero base offset fails, fall back to zero
This permits us to read files that earlier Go releases could read.
It is also compatible with other zip programs.
Change-Id: I7e2999f1073c4db5ba3f51f92681e0b149d55b3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/408734
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Lukas Joisten [Tue, 8 Mar 2022 11:21:00 +0000 (12:21 +0100)]
encoding/json: mention SyntaxError in Unmarshal doc comment
Change-Id: I71c9d9ef9d21a7ae9466d8c7b283fdfbba01f5a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/390734
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Joseph Tsai <joetsai@digital-static.net> Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Cuong Manh Le [Mon, 30 May 2022 14:34:01 +0000 (21:34 +0700)]
cmd/compile: fix wrong unsafe.Offsetof evaluation inside generic function
For instantiated generic functions, all implicit dot operations are
resolved. Thus unsafe.Offsetof may calculating the offset against the
wrong base selector.
To fix it, we must remove any implicit dot operations to find the first
non-implicit one, which is the right base selector for calculating the
offset.
Fixes #53137
Change-Id: I38504067ce0f274615b306edc8f7d7933bdb631a
Reviewed-on: https://go-review.googlesource.com/c/go/+/409355
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
Than McIntosh [Tue, 17 May 2022 12:17:38 +0000 (08:17 -0400)]
cmd/link: call syscall.FlushFileBuffers on outbuf Unmap
In the windows version of OutBuf.munmap, call syscall.FlushFileBuffers
after the call to syscall.FlushViewOfFile, on the theory that this
will help flush all associated meta-data for the file the linker is
writing.
Updates #44817.
Change-Id: Ibff7d05008a91eeed7634d2760153851e15e1c18
Reviewed-on: https://go-review.googlesource.com/c/go/+/406814 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Brad Fitzpatrick [Sat, 28 May 2022 21:06:43 +0000 (14:06 -0700)]
net: permit use of Resolver.PreferGo, netgo on Windows and Plan 9
This reverts commit CL 401754 (440c9312c8) which reverted CL 400654,
thus reapplying CL 400654, re-adding the func init() { netGo = true }
to cgo_stub.go CL 400654 had originally removed (mistakenly during
development?) that had broken the darwin nocgo builder.
Fixes #33097
Change-Id: I90f59746d2ceb6b5d2bd832c9fc90068f8ff7417
Reviewed-on: https://go-review.googlesource.com/c/go/+/409234 Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Keith Randall <khr@google.com>
Michael Anthony Knyszek [Fri, 27 May 2022 18:14:58 +0000 (18:14 +0000)]
test/heapsampling.go: slow down allocation rate and reduce iterations
As far as I can tell, this test suffers from #52433. For some reason,
this seems to become more of a problem on the windows/386 than anywhere
else. This CL is an attempt at a mitigation by slowing down the
allocation rate by inserting runtime.Gosched call in the inner loop. It
also cuts the iteration count which should help too (as less memory is
allocated in total), but the main motivation is to make sure the test
doesn't take too long to run.
Michael Anthony Knyszek [Wed, 25 May 2022 22:51:21 +0000 (22:51 +0000)]
runtime: cancel mark and scavenge assists if the limiter is enabled
This change forces mark and scavenge assists to be cancelled early if
the limiter is enabled. This avoids goroutines getting stuck in really
long assists if the limiter happens to be disabled when they first come
into the assist. This can get especially bad for mark assists, which, in
dire situations, can end up "owing" the GC a really significant debt.
For #52890.
Change-Id: I4bfaa76b8de3e167d49d2ffd8bc2127b87ea566a
Reviewed-on: https://go-review.googlesource.com/c/go/+/408816
Run-TryBot: Michael Knyszek <mknyszek@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Koichi Shiraishi [Wed, 25 May 2022 13:39:37 +0000 (22:39 +0900)]
doc/go1.19: fix strconv.Quote pkg link
For #51400.
Change-Id: I122b3a58e5fbaaa8ceb5b013e8e392f4bcbbd2e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/408495 Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Cherry Mui [Wed, 25 May 2022 14:15:28 +0000 (10:15 -0400)]
runtime: don't inspect the stack for delayed signals from TSAN
Cgo TSAN (not the Go race detector) intercepts signals and calls
the signal handler at a later time. When the signal handler is
called, the memory may have changed, but the signal context
remains old. As the signal context and the memory don't match, it
is unsafe to unwind the stack from the signal PC and SP. We have
to ignore the signal.
It is probably also not safe to do async preemption, which relies
on the signal PC, and inspects and even writes to the stack (for
call injection).
We also inspect the stack for fatal signals (e.g. SIGSEGV), but I
think they are not delayed. For other signals we don't inspect
the stack, so they are probably fine.
Fixes #27540.
Change-Id: I5c80a7512265b8ea4a91422954dbff32c6c3a0d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/408218
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
Guoqi Chen [Thu, 26 May 2022 11:38:02 +0000 (19:38 +0800)]
internal/cpu: fix cpu cacheLineSize for loong64
We choose 64 because the L1 Dcache of Loongson 3A5000 CPU is
4-way 256-line 64-byte-per-line.
Change-Id: Ifb9a9f993dd6f75b5adb4ff6e4d93e945b1b2a98
Reviewed-on: https://go-review.googlesource.com/c/go/+/408854
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Alex Rakoczy <alex@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
WANG Xuerui [Sat, 21 May 2022 13:05:00 +0000 (21:05 +0800)]
syscall: update linux/loong64 kernel ABI, emulate fstatat with statx
The linux/loong64 kernel ABI has changed a little since the inception
of the Go port; most notably fstat and fstatat are being removed [1],
leaving only statx as the stat mechanism. Fortunately the structs are
easy enough to translate, and we now exclusively use statx across the
board on loong64 for best compatibility with past and future kernels
(due to the architecture's young age, statx is always available).
In wiring up the statx calls, it turned out the linux/loong64 syscall
definitions were out-of-date, so the generation script received some
tweaking as well.
Change-Id: Ifebb9ab9fef783683e453fa331d623575e824a48
Reviewed-on: https://go-review.googlesource.com/c/go/+/407694
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Alex Rakoczy <alex@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Motiejus Jakštys [Fri, 20 May 2022 07:32:48 +0000 (07:32 +0000)]
cmd/dist: support spaces and quotes in CC
As of CL 334732 `go build` can accept `$CC` with spaces and quotes,
which lets us easily use `zig cc` as the C compiler, or easily pass
extra compiler parameters:
```
CC="zig cc" go build <...>
CC="clang-13 -v" go build <...>
CC="zig cc -Wl,--print-gc-sections" go build <...>
```
However, the same does not apply for building go itself:
```
$ CC="zig cc" ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.18.2 linux/amd64)
go tool dist: cannot invoke C compiler "zig cc": exec: "zig cc": executable file not found in $PATH
Go needs a system C compiler for use with cgo.
To set a C compiler, set CC=the-compiler.
To disable cgo, set CGO_ENABLED=0.
```
With this change Go can be built directly with `zig cc` (the linker arg
will disappear with CL 405414):
```
$ CC="zig cc -Wl,--no-gc-sections" ./make.bash
Building Go cmd/dist using /usr/local/go. (go1.18.2 linux/amd64)
Building Go toolchain1 using /usr/local/go.
Building Go bootstrap cmd/go (go_bootstrap) using Go toolchain1.
Building Go toolchain2 using go_bootstrap and Go toolchain1.
Building Go toolchain3 using go_bootstrap and Go toolchain2.
Building packages and commands for linux/amd64.
---
Installed Go for linux/amd64 in /home/motiejus/code/go
Installed commands in /home/motiejus/code/go/bin
$ ../bin/go version
go version devel go1.19-811f1913a8 Thu May 19 09:44:49 2022 +0300 linux/amd64
```
Fixes #52990
Change-Id: I66b3525d47db488d3c583c1aee3af78060fd5a38
GitHub-Last-Rev: ecc70d722406f0c7d0c1930c872db392e80e7cf5
GitHub-Pull-Request: golang/go#52991
Reviewed-on: https://go-review.googlesource.com/c/go/+/407216 Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Alex Rakoczy <alex@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Ian Lance Taylor [Thu, 26 May 2022 17:52:28 +0000 (17:52 +0000)]
Revert "reflect: deprecate (Slice|String)Header"
This reverts CL 401434.
Reason for revert: We should't deprecate these without a replacement.
Fixes #53079
Change-Id: I5515b03e39787d4e528a98c733cdb643b86b17ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/408815 Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Koichi Shiraishi [Wed, 25 May 2022 13:34:37 +0000 (22:34 +0900)]
doc/go1.19: fix reflect pkg link and "a" section
Change-Id: Ica05b2b699d8f6383c713460a473ccf753bc78c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/408494 Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Ian Lance Taylor [Wed, 25 May 2022 22:41:59 +0000 (15:41 -0700)]
runtime/internal/syscall: use correct result names for loong64
Fixes "GOARCH=loong64 go vet runtime/internal/syscall"
Change-Id: I5879eec3ff07b0c69a5a8ac8e854733261e98fbf
Reviewed-on: https://go-review.googlesource.com/c/go/+/408695 Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Motiejus Jakštys [Wed, 25 May 2022 02:55:34 +0000 (02:55 +0000)]
cmd/cgo: use --no-gc-sections if available
zig cc passes `--gc-sections` to the underlying linker, which then
causes undefined symbol errors when compiling with cgo but without C
code. Add `-Wl,--no-gc-sections` to make it work with zig cc. Minimal
example:
**main.go**
package main
import _ "runtime/cgo"
func main() {}
Run (works after the patch, doesn't work before):
CC="zig cc" go build main.go
Among the existing code, `src/runtime/testdata/testprognet` fails to
build:
src/runtime/testdata/testprognet$ CC="zig cc" go build .
net(.text): relocation target __errno_location not defined
net(.text): relocation target getaddrinfo not defined
net(.text): relocation target freeaddrinfo not defined
net(.text): relocation target gai_strerror not defined
runtime/cgo(.text): relocation target stderr not defined
runtime/cgo(.text): relocation target fwrite not defined
runtime/cgo(.text): relocation target vfprintf not defined
runtime/cgo(.text): relocation target fputc not defined
runtime/cgo(.text): relocation target abort not defined
runtime/cgo(.text): relocation target pthread_create not defined
runtime/cgo(.text): relocation target nanosleep not defined
runtime/cgo(.text): relocation target pthread_detach not defined
runtime/cgo(.text): relocation target stderr not defined
runtime/cgo(.text): relocation target strerror not defined
runtime/cgo(.text): relocation target fprintf not defined
runtime/cgo(.text): relocation target abort not defined
runtime/cgo(.text): relocation target pthread_mutex_lock not defined
runtime/cgo(.text): relocation target pthread_cond_wait not defined
runtime/cgo(.text): relocation target pthread_mutex_unlock not defined
runtime/cgo(.text): relocation target pthread_cond_broadcast not defined
runtime/cgo(.text): relocation target malloc not defined
With the patch both examples build as expected.
@ianlancetaylor suggested:
> It would be fine with me if somebody wants to send a cgo patch that
passes -Wl,--no-gc-sections, with a fallback if that option is not
supported.
... and this is what we are doing. Tested with zig
0.10.0-dev.2252+a4369918b
This is a continuation of CL 405414: the original one broke AIX and iOS
builds. To fix that, added `unknown option` to the list of strings
under lookup.
Fixes #52690
Change-Id: Id6743e1e759a02627b0fc6d2ac89bb69b706d04c
GitHub-Last-Rev: 86f227a14e9f326f1b461b641e4865bc4dc70780
GitHub-Pull-Request: golang/go#53028
Reviewed-on: https://go-review.googlesource.com/c/go/+/407814 Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Ian Lance Taylor [Wed, 25 May 2022 02:51:37 +0000 (19:51 -0700)]
go/printer: if comment gets formatted away, don't squash
We were dropping the preceding whitespace.
Fixes #53059
Change-Id: Ide0d6a76c463a7481ec4883a8568f7f7b5e87e9f
Reviewed-on: https://go-review.googlesource.com/c/go/+/408394 Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Damien Neil [Tue, 24 May 2022 23:13:42 +0000 (16:13 -0700)]
net: add even more timing slop for TestDialParallel
This test expects dials of a closed port to complete in about the same
amount of time: an initial probe value +/- 20%. Reduce test flakes on
Windows by increasing the slop to +/- 50% of the original value.
Fixes #52173
Change-Id: I813492c36aca2b0264b3b5b8c96e8bf97193af76
Reviewed-on: https://go-review.googlesource.com/c/go/+/408354
Run-TryBot: Damien Neil <dneil@google.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
path/filepath: do not remove prefix "." when following path contains ":".
Fixes #52476
Change-Id: I9eb72ac7dbccd6322d060291f31831dc389eb9bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/401595
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
David Chase [Mon, 16 May 2022 21:50:31 +0000 (17:50 -0400)]
cmd/compile: catch pointless recursion on function types
If a function type has no type parameters, note when it
is visited and do not recur. (It must be visited
at least once because of closures and their associated
types occurring in a generic context).
Fixes #51832.
Change-Id: Iee20612ffd0a03b838b9e59615f4a0206fc8940b
Reviewed-on: https://go-review.googlesource.com/c/go/+/406714 Reviewed-by: Keith Randall <khr@google.com>
Sean Liao [Mon, 23 May 2022 22:52:21 +0000 (23:52 +0100)]
builtin: clarify effect of close on receive
Fixes #53041
Change-Id: If6580c8f0f14edfdc297d3239a7767ce0570ff79
Reviewed-on: https://go-review.googlesource.com/c/go/+/407975 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Robert Findley [Sat, 7 May 2022 19:50:05 +0000 (15:50 -0400)]
go/types, types2: remove redundant calls to Named.resolve
The resolved status of a Named type should be owned by its API, and
callers should access resolved data via methods. Remove several
instances where Named.resolve is explicitly invoked, only to be followed
by a method that also resolves.
Also make two minor cleanups:
- Remove the tparams parameter to Checker.newNamed, as it was unused.
- Include position information when assertions fail, so that one doesn't
need to go digging in the panicking stack to find the assertion
location.
Updates #52728
Change-Id: Icbe8c89e9cfe02d60af7d9ba907eaebe1f00193e
Reviewed-on: https://go-review.googlesource.com/c/go/+/404874
Run-TryBot: Robert Findley <rfindley@google.com> Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>