]> Cypherpunks repositories - gostls13.git/log
gostls13.git
9 months agodebug/buildinfo: reuse buffer in searchMagic
Michael Pratt [Fri, 26 Jul 2024 19:57:27 +0000 (15:57 -0400)]
debug/buildinfo: reuse buffer in searchMagic

Allocating a new buffer for each chunk in searchMagic is very
inefficient. Refactor reading to allow us to reuse the same buffer for
each iteration.

This reduces the runtime of `go version` on a 2.5GB non-Go binary from
~1s and ~25MB RSS to ~250ms and ~15MB RSS.

For #68592.

Change-Id: Idae5c2c9b3b8a7158d5cc7f2f008998be75fd7af
Reviewed-on: https://go-review.googlesource.com/c/go/+/601460
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agodebug/buildinfo: read data in chunks
Michael Pratt [Fri, 26 Jul 2024 17:41:12 +0000 (13:41 -0400)]
debug/buildinfo: read data in chunks

Rather than reading the entire data segment into memory, read it in
smaller chunks to keep memory usage low.

For typically Go binaries, this doesn't matter much. For those, we read
the .go.buildinfo section, which should be quite small. But for non-Go
binaries (or Go binaries with section headers stripped), we search the
entire loadable data segment, which could be quite large.

This reduces the time for `go version` on a 2.5GB non-Go binary from
~1.2s and 1GB RSS (!!) to ~1s and ~25MB RSS.

Fixes #68592.

Change-Id: I9218854c5b6f2aa1331f561ab0850a9fd62ef23b
Reviewed-on: https://go-review.googlesource.com/c/go/+/601459
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd: add README generation for compiler + linker script tests
Than McIntosh [Tue, 30 Jul 2024 14:20:53 +0000 (14:20 +0000)]
cmd: add README generation for compiler + linker script tests

Add in automatic README generation and README consistency checking for
the cmd/compile and cmd/link script tests. This code is adapted from
the similar facility in cmd/go (e.g. scriptreadme_test.go); the README
helps folks writing new tests understand the mechanics.

Updates #68606.

Change-Id: I8ff7ff8e814abd4385bd670440511b2c60a4cef6
Reviewed-on: https://go-review.googlesource.com/c/go/+/601756
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/internal/script: new hook for adding in toolchain script conditions
Than McIntosh [Mon, 29 Jul 2024 17:40:10 +0000 (17:40 +0000)]
cmd/internal/script: new hook for adding in toolchain script conditions

Introduce a new function AddToolChainScriptConditions that augments a
default "script.Cond" set with a collection of useful conditions,
including godebug/goexperiment, cgo, race support, buildmode, asan,
msan, and so on. Having these conditions available makes it easier to
write script tests that deal with specific build-flavor corner cases.
The functions backing the new conditions are helper functions migrated
over from the Go command's script test setup.

Updates #68606.

Change-Id: I14def1115b54dc47529c983abcd2c5ea9326b9de
Reviewed-on: https://go-review.googlesource.com/c/go/+/601715
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agogo/types: record pointer and parentheses in receiver expressions
Robert Griesemer [Mon, 29 Jul 2024 22:29:08 +0000 (15:29 -0700)]
go/types: record pointer and parentheses in receiver expressions

CL 594740 rewrote type checking of method receiver types. Because that
CL takes apart receivers "manually" rather than using the regular code
for type checking type expressions, pointer and parenthesized receiver
type expressions were not recorded anymore.

Adjust the code that typechecks method receivers to a) use ordinary
type expression checking for non-generic receivers, and b) to record
a missing pointer and any intermediate parenthesized expressions in
case of a generic receiver.

Add many extra tests verifying that the correct types for parenthesized
and pointer type expressions are recorded in various source positions.

Note that the parser used by the compiler and types2 doesn't encode
unnecessary parentheses in type expressions in its syntax tree.
As a result, the tests that explicitly test parentheses don't work
in types2 and are commented out.

This CL adds code (disabled by default) to the parser to encode
parentheses in type expressions in the syntax tree. When enabled,
the commented out types2 tests pass like in go/types.

Fixes #68639.
For #51343.

Change-Id: Icf3d6c76f7540ee53e229660be8d78bb25380539
Reviewed-on: https://go-review.googlesource.com/c/go/+/601657
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agonet/http: match os.File.Readdir behavior in DotFileHiding
Sean Liao [Fri, 12 Jul 2024 19:14:23 +0000 (20:14 +0100)]
net/http: match os.File.Readdir behavior in DotFileHiding

Fixes #67697

Change-Id: I26b26262d885d0704851c08c79e7b2b4872b65ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/598075
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agocmd/cgo/internal/testsanitizers: avoid clang error in msan8.go
Ian Lance Taylor [Tue, 30 Jul 2024 18:48:10 +0000 (11:48 -0700)]
cmd/cgo/internal/testsanitizers: avoid clang error in msan8.go

In clang 16 the option -fsanitize-memory-param-retval was turned on by
default. That option causes MSAN to issue a warning when calling a
function with an uninitialized value. The msan8 test relies on being
able to do this, in order to get uninitialized values into registers.

This CL fixes the test by adding maybe_undef attributes that tell
clang that it's OK to pass an uninitialized variable. The docs for
maybe_undef say: "Please note that this is an attribute that is used as
an internal implementation detail and not intended to be used by
external users." So this may break in the future, but it does work for now.

Fixes #64616

Change-Id: I0ac8c0520fce8c32e26d2a5efb7ae5e02461c1ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/601779
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agogo/printer: correct cindex meaning in commentInfo comments
Mateusz Poliwczak [Tue, 30 Jul 2024 19:01:10 +0000 (19:01 +0000)]
go/printer: correct cindex meaning in commentInfo comments

(*printer).nextComment increases cindex by one after each call
and it always points to the next element.

Change-Id: I65754ab6e30e10dc7473882e39737d2e0dc29070
GitHub-Last-Rev: f859283324af6ddf9fdc75ef08ee42ae26bc581b
GitHub-Pull-Request: golang/go#68032
Reviewed-on: https://go-review.googlesource.com/c/go/+/592557
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.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/go/internal/load: recompute test variant's build info if necessary
Michael Matloob [Mon, 1 Jul 2024 20:34:08 +0000 (16:34 -0400)]
cmd/go/internal/load: recompute test variant's build info if necessary

The buildinfo used for a testmain is a copy from the buildinfo produced
for the package under test, and that in turn is only computed if the
package under test is package main. If there are //go:debug directives
in a test file for package main, the godebugs for the testmain (which
are computed using the regular package files as well as the test files'
//go:debug directives) will be different from those used to produce the
buildinfo of the package under test (computed using the //go:debug
directives only in the main package). In that case, recompute the
buildinfo for the testmain to incorporate the new godebug information.

Since we've only been generating buildinfo for tests on package main, in
this CL we'll only recompute the buildinfo if the test is for package
main. It's not clear to me though if we should be computing the
buildinfo for all test mains (or none of them?)

Fixes #68053

Change-Id: Ib6cdb118e2f233de483c33e171c0cd03df1fc7be
Reviewed-on: https://go-review.googlesource.com/c/go/+/595961
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
9 months agoruntime: make TestDebugLogInterleaving much more robust
Austin Clements [Wed, 24 Jul 2024 03:09:07 +0000 (23:09 -0400)]
runtime: make TestDebugLogInterleaving much more robust

The current test often doesn't actually generate enough interleaving
to result in multiple log shards. This CL rewrites this test to
forcibly create at least 10 log shards with interleaved log messages.
It also tests dlog's robustness to being held across M and P switches.

Change-Id: Ia913b17c0392384ff679832047f359945669bb15
Reviewed-on: https://go-review.googlesource.com/c/go/+/600699
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Austin Clements <austin@google.com>

9 months agocmd/compile: add "deadlocals" pass to remove unused locals
David Chase [Wed, 22 May 2024 21:00:43 +0000 (14:00 -0700)]
cmd/compile: add "deadlocals" pass to remove unused locals

This CL adds a "deadlocals" pass, which runs after inlining and before
escape analysis, to prune any unneeded local variables and
assignments. In particular, this helps avoid unnecessary Addrtaken
markings from unreachable closures.

Deadlocals is sensitive to "_ = ..." as a signal of explicit
use for testing.  This signal occurs only if the entire
left-hand-side is "_" targets; if it is
  `_, ok := someInlinedFunc(args)`
then the first return value is eligible for dead code elimination.

Use this (`_ = x`) to fix tests broken by deadlocals elimination.

Includes a test, based on one of the tests that required modification.

Matthew Dempsky wrote this, changing ownership to allow rebases, commits, tweaks.

Fixes #65158.

Old-Change-Id: I723fb69ccd7baadaae04d415702ce6c8901eaf4e
Change-Id: I1f25f4293b19527f305c18c3680b214237a7714c
Reviewed-on: https://go-review.googlesource.com/c/go/+/600498
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: David Chase <drchase@google.com>
Commit-Queue: David Chase <drchase@google.com>

9 months agocmd/compile/internal/ir: add DoChildrenWithHidden
David Chase [Wed, 22 May 2024 22:00:20 +0000 (15:00 -0700)]
cmd/compile/internal/ir: add DoChildrenWithHidden

Analogous to EditChildrenWithHidden.
A commit written by Matthew Dempsky

Old-Change-Id: I9fe0d3ee98d9dbe5f77eb02d666b9f317ee5b6af
Change-Id: I41aacb1545ab3142862b156bd1767fe4a3df4ca0
Reviewed-on: https://go-review.googlesource.com/c/go/+/600497
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile: verify that rangefunc assigning to no vars works
David Chase [Tue, 2 Jul 2024 16:45:30 +0000 (12:45 -0400)]
cmd/compile: verify that rangefunc assigning to no vars works

This adds a test for
   for range seq2rangefunc { ... }
and
   for onevar := range seq2rangefunc { ... }

For #65236.

Change-Id: I083f8e4c19eb4ba0d6024d5314ac29d941141778
Reviewed-on: https://go-review.googlesource.com/c/go/+/596135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agoencoding: add TextAppender and BinaryAppender
Mateusz Poliwczak [Mon, 29 Jul 2024 18:39:02 +0000 (18:39 +0000)]
encoding: add TextAppender and BinaryAppender

For #62384

Change-Id: I54707a29653df72ad9cd5633f434b87e0f630b94
GitHub-Last-Rev: 4f78947ac563d78f862c5c8de1c2e1578a8d6e08
GitHub-Pull-Request: golang/go#68620
Reviewed-on: https://go-review.googlesource.com/c/go/+/601595
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: Michael Knyszek <mknyszek@google.com>
9 months agocmd/go/internal/test: update documentation for the "go test" command
Julian Dax [Mon, 15 Jul 2024 14:36:07 +0000 (16:36 +0200)]
cmd/go/internal/test: update documentation for the "go test" command

The documentation referred to the package's source root as $GOPATH, which is no longer correct.

Fixes #64303

Change-Id: I2ea113497975726468d4ee4f85e2cfcbea9a76d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/598235
Reviewed-by: Julian Dax <julian.dax@posteo.de>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
9 months agointernal/coverage: add internal/stringslite to hard-coded coverpkg ID list
Than McIntosh [Tue, 30 Jul 2024 13:47:58 +0000 (13:47 +0000)]
internal/coverage: add internal/stringslite to hard-coded coverpkg ID list

Add internal/stringslite to the list of hard-coded package IDs to be
special cased in coverage package registration. This patch fixes
a new -coverpkg=all failure on the darwin longtest builders.

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

9 months agocmd/link: add variable_parameter attr to functype outparams
Than McIntosh [Thu, 27 Jun 2024 14:54:06 +0000 (14:54 +0000)]
cmd/link: add variable_parameter attr to functype outparams

When generating DW_TAG_subroutine_type DIEs during linker DWARF type
synthesis, ensure that in the list of children of the subroutine type
DIE (correspondings to input/output params) the output params are
marked with the DW_AT_variable_parameter attribute. In addition, fix
up the generated types of the output params: prior to this patch for a
given output parameter of type T, we would emit the DIE type as *T
(presumably due to how parameter passing/returning worked prior to the
register ABI); with this patch the emitted type will just be T, not *T.

Fixes #59977.

Change-Id: I5b5600be86473695663c75b85baeecad667b9245
Reviewed-on: https://go-review.googlesource.com/c/go/+/595715
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agoruntime: delete TestDebugLogBuild
Austin Clements [Tue, 23 Jul 2024 21:54:34 +0000 (17:54 -0400)]
runtime: delete TestDebugLogBuild

Now that we're actually testing debuglog in the regular build
configuration, it's far less important that we take the time to
rebuild with the debuglog tag.

Change-Id: I62bfd494ccb99087f35851c4476238b39ef40dec
Reviewed-on: https://go-review.googlesource.com/c/go/+/600698
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoruntime: run debuglog tests when debuglog tag is *not* set
Austin Clements [Tue, 23 Jul 2024 21:28:09 +0000 (17:28 -0400)]
runtime: run debuglog tests when debuglog tag is *not* set

Currently, the debuglog tests only run when the debuglog build tag is
set because, until the last few CLs, all of debuglog was compiled away
without that build tag. This causes two annoying problems:

1. The tests basically never run, because we don't regularly test this
configuration.

2. If you do turn on the debuglog build tag, it's probably because
you're adding debuglogs into the runtime, which are very likely to
mess up these tests, so you wind up disabling the tests and they,
again, don't get coverage.

Now we've set things up so the debuglog implementation is always
accessible, if you ask nicely enough. So we can switch these tests to
run when the tag is *not* set, and turn off when the tag *is* set (and
you're probably adding actual log statements).

Change-Id: Ib68d7a5022d4f5db96e9c7c8010cbef21d11fe11
Reviewed-on: https://go-review.googlesource.com/c/go/+/600697
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
9 months agoruntime: switch debuglog from const-toggled to type-toggled
Austin Clements [Tue, 23 Jul 2024 19:39:51 +0000 (15:39 -0400)]
runtime: switch debuglog from const-toggled to type-toggled

Currently, the debuglog build tag controls the dlogEnabled const, and
all methods of dlogger first check this const and immediately return
if dlog is not enabled. With constant folding and inlining, this makes
the whole dlog implementation compile away if it's not enabled.

However, we want to be able to test debuglog even when the build tag
isn't set. For that to work, we need a different mechanism.

This CL changes this mechanism so the debuglog build tag instead
controls the type alias for dlogger to be either dloggerImpl or
dloggerFake. These two types have the same method set, but one is just
stubs. This way, the methods of dloggerImpl don't need to be
conditional dlogEnabled, which sets us up to use the now
fully-functional dloggerImpl type in the test.

I confirmed that this change has no effect on the final size of the
cmd/go binary. It does increase the size of the runtime.a file by 0.9%
and make the runtime take ever so slightly longer to compile because
the compiler can no longer simply eliminate the bodies of the all of
dlogger during early deadcode. However, this all gets eliminated by
the linker. I consider this worth it to always get build and test
coverage of debuglog.

Change-Id: I81759e9e1411b7d369a23383a18b022ab7451421
Reviewed-on: https://go-review.googlesource.com/c/go/+/600696
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoruntime: rename dlogger to dloggerImpl
Austin Clements [Tue, 23 Jul 2024 19:11:14 +0000 (15:11 -0400)]
runtime: rename dlogger to dloggerImpl

This is a mechanical change, other than adding the type alias for dlogger.

This is a step in preparing us to make debuglog testable without the
debuglog build tag.

Change-Id: Ief12f0eaf5db98a8b006c759fd325dabcc9a52d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/600695
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/internal/obj/loong64, cmd/asm: remove useless instructions
limeidan [Sat, 6 Jan 2024 03:35:48 +0000 (11:35 +0800)]
cmd/internal/obj/loong64, cmd/asm: remove useless instructions

Change-Id: I180c40898672a757d72cd0ef38e6e8cc20dc4c3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/565618
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agocmd/internal/obj/loong64: remove unuseless functions
limeidan [Sat, 6 Jan 2024 08:59:56 +0000 (16:59 +0800)]
cmd/internal/obj/loong64: remove unuseless functions

Change-Id: Ieee97a9477090d4273e54a6667b0a051bb0c1e9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/565619
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
9 months agocmd/internal/obj/loong64: fixed operand assignment error for BFPT/BFPF instructions
limeidan [Sat, 6 Jan 2024 09:26:37 +0000 (17:26 +0800)]
cmd/internal/obj/loong64: fixed operand assignment error for BFPT/BFPF instructions

The BFPT correspond to BCNEZ instruction of LoongArch64 which structure
is:
| op-p1 | offs[15:0] | op-p2 | cj | offs[20:16] |
The register REG_FCC0 should be assigned to the source operand cj which named rj here.

Change-Id: I696d0a46028924da1cd7e240fbb40a1913f1a757
Reviewed-on: https://go-review.googlesource.com/c/go/+/565620
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
9 months agocmd/internal/obj: add stmt prologueEnd to DWARF for loong64
limeidan [Thu, 18 Jan 2024 02:41:09 +0000 (10:41 +0800)]
cmd/internal/obj: add stmt prologueEnd to DWARF for loong64

Change-Id: Ib477b2402e32ebb3c7623caf4e9d62f3afdee92f
Reviewed-on: https://go-review.googlesource.com/c/go/+/556615
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/internal/obj/loong64: return an error when getting address of tls variable
limeidan [Thu, 11 Jan 2024 02:48:12 +0000 (10:48 +0800)]
cmd/internal/obj/loong64: return an error when getting address of tls variable

The tls variable is thread local variable, an operation to get its address
is not supported, so we should return an error here.

Change-Id: Ia6a637f549cb886fdb643bdc04eeb269849d1096
Reviewed-on: https://go-review.googlesource.com/c/go/+/565621
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
9 months agonet/http: don't write HEAD response body in ResponseWriter.ReadFrom
Damien Neil [Fri, 26 Jul 2024 20:23:09 +0000 (13:23 -0700)]
net/http: don't write HEAD response body in ResponseWriter.ReadFrom

Responses to HEAD requests don't have a body.

The ResponseWriter automatically discards writes to the response body
when responding to a HEAD request. ResponseWriter.ReadFrom was failing
to discard writes under some circumstances; fix it to do so.

Fixes #68609

Change-Id: I912f6b2b2a535df28ae37b875fcf15b10da1af2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/601475
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agocmd,log,net,runtime: simplify string prefix and suffix processing
apocelipes [Mon, 29 Jul 2024 10:23:14 +0000 (10:23 +0000)]
cmd,log,net,runtime: simplify string prefix and suffix processing

Use the TrimPrefix, TrimSuffix and CutPrefix to simplify the code.

Change-Id: I3e2b271ec0d3f9ce664b830e2b0c21ab47337ed0
GitHub-Last-Rev: 4bd1577d2496173800d609da75b08f6de177aba9
GitHub-Pull-Request: golang/go#68629
Reviewed-on: https://go-review.googlesource.com/c/go/+/601675
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agonet/http: don't write body for HEAD responses in Response.Write
Damien Neil [Fri, 26 Jul 2024 22:34:03 +0000 (15:34 -0700)]
net/http: don't write body for HEAD responses in Response.Write

Fixes #62015

Change-Id: I88c5427f85e740d5b956942bb1c2727dac2935ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/601238
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile: add script testing facility for compiler use
Than McIntosh [Fri, 26 Jul 2024 12:58:29 +0000 (12:58 +0000)]
cmd/compile: add script testing facility for compiler use

Add support for running script tests as part of the compiler's suite
of tests, hooking in the script test engine packages recently moved
from cmd/go to cmd/internal. These script tests will use the test
binary itself as the compile tool for Go builds, and can also run the
C compiler if needed. New script test cases (*.txt files) should be
added to the directory cmd/compile/testdata/script.

Updates #68606.

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

9 months agocmd/link: add script testing facility for linker use
Than McIntosh [Thu, 25 Jul 2024 18:42:21 +0000 (18:42 +0000)]
cmd/link: add script testing facility for linker use

Add support for running script tests as part of the linker's suite of
tests, hooking in the script test engine packages recently moved from
cmd/go to cmd/internal. Linker script tests will use the test binary
itself as the linker for Go builds, and can also run the C compiler if
needed. New script test cases (*.txt files) should be added to the
directory cmd/link/testdata/script.

For demo purposes, this patch also adds a new "randlayout_option.txt"
script test that replicates the existing linker's TestRandLayout
testpoint in script form.

Updates #68606.

Change-Id: Icf26bf657850e39548d6ea819f2542fc68a3899b
Reviewed-on: https://go-review.googlesource.com/c/go/+/601360
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
9 months agocmd/internal/script/scriptest: add new apis for tool test use
Than McIntosh [Thu, 25 Jul 2024 17:15:35 +0000 (17:15 +0000)]
cmd/internal/script/scriptest: add new apis for tool test use

Add top level apis to provide a general-purpose "script test" runner
for clients within cmd, e.g. tools such as compile, link, nm, and so
on. This patch doesn't add any uses of the new apis, this will
happen in follow-on CLs.

Updates #68606.

Change-Id: Ib7200a75d4dc7dc50897628f1a6269937be15a76
Reviewed-on: https://go-review.googlesource.com/c/go/+/601359
Reviewed-by: David Chase <drchase@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: relocate cmd/go/internal/script to cmd/internal/script
Than McIntosh [Mon, 22 Jul 2024 15:50:33 +0000 (15:50 +0000)]
cmd: relocate cmd/go/internal/script to cmd/internal/script

Relocate cmd/go's internal/script package up a level into
cmd/internal/script, so as to enable the use of script tests in
other cmd packages.  No change in functionality.

Updates #68606.

Change-Id: I3974b0bf59c76e0f459184c9f3090d6077dd5d91
Reviewed-on: https://go-review.googlesource.com/c/go/+/601358
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd: extract cmd/go's cfg.LookPath into separate pathcache package
Than McIntosh [Sat, 27 Jul 2024 14:59:42 +0000 (14:59 +0000)]
cmd: extract cmd/go's cfg.LookPath into separate pathcache package

Lift out the LookPath cached lookup utility function into a separate
"cmd/internal/pathcache" package, so that it can be reused in other
commands in addition to cmd/go. No change in functionality.

Change-Id: Ica7fa627000843360c3e353d40a9a70605fbe033
Reviewed-on: https://go-review.googlesource.com/c/go/+/601479
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd: consolidate "known" os/arch tables into separate package
Than McIntosh [Mon, 22 Jul 2024 15:48:31 +0000 (15:48 +0000)]
cmd: consolidate "known" os/arch tables into separate package

Common up the the "known OS/Arch" tables from { cmd/go/internal/imports,
cmd/go/internal/modindex, go/build } and relocate them to a new
package, internal/syslist. No change in functionality.

Updates #68606.

Change-Id: I6414a05c96b8fddbdbd9678d322cb49d9b1b0af3
Reviewed-on: https://go-review.googlesource.com/c/go/+/601357
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd: relocate cmd/go/internal/robustio to cmd/internal/robustio
Than McIntosh [Mon, 22 Jul 2024 15:09:57 +0000 (15:09 +0000)]
cmd: relocate cmd/go/internal/robustio to cmd/internal/robustio

Relocate cmd/go's internal/robustio package up a level into
cmd/internal/robustio, so that it can be used by other cmd/internal
packages. No change in functionality. This change is intended to be in
support of making the cmd/go script test framework available to other
commands in addition to just the Go command.

Updates #68606.

Change-Id: Ic8421ef59d9b7d79a50c3679d180cfa2546c4cd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/601356
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
9 months agocmd: relocate cmd/go/internal/par to cmd/internal/par
Than McIntosh [Mon, 22 Jul 2024 15:02:06 +0000 (15:02 +0000)]
cmd: relocate cmd/go/internal/par to cmd/internal/par

Relocate cmd/go's internal/par package up a level into
cmd/internal/par, so that it can be used by other cmd/internal
packages. No change in functionality. This change is intended to be in
support of making the cmd/go script test framework available to other
commands in addition to just the Go command.

Updates #68606.

Change-Id: I920a5d5c9b362584fabdbb2305414325b42856a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/601355
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
9 months agodebug/buildinfo: add test for malformed strings
Michael Pratt [Fri, 26 Jul 2024 17:26:12 +0000 (13:26 -0400)]
debug/buildinfo: add test for malformed strings

Updates #68592.

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

9 months agodebug/buildinfo: add old-Go and not-Go tests
Michael Pratt [Fri, 26 Jul 2024 16:05:40 +0000 (12:05 -0400)]
debug/buildinfo: add old-Go and not-Go tests

There is currently no coverage for the pre-1.18 buildinfo format, or for
parsing non-Go binaries. Add basic tests for each of these.

Updates #68592.

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

9 months agodebug/buildinfo: improve format documentation
Michael Pratt [Fri, 26 Jul 2024 14:02:55 +0000 (10:02 -0400)]
debug/buildinfo: improve format documentation

Existing documentation is a bit sparse, and more importantly focuses
almost entirely on the old pre-1.18 format, with the new format as an
afterthought. Since the new format is the primary format, make it more
prominent.

Updates #68592.

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

9 months agointernal/trace: reduce event size by packing goroutine statuses
Nick Ripley [Fri, 26 Jul 2024 19:16:24 +0000 (15:16 -0400)]
internal/trace: reduce event size by packing goroutine statuses

The trace parser was using an otherwise-unused event argument to hold an
extra goroutine state argument for the GoStatus & GoStatusStack events.
This is needed because the execution tracer just records the "after" for
state transitions, but we want to have both the "before" and "after"
states available in the StateTransition info for the parsed event. When
GoStatusStack was added, the size of the argument array was increased to
still have room for the extra status. However, statuses are currently
only 1 byte, and the status argument is 8 bytes, so there is plenty of
room to pack the "before" and "after" statuses in a single argument. Do
that instead to avoid the need for an extra argument.

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

9 months agotest: add open-coded defer tests for too many exits path
Cuong Manh Le [Sun, 28 Jul 2024 13:12:59 +0000 (20:12 +0700)]
test: add open-coded defer tests for too many exits path

Add test cases that will disable open-coded defer when there are too
many exits path, even though number of defer statements are not greater
than 8.

Updates #14939
Updates #34481

Change-Id: If5af0e107ffc30043bc2902063f8c9b131a8bca4
Reviewed-on: https://go-review.googlesource.com/c/go/+/601635
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agocmd/internal/obj/loong64, cmd/asm: remove invalid optab items
limeidan [Thu, 11 Jan 2024 07:04:45 +0000 (15:04 +0800)]
cmd/internal/obj/loong64, cmd/asm: remove invalid optab items

Cases 27 and 28 are used to handle floating point operations, MOVW is usually
used for integer processing, and, in two cases there is code like this:
a :=AMOVF
if p.As == AMOVD {
        a=AMOVD
}
This means that MOVW was eventually replaced by MOVF, so removed MOVW from cases 27 and 28.

Change-Id: Ib438febab88058e98b569e0dfe70b8610668ee31
Reviewed-on: https://go-review.googlesource.com/c/go/+/565622
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agocmd/go: remove comparison that is always true
Zxilly [Sun, 28 Jul 2024 15:08:33 +0000 (15:08 +0000)]
cmd/go: remove comparison that is always true

Change-Id: Ia77769e03ee040451c044afb332ae4efae3065b9
GitHub-Last-Rev: 66c6d71c1308a86b1bf770f06a8b412f72a00b4f
GitHub-Pull-Request: golang/go#68623
Reviewed-on: https://go-review.googlesource.com/c/go/+/601615
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@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/compile: drop TODO in NilCheck for riscv64
Meng Zhuo [Thu, 27 Jun 2024 02:56:22 +0000 (10:56 +0800)]
cmd/compile: drop TODO in NilCheck for riscv64

Also add log as arm/amd64 do.

Change-Id: I3698993e2df0ebf3bfcf8bad5fe389affa0e8eff
Reviewed-on: https://go-review.googlesource.com/c/go/+/595355
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocmd/asm: change register type for loong64 floating-point
Xiaolin Zhao [Wed, 3 Apr 2024 07:13:04 +0000 (15:13 +0800)]
cmd/asm: change register type for loong64 floating-point

On Loong64, the two input operands and one output operand of the ADDF
instruction are both floating-point registers; and the floating-point
comparison instruction CMPEQ{F,D}, CMPGE{F,D}, CMPGT{F,D} both input
operands are floating-point registers, and the output operation is a
floating-point condition register, currently, only FCC0 is used as the
floating-point condition register.

Example:
ADDF F0, F1, F0
CMPEQF F0, F1, FCC0

Change-Id: I4c1c453e522d43f294a8dcab7b6b5247f41c9c68
Reviewed-on: https://go-review.googlesource.com/c/go/+/580281
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/link/internal/loadelf: remove useless relocation size information of loong64
limeidan [Tue, 24 Oct 2023 08:41:25 +0000 (16:41 +0800)]
cmd/link/internal/loadelf: remove useless relocation size information of loong64

As of CL 455017 we have switched to following the new style relocations on
loong64, these stack based relocations should be removed.

Change-Id: Ic129a5665cf6f183a32e13b6f1a55d712a99d721
Reviewed-on: https://go-review.googlesource.com/c/go/+/537335
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>
Commit-Queue: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
9 months agocmd/link: pass architecture to isPLTCall
limeidan [Wed, 17 Apr 2024 03:29:13 +0000 (11:29 +0800)]
cmd/link: pass architecture to isPLTCall

The relocation number of each architecture starts from 0. objabi.ElfRelocOffset
+ objabi.RelocType(xxx) cannot uniquely represent a relocation, so the new
argument 'arch' was added to help identify relocation.

Change-Id: Ic8121dbfd1a4f31f279d50ffdc9c932ce3066efd
Reviewed-on: https://go-review.googlesource.com/c/go/+/580275
Commit-Queue: abner chenc <chenguoqi@loongson.cn>
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>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>

9 months agocmd/internal/obj/loong64: add CPUCFG instructions support
Guoqi Chen [Fri, 7 Apr 2023 14:37:57 +0000 (22:37 +0800)]
cmd/internal/obj/loong64: add CPUCFG instructions support

The CPUCFG instruction is used to dynamically obtain the features
supported by the current CPU during the running of the program.

Go asm syntax:
CPUCFG RJ, RD

Equivalent platform assembler syntax:
cpucfg rd, rj

Reference: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Change-Id: I545110ff837ae9c5ccd7c448a1daf2d1277f9aa1
Reviewed-on: https://go-review.googlesource.com/c/go/+/493436
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoos: rm unused code
Kir Kolyshkin [Fri, 26 Jul 2024 19:12:39 +0000 (12:12 -0700)]
os: rm unused code

CL 588675 removes pidfdRelease, but misses this one.

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

9 months agogo/types, types2: add test for receiver type parameters
Robert Griesemer [Fri, 28 Jun 2024 18:12:48 +0000 (11:12 -0700)]
go/types, types2: add test for receiver type parameters

Issue #51503 was fixed with the rewrite in CL 594740.
Add a respective test case.

Fixes #51503.
For #51343.

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

9 months agogo/types, types2: completely rewrite method receiver type checking
Robert Griesemer [Wed, 26 Jun 2024 00:31:26 +0000 (17:31 -0700)]
go/types, types2: completely rewrite method receiver type checking

1) Factor out handling of receiver from Checker.funcType into
   Checker.collectRecv. Analyze the receiver parameter "manually"
   without resorting to calling Checker.collectParams.
   The code is more straight-forward and error handling is simpler
   because constructing the receiver type and variable is all handled
   in one function.

2) Change Checker.collectParams to collect parameter names and
   corresponding parameter variables, but do not declare them.
   Instead return two equal-length slices of parameter names
   and variables for later declaration.

3) Streamline Checker.funcType into a sequence of simple steps.
   By declaring the receiver and parameters after type parameters,
   there is no need for a temporary scope and scope squashing anymore.

4) Simplify Checker.unpackRecv some more: don't strip multiple
   *'s from receiver type expression because we don't typecheck
   that expression as a whole later (we don't use collectParams
   for receiver types anymore). If we have a **T receiver, we
   need to use *T (one * stripped) as receiver base type expression
   so that we can report an error later.

5) Remove Checker.recvTParamMap and associated machinery as it is
   not needed anymore.

6) Remove Scope.Squash/squash as it is not needed anymore.

7) Remove the explicit scope parameter from Checker.collectParams
   as it is not needed anymore.

8) Minor adjustments to tests: in some cases, error positions have
   shifted slightly (because we don't use Checker.collectParams to
   typecheck receivers anymore), and in some cases duplicate errors
   don't appear anymore (resolves TODOs).

Fixes #51343.

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

9 months agogo/types, types2: adjust Checker.unpackRecv signature slightly
Robert Griesemer [Wed, 26 Jun 2024 22:20:41 +0000 (15:20 -0700)]
go/types, types2: adjust Checker.unpackRecv signature slightly

Instead of returning the receiver type name (rname), return the
receiver type base expression (base), with pointer indirections
stripped. The type base may or may not not be a type name. This
is needed for further rewrites of the signature type-checking code.
Adjust call sites accordingly to preserve existing behavior.

For #51343.

Change-Id: Ib472ca25d43ec340762d0a8dd1ad038568c2b2bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/595335
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
9 months agogo/types, types2: fix test name (for debugging)
Robert Griesemer [Wed, 26 Jun 2024 00:33:15 +0000 (17:33 -0700)]
go/types, types2: fix test name (for debugging)

Change-Id: I982cf4da98af73ac41936a9d0b51588e3dbfd706
Reviewed-on: https://go-review.googlesource.com/c/go/+/594739
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

9 months agogo/types, types2: report type name in comp. literal error, if possible
Robert Griesemer [Tue, 25 Jun 2024 22:31:06 +0000 (15:31 -0700)]
go/types, types2: report type name in comp. literal error, if possible

When reporting an error for the element type of a struct literal, use
the element type's type name rather than it's underlying/core type.

Also, combine error reporting for invalid composite literal types in
one place, at the end.

Fixes #68184.

Change-Id: I1f407d5403777948da9a0eca95aacc1389f4bd44
Reviewed-on: https://go-review.googlesource.com/c/go/+/595075
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Tim King <taking@google.com>
9 months agogo/types, types2: remove superfluous if statement (minor cleanup)
Robert Griesemer [Tue, 25 Jun 2024 19:47:20 +0000 (12:47 -0700)]
go/types, types2: remove superfluous if statement (minor cleanup)

Found while re-reading this code.

Change-Id: I5c87bb38ce07e49f1d122db1630c48d5ff082a30
Reviewed-on: https://go-review.googlesource.com/c/go/+/594975
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Tim King <taking@google.com>
9 months agogo/types, types2: factor out method receiver validation
Robert Griesemer [Tue, 18 Jun 2024 18:32:18 +0000 (11:32 -0700)]
go/types, types2: factor out method receiver validation

While at it, slightly regroup surounding code for clarity.

For #51343.

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

9 months agogo/types, types2: slightly reorganize method receiver checking
Robert Griesemer [Tue, 18 Jun 2024 17:34:11 +0000 (10:34 -0700)]
go/types, types2: slightly reorganize method receiver checking

- move receiver checks up, closer to where the receiver is collected
- adjust some comments after verifying against some test cases
- removed some minor discrepancies between the two type checkers

For #51343.

Change-Id: I75b58efbed1e408df89b8d6536e6c6da45740f93
Reviewed-on: https://go-review.googlesource.com/c/go/+/593336
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
9 months agocmd/compile/internal/types2: use syntax.EndPos instead of local computation
Robert Griesemer [Mon, 17 Jun 2024 22:02:10 +0000 (15:02 -0700)]
cmd/compile/internal/types2: use syntax.EndPos instead of local computation

Previously, the end position for a select statement clause body was
computed explicitly as the start of the next clause or the closing "}"
of the select statement, respectively.

Since syntax.EndPos computes the end position of a node, there's no
need to compute these positions "manually", we can simply use the
syntax.ExdPos for each clause. The positions are not exactly the
same as before but for the purpose of identifier visibility in
scopes there is no semantic change.

Simplifies the code and brings it more in line with go/types.

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

9 months agogo/types, types2: use ":" as start of implicit type switch case scopes
Robert Griesemer [Thu, 13 Jun 2024 23:24:26 +0000 (16:24 -0700)]
go/types, types2: use ":" as start of implicit type switch case scopes

Adjust the respective API test accordingly.

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

9 months agogo/types, types2: cleanup of code handling type switch cases
Robert Griesemer [Thu, 13 Jun 2024 20:54:05 +0000 (13:54 -0700)]
go/types, types2: cleanup of code handling type switch cases

Move logic for type-specific variable type into typeCases function
which already does all the relevant work.

Add more detailed documentation to typeCases function.

Uncomment alernative typeCases function so that it is being type-
checked and kept up-to-date. Since it's not (yet) used, the code
will not appear in the binary.

Follow-up on CL 592555.

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

9 months agogo/types, types2: factor out list substitution code (cleanup)
Robert Griesemer [Thu, 23 May 2024 04:47:35 +0000 (21:47 -0700)]
go/types, types2: factor out list substitution code (cleanup)

- Replace the various subst.XList methods with a generic function.
- Rename comparable function to comparableType to avoid shadowing
  predeclared type comparable.
- Rename substFunc/Var to cloneFunc/Var which is more accurate.

Change-Id: I3243f2093e4c43a537766f47e3348402de517090
Reviewed-on: https://go-review.googlesource.com/c/go/+/587775
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
9 months agoruntime: allow experimental trace batches to be reused
Austin Clements [Mon, 24 Jun 2024 16:19:00 +0000 (12:19 -0400)]
runtime: allow experimental trace batches to be reused

Currently, we can only cache regular trace event buffers on each M. As
a result, calling unsafeTraceExpWriter will, in effect, always return
a new trace batch, with all of the overhead that entails.

This extends that cache to support buffers for experimental trace
data. This way, unsafeTraceExpWriter can return a partially used
buffer, which the caller can continue to extend. This gives the caller
control over when these buffers get flushed and reuses all of the
existing trace buffering mechanism.

This also has the consequence of simplifying the experimental batch
infrastructure a bit. Now, traceWriter needs to know the experiment ID
anyway, which means there's no need for a separate traceExpWriter
type.

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

9 months agoruntime: remove darwin-amd64-10_14 builder check
Cuong Manh Le [Fri, 26 Jul 2024 17:09:04 +0000 (00:09 +0700)]
runtime: remove darwin-amd64-10_14 builder check

By now macOS 11 is the minimum required version.

Updates #43926

Change-Id: I13716e2e521c26bd9997f0ea1b717cf72ab7e47c
Reviewed-on: https://go-review.googlesource.com/c/go/+/601276
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agonet: unskip TestUDPZeroBytePayload on Darwin
Dmitri Shuralyov [Fri, 26 Jul 2024 16:49:29 +0000 (12:49 -0400)]
net: unskip TestUDPZeroBytePayload on Darwin

From information we have available in the issue, this test was flaky
on OS X 10.10 but not newer. By now macOS 11 is the minimum required
version, and 1000 local runs of the test passed, so try to unskip as
the next step.

For #29225.

Change-Id: I18a24459f01e53ef9de05b50d1dd8786d0683107
Cq-Include-Trybots: luci.golang.try:gotip-darwin-amd64_11,gotip-darwin-amd64_14
Reviewed-on: https://go-review.googlesource.com/c/go/+/601395
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agocmd/compile, reflect: treat abi.NoEscape as cheap call
Cuong Manh Le [Fri, 26 Jul 2024 11:09:57 +0000 (18:09 +0700)]
cmd/compile, reflect: treat abi.NoEscape as cheap call

The abi.NoEscape function is introduced to replace all usages of
noescape wrapper in the standard library. However, the last usage in
reflect package is still present, because the inlining test failed if
abi.NoEscape were used. The reason is that reflect.noescape is treated
as a cheap call, while abi.NoEscape is not.

By treating abi.NoEscape a cheap call, the last usage of noescape in
reflect package can now be removed.

Change-Id: I798079780129221a5a26cbcb18c95ee30855b784
Reviewed-on: https://go-review.googlesource.com/c/go/+/601275
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agogo/internal/gcimporter: cleanup test code pre Unified IR
Cuong Manh Le [Wed, 24 Jul 2024 08:22:09 +0000 (15:22 +0700)]
go/internal/gcimporter: cleanup test code pre Unified IR

Same as CL 543315 did for cmd/compile.

Change-Id: I56a200664c92fe34d4b78c2dbf6ed56288e89e0e
Reviewed-on: https://go-review.googlesource.com/c/go/+/600675
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
9 months agocmd/compile: cleanup test code pre Unified IR
Cuong Manh Le [Fri, 17 Nov 2023 11:23:21 +0000 (18:23 +0700)]
cmd/compile: cleanup test code pre Unified IR

Change-Id: Ibb9a7ce37ac28873aa720a64d1f89cb87fc5fa27
Reviewed-on: https://go-review.googlesource.com/c/go/+/543315
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

9 months agotypes2, go/types: fix instantiation of named type with generic alias
Cuong Manh Le [Thu, 25 Jul 2024 10:17:44 +0000 (17:17 +0700)]
types2, go/types: fix instantiation of named type with generic alias

The typechecker is assuming that alias instances cannot be reached from
a named type. However, when type parameters on aliases are permited, it
can happen.

This CL changes the typechecker to propagate the correct named instance
is being expanded.

Updates #46477
Fixes #68580

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

9 months agocmd/compile/internal/types: fix typo in comment
HeGaoYuan [Thu, 25 Jul 2024 22:21:52 +0000 (22:21 +0000)]
cmd/compile/internal/types: fix typo in comment

Change-Id: Iacf22578338c8aa99587826a8342e1da6dc166a6
GitHub-Last-Rev: cdb3235e8ca932776ddf803621ac203c493bc873
GitHub-Pull-Request: golang/go#46598
Reviewed-on: https://go-review.googlesource.com/c/go/+/325510
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
9 months agoencoding/gob: fix package doc typo for wireType
Chen Su [Thu, 25 Jul 2024 07:30:24 +0000 (07:30 +0000)]
encoding/gob: fix package doc typo for wireType

Change-Id: Ib93f2b565e5271dfa3c3ca5d040ef24269c47cf8
GitHub-Last-Rev: 3f1da518a404f5459e38f34427ae9177fe68f51e
GitHub-Pull-Request: golang/go#68584
Reviewed-on: https://go-review.googlesource.com/c/go/+/601036
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agoruntime: allow the tracer to be reentrant
Michael Anthony Knyszek [Wed, 22 May 2024 21:46:29 +0000 (21:46 +0000)]
runtime: allow the tracer to be reentrant

This change allows the tracer to be reentrant by restructuring the
internals such that writing an event is atomic with respect to stack
growth. Essentially, a core set of functions that are involved in
acquiring a trace buffer and writing to it are all marked nosplit.

Stack growth is currently the only hidden place where the tracer may be
accidentally reentrant, preventing the tracer from being used
everywhere. It already lacks write barriers, lacks allocations, and is
non-preemptible. This change thus makes the tracer fully reentrant,
since the only reentry case it needs to handle is stack growth.

Since the invariants needed to attain this are subtle, this change also
extends the debugTraceReentrancy debug mode to check these invariants as
well. Specifically, the invariants are checked by setting the throwsplit
flag.

A side benefit of this change is it simplifies the trace event writing
API a good bit: there's no need to actually thread the event writer
through things, and most callsites look a bit simpler.

Change-Id: I7c329fb7a6cb936bd363c44cf882ea0a925132f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/587599
Reviewed-by: Austin Clements <austin@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoarchive: use slices and maps to clean up tests
apocelipes [Wed, 24 Jul 2024 10:24:16 +0000 (10:24 +0000)]
archive: use slices and maps to clean up tests

Replace reflect.DeepEqual with slices.Equal/maps.Equal, which is
much faster.

Clean up some unnecessary helper functions.

Change-Id: I9b94bd43886302b9b327539ab065a435ce0d75d9
GitHub-Last-Rev: b9ca21f165bcc5e45733e6a511a2344b1aa4a281
GitHub-Pull-Request: golang/go#67607
Reviewed-on: https://go-review.googlesource.com/c/go/+/587936
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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
9 months agoencoding: use slices and maps to clean up tests
apocelipes [Wed, 24 Jul 2024 10:32:38 +0000 (10:32 +0000)]
encoding: use slices and maps to clean up tests

Replace reflect.DeepEqual with slices.Equal/maps.Equal, which is
much faster.

Change-Id: I62ad60a66e28cfb2bb49c36037bafd4b9d201e88
GitHub-Last-Rev: 79554baddb1856260a44ba6587c205d223a527b1
GitHub-Pull-Request: golang/go#67611
Reviewed-on: https://go-review.googlesource.com/c/go/+/587818
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agoos,path/filepath,testing: use slices to clean up tests
apocelipes [Wed, 24 Jul 2024 10:47:14 +0000 (10:47 +0000)]
os,path/filepath,testing: use slices to clean up tests

Replace reflect.DeepEqual with slices.Equal which is much faster.

Change-Id: I299db6f998738174983731f08c1021346b87dfaa
GitHub-Last-Rev: 44ca9015d6af4e0fbe8d23c93b3f2da08a2d7728
GitHub-Pull-Request: golang/go#67613
Reviewed-on: https://go-review.googlesource.com/c/go/+/587938
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>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agoruntime: use slices and maps to clean up tests
apocelipes [Wed, 24 Jul 2024 10:24:06 +0000 (10:24 +0000)]
runtime: use slices and maps to clean up tests

Replace reflect.DeepEqual with slices.Equal/maps.Equal, which is
much faster.

Also remove some unecessary helper functions.

Change-Id: I3e4fa2938fed1598278c9e556cd4fa3b9ed3ad6d
GitHub-Last-Rev: 69bb43fc6e5c4a4a7d028528fe00b43db784464e
GitHub-Pull-Request: golang/go#67603
Reviewed-on: https://go-review.googlesource.com/c/go/+/587815
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agogo,internal,io,mime: use slices and maps to clean tests
apocelipes [Wed, 24 Jul 2024 10:39:58 +0000 (10:39 +0000)]
go,internal,io,mime: use slices and maps to clean tests

Replace reflect.DeepEqual with slices.Equal/maps.Equal, which is
much faster.

Change-Id: Id9cb550884da817da96befdeccfecb3325fb4414
GitHub-Last-Rev: 7d64d78feb86e3ea1af6c24ea6782cb85731bb52
GitHub-Pull-Request: golang/go#67612
Reviewed-on: https://go-review.googlesource.com/c/go/+/587819
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agonet: use slices and maps to clean up tests
apocelipes [Wed, 24 Jul 2024 10:39:48 +0000 (10:39 +0000)]
net: use slices and maps to clean up tests

Replace reflect.DeepEqual with slices.Equal/maps.Equal, which is
much faster.

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

9 months agodoc/next: use relative link to Go issue
Dmitri Shuralyov [Wed, 24 Jul 2024 17:30:28 +0000 (13:30 -0400)]
doc/next: use relative link to Go issue

The Go release notes are served on multiple domains (go.dev,
golang.google.cn, tip.golang.org, localhost:8080 and so on), so links
pointing to the Go website itself need to be relative to work in all
those contexts.

Caught by a test in x/website. The next CL adds the same test to this
repository so these kinds of problems are caught sooner and with less
friction.

For #68545.
Fixes #68575.

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

9 months agointernal/cpu: add DIT detection on arm64
Roland Shoemaker [Mon, 15 Jul 2024 17:04:42 +0000 (10:04 -0700)]
internal/cpu: add DIT detection on arm64

Add support for detecting the DIT feature on ARM64 processors. This
mirrors https://go.dev/cl/597377, but using the platform specific
semantics.

Updates #66450

Change-Id: Ia107e3e3369de7825af70823b485afe2f587358e
Reviewed-on: https://go-review.googlesource.com/c/go/+/598335
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agocmd/internal/obj/arm64: support MSR DIT
Roland Shoemaker [Wed, 10 Jul 2024 22:02:34 +0000 (17:02 -0500)]
cmd/internal/obj/arm64: support MSR DIT

Set the right instruction bits in asmout in order
to allow using MSR with DIT and an immediate
value. This allows us to avoid using an
intermediary register when we want to set DIT
(unsetting DIT already worked with the zero
register).

Ref: https://developer.arm.com/documentation/ddi0602/2024-06/Base-Instructions/MSR--immediate---Move-immediate-value-to-special-register-?lang=en
Change-Id: Id049a0b4e0feb534cea992553228f9b5e12ddcea
Reviewed-on: https://go-review.googlesource.com/c/go/+/597595
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agobytes,strings,unicode/utf16: use slices to clean up tests
apocelipes [Wed, 24 Jul 2024 10:32:22 +0000 (10:32 +0000)]
bytes,strings,unicode/utf16: use slices to clean up tests

Replace reflect.DeepEqual with slices.Equal, which is much faster.
Remove some redundant helper functions.

Change-Id: I51b32a3d0c3fc5ad0d3b6ff0dd03f39c507e5762
GitHub-Last-Rev: e21f46d4a026b6bf6e8d912dfb8d361a20a4e779
GitHub-Pull-Request: golang/go#67609
Reviewed-on: https://go-review.googlesource.com/c/go/+/587937
Reviewed-by: Ian Lance Taylor <iant@google.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: Robert Griesemer <gri@google.com>
9 months agoos: document CopyFS behavior for symlinks in destination
Damien Neil [Wed, 24 Jul 2024 17:29:13 +0000 (10:29 -0700)]
os: document CopyFS behavior for symlinks in destination

Also clarify the permissions of created files,
and note that CopyFS will not overwrite files.

Update a few places in documentation to use 0oXXX for octal consts.

For #62484

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

9 months agocrypto/x509,embed: use slices to clean up tests
apocelipes [Wed, 24 Jul 2024 10:32:31 +0000 (10:32 +0000)]
crypto/x509,embed: use slices to clean up tests

Replace reflect.DeepEqual with slices.Equal, which is much faster.

Change-Id: Ia93cc153d1f71ce92656129843be8dadcefbbca3
GitHub-Last-Rev: 0af0cc4205f51b31780ca2cbefe780e7256b1188
GitHub-Pull-Request: golang/go#67610
Reviewed-on: https://go-review.googlesource.com/c/go/+/587817
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Commit-Queue: 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>

9 months agocmd/compile: fix typo in comment
guoguangwu [Wed, 24 Jul 2024 06:55:35 +0000 (06:55 +0000)]
cmd/compile: fix typo in comment

Change-Id: Ied098312399d2d6557ebf0ee294ca0e71dfa677b
GitHub-Last-Rev: 82f914e85756728976646b490223352059c1953a
GitHub-Pull-Request: golang/go#68565
Reviewed-on: https://go-review.googlesource.com/c/go/+/600655
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: Dmitri Shuralyov <dmitshur@google.com>
9 months agointernal/trace/event: fix typo in comment
Koichi Shiraishi [Fri, 31 May 2024 01:33:13 +0000 (10:33 +0900)]
internal/trace/event: fix typo in comment

Change-Id: Ia191daf8e748f17dcea6038166504fb50e7ddb0d
Reviewed-on: https://go-review.googlesource.com/c/go/+/589535
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agoregexp: allow patterns with no alternates to be one-pass
Bryan Boreham [Mon, 27 May 2024 16:55:02 +0000 (16:55 +0000)]
regexp: allow patterns with no alternates to be one-pass

Check whether a regex has any 'alt' instructions before rejecting it as one-pass.
Previously `^abc` would run the backtrack matcher.

I tried to make the comment match what the code does now.

Updates #21463

```
name                            old time/op    new time/op    delta
Find-8                             167ns ± 1%     170ns ± 3%     ~     (p=0.500 n=5+5)
FindAllNoMatches-8                88.8ns ± 5%    87.3ns ± 0%     ~     (p=0.095 n=5+5)
FindString-8                       166ns ± 3%     164ns ± 0%     ~     (p=0.063 n=5+5)
FindSubmatch-8                     191ns ± 1%     191ns ± 0%     ~     (p=0.556 n=4+5)
FindStringSubmatch-8               183ns ± 0%     182ns ± 0%   -0.43%  (p=0.048 n=5+5)
Literal-8                         50.3ns ± 0%    50.1ns ± 0%   -0.40%  (p=0.016 n=5+4)
NotLiteral-8                       914ns ± 0%     927ns ± 7%     ~     (p=0.730 n=5+5)
MatchClass-8                      1.20µs ± 1%    1.22µs ± 6%     ~     (p=0.738 n=5+5)
MatchClass_InRange-8              1.20µs ± 6%    1.21µs ± 6%     ~     (p=0.548 n=5+5)
ReplaceAll-8                       796ns ± 0%     792ns ± 0%   -0.51%  (p=0.032 n=5+5)
AnchoredLiteralShortNonMatch-8    41.0ns ± 2%    34.2ns ± 2%  -16.47%  (p=0.008 n=5+5)
AnchoredLiteralLongNonMatch-8     53.3ns ± 0%    34.3ns ± 3%  -35.74%  (p=0.008 n=5+5)
AnchoredShortMatch-8              74.0ns ± 2%    75.8ns ± 0%   +2.46%  (p=0.032 n=5+4)
AnchoredLongMatch-8                146ns ± 3%      76ns ± 1%  -48.12%  (p=0.008 n=5+5)
OnePassShortA-8                    424ns ± 0%     423ns ± 0%     ~     (p=0.222 n=5+4)
NotOnePassShortA-8                 373ns ± 1%     375ns ± 2%     ~     (p=0.690 n=5+5)
OnePassShortB-8                    315ns ± 2%     308ns ± 0%   -2.12%  (p=0.008 n=5+5)
NotOnePassShortB-8                 244ns ± 3%     239ns ± 0%     ~     (p=0.476 n=5+5)
OnePassLongPrefix-8               61.6ns ± 2%    60.9ns ± 0%   -1.13%  (p=0.016 n=5+4)
OnePassLongNotPrefix-8             236ns ± 3%     230ns ± 0%     ~     (p=0.143 n=5+5)
```

Change-Id: I8a94b53bc761cd7ec89923c905ec8baaaa58a5fd
GitHub-Last-Rev: e9e0c29b7448c8ab7cb203c1ed58766dc5d91456
GitHub-Pull-Request: golang/go#48748
Reviewed-on: https://go-review.googlesource.com/c/go/+/353711
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Russ Cox <rsc@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agoencoding/json: rewrite interface{} to any
Ian Lance Taylor [Fri, 24 May 2024 03:50:25 +0000 (20:50 -0700)]
encoding/json: rewrite interface{} to any

For #49884

Change-Id: I1623201c47c820a152773d2f43d0072a1466d3bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/588118
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

9 months agotest: add test cases for local not-in-heap types
Cuong Manh Le [Thu, 11 Jul 2024 06:32:27 +0000 (13:32 +0700)]
test: add test cases for local not-in-heap types

Follow up review in CL 597535.

Updates #54846

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

9 months agotest: re-enabled fixedbugs/notinheap.go test
Cuong Manh Le [Wed, 10 Jul 2024 17:14:33 +0000 (00:14 +0700)]
test: re-enabled fixedbugs/notinheap.go test

By using cgo.Incomplete to represent not-in-heap type.

While at it, also removing the type conversions tests, since they could
not be present without //go:notinheap pragma.

Fixes #54846

Change-Id: I5ee2a4b6498d4100c9770ed7bd62f52623e42526
Reviewed-on: https://go-review.googlesource.com/c/go/+/597536
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>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

9 months agocmd/compile: restore not-in-heap check for map/channel type
Cuong Manh Le [Wed, 10 Jul 2024 17:00:32 +0000 (00:00 +0700)]
cmd/compile: restore not-in-heap check for map/channel type

CL 388538 removed unused -G=0 node types.

However, the code for checking not-in-heap types for map and channel
type was also removed, which is likely not intentional.

This CL restores the check, porting removed code to noder.

Updates #54846

Change-Id: I2995836b90e36d2684197fefc9829fddfffe8585
Reviewed-on: https://go-review.googlesource.com/c/go/+/597535
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocmd/compile: run checkbce after fuseLate pass
Cuong Manh Le [Tue, 16 Jul 2024 16:56:56 +0000 (23:56 +0700)]
cmd/compile: run checkbce after fuseLate pass

So the bounds check which are eliminated during late fuse pass could be
detected correctly.

Fixes #67329

Change-Id: Id7992fbb8c26e0d43e7db66a0a3a2c0d9ed937a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/598635
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile: prevent un-necessary wrapping in switch statement
Cuong Manh Le [Wed, 3 Jul 2024 17:17:05 +0000 (00:17 +0700)]
cmd/compile: prevent un-necessary wrapping in switch statement

Follow up discussion in CL 594575.

The wrapping in "any" is only necessary if either casType or tagType is
an interface, as "==" in this situation is implemented by upconverting
to an interface anyway.

Change-Id: I73da771d25685a23eec612ac696965c892db4764
Reviewed-on: https://go-review.googlesource.com/c/go/+/596555
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocmd/pprof: update vendored github.com/google/pprof
Dmitri Shuralyov [Tue, 23 Jul 2024 21:38:32 +0000 (17:38 -0400)]
cmd/pprof: update vendored github.com/google/pprof

Pull in the latest published version of github.com/google/pprof
as part of the continuous process of keeping Go's dependencies
up to date.

For #36905.

[git-generate]
cd src/cmd
go get github.com/google/pprof@v0.0.0-20240722153945-304e4f0156b8
go mod tidy
go mod vendor

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

9 months agocmd/go: fix TestNewReleaseRebuildsStalePackagesInGOPATH for runtime move
Dmitri Shuralyov [Tue, 23 Jul 2024 22:03:24 +0000 (18:03 -0400)]
cmd/go: fix TestNewReleaseRebuildsStalePackagesInGOPATH for runtime move

CL 600436 moved runtime/internal/sys to internal/runtime/sys and updated
TestNewReleaseRebuildsStalePackagesInGOPATH in part accordingly. This is
the other part that's needed for it to pass.

For #65355.

Change-Id: I26cff96c15caf185a4ee2c8fb31ec6c877ab87e2
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/600595
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
9 months agocmd/compile: make sync/atomic AND/OR operations intrinsic on amd64
Keith Randall [Tue, 25 Jun 2024 21:56:11 +0000 (14:56 -0700)]
cmd/compile: make sync/atomic AND/OR operations intrinsic on amd64

Update #61395

Change-Id: I59a950f48efc587dfdffce00e2f4f3ab99d8df00
Reviewed-on: https://go-review.googlesource.com/c/go/+/594738
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
9 months agocmd/compile: fix typing of atomic logical operations
Keith Randall [Tue, 25 Jun 2024 21:01:09 +0000 (14:01 -0700)]
cmd/compile: fix typing of atomic logical operations

For atomic AND and OR operations on memory, we currently have two
views of the op. One just does the operation on the memory and returns
just a memory. The other does the operation on the memory and returns
the old value (before having the logical operation done to it) and
memory.

Update #61395

These two type differently, and there's currently some confusion in
our rules about which is which. Use different names for the two
different flavors so we don't get them confused.

Change-Id: I07b4542db672b2cee98169ac42b67db73c482093
Reviewed-on: https://go-review.googlesource.com/c/go/+/594976
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Nicolas Hillegeer <aktau@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocmd/cgo: error on multiple incompatible function declarations
Keith Randall [Thu, 30 May 2024 02:37:43 +0000 (19:37 -0700)]
cmd/cgo: error on multiple incompatible function declarations

When there are multiple declarations of a function, ensure that
those declarations at least agree on the size/alignment of arguments
and return values.

It's hard to be stricter given existing code and situations where
arguments differ only by typedefs. For instance:
    int usleep(unsigned);
    int usleep(useconds_t);

Fixes #67699.

Change-Id: I3b4b17afee92b55f9e712b4590ec608ab1f7ac91
Reviewed-on: https://go-review.googlesource.com/c/go/+/588977
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agocmd/compile: don't treat an InlMark as a read during deadstore
Keith Randall [Thu, 13 Jun 2024 03:24:44 +0000 (20:24 -0700)]
cmd/compile: don't treat an InlMark as a read during deadstore

An InlMark "read" can't make an otherwise dead store live. Without this
CL, we sometimes zero an object twice in succession because we think
there is a reader in between.

Kind of challenging to make a test for this. The second zeroing has the
same instruction on the same line number, so codegen tests can't see it.

Fixes #67957

Change-Id: I7fb97ebff50d8eb6246fc4802d1136b7cc76c45f
Reviewed-on: https://go-review.googlesource.com/c/go/+/592615
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocmd/compile: store constant floats using integer constants
Keith Randall [Thu, 13 Jun 2024 01:25:55 +0000 (18:25 -0700)]
cmd/compile: store constant floats using integer constants

x86 is better at storing constant ints than constant floats.
(It uses a constant directly in the instruction stream, instead of
loading it from a constant global memory.)

Noticed as part of #67957

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