]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
12 months agoslices: add sorting and comparison functions
Eli Bendersky [Fri, 19 May 2023 17:10:21 +0000 (10:10 -0700)]
slices: add sorting and comparison functions

Now that the `cmp` package exists, sorting and comparison functions from
`x/exp/slices` can be ported to the standard library, using the
`cmp.Ordered` type and the `cmp.Less` and `cmp.Compare` functions.

This move also includes adjustments to the discussions in #60091 w.r.t.
NaN handling and cmp vs. less functions, and adds Min/Max functions.
The final API is taken from
https://github.com/golang/go/issues/60091#issuecomment-1553850782

Updates #60091

Change-Id: Id7e6c88035b60d4ddd0c48dd82add8e8bc4e22d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/496078
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Run-TryBot: Eli Bendersky‎ <eliben@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agogo/types, types2: enable interface inference
Robert Griesemer [Tue, 23 May 2023 21:32:41 +0000 (14:32 -0700)]
go/types, types2: enable interface inference

This CL sets enableInterfaceInference to true.
If problems arise due to this during the freeze, revert this CL.

Fixes #41176.
Fixes #57192.

Change-Id: I881ea6842e9c1101b24d9780323c6af365a40d3e
Reviewed-on: https://go-review.googlesource.com/c/go/+/497657
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
12 months agogo/types, types2: consider shared methods when unifying against interfaces
Robert Griesemer [Tue, 23 May 2023 21:29:12 +0000 (14:29 -0700)]
go/types, types2: consider shared methods when unifying against interfaces

When unifying two types A and B where one or both of them are
interfaces, consider the shared method signatures in unification.

1) If a defined interface (an interface with a type name) is unified
   with another (defined) interface, currently they must originate
   in the same type declaration (same origin) for unification to
   succeed. This is more restrictive than necessary for assignments:
   when interfaces are assigned to each other, corresponding methods
   must match, but the interfaces don't have to be identical.
   In unification, we don't know which direction the assignment is
   happening (or if we have an assignment in the first place), but
   in any case one interface must implement the other. Thus, we
   check that one interface has a subset of the methods of the other
   and that corresponding method signatures unify.
   The assignment or instantiation may still not be possible but that
   will be checked when instantiation and parameter passing is checked.
   If two interfaces are compared as part of another type during
   unification, the types must be equal. If they are not, unifying
   a method subset may still succeed (and possibly produce more type
   arguments), but that is ok: again, subsequent instantiation and
   assignment will fail if the types are indeed not identical.

2) In a non-interface type is unified with an interface, currently
   unification fails. If this unification is a consequence of an
   assignment (parameter passing), this is again too restrictive:
   the non-interface type must only implement the interface (possibly
   among other type set requirements). In any case, all methods of the
   interface type must be present in the non-interface type and unify
   with the corresponding interface methods. If they don't, unification
   will fail either way. If they do, we may infer additional type
   arguments. Again, the resulting types may still not be correct but
   that will be determined by the instantiation and parameter passing
   or assignment checks. If the non-interface type and the interface
   type appear as component of another type, unification may now
   produce additional type arguments. But that is again ok because the
   respective types won't pass instantiation or assignment checks since
   they are different types.

This CL introduces a new unifier flag, enableInterfaceInference, to
enable this new behavior. It is currently disabled.

For #60353.
For #41176.
For #57192.

Change-Id: I983d0ad5f043c7fe9d377dbb95f6b9342f36f45f
Reviewed-on: https://go-review.googlesource.com/c/go/+/497656
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

12 months agodebug/elf: define R_PPC64_REL24_P9NOTOC
Paul E. Murphy [Mon, 22 May 2023 15:38:12 +0000 (10:38 -0500)]
debug/elf: define R_PPC64_REL24_P9NOTOC

This relocation is not (yet?) defined in ELFv2, but has been added to
gnu gas a couple years ago. It is the same reloc as
R_PPC64_REL24_NOTOC, but hints power10 instructions should not be
emitted.

See binutils commit 7aba54da426b9999085d8f84e7896b8afdbb9ca6.

Fixes #60348

Change-Id: Ie953cd7bf1ffc621b498d4dbebb5de1231833c8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/496918
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
12 months agoruntime: move pinner variable into inner loop for benchmarks
Michael Anthony Knyszek [Tue, 23 May 2023 19:17:51 +0000 (19:17 +0000)]
runtime: move pinner variable into inner loop for benchmarks

Currently the pinner is created outside of the benchmarking loop.
However, this means that we get to reuse the same pinner for each loop;
in general, users are expected to create a pinner for a e.g. a cgo
call and then that variable will expire with the frame it lives in. (If
they can reuse the variable, great! However, I don't expect that to be
common.)

In essence, this benchmarks a harder case. It's not more right or wrong
than the previous version, but the fact that it's a slightly harder case
(that still mostly captures what the original version was capturing) is
useful.

Change-Id: I94987127f54d7bfecd7b8e6a5e632631ea57ad24
Reviewed-on: https://go-review.googlesource.com/c/go/+/497616
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

12 months agoRevert "go/types, types2: consider shared methods when unifying against interfaces"
Robert Griesemer [Tue, 23 May 2023 21:03:28 +0000 (21:03 +0000)]
Revert "go/types, types2: consider shared methods when unifying against interfaces"

This reverts commit c4afec232cec72ce030139ae2772450fad89f188.

Reason for revert: submitted accidentally via auto-commit

Change-Id: Idbfd90a4f1c2d582d86fc8aa45e037c406adbd40
Reviewed-on: https://go-review.googlesource.com/c/go/+/497655
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>

12 months agogo/types, types2: consider shared methods when unifying against interfaces
Robert Griesemer [Fri, 19 May 2023 15:28:24 +0000 (08:28 -0700)]
go/types, types2: consider shared methods when unifying against interfaces

When unifying two types A and B where one or both of them are
interfaces, consider the shared method signatures in unification.

1) If a defined interface (an interface with a type name) is unified
   with another (defined) interface, currently they must originate
   in the same type declaration (same origin) for unification to
   succeed. This is more restrictive than necessary for assignments:
   when interfaces are assigned to each other, corresponding methods
   must match, but the interfaces don't have to be identical.
   In unification, we don't know which direction the assignment is
   happening (or if we have an assignment in the first place), but
   in any case one interface must implement the other. Thus, we
   check that one interface has a subset of the methods of the other
   and that corresponding method signatures unify.
   The assignment or instantiation may still not be possible but that
   will be checked when instantiation and parameter passing is checked.
   If two interfaces are compared as part of another type during
   unification, the types must be equal. If they are not, unifying
   a method subset may still succeed (and possibly produce more type
   arguments), but that is ok: again, subsequent instantiation and
   assignment will fail if the types are indeed not identical.

2) In a non-interface type is unified with an interface, currently
   unification fails. If this unification is a consequence of an
   assignment (parameter passing), this is again too restrictive:
   the non-interface type must only implement the interface (possibly
   among other type set requirements). In any case, all methods of the
   interface type must be present in the non-interface type and unify
   with the corresponding interface methods. If they don't, unification
   will fail either way. If they do, we may infer additional type
   arguments. Again, the resulting types may still not be correct but
   that will be determined by the instantiation and parameter passing
   or assignment checks. If the non-interface type and the interface
   type appear as component of another type, unification may now
   produce additional type arguments. But that is again ok because the
   respective types won't pass instantiation or assignment checks since
   they are different types.

This CL introduces a new Config flag, EnableInterfaceInference, to
enable this new behavior. If not set, unification remains unchanged.
To be able to test the flag durign unification, a *Checker is passed
and stored with the unifier.

For #60353.
Fixes #41176.
Fixes #57192.

Change-Id: I6b167a9afa378d0682e9b101d9d86f5777308af7
Reviewed-on: https://go-review.googlesource.com/c/go/+/497015
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

12 months agofmt,math/big,net/url: fixes to old Benchmarks
Egon Elbre [Mon, 22 May 2023 19:40:47 +0000 (22:40 +0300)]
fmt,math/big,net/url: fixes to old Benchmarks

b.ResetTimer used to also stop the timer, however it does not anymore.
These benchmarks hadn't been fixed and as a result ended up measuring
some additional things.

Also, make some for loops more conventional.

Change-Id: I76ca68456d85eec51722a80587e5b2c9f5d836a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/496996
Run-TryBot: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

12 months agolog/slog: JSONHandler doesn't use special source format
Sean Liao [Sun, 21 May 2023 14:34:43 +0000 (15:34 +0100)]
log/slog: JSONHandler doesn't use special source format

Fixes #60329

Change-Id: Idb19da4830fa14c459bedbf143d550ce7c1dfdbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/496815
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/internal/goobj: update builtin list
Guoqi Chen [Thu, 20 Apr 2023 04:22:27 +0000 (12:22 +0800)]
cmd/internal/goobj: update builtin list

Change-Id: I8a903b76d80f451b498b145b14c97f96191e05f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/486775
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoencoding: document when marshaling methods can be added
Sean Liao [Sun, 21 May 2023 14:16:48 +0000 (15:16 +0100)]
encoding: document when marshaling methods can be added

Fixes #10275

Change-Id: I2b3d54f3eb0f85d65324ddc3c3b2a797d42a16c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/496537
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
12 months agoos: avoid second fcntl syscall in NewFile on unix
Tobias Klauser [Mon, 22 May 2023 18:37:05 +0000 (20:37 +0200)]
os: avoid second fcntl syscall in NewFile on unix

CL 494915 introduced an additional fcntl(F_GETFL) syscall to determine
whether the file is in append-only mode. The existing unix.IsNonblock
call also issues an fcntl(F_GETFL) syscall. The two can be combined and
both the append-only mode and the non-blocking flags can be determined
from that syscall's result.

Change-Id: I915589ed94e079f6abaa2fd0032ef01f78698f7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/497075
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>

12 months agoruntime: remove unused _F_{GET,SET}FL constants on solaris and openbsd
Tobias Klauser [Mon, 22 May 2023 18:55:07 +0000 (20:55 +0200)]
runtime: remove unused _F_{GET,SET}FL constants on solaris and openbsd

These are only needed on aix and darwin.

Change-Id: Iea67e4631197359f2bec346ef7d7b723ca23646e
Reviewed-on: https://go-review.googlesource.com/c/go/+/497076
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agogo/types: update TestStdlib to type-check concurrently
Rob Findley [Fri, 14 Apr 2023 00:52:53 +0000 (20:52 -0400)]
go/types: update TestStdlib to type-check concurrently

In order to have some test coverage of concurrent use of the go/types
APIs, update the Stdlib test to type-check concurrently. In combination
with non-deterministic ordering, this should hopefully provide moderate
test coverage of concurrent use.

Also, remove the arbitrary 10ms timeout in short mode, in favor of
simply not running.

After this change, TestStdlib went from taking 16s on my laptop to 2s,
in part because of the parallelism and in part because we are no longer
type-checking twice (once for the import er, once for the test).

Fixes golang/go#47729

Change-Id: Ie49743947ab2d5aec051c3d09ce045acf5b94ad4
Reviewed-on: https://go-review.googlesource.com/c/go/+/484540
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>

12 months agocmd/internal/objabi: regenerate RelocType strings
Ian Lance Taylor [Tue, 23 May 2023 18:54:44 +0000 (11:54 -0700)]
cmd/internal/objabi: regenerate RelocType strings

Change-Id: I6c9a8decb5b261be4548f148739b44e8860c5f8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/497595
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
12 months agocmd/compile: avoid slicebytetostring call in len(string([]byte))
Cuong Manh Le [Tue, 23 May 2023 04:23:48 +0000 (11:23 +0700)]
cmd/compile: avoid slicebytetostring call in len(string([]byte))

Change-Id: Ie04503e61400a793a6a29a4b58795254deabe472
Reviewed-on: https://go-review.googlesource.com/c/go/+/497276
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
12 months agoruntime/metrics: refactor CPU stats accumulation
Michael Anthony Knyszek [Thu, 18 May 2023 16:35:11 +0000 (16:35 +0000)]
runtime/metrics: refactor CPU stats accumulation

Currently the CPU stats are only updated once every mark termination,
but for writing robust tests, it's often useful to force this update.
Refactor the CPU stats accumulation out of gcMarkTermination and into
its own function. This is also a step toward real-time CPU stats.

While we're here, fix some incorrect documentation about dedicated GC
CPU time.

For #59749.
For #60276.

Change-Id: I8c1a9aca45fcce6ce7999702ae4e082853a69711
Reviewed-on: https://go-review.googlesource.com/c/go/+/487215
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

12 months agoruntime: fix usage of stale "now" value for netpolling Ms
Michael Anthony Knyszek [Thu, 18 May 2023 15:51:57 +0000 (15:51 +0000)]
runtime: fix usage of stale "now" value for netpolling Ms

Currently pidleget gets passed "now" from before the M goes into
netpoll, resulting in incorrect accounting of idle CPU time.
lastpoll is also stored with a stale "now": the mistake was added in the
same CL it was added for pidleget.

Recompute "now" after returning from netpoll.

Also, start tracking idle time on js/wasm at all.

Credit to Rhys Hiltner for the test case.

Fixes #60276.

Change-Id: I5dd677471f74c915dfcf3d01621430876c3ff307
Reviewed-on: https://go-review.googlesource.com/c/go/+/496183
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
12 months agoruntime/metrics: add /gc/scan/total:bytes
Felix Geisendörfer [Tue, 23 May 2023 10:35:48 +0000 (12:35 +0200)]
runtime/metrics: add /gc/scan/total:bytes

For #56857

Change-Id: I10dbc5db506c95b7578c2b6baf051a351f68bb2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/497576
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

12 months agoruntime/metrics: add /gc/scan/heap:bytes
Felix Geisendörfer [Tue, 23 May 2023 10:35:48 +0000 (12:35 +0200)]
runtime/metrics: add /gc/scan/heap:bytes

For #56857

Change-Id: If3b962f575c33b2cc29f89e33c7aafb476d98ce9
Reviewed-on: https://go-review.googlesource.com/c/go/+/497575
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
12 months agoruntime/metrics: add /gc/scan/globals:bytes
Felix Geisendörfer [Tue, 23 May 2023 10:35:48 +0000 (12:35 +0200)]
runtime/metrics: add /gc/scan/globals:bytes

For #56857

Change-Id: I748fd2a33ee76d9a83ea42f2ebf6d9edda243301
Reviewed-on: https://go-review.googlesource.com/c/go/+/497320
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime/metrics: add /gc/scan/stack:bytes
Felix Geisendörfer [Tue, 23 May 2023 10:30:43 +0000 (12:30 +0200)]
runtime/metrics: add /gc/scan/stack:bytes

For #56857

Change-Id: I58187d7c4112b35951014ab14f2969bed7f4c8e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/497319
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime/metrics: add /gc/gogc:percent
Felix Geisendörfer [Tue, 23 May 2023 09:26:22 +0000 (11:26 +0200)]
runtime/metrics: add /gc/gogc:percent

For #56857

Change-Id: I7e7d2ea3e6ab59291a4cd867c680605ad75bd21f
Reviewed-on: https://go-review.googlesource.com/c/go/+/497317
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
12 months agoruntime/metrics: add /gc/gomemlimit:bytes
Felix Geisendörfer [Tue, 23 May 2023 09:16:28 +0000 (11:16 +0200)]
runtime/metrics: add /gc/gomemlimit:bytes

For #56857

Change-Id: I184d752cc615874ada3d0dbc6ed1bf72c8debd0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/497316
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
12 months agoruntime: symbolize wrappers as a last resort in race tracebacks
Austin Clements [Mon, 22 May 2023 23:12:54 +0000 (19:12 -0400)]
runtime: symbolize wrappers as a last resort in race tracebacks

CL 466099 rewrote stack symbolization in race reports. Prior to this
CL, physical frames consisting entirely of wrapper logical frame would
print the wrapper, even though in other cases we try to avoid
printing wrappers. CL 466099 unintentionally changed this behavior and
now physical frames consisting entirely of wrapper frames instead fail
to symbolize and print "??()".

Fix this by taking the outermost wrapper frame if the entire logical
frame expansion consists of wrappers.

Fixes #60245.

Change-Id: I13de8857e508b757ea10d1fc7a47258d7fddbfdb
Reviewed-on: https://go-review.googlesource.com/c/go/+/497235
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Auto-Submit: Austin Clements <austin@google.com>

12 months agoruntime/metrics: add /gc/heap/live:bytes
Felix Geisendörfer [Mon, 21 Nov 2022 21:41:54 +0000 (21:41 +0000)]
runtime/metrics: add /gc/heap/live:bytes

For #56857

Change-Id: I0622af974783ab435e91b9fb3c1ba43f256ee4ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/497315
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
12 months agocmd/go: convert semver.IsValid to gover.ModIsValid
Russ Cox [Tue, 23 May 2023 14:29:47 +0000 (10:29 -0400)]
cmd/go: convert semver.IsValid to gover.ModIsValid

Change-Id: Id584c4bd6d1c12fd085414188bc7e7ca08164c04
Reviewed-on: https://go-review.googlesource.com/c/go/+/497416
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

12 months agocmd/go: convert semver.Compare to gover.ModCompare
Russ Cox [Tue, 23 May 2023 17:22:45 +0000 (13:22 -0400)]
cmd/go: convert semver.Compare to gover.ModCompare

This sets up for introducing the 'go' and 'toolchain' modules
but should be a no-op by itself.

For #57001.

Change-Id: I2e02b5d417f1edd4f4653b101e4975fe23093f66
Reviewed-on: https://go-review.googlesource.com/c/go/+/497456
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>

12 months agocmd/go: clean up old readEnvFile code
Russ Cox [Tue, 23 May 2023 17:42:22 +0000 (13:42 -0400)]
cmd/go: clean up old readEnvFile code

Now that cfg.CanGetenv does the right thing, we don't need a separate
readEnvFile in 'go env'.

Change-Id: I187c8615ad074ba132516bcf499f82877a32d5e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/497457
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/compile: implement min/max builtins
Matthew Dempsky [Fri, 19 May 2023 00:16:03 +0000 (17:16 -0700)]
cmd/compile: implement min/max builtins

Updates #59488.

Change-Id: I254da7cca071eeb5af2f8aecdcd9461703fe8677
Reviewed-on: https://go-review.googlesource.com/c/go/+/496257
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
12 months agocmd/go: set default GOTOOLCHAIN in GOROOT/go.env
Russ Cox [Tue, 23 May 2023 16:37:01 +0000 (12:37 -0400)]
cmd/go: set default GOTOOLCHAIN in GOROOT/go.env

As part of the work for #57179 we moved configurable defaults
to GOROOT/go.env, so that packagers don't have to modify
source code to change those defaults. Since packagers may want
to modify GOTOOLCHAIN's default, move it to go.env too.

This CL modifies 'go env' to print GOTOOLCHAIN by default.
It also refines CL 496957 from yesterday to recognize any env
var in either go.env or the user go/env, not just the user go/env.
When I put GOTOOLCHAIN in go.env, but before I added it to
the default printing list, 'go env GOTOOLCHAIN' was printing
an empty string, and it was incredibly confusing.

For #57001.
Fixes #60361 while we're here.

Also includes a fix for a review comment on CL 497079 that I forgot to mail.

Change-Id: I7b904d9202f05af789aaa33aed93f903b515aa28
Reviewed-on: https://go-review.googlesource.com/c/go/+/497437
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>

12 months agoruntime: add partial lock order between mspanSpecial and gcBitsArenas
Michael Anthony Knyszek [Tue, 23 May 2023 17:15:21 +0000 (17:15 +0000)]
runtime: add partial lock order between mspanSpecial and gcBitsArenas

CL 493275 started using gcBits for pinner bits. This means gcBits can be
allocated while holding the mspanSpecial lock. This is safe because
these were just parallel in the partial order, but now they need an
explicit edge between them.

For #58277.

Change-Id: I37917730e12d59cf0580f198d732198413a56424
Reviewed-on: https://go-review.googlesource.com/c/go/+/497475
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
12 months agocmd/compile: build compiler with PGO
Cherry Mui [Mon, 15 May 2023 20:42:45 +0000 (16:42 -0400)]
cmd/compile: build compiler with PGO

Reapples CL 495596, which was reverted at CL 496185. The x/tools
failure, #60263, has been resolved. The ppc64 failures, #60368, have
_not_ been resolved, but are believed to be specific to that port. This
CL will make ppc64 flaky while the issue is investigated, but give more
soak time on primary ports.

Build the compiler with PGO. As go build -pgo=auto is enabled by
default, we just need to store a profile in the compiler's
directory.

The profile is collected from building all std and cmd packages on
Linux/AMD64 machine, using profile.sh.

This improves the compiler speed. On Linux/AMD64,
name        old time/op       new time/op       delta
Template          138ms ± 5%        136ms ± 4%  -1.44%  (p=0.005 n=36+39)
Unicode           147ms ± 4%        140ms ± 4%  -4.99%  (p=0.000 n=40+39)
GoTypes           780ms ± 3%        778ms ± 4%    ~     (p=0.172 n=39+39)
Compiler          105ms ± 5%         99ms ± 7%  -5.64%  (p=0.000 n=40+40)
SSA               5.83s ± 6%        5.80s ± 6%    ~     (p=0.556 n=40+40)
Flate            89.0ms ± 5%       87.0ms ± 6%  -2.18%  (p=0.000 n=40+40)
GoParser          172ms ± 4%        167ms ± 4%  -2.72%  (p=0.000 n=39+40)
Reflect           333ms ± 4%        333ms ± 3%    ~     (p=0.426 n=40+39)
Tar               128ms ± 4%        126ms ± 4%  -1.82%  (p=0.000 n=39+39)
XML               173ms ± 4%        170ms ± 4%  -1.39%  (p=0.000 n=39+40)
[Geo mean]        253ms             248ms       -2.13%

The profile is pretty transferable. Using the same profile, we
see a bigger win on Darwin/ARM64,
name        old time/op       new time/op       delta
Template         71.0ms ± 2%       68.3ms ± 2%  -3.90%  (p=0.000 n=20+20)
Unicode          71.8ms ± 2%       66.8ms ± 2%  -6.90%  (p=0.000 n=20+20)
GoTypes           444ms ± 1%        428ms ± 1%  -3.53%  (p=0.000 n=19+20)
Compiler         48.9ms ± 3%       45.6ms ± 3%  -6.81%  (p=0.000 n=20+20)
SSA               3.25s ± 2%        3.09s ± 1%  -5.03%  (p=0.000 n=19+20)
Flate            44.0ms ± 2%       42.3ms ± 2%  -3.72%  (p=0.000 n=19+20)
GoParser         76.7ms ± 1%       73.5ms ± 1%  -4.15%  (p=0.000 n=18+19)
Reflect           172ms ± 1%        165ms ± 1%  -4.13%  (p=0.000 n=20+19)
Tar              63.1ms ± 1%       60.4ms ± 2%  -4.24%  (p=0.000 n=19+20)
XML              83.2ms ± 2%       79.2ms ± 2%  -4.79%  (p=0.000 n=20+20)
[Geo mean]        127ms             121ms       -4.73%

For #60368.

Change-Id: I2cec0fc85e21c38d57ba6f0e5e90cde5d443ebd2
Reviewed-on: https://go-review.googlesource.com/c/go/+/497455
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agodoc: write various runtime-related release notes
Michael Anthony Knyszek [Mon, 22 May 2023 19:23:21 +0000 (19:23 +0000)]
doc: write various runtime-related release notes

This includes release notes for several small runtime changes, including
runtime/trace and runtime package changes.

For #58645.

Change-Id: I3e9c804da1bb6b385088e16a20d9576c11098021
Reviewed-on: https://go-review.googlesource.com/c/go/+/497095
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ansiwen <ansiwen@gmail.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
12 months agocrypto/rsa: make DecryptPKCS1v15SessionKey warning more dire
Roland Shoemaker [Fri, 17 Feb 2023 19:14:49 +0000 (11:14 -0800)]
crypto/rsa: make DecryptPKCS1v15SessionKey warning more dire

Updates the DecryptPKCS1v15SessionKey function comment to be less cut
and dry about its protections against Bleichenbacher attacks. In
particular note that the protocol using this method must be explicitly
designed with these mitigations in mind, and call out usages which
may cause the migiations to be useless.

Change-Id: I06fd25157f12a3afb401bb08dff4faef7fb0a9b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/469235
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: David Chase <drchase@google.com>
12 months agosyscall: avoid serializing forks on ForkLock
Ian Lance Taylor [Sat, 6 Aug 2022 01:06:51 +0000 (18:06 -0700)]
syscall: avoid serializing forks on ForkLock

Fixes #23558
Fixes #54162

Change-Id: I3cf6efe466080cdb17e171218e9385ccb272c301
Reviewed-on: https://go-review.googlesource.com/c/go/+/421441
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
12 months agotest: remove *_unified.go variants
Cuong Manh Le [Tue, 23 May 2023 03:39:43 +0000 (10:39 +0700)]
test: remove *_unified.go variants

CL 415241 and CL 411935 break tests into unified/nounified variants, for
compatibility with old frontend while developing unified IR. Now the old
frontend was gone, so moving those tests back to the original files.

Change-Id: Iecdcd4e6ee33c723f6ac02189b0be26248e15f0f
Reviewed-on: https://go-review.googlesource.com/c/go/+/497275
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

12 months agocmd/go: refuse to run when the main module or workspace needs a newer Go
Russ Cox [Tue, 23 May 2023 16:09:09 +0000 (12:09 -0400)]
cmd/go: refuse to run when the main module or workspace needs a newer Go

We already refuse to build code in modules are too new (CL 476279).
This is a more comprehensive check: refuse to do anything at all with
modules or workspaces that are too new.

Since the module or workspace is new, it may have semantics we don't
understand and misinterpret well before we get to the actual building of code.
For example when we switched from // +build to //go:build that changed
the decision about which files go into a package, which affects the way
the overall load phase runs and which errors it reports. Waiting until the
building of code would miss earlier changes like that one.

Leaving the test from CL 476279 alone, but it's not load-bearing anymore.

For #57001.

Change-Id: I8c39943db1d7ddbcb9b5cae68d80459fddd68151
Reviewed-on: https://go-review.googlesource.com/c/go/+/497435
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

12 months agocmd/compile: indicate sense of hash/bisect match in output
David Chase [Mon, 22 May 2023 20:58:12 +0000 (16:58 -0400)]
cmd/compile: indicate sense of hash/bisect match in output

If a hash match is "disabled" (!enabled) indicate that in the
output with DISABLED.  This is helpful in ensuring that multiple
package-directed command-line flags have the intended behavior,
e.g.

```
go build -a                       \
-gcflags=all=-d=gossahash=vn      \
-gcflags=runtime=-d=gossahash=vy  \
std
```

Output looks like

[DISABLED] [bisect-match 0x11d0ee166d9d61b4]

or (w/ "v"-prefixed hashcode )

sort/slice.go:23:29 note [DISABLED] [bisect-match 0xa5252e1c1b85f2ec]
gossahash triggered sort/slice.go:23:29 note [DISABLED] 100001011111001011101100

Change-Id: I797e02b3132f9781d97bacd0dcd2e80af0035cd8
Reviewed-on: https://go-review.googlesource.com/c/go/+/497216
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agogo/types, types2: require CGO for TestIssue59944
Rob Findley [Tue, 23 May 2023 16:37:13 +0000 (12:37 -0400)]
go/types, types2: require CGO for TestIssue59944

This test is failing on the nocgo builder.

Change-Id: I9426ce77907956e4654fd437ad20e3af664e83ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/497436
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go: add support for 'go' and 'toolchain' repos in modfetch
Russ Cox [Mon, 22 May 2023 15:39:22 +0000 (11:39 -0400)]
cmd/go: add support for 'go' and 'toolchain' repos in modfetch

To make the new go lines work with 'go get' as minimum requirements,
this CL creates a synthetic 'go' module that has as its versions the valid
versions that can be listed on the 'go' line.

In preparation for allowing 'toolchain' changes as well, an equivalent
synthetic module is introduced for 'toolchain'.

For #57001.

Change-Id: Id0ebbd283f0f991859d516d21dffe59a834db540
Reviewed-on: https://go-review.googlesource.com/c/go/+/497080
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go: download newer toolchain if needed during go install m@v
Russ Cox [Mon, 22 May 2023 15:17:31 +0000 (11:17 -0400)]
cmd/go: download newer toolchain if needed during go install m@v

go install m@v and go run m@v are the only commands
that ignore the local go.mod. As such they need to use a
different signal to find the Go version, namely the m@v go.mod.
Because there is no way to predict that Go version (no equivalent
of "go version" for interrogating the local go.mod), if we do switch
toolchains we always print about it.

For #57001.

Change-Id: I981a0b8fa61992b353589355ba72a3b9d55914e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/497079
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go: accept non-standard versions like go1.21-20230523-foo in latest
Russ Cox [Tue, 23 May 2023 15:00:37 +0000 (11:00 -0400)]
cmd/go: accept non-standard versions like go1.21-20230523-foo in latest

Some custom toolchain builds add extra suffixes to the version.
Strip those off (cutting at - or +) to find the underlying Go version.

For #57001.

Change-Id: I234fb2d069aaf0922c0a2c848e4a4c38e4adf9bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/497415
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>

12 months agocmd/go/internal/gover: add new Go version package
Russ Cox [Sat, 20 May 2023 20:53:13 +0000 (16:53 -0400)]
cmd/go/internal/gover: add new Go version package

Clean up Go version comparison.

CL 494436 added an ad hoc version comparison for the toolchain switch.

There are also other version comparisons scattered throughout the code,
assuming that using semver.Compare with a "v" prefix gives the right answer.
As we start to allow versions like "go 1.21rc1" in the go.mod file,
those comparisons will not work properly.

A future CL will need to inject Go versions into semver for use with MVS,
so do what Bryan suggested in the review of CL 494436 and rewrite the
comparison in terms of that conversion.

For #57001.

Change-Id: Ia1d441f1bc259874c6c1b3b9349bdf9823a707d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/496735
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agoruntime: fall back on mmap if madvise is unsupported
Lance Yang [Tue, 16 May 2023 08:20:42 +0000 (08:20 +0000)]
runtime: fall back on mmap if madvise is unsupported

Since Linux 3.18, support for madvise is optional, depending on
the setting of the CONFIG_ADVISE_SYSCALLS configuration option.

The Go runtime currently assumes in several places that we
do not unmap heap memory; that needs to remain true. So, if
madvise is unsupported, we cannot fall back on munmap. AFAIK,
the only way to free the pages is to remap the memory region.

For the x86, the system call mmap() is implemented by sys_mmap2()
which calls do_mmap2() directly with the same parameters. The main
call trace for
mmap(v, n, PROT_READ|PROT_WRITE, MAP_ANON|MAP_FIXED|MAP_PRIVATE, -1, 0)
is as follows:

```
do_mmap2()
    \- do_mmap_pgoff()
        \- get_unmapped_area()
        \- find_vma_prepare()

        // If a VMA was found and it is part of the new mmaping, remove
        // the old mapping as the new one will cover both.
        // Unmap all the pages in the region to be unmapped.
        \- do_munmap()

        // Allocate a VMA from the slab allocator.
        \- kmem_cache_alloc()

        // Link in the new vm_area_struct.
        \- vma_link()
```

So, it's safe to fall back on mmap().
See D.2 https://www.kernel.org/doc/gorman/html/understand/understand021.html

Change-Id: Ia2b4234bc0bf8a4631a9926364598854618fe270
GitHub-Last-Rev: 179f04715442b44cd4b7bf3e6cae3dd9092128e7
GitHub-Pull-Request: golang/go#60218
Reviewed-on: https://go-review.googlesource.com/c/go/+/495081
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime: let Pinner preallocate a reusable ref array
Sven Anderson [Thu, 18 May 2023 19:45:28 +0000 (21:45 +0200)]
runtime: let Pinner preallocate a reusable ref array

With this change a Pinner preallocates an array of 5 pointers for
references to pinned objects. This reduces allocations when a pinner
is reused with up to 5 pinned objects.

This is a follow-up to CL 367296.

Signed-off-by: Sven Anderson <sven@anderson.de>
Change-Id: Ibea0b9ee4d7e39b0341a1da9d8276a4283e4956d
Reviewed-on: https://go-review.googlesource.com/c/go/+/496275
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

12 months agogo/types: resolve cgo base type names
Rob Findley [Tue, 9 May 2023 15:24:28 +0000 (11:24 -0400)]
go/types: resolve cgo base type names

When associating methods with their receiver base, we need to implement
the same indirection through Cgo types as is done for selector
expressions. This fixes a bug where methods declared on aliases of Cgo
types were not associated with their receiver.

While porting to types2, align the types2 testFiles helper with the
go/types implementation. In order to avoid call-site bloat, switch to an
options pattern for configuring the Config used to type-check.

Fixes golang/go#59944

Change-Id: Id14101f01c122b6c856ae5453bd00ec07e83f414
Reviewed-on: https://go-review.googlesource.com/c/go/+/493877
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go,testing: re-implement testing.Coverage
Than McIntosh [Fri, 12 May 2023 12:48:32 +0000 (08:48 -0400)]
cmd/go,testing: re-implement testing.Coverage

This patch revives the testing.Coverage() function, which takes a
snapshot of the coverage counters within an executing "go test -cover"
test binary and returns a percentage approximating the percent of
statements covered so far.

Fixes #59590.

Change-Id: I541d47a42d71c8fb2edc473d86c8951fa80f4ab0
Reviewed-on: https://go-review.googlesource.com/c/go/+/495450
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime/coverage: add support for "auxiliary" meta-data files
Than McIntosh [Mon, 15 May 2023 17:22:39 +0000 (13:22 -0400)]
runtime/coverage: add support for "auxiliary" meta-data files

Enhance the functions called by _testmain.go during "go test -cover"
test binary runs to allow for injection of extra or "auxiliary"
meta-data files when reporting coverage statistics. There are unit
tests for this functionality, but it is not yet wired up to be used by
the Go command yet, that will appear in a subsequent patch.

Change-Id: I10b79ca003fd7a875727dc1a86f23f58d6bf630c
Reviewed-on: https://go-review.googlesource.com/c/go/+/495451
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
12 months agoruntime/coverage: add coverage snapshot helper routine
Than McIntosh [Fri, 12 May 2023 12:20:08 +0000 (08:20 -0400)]
runtime/coverage: add coverage snapshot helper routine

Add a new function runtime/coverage.snapshot(), which samples the
current values of coverage counters in a running "go test -cover"
binary and returns percentage of statements executed so far. This
function is intended to be used by the function testing.Coverage().

Updates #59590.

Change-Id: I861393701c0cef47b4980aec14331168a9e64e8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/495449
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
12 months agointernal/coverage/cformat: add aggregation option to EmitPercent
Than McIntosh [Tue, 16 May 2023 17:06:22 +0000 (13:06 -0400)]
internal/coverage/cformat: add aggregation option to EmitPercent

Add a flag to EmitPercent indicating to emit a single line percent
summary across all packages as opposed to a line per package. We need
to set this flag when reporting as part of a "go test -cover" run, but
false when reporting as part of a "go tool covdata percent" run.

Change-Id: Iba6a81b9ae27e3a5aaf9d0e46c0023c0e7ceae16
Reviewed-on: https://go-review.googlesource.com/c/go/+/495448
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
12 months agocmd/covdata: tweak output format for 'go tool covdata percent'
Than McIntosh [Wed, 10 May 2023 11:04:58 +0000 (07:04 -0400)]
cmd/covdata: tweak output format for 'go tool covdata percent'

Include some additional whitepace when emitting percentage of
statements covered per package, to make "go tool covdata percent"
output more like "go test -cover" output.

Change-Id: I450cf2bfa05b1eed747cb2f99967314419fa446c
Reviewed-on: https://go-review.googlesource.com/c/go/+/495445
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>

12 months agocmd/covdata: relax mode clash policy for selected operations
Than McIntosh [Tue, 27 Dec 2022 19:34:11 +0000 (14:34 -0500)]
cmd/covdata: relax mode clash policy for selected operations

Relax the policy on counter mode clashes in certain cases for "go tool
covdata" operations. Specifically, when generating 'percent',
'pkglist' or 'func' reports, we only care about whether a given
statement is executed, thus counter mode clashes are irrelevant; there
is no need to report clashes for these ops.

Example:

  $ go build -covermode=count -o myprog.count.exe myprog
  $ go build -covermode=set -o myprog.set.exe myprog
  $ GOCOVERDIR=dir1 ./myprog.count.exe
  ...
  $ GOCOVERDIR=dir2 ./myprog.set.exe
  ...
  $ go tool covdata percent i=dir1,dir2
  error: counter mode clash while reading meta-data file dir2/covmeta.1a0cd0c8ccab07d3179f0ac3dd98159a: previous file had count, new file has set
  $

With this patch the command above will "do the right thing" and work
properly, and in addition merges using the "-pcombine" flag will also
operate with relaxed rules. Note that textfmt operations still require
inputs with consistent coverage modes.

Change-Id: I01e97530d9780943c99b399d03d4cfff05aafd8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/495440
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>

12 months agointernal/coverage: implement conforming Seek method in slicereader
Than McIntosh [Thu, 11 May 2023 20:09:38 +0000 (16:09 -0400)]
internal/coverage: implement conforming Seek method in slicereader

Implement a real Seek() method in the slicereader helper (prior to
this it had a simplified SeekTo function), so that slicereader's will
satisfy the ReadSeeker interface (needed in a subsequent patch).

Change-Id: I832e3ec1e34d0f8c6b5edf390470f6f943c6ece0
Reviewed-on: https://go-review.googlesource.com/c/go/+/495438
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
12 months agocmd/go: add some test skips for GOEXPERIMENT=nocoverageredesign
Than McIntosh [Tue, 16 May 2023 20:56:13 +0000 (16:56 -0400)]
cmd/go: add some test skips for GOEXPERIMENT=nocoverageredesign

Couple of test need to be skipped for GOEXPERIMENT=nocoverageredesign,
since they use "go build -cover". [This is a test-only CL].

Change-Id: I48c0855e2d8f042f9bc293e4cf48f326682112c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/495597
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agocmd/go: clear GOOS environment variable in TestScript/env_write
Bryan C. Mills [Tue, 23 May 2023 03:28:50 +0000 (23:28 -0400)]
cmd/go: clear GOOS environment variable in TestScript/env_write

Also clear the GOOS and GOARCH from the env file before testing other
environment variables.

This fixes various builders after CL 496957.

Change-Id: Ib0308ca48f9e64c1c872f1d26a92a1dedf6330f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/497256
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>

12 months agocmd/go: allow using go env with unknown vars already in go/env file
Russ Cox [Mon, 22 May 2023 18:05:08 +0000 (14:05 -0400)]
cmd/go: allow using go env with unknown vars already in go/env file

If you are using a newer toolchain and set go env -w X=Y, then it's
a bit frustrating that you can't update the variable in an older toolchain
with go env -w X=OTHER or go env -u X, or even see it with go env X.
This CL makes all those work.

This is particularly important when playing with go env -w GOTOOLCHAIN=oldversion
because from that point on the old version is handling 'go env' commands,
and the old version doesn't know about GOTOOLCHAIN.
The most complete way to recover from that situation is to use

GOTOOLCHAIN=local go env -w ...

but we will backport this CL to Go 1.19 and Go 1.20 so that they can
recover a bit more easily.

Fixes #59870.

Change-Id: I7a0bb043109e75a0d746069015f6e7992f78287f
Reviewed-on: https://go-review.googlesource.com/c/go/+/496957
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/compile: incorporate inlined function names into closure naming
Matthew Dempsky [Mon, 22 May 2023 20:25:15 +0000 (13:25 -0700)]
cmd/compile: incorporate inlined function names into closure naming

In Go 1.17, cmd/compile gained the ability to inline calls to
functions that contain function literals (aka "closures"). This was
implemented by duplicating the function literal body and emitting a
second LSym, because in general it might be optimized better than the
original function literal.

However, the second LSym was named simply as any other function
literal appearing literally in the enclosing function would be named.
E.g., if f has a closure "f.funcX", and f is inlined into g, we would
create "g.funcY" (N.B., X and Y need not be the same.). Users then
have no idea this function originally came from f.

With this CL, the inlined call stack is incorporated into the clone
LSym's name: instead of "g.funcY", it's named "g.f.funcY".

In the future, it seems desirable to arrange for the clone's name to
appear exactly as the original name, so stack traces remain the same
as when -l or -d=inlfuncswithclosures are used. But it's unclear
whether the linker supports that today, or whether any downstream
tooling would be confused by this.

Updates #60324.

Change-Id: Ifad0ccef7e959e72005beeecdfffd872f63982f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/497137
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

12 months agocmd/go: retain extra roots to disambiguate imports in 'go mod tidy'
Bryan C. Mills [Sat, 20 May 2023 02:35:33 +0000 (22:35 -0400)]
cmd/go: retain extra roots to disambiguate imports in 'go mod tidy'

We don't normally keep explicit requirements for test dependencies of
packages loaded from other modules when the required version is
already the selected version in the module graph. However, in some
cases we may need to keep an explicit requirement in order to make use
of lazy module loading to disambiguate an otherwise-ambiguous import.

Note that there is no Go version guard for this change: in the cases
where the behavior of 'go mod tidy' has changed, previous versions of
Go would produce go.mod files that break successive calls to
'go mod tidy'. Given that, I suspect that any existing user in the
wild affected by this bug either already has a workaround in place
using redundant import statements (in which case the change does not
affect them) or is running 'go mod tidy -e' to force past the error
(in which case a change in behavior to a non-error should not be
surprising).

Fixes #60313.

Change-Id: Idf294f72cbe3904b871290d79e4493595a0c7bfc
Reviewed-on: https://go-review.googlesource.com/c/go/+/496635
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go: add a test that reproduces an unstable 'go mod tidy'
Bryan C. Mills [Fri, 19 May 2023 20:01:02 +0000 (16:01 -0400)]
cmd/go: add a test that reproduces an unstable 'go mod tidy'

For #60313.

Change-Id: I76e48f52341e9962de9b809741a677d61baae6a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/496518
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

12 months agocmd/cgo/internal: skip in tests, not in TestMain
Austin Clements [Mon, 22 May 2023 19:19:49 +0000 (15:19 -0400)]
cmd/cgo/internal: skip in tests, not in TestMain

Many cgo integration tests do a lot of common setup in TestMain, and
that means they require a lot from the test environment to even get
off the ground. If something is missing, right now they print a "SKIP"
message to stderr and exit without running any tests.

Make these behave more like normal tests by instead setting a global
skip function if some precondition isn't satisfied, and having every
test call that. This way we run the tests and see them skip.

I would prefer something much more structured. For example, if we
replaced the global state set up by TestMain in these tests by instead
calling a function that returned that state (after setting it up on
the first call), that function could do the appropriate skips and
there would be no way to accidentally access this state without
checking the preconditions. But that's substantially more work and may
be much easier after we do further cleanup of these tests.

Change-Id: I92de569fd27596798c5e478402449cd735ec53a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/497096
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agocmd/cgo: merge overlayDir into one package
Austin Clements [Mon, 22 May 2023 14:32:31 +0000 (10:32 -0400)]
cmd/cgo: merge overlayDir into one package

There are many copies of overlaydir_test.go between the cgo tests
from when these couldn't share code. Now that they can, merge these
copies into a cmd/cgo/internal/cgotest package.

Change-Id: I203217f5d08e6306cb049a13718652cf7c447b80
Reviewed-on: https://go-review.googlesource.com/c/go/+/497078
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/cgo/internal/testcshared: drop bespoke host test support
Austin Clements [Mon, 22 May 2023 16:32:05 +0000 (12:32 -0400)]
cmd/cgo/internal/testcshared: drop bespoke host test support

Updates #59999.

Change-Id: If0b80713a6bb5d8c59d9dd0b219f2f47173090e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/497077
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>

12 months agocmd/compile: enable PGO-driven call devirtualization
Michael Pratt [Fri, 12 May 2023 20:39:43 +0000 (16:39 -0400)]
cmd/compile: enable PGO-driven call devirtualization

This CL is originally based on CL 484838 from rajbarik@uber.com.

Add a new PGO-based devirtualize pass. This pass conditionally
devirtualizes interface calls for the hottest callee. That is, it
performs a transformation like:

type Iface interface {
Foo()
}

type Concrete struct{}

func (Concrete) Foo() {}

func foo(i Iface) {
i.Foo()
}

to:

func foo(i Iface) {
if c, ok := i.(Concrete); ok {
c.Foo()
} else {
i.Foo()
}
}

The primary benefit of this transformation is enabling inlining of the
direct calls.

Today this change has no impact on the escape behavior, as the fallback
interface always forces an escape. But improving escape analysis to take
advantage of this is an area of potential work.

This CL is the bare minimum of a devirtualization implementation. There
are still numerous limitations:

* Callees not directly referenced in the current package can be missed
  (even if they are in the transitive dependences).
* Callees not in the transitive dependencies of the current package are
  missed.
* Only interface method calls are supported, not other indirect function
  calls.
* Multiple calls to compatible interfaces on the same line cannot be
  distinguished and will use the same callee target.
* Callees that only partially implement an interface (they are embedded
  in another type that completes the interface) cannot be devirtualized.
* Others, mentioned in TODOs.

Fixes #59959

Change-Id: I8bedb516139695ee4069650b099d05957b7ce5ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/492436
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agolog/slog: increase test coverage
Jonathan Amsterdam [Fri, 19 May 2023 13:46:22 +0000 (09:46 -0400)]
log/slog: increase test coverage

Change-Id: I2c7f3ca27ee1b1c2d65d713ffa6256c3cfdd8aad
Reviewed-on: https://go-review.googlesource.com/c/go/+/495979
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agolog/slog: improve test coverage of JSON handler
Jonathan Amsterdam [Fri, 19 May 2023 11:51:36 +0000 (07:51 -0400)]
log/slog: improve test coverage of JSON handler

Change-Id: I31e96fc1329bb17937974ed3dbfda3448e53d37e
Reviewed-on: https://go-review.googlesource.com/c/go/+/495978
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime: treat TestRaceSignal as flaky on Darwin
Ian Lance Taylor [Mon, 22 May 2023 18:38:46 +0000 (11:38 -0700)]
runtime: treat TestRaceSignal as flaky on Darwin

It should be impossible for the program to exit with SIGCHLD,
but it happens occasionally. Skip the test on Darwin.

For #60316

Change-Id: Idc9d89838e73f077afc42a9703554d61ac7a0069
Reviewed-on: https://go-review.googlesource.com/c/go/+/497055
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: 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>
Auto-Submit: Ian Lance Taylor <iant@google.com>

12 months agocmd/cgo: recognize unsafe.{StringData,SliceData}
Ian Lance Taylor [Mon, 8 May 2023 19:45:42 +0000 (12:45 -0700)]
cmd/cgo: recognize unsafe.{StringData,SliceData}

A simple call to unsafe.StringData can't contain any pointers.

When looking for field references, a call to unsafe.StringData or
unsafe.SliceData can be treated as a type conversion.

In order to make unsafe.SliceData useful, recognize slice expressions
when calling C functions.

Fixes #59954

Change-Id: I08a3ace7882073284c1d46a5210582a2521b0b4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/493556
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
12 months agolog/slog: fix check for nil prefix
Jonathan Amsterdam [Fri, 19 May 2023 11:31:44 +0000 (07:31 -0400)]
log/slog: fix check for nil prefix

Previously, handleState.prefix was nil if and only if the length of
the prefix was zero. Now, prefix is never nil.

Fix the nil check in the code by also checking if the length is non-zero.

Change-Id: I9f69c0029cb1c73fe6c2919c78fee7d4085bfd85
Reviewed-on: https://go-review.googlesource.com/c/go/+/495977
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
12 months agolog/slog: empty calls to With and WithGroup are no-ops
Jonathan Amsterdam [Thu, 18 May 2023 13:24:42 +0000 (09:24 -0400)]
log/slog: empty calls to With and WithGroup are no-ops

It doesn't make sense to call Logger.WithGroup with the empty string.
Make it a no-op by returning the receiver.
This relieves handlers of the burden of detecting that case themselves.

Less importantly, but for consistency, if Logger.With is called with
no args, make it a no-op by returning the receiver.

Along the way, fix obsolete mentions of "the Logger's context" in the
doc.

Change-Id: Ia6caa4f1ca70c1c4b0cab3e222b2fda48be73fef
Reviewed-on: https://go-review.googlesource.com/c/go/+/496175
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>

12 months agocmd/vet: add slog checker
Jonathan Amsterdam [Tue, 16 May 2023 17:47:46 +0000 (13:47 -0400)]
cmd/vet: add slog checker

Add the slog static analysis pass to `go vet`.

Vendor in golang.org/x/tools@master to pick up the pass.

Tweak a test in slog to avoid triggering the vet check.

Change-Id: I55ceac9a4e6876c8385897784542761ea0af2481
Reviewed-on: https://go-review.googlesource.com/c/go/+/496156
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agowasm: remove redundant calls to setTimeout and clearTimeout
Garet Halliday [Fri, 14 Oct 2022 00:35:18 +0000 (19:35 -0500)]
wasm: remove redundant calls to setTimeout and clearTimeout

The existing implementation clears and recreates Javascript
timeouts when Go is called from js, leading to excessive
load on the js scheduler. Instead, we should remove redundant
calls to clearTimeout and refrain from creating new timeouts
if the previous event's timestamp is within 1 millisecond of
our target (the js scheduler's max precision)

Fixes #56100

Change-Id: I42bbed4c2f1fa6579c1f3aa519b6ed8fc003a20c
Reviewed-on: https://go-review.googlesource.com/c/go/+/442995
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

12 months agogo/types, types2: remove unnecessary pkg argument from verifyVersion
Robert Griesemer [Mon, 22 May 2023 16:44:42 +0000 (09:44 -0700)]
go/types, types2: remove unnecessary pkg argument from verifyVersion

Change-Id: I802a9b8039740e71463694eb5503a81b2b75971d
Reviewed-on: https://go-review.googlesource.com/c/go/+/496919
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime: remove some unused constants from assembler code
Ian Lance Taylor [Sat, 20 May 2023 20:48:22 +0000 (13:48 -0700)]
runtime: remove some unused constants from assembler code

Change-Id: Ibcd919afcb7ff4db79036ef427d088097362a574
Reviewed-on: https://go-review.googlesource.com/c/go/+/496695
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

12 months agogo/types, types2: keep inferring type arguments from constraints for -lang < go1.21
Robert Griesemer [Mon, 22 May 2023 16:04:27 +0000 (09:04 -0700)]
go/types, types2: keep inferring type arguments from constraints for -lang < go1.21

Fixes #60346.

Change-Id: I14834858d53fd80f8261ec0c8d0eccdd75a1bc2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/496917
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agonet: skip TestFileFdBlocks if the "unix" network is not supported
Bryan C. Mills [Mon, 22 May 2023 15:18:30 +0000 (11:18 -0400)]
net: skip TestFileFdBlocks if the "unix" network is not supported

This may fix the android failures observed starting at CL 496080, such
as the one in
https://build.golang.org/log/7bfc4bd192e21c02a167d2d6a5649f1a2b63a8f1.

Change-Id: I4e8eaf9890da269bd1758f59a29fa2a8131d8ae6
Reviewed-on: https://go-review.googlesource.com/c/go/+/496955
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

12 months agocmd/compile: replace -d=pgoinline with -d=pgodebug
Michael Pratt [Fri, 12 May 2023 19:36:37 +0000 (15:36 -0400)]
cmd/compile: replace -d=pgoinline with -d=pgodebug

We will soon have PGO specialization. It doesn't make sense for the
debug flag to have inline in the name, so rename it to pgodebug.

pgoinline is now a flag that can be used to disable PGO inlining.
Devirtualization will have a similar debug flag.

For #59959.

Change-Id: I9770ff1f0d132dfa3cd417018a887a1bd5555bba
Reviewed-on: https://go-review.googlesource.com/c/go/+/494716
Auto-Submit: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
12 months agocmd/compile/internal/typecheck: export Implements
Michael Pratt [Wed, 17 May 2023 15:42:27 +0000 (11:42 -0400)]
cmd/compile/internal/typecheck: export Implements

Provide an exported version of implements to easily check if a type
implements an interface. This will be use for PGO devirtualization.

Even within the package, other callers can make use of this simpler API
to reduce duplication.

For #59959.

Change-Id: If4eb86f197ca32abc7634561e36498a247b5070f
Reviewed-on: https://go-review.googlesource.com/c/go/+/495915
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>

12 months agocmd/compile/internal/typecheck: remove base.Errorf from Assignop
Michael Pratt [Mon, 15 May 2023 17:42:13 +0000 (13:42 -0400)]
cmd/compile/internal/typecheck: remove base.Errorf from Assignop

The documentation for Assignop specifies that if the assignment is not
valid, the reason for the failure is returned via a reason string
without failing the build.

A few cases in Assignop1 -> implements -> ifacelookdot directly call
base.Errorf rather than plumbing through the reason string as they
should. Drop these calls. Since error messages are mostly unreachable
here (it only applies to generated code), don't maintain them and allow
them to just fallthrough to the generic "missing method" message.

This is important for PGO specialization, which opportunistically checks
if candidate interface call targets implement the interface. Many of
these will fail, which should not break the build.

For #59959.

Change-Id: I1891ca0ebebc1c1f51a0d0285035bbe8753036bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/494959
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

12 months agoruntime: fix TestSehUnwind
qmuntal [Thu, 18 May 2023 12:46:20 +0000 (14:46 +0200)]
runtime: fix TestSehUnwind

This CL fixes two problems:

- NewContextStub initialize a context with the wrong FP. That
function should dereference the FP returned by getcallerfp, as it
returns the callers's FP instead of the caller's caller FP.
CL 494857 will rename getcallerfp to getfp to make this fact clearer.

- sehCallers skips the bottom frame when it should.

Fixes #60053

Change-Id: I7d59b0175fc95281fcc7dd565ced9293064df3a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/496140
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agoruntime: rename getcallerfp to getfp
Felix Geisendörfer [Mon, 3 Apr 2023 23:10:55 +0000 (01:10 +0200)]
runtime: rename getcallerfp to getfp

The previous name was wrong due to the mistaken assumption that calling
f->g->getcallerpc and f->g->getcallersp would respectively return the
pc/sp at g. However, they are actually referring to their caller's
caller, i.e. f.

Rename getcallerfp to getfp in order to stay consistent with this
naming convention.

Also see discussion on CL 463835.

For #16638

This is a redo of CL 481617 that became necessary because CL 461738
added another call site for getcallerfp().

Change-Id: If0b536e85a6c26061b65e7b5c2859fc31385d025
Reviewed-on: https://go-review.googlesource.com/c/go/+/494857
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>

12 months agocmd/asm: encode instructions like SHA1SU0 with a separate case for arm64
Ruinan [Thu, 4 May 2023 04:31:36 +0000 (12:31 +0800)]
cmd/asm: encode instructions like SHA1SU0 with a separate case for arm64

Before this CL, instructions such as SHA1SU0, AESD and AESE are encoded
in case 1 together with FMOV/ADD, and some error checking is missing,
for example:

  SHA1SU0       V1.B16, V2.B16, V3.B16   // wrong data arrangement
  SHA1SU0       V1.4S, V2.S4, V3.S4      // correct

Both will be accepted by the assembler, but the first one is totally
incorrect.

This CL fixes these potential encoding issues by moving them into
separate cases, adds some error tests, and also fixes a wrong encoding
operand for ASHA1C.

Change-Id: Ic778321a567735d48bc34a1247ee005c4ed9e11f
Reviewed-on: https://go-review.googlesource.com/c/go/+/493195
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agodoc: add slog to release notes
Jonathan Amsterdam [Fri, 19 May 2023 15:42:04 +0000 (11:42 -0400)]
doc: add slog to release notes

Updates #58645

Change-Id: Ice8f115f00c62dcffd0c7b78bb8a7d66d832075d
Reviewed-on: https://go-review.googlesource.com/c/go/+/496194
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>

12 months agonet, os: net.Conn.File.Fd should return a blocking descriptor
Ian Lance Taylor [Fri, 19 May 2023 22:09:58 +0000 (15:09 -0700)]
net, os: net.Conn.File.Fd should return a blocking descriptor

Historically net.Conn.File.Fd has returned a descriptor in blocking mode.
That was broken by CL 495079, which changed the behavior for os.OpenFile
and os.NewFile without intending to affect net.Conn.File.Fd.
Use a hidden os entry point to preserve the historical behavior,
to ensure backward compatibility.

Change-Id: I8d14b9296070ddd52bb8940cb88c6a8b2dc28c27
Reviewed-on: https://go-review.googlesource.com/c/go/+/496080
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@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>

12 months agonet: ignore more errors in TestDialCancel
Ian Lance Taylor [Wed, 17 May 2023 22:22:25 +0000 (15:22 -0700)]
net: ignore more errors in TestDialCancel

TestDialCancel assumes that packets sent to the private IP addresses
198.18.0.254 and 2001:2::254 will be routed to /dev/null.
Not all systems are configured that way. We already ignore one
error case in the test; ignore a couple more than have appeared
on the builders. The test is still valid as long as some builders
discard the packets as expected.

Fixes #52579
Fixes #57364

Change-Id: Ibe9ed73b8b3b498623f1d18203dadf9207a0467e
Reviewed-on: https://go-review.googlesource.com/c/go/+/496037
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime: consolidate on a single closeonexec definition
Ian Lance Taylor [Sat, 20 May 2023 00:44:35 +0000 (17:44 -0700)]
runtime: consolidate on a single closeonexec definition

Now that we implement fcntl on all Unix systems, we can
write closeonexec that uses it. This lets us remove a bunch
of assembler code.

Change-Id: If35591df535ccfc67292086a9492f0a8920e3681
Reviewed-on: https://go-review.googlesource.com/c/go/+/496081
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
12 months agocmd/go: update help for empty environment variables
Sean Liao [Sun, 12 Mar 2023 02:34:04 +0000 (10:34 +0800)]
cmd/go: update help for empty environment variables

Fixes #50335

Change-Id: I44b9dc6afa8c70b5cc8c79fb3ebddc3f45d3cef8
Reviewed-on: https://go-review.googlesource.com/c/go/+/475695
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

12 months agoruntime: change fcntl to return two values
Ian Lance Taylor [Fri, 19 May 2023 04:13:03 +0000 (21:13 -0700)]
runtime: change fcntl to return two values

Separate the result and the errno value, rather than assuming
that the result can never be negative.

Change-Id: Ib01a70a3d46285aa77e95371cdde74e1504e7c12
Reviewed-on: https://go-review.googlesource.com/c/go/+/496416
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

12 months agocmd/go: implement GOTOOLCHAIN=auto
Russ Cox [Thu, 11 May 2023 18:32:56 +0000 (14:32 -0400)]
cmd/go: implement GOTOOLCHAIN=auto

The documentation is yet to be written (more work in the go
command remains first). This CL implements the toolchain
selection described in
https://go.dev/design/57001-gotoolchain#the-and-lines-in-in-the-work-module
with these changes based on the issue discussion:

1. GOTOOLCHAIN=auto looks for a go1.19.1 binary in $PATH
and if found uses it instead of downloading Go 1.19.1 as a module.

2. GOTOOLCHAIN=path is like GOTOOLCHAIN=auto, with
downloading disabled.

3. GOTOOLCHAIN=auto+version and GOTOOLCHAIN=path+version
set a different minimum version of Go to use during the version
selection. The default is to use the newer of what's on the go line
or the current toolchain. If you are have Go 1.22 installed locally
and want to switch to a minimum of Go 1.25 with go.mod files
allowed to bump even further, you would set GOTOOLCHAIN=auto+go1.25.
The minimum is also important when there is no go.mod involved,
such as when you write a tiny x.go program and run "go run x.go".
That would get Go 1.25 in this example, instead of falling back to
the local Go 1.22.

Change-Id: I286625a24420424c313d1082b9949a463b2fe14a
Reviewed-on: https://go-review.googlesource.com/c/go/+/494436
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

12 months agoio: prevent seeking to position prior to offsetwrite.base
Jabar Asadi [Fri, 19 May 2023 09:31:25 +0000 (09:31 +0000)]
io: prevent seeking to position prior to offsetwrite.base

We don't want to permit writing before the start of an OffsetWriter.

One of the goals of OffsetWriter is to restrict where data
can be written.

However, this rule can be violated by WriteAt() method of OffsetWriter
as the following code shows:

f, _ := os.Create("file.txt")
owr := io.NewOffsetWriter(f, 10)
owr.Write([]byte("world"))
owr.WriteAt([]byte("hello"), -10)

Change-Id: I6c7519fea68daefa641f25130cdd9803dc8aae22
GitHub-Last-Rev: a29d890d6f32fd5a1ecef84d012b8447b406e2e2
GitHub-Pull-Request: golang/go#60222
Reviewed-on: https://go-review.googlesource.com/c/go/+/495155
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jabar Asadi <jasadi@d2iq.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agonet/http/pprof: document query params
Sean Liao [Fri, 19 May 2023 18:39:29 +0000 (19:39 +0100)]
net/http/pprof: document query params

Fixes #59452

Change-Id: Ia0b5a03565f663190c480ef9e26309fa85ff192c
Reviewed-on: https://go-review.googlesource.com/c/go/+/496144
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>
Auto-Submit: Ian Lance Taylor <iant@google.com>

12 months agoruntime: improve Pinner with gcBits
Sven Anderson [Thu, 4 May 2023 22:15:07 +0000 (00:15 +0200)]
runtime: improve Pinner with gcBits

This change replaces the statically sized pinnerBits with gcBits
based ones, that are copied in each GC cycle if they exist.  The
pinnerBits now include a second bit per object, that indicates if a
pinner counter for multi-pins exists, in order to avoid unnecessary
specials iterations.

This is a follow-up to CL 367296.

Change-Id: I82e38cecd535e18c3b3ae54b5cc67d3aeeaafcfd
Reviewed-on: https://go-review.googlesource.com/c/go/+/493275
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
12 months agocmd/dist: use "pkg[:variant]" as dist test name
Dmitri Shuralyov [Thu, 18 May 2023 15:11:55 +0000 (11:11 -0400)]
cmd/dist: use "pkg[:variant]" as dist test name

The work to add the -json flag to the 'dist test' command also cleaned
how dist tests are tracked and registered. By now, a pair of (import
path, variant) strings is sufficient to uniquely identify every dist
test that exists. Some of the custom dist test names have been improved
along the way. And since the names are already changing a little anyway,
we use this opportunity to make them more uniform and predictable.

The mapping from the old dist test names to the new is as follows:

- "go_test:pkg"       → "pkg"  (this is the most common case)
- "go_test_bench:pkg" → "pkg:racebench"
- all other custom names are now called "pkg:variant", where variant
  is a description of their test configuration and pkg is the import
  path of the Go package under test

CL 495016 introduced test variants and used variant names for rewriting
the Package field in JSON events, and now that same name starts to also
be used as the dist test name.

Like previously done in CL 494496, registering a test variant involving
multiple Go packages creates a "pkg:variant" dist test name for each.
In the future we may combine their 'go test' invocation purely as an
optimization.

We can do this with the support of CL 496190 that keeps the coordinator
happy and capable of working with both new and old names.

In the end, all dist tests now have a consistent "pkg[:variant]" name.

For #37486.
For #59990.

Change-Id: I7eb02a42792a9831a2f3eeab583ff635d24269e8
Co-authored-by: Austin Clements <austin@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/496181
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agocmd/dist: remove unused functionality
Austin Clements [Fri, 19 May 2023 21:04:15 +0000 (17:04 -0400)]
cmd/dist: remove unused functionality

The moved_goroot test was the last user of the goroot functionality.
Now that it's been deleted, drop this and clean up loose ends.

Change-Id: Ie5e95644022dab76b1c06cf37f7729ee6616311f
Reviewed-on: https://go-review.googlesource.com/c/go/+/496520
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agocmd/dist: delete moved_goroot test
Austin Clements [Fri, 19 May 2023 20:58:37 +0000 (16:58 -0400)]
cmd/dist: delete moved_goroot test

This test is largely obviated by the goroot_executable and
list_goroot_symlink cmd/go script tests. It's the last user of several
special-case features in cmd/dist and runs only under a fairly
constrained set of conditions (including only running on builders, not
locally). Delete it.

Change-Id: Icc744e3f9f04813bfd0cad2ef3e88e42617ecf5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/496519
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Austin Clements <austin@google.com>

12 months agoall: generate NOTOC shared code on power10/PPC64/linux
Paul E. Murphy [Tue, 10 Jan 2023 21:18:04 +0000 (15:18 -0600)]
all: generate NOTOC shared code on power10/PPC64/linux

An explicit TOC pointer is not needed when building with GOPPC64=power10
on linux/PPC64 as all addressing is PC relative.

Apply changes to the compiler, assembler, and linker to remove R2/TOC
maintenance in these build configurations.

This results in noticeably smaller PIC binaries. For example the size
(in bytes) of the k8s binaries before and with this patch:

GOFLAGS="-buildmode=pie" \
FORCE_HOST_GO=y \
GOPPC64=power10 \
CGO_CFLAGS="-mcpu=power10 -O2 -g" \
make all

         apiextensions-apiserver   66060288   64487424   -1572864  -2.38%
                   e2e_node.test  163520856  159850760   -3670096  -2.24%
                        e2e.test  178167304  174890432   -3276872  -1.83%
                          ginkgo   11010048   10747904    -262144  -2.38%
                       go-runner    2162688    2162688          0      0%
                       k8s-tests  170182216  166970880   -3211336  -1.88%
                         kubeadm   52625408   51314688   -1310720  -2.49%
                 kube-aggregator   62849024   61341696   -1507328  -2.39%
                  kube-apiserver  147783680  144375808   -3407872  -2.30%
         kube-controller-manager  131137536  127991808   -3145728  -2.39%
                         kubectl   53608448   52363264   -1245184  -2.32%
                 kubectl-convert   52625408   51314688   -1310720  -2.49%
                         kubelet  120913920  118095872   -2818048  -2.33%
                 kube-log-runner    1900544    1835008     -65536  -3.44%
                        kubemark  119078912  116326400   -2752512  -2.31%
                      kube-proxy   58392576   56885248   -1507328  -2.58%
                  kube-scheduler   60751872   59244544   -1507328  -2.48%
                         mounter    1835008    1769472     -65536  -3.57%
               watch-termination   38076416   37158912    -917504  -2.40%

And text size changes:

         apiextensions-apiserver   30243288   28654116   -1589172  -5.25%
                   e2e_node.test   71132064   67520288   -3611776  -5.07%
                        e2e.test   61843984   58635088   -3208896  -5.18%
                          ginkgo    4975916    4769304    -206612  -4.15%
                       go-runner     896532     858400     -38132  -4.25%
                       k8s-tests   60925792   57752032   -3173760  -5.20%
                         kubeadm   24643240   23404100   -1239140  -5.02%
                 kube-aggregator   28688060   27160976   -1527084  -5.32%
                  kube-apiserver   65627332   62259460   -3367872  -5.13%
         kube-controller-manager   56773844   53706532   -3067312  -5.40%
                         kubectl   24344276   23080640   -1263636  -5.19%
                 kubectl-convert   23733764   22521768   -1211996  -5.10%
                         kubelet   52494580   49720340   -2774240  -5.28%
                 kube-log-runner     787128     753232     -33896  -4.30%
                        kubemark   51576580   48837380   -2739200  -5.31%
                      kube-proxy   26541092   25124080   -1417012  -5.33%
                  kube-scheduler   27448512   25976172   -1472340  -5.36%
                         mounter     744100     712628     -31472  -4.22%
               watch-termination   18047276   17139912    -907364  -5.02%

Change-Id: Ib4872823b06f93861e46a00679b5d4e5e30b538a
Reviewed-on: https://go-review.googlesource.com/c/go/+/495416
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
12 months agocmd/compile: tweaks to loopvar logging
David Chase [Fri, 19 May 2023 18:55:56 +0000 (14:55 -0400)]
cmd/compile: tweaks to loopvar logging

This adds the loop type to the json/LSP logging, to help with
studies of how many loops of which kind were modified.

Change-Id: I637a630cd275b413259601c0070b963f3c6d2185
Reviewed-on: https://go-review.googlesource.com/c/go/+/496515
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime: make trace.lock not reentrant
Michael Anthony Knyszek [Thu, 18 May 2023 14:21:05 +0000 (14:21 +0000)]
runtime: make trace.lock not reentrant

Currently trace.lock is reentrant in a few cases. AFAICT, this was
necessary a long time ago when the trace reader would goparkunlock, and
might flush a trace buffer while parking the goroutine. Today, that's no
longer true, since that always happens without the trace.lock held.

However, traceReadCPU does still rely on this behavior, since it could
get called either with trace.lock held, or without it held. The silver
lining here is that it doesn't *need* trace.lock to be held, so the
trace reader can just drop the lock to call traceReadCPU (this is
probably also nice for letting other goroutines flush while the trace
reader is reading from the CPU log).

Stress-tested with

$ stress ./trace.test -test.run="TestTraceCPUProfile|TestTraceStress|TestTraceStressStartStop"
...

42m0s: 24520 runs so far, 0 failures

Change-Id: I2016292c17fe7384050fcc0c446f5797c4e46437
Reviewed-on: https://go-review.googlesource.com/c/go/+/496296
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
12 months agoruntime: replace raw traceEv with traceBlockReason in gopark
Michael Anthony Knyszek [Wed, 17 May 2023 14:22:55 +0000 (14:22 +0000)]
runtime: replace raw traceEv with traceBlockReason in gopark

This change adds traceBlockReason which leaks fewer implementation
details of the tracer to the runtime. Currently, gopark is called with
an explicit trace event, but this leaks details about trace internals
throughout the runtime.

This change will make it easier to change out the trace implementation.

Change-Id: Id633e1704d2c8838c6abd1214d9695537c4ac7db
Reviewed-on: https://go-review.googlesource.com/c/go/+/494185
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

12 months agonet: make Dial fail faster on Windows closed loopback devices
qmuntal [Wed, 17 May 2023 16:21:04 +0000 (18:21 +0200)]
net: make Dial fail faster on Windows closed loopback devices

On Windows when connecting to an unavailable port, ConnectEx() will
retry for 2s, even on loopback devices.

This CL uses a call to WSAIoctl to make the ConnectEx() call fail
faster on local connections.

Fixes #23366

Change-Id: Iafeca8ea0053f01116b2504c45d88120f84d05e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/495875
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>