1
0
mirror of https://github.com/golang/go synced 2024-09-30 04:24:29 -06:00
Commit Graph

57604 Commits

Author SHA1 Message Date
Matthew Dempsky
2a0b8cfd80 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>
2023-08-18 22:38:01 +00:00
Matthew Dempsky
569def31fa 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>
2023-08-18 22:37:59 +00:00
Andy Pan
3419a0aec1 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>
2023-08-18 21:40:31 +00:00
Ian Lance Taylor
ce16086345 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>
2023-08-18 20:44:48 +00:00
Chris O'Hara
795e779610 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>
2023-08-18 17:06:41 +00:00
Michael Anthony Knyszek
e8a767b609 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>
2023-08-18 16:15:18 +00:00
Cherry Mui
b65e34f038 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>
2023-08-18 15:53:47 +00:00
Matthew Dempsky
d63c88d695 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>
2023-08-18 11:59:42 +00:00
Matthew Dempsky
925d2fb36c 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>
2023-08-18 11:58:37 +00:00
Joe Tsai
243c8c0eec encoding: require unique alphabet for base32 and base64
In order for decoding to faithfully reproduce the encoded input,
the symbols must be unique (i.e., provide a bijective mapping).
Thus, reject duplicate symbols in NewEncoding.

As a minor optimization, modify WithPadding to use the decodeMap
to quickly check whether the padding character is used in O(1)
instead of O(32) or O(64).

Change-Id: I5631f6ff9335c35d59d020dc0e307e3520786fbc
Reviewed-on: https://go-review.googlesource.com/c/go/+/520335
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
2023-08-18 02:08:03 +00:00
Robert Griesemer
9070f27039 go/types, types2: disable interface inference for versions before Go 1.21
Change the internal constant enableInterfaceInference to a unifier
field that can be controlled dynamically and set it for Go 1.21
or later.

This restores Go 1.20 unification behavior for interfaces.

Fixes #61903.

Change-Id: Iefd6c0899811f8208a8be9cef2650a07787ae177
Reviewed-on: https://go-review.googlesource.com/c/go/+/519855
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
2023-08-17 23:33:10 +00:00
Robert Griesemer
60dd831103 Revert "go/types, types2: remove internal constant enableInterfaceInference"
This reverts CL 514715.

This will make it easier to make interface inference conditional
based on the current language version.

For #61903.

Change-Id: I07820c861d6ebfd04899e41eb4123f26af2da1ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/520195
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
2023-08-17 23:32:40 +00:00
Robert Griesemer
ab3332eea9 spec: fix unification rule for inexact interface unification
Irrespective of whether unification is exact or inexact, method
signatures of interfaces must always match exactly: a type never
satisfies/implements an interface if relevant method signatures
are different (i.e., not identical, possibly after substitution).

This change matches the fix https://go.dev/cl/519435.

For #61879.

Change-Id: I28b0a32d32626d85afd32e107efce141235a923d
Reviewed-on: https://go-review.googlesource.com/c/go/+/519455
TryBot-Bypass: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-08-17 22:56:50 +00:00
Matthew Dempsky
639f6f7e78 cmd/compile/internal/ssagen: fix race added in CL 510539
The ssagen pass runs concurrently, so it's not safe to mutate global
variables like this.

Instead, turn it into a constant and add an assertion that the
constant has the correct value.

Fixes #62095.

Change-Id: Ia7f07e33582564892d194153ac3d8759429fc9ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/520598
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-08-17 21:51:00 +00:00
Guoqi Chen
6a1182027c internal/sysinfo: print cpu type from cpuinfo when internal cpu name is empty on Linux
Supports all linux operating systems. currently tested on x86, mips64le and loong64.

Example output:
$ go test -bench=.*
goos: linux
goarch: loong64
pkg: runtime
cpu: Loongson-3A5000-HV @ 2500.00MHz
BenchmarkSemTable/OneAddrCollision/n=1000         	   19261	     62302 ns/op
    ...

Change-Id: I02db12d70c11327e4625bb6e59f30dfaf37c2db0
Reviewed-on: https://go-review.googlesource.com/c/go/+/508735
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
2023-08-17 21:40:36 +00:00
Artem Teleshev
bcf83825ca log/slog: rename receiver name for the Value struct from a to v
Change-Id: Ib06234e781ed2faf5fa36efeda75c5ae439890ba
GitHub-Last-Rev: 760af94367
GitHub-Pull-Request: golang/go#61886
Reviewed-on: https://go-review.googlesource.com/c/go/+/517556
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-08-17 21:35:14 +00:00
Ian Lance Taylor
11390998ff cmd/internal/buildid: don't crash on 0 phdr.p_align field
A 0 in phdr.p_align is the same as 1, meaning no alignment.

Fixes #62097

Change-Id: I931bab443fd6a89b5b45c8f99ead217f02e9b453
Reviewed-on: https://go-review.googlesource.com/c/go/+/520597
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-08-17 20:40:42 +00:00
Matthew Dempsky
b75ac7a8d5 Revert "cmd/compile: enable zero-copy string->[]byte conversions"
This reverts CL 520395.

Reason for revert: thanm@ pointed out failure cases.

Change-Id: I3fd60b73118be3652be2c08b77ab39e793b42110
Reviewed-on: https://go-review.googlesource.com/c/go/+/520596
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-08-17 20:02:02 +00:00
Matthew Dempsky
48e05ee749 cmd/compile/internal/pkginit: use typecheck.LookupRuntime for asan
Change-Id: Ie9c90aa4560c982902738659737ae125cfcb6ba9
Reviewed-on: https://go-review.googlesource.com/c/go/+/520397
Run-TryBot: Matthew Dempsky <mdempsky@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>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-08-17 19:37:37 +00:00
Matthew Dempsky
c8adb3004f cmd/compile: enable zero-copy string->[]byte conversions
This CL enables the latent support for string->[]byte conversions
added go.dev/cl/520259.

One catch is that we need to make sure []byte("") evaluates to a
non-nil slice, even if "" is (nil, 0). This CL addresses that by
adding a "ptr != nil" check for OSTR2BYTESTMP, unless the NonNil flag
is set.

The existing uses of OSTR2BYTESTMP (which aren't concerned about
[]byte("") evaluating to nil) are updated to set this flag.

Fixes #2205.

Change-Id: I35a9cb16c164cd86156b7560915aba5108d8b523
Reviewed-on: https://go-review.googlesource.com/c/go/+/520395
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>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-08-17 19:37:36 +00:00
Matthew Dempsky
b805e18fbf cmd/compile/internal/escape: cleanup go/defer normalization cruft
This CL removes the extra complexity from escape analysis that was
only needed to support go/defer normalization. It does not affect
analysis results at all.

Change-Id: I75785e0cb4c4ce19bea3b8df0bf95821bd885291
Reviewed-on: https://go-review.googlesource.com/c/go/+/520261
TryBot-Result: Gopher Robot <gobot@golang.org>
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>
2023-08-17 19:37:33 +00:00
Matthew Dempsky
2c51ea11b0 cmd/compile/internal/typecheck: push ONEW into go/defer wrappers
Currently, we rewrite:

	go f(new(T))

into:

	tmp := new(T)
	go func() { f(tmp) }()

However, we can both shrink the closure and improve escape analysis by
instead rewriting it into:

	go func() { f(new(T)) }()

This CL does that.

Change-Id: Iae16a476368da35123052ca9ff41c49159980458
Reviewed-on: https://go-review.googlesource.com/c/go/+/520340
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: Dmitri Shuralyov <dmitshur@google.com>
2023-08-17 19:37:04 +00:00
Matthew Dempsky
7e2e648a2d cmd/compile/internal/typecheck: normalize go/defer statements earlier
Normalizing go/defer statements to always use functions with zero
parameters and zero results was added to escape analysis, because that
was the earliest point at which all three frontends converged. Now
that we only have the unified frontend, we can do it during typecheck,
which is where we perform all other desugaring and normalization
rewrites.

Change-Id: Iebf7679b117fd78b1dffee2974bbf85ebc923b23
Reviewed-on: https://go-review.googlesource.com/c/go/+/520260
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: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-17 19:36:58 +00:00
Matthew Dempsky
f4e6815652 cmd/compile/internal/noder: remove inlined closure naming hack
I previously used a clumsy hack to copy Closgen back and forth while
inlining, to handle when an inlined function contains closures, which
need to each be uniquely numbered.

The real solution was to name the closures using r.inlCaller, rather
than r.curfn. This CL adds a helper method to do exactly this.

Change-Id: I510553b5d7a8f6581ea1d21604e834fd6338cb06
Reviewed-on: https://go-review.googlesource.com/c/go/+/520339
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>
2023-08-17 19:36:29 +00:00
Matthew Dempsky
4e411e7bc4 cmd/compile: cleanup Func construction
This CL moves more common Func-setup logic into ir.NewFunc. In
particular, it now handles constructing the Name and wiring them
together, setting the Typecheck bit, and setting Sym.Func.

Relatedly, this CL also extends typecheck.DeclFunc to append the
function to typecheck.Target.Funcs, so that callers no longer need to
do this.

Change-Id: Ifa0aded8df0517188eb295d0dccc107af85f1e8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/520338
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>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2023-08-17 19:36:28 +00:00
Matthew Dempsky
5c6fbd2c3e cmd/compile: always construct typechecked closures
This CL extends ir.NewClosureFunc to take the signature type argument,
and to handle naming the closure and adding it to typecheck.Target.

It also removes the code for typechecking OCLOSURE and ODCLFUNC nodes,
by having them always constructed as typechecked. ODCLFUNC node
construction will be further simplified in the followup CL.

Change-Id: Iabde4557d33051ee470a3bc4fd49599490024cba
Reviewed-on: https://go-review.googlesource.com/c/go/+/520337
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-08-17 19:36:26 +00:00
Matthew Dempsky
e453971005 cmd/compile/internal/ir: add typ parameter to NewNameAt
Start making progress towards constructing IR with proper types.

Change-Id: Iad32c1cf60f30ceb8e07c31c8871b115570ac3bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/520263
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-08-17 19:36:24 +00:00
Joe Tsai
d63652b7c6 log/slog: simplify and optimize RFC3339 handling
In CL 421877 and CL 444278, time.Time.AppendFormat has been
specially optimized for the time.RFC3339Nano representation.
Relying on that optimization and modify the output to obtain the
fixed-width millisecond resolution that slog uses.

This both removes a lot of code and also improves performance:

	name       old time/op  new time/op  delta
	WriteTime  93.0ns ± 1%  80.8ns ± 0%  -13.17%  (p=0.000 n=8+9)

Change-Id: I61e8f4476c111443e3e2098a45b2c21a76137345
Reviewed-on: https://go-review.googlesource.com/c/go/+/478757
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
2023-08-17 16:48:35 +00:00
chanxuehong
aaa384cf3a math/big, math/rand: use the built-in max function
Change-Id: I71a38dd20bfaf2b1aed18892d54eeb017d3d7d66
GitHub-Last-Rev: 8da43b2cbd
GitHub-Pull-Request: golang/go#61955
Reviewed-on: https://go-review.googlesource.com/c/go/+/518595
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
2023-08-17 16:42:19 +00:00
Matthew Dempsky
36fc721419 cmd/compile/internal/ir: remove ODCLCONST and ODCLTYPE
These aren't constructed by the unified frontend.

Change-Id: Ied87baa9656920bd11055464bc605933ff448e21
Reviewed-on: https://go-review.googlesource.com/c/go/+/520264
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@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>
2023-08-17 16:36:37 +00:00
Matthew Dempsky
ff47dd1d66 cmd/compile/internal/escape: optimize indirect closure calls
This CL extends escape analysis in two ways.

First, we already optimize directly called closures. For example,
given:

	var x int  // already stack allocated today
	p := func() *int { return &x }()

we don't need to move x to the heap, because we can statically track
where &x flows. This CL extends the same idea to work for indirectly
called closures too, as long as we know everywhere that they're
called. For example:

	var x int  // stack allocated after this CL
	f := func() *int { return &x }
	p := f()

This will allow a subsequent CL to move the generation of go/defer
wrappers earlier.

Second, this CL adds tracking to detect when pointer values flow to
the pointee operand of an indirect assignment statement (i.e., flows
to p in "*p = x") or to builtins that modify memory (append, copy,
clear). This isn't utilized in the current CL, but a subsequent CL
will make use of it to better optimize string->[]byte conversions.

Updates #2205.

Change-Id: I610f9c531e135129c947684833e288ce64406f35
Reviewed-on: https://go-review.googlesource.com/c/go/+/520259
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>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-08-17 16:36:09 +00:00
Jes Cok
f278ae61d5 fmt: amend comment for getField
Change-Id: I52c9ed0c1a178f3ae3eb4f135d8f11018075fe3b
GitHub-Last-Rev: 407aa89c88
GitHub-Pull-Request: golang/go#62061
Reviewed-on: https://go-review.googlesource.com/c/go/+/519935
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-08-17 16:33:59 +00:00
Tobias Klauser
51fd0cb3c0 syscall: don't check non-existent return code in GetStartupInfo
Fixes #31316

Change-Id: I1ca5968836e7bcad91496e4ed3cf1a0caf1375f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/520275
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-08-17 16:33:09 +00:00
Joe Tsai
6c431fab37 encoding: reject negative runes in Encoding.WithPadding
A negative rune (other than NoPadding) makes no semantic sense.
Doing so relies on integer overflow of converting a rune to a byte
and would thus be equivalent to passing the positive byte value
of byte(padding).

This may cause existing code to panic.
An alternative is treat negative runes as equivalent to NoPadding.
However, the code already panics to report erroneous padding values,
so this is in line with the existing API.

Change-Id: I02499705519581598adc0c8525d90e25278dc056
Reviewed-on: https://go-review.googlesource.com/c/go/+/505236
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-08-17 16:32:08 +00:00
Joe Tsai
56076c3080 io: reduce allocations in Pipe constructor
Rather than having PipeWriter and PipeReader a wrapper type on pipe,
make them have the same underlying memory representation and
rely instead of simply casting the same *pipe pointer
as either a *PipeReader or *PipeWriter to control the set of methods.

This reduces the number of allocations by 2,
going from a total of 6 down to 4 allocations.

Change-Id: I09207a00c4b7afb44c7773d752c5628a07e24fda
Reviewed-on: https://go-review.googlesource.com/c/go/+/473535
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-17 16:25:48 +00:00
Joe Tsai
469d9e26ee encoding: add AppendEncode and AppendDecode
Implement append-like equivalent of Encode and Decode functions.

Fixes #53693

Change-Id: I79d8d834e3c8f77fad32be2fd391e33d4d1527ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/504884
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
2023-08-17 16:23:42 +00:00
ch3nnn
7af3107632 fmt: fix receiver names are different
"buffer" call the receiver "b" in other method, don't call it "bp" in
another. Keep the same receiver names, as prescribed in Go Code Review
Comments (https://go.dev/s/style#receiver-names).

Change-Id: I9fafc799a9e4102419ed743b941bca74e908f5c0
GitHub-Last-Rev: c8b851d372
GitHub-Pull-Request: golang/go#62066
Reviewed-on: https://go-review.googlesource.com/c/go/+/520016
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-08-17 16:21:46 +00:00
Cuong Manh Le
99b80993f6 cmd: go get golang.org/x/tools@74c255b and revendor
go get golang.org/x/tools@74c255b # CL 519295
go mod tidy
go mod vendor

Pulling in the fix for unnecessary dependency on *types.StdSizes, which
is non guaranteed behavior.

Updates #61035

Change-Id: Ifb04bab060343b6a849980db6bb65da9889b4665
Reviewed-on: https://go-review.googlesource.com/c/go/+/520435
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-08-17 14:32:19 +00:00
Matthew Dempsky
1038fc207b cmd/compile/internal/escape: change escapes and persists into bitset
This CL introduces a locAttr bitset type, which will make it easier to
add additional attributes in the near future.

Change-Id: I2689aa623097279dc1e7b7cf2adf5184d710c5a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/520258
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-08-17 14:31:30 +00:00
Matthew Dempsky
4e336b8e1e cmd/compile/internal/escape: flip transient to !persists
I want to add more location properties (e.g., to track indirect stores
and calls), and it's easier to reason about them if they're all
consistent that "true" means more consequences than less.

Change-Id: I3f8674bb11877ba33082a0f5f7d8e55ad6d7a4cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/520257
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>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-08-17 14:27:55 +00:00
Matthew Dempsky
570763e0ec cmd/compile/internal/escape: mark blankLoc as transient
Discarded values never persist, so they can be transiently allocated
too.

Change-Id: I036ce0c1eea45e437142497bb7df3ecb44b56e52
Reviewed-on: https://go-review.googlesource.com/c/go/+/520256
Auto-Submit: 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>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2023-08-17 14:23:25 +00:00
Joe Tsai
2fcfdb9686 strconv: rely on utf8.AppendRune
This is both simpler and more performant.

Quote             268ns ± 5%   258ns ± 4%  -3.70%  (p=0.014 n=10+10)
QuoteRune        28.9ns ± 3%  28.4ns ± 4%    ~     (p=0.113 n=9+10)
AppendQuote       165ns ± 3%   165ns ± 3%    ~     (p=0.661 n=9+10)
AppendQuoteRune  8.05ns ± 5%  7.75ns ± 7%    ~     (p=0.065 n=10+9)

Change-Id: Ib0ee332e970d4986026c05e5e0e368f41eff7977
Reviewed-on: https://go-review.googlesource.com/c/go/+/412338
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-08-17 05:23:49 +00:00
Russ Cox
1c00354013 runtime: change mutex profile to count every blocked goroutine
The pprof mutex profile was meant to match the Google C++ (now Abseil)
mutex profiler, originally designed and implemented by Mike Burrows.
When we worked on the Go version, pjw and I missed that C++ counts the
time each thread is blocked, even if multiple threads are blocked on a
mutex. That is, if 100 threads are blocked on the same mutex for the
same 10ms, that still counts as 1000ms of contention in C++. In Go, to
date, /debug/pprof/mutex has counted that as only 10ms of contention.
If 100 goroutines are blocked on one mutex and only 1 goroutine is
blocked on another mutex, we probably do want to see the first mutex
as being more contended, so the Abseil approach is the more useful one.

This CL adopts "contention scales with number of goroutines blocked",
to better match Abseil [1]. However, it still makes sure to attribute the
time to the unlock that caused the backup, not subsequent innocent
unlocks that were affected by the congestion. In this way it still gives
more accurate profiles than Abseil does.

[1] https://github.com/abseil/abseil-cpp/blob/lts_2023_01_25/absl/synchronization/mutex.cc#L2390

Fixes #61015.

Change-Id: I7eb9e706867ffa8c0abb5b26a1b448f6eba49331
Reviewed-on: https://go-review.googlesource.com/c/go/+/506415
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-08-17 01:30:31 +00:00
Cuong Manh Le
14a3ffc3d2 cmd/compile: use types2.Sizes instead of compiler own implementation
With #61035 fixed, types2.Sizes matches the compiler behavior, so use its
Sizes implementation instead of rolling our own copy.

Updates #61035

Change-Id: I7b9efd27a01f729a04c79cd6b4ee5f417fe6e664
Reviewed-on: https://go-review.googlesource.com/c/go/+/506716
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-08-16 21:01:11 +00:00
Cuong Manh Le
5fa4aac0ce go/types, types2: add Sizes computation to match gc behavior
Fixes #60431
Fixes #60734
Fixes #61035

Change-Id: I82513da3e1714e8271fae220fe242bf2bfb4eb9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/506856
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-08-16 21:00:48 +00:00
Bryan C. Mills
9f03e8367d os: skip Chown tests for auxiliary groups that fail due to permission errors
This addresses the failure mode described in
https://git.alpinelinux.org/aports/commit/community/go/tests-filter-overflow-gid.patch?id=9851dde0f5d2a5a50f7f3b5323d1b2ff22e1d028,
but without special-casing an implementation-specific group ID.

For #62053.

Change-Id: I70b1046837b8146889fff7085497213349cd2bf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/520055
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2023-08-16 19:05:12 +00:00
Jes Cok
5b8ceb38a1 log/slog: remove redundant dot in doc
Change-Id: Ic4fcfe7335dab219790c19ded3bbb7265857404f
GitHub-Last-Rev: afc69c79b2
GitHub-Pull-Request: golang/go#62062
Reviewed-on: https://go-review.googlesource.com/c/go/+/519955
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
2023-08-16 19:01:27 +00:00
Ian Lance Taylor
f6360cf488 syscall: remove deprecation notice
The syscall package isn't getting new system call support,
but it is not deprecated.

Fixes #60797

Change-Id: I33b60269f9ce70ac2108fa0f3d42fd87a3076bf1
Reviewed-on: https://go-review.googlesource.com/c/go/+/520018
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-16 18:54:55 +00:00
Cherry Mui
040dbf9c18 cmd/link: suppress -bind_at_load deprecation warning for ld-prime
ld-prime emits a deprecation warning for -bind_at_load. The flag
is needed for plugins to not deadlock (#38824) when linking with
older darwin linker. It is supposedly not needed with newer linker
when chained fixups are used. For now, we always pass it, and
suppress the warning.

For #61229.

Change-Id: I4b8a6f864a460c40dc38adbb533f664f7fd5343c
Reviewed-on: https://go-review.googlesource.com/c/go/+/508696
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2023-08-16 18:42:08 +00:00
David Chase
91bea5a21d runtime: guard against runtime/sema* ops on Darwin signal stack.
These operations misbehave and cause hangs and flakes.
Fail hard if they are attempted.

Tested by backing out the Darwin-profiling-hang fix
CL 518836 and running run.bash, the guard panicked in
runtime/pprof tests, as expected/hoped.

Updates #61768

Change-Id: I89b6f85745fbaa2245141ea98f584afc5d6b133e
Reviewed-on: https://go-review.googlesource.com/c/go/+/519275
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-16 17:51:47 +00:00