]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
8 months agonet/http: implement path value methods on Request
Jonathan Amsterdam [Wed, 13 Sep 2023 20:58:24 +0000 (16:58 -0400)]
net/http: implement path value methods on Request

Add Request.PathValue and Request.SetPathValue,
and the fields on Request required to support them.

Populate those fields in ServeMux.ServeHTTP.

Updates #61410.

Change-Id: Ic88cb865b0d865a30d3b35ece8e0382c58ef67d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/528355
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agocontext: support non-standard Context in Cause
Ian Lance Taylor [Mon, 11 Sep 2023 23:43:20 +0000 (16:43 -0700)]
context: support non-standard Context in Cause

If Cause is called on a non-standard Context, call ctx.Err.

Fixes #62582

Change-Id: Iac4ed93203eb5529f8839eb479b6ee2ee5ff6cbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/527277
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agonet/http: give ServeMux.handler a better name
Jonathan Amsterdam [Wed, 13 Sep 2023 20:00:45 +0000 (16:00 -0400)]
net/http: give ServeMux.handler a better name

Change-Id: I27bb7d9d5f172a84aa31304194b8a13036b9c5d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/528275
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agonet/http: add test for registration errors
Jonathan Amsterdam [Wed, 13 Sep 2023 19:58:25 +0000 (15:58 -0400)]
net/http: add test for registration errors

Change-Id: Ice378e2f1c4cce180f020683d25070c5ae1edbad
Reviewed-on: https://go-review.googlesource.com/c/go/+/528255
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agonet/http: scale rstAvoidanceDelay to reduce test flakiness
Bryan C. Mills [Mon, 11 Sep 2023 20:17:03 +0000 (16:17 -0400)]
net/http: scale rstAvoidanceDelay to reduce test flakiness

As far as I can tell, some flakiness is unavoidable in tests
that race a large client request write against a server's response
when the server doesn't read the full request.
It does not appear to be possible to simultaneously ensure that
well-behaved clients see EOF instead of ECONNRESET and also prevent
misbehaving clients from consuming arbitrary server resources.
(See RFC 7230 §6.6 for more detail.)

Since there doesn't appear to be a way to cleanly eliminate
this source of flakiness, we can instead work around it:
we can allow the test to adjust the hard-coded delay if it
sees a plausibly-related failure, so that the test can retry
with a longer delay.

As a nice side benefit, this also allows the tests to run more quickly
in the typical case: since the test will retry in case of spurious
failures, we can start with an aggressively short delay, and only back
off to a longer one if it is really needed on the specific machine
running the test.

Fixes #57084.
Fixes #51104.
For #58398.

Change-Id: Ia4050679f0777e5eeba7670307a77d93cfce856f
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-race,gotip-linux-amd64-race,gotip-windows-amd64-race
Reviewed-on: https://go-review.googlesource.com/c/go/+/527196
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

8 months agonet/http: ServeMux handles extended patterns
Jonathan Amsterdam [Wed, 13 Sep 2023 16:02:38 +0000 (12:02 -0400)]
net/http: ServeMux handles extended patterns

Modify ServeMux to handle patterns with methods and wildcards.

Remove the map and list of patterns. Instead patterns
are registered and matched using a routing tree.

We also reorganize the code around "trailing-slash redirection,"
the feature whereby a trailing slash is added to a path
if it doesn't match an existing one. The existing code
checked the map of paths twice, but searching the tree
twice would be needlessly expensive. The rewrite
searches the tree once, and then again only if a
trailing-slash redirection is possible.

There are a few omitted features in this CL, indicated
with TODOs.

Change-Id: Ifaef59f6c8c7b7131dc4a5d0f101cc22887bdc74
Reviewed-on: https://go-review.googlesource.com/c/go/+/528039
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
8 months agoos/exec: avoid calling LookPath in cmd.Start for resolved paths
Bryan C. Mills [Wed, 13 Sep 2023 16:02:52 +0000 (12:02 -0400)]
os/exec: avoid calling LookPath in cmd.Start for resolved paths

This reapplies CL 512155, which was previously reverted in CL 527337.
The race that prompted the revert should be fixed by CL 527820,
which will be submitted before this one.

For #36768.
Updates #62596.

Change-Id: I3c3cd92470254072901b6ef91c0ac52c8071e0a2
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-race,gotip-windows-amd64-race,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/528038
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

8 months agoos/exec: fix edge cases in Windows PATH resolution
Bryan C. Mills [Wed, 13 Sep 2023 15:41:00 +0000 (11:41 -0400)]
os/exec: fix edge cases in Windows PATH resolution

- Ignore empty entries in PATH, like PowerShell does.

- If we resolve a path using an explicit relative entry in PATH,
  treat it the same as we do for the implicit "." search path,
  by allowing a later (absolute) PATH entry that resolves to the
  same executable to return the absolute version of its path.

- If the requested path does not end with an extension matching
  PATHEXT, return ErrNotFound (indicating that we potentially searched
  for multiple alternatives and did not find one) instead of
  ErrNotExist (which would imply that we know the exact intended path
  but couldn't find it).

Fixes #61493.

Change-Id: I5b539d8616e3403825749d8eccf46725fa808a17
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-race,gotip-windows-amd64-race,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/528037
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agocmd/link: round up default start address to alignment
Cherry Mui [Wed, 13 Sep 2023 16:50:17 +0000 (12:50 -0400)]
cmd/link: round up default start address to alignment

If the -R flag (the segment alignment) is specified but the -T
flag (start address) is not, currently the default start address
may be under-aligned, and some math in the linker may be broken.
Round up the start address to align it.

Fixes #62064.

Change-Id: I3b98c9d0cf7d3cd944b9436a36808899d2e52572
Reviewed-on: https://go-review.googlesource.com/c/go/+/527822
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agocmd/compile/internal/pgo: remove stale comment
Michael Pratt [Tue, 12 Sep 2023 18:43:38 +0000 (14:43 -0400)]
cmd/compile/internal/pgo: remove stale comment

targetDeclFuncs was removed before CL 492436 was ever merged.

Change-Id: I1aafc28446ad23f63bcafc144b91f924dacd676e
Reviewed-on: https://go-review.googlesource.com/c/go/+/528176
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

8 months agoos/exec: avoid writing to Cmd.Path in Cmd.Start on Windows
Bryan C. Mills [Wed, 13 Sep 2023 13:58:17 +0000 (09:58 -0400)]
os/exec: avoid writing to Cmd.Path in Cmd.Start on Windows

Fixes #62596.

Change-Id: I9003318ac1c4e3036f32383e62e9ba08c383d5c2
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-race,gotip-windows-amd64-race,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/527820
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agoruntime/internal/atomic: add wasm And/Or operators
Mauri de Souza Meneguzzo [Sat, 9 Sep 2023 13:41:35 +0000 (13:41 +0000)]
runtime/internal/atomic: add wasm And/Or operators

In the WebAssembly version of these operators we avoid using
a CAS loop since the Go wasm implementation is single-threaded.

A new test file has been added that has build tags in order to
only test this feature on implemented architectures.

This is part of a series of CLs aimed to add the primitives
for And/Or atomic operations that will be used by the public
sync/atomic apis.

For #61395

Change-Id: Ic67ffefc9cfb626915ea86b6b21b500117710327
GitHub-Last-Rev: bbec3a5f356c55185af0357b929e76a9dfac230e
GitHub-Pull-Request: golang/go#62517
Reviewed-on: https://go-review.googlesource.com/c/go/+/526656
Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Keith Randall <khr@golang.org>

8 months agoruntime: silently allow pinning of non-Go pointers in runtime.Pinner.Pin
doujiang24 [Wed, 13 Sep 2023 09:44:19 +0000 (09:44 +0000)]
runtime: silently allow pinning of non-Go pointers in runtime.Pinner.Pin

People may not know the details of a pointer, this makes the
runtime.Pinner.Pin API easier to use.

Fixes #62356

Change-Id: I071df44e01320648a6df5e2a1e65afd6ea52e274
GitHub-Last-Rev: 560a581b63c6e7fe6c8829437e7ab3acd3b31514
GitHub-Pull-Request: golang/go#62549
Reviewed-on: https://go-review.googlesource.com/c/go/+/527156
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
8 months agoruntime: resolve false sharing for frequent memory allocate workloads
Li Gang [Tue, 5 Sep 2023 09:31:06 +0000 (17:31 +0800)]
runtime: resolve false sharing for frequent memory allocate workloads

False sharing observed inside mheap struct, between arenas and preceding
variables.Pad mheap.arenas and preceding variables to avoid false sharing

This false-sharing getting worse and impact performance on multi core
system and frequent memory allocate workloads. While running MinIO On a
2 socket system(56 Core per socket) and GOGC=1000, we observed HITM>8%
(perf c2c) on this cacheline.

After resolve this false-sharing issue, we got performance 17% improved.

Improvement verified on MinIO:
Server: https://github.com/minio/minio
Client: https://github.com/minio/warp
Config: Single node MinIO Server with 6 ramdisk, without TLS enabled,
        Run warp GET request, 128KB object and 512 concurrent

Fixes #62472

Signed-off-by: Li Gang<gang.g.li@intel.com>
Change-Id: I9a4a3c97f5bc8cd014c627f92d59d9187ebaaab5
Reviewed-on: https://go-review.googlesource.com/c/go/+/525955
Reviewed-by: Heschi Kreinick <heschi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

8 months agonet/http: use new Go Doc list syntax
Abhinav Gupta [Wed, 13 Sep 2023 15:55:06 +0000 (15:55 +0000)]
net/http: use new Go Doc list syntax

This tweaks the documentation for http.Client
to use the list syntax introduced in Go 1.19.

Change-Id: I1f7e0256c13f57e04fc76e5e2362608c8f9f524d
GitHub-Last-Rev: 11d384f9adb25605d44dbb7aaeec88fbb3b457ed
GitHub-Pull-Request: golang/go#62574
Reviewed-on: https://go-review.googlesource.com/c/go/+/527335
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

8 months agopath: use bytealg.LastIndexByteString
Tobias Klauser [Tue, 12 Sep 2023 21:09:48 +0000 (23:09 +0200)]
path: use bytealg.LastIndexByteString

While strings.LastIndex{,Byte} cannot be used in package path, the
respective internal/bytealg function can be used.

Change-Id: If0ecc36484308221f50875c8609913f6f2887fba
Reviewed-on: https://go-review.googlesource.com/c/go/+/527855
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
8 months agointernal/zstd: fix window resizing
Alexander Yastrebov [Sat, 9 Sep 2023 00:20:40 +0000 (00:20 +0000)]
internal/zstd: fix window resizing

Incorrect window resizing led to checksum error and invalid result.
To demonstrate the problem bigData must be a bit bigger, 3x is enough.

This change fixes window resizing, increases bigData size and decouples
TestLargeXXHash from bigData because it uses hardcoded hash value.

Change-Id: I50f74315b083f42e1ccd7ab2093e084f44631bb6
GitHub-Last-Rev: dbc90ba7a5f24db198cc3eab1c38aad665e41d06
GitHub-Pull-Request: golang/go#62543
Reviewed-on: https://go-review.googlesource.com/c/go/+/527115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agocmd/compile/internal/abi: replace types.Object with *ir.Name
Matthew Dempsky [Tue, 12 Sep 2023 04:57:45 +0000 (21:57 -0700)]
cmd/compile/internal/abi: replace types.Object with *ir.Name

types.Object only exists to avoid a circular dependency between
package types and ir.

Change-Id: I35196aff765d6977ca1e69fe482edbc987c381c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/527340
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
8 months agocmd/compile/internal/abi: use Type.Registers
Matthew Dempsky [Tue, 12 Sep 2023 04:13:10 +0000 (21:13 -0700)]
cmd/compile/internal/abi: use Type.Registers

Now that types can self-report how many registers they need, it's much
easier to determine whether a parameter will fit into the available
registers: simply compare the number of registers needed against the
number of registers still available.

This also eliminates the need for the NumParamRegs cache.

Also, the new code in NumParamRegs is stricter in only allowing it to
be called on types that can actually be passed in registers, which
requires a test to be corrected for that. While here, change mkstruct
to a variadic function, so the call sites require less boilerplate.

Change-Id: Iebe1a0456a8053a10e551e5da796014e5b1b695b
Reviewed-on: https://go-review.googlesource.com/c/go/+/527339
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
8 months agocmd/compile/internal/types: add Type.Registers
Matthew Dempsky [Tue, 12 Sep 2023 03:19:46 +0000 (20:19 -0700)]
cmd/compile/internal/types: add Type.Registers

To be used by package abi in the following CL.

Change-Id: Ic2470069e65f8d9b01ec161c28e5b86dca2ec141
Reviewed-on: https://go-review.googlesource.com/c/go/+/527338
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agosyscall: use SYS_SETRLIMIT in //sysnb setrlimit1 on linux/arm64
Tobias Klauser [Tue, 12 Sep 2023 09:46:25 +0000 (11:46 +0200)]
syscall: use SYS_SETRLIMIT in //sysnb setrlimit1 on linux/arm64

Otherwise the setrlimit1 wrapper would be generated using the inexistent
SYS_GETRLIMIT1 syscall number.

This was likely missed in CL 476097.

For #476097

Change-Id: I5cfa2ebacb58aeeaddd3db3639a45cf368fbe0ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/527555
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agoos/exec: simplify Windows-specific tests
Bryan C. Mills [Tue, 12 Sep 2023 18:50:50 +0000 (14:50 -0400)]
os/exec: simplify Windows-specific tests

- Use the test binary itself for printing paths instead of building a
  separate binary and running it through additional subprocesses.

- Factor out a common chdir helper.

- Use t.Setenv where appropriate.

- Reduce indirection in test helpers.

- Set NoDefaultCurrentDirectoryInExePath consistently in the
  environment.

Also add a test case demonstrating an interesting behavior for
relative paths that may interact with #62596.

Fixes #62594.
For #62596.

Change-Id: I19b9325034edf78cd0ca747594476cd7432bb451
Reviewed-on: https://go-review.googlesource.com/c/go/+/528035
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agotesting: use strings.LastIndexAny in (*common).decorate
Tobias Klauser [Tue, 12 Sep 2023 14:14:36 +0000 (16:14 +0200)]
testing: use strings.LastIndexAny in (*common).decorate

Change-Id: I14c521f4e599e14c71a52342b0ead5d0d4007f1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/527655
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agocmd/link: fix malformed .shstrtab section
Than McIntosh [Wed, 13 Sep 2023 13:26:41 +0000 (09:26 -0400)]
cmd/link: fix malformed .shstrtab section

For ELF targets, the code in the go linker that generates the
".shstrtab" section was using a loader symbol to accumulate the
contents of the section, then setting the section type to
sym.SELFROSECT. This resulted in a section whose offset indicated that
it fell into a loadable ELF segment, which is not how the .shstrtab is
supposed to work (it should be outside of all loadable segments,
similar to .strtab and .symtab). The peculiar .shstrtab caused
confusion in third party tools that operate on ELF files, notably
llvm-strip.

This patch rewrites the .shstrtab generation code to avoid using a
loader.Symbol and instead accumulate the contents of the section into
a regular byte slice, then emit the section's data in the same way
that .strtab is handled.

Fixes #62600.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: Ie54020d7b2d779d3ac9f5465fd505217d0681f79
Reviewed-on: https://go-review.googlesource.com/c/go/+/528036
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agogo/doc/comment: use slices.BinarySearch
qiulaidongfeng [Wed, 13 Sep 2023 13:14:15 +0000 (13:14 +0000)]
go/doc/comment: use slices.BinarySearch

Change-Id: Ifb28dd08faa59d9186a4a2337aab0c536d9a885e

Change-Id: Ifb28dd08faa59d9186a4a2337aab0c536d9a885e
GitHub-Last-Rev: dba95de0fbdafbef20a21f35b042a7a59f996a65
GitHub-Pull-Request: golang/go#62610
Reviewed-on: https://go-review.googlesource.com/c/go/+/527956
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
8 months agoarchive/tar: add AddFS method to Writer
Mauri de Souza Meneguzzo [Thu, 10 Aug 2023 21:13:11 +0000 (21:13 +0000)]
archive/tar: add AddFS method to Writer

The method AddFS can be used to add the contents of a fs.FS filesystem
to a tar archive. This method walks the directory tree starting at the root
of the filesystem and adds each file to the archive.

Fixes #58000

Change-Id: I0e6abac76b76bc5d95b74b7e5b37634ce3f76c85
GitHub-Last-Rev: 11a62bfd7ebc7ca93b1832da15018e6805c92520
GitHub-Pull-Request: golang/go#61599
Reviewed-on: https://go-review.googlesource.com/c/go/+/513316
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

8 months agogo/doc/comment: update TODO for isStdPkg
Jes Cok [Tue, 12 Sep 2023 22:43:28 +0000 (22:43 +0000)]
go/doc/comment: update TODO for isStdPkg

Even better is slices.BinarySearch, leave a TODO to update to that when possible.

Change-Id: Ie1ec75c34c0329c536725b45e520693790f0520e
GitHub-Last-Rev: 6cd811b186c95752794cead3ae747f54c2d0d0c5
GitHub-Pull-Request: golang/go#62585
Reviewed-on: https://go-review.googlesource.com/c/go/+/527341
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

8 months agocmd/compile: sparse conditional constant propagation
Yi Yang [Thu, 31 Aug 2023 02:48:34 +0000 (02:48 +0000)]
cmd/compile: sparse conditional constant propagation

sparse conditional constant propagation can discover optimization
opportunities that cannot be found by just combining constant folding
and constant propagation and dead code elimination separately.

This is a re-submit of PR#59575, which fix a broken dominance relationship caught by ssacheck

Updates https://github.com/golang/go/issues/59399

Change-Id: I57482dee38f8e80a610aed4f64295e60c38b7a47
GitHub-Last-Rev: 830016f24e3a5320c6c127a48ab7c84e2fc672eb
GitHub-Pull-Request: golang/go#60469
Reviewed-on: https://go-review.googlesource.com/c/go/+/498795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
8 months agoruntime: set _XOPEN_SORUCE_EXTENDED to 1 for aix
Michael Pratt [Tue, 12 Sep 2023 19:33:29 +0000 (15:33 -0400)]
runtime: set _XOPEN_SORUCE_EXTENDED to 1 for aix

aix requires that _XOPEN_SOURCE_EXTENDED is set to a number, not simply
defined.

For #62440.

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

8 months agocmd/compile: add a 'Tips' section to README to help new contributors
thepudds [Thu, 15 Jun 2023 19:09:11 +0000 (15:09 -0400)]
cmd/compile: add a 'Tips' section to README to help new contributors

This CL adds a new 'Tips' section to the cmd/compile README.

The primary intent is to help new-ish contributors.

It includes some basics on getting started, testing changes,
viewing coverage, juggling different compiler versions,
some links to additional tools, and so on.

Updates #30074

Change-Id: I393bf1137db9d2bb851f7e254b08455273ccad8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/503895
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: t hepudds <thepudds1460@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
8 months agoio/fs, path/filepath, cmd/gofmt: replace statDirEntry with fs.FileInfoToDirEntry
mstmdev [Tue, 12 Sep 2023 11:49:41 +0000 (11:49 +0000)]
io/fs, path/filepath, cmd/gofmt: replace statDirEntry with fs.FileInfoToDirEntry

Change-Id: Ie914367314ca72fab34c4d4529755dea853cf325
GitHub-Last-Rev: bc61665d33d7f15da371dcfb90c132fab25fc233
GitHub-Pull-Request: golang/go#62342
Reviewed-on: https://go-review.googlesource.com/c/go/+/523876
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
8 months agoos: fix TestRenameCaseDifference
Kir Kolyshkin [Sat, 9 Sep 2023 11:14:42 +0000 (04:14 -0700)]
os: fix TestRenameCaseDifference

Saw this failing on windows like this:

--- FAIL: TestRenameCaseDifference (2.96s)
--- FAIL: TestRenameCaseDifference/dir (1.64s)
    testing.go:1226: TempDir RemoveAll cleanup: remove C:\Users\gopher\AppData\Local\Temp\1\TestRenameCaseDifferencedir1375918868\001: The process cannot access the file because it is being used by another process.
--- FAIL: TestRenameCaseDifference/file (1.32s)
    testing.go:1226: TempDir RemoveAll cleanup: remove C:\Users\gopher\AppData\Local\Temp\1\TestRenameCaseDifferencefile3272269402\001: The process cannot access the file because it is being used by another process.
FAIL

The reason might be the directory fd is not closed. This may be
mitigated by retries in removeAll function from testing package,
but apparently it does not succeed all the time.

A link to the failed run which made me look into this: https://ci.chromium.org/ui/p/golang/builders/try/gotip-windows-386/b8770439049015378129/overview

Change-Id: Ibebe94958d1aef8d1d0eca8a969675708cd27a7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/527175
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agoall: calculate the median uniformly
Jes Cok [Tue, 12 Sep 2023 13:18:33 +0000 (13:18 +0000)]
all: calculate the median uniformly

This is a follow up of CL 526496.

Change-Id: I9f351951bf975e31befd36b9c951d195d2f8f9f7
GitHub-Last-Rev: 4307adafbffef7494d6f807b69df3e56328d6bf4
GitHub-Pull-Request: golang/go#62590
Reviewed-on: https://go-review.googlesource.com/c/go/+/527576
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agonet/http: routing tree
Jonathan Amsterdam [Mon, 11 Sep 2023 16:09:40 +0000 (12:09 -0400)]
net/http: routing tree

This CL implements a decision tree for efficient routing.
The tree holds all the registered patterns. To match
a request, we walk the tree looking for a match.

Change-Id: I7ed1cdf585fc95b73ef5ca2f942f278100a90583
Reviewed-on: https://go-review.googlesource.com/c/go/+/527315
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>

8 months agocmd/compile/internal/ir: add NewZero
Matthew Dempsky [Tue, 12 Sep 2023 11:51:16 +0000 (04:51 -0700)]
cmd/compile/internal/ir: add NewZero

This constructs a zero value of any type, which helps address some
corner case scenarios.

It should also eventually handle the predeclared "zero" value, at
least as currently implemented in go.dev/cl/520336.

For #61372.

Change-Id: I3a86a94fd8fa388c9c6bf281da8aa532b3da00fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/527696
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/compile/internal/dwarfgen: remove unversion
Matthew Dempsky [Tue, 12 Sep 2023 10:17:23 +0000 (03:17 -0700)]
cmd/compile/internal/dwarfgen: remove unversion

The unified export data format doesn't rely on embedding version
numbers in local variable names anymore, so there's no need to look
for them.

While here, simplify the checking for "~r" or "~b" to just "~",
because the next commit is going to eliminate "~b", but introduce
"~p".

Change-Id: I3ac73150ee561c66356a0c4aee5290b44a4893ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/527695
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
8 months agocmd/compile/internal/devirtualize: sort equal weight CallStat.Hottest by name
Michael Pratt [Tue, 12 Sep 2023 18:23:15 +0000 (14:23 -0400)]
cmd/compile/internal/devirtualize: sort equal weight CallStat.Hottest by name

When two callees have equal weight, we need to sort by another criteria
to ensure that we get stable output.

Note that this is only for the CallStat debug JSON output. The actual
callee selection already does this secondary sort in
findHotConcreteCallee.

Change-Id: I0de105623c5ccc793ca6f5799ea25e57bc286722
Reviewed-on: https://go-review.googlesource.com/c/go/+/527796
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agoruntime: set _XOPEN_SOURCE_EXTENDED for netbsd
Michael Pratt [Tue, 12 Sep 2023 17:35:15 +0000 (13:35 -0400)]
runtime: set _XOPEN_SOURCE_EXTENDED for netbsd

If _XOPEN_SOURCE is defined, then netbsd also requires
_XOPEN_SOURCE_EXTENDED to define stack_t.

For #62440.

Change-Id: Ib05658c3ca7fae1f6b051566e713ce7bc7c037a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/527775
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agoruntime: fix off-by-1 error in textOff
Cherry Mui [Tue, 12 Sep 2023 17:52:42 +0000 (13:52 -0400)]
runtime: fix off-by-1 error in textOff

The code meant to check if it is the last section, which is
i === len(md.textsectmap)-1. The -1 was missing.

Change-Id: Ifbb9e40df730abe3bec20fde5f56f5c75dfd9e8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/527795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
8 months agonet/http: mapping data structure
Jonathan Amsterdam [Mon, 11 Sep 2023 14:59:48 +0000 (10:59 -0400)]
net/http: mapping data structure

Our goal for the new ServeMux patterns is to match the routing
performance of the existing ServeMux patterns. To achieve that
we needed to optimize lookup for small maps.

This CL introduces a simple data structure called a mapping that
optimizes lookup by using a slice for small collections of key-value
pairs, switching to a map when the collection gets large.

Mappings are a core part of the routing algorithm, which uses a
decision tree to match path elements.   The children of a tree node are
held in a mapping.

Change-Id: I923b3ad1376ace2c3e3421aa9b802ad12d47c871
Reviewed-on: https://go-review.googlesource.com/c/go/+/526617
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
8 months agonet/http: pattern.conflictsWith
Jonathan Amsterdam [Fri, 8 Sep 2023 12:58:29 +0000 (08:58 -0400)]
net/http: pattern.conflictsWith

Add the conflictsWith method, which determines whether two patterns
conflict with each other.

Updates #61410.

Change-Id: Id4f9a471dc9d0420d927a68d2864128a096b74f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/526616
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agoruntime: allow update of system stack bounds on callback from C thread
Michael Pratt [Mon, 4 Sep 2023 13:55:01 +0000 (09:55 -0400)]
runtime: allow update of system stack bounds on callback from C thread

[This is a redo of CL 525455 with the test fixed on darwin by defining
_XOPEN_SOURCE, and disabled with android, musl, and openbsd, which do
not provide getcontext.]

Since CL 495855, Ms are cached for C threads calling into Go, including
the stack bounds of the system stack.

Some C libraries (e.g., coroutine libraries) do manual stack management
and may change stacks between calls to Go on the same thread.

Changing the stack if there is more Go up the stack would be
problematic. But if the calls are completely independent there is no
particular reason for Go to care about the changing stack boundary.

Thus, this CL allows the stack bounds to change in such cases. The
primary downside here (besides additional complexity) is that normal
systems that do not manipulate the stack may not notice unintentional
stack corruption as quickly as before.

Note that callbackUpdateSystemStack is written to be usable for the
initial setup in needm as well as updating the stack in cgocallbackg.

Fixes #62440.
For #62130.

Change-Id: I0fe0134f865932bbaff1fc0da377c35c013bd768
Reviewed-on: https://go-review.googlesource.com/c/go/+/527715
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
8 months agocmd/compile/internal/base: keep Ctxt.Flag_optimize in sync with Flag.N
Than McIntosh [Mon, 11 Sep 2023 16:15:48 +0000 (12:15 -0400)]
cmd/compile/internal/base: keep Ctxt.Flag_optimize in sync with Flag.N

This patch fixes an inconsistency in compiler flag handling introduced
accidentally in CL 521699. In the compiler we have both base.Flag.N
(which records whether the user has supplied the "-N" flag to disable
optimization) and base.Ctxt.Flag_optimize (which tracks whether
optimization is turned on). In this case Flag.N was updated without a
corresponding change to Ctxt.Flag_optimize, which led to problems with
DWARF generation for the runtime.

This CL doesn't include a regression test; a test will be added later
in the x/debug repo in a subsequent CL.

Updates #62523.

Change-Id: I0c383bb43ec0a0e7c12e7e2852c0590731416d6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/527319
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agoall: fix Microsoft links
qmuntal [Tue, 12 Sep 2023 12:48:12 +0000 (14:48 +0200)]
all: fix Microsoft links

This CL fixes the links to Microsoft documentation in the Go source
code. Some links were broken and some others were outdated.

Change-Id: I4c3bcd3aa3c07a31be1b7f94c25339dcc2e771e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/527556
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>

8 months agocmd/compile: remove typecheck.Orig* functions
Cuong Manh Le [Tue, 12 Sep 2023 03:45:54 +0000 (10:45 +0700)]
cmd/compile: remove typecheck.Orig* functions

Same as CL 526397, but for typecheck.

Change-Id: Ia8f19a54ffaa2ae3b86a4c66cbe6d973482796cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/526236
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/compile/internal/types: remove Type.vargen
Matthew Dempsky [Tue, 12 Sep 2023 01:50:26 +0000 (18:50 -0700)]
cmd/compile/internal/types: remove Type.vargen

The unified frontend diasmbiguates local types by putting vargen
directly into their symbol name instead. We no longer need a separate
int field for it.

Change-Id: I556c588ed68c5e2cb324cd46abd934894b5aaef9
Reviewed-on: https://go-review.googlesource.com/c/go/+/527517
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/compile: stop changing Field.Sym for parameters
Matthew Dempsky [Tue, 12 Sep 2023 00:45:37 +0000 (17:45 -0700)]
cmd/compile: stop changing Field.Sym for parameters

Field.Sym now always contains the original symbol as it appeared in Go
source, so we don't need OrigSym anymore.

Instead, when the mangled name is desired, Field.Nname.Sym() can be
used instead, which is always non-nil if Nname is non-nil.

Change-Id: I96cd61db6458d4a2e07ec5810239236e3dfba747
Reviewed-on: https://go-review.googlesource.com/c/go/+/527516
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
8 months agocmd/link: disable DWARF by default in c-shared mode on darwin
Cherry Mui [Mon, 11 Sep 2023 19:53:49 +0000 (15:53 -0400)]
cmd/link: disable DWARF by default in c-shared mode on darwin

Currently, linking a Go c-shared object with C code using Apple's
new linker, it fails with

% cc a.c go.so
ld: segment '__DWARF' filesize exceeds vmsize in 'go.so'

Apple's new linker has more checks for unmapped segments. It is
very hard to make it accept a Mach-O shared object with an
additional DWARF segment.

We may want to stop combinding DWARF into the shared object (see
also #62577). For now, disable DWARF by default in c-shared mode
on darwin. (One can still enable it with -ldflags=-w=0, which will
contain DWARF, but it will need the old C linker to link against
with.)

For #61229.

Change-Id: I4cc77da54fac10e2c2cbcffa92779cba82706d75
Reviewed-on: https://go-review.googlesource.com/c/go/+/527415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agocmd/compile/internal/typecheck: remove HasNamedResults check
Matthew Dempsky [Tue, 12 Sep 2023 00:23:55 +0000 (17:23 -0700)]
cmd/compile/internal/typecheck: remove HasNamedResults check

types2 has already checked for us that bare returns are valid, so no
need to duplicate the effort in typecheck.

Change-Id: I13b2387173966ba44058fbc841327896e04184e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/527515
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/compile: rename OEFACE to OMAKEFACE and remove OCONVIDATA
Matthew Dempsky [Mon, 11 Sep 2023 21:31:55 +0000 (14:31 -0700)]
cmd/compile: rename OEFACE to OMAKEFACE and remove OCONVIDATA

The "eface" in OEFACE suggests it's only for empty interfaces, and the
documentation suggests that too. But it's actually used for both empty
and non-empty interfaces, so rename to OMAKEFACE and adjust docs
accordingly.

Also, remove OCONVIDATA. This was used by the 1.18 frontend for
constructing interfaces containing derived types, but the unified
frontend always uses OCONVIFACE instead, so this is unused now.

Change-Id: I6ec5c62f909b26027f2804e5b3373b7a00029246
Reviewed-on: https://go-review.googlesource.com/c/go/+/527336
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agointernal/cpu: fix wrong cache line size of riscv64
Meng Zhuo [Fri, 8 Sep 2023 09:53:34 +0000 (17:53 +0800)]
internal/cpu: fix wrong cache line size of riscv64

All of riscv CPU using 64B for cache-line size.
i.e. U540 of Hifive Unleashed (https://www.sifive.com/boards/hifive-unleashed)

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

8 months agoRevert "os/exec: avoid calling LookPath in cmd.Start for resolved paths"
Ian Lance Taylor [Tue, 12 Sep 2023 00:07:55 +0000 (00:07 +0000)]
Revert "os/exec: avoid calling LookPath in cmd.Start for resolved paths"

This reverts CL 512155.

Reason for revert: CL 512155 introduced a race in that it caused
cmd.Start to set cmd.Path. Previously it was fine if code looked
at cmd.Path in one goroutine while calling cmd.Start in a different
goroutine.

A test case for this race is in CL 527495.

Change-Id: Ic18fdadf6763727f8ea748280d5f0e601b9bf374
Reviewed-on: https://go-review.googlesource.com/c/go/+/527337
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
8 months agocmd/compile/internal/ir: remove OSIZEOF, etc
Matthew Dempsky [Fri, 8 Sep 2023 23:25:02 +0000 (16:25 -0700)]
cmd/compile/internal/ir: remove OSIZEOF, etc

These are no longer needed after the previous CL, which moved handling
of unsafe.Sizeof, etc. directly into the unified frontend.

Change-Id: Ieb35ffca0bc25319e58132fb5d035c5b441acea7
Reviewed-on: https://go-review.googlesource.com/c/go/+/527098
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
8 months agocmd/compile/internal/noder: handle unsafe.Sizeof, etc in unified IR
Matthew Dempsky [Fri, 8 Sep 2023 23:21:17 +0000 (16:21 -0700)]
cmd/compile/internal/noder: handle unsafe.Sizeof, etc in unified IR

Previously, the unified frontend implemented unsafe.Sizeof, etc that
involved derived types by constructing a normal OSIZEOF, etc
expression, including fully instantiating their argument. (When
unsafe.Sizeof is applied to a non-generic type, types2 handles
constant folding it.)

This worked, but involves unnecessary work, since all we really need
to track is the argument type (and the field selections, for
unsafe.Offsetof).

Further, the argument expression could generate temporary variables,
which would then go unused after typecheck replaced the OSIZEOF
expression with an OLITERAL. This results in compiler failures after
CL 523315, which made later passes stricter about expecting the
frontend to not construct unused temporaries.

Fixes #62515.

Change-Id: I37baed048fd2e35648c59243f66c97c24413aa94
Reviewed-on: https://go-review.googlesource.com/c/go/+/527097
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

8 months agolog/slog: generate valid JSON string with empty attributes in Groups
Andy Pan [Sat, 19 Aug 2023 11:27:43 +0000 (19:27 +0800)]
log/slog: generate valid JSON string with empty attributes in Groups

Fixes #62152

Change-Id: I1f76ab26eae3a44292ebe6003006258d5e31d50f
Reviewed-on: https://go-review.googlesource.com/c/go/+/521135
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agonet/netip: add AddrPort.Compare and Prefix.Compare
David Anderson [Thu, 31 Aug 2023 22:46:45 +0000 (22:46 +0000)]
net/netip: add AddrPort.Compare and Prefix.Compare

Fixes #61642

Change-Id: I2262855dbe75135f70008e5df4634d2cfff76550
GitHub-Last-Rev: 949685a9e426f50f37753045d7527ebcccb082e7
GitHub-Pull-Request: golang/go#62387
Reviewed-on: https://go-review.googlesource.com/c/go/+/524616
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
8 months agocmd/go: cache results of exec.LookPath
qiulaidongfeng [Sat, 9 Sep 2023 00:58:21 +0000 (00:58 +0000)]
cmd/go: cache results of exec.LookPath

This CL package exec.LookPath to internal/cfg.LookPath and adds cache.

BenchmarkLookPath-4     24149096                50.48 ns/op            0 B/op          0 allocs/op

Fixes #36768

Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9

Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9
GitHub-Last-Rev: d67aa826f431affe829c23d1fdf2241fbb611303
GitHub-Pull-Request: golang/go#61464
Reviewed-on: https://go-review.googlesource.com/c/go/+/511458
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/compile/internal/staticinit: make staticopy safe
Matthew Dempsky [Thu, 24 Mar 2022 19:27:39 +0000 (12:27 -0700)]
cmd/compile/internal/staticinit: make staticopy safe

Currently, cmd/compile optimizes `var a = true; var b = a` into `var a
= true; var b = true`. But this may not be safe if we need to
initialize any other global variables between `a` and `b`, and the
initialization involves calling a user-defined function that reassigns
`a`.

This CL changes staticinit to keep track of the initialization
expressions that we've seen so far, and to stop applying the
staticcopy optimization once we've seen an initialization expression
that might have modified another global variable within this package.

To help identify affected initializers, this CL adds a -d=staticcopy
flag to warn when a staticcopy is suppressed and turned into a dynamic
copy.

Currently, `go build -gcflags=all=-d=staticcopy std` reports only four
instances:

```
encoding/xml/xml.go:1600:5: skipping static copy of HTMLEntity+0 with map[string]string{...}
encoding/xml/xml.go:1869:5: skipping static copy of HTMLAutoClose+0 with []string{...}
net/net.go:661:5: skipping static copy of .stmp_31+0 with poll.ErrNetClosing
net/http/transport.go:2566:5: skipping static copy of errRequestCanceled+0 with ~R0
```

Fixes #51913.

Change-Id: Iab41cf6f84c44f7f960e4e62c28a8aeaade4fbcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/395541
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
8 months agoruntime: avoid staticinit dependency with sigsetAllExiting
Matthew Dempsky [Wed, 11 May 2022 19:44:06 +0000 (12:44 -0700)]
runtime: avoid staticinit dependency with sigsetAllExiting

Currently, package runtime runs `osinit` before dynamic initialization
of package-scope variables; but on GOOS=linux, `osinit` involves
mutating `sigsetAllExiting`.

This currently works because cmd/compile and gccgo have
non-spec-conforming optimizations that statically initialize
`sigsetAllExiting`, but disabling that optimization causes
`sigsetAllExiting` to be dynamically initialized instead. This in turn
causes the mutations in `osinit` to get lost.

This CL moves the initialization of `sigsetAllExiting` from `osinit`
into its initialization expression, and then removes the special case
for continuing to perform the static-initialization optimization for
package runtime.

Updates #51913.

Change-Id: I3be31454277c103372c9701d227dc774b2311dad
Reviewed-on: https://go-review.googlesource.com/c/go/+/405549
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/compile/internal/ir: add missing SetTypecheck
Matthew Dempsky [Wed, 30 Aug 2023 11:19:35 +0000 (04:19 -0700)]
cmd/compile/internal/ir: add missing SetTypecheck

This was missed earlier, because NewConstAt is only used now to
construct the predeclared "true" and "false" constants. But these
constants are no longer actually accessed with unified IR.

For constant expressions, types2 (and go/types) sets
TypeAndValue.Value for the expression to the appropriate constant
value. The unified writer recognizes when expressions are constants,
and simply writes the underlying value, regardless of the original
expression. As a result, we never end up actually referencing the
*named* "true" and "false" constants; we just always construct
anonymous constant "true" and "false" values.

However, a manually constructed tree that includes an *ir.Name that
"Uses" the predeclared true/false Const Objects, yet doesn't set
TypeAndValue.Value will instead end up trying to use named constants
constructed with NewConstAt.

Thanks to Russ for reporting the issue on CL 510541, and to Cuong for
identifying the fix.

Change-Id: I0614105379d63ea76d7244ebd1e4db5c239d4670
Reviewed-on: https://go-review.googlesource.com/c/go/+/524357
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agonet/http: extended routing patterns
Jonathan Amsterdam [Fri, 8 Sep 2023 00:14:47 +0000 (20:14 -0400)]
net/http: extended routing patterns

This is the first of several CLs implementing the proposal
for enhanced ServeMux routing, https://go.dev/issue/61410.

Define a type to represent extended routing patterns and a function to
parse a string into one.

Updates #61410.

Change-Id: I779689acf1f14b20d12c9264251f7dc002b68c49
Reviewed-on: https://go-review.googlesource.com/c/go/+/526815
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agocmd/compile/internal/inline/inlheur: fixup tests for NewBasicLit change
Than McIntosh [Mon, 11 Sep 2023 16:27:17 +0000 (12:27 -0400)]
cmd/compile/internal/inline/inlheur: fixup tests for NewBasicLit change

Fix a regression test to use the correct new signature for
ir.NewBasicLit.

Change-Id: I06c849e83a5edfce784c780b5490f461f6c3b129
Reviewed-on: https://go-review.googlesource.com/c/go/+/527318
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agoRevert "runtime: allow update of system stack bounds on callback from C thread"
Michael Pratt [Mon, 11 Sep 2023 16:18:51 +0000 (12:18 -0400)]
Revert "runtime: allow update of system stack bounds on callback from C thread"

This reverts CL 525455. The test fails to build on darwin, alpine, and
android.

For #62440.

Change-Id: I39c6b1e16499bd61e0f166de6c6efe7a07961e62
Reviewed-on: https://go-review.googlesource.com/c/go/+/527317
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
8 months agoRevert "runtime: set stackguard1 on extra M g0"
Michael Pratt [Mon, 11 Sep 2023 16:17:40 +0000 (12:17 -0400)]
Revert "runtime: set stackguard1 on extra M g0"

This reverts CL 527056.

CL 525455 breaks darwin, alpine, and android. This CL must be reverted
in order to revert that CL.

For #62440.

Change-Id: I4e1b16e384b475a605e0214ca36c918d50faa22c
Reviewed-on: https://go-review.googlesource.com/c/go/+/527316
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agoruntime: don't clear procid on netbsd
Michael Pratt [Fri, 8 Sep 2023 21:59:02 +0000 (17:59 -0400)]
runtime: don't clear procid on netbsd

This is a partial revert of CL 526118.

NetBSD uses mp.procid in locking (semawake). unminit is called
surprisingly early in mexit, and there is definitely locking after that
point, so it isn't safe to clear procid so early.

Fixes #62524.
Fixes #62531.

Change-Id: Iefbef63e84fc0395e255970a301401e1187a910d
Reviewed-on: https://go-review.googlesource.com/c/go/+/527057
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
8 months agocmd/compile/internal/ir: add Type param to NewBasicLit
Matthew Dempsky [Fri, 8 Sep 2023 22:44:57 +0000 (15:44 -0700)]
cmd/compile/internal/ir: add Type param to NewBasicLit

This CL adds an explicit Type parameter to NewBasicLit so that callers
can directly construct typed OLITERAL nodes.

Change-Id: I0ab50ac3d7ddb7adcc903633a62ac496921165e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/527096
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
8 months agocmd/compile/internal/typecheck: fix closure field naming
Matthew Dempsky [Sat, 9 Sep 2023 01:04:31 +0000 (18:04 -0700)]
cmd/compile/internal/typecheck: fix closure field naming

When creating the struct type to hold variables captured by a function
literal, we currently reuse the captured variable names as fields.

However, there's no particular reason to do this: these struct types
aren't visible to users, and it adds extra complexity in making sure
fields belong to the correct packages.

Further, it turns out we were getting that subtly wrong. If two
function literals from different packages capture variables with
identical names starting with an uppercase letter (and in the same
order and with corresponding identical types) end up in the same
function (e.g., due to inlining), then we could end up creating
closure struct types that are "different" (i.e., not types.Identical)
yet end up with equal LinkString representations (which violates
LinkString's contract).

The easy fix is to just always use simple, exported, generated field
names in the struct. This should allow further struct reuse across
packages too, and shrink binary sizes slightly.

Fixes #62498.

Change-Id: I9c973f5087bf228649a8f74f7dc1522d84a26b51
Reviewed-on: https://go-review.googlesource.com/c/go/+/527135
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agoruntime: set stackguard1 on extra M g0
Michael Pratt [Fri, 8 Sep 2023 18:54:29 +0000 (14:54 -0400)]
runtime: set stackguard1 on extra M g0

Standard Ms set g0.stackguard1 to the same value as stackguard0 in
mstart0. For consistency, extra Ms should do the same for their g0. Do
this in needm -> callbackUpdateSystemStack.

Background: getg().stackguard1 is used as the stack guard for the stack
growth prolouge in functions marked //go:systemstack [1]. User Gs set
stackguard1 to ^uintptr(0) so that the check always fail, calling
morestackc, which throws to report a //go:systemstack function call on a
user stack.

g0 setting stackguard1 is unnecessary for this functionality. 0 would be
sufficient, as g0 is always allowed to call //go:systemstack functions.
However, since we have the check anyway, setting stackguard1 to the
actual stack bound is useful to detect actual stack overflows on g0
(though morestackc doesn't detect this case and would report a
misleading message about user stacks).

[1] cmd/internal/obj calls //go:systemstack functions AttrCFunc. This is
a holdover from when the runtime contained actual C functions. But since
CL 2275, it has simply meant "pretend this is a C function, which would
thus need to use the system stack". Hence the name morestackc. At this
point, this terminology is pretty far removed from reality and should
probably be updated to something more intuitive.

Change-Id: I8d0e5628ce31ac6a189a7d7a4124be85aef89862
Reviewed-on: https://go-review.googlesource.com/c/go/+/527056
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
8 months agoruntime: allow update of system stack bounds on callback from C thread
Michael Pratt [Mon, 4 Sep 2023 13:55:01 +0000 (09:55 -0400)]
runtime: allow update of system stack bounds on callback from C thread

Since CL 495855, Ms are cached for C threads calling into Go, including
the stack bounds of the system stack.

Some C libraries (e.g., coroutine libraries) do manual stack management
and may change stacks between calls to Go on the same thread.

Changing the stack if there is more Go up the stack would be
problematic. But if the calls are completely independent there is no
particular reason for Go to care about the changing stack boundary.

Thus, this CL allows the stack bounds to change in such cases. The
primary downside here (besides additional complexity) is that normal
systems that do not manipulate the stack may not notice unintentional
stack corruption as quickly as before.

Note that callbackUpdateSystemStack is written to be usable for the
initial setup in needm as well as updating the stack in cgocallbackg.

Fixes #62440.
For #62130.

Change-Id: I7841b056acea1111bdae3b718345a3bd3961b4a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/525455
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agocmd/compile/internal/typecheck: use constant.MakeUnknown()
qiulaidongfeng [Sun, 10 Sep 2023 04:33:34 +0000 (04:33 +0000)]
cmd/compile/internal/typecheck: use constant.MakeUnknown()

Complete a TODO.

Change-Id: I1bd23f0be725c9dd81b8316a7abba1bceecc346f

Change-Id: I1bd23f0be725c9dd81b8316a7abba1bceecc346f
GitHub-Last-Rev: 51523084a3675b91cdf49491bbaa9e78f78e3742
GitHub-Pull-Request: golang/go#62553
Reviewed-on: https://go-review.googlesource.com/c/go/+/527178
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

8 months agocmd/go/internal/generate: error if failed to find a package
Kirill Che [Fri, 8 Sep 2023 07:45:12 +0000 (07:45 +0000)]
cmd/go/internal/generate: error if failed to find a package

Add check for package loader to print error and fail `go generate` command,
if package can not be found.

Fixes #60079

Change-Id: Ib9e730c2b69df6e5ac307c7bdfea0ee993ab6ed8
GitHub-Last-Rev: d93332425a980d0298c74f33f1d154e0afbf5373
GitHub-Pull-Request: golang/go#60178
Reviewed-on: https://go-review.googlesource.com/c/go/+/494836
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agoall: calculate the median uniformly
Jes Cok [Thu, 7 Sep 2023 11:07:30 +0000 (11:07 +0000)]
all: calculate the median uniformly

Like sort.Search, use "h := int(uint(i+j) >> 1)" style code to calculate
the median.

Change-Id: Ifb1a19dde1c6ed6c1654bc642fc9565a8b6c5fc4
GitHub-Last-Rev: e2213b738832f1674948d6507f40e2c0b98cb972
GitHub-Pull-Request: golang/go#62503
Reviewed-on: https://go-review.googlesource.com/c/go/+/526496
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
8 months agocmd/compile/internal/inline/inlheur: delete ConstExpr case
Dmitri Shuralyov [Fri, 8 Sep 2023 23:28:58 +0000 (19:28 -0400)]
cmd/compile/internal/inline/inlheur: delete ConstExpr case

ir.ConstExpr was deleted in CL 526395, so no need to check for it.
Fixes the build error.

Change-Id: I642dab70d17369bc7c9ae880666ef42ff099b770
Reviewed-on: https://go-review.googlesource.com/c/go/+/526196
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
8 months agoRevert "cmd/cgo: silence unaligned-access"
Than McIntosh [Fri, 8 Sep 2023 23:07:12 +0000 (23:07 +0000)]
Revert "cmd/cgo: silence unaligned-access"

This reverts commit http://go.dev/cl/c/go/+/526915

Reason for revert: darwin builders unhappy with '-Wunaligned-access' C compiler flag

Change-Id: I5e6ca7c9a0ca08b7e758b7f603da70a2fca79b58
Reviewed-on: https://go-review.googlesource.com/c/go/+/526978
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agoruntime: test change to adapt to new inliner
Than McIntosh [Mon, 14 Aug 2023 13:41:43 +0000 (09:41 -0400)]
runtime: test change to adapt to new inliner

The new inliner tries to de-prioritize inlining of call sites on panic
paths, e.g. for a call such as the one to "foo" below, the inliner
will use a much lower size threshold when deciding whether to inline,
since the path is very likely to be "cold".

   if mumble() {
      foo()           <<-- here
      panic("bad")
   }

This patch reworks one of the traceback tests is relying on the old
inliner's "inline F everywhere if F inlinable" strategy by tweaking
the code slightly (no change in test functionality).

Change-Id: I83a686b0cc4d94a6cfc63d1e84e45455c1afd5b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/519196
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
8 months agocmd/compile/internal/inline/inlheur: assign scores to callsites
Than McIntosh [Tue, 18 Jul 2023 20:17:12 +0000 (16:17 -0400)]
cmd/compile/internal/inline/inlheur: assign scores to callsites

Assign scores to callsites based on previously computed function
properties and callsite properties. This currently works by taking the
size score for the function (as computed by CanInline) and then making
a series of adjustments, positive or negative based on various
function and callsite properties.

NB: much work also remaining on deciding what are the best score
adjustment values for specific heuristics. I've picked a bunch of
arbitrary constants, but they will almost certainly need tuning and
tweaking to arrive at something that has good performance.

Updates #61502.

Change-Id: I887403f95e76d7aa2708494b8686c6026861a6ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/511566
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/compile/internal/inline: add call site flag generation
Than McIntosh [Tue, 18 Jul 2023 15:45:42 +0000 (11:45 -0400)]
cmd/compile/internal/inline: add call site flag generation

Add code to detect call sites that are nested in loops, call sites
that are on an unconditional path to panic/exit, and call sites within
"init" functions. The panic-path processing reuses some of the
logic+state already present for the function flag version of "calls
panic/exit".

Updates #61502.

Change-Id: I1d728e0763282d3616a9cbc0a07c5cda115660f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/511565
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/compile/internal/inline: build call site table
Than McIntosh [Wed, 12 Jul 2023 20:13:39 +0000 (16:13 -0400)]
cmd/compile/internal/inline: build call site table

Build up a table of (potentially) inlinable call sites during inline
heuristic analysis, and introduce a framework for analyzing each call
site to collect applicable flags (for example, is call nested in
loop). This patch doesn't include any of the flag analysis, just the
machinery to collect the callsites and a regression test harness.

Updates #61502.

Change-Id: Ieaf4a008ac9868e9762c63f5b59bd264dc71ab30
Reviewed-on: https://go-review.googlesource.com/c/go/+/511564
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/compile/internal/inline: extend flag calculation via export data
Than McIntosh [Tue, 11 Jul 2023 16:42:12 +0000 (12:42 -0400)]
cmd/compile/internal/inline: extend flag calculation via export data

Extend the code that computes various properties and parameter flags
to incorporate information from export data in addition to things we
can get from the current package. Specifically:

 - when deciding whether the current function always calls panic/exit,
   check to see whether it has an unconditional call to some other
   function that has that flag.

 - when computing "parameter feeds" properties, look not just for
   cases where a parameter feeds an interesting construct (if/switch,
   indirect/interface call, etc) but where it feeds a call whose
   corresponding param has that flag.

 - when computing return properties, if a given return is always the
   results of a call to X, then set the return properties to those
   of X.

Updates #61502.

Change-Id: I6472fe98759cccad05b8eed58e4fc568201d88ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/511563
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/compile: write "properties" to export data for inlinable funcs
Than McIntosh [Thu, 29 Jun 2023 17:22:26 +0000 (13:22 -0400)]
cmd/compile: write "properties" to export data for inlinable funcs

Augment the ir.Inline container to include an entry for function
properties (currently serialized as a string), and if
GOEXPERIMENT=newinliner is set, compute and store function
properties for all inline candidates processed by the inliner.

The idea here is that if the function properties are going to drive
inlining decisions, we'd like to have the same info from non-local /
imported functions as for local / in-package functions, hence we need
to include the properties in the export data.

Hand testing on the compiler itself and with k8s kubelet shows that
this increases the size of export data overall by about 2-3 percent,
so a pretty modest increase.

Updates #61502.

Change-Id: I9d1c311aa8418d02ffea3629c3dd9d8076886d15
Reviewed-on: https://go-review.googlesource.com/c/go/+/511562
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
8 months agocmd/compile/internal/inline: analyze function param properties
Than McIntosh [Fri, 30 Jun 2023 20:44:31 +0000 (16:44 -0400)]
cmd/compile/internal/inline: analyze function param properties

Add code to analyze properties of function params, specifically
heuristics to look for cases where unmodified params feed into "if"
and "switch" statements in ways that might enable constant folding
and/or dead code elimination if the call were inlined at a callsite
that passes a constant to the correct param. We also look for cases
where a function parameter feeds unmodified into an interface method
call or indirect call.

Updates #61502.

Change-Id: Iaf7297e19637daeabd0ec72be88d654b545546ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/511561
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
8 months agocmd/cgo: silence unaligned-access
Egon Elbre [Fri, 8 Sep 2023 08:17:59 +0000 (11:17 +0300)]
cmd/cgo: silence unaligned-access

Clang 14+ introduced a warning when using mixed packed and unpacked structs.
This can cause problems when taking an address of the unpacked struct, which
may end up having a different alignment than expected.

This is not a problem in cgo, which does not take pointers from the packed
struct.

Fixes #62480

Change-Id: If5879eea5e1b77bc6dc7430f68f8c916bff9b090
Reviewed-on: https://go-review.googlesource.com/c/go/+/526915
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agonet: synchronize calls to Close in the withTCPConnPair test helper
Bryan C. Mills [Fri, 8 Sep 2023 20:39:17 +0000 (16:39 -0400)]
net: synchronize calls to Close in the withTCPConnPair test helper

withTCPConnPair is supposed to return only when both peer functions
have completed. However, due to the use of "defer" it was closing the
peers' connections after the synchronization point instead of before.

Fixes #62542.

Change-Id: I3e06c78984664172ff2d28b0fc582b8182f710f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/526977
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Commit-Queue: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agotesting/slogtest: add Run to run cases as subtests
Jonathan Amsterdam [Fri, 4 Aug 2023 17:33:35 +0000 (13:33 -0400)]
testing/slogtest: add Run to run cases as subtests

This is an implementation of proposal #61758.

It adds a function to slogtest that runs each test case in a subtest,
instead of running them all at once.

That allows the caller to control which cases are run.

Fixes #61706.
Fixes #61758.

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

8 months agoruntime: dump rdx on windows
Michael Pratt [Fri, 8 Sep 2023 20:12:44 +0000 (16:12 -0400)]
runtime: dump rdx on windows

CL 177090043 accidentally dropped RDX when converting from C.

Change-Id: I6bf9dc1b1d0c2850967005c048245d1185dcede4
Reviewed-on: https://go-review.googlesource.com/c/go/+/526976
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

9 months agoruntime: unskip TestG0StackOverflow
Cherry Mui [Mon, 28 Aug 2023 18:59:13 +0000 (14:59 -0400)]
runtime: unskip TestG0StackOverflow

The stack bounds from pthread are not always accurate, and could
cause seg fault if we run out of the actual stack space before
reaching the bounds. Here we use an artificially small stack bounds
to check overflow without actually running out of the system stack.

Change-Id: I8067c5e1297307103b315d9d0c60120293b57aab
Reviewed-on: https://go-review.googlesource.com/c/go/+/523695
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/ssa: replace Frontend.Auto with Func.NewLocal
Matthew Dempsky [Thu, 7 Sep 2023 05:42:11 +0000 (22:42 -0700)]
cmd/compile/internal/ssa: replace Frontend.Auto with Func.NewLocal

Change-Id: I0858568d225daba1c318842dc0c9b5e652dff612
Reviewed-on: https://go-review.googlesource.com/c/go/+/526519
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agocmd/compile/internal/ssagen: call AllocFrame after ssa.Compile
Matthew Dempsky [Thu, 7 Sep 2023 05:33:24 +0000 (22:33 -0700)]
cmd/compile/internal/ssagen: call AllocFrame after ssa.Compile

This indirection is no longer necessary.

Change-Id: Ibb5eb1753febdc17a93ea9c35130e3d2b26c360e
Reviewed-on: https://go-review.googlesource.com/c/go/+/526518
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agoencoding: modernize Go documentation
Joe Tsai [Fri, 1 Sep 2023 08:54:25 +0000 (01:54 -0700)]
encoding: modernize Go documentation

Across all encoding packages, linkify declarations if possible.
In some cases, we convert a code block into a bulleted list,
which then further allows for more linkification.

Change-Id: I68fedf362615b34228bab5d4859b7d87d831c570
Reviewed-on: https://go-review.googlesource.com/c/go/+/524977
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/compile/internal/ssa: rename ssagen.TypeOK as CanSSA
Matthew Dempsky [Thu, 7 Sep 2023 05:03:07 +0000 (22:03 -0700)]
cmd/compile/internal/ssa: rename ssagen.TypeOK as CanSSA

No need to indirect through Frontend for this.

Change-Id: I5812eb4dadfda79267cabc9d13aeab126c1479e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/526517
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/ssa: remove Frontend.MyImportPath
Matthew Dempsky [Thu, 7 Sep 2023 04:48:28 +0000 (21:48 -0700)]
cmd/compile/internal/ssa: remove Frontend.MyImportPath

This method is only used to find the path of the function being
compiled for hash debugging, but it was instead returning the path of
the package being compiled. These are typically the same, but can be
different for certain functions compiled across package boundaries
(e.g., method value wrappers and generic functions).

It's redundant either with f.fe.Func().Sym().Pkg.Path (package path of
the function being compiled) or f.Config.ctxt.Pkgpath (package path of
the compilation unit), so just remove it instead.

Change-Id: I1daae09055043d0ecb1fcc874a0b0006a6f8bddf
Reviewed-on: https://go-review.googlesource.com/c/go/+/526516
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agocmd/compile/internal/ssa: simplify NewFunc API
Matthew Dempsky [Thu, 7 Sep 2023 04:43:58 +0000 (21:43 -0700)]
cmd/compile/internal/ssa: simplify NewFunc API

Add Config and Cache as params rather than documenting that the caller
has to set them manually.

Change-Id: I8d530be695a0c94bcc4211b496d6e57ec2fff029
Reviewed-on: https://go-review.googlesource.com/c/go/+/526515
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocmd/compile: cleanup uses of ir.Orig and ir.SepCopy
Matthew Dempsky [Wed, 6 Sep 2023 23:11:34 +0000 (16:11 -0700)]
cmd/compile: cleanup uses of ir.Orig and ir.SepCopy

Mostly automated refactoring with gofmt:

gofmt -r 'ir.Orig(n) -> n'
gofmt -r 'ir.SepCopy(n) -> ir.Copy(n)'

Followed by some manual cleanups.

Change-Id: Ib35abeba9e60b70ba463e161fb39358fb058a83e
Reviewed-on: https://go-review.googlesource.com/c/go/+/526398
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/ir: remove OrigNode
Matthew Dempsky [Wed, 6 Sep 2023 23:05:11 +0000 (16:05 -0700)]
cmd/compile/internal/ir: remove OrigNode

The OrigNode functionality used to be relevant to the typecheck
frontend, because we wanted to report errors using the same syntax as
the user originally wrote. However, now that types2 handles all
spec-required error diagnostics, there's no need to preserve original
nodes anymore.

Change-Id: I64a0540b8952513913021e7b84d165beb1f9f801
Reviewed-on: https://go-review.googlesource.com/c/go/+/526397
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/ir: simplify formatting of CompLitExpr
Matthew Dempsky [Wed, 6 Sep 2023 23:03:38 +0000 (16:03 -0700)]
cmd/compile/internal/ir: simplify formatting of CompLitExpr

Composite literals always have a type now, so the extra fallback code
isn't necessary. But also, to prepare for the upcoming removal of
OrigNode, we need to print OSLICELIT with Implicit set as
"... argument" to satisfy existing regress tests.

Change-Id: I365e879066903eebf1b78e10c1b505565cea3ce3
Reviewed-on: https://go-review.googlesource.com/c/go/+/526396
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agocmd/internal/ir: remove ConstExpr in favor of BasicLit
Matthew Dempsky [Wed, 6 Sep 2023 22:52:55 +0000 (15:52 -0700)]
cmd/internal/ir: remove ConstExpr in favor of BasicLit

OrigNode will be going away soon, which is the only reason for
ConstExpr to exist. Otherwise, it's identical to BasicLit.

To keep existing code working, change NewConstExpr to construct and
return a BasicLit instead.

Change-Id: I68b43ec1fcaa57e6723f289ce9f953996aeefb14
Reviewed-on: https://go-review.googlesource.com/c/go/+/526395
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/compile/internal/noder: stop preserving original const strings
Matthew Dempsky [Wed, 6 Sep 2023 21:00:30 +0000 (14:00 -0700)]
cmd/compile/internal/noder: stop preserving original const strings

One of the more tedious quirks of the original frontend (i.e.,
typecheck) to preserve was that it preserved the original
representation of constants into the backend. To fit into the unified
IR model, I ended up implementing a fairly heavyweight workaround:
simply record the original constant's string expression in the export
data, so that diagnostics could still report it back, and match the
old test expectations.

But now that there's just a single frontend to support, it's easy
enough to just update the test expectations and drop this support for
"raw" constant expressions.

Change-Id: I1d859c5109d679879d937a2b213e777fbddf4f2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/526376
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agoruntime: increase g0 stack size in non-cgo case
Cherry Mui [Fri, 8 Sep 2023 16:14:30 +0000 (12:14 -0400)]
runtime: increase g0 stack size in non-cgo case

Currently, for non-cgo programs, the g0 stack size is 8 KiB on
most platforms. With PGO which could cause aggressive inlining in
the runtime, the runtime stack frames are larger and could
overflow the 8 KiB g0 stack. Increase it to 16 KiB. This is only
one per OS thread, so it shouldn't increase memory use much.

Fixes #62120.
Fixes #62489.

Change-Id: I565b154517021f1fd849424dafc3f0f26a755cac
Reviewed-on: https://go-review.googlesource.com/c/go/+/526995
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/internal/obj: mark unspill code in prologue preemptible
zhouguangyuan [Wed, 6 Sep 2023 16:09:31 +0000 (00:09 +0800)]
cmd/internal/obj: mark unspill code in prologue preemptible

The UnspillReg code should always be preemptible because all the arg registers will be saved by runtime.asyncpreempt.

Change-Id: Ie36b5d0cdd1275efcb95661354d83be2e1b00a86
Reviewed-on: https://go-review.googlesource.com/c/go/+/526235
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agosyscall: skip unshare tests if mount syscall is not available
Dmitri Shuralyov [Fri, 8 Sep 2023 00:21:44 +0000 (20:21 -0400)]
syscall: skip unshare tests if mount syscall is not available

CL 513779 added crude skips for tests that couldn't work when run under
'unshare --net --map-root-user' as used by the current iteration of the
no-network check in LUCI. Bryan suggested a more targeted way to detect
when the environment is insufficient, which makes it possible to remove
the builder-specific skip and its slightly incorrect explaining comment.

Updates #30612.

Change-Id: I0de79f44ab94d7f1018384c2e959ca7df3a1b0ae
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-amd64-longtest-race
Reviewed-on: https://go-review.googlesource.com/c/go/+/526835
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>