]> Cypherpunks repositories - gostls13.git/log
gostls13.git
2 years agolog/slog: function argument to Record.Attrs returns bool
Jonathan Amsterdam [Wed, 12 Apr 2023 13:11:59 +0000 (09:11 -0400)]
log/slog: function argument to Record.Attrs returns bool

Record.Attrs stops as soon as its argument function returns false.

Fixes #59060.

Change-Id: I578d64635e0e52b0fcdbc57f6d5a27a6efac8c70
Reviewed-on: https://go-review.googlesource.com/c/go/+/484096
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>

2 years agolog/slog: require entire Attr to be empty to elide
Jonathan Amsterdam [Mon, 27 Mar 2023 13:27:43 +0000 (09:27 -0400)]
log/slog: require entire Attr to be empty to elide

Specify that Handlers should ignore zero-valued Attrs.

Implement that policy in the built-in handlers.

Fixes #59282.

Change-Id: I4430686b61f49bdac849ee300daaabfac9895849
Reviewed-on: https://go-review.googlesource.com/c/go/+/484095
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2 years agocmd/internal/sys, cmd/dist, misc/cgo/testcshared: enable c-shared feature and test...
limeidan [Thu, 25 Aug 2022 03:14:15 +0000 (11:14 +0800)]
cmd/internal/sys, cmd/dist, misc/cgo/testcshared: enable c-shared feature and test on loong64

Linux kernel on loong64 has no Dup2 syscall support, so we use Dup3 to replace it like arm64 and riscv64.

Updates #53301
Fixes #58784

Change-Id: I4e0be140a71b86f4626ed39d76cf3ac78f842018
Reviewed-on: https://go-review.googlesource.com/c/go/+/425478
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
2 years agoregexp: add Regexp.TextMarshaler/TextUnmarshaler
Jonathan Hall [Mon, 27 Mar 2023 11:23:36 +0000 (13:23 +0200)]
regexp: add Regexp.TextMarshaler/TextUnmarshaler

Fixes #46159

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

2 years agoembed: implement openFile.ReadAt
Nuno Cruces [Tue, 11 Apr 2023 23:25:07 +0000 (23:25 +0000)]
embed: implement openFile.ReadAt

Implementation copied from testing/fstest/mapfs.go

Fixes #57803

Change-Id: I531682b50ab6663511bac41fce7614ab9197bf38
GitHub-Last-Rev: d9bcc1c0bf4d339edcdabaf4d4d67b848ad8818d
GitHub-Pull-Request: golang/go#59489
Reviewed-on: https://go-review.googlesource.com/c/go/+/483235
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
2 years agolog/slog: don't call SetDefault in examples
Jonathan Amsterdam [Wed, 5 Apr 2023 10:13:17 +0000 (06:13 -0400)]
log/slog: don't call SetDefault in examples

Replace the default Logger in some examples with a locally constructed
Logger.

Calling SetDefault changes global state that could affect other tests.
Although we could use a defer to restore the state, that clutters
the example and would not work if tests were run concurrently.

Change-Id: Ib2595c57f8e6c3e0b39b982f682ba287c2ae249d
Reviewed-on: https://go-review.googlesource.com/c/go/+/482475
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2 years agocmd/compile: fix ir.StaticValue for ORANGE
Junwei Zuo [Wed, 12 Apr 2023 10:53:51 +0000 (18:53 +0800)]
cmd/compile: fix ir.StaticValue for ORANGE

Range statement will mutate the key and value, so we should treat them as reassigned.

Fixes #59572

Change-Id: I9c6b67d938760a0c6a1d9739f2737c67af4a3a10
Reviewed-on: https://go-review.googlesource.com/c/go/+/483855
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2 years agolog,log/slog: get correct source line when slog calls log
Jonathan Amsterdam [Tue, 4 Apr 2023 11:08:57 +0000 (07:08 -0400)]
log,log/slog: get correct source line when slog calls log

Before slog.SetDefault is called the first time, calls to slog's
default Logger invoke log's default Logger.

Originally, this was done by calling log.Output. This caused source
line information to be wrong sometimes, because log.Output requires a
call depth and the code invoking it could not know how many calls were
between it and the original logging call (slog.Info, etc.). The line
information would be right if the default handler was called directly,
but wrong if it was wrapped by another handler. The handler has the pc
of the logging call, but it couldn't give that pc to the log package.

This CL fixes the problem by adding a function in the log package
that uses the pc instead of a call depth, and making that function
available to slog.

The simplest way to add pc functionality to the log package is to add
a pc argument to Logger.output, which uses it only if it's not zero.

To make that function visible to slog without exporting it, we store
the function in a variable that lives in the new log/internal package.

Change-Id: I0bb6daebb4abc518a7ccc4e6d2f3c1093b1d0fe4
Reviewed-on: https://go-review.googlesource.com/c/go/+/482239
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Jonathan Amsterdam <jba@google.com>

2 years agolog/syslog: report hostname mismatch error details
Michael Pratt [Wed, 12 Apr 2023 15:56:14 +0000 (11:56 -0400)]
log/syslog: report hostname mismatch error details

The existing error log in check doesn't report the got/want hostname
even though that can be the cause of the error. Log those as well.

While we're here, also report os.Hostname() errors.

For #59568.

Change-Id: Ia277f85eddc541f2e78d719bc731db24e4513754
Reviewed-on: https://go-review.googlesource.com/c/go/+/483915
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agonet/http: avoid leaking writer goroutines in tests
Bryan C. Mills [Wed, 12 Apr 2023 13:58:54 +0000 (13:58 +0000)]
net/http: avoid leaking writer goroutines in tests

In TestTransportPrefersResponseOverWriteError and TestMaxBytesHandler,
the server may respond to an incoming request without ever reading the
request body. The client's Do method will return as soon as the
server's response headers are read, but the Transport will remain
active until it notices that the server has closed the connection,
which may be arbitrarily later.

When the server has closed the connection, it will call the Close
method on the request body (if it has such a method). So we can use
that method to find out when the Transport is close enough to done for
the test to complete without interfering too much with other tests.

For #57612.
For #59526.

Change-Id: Iddc7a3b7b09429113ad76ccc1c090ebc9e1835a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/483895
Run-TryBot: Bryan Mills <bcmills@google.com>
Commit-Queue: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agonet/http: only report the first leak of each test run
Bryan C. Mills [Wed, 12 Apr 2023 14:45:44 +0000 (14:45 +0000)]
net/http: only report the first leak of each test run

We don't have a way to terminate the leaked goroutines, and we can't
wait forever for them to exit (or else we would risk timing out the
test and losing the log line describing what exactly leaked).
So we have reason to believe that they will remain leaked while we run
the next test, and we don't want the goroutines from the first leak to
generate a spurious error when the second test completes.

This also removes a racy Parallel call I added in CL 476036, which was
flagged by the race detector in the duplicate-suppression check.
(I hadn't considered the potential interaction with the leak checker.)

For #59526.
Updates #56421.

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

2 years agocmd/dist: check for errors from filepath.Glob
wangjianwen [Tue, 11 Apr 2023 02:44:55 +0000 (02:44 +0000)]
cmd/dist: check for errors from filepath.Glob

Change-Id: Ib5bcd3d1e9618d65b4d4b0895d0e40dbd76646c6
GitHub-Last-Rev: 174084ca6c67ff99a4b3628d213b2de198f74dd0
GitHub-Pull-Request: golang/go#59516
Reviewed-on: https://go-review.googlesource.com/c/go/+/483435
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agosyscall: implement Fchdir on Windows
qmuntal [Wed, 29 Mar 2023 08:28:33 +0000 (10:28 +0200)]
syscall: implement Fchdir on Windows

This CL adds support for os.File.Chdir() on Windows by implementing
syscall.Fchdir, which is internally used by Chdir.

Windows does not provide a function that sets the working directory
using a file handle, so we have to fallback to retrieving the file
handle path and then use it in SetCurrentDirectory.

Change-Id: I2ae93575e50411e5a9426ea531541958d7c9e812
Reviewed-on: https://go-review.googlesource.com/c/go/+/480135
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agoall: update vendored golang.org/x/net
Tobias Klauser [Tue, 11 Apr 2023 22:28:06 +0000 (00:28 +0200)]
all: update vendored golang.org/x/net

Pull in CL 483375. This also updates golang.org/x/sys to v0.7.0 and thus
we also need to update it to that version in cmd to keep
TestDependencyVersionsConsistent happy.

Fixes #22927

Change-Id: Ice14cd66a5c2a621b373c3d29455c75494436045
Reviewed-on: https://go-review.googlesource.com/c/go/+/483595
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/dist: add -distpack flag to build distribution archives
Russ Cox [Thu, 19 Jan 2023 22:04:07 +0000 (17:04 -0500)]
cmd/dist: add -distpack flag to build distribution archives

We want to enable others to reproduce the exact distribution archives
we are serving on go.dev/dl. Today the code for building those
archives lives in golang.org/x/build, which is fundamentally tied to
running on the Go team build infrastructure and not easy for others to
run. This CL adds a new flag -distpack to cmd/dist, usually invoked as
make.bash -distpack, to build the distribution archives using code in
the main repository that anyone can run. Starting in Go 1.21,
the Go team build infrastructure will run this instead of its current
custom code to build those archives.

The current builds are not reproducible even given identical
infrastructure, because the archives are stamped with the current
time. It is helpful to have a timestamp in the archives indicating
when the code is from, but that time needs to be reproducible.
To ensure this, the new -distpack flag extends the VERSION file to
include a time stamp, which it uses as the modification time for all
files in the archive.

The new -distpack flag is implemented by a separate program,
cmd/distpack, instead of being in cmd/dist, so that it can be compiled
by the toolchain being distributed and not the bootstrap toolchain.
Otherwise details like the exact compression algorithms might vary
from one bootstrap toolchain to another and produce non-reproducible
builds. So there is a new 'go tool distpack', but it's omitted from
the distributions themselves, just as 'go tool dist' is.

make.bash already accepts any flags for cmd/dist, including -distpack.
make.bat is less sophisticated and looks for each known flag, so this
CL adds an update to look for -distpack. The CL also changes make.bat
to accept the idiomatic Go -flagname in addition to the non-idiomatic
(for Go) --flagname. Previously it insisted on the --flag form.

I have confirmed that using make.bash -distpack produces the
identical distribution archives for windows/amd64, linux/amd64,
darwin/amd64, and darwin/arm64 whether it is run on
windows/amd64, linux/amd64, or darwin/amd64 hosts.

For #24904.

Change-Id: Ie6d69365ee3d7294d05b4f96ffb9159b41918074
Reviewed-on: https://go-review.googlesource.com/c/go/+/470676
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Carlos Amedee <amedee@google.com>
2 years agosyscall: add a Go directive "go:nocheckptr" to forkAndExecInChild1
root [Sat, 1 Apr 2023 18:36:57 +0000 (18:36 +0000)]
syscall: add a Go directive "go:nocheckptr" to forkAndExecInChild1

forkAndExecInChild1 func must not acquire any locks in child, because
they might have been locked at the time of the fork. This implies to
no rescheduling, no malloc calls, and no new stack segments.

So, doing a "checkptrAlignment" is bad here, because checkptr
functions added by the instrumentation could grow the stack, which
should not be done between fork and exec calls.

Hence using a Go directive "go:nocheckptr" to forkAndExecInChild1
func,so that the compiler should not do "checkptrAlignment" when
functions marked with "go:norace".

This race detection bug was caught in go 1.21 on s390x.
Running a "./race.bash" script from "go/src" directory failed and the
bug details are provided in issue link mentioned below.

Fixes #58785

Change-Id: I254091368b0789d886acdf26f8aa8d8f5a986b24
Reviewed-on: https://go-review.googlesource.com/c/go/+/481415
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2 years agocmd/dist: mark wasip1/wasm as working
Johan Brandhorst-Satzkorn [Tue, 4 Apr 2023 19:25:27 +0000 (12:25 -0700)]
cmd/dist: mark wasip1/wasm as working

Now that all preceding CLs are merged, the port should
be working.

Change-Id: Ic45eaf42564ea286d0a429aa992c5ec0166945e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/482255
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>

2 years agoall: add wasip1 support
Johan Brandhorst-Satzkorn [Sun, 26 Mar 2023 00:01:38 +0000 (17:01 -0700)]
all: add wasip1 support

Fixes #58141

Co-authored-by: Richard Musiol <neelance@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Evan Phoenix <evan@phx.io>
Change-Id: I49b66946acc90fdf09ed9223096bfec9a1e5b923
Reviewed-on: https://go-review.googlesource.com/c/go/+/479627
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Ian Lance Taylor <iant@golang.org>

2 years agotime: add wasip1 support
Johan Brandhorst-Satzkorn [Sat, 8 Apr 2023 01:26:50 +0000 (18:26 -0700)]
time: add wasip1 support

Fixes #58141

Co-authored-by: Richard Musiol <neelance@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Evan Phoenix <evan@phx.io>
Change-Id: I51dabbf17b8f5540c964f90223d18457f6f9fbef
Reviewed-on: https://go-review.googlesource.com/c/go/+/483236
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agonet: add wasip1 support
Johan Brandhorst-Satzkorn [Sat, 25 Mar 2023 23:57:07 +0000 (16:57 -0700)]
net: add wasip1 support

For #58141

Co-authored-by: Richard Musiol <neelance@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Evan Phoenix <evan@phx.io>
Change-Id: I09a7cf33e43cb0e17ab3793c22cbad90b9e83b62
Reviewed-on: https://go-review.googlesource.com/c/go/+/479626
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agonet/http, net/internal, net/smtp: add wasip1
Johan Brandhorst-Satzkorn [Sat, 25 Mar 2023 23:38:37 +0000 (16:38 -0700)]
net/http, net/internal, net/smtp: add wasip1

For #58141

Co-authored-by: Richard Musiol <neelance@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Evan Phoenix <evan@phx.io>
Change-Id: Ib49b7ccabe18de544455f7d09c7d715d6564a73d
Reviewed-on: https://go-review.googlesource.com/c/go/+/479625
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocrypto: add wasip1 support
Johan Brandhorst-Satzkorn [Sat, 25 Mar 2023 17:35:11 +0000 (10:35 -0700)]
crypto: add wasip1 support

Adds crypto/dsa, crypto/rand, x509 files and changes for the new
wasip1 port.

For #58141

Co-authored-by: Richard Musiol <neelance@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Evan Phoenix <evan@phx.io>
Change-Id: I9609e3d021cd7e06b813eedf5912febc52cc0f2c
Reviewed-on: https://go-review.googlesource.com/c/go/+/479624
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agocrypto/internal/nistec: update generator for re-enabled s390x asm
Ian Lance Taylor [Tue, 11 Apr 2023 18:54:46 +0000 (11:54 -0700)]
crypto/internal/nistec: update generator for re-enabled s390x asm

CL 404058 modified the generated file p256.go without modifying
the generator program. This CL updates the generator program so
that it generates the p256.go file currently in the tree.

For #52709

Change-Id: I86927a8bb84b2e17426b7ba74a86f1aba781628e
Reviewed-on: https://go-review.googlesource.com/c/go/+/483715
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agotime: update windows zoneinfo_abbrs
Ian Lance Taylor [Tue, 11 Apr 2023 18:57:47 +0000 (11:57 -0700)]
time: update windows zoneinfo_abbrs

While running "go generate" I noticed that there has been a change.

For #58113

Change-Id: Icca349d0a100dd4b11d34e4bbcfd1aef57346db7
Reviewed-on: https://go-review.googlesource.com/c/go/+/483716
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agoall: re-run stringer
Ian Lance Taylor [Tue, 11 Apr 2023 19:01:43 +0000 (12:01 -0700)]
all: re-run stringer

Re-run all go:generate stringer commands. This mostly adds checks
that the constant values did not change, but does add new strings
for the debug/dwarf and internal/pkgbits packages.

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

2 years agogo/ast: add File.GoVersion
Russ Cox [Mon, 13 Mar 2023 21:12:40 +0000 (17:12 -0400)]
go/ast: add File.GoVersion

For #57001, compilers and others tools will need to understand that
a different Go version can be used in different files in a program,
according to the //go:build lines in those files.

This CL adds a GoVersion string field to ast.File, to allow exposing this
per-file Go version information.

For #59033.

Change-Id: I3931ea86c237983d152964f48dce498bcb1f06aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/476276
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>

2 years agogo/build/constraint: add GoVersion
Russ Cox [Mon, 13 Mar 2023 21:23:13 +0000 (17:23 -0400)]
go/build/constraint: add GoVersion

For #57001, programs need to be able to deduce the Go version
implied by a given build constraint. GoVersion determines that,
by discarding all build tags other than Go versions and computing
the minimum Go version implied by the resulting expression.

For #59033.

Change-Id: Ifb1e7af2bdbdf172f82aa490c826c9b6ca5e824b
Reviewed-on: https://go-review.googlesource.com/c/go/+/476275
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/go: rewrite collectDeps to only depend on imports' deps
Michael Matloob [Mon, 10 Apr 2023 20:13:14 +0000 (16:13 -0400)]
cmd/go: rewrite collectDeps to only depend on imports' deps

Change-Id: I0cac9f32855e49e9899709a2f4421083aa0e75cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/483515
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 years agoruntime: filter i/o async entries using completion key on windows
Will Hawkins [Wed, 5 Apr 2023 07:15:56 +0000 (03:15 -0400)]
runtime: filter i/o async entries using completion key on windows

In the case where a user program requests overlapped I/O directly on a
handlethat is managed by the runtime, it is possible that
runtime.netpoll will attempt to dereference a pointer with an invalid
value. This CL prevents the runtime from accessing the invalid pointer
value by adding a special key to each overlapped I/O operation that it
creates.

Fixes #58870

Co-authored-by: quimmuntal@gmail.com
Change-Id: Ib58ee757bb5555efba24c29101fc6d1a0dedd61a
Reviewed-on: https://go-review.googlesource.com/c/go/+/482495
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/asm,cmd/internal/obj/x86: add RDPID instruction to x86 assembler
Joel Sing [Thu, 6 Apr 2023 20:15:59 +0000 (06:15 +1000)]
cmd/asm,cmd/internal/obj/x86: add RDPID instruction to x86 assembler

Add support for the Read Processor ID (RDPID) instruction to the x86
assembler. This returns the current logical processor's ID in the
specified register, as a faster alternative to RDTSCP.

Fixes #56525

Change-Id: I43482e42431dfc385ce2e7f6d44b9746b0cc4548
Reviewed-on: https://go-review.googlesource.com/c/go/+/482955
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2 years agonet: allow TestDialListenerAddr without an external network
Bryan C. Mills [Tue, 11 Apr 2023 16:26:53 +0000 (16:26 +0000)]
net: allow TestDialListenerAddr without an external network

As of CL 482163, this test now works when only a loopback network is
available.

Updates #59497.

Change-Id: I32be4b74bbc663eb109763ea19d79f22c63f50ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/483696
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

2 years agodoc: add missing oxford comma in Constants
Daniel Frederick Crisman [Mon, 10 Apr 2023 23:14:56 +0000 (23:14 +0000)]
doc: add missing oxford comma in Constants

In the language specification under "Constants" the lists matching default
types to untyped contstant types is missing an Oxford comma in the first
list. I found a number of other places in the spec and #23442 that use the
Oxford comma to support its use.

Add missing Oxford comma in Constants default type list.

Change-Id: I4562d692610334bc82452db076145d2414617a04
GitHub-Last-Rev: 8acdb60d6e255f73fdeb908d2540d4ee35db3fd7
GitHub-Pull-Request: golang/go#59528
Reviewed-on: https://go-review.googlesource.com/c/go/+/483555
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agocmd/go/internal/cache: return and check errors from Trim
Bryan C. Mills [Thu, 6 Apr 2023 12:31:57 +0000 (12:31 +0000)]
cmd/go/internal/cache: return and check errors from Trim

It's fine to ignore errors when reading trim.txt, since it might not
exist or might be corrupted. However, if we encounter an error in
writing the file, we will end up trimming again at every cmd/go
invocation, which will cause invocations to become progressively
slower (because each command will check more and more cache files for
trimming).

Although that situation would not cause the output of any 'go' command
to be invalid, it still seems better to escalate the problem to the
user to be fixed instead of proceeding in a degraded state.

Returning an explicit error also allows TestCacheTrim to skip if the
Trim error indicates that a required operation (in this case, file
locking) is not supported by the platform or filesystem.

For #58141.
Updates #35220.
Updates #26794.

Change-Id: Iedb94bff4544fd9914f5ac779a783a116372c80f
Reviewed-on: https://go-review.googlesource.com/c/go/+/482795
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

2 years agocmd/internal/obj/loong64, cmd/internal/objabi, cmd/link: add support for --buildmode...
limeidan [Thu, 25 Aug 2022 03:13:10 +0000 (11:13 +0800)]
cmd/internal/obj/loong64, cmd/internal/objabi, cmd/link: add support for --buildmode=c-shared on loong64

Updates #53301
Updates #58784

Change-Id: Ifcb40871f609531dfd8b568db9ac14da9b451742
Reviewed-on: https://go-review.googlesource.com/c/go/+/425476
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: WANG Xuerui <git@xen0n.name>
2 years agoRevert "go/printer: reuse go/token.FileSet.PositionFor calls in setPos"
Than McIntosh [Tue, 11 Apr 2023 14:15:36 +0000 (14:15 +0000)]
Revert "go/printer: reuse go/token.FileSet.PositionFor calls in setPos"

This reverts commit http://go.dev/cl/461739

Reason for revert: Causes longtest failures due to odd formatting.

Change-Id: I7e31ff107e730b6d667866ea7718bc8632760422
Reviewed-on: https://go-review.googlesource.com/c/go/+/483676
Reviewed-by: Russ Cox <rsc@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime,cmd/internal/obj/ppc64: cleanup ppc64le runtime.racecallbackthunk
Paul E. Murphy [Mon, 13 Mar 2023 22:02:15 +0000 (17:02 -0500)]
runtime,cmd/internal/obj/ppc64: cleanup ppc64le runtime.racecallbackthunk

Update to use the common macros to ensure all ELFv2 callee-save registers
are saved properly when transitioning from ELFv2 to Go calling/stack
conventions. Simplify the inlined Go function call, and remove the asm
hacks which inhibited implicit stack frame management.

Change-Id: Iee118a4069962a791436c6fe19370e1929404a8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/479795
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoos: adjust wait6/waitid comment for netbsd
Tobias Klauser [Sun, 9 Apr 2023 11:39:12 +0000 (13:39 +0200)]
os: adjust wait6/waitid comment for netbsd

CL 431855 changed (*Process).blockUntilWaitable on netbsd to use wait6
again.

Update #48789

Change-Id: I948f5445a44ab2e82c02560480a2a244d2b5f473
Reviewed-on: https://go-review.googlesource.com/c/go/+/483396
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agodebug/elf: avoid decompress of section twice
Meng Zhuo [Sun, 2 Apr 2023 12:01:28 +0000 (20:01 +0800)]
debug/elf: avoid decompress of section twice

In rare cases, elf will get a corrupted section starts with 0x1,
which happens to be COMPRESS_ZLIB that causing decompress twice.
This CL drops sectionData decompress data after open section.

Fixes #59208

Change-Id: I7999a55868b3b3481509e1ac35985f7580f0f688
Reviewed-on: https://go-review.googlesource.com/c/go/+/480895
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: M Zhuo <mzh@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/internal/obj/loong64: auto-align loop heads to 16-byte boundaries
WANG Xuerui [Tue, 28 Mar 2023 13:10:16 +0000 (21:10 +0800)]
cmd/internal/obj/loong64: auto-align loop heads to 16-byte boundaries

CL 479816 took care of loops in hand-written assembly, but did not
account for those written in Go, that may become performance-sensitive
as well.

In this patch, all loop heads are automatically identified and aligned
to 16-byte boundaries, by inserting a synthetic `PCALIGN $16` before
them. "Loop heads" are defined as targets of backward branches.

While at it, tweak some of the local comments so the flow is hopefully
clearer.

Because LoongArch instructions are all 32 bits long, at most 3 NOOPs
can be inserted for each target Prog. This may sound excessive, but
benchmark results indicate the current approach is overall profitable
anyway.

Benchmark results on Loongson 3A5000 (LA464):

goos: linux
goarch: loong64
pkg: test/bench/go1
                      │  CL 479816  │              this CL               │
                      │   sec/op    │   sec/op     vs base               │
BinaryTree17             14.10 ± 1%    14.06 ± 1%       ~ (p=0.280 n=10)
Fannkuch11               3.579 ± 0%    3.419 ± 0%  -4.45% (p=0.000 n=10)
FmtFprintfEmpty         94.73n ± 0%   94.44n ± 0%  -0.31% (p=0.000 n=10)
FmtFprintfString        151.9n ± 0%   149.1n ± 0%  -1.84% (p=0.000 n=10)
FmtFprintfInt           158.3n ± 0%   155.2n ± 0%  -1.96% (p=0.000 n=10)
FmtFprintfIntInt        241.4n ± 0%   235.4n ± 0%  -2.49% (p=0.000 n=10)
FmtFprintfPrefixedInt   320.2n ± 0%   314.7n ± 0%  -1.73% (p=0.000 n=10)
FmtFprintfFloat         414.3n ± 0%   398.7n ± 0%  -3.77% (p=0.000 n=10)
FmtManyArgs             949.9n ± 0%   929.8n ± 0%  -2.12% (p=0.000 n=10)
GobDecode               15.24m ± 0%   15.30m ± 0%  +0.38% (p=0.035 n=10)
GobEncode               18.10m ± 2%   17.59m ± 1%  -2.81% (p=0.002 n=10)
Gzip                    429.9m ± 0%   421.5m ± 0%  -1.97% (p=0.000 n=10)
Gunzip                  88.31m ± 0%   87.39m ± 0%  -1.04% (p=0.000 n=10)
HTTPClientServer        85.71µ ± 0%   87.24µ ± 0%  +1.79% (p=0.000 n=10)
JSONEncode              19.74m ± 0%   18.55m ± 0%  -6.00% (p=0.000 n=10)
JSONDecode              78.60m ± 1%   77.93m ± 0%  -0.84% (p=0.000 n=10)
Mandelbrot200           7.208m ± 0%   7.217m ± 0%       ~ (p=0.481 n=10)
GoParse                 7.616m ± 1%   7.630m ± 2%       ~ (p=0.796 n=10)
RegexpMatchEasy0_32     133.0n ± 0%   134.1n ± 0%  +0.83% (p=0.000 n=10)
RegexpMatchEasy0_1K     1.362µ ± 0%   1.364µ ± 0%  +0.15% (p=0.000 n=10)
RegexpMatchEasy1_32     161.8n ± 0%   163.7n ± 0%  +1.17% (p=0.000 n=10)
RegexpMatchEasy1_1K     1.497µ ± 0%   1.497µ ± 0%       ~ (p=1.000 n=10)
RegexpMatchMedium_32    1.420µ ± 0%   1.446µ ± 0%  +1.83% (p=0.000 n=10)
RegexpMatchMedium_1K    42.25µ ± 0%   42.53µ ± 0%  +0.65% (p=0.000 n=10)
RegexpMatchHard_32      2.108µ ± 0%   2.116µ ± 0%  +0.38% (p=0.000 n=10)
RegexpMatchHard_1K      62.65µ ± 0%   63.23µ ± 0%  +0.93% (p=0.000 n=10)
Revcomp                  1.192 ± 0%    1.198 ± 0%  +0.55% (p=0.000 n=10)
Template                115.6m ± 2%   116.9m ± 1%       ~ (p=0.075 n=10)
TimeParse               418.1n ± 1%   414.7n ± 0%  -0.81% (p=0.000 n=10)
TimeFormat              517.9n ± 0%   513.7n ± 0%  -0.81% (p=0.000 n=10)
geomean                 103.5µ        102.6µ       -0.79%

                     │  CL 479816   │               this CL               │
                     │     B/s      │     B/s       vs base               │
GobDecode              48.04Mi ± 0%   47.86Mi ± 0%  -0.38% (p=0.035 n=10)
GobEncode              40.44Mi ± 2%   41.61Mi ± 1%  +2.89% (p=0.001 n=10)
Gzip                   43.04Mi ± 0%   43.91Mi ± 0%  +2.02% (p=0.000 n=10)
Gunzip                 209.6Mi ± 0%   211.8Mi ± 0%  +1.05% (p=0.000 n=10)
JSONEncode             93.76Mi ± 0%   99.75Mi ± 0%  +6.39% (p=0.000 n=10)
JSONDecode             23.55Mi ± 1%   23.75Mi ± 0%  +0.85% (p=0.000 n=10)
GoParse                7.253Mi ± 1%   7.238Mi ± 2%       ~ (p=0.698 n=10)
RegexpMatchEasy0_32    229.4Mi ± 0%   227.6Mi ± 0%  -0.82% (p=0.000 n=10)
RegexpMatchEasy0_1K    717.3Mi ± 0%   716.2Mi ± 0%  -0.15% (p=0.000 n=10)
RegexpMatchEasy1_32    188.6Mi ± 0%   186.4Mi ± 0%  -1.13% (p=0.000 n=10)
RegexpMatchEasy1_1K    652.2Mi ± 0%   652.3Mi ± 0%  +0.01% (p=0.005 n=10)
RegexpMatchMedium_32   21.49Mi ± 0%   21.11Mi ± 0%  -1.73% (p=0.000 n=10)
RegexpMatchMedium_1K   23.11Mi ± 0%   22.96Mi ± 0%  -0.62% (p=0.000 n=10)
RegexpMatchHard_32     14.48Mi ± 0%   14.42Mi ± 0%  -0.40% (p=0.000 n=10)
RegexpMatchHard_1K     15.59Mi ± 0%   15.44Mi ± 0%  -0.98% (p=0.000 n=10)
Revcomp                203.4Mi ± 0%   202.3Mi ± 0%  -0.55% (p=0.000 n=10)
Template               16.00Mi ± 2%   15.83Mi ± 1%       ~ (p=0.078 n=10)
geomean                60.72Mi        60.89Mi       +0.29%

The slight regression on the Regexp cases is likely because the previous
numbers are just coincidental: indeed, large regressions or improvements
(of roughly ±10%) happen with definitely irrelevant changes during
development. This CL should (hopefully) bring such random performance
fluctuations down a bit.

Change-Id: I8bdda6e65336da00d4ad79650937b3eeb9db0e7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/479817
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: WANG Xuerui <git@xen0n.name>

2 years agogo/printer: reuse go/token.FileSet.PositionFor calls in setPos
Daniel Martí [Thu, 12 Jan 2023 18:29:28 +0000 (18:29 +0000)]
go/printer: reuse go/token.FileSet.PositionFor calls in setPos

setPos is called for most nodes, and in a number of cases,
the position is already the same.
PositionFor is a relatively expensive call,
as it needs to "unpack" a token.Pos into a token.Position.

If we can tell that the position is the same in a cheap way,
we can then avoid calling setPos and PositionFor.
Luckily, we can get the position's offset within the file,
and it doesn't involve the relatively expensive unpacking.

name          old time/op    new time/op    delta
PrintFile-16    4.79ms ± 1%    4.36ms ± 1%  -8.88%  (p=0.008 n=5+5)

name          old speed      new speed      delta
PrintFile-16  10.8MB/s ± 1%  11.9MB/s ± 1%  +9.73%  (p=0.008 n=5+5)

name          old alloc/op   new alloc/op   delta
PrintFile-16     106kB ± 1%     106kB ± 1%    ~     (p=0.167 n=5+5)

name          old allocs/op  new allocs/op  delta
PrintFile-16     2.42k ± 0%     2.42k ± 0%    ~     (all equal)

This does assume that the positions of a node being printed are all
within a file, as go/token.Position.Offset is relative to each file.
This seems like a perfectly fine assumption to make right now,
as the largest node which can be printed is an *ast.File.

Change-Id: I2ae55f507ba8ba9f280898c9c8e01c994d9b2a26
Reviewed-on: https://go-review.googlesource.com/c/go/+/461739
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2 years agocmd/compile: split DIVV/DIVVU op on loong64
Wayne Zuo [Thu, 2 Mar 2023 07:55:03 +0000 (15:55 +0800)]
cmd/compile: split DIVV/DIVVU op on loong64

Previously, we need calculate both quotient and remainder together.
However, in most cases, only one result is needed. By separating these
instructions, we can save one instruction in most cases.

Change-Id: I0a2d4167cda68ab606783ba1aa2720ede19d6b53
Reviewed-on: https://go-review.googlesource.com/c/go/+/475315
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2 years agodoc: fix "are" to "or" in core types
cui fliter [Sun, 9 Apr 2023 14:51:47 +0000 (22:51 +0800)]
doc: fix "are" to "or" in core types

Fixes #59506

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

2 years agocmd/internal/obj/arm64: improve comment and signature of pcAlignPadLength
WANG Xuerui [Fri, 7 Apr 2023 18:06:18 +0000 (02:06 +0800)]
cmd/internal/obj/arm64: improve comment and signature of pcAlignPadLength

The function just calculates the number of needed padding bytes,
instead of actually carrying out the alignment operation. And it has
the context argument at the end of the argument list, while contexts
idiomatically come first. Indeed, this is the only case in
cmd/internal/obj where ctxt is not the only argument and does not come
first.

Fix those two nits; no functional change intended.

Suggested by Ian during review of CL 479815 (that introduces a copy of
this helper into the loong64 port).

Change-Id: Ieb221ead23282abe6e04804d537e1234c7ab21d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/483155
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agonet: avoid opening an external port in TestDialListenerAddr
Bryan C. Mills [Mon, 10 Apr 2023 13:59:12 +0000 (13:59 +0000)]
net: avoid opening an external port in TestDialListenerAddr

The behavior in #18806 can be tested with a localhost-only port,
provided that we're willing to assume what format the listener would
report for an external dual-stack port.

Fixes #59497.

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

2 years agocmd/doc: format field doc comments when printing entire struct
Ian Lance Taylor [Fri, 7 Apr 2023 02:36:01 +0000 (19:36 -0700)]
cmd/doc: format field doc comments when printing entire struct

cmd/doc passes structs to go/format, but that means that comments
on fields within those structs don't look like what cmd/doc prints
when asked for a struct field directly. Tweak the field comments
so that they look the same either way.

Fixes #56592

Change-Id: I198cb7a58e3d8558406c386072c630332f91c6b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/483055
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>

2 years agocmd/go: localize computation of deps/depserrors in list
Michael Matloob [Sat, 8 Apr 2023 01:13:30 +0000 (21:13 -0400)]
cmd/go: localize computation of deps/depserrors in list

Stop depending on DepsErrors to report errors to the user and instead
only use it and compute it in list. Instead, use Incomplete to figure
out when a package or its depencies have an error, and only if they
do, do the work of finding all those errors.

For #59157

Change-Id: Ied927f53e7b1f66fad9248b40dd11ed960b3ef91
Reviewed-on: https://go-review.googlesource.com/c/go/+/483495
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Matloob <matloob@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2 years agomisc/cgo: remove +build lines, add go:build where needed
Ian Lance Taylor [Tue, 4 Apr 2023 21:20:26 +0000 (14:20 -0700)]
misc/cgo: remove +build lines, add go:build where needed

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

2 years agomisc/cgo: gofmt
Ian Lance Taylor [Tue, 4 Apr 2023 20:59:06 +0000 (13:59 -0700)]
misc/cgo: gofmt

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

2 years agocmd/compile: don't inline hot calls into big functions
Michael Pratt [Tue, 28 Mar 2023 16:45:17 +0000 (12:45 -0400)]
cmd/compile: don't inline hot calls into big functions

Standard inlining has a reduced maximum cost of callees (20 instead of
80) when inlining into a "big" function, to limit how much bigger we
will make an already big function.

When adding PGO hot call budget increases, we inadvertently bypassed
this "big" function restriction, allowing hot calls of up to
inlineHotMaxBudget, even into big functions.

Add the restriction back, even for hot calls. If a function is already
very large, we probably shouldn't inline even more.

A very important note here is that function "big"-ness is computed prior
to any inlining. One potential problem with PGO is that many hot calls
inline into an initially-small function and ultimately make it very
large. This CL does nothing to address that case, which would require
recomputing size after inlining.

This CL has no impact on sweet PGO benchmarks. I specifically dug into
tile38, which contained 0 hot big functions. Other benchmarks are
probably similar.

Change-Id: I3b6304eaf7738a219359d4b8bb121d68babfea8b
Reviewed-on: https://go-review.googlesource.com/c/go/+/482157
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>

2 years agocmd/go: return and handle errors from loadImport for bad imports
Michael Matloob [Mon, 3 Apr 2023 20:07:41 +0000 (16:07 -0400)]
cmd/go: return and handle errors from loadImport for bad imports

And assign the error to the importing package. Before this change, for
some errors for bad imports, such as importing a vendored package with
the wrong path, we would make a dummy package for the imported package
with the error on it. Instead report the error on the importing
package where it belongs. Do so by returning an error from loadImport
and handling it on the importing package.

For #59157

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

2 years agoreflect: remove typedmemmovepartial as it is unused
Daniel Martí [Fri, 7 Apr 2023 17:41:10 +0000 (18:41 +0100)]
reflect: remove typedmemmovepartial as it is unused

It appears to have been unused since https://go.dev/cl/298670
in April 2021, as that change removed its only use.
It is always in the git history if it is needed again.

Change-Id: Ie55d059c102dfaa75bd253e09d48a4b30f45e941
Reviewed-on: https://go-review.googlesource.com/c/go/+/483136
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

2 years agoruntime: support GOTRACEBACK=wer on Windows
qmuntal [Thu, 9 Mar 2023 13:55:31 +0000 (14:55 +0100)]
runtime: support GOTRACEBACK=wer on Windows

GOTRACEBACK=wer is a new traceback level that acts as "crash" and
also enables WER. The same effect can be achieved using
debug.SetTraceback("wer").

The Go runtime currently crashes using exit(2), which bypasses WER
even if it is enabled. To best way to trigger WER is calling
RaiseFailFastException [1] instead, which internally launches the
WER machinery.

This CL also changes how GOTRACEBACK=crash crashes, so both "wer" and
"crash" crash using RaiseFailFastException, which simplifies the
implementation and resolves a longstanding TODO.

Fixes #57441
Fixes #20498

[1] https://learn.microsoft.com/en-us/windows/win32/api/errhandlingapi/nf-errhandlingapi-raisefailfastexception

Change-Id: I45669d619fbbd2f6413ce5e5f08425ed1d9aeb64
Reviewed-on: https://go-review.googlesource.com/c/go/+/474915
Reviewed-by: Davis Goodin <dagood@microsoft.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>

2 years agonet: re-enable unixpacket tests on netbsd/386
Tobias Klauser [Sun, 9 Apr 2023 08:31:41 +0000 (10:31 +0200)]
net: re-enable unixpacket tests on netbsd/386

The tests seem to work fine on netbsd/386 (NetBSD 9.3). This reverts CL
80756.

Updates #22927

Change-Id: I2235d69129aa81b43513a171834d058f47cd9933
Reviewed-on: https://go-review.googlesource.com/c/go/+/483395
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

2 years agocmd/compile: teach prove about bitwise OR operation
Cuong Manh Le [Mon, 10 Apr 2023 04:08:25 +0000 (11:08 +0700)]
cmd/compile: teach prove about bitwise OR operation

For now, only apply the rule if either of arguments are constants. That
would catch a lot of real user code, without slowing down the compiler
with code generated for string comparison (experience in CL 410336).

Updates #57959
Fixes #45928

Change-Id: Ie2e830d6d0d71cda3947818b22c2775bd94f7971
Reviewed-on: https://go-review.googlesource.com/c/go/+/483359
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2 years agocmd/compile: replace isSigned(t) with t.IsSigned()
Keith Randall [Sun, 9 Apr 2023 15:36:12 +0000 (08:36 -0700)]
cmd/compile: replace isSigned(t) with t.IsSigned()

No change in semantics, just removing an unneeded helper.

Also align rules a bit.

Change-Id: Ie4dabb99392315a7700c645b3d0931eb8766a5fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/483439
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2 years agocmd/compile: clean up store rules to use store type, not argument type
Keith Randall [Sun, 9 Apr 2023 15:11:06 +0000 (08:11 -0700)]
cmd/compile: clean up store rules to use store type, not argument type

Argument type is dangerous because it may be thinner than the actual
store being issued.

Change-Id: Id19fbd8e6c41390a453994f897dd5048473136aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/483438
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
2 years agocrypto/x509: skip broken darwin root tests
Michael Pratt [Mon, 10 Apr 2023 15:25:06 +0000 (11:25 -0400)]
crypto/x509: skip broken darwin root tests

For #57428.
For #35678.

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

2 years agoruntime: add support for --buildmode=c-shared on loong64
limeidan [Thu, 25 Aug 2022 03:07:25 +0000 (11:07 +0800)]
runtime: add support for --buildmode=c-shared on loong64

These c-shared related CLs are follow up of CLs 455016, 455017, 455018. Here we
follow the LoongArch ELF psABI v2 standard, which requires the support of the
PCALAU12I instruction.

Updates #53301
Updates #58784

Change-Id: I7f1ddbf3b2470d610f12069d147aa9b3a6a96f32
Reviewed-on: https://go-review.googlesource.com/c/go/+/425474
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/internal/obj/loong64, cmd/link/internal: switch to LoongArch ELF psABI v2 relocs
WANG Xuerui [Sat, 3 Dec 2022 13:16:49 +0000 (21:16 +0800)]
cmd/internal/obj/loong64, cmd/link/internal: switch to LoongArch ELF psABI v2 relocs

The LoongArch ELF psABI v2 [1] relocs are vastly simplified from the v1
which involved a stack machine for computing the reloc values, but the
details of PC-relative addressing are changed as well. Specifically, the
`pcaddu12i` instruction is substituted with the `pcalau12i`, which is
like arm64's `adrp` -- meaning the lower bits of a symbol's address now
have to be absolute and not PC-relative.

However, apart from the little bit of added complexity, the obvious
advantage is that only 1 reloc needs to be emitted for every kind of
external reloc we care about. This can mean substantial space savings
(each RELA reloc occupies 24 bytes), and no open-coded stack ops has to
remain any more.

While at it, update the preset value for the output ELF's flags to
indicate the psABI update.

Fixes #58784

[1]: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html

Change-Id: I5c13bc710eaf58293a32e930dd33feff2ef14c28
Reviewed-on: https://go-review.googlesource.com/c/go/+/455017
Run-TryBot: Ben Shi <powerman1st@163.com>
Reviewed-by: xiaodong liu <teaofmoli@gmail.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/compile, cmd/dist, internal: enable buildmode=pie for linux/loong64
WANG Xuerui [Sun, 4 Dec 2022 07:06:45 +0000 (15:06 +0800)]
cmd/compile, cmd/dist, internal: enable buildmode=pie for linux/loong64

This is actually not tied to the ELF psABI v2 upgrade, and can be
enabled "for free".

Change-Id: I6906d9eb4bd8655c685b059283e200cb7e210369
Reviewed-on: https://go-review.googlesource.com/c/go/+/455075
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Run-TryBot: Ben Shi <powerman1st@163.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Run-TryBot: WANG Xuerui <git@xen0n.name>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
2 years agocmd/compile/internal/amd64: improve fix up code for signed division
Joel Sing [Wed, 5 Apr 2023 20:11:14 +0000 (06:11 +1000)]
cmd/compile/internal/amd64: improve fix up code for signed division

In order to avoid a CPU exception resulting from signed overflow, the signed
division code tests if the divisor is -1 and if it is, runs fix up code to
manually compute the quotient and remainder (thus avoiding IDIV and potential
signed overflow).

However, the way that this is currently structured means that the normal code
path for the case where the divisor is not -1 results in five instructions
and two branches (CMP, JEQ, followed by sign extension, IDIV and another JMP
to skip over the fix up code).

Rework the fix up code such that the final JMP is incurred by the less likely
divisor is -1 code path, rather than more likely code path (which is already
more expensive due to IDIV). This result in a four instruction sequence
(CMP, JNE, sign extension, IDIV), with only a single branch.

Updates #59089

Change-Id: Ie8d065750a178518d7397e194920b201afeb0530
Reviewed-on: https://go-review.googlesource.com/c/go/+/482658
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agocmd/compile/internal/amd64: simplify code generation for signed division
Joel Sing [Wed, 5 Apr 2023 20:11:10 +0000 (06:11 +1000)]
cmd/compile/internal/amd64: simplify code generation for signed division

The same switch statement handles code generation for signed division of
words, double words and quad words. Rather than using multiple switch
statements to select the appropriate instructions, determine all of the
correctly sized operands up front, then use them as needed.

Updates #59089

Change-Id: I2b7567c8e0ecb9904c37607332538c95b0521dca
Reviewed-on: https://go-review.googlesource.com/c/go/+/482657
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: mark map bucket slots as empty during map clear
Cuong Manh Le [Tue, 4 Apr 2023 05:49:39 +0000 (12:49 +0700)]
runtime: mark map bucket slots as empty during map clear

So iterators that are in progress can know entries have been deleted and
terminate the iterator properly.

Update #55002
Update #56351
Fixes #59411

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

2 years agoos: add wasip1 support
Johan Brandhorst-Satzkorn [Sat, 25 Mar 2023 17:18:26 +0000 (10:18 -0700)]
os: add wasip1 support

For #58141

Co-authored-by: Richard Musiol <neelance@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Evan Phoenix <evan@phx.io>
Change-Id: I52e3e161f81dcbe8605570e47d732992979c4d34
Reviewed-on: https://go-review.googlesource.com/c/go/+/479623
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

2 years agointernal: add wasip1 support
Johan Brandhorst-Satzkorn [Sat, 25 Mar 2023 16:03:15 +0000 (09:03 -0700)]
internal: add wasip1 support

For #58141

Co-authored-by: Richard Musiol <neelance@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Evan Phoenix <evan@phx.io>
Change-Id: I1488726e5b43cd21c5f83900476afd2fb63d70c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/479622
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

2 years agoslices: add DeleteFunc
Ian Lance Taylor [Fri, 7 Apr 2023 21:03:55 +0000 (14:03 -0700)]
slices: add DeleteFunc

Fixes #54768

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

2 years agocmd/compile: use correct type for byteswaps on multi-byte stores
Keith Randall [Sat, 1 Apr 2023 17:33:26 +0000 (10:33 -0700)]
cmd/compile: use correct type for byteswaps on multi-byte stores

Use the type of the store for the byteswap, not the type of the
store's value argument.

Normally when we're storing a 16-bit value, the value being stored is
also typed as 16 bits. But sometimes it is typed as something smaller,
usually because it is the result of an upcast from a smaller value,
and that upcast needs no instructions.

If the type of the store's arg is thinner than the type being stored,
and the byteswap'd value uses that thinner type, and the byteswap'd
value needs to be spilled & restored, that spill/restore happens using
the thinner type, which causes us to lose some of the top bits of the
value.

Fixes #59367

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

2 years agocmd/compile: minor cleanup to HashDebugPos
David Chase [Thu, 6 Apr 2023 14:09:51 +0000 (10:09 -0400)]
cmd/compile: minor cleanup to HashDebugPos

HashDebugPos function/method included a parameter that was always
the same, and a variable in the same package as the hashdebug code.
So remove it.

(I wrote that code, there was no reason for it to be that way).

Also corrects a stale comment in the loopvar code.

Change-Id: Id3da69cfe6dadeb31d5de62fb76d15103a5d6152
Reviewed-on: https://go-review.googlesource.com/c/go/+/482816
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2 years agocmd/internal/objfile: align the load address of ELF binary
Cherry Mui [Fri, 7 Apr 2023 00:26:55 +0000 (20:26 -0400)]
cmd/internal/objfile: align the load address of ELF binary

The ELF ABI just requires that the address and the offset of a
segment are congruent modulo the alignment, but does not require
the start address to be aligned. While usually the segment's
start address is aligned, apparently the zig linker generates
binary with unaligned address.

At the run time, the memory mapping that contains the segment
starts at an aligned address (rounding down). Use the aligned
address for the load address, which matches the mapping.
Apparently this is what the pprof library expects.

Fixes #59466.

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

2 years agocmd/link: bump loong64 function alignment to 16 bytes
WANG Xuerui [Tue, 4 Apr 2023 08:35:06 +0000 (16:35 +0800)]
cmd/link: bump loong64 function alignment to 16 bytes

The loong64 PCALIGN directive works with PCs relative to beginning of
functions. So if the function alignment is less than that requested by
PCALIGN, the following code may in fact not be aligned as such, leading
to unexpected performance.

The current function alignment on loong64 is 8 bytes, which seems to
stem from mips64 or riscv64. In order to make performance more
predictable on loong64, it is raised to 16 bytes to ensure that at
least `PCALIGN $16` works.

As alignment of loops written in Go is yet to be tackled, and the
codegen is not otherwise touched, benchmark numbers for this change are
not going to be meaningful, and not included.

Change-Id: I2120ef3746ce067e274920c82091810073bfa3be
Reviewed-on: https://go-review.googlesource.com/c/go/+/481936
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2 years agointernal/bytealg, runtime: align some loong64 asm loops to 16-byte boundaries
WANG Xuerui [Tue, 28 Mar 2023 11:58:17 +0000 (19:58 +0800)]
internal/bytealg, runtime: align some loong64 asm loops to 16-byte boundaries

The LA464 micro-architecture is very sensitive to alignment of loops,
so the final performance of linked binaries can vary wildly due to
uncontrolled alignment of certain performance-critical loops. Now that
PCALIGN is available on loong64, let's make use of it and manually align
some assembly loops. The functions are identified based on perf records
of some easily regressed go1 benchmark cases (e.g. FmtFprintfPrefixedInt,
RegexpMatchEasy0_1K and Revcomp are particularly sensitive; even those
optimizations purely reducing dynamic instruction counts can regress
those cases by 6~12%, making the numbers almost useless).

Benchmark results on Loongson 3A5000 (which is an LA464 implementation):

goos: linux
goarch: loong64
pkg: test/bench/go1
                      │  CL 416154  │               this CL               │
                      │   sec/op    │   sec/op     vs base                │
BinaryTree17             14.10 ± 1%    14.10 ± 1%        ~ (p=1.000 n=10)
Fannkuch11               3.672 ± 0%    3.579 ± 0%   -2.53% (p=0.000 n=10)
FmtFprintfEmpty         94.72n ± 0%   94.73n ± 0%   +0.01% (p=0.000 n=10)
FmtFprintfString        149.9n ± 0%   151.9n ± 0%   +1.33% (p=0.000 n=10)
FmtFprintfInt           154.1n ± 0%   158.3n ± 0%   +2.73% (p=0.000 n=10)
FmtFprintfIntInt        236.2n ± 0%   241.4n ± 0%   +2.20% (p=0.000 n=10)
FmtFprintfPrefixedInt   314.2n ± 0%   320.2n ± 0%   +1.91% (p=0.000 n=10)
FmtFprintfFloat         405.0n ± 0%   414.3n ± 0%   +2.30% (p=0.000 n=10)
FmtManyArgs             933.6n ± 0%   949.9n ± 0%   +1.75% (p=0.000 n=10)
GobDecode               15.51m ± 1%   15.24m ± 0%   -1.77% (p=0.000 n=10)
GobEncode               18.42m ± 4%   18.10m ± 2%        ~ (p=0.631 n=10)
Gzip                    423.6m ± 0%   429.9m ± 0%   +1.49% (p=0.000 n=10)
Gunzip                  88.75m ± 0%   88.31m ± 0%   -0.50% (p=0.000 n=10)
HTTPClientServer        85.44µ ± 0%   85.71µ ± 0%   +0.31% (p=0.035 n=10)
JSONEncode              18.65m ± 0%   19.74m ± 0%   +5.81% (p=0.000 n=10)
JSONDecode              77.75m ± 0%   78.60m ± 1%   +1.09% (p=0.000 n=10)
Mandelbrot200           7.214m ± 0%   7.208m ± 0%        ~ (p=0.481 n=10)
GoParse                 7.616m ± 2%   7.616m ± 1%        ~ (p=0.739 n=10)
RegexpMatchEasy0_32     142.9n ± 0%   133.0n ± 0%   -6.93% (p=0.000 n=10)
RegexpMatchEasy0_1K     1.535µ ± 0%   1.362µ ± 0%  -11.27% (p=0.000 n=10)
RegexpMatchEasy1_32     161.8n ± 0%   161.8n ± 0%        ~ (p=0.628 n=10)
RegexpMatchEasy1_1K     1.635µ ± 0%   1.497µ ± 0%   -8.41% (p=0.000 n=10)
RegexpMatchMedium_32    1.429µ ± 0%   1.420µ ± 0%   -0.63% (p=0.000 n=10)
RegexpMatchMedium_1K    41.86µ ± 0%   42.25µ ± 0%   +0.93% (p=0.000 n=10)
RegexpMatchHard_32      2.144µ ± 0%   2.108µ ± 0%   -1.68% (p=0.000 n=10)
RegexpMatchHard_1K      63.83µ ± 0%   62.65µ ± 0%   -1.86% (p=0.000 n=10)
Revcomp                  1.337 ± 0%    1.192 ± 0%  -10.89% (p=0.000 n=10)
Template                116.4m ± 1%   115.6m ± 2%        ~ (p=0.579 n=10)
TimeParse               421.4n ± 2%   418.1n ± 1%   -0.78% (p=0.001 n=10)
TimeFormat              515.1n ± 0%   517.9n ± 0%   +0.54% (p=0.001 n=10)
geomean                 104.5µ        103.5µ        -0.99%

                     │  CL 416154   │               this CL                │
                     │     B/s      │     B/s       vs base                │
GobDecode              47.19Mi ± 1%   48.04Mi ± 0%   +1.80% (p=0.000 n=10)
GobEncode              39.73Mi ± 4%   40.44Mi ± 2%        ~ (p=0.631 n=10)
Gzip                   43.68Mi ± 0%   43.04Mi ± 0%   -1.47% (p=0.000 n=10)
Gunzip                 208.5Mi ± 0%   209.6Mi ± 0%   +0.50% (p=0.000 n=10)
JSONEncode             99.21Mi ± 0%   93.76Mi ± 0%   -5.49% (p=0.000 n=10)
JSONDecode             23.80Mi ± 0%   23.55Mi ± 1%   -1.08% (p=0.000 n=10)
GoParse                7.253Mi ± 2%   7.253Mi ± 1%        ~ (p=0.810 n=10)
RegexpMatchEasy0_32    213.6Mi ± 0%   229.4Mi ± 0%   +7.41% (p=0.000 n=10)
RegexpMatchEasy0_1K    636.3Mi ± 0%   717.3Mi ± 0%  +12.73% (p=0.000 n=10)
RegexpMatchEasy1_32    188.6Mi ± 0%   188.6Mi ± 0%        ~ (p=0.810 n=10)
RegexpMatchEasy1_1K    597.4Mi ± 0%   652.2Mi ± 0%   +9.17% (p=0.000 n=10)
RegexpMatchMedium_32   21.35Mi ± 0%   21.49Mi ± 0%   +0.63% (p=0.000 n=10)
RegexpMatchMedium_1K   23.33Mi ± 0%   23.11Mi ± 0%   -0.94% (p=0.000 n=10)
RegexpMatchHard_32     14.24Mi ± 0%   14.48Mi ± 0%   +1.67% (p=0.000 n=10)
RegexpMatchHard_1K     15.30Mi ± 0%   15.59Mi ± 0%   +1.93% (p=0.000 n=10)
Revcomp                181.3Mi ± 0%   203.4Mi ± 0%  +12.21% (p=0.000 n=10)
Template               15.89Mi ± 1%   16.00Mi ± 2%        ~ (p=0.542 n=10)
geomean                59.33Mi        60.72Mi        +2.33%

Change-Id: I9ac28d936e03d21c46bb19fa100018f61ace6b42
Reviewed-on: https://go-review.googlesource.com/c/go/+/479816
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2 years agocmd/link, cmd/internal/obj/loong64: support the PCALIGN directive
WANG Xuerui [Tue, 28 Mar 2023 11:30:04 +0000 (19:30 +0800)]
cmd/link, cmd/internal/obj/loong64: support the PCALIGN directive

Allow writing `PCALIGN $imm` where imm is a power-of-2 between 8 and
2048 (inclusive), for ensuring that the following instruction is
placed at an imm-byte boundary relative to the beginning of the
function. If the PC is not sufficiently aligned, NOOPs will be
inserted to make it so, otherwise the directive will do nothing.

This could be useful for both asm performance hand-tuning, and future
scenarios where a certain bigger alignment might be required.

Change-Id: Iad6244669a3d5adea88eceb0dc7be1af4f0d4fc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/479815
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agoencoding/xml: use reflect.Value.Grow
Daniel Martí [Fri, 7 Apr 2023 17:21:00 +0000 (18:21 +0100)]
encoding/xml: use reflect.Value.Grow

Like https://go.dev/cl/481376 did for encoding/gob,
but now for encoding/xml, which had very similar code.

One minor difference is that encoding/xml now needs a SetLen before the
call to Index, as otherwise we index just past the length.
Still, calling Grow and SetLen is easier to understand,
and avoids needing to make a new zero value.

goos: linux
goarch: amd64
pkg: encoding/xml
cpu: AMD Ryzen 7 PRO 5850U with Radeon Graphics
│     old     │                new                │
│   sec/op    │   sec/op     vs base              │
Unmarshal-8   6.904µ ± 1%   6.980µ ± 1%  +1.10% (p=0.009 n=6)

│     old      │                new                 │
│     B/op     │     B/op      vs base              │
Unmarshal-8   7.656Ki ± 0%   7.586Ki ± 0%  -0.92% (p=0.002 n=6)

│    old     │               new                │
│ allocs/op  │ allocs/op   vs base              │
Unmarshal-8   188.0 ± 0%   185.0 ± 0%  -1.60% (p=0.002 n=6)

Change-Id: Id83feb467a9c59c80c7936aa892780aae7e8b809
Reviewed-on: https://go-review.googlesource.com/c/go/+/483135
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agonet/http: expose "http: server gave HTTP response to HTTPS client" error
Akihiro Suda [Fri, 7 Apr 2023 01:19:21 +0000 (01:19 +0000)]
net/http: expose "http: server gave HTTP response to HTTPS client" error

Expose "http: server gave HTTP response to HTTPS client" error as `ErrSchemeMismatch`, so that it can be compared with `errors.Is` .

Fixes #44855

Change-Id: If96e0d000fdef641fea407310faf9e1c4f7ad0f0
GitHub-Last-Rev: 22879fc88367d77817d7d96c9164f22e55f3a192
GitHub-Pull-Request: golang/go#50939
Reviewed-on: https://go-review.googlesource.com/c/go/+/382117
Run-TryBot: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agocmd/compile: remove broken LEA "optimization"
David Chase [Thu, 6 Apr 2023 18:42:53 +0000 (14:42 -0400)]
cmd/compile: remove broken LEA "optimization"

CL 440035 added rewrite rules to simplify "costly" LEA
instructions, but the types in the rewrites were wrong and
the code would go bad if the wrong-typed register was spilled.

CL 482536 attempted to fix this by correcting the type in the
rewrite, but that "fix" broke something on windows-amd64-race.

Instead / for-now, remove the offending rewrite rules.

Updates #21735.
Fixes #59432.

Change-Id: I0497c42db414f2055e1378e0a53e2bceee9cd5d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/482820
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agonet/http: wait forever for write results in tests
Damien Neil [Fri, 7 Apr 2023 17:04:42 +0000 (10:04 -0700)]
net/http: wait forever for write results in tests

After performing a round trip on a connection, the connection is
usually returned to the idle connection pool. If the write of the
request did not complete successfully, the connection is not
returned.

It is possible for the response to be read before the write
goroutine has finished signalling that its write has completed.
To allow for this, the check to see if the write completed successfully
waits for 50ms for the write goroutine to report the result of the
write.

See comments in persistConn.wroteRequest for more details.

On a slow builder, it is possible for the write goroutine to take
longer than 50ms to report the status of its write, leading to test
flakiness when successive requests unexpectedly use different connections.

Set the timeout for waiting for the writer to an effectively
infinite duration in tests.

Fixes #51147
Fixes #56275
Fixes #56419
Fixes #56577
Fixes #57375
Fixes #57417
Fixes #57476
Fixes #57604
Fixes #57605

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

2 years agonet/http: fix a race in TestResponseControllerSetPastReadDeadline
Bryan C. Mills [Fri, 7 Apr 2023 15:37:18 +0000 (15:37 +0000)]
net/http: fix a race in TestResponseControllerSetPastReadDeadline

If the Write goroutine is delayed for long enough after its first
Write, the handler may have closed both the readc and donec channels
by the time it selects over them, and the donec case may be randomly
chosen. Handle that case by explicitly checking readc as well.

This fixes a race accidentally introduced in CL 482935 and observed in
https://build.golang.org/log/fa684750994d1fda409722f144b90c65b4c52cf9.

For #59447.

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

2 years agocmd/compile: allow more inlining of functions that construct closures
Than McIntosh [Tue, 4 Apr 2023 22:31:46 +0000 (18:31 -0400)]
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 since fixed in CL 482355.]

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)

Updates #56102.

Change-Id: I1f4fc96c71609c8feb59fecdb92b69ba7e3b5b41
Reviewed-on: https://go-review.googlesource.com/c/go/+/482356
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: deadcode unreferenced hidden closures during inlining
Than McIntosh [Tue, 4 Apr 2023 22:56:21 +0000 (18:56 -0400)]
cmd/compile: deadcode unreferenced hidden closures during inlining

When a closure is inlined, it may contain other hidden closures, which
the inliner will duplicate, rendering the original nested closures as
unreachable. Because they are unreachable, they don't get processed in
escape analysis, meaning that go/defer statements don't get rewritten,
which can then in turn trigger errors in walk. This patch looks for
nested hidden closures and marks them as dead, so that they can be
skipped later on in the compilation flow.  NB: if during escape
analysis we rediscover a hidden closure (due to an explicit reference)
that was previously marked dead, revive it at that point.

Fixes #59404.

Change-Id: I76db1e9cf1ee38bd1147aeae823f916dbbbf081b
Reviewed-on: https://go-review.googlesource.com/c/go/+/482355
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agoruntime: permit core dumps in darwin-amd64
Ian Lance Taylor [Thu, 6 Apr 2023 23:38:47 +0000 (16:38 -0700)]
runtime: permit core dumps in darwin-amd64

Previously we did not permit them as Go programs generated enormous
core dumps on macOS. However, according to an investigation in #59446,
they are OK now.

For #59446

Change-Id: I1d7a3f500a6bc525aa6de8dfa8a1d8dbb15feadc
Reviewed-on: https://go-review.googlesource.com/c/go/+/483015
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agocmd/link/internal/ppc64: generate PCrel trampolines on P10
Paul E. Murphy [Tue, 10 Jan 2023 21:14:46 +0000 (15:14 -0600)]
cmd/link/internal/ppc64: generate PCrel trampolines on P10

PCrelative trampolines have no dependence on the TOC pointer or build
mode, thus they are preferable to use when supported.

This is a step towards eliminating the need to use and maintain the
TOC pointer in R2 when PCrel is supported.

Change-Id: I1b1a7e16831cfd6732b31f7fad8df2a7c88c8f84
Reviewed-on: https://go-review.googlesource.com/c/go/+/461599
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>

2 years agocmd/link/internal/ld: don't set IMAGE_FILE_DEBUG_STRIPPED on PE binaries
qmuntal [Mon, 3 Apr 2023 08:01:43 +0000 (10:01 +0200)]
cmd/link/internal/ld: don't set IMAGE_FILE_DEBUG_STRIPPED on PE binaries

The IMAGE_FILE_DEBUG_STRIPPED characteristic is used to inform that
the debugging information have been removed from the PE files and moved
into a DBG file, but the Go linker doesn't generate DBG files.

Having this characteristic can confuse debugging tools, so better
don't set it.

While here, remove also IMAGE_FILE_LINE_NUMS_STRIPPED, which is
deprecated and should be zero [1].

Fixes #59391

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

Change-Id: Ia6b1dc3353bfa292a17c4bef17c9bac8dc95189a
Reviewed-on: https://go-review.googlesource.com/c/go/+/481615
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agocmd/compile: get more bounds info from logic operators in prove pass
ruinan [Tue, 12 Jul 2022 04:05:41 +0000 (04:05 +0000)]
cmd/compile: get more bounds info from logic operators in prove pass

Currently, the prove pass can get knowledge from some specific logic
operators only before the CFG is explored, which means that the bounds
information of the branch will be ignored.

This CL updates the facts table by the logic operators in every
branch. Combined with the branch information, this will be helpful for
BCE in some circumstances.

Fixes #57243

Change-Id: I0bd164f1b47804ccfc37879abe9788740b016fd5
Reviewed-on: https://go-review.googlesource.com/c/go/+/419555
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Eric Fang <eric.fang@arm.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2 years agoruntime: correct GoCheckBindM's C declaration in EnsureBindM test
Cherry Mui [Thu, 6 Apr 2023 21:36:05 +0000 (17:36 -0400)]
runtime: correct GoCheckBindM's C declaration in EnsureBindM test

The test file has a C declaration which doesn't match the actual
definition. Remove it and include "_cgo_export.h" to have the
right declaration.

Change-Id: Iddf6d8883ee0e439147c7027029dd3e352ef090d
Reviewed-on: https://go-review.googlesource.com/c/go/+/482975
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd: add wasip1 support
Johan Brandhorst-Satzkorn [Sat, 25 Mar 2023 15:50:19 +0000 (08:50 -0700)]
cmd: add wasip1 support

For #58141

Co-authored-by: Richard Musiol <neelance@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Evan Phoenix <evan@phx.io>
Change-Id: I530ea78a3cd142f3a745f650b21c30e7f10ce981
Reviewed-on: https://go-review.googlesource.com/c/go/+/479621
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agocmd/go: improve packages help description
Oleksandr Redko [Wed, 5 Apr 2023 10:07:14 +0000 (13:07 +0300)]
cmd/go: improve packages help description

Clarify that 'action' is not the valid 'go' command.

Change-Id: I0a77722c46a3dc56f81c5e6e177e0c73bc60adc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/482455
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agonet/http: improve failure mode for TestResponseControllerSetPastReadDeadline
Damien Neil [Thu, 6 Apr 2023 19:09:04 +0000 (12:09 -0700)]
net/http: improve failure mode for TestResponseControllerSetPastReadDeadline

A test flake in #59447 seems to indicate that this test got stuck
waiting for the test handler to close the readc channel.
If the handler returns early due to an unexpected error, it might
fail to close this channel. Add a second channel to act as a
signal that the handler has given up and the test should stop.
This won't fix whatever happened in the flake, but might help
us debug it if it happens again.

For #59447

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

2 years agomisc/wasm: add wasip1/wasm exec script
Johan Brandhorst-Satzkorn [Sat, 25 Mar 2023 15:48:03 +0000 (08:48 -0700)]
misc/wasm: add wasip1/wasm exec script

This script uses Wazero, the open source, zero dependencies
pure Go Wasm and WASI runtime. This is the runtime that allows
the greatest number of standard library tests to pass.

For #58141

Co-authored-by: Richard Musiol <neelance@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Evan Phoenix <evan@phx.io>
Change-Id: I789465ae4daf2b380f3c05a9365b8d449c6af56c
Reviewed-on: https://go-review.googlesource.com/c/go/+/479620
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agosyscall: add remaining wasip1 files
Johan Brandhorst-Satzkorn [Sat, 25 Mar 2023 06:16:43 +0000 (23:16 -0700)]
syscall: add remaining wasip1 files

Implements filesystem, networking and os interactions.

For #58141

Co-authored-by: Richard Musiol <neelance@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Evan Phoenix <evan@phx.io>
Change-Id: If5c43ad5bd2955e6d2d4e2822fd68bce89ca786c
Reviewed-on: https://go-review.googlesource.com/c/go/+/479619
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>

2 years agocmd/go/internal/modfetch/codehost: set core.longpaths in Git repos on Windows
Bryan C. Mills [Thu, 6 Apr 2023 18:40:51 +0000 (18:40 +0000)]
cmd/go/internal/modfetch/codehost: set core.longpaths in Git repos on Windows

This setting appears to be needed to avoid “Filename too long” errors
when downloading modules from repos with long branch names,
particularly if the path to the module cache is already fairly long
(as may be the case in CI systems and in tests of cmd/go itself).

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

2 years agogo/scanner: align line and column limit with the compiler's limit
Damien Neil [Wed, 5 Apr 2023 16:28:00 +0000 (09:28 -0700)]
go/scanner: align line and column limit with the compiler's limit

The compiler disallows line and column numbers > (1<<30)
(cmd/compiler/internal/syntax.PosMax).

Set the go/scanner limit to the same rather than off by one.

For #59180

Change-Id: Ibf9e0e6826d6f6230b0d492543b7e906298a0524
Reviewed-on: https://go-review.googlesource.com/c/go/+/482595
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Damien Neil <dneil@google.com>

2 years agonet/http: add tests covering non-GET methods for file serving
Damien Neil [Thu, 6 Apr 2023 18:01:05 +0000 (11:01 -0700)]
net/http: add tests covering non-GET methods for file serving

ServeFile and FileServer will respond to methods such as DELETE by
serving the file contents. This is surprising, but we don't want to
change it without some consideration.

Add tests covering the current behavior.

For #59470

Change-Id: Ib6a2594c5b2b7f380149fc1628f7204b308161e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/482876
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoRevert "cmd/compile: use correct type in amd64 late-lower rules"
David Chase [Thu, 6 Apr 2023 17:03:24 +0000 (17:03 +0000)]
Revert "cmd/compile: use correct type in amd64 late-lower rules"

This reverts CL 482536.

Reason for revert: breaks windows-amd64-race

Change-Id: I033c52fe0d6bbbc879ed2a33d91fb1357f4874bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/482817
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agocmd/go: fix tests for new builder environment
Heschi Kreinick [Wed, 29 Mar 2023 17:13:19 +0000 (13:13 -0400)]
cmd/go: fix tests for new builder environment

Fix two long tests that fail in the builders we're trying out:

- TestQueryImport was failing with:
  open /nonexist-gopath/pkg/sumdb/sum.golang.org/latest: no such file or directory
  which eventually turns out to be because it couldn't create
  /nonexist-gopath because it wasn't running as root. The test already
  uses a temporary GOPATH, but missed overriding a configuration
  variable set at init time.
- test_flags fails if the working directory has /x/ in it, which it now
  happens to.

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

2 years agoruntime: add remaining wasip1 files
Johan Brandhorst-Satzkorn [Sat, 25 Mar 2023 06:11:55 +0000 (23:11 -0700)]
runtime: add remaining wasip1 files

Implements OS interactions and memory management.

For #58141

Co-authored-by: Richard Musiol <neelance@gmail.com>
Co-authored-by: Achille Roussel <achille.roussel@gmail.com>
Co-authored-by: Julien Fabre <ju.pryz@gmail.com>
Co-authored-by: Evan Phoenix <evan@phx.io>
Change-Id: I876e7b033090c2fe2d76d2535bb63d52efa36185
Reviewed-on: https://go-review.googlesource.com/c/go/+/479618
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

2 years agoRevert "net/http: FileServer method check + minimal OPTIONS implementation"
Damien Neil [Wed, 5 Apr 2023 17:19:44 +0000 (10:19 -0700)]
Revert "net/http: FileServer method check + minimal OPTIONS implementation"

This reverts https://go.dev/cl/413554

Reason for revert: Backwards-incompatible change in behavior.

For #53501
For #59375

Change-Id: Ic3f63b378f9c819599b32e5e6e410f6163849317
Reviewed-on: https://go-review.googlesource.com/c/go/+/482635
Reviewed-by: Tatiana Bradley <tatianabradley@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: fix typo in traceback.go
Kaiya [Thu, 6 Apr 2023 07:01:34 +0000 (15:01 +0800)]
runtime: fix typo in traceback.go

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

2 years agocmd/compile: modify debug-hash to support match exclusion
David Chase [Fri, 31 Mar 2023 21:26:04 +0000 (17:26 -0400)]
cmd/compile: modify debug-hash to support match exclusion

The goal here is to enable a search that will locate all the instances
of a failure, not just the first one.  This helps with searches for
loopvar-change breakage, FP differences from fused-multiply-add, and
allows certain semantics queries that can be implemented as compiler
changes (for example, where does integer overflow routinely occur?)

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

2 years agocmd/compile: use correct type in amd64 late-lower rules
David Chase [Wed, 5 Apr 2023 19:49:07 +0000 (15:49 -0400)]
cmd/compile: use correct type in amd64 late-lower rules

The wrong type causes the wrong width spill, which corrupts
the value.  I tried to write a test for this and did not
succeed, but was able (using gossahash and ssa.html) to
isolate to exact change and spill.

Fixes #59432.

Change-Id: I85ad82c9f8fed7674c69d6a2b0a62e111f690454
Reviewed-on: https://go-review.googlesource.com/c/go/+/482536
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: flush each idle P's page cache at the end of each GC cycle
Michael Anthony Knyszek [Mon, 28 Nov 2022 19:53:20 +0000 (19:53 +0000)]
runtime: flush each idle P's page cache at the end of each GC cycle

Currently pages may linger in an idle P's page cache, hiding the memory
from the scavenger precisely when it's useful to return memory to the OS
and reduce the application's footprint.

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