]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
8 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>
8 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>

8 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>

8 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>

8 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>
8 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>
8 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>
8 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>
8 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>
8 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>

8 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>
8 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>
8 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>

8 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>

8 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>

8 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>
8 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>

8 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>
8 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>
8 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>

8 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>
8 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>

8 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>

8 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>

8 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>

8 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>
8 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>

8 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>
8 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>

8 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>

8 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>
8 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>

8 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>

8 months agoio: add (*SectionReader).Outer()
Carlo Alberto Ferraris [Thu, 7 Sep 2023 23:21:58 +0000 (08:21 +0900)]
io: add (*SectionReader).Outer()

Fixes #61870
Updates #61727

Change-Id: Iaef9b59c402d68f6bf64be212db2b6746abe8900
Reviewed-on: https://go-review.googlesource.com/c/go/+/526855
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: Dmitri Shuralyov <dmitshur@google.com>

8 months agoreflect: compute the median h uniformly
Jes Cok [Sat, 7 Oct 2023 16:18:16 +0000 (16:18 +0000)]
reflect: compute the median h uniformly

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

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

8 months agoruntime: normalize line endings in TestGdbPython
qmuntal [Thu, 5 Oct 2023 10:02:43 +0000 (12:02 +0200)]
runtime: normalize line endings in TestGdbPython

TestGdbPython fails on some Windows setups because the line endings in
the output of the gdb command can potentially be CRLF, but the test
expects LF.

This CL changes the test to normalize the line endings.

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

8 months agocmd/go: remove unnecessary b.Print setting
Austin Clements [Thu, 24 Aug 2023 20:48:14 +0000 (16:48 -0400)]
cmd/go: remove unnecessary b.Print setting

The Builder returned by work.NewBuilder is already setup to print to
os.Stderr, so it's not necessary for runRun to set b.Print to a
different function that does exactly the same thing.

This b.Print assignment was introduced in CL 5591045. At the time, the
builder type defaulted to printing to os.Stdout, so this was necessary
to make "go run" print build errors to stderr.

Change-Id: I0c07984616c5efc37ba681f4cf69e83542566bab
Reviewed-on: https://go-review.googlesource.com/c/go/+/522796
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
8 months agogo/types: document unfixable bug at Selection.Indirect
Alan Donovan [Mon, 9 Oct 2023 18:18:06 +0000 (14:18 -0400)]
go/types: document unfixable bug at Selection.Indirect

Updates #8353

Change-Id: I80cdbfccb8f7db00e04c293a68aaebc7c71bbbe9
Reviewed-on: https://go-review.googlesource.com/c/go/+/533935
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocrypto/aes,crypto/cipher: improve gcm performance on ppc64x
Lynn Boger [Tue, 11 Apr 2023 19:49:29 +0000 (14:49 -0500)]
crypto/aes,crypto/cipher: improve gcm performance on ppc64x

This improves performance for AES-GCM. The function
counterCrypt is written in assembler so the loop can
be unrolled and the stitched approach used for the
encryption.

This implementation works on ppc64le and ppc64. The use
of GOPPC64=power9 generates the best performance,
goos: linux
goarch: ppc64le
pkg: crypto/cipher
cpu: POWER10
                     │ gcmx8.cpu1.out │         gcmx8.new.cpu1.out         │
                     │     sec/op     │   sec/op     vs base               │
AESGCM/Open-128-64        180.5n ± 0%   152.7n ± 1%  -15.43% (p=0.000 n=8)
AESGCM/Seal-128-64        166.8n ± 0%   147.2n ± 0%  -11.72% (p=0.000 n=8)
AESGCM/Open-256-64        194.9n ± 0%   156.6n ± 1%  -19.65% (p=0.000 n=8)
AESGCM/Seal-256-64        183.7n ± 0%   157.0n ± 0%  -14.51% (p=0.000 n=8)
AESGCM/Open-128-1350     1769.5n ± 0%   454.5n ± 0%  -74.31% (p=0.000 n=8)
AESGCM/Seal-128-1350     1759.0n ± 0%   453.7n ± 0%  -74.21% (p=0.000 n=8)
AESGCM/Open-256-1350     2104.0n ± 0%   504.4n ± 1%  -76.03% (p=0.000 n=8)
AESGCM/Seal-256-1350     2092.0n ± 0%   503.0n ± 0%  -75.96% (p=0.000 n=8)
AESGCM/Open-128-8192     10.054µ ± 0%   1.961µ ± 0%  -80.50% (p=0.000 n=8)
AESGCM/Seal-128-8192     10.050µ ± 0%   1.965µ ± 0%  -80.45% (p=0.000 n=8)
AESGCM/Open-256-8192     12.080µ ± 0%   2.232µ ± 0%  -81.52% (p=0.000 n=8)
AESGCM/Seal-256-8192     12.069µ ± 0%   2.238µ ± 0%  -81.46% (p=0.000 n=8)
geomean                   1.566µ        535.5n       -65.80%

                     │ gcmx8.cpu1.out │          gcmx8.new.cpu1.out           │
                     │      B/s       │      B/s       vs base                │
AESGCM/Open-128-64       338.1Mi ± 0%    399.8Mi ± 1%   +18.27% (p=0.000 n=8)
AESGCM/Seal-128-64       366.1Mi ± 0%    414.6Mi ± 0%   +13.28% (p=0.000 n=8)
AESGCM/Open-256-64       313.1Mi ± 0%    389.7Mi ± 0%   +24.47% (p=0.000 n=8)
AESGCM/Seal-256-64       332.3Mi ± 0%    388.5Mi ± 0%   +16.93% (p=0.000 n=8)
AESGCM/Open-128-1350     727.6Mi ± 0%   2832.8Mi ± 0%  +289.33% (p=0.000 n=8)
AESGCM/Seal-128-1350     732.0Mi ± 0%   2837.8Mi ± 0%  +287.70% (p=0.000 n=8)
AESGCM/Open-256-1350     611.9Mi ± 0%   2552.6Mi ± 0%  +317.18% (p=0.000 n=8)
AESGCM/Seal-256-1350     615.3Mi ± 0%   2559.6Mi ± 0%  +315.97% (p=0.000 n=8)
AESGCM/Open-128-8192     777.1Mi ± 0%   3983.5Mi ± 0%  +412.63% (p=0.000 n=8)
AESGCM/Seal-128-8192     777.3Mi ± 0%   3975.9Mi ± 0%  +411.47% (p=0.000 n=8)
AESGCM/Open-256-8192     646.7Mi ± 0%   3500.6Mi ± 0%  +441.27% (p=0.000 n=8)
AESGCM/Seal-256-8192     647.3Mi ± 0%   3491.1Mi ± 0%  +439.30% (p=0.000 n=8)
geomean                  542.7Mi         1.550Gi       +192.42%

Change-Id: I3600831a263ec8a99b5e3bdd495eb36e966d8075
Reviewed-on: https://go-review.googlesource.com/c/go/+/484575
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
8 months agocmd/compile: use type hash from itab field instead of type field
Keith Randall [Tue, 26 Sep 2023 01:00:10 +0000 (18:00 -0700)]
cmd/compile: use type hash from itab field instead of type field

It is one less dependent load away, and right next to another
field in the itab we also load as part of the type switch or
type assert.

Change-Id: If7aaa7814c47bd79a6c7ed4232ece0bc1d63550e
Reviewed-on: https://go-review.googlesource.com/c/go/+/533117
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
8 months agocmd/compile: fix typecheck range over negative integer
Cuong Manh Le [Thu, 5 Oct 2023 04:11:51 +0000 (11:11 +0700)]
cmd/compile: fix typecheck range over negative integer

Before range over integer, types2 leaves constant expression in RHS of
non-constant shift untyped, so idealType do the validation to ensure
that constant value must be an int >= 0.

With range over int, the range expression can also be left untyped, and
can be an negative integer, causing the validation false.

Fixing this by relaxing the validation in idealType, and moving the
check to Unified IR reader.

Fixes #63378

Change-Id: I43042536c09afd98d52c5981adff5dbc5e7d882a
Reviewed-on: https://go-review.googlesource.com/c/go/+/532835
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
8 months agogo/types: clarify semantics of Selection
Alan Donovan [Mon, 9 Oct 2023 17:31:25 +0000 (13:31 -0400)]
go/types: clarify semantics of Selection

This is one of the more complex areas of the (pre-generics)
spec, and I'm probably not the only person who can never
remember all the details each time I need them.

Change-Id: I25b3c46311df4db33357af5601c5e3586327dac2
Reviewed-on: https://go-review.googlesource.com/c/go/+/533736
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>

8 months agocrypto/cipher: update GCM test
Lynn Boger [Wed, 4 Oct 2023 14:50:29 +0000 (09:50 -0500)]
crypto/cipher: update GCM test

This adds more variations for sizes of the input text
to the gcm tests.

Change-Id: I39dba5f08c77f04f94278200c3ce9234f977506f
Reviewed-on: https://go-review.googlesource.com/c/go/+/532635
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
8 months agocmd/compile: use cache in front of convI2I
Keith Randall [Mon, 25 Sep 2023 20:42:19 +0000 (13:42 -0700)]
cmd/compile: use cache in front of convI2I

This is the last of the getitab users to receive a cache.
We should now no longer see getitab (and callees) in profiles.
Hopefully.

Change-Id: I2ed72b9943095bbe8067c805da7f08e00706c98c
Reviewed-on: https://go-review.googlesource.com/c/go/+/531055
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
8 months agocmd/compile: use internal/abi types in the compiler
Keith Randall [Sun, 1 Oct 2023 17:02:39 +0000 (10:02 -0700)]
cmd/compile: use internal/abi types in the compiler

It is tricky to use those types directly, because the layout of those
types in the compiler may not be the same as the layout of those
types in target binary (typically because of 32 vs 64 bit differences).

Instead, translate an internal/abi type into a cmd/compile/internal/types
type, which will then be laid out for the target machine.

Along with the translation, keep track of where all the bits of the
type are so we can reference their locations symbolically instead of
hardcoding them.

Change-Id: I2694c58968d4dc7ead63a2b1b29adfedd90ddd2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/532155
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@google.com>
8 months agomap: use correct load factor for deciding when to grow
Keith Randall [Sat, 7 Oct 2023 16:19:16 +0000 (09:19 -0700)]
map: use correct load factor for deciding when to grow

The correct load factor is 6.5, not 6.
This got broken by accident in CL 462115.

Fixes #63438

Change-Id: Ib07bb6ab6103aec87cb775bc06bd04362a64e489
Reviewed-on: https://go-review.googlesource.com/c/go/+/533279
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/compile: fix ICE with parenthesized builtin calls
Cuong Manh Le [Sat, 7 Oct 2023 15:54:50 +0000 (22:54 +0700)]
cmd/compile: fix ICE with parenthesized builtin calls

CL 419456 starts using lookupObj to find types2.Object associated with
builtin functions. However, the new code does not un-parenthesized the
callee expression, causing an ICE because of nil obj returned.

Un-parenthesizing the callee expression fixes the problem.

Fixes #63436

Change-Id: Iebb4fbc08575e7d0b1dbd026c98e8f949ca16460
Reviewed-on: https://go-review.googlesource.com/c/go/+/533476
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
8 months agocmd/compile/internal: stop lowering OpConvert on riscv64
Joel Sing [Fri, 6 Oct 2023 05:45:12 +0000 (16:45 +1100)]
cmd/compile/internal: stop lowering OpConvert on riscv64

Lowering for OpConvert was removed for all architectures in CL#108496,
prior to the riscv64 port being upstreamed. Remove lowering of OpConvert
on riscv64, which brings it inline with all other architectures. This
results in 1,600+ instructions being removed from the riscv64 go binary.

Change-Id: Iaaf1f8b397875926604048b66ad8ac91a98c871e
Reviewed-on: https://go-review.googlesource.com/c/go/+/533335
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
8 months agocmd/compile: optimize right shifts of uint32 on riscv
Mark Ryan [Sun, 17 Sep 2023 11:08:55 +0000 (13:08 +0200)]
cmd/compile: optimize right shifts of uint32 on riscv

The compiler is currently zero extending 32 bit unsigned integers to
64 bits before right shifting them using a 64 bit shift instruction.
There's no need to do this as RISC-V has instructions for right
shifting 32 bit unsigned values (srlw and srliw) which zero extend
the result of the shift to 64 bits.  Change the compiler so that
it uses srlw and srliw for 32 bit unsigned shifts reducing in most
cases the number of instructions needed to perform the shift.

Here are some examples of code sequences that are changed by this
patch:

uint32(a) >> 2

  before:

    sll     x5,x10,0x20
    srl     x10,x5,0x22

  after:

    srlw    x10,x10,0x2

uint32(a) >> int(b)

  before:

    sll     x5,x10,0x20
    srl     x5,x5,0x20
    srl     x5,x5,x11
    sltiu   x6,x11,64
    neg     x6,x6
    and     x10,x5,x6

  after:

    srlw    x5,x10,x11
    sltiu   x6,x11,32
    neg     x6,x6
    and     x10,x5,x6

bits.RotateLeft32(uint32(a), 1)

  before:

    sll     x5,x10,0x1
    sll     x6,x10,0x20
    srl     x7,x6,0x3f
    or      x5,x5,x7

  after:

   sll     x5,x10,0x1
   srlw    x6,x10,0x1f
   or      x10,x5,x6

bits.RotateLeft32(uint32(a), int(b))

  before:
    and     x6,x11,31
    sll     x7,x10,x6
    sll     x8,x10,0x20
    srl     x8,x8,0x20
    add     x6,x6,-32
    neg     x6,x6
    srl     x9,x8,x6
    sltiu   x6,x6,64
    neg     x6,x6
    and     x6,x9,x6
    or      x6,x6,x7

  after:

    and     x5,x11,31
    sll     x6,x10,x5
    add     x5,x5,-32
    neg     x5,x5
    srlw    x7,x10,x5
    sltiu   x5,x5,32
    neg     x5,x5
    and     x5,x7,x5
    or      x10,x6,x5

The one regression observed is the following case, an unbounded right
shift of a uint32 where the value we're shifting by is known to be
< 64 but > 31.  As this is an unusual case this commit does not
optimize for it, although the existing code does.

uint32(a) >> (b & 63)

  before:

    sll     x5,x10,0x20
    srl     x5,x5,0x20
    and     x6,x11,63
    srl     x10,x5,x6

  after

    and     x5,x11,63
    srlw    x6,x10,x5
    sltiu   x5,x5,32
    neg     x5,x5
    and     x10,x6,x5

Here we have one extra instruction.

Some benchmark highlights, generated on a VisionFive2 8GB running
Ubuntu 23.04.

pkg: math/bits
LeadingZeros32-4    18.64n ± 0%     17.32n ± 0%   -7.11% (p=0.000 n=10)
LeadingZeros64-4    15.47n ± 0%     15.51n ± 0%   +0.26% (p=0.027 n=10)
TrailingZeros16-4   18.48n ± 0%     17.68n ± 0%   -4.33% (p=0.000 n=10)
TrailingZeros32-4   16.87n ± 0%     16.07n ± 0%   -4.74% (p=0.000 n=10)
TrailingZeros64-4   15.26n ± 0%     15.27n ± 0%   +0.07% (p=0.043 n=10)
OnesCount32-4       20.08n ± 0%     19.29n ± 0%   -3.96% (p=0.000 n=10)
RotateLeft-4        8.864n ± 0%     8.838n ± 0%   -0.30% (p=0.006 n=10)
RotateLeft32-4      8.837n ± 0%     8.032n ± 0%   -9.11% (p=0.000 n=10)
Reverse32-4         29.77n ± 0%     26.52n ± 0%  -10.93% (p=0.000 n=10)
ReverseBytes32-4    9.640n ± 0%     8.838n ± 0%   -8.32% (p=0.000 n=10)
Sub32-4             8.835n ± 0%     8.035n ± 0%   -9.06% (p=0.000 n=10)
geomean             11.50n          11.33n        -1.45%

pkg: crypto/md5
Hash8Bytes-4             1.486µ ± 0%   1.426µ ± 0%  -4.04% (p=0.000 n=10)
Hash64-4                 2.079µ ± 0%   1.968µ ± 0%  -5.36% (p=0.000 n=10)
Hash128-4                2.720µ ± 0%   2.557µ ± 0%  -5.99% (p=0.000 n=10)
Hash256-4                3.996µ ± 0%   3.733µ ± 0%  -6.58% (p=0.000 n=10)
Hash512-4                6.541µ ± 0%   6.072µ ± 0%  -7.18% (p=0.000 n=10)
Hash1K-4                 11.64µ ± 0%   10.75µ ± 0%  -7.58% (p=0.000 n=10)
Hash8K-4                 82.95µ ± 0%   76.32µ ± 0%  -7.99% (p=0.000 n=10)
Hash1M-4                10.436m ± 0%   9.591m ± 0%  -8.10% (p=0.000 n=10)
Hash8M-4                 83.50m ± 0%   76.73m ± 0%  -8.10% (p=0.000 n=10)
Hash8BytesUnaligned-4    1.494µ ± 0%   1.434µ ± 0%  -4.02% (p=0.000 n=10)
Hash1KUnaligned-4        11.64µ ± 0%   10.76µ ± 0%  -7.52% (p=0.000 n=10)
Hash8KUnaligned-4        83.01µ ± 0%   76.32µ ± 0%  -8.07% (p=0.000 n=10)
geomean                  28.32µ        26.42µ       -6.72%

Change-Id: I20483a6668cca1b53fe83944bee3706aadcf8693
Reviewed-on: https://go-review.googlesource.com/c/go/+/528975
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agocmd/dist: emphasize when all tests are excluded
Dmitri Shuralyov [Mon, 2 Oct 2023 13:38:24 +0000 (09:38 -0400)]
cmd/dist: emphasize when all tests are excluded

As observed in https://go.dev/issue/61666#issuecomment-1739476954,
if a -run flag value matches no tests, dist test output doesn't do much
to help users notice that was what happened. It is valid and sometimes
intended¹ to match no tests, so I want to reserve failed status with
exit code 1 to the actionable outcome where at least 1 test failed.
But it seems reasonable to extend the existing "some were excluded"
mechanism of reporting partial testing to be more helpful.

In non-JSON mode, which is more likely to be used manually by humans,
print a special² last line that will hopefully be easier to notice when
matching no tests wasn't intended. Change nothing for -json mode since
that's likely used by machines and they can make sense of 0 JSON events.

The go test command already has this behavior, so this brings dist test
closer³ to it. (Slightly unfortunate duplicate maintenance for us, and
the need for the rare dist test users to learn its CLI quirks; oh well.)

¹ It might seem counter-intuitive at first: what's the point of calling
  dist test and asking it to run no tests? One possible answer is that
  it permits writing code capable of running N intended tests, where N
  is 0 or higher. That is, it allows for 0 to not be a special case that
  the caller would have no choice but handle differently.
² I initially considered making it say something like "N of M tests were
  excluded", but decided to leave it alone since the current coordinator
  code still has that text hardcoded and I don't want to break it. Hence
  the new status that I expect only humans will see. And it seems better
  this way anyway.
³ In particular, the "matched no tests" and "no tests to run" phrases
  were selected precisely because they're already used in cmd/go output.

Change-Id: I6768d9932587195ae6dbc6e2c4742479e265733b
Reviewed-on: https://go-review.googlesource.com/c/go/+/532115
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocrypto/subtle: improve xorBytes assembler on PPC64
Lynn Boger [Mon, 25 Sep 2023 15:49:11 +0000 (10:49 -0500)]
crypto/subtle: improve xorBytes assembler on PPC64

This makes some improvements to the xorBytes assembler
implementation for PPC64 targets.

The loops to process large streams of bytes has been changed to
do 64 bytes at a time. Other changes were made to prevent
degradations in some of the common sizes like 8, 16.

The case for < 8 bytes on power10 has been modified to use
the LXVL and STXVL instructions.

Change-Id: I7477d12d5375d484af8c274443d595ccdafbda7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/530877
Reviewed-by: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Jayanth Krishnamurthy <jayanth.krishnamurthy@ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>

8 months agosync: use atomic.Uint32 in Once
mstmdev [Fri, 6 Oct 2023 19:00:52 +0000 (19:00 +0000)]
sync: use atomic.Uint32 in Once

Change-Id: If9089f8afd78de3e62cd575f642ff96ab69e2099
GitHub-Last-Rev: 14165018d67e84685dcf84be0320623ccb3afc0e
GitHub-Pull-Request: golang/go#63386
Reviewed-on: https://go-review.googlesource.com/c/go/+/532895
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jorropo <jorropo.pgm@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

8 months agocmd/compile: expand calls cleanup
David Chase [Tue, 9 May 2023 14:34:52 +0000 (10:34 -0400)]
cmd/compile: expand calls cleanup

Convert expand calls into a smaller number of focused
recursive rewrites, and rely on an enhanced version of
"decompose" to clean up afterwards.

Debugging information seems to emerge intact.

Change-Id: Ic46da4207e3a4da5c8e2c47b637b0e35abbe56bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/507295
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agointernal/bytealg: process two AVX2 lanes per Count loop
Achille Roussel [Wed, 4 Oct 2023 04:58:03 +0000 (04:58 +0000)]
internal/bytealg: process two AVX2 lanes per Count loop

The branch taken by the bytealg.Count algorithm used to process a single
32 bytes block per loop iteration. Throughput of the algorithm can be
improved by unrolling two iterations per loop: the lack of data
dependencies between each iteration allows for better utilization of the
CPU pipeline. The improvement is most significant on medium size payloads
that fit in the L1 cache; beyond the L1 cache size, memory bandwidth is
likely the bottleneck and the change does not show any measurable
improvements.

goos: linux
goarch: amd64
pkg: bytes
cpu: Intel(R) Xeon(R) CPU @ 2.60GHz
                │   old.txt   │               new.txt               │
                │   sec/op    │   sec/op     vs base                │
CountSingle/10    4.800n ± 0%   4.811n ± 0%   +0.23% (p=0.000 n=10)
CountSingle/32    5.445n ± 0%   5.430n ± 0%        ~ (p=0.085 n=10)
CountSingle/4K    81.38n ± 1%   63.12n ± 0%  -22.43% (p=0.000 n=10)
CountSingle/4M    133.0µ ± 7%   130.1µ ± 4%        ~ (p=0.280 n=10)
CountSingle/64M   4.079m ± 1%   4.070m ± 3%        ~ (p=0.796 n=10)
geomean           1.029µ        973.3n        -5.41%

                │   old.txt    │               new.txt                │
                │     B/s      │     B/s       vs base                │
CountSingle/10    1.940Gi ± 0%   1.936Gi ± 0%   -0.22% (p=0.000 n=10)
CountSingle/32    5.474Gi ± 0%   5.488Gi ± 0%        ~ (p=0.075 n=10)
CountSingle/4K    46.88Gi ± 1%   60.43Gi ± 0%  +28.92% (p=0.000 n=10)
CountSingle/4M    29.39Gi ± 7%   30.02Gi ± 4%        ~ (p=0.280 n=10)
CountSingle/64M   15.32Gi ± 1%   15.36Gi ± 3%        ~ (p=0.796 n=10)
geomean           11.75Gi        12.42Gi        +5.71%

Change-Id: I1098228c726a2ee814806dcb438b7e92febf4370
Reviewed-on: https://go-review.googlesource.com/c/go/+/532457
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agointernal/syscall/unix: implement Eaccess on dragonfly
Tobias Klauser [Wed, 4 Oct 2023 16:07:37 +0000 (18:07 +0200)]
internal/syscall/unix: implement Eaccess on dragonfly

Like on other BSDs, use faccessat(AT_FDCWD, path, mode, AT_EACCESS)

Change-Id: I5b7649815651725ab9245aed3c8c1941ff9b7606
Reviewed-on: https://go-review.googlesource.com/c/go/+/532675
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agoencoding/json: fix appendCompact escaping
Alexander Yastrebov [Thu, 5 Oct 2023 21:55:06 +0000 (21:55 +0000)]
encoding/json: fix appendCompact escaping

CL 469555 changed Compact to use append instead of bytes.Buffer.

appendCompact iterates over input src slice and performs escaping
of certain characters.
To optimize copying it does not copy characters one by one
but keeps track of the start offset of the data to copy when
it reaches next character to escape or the end of the input.

This start offset may become greater than input character offset
so copying of preceding data should check this condition.

CL 469555 removed boundary checks for copying data preceding
escaped characters and this change restores them.

Fixes https://github.com/golang/go/issues/63379

Change-Id: I5b7856239f256c67faf58834705675c0aea08cc2
GitHub-Last-Rev: 661576fb54951a05a8399beb3f9ac2a2f9a340b4
GitHub-Pull-Request: golang/go#63400
Reviewed-on: https://go-review.googlesource.com/c/go/+/533275
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agocrypto/x509: avoid Android root store paths on other Linuxes
Filippo Valsorda [Wed, 4 Oct 2023 11:53:31 +0000 (13:53 +0200)]
crypto/x509: avoid Android root store paths on other Linuxes

Updates #58922

Change-Id: I0eb2c97babb05b2d9bc36ed8af03579094bc02ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/531878
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ingo Oeser <nightlyone@googlemail.com>
8 months agocmd/compile: use cache in front of type assert runtime call
Keith Randall [Mon, 18 Sep 2023 20:31:49 +0000 (13:31 -0700)]
cmd/compile: use cache in front of type assert runtime call

That way we don't need to call into the runtime for every
type assertion (to an interface type).

name           old time/op  new time/op  delta
TypeAssert-24  3.78ns ± 3%  1.00ns ± 1%  -73.53%  (p=0.000 n=10+8)

Change-Id: I0ba308aaf0f24a5495b4e13c814d35af0c58bfde
Reviewed-on: https://go-review.googlesource.com/c/go/+/529316
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
8 months agocmd/compile: use descriptors for type assertion runtime calls
Keith Randall [Mon, 18 Sep 2023 17:13:18 +0000 (10:13 -0700)]
cmd/compile: use descriptors for type assertion runtime calls

Mostly a reorganization to make further changes easier.

This reorganization will make it easier to add a cache in front
of the runtime call.

Leave the old code alone for dynamic type assertions (aka generics).

Change-Id: Ia7dcb7aeb1f63baf93584ccd792e8e31510e8aea
Reviewed-on: https://go-review.googlesource.com/c/go/+/529196
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
8 months agocmd/compile: pass only the itab to the assertI2I-style functions
Keith Randall [Mon, 11 Sep 2023 21:39:06 +0000 (14:39 -0700)]
cmd/compile: pass only the itab to the assertI2I-style functions

It is currently slightly better to pass the whole interface to these
functions, so that we don't need to spill/restore the data word across
the function call.

I'm adding a cache in front of these calls, which means we'll no longer
need a spill/restore in the common case, so it is better to just pass
the itab word.

It also makes unifying the logic between I2I and I2I2 versions easier.

Change-Id: I3c3e9fbb1e54890482840d76a1df79f4325bb5bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/528075
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
8 months agocmd/compile: add a cache to interface type switches
Keith Randall [Wed, 6 Sep 2023 20:59:35 +0000 (13:59 -0700)]
cmd/compile: add a cache to interface type switches

That way we don't need to call into the runtime when the type being
switched on has been seen many times before.

The cache is just a hash table of a sample of all the concrete types
that have been switched on at that source location.  We record the
matching case number and the resulting itab for each concrete input
type.

The caches seldom get large. The only two in a run of all.bash that
get more than 100 entries, even with the sampling rate set to 1, are

test/fixedbugs/issue29264.go, with 101
test/fixedbugs/issue29312.go, with 254

Both happen at the type switch in fmt.(*pp).handleMethods, perhaps
unsurprisingly.

name                                 old time/op  new time/op  delta
SwitchInterfaceTypePredictable-24    25.8ns ± 2%   2.5ns ± 3%  -90.43%  (p=0.000 n=10+10)
SwitchInterfaceTypeUnpredictable-24  37.5ns ± 2%  11.2ns ± 1%  -70.02%  (p=0.000 n=10+10)

Change-Id: I4961ac9547b7f15b03be6f55cdcb972d176955eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/526658
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
8 months agocmd/compile: improve interface type switches
Keith Randall [Sat, 2 Sep 2023 03:32:07 +0000 (20:32 -0700)]
cmd/compile: improve interface type switches

For type switches where the targets are interface types,
call into the runtime once instead of doing a sequence
of assert* calls.

name                                 old time/op  new time/op  delta
SwitchInterfaceTypePredictable-24    26.6ns ± 1%  25.8ns ± 2%  -2.86%  (p=0.000 n=10+10)
SwitchInterfaceTypeUnpredictable-24  39.3ns ± 1%  37.5ns ± 2%  -4.57%  (p=0.000 n=10+10)

Not super helpful by itself, but this code organization allows
followon CLs that add caching to the lookups.

Change-Id: I7967f85a99171faa6c2550690e311bea8b54b01c
Reviewed-on: https://go-review.googlesource.com/c/go/+/526657
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
8 months agocmd/compile: some cleanup with old irgen code
Cuong Manh Le [Tue, 3 Oct 2023 15:51:03 +0000 (22:51 +0700)]
cmd/compile: some cleanup with old irgen code

 - Un-export Convertop: it's only used by tcConv.
 - Remove AssignOp1: introduced in CL 349614, only used by irgen.
 - Un-export Assignop: it was exported to be used by irgen only.

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

8 months agocmd/compile: do not fatal when typechecking conversion expression
Cuong Manh Le [Tue, 3 Oct 2023 14:54:48 +0000 (21:54 +0700)]
cmd/compile: do not fatal when typechecking conversion expression

The types2 typechecker already reported all invalid conversions required
by the Go language spec. However, the conversion involves go pragma is
not specified in the spec, so is not checked by types2.

Fixing this by handling the error gracefully during typecheck, just like
how old typechecker did before CL 394575.

Fixes #63333

Change-Id: I04c4121971c62d96f75ded1794ab4bdf3a6cd0ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/532515
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: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

8 months agonet/http: fix ServeMux pattern registration
Jonathan Amsterdam [Thu, 5 Oct 2023 15:27:36 +0000 (11:27 -0400)]
net/http: fix ServeMux pattern registration

When the httpmuxgo121 GODEBUG setting was active, we were registering
patterns in the old and the new way. Fix to register only in the old
way.

Change-Id: Ibc1fd41e7f4d162ee5bc34575df409e1db5657cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/533095
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Olena Synenka <olenasynenka@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
8 months agocmd/compile/internal/ir: tweak a couple names
Matthew Dempsky [Wed, 4 Oct 2023 22:22:49 +0000 (15:22 -0700)]
cmd/compile/internal/ir: tweak a couple names

CallExpr.X -> CallExpr.Fun

This consistent with go/ast and cmd/compile/internal/syntax.

OPRINTN -> OPRINTLN

This op represents the "println" builtin; might as well spell it the
same way.

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

8 months agocmd/internal/obj/ppc64: generate MOVD mask constants in register
Paul E. Murphy [Tue, 19 Sep 2023 22:01:28 +0000 (17:01 -0500)]
cmd/internal/obj/ppc64: generate MOVD mask constants in register

Add a new form of RLDC which maps directly to the ISA definition
of rldc: RLDC Rs, $sh, $mb, Ra. This is used to generate mask
constants described below.

Using MOVD $-1, Rx; RLDC Rx, $sh, $mb, Rx, any mask constant
can be generated. A mask is a contiguous series of 1 bits, which
may wrap.

Change-Id: Ifcaae1114080ad58b5fdaa3e5fc9019e2051f282
Reviewed-on: https://go-review.googlesource.com/c/go/+/531120
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agohtml/template: only track brace depth when we are in a JS tmpl lit
Roland Shoemaker [Wed, 4 Oct 2023 13:18:08 +0000 (06:18 -0700)]
html/template: only track brace depth when we are in a JS tmpl lit

The change that keeps on giving. Only track brace depth in tJS if we are
already inside of a template literal. If we start tracking depth outside
of nested literals it can cause the parser to think we're still in a JS
context when we've actually closed the string interp.

I believe this _mostly_ captures the expected parsing, but since the
JS parser does not implement proper lexical goal symbols, it may not
be entirely accurate. At some point in the future we may be able to
significantly reduce the complexity of this implementation by
implementing a lexical parser that more closely follows the ECMAScript
specification, and structuring escaping rules based on which symbol an
action appears in. This would also allow us to catch errors, which
we currently cannot reasonable do (although perhaps this is beyond the
scope of what html/template _should_ be doing).

Updates #61619

Change-Id: I56e1dbc0d0705ef8fb7a5454ebe2421d4e162ef6
Reviewed-on: https://go-review.googlesource.com/c/go/+/532595
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
8 months agoruntime: support SetUnhandledExceptionFilter on Windows
qmuntal [Mon, 4 Sep 2023 15:30:08 +0000 (17:30 +0200)]
runtime: support SetUnhandledExceptionFilter on Windows

The Windows unhandled exception mechanism fails to call the callback
set in SetUnhandledExceptionFilter if the stack can't be correctly
unwound.

Some cgo glue code was not properly chaining the frame pointer, making
the stack unwind to fail in case of an exception inside a cgo call.
This CL fix that and adds a test case to avoid regressions.

Fixes #50951

Change-Id: Ic782b5257fe90b05e3def8dbf0bb8d4ed37a190b
Reviewed-on: https://go-review.googlesource.com/c/go/+/525475
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agocmd/internal/obj/ppc64: generate small, shifted constants in register
Paul E. Murphy [Mon, 18 Sep 2023 22:14:03 +0000 (17:14 -0500)]
cmd/internal/obj/ppc64: generate small, shifted constants in register

Check for shifted 16b constants, and transform them to avoid the load
penalty. This should be much faster than loading, and reduce binary
size by reducing the constant pool size.

Change-Id: I6834e08be7ca88e3b77449d226d08d199db84299
Reviewed-on: https://go-review.googlesource.com/c/go/+/531119
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/go: fix objdir for run actions for -cover no-test packages
Than McIntosh [Wed, 4 Oct 2023 13:29:48 +0000 (09:29 -0400)]
cmd/go: fix objdir for run actions for -cover no-test packages

As of CL 495447 we now synthesize coverage data (including coverage
profiles) for packages that have no tests, if they are included in a
"go test -cover" run. The code that set up the "run" actions for such
tests wasn't setting the objdir for the action, which meant that the
coverage profile temp file fragment ("_cover_.out") was being created
in the dir where the test was run, and in addition the same fragment
could be written to by more than one package (which could lead to a
corrupted file). This CL updates the code to properly set the objdir,
and to create the dir when needed.

Updates #24570.
Fixes #63356.

Change-Id: Iffe131cf50f07ce91085b816a039308e0ca84776
Reviewed-on: https://go-review.googlesource.com/c/go/+/532555
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agonet/http/cgi: set SERVER_PORT to 443 when req.TLS != nil
edef [Sat, 3 Dec 2022 00:09:22 +0000 (00:09 +0000)]
net/http/cgi: set SERVER_PORT to 443 when req.TLS != nil

A hostname without a port leaves the port implied by the protocol.
For HTTPS, the implied port is 443, not 80.

Change-Id: I873a076068f84c8041abf10a435d9499635730a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/454975
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agoruntime: unlock OS thread after cgocallbackg1
Cherry Mui [Wed, 4 Oct 2023 14:21:39 +0000 (10:21 -0400)]
runtime: unlock OS thread after cgocallbackg1

For cgo callbacks, currently cgocallbackg locks the OS thread and
then call cgocallbackg1, which invokes the actual callback, and
then unlocks the OS thread in a deferred call. cgocallback then
continues assuming we are on the same M. This assumes there is no
preemption point between the deferred unlockOSThread and returning
to the caller (cgocallbackg). But this is not always true. E.g.
when open defer is not used (e.g. PIE or shared build mode on 386),
there is a preemption point in deferreturn after invoking the
deferred function (when it checks whether there are still defers
to run).

Instead of relying on and requiring the defer implementation has
no preemption point, we move the unlockOSThread to the caller, and
ensuring no preemption by setting incgo to true before unlocking.
This doesn't cover the panicking path, so we also adds an
unlockOSThread there. There we don't need to worry about preemption,
because we're panicking out of the callback and we have unwound the
g0 stack, instead of reentering cgo.

Fixes #62102.

Change-Id: I0e0b9f9091be88d01675c0acb7339b81402545be
Reviewed-on: https://go-review.googlesource.com/c/go/+/532615
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agogo/printer: parenthesize type in <-((<-chan int)(nil))
Alan Donovan [Wed, 4 Oct 2023 14:26:17 +0000 (10:26 -0400)]
go/printer: parenthesize type in <-((<-chan int)(nil))

When printing synthetic syntax (not created by the parser),
the tree for <-((<-chan int)(nil)) without any ParenExpr nodes
was misprinted so that it was parsed back as a receive of
a receive. This changes emits parens around the channel type.

Fixes #63362

Change-Id: I2041ced224f0bca001cee5d37f7a127265d21020
Reviewed-on: https://go-review.googlesource.com/c/go/+/532556
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
8 months agocmd/compile: adjust GOSSAFUNC html dumping to be more ABI-aware
David Chase [Tue, 3 Oct 2023 16:14:53 +0000 (12:14 -0400)]
cmd/compile: adjust GOSSAFUNC html dumping to be more ABI-aware

Uses ,ABI instead of <ABI> because of problems with shell escaping
and windows file names, however if someone goes to all the trouble
of escaping the linker syntax and uses that instead, that works too.

Examples:
```
GOSSAFUNC=runtime.exitsyscall go build main.go
\# runtime
dumped SSA for exitsyscall,0 to ../../src/loopvar/ssa.html
dumped SSA for exitsyscall,1 to ../../src/loopvar/ssa.html

GOSSADIR=`pwd` GOSSAFUNC=runtime.exitsyscall go build main.go
\# runtime
dumped SSA for exitsyscall,0 to ../../src/loopvar/runtime.exitsyscall,0.html
dumped SSA for exitsyscall,1 to ../../src/loopvar/runtime.exitsyscall,1.html

GOSSAFUNC=runtime.exitsyscall,0 go build main.go
\# runtime
dumped SSA for exitsyscall,0 to ../../src/loopvar/ssa.html

GOSSAFUNC=runtime.exitsyscall\<1\> go build main.go
\# runtime
dumped SSA for exitsyscall,1 to ../../src/loopvar/ssa.html
```

Change-Id: Ia1138b61c797d0de49dbfae702dc306b9650a7f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/532475
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: David Chase <drchase@google.com>

8 months agocrypto/x509: Add android user trusted CA folder
Jean-Baptiste PIN [Wed, 27 Sep 2023 07:11:05 +0000 (07:11 +0000)]
crypto/x509: Add android user trusted CA folder

User can trust new CA on android but it seems that go build package are not able to use it.

This PR will add the folder where user CA trusted certificate is added to.

Change-Id: I9ea7801b35847ea3eb4eedd875227743ba99af00
GitHub-Last-Rev: c49ffd270b6483b750d97e422b76237b112e508c
GitHub-Pull-Request: golang/go#50240
Reviewed-on: https://go-review.googlesource.com/c/go/+/473035
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agobufio: use max/min func
qiulaidongfeng [Wed, 4 Oct 2023 03:23:54 +0000 (03:23 +0000)]
bufio: use max/min func

Change-Id: I52875f8dd4bbdc9296ba8e4f801356047ee14e62
GitHub-Last-Rev: dfb2a343e60f0994a5741e1b4534e464a80ba2ef
GitHub-Pull-Request: golang/go#63344
Reviewed-on: https://go-review.googlesource.com/c/go/+/532216
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

8 months agocmd/go/testdata/mod: add golang toolchain test data for openbsd/riscv64
Joel Sing [Thu, 10 Aug 2023 15:51:53 +0000 (01:51 +1000)]
cmd/go/testdata/mod: add golang toolchain test data for openbsd/riscv64

Updates #55999

Change-Id: I65e3bfb08ed2dd1602531902c7df8232e5151aa8
Reviewed-on: https://go-review.googlesource.com/c/go/+/518628
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Aaron Bieber <deftly@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agosyscall: add syscall support for openbsd/riscv64 port
Joel Sing [Sat, 17 Sep 2022 16:35:40 +0000 (02:35 +1000)]
syscall: add syscall support for openbsd/riscv64 port

Updates #55999

Change-Id: I5b8452207e951e543b9be42ebcb7d62c0c023f08
Reviewed-on: https://go-review.googlesource.com/c/go/+/518627
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Aaron Bieber <deftly@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agoruntime: add runtime support for openbsd/riscv64 port
Joel Sing [Sat, 17 Sep 2022 16:35:00 +0000 (02:35 +1000)]
runtime: add runtime support for openbsd/riscv64 port

Updates #55999

Change-Id: I0e80f80d49696a00d979f85230d482e24d4c2d7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/518626
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Aaron Bieber <deftly@gmail.com>
8 months agotime: fix Time godoc
Tobias Klauser [Tue, 3 Oct 2023 20:19:42 +0000 (22:19 +0200)]
time: fix Time godoc

The additional empty line was inadvertently introduced by CL 526676,
causing only part of the Time godoc to be rendered on pkg.go.dev.

Change-Id: I868315752eb160ebaab227c8b5369054c557cb7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/531877
Reviewed-by: 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>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>

8 months agogo/types, types2: don't implicitly modify an argument function's type
Robert Griesemer [Mon, 2 Oct 2023 22:47:08 +0000 (15:47 -0700)]
go/types, types2: don't implicitly modify an argument function's type

See the comment in the (very small) fix for a detailed description.
Use the opportunity to introduce a generic clone function which may
be useful elsewhere.

Fixes #63260.

Change-Id: Ic63c6b8bc443011b1a201908254f7d062e1aec71
Reviewed-on: https://go-review.googlesource.com/c/go/+/532157
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>
TryBot-Result: Gopher Robot <gobot@golang.org>

8 months agocmd: add a new analyzer for check missing values after append
cui fliter [Fri, 26 May 2023 04:02:54 +0000 (12:02 +0800)]
cmd: add a new analyzer for check missing values after append

If there is no second parameter added during append, there will be no prompt when executing go vet. Add an analyzer to detect this situation

Update #60448

Change-Id: If9848835424f310c54e3e9377aaaad4a1516871a
Reviewed-on: https://go-review.googlesource.com/c/go/+/498416
Run-TryBot: shuang cui <imcusg@gmail.com>
Run-TryBot: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
8 months agocmd/internal/asm/ppc64: support 34b ADD/MOVD $const, Rx
Paul E. Murphy [Tue, 12 Sep 2023 21:06:45 +0000 (16:06 -0500)]
cmd/internal/asm/ppc64: support 34b ADD/MOVD $const, Rx

For constant signed values which require 34b to represent,
the assembler will generate a pli instruction on
linux/power10/PPC64 instead of loading a constant.

Similarly, ADD is extended to support 34b signed constants.
On linux/power10/PPC64, this generates a paddi instruction.
For assembler consistency, a second form is added if paddi
cannot be used. The second form is provided for assembly
writers.

Change-Id: I98144306af766b02fbbe36b72856a23cdf51d247
Reviewed-on: https://go-review.googlesource.com/c/go/+/528317
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
8 months agoruntime/internal/atomic: add ppc64x operators for And/Or
Mauri de Souza Meneguzzo [Sat, 30 Sep 2023 00:53:11 +0000 (00:53 +0000)]
runtime/internal/atomic: add ppc64x operators for And/Or

These primitives will be used by the new And/Or sync/atomic apis.

For #61395

Change-Id: I9ad92634add0357092e49b5a4a40c177e242a0b6
GitHub-Last-Rev: cf3fb0dce6a462b5d63fe8fe974573ab86df0b66
GitHub-Pull-Request: golang/go#63294
Reviewed-on: https://go-review.googlesource.com/c/go/+/531716
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Paul Murphy <murp@ibm.com>
8 months agoregexp/syntax: use min func
qiulaidongfeng [Tue, 3 Oct 2023 14:22:16 +0000 (14:22 +0000)]
regexp/syntax: use min func

Change-Id: I679c906057577d4a795c07a2f572b969c3ee14d5
GitHub-Last-Rev: fba371d2d6bfc7fbf3a93a53bb22039acf65d7cf
GitHub-Pull-Request: golang/go#63350
Reviewed-on: https://go-review.googlesource.com/c/go/+/532218
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agocmd/compile/internal: intrinsify publicationBarrier on riscv64
Xianmiao Qu [Sat, 30 Sep 2023 08:12:34 +0000 (16:12 +0800)]
cmd/compile/internal: intrinsify publicationBarrier on riscv64

This enables publicationBarrier to be used as an intrinsic
on riscv64, optimizing the required function call and return
instructions for invoking the "runtime.publicationBarrier"
function.

This function is called by mallocgc. The benchmark results for malloc tested on Lichee-Pi-4A(TH1520, RISC-V 2.0G C910 x4) are as follows.

goos: linux
goarch: riscv64
pkg: runtime
                    │   old.txt   │              new.txt               │
                    │   sec/op    │   sec/op     vs base               │
Malloc8-4             92.78n ± 1%   90.77n ± 1%  -2.17% (p=0.001 n=10)
Malloc16-4            156.5n ± 1%   151.7n ± 2%  -3.10% (p=0.000 n=10)
MallocTypeInfo8-4     131.7n ± 1%   130.6n ± 2%       ~ (p=0.165 n=10)
MallocTypeInfo16-4    186.5n ± 2%   186.2n ± 1%       ~ (p=0.956 n=10)
MallocLargeStruct-4   1.345µ ± 1%   1.355µ ± 1%       ~ (p=0.093 n=10)
geomean               216.9n        214.5n       -1.10%

Change-Id: Ieab6c02309614bac5c1b12b5ee3311f988ff644d
Reviewed-on: https://go-review.googlesource.com/c/go/+/531719
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: M Zhuo <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
8 months agodatabase/sql: use the built-in min function
mstmdev [Mon, 25 Sep 2023 08:43:18 +0000 (08:43 +0000)]
database/sql: use the built-in min function

Change-Id: Ib6a0e1e1583e45e3d239455e8b131c81602b2d5d
GitHub-Last-Rev: dc82635562a7fb4488f374d7a9ed26b29310e918
GitHub-Pull-Request: golang/go#63200
Reviewed-on: https://go-review.googlesource.com/c/go/+/530875
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agonet/http: document new ServeMux patterns
Jonathan Amsterdam [Mon, 25 Sep 2023 16:39:43 +0000 (12:39 -0400)]
net/http: document new ServeMux patterns

Updates #61410.

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

8 months agocmd/link: enable linking on openbsd/riscv64
Joel Sing [Sat, 17 Sep 2022 16:36:20 +0000 (02:36 +1000)]
cmd/link: enable linking on openbsd/riscv64

Updates #55999

Change-Id: I6e48e6649e19a9b2d776745c05eefb3995b6dd00
Reviewed-on: https://go-review.googlesource.com/c/go/+/518625
Reviewed-by: Aaron Bieber <deftly@gmail.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>

8 months agocmd/compile,runtime: remove runtime.mulUintptr
qiulaidongfeng [Tue, 3 Oct 2023 10:33:48 +0000 (10:33 +0000)]
cmd/compile,runtime: remove runtime.mulUintptr

For #48798

Change-Id: I3e928d3921cfd5a7bf35b23d0ae6442aa6d2d482
GitHub-Last-Rev: b101a8a54f2cc9ea917f879a545f30c702508743
GitHub-Pull-Request: golang/go#63349
Reviewed-on: https://go-review.googlesource.com/c/go/+/532355
TryBot-Result: Gopher Robot <gobot@golang.org>
Commit-Queue: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Martin Möhrmann <moehrmann@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Martin Möhrmann <moehrmann@google.com>
8 months agosyscall: return pointer from test function OrigRlimitNofile
Ian Lance Taylor [Mon, 2 Oct 2023 23:26:27 +0000 (16:26 -0700)]
syscall: return pointer from test function OrigRlimitNofile

Change-Id: I8740a2a7ebb3045d8daa97bcb0da7f31f6f7b881
Reviewed-on: https://go-review.googlesource.com/c/go/+/531996
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agointernal/syscall/unix: implement Eaccess on netbsd
Tobias Klauser [Tue, 3 Oct 2023 09:20:29 +0000 (11:20 +0200)]
internal/syscall/unix: implement Eaccess on netbsd

Like on linux and freebsd, use faccessat(AT_FDCWD, path, mode, AT_EACCESS)

Change-Id: Ia76ba67023b6deba6f0cdaf30a0b9cee0c140bb8
Reviewed-on: https://go-review.googlesource.com/c/go/+/531876
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@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>

8 months agotime: clarify docs to avoid date calculation pitfalls
Brendan Jackman [Fri, 8 Sep 2023 07:46:19 +0000 (07:46 +0000)]
time: clarify docs to avoid date calculation pitfalls

I recently reviewed some code that did time calculations using
`time.UnixMicro(0).UTC()`. I commented that because time calculations
are independent of the location, they should drop the `.UTC()`, and they
replied that it made their tests fail.

I looked into it and eventually discovered it was because they were
using AddDate. Dramatically simplified, their code did something like:

    orig := time.Date(2013, time.March, 23, 12, 00, 0, 0, time.UTC)
    want := time.Date(2013, time.March, 23, 0, 0, 0, 0, time.UTC)

    epoch := time.UnixMicro(0)

    days := int(orig.Sub(epoch).Hours() / 24)

    got := epoch.AddDate(0, 0, days)
    if !got.Equal(want) {
        t.Errorf("ay caramba: %v vs %v", got.UTC(), want.UTC())
    }

The issue is that their tests run in Pacific time, which is currently
PST (UTC-8) but was PDT (UTC-7) in January 1970.

It turns out they were implementing some business policy that really
cares abut calendar days so AddDate is correct, but it's certainly a bit
confusing!

The idea with this change is to remove the risk that readers make a
false shortcut in their mind: "Locations do not affect time
calculations". To do this we remove some text from the core time.Time
doc and shift it to the areas of the library that deal with these
intrinsically confusing operations.

Change-Id: I8200e9edef7d1cdd8516719e34814eb4b78d30a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/526676
Reviewed-by: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agocmd: fix mismatched symbols
cui fliter [Mon, 2 Oct 2023 07:09:26 +0000 (15:09 +0800)]
cmd: fix mismatched symbols

Change-Id: I6365cdf22ad5e669908519d0ee8b78d76ae8f1b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/532075
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agomake.bash: use [[ rather than [
Daniel Martí [Sat, 30 Sep 2023 08:57:36 +0000 (09:57 +0100)]
make.bash: use [[ rather than [

[[ is a compound command part of the language with structure,
whereas [ is simply a standard program with string arguments.
The former has a few significant advantages over the latter:

* Better syntax, e.g. && and || rather than -a and -o,
  as well as == rather than = for comparisons
* No need for fork+exec to evaluate each conditional
* Forgetting the closing token is an early parse error

The only advantage of [ over [[ is that [[ is Bash syntax,
whereas [ and "test" are portable POSIX Shell utilities.
However, this is a Bash script, so that is not a concern.

Change-Id: I8a4bdd16845bd67bf67a348d7d96d45d5b131d85
Reviewed-on: https://go-review.googlesource.com/c/go/+/531875
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agosyscall: copy original rlimit before modifying
Michael Pratt [Mon, 2 Oct 2023 19:55:29 +0000 (15:55 -0400)]
syscall: copy original rlimit before modifying

CL 531516 converted origRlimitNofile from an atomic.Value to
atomic.Pointer[Rlimit]. i.e., it changed from storing a value to storing
a pointer.

After storing a pointer to lim, the remainder of this function
immediately modifies it, thus mutating the value pointer to by
origRlimitNofile (and thus defeating the point of origRlimitNofile).

This broke the android-amd64-emu builder because it is (apparently) the
only builder where the original RLIMIT_NOFILE Cur != Max.
TestRlimitRestored is skipped on every other builder.

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

8 months agonet: handle the network parameter properly in LookupPort
Mateusz Poliwczak [Mon, 2 Oct 2023 16:24:26 +0000 (16:24 +0000)]
net: handle the network parameter properly in LookupPort

The cgo version (unix) is populating the GetAddrInfo hints
based on the network parameter, but windows not quite.

This change populates the hints the same way as the
cgo unix version does now.

This bug was spotted by Bryan in CL 530415.
https://go-review.googlesource.com/c/go/+/530415/comment/76640dc7_ed0409ca/

Change-Id: I6fc29b1e4cdc879123ab0f5a624b6f37c68c00ba
GitHub-Last-Rev: eaa616378b3fa9a5a72192f3d501c591804f45d8
GitHub-Pull-Request: golang/go#63284
Reviewed-on: https://go-review.googlesource.com/c/go/+/531635
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David du Colombier <0intro@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
8 months agoruntime: use smaller fields for mspan.freeindex and nelems
Cherry Mui [Wed, 16 Nov 2022 22:32:08 +0000 (17:32 -0500)]
runtime: use smaller fields for mspan.freeindex and nelems

mspan.freeindex and nelems can fit into uint16 for all possible
values. Use uint16 instead of uintptr.

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

8 months agonet/http: add a test for an empty ServeMux
Jonathan Amsterdam [Mon, 25 Sep 2023 13:46:32 +0000 (09:46 -0400)]
net/http: add a test for an empty ServeMux

Make sure a ServeMux with no patterns is well-behaved.

Updates #61410.

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