]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
9 months agocmd/compile: absorb InvertFlags into Noov comparisons
Keith Randall [Wed, 6 Sep 2023 20:06:58 +0000 (13:06 -0700)]
cmd/compile: absorb InvertFlags into Noov comparisons

Unfortunately, there isn't a single op that provides the resulting
computation.
At least, I couldn't find one.

Fixes #62469

Change-Id: I236f3965b827aaeb3d70ef9fe89be66b116494f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/526276
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocmd/compile/internal/inline/inlheur: remove ConstExpr assumption
Matthew Dempsky [Wed, 6 Sep 2023 22:43:12 +0000 (15:43 -0700)]
cmd/compile/internal/inline/inlheur: remove ConstExpr assumption

OLITERAL isn't always ConstExpr. It can also be BasicLit or Name.

Change-Id: I44d595830f9e206eccf6fb37bd47ddf957db0866
Reviewed-on: https://go-review.googlesource.com/c/go/+/526277
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
9 months agocmd/compile/internal/ir: simplify printing of OLITERALs
Matthew Dempsky [Wed, 6 Sep 2023 21:43:22 +0000 (14:43 -0700)]
cmd/compile/internal/ir: simplify printing of OLITERALs

This formatting used to be relevant to user error diagnostics and
(much earlier) even to the old textual export data format, but now
it's only relevant to backend debugging. So we can simplify a lot,
adjusting a few test expectations accordingly.

Change-Id: Ibe8e029284ce6150bfa24ef794d8d9eff66dbdea
Reviewed-on: https://go-review.googlesource.com/c/go/+/526375
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agocmd/link: avoid deadcode of global map vars for programs using plugins
Than McIntosh [Wed, 6 Sep 2023 14:15:37 +0000 (10:15 -0400)]
cmd/link: avoid deadcode of global map vars for programs using plugins

If a program imports the plugin package, the mechanisms in place for
detecting and deleting unused global map variables are no longer safe,
since it's possibly for a given global map var to be unreferenced in
the main program but referenced by a plugin. This patch changes the
linker to test for plugin use and to avoid removing any unused global
map variables if the main program could possibly load up a plugin.

Fixes #62430.

Change-Id: Ie00b18b681cb0d259e3c859ac947ade5778cd6c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/526115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agofmt: avoid reflect.Value.Slice to help escape analysis
thepudds [Wed, 21 Jun 2023 18:35:53 +0000 (14:35 -0400)]
fmt: avoid reflect.Value.Slice to help escape analysis

This is part of a series of CLs that aim to reduce how often
interface arguments escape for the print functions in fmt.

Prior to this change, one reason arguments escape is because
printValue calls reflect.Value.Slice, which causes its
value argument to escape (though at this CL, that is
shrouded in the fmt escape analysis logs by other
printValue escape reasons).

This CL avoids that usage by calling f.Bytes instead,
which is possible because we know f is a slice of bytes
or an addressable array of bytes.

Arguments still escape for other reasons.

Change-Id: Ic3f064117a364007e1dd3197cef9d641abbf784a
Reviewed-on: https://go-review.googlesource.com/c/go/+/524940
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: t hepudds <thepudds1460@gmail.com>

9 months agofmt: avoid reflect.Value.Pointer to help escape analysis
thepudds [Wed, 21 Jun 2023 18:18:56 +0000 (14:18 -0400)]
fmt: avoid reflect.Value.Pointer to help escape analysis

This is part of a series of CLs that aim to reduce how often
interface arguments escape for the print functions in fmt.

Prior to this change, one reason arguments escape is because
fmtPointer calls reflect.Value.Pointer:

./print.go:551:39: parameter value leaks to <heap> for (*pp).fmtPointer with derefs=0:
./print.go:551:39:   flow: <heap> ← value:
./print.go:551:39:     from reflect.Value.Pointer(value) (call parameter) at ./print.go:555:20

printValue also has its value argument escape for this reason,
among others.

This CL changes those uses to reflect.Value.UnsafePointer instead,
which does not cause an escape.

Arguments still escape for other reasons.

Change-Id: I81c4f737f11fe835c5ccb122caee40a39b553451
Reviewed-on: https://go-review.googlesource.com/c/go/+/524939
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: t hepudds <thepudds1460@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/go: remove unused (*testgoData).FailSSH test helper
Tobias Klauser [Wed, 6 Sep 2023 09:31:53 +0000 (11:31 +0200)]
cmd/go: remove unused (*testgoData).FailSSH test helper

The last remaining user was removed by CL 213829.

Change-Id: Ic788b22b2de0d20e5fa096d137536d3b5c6d6c36
Reviewed-on: https://go-review.googlesource.com/c/go/+/525876
Reviewed-by: Bryan Mills <bcmills@google.com>
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>

9 months agocmd/compile/internal/dwarfgen: make scope test less sensitive to changes in escape...
thepudds [Thu, 31 Aug 2023 14:16:01 +0000 (10:16 -0400)]
cmd/compile/internal/dwarfgen: make scope test less sensitive to changes in escape analysis

The test function fi is used in TestEscape, and the intent of fi
seems to be to leak its argument, but fi is currently
sensitive to changes in escape analysis regarding interface receivers.

Make fi less sensitive by directly leaking its argument.

Change-Id: I16cc3d3a6bd7b08a08c8fc292b0b99c9a54d68d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/524943
Run-TryBot: t hepudds <thepudds1460@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agoruntime: fix the miscalculation of memoryLimitGoal in gcPaceScavenger
Andy Pan [Tue, 5 Sep 2023 09:12:24 +0000 (17:12 +0800)]
runtime: fix the miscalculation of memoryLimitGoal in gcPaceScavenger

The goal is supposed to be (100-reduceExtraPercent) / 100 * memoryLimit,
as stated in the original design.

Fixes #62449

Change-Id: Ia33acadc3320aa3625814595a24b9631ae8896d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/525555
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>

9 months agoruntime: clear procid in unminit
Michael Pratt [Wed, 6 Sep 2023 14:31:32 +0000 (10:31 -0400)]
runtime: clear procid in unminit

Extra Ms can move between system threads. needm will reinitialize procid
(via minit) on the new thread, but leaving a stale procid behind after
dropm can be misleading if printing the M early in needm for debugging.

Change-Id: I668891971a0baeab31170d1e40a97126416e7379
Reviewed-on: https://go-review.googlesource.com/c/go/+/526118
Reviewed-by: Cherry Mui <cherryyz@google.com>
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>

9 months agocmd/go: permit $AR to include options
Ian Lance Taylor [Wed, 6 Sep 2023 18:18:07 +0000 (11:18 -0700)]
cmd/go: permit $AR to include options

Handle the AR environment variable, used by gccgo,
the same way we handle the CC environment variable.

Change-Id: I4f42161469392f68f0b5adeb9c8b52359d5108a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/526275
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agocmd/compile/internal/inline: analyze function result properties
Than McIntosh [Fri, 30 Jun 2023 17:41:59 +0000 (13:41 -0400)]
cmd/compile/internal/inline: analyze function result properties

Add code to analyze properties of function result values, specifically
heuristics for cases where we always return allocated memory, always
return the same constant, or always return the same function.

Updates #61502.

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

9 months agocmd/compile/internal/ir: add "never returns" func flag
Than McIntosh [Tue, 1 Aug 2023 16:00:57 +0000 (12:00 -0400)]
cmd/compile/internal/ir: add "never returns" func flag

Add a flag to ir.Func's flags field to record whether a given function
is deemed to never return (e.g. always calls exit or panic or
equivalent on all control paths). So as to not increase the amount of
flag storage, this new flag replaces the existing "ExportInline" flag,
which is currently unused.

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

9 months agocmd/go: reject toolchain directives containing path separators
Bryan C. Mills [Thu, 17 Aug 2023 21:12:44 +0000 (17:12 -0400)]
cmd/go: reject toolchain directives containing path separators

If GOTOOLCHAIN="path" or "auto", the go command uses exec.LookPath to
search for it in order to allow toolchains to refer to local-only
toolchain variants (such as toolchains built from enterprise- or
distro-patched source). However, those toolchains should only be
resolved from $PATH, not relative to the working directory of the
command.

Thanks to Juho Nurminen of Mattermost for reporting this issue.

Fixes #62198.
Fixes CVE-2023-39320.

Change-Id: I247c7acea95d737362dd0475e9fc8515430d0fcc
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1996318
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/526158
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agohtml/template: properly handle special tags within the script context
Roland Shoemaker [Thu, 3 Aug 2023 19:28:28 +0000 (12:28 -0700)]
html/template: properly handle special tags within the script context

The HTML specification has incredibly complex rules for how to handle
"<!--", "<script", and "</script" when they appear within literals in
the script context. Rather than attempting to apply these restrictions
(which require a significantly more complex state machine) we apply
the workaround suggested in section 4.12.1.3 of the HTML specification [1].

More precisely, when "<!--", "<script", and "</script" appear within
literals (strings and regular expressions, ignoring comments since we
already elide their content) we replace the "<" with "\x3C". This avoids
the unintuitive behavior that using these tags within literals can cause,
by simply preventing the rendered content from triggering it. This may
break some correct usages of these tags, but on balance is more likely
to prevent XSS attacks where users are unknowingly either closing or not
closing the script blocks where they think they are.

Thanks to Takeshi Kaneko (GMO Cybersecurity by Ierae, Inc.) for
reporting this issue.

Fixes #62197
Fixes CVE-2023-39319

[1] https://html.spec.whatwg.org/#restrictions-for-contents-of-script-elements

Change-Id: Iab57b0532694827e3eddf57a7497ba1fab1746dc
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1976594
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/526157
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
9 months agohtml/template: support HTML-like comments in script contexts
Roland Shoemaker [Thu, 3 Aug 2023 19:24:13 +0000 (12:24 -0700)]
html/template: support HTML-like comments in script contexts

Per Appendix B.1.1 of the ECMAScript specification, support HTML-like
comments in script contexts. Also per section 12.5, support hashbang
comments. This brings our parsing in-line with how browsers treat these
comment types.

Thanks to Takeshi Kaneko (GMO Cybersecurity by Ierae, Inc.) for
reporting this issue.

Fixes #62196
Fixes CVE-2023-39318

Change-Id: Id512702c5de3ae46cf648e268cb10e1eb392a181
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/1976593
Run-TryBot: Roland Shoemaker <bracewell@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/526156
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
9 months agocmd/compile/internal/inline: no-return flag analysis for inline heuristics
Than McIntosh [Fri, 30 Jun 2023 16:17:06 +0000 (12:17 -0400)]
cmd/compile/internal/inline: no-return flag analysis for inline heuristics

Add code to compute whether a given function appears to
unconditionally call panic or exit, as a means of driving inlining
decisions. Note that this determination is based on
heuristics/guesses, as opposed to strict safety analysis; in some
cases we may miss a function that does indeed always panic, or mark a
function as always invoking panic when it doesn't; the intent is get
the right answer in "most" cases.

Updates #61502.

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

9 months agocmd/compile/internal/ssa: improve masking codegen on PPC64
Paul E. Murphy [Tue, 27 Jun 2023 22:17:33 +0000 (17:17 -0500)]
cmd/compile/internal/ssa: improve masking codegen on PPC64

Generate RLDIC[LR] instead of MOVD mask, Rx; AND Rx, Ry, Rz.
This helps reduce code size, and reduces the latency caused
by the constant load.

Similarly, for smaller-than-register values, truncate constants
which exceed the range of the value's type to avoid needing to
load a constant.

Change-Id: I6019684795eb8962d4fd6d9585d08b17c15e7d64
Reviewed-on: https://go-review.googlesource.com/c/go/+/515576
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agoruntime/metrics: fix /gc/scan/* metrics
Nayef Ghattas [Tue, 5 Sep 2023 12:00:17 +0000 (14:00 +0200)]
runtime/metrics: fix /gc/scan/* metrics

In the existing implementation, all /gc/scan/* metrics are
always equal to 0 due to the dependency on gcStatDep not being
set. This leads to gcStatAggregate always containing zeros, and
always reporting 0 for those metrics.

Also, add a test to ensure that /gc/scan/* metrics are not empty.

Fixes #62477.

Change-Id: I67497347d50ed5c3ce1719a18714c062ec938cab
Reviewed-on: https://go-review.googlesource.com/c/go/+/525595
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
9 months agoruntime: ignore SPWrite on innermost traceback frame
Austin Clements [Tue, 5 Sep 2023 20:10:02 +0000 (16:10 -0400)]
runtime: ignore SPWrite on innermost traceback frame

Prior to CL 458218, gentraceback ignored the SPWrite function flag on
the innermost frame when doing a precise traceback on the assumption
that precise tracebacks could only be started from the morestack
prologue, and that meant that the innermost function could not have
modified SP yet.

CL 458218 rearranged this logic a bit and unintentionally lost this
particular case. As a result, if traceback starts in an assembly
function that modifies SP (either as a result of stack growth or stack
scanning during a GC preemption), traceback stop at the SPWrite
function and then crash with "traceback did not unwind completely".

Fix this by restoring the earlier special case for when the innermost
frame is SPWrite.

This is a fairly minimal change that should be easy to backport. I
think a more robust change would be to encode this per-PC in the
spdelta table, so it would be clear that we're unwinding from the
morestack prologue and wouldn't rely on a complicated and potentially
fragile set of conditions.

Fixes #62326.

Change-Id: I34f38157631890d33a79d0bd32e32c0fcc2574e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/525835
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
9 months agoall: use ^$ instead of XXXX, NoSuchTestExists to match no tests
Dmitri Shuralyov [Sun, 3 Sep 2023 17:48:01 +0000 (13:48 -0400)]
all: use ^$ instead of XXXX, NoSuchTestExists to match no tests

It's shorter and can't accidentally match unlikely test names.

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

9 months agoall: use ^TestName$ regular pattern for invoking a single test
Dmitri Shuralyov [Sun, 3 Sep 2023 18:23:02 +0000 (14:23 -0400)]
all: use ^TestName$ regular pattern for invoking a single test

Use ^ and $ in the -run flag regular expression value when the intention
is to invoke a single named test. This removes the reliance on there not
being another similarly named test to achieve the intended result.

In particular, package syscall has tests named TestUnshareMountNameSpace
and TestUnshareMountNameSpaceChroot that both trigger themselves setting
GO_WANT_HELPER_PROCESS=1 to run alternate code in a helper process. As a
consequence of overlap in their test names, the former was inadvertently
triggering one too many helpers.

Spotted while reviewing CL 525196. Apply the same change in other places
to make it easier for code readers to see that said tests aren't running
extraneous tests. The unlikely cases of -run=TestSomething intentionally
being used to run all tests that have the TestSomething substring in the
name can be better written as -run=^.*TestSomething.*$ or with a comment
so it is clear it wasn't an oversight.

Change-Id: Iba208aba3998acdbf8c6708e5d23ab88938bfc1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/524948
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoruntime: don't let the tests leave core files behind
Ian Lance Taylor [Fri, 1 Sep 2023 19:52:48 +0000 (12:52 -0700)]
runtime: don't let the tests leave core files behind

Also add a check that we didn't leave any core files behind.

Change-Id: I30444ef43ad1a8cc1cacd3b75280f2128e104939
Reviewed-on: https://go-review.googlesource.com/c/go/+/525175
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agoos: don't invoke shell in TestStatStdin
Ian Lance Taylor [Mon, 4 Sep 2023 17:35:13 +0000 (10:35 -0700)]
os: don't invoke shell in TestStatStdin

Change-Id: I4048caffd4f79e3ffb6a0a3770bdfa830d1a2f35
Reviewed-on: https://go-review.googlesource.com/c/go/+/525515
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>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agotesting: add doc to not call Init concurrently
go101 [Tue, 5 Sep 2023 03:53:29 +0000 (03:53 +0000)]
testing: add doc to not call Init concurrently

Change-Id: I2e218805fbe4858be125df97bdaf921799315799
GitHub-Last-Rev: 32b798d75f7ec0f72e18a65932ad93d8e5f1040a
GitHub-Pull-Request: golang/go#62410
Reviewed-on: https://go-review.googlesource.com/c/go/+/525015
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agocmd/go: correct function name in comment
Ian Lance Taylor [Tue, 5 Sep 2023 21:39:56 +0000 (14:39 -0700)]
cmd/go: correct function name in comment

Change-Id: I9d8056117367998c3723ec4cc09f47b46ec8b4ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/525855
Reviewed-by: Ian Lance Taylor <iant@google.com>
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>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

9 months agocmd/asm: add KMA and KMCTR instructions on s390x.
root [Wed, 2 Aug 2023 09:46:27 +0000 (09:46 +0000)]
cmd/asm: add KMA and KMCTR instructions on s390x.

This CL is to add assembly instruction mnemonics for the following instructions, mainly used in crypto packages.

 * KMA    - cipher message with authentication
 * KMCTR  - cipher message with counter

Fixes #61163

Change-Id: Iff9a69911aeb4fab4bca8755b23a106eaebb2332
Reviewed-on: https://go-review.googlesource.com/c/go/+/515195
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

9 months agocompile/internal/walk: add walkGrowslice
Egon Elbre [Wed, 17 May 2023 15:10:58 +0000 (18:10 +0300)]
compile/internal/walk: add walkGrowslice

Move growslice generation to a separate func so that specialization
logic can be shared.

Updates #49480

Change-Id: I9ea5bb898753622d2d767546a46b4db6410dc725
Reviewed-on: https://go-review.googlesource.com/c/go/+/495877
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
9 months agosyscall: fixup TestUseCgroupFD error checking
Kir Kolyshkin [Mon, 4 Sep 2023 07:00:11 +0000 (00:00 -0700)]
syscall: fixup TestUseCgroupFD error checking

Fixup for CL 520265; of course errors returned from os/exec are wrapped.

While at it, change the order -- it seems more readable this way.

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

9 months agoruntime: introduce nextslicecap
Egon Elbre [Wed, 17 May 2023 14:33:15 +0000 (17:33 +0300)]
runtime: introduce nextslicecap

This allows to reuse the slice cap computation across
specialized growslice funcs.

Updates #49480

Change-Id: Ie075d9c3075659ea14c11d51a9cd4ed46aa0e961
Reviewed-on: https://go-review.googlesource.com/c/go/+/495876
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Egon Elbre <egonelbre@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

9 months agoruntime: optimize growslice
Egon Elbre [Tue, 9 May 2023 08:29:51 +0000 (11:29 +0300)]
runtime: optimize growslice

This is tiny optimization for growslice, which is probably too small to
measure easily.

Move the for loop to avoid multiple checks inside the loop.
Also, use >> 2 instead of /4, which generates fewer instructions.

Change-Id: I9ab09bdccb56f98ab22073f23d9e102c252238c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/493795
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Egon Elbre <egonelbre@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocmd/compile/internal/ssa: fix typos in comments
Jes Cok [Mon, 4 Sep 2023 12:14:50 +0000 (12:14 +0000)]
cmd/compile/internal/ssa: fix typos in comments

Change-Id: Idb09d68ce1e4823c8a330430e082d5c7ac2d8fc5
GitHub-Last-Rev: 5a2b71b21eb83a100c63c1fd1c1c5cab231a49ad
GitHub-Pull-Request: golang/go#62441
Reviewed-on: https://go-review.googlesource.com/c/go/+/525415
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agonet: respect hosts file when resolving names for Windows
Nikita Vaniasin [Mon, 28 Aug 2023 13:26:32 +0000 (15:26 +0200)]
net: respect hosts file when resolving names for Windows

Fixes #57757.

Change-Id: I896dae8e5905ae98539ab83c9379fd1c9886d44a
Reviewed-on: https://go-review.googlesource.com/c/go/+/467335
Reviewed-by: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agoencoding: show the alphabet for base32 and base64
Joe Tsai [Sun, 3 Sep 2023 03:38:49 +0000 (20:38 -0700)]
encoding: show the alphabet for base32 and base64

There is not a great reason to hide the alphabet used
for StdEncoding, HexEncoding, and URLEncoding.

Although this is specified in RFC 4748,
showing it in GoDoc saves an extra click from going
to the RFC itself to see the alphabet being used.

Also, split exported and unexported constants apart
so that GoDoc renders more cleanly.

Fixes #55126

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

9 months agocmd/compile/internal/liveness: remove excess bits for stackmap
zhangjian [Sun, 11 Jun 2023 11:29:55 +0000 (11:29 +0000)]
cmd/compile/internal/liveness: remove excess bits for stackmap

ArgWidth() already includes the stack space required for
input parameters and return values, so their offset will
not exceed the value of ArgWidth(), so there is no need
to double it.

Change-Id: I10fde7afbf2a5714b5142075c2116af14debc7e8
GitHub-Last-Rev: eaf3fd5eb86ed1d968a6d5962c71ee3144424598
GitHub-Pull-Request: golang/go#60591
Reviewed-on: https://go-review.googlesource.com/c/go/+/500675
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: guangyuan zhou <zhouguangyuan@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agosyscall: inline TestUseCgroupFDHelper
Kir Kolyshkin [Fri, 1 Sep 2023 21:59:27 +0000 (14:59 -0700)]
syscall: inline TestUseCgroupFDHelper

This way, the test case is self-contained, and the test output no longer
has useless lines related to TestUseCgroupFDHelper.

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

9 months agocmd: fix some comments
cui fliter [Sat, 2 Sep 2023 16:08:17 +0000 (00:08 +0800)]
cmd: fix some comments

Change-Id: I8b3eb51e31139314d222d796b56ab7d42338797f
Reviewed-on: https://go-review.googlesource.com/c/go/+/525315
Run-TryBot: shuang cui <imcusg@gmail.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>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Keith Randall <khr@golang.org>

9 months agoencoding/gob: add comma in field comment of userTypeInfo for consistency
Jes Cok [Sat, 2 Sep 2023 00:15:13 +0000 (00:15 +0000)]
encoding/gob: add comma in field comment of userTypeInfo for consistency

Change-Id: I80c494a357195dad3ade98fcce0a6883303777ce
GitHub-Last-Rev: a30615f3733fb0a43628cc81df7ad286e789b445
GitHub-Pull-Request: golang/go#62422
Reviewed-on: https://go-review.googlesource.com/c/go/+/524998
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agocompress: linkify references to io.ByteReader
Joe Tsai [Fri, 1 Sep 2023 07:27:12 +0000 (00:27 -0700)]
compress: linkify references to io.ByteReader

The special treatment of io.ByteReader is somewhat significant.
Linkify references to that type from documentation.

Change-Id: I77c06e4c6b957d107638e2ff2a4c58148b396ed3
Reviewed-on: https://go-review.googlesource.com/c/go/+/525016
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>

9 months agoreflect: make Value.IsZero identical to v == zero
Joe Tsai [Wed, 9 Aug 2023 18:17:42 +0000 (11:17 -0700)]
reflect: make Value.IsZero identical to v == zero

The upcoming built-in zero value provides an idiomatic way
to test for zero by comparing to the zero literal: v == zero.

The reflect package is meant to provide a programmatic way to perform
operations that the Go language itself provides.
Thus, it seems prudent that reflect.ValueOf(&v).Elem().IsZero() is
identical to v == zero.

This change alters the behavior of Value.IsZero in two concrete ways:
* negative zero is identical to zero
* blank fields in a struct are ignored

Prior to this change, we were already in an inconsistent state
due to a regression introduced by CL 411478.
The new behavior was already the case for comparable composite types.
This change makes it consistent for all other types
(in particular incomparable composite types and standalone numbers).

Updates #61372
Fixes #61827

Change-Id: Id23fb97eb3b8921417cc75a1d3ead963e22dc3d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/517777
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agosync: prevent (*Map).Range from always escaping
Mauri de Souza Meneguzzo [Fri, 1 Sep 2023 18:26:49 +0000 (18:26 +0000)]
sync: prevent (*Map).Range from always escaping

After the change from CL 426074 the Range method on Map always
escape the read variable, leading to an allocation.

Since the compiler doesn't do live-range splitting for local variables we
need to use some hints to only escape in that particular branch.

Fixes #62404

Change-Id: I938a5e593647455fa827e3dd3ed8ea22c7365df1
GitHub-Last-Rev: fcbedb467c7b4e6f1d49e299d243cad70deb34e9
GitHub-Pull-Request: golang/go#62408
Reviewed-on: https://go-review.googlesource.com/c/go/+/524976
Auto-Submit: 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>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/internal/dwarf: replace Sym.Length with Context.Size
Matthew Dempsky [Fri, 1 Sep 2023 04:17:46 +0000 (21:17 -0700)]
cmd/internal/dwarf: replace Sym.Length with Context.Size

Preparatory refactoring before next CL.

Change-Id: I06fb4670b933fddff1a2a70f3cf1eb124cbd86ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/524899
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agocmd/link: type alias sym.LoaderSym and loader.Sym
Matthew Dempsky [Fri, 1 Sep 2023 20:12:49 +0000 (13:12 -0700)]
cmd/link: type alias sym.LoaderSym and loader.Sym

Rather than making these two different types, we can type alias them
together. This will ease converting cmd/internal/dwarf to use generics
in a subsequent CL.

The one unfortunate quirk is that while we'd currently like loader.Sym
to be the authoritative type, to break the cycle we have to instead
make loader.Sym an alias of sym.LoaderSym.

Change-Id: I6dde0d492ca89a478c2470c426bb4eed3393d680
Reviewed-on: https://go-review.googlesource.com/c/go/+/525195
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/internal/obj: simplify filename handling
Matthew Dempsky [Mon, 28 Aug 2023 12:13:03 +0000 (05:13 -0700)]
cmd/internal/obj: simplify filename handling

The old Go object file format used linker symbols like "gofile..foo"
to record references to the filename "foo". But the current object
file format has a dedicated section for file names, so we don't need
these useless prefixes anymore.

Also, change DWARF generation to pass around the src.Pos directly,
rather than the old file symbols, which it just turned back into a
file index before writing out anyway.

Finally, directly record the FileIndex into src.PosBase, so that we
can skip the map lookups.

Change-Id: Ia4a5ebfa95da271f2522e45befdb9f137c16d373
Reviewed-on: https://go-review.googlesource.com/c/go/+/523378
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

9 months agoruntime: remove the meaningless offset of 8 for duffzero on loong64
Guoqi Chen [Fri, 21 Apr 2023 03:08:09 +0000 (11:08 +0800)]
runtime: remove the meaningless offset of 8 for duffzero on loong64

Currently we subtract 8 from offset when calling duffzero because 8
is added to offset in the duffzero implementation. This operation is
meaningless, so remove it.

Change-Id: I7e451d04d7e98ccafe711645d81d3aadf376766f
Reviewed-on: https://go-review.googlesource.com/c/go/+/487295
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Run-TryBot: WANG Xuerui <git@xen0n.name>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

9 months agonet: deflake TestDialTimeout on windows
Bryan C. Mills [Thu, 31 Aug 2023 19:22:14 +0000 (15:22 -0400)]
net: deflake TestDialTimeout on windows

The time granularity on windows is large enough that setting even an
implausibly small timeout still gives ConnectEx enough time to succeed
before the timeout expires. That causes TestDialTimeout to sometimes
flake, because it expects to be able to provoke a timeout using some
nonzero duration.

This change takes a two-pronged approach to address the problem:

1. We can set a deadline on the FD more aggressively. (If the Context
has already expired, or the deadline is already known, we can go ahead
and set it on the fd without waiting for a background goroutine to get
around to it.)

2. We can reintroduce a test hook to ensure that Dial takes a
measurable amount of time before it completes, so that setting an
implausibly short deadline sets that deadline in the past instead of
the future.

Together, these reduce the flake rate on a windows-amd64-longtest
gomote from around 1-in-10 to less than 1-in-2000.

For #62377.

Change-Id: I03975c32f61fffa9f6f84efb3c474a01ac5a0d1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/524936
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.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>

9 months agocmd/internal/objabi: rename R_USEGENERICIFACEMETHOD to R_USENAMEDMETHOD.
Dominique Lefevre [Fri, 25 Aug 2023 13:06:36 +0000 (16:06 +0300)]
cmd/internal/objabi: rename R_USEGENERICIFACEMETHOD to R_USENAMEDMETHOD.

Now we have two cases when we want to keep methods with a specific name:
calls to generic interface methods and MethodByName("Foo"). Both use
the same relocation type, so let us give it a name that is not limited
to the implementation of generic interfaces.

Also, introduce staticdata.StrSymNoCommon(). It creates a symbol that
does not appear in the final binary and only communicates arguments
to the linker.

Change-Id: Icc9f49febfde1f31a4455b5acb903e8838d1c0af
Reviewed-on: https://go-review.googlesource.com/c/go/+/523016
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/link: add testcases for MethodByName(string literal).
Dominique Lefevre [Thu, 24 Aug 2023 07:17:36 +0000 (10:17 +0300)]
cmd/link: add testcases for MethodByName(string literal).

Change-Id: I96ea268ecceea75a24303526ed2f17c8a5e142c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/522438
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

9 months agocmd/link: remove special cases for Method() and MethodByName().
Dominique Lefevre [Thu, 24 Aug 2023 07:17:20 +0000 (10:17 +0300)]
cmd/link: remove special cases for Method() and MethodByName().

There is no more need to do this in the linker. The compiler now
handles both Type.Method() and Value.Method(), and flags their
users as ReflectMethod.

Change-Id: Ice93d5d975a1b93a324471e8abdebdce141d17d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/522437
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agocmd/compile: special-case MethodByName(string literal) to keep the DCE enabled.
Dominique Lefevre [Thu, 24 Aug 2023 07:15:29 +0000 (10:15 +0300)]
cmd/compile: special-case MethodByName(string literal) to keep the DCE enabled.

Normally, a call to MethodByName() disables the DCE because the linker
assumes that any method can be accessed this way. This pessimises
the code generation for k8s.io/apimachinery which needs MethodByName()
to verify whether or not a struct implements DeepCopyInto(). It cannot
cast a struct to `interface { DeepCopyInto() Foo }` because the return
type may vary. Instead, it does the following:

  if m := reflect.ValueOf(obj).MethodByName("DeepCopyInto"); ... {

In this case there is no need to disable the DCE altogether. It
suffices to add a relocation to keep methods named DeepCopyInto().

Fixes #62257.

Change-Id: I583c2f04d8309a8807de75cd962c04151baeeb1b
Reviewed-on: https://go-review.googlesource.com/c/go/+/522436
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoruntime/pprof: print stderr on test failure
Cosmos Nicolaou [Tue, 29 Aug 2023 21:34:40 +0000 (14:34 -0700)]
runtime/pprof: print stderr on test failure

Print Stderr on test failure to track down the intermittent
test failure reported in issue #62352.

Change-Id: I547a3220dc07d05578dac093d6c028a9103b552a
Reviewed-on: https://go-review.googlesource.com/c/go/+/524156
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agosyscall: fix skipping TestUseCgroupFD
Kir Kolyshkin [Thu, 17 Aug 2023 00:45:14 +0000 (17:45 -0700)]
syscall: fix skipping TestUseCgroupFD

The check in prepareCgroupFD tried to find out if clone3 with
CLONE_INTO_CGROUP flag is supported, by supplying arguments in
SysProcAttr that will make ForkExec use clone3 with CLONE_INTO_CGROUP
and fail.

CL 456375 inadvertently broke the above check by adding more errno
values to ignore. As a result, TestUseCgroupFD is always skipped, even
when the test could in fact be run.

Fix by removing the check entirely, instead let's use the functionality
and figure out from the errno if this has failed because of unsupported
syscall, lack of permissions, or other reason.

Change-Id: I108b27b6cfeec390ebd3f161ac39e8597569b666
Reviewed-on: https://go-review.googlesource.com/c/go/+/520265
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Kirill Kolyshkin <kolyshkin@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>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agobytes, strings: use "reports whether" in HasPrefix and HasSuffix
Matthew Dempsky [Fri, 1 Sep 2023 02:15:19 +0000 (19:15 -0700)]
bytes, strings: use "reports whether" in HasPrefix and HasSuffix

Update the doc comments to use the more idiomatic and common phrase
"reports whether" instead of "tests whether".

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

9 months agogo/types, types2: fix doc string
Robert Griesemer [Thu, 31 Aug 2023 23:26:29 +0000 (16:26 -0700)]
go/types, types2: fix doc string

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

9 months agocmd/compile/internal/types2: use strings.ReplaceAll for goTypeName
Jes Cok [Wed, 30 Aug 2023 05:09:56 +0000 (05:09 +0000)]
cmd/compile/internal/types2: use strings.ReplaceAll for goTypeName

strings.ReplaceAll is currently available.

Change-Id: I111b97f12723c97791b59d81fd035a0d5e97cd4b
GitHub-Last-Rev: 561dbab6d22df42636f34a53a97c2f52b9138f3e
GitHub-Pull-Request: golang/go#62369
Reviewed-on: https://go-review.googlesource.com/c/go/+/524157
Reviewed-by: 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: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agonet: remove unused errTimedout
Tobias Klauser [Thu, 31 Aug 2023 10:56:34 +0000 (12:56 +0200)]
net: remove unused errTimedout

It's unused since CL 524055.

Change-Id: I767eac6a66379e67337e24051e5f79aa027e9fad
Reviewed-on: https://go-review.googlesource.com/c/go/+/524715
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
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>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoruntime: remove unnecessary timeout in TestCallbackInAnotherThread
qmuntal [Thu, 31 Aug 2023 07:13:06 +0000 (09:13 +0200)]
runtime: remove unnecessary timeout in TestCallbackInAnotherThread

Waiting only for 100ms might be not enough for the callback to be
called. It is more reliable to wait infinitely and rely on the
test timeout to fail the test if the callback is not called.

Fixes #62206

Change-Id: I06b5eadae1dd334a2afc41af31a44b42cb5e596d
Reviewed-on: https://go-review.googlesource.com/c/go/+/524695
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
9 months agoos/user: use correct size for initial call in retryWithBuffer
Ian Lance Taylor [Wed, 30 Aug 2023 18:28:54 +0000 (11:28 -0700)]
os/user: use correct size for initial call in retryWithBuffer

We were accidentally using the sysconf parameter constant.
Change to using the value of that sysconf parameter.

Change-Id: Id7668e7cced0ce7504df99dbbff0757d29dee8c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/524555
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agoall: rewrite internal/saferio.SliceCap using generics and add func SliceCapWithSize
Jes Cok [Wed, 30 Aug 2023 04:23:55 +0000 (04:23 +0000)]
all: rewrite internal/saferio.SliceCap using generics and add func SliceCapWithSize

Change-Id: I265173bf2722796c4be545c968efef3a1a6f7a7d
GitHub-Last-Rev: 04d95cdd615f906167545f246f707e1440c39374
GitHub-Pull-Request: golang/go#62365
Reviewed-on: https://go-review.googlesource.com/c/go/+/524257
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agoruntime: correct linux-arm64 vdso hash codes
Ian Lance Taylor [Tue, 29 Aug 2023 13:51:54 +0000 (06:51 -0700)]
runtime: correct linux-arm64 vdso hash codes

Also add a test that the VDSO is actually working.

Fixes #62309

Change-Id: Ia846b36dfc21716f1653bdf2671485a4cf4a7bd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/523955
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/cgo: only write _cgo_flags for gccgo
Ian Lance Taylor [Wed, 30 Aug 2023 21:06:45 +0000 (14:06 -0700)]
cmd/cgo: only write _cgo_flags for gccgo

We only use it for gccgo. Also only write out LDFLAGS,
as that is all that cmd/go uses.

Fixes #60642

Change-Id: I6ccc419a17a433583d9868dd63aa7ec41c2b22c4
Reviewed-on: https://go-review.googlesource.com/c/go/+/524556
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: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agonet: retry TestDialTimeout subtests with progressively shorter timeouts
Bryan C. Mills [Wed, 30 Aug 2023 19:16:04 +0000 (15:16 -0400)]
net: retry TestDialTimeout subtests with progressively shorter timeouts

The LUCI builders seem to show that the failure mode in #62359 is not
specific to windows/arm64, but it occurs to me that we ought to be
able to eventually retry by making the timeout so short that the
remote end can't possibly respond in time (discounting the possibility
that the kernel itself might short-circuit the loopback address).

For #62377.
Updates #62359.
Updates #56876.

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

9 months agoencoding/xml: overriding by empty namespace when no new name declaration
xuri [Wed, 23 Aug 2023 22:31:34 +0000 (22:31 +0000)]
encoding/xml: overriding by empty namespace when no new name declaration

The unmarshal and marshal XML text should be consistent if not modified deserialize variable.

Fixes #61881

Change-Id: I475f7b05211b618685597d3ff20b97e3bbeaf8f8
GitHub-Last-Rev: 6831c770c384831798cb1c6dc4674e5d4caa5e3c
GitHub-Pull-Request: golang/go#58401
Reviewed-on: https://go-review.googlesource.com/c/go/+/466295
Reviewed-by: ri xu <xuri.me@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoencoding/asn1: use reflect.TypeFor for known types
apocelipes [Wed, 30 Aug 2023 05:51:23 +0000 (05:51 +0000)]
encoding/asn1: use reflect.TypeFor for known types

For #60088

Change-Id: I4b2a5c6c59ef26361f343052a4ddaabde5d3bc94
GitHub-Last-Rev: d519835ad592efab031917c83483e5dcbeff1c3a
GitHub-Pull-Request: golang/go#62370
Reviewed-on: https://go-review.googlesource.com/c/go/+/524259
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agoarchive/zip: update link to zip specification
Yusuf Birader [Tue, 29 Aug 2023 22:45:52 +0000 (23:45 +0100)]
archive/zip: update link to zip specification

Change-Id: Iad902ec2a13b0c5c594c60ecac0b40f641574a1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/524275
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agocmd/go: add missing str imports to fix addmod and savedir
Davis Goodin [Tue, 29 Aug 2023 17:39:58 +0000 (12:39 -0500)]
cmd/go: add missing str imports to fix addmod and savedir

The addmod.go and savedir.go testdata generation tools were missing the
"cmd/go/internal/str" import, causing them to fail to build. This change
adds the imports.

This makes progress on the work to use Join functions rather than path
manipulation using the path separator:
https://go-review.googlesource.com/c/go/+/463178

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

9 months agolog/slog: package doc fixes
Sean Liao [Sat, 26 Aug 2023 12:48:38 +0000 (13:48 +0100)]
log/slog: package doc fixes

Fixes #62286

Change-Id: If463436e3b5ba6e4eb850097395e00482d0dc671
Reviewed-on: https://go-review.googlesource.com/c/go/+/523196
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Sean Liao <sean@liao.dev>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>

9 months agointernal/poll, net: use (*FD).SetsockoptInet4Addr in setIPv4MulticastInterface on...
Tobias Klauser [Tue, 29 Aug 2023 11:52:07 +0000 (13:52 +0200)]
internal/poll, net: use (*FD).SetsockoptInet4Addr in setIPv4MulticastInterface on windows

Change-Id: Ic29d15bf62d8e693ca969354b415d958823bf41d
Reviewed-on: https://go-review.googlesource.com/c/go/+/523915
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
9 months agonet: skip TestDialTimeout subtests on Windows if Dial returns WSAECONNREFUSED
Bryan C. Mills [Wed, 30 Aug 2023 14:48:09 +0000 (10:48 -0400)]
net: skip TestDialTimeout subtests on Windows if Dial returns WSAECONNREFUSED

Since we have only seen this failure mode on windows/arm64,
we do not skip on the Go project's windows/amd64 builders
so that we will be more likely to find out whether this failure mode
is specific to arm64.

Also simplify the ECONNRESET check, since I've remembered that the
error_*_test.go files exist.

Fixes #62359.
Updates #56876.

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

9 months agogo/types, types2: use asNamed(t) instead of t.(*Named) type assertions
Robert Griesemer [Thu, 24 Aug 2023 16:07:03 +0000 (09:07 -0700)]
go/types, types2: use asNamed(t) instead of t.(*Named) type assertions

Preparation for the introduction of alias types.
Because asNamed is not exported, existing external
tests continue to use t.(*Named).

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

9 months agoRevert "cmd/compile: use shorter ANDL/TESTL if upper 32 bits are known to be zero"
Keith Randall [Tue, 29 Aug 2023 22:43:02 +0000 (22:43 +0000)]
Revert "cmd/compile: use shorter ANDL/TESTL if upper 32 bits are known to be zero"

This reverts commit c1dfbf72e1298df8495171810a553836e5027f98.

Reason for revert: TESTL rule is wrong when the result is used for an ordered comparison.

Fixes #62360

Change-Id: I4d5b6aca24389b0a2bf767bfbc0a9d085359eb38
Reviewed-on: https://go-review.googlesource.com/c/go/+/524255
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agogo/types, types2: remove order dependency in inference involving channels
Robert Griesemer [Mon, 21 Aug 2023 22:50:18 +0000 (15:50 -0700)]
go/types, types2: remove order dependency in inference involving channels

In inexact unification, when a named type matches against an inferred
unnamed type, we change the previously inferred type to the named type.
This preserves the type name and assignability.

We have to do the same thing when encountering a directional channel:
a bidirectional channel can always be assigned to a directional channel
but not the other way around. Thus, if we see a directional channel, we
must choose the directional channel.

This CL extends the previously existing logic for named types to
directional channels and also makes the code conditional on inexact
unification. The latter is an optimization - if unification is exact,
type differences don't exist and updating an already inferred type has
no effect.

Fixes #62157.

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

9 months agocmd/compile/internal/ir: remove old variable capture logic
Matthew Dempsky [Tue, 29 Aug 2023 19:50:40 +0000 (12:50 -0700)]
cmd/compile/internal/ir: remove old variable capture logic

This logic is no longer used, since the removal of the non-unified
frontends.

Change-Id: I7256d4eb06f0b4e5308bc7c7476e90af9e70b7d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/524215
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>

9 months agoruntime: log stderr in TestLockRankGenerated on failure
Bryan C. Mills [Tue, 29 Aug 2023 16:15:23 +0000 (12:15 -0400)]
runtime: log stderr in TestLockRankGenerated on failure

For #62334.

Change-Id: I6d93dacc914590ef9c5a034dd4633466ec0bde8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/524056
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>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>

9 months agonet: avoid internal hooks in TestDialTimeout
Bryan C. Mills [Tue, 29 Aug 2023 15:26:45 +0000 (11:26 -0400)]
net: avoid internal hooks in TestDialTimeout

TestDialTimeout has historically been very flaky
(#11872, #13144, #22896, and now #56876),
apparently in part due to implementation details of the socktest
package it relies on.

In reviewing CL 467335, I noticed that TestDialTimeout is the last
remaining use of testHookDialChannel (added for #5349), and that that
hook no longer has any effect for Unix and Windows.

As an experiment, I tried removing both that hook and the call to
time.Sleep in the socktest filter, and to my surprise the test
continued to pass. That greatly undermined my confidence in the test,
since it appears that the “timeout” behavior it observes is caused by
the socktest filter injecting an error rather than anything in the net
package proper actually timing out.

To restore confidence in the test, I think it should be written
against only the public API of the net package, and should test the
publicly-documented behaviors. This change implements that approach.

Notably, when a timeout is set on a Dial call, that does not guarantee
that the listener will actually call Accept on the connection before
the timeout occurs: the kernel's network stack may preemptively accept
and buffer the connection on behalf of the listener. To avoid test
flakiness, the test must tolerate (and leave open) those spurious
connections: when the kernel has accepted enough of them, it will
start to block new connections until the buffered connections have
been accepted, and the expected timeout behavior will occur.

This also allows the test to run much more quickly and in parallel:
since we are relying on real timeouts instead of injected calls to
time.Sleep, we can set the timeouts to be much shorter and run
concurrently with other public-API tests without introducing races.

Fixes #56876.

Change-Id: I90dcb2ed70976e70857ca29c253ed760cb078a4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/524055
TryBot-Bypass: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>

9 months agocmd/compile: remove vestigial importpath symbol logic
Matthew Dempsky [Tue, 29 Aug 2023 08:15:55 +0000 (01:15 -0700)]
cmd/compile: remove vestigial importpath symbol logic

The object file format now has an explicit section for tracking which
packages were imported, so we don't need to write out importpath
symbols for all directly imported packages anymore.

However, keep the logic for writing out individual importpath symbols,
because it's still relevant to runtime type descriptor generation.

Change-Id: I184ff320e894ba43ca0f8a3d2678e4b2bbbe6da5
Reviewed-on: https://go-review.googlesource.com/c/go/+/523875
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agocmd/compile/internal/ir: drop Inl.Body
Matthew Dempsky [Sat, 26 Aug 2023 23:37:24 +0000 (16:37 -0700)]
cmd/compile/internal/ir: drop Inl.Body

We don't actually depend on Inl.Body anywhere, except it implicitly
serves to indicate whether Inl.Dcl has been populated. So replace it
with a boolean so we don't need to keep a useless copy of every
inlinable function body in memory.

While here, also add some Fatalfs to make sure there are no unused
local variables. The unified frontend now omits unreachable code
during export data writing, so there shouldn't be unused local
variables.

Also, since unified IR uses the same code/data to construct the
original function as inlined and/or imported functions, the Dcl list
should always be the same, which addresses the real root issue (i.e.,
that export/import could skew the Dcl lists).

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

9 months agocmd/internal/obj: add Func type to replace "curfn any"
Matthew Dempsky [Mon, 28 Aug 2023 12:43:51 +0000 (05:43 -0700)]
cmd/internal/obj: add Func type to replace "curfn any"

This adds a modicum of type safety to these APIs, which are otherwise
quite confusing to follow.

Change-Id: I268a9a1a99a47dcfef6dc1e9e5be13673af3fb85
Reviewed-on: https://go-review.googlesource.com/c/go/+/523396
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/compile/internal/ssagen: stop canonicalizing symabis
Matthew Dempsky [Sun, 27 Aug 2023 21:42:26 +0000 (14:42 -0700)]
cmd/compile/internal/ssagen: stop canonicalizing symabis

cmd/asm writes canonicalized symabis now.

Change-Id: I65cc39ce1671a3c225f14003b336015f0cc33980
Reviewed-on: https://go-review.googlesource.com/c/go/+/523339
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/internal/{dwarf,obj}: stop substituting "" with pkgprefix
Matthew Dempsky [Sun, 27 Aug 2023 21:10:29 +0000 (14:10 -0700)]
cmd/internal/{dwarf,obj}: stop substituting "" with pkgprefix

cmd/asm and cmd/compile now always create symbols with the appropriate
package prefixes, so cmd/internal/dwarf and cmd/internal/obj can stop
worrying about qualifying names itself.

Change-Id: I9aee5d759bf0d41a61722c777e7f66fce957e79e
Reviewed-on: https://go-review.googlesource.com/c/go/+/523338
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile: eliminate fallback code for missing -p flag
Matthew Dempsky [Sun, 27 Aug 2023 20:55:47 +0000 (13:55 -0700)]
cmd/compile: eliminate fallback code for missing -p flag

cmd/compile has required the -p flag since go.dev/cl/391014. It's safe
to eliminate the fallback code that tried to cope without.

Change-Id: I9a62ff829e34a6fa5bfe6ae6a836610cc3f0cd33
Reviewed-on: https://go-review.googlesource.com/c/go/+/523337
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/asm: stop using "" as the local package prefix
Matthew Dempsky [Sun, 27 Aug 2023 02:44:21 +0000 (19:44 -0700)]
cmd/asm: stop using "" as the local package prefix

Now that cmd/asm always knows its package path, we can create symbols
with the appropriate package prefix instead of "".

Change-Id: I56864089e8f1b38ff4197b3158131f976b329572
Reviewed-on: https://go-review.googlesource.com/c/go/+/523336
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/internal/obj: tweak implicit {ArgsPointerMaps,ArgInfo} behavior
Matthew Dempsky [Sun, 27 Aug 2023 22:31:33 +0000 (15:31 -0700)]
cmd/internal/obj: tweak implicit {ArgsPointerMaps,ArgInfo} behavior

This CL changes cmd/internal/obj to also implicitly set
ArgsPointerMaps and ArgInfo for assembly functions that are explicitly
package qualified (e.g., "pkg·name", not just "·name"). This is a
prerequisite for changing cmd/asm to stop emitting `"".`-prefixed
symbol names.

Change-Id: I4e14bc24c87cf4d7114a7aed9beaf0c8d1f9c07f
Reviewed-on: https://go-review.googlesource.com/c/go/+/523335
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

9 months agocrypto/des: test using the public API
qmuntal [Thu, 17 Aug 2023 13:30:58 +0000 (15:30 +0200)]
crypto/des: test using the public API

Several of the tests in crypto/des were using the unexported
desCipher type and other unexported functions to test the package,
leaving desCipher.Encrypt and desCipher.Decrypt only partially tested.

This CL changes the tests to use the public API, except for
TestInitialPermute and TestFinalPermute, which are testing
implementation details on purpose.

Change-Id: I0bc13cea06b79b29425412b9bf36b997871518ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/520495
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agoimage: add a security considerations section to package doc
Roland Shoemaker [Tue, 29 Aug 2023 01:13:29 +0000 (18:13 -0700)]
image: add a security considerations section to package doc

Internally the security model for the image package has always been,
if you don't call DecodeConfig before Decode, you cannot complain if
Decode attempts to create an arbitrarily large image (with the
assumption that DecodeConfig would've told you this information). This
should be explicitly documented.

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

9 months agocmd/link/internal/sym: uncomment code for RelocName
Jes Cok [Mon, 28 Aug 2023 22:16:33 +0000 (22:16 +0000)]
cmd/link/internal/sym: uncomment code for RelocName

Currently we include those relocation types in bootstrap code.

Change-Id: I3016f33f70a756255545431319ffc542893e75aa
GitHub-Last-Rev: 24916e86d0e90f88ba953cea60d38805dcb8a6a3
GitHub-Pull-Request: golang/go#62322
Reviewed-on: https://go-review.googlesource.com/c/go/+/523395
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

9 months agocmd/compile: do not flag reflect.StructOf() as a ReflectMethod.
Dominique Lefevre [Thu, 24 Aug 2023 07:14:54 +0000 (10:14 +0300)]
cmd/compile: do not flag reflect.StructOf() as a ReflectMethod.

StructOf() calls reflect.Type.Method(), but looks up only methods
accessible via interfaces. DCE does not remove such methods, so
there is no need to disable the DCE if StructOf() is used.

There is a dependency chain between struct rtype and StructOf():

  (*rtype).Method() -> FuncOf() -> initFuncTypes() -> StructOf().

Thus, any use of (*rtype).Method() or (*rtype).MethodByName()
disables the DCE in the linker. This is not an issue just yet
because all users of Method() and MethodByName() are flagged
as ReflectMethods. A subsequent patch avoids this flag on callers
of MethodByName(string literal). When that patch is applied,
it becomes important to have no ReflectMethods down the call
chain of MethodByName().

Change-Id: I9b3e55c495c122ed70ef31f9d978c0e2e0573799
Reviewed-on: https://go-review.googlesource.com/c/go/+/522435
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>

9 months agolog/slog: use atomic.Pointer instead of atomic.Value
Mateusz Poliwczak [Fri, 25 Aug 2023 16:42:42 +0000 (16:42 +0000)]
log/slog: use atomic.Pointer instead of atomic.Value

There is no need to use atomic.Value, atomic.Pointer should also
be more performant here.

Change-Id: I04cc1befbe1112665a9d9e16197ea3caef5e5fa3
GitHub-Last-Rev: 577902519ff744c936c5e707802f66aeae32c760
GitHub-Pull-Request: golang/go#62288
Reviewed-on: https://go-review.googlesource.com/c/go/+/523035
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>

9 months agolog/slog: fix documented value type for SourceKey
Sean Liao [Sat, 26 Aug 2023 12:32:09 +0000 (13:32 +0100)]
log/slog: fix documented value type for SourceKey

Fixes #62294

Change-Id: I5df0d8bdf5ae8bc11ffa0e66e3e8776fd3e565a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/523195
Run-TryBot: Sean Liao <sean@liao.dev>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
9 months agotesting/slogtest: clarify that passed handler must be enabled at info
Jonathan Amsterdam [Thu, 17 Aug 2023 20:00:08 +0000 (16:00 -0400)]
testing/slogtest: clarify that passed handler must be enabled at info

Fixes #62115.

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

9 months agocmd: simplify some handling of package paths
Matthew Dempsky [Sun, 27 Aug 2023 02:06:33 +0000 (19:06 -0700)]
cmd: simplify some handling of package paths

We have obj.Link.Pkgpath, so we don't need to pass it redundantly in
places where we already have an *obj.Link.

Also, renaming the parser's "compilingRuntime" field to "allowABI", to
match the "AllowAsmABI" name used by objabi.LookupPkgSpecial.

Finally, push the handling of GOEXPERIMENT_* flags up to cmd/asm's
main entry point, by simply appending them to flags.D.

Change-Id: I6ada134522b0cbc90d35bcb145fbe045338fefb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/523297
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoRevert "cmd/compile/internal/liveness: remove repetitive word"
shuang cui [Tue, 29 Aug 2023 00:43:43 +0000 (00:43 +0000)]
Revert "cmd/compile/internal/liveness: remove repetitive word"

This reverts commit 50bd17205fd9540615c03461a0047e59d29e6efd.

Reason for revert: The first being the English word, the second being the name of the 3rd parameter.

Change-Id: Iabca436b93ecc5481874e1eac0a1768292447431
Reviewed-on: https://go-review.googlesource.com/c/go/+/523835
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: shuang cui <imcusg@gmail.com>

9 months agoencoding/json: adjust comment about encoding \b and \f
Christian Höppner [Mon, 28 Aug 2023 13:12:08 +0000 (15:12 +0200)]
encoding/json: adjust comment about encoding \b and \f

The encoding for the control characters \b and \f was
changed in http://go.dev/cl/521675. This CL adjusts the
corresponding comment about encoding bytes < 0x20.

Change-Id: I83b7311e4fa0731f6601ca64a66042425b4cecac
Reviewed-on: https://go-review.googlesource.com/c/go/+/523435
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
9 months agoruntime, cmd/go: enable address sanitizer on linux/loong64
Xiaolin Zhao [Fri, 31 Mar 2023 09:08:44 +0000 (17:08 +0800)]
runtime, cmd/go: enable address sanitizer on linux/loong64

The recently released llvm-16/LoongArch already supports the asan feature;
but gcc13/LoongArch does not yet fully support the asan feature, and asan
will be fully supported in gcc14.

Change-Id: I48a65f2f10e3dc488acd9c02ea1a1f37de192be0
Reviewed-on: https://go-review.googlesource.com/c/go/+/481317
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agocmd/go: only print cgo.Incomplete warning if -x
Ian Lance Taylor [Mon, 28 Aug 2023 18:26:17 +0000 (11:26 -0700)]
cmd/go: only print cgo.Incomplete warning if -x

Change-Id: I1e0476d6d67f0b2d3d4ad487c2619e3d09f485d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/523576
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agoruntime: fix bp restoration in panic recovery for arm64
Michael Anthony Knyszek [Mon, 28 Aug 2023 19:26:46 +0000 (19:26 +0000)]
runtime: fix bp restoration in panic recovery for arm64

Previously, the frame pointer wouldn't be restored at all, which could
cause panics during frame pointer unwinding. As of CL 516157, the frame
pointer is restored, but it's restored incorrectly on arm64: on arm64,
the frame pointer points one word below SP, but here it's one below
panic.fp which is the stack pointer of the caller's frame (nothing to do
with the architectural bp).

For #61766.

Change-Id: I86504b85a4d741df5939b51c914d9e7c8d6edaad
Reviewed-on: https://go-review.googlesource.com/c/go/+/523697
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/go: allow -buildmode=pie with -race on darwin
Andy Pan [Mon, 28 Aug 2023 12:40:51 +0000 (20:40 +0800)]
cmd/go: allow -buildmode=pie with -race on darwin

Fixes #62318

Change-Id: I6f1b22c9a4523461aa4c7fcd12e72dbc4430812d
Reviewed-on: https://go-review.googlesource.com/c/go/+/523475
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agonet/http: revert "support streaming POST content in wasm"
haruyama480 [Fri, 25 Aug 2023 06:14:35 +0000 (15:14 +0900)]
net/http: revert "support streaming POST content in wasm"

CL 458395 added support for streaming POST content in Wasm.
Unfortunately, this breaks requests to servers that only support HTTP/1.1.
Revert the change until a suitable fallback or opt-in strategy can be decided.

Fixes #61889

Change-Id: If53a77e1890132063b39abde867d34515d4ac2af
Reviewed-on: https://go-review.googlesource.com/c/go/+/522955
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
9 months agocmd/internal/obj/arm64: avoid unnecessary pool literal usage for load/store pairs
Joel Sing [Wed, 2 Aug 2023 10:29:52 +0000 (20:29 +1000)]
cmd/internal/obj/arm64: avoid unnecessary pool literal usage for load/store pairs

Implement better classification for load and store pair operations. This in
turn allows us to avoid using pool literals when the offset fits in a 24 bit
unsigned immediate. In this case, the offset can be calculated using two
add immediate instructions, rather than loading the offset from the pool
literal and then adding the offset to the base register. This requires the
same number of instructions, however avoids a load from memory and does
not require the offset to be stored in the literal pool.

Updates #59615

Change-Id: I316ec3d54f1d06ae9d930e98d0c32471775fcb26
Reviewed-on: https://go-review.googlesource.com/c/go/+/515615
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agointernal/bytealg: improve compare on Power10/PPC64
Paul Murphy [Thu, 17 Aug 2023 21:35:55 +0000 (16:35 -0500)]
internal/bytealg: improve compare on Power10/PPC64

Handle comparisons of 15 or less bytes more efficiently
with Power10 instructions when building with GOPPC64=power10.

name            old time/op  new time/op  delta
BytesCompare/1  2.53ns ± 0%  2.17ns ± 0%  -14.17%
BytesCompare/2  2.70ns ± 0%  2.17ns ± 0%  -19.77%
BytesCompare/4  2.59ns ± 0%  2.17ns ± 0%  -16.20%
BytesCompare/8  2.66ns ± 0%  2.17ns ± 0%  -18.63%

Change-Id: I6d7c6af0a58ea3e03acc3930c54b77f2ac1dfbd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/522315
Reviewed-by: Joedian Reid <joedian@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>