]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
7 months agomisc: drop old +build lines
Dmitri Shuralyov [Tue, 17 Oct 2023 19:21:15 +0000 (15:21 -0400)]
misc: drop old +build lines

This is all there was outside of the src and test top-level directories.

Change-Id: Id29b1c92cab7087681f89504e861a47dc30ba834
Reviewed-on: https://go-review.googlesource.com/c/go/+/536238
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agoall: drop old +build lines
Dmitri Shuralyov [Tue, 17 Oct 2023 19:19:33 +0000 (15:19 -0400)]
all: drop old +build lines

Running 'go fix' on the cmd+std packages handled much of this change.

Also update code generators to use only the new go:build lines,
not the old +build ones.

For #41184.
For #60268.

Change-Id: If35532abe3012e7357b02c79d5992ff5ac37ca23
Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest,gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/536237
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agotest: migrate remaining files to go:build syntax
Dmitri Shuralyov [Tue, 17 Oct 2023 19:07:58 +0000 (15:07 -0400)]
test: migrate remaining files to go:build syntax

Most of the test cases in the test directory use the new go:build syntax
already. Convert the rest. In general, try to place the build constraint
line below the test directive comment in more places.

For #41184.
For #60268.

Change-Id: I11c41a0642a8a26dc2eda1406da908645bbc005b
Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest,gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/536236
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agocmd/go: move all Shell methods to shell.go
Austin Clements [Thu, 19 Oct 2023 17:43:51 +0000 (13:43 -0400)]
cmd/go: move all Shell methods to shell.go

This is a pure code movement change.

Now that we've introduced a Shell type that lives in shell.go, move
all of its methods (which used to be on Builder) to shell.go as well.

Change-Id: Ie1802353c8a64590219b08893e8c74649228e5e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/536536
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
7 months agocmd/go: add Shell.RemoveAll
Austin Clements [Tue, 17 Oct 2023 19:05:32 +0000 (15:05 -0400)]
cmd/go: add Shell.RemoveAll

There are quite a few places that perform their own command logging
and then use os.RemoveAll. Unify (nearly) all of these into
(*Shell).RemoveAll, like many of the other internal implementations of
basic shell operations.

Change-Id: I94a2cbd9dc150a4c94a4051c42ce8e86dcc736fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/536099
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agocmd/go: introduce Shell abstraction
Austin Clements [Wed, 20 Sep 2023 21:01:40 +0000 (17:01 -0400)]
cmd/go: introduce Shell abstraction

This CL separates running shell commands and doing shell-like
operations out of the Builder type and into their own, new Shell type.
Shell is responsible for tracking output streams and the Action that's
running commands. Shells form a tree somewhat like Context, where new
Shells can be derived from a root shell to adjust their state.

The primary intent is to support "go build -json", where we need to
flow the current package ID down to the lowest level of command output
printing. Shell gives us a way to easily flow that context down.

However, this also puts a clear boundary around how we run commands,
removing this from the rather large Builder abstraction.

For #62067.

Change-Id: Ia9ab2a2d7cac0269ca627bbb316dbd9610bcda44
Reviewed-on: https://go-review.googlesource.com/c/go/+/535016
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Austin Clements <austin@google.com>

7 months agocmd/go: serialize access to scriptDir with output
Austin Clements [Thu, 19 Oct 2023 14:51:07 +0000 (10:51 -0400)]
cmd/go: serialize access to scriptDir with output

Currently, Builder.fmtcmd can read scriptDir without taking the output
lock. This introduces a potential data race between the read in fmtcmd
and the write in Showcmd. There's also a logical race here: because
fmtcmd doesn't know when its output is going to be printed, Showcmd
may print a "cd" command between when fmtcmd is called and when its
output is printed. As a result, it doesn't make sense to just lock
around the access in fmtcmd.

Instead, move the entire scriptDir substitution to Showcmd. This will
generally result in the same output. In the cases where Builder.run is
called with a non-empty desc, it means we may print a full path in the
comment line above output rather than substituting the script
directory. I think this is okay.

This lets us undo the workaround in CL 536355.

Change-Id: I617fe136eaafcc9bbb7e701b427d956aeab8a2b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/536376
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Austin Clements <austin@google.com>

7 months agocmd/go: clean up adding import path to command error
Austin Clements [Wed, 11 Oct 2023 16:15:57 +0000 (12:15 -0400)]
cmd/go: clean up adding import path to command error

Currently, cmdError makes a somewhat fuzzy attempt to ensure the
package import path is part of the printed error, using a string
prefix check. Also, if it decides it does need to add the import path,
it prints it as a "go build" line, which could be misleading because
it can happen outside of "go build".

Clean up the whole code path by explicitly checking the provided error
description against Package.Desc(), and instead of emitting "go build"
in the error message, print it as "# importPath" just like we do in
the common case.

Change-Id: Idb61ac8ffd6920a3d2d282697f4d7d5555ebae0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/534655
Auto-Submit: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
7 months agoimage: add available godoc link
cui fliter [Fri, 13 Oct 2023 17:24:33 +0000 (01:24 +0800)]
image: add available godoc link

Change-Id: I2839ecb091c4f0b30d0dcee708bf9e9a55e3672a
Reviewed-on: https://go-review.googlesource.com/c/go/+/535196
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>

7 months agogo: add available godoc link
cui fliter [Fri, 13 Oct 2023 16:45:28 +0000 (00:45 +0800)]
go: add available godoc link

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

7 months agomath: add available godoc link
cui fliter [Sat, 14 Oct 2023 13:09:16 +0000 (21:09 +0800)]
math: add available godoc link

Change-Id: I4a6c2ef6fd21355952ab7d8eaad883646a95d364
Reviewed-on: https://go-review.googlesource.com/c/go/+/535087
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
7 months agointernal/nettrace: fix comment typo
flaxinger [Mon, 16 Oct 2023 08:55:11 +0000 (08:55 +0000)]
internal/nettrace: fix comment typo

Change-Id: I23e2bc67476ed1cedf61db9953683e57ab6bf522
GitHub-Last-Rev: 458581ec261eae790fc54537fcecb0fd5915af1e
GitHub-Pull-Request: golang/go#63530
Reviewed-on: https://go-review.googlesource.com/c/go/+/535655
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Yohan Mok <yohan@ab180.co>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agocmd/compile: report mismatched version set by //go:build
Cuong Manh Le [Thu, 12 Oct 2023 01:35:37 +0000 (08:35 +0700)]
cmd/compile: report mismatched version set by //go:build

Fixes #63489

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

7 months agointernal/poll: add SPLICE_F_NONBLOCK flag for splice to avoid inconsistency with...
Andy Pan [Tue, 17 Oct 2023 14:38:17 +0000 (22:38 +0800)]
internal/poll: add SPLICE_F_NONBLOCK flag for splice to avoid inconsistency with O_NONBLOCK

For #59041

Details: https://github.com/golang/go/issues/59041#issuecomment-1766610087

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

7 months agoslices: avoid an unnecessary check in Replace
go101 [Wed, 18 Oct 2023 17:17:18 +0000 (17:17 +0000)]
slices: avoid an unnecessary check in Replace

The current implementation of the builtin copy function will return early
when it is found that the addresses of the first elements of the two
slice arguments are identical, so it is unnecessarily to do this in user code.

See #57759 for details.

Change-Id: I7c101eee496923d7aa59f94720da6c84feb93af8
GitHub-Last-Rev: 4d6819fb25143f5ad3ff65eca7fe6094c37f2af2
GitHub-Pull-Request: golang/go#63617
Reviewed-on: https://go-review.googlesource.com/c/go/+/536255
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
7 months agotest/codegen: fix PPC64 AddLargeConst test
Paul E. Murphy [Wed, 18 Oct 2023 18:42:25 +0000 (13:42 -0500)]
test/codegen: fix PPC64 AddLargeConst test

Commit 061d77cb70 was published in parallel with another commit
36ecff0893 which changed how certain constants were generated.

Update the test to account for the changes.

Change-Id: I314b735a34857efa02392b7a0dd9fd634e4ee428
Reviewed-on: https://go-review.googlesource.com/c/go/+/536256
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Paul Murphy <murp@ibm.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agocmd/go: work around race in fmtCmd
Austin Clements [Wed, 18 Oct 2023 20:49:50 +0000 (16:49 -0400)]
cmd/go: work around race in fmtCmd

CL 529219 made an existing race with accessing Builder.scriptDir from
Builder.fmtcmd (and now also Builder.Showcmd) much more likely by
dropping a theoretically unnecessary condition from the call from
Builder.run to Builder.fmtcmd.

For an example race report, see
https://build.golang.org/log/c3cad62d0fc33a8381d2091661c685ea1fc525c4

The race is between

  (*Builder).cover2() -> (*Builder).run() -> (*Builder).fmtcmd()

and various other call paths of the form

  (*Builder).build() -> (*gcToolchain).*  (*Builder).Showcmd() -> (*Builder).fmtcmd()

The race can be reproduced with

  go install -race cmd/go
  stress -p 1 go test -x -cover -a log

Return this race to its existing likelihood by putting the condition
back. This isn't a "correct" solution because the race could still
happen if the "cover" tool invoked by Builder.cover2 emits output. But
this will do for a temporary fix.

Change-Id: Ifd811dea07f05e1422fd02b63cd958627727aa12
Reviewed-on: https://go-review.googlesource.com/c/go/+/536355
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agoencoding/json: use reflect.Value.IsZero
andig [Sat, 14 Oct 2023 09:32:20 +0000 (09:32 +0000)]
encoding/json: use reflect.Value.IsZero

IsZero does the same thing, using this rather than writing it again.

Follow-up to https://github.com/golang/go/pull/63519

Change-Id: I93768874052935dd7cb58804f22748091bcc3ef7
GitHub-Last-Rev: dfbc6ed635125535a73fe509716e0df31cc8f7b0
GitHub-Pull-Request: golang/go#63540
Reviewed-on: https://go-review.googlesource.com/c/go/+/535415
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agodatabase: add available godoc link
cui fliter [Fri, 13 Oct 2023 05:07:28 +0000 (13:07 +0800)]
database: add available godoc link

Change-Id: I6150858f1186edc6cebd38ff166d57287fa430f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/535078
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agoembed: add available godoc link
cui fliter [Fri, 13 Oct 2023 06:53:49 +0000 (14:53 +0800)]
embed: add available godoc link

Change-Id: Iefccc7aeb0f697c555ae8a6a6bb6cd5091882195
Reviewed-on: https://go-review.googlesource.com/c/go/+/535079
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: shuang cui <imcusg@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agoflag: add available godoc link
cui fliter [Fri, 13 Oct 2023 07:20:55 +0000 (15:20 +0800)]
flag: add available godoc link

Change-Id: I00d49ded65801ab12322f711d1ac6131d69aea34
Reviewed-on: https://go-review.googlesource.com/c/go/+/535081
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agoio: add available godoc link
cui fliter [Sat, 14 Oct 2023 09:47:57 +0000 (17:47 +0800)]
io: add available godoc link

Change-Id: I5973a352edb73e02a274d939d6d0573788640dc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/535435
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
7 months agodebug: add available godoc link
cui fliter [Fri, 13 Oct 2023 06:48:33 +0000 (14:48 +0800)]
debug: add available godoc link

Change-Id: I9e7b7e10d9e3d23e4ed540eb8137cd1f4d103711
Reviewed-on: https://go-review.googlesource.com/c/go/+/534761
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

7 months agocmd/go/internal/modcmd: do not copy test embed files when vendoring
Quan Tong [Wed, 11 Oct 2023 01:55:24 +0000 (01:55 +0000)]
cmd/go/internal/modcmd: do not copy test embed files when vendoring

Currently, go mod vendor copy all files matched by //go:embed,
even when it is in a _test.go file. According to the documentation,
it should not include test code for vendored packages.

Fixes #63473

Change-Id: I28c411724fc7b7aeb683857fc114e20b08635e01
Reviewed-on: https://go-review.googlesource.com/c/go/+/534376
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
7 months agocmd/internal/obj/ppc64: refactor maskgen64 usage
Paul E. Murphy [Wed, 27 Sep 2023 15:31:52 +0000 (10:31 -0500)]
cmd/internal/obj/ppc64: refactor maskgen64 usage

Converting and verifying a bitmask can be done much quicker
and simpler. Since this touches the MD-form opcodes, cleanup
their encoding too.

Change-Id: I9b1c1fdc4c9622e489ff6cf8181c5b647afae7c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/534017
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
7 months agocmd/compile/internal/ssa: on PPC64, generate large constant paddi
Paul E. Murphy [Fri, 15 Sep 2023 20:20:56 +0000 (15:20 -0500)]
cmd/compile/internal/ssa: on PPC64, generate large constant paddi

This is only supported power10/linux/PPC64. This generates smaller,
faster code by merging a pli + add into paddi.

Change-Id: I1f4d522fce53aea4c072713cc119a9e0d7065acc
Reviewed-on: https://go-review.googlesource.com/c/go/+/531717
Run-TryBot: Paul Murphy <murp@ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
7 months agocmd/compile: update to rules on PPC64 folding bit reversal to load
Jayanth Krishnamurthy [Wed, 27 Sep 2023 13:11:49 +0000 (08:11 -0500)]
cmd/compile: update to rules on PPC64 folding bit reversal to load

In the Power10 rule to fold bit reversal into load, the MOVWZreg or
MOVHZreg (Zeroing out the upper bits of a  word or halfword) becomes
redundant since byte reverse (BR) load clears the upper bits. Hence
removing for Power10. Similarly for < Power10  cases in the rule used to
fold bit reversal into load (Bswap), the above redundant operation is removed.

Change-Id: Idb027e8b6e79b6acfb81d48a9a6cc06f8e9cd2db
Reviewed-on: https://go-review.googlesource.com/c/go/+/531377
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agocmd/internal/obj/arm64: replace the migrated url address
cui fliter [Tue, 19 Sep 2023 16:01:26 +0000 (00:01 +0800)]
cmd/internal/obj/arm64: replace the migrated url address

Change-Id: I36a0f0989d37bef45ea8778da799b56a7e9a0c30
Reviewed-on: https://go-review.googlesource.com/c/go/+/529515
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

7 months agoruntime: speed up readvarintUnsafe
Cuong Manh Le [Mon, 16 Oct 2023 16:07:49 +0000 (23:07 +0700)]
runtime: speed up readvarintUnsafe

The documentation of readvarintUnsafe claims itself and readvarint are
duplicated. However, two implementation are not in synced, since when
readvarint got some minor improvements in CL 43150.

Updating readvarintUnsafe to match readvarint implementation to gain a
bit of speed. While at it, also updating its documentation to clarify
the main difference.

name                    time/op
ReadvarintUnsafe/old-8  6.04ns ± 2%
ReadvarintUnsafe/new-8  5.31ns ± 3%

Change-Id: Ie1805d0747544f69de88f6ba9d1b3960f80f00e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/535815
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
7 months agocmd/compile: move ssagen.dvarint to objw.Uvarint
Cuong Manh Le [Mon, 16 Oct 2023 08:47:08 +0000 (15:47 +0700)]
cmd/compile: move ssagen.dvarint to objw.Uvarint

Follow up discussion in CL 535077.

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

7 months agocmd/compile: fix funcdata encode for functions with large frame size
Cuong Manh Le [Fri, 13 Oct 2023 03:32:57 +0000 (10:32 +0700)]
cmd/compile: fix funcdata encode for functions with large frame size

The funcdata is encoded as varint, with the upper limit set to 1e9.
However, the stack offsets could be up to 1<<30. Thus emitOpenDeferInfo
will trigger an ICE for function with large frame size.

By using binary.PutUvarint, the frame offset could be encoded correctly
for value larger than 1<<35, allow the compiler to report the error.

Further, the runtime also do validation when reading in the funcdata
value, so a bad offset won't likely cause mis-behavior.

Fixes #52697

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

7 months agocmd/compile: avoid ANDCCconst on PPC64 if condition not needed
Lynn Boger [Wed, 27 Sep 2023 17:15:04 +0000 (12:15 -0500)]
cmd/compile: avoid ANDCCconst on PPC64 if condition not needed

In the PPC64 ISA, the instruction to do an 'and' operation
using an immediate constant is only available in the form that
also sets CR0 (i.e. clobbers the condition register.) This means
CR0 is being clobbered unnecessarily in many cases. That
affects some decisions made during some compiler passes
that check for it.

In those cases when the constant used by the ANDCC is a right
justified consecutive set of bits, a shift instruction can
be used which has the same effect if CR0 does not need to be
set. The rule to do that has been added to the late rules file
after other rules using ANDCCconst have been processed in the
main rules file.

Some codegen tests had to be updated since ANDCC is no
longer generated for some cases. A new test case was added to
verify the ANDCC is present if the results for both the AND
and CR0 are used.

Change-Id: I304f607c039a458e2d67d25351dd00aea72ba542
Reviewed-on: https://go-review.googlesource.com/c/go/+/531435
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
7 months agocmd/go: make pkg-config check less picky
Austin Clements [Wed, 18 Oct 2023 14:48:50 +0000 (10:48 -0400)]
cmd/go: make pkg-config check less picky

CL 529219 tweaked the list_pkgconfig_error script test currently to
expect pkg-config to fail with "Package .* not found$", but on several
OSes (at least OpenBSD, AIX, and Solaris), pkg-config prints "Package
libnot-a-valid-cgo-library was not found in the pkg-config search
path". Fix the test on these OSes by dropping the "$" so the test
doesn't require the line to end with "not found".

Change-Id: I40c577521f34c360a1d62355596958f6f969eb54
Reviewed-on: https://go-review.googlesource.com/c/go/+/536195
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agocmd/go: drop unnecessary Package argument to reportCmd
Austin Clements [Tue, 17 Oct 2023 16:39:32 +0000 (12:39 -0400)]
cmd/go: drop unnecessary Package argument to reportCmd

Now that we've dropped the redundant Package arguments to many
functions, we can see that the Package argument to reportCmd is always
nil. That means we can drop it and always use a.Package.

For #62067.

Change-Id: I2e11e770f495d6f770047993358c76b08204e923
Reviewed-on: https://go-review.googlesource.com/c/go/+/536096
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agocmd/go: drop unnecessary Package arguments
Austin Clements [Tue, 17 Oct 2023 16:32:52 +0000 (12:32 -0400)]
cmd/go: drop unnecessary Package arguments

There are several functions that take both an Action argument and a
Package argument. It takes a decent amount of work to determine that
in all cases the value of the Package argument is just Action.Package.
This makes these Package arguments both redundant and potentially
confusing because it makes these APIs look like they have more
flexibility than they actually do.

Drop these unnecessary Package arguments.

For #62067.

Change-Id: Ibd3295cf6a79d95ceb421d60671f87e023517f8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/536095
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agocmd/go: move fmtcmd's side effect to Showcmd
Austin Clements [Thu, 12 Oct 2023 14:54:40 +0000 (10:54 -0400)]
cmd/go: move fmtcmd's side effect to Showcmd

Currently, fmtcmd may have the side effect of updating
Builder.scriptDir, the logical working directory of the printed
script. If it does so, it also returns a two line command consisting
of both a "cd" into the new scriptDir and the original command.

When fmtcmd is used as part of Showcmd, that's fine, but fmtcmd is
also used in a handful of places to construct command descriptions
that are ultimately passed to Builder.reportCmd. In these cases, it's
surprising that fmtcmd has any side effects, but the bigger problem is
that reportCmd isn't expecting a two-line description and will print
it wrong in the output.

One option is to fix printing multi-line descriptions in reportCmd,
but we can fix the surprise side effect too by instead moving the
working directory update to Showcmd. With this CL, fmtcmd merely
consults the working directory to shorten it in the output and does
not update it.

For #62067.

Change-Id: I7808b279a430551f4ba51545417adf0bb132f931
Reviewed-on: https://go-review.googlesource.com/c/go/+/534857
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Austin Clements <austin@google.com>

7 months agocmd/go: use Builder.writeFile more extensively
Austin Clements [Fri, 22 Sep 2023 00:07:41 +0000 (20:07 -0400)]
cmd/go: use Builder.writeFile more extensively

Change-Id: Id9dfbb788194e1de5d55daba40dc9f34fd36180c
Reviewed-on: https://go-review.googlesource.com/c/go/+/534656
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agocmd/go: delete showOutput, formatOutput, and processOutput
Austin Clements [Sun, 17 Sep 2023 22:20:11 +0000 (18:20 -0400)]
cmd/go: delete showOutput, formatOutput, and processOutput

This functions have been replaced with Builder.reportCmd.

For #62067.

Change-Id: Ifeccee720b3da3dc44c49fe11da1eca7b5f46551
Reviewed-on: https://go-review.googlesource.com/c/go/+/529220
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
7 months agocmd/go: replace formatOutput/showOutput with reportCmd
Austin Clements [Fri, 15 Sep 2023 16:45:17 +0000 (12:45 -0400)]
cmd/go: replace formatOutput/showOutput with reportCmd

The general pattern is to replace

if len(cmdOut) > 0 {
output := b.processOutput(cmdOut)
if err != nil {
err = formatOutput(b.WorkDir, dir, p.ImportPath, desc, output)
} else {
b.showOutput(a, dir, desc, output)
}
}
if err != nil {
return err
}

with

if err := b.reportCmd(a, p, desc, dir, cmdOut, err); err != nil {
return err
}

However, there is a fair amount of variation between call sites. The
most common non-trivial variation is sites where errors are an
expected outcome. In this case, often we simply pass "nil" for the
error to trigger only the printing behavior of reportCmd.

For #62067, but also a nice cleanup on its own.

Change-Id: Ie5f918017c02d8558f23ad4c38261077c0fa4ea3
Reviewed-on: https://go-review.googlesource.com/c/go/+/529219
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
7 months agocmd/go: consolidate showOutput, formatOutput, and processOutput into reportCmd
Austin Clements [Tue, 5 Sep 2023 15:07:29 +0000 (11:07 -0400)]
cmd/go: consolidate showOutput, formatOutput, and processOutput into reportCmd

Many uses of showOutput, formatOutput, and processOutput follow a very
similar (somewhat complex) pattern. Places that diverge from this
pattern are often minor bugs. Furthermore, the roles of formatOutput
and processOutput have somewhat blurred over time; e.g., formatOutput
performs directory shortening, while processOutput performs cgo
demangling.

This CL consolidates all of this logic into a single, new function:
Builder.reportCmd.

In the following CL, we'll replace all calls of the three original
functions with reportCmd.

In addition to being a nice cleanup, this puts us in a much better
position to change how build output is formatted in order to support
`go build -json`.

For #62067.

Change-Id: I733162825377d82d0015c8aae2820e56a1b32958
Reviewed-on: https://go-review.googlesource.com/c/go/+/529218
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agocmd/cgo/internal/testfortran: relax test output
Cuong Manh Le [Tue, 17 Oct 2023 13:50:30 +0000 (20:50 +0700)]
cmd/cgo/internal/testfortran: relax test output

Some new linker may emit warning message to standard error, causing
false positive in test result.

Fixing this by testing only stdout output.

Fixes #63588

Change-Id: I272048c41dc1c316f44af2dfc903bb03383baea3
Reviewed-on: https://go-review.googlesource.com/c/go/+/535975
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agoruntime: fix comments for itab
bestgopher [Wed, 18 Oct 2023 00:13:21 +0000 (00:13 +0000)]
runtime: fix comments for itab

The function WriteTabs has been renamed WritePluginTable.

Change-Id: I5f04b99b91498c41121f898cb7774334a730d7b4
GitHub-Last-Rev: c98ab3f87210cef9146a1aec97e2f1f4a2bc0593
GitHub-Pull-Request: golang/go#63595
Reviewed-on: https://go-review.googlesource.com/c/go/+/535996
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
7 months agoruntime: use cgo_import_dynamic for QueryPerformanceCounter
qmuntal [Thu, 5 Oct 2023 10:35:35 +0000 (12:35 +0200)]
runtime: use cgo_import_dynamic for QueryPerformanceCounter

QueryPerformanceCounter is available since Windows 2000 [1], so there
is no need to conditionally load it.

Even if the Go runtime doesn't eventually use it, it is still simpler
and faster to just tell the Windows loader to load it, instead of doing
it ourselves.

[1]: https://learn.microsoft.com/en-us/windows/win32/api/profileapi/nf-profileapi-queryperformancecounter

Change-Id: Ied3b54a6a8fe3b8d51aefab0fe483b3a193b5522
Reviewed-on: https://go-review.googlesource.com/c/go/+/532915
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
7 months agoruntime: unconditionally load AddVectoredContinueHandler on Windows
qmuntal [Thu, 5 Oct 2023 10:28:42 +0000 (12:28 +0200)]
runtime: unconditionally load AddVectoredContinueHandler on Windows

AddVectoredContinueHandler is available since Windows XP [1], there is
no need to check if it is available.

[1]: https://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-addvectoredcontinuehandler

Change-Id: I1ddc3d58b3294d9876620cd46159d9692694b475
Reviewed-on: https://go-review.googlesource.com/c/go/+/532817
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
7 months agogo/printer: fix invalid output for empty decls
Mauri de Souza Meneguzzo [Tue, 17 Oct 2023 18:36:31 +0000 (18:36 +0000)]
go/printer: fix invalid output for empty decls

The current output for empty declarations such as var, const, import
results in "var", "const", "import" respectively. These are not valid
and the parser will promptly reject them as invalid syntax.

This CL updates this behavior by adding "()" to the output of empty
decls so the syntax becomes valid, e.g "var ()" instead of "var".

Fixes #63566

Change-Id: I571b182d9ccf71b159360c8de003ad55d0ff3443
GitHub-Last-Rev: 2720419e364938e9962be71d0e6ed51375fec404
GitHub-Pull-Request: golang/go#63593
Reviewed-on: https://go-review.googlesource.com/c/go/+/535995
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com>

7 months agocmd/internal/testdir: accept build go1.x build tag
Cuong Manh Le [Tue, 17 Oct 2023 17:26:42 +0000 (00:26 +0700)]
cmd/internal/testdir: accept build go1.x build tag

While at it, also using "slices" package to simplify code.

For #63489

Change-Id: I72b325f6ad379b996c108145885fa71706f6659f
Reviewed-on: https://go-review.googlesource.com/c/go/+/536055
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agocmd/go: rename ld, ldShared "out" argument to "targetPath"
Austin Clements [Wed, 11 Oct 2023 16:31:55 +0000 (12:31 -0400)]
cmd/go: rename ld, ldShared "out" argument to "targetPath"

"out" is often used for stdout or stderr. Rename it to targetPath to
clarify its meaning.

Change-Id: I95823e9119843a7026dc26c192497776ee4219e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/534595
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Austin Clements <austin@google.com>

7 months agospec: explain eval order of binary operator examples with comments
Robert Griesemer [Mon, 16 Oct 2023 16:08:51 +0000 (09:08 -0700)]
spec: explain eval order of binary operator examples with comments

Fixes #63525.

Change-Id: Ie9aa4dd47c025cd593e576c6e8de1774e1d1e302
Reviewed-on: https://go-review.googlesource.com/c/go/+/535775
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
7 months agohtml/template: track brace depth for each nested expression
Roland Shoemaker [Thu, 5 Oct 2023 13:16:18 +0000 (06:16 -0700)]
html/template: track brace depth for each nested expression

We need to track the brace depth for each individual nested expression,
since a string interpolation expression may be nested inside of an
object.

e.g. `${ {1:`${}`}}` has brace depths [1, 0] when inside of the inner
${} expression. When we exit the inner expression, we need to reset to
the previous brace depth (1) so that we know that the following } closes
the object, but not the outer expression.

Note that if you write a broken expression (i.e. `${ { }`) escaping will
clearly not work as expected (or depending on your interpretation, since
it is broken, it will work as expected). Since the JS parser doesn't
catch syntax errors, it's up to the user to write a valid template.

Updates #61619

Change-Id: I4c33723d12aff49facdcb1134d9ca82b7a0dffc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/532995
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agoall: fix function names
cui fliter [Mon, 3 Jul 2023 05:41:45 +0000 (13:41 +0800)]
all: fix function names

Change-Id: Iba8878420c59d705066d1d9955e91a5c2eb4faf5
Reviewed-on: https://go-review.googlesource.com/c/go/+/507615
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agobufio: link "too large to fit" to Scanner.Buffer
Ian Lance Taylor [Fri, 13 Oct 2023 19:38:57 +0000 (12:38 -0700)]
bufio: link "too large to fit" to Scanner.Buffer

Change-Id: Id0a4f5716da98008eec10eee05b74fc2a155ba3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/535216
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
7 months agoruntime: use real type size in map keys and values functions
Ian Lance Taylor [Fri, 13 Oct 2023 17:34:30 +0000 (10:34 -0700)]
runtime: use real type size in map keys and values functions

We were using the size stored in the map, which is the smaller
of the real type size and 128.

As of CL 61538 we don't use these functions, but we expect to
use them again in the future after #61626 is resolved.

Change-Id: I7bfb4af5f0e3a56361d4019a8ed7c1ec59ff31fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/535215
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
7 months agocompress: some minor corrections or adjustments for godoc link
cui fliter [Fri, 13 Oct 2023 03:28:53 +0000 (11:28 +0800)]
compress: some minor corrections or adjustments for godoc link

Change-Id: Ic1fc777b9a4e8262851e27646d53a0ec4fe55b64
Reviewed-on: https://go-review.googlesource.com/c/go/+/535076
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
7 months agostrconv: add example for QuotedPrefix
Joe Tsai [Thu, 22 Jul 2021 22:41:53 +0000 (15:41 -0700)]
strconv: add example for QuotedPrefix

Example can sometimes be more informative than additional prose.

Fixes #46829

Change-Id: Ia5a5b121ad0b891026e77420d5f7f1b2c4a407da
Reviewed-on: https://go-review.googlesource.com/c/go/+/336749
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agoexpvar: add available godoc link
cui fliter [Fri, 13 Oct 2023 07:04:09 +0000 (15:04 +0800)]
expvar: add available godoc link

Change-Id: I2db83e3c97a154f8599b4fcbceeebf1c69ee61ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/534762
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agohash: add available godoc link
cui fliter [Fri, 13 Oct 2023 16:54:45 +0000 (00:54 +0800)]
hash: add available godoc link

Change-Id: Ieb43f28400e9ded3dc7e57f27f6d7514b14cc66d
Reviewed-on: https://go-review.googlesource.com/c/go/+/535083
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

7 months agoindex/suffixarray: add available godoc link
cui fliter [Fri, 13 Oct 2023 17:28:00 +0000 (01:28 +0800)]
index/suffixarray: add available godoc link

Change-Id: Ic6397348108f00fc88b59b259169bd98daceba3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/535085
Run-TryBot: shuang cui <imcusg@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agoarchive: add available godoc link
cui fliter [Thu, 12 Oct 2023 04:18:18 +0000 (12:18 +0800)]
archive: add available godoc link

Change-Id: I813aa09f8a65936796469fa637d0f23004d26098
Reviewed-on: https://go-review.googlesource.com/c/go/+/534757
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>

7 months agobytes,strings: add available godoc link
cui fliter [Thu, 12 Oct 2023 03:49:26 +0000 (11:49 +0800)]
bytes,strings: add available godoc link

Change-Id: Id9706a783d3321e3706eeee102286522e7968efd
Reviewed-on: https://go-review.googlesource.com/c/go/+/534775
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agocrypto: add available godoc link
cui fliter [Thu, 12 Oct 2023 10:08:04 +0000 (18:08 +0800)]
crypto: add available godoc link

Change-Id: Ifc669399dde7d6229c6ccdbe29611ed1f8698fb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/534778
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agocmd/compile/internal/pgo: readability refactor
Michael Pratt [Tue, 19 Sep 2023 21:04:06 +0000 (17:04 -0400)]
cmd/compile/internal/pgo: readability refactor

Construction of Profile is getting more complex. Currently, we construct
a partial Profile and then use methods to slowly complete the structure.
This can hide dependencies and make refactoring fragile as the
requirements and outputs of the methods is not clearly specified.

Refactor construction to build the Profile only once all of the parts
are complete. The intermediate states explicitly pass input and outputs
as arguments.

Additionally, rename Profile.NodeMap to NamedEdgeMap to make its
contents more clear (edges, specified by caller/callee name rather than
IR). Remove the node flat/cumulative weight from this map; they are
unused.

Change-Id: I2079cd991daac6398d74375b04dfe120b473d908
Reviewed-on: https://go-review.googlesource.com/c/go/+/529558
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
7 months agocmd/compile: lookup indirect callees from export data for devirtualization
Michael Pratt [Mon, 15 May 2023 22:00:57 +0000 (18:00 -0400)]
cmd/compile: lookup indirect callees from export data for devirtualization

Today, the PGO IR graph only contains entries for ir.Func loaded into
the package. This can include functions from transitive dependencies,
but only if they happen to be referenced by something in the current
package. If they are not referenced, noder never bothers to load them.

This leads to a deficiency in PGO devirtualization: some callee methods
are available in transitive dependencies but do not devirtualize because
they happen to not get loaded from export data.

Resolve this by adding an explicit lookup from export data of callees
mentioned in the profile.

I have chosen to do this during loading of the profile for simplicity:
the PGO IR graph always contains all of the functions we might need.
That said, it isn't strictly necessary. PGO devirtualization could do
the lookup lazily if it decides it actually needs a method. This saves
work at the expense of a bit more complexity, but I've chosen the
simpler approach for now as I measured the cost of this as significantly
less than the rest of PGO loading.

For #61577.

Change-Id: Ieafb2a549510587027270ee6b4c3aefd149a901f
Reviewed-on: https://go-review.googlesource.com/c/go/+/497175
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
7 months agocmd/internal/objabi: add inverse of PathToPrefix
Michael Pratt [Fri, 15 Sep 2023 17:49:56 +0000 (13:49 -0400)]
cmd/internal/objabi: add inverse of PathToPrefix

Add PrefixToPath, which can be used to convert a package path in a
symbol name back to the original package path.

For #61577.

Change-Id: Ifbe8c852a7f41ff9b81ad48b92a26a0e1b046777
Reviewed-on: https://go-review.googlesource.com/c/go/+/529557
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
7 months agocmd/link/internal/ld: assign temporary addresses to per-package text
Joel Sing [Fri, 10 Sep 2021 16:03:10 +0000 (02:03 +1000)]
cmd/link/internal/ld: assign temporary addresses to per-package text

If trampolines may be required, the current text addressing second
pass resets all assigned addresses, before assigning addresses and
laying down trampolines in a linear fashion. However, this approach
means that intra-package calls are to a symbol that has not yet
been assigned an address, when the symbol is ahead of the current
function.

In the case of RISC-V the JAL instruction is limited to +/-1MiB.
As such, if a call is to a symbol with no address currently assigned,
we have to assume that a trampoline will be required. During the
relocation phase we can fix up and avoid trampolines in some cases,
however this results in unused trampolines that are still present
in the binary (since removing them would change text addresses).

In order to significantly reduce the number of unused trampolines,
assign temporary addresses to functions within the same package,
based on the maximum number of trampolines that may be required by
a function. This allows for better decisions to be made regarding
the requirement for intra-package trampolines, as we reset the
addressing for a function, assign its final address and lay down
any resulting trampolines.

This results in ~2,300 unused trampolines being removed from the
Go binary and ~5,600 unused trampolines being removed from the
compile binary, on linux/riscv64.

This reapplies CL 349650, however does not pass big to assignAddress
when assigning temporary addresses, as this can result in side
effects such as section splitting.

Change-Id: Id7febdb65d962d6b1297a91294a8dc27c94d8696
Reviewed-on: https://go-review.googlesource.com/c/go/+/534760
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
7 months agoencoding/xml: use reflect.Value.IsZero
apocelipes [Thu, 12 Oct 2023 15:55:54 +0000 (15:55 +0000)]
encoding/xml: use reflect.Value.IsZero

IsZero does the same thing, using this rather than writing it again.

Change-Id: I62810ac2d1a6e189feac03b022c8931fb6993e19
GitHub-Last-Rev: 1d5fd10d96baf75e8b170a2c71949ff3d0884c46
GitHub-Pull-Request: golang/go#63519
Reviewed-on: https://go-review.googlesource.com/c/go/+/534935
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
7 months agoruntime: don't print "unexpected SPWRITE" when printing traceback
Cherry Mui [Fri, 29 Sep 2023 18:00:04 +0000 (14:00 -0400)]
runtime: don't print "unexpected SPWRITE" when printing traceback

The system stack often starts with a stack transition function
like "systemstack" or "mcall", which is marked as SPWRITE. When
unwinding a system stack for printing, we want the traceback stop
at the stack switching frame, but not print the "unexpected
SPWRITE" message.

Previously before CL 525835, we don't print the "unexpected
SPWRITE" message if unwindPrintErrors is set, i.e. printing a
stack trace. This CL restores this behavior.

Another possibility is not printing the message only on the system
stack. We don't expect a stack transition function to appear in a
user G.

Change-Id: I173e89ead2cd4fbf1f0f8cca225f28718b5baebe
Reviewed-on: https://go-review.googlesource.com/c/go/+/531815
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
7 months agocmd/compile: synchronize inlinability logic between hairyVisitor and mkinlcall
Michael Pratt [Mon, 10 Apr 2023 21:11:39 +0000 (17:11 -0400)]
cmd/compile: synchronize inlinability logic between hairyVisitor and mkinlcall

When computing function cost, hairyVisitor.doNode has two primary cases
for determining the cost of a call inside the function:

* Normal calls are simply cost 57.
* Calls that can be inlined have the cost of the inlined function body,
  since that body will end up in this function.

Determining which "calls can be inlined" is where this breaks down.
doNode simply assumes that any function with `fn.Inl != nil` will get
inlined. However, this are more complex in mkinlcall, which has a
variety of cases where it may not inline.

For standard builds, most of these reasons are fairly rare (recursive
calls, calls to runtime functions in instrumented builds, etc), so this
simplification isn't too build.

However, for PGO builds, any function involved in at least one inlinable
hot callsite will have `fn.Inl != nil`, even though mkinlcall will only
inline at the hot callsites. As a result, cold functions calling hot
functions will use the (potentially very large) hot function inline body
cost in their call budget. This could make these functions too expensive
to inline even though they won't actually inline the hot function.

Handle this case plus the other inlinability cases (recursive calls,
etc) by consolidating mkinlcall's inlinability logic into
canInlineCallExpr, which is shared by doNode.

mkinlcall and doNode now have identical logic, except for one case: we
check for recursive cycles via inlined functions by looking at the
inline tree. Since we haven't actually done any inlining yet when in
doNode, we will miss those cases.

This CL doesn't change any inlining decisions in a standard build of the
compiler.

In the new inliner, the inlining decision is also based on the call
site, so this synchronization is also helpful.

Fixes #59484

Change-Id: I6ace66e37d50526535972215497ef75cd71f8b9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/483196
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
7 months agocmd/compile: when combining stores, use line number of first store
Keith Randall [Mon, 21 Aug 2023 22:55:35 +0000 (15:55 -0700)]
cmd/compile: when combining stores, use line number of first store

var p *[2]uint32 = ...
p[0] = 0
p[1] = 0

When we combine these two 32-bit stores into a single 64-bit store,
use the line number of the first store, not the second one.
This differs from the default behavior because usually with the combining
that the compiler does, we use the line number of the last instruction
in the combo (e.g. load+add, we use the line number of the add).

This is the same behavior that gcc does in C (picking the line
number of the first of a set of combined stores).

Change-Id: Ie70bf6151755322d33ecd50e4d9caf62f7881784
Reviewed-on: https://go-review.googlesource.com/c/go/+/521678
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
7 months agocompress: add available godoc link
cui fliter [Thu, 12 Oct 2023 06:43:47 +0000 (14:43 +0800)]
compress: add available godoc link

Change-Id: Ia6e88aec59cb294e8b303a00fcd69f4cbf0dc09a
Reviewed-on: https://go-review.googlesource.com/c/go/+/534759
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>

7 months agocontainer/heap: add available godoc link
cui fliter [Thu, 12 Oct 2023 06:54:31 +0000 (14:54 +0800)]
container/heap: add available godoc link

Change-Id: I886a8869ba885286ac8219bc7e245c9237ad4c99
Reviewed-on: https://go-review.googlesource.com/c/go/+/534777
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agobufio: add available godoc link
cui fliter [Thu, 12 Oct 2023 06:13:36 +0000 (14:13 +0800)]
bufio: add available godoc link

Change-Id: Id32bae57c9fcc2074f82089ba9c69be9a601f128
Reviewed-on: https://go-review.googlesource.com/c/go/+/534758
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

7 months agoruntime: don't use atomic store in noteclear on AIX
Ian Lance Taylor [Wed, 11 Oct 2023 21:09:20 +0000 (14:09 -0700)]
runtime: don't use atomic store in noteclear on AIX

In CL 163624 we added an atomic store in noteclear on AIX only.
In the discussion on issue #63384 we think we figured out that the
real problem was in the implementation of compare-and-swap on ppc64.
That is fixed by CL 533118, so the atomic store is no longer required.

For #30189
For #63384

Change-Id: I60f4f2fac75106f2bee51a8d9663259dcde2029c
Reviewed-on: https://go-review.googlesource.com/c/go/+/534517
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agocmd/compiler: make decompose shortcuts apply for PtrShaped, not just Ptr
David Chase [Wed, 11 Oct 2023 21:28:02 +0000 (17:28 -0400)]
cmd/compiler: make decompose shortcuts apply for PtrShaped, not just Ptr

The immediate-data interface shortcuts also apply to pointer-shaped
things like maps, channels, and functions.

Fixes #63505.

Change-Id: I43982441bf523f53e9e5d183e95aea7c6655dd6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/534657
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Auto-Submit: David Chase <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
7 months agoruntime/cgo: avoid taking the address of crosscall2 in code
Cherry Mui [Sat, 7 Oct 2023 00:53:27 +0000 (20:53 -0400)]
runtime/cgo: avoid taking the address of crosscall2 in code

Currently, set_crosscall2 takes the address of crosscall2 without
using the GOT, which, on some architectures, results in a
PC-relative relocation (e.g. R_AARCH64_ADR_PREL_PG_HI21 on ARM64)
to the crosscall2 symbol. But crosscall2 is dynamically exported,
so the C linker thinks it may bind to a symbol from a different
DSO. Some C linker may not like a PC-relative relocation to such a
symbol. Using a local trampoline to avoid taking the address of a
dynamically exported symbol.

It may be possible to not dynamically export crosscall2. But this
CL is safer for backport. Later we may remove the trampolines
after unexport crosscall2, if they are not needed.

Fixes #62556.

Change-Id: Id28457f65ef121d3f87d8189803abc65ed453283
Reviewed-on: https://go-review.googlesource.com/c/go/+/533535
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agonet: clear malloc'ed memory in cgoResSearch
Ian Lance Taylor [Wed, 11 Oct 2023 20:24:54 +0000 (13:24 -0700)]
net: clear malloc'ed memory in cgoResSearch

For #61666

Change-Id: I7a0a849fba0abebe28804bdd6d364b154456e399
Reviewed-on: https://go-review.googlesource.com/c/go/+/534516
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agocmd/compile, runtime/internal/atomic: add lwsync for false ppc64 cas
Ian Lance Taylor [Fri, 6 Oct 2023 19:20:19 +0000 (12:20 -0700)]
cmd/compile, runtime/internal/atomic: add lwsync for false ppc64 cas

This CL changes ppc64 atomic compare-and-swap (cas). Before this CL,
if the cas failed--if the value in memory was not the value expected
by the cas call--the atomic function would not synchronize memory.

In the note code in runtime/lock_sema.go, used on BSD systems,
notesleep and notetsleep first try a cas on the key. If that cas fails,
something has already called notewakeup, and the sleep completes.
However, because the cas did not synchronize memory on failure,
this meant that notesleep/notetsleep could return to a core that was
unable to see the memory changes that the notewakeup was reporting.

Fixes #30189
Fixes #63384

Change-Id: I9b921de5c1c09b10a37df6b3206b9003c3f32986
Reviewed-on: https://go-review.googlesource.com/c/go/+/533118
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agocmd/compile: use absolute file name in isCgo check
Ian Lance Taylor [Wed, 20 Sep 2023 23:16:29 +0000 (16:16 -0700)]
cmd/compile: use absolute file name in isCgo check

For #23672
Fixes #63211
Fixes CVE-2023-39323

Change-Id: I4586a69e1b2560036afec29d53e53cf25e6c7352
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/2032884
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/534158
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agoio/fs: add godoc links
Olivier Mengué [Tue, 10 Oct 2023 20:54:39 +0000 (22:54 +0200)]
io/fs: add godoc links

Change-Id: Icde42bd33d58f75acdede439f7525f9d06554140
Reviewed-on: https://go-review.googlesource.com/c/go/+/534096
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agoregexp: add godoc links
Olivier Mengué [Mon, 3 Jul 2023 21:13:44 +0000 (23:13 +0200)]
regexp: add godoc links

Change-Id: I087162f866e781258f9fbb96215c1ff6a5c315a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/507776
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
7 months agomaps: add examples for Clone,Copy and Equal
cui fliter [Tue, 10 Oct 2023 02:51:19 +0000 (10:51 +0800)]
maps: add examples for Clone,Copy and Equal

Change-Id: I72adaf48588e7d6cffbc0ee8005decda06808e84
Reviewed-on: https://go-review.googlesource.com/c/go/+/534055
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agotesting/fstest: add godoc links
Olivier Mengué [Mon, 9 Oct 2023 21:56:48 +0000 (23:56 +0200)]
testing/fstest: add godoc links

Change-Id: I611f04f12bb93197fea5ae40a08e5f60426f1c00
Reviewed-on: https://go-review.googlesource.com/c/go/+/534076
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agotesting/fstest: MapFS: set perm 0555 on synthetized dirs
Olivier Mengué [Sun, 8 Oct 2023 15:51:00 +0000 (17:51 +0200)]
testing/fstest: MapFS: set perm 0555 on synthetized dirs

As MapFS ignores filemodes and always grant read and traverse access on
directories, let's make synthetized directory entries to expose filemode
0555 instead of 0000.
Fixes #63468.

Change-Id: I5d64a6bf2f2ac6082ca5dde55b3062669fb50b8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/534075
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agoruntime: remove write-only sweepdata fields
Michael Pratt [Tue, 10 Oct 2023 19:30:09 +0000 (15:30 -0400)]
runtime: remove write-only sweepdata fields

Change-Id: Ia238889a704812473b838b20efedfe9d24b1e26f
Reviewed-on: https://go-review.googlesource.com/c/go/+/534160
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
7 months agoruntime: remove stale non-atomic access comment
Michael Pratt [Wed, 11 Oct 2023 16:02:28 +0000 (12:02 -0400)]
runtime: remove stale non-atomic access comment

CL 397014 converted this into an atomic access.

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

7 months agocmd/go: clean up "cover" debug output
Austin Clements [Wed, 11 Oct 2023 16:20:19 +0000 (12:20 -0400)]
cmd/go: clean up "cover" debug output

Currently, the two places that run the cover tool manually construct a
terse command description. However, this actually prevents Builder.run
from constructing a more detailed description from the actual command
being run. Fix this by passing "" as the description to get the
default behavior.

Change-Id: I27d42cb1fda9bba70c631dc43417a03b8bddec92
Reviewed-on: https://go-review.googlesource.com/c/go/+/534157
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
7 months agotypes2, go/types: remove doc link from Func.Pkg comment
Cuong Manh Le [Wed, 11 Oct 2023 08:34:09 +0000 (15:34 +0700)]
types2, go/types: remove doc link from Func.Pkg comment

The documentation link only works with exported identifiers. Further,
the built-in error interface lives in pseudo package "builtin" only,
thus it's not a real package that can be referred using doc links.

Change-Id: I2116beb27fc73ba33f8352301fe77b4b6abc3ec1
Reviewed-on: https://go-review.googlesource.com/c/go/+/534436
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
7 months agogo/types: clarify the documentation for Func.Pkg
Jonathan Amsterdam [Tue, 10 Oct 2023 19:34:42 +0000 (15:34 -0400)]
go/types: clarify the documentation for Func.Pkg

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

7 months agoRevert "cmd/link/internal/ld: assign temporary addresses to per-package text"
Than McIntosh [Tue, 10 Oct 2023 19:56:41 +0000 (19:56 +0000)]
Revert "cmd/link/internal/ld: assign temporary addresses to per-package text"

This reverts commit http://go.dev/cl/349650

Reason for revert: CL breaks multiple builders with failure in TestLargeTextSectionSplitting

Change-Id: I4894ffd101b2757a6e6359212d5b8a64da1fcdf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/534299
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
7 months agoruntime: quote -ex and -iex gdb arguments on Windows
qmuntal [Tue, 10 Oct 2023 12:58:37 +0000 (14:58 +0200)]
runtime: quote -ex and -iex gdb arguments on Windows

On Windows, some gdb flavors expect -ex and -iex arguments containing
spaces to be double quoted.

Change-Id: I2891e115f98c1df3a7a481bd9f9d9215bfbecd44
Reviewed-on: https://go-review.googlesource.com/c/go/+/534097
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>

7 months agocmd/link/internal/ld: assign temporary addresses to per-package text
Joel Sing [Fri, 10 Sep 2021 16:03:10 +0000 (02:03 +1000)]
cmd/link/internal/ld: assign temporary addresses to per-package text

If trampolines may be required, the current text addressing second
pass resets all assigned addresses, before assigning addresses and
laying down trampolines in a linear fashion. However, this approach
means that intra-package calls are to a symbol that has not yet
been assigned an address, when the symbol is ahead of the current
function.

In the case of RISC-V the JAL instruction is limited to +/-1MiB.
As such, if a call is to a symbol with no address currently assigned,
we have to assume that a trampoline will be required. During the
relocation phase we can fix up and avoid trampolines in some cases,
however this results in unused trampolines that are still present
in the binary (since removing them would change text addresses).

In order to significantly reduce the number of unused trampolines,
assign temporary addresses to functions within the same package,
based on the maximum number of trampolines that may be required by
a function. This allows for better decisions to be made regarding
the requirement for intra-package trampolines, as we reset the
addressing for a function, assign its final address and lay down
any resulting trampolines.

This results in ~2,300 unused trampolines being removed from the
Go binary and ~5,600 unused trampolines being removed from the
compile binary, on linux/riscv64.

Change-Id: I8a9cf035dea82e1e1e66ae5b1093dce78e4ff0d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/349650
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

7 months agocmd/compile: get rid of zero-sized values in call expansion
David Chase [Tue, 10 Oct 2023 16:18:43 +0000 (12:18 -0400)]
cmd/compile: get rid of zero-sized values in call expansion

Do this by removing all stores of zero-sized anything.

Fixes #63433.

Change-Id: I5d8271edab992d15d02005fa3fe31835f2eff8fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/534296
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

7 months agoall: pull in x/net v0.17.0 and its dependencies
Dmitri Shuralyov [Tue, 10 Oct 2023 15:22:17 +0000 (11:22 -0400)]
all: pull in x/net v0.17.0 and its dependencies

Pull in a security fix from x/net/http2:
http2: limit maximum handler goroutines to MaxConcurrentStreams

Fixes #63417.
Fixes CVE-2023-39325.

Change-Id: I01e7774912e81007a7cf70f33e5989fb50a0b708
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/534295
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agogo/types: update FileVersions API to match proposal changes
Robert Griesemer [Mon, 9 Oct 2023 21:49:37 +0000 (14:49 -0700)]
go/types: update FileVersions API to match proposal changes

For #62605.

Change-Id: I6e9032eb92db758bf359e7cc9c4cedc1e0fb2309
Reviewed-on: https://go-review.googlesource.com/c/go/+/534018
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
7 months agoruntime: fix some comments
Jes Cok [Mon, 9 Oct 2023 16:41:24 +0000 (16:41 +0000)]
runtime: fix some comments

Change-Id: I06403cf217a4d2645e13115e7ca358b7f3d3f2ef
GitHub-Last-Rev: e2b4e5326a6c68d066b637c6add86723e0cefd3b
GitHub-Pull-Request: golang/go#63474
Reviewed-on: https://go-review.googlesource.com/c/go/+/533875
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

7 months agotesting: remove unnecessary TempDir implementation detail from its doc
Ville Skyttä [Mon, 9 Oct 2023 21:03:10 +0000 (21:03 +0000)]
testing: remove unnecessary TempDir implementation detail from its doc

The "by Cleanup" detail about the removal mechanism is not necessary for
users. The previous wording could even cause confusion whether they
should do something for Cleanup to occur.

Change-Id: I617a7a4e118a70a3ad8a83a2d81cd911dde8ee08
GitHub-Last-Rev: fba4cde6362d1f0ea0c730d50fdd3fbaae4e17cf
GitHub-Pull-Request: golang/go#63479
Reviewed-on: https://go-review.googlesource.com/c/go/+/534016
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
7 months agocmd/compile: fix wrong argument of OpSelectN during expand_calls
Cuong Manh Le [Mon, 9 Oct 2023 15:39:50 +0000 (22:39 +0700)]
cmd/compile: fix wrong argument of OpSelectN during expand_calls

Fixes #63462

Change-Id: I5ddf831eab630e23156f8f27a079b4ca4bb3a261
Reviewed-on: https://go-review.googlesource.com/c/go/+/533795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

7 months agocmd/compile: regenerate rewriteRISCV64.go to match cl 528975
Mark Ryan [Mon, 9 Oct 2023 13:49:44 +0000 (15:49 +0200)]
cmd/compile: regenerate rewriteRISCV64.go to match cl 528975

The final revision of

https://go-review.googlesource.com/c/go/+/528975

made a small change to the RISCV64.rules file but neglected to update
the regenerated rewriteRISCV64.go file.

Change-Id: I04599f4e3b0dac7102c54166c9bae6fc9b6621d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/533815
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

7 months agogo/token: use "// Output:" instead of "//Output:" in examples
Jes Cok [Sun, 8 Oct 2023 15:52:43 +0000 (15:52 +0000)]
go/token: use "// Output:" instead of "//Output:" in examples

Change-Id: I86eb365650749bb4f41e9ae62123674581dffe2b
GitHub-Last-Rev: 7a9d6800ab3f2c8e6c738d36c2f882486ce2703a
GitHub-Pull-Request: golang/go#63449
Reviewed-on: https://go-review.googlesource.com/c/go/+/533120
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
7 months agoos: use strings.EqualFold in os_test.go
cui fliter [Sun, 8 Oct 2023 02:51:45 +0000 (10:51 +0800)]
os: use strings.EqualFold in os_test.go

strings.EqualFold has no memory overhead and has better performance than strings.ToLower.

This is a performance test:

package bench

import (
"strings"
"testing"
)

func BenchmarkToLower(b *testing.B) {

str1 := "Windows"
str2 := "windows"

for i := 0; i < b.N; i++ {
if strings.ToLower(str1) == strings.ToLower(str2) {
}
}
}

func BenchmarkEqualFold(b *testing.B) {

str1 := "Windows"
str2 := "windows"

for i := 0; i < b.N; i++ {
if strings.EqualFold(str1, str2) {
}
}
}

The result:

goos: darwin
goarch: arm64
BenchmarkToLower-8      31404808                36.99 ns/op            8 B/op          1 allocs/op
BenchmarkEqualFold-8    194780793                5.989 ns/op           0 B/op          0 allocs/op
PASS

Change-Id: Id3d92534942d3eb0bdc1d01359324030ad0e434f
Reviewed-on: https://go-review.googlesource.com/c/go/+/533635
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

7 months agobytes,strings: add example for ContainsFunc
cui fliter [Sun, 8 Oct 2023 08:42:26 +0000 (16:42 +0800)]
bytes,strings: add example for ContainsFunc

Change-Id: I340e892aa4ecc780905be984016efc86699a45a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/533556
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>