]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
12 months agohtml/template: expose ErrJSTemplate
cuiweixie [Fri, 19 May 2023 02:07:04 +0000 (10:07 +0800)]
html/template: expose ErrJSTemplate

Fixes #59584

Change-Id: Iabe61476c7457dfffbfe5d0b1fe904901a466c73
Reviewed-on: https://go-review.googlesource.com/c/go/+/496395
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
12 months agoruntime: flush idle time to sched.idleTime on limiter event consumption
Michael Anthony Knyszek [Thu, 18 May 2023 17:19:37 +0000 (17:19 +0000)]
runtime: flush idle time to sched.idleTime on limiter event consumption

This was an oversight, which might cause accounted-for idle time to be
lost. Noticed this while working on #60276.

Change-Id: Ic743785d6dc82555e660f2c9b6aaa9dedef56ed8
Reviewed-on: https://go-review.googlesource.com/c/go/+/496117
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
12 months agoruntime: fix lockrank ordering for pinner implementation
Michael Anthony Knyszek [Fri, 19 May 2023 15:56:07 +0000 (15:56 +0000)]
runtime: fix lockrank ordering for pinner implementation

The new Pinner API's implementation imposes some partial-orders that are
safe but previously did not exist between a mspanSpecial, mheapSpecial,
and mheap. Fix that up in the lock ranking.

For #46787.

Change-Id: I51cc8f7f069240caeb44d749bed43515634f4814
Reviewed-on: https://go-review.googlesource.com/c/go/+/496193
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>

12 months agomaps,runtime: improve maps.Keys
cuiweixie [Sun, 2 Apr 2023 07:49:58 +0000 (15:49 +0800)]
maps,runtime: improve maps.Keys

name     old time/op    new time/op    delta
Keys-10    8.65ms ± 0%    7.06ms ± 0%  -18.41%  (p=0.000 n=9+9)

name     old alloc/op   new alloc/op   delta
Keys-10    58.2kB ± 1%    47.4kB ± 2%  -18.54%  (p=0.000 n=10+10)

name     old allocs/op  new allocs/op  delta
Keys-10      0.00           0.00          ~     (all equal)

Change-Id: Ia7061c37be89e906e79bc3ef3bb1ef0d7913f9f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/481435
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: xie cui <523516579@qq.com>

12 months agoruntime: implement Pinner API for object pinning
Sven Anderson [Sun, 28 Nov 2021 04:05:16 +0000 (13:05 +0900)]
runtime: implement Pinner API for object pinning

Some C APIs require the use or structures that contain pointers to
buffers (iovec, io_uring, ...).  The pointer passing rules would
require that these buffers are allocated in C memory and to process
this data with Go libraries it would need to be copied.

In order to provide a zero-copy way to use these C APIs, this CL
implements a Pinner API that allows to pin Go objects, which
guarantees that the garbage collector does not move these objects
while pinned.  This allows to relax the pointer passing rules so that
pinned pointers can be stored in C allocated memory or can be
contained in Go memory that is passed to C functions.

The Pin() method accepts pointers to objects of any type and
unsafe.Pointer.  Slices and arrays can be pinned by calling Pin()
with the pointer to the first element.  Pinning of maps is not
supported.

If the GC collects unreachable Pinner holding pinned objects it
panics.  If Pin() is called with the other non-pointer types it
panics as well.

Performance considerations: This change has no impact on execution
time on existing code, because checks are only done in code paths,
that would panic otherwise.  The memory footprint on existing code is
one pointer per memory span.

Fixes: #46787
Signed-off-by: Sven Anderson <sven@anderson.de>
Change-Id: I110031fe789b92277ae45a9455624687bd1c54f2
Reviewed-on: https://go-review.googlesource.com/c/go/+/367296
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

12 months agogo/types: fix typos in comments
Oleksandr Redko [Thu, 18 May 2023 08:16:31 +0000 (11:16 +0300)]
go/types: fix typos in comments

Change-Id: Ifadb11dc8ba8e63c736cb7ac277247bc587ce4b3
Reviewed-on: https://go-review.googlesource.com/c/go/+/496136
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
12 months agoruntime: make the memory limit heap goal headroom proportional
Michael Anthony Knyszek [Tue, 3 Jan 2023 20:39:23 +0000 (20:39 +0000)]
runtime: make the memory limit heap goal headroom proportional

Currently if GOGC=off and GOMEMLIMIT is set, then the synchronous
scavenger is likely to work fairly often to maintain the limit, since
the heap goal goes right up to the edge of the memory limit (minus a
fixed 1 MiB of headroom).

If the application's allocation rate is high, and page-level
fragmentation is high, then most allocations will scavenge.

This change mitigates this problem by adding a proportional component
to constant headroom added to the memory-limit-based heap goal. This
means the runtime will have much more headroom before fragmentation
forces memory to be eagerly scavenged.

The proportional headroom in this case is 3%, or ~30 MiB for a 1 GiB
heap. This technically will increase GC frequency in the GOGC=off case
by a tiny amount, but will likely have a positive impact on both
allocation throughput and latency that outweighs this difference.

I wrote a small program to reproduce this issue and confirmed that the
issue is resolved by this patch:

https://github.com/golang/go/issues/57069#issuecomment-1551746565

This value of 3% is chosen as it seems to be a inflection point in this
particular small program. 2% still resulted in quite a bit of eager
scavenging work. I confirmed this results in a GC frequency increase of
about 3%.

This choice is still somewhat arbitrary because the program is
arbitrary, so perhaps worth revisiting in the future. Still, it should
help a good number of programs.

Fixes #57069.

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

12 months agoruntime: report correct fcntl syscall error in checkCloseonexec
Tobias Klauser [Wed, 17 May 2023 07:38:20 +0000 (09:38 +0200)]
runtime: report correct fcntl syscall error in checkCloseonexec

runtime.fcntl returns the error value as a negative value, so it needs
to be inverted before being converted to syscall.Errno.

Change-Id: I43cd0b035150424ac59e623b17a9396c7d62c186
Reviewed-on: https://go-review.googlesource.com/c/go/+/495675
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
12 months agogo/types, types2: fix comments in unify.go
Robert Griesemer [Thu, 18 May 2023 23:43:10 +0000 (16:43 -0700)]
go/types, types2: fix comments in unify.go

No code changes.

Change-Id: I4c17e87673fc7dc1d87807e73beec828cbd4289b
Reviewed-on: https://go-review.googlesource.com/c/go/+/496355
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
12 months agogo/types, types2: type-check built-ins even if there's a version error
Robert Griesemer [Fri, 19 May 2023 03:06:42 +0000 (20:06 -0700)]
go/types, types2: type-check built-ins even if there's a version error

There is no harm in continuing type-checking a built-in even if there
is a version error.

Change-Id: I161abd904a26075694c26639e247a17126947fcd
Reviewed-on: https://go-review.googlesource.com/c/go/+/496415
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
12 months agoruntime: add eager scavenging details to GODEBUG=scavtrace=1
Michael Anthony Knyszek [Wed, 17 May 2023 16:36:07 +0000 (16:36 +0000)]
runtime: add eager scavenging details to GODEBUG=scavtrace=1

Also, clean up atomics on released-per-cycle while we're here.

For #57069.

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

12 months agocmd/link: add ReflectMethod flag to -dumpdep output
Alessandro Arzilli [Wed, 17 May 2023 09:35:52 +0000 (11:35 +0200)]
cmd/link: add ReflectMethod flag to -dumpdep output

Adds ReflectMethod flag to the output of -dumpdep.

Fixes #60221

Change-Id: I631d72ee21b819a3a629780317ff4d962cc121e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/495715
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
12 months agocmd/go: add a GODEBUG to limit the number of concurrent network connections
Bryan C. Mills [Fri, 3 Mar 2023 14:48:19 +0000 (14:48 +0000)]
cmd/go: add a GODEBUG to limit the number of concurrent network connections

I implemented this in order to debug connection failures on a
new-to-me VM development environment that uses Cloud NAT. It doesn't
directly fix the bug, but perhaps folks will find it useful to
diagnose port-exhaustion-related flakiness in other environments.

For #52545.

Change-Id: Icd3f13dcf62e718560c4f4a965a4df7c1bd785ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/473277
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>

12 months agocmd/cgo/internal/testcarchive: fix nocgo and no-c-archive builds
Austin Clements [Fri, 19 May 2023 01:46:55 +0000 (21:46 -0400)]
cmd/cgo/internal/testcarchive: fix nocgo and no-c-archive builds

CL 495918 enabled testcarchive much more widely and added many dynamic
test skips. CL 495855 added TestDeepStack before these dynamic skips
were in. Unfortunately, the two CLs don't logically commute, so when
CL 495918 landed, it broke at least nocgo builders and platforms that
don't support c-archive builds. Fix this by adding the necessary skips
to TestDeepStack.

Change-Id: I3d352f731fe67a01c7b96871fde772db8eb21b5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/496376
Auto-Submit: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
12 months agocmd/compile: use more lenient type inference for untyped arguments for go1.21
Robert Griesemer [Wed, 17 May 2023 21:48:51 +0000 (14:48 -0700)]
cmd/compile: use more lenient type inference for untyped arguments for go1.21

This CL permanently enables the new behavior for -lang=go1.21 and
newer, and keeps the existing behavior if -lang=go1.20 or older.

To be submitted once #58671 is accepted.

For #58671.

Change-Id: I83a1d393f0ce7871be8f38ec35742d393946c55f
Reviewed-on: https://go-review.googlesource.com/c/go/+/496035
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
12 months agocmd/cgo/internal/testsovar: merge into testso
Austin Clements [Thu, 18 May 2023 21:32:05 +0000 (17:32 -0400)]
cmd/cgo/internal/testsovar: merge into testso

The test driver for testso and testsovar are literally identical, and
only the testdata code is different between the two test packages.
Merge them into a single test package with two tests that share a
driver.

Change-Id: I3f107a6aba345c0dd58606c10e3ac8eee33b33c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/496315
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
12 months agocmd/cgo/internal/testtls: cleanup and support more arches
Austin Clements [Thu, 18 May 2023 20:26:13 +0000 (16:26 -0400)]
cmd/cgo/internal/testtls: cleanup and support more arches

Currently, this test only enabled on non-Darwin UNIX platforms because
it uses the non-standard _thread attribute for thread-local storage.
C11 introduced a standard way to declare something thread-local, so
this CL takes advantage of that to generalize the test to Darwin and
Windows.

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

12 months agocmd/dist: drop remaining conditions on default cgo tests
Austin Clements [Wed, 17 May 2023 20:02:06 +0000 (16:02 -0400)]
cmd/dist: drop remaining conditions on default cgo tests

Currently, dist registers cmd/cgo/internal{test,testtls,testnocgo}
specially, so they're opted out of "go test std cmd". It has to
register these test packages to run in various non-default build
configurations, but at this point they can also run with the default
build configuration (and for test and testtls, we intentionally want
to test them in the default configuration; this is pointless but
harmless for testnocgo). Hence, this CL drops the special registration
of their default build configurations from registerCgoTests and lets
them be registered as part of registerStdTests.

Change-Id: Id283f3cdcdb202955a854648c0ed1e3c4aa554d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/496179
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agocmd/cgo/internal/testnocgo: always run in default configuration
Austin Clements [Wed, 17 May 2023 19:59:47 +0000 (15:59 -0400)]
cmd/cgo/internal/testnocgo: always run in default configuration

This test is actually intended to test that we can build in -static
mode even without any cgo. That means it's quite harmless to run in
the default build configuration (in addition to running with various
other build configurations).

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

12 months agocmd/cgo/internal/testtls: build and run everywhere
Austin Clements [Wed, 17 May 2023 19:32:41 +0000 (15:32 -0400)]
cmd/cgo/internal/testtls: build and run everywhere

This makes testtls build and run on all platforms in the default build
configuration (though it will Skip on some).

Change-Id: I6aba96a82d618c9798a0d4418b40b2644cfceec9
Reviewed-on: https://go-review.googlesource.com/c/go/+/496177
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agocmd/dist: don't pass -linkmode=auto
Austin Clements [Wed, 17 May 2023 19:10:51 +0000 (15:10 -0400)]
cmd/dist: don't pass -linkmode=auto

This is the default value of this flag, so passing it clutters up
debugging output. This also makes it clearer which tests are running
with a default configuration.

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

12 months agocmd/dist: let several cgo tests run as regular cmd tests
Austin Clements [Wed, 10 May 2023 18:28:30 +0000 (14:28 -0400)]
cmd/dist: let several cgo tests run as regular cmd tests

Several cgo tests no longer have any special conditions, so they can
just be normal cmd tests. This brings dist's "go_test:.*" tests much
closer to what "go test std cmd" runs.

Change-Id: I4d09f60628a41081e97e6b6e7dd0d93df47a65bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/495919
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agocmd/dist: refine test conditions and enable more cgo tests on Android, iOS
Austin Clements [Wed, 26 Apr 2023 16:16:26 +0000 (12:16 -0400)]
cmd/dist: refine test conditions and enable more cgo tests on Android, iOS

This CL moves many cgo test conditions out of dist and into the tests
themselves, now that they can use the testenv.Must* helpers.

This refines a lot of the conditions, which happens to have the effect
of enabling many tests on Android and iOS that are disabled by
too-coarse GOOS checks in dist today.

Fixes #15919.

Change-Id: I2947526b08928d2f7f89f107b5b2403b32092ed8
Reviewed-on: https://go-review.googlesource.com/c/go/+/495918
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agocmd/dist: enable more cgo tests if GO_GCFLAGS != ""
Austin Clements [Wed, 10 May 2023 17:55:10 +0000 (13:55 -0400)]
cmd/dist: enable more cgo tests if GO_GCFLAGS != ""

Currently, we have several tests disabled if GO_GCFLAGS is non-empty.

Long ago, this was critical because many of these tests use "go
install" with no -gcflags and would thus overwrite std packages in
GOROOT built with -gcflags=$GO_GCFLAGS. Now these packages all live in
the build cache, so this is no longer a concern.

The other reason for this (the reason given in the code comment), is
that these tests will rebuild significant portions of std without
flags. While this is still theoretically true, there are many tests
that run "go build" with no -gcflags, so these tests don't contribute
much overall.

Empirically, on my linux/amd64 host, running these tests at all grows
the Go build cache by 14%, from 1.899 GB to 2.165 GB. When building
with GO_GCFLAGS="-N -l" (the only use case on the builders), enabling
them grows the Go build cache by 18%, from 1.424 GB to 1.684 GB. This
is only a 4 percentage point difference, and still results in a build
cache that's smaller than the default build

Given all this, there's little reason to carry the complexity of
disabling these tests when GO_GCFLAGS != "". Removing this condition
is a step toward running these as regular cmd tests.

Change-Id: I2c41be721927c40a742e01476cd9a0f7650d38e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/495917
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agocmd/api: skip TestIssue21181
Russ Cox [Fri, 19 May 2023 01:24:07 +0000 (21:24 -0400)]
cmd/api: skip TestIssue21181

It is incredibly slow, taking half as long as the regular cmd/api checks
and over 5 minutes on plan9-arm. Leave it for the longtest builders.

Change-Id: Ic8bd420f174268d0b6a13d84e7bd364f6c13cf41
Reviewed-on: https://go-review.googlesource.com/c/go/+/496375
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
12 months agoslices: add in-place Reverse function
Alan Donovan [Thu, 16 Feb 2023 16:02:12 +0000 (11:02 -0500)]
slices: add in-place Reverse function

Fixes #58565

Change-Id: I583f8380c12386178fb18e553322bbb019d9fae0
Reviewed-on: https://go-review.googlesource.com/c/go/+/468855
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Shay Nehmad <dude500@gmail.com>
12 months agoos: remove unnecessary return after t.Fatal
Oleksandr Redko [Thu, 18 May 2023 07:53:28 +0000 (10:53 +0300)]
os: remove unnecessary return after t.Fatal

Change-Id: Ibddf36431abb799d8f9288d6e17159ce1538d62e
Reviewed-on: https://go-review.googlesource.com/c/go/+/495879
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agodoc: add TODOs to go1.21
Heschi Kreinick [Thu, 18 May 2023 21:44:16 +0000 (17:44 -0400)]
doc: add TODOs to go1.21

Generated with relnote. I did my best to put things where they made
sense, but some weren't obvious, like the Unicode upgrade and backward
compatibility stuff.

For #58645.

Change-Id: Ic3cd9ef32cec7591ace4d2df1da40e4afd97d083
Reviewed-on: https://go-review.googlesource.com/c/go/+/496316
Auto-Submit: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Heschi Kreinick <heschi@google.com>

12 months agogo/types, types2: remove unnecessary assignment (minor cleanup)
Robert Griesemer [Thu, 18 May 2023 18:40:19 +0000 (11:40 -0700)]
go/types, types2: remove unnecessary assignment (minor cleanup)

Change-Id: I77e5056a159b6041ca49480a3c493a515d4b3a2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/496255
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 agocmd/dist: tweaks to -json mode
Austin Clements [Wed, 17 May 2023 21:59:49 +0000 (17:59 -0400)]
cmd/dist: tweaks to -json mode

These are some follow-up tweaks to CL 494958. This CL drops a stale
and unnecessary check and passes through trailing non-JSON output.

Updates #37486.

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

12 months agogo/types, types2: implement min/max builtins
Robert Griesemer [Wed, 17 May 2023 22:47:12 +0000 (15:47 -0700)]
go/types, types2: implement min/max builtins

For #59488.

Change-Id: I4553ab11af9179a4786dede44877f88286c168dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/496038
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

12 months agocmd/go/internal/modfetch: avoid creating unused temp directories
Bryan C. Mills [Thu, 11 May 2023 14:37:44 +0000 (10:37 -0400)]
cmd/go/internal/modfetch: avoid creating unused temp directories

(Discovered via #60113, but this doesn't address that issue.)

Change-Id: I8b89e74b786dcfb0aa5d71fcbd0df8af33b98f36
Reviewed-on: https://go-review.googlesource.com/c/go/+/494375
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
12 months agocmd/go/internal/modload: fix sanity check in rawGoModSummary
Bryan C. Mills [Wed, 26 Apr 2023 06:43:06 +0000 (02:43 -0400)]
cmd/go/internal/modload: fix sanity check in rawGoModSummary

m.Path is never empty for a module in the build list; this fixes a
typo from CL 334932.

Change-Id: I5328081ba3bcf5eeac9a1b21a03969ba82ab20ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/489076
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>

12 months agocmd/go: log more information about leaked temp files
Bryan C. Mills [Thu, 23 Mar 2023 20:10:52 +0000 (16:10 -0400)]
cmd/go: log more information about leaked temp files

Previously, we were only logging the top-level names of leaked
directories, which doesn't provide much information for debugging.

For #55260.

Change-Id: I845d158135d67b5d7fdeb16ab7031a061535e643
Reviewed-on: https://go-review.googlesource.com/c/go/+/479055
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go: make TestScript/gotoolchain more realistic
Bryan C. Mills [Wed, 19 Apr 2023 19:59:19 +0000 (15:59 -0400)]
cmd/go: make TestScript/gotoolchain more realistic

- Build the fake go1.999testpath binary from Go source instead of
  special-casing a fake command on Windows.

- Skip the part of the test that uses shell scripts served from the
  test GOPROXY if /bin/sh is not present.

This makes the test more expensive, but also more realistic: notably,
it does not require test hooks to determine whether to run a real or
fake binary.

Change-Id: If14fec52186631d7833eba653c91ec5198dede58
Reviewed-on: https://go-review.googlesource.com/c/go/+/486400
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/go: propagate Context arguments through modfetch methods
Bryan C. Mills [Mon, 21 Nov 2022 20:32:52 +0000 (15:32 -0500)]
cmd/go: propagate Context arguments through modfetch methods

For #56886.
For #38714.

Change-Id: I15c4a8673407d3423d7e203d645c6d0fb780d192
Reviewed-on: https://go-review.googlesource.com/c/go/+/452456
Reviewed-by: Michael Matloob <matloob@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 agogo/types, types2: factor out type matching in binary operations
Robert Griesemer [Thu, 18 May 2023 04:10:44 +0000 (21:10 -0700)]
go/types, types2: factor out type matching in binary operations

Change-Id: Ica61698b6ba00687dcd133245bfc3d87808c7bca
Reviewed-on: https://go-review.googlesource.com/c/go/+/496096
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
12 months agogo/types, types2: reduce differences between go/types and types2 builtins.go
Robert Griesemer [Wed, 17 May 2023 03:05:13 +0000 (20:05 -0700)]
go/types, types2: reduce differences between go/types and types2 builtins.go

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

12 months agogo/types, types2: assert that builtin reports valid operand mode upon success
Robert Griesemer [Wed, 17 May 2023 00:24:16 +0000 (17:24 -0700)]
go/types, types2: assert that builtin reports valid operand mode upon success

Fix a case where x.mode == invalid was returned despite builtin
returning true.

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

12 months agogo/types, types2: remove argument "getter" use from Checker.builtins (cleanup)
Robert Griesemer [Tue, 16 May 2023 21:15:07 +0000 (14:15 -0700)]
go/types, types2: remove argument "getter" use from Checker.builtins (cleanup)

Check all arguments for validity once, in the beginning.
Conservatively replace arg(x, i) calls with *x = args[i].
Use y (2nd arguments) directly, w/o copying.
Remove unnecessary copies and slice creations in append.

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

12 months agoRevert "cmd/compile: build compiler with PGO"
Michael Pratt [Thu, 18 May 2023 17:12:26 +0000 (17:12 +0000)]
Revert "cmd/compile: build compiler with PGO"

This reverts CL 495596.

Reason for revert: duplicate symbol failures in x/tools and random PPC crashes.

Change-Id: I57305f8e72ee1567dc5a6a829c2d70fb5719028a
Reviewed-on: https://go-review.googlesource.com/c/go/+/496185
Reviewed-by: Bryan Mills <bcmills@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 agocmd/cgo/internal/test: fix TestThreadLock
Austin Clements [Thu, 18 May 2023 15:19:54 +0000 (11:19 -0400)]
cmd/cgo/internal/test: fix TestThreadLock

This test was introduced in CL 18882, but only recently enabled as of
CL 493603. It's intended to check that we don't move executing C code
between threads when it re-enters Go, but it has always contained a
flake. Go *can* preempt between the Go call to gettid and the C call
to gettid and move the goroutine to another thread because there's no
C code on the stack during the Go call to gettid. This will cause the
test to fail.

Fix this by making both gettid calls in C, with a re-entry to Go
between them.

Fixes #60265

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

12 months agodoc/go1.21: fix HTML formatting
Cherry Mui [Thu, 18 May 2023 04:13:11 +0000 (00:13 -0400)]
doc/go1.21: fix HTML formatting

Fix formatting mistakes in my previous CLs -- a missing code tag
and a broken comment tag.

Change-Id: I7f558f59b4e8fe9cb398d0093e5389b968d89eb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/496115
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agocmd/gofmt: fix a data race in TestPermissions
Bryan C. Mills [Thu, 18 May 2023 12:20:54 +0000 (08:20 -0400)]
cmd/gofmt: fix a data race in TestPermissions

The asynchronous call to processFile is synchronized by the call to
GetExitCode. We can't safely access errBuf until then, because
processFile may still be writing to it.

This is diagnosed by 'go test -race cmd/gofmt', but only the
darwin-amd64-race builder caught it because the other "-race" builders
apparently all run as root (see #10719).

Updates #60225.

Change-Id: Ie66bb4e47429ece81043d6425f26953b7bb26002
Reviewed-on: https://go-review.googlesource.com/c/go/+/496155
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
12 months agocmd/compile: intrinsify runtime/internal/atomic.{And,Or} on MIPS64x
Junxian Zhu [Mon, 15 May 2023 06:06:02 +0000 (14:06 +0800)]
cmd/compile: intrinsify runtime/internal/atomic.{And,Or} on MIPS64x

This CL intrinsify atomic{And,Or} on mips64x, which already implemented on mipsx.

goos: linux
goarch: mips64le
pkg: runtime/internal/atomic
                _  oldatomic  _             newatomic              _
                _   sec/op    _   sec/op     vs base               _
AtomicLoad64-4    27.96n _ 0%   28.02n _ 0%   +0.20% (p=0.026 n=8)
AtomicStore64-4   29.14n _ 0%   29.21n _ 0%   +0.22% (p=0.004 n=8)
AtomicLoad-4      27.96n _ 0%   28.02n _ 0%        ~ (p=0.220 n=8)
AtomicStore-4     29.15n _ 0%   29.21n _ 0%   +0.19% (p=0.002 n=8)
And8-4            53.09n _ 0%   41.71n _ 0%  -21.44% (p=0.000 n=8)
And-4             49.87n _ 0%   39.93n _ 0%  -19.93% (p=0.000 n=8)
And8Parallel-4    70.45n _ 0%   68.58n _ 0%   -2.65% (p=0.000 n=8)
AndParallel-4     70.40n _ 0%   67.95n _ 0%   -3.47% (p=0.000 n=8)
Or8-4             52.09n _ 0%   41.11n _ 0%  -21.08% (p=0.000 n=8)
Or-4              49.80n _ 0%   39.87n _ 0%  -19.93% (p=0.000 n=8)
Or8Parallel-4     70.43n _ 0%   68.25n _ 0%   -3.08% (p=0.000 n=8)
OrParallel-4      70.42n _ 0%   67.94n _ 0%   -3.51% (p=0.000 n=8)
Xadd-4            67.83n _ 0%   67.92n _ 0%   +0.13% (p=0.003 n=8)
Xadd64-4          67.85n _ 0%   67.92n _ 0%   +0.09% (p=0.021 n=8)
Cas-4             81.34n _ 0%   81.37n _ 0%        ~ (p=0.859 n=8)
Cas64-4           81.43n _ 0%   81.53n _ 0%   +0.13% (p=0.001 n=8)
Xchg-4            67.15n _ 0%   67.18n _ 0%        ~ (p=0.367 n=8)
Xchg64-4          67.16n _ 0%   67.21n _ 0%   +0.08% (p=0.008 n=8)
geomean           54.04n        51.01n        -5.61%

Change-Id: I9a4353f4b14134f1e9cf0dcf99db3feb951328ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/494875
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Junxian Zhu <zhujunxian@oss.cipunited.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoos: set File.appendMode in NewFile if file was opened with O_APPEND
Tobias Klauser [Wed, 17 May 2023 07:57:37 +0000 (09:57 +0200)]
os: set File.appendMode in NewFile if file was opened with O_APPEND

To allow skipping the use of the copy_file_range syscall on Linux which
isn't supported for destination files opened with O_APPEND, see comment
in (*File).readFrom and
https://man7.org/linux/man-pages/man2/copy_file_range.2.html#ERRORS

Fixes #60181

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

12 months agointernal/poll, internal/syscall/unix, net: move and export fcntl syscall wrapper
Tobias Klauser [Wed, 17 May 2023 07:57:34 +0000 (09:57 +0200)]
internal/poll, internal/syscall/unix, net: move and export fcntl syscall wrapper

This will allow to use the fcntl syscall in packages other than
internal/poll.

For #60181

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

12 months agocmd/asm: remove unsupported opcodes MOVNP and STLP for arm64
erifan01 [Wed, 17 May 2023 04:01:07 +0000 (12:01 +0800)]
cmd/asm: remove unsupported opcodes MOVNP and STLP for arm64

ARM64 doesn't have MOVNP/MOVNPW and STLP/STLPW instructions, which are
currently useless instructions as well. This CL deletes them. At the
same time this CL sorts the opcodes by name, which looks cleaner.

Change-Id: I25cfb636b23356ba0a50cba527a8c85b3f7e2ee4
Reviewed-on: https://go-review.googlesource.com/c/go/+/495695
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agocmd/compile: enable more lenient type inference for untyped arguments
Robert Griesemer [Wed, 17 May 2023 19:26:05 +0000 (12:26 -0700)]
cmd/compile: enable more lenient type inference for untyped arguments

This enables the implementation for proposal #58671, which is
a likely accept. By enabling it early we get a bit extra soak
time for this feature. The change can be reverted trivially, if
need be.

For #58671.

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

12 months agodoc/go1.21: document that -pgo=auto enabled by default
Cherry Mui [Tue, 16 May 2023 21:51:43 +0000 (17:51 -0400)]
doc/go1.21: document that -pgo=auto enabled by default

Updates #58099.

Change-Id: I95c0397add696f677c86ab7618482e07eb4e9fda
Reviewed-on: https://go-review.googlesource.com/c/go/+/495477
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime/cgo: store M for C-created thread in pthread key
Cherry Mui [Wed, 17 May 2023 16:01:15 +0000 (12:01 -0400)]
runtime/cgo: store M for C-created thread in pthread key

This reapplies CL 485500, with a fix drafted in CL 492987 incorporated.

CL 485500 is reverted due to #60004 and #60007. #60004 is fixed in
CL 492743. #60007 is fixed in CL 492987 (incorporated in this CL).

[Original CL 485500 description]

This reapplies CL 481061, with the followup fixes in CL 482975, CL 485315, and
CL 485316 incorporated.

CL 481061, by doujiang24 <doujiang24@gmail.com>, speed up C to Go
calls by binding the M to the C thread. See below for its
description.
CL 482975 is a followup fix to a C declaration in testprogcgo.
CL 485315 is a followup fix for x_cgo_getstackbound on Illumos.
CL 485316 is a followup cleanup for ppc64 assembly.

CL 479915 passed the G to _cgo_getstackbound for direct updates to
gp.stack.lo. A G can be reused on a new thread after the previous thread
exited. This could trigger the C TSAN race detector because it couldn't
see the synchronization in Go (lockextra) preventing the same G from
being used on multiple threads at the same time.

We work around this by passing the address of a stack variable to
_cgo_getstackbound rather than the G. The stack is generally unique per
thread, so TSAN won't see the same address from multiple threads. Even
if stacks are reused across threads by pthread, C TSAN should see the
synchonization in the stack allocator.

A regression test is added to misc/cgo/testsanitizer.

[Original CL 481061 description]

This reapplies CL 392854, with the followup fixes in CL 479255,
CL 479915, and CL 481057 incorporated.

CL 392854, by doujiang24 <doujiang24@gmail.com>, speed up C to Go
calls by binding the M to the C thread. See below for its
description.
CL 479255 is a followup fix for a small bug in ARM assembly code.
CL 479915 is another followup fix to address C to Go calls after
the C code uses some stack, but that CL is also buggy.
CL 481057, by Michael Knyszek, is a followup fix for a memory leak
bug of CL 479915.

[Original CL 392854 description]

In a C thread, it's necessary to acquire an extra M by using needm while invoking a Go function from C. But, needm and dropm are heavy costs due to the signal-related syscalls.
So, we change to not dropm while returning back to C, which means binding the extra M to the C thread until it exits, to avoid needm and dropm on each C to Go call.
Instead, we only dropm while the C thread exits, so the extra M won't leak.

When invoking a Go function from C:
Allocate a pthread variable using pthread_key_create, only once per shared object, and register a thread-exit-time destructor.
And store the g0 of the current m into the thread-specified value of the pthread key,  only once per C thread, so that the destructor will put the extra M back onto the extra M list while the C thread exits.

When returning back to C:
Skip dropm in cgocallback, when the pthread variable has been created, so that the extra M will be reused the next time invoke a Go function from C.

This is purely a performance optimization. The old version, in which needm & dropm happen on each cgo call, is still correct too, and we have to keep the old version on systems with cgo but without pthreads, like Windows.

This optimization is significant, and the specific value depends on the OS system and CPU, but in general, it can be considered as 10x faster, for a simple Go function call from a C thread.

For the newly added BenchmarkCGoInCThread, some benchmark results:
1. it's 28x faster, from 3395 ns/op to 121 ns/op, in darwin OS & Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
2. it's 6.5x faster, from 1495 ns/op to 230 ns/op, in Linux OS & Intel(R) Xeon(R) CPU E5-2630 0 @ 2.30GHz

[CL 479915 description]

Currently, when C calls into Go the first time, we grab an M
using needm, which sets m.g0's stack bounds using the SP. We don't
know how big the stack is, so we simply assume 32K. Previously,
when the Go function returns to C, we drop the M, and the next
time C calls into Go, we put a new stack bound on the g0 based on
the current SP. After CL 392854, we don't drop the M, and the next
time C calls into Go, we reuse the same g0, without recomputing
the stack bounds. If the C code uses quite a bit of stack space
before calling into Go, the SP may be well below the 32K stack
bound we assumed, so the runtime thinks the g0 stack overflows.

This CL makes needm get a more accurate stack bound from
pthread. (In some platforms this may still be a guess as we don't
know exactly where we are in the C stack), but it is probably
better than simply assuming 32K.

[CL 492987 description]

On the first call into Go from a C thread, currently we set the g0
stack's high bound imprecisely based on the SP. With CL 485500, we
keep the M and don't recompute the stack bounds when it calls into
Go again. If the first call is made when the C thread uses some
deep stack, but a subsequent call is made with a shallower stack,
the SP may be above g0.stack.hi.

This is usually okay as we don't check usually stack.hi. One place
where we do check for stack.hi is in the signal handler, in
adjustSignalStack. In particular, C TSAN delivers signals on the
g0 stack (instead of the usual signal stack). If the SP is above
g0.stack.hi, we don't see it is on the g0 stack, and throws.

This CL makes it get an accurate stack upper bound with the
pthread API (on the platforms where it is available).

Also add some debug print for the "handler not on signal stack"
throw.

Fixes #51676.
Fixes #59294.
Fixes #59678.
Fixes #60007.

Change-Id: Ie51c8e81ade34ec81d69fd7bce1fe0039a470776
Reviewed-on: https://go-review.googlesource.com/c/go/+/495855
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
12 months agocmd/gofmt: try to write original data on rewrite failure
Ian Lance Taylor [Tue, 16 May 2023 17:18:54 +0000 (10:18 -0700)]
cmd/gofmt: try to write original data on rewrite failure

When gofmt needs to rewrite a file, it first copies it into a backup.
If the rewrite fails, it used to rename the backup to the original.
However, if for some reason the file is owned by some other user,
and if the rewrite fails because gofmt doesn't have permission to
write to the file, then renaming the backup file will change
the file owner. This CL changes gofmt so that if it fails to rewrite
a file, it tries to write the original contents. If writing the original
content fails, it reports the problem to the user referring to the
backup file, rather than trying a rename.

Also create the backup file with the correct permissions,
to avoid a tiny gap when some process might get write access to the
file contents that it shouldn't have. (This tiny gap only applies to
files that are not formatted correctly, and have read-only permission,
and are in a directory with write permission.)

Fixes #60225

Change-Id: Ic16dd0c85cf416d6b2345e0650d5e64413360847
Reviewed-on: https://go-review.googlesource.com/c/go/+/495316
TryBot-Result: Gopher Robot <gobot@golang.org>
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>
Auto-Submit: Ian Lance Taylor <iant@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

Reapplies CL 451292, which is reverted at CL 495475. The failure
is fixed at CL 495595.

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%

Change-Id: Ifbe35e48b3ea3b29430249b4667d2df8a2515aeb
Reviewed-on: https://go-review.googlesource.com/c/go/+/495596
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
12 months agoos: if descriptor is non-blocking, retain that in Fd method
Ian Lance Taylor [Tue, 16 May 2023 04:50:51 +0000 (21:50 -0700)]
os: if descriptor is non-blocking, retain that in Fd method

For #58408
Fixes #60211

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

12 months agocrypto/x509: fix certificate validation with FQDN on Windows
Patryk Chelmecki [Wed, 17 May 2023 20:48:28 +0000 (20:48 +0000)]
crypto/x509: fix certificate validation with FQDN on Windows

Currently certificate verification on Windows fails if the provided dns name ends with a dot (which means it is a Fully Qualified Domain Name). The certificates according to RFC 6066 (https://www.rfc-editor.org/rfc/rfc6066#section-3) do not contain that ending dot. Go uses CertVerifyCertificateChainPolicy Windows system call with CERT_CHAIN_POLICY_SSL option for verification of the certificates. That call fails if the specified domain name contains the dot at the end.

Examples of other open source codebases that use the same system call and trim the trailing dot before executing it:
MongoDb - https://github.com/mongodb/mongo/blob/master/src/mongo/util/net/ssl_manager_windows.cpp#L1777
Dot Net - https://github.com/dotnet/runtime/blob/v7.0.5/src/libraries/System.Net.Security/src/System/Net/Security/SslAuthenticationOptions.cs#L52

Change-Id: I5db558eb277cf00f5401ec0ffc96c935023ad100
GitHub-Last-Rev: cc69ab9be35f79a93279bd618912a3fd6aaa9f88
GitHub-Pull-Request: golang/go#59846
Reviewed-on: https://go-review.googlesource.com/c/go/+/489135
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Patryk Chełmecki <patchelmecki@google.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>

12 months agoruntime: publish netpoll info after incrementing fdseq
Ian Lance Taylor [Tue, 16 May 2023 23:03:38 +0000 (16:03 -0700)]
runtime: publish netpoll info after incrementing fdseq

I think there is a theoretical possibility of a mistake before this CL.
pollCache.free would increment fdseq, but would not update atomicInfo.
The epoll code could compare to fdseq before the increment, but suspend
before calling setEventErr. The pollCache could get reallocated,
and pollOpen could clear eventErr. Then the setEventErr could continue
and set it again. Then pollOpen could call publishInfo.

Avoid this rather remote possibility by calling publishInfo after
incrementing fdseq. That ensures that delayed setEventErr will not
modify the eventErr flag.

Fixes #60133

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

12 months agocmd/link, internal/abi: minor follow-up cleanups
David Chase [Wed, 17 May 2023 14:37:18 +0000 (10:37 -0400)]
cmd/link, internal/abi: minor follow-up cleanups

these address comments on CLs in the large refactoring stack
recently submitted.

Change-Id: Ic9023c32aafe4dda953b42c9a36834d3ab3432eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/495835
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
12 months agocmd/dist: add -json flag
Austin Clements [Thu, 11 May 2023 20:20:36 +0000 (16:20 -0400)]
cmd/dist: add -json flag

This enables JSON output for all tests run by dist.

Most the complexity here is that, in order to disambiguate JSON
records from different package variants, we have to rewrite the JSON
stream on the fly to include variant information. We do this by
rewriting the Package field to be pkg:variant so existing CI systems
will naturally pick up the disambiguated test name.

Fixes #37486.

Change-Id: I0094e5e27b3a02ffc108534b8258c699ed8c3b87
Reviewed-on: https://go-review.googlesource.com/c/go/+/494958
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agocmd/dist: refactor rtPreFunc to print skips in only one place
Austin Clements [Wed, 17 May 2023 15:54:45 +0000 (11:54 -0400)]
cmd/dist: refactor rtPreFunc to print skips in only one place

Currently, all uses of rtPreFunc are to print a message and skip a
test. When we move to JSON, the logic to just "print a message" is
going to be more complicated, so refactor this so the function returns
the skip message and we print it in just one place. We also rename the
option to rtSkipFunc to better represent what we use it for.

For #37486.

Change-Id: Ibd537064fa646a956a1c0f85a5d8c6febd098dde
Reviewed-on: https://go-review.googlesource.com/c/go/+/495856
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agocmd/dist: make it possible to filter output of background commands
Austin Clements [Fri, 12 May 2023 18:57:39 +0000 (14:57 -0400)]
cmd/dist: make it possible to filter output of background commands

Many of the commands dist test executes are "background" commands run
by a work queue system. The work queue allows it to run commands in
parallel, but still serialize their output. Currently, the work queue
system assumes that exec.Cmd.Stdout and Stderr will be nil and that it
can take complete control over them.

We're about to inject output filters on many of these commands, so we
need a way to interpose on Stdout and Stderr. This CL rearranges
responsibilities in the work queue system to make that possible. Now,
the thing enqueuing the work item is responsible to constructing the
Cmd to write its output to work.out. There's only one place that
constructs work objects (there used to be many more), so that's
relatively easy, and sets us up to add filters.

For #37486.

Change-Id: I55ab71ddd456a12fdbf676bb49f698fc08a5689b
Reviewed-on: https://go-review.googlesource.com/c/go/+/494957
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agocmd/dist: simplify work list functions
Austin Clements [Fri, 12 May 2023 19:04:21 +0000 (15:04 -0400)]
cmd/dist: simplify work list functions

There are no uses of addCmd, so delete it. The only use of bgDirCmd is
dirCmd, so inline it. Now the only function that interacts with the
work queue is registerTest and dist's "background commands" are used
exclusively in goTest.bgCommand and registerTest (which calls
goTest.bgCommand).

For #37486.

Change-Id: Iebbb24cf9dbee45f3975fe9504d858493e1cd947
Reviewed-on: https://go-review.googlesource.com/c/go/+/494956
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agocmd: update vendored golang.org/x/mod
Dmitri Shuralyov [Fri, 12 May 2023 12:55:49 +0000 (08:55 -0400)]
cmd: update vendored golang.org/x/mod

Pull in CL 492990. This teaches 'go mod tidy' and other go subcommands
that write go.mod files to use semantic sort for exclude blocks, gated
on said files declaring Go version 1.21 or higher.

go get golang.org/x/mod@e7bea8f1d64f  # includes CL 492990
go mod tidy
go mod vendor

Fixes #60028.

Change-Id: Ia9342dcc23cd68de068a70657b59c25f69afa381
Reviewed-on: https://go-review.googlesource.com/c/go/+/494578
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

12 months agodoc/go1.21: document wasip1 port
Cherry Mui [Tue, 16 May 2023 21:26:53 +0000 (17:26 -0400)]
doc/go1.21: document wasip1 port

Updates #58141.

Change-Id: Iad11e7880efb37e9a1e17daf48d36b886725f75d
Reviewed-on: https://go-review.googlesource.com/c/go/+/495476
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agoencoding/xml: wrap charsetReader errors
Thuy Linh Luu [Tue, 16 May 2023 12:30:43 +0000 (12:30 +0000)]
encoding/xml: wrap charsetReader errors

This change wraps the errors from the CharsetReader function so the caller can distinguish different error conditions.

Context: I have an XML file with an unknown encoding which I like to handle separately. I like to use the CharsetReader for this but the error type has not been forwarded.

Change-Id: I6739a0dee04ec376cd20536be2806ce7f50c5213
GitHub-Last-Rev: ada9dd510f9a5b7f8c9473f6864077e0ed6898bd
GitHub-Pull-Request: golang/go#60199
Reviewed-on: https://go-review.googlesource.com/c/go/+/494897
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

12 months agoruntime: replace sysBlockTraced with tracedSyscallEnter
Michael Anthony Knyszek [Fri, 12 May 2023 18:55:25 +0000 (18:55 +0000)]
runtime: replace sysBlockTraced with tracedSyscallEnter

sysBlockTraced is a subtle and confusing flag.

Currently, it's only used in one place: a condition around whether to
traceGoSysExit when a goroutine is about to start running. That condition
looks like "gp.syscallsp != 0 && gp.trace.sysBlockTraced".

In every case but one, "gp.syscallsp != 0" is equivalent to
"gp.trace.sysBlockTraced."

That one case is where a goroutine is running without a P and racing
with trace start (world is stopped). It switches itself back to
_Grunnable from _Gsyscall before the trace start goroutine notices, such
that the trace start goroutine fails to emit a EvGoInSyscall event for
it (EvGoInSyscall or EvGoSysBlock must precede any EvGoSysExit event).
sysBlockTraced is set unconditionally on every syscall entry and the
trace start goroutine clears it if there was no EvGoInSyscall event
emitted (i.e. did not observe _Gsyscall on the goroutine). That way when
the goroutine-without-a-P wakes up and gets scheduled, it only emits
EvGoSysExit if the flag is set, i.e. trace start didn't _clear_ the
flag.

What makes this confusing is the fact that the flag is set
unconditionally and the code relies on it being *cleared*. Really, all
it's trying to communicate is whether the tracer is aware of a
goroutine's syscall at the point where a goroutine that lost its P
during a syscall is trying to run again.

Therefore, we can replace this flag with a less subtle one:
tracedSyscallEnter. It is set when GoSysCall is traced, indicating on
the goroutine that the tracer is aware of the syscall. Later, if
traceGoSysExit is called, the tracer knows its safe to emit an event
because the tracer is aware of the syscall.

This flag is then also set at trace start, when it emits EvGoInSyscall,
which again, lets the goroutine know the tracer is aware of its syscall.

The flag is cleared by GoSysExit to indicate that the tracer is no
longer aware of any syscalls on the goroutine. It's also cleared by
trace start. This is necessary because a syscall may have been started
while a trace was stopping. If the GoSysExit isn't emitted (because it
races with the trace end STW) then the flag will be left set at the
start of the next trace period, which will result in an erroneous
GoSysExit. Instead, the flag is cleared in the same way sysBlockTraced
is today: if the tracer doesn't notice the goroutine is in a syscall, it
makes that explicit to the goroutine.

A more direct flag to use here would be one that explicitly indicates
whether EvGoInSyscall or EvGoSysBlock specifically were already emitted
for a goroutine. The reason why we don't just do this is because setting
the flag when EvGoSysBlock is emitted would be racy: EvGoSysBlock is
emitted by whatever thread is stealing the P out from under the
syscalling goroutine, so it would need to synchronize with the goroutine
its emitting the event for.

The end result of all this is that the new flag can be managed entirely
within trace.go, hiding another implementation detail about the tracer.

Tested with `stress ./trace.test -test.run="TestTraceStressStartStop"`
which was occasionally failing before the CL in which sysBlockTraced was
added (CL 9132). I also confirmed also that this test is still sensitive
to `EvGoSysExit` by removing the one use of sysBlockTraced. The result
is about a 5% error rate. If there is something very subtly wrong about
how this CL emits `EvGoSysExit`, I would expect to see it as a test
failure. Instead:

    53m55s: 200434 runs so far, 0 failures

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

12 months agoruntime: hide sysExitTicks a little better
Michael Anthony Knyszek [Wed, 10 May 2023 21:06:54 +0000 (21:06 +0000)]
runtime: hide sysExitTicks a little better

Just another step to hiding implementation details.

Change-Id: I71b7cc522d18c23f03a9bf32e428279e62b39a89
Reviewed-on: https://go-review.googlesource.com/c/go/+/494192
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
12 months agocmd/compile: don't inline from norace packages in race mode
Cherry Mui [Tue, 16 May 2023 23:52:41 +0000 (19:52 -0400)]
cmd/compile: don't inline from norace packages in race mode

In race mode (or other instrumentation mode), if the caller is in
a regular package and the callee is in a norace (or noinstrument)
package, don't inline. Otherwise, when the caller is instumented
it will also affect the inlined callee.

An example is sync.(*Mutex).Unlock, which is typically not inlined
but with PGO it can be inlined into a regular function, which is
then get instrumented. But the rest of the sync package, in
particular, the Lock function is not instrumented, causing the
race detector to signal false race.

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

12 months agocrypto/ed25519,crypto/rsa: make Equal methods constant time
Filippo Valsorda [Fri, 5 May 2023 11:22:02 +0000 (13:22 +0200)]
crypto/ed25519,crypto/rsa: make Equal methods constant time

Fixes #53849
Updates #57752

Change-Id: I055564f31a47c79565b82bf9844fcf626989b295
Reviewed-on: https://go-review.googlesource.com/c/go/+/492955
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

12 months agoruntime: capture per-p trace state in a type
Michael Anthony Knyszek [Wed, 10 May 2023 20:42:23 +0000 (20:42 +0000)]
runtime: capture per-p trace state in a type

More tightening up of the tracer's interface.

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

12 months agoruntime: capture per-m trace state in a type
Michael Anthony Knyszek [Wed, 10 May 2023 20:36:08 +0000 (20:36 +0000)]
runtime: capture per-m trace state in a type

More tightening up of the tracer's interface.

While we're here, clarify why waittraceskip isn't included by explaining
what the wait* fields in the M are really for.

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

12 months agoruntime: capture per-g trace state in a type
Michael Anthony Knyszek [Wed, 10 May 2023 20:12:35 +0000 (20:12 +0000)]
runtime: capture per-g trace state in a type

More tightening up of the tracer's interface.

This increases the size of each G very slightly, which isn't great, but
we stay within the same size class, so actually memory use will be
unchanged.

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

12 months agohash/maphash: weaken avalanche test a bit
Keith Randall [Tue, 16 May 2023 19:02:52 +0000 (12:02 -0700)]
hash/maphash: weaken avalanche test a bit

Give the test a bit more wiggle room.

Previously the allowed range was about 46.5% to 53.5%. Now it is about 43% TO 57%.

Fixes #60170

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

12 months agoruntime: factor our oneNewExtraM trace code
Michael Anthony Knyszek [Wed, 10 May 2023 03:14:22 +0000 (03:14 +0000)]
runtime: factor our oneNewExtraM trace code

In the interest of further cleaning up the trace.go API, move the trace
logic in oneNewExtraM into its own function.

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

12 months agointernal/abi: update type name in comment
Ian Lance Taylor [Fri, 12 May 2023 21:39:42 +0000 (14:39 -0700)]
internal/abi: update type name in comment

method -> Method

For #59670

Change-Id: I78e0410f3d5094aa12b2f3ccd6735fec0d696190
Reviewed-on: https://go-review.googlesource.com/c/go/+/494795
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

12 months agocmd/go: prune more dependencies in 'go get'
Bryan C. Mills [Fri, 18 Nov 2022 22:35:45 +0000 (17:35 -0500)]
cmd/go: prune more dependencies in 'go get'

Prior to this change, 'go get' pulled in every version of each module
whose path is explicitly listed in the go.mod file. When graph pruning
is enabled (that is, when the main module is at 'go 1.17' or higher),
that pulled in transitive dependencies of older-than-selected versions
of dependencies, which are normally pruned out by other 'go' commands
(including 'go mod tidy' and 'go mod graph').

To make matters worse, different parts of `go get` were making
different assumptions about which kinds of conflicts would be
reported: the modget package assumed that any conflict is necessarily
due to some explicit constraint, but 'go get' was imposing an
additional constraint that modules could not be incidentally upgraded
in the course of a downgrade. When that additional constraint failed,
the modload package reported the failure as though it were a real
(caller-supplied) constraint, confusing the caller (which couldn't
identify any specific package or argument that caused the failure).

This change fixes both of those problems by replacing the
modload.EditRequirements algorithm with a different one.

The new algorithm is, roughly, as follows.

1. Propose a list of “root requirements” to be written to the updated
   go.mod file.

2. Load the module graph from those requirements mostly as usual, but
   if any root is upgraded due to transitive dependencies, retain the
   original roots and the paths leading from those roots to the
   upgrades. (This forms an “extended graph”, in which we can trace a
   path from to each version that appears in the graph starting at one
   or more of the original roots.)

3. Identify which roots caused any module path to be upgraded above
   its passed-in version constraint. For each such root, either report
   an unresolvable conflict (if the root itself is constrained to a
   specific version) or identify an updated version to propose: either
   a downgrade to the next-highest version, or an upgrade to the
   actually-selected version of the root (if that version is allowed).
   To avoid looping forever or devolving into an NP-complete search,
   we never propose a version that was already rejected previously,
   regardless of what other roots were present alongside it at the
   time.

4. If the version of any root was changed, repeat from (1).

This algorithm is guaranteed to terminate, because there are finitely
many root versions and we permanently reject at least one each time we
downgrade its path to a lower version.

In addition, this change implements support for the '-v' flag to log
more information about version changes at each iteration.

Fixes #56494.
Fixes #55955.

Change-Id: Iebc17dd7586594d5732e228043c3c4c6da230f44
Reviewed-on: https://go-review.googlesource.com/c/go/+/471595
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
12 months agocmd/go: add a test that reproduces the root cause of issue #56494
Bryan C. Mills [Thu, 3 Nov 2022 21:12:15 +0000 (17:12 -0400)]
cmd/go: add a test that reproduces the root cause of issue #56494

For #56494.

Change-Id: I9bbded6d014ac73d81b973f2d7b4783e64380031
Reviewed-on: https://go-review.googlesource.com/c/go/+/447797
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>

12 months agocrypto/rsa: use BoringCrypto for 4096 bit keys
Filippo Valsorda [Wed, 8 Mar 2023 16:35:30 +0000 (17:35 +0100)]
crypto/rsa: use BoringCrypto for 4096 bit keys

Fixes #58803

Change-Id: I097938ff61dae2b65214f8d0126d68de63525f5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/474515
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
12 months agoruntime: consistently define fcntl
Ian Lance Taylor [Mon, 15 May 2023 23:34:36 +0000 (16:34 -0700)]
runtime: consistently define fcntl

Clean up and consolidate on a single consistent definition of fcntl,
which takes three int32 arguments and returns either a positive result
or a negative errno value.

Change-Id: Id9505492712db4b0aab469c6bd15e4fce3c9ff6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/495075
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>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
12 months agoslices: for Insert and Replace, grow slices like append does
Keith Randall [Tue, 16 May 2023 22:16:06 +0000 (15:16 -0700)]
slices: for Insert and Replace, grow slices like append does

At least when we're inserting/replacing near the end of a slice, when
we have to grow it use the same multiplicative growth factor that the
runtime uses for append.

Before this CL, we would grow the slice one page (8192 bytes) at a time
for large slices. This would cause O(n^2) work when appending near the
end should only take O(n) work.

This doesn't fix the problem if you insert/replace near the start of the
array, but maybe that doesn't need fixing because it is O(n^2) anyway.

Fixes #60134

Change-Id: If05376bc512ab839769180e5ce4cb929f47363b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/495296
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
12 months agoslices: handle aliasing cases in Insert/Replace
Keith Randall [Sat, 13 May 2023 03:23:57 +0000 (20:23 -0700)]
slices: handle aliasing cases in Insert/Replace

Handle cases where the inserted slice is actually part of the slice
that is being inserted into.

Requires a bit more work, but no more allocations. (Compare to #494536.)

Not entirely sure this is worth the complication.

Fixes #60138

Change-Id: Ia72c872b04309b99025e6ca5a4a326ebed2abb69
Reviewed-on: https://go-review.googlesource.com/c/go/+/494817
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agogo/types, types2: permit partially instantiated functions as function arguments
Robert Griesemer [Tue, 9 May 2023 19:38:40 +0000 (12:38 -0700)]
go/types, types2: permit partially instantiated functions as function arguments

This CL changes Checker.genericExprList such that it collects partially
instantiated generic functions together with their (partial) type
argument (and corresponding) expression lists, instead of trying to
infer the missing type arguments in place or to report an error.
Special care is being taken to explictly record expression types where
needed (because we can't use one of the usual expr evaluators which
takes care of that), or to track the correct instance expression for
later recording with Checker.arguments.

The resulting generic expression list is passed to Checker.arguments
which is changed to accept explicit partial type argument (and
corresponding) expression lists. The provided type arguments are fed
into type inference, matching up with their respective type parameters
(which were collected already, before this CL). If type inference is
successful, the instantiated functions are recorded as needed.

For now, the type argument expression lists are collected and passed
along but not yet used. We may use them eventually for better error
reporting.

Fixes #59958.
For #59338.

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

12 months agogo/types, types2: remove superfluous argument test in Checker.arguments
Robert Griesemer [Tue, 16 May 2023 18:34:14 +0000 (11:34 -0700)]
go/types, types2: remove superfluous argument test in Checker.arguments

There's only two places which call Checker.arguments: Checker.callExpr
and Checker.builtin. Both ensure that the passed argument list doesn't
contain type expressions, so we don't need that extra check at the start
of Checker.arguments.

The remaining check causes Checker.arguments to exit early if any of
the passed arguments is invalid. This reduces the number of reported
errors in rare cases but is executed all the time.
If the extra errors are a problem, it would be better to not call
Checker.arguments in the first place, or only do the extra check
before Checker.arguments reports an error.

Removing this code for now. Removes a long-standing TODO.

Change-Id: Ief654b680eb6b6a768bb1b4c621d3c8169953f17
Reviewed-on: https://go-review.googlesource.com/c/go/+/495395
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
12 months agocmd/compile: call phiElimValue from removePhiArg
Jakub Ciolek [Mon, 6 Feb 2023 06:18:53 +0000 (07:18 +0100)]
cmd/compile: call phiElimValue from removePhiArg

With the exception of the shortcircuit pass, removePhiArg is always unconditionally followed by phiElimValue.
Move the phiElimValue inside removePhiArg.

Resolves a TODO.

See CL 357964 for more info.

Change-Id: I8460b35864f4cd7301ba86fc3dce08ec8041da7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/465435
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>

12 months agodoc/go1.21: document reflect.Value escape improvements
Cherry Mui [Fri, 12 May 2023 19:09:03 +0000 (15:09 -0400)]
doc/go1.21: document reflect.Value escape improvements

With CL 408826, CL 413474, etc. reflect.ValueOf no longer
unconditionally escapes its argument, allowing a Value's content
to be allocated on the stack.

Change-Id: I3a0af85c11e2fd0df42b056095565f0ce5548886
Reviewed-on: https://go-review.googlesource.com/c/go/+/494657
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Austin Clements <austin@google.com>
12 months agocmd/compile/internal/noder: suppress unionType consistency check
Matthew Dempsky [Tue, 16 May 2023 19:46:33 +0000 (12:46 -0700)]
cmd/compile/internal/noder: suppress unionType consistency check

In the types1 universe, we only need to represent value types. For
interfaces, this means we only need to worry about pure interfaces. A
pure interface can embed a union type, but the overall union must be
equivalent to "any".

In go.dev/cl/458619, we changed the types1 reader to return "any", but
to incorporate a consistency check to make sure this is valid.
Unfortunately, a pure interface can actually still reference impure
interfaces, and in general this is hard to check precisely without
reimplementing a lot of types2 data structures and logic into types1.

We haven't had any other reports of this check failing since 1.20, so
it seems simplest to just suppress for now.

Fixes #60117.

Change-Id: I5053faafe2d1068c6d438b2193347546bf5330cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/495455
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
12 months agoRevert "cmd/compile: build compiler with PGO"
Cherry Mui [Tue, 16 May 2023 20:53:53 +0000 (20:53 +0000)]
Revert "cmd/compile: build compiler with PGO"

This reverts CL 451292.

Reason for revert: causes the racecompile builder failure.
https://build.golang.org/log/32d2fc21bd6e3bd415495d04befe806c0f10ea8b

Change-Id: I5863437d4b814712b1280a1c21ba86009c332645
Reviewed-on: https://go-review.googlesource.com/c/go/+/495475
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@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

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%

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

12 months agocmd/compile: add more information to the bisect-verbose report
David Chase [Wed, 10 May 2023 23:29:18 +0000 (19:29 -0400)]
cmd/compile: add more information to the bisect-verbose report

running on cmd/compile/internal/testdata/inlines now shows:
```
--- change set #1 (enabling changes causes failure)
b/b.go:16:6: loop variable i now per-iteration (loop inlined into b/b.go:10)
b/b.go:16:6: loop variable i now per-iteration
./b/b.go:16:6: loop variable b.i now per-iteration (loop inlined into a/a.go:18)
./b/b.go:16:6: loop variable b.i now per-iteration (loop inlined into ./main.go:37)
./b/b.go:16:6: loop variable b.i now per-iteration (loop inlined into ./main.go:38)
---
```
and
```
--- change set #2 (enabling changes causes failure)
./main.go:27:6: loop variable i now per-iteration
./main.go:27:6: loop variable i now per-iteration (loop inlined into ./main.go:35)
---
```

Still unsure about the utility of mentioning the inlined occurrence, but better
than mysteriously repeating the line over and over again.

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

12 months agocmd/link/internal/ppc64: link ELFv2 objects built with -mcpu=power10
Paul E. Murphy [Mon, 1 May 2023 15:06:22 +0000 (10:06 -0500)]
cmd/link/internal/ppc64: link ELFv2 objects built with -mcpu=power10

Specifically, objects built via cgo using CGO_CFLAGS="-O2 -g -mcpu=power10".

These use new relocations defined by ELFv2 1.5, and the R_PPC64_REL24_NOTOC
relocation. These objects contain functions which may not use a TOC
pointer requiring the insertion of trampolines to use correctly.

The relocation targets of these ELFv2 objects may also contain non-zero
values. Clear the relocated bits before setting them.

Extra care is taken if GOPPC64 < power10. The R_PPC64_REL24_NOTOC reloc
existed prior to ELFv2 1.5. The presence of this relocation itself does
not imply a power10 target. Generate power8 compatible stubs if
GOPPC64 < power10.

Updates #44549

Change-Id: I06ff8c4e47ed9af835a7dcfbafcfa4c538f75544
Reviewed-on: https://go-review.googlesource.com/c/go/+/492617
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
12 months agocmd/compile: make memcombine pass a bit more robust to reassociation of exprs
Keith Randall [Tue, 9 May 2023 20:25:40 +0000 (13:25 -0700)]
cmd/compile: make memcombine pass a bit more robust to reassociation of exprs

Be more liberal about expanding the OR tree. Handle any tree shape
instead of a fully left or right associative tree.

Also remove tail feature, it isn't ever needed.

Change-Id: If16bebef94b952a604d6069e9be3d9129994cb6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/494056
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Ryan Berger <ryanbberger@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
12 months agolog/slog: create prefix buffer earlier
Jonathan Amsterdam [Wed, 10 May 2023 00:56:09 +0000 (20:56 -0400)]
log/slog: create prefix buffer earlier

It's possible that the replacement for a built-in attribute is a Group.
That would cause a nil pointer exception because the handleState.prefix
field isn't set until later, in appendNonBuiltIns.

So create the prefix field earlier, at the start of commonHandler.handle.

Once we do this, we can simplify the code by creating and freeing the
prefix in newHandleState.

Along the way I discovered a line that wasn't being tested:
state.prefix.WriteString(h.groupPrefix)
so I modified an existing test case to cover it.

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

12 months agocmd/compile/internal/walk: delete statement that don't need
cuiweixie [Sat, 13 May 2023 11:05:03 +0000 (19:05 +0800)]
cmd/compile/internal/walk: delete statement that don't need

Change-Id: I7253aed4808a06379caebf0949aec0f305245d23
Reviewed-on: https://go-review.googlesource.com/c/go/+/494835
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: xie cui <523516579@qq.com>

12 months agoruntime: improve ppc64x memclr for tail bytes
Lynn Boger [Mon, 15 May 2023 19:11:30 +0000 (14:11 -0500)]
runtime: improve ppc64x memclr for tail bytes

This improves memclr for the last few bytes when
compiling for power9 or earlier.

Change-Id: I46940ebc7e98e27a2e48d4b319acb7d2106a6f29
Reviewed-on: https://go-review.googlesource.com/c/go/+/495035
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
12 months agonet: use and assert correct res state size at compile time when cgo available on...
Mateusz Poliwczak [Thu, 11 May 2023 08:21:21 +0000 (08:21 +0000)]
net: use and assert correct res state size at compile time when cgo available on darwin

Change-Id: I961bb18604dd1568ea21431545f43aa6a417b3d9
GitHub-Last-Rev: 735f3364a4f2182f3e3e1b84f39a042e86987967
GitHub-Pull-Request: golang/go#60046
Reviewed-on: https://go-review.googlesource.com/c/go/+/493415
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
12 months agocmd/dist: introduce test variants
Austin Clements [Mon, 15 May 2023 18:53:45 +0000 (14:53 -0400)]
cmd/dist: introduce test variants

This introduces the concept of test variants in dist, which are
different configurations of the same package. The variant of a test is
a short string summarizing the configuration.

The "variant name" of a test is either the package name if the variant
is empty, or package:variant if not. Currently this isn't used for
anything, but soon we'll use this as the Package field of the test
JSON output so that we can disambiguate output from differently
configured runs of the same test package, and naturally flow this
through to any test result viewer.

The long-term plan is to use variant names as dist's own test names
and eliminate the ad hoc names it has right now. Unfortunately, the
build coordinator is aware of many of the ad hoc dist test names, so
some more work is needed to get to that point. This CL keeps almost
all test names the same, with the exception of tests registered by
registerCgoTests, where we regularize test names a bit using variants
to avoid some unnecessary complexity (I believe nothing depends on the
names of these tests).

For #37486.

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

12 months agocmd/dist: put cgo tests under a "Testing cgo" heading
Austin Clements [Thu, 11 May 2023 19:12:45 +0000 (15:12 -0400)]
cmd/dist: put cgo tests under a "Testing cgo" heading

Currently the cgo tests mostly use their package name as a heading,
which means we get a large number of test sections that each have a
single test package in them.

Unify them all under "Testing cgo" to reduce output noise.

This leaves just the cmd/api test without a heading, so we give it a
heading and require that all tests have a heading.

Change-Id: I24cd9a96eb35bbc3ff9335ca8a382ec2426306c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/494497
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
12 months agocmd/dist: refactor adding to the test list into a method
Austin Clements [Mon, 15 May 2023 18:24:00 +0000 (14:24 -0400)]
cmd/dist: refactor adding to the test list into a method

Currently, there are four places that add distTests to the
tester.tests list. That means we're already missing a few name
uniqueness checks, and we're about to start enforcing some more
requirements on tests that would be nice to have in one place. Hence,
to prepare for this, this CL refactors the process of adding to the
tester.tests list into a method. That also means we can trivially use
a map to check name uniqueness rather than an n^2 slice search.

For #37486.

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

12 months agocmd/compile: enhance tighten pass for memory values
eric fang [Fri, 5 May 2023 01:07:25 +0000 (01:07 +0000)]
cmd/compile: enhance tighten pass for memory values

[This is a roll-forward of CL 458755, which was reverted due to make.bash
being broken on GOAMD64=v3. But it turned out that the problem was caused
by wrong bswap/load rewrite rules, and it was fixed in CL 492616.]

This CL enhances the tighten pass. Previously if a value has memory arg,
then the tighten pass won't move it, actually if the memory state is
consistent among definition and use block, we can move the value. This
CL optimizes this case. This is useful for the following situation:
b1:
  x = load(...mem)
  if(...) goto b2 else b3
b2:
  use(x)
b3:
  some_op_not_use_x

For the micro-benchmark mentioned in #56620, the performance improvement
is about 15%.
There's no noticeable performance change in the go1 benchmark.

Fixes #56620

Change-Id: I36ea68bed384986cd3ae81cb9e6efe84bb213adc
Reviewed-on: https://go-review.googlesource.com/c/go/+/492895
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>

12 months agoos, syscall: permit setting mtime to Unix 0 on Windows
Ian Lance Taylor [Mon, 15 May 2023 20:53:21 +0000 (13:53 -0700)]
os, syscall: permit setting mtime to Unix 0 on Windows

This edge case was accidentally broken by CL 219638.

Change-Id: I673b3b580fbe379a04f8650cf5969fe9bce83691
Reviewed-on: https://go-review.googlesource.com/c/go/+/495036
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

12 months agoRevert "net/http: do not force the Content-Length header if nilled"
Austin Clements [Mon, 15 May 2023 21:19:08 +0000 (21:19 +0000)]
Revert "net/http: do not force the Content-Length header if nilled"

This reverts CL 469095.

The newly added TestDisableContentLength is failing on all longtest
builders.

Change-Id: Id307df61c7bf80691d9c276e8d200eebf6d4a59c
Reviewed-on: https://go-review.googlesource.com/c/go/+/495017
Auto-Submit: Austin Clements <austin@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>