]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
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>
9 months agocmd/compile/internal/types: simplify iterating all parameters
Matthew Dempsky [Sun, 20 Aug 2023 22:07:00 +0000 (15:07 -0700)]
cmd/compile/internal/types: simplify iterating all parameters

The types.RecvsParamsResults, etc. helpers existed to make it "easier"
to iterate over all parameters, or recvs+params, or params+results;
but they end up still being quite clumsy to use due to the design goal
of not allocating temporary slices.

Now that recvs+params+results are stored in a single consecutive slice
anyway, we can just return different subslices and simplify the loops.

Change-Id: I84791b80dc099dfbfbbe6eddbc006135528c23b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/521375
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
9 months agocmd/compile/internal/types: simpler signature type representation
Matthew Dempsky [Sun, 20 Aug 2023 21:33:32 +0000 (14:33 -0700)]
cmd/compile/internal/types: simpler signature type representation

Now that all of the uses of signature types have been cleaned up, we
can simplify the internal representation significantly.

In particular, instead of 3 separate struct objects each with 3
separate slices of fields, we can store all of the parameters in a
single slice and track the boundaries between them.

We still need a results tuple struct for representing the type of
multi-value call expressions, but just a single one and it can safely
reuse the results subsection of the full parameters slice.

Note: while Sizeof(Func) has increased (e.g., 32->56 on amd64), we're
saving on the allocation of 2 Types, 2 Structs, and 2 []*Field (288
bytes total on amd64), not counting any extra GC size class padding
from using a single shared []*Field instead of 3 separate ones.

Change-Id: I119b5e960e715b3bc4f1f726e58b910a098659da
Reviewed-on: https://go-review.googlesource.com/c/go/+/521335
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Bypass: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agocmd/compile/internal/types: replace BOGUS_FUNARG_OFFSET with BADWIDTH
Matthew Dempsky [Sun, 20 Aug 2023 21:27:27 +0000 (14:27 -0700)]
cmd/compile/internal/types: replace BOGUS_FUNARG_OFFSET with BADWIDTH

We already have a magic constant to represent fields that haven't had
their offsets calculated. We don't need two.

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

9 months agocmd/compile: use MOVQ + MOVL for 11 byte moves
Jakub Ciolek [Mon, 21 Aug 2023 08:09:54 +0000 (10:09 +0200)]
cmd/compile: use MOVQ + MOVL for 11 byte moves

Instead of using two MOVQ, use a shorter MOVL for the remaining 3 bytes.

compilecmp (linux/amd64):

runtime/pprof
runtime/pprof.printCountProfile.func1 875 -> 869  (-0.69%)

fmt [cmd/compile]
fmt.Sprintf 5009 -> 4977  (-0.64%)

runtime/pprof [cmd/compile]
runtime/pprof.printCountProfile.func1 875 -> 869  (-0.69%)

cmd/vendor/github.com/ianlancetaylor/demangle
cmd/vendor/github.com/ianlancetaylor/demangle.(*GlobalCDtor).print 957 -> 938  (-1.99%)
cmd/vendor/github.com/ianlancetaylor/demangle.(*ImaginaryType).printInner 270 -> 261  (-3.33%)
cmd/vendor/github.com/ianlancetaylor/demangle.(*TemplateTemplateParam).print 876 -> 874  (-0.23%)

cmd/cgo/internal/test
cmd/cgo/internal/test.test18146.func1 73 -> 66  (-9.59%)

cmd/go/internal/work
cmd/go/internal/work.(*Builder).gccSupportsFlag 3469 -> 3461  (-0.23%)

file                                            before   after    Δ       %
runtime/pprof.s                                 79729    79723    -6      -0.008%
fmt [cmd/compile].s                             83679    83647    -32     -0.038%
runtime/pprof [cmd/compile].s                   79729    79723    -6      -0.008%
cmd/vendor/github.com/ianlancetaylor/demangle.s 254999   254969   -30     -0.012%
cmd/cgo/internal/test.s                         212272   212265   -7      -0.003%
cmd/go/internal/work.s                          287700   287692   -8      -0.003%
cmd/compile/internal/ssa.s                      3193233  3193553  +320    +0.010%
cmd/compile/internal/ssa [cmd/compile].s        3362126  3362446  +320    +0.010%
total                                           30810158 30810709 +551    +0.002%

Change-Id: Iad09a42fb247c85ca1c649c367aaf75a620dbbc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/521475
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocmd/compile: use shorter MOVs for clears of 9, 10, 11 and 12 bytes
Jakub Ciolek [Mon, 21 Aug 2023 07:36:29 +0000 (09:36 +0200)]
cmd/compile: use shorter MOVs for clears of 9, 10, 11 and 12 bytes

Instead of using two MOVQ, use a smaller MOV(B|W|L) for the remainder.

compilecmp:

vendor/golang.org/x/net/dns/dnsmessage
vendor/golang.org/x/net/dns/dnsmessage.(*SRVResource).GoString 1263 -> 1231  (-2.53%)
vendor/golang.org/x/net/dns/dnsmessage.(*OpCode).GoString 285 -> 279  (-2.11%)
vendor/golang.org/x/net/dns/dnsmessage.(*MXResource).GoString 603 -> 581  (-3.65%)
vendor/golang.org/x/net/dns/dnsmessage.(*Option).GoString 485 -> 478  (-1.44%)

os/signal
os/signal.cancel.func1 378 -> 346  (-8.47%)

fmt
fmt.newPrinter 145 -> 138  (-4.83%)
fmt.(*pp).catchPanic 1369 -> 1357  (-0.88%)
fmt.(*fmt).clearflags 17 -> 13  (-23.53%)
fmt.(*fmt).init 85 -> 81  (-4.71%)

vendor/golang.org/x/crypto/chacha20poly1305
vendor/golang.org/x/crypto/chacha20poly1305.(*xchacha20poly1305).Seal 527 -> 526  (-0.19%)

cmd/vendor/golang.org/x/sys/unix
cmd/vendor/golang.org/x/sys/unix.(*TIPCSocketAddr).tipcAddr 88 -> 86  (-2.27%)
cmd/vendor/golang.org/x/sys/unix.(*TIPCServiceRange).tipcAddr 95 -> 93  (-2.11%)
cmd/vendor/golang.org/x/sys/unix.(*TIPCServiceName).tipcAddr 95 -> 93  (-2.11%)

fmt [cmd/compile]
fmt.(*fmt).clearflags 17 -> 13  (-23.53%)
fmt.newPrinter 304 -> 298  (-1.97%)
fmt.(*pp).catchPanic 1369 -> 1357  (-0.88%)
fmt.Fprint 536 -> 535  (-0.19%)
fmt.Sprintf 5009 -> 4945  (-1.28%)
fmt.(*fmt).init 85 -> 81  (-4.71%)

net/http
net/http.http2FrameHeader.Header 89 -> 88  (-1.12%)
net/http.http2HeadersFrame.Header 95 -> 94  (-1.05%)
net/http.http2RSTStreamFrame.Header 120 -> 119  (-0.83%)
net/http.http2WindowUpdateFrame.Header 120 -> 119  (-0.83%)
net/http.http2Frame.Header 181 -> 179  (-1.10%)
net/http.http2PingFrame.Header 95 -> 94  (-1.05%)
net/http.(*http2FrameHeader).Header 119 -> 113  (-5.04%)
net/http.http2GoAwayFrame.Header 95 -> 94  (-1.05%)
net/http.http2MetaHeadersFrame.Header 133 -> 132  (-0.75%)

cmd/vendor/golang.org/x/term
cmd/vendor/golang.org/x/term.(*Terminal).clearLineToRight 338 -> 337  (-0.30%)

cmd/link/internal/ld
cmd/link/internal/ld.appendString 424 -> 421  (-0.71%)

cmd/compile/internal/reflectdata [cmd/compile]
cmd/compile/internal/reflectdata.dnameData 1574 -> 1561  (-0.83%)

file                                             before   after    Δ       %
vendor/golang.org/x/net/dns/dnsmessage.s         74536    74469    -67     -0.090%
os/signal.s                                      7192     7160     -32     -0.445%
fmt.s                                            70428    70401    -27     -0.038%
vendor/golang.org/x/crypto/chacha20poly1305.s    7103     7102     -1      -0.014%
cmd/vendor/golang.org/x/sys/unix.s               118033   118027   -6      -0.005%
fmt [cmd/compile].s                              83679    83588    -91     -0.109%
net/http.s                                       536737   536722   -15     -0.003%
cmd/vendor/golang.org/x/term.s                   23505    23504    -1      -0.004%
cmd/link/internal/ld.s                           571046   571043   -3      -0.001%
cmd/compile/internal/reflectdata [cmd/compile].s 72645    72632    -13     -0.018%
cmd/compile/internal/ssa.s                       3193233  3193841  +608    +0.019%
cmd/compile/internal/ssa [cmd/compile].s         3362126  3362734  +608    +0.018%
total                                            30810158 30811118 +960    +0.003%

Change-Id: Iade49c590027c0a09a6e546a3b94d2dccd5b7116
Reviewed-on: https://go-review.googlesource.com/c/go/+/521455
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/asm: add more flags to the documentation
mstmdev [Tue, 22 Aug 2023 16:34:22 +0000 (16:34 +0000)]
cmd/asm: add more flags to the documentation

Add the flags -e and -v.

Change-Id: I48c22141ea0bc634f30625214b1a277e686bb98e
GitHub-Last-Rev: 4a12fe4f4448804f9d8a9635a6c869556891225f
GitHub-Pull-Request: golang/go#62208
Reviewed-on: https://go-review.googlesource.com/c/go/+/521679
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/compile/internal/types: separate printing of structs and tuples
Matthew Dempsky [Sun, 20 Aug 2023 21:10:38 +0000 (14:10 -0700)]
cmd/compile/internal/types: separate printing of structs and tuples

This CL changes the pretty printer to not rely on parameter lists
being represented as TSTRUCTs.

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

9 months agocmd/compile/internal/types: remove Funarg
Matthew Dempsky [Sun, 20 Aug 2023 21:06:17 +0000 (14:06 -0700)]
cmd/compile/internal/types: remove Funarg

There's no need for the Funarg type anymore. A simple boolean suffices
to indicate whether a TSTRUCT represents a parameter tuple.

While here, rename Struct.Funarg to ParamTuple.

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

9 months agocmd/compile/internal/types: refactor struct size calculation
Matthew Dempsky [Sun, 20 Aug 2023 20:14:44 +0000 (13:14 -0700)]
cmd/compile/internal/types: refactor struct size calculation

This CL simplifies how struct sizes and field offsets are calculated.

Change-Id: If4af778cb49218d295277df596e45bdd8b23ed9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/521276
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agocmd/internal/objabi,cmd/compile: move NoInstrumentPkgs and NoRacePkgs to PkgSpecials
Austin Clements [Fri, 7 Jul 2023 21:01:47 +0000 (17:01 -0400)]
cmd/internal/objabi,cmd/compile: move NoInstrumentPkgs and NoRacePkgs to PkgSpecials

This consolidates the NoInstrumentPkgs and NoRacePkgs lists into the
objabi.LookupPkgSpecial mechanism.

Change-Id: I411654afdd690fb01c412e7e8b57ddfbe85415e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/521702
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Austin Clements <austin@google.com>

9 months agocmd/compile: add all runtime package dependencies to NoInstrumentPkgs
Austin Clements [Thu, 6 Jul 2023 15:15:27 +0000 (11:15 -0400)]
cmd/compile: add all runtime package dependencies to NoInstrumentPkgs

Currently, this list includes *almost* all runtime packages, but not
quite all.

We leave out internal/bytealg for reasons explained in the code.

Compiling with or without race instrumentation has no effect on the
other packages added to the list here, so this is a no-op change
today, but makes this more robust.

Change-Id: Iaec585b2efbc72983d8cb3929394524c42dd664d
Reviewed-on: https://go-review.googlesource.com/c/go/+/521701
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/internal/objabi: test runtime package list
Austin Clements [Wed, 5 Jul 2023 19:16:41 +0000 (15:16 -0400)]
cmd/internal/objabi: test runtime package list

This adds a test that all packages imported by runtime are marked as
runtime tests by LookupPkgSpecial. We add two packages that were
missing from the list.

Change-Id: I2545980ab09474de0181cf546541527d8baaf2e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/521700
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile,cmd/dist,cmd/go: compute -+ flag from package path
Austin Clements [Fri, 30 Jun 2023 20:33:49 +0000 (16:33 -0400)]
cmd/compile,cmd/dist,cmd/go: compute -+ flag from package path

As we did for the asm -compiling-runtime flag, this CL modifies the
compiler to compute the -+ (compiling runtime) flag from the package
path. Unlike for asm, some tests use -+ explicitly to opt in to
runtime restrictions, so we leave the flag, but it's no longer passed
by any build tools.

This lets us eliminate cmd/go's list of "runtime packages" in favor of
the unified objabi.LookupPkgSpecial. It also fixes an inconsistency
with dist, which only passed -+ when compiling "runtime" itself.

One consequence of this is that the compiler now ignores the -N flag
when compiling runtime packages. Previously, cmd/go would strip -N
when passing -+ and the compiler would fatal if it got both -N and -+,
so the overall effect was that the compiler never saw -N when
compiling a runtime package. Now we simply move that logic to disable
-N down into the compiler.

Change-Id: I4876047a1563210ed122a31b72d62798762cbcf5
Reviewed-on: https://go-review.googlesource.com/c/go/+/521699
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/internal/objabi: generalize "is runtime package" check
Austin Clements [Fri, 30 Jun 2023 21:11:31 +0000 (17:11 -0400)]
cmd/internal/objabi: generalize "is runtime package" check

There are several implementations of "is this package path a runtime
package". They all have slightly different lists because they all care
about slightly different properties of building the runtime.

To start converging these, we replace objabi.IsRuntimePackagePath with
objabi.LookupPkgSpecial, which returns a struct we can extend with
various special build properties. We'll extend this with several other
flags in the following CLs.

Change-Id: I21959cb8c3d18a350d6060467681c72ea49af712
Reviewed-on: https://go-review.googlesource.com/c/go/+/521698
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>

9 months agocmd/asm,cmd/dist,cmd/go: remove asm -compiling-runtime flag
Austin Clements [Fri, 30 Jun 2023 20:33:49 +0000 (16:33 -0400)]
cmd/asm,cmd/dist,cmd/go: remove asm -compiling-runtime flag

Currently, dist and go pass a -compiling-runtime flag to asm if
they're compiling a runtime package. However, now that we always pass
the package path to asm, it can make that determination just as well
as its callers can. This CL moves that check into asm and drops the
flag.

This in turn makes dist's copy of IsRuntimePackagePath unnecessary, so
we delete it.

Change-Id: I6ecf2d50b5b83965012af34dbe5f9a973ba0778b
Reviewed-on: https://go-review.googlesource.com/c/go/+/521697
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile: redo IsRuntimePkg/IsReflectPkg predicate
Austin Clements [Fri, 7 Jul 2023 20:16:30 +0000 (16:16 -0400)]
cmd/compile: redo IsRuntimePkg/IsReflectPkg predicate

Currently, the types package has IsRuntimePkg and IsReflectPkg
predicates for testing if a Pkg is the runtime or reflect packages.
IsRuntimePkg returns "true" for any "CompilingRuntime" package, which
includes all of the packages imported by the runtime. This isn't
inherently wrong, except that all but one use of it is of the form "is
this Sym a specific runtime.X symbol?" for which we clearly only want
the package "runtime" itself. IsRuntimePkg was introduced (as
isRuntime) in CL 37538 as part of separating the real runtime package
from the compiler built-in fake runtime package. As of that CL, the
"runtime" package couldn't import any other packages, so this was
adequate at the time.

We could fix this by just changing the implementation of IsRuntimePkg,
but the meaning of this API is clearly somewhat ambiguous. Instead, we
replace it with a new RuntimeSymName function that returns the name of
a symbol if it's in package "runtime", or "" if not. This is what
every call site (except one) actually wants, which lets us simplify
the callers, and also more clearly addresses the ambiguity between
package "runtime" and the general concept of a runtime package.

IsReflectPkg doesn't have the same issue of ambiguity, but it
parallels IsRuntimePkg and is used in the same way, so we replace it
with a new ReflectSymName for consistency.

Change-Id: If3a81d7d11732a9ab2cac9488d17508415cfb597
Reviewed-on: https://go-review.googlesource.com/c/go/+/521696
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoruntime: avoid MADV_HUGEPAGE for heap memory
Michael Anthony Knyszek [Mon, 7 Aug 2023 19:09:59 +0000 (19:09 +0000)]
runtime: avoid MADV_HUGEPAGE for heap memory

Currently the runtime marks all new memory as MADV_HUGEPAGE on Linux and
manages its hugepage eligibility status. Unfortunately, the default
THP behavior on most Linux distros is that MADV_HUGEPAGE blocks while
the kernel eagerly reclaims and compacts memory to allocate a hugepage.

This direct reclaim and compaction is unbounded, and may result in
significant application thread stalls. In really bad cases, this can
exceed 100s of ms or even seconds.

Really all we want is to undo MADV_NOHUGEPAGE marks and let the default
Linux paging behavior take over, but the only way to unmark a region as
MADV_NOHUGEPAGE is to also mark it MADV_HUGEPAGE.

The overall strategy of trying to keep hugepages for the heap unbroken
however is sound. So instead let's use the new shiny MADV_COLLAPSE if it
exists.

MADV_COLLAPSE makes a best-effort synchronous attempt at collapsing the
physical memory backing a memory region into a hugepage. We'll use
MADV_COLLAPSE where we would've used MADV_HUGEPAGE, and stop using
MADV_NOHUGEPAGE altogether.

Because MADV_COLLAPSE is synchronous, it's also important to not
re-collapse huge pages if the huge pages are likely part of some large
allocation. Although in many cases it's advantageous to back these
allocations with hugepages because they're contiguous, eagerly
collapsing every hugepage means having to page in at least part of the
large allocation.

However, because we won't use MADV_NOHUGEPAGE anymore, we'll no longer
handle the fact that khugepaged might come in and back some memory we
returned to the OS with a hugepage. I've come to the conclusion that
this is basically unavoidable without a new madvise flag and that it's
just not a good default. If this change lands, advice about Linux huge
page settings will be added to the GC guide.

Verified that this change doesn't regress Sweet, at least not on my
machine with:

/sys/kernel/mm/transparent_hugepage/enabled [always or madvise]
/sys/kernel/mm/transparent_hugepage/defrag [madvise]
/sys/kernel/mm/transparent_hugepage/khugepaged/max_ptes_none [0 or 511]

Unfortunately, this workaround means that we only get forced hugepages
on Linux 6.1+.

Fixes #61718.

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

9 months agonet/http: use testenv.Command instead of exec.Command in tests
Bryan C. Mills [Tue, 22 Aug 2023 15:01:29 +0000 (11:01 -0400)]
net/http: use testenv.Command instead of exec.Command 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: Ia2e9d14718a26001e030e162c69892497a8ebb21
Reviewed-on: https://go-review.googlesource.com/c/go/+/521816
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>

9 months agonet/netip: remove unused netIPv{4,6}len consts
Tobias Klauser [Tue, 22 Aug 2023 11:48:02 +0000 (13:48 +0200)]
net/netip: remove unused netIPv{4,6}len consts

These were added by CL 339309 but never used.

Change-Id: I40cbb5b18ac94e72bc56c15bb239677de2a202f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/521216
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agocmd/compile: use better line numbers for write barriers
Keith Randall [Mon, 21 Aug 2023 21:10:24 +0000 (14:10 -0700)]
cmd/compile: use better line numbers for write barriers

When the write barrier does several pointer writes under one
write barrier flag check, the line numbers aren't really correct.

The writes inside the write barrier have a confusing set of positions.
The loads of the old values are given the line number of the
corresponding store instruction, but the stores into the write buffer
are given the line number of the first store. Instead, give them all
line numbers corresponding to the store instruction.

The writes at the merge point, which are the original writes and the
only ones that happen when the barrier is off, are currently all given
the line number of the first write. Instead give them their original
line number.

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

9 months agocmd/compile: add single-precision FMA code generation for riscv64
Meng Zhuo [Wed, 28 Jun 2023 08:45:07 +0000 (16:45 +0800)]
cmd/compile: add single-precision FMA code generation for riscv64

This CL adds FMADDS,FMSUBS,FNMADDS,FNMSUBS SSA support for riscv

Change-Id: I1e7dd322b46b9e0f4923dbba256303d69ed12066
Reviewed-on: https://go-review.googlesource.com/c/go/+/506616
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: M Zhuo <mzh@golangcn.org>

9 months agocmd/compile: improve FP FMA performance on riscv64
Meng Zhuo [Mon, 26 Jun 2023 12:46:49 +0000 (20:46 +0800)]
cmd/compile: improve FP FMA performance on riscv64

FMADD/FMSUB/FNSUB are an efficient FP FMA instructions, which can
be used by the compiler to improve FP performance.

Erf               188.0n ± 2%   139.5n ± 2%  -25.82% (p=0.000 n=10)
Erfc              193.6n ± 1%   143.2n ± 1%  -26.01% (p=0.000 n=10)
Erfinv            244.4n ± 2%   172.6n ± 0%  -29.40% (p=0.000 n=10)
Erfcinv           244.7n ± 2%   173.0n ± 1%  -29.31% (p=0.000 n=10)
geomean           216.0n        156.3n       -27.65%

Ref: The RISC-V Instruction Set Manual Volume I: Unprivileged ISA
11.6 Single-Precision Floating-Point Computational Instructions

Change-Id: I89aa3a4df7576fdd47f4a6ee608ac16feafd093c
Reviewed-on: https://go-review.googlesource.com/c/go/+/506036
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: M Zhuo <mzh@golangcn.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agosyscall: add support for openbsd/ppc64
Joel Sing [Sat, 11 Mar 2023 15:15:43 +0000 (02:15 +1100)]
syscall: add support for openbsd/ppc64

Add syscall support for the openbsd/ppc64 port.

Updates #56001

Change-Id: I695c5c296e90645515de0c8f89f1bc57e976679d
Reviewed-on: https://go-review.googlesource.com/c/go/+/475636
Reviewed-by: Eric Grosse <grosse@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoruntime: add support for openbsd/ppc64
Joel Sing [Sat, 11 Mar 2023 15:09:06 +0000 (02:09 +1100)]
runtime: add support for openbsd/ppc64

Add runtime support for the openbsd/ppc64 port.

Updates #56001

Change-Id: I3cf010b34f96ce269858b02f16481fdad2cd5b77
Reviewed-on: https://go-review.googlesource.com/c/go/+/475618
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Eric Grosse <grosse@gmail.com>
9 months agoruntime: rework asmcgocall on ppc64x
Joel Sing [Sat, 18 Mar 2023 08:51:52 +0000 (19:51 +1100)]
runtime: rework asmcgocall on ppc64x

On some platforms asmcgocall can be called with a nil g. Additionally, it
can be called when already on a the system (g0) stack or on a signal stack.
In these cases we do not need to switch (and/or cannot switch) to the
system stack and as a result, do not need to save the g.

Rework asmcgocall on ppc64x to follow the pattern used on other architectures,
such as amd64 and arm64, where a separate nosave path is called in the above
cases. The nil g case will be needed to support openbsd/ppc64.

Updates #56001

Change-Id: I431d4200bcbc4aaddeb617aefe18590165ff2927
Reviewed-on: https://go-review.googlesource.com/c/go/+/478775
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/internal/obj/arm64: add test coverage for VMOVS and VMOVD
Joel Sing [Wed, 2 Aug 2023 14:42:54 +0000 (00:42 +1000)]
cmd/internal/obj/arm64: add test coverage for VMOVS and VMOVD

Change-Id: I31ba6696e124dccf37d674d090fdf04ba0a049a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/515616
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>

9 months agocmd/compile/internal/types: overhaul and simplify API
Matthew Dempsky [Sun, 20 Aug 2023 17:05:29 +0000 (10:05 -0700)]
cmd/compile/internal/types: overhaul and simplify API

This CL removes a lot of the redundant methods for accessing struct
fields and signature parameters. In particular, users never have to
write ".Slice()" or ".FieldSlice()" anymore; the exported APIs just do
what you want.

Further internal refactorings to follow.

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

9 months agocmd/compile/internal/walk: reuse runtime.scase
Matthew Dempsky [Mon, 21 Aug 2023 21:08:46 +0000 (14:08 -0700)]
cmd/compile/internal/walk: reuse runtime.scase

Shaves ~1.5kB off cmd/go binary.

Change-Id: I8ad85aa4a24bc197b009c8e1ea9201957222152a
Reviewed-on: https://go-review.googlesource.com/c/go/+/521677
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocmd/compile/internal/ssagen: share runtime._defer types
Matthew Dempsky [Mon, 21 Aug 2023 20:51:21 +0000 (13:51 -0700)]
cmd/compile/internal/ssagen: share runtime._defer types

Rather than constructing a new runtime._defer struct type at each
defer statement, we can use a single shared one. Also, by naming it
runtime._defer, we avoid emitting new runtime and DWARF type
descriptors in every package that contains a "defer" statement.

Shaves ~1kB off cmd/go.

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

9 months agocmd/compile/internal/reflectdata: share hmap and hiter types
Matthew Dempsky [Mon, 21 Aug 2023 18:26:15 +0000 (11:26 -0700)]
cmd/compile/internal/reflectdata: share hmap and hiter types

There's no need for distinct hmap and hiter types for each map.

Shaves 9kB off cmd/go binary size.

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

9 months agospec: clarify that []byte("") must be non-nil
Matthew Dempsky [Fri, 18 Aug 2023 22:52:34 +0000 (15:52 -0700)]
spec: clarify that []byte("") must be non-nil

The example text below suggests that []byte("") always evaluates to
the non-nil value []byte{}, but the text proper doesn't explicitly
require that. This CL makes it clear that it must not evaluate to
[]byte(nil), which otherwise was allowed by the wording.

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

9 months agoos/exec: don't convert byte slice to string when using verb %s
Jes Cok [Sat, 19 Aug 2023 00:21:00 +0000 (00:21 +0000)]
os/exec: don't convert byte slice to string when using verb %s

Change-Id: I4d755e401acf670fb5a154ff59e4e4335ed2138e
GitHub-Last-Rev: a91d74ae55f84a0e572d2ace335ec42038d7a76f
GitHub-Pull-Request: golang/go#62150
Reviewed-on: https://go-review.googlesource.com/c/go/+/520918
Run-TryBot: Ian Lance Taylor <iant@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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agonet: use avoidDNS for search suffixes
Mateusz Poliwczak [Fri, 21 Jul 2023 09:51:42 +0000 (09:51 +0000)]
net: use avoidDNS for search suffixes

The go resolver shouldn't attempt to query .onion domains, but
the restriction was not restricted for search domains.

Also before this change query for "sth.onion" would
not be suffixed with any search domain (for "go.dev" search
domain, it should query fine the "std.onion.go.dev" domain).

Change-Id: I0f3e1387e0d59721381695f94586e3743603c30e
GitHub-Last-Rev: 7e8ec44078529353c18c8fe34e5207014ce1e685
GitHub-Pull-Request: golang/go#60678
Reviewed-on: https://go-review.googlesource.com/c/go/+/501701
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/compile/internal/compare: simplify unit test framework
Matthew Dempsky [Sun, 20 Aug 2023 17:23:03 +0000 (10:23 -0700)]
cmd/compile/internal/compare: simplify unit test framework

This CL refactors the compare unit tests to be simpler and to stop
using the types API in non-idiomatic ways, to facilitate further
refactoring of the API.

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

9 months agocmd/compile/internal/abi: stop using types.Func
Matthew Dempsky [Sun, 20 Aug 2023 06:04:46 +0000 (23:04 -0700)]
cmd/compile/internal/abi: stop using types.Func

This is supposed to be an internal type within package types. At least
for now, users of the types package should stick to the types.Type
APIs as much as possible.

This CL also unexports FuncType and a few others to prevent
backsliding.

Change-Id: I053fc115a5e6a57c148c8149851a45114756072f
Reviewed-on: https://go-review.googlesource.com/c/go/+/521255
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: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile: do some TODOs about Fatalf
Matthew Dempsky [Sun, 20 Aug 2023 05:32:08 +0000 (22:32 -0700)]
cmd/compile: do some TODOs about Fatalf

Separate CL in case I'm mistaken.

Change-Id: I6b5fa0efb27a6b4fb4c133698bd7e2f01b4cccdb
Reviewed-on: https://go-review.googlesource.com/c/go/+/521195
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agoruntime: drop stack-allocated pcvalueCaches
Austin Clements [Tue, 1 Aug 2023 18:41:42 +0000 (14:41 -0400)]
runtime: drop stack-allocated pcvalueCaches

Now that pcvalue keeps its cache on the M, we can drop all of the
stack-allocated pcvalueCaches and stop carefully passing them around
between lots of operations. This significantly simplifies a fair
amount of code and makes several structures smaller.

This series of changes has no statistically significant effect on any
runtime Stack benchmarks.

I also experimented with making the cache larger, now that the impact
is limited to the M struct, but wasn't able to measure any
improvements.

This is a re-roll of CL 515277

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

9 months agoruntime: move pcvalue cache to M
Austin Clements [Tue, 1 Aug 2023 17:54:32 +0000 (13:54 -0400)]
runtime: move pcvalue cache to M

Currently, the pcvalue cache is stack allocated for each operation
that needs to look up a lot of pcvalues. It's not always clear where
to put it, a lot of the time we just pass a nil cache, it doesn't get
reused across operations, and we put a surprising amount of effort
into threading these caches around.

This CL moves it to the M, where it can be long-lived and used by all
pcvalue lookups, and we don't have to carefully thread it across
operations.

This is a re-roll of CL 515276 with a fix for reentrant use of the
pcvalue cache from the signal handler.

Change-Id: Id94c0c0fb3004d1fda1b196790eebd949c621f28
Reviewed-on: https://go-review.googlesource.com/c/go/+/520063
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agocmd/compile: remove more extension ops when not needed
Keith Randall [Mon, 21 Aug 2023 17:03:07 +0000 (10:03 -0700)]
cmd/compile: remove more extension ops when not needed

If we're not using the upper bits, don't bother issuing a
sign/zero extension operation.

For arm64, after CL 520916 which fixed a correctness bug with
extensions but as a side effect leaves many unnecessary ones
still in place.

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

9 months agocmd/compile: ensure we keep top 32 bits zeroed for 32-bit arm64 ops
Keith Randall [Fri, 18 Aug 2023 19:38:32 +0000 (12:38 -0700)]
cmd/compile: ensure we keep top 32 bits zeroed for 32-bit arm64 ops

When rewriting, for example, MSUBW, we need to ensure that the result
has its 32 top bits zeroed. That's what the instruction is spec'd to do.
Normally, we'd only use MSUBW for computations on 32-bit values, and
as such the top 32 bits aren't normally used. But some situations, like
if we cast the result to a uint64, the top 32 bits do matter.

This comes up in 62131 because we have a rule saying, MOVWUreg applied
to a MSUBW is unnecessary, as the arg to MOVWUreg already has zeroed
top 32 bits. But if MSUBW is later rewritten to another op that doesn't
zero the top 32 bits (SUB, probably), getting rid of the MOVWUreg earlier
causes a problem.

So change rewrite rules to always maintain the top 32 bits as zero if the
instruction is spec'd to provide that. We need to introduce a few *W operations
to make that happen.

Fixes #62131

Change-Id: If3d160821e285fd7454746b735a243671bff8894
Reviewed-on: https://go-review.googlesource.com/c/go/+/520916
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocontext: fix synchronization in ExampleAfterFunc_cond
Bryan C. Mills [Mon, 21 Aug 2023 16:55:43 +0000 (12:55 -0400)]
context: fix synchronization in ExampleAfterFunc_cond

Condition variables are subtle and error-prone, and this example
demonstrates exactly the sorts of problems that they introduce.
Unfortunately, we're stuck with them for the foreseeable future.

As previously implemented, this example was racy: since the callback
passed to context.AfterFunc did not lock the mutex before calling
Broadcast, it was possible for the Broadcast to occur before the
goroutine was parked in the call to Wait, causing in a missed wakeup
resulting in deadlock.

The example also had a more insidious problem: it was not safe for
multiple goroutines to call waitOnCond concurrently, but the whole
point of using a sync.Cond is generally to synchronize concurrent
goroutines. waitOnCond must use Broadcast to ensure that it wakes up
the target goroutine, but the use of Broadcast in this way would
produce spurious wakeups for all of the other goroutines waiting on
the same condition variable. Since waitOnCond did not recheck the
condition in a loop, those spurious wakeups would cause waitOnCond
to spuriously return even if its own ctx was not yet done.

Fixing the aforementioned bugs exposes a final problem, inherent to
the use of condition variables in this way. This one is a performance
problem: for N concurrent calls to waitOnCond, the resulting CPU cost
is at least O(N²). This problem cannot be addressed without either
reintroducing one of the above bugs or abandoning sync.Cond in the
example entirely. Given that this example was already published in Go
1.21, I worry that Go users may think that it is appropriate to use a
sync.Cond in conjunction with context.AfterFunc, so I have chosen to
retain the Cond-based example and document its pitfalls instead of
removing or replacing it entirely.

I described this class of bugs and performance issues — and suggested
some channel-based alternatives — in my GopherCon 2018 talk,
“Rethinking Classical Concurrency Patterns”. The section on condition
variables starts on slide 37. (https://youtu.be/5zXAHh5tJqQ?t=679)

Fixes #62180.
For #20491.

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

9 months agocmd/go: find GOROOT using os.Executable when installed to GOROOT/bin/GOOS_GOARCH
Bryan C. Mills [Fri, 18 Aug 2023 19:38:44 +0000 (15:38 -0400)]
cmd/go: find GOROOT using os.Executable when installed to GOROOT/bin/GOOS_GOARCH

When running make.bash in a cross-compiled configuration
(for example, GOARCH different from GOHOSTARCH), cmd/go
is installed to GOROOT/bin/GOOS_GOARCH instead of GOROOT/bin.

That means that we need to look for GOROOT in both ../.. and ../../..,
not just the former.

Fixes #62119.
Updates #18678.

Change-Id: I283c6a10c46df573ff44da826f870417359226a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/521015
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile: move racewalk comment to walk/race.go
Austin Clements [Fri, 7 Jul 2023 21:06:23 +0000 (17:06 -0400)]
cmd/compile: move racewalk comment to walk/race.go

This comment got left behind in some refactoring and now refers to
code "below" that is no longer below. Move it to be with the code it's
referring to.

Change-Id: I7f7bf0cf8b22c1f6e05ff12b8be71d18fb3359d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/521177
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Austin Clements <austin@google.com>
TryBot-Bypass: Austin Clements <austin@google.com>

9 months agoruntime: remove runtime.Add testing function
Austin Clements [Tue, 27 Jun 2023 02:34:05 +0000 (22:34 -0400)]
runtime: remove runtime.Add testing function

Replace with unsafe.Add.

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

9 months agonet/http: clear reference to the request context after transport getConn
Alexander Yastrebov [Tue, 25 Jul 2023 10:53:58 +0000 (10:53 +0000)]
net/http: clear reference to the request context after transport getConn

Clears wannConn ctx and prevents pending dialConnFor after connection delivered or canceled.

Updates #50798

Change-Id: I9a681ac0f222be56571fa768700220f6b5ee0888
GitHub-Last-Rev: fd6c83ab072c62d224ed8220c4c286b6e90bc151
GitHub-Pull-Request: golang/go#61524
Reviewed-on: https://go-review.googlesource.com/c/go/+/512196
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agonet/http: use cancelKey to cancel request
Alexander Yastrebov [Wed, 2 Aug 2023 22:15:59 +0000 (22:15 +0000)]
net/http: use cancelKey to cancel request

Follows up on CL 245357 and adds missing returns in waitCondition (CL 477196)

Fixes #51354

Change-Id: I7950ff889ad72c4927a969c35fedc0186e863bd6
GitHub-Last-Rev: 52ce05bc83ef88c7104df9254bc1add0dda83ae0
GitHub-Pull-Request: golang/go#61724
Reviewed-on: https://go-review.googlesource.com/c/go/+/515435
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>

9 months agoos: add tests for UserCacheDir and UserConfigDir
Josh Kraft [Thu, 17 Aug 2023 00:36:46 +0000 (18:36 -0600)]
os: add tests for UserCacheDir and UserConfigDir

Adds basic test scenarios for UserCacheDir and
UserConfigDir.

Fixes #57638

Change-Id: Ieb86e95faff44287bfa13daa0cb26e7b5401373b
Reviewed-on: https://go-review.googlesource.com/c/go/+/520262
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Bypass: Bryan Mills <bcmills@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

9 months agoruntime: document maxStack and m.createstack in more details
Andy Pan [Thu, 10 Aug 2023 06:02:03 +0000 (14:02 +0800)]
runtime: document maxStack and m.createstack in more details

Change-Id: If93b6cfa5a598a5f4101c879a0cd88a194e4a6aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/518116
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Andy Pan <panjf2000@gmail.com>

9 months agoos: avoid allocating a string for ReadDir skipped entries on Windows
qmuntal [Thu, 17 Aug 2023 08:26:36 +0000 (10:26 +0200)]
os: avoid allocating a string for ReadDir skipped entries on Windows

Shave off a few allocations while reading a directory by checking
if the entry name is "." or ".." before allocating a string for it.

Change-Id: I05a87d7572bd4fc191db70aaa9e22a6102f68b4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/520415
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoruntime: add self-check mode to cache in pcvalue
Austin Clements [Wed, 16 Aug 2023 16:30:10 +0000 (12:30 -0400)]
runtime: add self-check mode to cache in pcvalue

This would have helped with debugging the failures caused by CL 515276.

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

9 months agocmd/compile/internal/typecheck: add selector helpers
Matthew Dempsky [Sat, 19 Aug 2023 02:40:33 +0000 (19:40 -0700)]
cmd/compile/internal/typecheck: add selector helpers

This CL refactors common patterns for constructing field and method
selector expressions. Notably, XDotField and XDotMethod are now the
only two functions where a SelecterExpr with OXDOT is constructed.

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

9 months agocmd/compile/internal/typecheck: simplify NewMethodExpr
Matthew Dempsky [Sat, 19 Aug 2023 01:13:58 +0000 (18:13 -0700)]
cmd/compile/internal/typecheck: simplify NewMethodExpr

This CL changes NewMethodExpr to directly construct the OMETHEXPR
node, instead of running through the generic OXDOT typechecking
machinery.

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

9 months agocmd/compile/internal/typecheck: add NewMethodExpr helper
Matthew Dempsky [Sat, 19 Aug 2023 01:03:24 +0000 (18:03 -0700)]
cmd/compile/internal/typecheck: add NewMethodExpr helper

This CL refactors the common pattern for constructing OMETHEXPR nodes,
which is the most common use of ir.TypeNode currently.

Change-Id: I446a21af97ab5a4bc2f04bbd581c1ede8a5ede60
Reviewed-on: https://go-review.googlesource.com/c/go/+/520978
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agocmd/compile/internal/typecheck: refactor and simplify DeclFunc
Matthew Dempsky [Sat, 19 Aug 2023 00:43:15 +0000 (17:43 -0700)]
cmd/compile/internal/typecheck: refactor and simplify DeclFunc

This CL refactors typecheck.DeclFunc to require the caller to have
already constructed the ir.Func and signature type using ir.NewFunc
and types.NewSignature, and simplifies typecheck.DeclFunc to simply
return the slices of param and results ONAMEs.

typecheck.DeclFunc was the last reason that ir.Field still exists, so
this CL also gets rid of that.

Change-Id: Ib398420bac2fd135a235810b8af1635fa754965c
Reviewed-on: https://go-review.googlesource.com/c/go/+/520977
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agoslices: simplify Clone a bit
Brad Fitzpatrick [Sat, 19 Aug 2023 16:08:38 +0000 (09:08 -0700)]
slices: simplify Clone a bit

No need for an explicit nil check. Slicing the input slice
down to zero capacity also preserves nil.

Change-Id: I1f53cc485373d0e65971cd87b6243650ac72612c
Reviewed-on: https://go-review.googlesource.com/c/go/+/521037
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agonet: return "cannot unmarshal" error while parsing DNS messages
Mateusz Poliwczak [Sat, 19 Aug 2023 07:52:34 +0000 (07:52 +0000)]
net: return "cannot unmarshal" error while parsing DNS messages

Change-Id: I407f5d3d3a3e8b3d43ff154f731d885e831971e9
GitHub-Last-Rev: d6a400d1ba6a09e726c9b4e4774a7e8a611611e8
GitHub-Pull-Request: golang/go#62155
Reviewed-on: https://go-review.googlesource.com/c/go/+/520980
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>

9 months agocmd/compile/internal/gc: remove unused reflectdata import
Dmitri Shuralyov [Sat, 19 Aug 2023 22:59:04 +0000 (18:59 -0400)]
cmd/compile/internal/gc: remove unused reflectdata import

CL 521036 was prepared and tested before the revert CL 521155,
and it so happens that the reflectdata import ended up unused.
Drop it to fix the build.

Change-Id: I230c8fee616fc58cc82f3e5da886bcee2e02a3d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/521175
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@google.com>

9 months agoexpvar: emit valid JSON strings
Joe Tsai [Tue, 14 Mar 2023 22:35:36 +0000 (15:35 -0700)]
expvar: emit valid JSON strings

Map.String and expvarHandler used the %q flag with fmt.Fprintf
to escape Go strings, which does so according to the Go grammar,
which is not always compatible with JSON strings.

Rather than calling json.Marshal for every string,
which will always allocate, declare a local appendJSONQuote
function that does basic string escaping.
Also, we declare an unexported appendJSON method on every
concrete Var type so that the final JSON output can be
constructed with far fewer allocations.

The resulting logic is both more correct and also much faster.
This does not alter the whitespace style of Map.String or expvarHandler,
but may alter the representation of JSON strings.

Performance:

name         old time/op    new time/op    delta
MapString    5.10µs ± 1%    1.56µs ± 1%  -69.33%  (p=0.000 n=10+9)

name         old alloc/op   new alloc/op   delta
MapString    1.21kB ± 0%    0.66kB ± 0%  -45.12%  (p=0.000 n=10+10)

name         old allocs/op  new allocs/op  delta
MapString      37.0 ± 0%       7.0 ± 0%  -81.08%  (p=0.000 n=10+10)

Fixes #59040

Change-Id: I46a2125f43550b91d52019e5edc003d9dd19590f
Reviewed-on: https://go-review.googlesource.com/c/go/+/476336
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoencoding/csv: correct Column docs
Ian Lance Taylor [Fri, 18 Aug 2023 23:34:29 +0000 (16:34 -0700)]
encoding/csv: correct Column docs

For #44221
Fixes #62147

Change-Id: Ibcc0d11c8253f51a8f5771791ea4173a38a61950
Reviewed-on: https://go-review.googlesource.com/c/go/+/520917
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agoencoding/gob: prevent panic from index out of range in Decoder.typeString
Andy Pan [Fri, 18 Aug 2023 05:39:57 +0000 (13:39 +0800)]
encoding/gob: prevent panic from index out of range in Decoder.typeString

I believe this bug is introduced by CL 460543 which optimizes the allocations
by changing the type of `idToType` from map to slice, but didn't update the
access code in `Decoder.typeString` that is safe for map but not for slice.

Fixes #62117

Change-Id: I0f2e4cc2f34c54dada1f83458ba512a6fde6dcbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/520757
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: Andy Pan <panjf2000@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

9 months agocmd/compile/internal/typecheck: remove NeedRuntimeType
Matthew Dempsky [Fri, 18 Aug 2023 08:14:50 +0000 (01:14 -0700)]
cmd/compile/internal/typecheck: remove NeedRuntimeType

The only remaining use for typecheck.NeedRuntimeType is to make sure
that method expressions with anonymous receiver types (e.g.,
"struct{T}.M") have the promoted-method wrapper generated. But the
unified frontend takes care of arranging for this now.

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

9 months agoencoding: optimize growth behavior in Encoding.AppendDecode
Joe Tsai [Thu, 17 Aug 2023 04:27:15 +0000 (21:27 -0700)]
encoding: optimize growth behavior in Encoding.AppendDecode

The Encoding.DecodedLen API only returns the maximum length of the
expected decoded output, since it does not know about padding.
Since we have the input, we can do better by computing the
input length without padding, and then perform the DecodedLen
calculation as if there were no padding.

This avoids over-growing the destination slice if possible.
Over-growth is still possible since the input may contain
ignore characters like newlines and carriage returns,
but those a rarely encountered in practice.

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

9 months agoRevert "cmd/compile/internal/gc: steps towards work-queue"
Matthew Dempsky [Sat, 19 Aug 2023 20:09:05 +0000 (20:09 +0000)]
Revert "cmd/compile/internal/gc: steps towards work-queue"

This reverts commit CL 520611.

Reason for revert: #62156.

Change-Id: Iebd17bdfc00824de3d5011a74d071a41c4fa06f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/521155
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
9 months agotime: make Duration.String inlineable
Joe Tsai [Fri, 18 Aug 2023 01:13:01 +0000 (18:13 -0700)]
time: make Duration.String inlineable

Perform the [32]byte to string conversion in an inlinable method.
Thus, if the result does not escape in the context of the caller,
we can entirely avoid a call to runtime.slicebytetostring.

Change-Id: Iae8ec2a532776ed6cf99597f19e3f7f21c694c3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/520602
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agoerrors: optimize Is and As by reusing reflection of target
j178 [Fri, 18 Aug 2023 04:04:35 +0000 (12:04 +0800)]
errors: optimize Is and As by reusing reflection of target

goos: darwin
goarch: amd64
pkg: errors
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
        │     old     │                 new                 │
        │   sec/op    │   sec/op     vs base                │
Is-12     133.4n ± 0%   126.8n ± 3%   -4.91% (p=0.001 n=10)
As-12     464.1n ± 1%   307.2n ± 0%  -33.80% (p=0.000 n=10)
geomean   248.8n        197.4n       -20.66%

        │    old     │                 new                 │
        │    B/op    │    B/op     vs base                 │
Is-12     24.00 ± 0%   24.00 ± 0%       ~ (p=1.000 n=10) ¹
As-12     40.00 ± 0%   40.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean   30.98        30.98       +0.00%
¹ all samples are equal

        │    old     │                 new                 │
        │ allocs/op  │ allocs/op   vs base                 │
Is-12     1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=10) ¹
As-12     2.000 ± 0%   2.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean   1.414        1.414       +0.00%
¹ all samples are equal

Change-Id: I0844f3ab77e63b5f773594157dcffaffffd5e70d
Reviewed-on: https://go-review.googlesource.com/c/go/+/520756
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
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 agocmd/compile: construct more IR nodes as typed
Matthew Dempsky [Fri, 18 Aug 2023 07:54:28 +0000 (00:54 -0700)]
cmd/compile: construct more IR nodes as typed

As of this CL, all OLITERAL, OLINKSYMOFFSET, ONIL, and OTYPE nodes are
constructed as typed and typechecked.

Change-Id: I39b2ad772a9b0419c701890a505a0949f9ea456e
Reviewed-on: https://go-review.googlesource.com/c/go/+/520795
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
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 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: I0e51e60f6ef9e7f96a4a3ccd5801f7baf83eba9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/520611
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/compile/internal/ir: remove AsNode
Matthew Dempsky [Fri, 18 Aug 2023 07:09:06 +0000 (00:09 -0700)]
cmd/compile/internal/ir: remove AsNode

Except for a single call site in escape analysis, every use of
ir.AsNode involves a types.Object that's known to contain
an *ir.Name. Asserting directly to that type makes the code simpler
and more efficient.

The one use in escape analysis is extended to handle nil correctly
without it.

Change-Id: I694ae516903e541341d82c2f65a9155e4b0a9809
Reviewed-on: https://go-review.googlesource.com/c/go/+/520775
TryBot-Bypass: Matthew Dempsky <mdempsky@google.com>
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: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/compile/internal/typecheck: remove DeclContext
Matthew Dempsky [Fri, 18 Aug 2023 06:28:32 +0000 (23:28 -0700)]
cmd/compile/internal/typecheck: remove DeclContext

The last use of this was removed in go.dev/cl/518757.

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

9 months agocmd/compile/internal/ir: remove Ntype
Matthew Dempsky [Fri, 18 Aug 2023 06:23:40 +0000 (23:23 -0700)]
cmd/compile/internal/ir: remove Ntype

This type used to provide extra type safety around which syntactic
nodes could also represent types, but now the only remaining use is
ir.TypeNode, and it always ends up as an ir.Node anyway. So we might
as well use Node instead.

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

9 months agocmd/compile/internal/ir: remove OFUNCINST and InstExpr
Matthew Dempsky [Fri, 18 Aug 2023 06:04:08 +0000 (23:04 -0700)]
cmd/compile/internal/ir: remove OFUNCINST and InstExpr

These were only ever used by the pre-unified generics frontend. I
initially kept them because I thought they'd be useful for the unified
frontend eventually too, but that hasn't manifested.

Change-Id: Iaa31a76ac4d62533ec269d2a7141442b8e344180
Reviewed-on: https://go-review.googlesource.com/c/go/+/520608
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/compile/internal/typecheck: prune some useless code
Matthew Dempsky [Fri, 18 Aug 2023 06:01:42 +0000 (23:01 -0700)]
cmd/compile/internal/typecheck: prune some useless code

This error checking code is all obsolete by types2.

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

9 months agocmd/compile: remove some uses of ir.CurFunc
Matthew Dempsky [Fri, 18 Aug 2023 05:13:22 +0000 (22:13 -0700)]
cmd/compile: remove some uses of ir.CurFunc

This CL updates several frontend passes to stop relying on
ir.CurFunc (at least directly).

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

9 months agocmd/compile/internal/typecheck: replace Temp calls with TempAt
Matthew Dempsky [Fri, 18 Aug 2023 05:19:10 +0000 (22:19 -0700)]
cmd/compile/internal/typecheck: replace Temp calls with TempAt

Steps towards eliminating implicit dependencies on base.Pos and
ir.CurFunc. Mechanical CL produced with gofmt -r.

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

9 months agocmd/compile/internal/reflectdata: remove special case for init
Matthew Dempsky [Fri, 18 Aug 2023 05:16:07 +0000 (22:16 -0700)]
cmd/compile/internal/reflectdata: remove special case for init

Now that package initialization ordering is handled by types2 instead
of pkginit, we can get rid of this special case.

Change-Id: I4b94df02813b662498ae7d2e829119e3bb932d6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/520604
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agocmd/compile: prune some deadcode around ODCLFUNC
Matthew Dempsky [Fri, 18 Aug 2023 05:04:49 +0000 (22:04 -0700)]
cmd/compile: prune some deadcode around ODCLFUNC

An *ir.Func is always ODCLFUNC, so no need to double-check this
anymore. The type system statically ensures we have the right Op.

Also, pkginit.initRequiredForCoverage appears to be unused, so we can
get rid of it completely.

Change-Id: If1abb35672b40f705f23c365ad2a828c2661e9c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/520603
Run-TryBot: Matthew Dempsky <mdempsky@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>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agoencoding/json: use base64.Encoding.AppendEncode
Andy Pan [Fri, 18 Aug 2023 03:54:48 +0000 (11:54 +0800)]
encoding/json: use base64.Encoding.AppendEncode

For #53693

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

9 months agospec: correct type parameter name used in example
Ian Lance Taylor [Fri, 18 Aug 2023 16:44:16 +0000 (09:44 -0700)]
spec: correct type parameter name used in example

Change-Id: I40595a3f598483d029473af465c756f8777ecc91
Reviewed-on: https://go-review.googlesource.com/c/go/+/520915
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agoruntime/internal/wasitest: skip racy TCP echo test
Chris O'Hara [Wed, 16 Aug 2023 01:14:53 +0000 (11:14 +1000)]
runtime/internal/wasitest: skip racy TCP echo test

The wasip1 TCP echo test introduced in CL 493358 has a race
condition with port selection. The test runner probes for a free
port and then asks the WASM runtime to listen on the port, which
may be taken by another process in the interim.

Due to limitations with WASI preview 1, the guest is unable to
query the port it's listening on. The test cannot ask the WASM
runtime to listen on port 0 (choose a free port) since there's
currently no way for the test to query the selected port and
connect to it.

Given the race condition is unavoidable, this test is now disabled
by default and requires opt-in via an environment variable.

This commit also eliminates the hard-coded connection timeout.

Fixes #61820.

Change-Id: I375145c1a1d03ad45c44f528da3347397e6dcb01
Reviewed-on: https://go-review.googlesource.com/c/go/+/519895
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agoruntime/pprof: increase contention upper bound in TestMutexProfile
Michael Anthony Knyszek [Thu, 17 Aug 2023 18:36:00 +0000 (18:36 +0000)]
runtime/pprof: increase contention upper bound in TestMutexProfile

Currently TestMutexProfile expects contention to reported as somewhere
between 0.9x and 2.0x the expected amount introduced. While bounding
from below is fine (especially since the goroutine holding the mutex
doesn't even start to sleep until the required number of goroutines are
blocked on a mutex), bounding from above can easily lead to flakiness.
Delays and non-determinism can come from anywhere in the system,
and nevertheless clocks keep ticking. The result is that goroutines
could easily appear to be blocked on a mutex much longer than just the
sleep time.

However, the contention upper bound is still useful, especially for
identifying wildly incorrect values. Set the contention total to be
proportional to the total wall-time spent in the actual sampling mutex
block sampling portion of the code. This should be a generous
upper-bound on how much contention there could be, because it should in
theory capture any delays from the environment in it as well.

Still, rounding errors could be an issue, and on Windows the time
granularity is quite low (~15ms, or 15% of what each goroutine is
supposed to add to the mutex profile), so getting unlucky with where
time measurements fall within each tick could also be a problem. Add an
extra 10%, which seems to make it much less likely to fail in a Windows
gomote.

Fixes #62094.

Change-Id: I59a10a73affd077185dada8474b91d0bc43b4a43
Reviewed-on: https://go-review.googlesource.com/c/go/+/520635
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>

9 months agocmd/link: don't mangle string symbol names
Cherry Mui [Fri, 18 Aug 2023 15:10:23 +0000 (11:10 -0400)]
cmd/link: don't mangle string symbol names

String symbol names could contain weird characters as we put the
string literal into the symbol name. So it may appear to need
mangling. However, as string symbols are grouped into a single
"go:string.*" symbol, the individual symbol names actually don't
matter. So don't mangle them.

Also make the mangling code more defensive in case of weird
symbol names.

Fixes #62098.

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

9 months agocmd/compile: enable -d=zerocopy by default
Matthew Dempsky [Fri, 18 Aug 2023 00:04:10 +0000 (17:04 -0700)]
cmd/compile: enable -d=zerocopy by default

Fixes #2205.

Change-Id: Ib0802fee2b274798b35f0ebbd0b736b1be5ae00a
Reviewed-on: https://go-review.googlesource.com/c/go/+/520600
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agocmd/compile: restore zero-copy string->[]byte optimization
Matthew Dempsky [Thu, 17 Aug 2023 21:15:04 +0000 (14:15 -0700)]
cmd/compile: restore zero-copy string->[]byte optimization

This CL implements the remainder of the zero-copy string->[]byte
conversion optimization initially attempted in go.dev/cl/520395, but
fixes the tracking of mutations due to ODEREF/ODOTPTR assignments, and
adds more comprehensive tests that I should have included originally.

However, this CL also keeps it behind the -d=zerocopy flag. The next
CL will enable it by default (for easier rollback).

Updates #2205.

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