]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
14 months agocrypto/x509: surface ReasonCode in RevocationList API
Aaron Gable [Wed, 15 Feb 2023 22:25:34 +0000 (14:25 -0800)]
crypto/x509: surface ReasonCode in RevocationList API

Creates x509.RevocationListEntry, a new type representing a single
revoked certificate entry in a CRL. Like the existing Certificate and
RevocationList types, this new type has a field for its Raw bytes, and
exposes its mostly-commonly-used extension (ReasonCode) as a top-level
field. This provides more functionality to the user than the existing
pkix.RevokedCertificate type.

Adds a RevokedCertificateEntries field which is a []RevocationListEntry
to RevocationList. This field deprecates the RevokedCertificates field.
When the RevokedCertificates field is removed in a future release, this
will remove one of the last places where a pkix type is directly exposed
in the x509 package API.

Updates the ParseRevocationList function to populate both fields for
now, and updates the CreateRevocationList function to prefer the new
field if it is populated, but use the deprecated field if not. Finally,
also updates the x509 unit tests to use the new .ReasonCode field in
most cases.

Fixes #53573

Change-Id: Ia6de171802a5bd251938366508532e806772d7d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/468875
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Roland Shoemaker <roland@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
14 months agosyscall: use clone3 syscall with CLONE_NEWTIME
Tobias Klauser [Wed, 8 Mar 2023 11:49:10 +0000 (12:49 +0100)]
syscall: use clone3 syscall with CLONE_NEWTIME

CLONE_NEWTIME can only be used with the clone3 and unshare system calls,
see https://github.com/torvalds/linux/commit/769071ac9f20b6a447410c7eaa55d1a5233ef40c:

> All available clone flags have been used, so CLONE_NEWTIME uses the highest
> bit of CSIGNAL. It means that it can be used only with the unshare() and
> the clone3() system calls.

The clone3 syscall was added in Linux kernel version 5.3 and
CLONE_NEWTIME was added in version 5.6. However, it was non-functional
until version 6.3 (and stable versions with the corresponding fix [1]).

[1] https://lore.kernel.org/lkml/20230308105126.10107-1-tklauser@distanz.ch/

In case CLONE_NEWTIME is set in SysProcAttr.Cloneflags on an unsupported
kernel version, the fork/exec call will fail.

Fixes #49779

Change-Id: Ic3ecfc2b601bafaab12b1805d7f9512955a8c7e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/474356
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
14 months agocrypto/internal/nistec: refactor scalar multiplication
Filippo Valsorda [Mon, 13 Feb 2023 19:49:38 +0000 (20:49 +0100)]
crypto/internal/nistec: refactor scalar multiplication

The assumptions of some of the assembly functions were still scarcely
documented and even disregarded: p256ScalarMult was relying on the fact
that the "undefined behavior" of p256PointAddAsm with regards to
infinity inputs was returning the infinity.

Aside from expanding comments, moving the bit window massaging into a
more easily understood p256OrdRsh function, and fixing the above, this
change folds the last iteration of p256ScalarMult into the loop to
reduce special cases and inverts the iteration order of p256BaseMult so
it matches p256ScalarMult for ease of comparison.

Updates #58647

Change-Id: Ie5712ea778aadbe5adcdb478d111c2527e83caa0
Reviewed-on: https://go-review.googlesource.com/c/go/+/471256
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>

14 months agotime: fix timezone lookup logic for non-DST zones
Geon Kim [Sat, 11 Mar 2023 00:57:57 +0000 (00:57 +0000)]
time: fix timezone lookup logic for non-DST zones

This change fixes time.LoadLocationFromTZData and time.Location.lookup logic if the given time is after the last transition and the extend string doesn't have the DST rule.

Fixes #58682

Change-Id: Ie34a6d658d14c2b33098b29ab83c041ef0d34266
GitHub-Last-Rev: f6681eb44c0ea0772004e56eb68fcbd9023d971e
GitHub-Pull-Request: golang/go#58684
Reviewed-on: https://go-review.googlesource.com/c/go/+/471020
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

14 months agobytes: add Buffer.Available and Buffer.AvailableBuffer
Joe Tsai [Mon, 6 Feb 2023 19:37:39 +0000 (11:37 -0800)]
bytes: add Buffer.Available and Buffer.AvailableBuffer

This adds a new Buffer.AvailableBuffer method that returns
an empty buffer with a possibly non-empty capacity for use
with append-like APIs.

The typical usage pattern is something like:

b := bb.AvailableBuffer()
b = appendValue(b, v)
bb.Write(b)

It allows logic combining append-like APIs with Buffer
to avoid needing to allocate and manage buffers themselves and
allows the append-like APIs to directly write into the Buffer.

The Buffer.Write method uses the builtin copy function,
which avoids copying bytes if the source and destination are identical.
Thus, Buffer.Write is a constant-time call for this pattern.

Performance:

BenchmarkBufferAppendNoCopy  2.909 ns/op  5766942167.24 MB/s

This benchmark should only be testing the cost of bookkeeping
and never the copying of the input slice.
Thus, the MB/s should be orders of magnitude faster than RAM.

Fixes #53685

Change-Id: I0b41e54361339df309db8d03527689b123f99085
Reviewed-on: https://go-review.googlesource.com/c/go/+/474635
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
14 months agocmd/go: unify the format of the go help xxx command
cui fliter [Wed, 8 Mar 2023 11:00:51 +0000 (19:00 +0800)]
cmd/go: unify the format of the go help xxx command

Fixes #58871
Updates #58871

Change-Id: I947b71083e9559859b3ae6e17b5daad03a976707
Reviewed-on: https://go-review.googlesource.com/c/go/+/474375
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

14 months agoall: fix some problematic comments
cui fliter [Sat, 11 Mar 2023 02:33:57 +0000 (10:33 +0800)]
all: fix some problematic comments

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

14 months agocmd/dist: omit DWARF in build release toolchain binaries
Russ Cox [Wed, 8 Mar 2023 19:48:41 +0000 (14:48 -0500)]
cmd/dist: omit DWARF in build release toolchain binaries

The vast majority of users of Go toolchains have no need for
binaries like the go command and compiler to include DWARF
information, and the DWARF information is 34% of the size of
the overall Go toolchain zip files (14% when the toolchain is
unzipped on disk, because other parts get bigger).

To save network and disk, disable DWARF in build release binaries.
DWARF remains enabled when developing in the main branch
(signaled by no VERSION file existing), for better debuggability
when actually working on the compiler and go command.

Note that removing DWARF does not break the backtraces shown
when a binary panics, nor does it break other uses of stack traces
from within a Go program, such as runtime.Callers.

To build a release toolchain with DWARF included, people can use

GO_LDFLAGS=-w=0 ./make.bash

Change-Id: Ib0bbe1446adca4599066b2fb2f2734e6825c1106
Reviewed-on: https://go-review.googlesource.com/c/go/+/475378
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

14 months agocmd/dist: reproducibility fixes
Russ Cox [Sun, 5 Mar 2023 18:05:25 +0000 (13:05 -0500)]
cmd/dist: reproducibility fixes

Fix a few lingering reproducibility problems.

- Do not set CC during go install std if it is unset,
  so that the automatic disabling of cgo in cmd/go can run.

- Since CC is not necessary, remove code insisting on it.

- Use a fixed quoting algorithm instead of %q from the
  bootstrap toolchain, which can differ from release to release.

- Remove go_bootstrap tool successfully on Windows.

For #24904.

Change-Id: I5c29ba6a8592e93bfab37f123b69f55c02f12ce3
Reviewed-on: https://go-review.googlesource.com/c/go/+/475377
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
14 months agoruntime: remove NOFRAME from asmcgocall, systemstack and mcall
qmuntal [Tue, 28 Feb 2023 18:30:32 +0000 (19:30 +0100)]
runtime: remove NOFRAME from asmcgocall, systemstack and mcall

This CL removes the NOFRAME flag from runtime.asmcgocall,
runtime.systemstack and runtime.mcall so the compiler can place
the frame pointer on the stack.

This will help unwinding cgo stack frames, and might be all what's
needed for tools that only use the frame pointer to unwind the stack.
That's not the case for gdb, which uses DWARF CFI, and windbg,
which uses SEH. Yet, having the frame pointer correctly set lays
the foundation for supporting cgo unwinding with DWARF CFI and SEH.

Updates #58378

Change-Id: I7655363b3fb619acccd9d5a7f0e3d3dec953cd52
Reviewed-on: https://go-review.googlesource.com/c/go/+/472195
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
14 months agoruntime: implement high resolution timer on windows arm/arm64
qmuntal [Fri, 24 Feb 2023 17:15:32 +0000 (18:15 +0100)]
runtime: implement high resolution timer on windows arm/arm64

This CL moves the usleep2HighRes from assembly to good old Go.
This is safe because since CL 288793 usleep is always called with
a g, else one wold have to call usleep_no_g. This condition was
not enforced when high resolution timers were first implemented
on Windows (CL 248699), so the implementation was done in assembly.

Other than removing a bunch of obscure assembly code, this CL makes
high resolution timers work on windows arm/arm64 by free, as the
system calls are the same in all windows platforms.

Change-Id: I41ecf78026fd7e11e85258a411ae074a77e8c7fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/471142
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>

14 months agocmd/internal/obj/loong64: remove invalid branch delay slots
Guoqi Chen [Wed, 3 Aug 2022 09:45:02 +0000 (17:45 +0800)]
cmd/internal/obj/loong64: remove invalid branch delay slots

Change-Id: I222717771019f7aefa547971b2d94ef4677a42c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/420979
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Run-TryBot: hopehook <hopehook@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
14 months agoos: correct func name in WriteFile godoc comment
Tobias Klauser [Wed, 8 Mar 2023 10:30:16 +0000 (11:30 +0100)]
os: correct func name in WriteFile godoc comment

Change-Id: Ideb70ce04f49ff676c20c2e1f0b43f1d7a6665dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/474355
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>

15 months agoerrors: add ErrUnsupported
Andy Pan [Thu, 2 Mar 2023 03:57:24 +0000 (11:57 +0800)]
errors: add ErrUnsupported

Fixes #41198

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

15 months agocmd/link: define correct complex types values for COFF symbols
qmuntal [Fri, 10 Mar 2023 15:19:58 +0000 (16:19 +0100)]
cmd/link: define correct complex types values for COFF symbols

This CL updates IMAGE_SYM_DTYPE_FUNCTION and IMAGE_SYM_DTYPE_ARRAY
definition and usage so their value can be set to what's defined in
the Microsoft PE docs [1], fixing a long-standing TODO.

[1] https://learn.microsoft.com/en-us/windows/win32/debug/pe-format#type-representation

Change-Id: I93c19eb78e8a770e8c72245fe9495647e2c5ae5b
Reviewed-on: https://go-review.googlesource.com/c/go/+/475355
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoos: skip TestExecutableDeleted earlier when 'go build' is not supported
Bryan C. Mills [Fri, 10 Mar 2023 19:21:01 +0000 (14:21 -0500)]
os: skip TestExecutableDeleted earlier when 'go build' is not supported

The test unconditionally calls testenv.GoToolPath, which will skip the
test anyway. Moving the skip earlier gets this test out of goroutine
dumps if the test process fails or times out, making it easier to
diagnose failures in the remaining tests.

Change-Id: Ibd39546708a83b6f15616b2c4ae7af420e2401f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/475455
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agoall: skip tests that fail on android/arm64
Bryan C. Mills [Wed, 1 Mar 2023 13:45:18 +0000 (13:45 +0000)]
all: skip tests that fail on android/arm64

Many of the tests skipped platforms that build PIE binaries by
default, but (still) lack a central function to report which platforms
those are.

Some of the tests assumed (but did not check for) internal linking
support, or invoked `go tool link` directly without properly
configuring the external linker.

A few of the tests seem to be triggering latent bugs in the linker.

For #58806.
For #58807.
For #58794.

Change-Id: Ie4d06b1597f404590ad2abf978d4c363647407ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/472455
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/compile: pass type checker error codes in the compiler
Robert Griesemer [Fri, 10 Mar 2023 00:21:22 +0000 (16:21 -0800)]
cmd/compile: pass type checker error codes in the compiler

Pass type checker error codes to base.ErrorfAt function calls
in the compiler (but don't do anything yet with the code).

Also, provide error codes to base.ErrorfAt calls in the
compiler as needed.

This opens the door towards reporting the error code and/or
providing a link/reference to more detailed explanations
(see internal/types/errors/codes.go).

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

15 months agoruntime: delete gentraceback
Austin Clements [Tue, 14 Feb 2023 18:54:29 +0000 (13:54 -0500)]
runtime: delete gentraceback

Printing is the only remaining functionality of gentraceback. Move
this into the traceback printing code and eliminate gentraceback. This
lets us simplify the logic, which fixes at least one minor bug:
previously, if inline unwinding pushed the total printed count over
_TracebackMaxFrames, we would print extra frames and then fail to
print "additional frames elided".

The cumulative performance effect of the series of changes starting
with "add a benchmark of Callers" (CL 472956) is:

goos: linux
goarch: amd64
pkg: runtime
cpu: Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz
                       │  baseline   │              unwinder               │
                       │   sec/op    │   sec/op     vs base                │
Callers/cached-48        1.464µ ± 1%   1.684µ ± 1%  +15.03% (p=0.000 n=20)
Callers/inlined-48       1.391µ ± 1%   1.536µ ± 1%  +10.42% (p=0.000 n=20)
Callers/no-cache-48      10.50µ ± 1%   11.11µ ± 0%   +5.82% (p=0.000 n=20)
StackCopyPtr-48          88.74m ± 1%   81.22m ± 2%   -8.48% (p=0.000 n=20)
StackCopy-48             80.90m ± 1%   70.56m ± 1%  -12.78% (p=0.000 n=20)
StackCopyNoCache-48      2.458m ± 1%   2.209m ± 1%  -10.15% (p=0.000 n=20)
StackCopyWithStkobj-48   26.81m ± 1%   25.66m ± 1%   -4.28% (p=0.000 n=20)
geomean                  518.8µ        512.9µ        -1.14%

The performance impact of intermediate CLs in this sequence varies a
lot as we went through many refactorings. The slowdown in Callers
comes primarily from the introduction of unwinder because that doesn't
get inlined and results in somewhat worse code generation in code
that's extremely hot in those microbenchmarks. The performance gains
on stack copying come mostly from replacing callbacks with direct use
of the unwinder.

Updates #54466.
Fixes #32383.

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

15 months agoruntime: new API for filling PC traceback buffers
Austin Clements [Tue, 14 Feb 2023 17:25:11 +0000 (12:25 -0500)]
runtime: new API for filling PC traceback buffers

Currently, filling PC traceback buffers is one of the jobs of
gentraceback. This moves it into a new function, tracebackPCs, with a
simple API built around unwinder, and changes all callers to use this
new API.

Updates #54466.

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

15 months agoruntime: move cgo traceback into unwinder
Austin Clements [Tue, 14 Feb 2023 16:50:30 +0000 (11:50 -0500)]
runtime: move cgo traceback into unwinder

Currently, gentraceback's loop ends with a call to tracebackCgoContext
to process cgo frames. This requires spreading various parts of the
printing and pcbuf logic across these two functions.

Clean this up by moving cgo unwinding into unwinder and then lifting
the printing and pcbuf logic from tracebackCgoContext into
gentraceback along with the other printing and pcbuf logic.

Updates #54466.

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

15 months agoruntime: simplify traceback PC back-up logic
Austin Clements [Mon, 13 Feb 2023 22:57:26 +0000 (17:57 -0500)]
runtime: simplify traceback PC back-up logic

Updates #54466.

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

15 months agoruntime: replace all callback uses of gentraceback with unwinder
Austin Clements [Mon, 13 Feb 2023 21:20:54 +0000 (16:20 -0500)]
runtime: replace all callback uses of gentraceback with unwinder

This is a really nice simplification for all of these call sites.

It also achieves a nice performance improvement for stack copying:

goos: linux
goarch: amd64
pkg: runtime
cpu: Intel(R) Xeon(R) CPU E5-2690 v3 @ 2.60GHz
                       │   before    │                after                │
                       │   sec/op    │   sec/op     vs base                │
StackCopyPtr-48          89.25m ± 1%   79.78m ± 1%  -10.62% (p=0.000 n=20)
StackCopy-48             83.48m ± 2%   71.88m ± 1%  -13.90% (p=0.000 n=20)
StackCopyNoCache-48      2.504m ± 2%   2.195m ± 1%  -12.32% (p=0.000 n=20)
StackCopyWithStkobj-48   21.66m ± 1%   21.02m ± 2%   -2.95% (p=0.000 n=20)
geomean                  25.21m        22.68m       -10.04%

Updates #54466.

Change-Id: I31715b7b6efd65726940041d3052bb1c0a1186f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/468297
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
15 months agoruntime: make unsafe.Slice usable from nowritebarrierrec
Austin Clements [Mon, 13 Feb 2023 20:55:21 +0000 (15:55 -0500)]
runtime: make unsafe.Slice usable from nowritebarrierrec

Many compiler-generated panics are dynamically changed to a "throw"
when they happen in the runtime. One effect of this is that they are
allowed in nowritebarrierrec contexts. Currently, the unsafe.Slice
panics don't have this treatment.

We're about to expose more code that uses unsafe.Slice to the write
barrier checker (it's actually already there and it just can't see
through an indirect call), so give these panics the dynamic check.

Very indirectly updates #54466.

Change-Id: I65cb96fa17eb751041e4fa25a1c1bd03246c82ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/468296
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
15 months agoruntime: implement traceback iterator
Austin Clements [Thu, 14 Jul 2022 16:22:24 +0000 (12:22 -0400)]
runtime: implement traceback iterator

Currently, all stack walking logic is in one venerable, large, and
very, very complicated function: runtime.gentraceback. This function
has three distinct operating modes: printing, populating a PC buffer,
or invoking a callback. And it has three different modes of unwinding:
physical Go frames, inlined Go frames, and cgo frames. It also has
several flags. All of this logic is very interwoven.

This CL reimplements the monolithic gentraceback function as an
"unwinder" type with an iterator API. It moves all of the logic for
stack walking into this new type, and gentraceback is now a
much-simplified wrapper around the new unwinder type that still
implements printing, populating a PC buffer, and invoking a callback.
Follow-up CLs will replace uses of gentraceback with direct uses of
unwinder.

Exposing traceback functionality as an iterator API will enable a lot
of follow-up work such as simplifying the open-coded defer
implementation (which should in turn help with #26813 and #37233),
printing the bottom of deep stacks (#7181), and eliminating the small
limit on CPU stacks in profiles (#56029).

Fixes #54466.

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

15 months agoruntime: replace cgoCtxt slice with index in traceback
Austin Clements [Thu, 9 Feb 2023 19:40:05 +0000 (14:40 -0500)]
runtime: replace cgoCtxt slice with index in traceback

Currently, gentraceback consumes the gp.cgoCtxt slice by copying the
slice header and then sub-slicing it as it unwinds. The code for this
is nice and clear, but we're about to lift this state into a structure
and mutating it is going to introduce write barriers that are
disallowed in gentraceback.

This CL replaces the mutable slice header with an index into
gp.cgoCtxt.

For #54466.

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

15 months agoruntime: skip TestTracebackInlined if inlining is disabled
Austin Clements [Fri, 10 Mar 2023 17:33:24 +0000 (12:33 -0500)]
runtime: skip TestTracebackInlined if inlining is disabled

This should fix the noopt builders.

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

15 months agoruntime: use inlineUnwinder
Austin Clements [Mon, 6 Feb 2023 02:37:07 +0000 (21:37 -0500)]
runtime: use inlineUnwinder

This converts all places in the runtime that perform inline expansion
to use the new inlineUnwinder abstraction.

For #54466.

Change-Id: I48d996fb6263ed5225bd21d30914a27ae434528d
Reviewed-on: https://go-review.googlesource.com/c/go/+/466099
Run-TryBot: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
15 months agoruntime: add tests of printing inlined frames in tracebacks
Austin Clements [Mon, 6 Feb 2023 19:13:54 +0000 (14:13 -0500)]
runtime: add tests of printing inlined frames in tracebacks

We're about to rewrite this code and it has almost no test coverage
right now.

This test is also more complete than the existing
TestTracebackInlineExcluded, so we delete that test.

For #54466.

Change-Id: I144154282dac5eb3798f7d332b806f44c4a0bdf6
Reviewed-on: https://go-review.googlesource.com/c/go/+/466098
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
15 months agoruntime: use srcFunc for showframe
Austin Clements [Mon, 6 Feb 2023 03:02:03 +0000 (22:02 -0500)]
runtime: use srcFunc for showframe

Since srcFunc can represent information for either an real text
function or an inlined function, this means we no longer have to
synthesize a fake _func just to call showframe on an inlined frame.

This is cleaner and also eliminates the one case where _func values
live in the heap. This will let us mark them NotInHeap, which will in
turn eliminate pesky write barriers in the traceback rewrite.

For #54466.

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

15 months agoruntime: create an API for unwinding inlined frames
Austin Clements [Sun, 5 Feb 2023 20:54:33 +0000 (15:54 -0500)]
runtime: create an API for unwinding inlined frames

We've replicated the code to expand inlined frames in many places in
the runtime at this point. This CL adds a simple iterator API that
abstracts this out.

We also use this to try out a new idea for structuring tests of
runtime internals: rather than exporting this whole internal data type
and API, we write the test in package runtime and import the few bits
of std we need. The idea is that, for tests of internals, it's easier
to inject public APIs from std than it is to export non-public APIs
from runtime. This is discussed more in #55108.

For #54466.

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

15 months agoruntime: dedup function name logic into moduledata method
Austin Clements [Fri, 3 Feb 2023 22:49:53 +0000 (17:49 -0500)]
runtime: dedup function name logic into moduledata method

For #54466.

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

15 months agoruntime: resolve caller funcInfo after processing current frame
Austin Clements [Sun, 17 Jul 2022 19:57:09 +0000 (15:57 -0400)]
runtime: resolve caller funcInfo after processing current frame

Currently, gentraceback resolves the funcInfo of the caller prior to
processing the current frame (calling the callback, printing it, etc).
As a result, if this lookup fails in a verbose context, it will print
the failure before printing the frame that it's already resolved.

To fix this, move the resolution of LR to a funcInfo to after current
frame processing.

This also has the advantage that we can reduce the scope of "flr" (the
caller's funcInfo) to only the post-frame part of the loop, which will
make it easier to stack-rip gentraceback into an iterator.

For #54466.

Change-Id: I8be44d4eac598a686c32936ab37018b8aa97c00b
Reviewed-on: https://go-review.googlesource.com/c/go/+/458217
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
15 months agoruntime: eliminate waspanic from gentraceback
Austin Clements [Sun, 17 Jul 2022 19:43:01 +0000 (15:43 -0400)]
runtime: eliminate waspanic from gentraceback

gentraceback also tracks the funcID of the callee, which is more
general. Fix this up to happen in all cases and eliminate waspanic in
favor of checking the funcID of the caller.

For #54466.

Change-Id: Idc98365a6f05022db18ddcd5b3ed8684a6872a88
Reviewed-on: https://go-review.googlesource.com/c/go/+/458216
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoruntime: don't track stack separately in gentraceback
Austin Clements [Tue, 12 Jul 2022 20:42:06 +0000 (16:42 -0400)]
runtime: don't track stack separately in gentraceback

Currently, gentraceback keeps a copy of the stack bounds of the stack
it's walking in the "stack" variable. Now that "gp" always refers to
the G whose stack it's walking, we can simply use gp.stack instead of
keeping a separate copy.

For #54466.

Change-Id: I68256e5dff6212cfcf14eda615487e66a92d4914
Reviewed-on: https://go-review.googlesource.com/c/go/+/458215
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoruntime: add a benchmark of Callers
Austin Clements [Tue, 28 Feb 2023 14:13:56 +0000 (09:13 -0500)]
runtime: add a benchmark of Callers

We're about to make major changes to tracebacks. We have benchmarks of
stack copying, but not of PC buffer filling, so add some that we can
track through these changes.

For #54466.

Change-Id: I3ed61d75144ba03b61517cd9834eeb71c99d74df
Reviewed-on: https://go-review.googlesource.com/c/go/+/472956
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
15 months agocmd/compile/internal/types2: record error code in Error struct
Robert Griesemer [Thu, 9 Mar 2023 22:44:46 +0000 (14:44 -0800)]
cmd/compile/internal/types2: record error code in Error struct

go/types already does this, if slightly differently.

Change-Id: I9cf5f493714d865deec5ad23e2ee9b5c5d3f2f0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/475197
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>
Reviewed-by: Robert Findley <rfindley@google.com>
15 months agointernal/fuzz: avoid deadlock on duplicate entries with exec limit
Roland Shoemaker [Thu, 9 Mar 2023 23:59:17 +0000 (15:59 -0800)]
internal/fuzz: avoid deadlock on duplicate entries with exec limit

If there was a execution limit enabled, and a result put us beyond that
limit, but the result expanded coverage *and* was a duplicate of an
entry already in the cache, the check if we were passed the limit would
be skipped. Since this check was inside the result check body, and we
would no longer send any new inputs, we'd never get to that check again,
causing the coordinator to just sit in an infinite loop.

This moves the check up to the top of the coordinator loop, so that it
is checked after every result is processed. Also add a cmd/go TestScript
regression test which triggered this case much more frequently.

Updates #51484

Change-Id: I7a2181051177acb853c1009beedd334a40796177
Reviewed-on: https://go-review.googlesource.com/c/go/+/475196
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agoruntime: implement cputicks with the stable counter on loong64
Guoqi Chen [Fri, 5 Aug 2022 05:32:08 +0000 (13:32 +0800)]
runtime: implement cputicks with the stable counter on loong64

The stable counter is described in Section 2.2.10.4, LoongArch Reference Manual Volume 1.

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

Change-Id: I160b695a8c0e38ef49b21fb8b41460fd23d9538c
Reviewed-on: https://go-review.googlesource.com/c/go/+/421656
Reviewed-by: Meidan Li <limeidan@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Michael Pratt <mpratt@google.com>
15 months agocmd/compile: reorder operations in SCCs to enable more inlining
Than McIntosh [Thu, 9 Mar 2023 14:59:26 +0000 (09:59 -0500)]
cmd/compile: reorder operations in SCCs to enable more inlining

This patch changes the relative order of "CanInline" and "InlineCalls"
operations within the inliner for clumps of functions corresponding to
strongly connected components in the call graph. This helps increase
the amount of inlining within SCCs, particularly in Go's runtime
package, which has a couple of very large SCCs.

For a given SCC of the form { fn1, fn2, ... fnk }, the inliner would
(prior to this point) walk through the list of functions and for each
function first compute inlinability ("CanInline") and then perform
inlining ("InlineCalls"). This meant that if there was an inlinable
call from fn3 to fn4 (for example), this call would never be inlined,
since at the point fn3 was visited, we would not have computed
inlinability for fn4.

We now do inlinability analysis for all functions in an SCC first,
then do actual inlining for everything. This results in 47 additional
inlines in the Go runtime package (a fairly modest increase
percentage-wise of 0.6%).

Updates #58905.

Change-Id: I48dbb1ca16f0b12f256d9eeba8cf7f3e6dd853cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/474955
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
15 months agocmd/link: use only the configured C compiler in TestCGOLTO
Bryan C. Mills [Thu, 9 Mar 2023 21:17:30 +0000 (16:17 -0500)]
cmd/link: use only the configured C compiler in TestCGOLTO

The test had been assuming that any 'gcc' or 'clang' command found in
$PATH could be used to compile cgo dependencies for the target GOARCH
and GOOS. That assumption does not hold in general: for example,
the GOARCH/GOOS configuration may be cross-compiling, which will cause
the test to fail if the native 'gcc' and/or 'clang' is not configured
for the target architecture.

Instead, leave the 'CC' variable unset and assume only that the user
has configured it appropriate to the environment in which they are
running the test.

For #58829.

Change-Id: I9a1269ae3e0b4af281702114dabba844953f74bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/475155
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agocmd/link: use label symbols for Duff's devices on darwin/arm64
Cherry Mui [Wed, 8 Mar 2023 21:38:32 +0000 (16:38 -0500)]
cmd/link: use label symbols for Duff's devices on darwin/arm64

On darwin, the external linker generally supports CALL relocations
with addend. One exception is that for a very large binary when it
decides to insert a trampoline, instead of applying the addend to
the call target (in the trampoline), it applies the addend to the
CALL instruction in the caller, i.e. generating a call to
trampoline+addend, which is not the correct address and usually
points to unreloated functions.

To work around this, we use label symbols so the CALL is targeting
a label symbol without addend. To make things simple we always use
label symbols for CALLs with addend (in external linking mode on
darwin/arm64), even for small binaries.

Fixes #58935.

Change-Id: I38aed6b62a0496c277c589b5accbbef6aace8dd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/474620
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
15 months agogo/types, types2: clean up defined type identity check/unification
Robert Griesemer [Wed, 8 Mar 2023 03:01:38 +0000 (19:01 -0800)]
go/types, types2: clean up defined type identity check/unification

Factor out check for identical origin.
Match unification code with type identity check.
Add a test case for #53692.

Change-Id: I1238b28297a5ac549e99261c8a085dd46f3dd65f
Reviewed-on: https://go-review.googlesource.com/c/go/+/474197
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agocmd/compile: remove -wrapglobalmapinit flag
Than McIntosh [Thu, 9 Mar 2023 18:20:01 +0000 (13:20 -0500)]
cmd/compile: remove -wrapglobalmapinit flag

Remove the compiler's "-wrapglobalmapinit" flag; it is potentially
confusing for users and isn't appropriate as a top level flag. Move
the enable/disable control to the "wrapglobalmapctl" debug flag
(values: 0 on by default, 1 disabled, 2 stress mode). No other changes
to compiler functionality.

Change-Id: I0d120eaf90ee34e29d5032889e673d42fe99e5dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/475035
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/compile: clarify a few redundant deletions of internal/ssagen.state.vars
Andy Pan [Sat, 25 Feb 2023 10:31:13 +0000 (18:31 +0800)]
cmd/compile: clarify a few redundant deletions of internal/ssagen.state.vars

Fixes #58729

The reason why these deletions exist is that the old state.variable method
will assign the new value to the given key of map when the key doesn't exist,
but after this commit: https://github.com/golang/go/commit/5a6e511c614a158cb58150fb62bfbc207a33922d#diff-e754f9fc8eaf878714250cfc03844eb3b58185ac806a8c1c4f9fbabd86cda921L3972
the state.variable doesn't do that anymore, thus these deletions became redundant.

Change-Id: Ie6e2471ca445f907a2bb1607c293f9301f0d73e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/471355
Run-TryBot: Andy Pan <panjf2000@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
15 months agoRevert "cmd/link: establish dependable package initialization order"
Keith Randall [Thu, 9 Mar 2023 16:31:41 +0000 (16:31 +0000)]
Revert "cmd/link: establish dependable package initialization order"

This reverts commit ce2a609909d9de3391a99a00fe140506f724f933.
aka CL 462035

Reason for revert: this CL is causing some problems in some internal Google programs.

Change-Id: I4476b8d8d2c3d7b5703d1d85c93baebb4b4e5d26
Reviewed-on: https://go-review.googlesource.com/c/go/+/474976
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
15 months agoRevert "cmd/internal/objabi: regenerate RelocType stringer file"
Keith Randall [Thu, 9 Mar 2023 16:30:46 +0000 (16:30 +0000)]
Revert "cmd/internal/objabi: regenerate RelocType stringer file"

This reverts commit 99914db5eea927c7694276169585f1fff9e614c8.
aka CL 473875

Reason for revert: init order change that required this CL is causing some problems in some internal Google programs.

Change-Id: I801e278ab58d542c05c0332a9f1977b9588b6151
Reviewed-on: https://go-review.googlesource.com/c/go/+/474975
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Keith Randall <khr@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
15 months agoruntime/trace: update outdated Task and Region documentation
Nick Ripley [Thu, 2 Mar 2023 21:20:07 +0000 (16:20 -0500)]
runtime/trace: update outdated Task and Region documentation

A previous iteration of the tracer's user annotation API had different
names for tasks and regions, and used to return functions for ending
them rather than types with End methods. This CL updates the doc
comments to reflect those changes, and also fixes up the internal
documentation of the events (similar to go.dev/cl/465335, the stack
argument was in the wrong place in the list).

The User Log event internal documentation might also look wrong since
the value argument follows the stack argument. However, the User Log
event is a special case where the log message is appended immediately
following the normal event, including the stack argument. There isn't
much room to clarify this next to the event type definitions, so this CL
clarifies the comment where the event is encoded.

Change-Id: I846c709f6026ef01c0a272557d6390b2c17074e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/472955
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Nick Ripley <nick.ripley@datadoghq.com>

15 months agonet/http: use Copy in ServeContent if CopyN not needed
Leo Antunes [Sun, 30 Oct 2022 10:15:27 +0000 (10:15 +0000)]
net/http: use Copy in ServeContent if CopyN not needed

This small PR allows optimizations made in io.Copy (like the use of
io.WriterTo) to be used in one possible path of http.ServeContent
(in case of a non-Range request).
This, in turn, allows us to skip the buffer allocation in io.Copy.

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

15 months agocmd/compile: report profile open/parse errors
Michael Pratt [Thu, 9 Mar 2023 17:10:25 +0000 (12:10 -0500)]
cmd/compile: report profile open/parse errors

Currently we fail to print errors from os.Open and profile.Parse of the
PGO profile, losing context useful to understand these errors.

In fixing this, cleanup error use overall to return an error from
pgo.New and report the problematic file at the top level.

Change-Id: Id7e9c781c4b8520eee96b6f5fe8a0b757d947f7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/474995
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>

15 months agointernal/bytealg: remove aix and linux build tags from ppc64 index code
Joel Sing [Thu, 2 Mar 2023 14:23:59 +0000 (01:23 +1100)]
internal/bytealg: remove aix and linux build tags from ppc64 index code

This code is generic to ppc64/ppc64le - there is no need to limit it to
aix or linux.

Updates #56001

Change-Id: I613964a90f9c5ca637720219a0260d65427f4be0
Reviewed-on: https://go-review.googlesource.com/c/go/+/473697
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
15 months agosyscall: avoid race in plan9 while syncing Chdir across goroutines
miller [Tue, 7 Mar 2023 15:15:10 +0000 (15:15 +0000)]
syscall: avoid race in plan9 while syncing Chdir across goroutines

Because each M in Plan 9 runs in a separate OS process with its
own current working directory, a Chdir call in one goroutine needs
to be propagated to other goroutines before a subsequent syscall
with a local pathname (see #9428). This is done by function
syscall.Fixwd, but there is still a race if a goroutine is
preempted and rescheduled on a different M between calling Fixwd
and executing the syscall which it protects. By locking the
goroutine to its OS thread from the start of Fixwd to the end of
the protected syscall, this race can be prevented.

Fixes #58802.

Change-Id: I89c0e43ef4544b5bfb5db7d2158f13f24b42e1f6
Reviewed-on: https://go-review.googlesource.com/c/go/+/474055
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agonet/http: remove arbitrary timeout in TestServerAllowsBlockingRemoteAddr
Bryan C. Mills [Wed, 8 Mar 2023 22:10:06 +0000 (17:10 -0500)]
net/http: remove arbitrary timeout in TestServerAllowsBlockingRemoteAddr

If the test actually deadlocks, we probably want a goroutine dump to
debug it anyway. Otherwise, the arbitrary timeout can only cause
spurious failures.

Fixes #36179.

Change-Id: Ic2037496959a38d3231eefdbc1dd5d45eebdf306
Reviewed-on: https://go-review.googlesource.com/c/go/+/474582
Auto-Submit: 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>

15 months agoruntime/cgo: add tsan sync for traceback function
Ian Lance Taylor [Wed, 8 Mar 2023 04:27:59 +0000 (20:27 -0800)]
runtime/cgo: add tsan sync for traceback function

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

15 months agotest: test for issue 53087
Keith Randall [Thu, 2 Jun 2022 16:31:30 +0000 (09:31 -0700)]
test: test for issue 53087

This issue has been fixed with unified IR, so just add a test.

Update #53087

Change-Id: I965d9f27529fa6b7c89e2921c65e5a100daeb9fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/410197
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Keith Randall <khr@google.com>

15 months agodebug/buildinfo: recognize macOS fat binary in go version
Nikola Jokic [Mon, 6 Mar 2023 08:52:12 +0000 (09:52 +0100)]
debug/buildinfo: recognize macOS fat binary in go version

buildinfo did not check for fat magic, which caused go version to report
unrecognized file format.

This change reads the fat file and passes the first arch file to machoExe.

Fixes #58796

Change-Id: I45cd26729352e46cc7ecfb13f2e9a8d96d62e0a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/473615
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agocmd/internal/obj/ppc64: add SETB instruction
Paul E. Murphy [Mon, 27 Feb 2023 22:05:34 +0000 (16:05 -0600)]
cmd/internal/obj/ppc64: add SETB instruction

This ISA 3.0 (power9) instruction is helpful for some string functions
in a future change.

Change-Id: I1a659488ffb5099f8c89f480c39af4ef9c4b556a
Reviewed-on: https://go-review.googlesource.com/c/go/+/472635
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agonet/http: support full-duplex HTTP/1 responses
Damien Neil [Wed, 1 Mar 2023 23:17:35 +0000 (15:17 -0800)]
net/http: support full-duplex HTTP/1 responses

Add support for concurrently reading from an HTTP/1 request body
while writing the response.

Normally, the HTTP/1 server automatically consumes any remaining
request body before starting to write a response, to avoid deadlocking
clients which attempt to write a complete request before reading the
response.

Add a ResponseController.EnableFullDuplex method which disables this
behavior.

For #15527
For #57786

Change-Id: Ie7ee8267d8333e9b32b82b9b84d4ad28ab8edf01
Reviewed-on: https://go-review.googlesource.com/c/go/+/472636
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
15 months agocmd/go: simplify cgo and buildmode checks in tests
Bryan C. Mills [Tue, 7 Mar 2023 20:56:20 +0000 (15:56 -0500)]
cmd/go: simplify cgo and buildmode checks in tests

Change-Id: I0d6e49226a8708cc5f6ed3bea7658bec202a7ae7
Reviewed-on: https://go-review.googlesource.com/c/go/+/474138
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agocmd/go: avoid running slow tests on non-longtest builders
Bryan C. Mills [Tue, 7 Mar 2023 20:12:29 +0000 (15:12 -0500)]
cmd/go: avoid running slow tests on non-longtest builders

Also annotate calls to tooSlow with specific reasons.

This will somewhat reduce test coverage on the 'darwin' builders until
we have darwin 'longtest' builders (#35678,#49055), but still seems
worthwhile to avoid alert fatigue from tests that really shouldn't be
running in the short configurations.

Fixes #58918.
Fixes #58919.

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

15 months agonet: document the Close blocking with SO_LINGER on some OS's
Andy Pan [Tue, 7 Mar 2023 11:34:17 +0000 (19:34 +0800)]
net: document the Close blocking with SO_LINGER on some OS's

Fixes #58882

Change-Id: I65842a4aa3f808533e28128078e7e94a9b121404
Reviewed-on: https://go-review.googlesource.com/c/go/+/473915
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

15 months agocmd/internal/objabi: regenerate RelocType stringer file
qmuntal [Tue, 7 Mar 2023 07:37:31 +0000 (08:37 +0100)]
cmd/internal/objabi: regenerate RelocType stringer file

reloctype_strings.go is out-of-date since CL 462035, regenerate it.

Found while working on CL 461737.

Change-Id: I5cf910ab14c3618d6653c87861a4d53d3c91feff
Reviewed-on: https://go-review.googlesource.com/c/go/+/473875
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
15 months agoruntime: fix comment mismatch for currentConsMark
Revolution [Tue, 7 Mar 2023 08:32:32 +0000 (08:32 +0000)]
runtime: fix comment mismatch for currentConsMark

Change-Id: Ie0ed83e17be180100f144ce61bbd2c72a64d857b
GitHub-Last-Rev: 9db7a90a951c0fa9d18697fa93ae14267ab9b385
GitHub-Pull-Request: golang/go#58910
Reviewed-on: https://go-review.googlesource.com/c/go/+/473820
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
15 months agoruntime: allow for 5 more threads in TestWindowsStackMemory*
Alex Brainman [Sat, 4 Mar 2023 03:35:35 +0000 (14:35 +1100)]
runtime: allow for 5 more threads in TestWindowsStackMemory*

Original version of TestWindowsStackMemory did not consider sysmon and
other threads running during the test. Allow for 5 extra threads in this
test - this should cover any new threads in the future.

Fixes #58570

Change-Id: I215790f9b94ff40a32ddd7aa54af715d1dc391c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/473415
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
15 months agocmd/compile: enable address folding for globals on ARM64, just not -dynlink mode
Cherry Mui [Tue, 7 Mar 2023 20:32:30 +0000 (15:32 -0500)]
cmd/compile: enable address folding for globals on ARM64, just not -dynlink mode

On ARM64, in -dynlink mode (building a shared library or a plugin),
accessing global variable is made using the GOT. Currently, the
GOT accessing instruction sequence our assembler generates doesn't
handle large offset well, so we don't fold the offset into loads
and stores in the compiler. Currently, the rewrite rules are
guarded with the -shared flag. However, the GOT access
instructions are only generated in the -dynlink mode (which
implies -shared, but not the other direction).

CL 445535 attempted to remove the guard althgether. But that
causes build failure for -dynlink mode for the reason above. This
CL changes it to guard specifically on -dynlink mode, allowing
the optimization in more cases (-shared but not -dynlink build
modes).

Updates #58826.

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

15 months agoRevert "cmd/compile: enable address folding for global symbols of shared library"
Cherry Mui [Tue, 7 Mar 2023 18:23:40 +0000 (18:23 +0000)]
Revert "cmd/compile: enable address folding for global symbols of shared library"

This reverts CL 445535.

Reason for revert: see issue #58826. It doesn't handle large offset well.

Fixes #58826.

Change-Id: Ic4a33f4c510c88628ea7e16207a60977a04cf798
Reviewed-on: https://go-review.googlesource.com/c/go/+/474175
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
15 months agogo/types, types2: fine-tune inference tracing output (debugging support)
Robert Griesemer [Tue, 7 Mar 2023 17:59:35 +0000 (09:59 -0800)]
go/types, types2: fine-tune inference tracing output (debugging support)

No changes to non-tracing related code.

Change-Id: I3d004528281111a4479a02543a3e5443485182cf
Reviewed-on: https://go-review.googlesource.com/c/go/+/474135
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agodebug/elf: retrieve values for dynamic section tags
Florin Papa [Mon, 21 Nov 2022 20:54:11 +0000 (12:54 -0800)]
debug/elf: retrieve values for dynamic section tags

Add functionality to retrieve values for .dynamic entries that don't
correspond to entries in the string table.

Fixes #56892

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

15 months agocmd: fix mismatched symbols
cui fliter [Tue, 7 Mar 2023 15:04:26 +0000 (23:04 +0800)]
cmd: fix mismatched symbols

Change-Id: Ib2c4ddec9740f7c21c180c9f0980394dceeedfaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/473975
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
15 months agocrypto/ed25519: improve Ed25519ctx error for oversized contexts
Tom Thorogood [Mon, 6 Mar 2023 07:43:45 +0000 (18:13 +1030)]
crypto/ed25519: improve Ed25519ctx error for oversized contexts

Previously if PrivateKey.Sign was called for Ed25519ctx with a context
longer than 255 bytes, the error message would mention Ed25519ph.

For Ed25519ph, the order of message length vs context length errors now
matches VerifyWithOptions. A message length error will be surfaced in
preference to a context length error. It also preferences hash errors
ahead of context length errors which also matches the behaviour of
VerifyWithOptions.

Change-Id: Iae380b3d879e0a9877ea057806fcd1e0ef7f7376
Reviewed-on: https://go-review.googlesource.com/c/go/+/473595
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
15 months agogo/types, types2: better error when method is missing due to ambiguity
Robert Griesemer [Mon, 6 Mar 2023 21:05:29 +0000 (13:05 -0800)]
go/types, types2: better error when method is missing due to ambiguity

If a type doesn't implement an interface due to an ambiguous method,
say so in the error message instead of just reporting a missing method.

Fixes #57352.

Change-Id: I5608f893c485de578b7f86362ca6f66033653695
Reviewed-on: https://go-review.googlesource.com/c/go/+/473658
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

15 months agogo/types, types2: avoid 2nd lookup when looking for method on ptr recv
Robert Griesemer [Mon, 6 Mar 2023 03:44:34 +0000 (19:44 -0800)]
go/types, types2: avoid 2nd lookup when looking for method on ptr recv

If a method is not found on a type V, for better error messages we
report if the method is on *V. There's no need to do a 2nd lookup
for that because the relevant information is readily returned by
lookupFieldOrMethod already.

Simplifies code and removes a long-standing TODO.

Change-Id: Ibdb2269b04c0db61bfe4641404ab1df330397b2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/473655
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agoRevert "cmd/go: extend path shortening to all paths in messages"
David Chase [Mon, 6 Mar 2023 20:38:31 +0000 (20:38 +0000)]
Revert "cmd/go: extend path shortening to all paths in messages"

This reverts CL 465805 (commit 3eedba50b10ca9086646f12d7917912cff7d4d0a).

Reason for revert: The longtest on Windows was typoed, silently ignored, and it turns out it fails there.

Change-Id: I362e9a22a7ec569314a0da932730ba137a98ecda
Reviewed-on: https://go-review.googlesource.com/c/go/+/473795
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agodebug/buildinfo: use saferio in ReadData methods
Ian Lance Taylor [Mon, 6 Mar 2023 19:39:22 +0000 (11:39 -0800)]
debug/buildinfo: use saferio in ReadData methods

This avoids a very large memory allocation if corrupt data says that
we need to read a very long string.

No test case because the problem can only happen for invalid data. Let
the fuzzer find cases like this.

For #47653
Fixes #58886

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

15 months agocmd/go: distinguish packages built for different main packages in printing
Cherry Mui [Fri, 3 Mar 2023 00:16:34 +0000 (19:16 -0500)]
cmd/go: distinguish packages built for different main packages in printing

In -pgo=auto mode, a package may be built multiple times. E.g. for

go build -pgo=auto cmd/a cmd/b

and both cmd/a and cmd/b imports package p, p may be built twice,
one using a's profile, one using b's. If we need to print p, e.g.
in "go list -deps" or when there is a build failure, p will be
printed twice, and currently we don't distinguish them.

We have a precedence for a similar case: for testing, there is the
original package, and the (internal) test version of the package
(which includes _test.go files). Packages that import the package
under testing may also have two versions (one imports the original,
one imports the testing version). In printing, the go command
distinguishes them by adding a "[p.test]" suffix for the latter,
as they are specifically built for the p.test binary.

We do the similar. When a package needs to be compiled multiple
times for different main packages, we attach the main package's
import path, like "p [cmd/a]" for package p built specifically
for cmd/a.

For #58099.

Change-Id: I4a040cf17e1dceb5ca1810c217f16e734c858ab6
Reviewed-on: https://go-review.googlesource.com/c/go/+/473275
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agocmd/go: support multiple main packages with -pgo=auto
Cherry Mui [Tue, 28 Feb 2023 23:43:14 +0000 (18:43 -0500)]
cmd/go: support multiple main packages with -pgo=auto

In -pgo=auto mode, the go command finds a profile named
default.pgo in the main package's directly, and if found, use it
as the profile for the build. Currently we only support a single
main package when -pgo=auto is used.

When multiple main packages are included in a build, they may
have different default profiles (or some have profiles whereas
some don't), so a common dependent package would need to be built
multiple times, with different profiles (or lack of). This CL
handles this. To do so, we need to split (unshare) the dependency
graph so they can attach different profiles.

Fixes #58099.

Change-Id: I1ad21361967aafbf5089d8d5e89229f95fe31276
Reviewed-on: https://go-review.googlesource.com/c/go/+/472358
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agocmd/go: make PGO profile path per package
Cherry Mui [Mon, 27 Feb 2023 20:37:32 +0000 (15:37 -0500)]
cmd/go: make PGO profile path per package

Currently, the PGO profile path is global for a single go command
invocation, as it applies to all packages being built (or none).
With -pgo=auto mode with multiple main packages, packages from a
single go command invocation could have different profiles. So it
is necessary that the PGO profile path is per package, which is
this CL does.

For #58099.

Change-Id: I148a15970ec907272db85b4b27ad6b08c41d6c0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/472357
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
15 months agocmd/go: extend path shortening to all paths in messages
David Chase [Mon, 6 Feb 2023 22:10:10 +0000 (17:10 -0500)]
cmd/go: extend path shortening to all paths in messages

The previous code only shortened the directory name for files
in the directory being compiled (and $WORK and runtime/std).

This extends the shortening to all file names.

Change-Id: I6abef6141d57036d893420b82e01ed0fbb637788
Reviewed-on: https://go-review.googlesource.com/c/go/+/465805
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>

15 months agocmd/compile: add flag to FOR/RANGE to preserve loop semantics across inlines
David Chase [Wed, 25 Jan 2023 22:08:16 +0000 (17:08 -0500)]
cmd/compile: add flag to FOR/RANGE to preserve loop semantics across inlines

This modifies the loopvar change to be tied to the
package if it is specified that way, and preserves
the change across inlining.

Down the road, this will be triggered (and flow correctly)
if the changed semantics are tied to Go version specified
in go.mod (or rather, for the compiler, by the specified
version for compilation).

Includes tests.

Change-Id: If54e8b6dd23273b86be5ba47838c90d38af9bd1a
Reviewed-on: https://go-review.googlesource.com/c/go/+/463595
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
15 months agocmd/compile: experimental loop iterator capture semantics change
David Chase [Sun, 12 Jun 2022 19:33:57 +0000 (15:33 -0400)]
cmd/compile: experimental loop iterator capture semantics change

Adds:
GOEXPERIMENT=loopvar (expected way of invoking)
-d=loopvar={-1,0,1,2,11,12} (for per-package control and/or logging)
-d=loopvarhash=... (for hash debugging)

loopvar=11,12 are for testing, benchmarking, and debugging.

If enabled,for loops of the form `for x,y := range thing`, if x and/or
y are addressed or captured by a closure, are transformed by renaming
x/y to a temporary and prepending an assignment to the body of the
loop x := tmp_x.  This changes the loop semantics by making each
iteration's instance of x be distinct from the others (currently they
are all aliased, and when this matters, it is almost always a bug).

3-range with captured iteration variables are also transformed,
though it is a more complex transformation.

"Optimized" to do a simpler transformation for
3-clause for where the increment is empty.

(Prior optimization of address-taking under Return disabled, because
it was incorrect; returns can have loops for children.  Restored in
a later CL.)

Includes support for -d=loopvarhash=<binary string> intended for use
with hash search and GOCOMPILEDEBUG=loopvarhash=<binary string>
(use `gossahash -e loopvarhash command-that-fails`).

Minor feature upgrades to hash-triggered features; clients can specify
that file-position hashes use only the most-inline position, and/or that
they use only the basenames of source files (not the full directory path).
Most-inlined is the right choice for debugging loop-iteration change
once the semantics are linked to the package across inlining; basename-only
makes it tractable to write tests (which, otherwise, depend on the full
pathname of the source file and thus vary).

Updates #57969.

Change-Id: I180a51a3f8d4173f6210c861f10de23de8a1b1db
Reviewed-on: https://go-review.googlesource.com/c/go/+/411904
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agogo/types, types2: use "undefined type" rather than "<T>" in have/want error messages
Robert Griesemer [Fri, 3 Mar 2023 18:43:02 +0000 (10:43 -0800)]
go/types, types2: use "undefined type" rather than "<T>" in have/want error messages

In assignments and return statements, if we have the wrong number
of LHS or return values, we report the pattern that we have and
the pattern that we want. For untyped constants we use "number"
(to be not overly specific). For unknown types (due to earlier
errors), now use "unknown type" rather than the (cryptic) "<T>".

Fixes #58742.

Change-Id: I69c84ee29fb64badb0121e26a96f003b381024aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/473255
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
15 months agocmd/go: trim spaces in pkg-config ldflags output
qmuntal [Mon, 6 Mar 2023 11:36:31 +0000 (12:36 +0100)]
cmd/go: trim spaces in pkg-config ldflags output

Fixes #58889
Updates #35262

Change-Id: I1d51aa03f445faaf4f4e9cc412d5499cad526663
Reviewed-on: https://go-review.googlesource.com/c/go/+/473616
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agocmd/compile/internal/ir: explicit Pos for New{Bool,Int,String}
Matthew Dempsky [Tue, 28 Feb 2023 21:27:51 +0000 (13:27 -0800)]
cmd/compile/internal/ir: explicit Pos for New{Bool,Int,String}

Stop depending on base.Pos for these.

Change-Id: I58dea44f8141eb37b59a6e9f7db0c6baa516ad93
Reviewed-on: https://go-review.googlesource.com/c/go/+/472296
Reviewed-by: Keith Randall <khr@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: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/link: establish dependable package initialization order
Keith Randall [Fri, 13 Jan 2023 04:25:39 +0000 (20:25 -0800)]
cmd/link: establish dependable package initialization order

As described here:

https://github.com/golang/go/issues/31636#issuecomment-493271830

"Find the lexically earliest package that is not initialized yet,
but has had all its dependencies initialized, initialize that package,
 and repeat."

Simplify the runtime a bit, by just computing the ordering required
in the linker and giving a list to the runtime.

Update #31636
Fixes #57411

RELNOTE=yes

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

15 months agogo/types, types2: added clarifying comments, removed TODO in lookup.go
Robert Griesemer [Fri, 3 Mar 2023 01:24:32 +0000 (17:24 -0800)]
go/types, types2: added clarifying comments, removed TODO in lookup.go

Also, renamed lookupFieldOrMethod to lookupFieldOrMethodImpl to make
a clearer distinction between this function and the exported version
LookupFieldOrMethod.

Except for the rename, all changes are to comments only.

Change-Id: If7d1465c9cf659ea86bbbbcba8b95f16d2170fcc
Reviewed-on: https://go-review.googlesource.com/c/go/+/473075
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

15 months agocmd/compile: ensure FuncForPC works on closures that start with NOPs
Keith Randall [Tue, 14 Feb 2023 07:27:51 +0000 (23:27 -0800)]
cmd/compile: ensure FuncForPC works on closures that start with NOPs

A 0-sized no-op shouldn't prevent us from detecting that the first
instruction is from an inlined callee.

Update #58300

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

15 months agoruntime: skip TestGdbPanic on Windows
qmuntal [Fri, 3 Mar 2023 15:04:56 +0000 (16:04 +0100)]
runtime: skip TestGdbPanic on Windows

TestGdbPanic expects crash() to raise a SIGABRT signal interceptable
by gdb, but Windows doesn't have signals.

Windows builders haven't caught this failing test because they still
don't have gdb installed (tracked in #22021).

Change-Id: I7c7f2523a54d61aea0a9821c4db7c79e58a7217c
Reviewed-on: https://go-review.googlesource.com/c/go/+/473116
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>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>

15 months agocmd/compile: optimize multiplication on loong64
Wayne Zuo [Thu, 2 Mar 2023 05:33:21 +0000 (13:33 +0800)]
cmd/compile: optimize multiplication on loong64

Previously, multiplication on loong64 architecture was performed using
MULV and MULHVU instructions to calculate the low 64-bit and high
64-bit of a multiplication respectively. However, in most cases, only
the low 64-bits are needed. This commit enalbes only computating the low
64-bit result with the MULV instruction.

Reduce the binary size slightly.

file      before    after     Δ       %
addr2line 2833777   2833849   +72     +0.003%
asm       5267499   5266963   -536    -0.010%
buildid   2579706   2579402   -304    -0.012%
cgo       4798260   4797444   -816    -0.017%
compile   25247419  25175030  -72389  -0.287%
cover     4973091   4972027   -1064   -0.021%
dist      3631013   3565653   -65360  -1.800%
doc       4076036   4074004   -2032   -0.050%
fix       3496378   3496066   -312    -0.009%
link      6984102   6983214   -888    -0.013%
nm        2743820   2743516   -304    -0.011%
objdump   4277171   4277035   -136    -0.003%
pack      2379248   2378872   -376    -0.016%
pprof     14419090  14419874  +784    +0.005%
test2json 2684386   2684018   -368    -0.014%
trace     13640018  13631034  -8984   -0.066%
vet       7748918   7752630   +3712   +0.048%
go        15643850  15638098  -5752   -0.037%
total     127423782 127268729 -155053 -0.122%

Change-Id: Ifce4a9a3ed1d03c170681e39cb6f3541db9882dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/472775
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: David Chase <drchase@google.com>
15 months agoarchive/zip: make receiver names consistent
Oleksandr Redko [Sun, 12 Feb 2023 12:21:26 +0000 (12:21 +0000)]
archive/zip: make receiver names consistent

Fixes revive linter receiver-naming warnings:

- receiver name f should be consistent with previous receiver name e for fileListEntry
- receiver name r should be consistent with previous receiver name z for Reader
- receiver name f should be consistent with previous receiver name h for FileHeader

Change-Id: Ibfa14b97f6ca7adc86e3a1df919c5bb5de9716dc
GitHub-Last-Rev: dd7315b09d224bb2953b82cc6bd97d81c9eaca0a
GitHub-Pull-Request: golang/go#58477
Reviewed-on: https://go-review.googlesource.com/c/go/+/467519
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@google.com>

15 months agoall: move //go: function directives directly above functions
Michael Pratt [Thu, 2 Mar 2023 22:09:22 +0000 (17:09 -0500)]
all: move //go: function directives directly above functions

These directives affect the next declaration, so the existing form is
valid, but can be confusing because it is easy to miss. Move then
directly above the declaration for improved readability.

CL 69120 previously moved the Gosched nosplit away to hide it from
documentation. Since CL 224737, directives are automatically excluded
from documentation.

Change-Id: I8ebf2d47fbb5e77c6f40ed8afdf79eaa4f4e335e
Reviewed-on: https://go-review.googlesource.com/c/go/+/472957
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Austin Clements <austin@google.com>
15 months agonet: re-enable TestVariousDeadlines on Plan 9
miller [Wed, 1 Mar 2023 09:46:14 +0000 (09:46 +0000)]
net: re-enable TestVariousDeadlines on Plan 9

After CL 470215 it should be safe to run this test on Plan 9.

Fixes #26945

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

15 months agogo/types, types2: simplify missingMethod some more (cleanup)
Robert Griesemer [Thu, 2 Mar 2023 20:19:53 +0000 (12:19 -0800)]
go/types, types2: simplify missingMethod some more (cleanup)

Remove unnecessary assignments by using the same two variables
for methods consistently throughout.

Change-Id: I8b9bc8dbc8022b2472724d2a170f2635de3306e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/472915
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

15 months agogo/types, types2: disentangle convoluted logic for missing method cause
Robert Griesemer [Thu, 2 Mar 2023 01:08:15 +0000 (17:08 -0800)]
go/types, types2: disentangle convoluted logic for missing method cause

Use a state to exactly track lookup results. In case of lookup failure,
use the state to directly report the cause instead of trying to guess
from the missing and alternative method.

Addresses a TODO (incorrect error message).

Change-Id: I50902752deab741f8199a09fd1ed29286cf5be42
Reviewed-on: https://go-review.googlesource.com/c/go/+/472637
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
15 months agocmd/link/internal/ld: move more of mustLinkExternal into internal/platform
Bryan C. Mills [Wed, 1 Mar 2023 16:11:07 +0000 (16:11 +0000)]
cmd/link/internal/ld: move more of mustLinkExternal into internal/platform

internal/platform.MustLinkExternal is used in various places to
determine whether external linking is required. It should always
match what the linker actually requires, but today does not match
because the linker imposes additional constraints.

Updates #31544.

Change-Id: I0cc6ad587e95c607329dea5d60d29a5fb2a9e722
Reviewed-on: https://go-review.googlesource.com/c/go/+/472515
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agocmd/asm: don't panic on bad GATHER x86 instructions
Keith Randall [Thu, 2 Mar 2023 06:32:46 +0000 (22:32 -0800)]
cmd/asm: don't panic on bad GATHER x86 instructions

Fixes #58822

Change-Id: I9c44c57dac72884ec3209d87ddb25e7e1675a737
Reviewed-on: https://go-review.googlesource.com/c/go/+/472795
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@google.com>
15 months agogo/types, types2: combine missingMethodCause with missingMethod
Robert Griesemer [Wed, 1 Mar 2023 21:53:48 +0000 (13:53 -0800)]
go/types, types2: combine missingMethodCause with missingMethod

For now this is simply a mechanical combination without any
relevant logic changes. This will make it easier to review
subsequent changes.

Change-Id: Ic2e2ae32b031d2dda0f69a08a5cc2349748bd25d
Reviewed-on: https://go-review.googlesource.com/c/go/+/472675
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>

15 months agointernal/poll: remove redundant atomics from poll.FD on plan9
miller [Wed, 1 Mar 2023 09:33:27 +0000 (09:33 +0000)]
internal/poll: remove redundant atomics from poll.FD on plan9

After CL 235820 all references to FD.rtimedout and FD.wtimedout
are guarded by mutexes. Therefore they can safely be changed
from type atomic.Bool to bool.

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

15 months agoall: implement wasmimport directive
Evan Phoenix [Sun, 22 Jan 2023 23:30:59 +0000 (15:30 -0800)]
all: implement wasmimport directive

Go programs can now use the //go:wasmimport module_name function_name
directive to import functions from the WebAssembly runtime.

For now, the directive is restricted to the runtime and syscall/js
packages.

* Derived from CL 350737
* Original work modified to work with changes to the IR conversion code.
* Modification of CL 350737 changes to fully exist in Unified IR path (emp)
* Original work modified to work with changes to the ABI configuration code.
* Fixes #38248

Co-authored-by: Vedant Roy <vroy101@gmail.com>
Co-authored-by: Richard Musiol <mail@richard-musiol.de>
Co-authored-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Change-Id: I740719735d91c306ac718a435a78e1ee9686bc16
Reviewed-on: https://go-review.googlesource.com/c/go/+/463018
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
15 months agoruntime: fix function name in comments
cui fliter [Wed, 1 Mar 2023 14:43:22 +0000 (22:43 +0800)]
runtime: fix function name in comments

Change-Id: I18bb87bfdea8b6d7994091ced5134aa2549f221e
Reviewed-on: https://go-review.googlesource.com/c/go/+/472476
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: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
15 months agogo/types, types2: change missingMethod to match MissingMethod signature
Robert Griesemer [Wed, 1 Mar 2023 16:06:42 +0000 (08:06 -0800)]
go/types, types2: change missingMethod to match MissingMethod signature

This simplifies the use of missingMethod and also opens the door to
further missingMethod-internal simplifications.

Change-Id: I74d9694b6fca67c4103aea04d08916a69ad0e3c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/472495
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>