1
0
mirror of https://github.com/golang/go synced 2024-09-28 23:24:33 -06:00
Commit Graph

56428 Commits

Author SHA1 Message Date
Stefan
f22e2350c9 Refined deMorgan's tests to be more explicit with regexp 2023-05-09 21:30:09 -04:00
Stefan
b9f424e7d1 Added DeMorgans test in codegen/logic.go 2023-05-08 21:57:46 -04:00
Stefan
59cdce2259 Added DeMorgan's law peephole optimization 2023-05-05 22:41:43 -05:00
Bryan C. Mills
3e35df5edb internal/testenv: reduce init-time work for MustHaveExec
In CL 486275 I added a somewhat complex init function that sets up a
callback to probe for exec support. A lot of the complexity was simply
to avoid an unnecessary call to os.Environ during init.

In CL 491660, I made the os.Environ call unconditional on all
platforms anyway in order to make HasGoBuild more robust.

Since the init-function indirection no longer serves a useful purpose,
I would like to simplify it to a package-level function, avoiding the
complexity of changing package variables at init time.

Change-Id: Ie0041d52cbde06ff14540192c8fba869a851158e
Reviewed-on: https://go-review.googlesource.com/c/go/+/492977
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-05 23:33:02 +00:00
Robert Griesemer
05ca41d3ef go/types, types2: factor out maximum type computation
For untyped constant binary operations we need to determine the
"maximum" (untyped) type which includes both constant types.
Factor out this functionality.

Change-Id: If42bd793d38423322885a3063a4321bd56443b36
Reviewed-on: https://go-review.googlesource.com/c/go/+/492619
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-05 22:31:54 +00:00
Than McIntosh
445e520d49 cmd/compile: allow more inlining of functions that construct closures
[This is a roll-forward of CL 479095, which was reverted due to a bad
interaction between inlining and escape analysis, then later fixed
first with an attempt in CL 482355, then again in CL 484859, and then
one more time with CL 492135.]

Currently, when the inliner is determining if a function is
inlineable, it descends into the bodies of closures constructed by
that function. This has several unfortunate consequences:

- If the closure contains a disallowed operation (e.g., a defer), then
  the outer function can't be inlined. It makes sense that the
  *closure* can't be inlined in this case, but it doesn't make sense
  to punish the function that constructs the closure.

- The hairiness of the closure counts against the inlining budget of
  the outer function. Since we currently copy the closure body when
  inlining the outer function, this makes sense from the perspective
  of export data size and binary size, but ultimately doesn't make
  much sense from the perspective of what should be inlineable.

- Since the inliner walks into every closure created by an outer
  function in addition to starting a walk at every closure, this adds
  an n^2 factor to inlinability analysis.

This CL simply drops this behavior.

In std, this makes 57 more functions inlinable, and disallows inlining
for 10 (due to the basic instability of our bottom-up inlining
approach), for an net increase of 47 inlinable functions (+0.6%).

This will help significantly with the performance of the functions to
be added for #56102, which have a somewhat complicated nesting of
closures with a performance-critical fast path.

The downside of this seems to be a potential increase in export data
and text size, but the practical impact of this seems to be
negligible:

	       │    before    │           after            │
	       │    bytes     │    bytes      vs base      │
Go/binary        15.12Mi ± 0%   15.14Mi ± 0%  +0.16% (n=1)
Go/text          5.220Mi ± 0%   5.237Mi ± 0%  +0.32% (n=1)
Compile/binary   22.92Mi ± 0%   22.94Mi ± 0%  +0.07% (n=1)
Compile/text     8.428Mi ± 0%   8.435Mi ± 0%  +0.08% (n=1)

Change-Id: I5f75fcceb177f05853996b75184a486528eafe96
Reviewed-on: https://go-review.googlesource.com/c/go/+/492017
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-05-05 21:04:48 +00:00
Than McIntosh
89138ce740 cmd/compile: un-hide closure func if parent expr moved to staticinit
If the function referenced by a closure expression is incorporated
into a static init, be sure to mark it as non-hidden, since otherwise
it will be live but no longer reachable from the init func, hence it
will be skipped during escape analysis, which can lead to
miscompilations.

Fixes #59680.

Change-Id: Ib858aee296efcc0b7655d25c23ab8a6a8dbdc5f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/492135
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-05-05 21:04:38 +00:00
Than McIntosh
ea69de9b92 cmd/compile: rework marking of dead hidden closure functions
[This is a roll-forward of CL 484859, this time including a fix for
issue #59709. The call to do dead function marking was taking place in
the wrong spot, causing it to run more than once if generics were
instantiated.]

This patch generalizes the code in the inliner that marks unreferenced
hidden closure functions as dead. Rather than doing the marking on the
fly (previous approach), this new approach does a single pass at the
end of inlining, which catches more dead functions.

Change-Id: I0e079ad755c21295477201acbd7e1a732a98fffd
Reviewed-on: https://go-review.googlesource.com/c/go/+/492016
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-05-05 21:04:28 +00:00
Cherry Mui
10ad6c91de runtime, runtime/pprof: record instantiated symbol name in CPU profile
For generic functions, the previous CL makes it record the full
instantiated symbol name in the runtime func table. This CL
changes the pprof package to use that name in CPU profile. This
way, it matches the symbol name the compiler sees, so it can apply
PGO.

TODO: add a test.

Fixes #58712.

Change-Id: If40db01cbef5f73c279adcc9c290a757ef6955b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/491678
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2023-05-05 19:53:39 +00:00
Cherry Mui
1a612783c5 cmd/link, runtime: include full symbol name for generic functions in runtime table
For generic functions and methods, we replace the instantiated
shape type parameter name to "...", to make the function name
printed in stack traces looks more user friendly. Currently, this
is done in the binary's runtime func table at link time, and the
runtime has no way to access the full symbol name. This causes
the profile to also contain the replaced name. For PGO, this also
cause the compiler to not be able to find out the original fully
instantiated function name from the profile.

With this CL, we change the linker to record the full name, and
do the name substitution at run time when a printing a function's
name in traceback.

For #58712.

Change-Id: Ia0ea0989a1ec231f3c4fbf59365c9333405396c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/491677
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-05 19:53:20 +00:00
Cherry Mui
75136fc14c cmd/link: remove zdebug from ELF section header table
We now use SHF_COMPRESSED sections for DWARF compression, and no
longer generate zdebug sections on ELF platforms. No need to
generate them in the section header string table.

Updates #50796.

Change-Id: I5c79ccd43f803c75dbd86e28195d0db1c0beb087
Reviewed-on: https://go-review.googlesource.com/c/go/+/492719
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-05 19:20:27 +00:00
Cherry Mui
f90bb8a38f cmd/link: remove elfsetstring out of the loader
Currently, we pass elfsetstring to the loader as a callback, for
a special case of Addstring. This is only used for ELF when adding
strings to the section header string table. Move the logic to the
caller instead, so the loader would not have this special case.

Change-Id: Icfb91f380fe4ba435985c3019681597932f58242
Reviewed-on: https://go-review.googlesource.com/c/go/+/492718
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-05-05 19:20:01 +00:00
Robert Griesemer
26899ef3ee go/types, types2: better error message for bad assignment
If the LHS of an assignment is neither addressable nor a map expression
(and not the blank identifier), explicitly say so for a better error
message.

For #3117.

Change-Id: I4bffc35574fe390a0567e89182b23585eb5a90de
Reviewed-on: https://go-review.googlesource.com/c/go/+/492875
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-05-05 19:07:50 +00:00
Robert Griesemer
a5350558e6 go/types, types2: exclude untyped nil arguments early in type inference
An untyped nil argument cannot be used to infer any type information.
We don't need to include it in the untyped arguments.

Change-Id: Ied44738ff1b135e65a3acfa19223cd3889b7fa7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/492695
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
2023-05-05 16:51:41 +00:00
Than McIntosh
695a53620f internal/coverage/encodecounter: followup changes from code review
This patch contains a small set of changes with fixes for some
issues that surfaced during the code review for CL 484535. Due
to an error on my part, these never got included in the final version
that was checked in (I rebased, mailed the rebase, but then never
mailed the final patch set with the changes). This patch sends
the remaining bits and pieces.

Updates #59563.

Change-Id: I87dc05a83f8e44c8bfe7203bc2b035defc817af9
Reviewed-on: https://go-review.googlesource.com/c/go/+/492981
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-05-05 16:49:44 +00:00
David Chase
13a59e36c0 cmd/dist: add explicit module version to generated go.mod
This avoids bootstrapping problems with 1.20.
Tested w/ 1.19 and 1.20.

Change-Id: I0ca9e111719e8c1bcd1a0b53b9f16d9a2d77e836
Reviewed-on: https://go-review.googlesource.com/c/go/+/492982
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-05 15:46:57 +00:00
Bryan C. Mills
06fd1f30e9 cmd/go: save checksums for go.mod files needed for go version lines
When we load a package from a module, we need the go version line from
that module's go.mod file to know what language semantics to use for
the package. We need to save a checksum for the go.mod file even if
the module's requirements are pruned out of the module graph.
Previously, we were missing checksums for test dependencies of
packages in 'all' and packages passed to 'go get -t'.

This change preserves the existing bug for 'go mod tidy' in older
module versions, but fixes it for 'go mod tidy' in modules at go 1.21
or higher and for 'go get -t' at all versions.

Fixes #56222.

Change-Id: Icd6acce348907621ae0b02dbeac04fb180353dcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/489075
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
2023-05-05 15:42:09 +00:00
Russ Cox
761e813829 cmd/compile: work with new bisect command
CL 491875 introduces a new bisect command, which we plan to
document for use by end users to debug semantic changes in
the compiler and in GODEBUGs.

This CL adapts the existing GOSSAHASH support, which bisect
is a revision of, to support the specific syntax and output used
by bisect as well.

A followup CL will remove the old GOSSAHASH syntax and output
once existing consumers of that interface have been updated.

Change-Id: I99c4af54bb82c91c74bd8b8282ded968e6316f56
Reviewed-on: https://go-review.googlesource.com/c/go/+/491895
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2023-05-05 15:03:53 +00:00
Russ Cox
068d7b1052 internal/bisect: copy from golang.org/x/tools/bisect
We don't want std to depend on x/tools, so just as we
did with txtar, copy the bisect package into internal
rather than using a require + vendor.

Change-Id: Id775254f7c765a9244ba6eaf041c13e6e5c5e9f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/492595
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-05 15:03:42 +00:00
David Chase
bdc6ae579a internal/abi: refactor (basic) type struct into one definition
This touches a lot of files, which is bad, but it is also good,
since there's N copies of this information commoned into 1.

The new files in internal/abi are copied from the end of the stack;
ultimately this will all end up being used.

Change-Id: Ia252c0055aaa72ca569411ef9f9e96e3d610889e
Reviewed-on: https://go-review.googlesource.com/c/go/+/462995
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2023-05-05 14:59:28 +00:00
David Chase
dace96b9a1 cmd/compile: add "loop-transformed" (for whole loop) to logopt
This is intended to support automated pairing of performance
regressions with transformed loops; there is already a POC
for doing this in the general missed-optimization case; the
difference here is the ability to describe an entire range,
which required some extra plumbing to acquire and publish
the ending line+column.

Change-Id: Ibe606786f6be917b5a9a69d773560ed716a0754d
Reviewed-on: https://go-review.googlesource.com/c/go/+/492717
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-05 14:58:27 +00:00
Junxian Zhu
574431cfcd math: optimize math.Abs on mips64x
This commit optimized math.Abs function implementation on mips64x.
Tested on loongson 3A2000.

goos: linux
goarch: mips64le
pkg: math
                      │    oldmath    │               newmath               │
                      │    sec/op     │    sec/op     vs base               │
Acos-4                   258.0n ± ∞ ¹   257.1n ± ∞ ¹   -0.35% (p=0.008 n=5)
Acosh-4                  417.0n ± ∞ ¹   377.9n ± ∞ ¹   -9.38% (p=0.008 n=5)
Asin-4                   248.0n ± ∞ ¹   259.9n ± ∞ ¹   +4.80% (p=0.008 n=5)
Asinh-4                  439.6n ± ∞ ¹   408.3n ± ∞ ¹   -7.12% (p=0.008 n=5)
Atan-4                   189.6n ± ∞ ¹   188.8n ± ∞ ¹        ~ (p=0.056 n=5)
Atanh-4                  390.0n ± ∞ ¹   356.4n ± ∞ ¹   -8.62% (p=0.008 n=5)
Atan2-4                  279.0n ± ∞ ¹   263.9n ± ∞ ¹   -5.41% (p=0.008 n=5)
Cbrt-4                   314.2n ± ∞ ¹   322.3n ± ∞ ¹   +2.58% (p=0.008 n=5)
Ceil-4                   139.7n ± ∞ ¹   136.6n ± ∞ ¹   -2.22% (p=0.008 n=5)
Compare-4                21.11n ± ∞ ¹   21.09n ± ∞ ¹        ~ (p=0.405 n=5)
Compare32-4              20.10n ± ∞ ¹   20.12n ± ∞ ¹        ~ (p=0.206 n=5)
Copysign-4               32.17n ± ∞ ¹   35.71n ± ∞ ¹  +11.00% (p=0.008 n=5)
Cos-4                    222.8n ± ∞ ¹   169.8n ± ∞ ¹  -23.79% (p=0.008 n=5)
Cosh-4                   550.2n ± ∞ ¹   477.4n ± ∞ ¹  -13.23% (p=0.008 n=5)
Erf-4                    171.6n ± ∞ ¹   174.5n ± ∞ ¹        ~ (p=0.635 n=5)
Erfc-4                   182.6n ± ∞ ¹   170.2n ± ∞ ¹   -6.79% (p=0.008 n=5)
Erfinv-4                 177.6n ± ∞ ¹   196.6n ± ∞ ¹  +10.70% (p=0.008 n=5)
Erfcinv-4                177.8n ± ∞ ¹   197.8n ± ∞ ¹  +11.25% (p=0.008 n=5)
Exp-4                    422.8n ± ∞ ¹   382.1n ± ∞ ¹   -9.63% (p=0.008 n=5)
ExpGo-4                  416.1n ± ∞ ¹   383.2n ± ∞ ¹   -7.91% (p=0.008 n=5)
Expm1-4                  232.9n ± ∞ ¹   252.2n ± ∞ ¹   +8.29% (p=0.008 n=5)
Exp2-4                   404.8n ± ∞ ¹   389.1n ± ∞ ¹   -3.88% (p=0.008 n=5)
Exp2Go-4                 407.0n ± ∞ ¹   372.3n ± ∞ ¹   -8.53% (p=0.008 n=5)
Abs-4                   30.120n ± ∞ ¹   3.014n ± ∞ ¹  -89.99% (p=0.008 n=5)
Dim-4                    5.021n ± ∞ ¹   5.023n ± ∞ ¹        ~ (p=0.071 n=5)
Floor-4                  127.8n ± ∞ ¹   127.1n ± ∞ ¹   -0.55% (p=0.008 n=5)
Max-4                    77.69n ± ∞ ¹   76.33n ± ∞ ¹   -1.75% (p=0.008 n=5)
Min-4                    83.27n ± ∞ ¹   77.87n ± ∞ ¹   -6.48% (p=0.008 n=5)
Mod-4                    906.2n ± ∞ ¹   692.9n ± ∞ ¹  -23.54% (p=0.008 n=5)
Frexp-4                  150.6n ± ∞ ¹   108.6n ± ∞ ¹  -27.89% (p=0.008 n=5)
Gamma-4                  418.4n ± ∞ ¹   386.1n ± ∞ ¹   -7.72% (p=0.008 n=5)
Hypot-4                 148.20n ± ∞ ¹   93.78n ± ∞ ¹  -36.72% (p=0.008 n=5)
HypotGo-4               148.20n ± ∞ ¹   94.47n ± ∞ ¹  -36.26% (p=0.008 n=5)
Ilogb-4                 135.50n ± ∞ ¹   92.38n ± ∞ ¹  -31.82% (p=0.008 n=5)
J0-4                     937.7n ± ∞ ¹   861.7n ± ∞ ¹   -8.10% (p=0.008 n=5)
J1-4                     915.4n ± ∞ ¹   875.9n ± ∞ ¹   -4.32% (p=0.008 n=5)
Jn-4                     1.974µ ± ∞ ¹   1.863µ ± ∞ ¹   -5.62% (p=0.008 n=5)
Ldexp-4                  158.5n ± ∞ ¹   129.3n ± ∞ ¹  -18.42% (p=0.008 n=5)
Lgamma-4                 209.0n ± ∞ ¹   211.8n ± ∞ ¹        ~ (p=0.095 n=5)
Log-4                    326.4n ± ∞ ¹   295.2n ± ∞ ¹   -9.56% (p=0.008 n=5)
Logb-4                   147.7n ± ∞ ¹   105.0n ± ∞ ¹  -28.91% (p=0.008 n=5)
Log1p-4                  303.4n ± ∞ ¹   266.3n ± ∞ ¹  -12.23% (p=0.008 n=5)
Log10-4                  329.2n ± ∞ ¹   298.3n ± ∞ ¹   -9.39% (p=0.008 n=5)
Log2-4                   187.4n ± ∞ ¹   153.0n ± ∞ ¹  -18.36% (p=0.008 n=5)
Modf-4                   110.5n ± ∞ ¹   103.5n ± ∞ ¹   -6.33% (p=0.008 n=5)
Nextafter32-4            128.4n ± ∞ ¹   121.5n ± ∞ ¹   -5.37% (p=0.016 n=5)
Nextafter64-4            109.5n ± ∞ ¹   110.5n ± ∞ ¹   +0.91% (p=0.008 n=5)
PowInt-4                 603.3n ± ∞ ¹   516.4n ± ∞ ¹  -14.40% (p=0.008 n=5)
PowFrac-4                1.365µ ± ∞ ¹   1.183µ ± ∞ ¹  -13.33% (p=0.008 n=5)
Pow10Pos-4               15.07n ± ∞ ¹   15.07n ± ∞ ¹        ~ (p=0.738 n=5)
Pow10Neg-4               21.11n ± ∞ ¹   21.10n ± ∞ ¹        ~ (p=0.190 n=5)
Round-4                  44.23n ± ∞ ¹   44.22n ± ∞ ¹        ~ (p=0.635 n=5)
RoundToEven-4            50.25n ± ∞ ¹   46.27n ± ∞ ¹   -7.92% (p=0.008 n=5)
Remainder-4              675.6n ± ∞ ¹   530.4n ± ∞ ¹  -21.49% (p=0.008 n=5)
Signbit-4                17.07n ± ∞ ¹   17.95n ± ∞ ¹   +5.16% (p=0.008 n=5)
Sin-4                    171.6n ± ∞ ¹   189.1n ± ∞ ¹  +10.20% (p=0.008 n=5)
Sincos-4                 201.5n ± ∞ ¹   200.5n ± ∞ ¹        ~ (p=0.421 n=5)
Sinh-4                   529.6n ± ∞ ¹   484.6n ± ∞ ¹   -8.50% (p=0.008 n=5)
SqrtIndirect-4           5.021n ± ∞ ¹   5.023n ± ∞ ¹   +0.04% (p=0.048 n=5)
SqrtLatency-4            8.032n ± ∞ ¹   8.039n ± ∞ ¹   +0.09% (p=0.024 n=5)
SqrtIndirectLatency-4    8.036n ± ∞ ¹   8.038n ± ∞ ¹        ~ (p=0.056 n=5)
SqrtGoLatency-4          338.8n ± ∞ ¹   338.7n ± ∞ ¹        ~ (p=0.841 n=5)
SqrtPrime-4              5.379µ ± ∞ ¹   5.382µ ± ∞ ¹   +0.06% (p=0.048 n=5)
Tan-4                    182.7n ± ∞ ¹   191.8n ± ∞ ¹   +4.98% (p=0.008 n=5)
Tanh-4                   558.7n ± ∞ ¹   497.6n ± ∞ ¹  -10.94% (p=0.008 n=5)
Trunc-4                  122.5n ± ∞ ¹   122.6n ± ∞ ¹        ~ (p=0.405 n=5)
Y0-4                     892.8n ± ∞ ¹   851.7n ± ∞ ¹   -4.60% (p=0.008 n=5)
Y1-4                     887.2n ± ∞ ¹   863.2n ± ∞ ¹   -2.71% (p=0.008 n=5)
Yn-4                     1.889µ ± ∞ ¹   1.832µ ± ∞ ¹   -3.02% (p=0.008 n=5)
Float64bits-4            13.05n ± ∞ ¹   13.06n ± ∞ ¹   +0.08% (p=0.040 n=5)
Float64frombits-4        13.05n ± ∞ ¹   13.06n ± ∞ ¹        ~ (p=0.143 n=5)
Float32bits-4            13.05n ± ∞ ¹   13.06n ± ∞ ¹   +0.08% (p=0.008 n=5)
Float32frombits-4        13.05n ± ∞ ¹   13.08n ± ∞ ¹   +0.23% (p=0.016 n=5)
FMA-4                    445.7n ± ∞ ¹   448.1n ± ∞ ¹   +0.54% (p=0.008 n=5)
geomean                  157.2n         142.8n         -9.17%

Change-Id: I9bf104848b588c9ecf79401a81d483d7fcdb0a79
Reviewed-on: https://go-review.googlesource.com/c/go/+/481575
Reviewed-by: M Zhuo <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Rong Zhang <rongrong@oss.cipunited.com>
2023-05-05 14:54:39 +00:00
Chressie Himpel
72c33a5ef0 Revert "runtime/cgo: store M for C-created thread in pthread key"
This reverts CL 485500.

Reason for revert: This breaks internal tests at Google, see b/280861579 and b/280820455.

Change-Id: I426278d400f7611170918fc07c524cb059b9cc55
Reviewed-on: https://go-review.googlesource.com/c/go/+/492995
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Chressie Himpel <chressie@google.com>
2023-05-05 14:37:29 +00:00
Michael Matloob
f379e78951 cmd/go: sanitize go env outputs
go env, without any arguments, outputs the environment variables in
the form of a script that can be run on the host OS. On Unix, single
quote the strings and place single quotes themselves outside the
single quoted strings. On windows use the set "var=val" syntax with
the quote starting before the variable.

Fixes #58508

Change-Id: Iecd379a4af7285ea9b2024f0202250c74fd9a2bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/488375
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2023-05-05 14:28:38 +00:00
Bryan C. Mills
fe10464358 cmd/go/internal/modfetch/codehost: skip tests that fail due to tag mismatches
For #56881.

Change-Id: If9d8fa2942e4dd8da5e673631cdc277e0fe6c962
Reviewed-on: https://go-review.googlesource.com/c/go/+/492975
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-05 13:20:58 +00:00
qmuntal
2fd8c5b2d8 runtime: don't check the exit code in TestWERDialogue
TestWERDialogue intent is to check that the WER dialog doesn't pop-up
when `GOTRACEBACK=wer` is set. CL 474915 extended the test to also
check the error code of the crashed process. This change is causing
failures in Microsoft internal test pipelines because some WER setups
can modify the exit code of the crashed application, for example to
signal that the crash dump has been collected.

Fix this issue by not checking the error code in TestWERDialogue. Also,
add a new test, TestCrashExitCode, which does the same but using
`GOTRACEBACK=crash` instead, so that we have one test that checks the
error code.

Change-Id: Iedde09e1df7223009ebef38a32a460f1ab07e31a
Reviewed-on: https://go-review.googlesource.com/c/go/+/491935
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-05-05 07:29:13 +00:00
Bryan C. Mills
e335a2665f testenv: allow HasGoBuild to be false on -noopt builders
-noopt uses GO_GCFLAGS to disable optimization, and
GO_GCFLAGS has caused HasGoBuild to be false since CL 74470.

Change-Id: Iadcd15d412c05aec11e9a23b86d7b24af79d73bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/492795
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2023-05-04 21:30:44 +00:00
Jonathan Amsterdam
0022bd37a7 log/slog: remove special float handling from JSONHandler
Remove the special-case handling of NaN and infinities from
appendJSONValue, making JSONHandler behave almost exactly like
a json.Encoder without HTML escaping.

The only differences are:

- Encoding errors are turned into strings, instead of causing the Handle method to fail.

- Values of type `error` are displayed as strings by calling their `Error` method.

Fixes #59345.

Change-Id: Id06bd952bbfef596e864bd5fd3f9f4f178f738c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/486855
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2023-05-04 20:20:40 +00:00
Cherry Mui
0212b80eac runtime: don't run TestStackGrowth in parallel with other tests
This test calls runtime.GC quite a number of times. GC is a global
operation. To reduce interference with other tests, don't run this
test in parallel with other tests.

May fix #57601.

Change-Id: I6efadb62c4dada37a927455f5c6cd98cafb88aaf
Reviewed-on: https://go-review.googlesource.com/c/go/+/492715
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-05-04 20:09:34 +00:00
Jonathan Amsterdam
ae59562c71 log/slog: rearrange package doc
Move the "Attrs and Values" section lower. It describes an optimization;
the API it covers is not essential.

Also, move the brief section on Logger.With up to the first section.
It was in the "Groups" section but didn't belong there.

Change-Id: I0e36ef654e95f918d5b480566ec58d9990d26b40
Reviewed-on: https://go-review.googlesource.com/c/go/+/487856
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
2023-05-04 19:53:26 +00:00
Jonathan Amsterdam
2f5f231ac1 log/slog: Group takes ...any
The Group function takes a key and a ...any, which is converted
into attrs.

Fixes #59204.

Change-Id: Ib714365dcda2eda37863ce433f3dd8cf5eeda610
Reviewed-on: https://go-review.googlesource.com/c/go/+/487855
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-04 19:53:09 +00:00
Bryan C. Mills
79723f389b internal/testenv: remove HasExec and simplify other support checks again
HasExec is an attractive nuisance: it is tempting to check in a
TestMain function, but TestMain really shouldn't be running
subprocesses eagerly anyway (they add needless overhead for operations
like 'go test -list=.'), and the trick of re-executing the test binary
to determine whether 'exec' works ends up in infinite recursion if
TestMain itself calls HasExec.

Instead, tests that need to execute a subprocess should call
MustHaveExec or MustHaveExecPath from within a specific test,
or just try to exec the program and check its error status
(perhaps using testenv.SyscallIsNotSupported).

While I'm in here and testing on the SlowBots anyway, a few other
cleanups relating to subprocesses:

- Add more t.Helper calls to support checks where appropriate.

- Remove findGoTool, which can be simplified to exec.LookPath as of
  CL 404134.

- Add tests confirming the expected behavior of the support functions
  on the Go project's builders.

Change-Id: I163c701b2dd6eb6b7a036c6848f99b64dd9f0838
Reviewed-on: https://go-review.googlesource.com/c/go/+/491660
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-05-04 19:52:29 +00:00
Jonathan Amsterdam
a82f69f60e log/slog: built-in handler constructors take options as a second arg
There is now one constructor function for each built-in handler, with
signature

    NewXXXHandler(io.Writer, *HandlerOptions) *XXXHandler

Fixes #59339.

Change-Id: Ia02183c5ce0dc15c64e33ad05fd69bca09df2d2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/486415
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
2023-05-04 18:32:54 +00:00
Paul E. Murphy
5c51e9f45b runtime/cgo: preserve VRs across crosscall_ppc64 on linux
Rework this function to closely match the PPC64 crosscall2, but
written in gnu asm. Likewise, fix this to store TOC in the new
frame, not the caller's, as is required by the ELF ABIs.

Change-Id: I8902c74f2607e3436260882a7bea52e72a67b8f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/486335
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Carlos Amedee <carlos@golang.org>
2023-05-04 18:03:04 +00:00
Paul E. Murphy
1e51b1fac3 runtime/cgo: preserve nonvolatile VRs when crosscalling into Go on PPC64
ELFv1 and ELFv2 declare V20-V31 as nonvolatile (callee save) registers.
Go does not. Preserve them before calling into Go.

Change-Id: If60a6d8f71b51b1136a86eab2b90d964900becd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/480657
Auto-Submit: Carlos Amedee <carlos@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-04 18:02:59 +00:00
Bryan C. Mills
c6116bea03 cmd/fix: move cgo and 'go build' support checks into TestRewrite
This avoids unnecessary work to determine 'go build' and cgo support
if we're not actually running the test (as in 'go test -list').

Change-Id: Id175a759605b2130d4de8bff8eba4c23fe65ccba
Reviewed-on: https://go-review.googlesource.com/c/go/+/491657
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Austin Clements <austin@google.com>
2023-05-04 18:02:12 +00:00
Keith Randall
10141676d1 cmd/compile: fix bswap/load rewrite rules
When combining a byteswap and a load, the resulting combined op
must go in the load's block, not the byteswap's block, as the load
has a memory argument that might only be valid in its original block.

Fixes #59973

Change-Id: Icd84863ef3a9ca1fc22f2bb794a003f2808c746f
Reviewed-on: https://go-review.googlesource.com/c/go/+/492616
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Keith Randall <khr@google.com>
2023-05-04 18:01:29 +00:00
Robert Griesemer
fc106b016c go/types, types2: remove Config.EnableReverseTypeInference flag
Proposal #59338 has been accepted and we expect this feature to
be available starting with Go 1.21. Remove the flag to explicitly
enable it through the API and enable by default.

For now keep an internal constant enableReverseTypeInference to
guard and mark the respective code, so we can disable it for
debugging purposes.

For #59338.

Change-Id: Ia1bf3032483ae603017a0f459417ec73837e2891
Reviewed-on: https://go-review.googlesource.com/c/go/+/491798
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-04 17:35:44 +00:00
Robert Griesemer
13201d5728 go/types, types2: consider generic functions in inference simplify step
After type arguments for all type parameters have been determined,
the type arguments are "simplified" by substituting any type parameters
that might occur in them with their corresponding type arguments until
all type parameters have been removed.

If in this process a (formerly) generic function signature becomes
non-generic, make sure to nil out its (declared) type parameters.

Fixes #59953.
For #59338.

Change-Id: Ie16bffd7b0a8baed18e76e5532cdfaecd26e4278
Reviewed-on: https://go-review.googlesource.com/c/go/+/491797
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-05-04 17:35:06 +00:00
Frediano Ziglio
60c724c55a syscall: reduce memory allocated by UTF16FromString
The function allocated a buffer larger than needed.
Fixes #59967.

Signed-off-by: Frediano Ziglio <frediano.ziglio@nextdlp.com>
Change-Id: I5f30a135acf5f27d6c2ef4bc4abef5144da4dc94
Reviewed-on: https://go-review.googlesource.com/c/go/+/492575
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-05-04 17:28:54 +00:00
Bryan C. Mills
8f7830978a cmd/go: fix short tests on ios
As of CL 488076, many cmd/go tests can run on the ios-arm64-corellium
builder. Some of them had made erroneous assumptions about cmd/go's
use of the C toolchain.

Change-Id: Ib59d9858ef3930de2b412daa4462b72065f69cfd
Reviewed-on: https://go-review.googlesource.com/c/go/+/492597
Reviewed-by: Michael Matloob <matloob@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-05-04 17:09:07 +00:00
Robert Griesemer
8337ca094b go/types, types2: rename generic function arguments
For correct inference, if the same generic function is provided
more than once as an argument to another function, the argument
function's type parameters must be unique for each argument so
that the type parameters can be correctly inferred.

Example:

	func f(func(int), func(string)) {}

	func g[P any](P) {}

	func _() {
		f(g, g)
	}

Here the type parameter P for the first g argument resolves to int
and the type parameter P for the second g argument resolves to string.

Fixes #59956.
For #59338.

Change-Id: I10ce0ea08c2033722dd7c7c976b2a5448b2ee2d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/492516
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-05-04 17:01:49 +00:00
Robert Griesemer
8dea635470 go/types, types2: make Checker.renameTParams work on any type
This permits the rewrite of type parameters in arbitrary types,
not just tuples.

Preparation for fixing #59956.
For #59338.

Change-Id: I9ccaac1f163051cb837cae2208763cafb1d239cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/492515
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-05-04 16:36:39 +00:00
Mateusz Poliwczak
2c49bf89ed net: net remove completed return from cgo lookup functions
After CL 487196 there is no need anymore to return
completed == false from the cgo lookup functions and
then fallback to to go resolver.  (Before CL 487196 this
change would cause the (only?) tests to fail)
Now the cgoAvailable constant guards that correctly.

This change will cause a panic when the cgo resolver is being
used without the cgo support, so it will be easier to
detect bug while changing the code in the net package.

I am leaving the completed return from cgoLookupCNAME,
because it is super broken now.

Change-Id: I2661b9a3725de2b1a229847c12adf64b3f62b136
GitHub-Last-Rev: 2a6501a53e
GitHub-Pull-Request: golang/go#59925
Reviewed-on: https://go-review.googlesource.com/c/go/+/491275
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-05-04 16:28:59 +00:00
Ian Lance Taylor
1596aeec8e all: add String for fs.{FileInfo,DirEntry} implementations
The new String methods use the new FormatFileInfo and
FormatDirEntry functions.

Fixes #54451

Change-Id: I414cdfc212ec3c316fb2734756d2117842a23631
Reviewed-on: https://go-review.googlesource.com/c/go/+/491175
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
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: Bryan Mills <bcmills@google.com>
2023-05-04 16:27:35 +00:00
Bryan C. Mills
09a24a91b5 cmd/go/internal/modfetch/codehost: initialize localGitURL lazily and clean up skips
Previously localGitURL was initialized in TestMain, which creates
needless work if the test flags do not result in running a test that
requires localGitURL.

We had also been skipping a bunch of tests that used
vcs-test.golang.org in order to avoid network traffic, but now that
that content is served through an in-process vcweb server that is no
longer necessary. (All of the 'git' tests together take less than a
second to run.)

The 'hg' tests are much slower, so we do still skip those in short
mode.

Updates #59940.

Change-Id: Ie4f2d2bc825d7a011e25e754edf1a7c3c6010c77
Reviewed-on: https://go-review.googlesource.com/c/go/+/491659
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-05-04 16:24:04 +00:00
Bryan C. Mills
dcd1c31032 runtime: skip TestSegv/SegvInCgo earlier on ios
It appears to sometimes hang instead of crashing,
which can cause subsequent tests to time out.

For #59947.

Change-Id: Id4ac3c0cd5f7f345334d3e0ed3f48e40b9ff191c
Reviewed-on: https://go-review.googlesource.com/c/go/+/492075
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-05-04 16:23:46 +00:00
Bryan C. Mills
ca49b8d7af cmd/go: remove a redundant HasExec check in TestScript/README
The test checks testenv.HasExec right before calling testenv.Command,
but testenv.Command already skips the test if HasExec is false.

Change-Id: I04716bf823a1b76640394a964973ff34c65afb1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/491658
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2023-05-04 16:22:43 +00:00
nilsocket
3a872a2262 slog: fix grammatical mistakes in docs
Change-Id: I183dda71fcec04fc1e622c66f719bd745d8b4eea
Reviewed-on: https://go-review.googlesource.com/c/go/+/484975
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Carlos Amedee <carlos@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2023-05-04 16:22:29 +00:00
Paul E. Murphy
f742ddc349 cmd/link/internal/ppc64: support non-PIC PLT call stubs
Simplify the PLT stub generation code to minimize stub generation
knowing there is only ever a single TOC pointer when linking
internally.

The OpenBSD port requires Go make dynamic calls into its C library,
so the linker must create stubs which work without R2 being set up.
This new case is exactly case 3 described in the PPC64 ELFv2 1.5
section 4.2.5.3.

Updates #56001

Change-Id: I07ebd08442302e55b94b57db474dfd7e7a0c2ac9
Reviewed-on: https://go-review.googlesource.com/c/go/+/488316
Auto-Submit: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
2023-05-03 22:13:51 +00:00