]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
8 months agocmd/compile: implement range over func
Russ Cox [Wed, 14 Jun 2023 14:56:49 +0000 (10:56 -0400)]
cmd/compile: implement range over func

Add compiler support for range over functions.
See the large comment at the top of
cmd/compile/internal/rangefunc/rewrite.go for details.

This is only reachable if GOEXPERIMENT=range is set,
because otherwise type checking will fail.

For proposal #61405 (but behind a GOEXPERIMENT).
For #61717.

Change-Id: I05717f94e63089c503acc49b28b47edeb4e011b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/510541
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

8 months agocmd/compile: implement range over integer
Russ Cox [Wed, 14 Jun 2023 14:55:06 +0000 (10:55 -0400)]
cmd/compile: implement range over integer

Add compiler implementation of range over integers.
This is only reachable if GOEXPERIMENT=range is set,
because otherwise type checking will fail.

For proposal #61405 (but behind a GOEXPERIMENT).
For #61717.

Change-Id: I4e35a73c5df1ac57f61ffb54033a433967e5be51
Reviewed-on: https://go-review.googlesource.com/c/go/+/510538
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

8 months agocmd/compile, go/types: typechecking of range over int, func
Russ Cox [Wed, 14 Jun 2023 13:52:44 +0000 (09:52 -0400)]
cmd/compile, go/types: typechecking of range over int, func

Add type-checking logic for range over integers and functions,
behind GOEXPERIMENT=range.

For proposal #61405 (but behind a GOEXPERIMENT).
For #61717.

Change-Id: Ibf78cf381798b450dbe05eb922df82af2b009403
Reviewed-on: https://go-review.googlesource.com/c/go/+/510537
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
8 months agocmd/link, runtime: initialize packages in shared build mode
Cherry Mui [Wed, 16 Aug 2023 23:49:04 +0000 (19:49 -0400)]
cmd/link, runtime: initialize packages in shared build mode

Currently, for the shared build mode, we don't generate the module
inittasks. Instead, we rely on the main executable to do the
initialization, for both the executable and the shared library.
But, with the model as of CL 478916, the main executable only
has relocations to packages that are directly imported. It won't
see the dependency edges between packages within a shared library.
Therefore indirect dependencies are not included, and thus not
initialized. E.g. main imports a, which imports b, but main
doesn't directly import b. a and b are in a shared object. When
linking main, it sees main depends on a, so it generates main's
inittasks to run a's init before main's, but it doesn't know b,
so b's init doesn't run.

This CL makes it initialize all packages in a shared library when
the library is loaded, as any of them could potentially be
imported, directly or indirectly.

Also, in the runtime, when running the init functions, make sure
to go through the DSOs in dependency order. Otherwise packages
can be initialized in the wrong order.

Fixes #61973.

Change-Id: I2a090336fe9fa0d6c7e43912f3ab233c9c47e247
Reviewed-on: https://go-review.googlesource.com/c/go/+/520375
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agonet/http: add a benchmark for multi indexing
Jonathan Amsterdam [Tue, 19 Sep 2023 21:23:58 +0000 (17:23 -0400)]
net/http: add a benchmark for multi indexing

We don't index multis, so a corpus full of them will take quadratic
time to check for conflicts. How slow is that going to be in practice?

This benchmark indexes and checks a thousand multi patterns, all disjoint.
It runs in about 35ms.

Change-Id: Id27940ab19ad003627bd5c43c53466e01456b796
Reviewed-on: https://go-review.googlesource.com/c/go/+/529477
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
8 months agonet/http: test index exhaustively
Jonathan Amsterdam [Tue, 19 Sep 2023 21:03:45 +0000 (17:03 -0400)]
net/http: test index exhaustively

Replace the fuzz test with one that enumerates all relevant patterns
up to a certain length.

For conflict detection, we don't need to check every possible method,
host and segment, only a few that cover all the possibilities. There
are only 2400 distinct patterns in the corpus we generate, and the
test generates, indexes and compares them all in about a quarter of a
second.

Change-Id: I9fde88e87cec07b1b244306119e4e71f7205bb77
Reviewed-on: https://go-review.googlesource.com/c/go/+/529556
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
8 months agoruntime: set stackguard1 on extra M g0
Michael Pratt [Fri, 8 Sep 2023 18:54:29 +0000 (14:54 -0400)]
runtime: set stackguard1 on extra M g0

[This is an unmodified redo of CL 527056.]

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

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

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

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

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

8 months agonet/http: show offset in pattern parsing error
Jonathan Amsterdam [Tue, 19 Sep 2023 13:17:42 +0000 (09:17 -0400)]
net/http: show offset in pattern parsing error

Track the offset in the pattern string being parsed so we can show it
in the error message.

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

8 months agonet/http: explain why two patterns conflict
Jonathan Amsterdam [Tue, 19 Sep 2023 11:54:09 +0000 (07:54 -0400)]
net/http: explain why two patterns conflict

It can be difficult to tell at a glance why two patterns conflict, so
explain it with example paths.

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

8 months agonet/http: index patterns for faster conflict detection
Jonathan Amsterdam [Mon, 18 Sep 2023 19:51:04 +0000 (15:51 -0400)]
net/http: index patterns for faster conflict detection

Add an index so that pattern registration isn't always quadratic.

If there were no index, then every pattern that was registered would
have to be compared to every existing pattern for conflicts. This
would make registration quadratic in the number of patterns, in every
case.

The index in this CL should help most of the time. If a pattern has a
literal segment, it will weed out all other patterns that have a
different literal in that position.

The worst case will still be quadratic, but it is unlikely that a set
of such patterns would arise naturally.

One novel (to me) aspect of the CL is the use of fuzz testing on data
that is neither a string nor a byte slice. The test uses fuzzing to
generate a byte slice, then decodes the byte slice into a valid
pattern (most of the time). This test actually caught a bug: see
https://go.dev/cl/529119.

Change-Id: Ice0be6547decb5ce75a8062e4e17227815d5d0b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/529121
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
8 months agocmd/internal/obj/riscv,cmd/link: rework riscv64 call relocations
Joel Sing [Wed, 16 Aug 2023 15:13:32 +0000 (01:13 +1000)]
cmd/internal/obj/riscv,cmd/link: rework riscv64 call relocations

The riscv64 assembler and linker generate three types of calls.
Most calls are made via a single JAL instruction, however this is
limited to +/-1MB of text. In the case where a call target is
unreachable (or unknown), the JAL targets an AUIPC+JALR trampoline.
All other cases use AUIPC+JALR pairs, including the case where a
single function exceeds 1MB in text size, potentially making it
impossible to reach trampolines.

Currently, the single instruction JAL call is marked with R_RISCV_CALL
and the two instruction AUIPC+JALR call is marked with
R_RISCV_PCREL_ITYPE, which is also used for memory load instructions.
This means that we have no way to identify that the latter is a call.

Switch to using R_RISCV_CALL to mark the AUIPC+JALR pair (aligning
somewhat with the elf.R_RISCV_CALL, which is deprecated in favour of
elf.R_RISCV_CALL_PLT). Add R_RISCV_JAL and use this to mark the single
instruction JAL direct calls. This is clearer and allows us to map
elf.R_RISCV_CALL_PLT to Go's R_RISCV_CALL.

Add all three types to IsDirectCall, so that direct calls are correctly
identified when a function exceeds 1MB of text.

Fixes #62465

Change-Id: Id3eea09688a2b7d6e481eae9ed0aa0d1f9a3a48f
Reviewed-on: https://go-review.googlesource.com/c/go/+/520095
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Than McIntosh <thanm@google.com>
8 months agonet/http: buffer the testConn close channel in TestHandlerFinishSkipBigContentLengthRead
Bryan C. Mills [Tue, 19 Sep 2023 14:37:28 +0000 (10:37 -0400)]
net/http: buffer the testConn close channel in TestHandlerFinishSkipBigContentLengthRead

Previously the test used an unbuffered channel, but testConn.Close
sends to it with a select-with-default, so the send would be dropped
if the test goroutine happened not to have parked on the receive yet.

To make this kind of bug less likely in future tests, use a
newTestConn helper function instead of constructing testConn channel
literals in each test individually.

Fixes #62622.

Change-Id: I016cd0a89cf8a2a748ed57a4cdbd01a178f04dab
Reviewed-on: https://go-review.googlesource.com/c/go/+/529475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
8 months agocmd/go: in TestGoBuildUmask, create a file using os.WriteFile as a control
Bryan C. Mills [Tue, 19 Sep 2023 15:37:25 +0000 (11:37 -0400)]
cmd/go: in TestGoBuildUmask, create a file using os.WriteFile as a control

Fixes #62724.
Updates #17909.

Change-Id: Ib2e9abec4fb88f418c4251ece7fcdef315190835
Reviewed-on: https://go-review.googlesource.com/c/go/+/529495
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agocmd/compile: add pgohash for debugging/bisecting PGO optimizations
Cherry Mui [Fri, 15 Sep 2023 16:13:09 +0000 (12:13 -0400)]
cmd/compile: add pgohash for debugging/bisecting PGO optimizations

When a PGO build fails or produces incorrect program, it is often
unclear what the problem is. Add pgo hash so we can bisect to
individual optimization decisions, which often helps debugging.

Related to #58153.

Change-Id: I651ffd9c53bad60f2f28c8ec2a90a3f532982712
Reviewed-on: https://go-review.googlesource.com/c/go/+/528400
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
8 months agosyscall: correctly generate accept on linux/arm
Tobias Klauser [Mon, 18 Sep 2023 13:36:38 +0000 (15:36 +0200)]
syscall: correctly generate accept on linux/arm

CL 457995 introduced syscall_linux_accept.go which is used on linux/arm
to generate accept and use it in Accept. However, that CL forgot to
include the file in the list of files used with mksyscall.pl to generate
the syscall wrappers. This lead to accept no longer being generated when
re-running mkall.sh on linux/arm.

Change-Id: I7747399afae47a883a7fb079c82e835b90f366cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/529055
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Commit-Queue: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

8 months agoruntime: skip TestStackSwitchCallback on ios
Michael Pratt [Mon, 18 Sep 2023 20:12:36 +0000 (16:12 -0400)]
runtime: skip TestStackSwitchCallback on ios

getcontext is unsupported on ios, returning ENOTSUP.

Fixes #62700.

Change-Id: Icc6c45fbd574886766d5289e2fbdbd62981d77eb
Reviewed-on: https://go-review.googlesource.com/c/go/+/529216
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

8 months agocmd/go: in TestScript/gotoolchain_path, remove the user's PATH
Bryan C. Mills [Mon, 18 Sep 2023 20:49:41 +0000 (16:49 -0400)]
cmd/go: in TestScript/gotoolchain_path, remove the user's PATH

This test checks a behavior of GOTOOLCHAIN when an appropriate
toolchain is found in PATH. That requires it to exclude any suitable
toolchain binaries from the user's $PATH, which may otherwise
interfere.

Fixes #62709.

Change-Id: Ie9161e52d33a65be0b5265cb49e9f2bc8473e057
Reviewed-on: https://go-review.googlesource.com/c/go/+/529217
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: 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 agonet/http: fix bugs in comparePaths and combineRelationships
Jonathan Amsterdam [Mon, 18 Sep 2023 17:55:42 +0000 (13:55 -0400)]
net/http: fix bugs in comparePaths and combineRelationships

combineRelationships was wrong on one case: if one part of a pattern
overlaps and the other is disjoint, the result is disjoint, not overlaps.
For example:

    /a/{x}/c
    /{x}/b/d

Here the prefix consisting of the first two segments overlaps, but the
third segments are disjoint. The patterns as a whole are disjoint.

comparePaths was wrong in a couple of ways:

First, the loop shouldn't exit early when it sees an overlap,
for the reason above: later information may change that.

Once the loop was allowed to continue, we had to handle the "overlaps"
case at the end. The insight there, which generalized the existing
code, is that if the shorter path ends in a multi, that multi matches
the remainder of the longer path and more. (It must be "and more": the
longer path has at least two segments, so it couldn't match one
segment while the shorter path's multi can.) That means we can treat
the result as the combination moreGeneral and the relationship of the
common prefix.

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

8 months agocmd/go: avoid writing non-JSON "build failed" errors from 'go test -json'
Bryan C. Mills [Mon, 18 Sep 2023 19:50:27 +0000 (15:50 -0400)]
cmd/go: avoid writing non-JSON "build failed" errors from 'go test -json'

In 'go test -json' we expect stdout to contain only JSON events,
not unstructured text. Unstructured text should either go to stderr
or be wrapped in a JSON event.

(If we add structured build output in #62067, we can emit this output
as a build event instead of a test event.)

Fixes #35169.
For #54378.

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

8 months agoall: clean unnecessary casts
Jes Cok [Fri, 15 Sep 2023 21:15:56 +0000 (21:15 +0000)]
all: clean unnecessary casts

Run 'unconvert -safe -apply' (https://github.com/mdempsky/unconvert)

Change-Id: I24b7cd7d286cddce86431d8470d15c5f3f0d1106
GitHub-Last-Rev: 022e75384c08bb899a8951ba0daffa0f2e14d5a7
GitHub-Pull-Request: golang/go#62662
Reviewed-on: https://go-review.googlesource.com/c/go/+/528696
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: Michael Pratt <mpratt@google.com>
8 months agogo/types: use InvalidSyntaxTree in a couple of places (cleanup)
Robert Griesemer [Mon, 18 Sep 2023 17:57:28 +0000 (10:57 -0700)]
go/types: use InvalidSyntaxTree in a couple of places (cleanup)

Change-Id: I3dcff95b49a72edc30035f50b1ac1d3f9cdec91b
Reviewed-on: https://go-review.googlesource.com/c/go/+/529235
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 agodoc/go1.22: correct tipo languague => language
Ian Lance Taylor [Sun, 17 Sep 2023 00:15:09 +0000 (17:15 -0700)]
doc/go1.22: correct tipo languague => language

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

8 months agoos: in TestMkdirStickyUmask, create a non-sticky directory as a control
Bryan C. Mills [Mon, 18 Sep 2023 15:48:15 +0000 (11:48 -0400)]
os: in TestMkdirStickyUmask, create a non-sticky directory as a control

Fixes #62684.

Change-Id: If7afa811526973671d83e21440cbbc1a7b2120d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/529115
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agonet: enable most tests on wasip1 and js
Bryan C. Mills [Wed, 30 Aug 2023 14:06:18 +0000 (10:06 -0400)]
net: enable most tests on wasip1 and js

To get them to pass, implement more fake syscalls.
To make those syscalls easier to reason about, replace
the use of sync.Cond with selectable channels.

Fixes #59718.
Fixes #50216.

Change-Id: I135a6656f5c48f0e5c43dc4d4bcbdb48ee5535d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/526117
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Achille Roussel <achille.roussel@gmail.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agoos/exec: adjust function name in fatal message
Tobias Klauser [Mon, 18 Sep 2023 15:41:55 +0000 (17:41 +0200)]
os/exec: adjust function name in fatal message

CL 481620 changed the test to use LookPath.

Change-Id: Ie7b3110775b586701b6df6aeee38f26402227eb4
Reviewed-on: https://go-review.googlesource.com/c/go/+/529095
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Bypass: Bryan Mills <bcmills@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agocontext: avoid key collisions in test afterfunc map
Damien Neil [Thu, 7 Sep 2023 16:27:50 +0000 (09:27 -0700)]
context: avoid key collisions in test afterfunc map

The afterFuncContext type, used only in tests, contains a
set of registered afterfuncs indexed by an arbitrary unique key.

That key is currently a *struct{}. Unfortunately, all
*struct{} pointers are equal to each other, so all registered
funcs share the same key. Fortunately, the tests using this
type never register more than one afterfunc.

Change the key to a *byte.

Change-Id: Icadf7d6f258e328f6e3375846d29ce0f98b60924
Reviewed-on: https://go-review.googlesource.com/c/go/+/526655
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
8 months agocmd/link: allow deriving GNU build ID from Go build ID ID
Patrick Steinhardt [Sat, 16 Sep 2023 11:12:12 +0000 (11:12 +0000)]
cmd/link: allow deriving GNU build ID from Go build ID ID

While it is possible to embed a GNU build ID into the linked
executable by passing `-B 0xBUILDID` to the linker, the build ID will
need to be precomputed by the build system somehow. This makes it
unnecessarily complex to generate a deterministic build ID as it
either requires the build system to hash all inputs manually or to
build the binary twice, once to compute its hash and once with the GNU
build ID derived from that hash. Despite being complex, it is also
inefficient as it requires the build system to duplicate some of the
work that the Go linker already performs anyway.

Introduce a new argument "gobuildid" that can be passed to `-B` that
causes the linker to automatically derive the GNU build ID from the Go
build ID. Given that the Go build ID is deterministically computed
from all of its inputs, the resulting GNU build ID should be
deterministic in the same way, which is the desired behaviour.

Furthermore, given that the `-B` flag currently requires a "0x" prefix
for all values passed to it, using "gobuildid" as value is a backwards
compatible change.

An alternative would be to unconditionally calculate the GNU build ID
unless otherwise specified. This would require some larger rework
though because building the Go toolchain would not converge anymore
due the GNU build ID changing on every stage, which in turn would
cause the Go build ID to change as well.

Fixes #41004

Change-Id: I707c5fc321749c00761643d6cc79d44bf2cd744d
GitHub-Last-Rev: 5483305a8566937836e5f39149a3df805d94580b
GitHub-Pull-Request: golang/go#61469
Reviewed-on: https://go-review.googlesource.com/c/go/+/511475
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agoruntime: skip TestG0StackOverflow on iOS
Cherry Mui [Fri, 15 Sep 2023 23:57:36 +0000 (19:57 -0400)]
runtime: skip TestG0StackOverflow on iOS

Apparently it falls into infinite printing loop. Skipping for now.
Will investigate.

For #62671.

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

8 months agocmd/cgo: silence unaligned-access
Egon Elbre [Sun, 17 Sep 2023 06:27:41 +0000 (09:27 +0300)]
cmd/cgo: silence unaligned-access

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

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

Updated version of https://go.dev/cl/526915, which includes
"-Wunknown-warning-option" for compilers that do not have the specific flag.

Fixes #62480

Change-Id: I788c6604d0ed5267949f4367f148fa26d2116f51
Reviewed-on: https://go-review.googlesource.com/c/go/+/528935
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
8 months agocmd/internal/obj/riscv: clean up immediate checking
Joel Sing [Sun, 27 Aug 2023 15:22:02 +0000 (01:22 +1000)]
cmd/internal/obj/riscv: clean up immediate checking

Change immIFits to return an error in the case that it does not fit.
This allows for deduplication and consistency of error messages.
Additionally, since we've already calculated the min and max values,
we can easily include these in the message. Also provide and use
immEven, for the same reasons.

Change-Id: Ie680558744f3e9bc19d6913c4144ce9ddbd0429c
Reviewed-on: https://go-review.googlesource.com/c/go/+/523458
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Run-TryBot: M Zhuo <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: M Zhuo <mzh@golangcn.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
8 months agonet/http: avoid leaking goroutines when TestServerGracefulClose retries
Bryan C. Mills [Fri, 15 Sep 2023 14:37:08 +0000 (10:37 -0400)]
net/http: avoid leaking goroutines when TestServerGracefulClose retries

If the call to ReadString returns an error, the closure in
testServerGracefulClose will return an error and retry the test with a
longer timeout. If that happens, we need to wait for the conn.Write
goroutine to complete so that we don't leak connections across tests.

Updates #57084.
Fixes #62643.

Change-Id: Ia86c1bbd0a5e5d0aeccf4dfeb994c19d1fb10b00
Reviewed-on: https://go-review.googlesource.com/c/go/+/528398
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
8 months agocmd/compile: reset memcombine correctly between basic blocks
Keith Randall [Tue, 12 Sep 2023 23:15:59 +0000 (16:15 -0700)]
cmd/compile: reset memcombine correctly between basic blocks

Not sure why this bug didn't cause a complete failure, but it
certainly makes for doing a lot more work than is necessary.

Fixes #62604

Change-Id: If0be4acb6eafc3d7eeb42d2f4263c21b4e6e1c7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/527699
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
8 months agoruntime: remove an arbitrary timeout in TestProfBuf
Bryan C. Mills [Fri, 15 Sep 2023 14:56:32 +0000 (10:56 -0400)]
runtime: remove an arbitrary timeout in TestProfBuf

The failure observed in
https://build.golang.org/log/766ad55d098ee1979ba1ae261e0813063567743e
appears to be spurious. If it is, this change will fix it.

If it is not, and somehow the Read has deadlocked,
then this change will help to diagnose it
(by causing the test to time out and dump its running goroutines).

For #56196.

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

8 months agoarchive/zip: reject non-regular files in AddFS
Mauri de Souza Meneguzzo [Thu, 7 Sep 2023 21:34:01 +0000 (21:34 +0000)]
archive/zip: reject non-regular files in AddFS

When a filesystem with non-regular files is used
the resulting files inside the zip archive are empty.

In this case we can be explicit and return an error.

Fixes #61875

Change-Id: I1aeac544521002e0c4bad328e73f51852ad4eee3
GitHub-Last-Rev: 5e53dcfd7c12e45d4142016d0b9b286f9aa83d56
GitHub-Pull-Request: golang/go#61876
Reviewed-on: https://go-review.googlesource.com/c/go/+/517475
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
8 months agonet/http: handle MethodNotAllowed
Jonathan Amsterdam [Fri, 15 Sep 2023 16:17:15 +0000 (12:17 -0400)]
net/http: handle MethodNotAllowed

If no pattern matches a request, but a pattern would have
matched if the request had a different method, then
serve a 405 (Method Not Allowed), and populate the
"Allow" header with the methods that would have succeeded.

Updates #61640.

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

8 months agocmd/link: reject invalid -R flag
Cherry Mui [Fri, 15 Sep 2023 16:02:01 +0000 (12:02 -0400)]
cmd/link: reject invalid -R flag

Reject -R value that is not a power of 2, or less than 4K.

Fixes #62660.

Change-Id: I3fa33c23c25311a93c0accc9acbd1e465789b8c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/528715
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agogo/types, types2: introduce `isValid` predicate and use throughout
Robert Griesemer [Fri, 15 Sep 2023 01:02:41 +0000 (18:02 -0700)]
go/types, types2: introduce `isValid` predicate and use throughout

Preparation for Alias type nodes. Using a predicate will ensure
that alias indirection can be taken care of when needed, eventually.

Change-Id: I689fab6052060eb6bcb2eeac28ba09fdb73f6868
Reviewed-on: https://go-review.googlesource.com/c/go/+/528695
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

8 months agocmd/internal/obj/ppc64: improve RLWNM encoding
Paul E. Murphy [Fri, 7 Jul 2023 16:46:45 +0000 (11:46 -0500)]
cmd/internal/obj/ppc64: improve RLWNM encoding

If the rotate argument is the constant 0, rlwnm may be generated
instead of rlwinm. In all reasonable cases, this is OK as R0 should
hold 0. However, this could be problematic in some cases when
writing PPC64 assembly.

This consolidates the RLWNM and RLWMI optab entries. Invalid RLWMI
usage is still rejected, however the error will be be slightly
different. The invalid usage will be caught in oprrr instead of oplook.

Change-Id: I9958bd24660fea5f8fc9e3e50d51daa7349e3206
Reviewed-on: https://go-review.googlesource.com/c/go/+/527275
Reviewed-by: Heschi Kreinick <heschi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>

8 months agotestdata/vcstest/bzr: fix unit test with Ubuntu 2020 LTS bzr 3.0.2
Arnaud Lacombe [Thu, 14 Sep 2023 20:52:54 +0000 (20:52 +0000)]
testdata/vcstest/bzr: fix unit test with Ubuntu 2020 LTS bzr 3.0.2

As pointed by @bcmills, upstream fixed this in 3.1.0 in https://github.com/breezy-team/breezy/commit/30143860ced0ad9f42cbf18a119f2800117decff

Fixes #62620.

Change-Id: I9fa179a5293aec59496ddd401edec02e1080f1a5
GitHub-Last-Rev: 6066b05054877b33b78afbb32a81457c19f11c9b
GitHub-Pull-Request: golang/go#62652
Reviewed-on: https://go-review.googlesource.com/c/go/+/528437
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

8 months agonet: use bytealg.LastIndexByteString
apocelipes [Thu, 14 Sep 2023 18:43:14 +0000 (18:43 +0000)]
net: use bytealg.LastIndexByteString

There is no need to handwrite the "last" function, the bytealg package already provides "LastIndexByteString".

Change-Id: I6000705bffe8450a10cf8f3fa716a8d4605ada1f
GitHub-Last-Rev: 6627c65fb40fad96239edd28bde27a30f9f8f544
GitHub-Pull-Request: golang/go#62647
Reviewed-on: https://go-review.googlesource.com/c/go/+/527976
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 agocmd/compile/internal/inline/inlheur: rescore callsites based on result use
Than McIntosh [Thu, 17 Aug 2023 19:30:23 +0000 (15:30 -0400)]
cmd/compile/internal/inline/inlheur: rescore callsites based on result use

Add a post-processing pass that updates the scores on callsites based
on how their results are used. This is similar to the "param feeds
unmodified into <XXX>" heuristics, but applies to returned results
instead: if we know that function F always returns a constant, and we
can see that the result from a given call feeds unmodified into an
if/switch, then decrease the score on the call to encourage inlining.

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

8 months agocmd/compile/internal/inlheur: minor debug trace changes
Than McIntosh [Wed, 16 Aug 2023 15:15:08 +0000 (11:15 -0400)]
cmd/compile/internal/inlheur: minor debug trace changes

Minor changes to debug tracing and to the -d=dumpinlfuncprops
debug flag implementation.

Change-Id: Ibaefd489c94675ac7f5a04ec0331b7f888c15a49
Reviewed-on: https://go-review.googlesource.com/c/go/+/521818
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
8 months agocmd/compile/internal/inl: use func-level "never returns" flag
Than McIntosh [Tue, 1 Aug 2023 16:04:12 +0000 (12:04 -0400)]
cmd/compile/internal/inl: use func-level "never returns" flag

Make use of the "never returns" flag bit in ir.Func when computing
function properties: update the bit when we're done looking at a given
function, and read the bit from imported functions during flag
analysis. The advantage of using the ir.Func flag is that it will get
set (and will propagate through to export data) for all functions,
nost just those that are inline candidates.

Change-Id: I7002364b2c4ff5424ed70748fad87fad1a9e4786
Reviewed-on: https://go-review.googlesource.com/c/go/+/518257
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
8 months agocmd/compile/internal/inline: add callsite trace output debugging flag
Than McIntosh [Mon, 24 Jul 2023 14:58:26 +0000 (10:58 -0400)]
cmd/compile/internal/inline: add callsite trace output debugging flag

Add a new debug flag "-d=dumpinlcallsitescores" that dumps out a
summary of all callsites in the package being compiled with info on
inlining heuristics, for human consumption. Sample output lines:

  Score  Adjustment  Status  Callee  CallerPos ScoreFlags
  ...
  115    40      DEMOTED  cmd/compile/internal/abi.(*ABIParamAssignment).Offset expand_calls.go:1679:14|6 panicPathAdj
  ...
  76     -5          PROMOTED runtime.persistentalloc mcheckmark.go:48:45|3 inLoopAdj
  ...
  201    0      --- PGO  unicode.DecodeRuneInString utf8.go:312:30|1
  ...
  7      -5      --- PGO  internal/abi.Name.DataChecked type.go:625:22|0 inLoopAdj

Here "Score" is the final score calculated for the callsite,
"Adjustment" is the amount added to or subtracted from the original
hairyness estimate to form the score. "Status" shows whether anything
changed with the site -- did the adjustment bump it down just below
the threshold ("PROMOTED") or instead bump it above the threshold
("DEMOTED") or did nothing happen as a result of the heuristics
("---"); "Status" also shows whether PGO was involved. "Callee" is the
name of the function called, "CallerPos" is the position of the
callsite, and "ScoreFlags" is a digest of the specific properties we
used to make adjustments to callsite score via heuristics.

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

8 months ago.github: issue template for telemetry proposals
Hana (Hyang-Ah) Kim [Thu, 14 Sep 2023 00:52:51 +0000 (20:52 -0400)]
.github: issue template for telemetry proposals

This uses the github's newer template syntax.

https://docs.github.com/en/communities/using-templates-to-encourage-useful-issues-and-pull-requests/syntax-for-issue-forms

See
https://github.com/hyangah/go/issues/new?assignees=&labels=Telemetry-Proposal&projects=hyangah%2F3&template=12-telemetry.yml&title=x%2Ftelemetryconfig%3A+
for demo.

Change-Id: I13105711b1fe97680b505eefa1f0e7082e76e92c
Reviewed-on: https://go-review.googlesource.com/c/go/+/528357
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
8 months agocmd/cover: add new "emit meta file" mode for packages without tests
Than McIntosh [Fri, 5 May 2023 19:53:33 +0000 (15:53 -0400)]
cmd/cover: add new "emit meta file" mode for packages without tests

Introduce a new mode of execution for instrumenting packages that have
no test files. Instead of just skipping packages with no test files
(during "go test -cover" runs), the go command will invoke cmd/cover
on the package passing in an option in the config file indicating that
it should emit a coverage meta-data file directly for the package (if
the package has no functions, an empty file is emitted). Note that
this CL doesn't actually wire up this functionality in the Go command,
that will come in a later patch.

Updates #27261.
Updates #58770
Updates #24570.

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

8 months agocmd/compile/internal/inl: inline based on scoring when GOEXPERIMENT=newinliner
Than McIntosh [Fri, 11 Aug 2023 13:40:31 +0000 (09:40 -0400)]
cmd/compile/internal/inl: inline based on scoring when GOEXPERIMENT=newinliner

This patch changes the inliner to use callsite scores when deciding to
inline as opposed to looking only at callee cost/hairyness.

For this to work, we have to relax the inline budget cutoff as part of
CanInline to allow for the possibility that a given function might
start off with a cost of N where N > 80, but then be called from a
callsites whose score is less than 80. Once a given function F in
package P has been approved by CanInline (based on the relaxed budget)
it will then be emitted as part of the export data, meaning that other
packages importing P will need to also need to compute callsite scores
appropriately.

For a function F that calls function G, if G is marked as potentially
inlinable then the hairyness computation for F will use G's cost for
the call to G as opposed to the default call cost; for this to work
with the new scheme (given relaxed cost change described above) we
use G's cost only if it falls below inlineExtraCallCost, otherwise
just use inlineExtraCallCost.

Included in this patch are a bunch of skips and workarounds to
selected 'errorcheck' tests in the <GOROOT>/test directory to deal
with the additional "can inline" messages emitted when the new inliner
is turned on.

Change-Id: I9be5f8cd0cd8676beb4296faf80d2f6be7246335
Reviewed-on: https://go-review.googlesource.com/c/go/+/519197
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
8 months agoruntime/pprof: TestVMInfo reworked to avoid test flakiness.
Cosmos Nicolaou [Mon, 11 Sep 2023 18:27:30 +0000 (11:27 -0700)]
runtime/pprof: TestVMInfo reworked to avoid test flakiness.

Fixes #62352.

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

8 months agocmd/link: clean up some unnecessary casts
Cherry Mui [Thu, 14 Sep 2023 18:02:47 +0000 (14:02 -0400)]
cmd/link: clean up some unnecessary casts

In CL 527822, the type of FlagRound is changed to *int64, so casts
to int64 are no longer necessary. Remove them.

Change-Id: I68a89f6e51e0ae3813cb79959b8062ca6bea4980
Reviewed-on: https://go-review.googlesource.com/c/go/+/528575
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agonet/http: synchronize tests that use reqNum counters
Bryan C. Mills [Thu, 14 Sep 2023 13:03:37 +0000 (09:03 -0400)]
net/http: synchronize tests that use reqNum counters

This suppresses the race reported in #62638.

I am not 100% certain how that race happens, but here is my theory.
The increment of reqNum happens before the server writes the response
headers, and the server necessarily writes the headers before the
client receives them. However, that write/read pair occurs through I/O
syscalls rather than Go synchronization primitives, so it doesn't
necessarily create a “happens before” relationship as defined by the
Go memory model: although we can establish a sequence of events, that
sequence is not visible to the race detector, nor to the compiler.

Fixes #62638.

Change-Id: I90d66ec3fc32b9b8e1f9bbf0bc2eb289b964b99b
Reviewed-on: https://go-review.googlesource.com/c/go/+/528475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

8 months agolog/slog: fix Record.back slice always too small during Add()
Chris Duncan [Wed, 13 Sep 2023 22:26:19 +0000 (22:26 +0000)]
log/slog: fix Record.back slice always too small during Add()

When slog.Record.Add(args) is called, with enough args to cause the
Record.back []Attr to be created, it is being created 1 too small, which
results in it immediately being grown again by append before the function
exits (needless allocation and copying).
This is because it is created with a capacity equal to countAttrs(args),
but forgets that there is an additional attribute to be appended: a
(args is just the remaining unconsumed attributes).
This PR fixes that by adding 1 to the capacity to account for the `a` attribute.

Additionally, when Record.back already exists, it will most likely be at
max capacity already. Rather than append to it and risk having it grown
multiple times, or grow too large, this adds a slices.Grow call to set it
to the right capacity, similar to what is already done in the
Record.AddAttrs(attrs) function.

Change-Id: Ic4bcf45909fe4436c586ccd2b8d61f24606b6be8
GitHub-Last-Rev: 4c924b610a7987a940360bb1b4cc7c53981afdc5
GitHub-Pull-Request: golang/go#62388
Reviewed-on: https://go-review.googlesource.com/c/go/+/524618
Reviewed-by: Jonathan Amsterdam <jba@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
8 months agocmd/link/internal/loadelf: correct the relocation size of R_LARCH_64
limeidan [Thu, 14 Sep 2023 12:11:07 +0000 (20:11 +0800)]
cmd/link/internal/loadelf: correct the relocation size of R_LARCH_64

Change-Id: If3eaca8b92e8f5265c7763d13021a6353b9df9b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/528455
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agosyscall: remove unused ptracePtr on openbsd
Tobias Klauser [Thu, 14 Sep 2023 16:15:47 +0000 (18:15 +0200)]
syscall: remove unused ptracePtr on openbsd

ptracePtr was introduced in CL 470299 for openbsd but it's not used on
this platform.

For #58387

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

8 months agoregexp: use built-in clear to clear b.visited in *bitState.reset
Jes Cok [Wed, 13 Sep 2023 13:07:09 +0000 (13:07 +0000)]
regexp: use built-in clear to clear b.visited in *bitState.reset

Change-Id: I1a723124f7050aeb971377db8c3cd04ebf9f7a16
GitHub-Last-Rev: 465da88feb20b4a3ebea3c3e36560f6c82f7fa2e
GitHub-Pull-Request: golang/go#62611
Reviewed-on: https://go-review.googlesource.com/c/go/+/527975
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
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: Heschi Kreinick <heschi@google.com>
8 months agocmd/compile/internal/ir: remove Func.ReflectMethod
Matthew Dempsky [Thu, 14 Sep 2023 10:03:52 +0000 (03:03 -0700)]
cmd/compile/internal/ir: remove Func.ReflectMethod

This flag doesn't serve any purpose anymore. The only place that it's
currently set happens after it's checked.

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

8 months agocmd/compile: move remaining instrumentation logic into ssagen
Matthew Dempsky [Thu, 14 Sep 2023 05:48:43 +0000 (22:48 -0700)]
cmd/compile: move remaining instrumentation logic into ssagen

Allows removing Func.{Enter,Exit}, which were only ever used to hold
at most one function call each.

Change-Id: I8b629c82e90bac3fcbe54db89900492406c7dca6
Reviewed-on: https://go-review.googlesource.com/c/go/+/528319
Auto-Submit: 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>
8 months agocmd/cgo/internal/testcshared: remove an arbitrary timeout in TestSignalHandlersWithNotify
Bryan C. Mills [Fri, 14 Jul 2023 17:24:55 +0000 (13:24 -0400)]
cmd/cgo/internal/testcshared: remove an arbitrary timeout in TestSignalHandlersWithNotify

Also log verbose information when -test.v is set.

We need an arbitrary delay when checking that a signal is *not*
delivered, but when we expect the signal to arrive we don't need to
set an arbitrary limit on how long that can take.

Fixes #61264.

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

8 months agocmd/compile/internal/noder: drop unused *types.Pkg results
Matthew Dempsky [Thu, 14 Sep 2023 03:01:56 +0000 (20:01 -0700)]
cmd/compile/internal/noder: drop unused *types.Pkg results

Several methods return a (*types.Pkg, *types.Sym) pair instead of just
a *types.Sym, because we used to need to preserve the *types.Pkg for
certain types so that we could write out export data for go/types to
use (which exposes these through its APIs).

But now that we write export data from the types2 representation
directly, there's no need for the rest of the compiler to be
concerned about that.

Change-Id: I6ac81a6db71b8e0795ff2f33399b839871564eb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/528416
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@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/internal/ir: add Func.DeclareParams
Matthew Dempsky [Thu, 14 Sep 2023 02:26:32 +0000 (19:26 -0700)]
cmd/compile/internal/ir: add Func.DeclareParams

There's several copies of this function. We only need one.

While here, normalize so that we always declare parameters, and always
use the names ~pNN for params and ~rNN for results.

Change-Id: I49e90d3fd1820f3c07936227ed5cfefd75d49a1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/528415
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
8 months agotime: unconditionally use RegLoadMUIString on Windows
qmuntal [Tue, 12 Sep 2023 13:32:22 +0000 (15:32 +0200)]
time: unconditionally use RegLoadMUIString on Windows

RegLoadMUIString is supported on Windows Vista and later, so this
should be safe to do unconditionally.

While here, also unconditionally use GetDynamicTimeZoneInformation
in syscall/windows/registry tests, since it's also supported on Windows
Vista and later.

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

8 months agospec: specify evaluation order for binary logical operations
Matthew Dempsky [Fri, 25 Aug 2023 23:24:54 +0000 (16:24 -0700)]
spec: specify evaluation order for binary logical operations

This CL clarifies the order of evaluation of the binary logical
operators, && and ||. The clarified semantics matches what cmd/compile
and x/tools/go/ssa already implement, and prohibit some optimizations
that are arguably allowed today but risk surprising users.

First, it specifies that the left operand is evaluated before the
right operand. This prohibits "(f() || true) && *p" from evaluating
"*p" before "f()".

Second, it specifies that binary logical operations are also ordered
lexically left-to-right with regard to function calls and receive
operations. This prohibits "h(*p || true || f(), g())" from evaluating
"*p" after "g()".

Finally, the "order of evaluation of [...] is not specified" wording
in the example is clarified to acknowledge that there are still some
other orderings that are implied lexically; e.g., x must be evaluated
and indexed before g(), and z now must be evaluated before h(). (Note:
Whether z is evaluated before or after f() remains unspecified, as
there's no lexical dependency.)

Change-Id: I9d316a7f1fbc83be663e116380a2cc7a4ace623d
Reviewed-on: https://go-review.googlesource.com/c/go/+/522938
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

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

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

Populate those fields in ServeMux.ServeHTTP.

Updates #61410.

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

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

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

Fixes #62582

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

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

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

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

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

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

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

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

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

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

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

Modify ServeMux to handle patterns with methods and wildcards.

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

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

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

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

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

For #36768.
Updates #62596.

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

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

- Ignore empty entries in PATH, like PowerShell does.

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

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

Fixes #61493.

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

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

Fixes #62064.

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

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

targetDeclFuncs was removed before CL 492436 was ever merged.

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

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

Fixes #62596.

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

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

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

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

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

For #61395

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

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

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

Fixes #62356

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

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

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

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

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

Fixes #62472

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

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

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

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

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

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

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

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

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

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

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

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

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

This also eliminates the need for the NumParamRegs cache.

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

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

To be used by package abi in the following CL.

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

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

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

This was likely missed in CL 476097.

For #476097

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

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

- Factor out a common chdir helper.

- Use t.Setenv where appropriate.

- Reduce indirection in test helpers.

- Set NoDefaultCurrentDirectoryInExePath consistently in the
  environment.

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

Fixes #62594.
For #62596.

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

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

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

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

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

Fixes #62600.

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

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

Change-Id: Ifb28dd08faa59d9186a4a2337aab0c536d9a885e

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

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

Fixes #58000

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

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

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

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

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

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

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

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

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

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

For #62440.

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

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

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

The primary intent is to help new-ish contributors.

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

Updates #30074

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

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

Saw this failing on windows like this:

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

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

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

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

This is a follow up of CL 526496.

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

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

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

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

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

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

For #61372.

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

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

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

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

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

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

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

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

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

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

For #62440.

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

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

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

Change-Id: Ifbb9e40df730abe3bec20fde5f56f5c75dfd9e8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/527795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>