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

9 months agocmd/compile/internal/types2: use ReplaceAll in *Context.instanceHash
Jes Cok [Mon, 28 Aug 2023 05:24:44 +0000 (05:24 +0000)]
cmd/compile/internal/types2: use ReplaceAll in *Context.instanceHash

strings.ReplaceAll is currently available.

Change-Id: I5e03ed43be123f9091a4e3b6bf05ffae8fb0d59b
GitHub-Last-Rev: 2cccdd0305fc709c8acfbb00eab744b28ca0c8fc
GitHub-Pull-Request: golang/go#62307
Reviewed-on: https://go-review.googlesource.com/c/go/+/523298
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
9 months agocmd/compile/internal/liveness: remove repetitive word
cui fliter [Sat, 26 Aug 2023 15:07:27 +0000 (23:07 +0800)]
cmd/compile/internal/liveness: remove repetitive word

Change-Id: I27789840d92cc2c1e799db5b58e1eb1570e264df
Reviewed-on: https://go-review.googlesource.com/c/go/+/523235
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Run-TryBot: shuang cui <imcusg@gmail.com>

9 months agocrypto/internal/edwards25519: shorten quick.Check tests in short mode
Bryan C. Mills [Thu, 24 Aug 2023 18:40:14 +0000 (14:40 -0400)]
crypto/internal/edwards25519: shorten quick.Check tests in short mode

The edwards25519 tests can be quite slow on platforms without a
well-optimized implementation, especially if the race detector is also
enabled. Since these tests aren't checking for specific inputs anyway,
the extra coverage of a more aggressive quick.Config does not seem
worth wasting extra time on slow CI builders and TryBots.

For #60109.

Change-Id: I530e75a0b76725585df5a2f5ded6705ab1b9da51
Reviewed-on: https://go-review.googlesource.com/c/go/+/522715
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
9 months agocmd/compile: use shorter ANDL/TESTL if upper 32 bits are known to be zero
Jakub Ciolek [Fri, 25 Aug 2023 09:02:01 +0000 (11:02 +0200)]
cmd/compile: use shorter ANDL/TESTL if upper 32 bits are known to be zero

compilecmp linux/amd64:

math/bits
math/bits.Div32 122 -> 121  (-0.82%)
math/bits.Rem32 39 -> 38  (-2.56%)

math/bits [cmd/compile]
math/bits.Rem32 39 -> 38  (-2.56%)
math/bits.Div32 122 -> 121  (-0.82%)

runtime
runtime.funcMaxSPDelta 296 -> 294  (-0.68%)
runtime.dumpGCProg 677 -> 666  (-1.62%)
runtime.(*itabTableType).find 66 -> 65  (-1.52%)
runtime.(*itabTableType).add 71 -> 70  (-1.41%)
runtime.funpack32 122 -> 121  (-0.82%)

vendor/golang.org/x/net/dns/dnsmessage
vendor/golang.org/x/net/dns/dnsmessage.(*Message).pack 211 -> 200  (-5.21%)
vendor/golang.org/x/net/dns/dnsmessage.(*Header).pack 163 -> 161  (-1.23%)
vendor/golang.org/x/net/dns/dnsmessage.NewBuilder 589 -> 581  (-1.36%)

runtime [cmd/compile]
runtime.dumpGCProg 677 -> 666  (-1.62%)
runtime.funpack32 122 -> 121  (-0.82%)
runtime.(*itabTableType).add 71 -> 70  (-1.41%)
runtime.(*itabTableType).find 66 -> 65  (-1.52%)

internal/types/errors
internal/types/errors.Code.String 666 -> 634  (-4.80%)

internal/types/errors [cmd/compile]
internal/types/errors.Code.String 666 -> 634  (-4.80%)

debug/gosym
debug/gosym.(*LineTable).stringFrom 436 -> 435  (-0.23%)

debug/dwarf
debug/dwarf.Class.String 186 -> 175  (-5.91%)

vendor/golang.org/x/text/unicode/norm
vendor/golang.org/x/text/unicode/norm.(*reorderBuffer).runeAt 181 -> 180  (-0.55%)
vendor/golang.org/x/text/unicode/norm.(*reorderBuffer).assignRune 222 -> 221  (-0.45%)

debug/macho
debug/macho.RelocTypeARM64.String 186 -> 175  (-5.91%)
debug/macho.RelocTypeGeneric.String 186 -> 175  (-5.91%)
debug/macho.RelocTypeX86_64.String 186 -> 175  (-5.91%)
debug/macho.RelocTypeARM.String 186 -> 175  (-5.91%)

internal/xcoff
internal/xcoff.getString 173 -> 172  (-0.58%)

debug/pe
debug/pe.StringTable.String 278 -> 277  (-0.36%)

math/big
math/big.(*Int).Int64 35 -> 34  (-2.86%)
math/big.(*Float).ord 57 -> 56  (-1.75%)
math/big.Accuracy.String 219 -> 217  (-0.91%)
math/big.(*Int).Cmp 153 -> 152  (-0.65%)

go/constant
go/constant.makeInt 155 -> 154  (-0.65%)

archive/tar
archive/tar.(*Reader).readHeader.func2 51 -> 50  (-1.96%)

crypto/rsa
crypto/rsa.VerifyPKCS1v15 1288 -> 1285  (-0.23%)
crypto/rsa.decryptPKCS1v15 495 -> 493  (-0.40%)

vendor/golang.org/x/net/idna
vendor/golang.org/x/net/idna.(*Profile).simplify 114 -> 113  (-0.88%)
vendor/golang.org/x/net/idna.validateFromPunycode 607 -> 591  (-2.64%)

encoding/asn1
encoding/asn1.parseBitString 298 -> 297  (-0.34%)

log/slog
log/slog.TextHandler.attrSep 57 -> 56  (-1.75%)
log/slog.(*handleState).appendKey 747 -> 746  (-0.13%)
log/slog.JSONHandler.attrSep 57 -> 56  (-1.75%)
log/slog.(*TextHandler).attrSep 59 -> 58  (-1.69%)
log/slog.(*JSONHandler).attrSep 59 -> 58  (-1.69%)

cmd/internal/objabi
cmd/internal/objabi.SymKind.String 219 -> 207  (-5.48%)

vendor/golang.org/x/crypto/cryptobyte
vendor/golang.org/x/crypto/cryptobyte.(*String).readLengthPrefixed 315 -> 313  (-0.63%)

cmd/internal/goobj
cmd/internal/goobj.(*FuncInfo).ReadInlTree 216 -> 215  (-0.46%)
cmd/internal/goobj.(*Reader).BytesAt 96 -> 95  (-1.04%)

html/template
html/template.state.String 219 -> 207  (-5.48%)

cmd/internal/obj
cmd/internal/obj.AddrType.String 219 -> 207  (-5.48%)

go/build
go/build.(*Context).importGo 4511 -> 4505  (-0.13%)

cmd/internal/gcprog
cmd/internal/gcprog.progbits 569 -> 549  (-3.51%)

cmd/compile/internal/base
cmd/compile/internal/base.PkgLinksym 373 -> 367  (-1.61%)

cmd/cgo
main.(*Package).writeDefsFunc 6117 -> 6085  (-0.52%)

cmd/compile/internal/types
cmd/compile/internal/types.Kind.String 219 -> 207  (-5.48%)
cmd/compile/internal/types.AlgKind.String 207 -> 201  (-2.90%)

cmd/internal/gcprog [cmd/compile]
cmd/internal/gcprog.progbits 569 -> 549  (-3.51%)

crypto/tls
crypto/tls.CurveID.String 273 -> 265  (-2.93%)

cmd/internal/objabi [cmd/compile]
cmd/internal/objabi.SymKind.String 219 -> 207  (-5.48%)

cmd/internal/goobj [cmd/compile]
cmd/internal/goobj.(*FuncInfo).ReadInlTree 216 -> 215  (-0.46%)
cmd/internal/goobj.(*Reader).BytesAt 96 -> 95  (-1.04%)

math/big [cmd/compile]
math/big.(*Float).ord 57 -> 56  (-1.75%)
math/big.(*Int).Cmp 153 -> 152  (-0.65%)
math/big.(*Int).Int64 35 -> 34  (-2.86%)
math/big.Accuracy.String 219 -> 217  (-0.91%)

go/constant [cmd/compile]
go/constant.makeInt 155 -> 154  (-0.65%)

cmd/internal/obj [cmd/compile]
cmd/internal/obj.AddrType.String 219 -> 207  (-5.48%)

cmd/link/internal/sym
cmd/link/internal/sym.SymKind.String 219 -> 207  (-5.48%)

cmd/compile/internal/base [cmd/compile]
cmd/compile/internal/base.PkgLinksym 317 -> 315  (-0.63%)

go/build [cmd/compile]
go/build.(*Context).importGo 4511 -> 4505  (-0.13%)

cmd/go/internal/script
cmd/go/internal/script.(*Engine).ListCmds 1269 -> 1263  (-0.47%)

cmd/go/internal/modindex
cmd/go/internal/modindex.fromBytes 1206 -> 1199  (-0.58%)
cmd/go/internal/modindex.(*decoder).boolAt 212 -> 201  (-5.19%)
cmd/go/internal/modindex.(*reader).bool 229 -> 218  (-4.80%)

cmd/link/internal/loader
cmd/link/internal/loader.(*FuncInfo).File 142 -> 141  (-0.70%)

cmd/compile/internal/types [cmd/compile]
cmd/compile/internal/types.Kind.String 219 -> 207  (-5.48%)
cmd/compile/internal/types.(*Sym).LinksymABI 333 -> 332  (-0.30%)
cmd/compile/internal/types.AlgKind.String 207 -> 201  (-2.90%)

cmd/link/internal/loadmacho
cmd/link/internal/loadmacho.macholoadsym 1243 -> 1236  (-0.56%)

cmd/vendor/golang.org/x/sys/unix
cmd/vendor/golang.org/x/sys/unix.(*FileHandle).Bytes 80 -> 79  (-1.25%)
cmd/vendor/golang.org/x/sys/unix.Mkdev 54 -> 52  (-3.70%)

cmd/go/internal/work
cmd/go/internal/work.(*Builder).printLinkerConfig 1865 -> 1864  (-0.05%)

cmd/go/internal/run
cmd/go/internal/run.runRun 3197 -> 3182  (-0.47%)

cmd/compile/internal/ssa [cmd/compile]
cmd/compile/internal/ssa.rewriteValueAMD64 21221 -> 19514  (-8.04%)

file                                       before   after    Δ       %
math/bits.s                                2373     2371     -2      -0.084%
math/bits [cmd/compile].s                  2373     2371     -2      -0.084%
runtime.s                                  520472   520467   -5      -0.001%
vendor/golang.org/x/net/dns/dnsmessage.s   74378    74357    -21     -0.028%
runtime [cmd/compile].s                    582206   582203   -3      -0.001%
internal/types/errors.s                    750      718      -32     -4.267%
internal/types/errors [cmd/compile].s      750      718      -32     -4.267%
debug/gosym.s                              34742    34741    -1      -0.003%
debug/dwarf.s                              113249   113238   -11     -0.010%
vendor/golang.org/x/text/unicode/norm.s    62802    62800    -2      -0.003%
debug/macho.s                              29021    28977    -44     -0.152%
internal/xcoff.s                           17911    17910    -1      -0.006%
debug/pe.s                                 23421    23420    -1      -0.004%
math/big.s                                 163522   163517   -5      -0.003%
go/constant.s                              28512    28511    -1      -0.004%
archive/tar.s                              58377    58376    -1      -0.002%
crypto/rsa.s                               26261    26256    -5      -0.019%
vendor/golang.org/x/net/idna.s             21342    21325    -17     -0.080%
encoding/asn1.s                            45357    45356    -1      -0.002%
log/slog.s                                 78618    78613    -5      -0.006%
cmd/internal/objabi.s                      15878    15866    -12     -0.076%
vendor/golang.org/x/crypto/cryptobyte.s    30577    30575    -2      -0.007%
cmd/internal/goobj.s                       11515    11513    -2      -0.017%
html/template.s                            87816    87804    -12     -0.014%
cmd/internal/obj.s                         124786   124774   -12     -0.010%
go/build.s                                 67665    67659    -6      -0.009%
cmd/internal/gcprog.s                      5856     5836     -20     -0.342%
cmd/compile/internal/base.s                41802    41796    -6      -0.014%
cmd/internal/obj/arm64.s                   144141   144172   +31     +0.022%
cmd/cgo.s                                  197681   197649   -32     -0.016%
cmd/compile/internal/types.s               62811    62793    -18     -0.029%
cmd/internal/gcprog [cmd/compile].s        5856     5836     -20     -0.342%
crypto/tls.s                               318862   318854   -8      -0.003%
cmd/internal/objabi [cmd/compile].s        15887    15875    -12     -0.076%
cmd/internal/goobj [cmd/compile].s         11596    11594    -2      -0.017%
math/big [cmd/compile].s                   165178   165173   -5      -0.003%
go/constant [cmd/compile].s                29743    29742    -1      -0.003%
cmd/internal/obj [cmd/compile].s           165646   165634   -12     -0.007%
cmd/link/internal/sym.s                    1829     1817     -12     -0.656%
cmd/compile/internal/base [cmd/compile].s  41937    41935    -2      -0.005%
go/build [cmd/compile].s                   67601    67595    -6      -0.009%
cmd/go/internal/script.s                   79959    79953    -6      -0.008%
cmd/go/internal/modindex.s                 85936    85907    -29     -0.034%
cmd/internal/obj/arm64 [cmd/compile].s     144090   144121   +31     +0.022%
cmd/link/internal/loader.s                 77864    77863    -1      -0.001%
cmd/compile/internal/types [cmd/compile].s 76072    76053    -19     -0.025%
cmd/link/internal/loadmacho.s              20367    20360    -7      -0.034%
cmd/vendor/golang.org/x/sys/unix.s         118027   118024   -3      -0.003%
cmd/go/internal/work.s                     285265   285264   -1      -0.000%
cmd/go/internal/run.s                      4758     4743     -15     -0.315%
cmd/compile/internal/ssa.s                 3191919  3192241  +322    +0.010%
cmd/compile/internal/ssa [cmd/compile].s   3362994  3361609  -1385   -0.041%
total                                      30756856 30755380 -1476   -0.005%

Change-Id: Ia259c87216af6ff67efe33c7d39f3dbde7f37a43
Reviewed-on: https://go-review.googlesource.com/c/go/+/522975
Auto-Submit: Keith Randall <khr@golang.org>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
9 months agonet/http: document setting of Proxy-Authorization header
Damien Neil [Mon, 24 Jul 2023 15:24:40 +0000 (11:24 -0400)]
net/http: document setting of Proxy-Authorization header

Add a test for setting a proxy username/password in
the HTTP_PROXY environment variable as well.

Fixes #61505

Change-Id: I31c3fa94c7bc463133321e9af9289fd47da75b46
Reviewed-on: https://go-review.googlesource.com/c/go/+/512555
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/cgo/internal/test: benchmark for #cgo noescape directive
doujiang24 [Sat, 26 Aug 2023 04:49:53 +0000 (04:49 +0000)]
cmd/cgo/internal/test: benchmark for #cgo noescape directive

case: passing a single Go string object to C function.
result: 87 ns vs 61 ns.

BenchmarkCgoCall/string-pointer-escape
BenchmarkCgoCall/string-pointer-escape-12        67731663   87.02 ns/op
BenchmarkCgoCall/string-pointer-noescape
BenchmarkCgoCall/string-pointer-noescape-12    99424776   61.30 ns/op

For #56378

Change-Id: Iff5c69d8deedfa248f5d7399e1921a5cb0dc8b16
GitHub-Last-Rev: fc67d5ad7a1ba56025f2c142bb88cc4174fa3a27
GitHub-Pull-Request: golang/go#62297
Reviewed-on: https://go-review.googlesource.com/c/go/+/522939
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agogo/scanner: give specific error for curvy “abc” quotes
Alan Donovan [Tue, 25 Jul 2023 11:47:05 +0000 (12:47 +0100)]
go/scanner: give specific error for curvy “abc” quotes

Code examples sometimes mistakenly use curvy quotes,
leading to hard-to-spot invalid token errors.
This change makes the error message explicit.

(An alternative change would be to accept them in place
of "abc" and emit an error, but the extra check would
likely add an unacceptable dynamic cost to string scanning.)

Fixes #61450

Change-Id: Ie2b18c958c6f8f71a56ac193a94a8d16eea839db
Reviewed-on: https://go-review.googlesource.com/c/go/+/512855
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile/internal/ir: remove redundant not in doc
Jes Cok [Sat, 26 Aug 2023 11:56:38 +0000 (11:56 +0000)]
cmd/compile/internal/ir: remove redundant not in doc

Change-Id: Ia4fc2ceafa92f38742d3a017e37350875fdcc25e
GitHub-Last-Rev: 482f5e4fe626bfe97058ea052324cca68b91263d
GitHub-Pull-Request: golang/go#62299
Reviewed-on: https://go-review.googlesource.com/c/go/+/522940
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/compile: replace floating-pointer with floating-point
Jes Cok [Mon, 28 Aug 2023 11:57:07 +0000 (11:57 +0000)]
cmd/compile: replace floating-pointer with floating-point

Change-Id: I2b1cf35966fec255c6e0ed587f02d035783ab2ad
GitHub-Last-Rev: 3466a67c02613a233f14dbc39a17b9394047efb6
GitHub-Pull-Request: golang/go#62320
Reviewed-on: https://go-review.googlesource.com/c/go/+/523377
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/compile/internal/ir: set Addrtaken on Canonical ONAME too
Matthew Dempsky [Mon, 28 Aug 2023 09:33:06 +0000 (02:33 -0700)]
cmd/compile/internal/ir: set Addrtaken on Canonical ONAME too

In CL 522879, I moved the logic for setting Addrtaken from typecheck's
markAddrOf and ComputeAddrtaken directly into ir.NewAddrExpr. However,
I took the logic from markAddrOf, and failed to notice that
ComputeAddrtaken also set Addrtaken on the canonical ONAME.

The result is that if the only address-of expressions were within a
function literal, the canonical variable never got marked Addrtaken.
In turn, this could cause the consistency check in ir.Reassigned to
fail. (Yay for consistency checks turning mistakes into ICEs, rather
than miscompilation.)

Fixes #62313.

Change-Id: Ieab2854cd7fcc1b6c5d1e61de66453add9890a4f
Reviewed-on: https://go-review.googlesource.com/c/go/+/523375
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agomake.bat: don't try to download a newer toolchain
qmuntal [Fri, 25 Aug 2023 12:29:13 +0000 (14:29 +0200)]
make.bat: don't try to download a newer toolchain

Calling `go env GOROOT` and `go version` will try to download a newer
toolchain if the current one is too old. This is not what we want when
building the toolchain itself. Avoid this by setting `GO111MODULE=off`.

While here, align the unset variables with nogoenv(), present in
make.bash and make.rc.

Fixes #62201
Fixes #62281

Change-Id: I2d3ac817c2fb161f7a31bf83e32ba934e773b6c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/523015
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
9 months agonet: centralize resolver selection logic
Mateusz Poliwczak [Sat, 26 Aug 2023 16:43:17 +0000 (16:43 +0000)]
net: centralize resolver selection logic

This change removes the per GOOS hostLookupOrder wrappers.
passes the correct hostname to hostLookupOrder (windows,
plan9), so that the netdns+2 GODEBUG doesn't show empty
hostnames.

Uses the mustUseGoResolver instead of hostLookupOrder,
hostLookupOrder should only be used for hostname resolution,
not for lookups that do only DNS.

Change-Id: I18bbff06957910ae25c2bc78dfa9a46da76529fd
GitHub-Last-Rev: a27545dc25fffb3a51da9d943ffa9bd1a09182ee
GitHub-Pull-Request: golang/go#61525
Reviewed-on: https://go-review.googlesource.com/c/go/+/512215
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoRevert "net/http/cgi: workaround for closure inlining issue"
Cuong Manh Le [Sat, 26 Aug 2023 01:08:30 +0000 (08:08 +0700)]
Revert "net/http/cgi: workaround for closure inlining issue"

This reverts CL 522935.

Issue #62277 is fixed, the workaround can be dropped.

Updates #62277

Change-Id: I7c69e35248942b4d4fcdd81121051cca9b098980
Reviewed-on: https://go-review.googlesource.com/c/go/+/523175
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/compile: un-hide closure func in init function
Cuong Manh Le [Fri, 25 Aug 2023 08:08:05 +0000 (15:08 +0700)]
cmd/compile: un-hide closure func in init function

Same as CL 492135, but for init function.

Fixes #62277

Change-Id: If5ff9bc2ce2a73193b1f7ee5f7f14045d1354f56
Reviewed-on: https://go-review.googlesource.com/c/go/+/522956
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

9 months agodoc/go1.22: mention new #cgo directives
Ian Lance Taylor [Fri, 25 Aug 2023 23:41:17 +0000 (16:41 -0700)]
doc/go1.22: mention new #cgo directives

For #56378

Change-Id: I0c9c662c6d765cad6f7bf17fdd648db8d73e429b
Reviewed-on: https://go-review.googlesource.com/c/go/+/522937
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agocmd/go: don't set LD_LIBRARY_PATH for SWIG
Ian Lance Taylor [Tue, 22 Aug 2023 22:08:11 +0000 (15:08 -0700)]
cmd/go: don't set LD_LIBRARY_PATH for SWIG

Setting LD_LIBRARY_PATH when running "go test" for a package that uses
SWIG dates back to the initial introduction of SWIG support in
CL 5845071 in 2012. Back then SWIG worked by creating a shared library,
but in CL 6851 in 2015 we changed SWIG to generate cgo input files,
and no shared library was used. Since we no longer use a shared library,
we no longer need to set LD_LIBRARY_PATH.

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

9 months agoruntime, cmd/go: enable memory sanitizer on linux/loong64
Xiaolin Zhao [Fri, 31 Mar 2023 07:36:59 +0000 (15:36 +0800)]
runtime, cmd/go: enable memory sanitizer on linux/loong64

The msan feature depends on llvm. The currently released llvm-16
already supports the LoongArch architecture, and msan's support
for LoongArch64 has been added in this patch[1], and it has been
merged in branches main and release/17.x.

[1]: https://reviews.llvm.org/D140528

Change-Id: If537c5ffb1c9d4b3316b9b3794d411953bc5764b
Reviewed-on: https://go-review.googlesource.com/c/go/+/481315
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>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: WANG Xuerui <git@xen0n.name>

9 months agocrypto/tls: QUIC: fix panics when processing post-handshake messages
Damien Neil [Thu, 24 Aug 2023 16:57:58 +0000 (09:57 -0700)]
crypto/tls: QUIC: fix panics when processing post-handshake messages

The check for fragmentary post-handshake messages in QUICConn.HandleData
was reversed, resulting in a potential panic when HandleData receives
a partial message.

In addition, HandleData wasn't checking the size of buffered
post-handshake messages. Produce an error when a post-handshake
message is larger than maxHandshake.

TestQUICConnectionState was using an onHandleCryptoData hook
in runTestQUICConnection that was never being called.
(I think it was inadvertently removed at some point while
the CL was in review.) Fix this test while making the hook
more general.

Fixes #62266

Change-Id: I210b70634e50beb456ab3977eb11272b8724c241
Reviewed-on: https://go-review.googlesource.com/c/go/+/522595
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Marten Seemann <martenseemann@gmail.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
9 months agonet/http/cgi: workaround for closure inlining issue
Matthew Dempsky [Fri, 25 Aug 2023 06:14:43 +0000 (23:14 -0700)]
net/http/cgi: workaround for closure inlining issue

This is a temporary workaround for issue #62277, to get the longtest
builders passing again. As mentioned on the issue, the underlying
issue was present even before CL 522318; it just now affects inlined
closures in initialization expressions too, not just explicit init
functions.

This CL can and should be reverted once that issue is fixed properly.

Change-Id: I612a501e131d1b5eea648aafeb1a3a3fe8fe8c83
Reviewed-on: https://go-review.googlesource.com/c/go/+/522935
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/cgo: add #cgo noescape/nocallback annotations
doujiang24 [Fri, 25 Aug 2023 17:06:31 +0000 (17:06 +0000)]
cmd/cgo: add #cgo noescape/nocallback annotations

When passing pointers of Go objects from Go to C, the cgo command generate _Cgo_use(pN) for the unsafe.Pointer type arguments, so that the Go compiler will escape these object to heap.

Since the C function may callback to Go, then the Go stack might grow/shrink, that means the pointers that the C function have will be invalid.

After adding the #cgo noescape annotation for a C function, the cgo command won't generate _Cgo_use(pN), and the Go compiler won't force the object escape to heap.

After adding the #cgo nocallback annotation for a C function, which means the C function won't callback to Go, if it do callback to Go, the Go process will crash.

Fixes #56378

Change-Id: Ifdca070584e0d349c7b12276270e50089e481f7a
GitHub-Last-Rev: f1a17b08b0590eca2670e404bbfedad5461df72f
GitHub-Pull-Request: golang/go#60399
Reviewed-on: https://go-review.googlesource.com/c/go/+/497837
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agonet/http: document when request bodies are closed in more places
Damien Neil [Thu, 24 Aug 2023 17:58:51 +0000 (10:58 -0700)]
net/http: document when request bodies are closed in more places

It isn't obvious that request bodies can be closed asynchronously,
and it's easy to overlook the documentation of this fact in
RoundTripper, which is a fairly low-level interface.

Change-Id: I3b825c505418af7e1d3f6ed58f3704e55cf16901
Reviewed-on: https://go-review.googlesource.com/c/go/+/523036
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Damien Neil <dneil@google.com>

9 months agonet/http: deflake TestRequestBodyLimit
Damien Neil [Thu, 24 Aug 2023 17:58:51 +0000 (10:58 -0700)]
net/http: deflake TestRequestBodyLimit

This test can return with a Transport still processing
an in-flight request, resulting in a test failure due
to the leaked Transport.

Avoid this by waiting for the Transport to close the
request body before returning.

Fixes #60264

Change-Id: I8d8b54f633c2e28da2b1bf1bc01ce09dd77769de
Reviewed-on: https://go-review.googlesource.com/c/go/+/522695
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>

9 months agocmd/compile/internal/ir: mark Addrtaken in NewAddrExpr
Matthew Dempsky [Fri, 25 Aug 2023 00:21:58 +0000 (17:21 -0700)]
cmd/compile/internal/ir: mark Addrtaken in NewAddrExpr

This CL changes NewAddrExpr to require its operand to always be
typechecked, so it can return an appropriately typechecked node and
mark Addrtaken as appropriate in the process.

Change-Id: I97c1f29305a9abfda35c42a43561c4c15fb5b52e
Reviewed-on: https://go-review.googlesource.com/c/go/+/522879
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/compile/internal/noder: avoid ir.Node temps in FixValue
Matthew Dempsky [Fri, 25 Aug 2023 00:05:50 +0000 (17:05 -0700)]
cmd/compile/internal/noder: avoid ir.Node temps in FixValue

Instead of constructing an untyped basic literal IR node, having
typecheck convert it and return a new one, only to extract the
constant.Value; just have typecheck export the underlying value
conversion function, so we can call it directly.

Change-Id: Ie98f5362b3926a728d80262b0274a0b4fd023eaf
Reviewed-on: https://go-review.googlesource.com/c/go/+/522878
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/compile: remove ErrorfVers and base.Flag.Lang hack
Matthew Dempsky [Thu, 24 Aug 2023 23:17:44 +0000 (16:17 -0700)]
cmd/compile: remove ErrorfVers and base.Flag.Lang hack

ErrorfVers used to be used by typecheck to report when new language
functionality was used, but the -lang flag (from go.mod) was set to an
older version. However, all of the callers have been since removed,
now that this is handled by types2.

And for the same reason, we can stop changing base.Flag.Lang. This was
previously a workaround so that the unified frontend could generate
arbitrary IR without upsetting typecheck, at a time when typecheck was
itself a real frontend. Now it's just a glorified desugaring pass.

Change-Id: I1c0316dbfe2e08ba089acd50fdfe20b17176be25
Reviewed-on: https://go-review.googlesource.com/c/go/+/522877
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoruntime: fix maps.Clone bug when cloning a map mid-grow
Keith Randall [Wed, 23 Aug 2023 22:19:15 +0000 (15:19 -0700)]
runtime: fix maps.Clone bug when cloning a map mid-grow

Fixes #62203

Change-Id: I0459d3f481b0cd20102f6d9fd3ea84335a7739a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/522317
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoencoding/json: modernize tests
Joe Tsai [Thu, 24 Aug 2023 19:49:10 +0000 (12:49 -0700)]
encoding/json: modernize tests

There are no changes to what is being tested.
No test cases were removed or added.

Changes made:
* Use a local implementation of test case position marking. See #52751.
* Use consistent names for all test tables and variables.
* Generally speaking, follow modern Go style guide for tests.
* Move global tables local to the test function if possible.
* Make every table entry run in a distinct testing.T.Run.

The purpose of this change is to make it easier to perform
v1-to-v2 development where we want v2 to support close to
bug-for-bug compatibility when running in v1 mode.

Annotating each test case with the location of the test data
makes it easier to jump directly to the test data itself
and understand why this particular case is failing.

Having every test case run in its own t.Run makes it easier
to isolate a particular failing test and work on fixing the code
until that test case starts to pass again.

Unfortunately, many tests are annotated with an empty name.
An empty name is better than nothing, since the testing framework
auto assigns a numeric ID for duplicate names.
It is not worth the trouble to give descriptive names to each
of the thousands of test cases.

Change-Id: I43905f35249b3d77dfca234b9c7808d40e225de8
Reviewed-on: https://go-review.googlesource.com/c/go/+/522880
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
9 months agotime: make time.Until a few nanoseconds faster
korzhao [Tue, 22 Aug 2023 06:22:53 +0000 (14:22 +0800)]
time: make time.Until a few nanoseconds faster

This is similar to CL 518336.

For #61765.

Change-Id: I7c1d92a3b3e2b6c1c0058a2094997d93082ad139
Reviewed-on: https://go-review.googlesource.com/c/go/+/521237
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@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 agointernal/bytealg: add generic LastIndexByte{,String}
Tobias Klauser [Thu, 24 Aug 2023 13:10:39 +0000 (15:10 +0200)]
internal/bytealg: add generic LastIndexByte{,String}

To avoid duplicating them in net/netip and os and to allow these
packages automatically benefiting from future performance improvements
when optimized native LastIndexByte{,String} implementations are added.

For #36891

Change-Id: I4905a4742273570c2c36b867df57762c5bfbe1e4
Reviewed-on: https://go-review.googlesource.com/c/go/+/522475
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agoruntime/debug: fix minor BuildSetting doc typos
crozzy [Thu, 24 Aug 2023 22:14:44 +0000 (22:14 +0000)]
runtime/debug: fix minor BuildSetting doc typos

Corrects a couple of defined key descriptions.

Change-Id: I8c5c0e3aca5431086076d19792291aee96f5d1d5
GitHub-Last-Rev: e722d0a923f6c556cbc7fd52f21862844538d75b
GitHub-Pull-Request: golang/go#62273
Reviewed-on: https://go-review.googlesource.com/c/go/+/522875
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agonet: remove unused ipv4AddrToInterface
Tobias Klauser [Thu, 24 Aug 2023 10:03:08 +0000 (12:03 +0200)]
net: remove unused ipv4AddrToInterface

It's unused since CL 6497044.

Change-Id: Iee07e7af7b80fc3f00146b64cebead844daee087
Reviewed-on: https://go-review.googlesource.com/c/go/+/522196
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agoencoding/json: avoid allocation when decoding number types
korzhao [Fri, 11 Aug 2023 09:20:36 +0000 (17:20 +0800)]
encoding/json: avoid allocation when decoding number types

In CL 345488, we optimized strconv.ParseXXX for []byte arguments.
That allows immediate casting of a []byte to a string that does not escape to be copied on the stack.

Performance:

goos: darwin
goarch: arm64
pkg: encoding/json
old sec/op new sec/op delta
CodeUnmarshal-10        3.019m ± 6%   2.865m ± 10%   -5.10% (p=0.043 n=10)
CodeUnmarshalReuse-10   2.528m ± 4%   2.274m ± 13%  -10.03% (p=0.009 n=10)
geomean                 2.762m        2.553m         -7.60%

old B/s new B/s delta
CodeUnmarshal-10        613.1Mi ± 5%   646.0Mi ±  9%   +5.37% (p=0.043 n=10)
CodeUnmarshalReuse-10   732.1Mi ± 4%   813.7Mi ± 12%  +11.15% (p=0.009 n=10)
geomean                 669.9Mi        725.0Mi         +8.22%

old B/op new B/op delta
CodeUnmarshal-10         2.782Mi ± 0%   1.918Mi ± 0%  -31.04% (p=0.000 n=10)
CodeUnmarshalReuse-10   1600.8Ki ± 0%   713.3Ki ± 0%  -55.44% (p=0.000 n=10)
geomean                  2.085Mi        1.156Mi       -44.57%

old allocs/op  new allocs/op  delta
CodeUnmarshal-10        91.31k ± 0%   39.99k ± 0%  -56.20% (p=0.000 n=10)
CodeUnmarshalReuse-10   76.58k ± 0%   25.23k ± 0%  -67.06% (p=0.000 n=10)
geomean                 83.62k        31.76k       -62.02%

Change-Id: I208c57089040daee0f9d979d1df725e3acf34f81
Reviewed-on: https://go-review.googlesource.com/c/go/+/518277
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
9 months agoencoding/json: optimize Marshal for maps
korzhao [Wed, 2 Aug 2023 09:39:09 +0000 (17:39 +0800)]
encoding/json: optimize Marshal for maps

Optimize marshaling of maps by using slices.SortFunc.

This drops an unnecessary field from reflectWithString,
which also reduces the cost of each swap operation.

benchmark                  old ns/op     new ns/op     delta
BenchmarkMarshalMap-10     228           139           -39.24%

benchmark                  old allocs     new allocs     delta
BenchmarkMarshalMap-10     11             8              -27.27%

benchmark                  old bytes     new bytes     delta
BenchmarkMarshalMap-10     432           232           -46.30%

Change-Id: Ic2ba7a1590863c7536305c6f6536372b26ec9b0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/515176
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agoos: omit existence check for GetFinalPathNameByHandle
qmuntal [Wed, 23 Aug 2023 14:52:37 +0000 (16:52 +0200)]
os: omit existence check for GetFinalPathNameByHandle

GetFinalPathNameByHandle exists since Windows Vista, which we no longer
support, so we don't need to prove that it exists before using it.

Updates #57003

Change-Id: Iff2bbe51d3baa3aabcaacf39ea3cbeda0088b9d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/522195
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agocmd/internal/obj/arm64: load large constants into vector registers from rodata
Joel Sing [Sat, 7 Jan 2023 05:26:15 +0000 (16:26 +1100)]
cmd/internal/obj/arm64: load large constants into vector registers from rodata

Load large constants into vector registers from rodata, instead of placing them
in the literal pool. This treats VMOVQ/VMOVD/VMOVS the same as FMOVD/FMOVS and
makes use of the existing mechanism for storing values in rodata. Two additional
instructions are required for a load, however these instructions are used
infrequently and already have a high latency.

Updates #59615

Change-Id: I54226730267689963d73321e548733ae2d66740e
Reviewed-on: https://go-review.googlesource.com/c/go/+/515617
Reviewed-by: Eric Fang <eric.fang@arm.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agonet/http: use reflect.TypeFor for known types
Ian Lance Taylor [Wed, 23 Aug 2023 22:57:48 +0000 (15:57 -0700)]
net/http: use reflect.TypeFor for known types

For #60088

Change-Id: I9e4044d9c2694fe86aab1f5220622c8d952b1a90
Reviewed-on: https://go-review.googlesource.com/c/go/+/522338
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agocmd/compile: create "init" function during noding
Matthew Dempsky [Thu, 24 Aug 2023 10:04:01 +0000 (03:04 -0700)]
cmd/compile: create "init" function during noding

This CL arranges for package-scope initialization statements to be
constructed directly into their eventual "init" function, so we can
eliminate the roundabout solution of using InitTodoFunc.

While here, somewhat simplify and generalize the logic for outlining
map initialization statements.

Change-Id: I8aff042e6b266f7024de436424ec6711b8b69129
Reviewed-on: https://go-review.googlesource.com/c/go/+/522318
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile/internal/gc: steps towards work-queue
Matthew Dempsky [Fri, 18 Aug 2023 07:32:11 +0000 (00:32 -0700)]
cmd/compile/internal/gc: steps towards work-queue

[This is a reattempt of go.dev/cl/520611.]

This CL reorganizes the top-level functions for handling package-level
declarations, runtime type descriptors, and SSA compilation to work in
a loop. This generalizes the loop that previously existed in dumpdata.

Change-Id: I7502798a8662b3cec92d3001169f3af4f804df2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/522339
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile/internal/syntax: use strings.LastIndexByte in trailingDigits
Tobias Klauser [Thu, 24 Aug 2023 09:58:58 +0000 (11:58 +0200)]
cmd/compile/internal/syntax: use strings.LastIndexByte in trailingDigits

Previously, strings.LastIndexByte couldn't be used because it was only
added in Go 1.5 but Go 1.4 was required for bootstrapping. In Go 1.18,
the bootstrap toolchain was bumped to Go 1.17 (see #44505), thus
strings.LastIndexByte can be used now.

Change-Id: I01a70a59dbfc853cf03d49747a2dd62d21ba74e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/522197
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
9 months agocmd/go: clarify promotion of C warnings to errors
Austin Clements [Thu, 24 Aug 2023 19:14:44 +0000 (15:14 -0400)]
cmd/go: clarify promotion of C warnings to errors

CL 23005 (back in 2016!) added logic to promote C compiler warnings to
errors when running on the Go builders.

CL 437298 kept the logic to promote warnings to errors on the
builders, but dropped the explanatory message, I believe
unintentionally. Indeed, now there isn't even a comment in the code
explaining what's going on.

This CL adds back an explanatory message to the printed output, which
also serves as a explanation in the code as to why we're checking
$GO_BUILDER_NAME.

Change-Id: I769c55d213f96f73d20a41ab926fb91e71a5a22c
Reviewed-on: https://go-review.googlesource.com/c/go/+/522775
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/internal/goobj: fix the size of Header
mstmdev [Mon, 21 Aug 2023 09:04:07 +0000 (09:04 +0000)]
cmd/internal/goobj: fix the size of Header

Missed the length of the Fingerprint field.

Change-Id: I690955466895e73821dc1e30f8400efc30338ae6
GitHub-Last-Rev: 87bd06d8053c003a412a6ea11b3eafcc280b94d1
GitHub-Pull-Request: golang/go#62174
Reviewed-on: https://go-review.googlesource.com/c/go/+/521495
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

9 months agostrconv: add missing function name, avoid unnecessary raw string
Luka Krmpotić [Mon, 21 Aug 2023 23:17:31 +0000 (23:17 +0000)]
strconv: add missing function name, avoid unnecessary raw string

Change-Id: Iecd68f69f5265f1a4ea41b90aa819ce68fe55908
GitHub-Last-Rev: 4d1f4a1bc2740fc19bbb4768009ccfea1c8eb5bc
GitHub-Pull-Request: golang/go#62177
Reviewed-on: https://go-review.googlesource.com/c/go/+/521277
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agonet/http: remove arbitrary timeout from TestTransportGCRequest
Damien Neil [Thu, 24 Aug 2023 17:12:38 +0000 (10:12 -0700)]
net/http: remove arbitrary timeout from TestTransportGCRequest

This test expects a *Request to be garbage collected
within five seconds. Some slow builders take longer.
Drop the arbitrary timeout.

Fixes #56809

Change-Id: I4b5bdce09002a5b52b7b5d0b33e7876d48740bc3
Reviewed-on: https://go-review.googlesource.com/c/go/+/522615
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/internal/testdir: parse past gofmt'd //go:build lines
Bryan C. Mills [Thu, 24 Aug 2023 17:16:48 +0000 (13:16 -0400)]
cmd/internal/testdir: parse past gofmt'd //go:build lines

Also gofmt a test file to make sure the parser works.

Fixes #62267.

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

9 months agoruntime: remove unused F_{GET,SET}FL cgo constants on solaris and openbsd
Tobias Klauser [Fri, 14 Jul 2023 18:30:43 +0000 (20:30 +0200)]
runtime: remove unused F_{GET,SET}FL cgo constants on solaris and openbsd

The generated constants were already removed by CL 497076, so the cgo
constants used to generate them are no longer needed as well.

Change-Id: I37dabd800461d134424af8bd72fb0c1b8504d604
Reviewed-on: https://go-review.googlesource.com/c/go/+/509676
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

9 months agosyscall: skip TestUnshareMountNameSpaceChroot on platforms that require external...
Bryan C. Mills [Thu, 24 Aug 2023 14:45:11 +0000 (10:45 -0400)]
syscall: skip TestUnshareMountNameSpaceChroot on platforms that require external linking

TestUnshareMountNameSpaceChroot attempts to build a statically-linked
binary to run in a chroot, and sets CGO_ENABLED=0 in order to do so.
Rather than trying to figure out some other way to coax the linker
into building a static binary, let's just skip the test on Linux
platforms that require external linking (namely android/arm).

This should fix the build failure reported in
https://build.golang.org/log/1ea245a9c2e916c81043db177be76778bab00058.

While we're here, let's also fix the failure logging to make the text
readable!

Updates #46330.

Change-Id: I4fa07640ce012ac141bf4698bc3215a7f146062c
Reviewed-on: https://go-review.googlesource.com/c/go/+/522182
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agotest/fixedbugs: require cgo for issue10607.go
Bryan C. Mills [Thu, 24 Aug 2023 15:09:41 +0000 (11:09 -0400)]
test/fixedbugs: require cgo for issue10607.go

This test passes "-linkmode=external" to 'go run' to link the binary
using the system C linker.

CGO_ENABLED=0 explicitly tells cmd/go not to use the C toolchain,
so the test should not be run in that configuration.

Updates #46330.

Change-Id: I16ac66aac91178045f9decaeb28134061e9711f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/522495
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>

9 months agocmd/compile/internal/syntax: add Unparen and UnpackListExpr helpers
Matthew Dempsky [Wed, 23 Aug 2023 20:52:25 +0000 (13:52 -0700)]
cmd/compile/internal/syntax: add Unparen and UnpackListExpr helpers

We've added Unparen to go/ast, so add syntax.Unparen to be
consistent (and because it's similarly useful).

Also, types2 and noder both have similar functions for unpacking
ListExprs, so might as well add a common implementation in package
syntax too.

Finally, addressing the TODO: UnpackListExpr is small enough to be
inlined (when default optimizations are enabled), and for typical uses
of UnpackListExpr (e.g., "range UnpackListExpr(x)") the single-element
slice result is stack allocated in the caller. This CL adds a test
using testing.AllocsPerRun to ensure this remains so in the future.

Change-Id: I96a5591d202193ed5bf1ce6f290919107e3dc01b
Reviewed-on: https://go-review.googlesource.com/c/go/+/522336
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/compile/internal: fix receiver names are different
cui fliter [Thu, 24 Aug 2023 03:18:18 +0000 (11:18 +0800)]
cmd/compile/internal: fix receiver names are different

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

9 months agocmd/compile: use s.temp for creating defer struct
Cuong Manh Le [Wed, 23 Aug 2023 03:20:29 +0000 (10:20 +0700)]
cmd/compile: use s.temp for creating defer struct

Follow discussion in go.dev/cl/521676.

Change-Id: Ie5c0ce66b60fcbfd59385e8c2c45d431133ab53a
Reviewed-on: https://go-review.googlesource.com/c/go/+/522115
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/go: error out of linking package main if cgo is required but not enabled
Bryan C. Mills [Wed, 23 Aug 2023 20:32:46 +0000 (16:32 -0400)]
cmd/go: error out of linking package main if cgo is required but not enabled

Fixes #46330.
Fixes #62123.
Updates #31544.

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

9 months agoencoding/json: encode \b and \f as '\b' and '\f' in JSON strings
Joe Tsai [Mon, 21 Aug 2023 20:06:23 +0000 (13:06 -0700)]
encoding/json: encode \b and \f as '\b' and '\f' in JSON strings

According to RFC 8259, there are exactly 5 control characters
that have a shorter escape sequence than the generic \uXXXX format.

Over the years, we added ad-hoc support for the short sequences:
* https://go.dev/cl/4678046 supports \r and \n
* https://go.dev/cl/162340043 supports \t

This CL completes the set by supporting \b and \f.

This may change the encoding of strings in relatively rare cases,
but is a permissible change since the Go 1 compatibility document does
not guarantee that "json" produces byte-for-byte identical outputs.

In fact, we have made even more observable output changes in the past
such as with https://go.dev/cl/30371 which changes the representation
of many JSON numbers.

This change is to prepare the path forward for a potential
v2 "json" package, which has more consistent encoding of JSON strings.

Change-Id: I11102a0602dfb1a0c14eaad82ed23e8df7553c6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/521675
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agoos: use testenv.Command and os.Executable in tests
Bryan C. Mills [Tue, 22 Aug 2023 15:32:20 +0000 (11:32 -0400)]
os: use testenv.Command and os.Executable in tests

On Unix platforms, testenv.Command sends SIGQUIT to stuck commands
before the test times out. For subprocesses that are written in Go,
that causes the runtime to dump running goroutines, and in other
languages it triggers similar behavior (such as a core dump).
If the subprocess is stuck due to a bug (such as #57999), that may
help to diagnose it.

For #57999.

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

9 months agocmd/compile/internal/noder: elide statically known "if" statements
Matthew Dempsky [Wed, 23 Aug 2023 00:44:19 +0000 (17:44 -0700)]
cmd/compile/internal/noder: elide statically known "if" statements

In go.dev/cl/517775, I moved the frontend's deadcode elimination pass
into unified IR. But I also made a small enhancement: a branch like
"if x || true" is now detected as always taken, so the else branch can
be eliminated.

However, the inliner also has an optimization for delaying the
introduction of the result temporary variables when there's a single
return statement (added in go.dev/cl/266199). Consequently, the
inliner turns "if x || true { return true }; return true" into:

if x || true {
~R0 := true
goto .i0
}
.i0:
// code that uses ~R0

In turn, this confuses phi insertion, because it doesn't recognize
that the "if" statement is always taken, and so ~R0 will always be
initialized.

With this CL, after inlining we instead produce:

_ = x || true
~R0 := true
goto .i0
.i0:

Fixes #62211.

Change-Id: Ic8a12c9eb85833ee4e5d114f60e6c47817fce538
Reviewed-on: https://go-review.googlesource.com/c/go/+/522096
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agonet: use internal/bytealg.CountString
Tobias Klauser [Wed, 23 Aug 2023 09:22:04 +0000 (11:22 +0200)]
net: use internal/bytealg.CountString

On platforms that provide a native implementation this might be slightly
faster. On other platforms it is equivalent to the count func.

Change-Id: If46cc65598993e64084cc98533cb8c1e9679a6fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/522136
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>

9 months agonet: remove unused func appendHex
Tobias Klauser [Wed, 23 Aug 2023 08:54:37 +0000 (10:54 +0200)]
net: remove unused func appendHex

It's unused since CL 463987.

Change-Id: Ic28fd3b4a613cd7b43f817118841d40e3005a5fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/522135
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
9 months agonet/http: revert fix request canceler leak on connection close
Alexander Yastrebov [Wed, 23 Aug 2023 15:39:26 +0000 (15:39 +0000)]
net/http: revert fix request canceler leak on connection close

This reverts CL 515796 due to a flaking test.

Updates #61708
Fixes #62224

Change-Id: I53911a07677d08c3196daaaa2708269593baf472
GitHub-Last-Rev: 3544648ecc3783dcb10d54fc2b266797c02f9a75
GitHub-Pull-Request: golang/go#62233
Reviewed-on: https://go-review.googlesource.com/c/go/+/522097
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
9 months agoruntime: create wrappers for gcDrain to identify time in profiles
Michael Anthony Knyszek [Mon, 21 Aug 2023 22:29:11 +0000 (22:29 +0000)]
runtime: create wrappers for gcDrain to identify time in profiles

Currently it's impossible to identify in profiles where gcDrain-related
time is coming from. More specifically, what kind of worker. Create
trivial wrappers for each worker so that the difference shows up in
stack traces.

Also, clarify why gcDrain disables write barriers.

Change-Id: I966e3c0b1c583994e691f486bf0ed8cabb91dbbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/521815
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/internal/obj/riscv,cmd/link: add support for internal cgo linking on riscv64
Joel Sing [Wed, 31 Aug 2022 08:18:19 +0000 (18:18 +1000)]
cmd/internal/obj/riscv,cmd/link: add support for internal cgo linking on riscv64

Make it possible to internally link cgo on riscv64, which also adds
support for SDYNIMPORT calls without external linking being required.

This reduces the time of an ./all.bash run on a Sifive Hifive Unleashed by
approximately 20% (~140 minutes down to ~110 minutes).

Change-Id: I43f1348de31672718ae8676cc82f6fdc1dfee054
Reviewed-on: https://go-review.googlesource.com/c/go/+/431104
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Than McIntosh <thanm@google.com>
9 months agocmd/go/testdata/mod: add golang toolchain test data for openbsd/ppc64
Joel Sing [Thu, 10 Aug 2023 14:57:27 +0000 (00:57 +1000)]
cmd/go/testdata/mod: add golang toolchain test data for openbsd/ppc64

Updates #56001

Change-Id: Ic7b4ecb2e471292894c54610e8acda8822c890fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/518275
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/link: add support for openbsd/ppc64
Joel Sing [Thu, 2 Mar 2023 14:24:00 +0000 (01:24 +1100)]
cmd/link: add support for openbsd/ppc64

Add linker support for the openbsd/ppc64 port.

Updates #56001

Change-Id: I18bc19b4086599996aebfbe68f2e85e1200589ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/475619
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Eric Grosse <grosse@gmail.com>
9 months agocmd/compile: use jump tables for large type switches
Keith Randall [Thu, 17 Aug 2023 21:20:21 +0000 (14:20 -0700)]
cmd/compile: use jump tables for large type switches

For large interface -> concrete type switches, we can use a jump
table on some bits of the type hash instead of a binary search on
the type hash.

name                        old time/op  new time/op  delta
SwitchTypePredictable-24    1.99ns ± 2%  1.78ns ± 5%  -10.87%  (p=0.000 n=10+10)
SwitchTypeUnpredictable-24  11.0ns ± 1%   9.1ns ± 2%  -17.55%  (p=0.000 n=7+9)

Change-Id: Ida4768e5d62c3ce1c2701288b72664aaa9e64259
Reviewed-on: https://go-review.googlesource.com/c/go/+/521497
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>

9 months agocmd/compile: allow non-pointer writes in the middle of a write barrier
Keith Randall [Fri, 18 Aug 2023 19:44:37 +0000 (12:44 -0700)]
cmd/compile: allow non-pointer writes in the middle of a write barrier

This lets us combine more write barriers, getting rid of some of the
test+branch and gcWriteBarrier* calls.
With the new write barriers, it's easy to add a few non-pointer writes
to the set of values written.

We allow up to 2 non-pointer writes between pointer writes. This is enough
for, for example, adjacent slice fields.

Fixes #62126

Change-Id: I872d0fa9cc4eb855e270ffc0223b39fde1723c4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/521498
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
9 months agoall: remove redundant string conversions when formatting []byte with %s
cui fliter [Sun, 20 Aug 2023 10:33:50 +0000 (18:33 +0800)]
all: remove redundant string conversions when formatting []byte with %s

Change-Id: I603051a3174b139ffb81d20d42979c7f3f04a09a
Reviewed-on: https://go-review.googlesource.com/c/go/+/521136
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agonet/http: fix request canceler leak on connection close
Alexander Yastrebov [Tue, 22 Aug 2023 21:14:14 +0000 (21:14 +0000)]
net/http: fix request canceler leak on connection close

Due to a race condition persistConn could be closed without removing request canceler.

Note that without the fix test occasionally passes and to demonstrate the issue it has to be run multiple times, e.g. using -count=10.

Fixes #61708

Change-Id: I9029d7d65cf602dd29ee1b2a87a77a73e99d9c92
GitHub-Last-Rev: 6b31f9826da71dad4ee8c0491efba995a8f51440
GitHub-Pull-Request: golang/go#61745
Reviewed-on: https://go-review.googlesource.com/c/go/+/515796
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/go: retry ETXTBSY errors when running test binaries
Bryan C. Mills [Tue, 22 Aug 2023 21:33:50 +0000 (17:33 -0400)]
cmd/go: retry ETXTBSY errors when running test binaries

An ETXTBSY error when starting a test binary is almost certainly
caused by the race reported in #22315. That race will resolve quickly
on its own, so we should just retry the command instead of reporting a
spurious failure.

Fixes #62221.

Change-Id: I408f3eaa7ab5d7efbc7a2b1c8bea3dbc459fc794
Reviewed-on: https://go-review.googlesource.com/c/go/+/522015
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agoruntime/cgo: get getstackbound for set_stacklo
Ian Lance Taylor [Wed, 16 Aug 2023 00:29:40 +0000 (17:29 -0700)]
runtime/cgo: get getstackbound for set_stacklo

Change-Id: Ia63a4604449b5e460e6f54c962fb7d6db2bc6a43
Reviewed-on: https://go-review.googlesource.com/c/go/+/519457
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agocmd/compile/internal/typecheck: use types.IsMethodApplicable
Matthew Dempsky [Mon, 21 Aug 2023 01:15:43 +0000 (18:15 -0700)]
cmd/compile/internal/typecheck: use types.IsMethodApplicable

In checking whether a type implements an interface, there's this
complex predicate spanning multiple lines, which is very obtuse.

So let's just use the helper function we already have in package types
instead.

Change-Id: I80f69d41c2bee8d6807601cf913840fa4f042b5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/521435
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/compile/internal/typecheck: merge SubstArgTypes into LookupRuntime
Matthew Dempsky [Sun, 20 Aug 2023 23:14:50 +0000 (16:14 -0700)]
cmd/compile/internal/typecheck: merge SubstArgTypes into LookupRuntime

LookupRuntime is the only reason for using SubstArgTypes, and most
callers to LookupRuntime need to immediately call it anyway. So might
as well fuse them together.

Change-Id: Ie0724ed164b949040e898a2a77bea632801b64fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/521415
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
9 months agocmd/compile: simplify various signature type handling code
Matthew Dempsky [Sun, 20 Aug 2023 22:37:34 +0000 (15:37 -0700)]
cmd/compile: simplify various signature type handling code

Make more use of RecvParams and RecvParamsResults helper methods.

Also, correct misuse of Go spec terminology ("return" is a statement;
"result" is the class of parameters that appear in a function type).

Change-Id: I94807a747c494c9daa5441da7d9e3aea77aae33b
Reviewed-on: https://go-review.googlesource.com/c/go/+/521395
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>