]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
9 months agoarchive/tar: add AddFS method to Writer
Mauri de Souza Meneguzzo [Thu, 10 Aug 2023 21:13:11 +0000 (21:13 +0000)]
archive/tar: add AddFS method to Writer

The method AddFS can be used to add the contents of a fs.FS filesystem
to a tar archive. This method walks the directory tree starting at the root
of the filesystem and adds each file to the archive.

Fixes #58000

Change-Id: I0e6abac76b76bc5d95b74b7e5b37634ce3f76c85
GitHub-Last-Rev: 11a62bfd7ebc7ca93b1832da15018e6805c92520
GitHub-Pull-Request: golang/go#61599
Reviewed-on: https://go-review.googlesource.com/c/go/+/513316
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>

9 months agogo/doc/comment: update TODO for isStdPkg
Jes Cok [Tue, 12 Sep 2023 22:43:28 +0000 (22:43 +0000)]
go/doc/comment: update TODO for isStdPkg

Even better is slices.BinarySearch, leave a TODO to update to that when possible.

Change-Id: Ie1ec75c34c0329c536725b45e520693790f0520e
GitHub-Last-Rev: 6cd811b186c95752794cead3ae747f54c2d0d0c5
GitHub-Pull-Request: golang/go#62585
Reviewed-on: https://go-review.googlesource.com/c/go/+/527341
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agocmd/compile: sparse conditional constant propagation
Yi Yang [Thu, 31 Aug 2023 02:48:34 +0000 (02:48 +0000)]
cmd/compile: sparse conditional constant propagation

sparse conditional constant propagation can discover optimization
opportunities that cannot be found by just combining constant folding
and constant propagation and dead code elimination separately.

This is a re-submit of PR#59575, which fix a broken dominance relationship caught by ssacheck

Updates https://github.com/golang/go/issues/59399

Change-Id: I57482dee38f8e80a610aed4f64295e60c38b7a47
GitHub-Last-Rev: 830016f24e3a5320c6c127a48ab7c84e2fc672eb
GitHub-Pull-Request: golang/go#60469
Reviewed-on: https://go-review.googlesource.com/c/go/+/498795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agoruntime: set _XOPEN_SORUCE_EXTENDED to 1 for aix
Michael Pratt [Tue, 12 Sep 2023 19:33:29 +0000 (15:33 -0400)]
runtime: set _XOPEN_SORUCE_EXTENDED to 1 for aix

aix requires that _XOPEN_SOURCE_EXTENDED is set to a number, not simply
defined.

For #62440.

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

9 months agocmd/compile: add a 'Tips' section to README to help new contributors
thepudds [Thu, 15 Jun 2023 19:09:11 +0000 (15:09 -0400)]
cmd/compile: add a 'Tips' section to README to help new contributors

This CL adds a new 'Tips' section to the cmd/compile README.

The primary intent is to help new-ish contributors.

It includes some basics on getting started, testing changes,
viewing coverage, juggling different compiler versions,
some links to additional tools, and so on.

Updates #30074

Change-Id: I393bf1137db9d2bb851f7e254b08455273ccad8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/503895
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: t hepudds <thepudds1460@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
9 months agoio/fs, path/filepath, cmd/gofmt: replace statDirEntry with fs.FileInfoToDirEntry
mstmdev [Tue, 12 Sep 2023 11:49:41 +0000 (11:49 +0000)]
io/fs, path/filepath, cmd/gofmt: replace statDirEntry with fs.FileInfoToDirEntry

Change-Id: Ie914367314ca72fab34c4d4529755dea853cf325
GitHub-Last-Rev: bc61665d33d7f15da371dcfb90c132fab25fc233
GitHub-Pull-Request: golang/go#62342
Reviewed-on: https://go-review.googlesource.com/c/go/+/523876
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
9 months agoos: fix TestRenameCaseDifference
Kir Kolyshkin [Sat, 9 Sep 2023 11:14:42 +0000 (04:14 -0700)]
os: fix TestRenameCaseDifference

Saw this failing on windows like this:

--- FAIL: TestRenameCaseDifference (2.96s)
--- FAIL: TestRenameCaseDifference/dir (1.64s)
    testing.go:1226: TempDir RemoveAll cleanup: remove C:\Users\gopher\AppData\Local\Temp\1\TestRenameCaseDifferencedir1375918868\001: The process cannot access the file because it is being used by another process.
--- FAIL: TestRenameCaseDifference/file (1.32s)
    testing.go:1226: TempDir RemoveAll cleanup: remove C:\Users\gopher\AppData\Local\Temp\1\TestRenameCaseDifferencefile3272269402\001: The process cannot access the file because it is being used by another process.
FAIL

The reason might be the directory fd is not closed. This may be
mitigated by retries in removeAll function from testing package,
but apparently it does not succeed all the time.

A link to the failed run which made me look into this: https://ci.chromium.org/ui/p/golang/builders/try/gotip-windows-386/b8770439049015378129/overview

Change-Id: Ibebe94958d1aef8d1d0eca8a969675708cd27a7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/527175
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agoall: calculate the median uniformly
Jes Cok [Tue, 12 Sep 2023 13:18:33 +0000 (13:18 +0000)]
all: calculate the median uniformly

This is a follow up of CL 526496.

Change-Id: I9f351951bf975e31befd36b9c951d195d2f8f9f7
GitHub-Last-Rev: 4307adafbffef7494d6f807b69df3e56328d6bf4
GitHub-Pull-Request: golang/go#62590
Reviewed-on: https://go-review.googlesource.com/c/go/+/527576
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agonet/http: routing tree
Jonathan Amsterdam [Mon, 11 Sep 2023 16:09:40 +0000 (12:09 -0400)]
net/http: routing tree

This CL implements a decision tree for efficient routing.
The tree holds all the registered patterns. To match
a request, we walk the tree looking for a match.

Change-Id: I7ed1cdf585fc95b73ef5ca2f942f278100a90583
Reviewed-on: https://go-review.googlesource.com/c/go/+/527315
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>

9 months agocmd/compile/internal/ir: add NewZero
Matthew Dempsky [Tue, 12 Sep 2023 11:51:16 +0000 (04:51 -0700)]
cmd/compile/internal/ir: add NewZero

This constructs a zero value of any type, which helps address some
corner case scenarios.

It should also eventually handle the predeclared "zero" value, at
least as currently implemented in go.dev/cl/520336.

For #61372.

Change-Id: I3a86a94fd8fa388c9c6bf281da8aa532b3da00fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/527696
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/dwarfgen: remove unversion
Matthew Dempsky [Tue, 12 Sep 2023 10:17:23 +0000 (03:17 -0700)]
cmd/compile/internal/dwarfgen: remove unversion

The unified export data format doesn't rely on embedding version
numbers in local variable names anymore, so there's no need to look
for them.

While here, simplify the checking for "~r" or "~b" to just "~",
because the next commit is going to eliminate "~b", but introduce
"~p".

Change-Id: I3ac73150ee561c66356a0c4aee5290b44a4893ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/527695
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
9 months agocmd/compile/internal/devirtualize: sort equal weight CallStat.Hottest by name
Michael Pratt [Tue, 12 Sep 2023 18:23:15 +0000 (14:23 -0400)]
cmd/compile/internal/devirtualize: sort equal weight CallStat.Hottest by name

When two callees have equal weight, we need to sort by another criteria
to ensure that we get stable output.

Note that this is only for the CallStat debug JSON output. The actual
callee selection already does this secondary sort in
findHotConcreteCallee.

Change-Id: I0de105623c5ccc793ca6f5799ea25e57bc286722
Reviewed-on: https://go-review.googlesource.com/c/go/+/527796
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoruntime: set _XOPEN_SOURCE_EXTENDED for netbsd
Michael Pratt [Tue, 12 Sep 2023 17:35:15 +0000 (13:35 -0400)]
runtime: set _XOPEN_SOURCE_EXTENDED for netbsd

If _XOPEN_SOURCE is defined, then netbsd also requires
_XOPEN_SOURCE_EXTENDED to define stack_t.

For #62440.

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

9 months agoruntime: fix off-by-1 error in textOff
Cherry Mui [Tue, 12 Sep 2023 17:52:42 +0000 (13:52 -0400)]
runtime: fix off-by-1 error in textOff

The code meant to check if it is the last section, which is
i === len(md.textsectmap)-1. The -1 was missing.

Change-Id: Ifbb9e40df730abe3bec20fde5f56f5c75dfd9e8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/527795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
9 months agonet/http: mapping data structure
Jonathan Amsterdam [Mon, 11 Sep 2023 14:59:48 +0000 (10:59 -0400)]
net/http: mapping data structure

Our goal for the new ServeMux patterns is to match the routing
performance of the existing ServeMux patterns. To achieve that
we needed to optimize lookup for small maps.

This CL introduces a simple data structure called a mapping that
optimizes lookup by using a slice for small collections of key-value
pairs, switching to a map when the collection gets large.

Mappings are a core part of the routing algorithm, which uses a
decision tree to match path elements.   The children of a tree node are
held in a mapping.

Change-Id: I923b3ad1376ace2c3e3421aa9b802ad12d47c871
Reviewed-on: https://go-review.googlesource.com/c/go/+/526617
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
9 months agonet/http: pattern.conflictsWith
Jonathan Amsterdam [Fri, 8 Sep 2023 12:58:29 +0000 (08:58 -0400)]
net/http: pattern.conflictsWith

Add the conflictsWith method, which determines whether two patterns
conflict with each other.

Updates #61410.

Change-Id: Id4f9a471dc9d0420d927a68d2864128a096b74f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/526616
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoruntime: allow update of system stack bounds on callback from C thread
Michael Pratt [Mon, 4 Sep 2023 13:55:01 +0000 (09:55 -0400)]
runtime: allow update of system stack bounds on callback from C thread

[This is a redo of CL 525455 with the test fixed on darwin by defining
_XOPEN_SOURCE, and disabled with android, musl, and openbsd, which do
not provide getcontext.]

Since CL 495855, Ms are cached for C threads calling into Go, including
the stack bounds of the system stack.

Some C libraries (e.g., coroutine libraries) do manual stack management
and may change stacks between calls to Go on the same thread.

Changing the stack if there is more Go up the stack would be
problematic. But if the calls are completely independent there is no
particular reason for Go to care about the changing stack boundary.

Thus, this CL allows the stack bounds to change in such cases. The
primary downside here (besides additional complexity) is that normal
systems that do not manipulate the stack may not notice unintentional
stack corruption as quickly as before.

Note that callbackUpdateSystemStack is written to be usable for the
initial setup in needm as well as updating the stack in cgocallbackg.

Fixes #62440.
For #62130.

Change-Id: I0fe0134f865932bbaff1fc0da377c35c013bd768
Reviewed-on: https://go-review.googlesource.com/c/go/+/527715
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agocmd/compile/internal/base: keep Ctxt.Flag_optimize in sync with Flag.N
Than McIntosh [Mon, 11 Sep 2023 16:15:48 +0000 (12:15 -0400)]
cmd/compile/internal/base: keep Ctxt.Flag_optimize in sync with Flag.N

This patch fixes an inconsistency in compiler flag handling introduced
accidentally in CL 521699. In the compiler we have both base.Flag.N
(which records whether the user has supplied the "-N" flag to disable
optimization) and base.Ctxt.Flag_optimize (which tracks whether
optimization is turned on). In this case Flag.N was updated without a
corresponding change to Ctxt.Flag_optimize, which led to problems with
DWARF generation for the runtime.

This CL doesn't include a regression test; a test will be added later
in the x/debug repo in a subsequent CL.

Updates #62523.

Change-Id: I0c383bb43ec0a0e7c12e7e2852c0590731416d6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/527319
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoall: fix Microsoft links
qmuntal [Tue, 12 Sep 2023 12:48:12 +0000 (14:48 +0200)]
all: fix Microsoft links

This CL fixes the links to Microsoft documentation in the Go source
code. Some links were broken and some others were outdated.

Change-Id: I4c3bcd3aa3c07a31be1b7f94c25339dcc2e771e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/527556
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>

9 months agocmd/compile: remove typecheck.Orig* functions
Cuong Manh Le [Tue, 12 Sep 2023 03:45:54 +0000 (10:45 +0700)]
cmd/compile: remove typecheck.Orig* functions

Same as CL 526397, but for typecheck.

Change-Id: Ia8f19a54ffaa2ae3b86a4c66cbe6d973482796cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/526236
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/types: remove Type.vargen
Matthew Dempsky [Tue, 12 Sep 2023 01:50:26 +0000 (18:50 -0700)]
cmd/compile/internal/types: remove Type.vargen

The unified frontend diasmbiguates local types by putting vargen
directly into their symbol name instead. We no longer need a separate
int field for it.

Change-Id: I556c588ed68c5e2cb324cd46abd934894b5aaef9
Reviewed-on: https://go-review.googlesource.com/c/go/+/527517
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile: stop changing Field.Sym for parameters
Matthew Dempsky [Tue, 12 Sep 2023 00:45:37 +0000 (17:45 -0700)]
cmd/compile: stop changing Field.Sym for parameters

Field.Sym now always contains the original symbol as it appeared in Go
source, so we don't need OrigSym anymore.

Instead, when the mangled name is desired, Field.Nname.Sym() can be
used instead, which is always non-nil if Nname is non-nil.

Change-Id: I96cd61db6458d4a2e07ec5810239236e3dfba747
Reviewed-on: https://go-review.googlesource.com/c/go/+/527516
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
9 months agocmd/link: disable DWARF by default in c-shared mode on darwin
Cherry Mui [Mon, 11 Sep 2023 19:53:49 +0000 (15:53 -0400)]
cmd/link: disable DWARF by default in c-shared mode on darwin

Currently, linking a Go c-shared object with C code using Apple's
new linker, it fails with

% cc a.c go.so
ld: segment '__DWARF' filesize exceeds vmsize in 'go.so'

Apple's new linker has more checks for unmapped segments. It is
very hard to make it accept a Mach-O shared object with an
additional DWARF segment.

We may want to stop combinding DWARF into the shared object (see
also #62577). For now, disable DWARF by default in c-shared mode
on darwin. (One can still enable it with -ldflags=-w=0, which will
contain DWARF, but it will need the old C linker to link against
with.)

For #61229.

Change-Id: I4cc77da54fac10e2c2cbcffa92779cba82706d75
Reviewed-on: https://go-review.googlesource.com/c/go/+/527415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile/internal/typecheck: remove HasNamedResults check
Matthew Dempsky [Tue, 12 Sep 2023 00:23:55 +0000 (17:23 -0700)]
cmd/compile/internal/typecheck: remove HasNamedResults check

types2 has already checked for us that bare returns are valid, so no
need to duplicate the effort in typecheck.

Change-Id: I13b2387173966ba44058fbc841327896e04184e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/527515
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile: rename OEFACE to OMAKEFACE and remove OCONVIDATA
Matthew Dempsky [Mon, 11 Sep 2023 21:31:55 +0000 (14:31 -0700)]
cmd/compile: rename OEFACE to OMAKEFACE and remove OCONVIDATA

The "eface" in OEFACE suggests it's only for empty interfaces, and the
documentation suggests that too. But it's actually used for both empty
and non-empty interfaces, so rename to OMAKEFACE and adjust docs
accordingly.

Also, remove OCONVIDATA. This was used by the 1.18 frontend for
constructing interfaces containing derived types, but the unified
frontend always uses OCONVIFACE instead, so this is unused now.

Change-Id: I6ec5c62f909b26027f2804e5b3373b7a00029246
Reviewed-on: https://go-review.googlesource.com/c/go/+/527336
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agointernal/cpu: fix wrong cache line size of riscv64
Meng Zhuo [Fri, 8 Sep 2023 09:53:34 +0000 (17:53 +0800)]
internal/cpu: fix wrong cache line size of riscv64

All of riscv CPU using 64B for cache-line size.
i.e. U540 of Hifive Unleashed (https://www.sifive.com/boards/hifive-unleashed)

Change-Id: I0d72d88ac026f45383c3b3eb3a77233d3c2e4004
Reviewed-on: https://go-review.googlesource.com/c/go/+/526659
Run-TryBot: M Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoRevert "os/exec: avoid calling LookPath in cmd.Start for resolved paths"
Ian Lance Taylor [Tue, 12 Sep 2023 00:07:55 +0000 (00:07 +0000)]
Revert "os/exec: avoid calling LookPath in cmd.Start for resolved paths"

This reverts CL 512155.

Reason for revert: CL 512155 introduced a race in that it caused
cmd.Start to set cmd.Path. Previously it was fine if code looked
at cmd.Path in one goroutine while calling cmd.Start in a different
goroutine.

A test case for this race is in CL 527495.

Change-Id: Ic18fdadf6763727f8ea748280d5f0e601b9bf374
Reviewed-on: https://go-review.googlesource.com/c/go/+/527337
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/compile/internal/ir: remove OSIZEOF, etc
Matthew Dempsky [Fri, 8 Sep 2023 23:25:02 +0000 (16:25 -0700)]
cmd/compile/internal/ir: remove OSIZEOF, etc

These are no longer needed after the previous CL, which moved handling
of unsafe.Sizeof, etc. directly into the unified frontend.

Change-Id: Ieb35ffca0bc25319e58132fb5d035c5b441acea7
Reviewed-on: https://go-review.googlesource.com/c/go/+/527098
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocmd/compile/internal/noder: handle unsafe.Sizeof, etc in unified IR
Matthew Dempsky [Fri, 8 Sep 2023 23:21:17 +0000 (16:21 -0700)]
cmd/compile/internal/noder: handle unsafe.Sizeof, etc in unified IR

Previously, the unified frontend implemented unsafe.Sizeof, etc that
involved derived types by constructing a normal OSIZEOF, etc
expression, including fully instantiating their argument. (When
unsafe.Sizeof is applied to a non-generic type, types2 handles
constant folding it.)

This worked, but involves unnecessary work, since all we really need
to track is the argument type (and the field selections, for
unsafe.Offsetof).

Further, the argument expression could generate temporary variables,
which would then go unused after typecheck replaced the OSIZEOF
expression with an OLITERAL. This results in compiler failures after
CL 523315, which made later passes stricter about expecting the
frontend to not construct unused temporaries.

Fixes #62515.

Change-Id: I37baed048fd2e35648c59243f66c97c24413aa94
Reviewed-on: https://go-review.googlesource.com/c/go/+/527097
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

9 months agolog/slog: generate valid JSON string with empty attributes in Groups
Andy Pan [Sat, 19 Aug 2023 11:27:43 +0000 (19:27 +0800)]
log/slog: generate valid JSON string with empty attributes in Groups

Fixes #62152

Change-Id: I1f76ab26eae3a44292ebe6003006258d5e31d50f
Reviewed-on: https://go-review.googlesource.com/c/go/+/521135
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agonet/netip: add AddrPort.Compare and Prefix.Compare
David Anderson [Thu, 31 Aug 2023 22:46:45 +0000 (22:46 +0000)]
net/netip: add AddrPort.Compare and Prefix.Compare

Fixes #61642

Change-Id: I2262855dbe75135f70008e5df4634d2cfff76550
GitHub-Last-Rev: 949685a9e426f50f37753045d7527ebcccb082e7
GitHub-Pull-Request: golang/go#62387
Reviewed-on: https://go-review.googlesource.com/c/go/+/524616
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
9 months agocmd/go: cache results of exec.LookPath
qiulaidongfeng [Sat, 9 Sep 2023 00:58:21 +0000 (00:58 +0000)]
cmd/go: cache results of exec.LookPath

This CL package exec.LookPath to internal/cfg.LookPath and adds cache.

BenchmarkLookPath-4     24149096                50.48 ns/op            0 B/op          0 allocs/op

Fixes #36768

Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9

Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9
GitHub-Last-Rev: d67aa826f431affe829c23d1fdf2241fbb611303
GitHub-Pull-Request: golang/go#61464
Reviewed-on: https://go-review.googlesource.com/c/go/+/511458
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: Heschi Kreinick <heschi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/staticinit: make staticopy safe
Matthew Dempsky [Thu, 24 Mar 2022 19:27:39 +0000 (12:27 -0700)]
cmd/compile/internal/staticinit: make staticopy safe

Currently, cmd/compile optimizes `var a = true; var b = a` into `var a
= true; var b = true`. But this may not be safe if we need to
initialize any other global variables between `a` and `b`, and the
initialization involves calling a user-defined function that reassigns
`a`.

This CL changes staticinit to keep track of the initialization
expressions that we've seen so far, and to stop applying the
staticcopy optimization once we've seen an initialization expression
that might have modified another global variable within this package.

To help identify affected initializers, this CL adds a -d=staticcopy
flag to warn when a staticcopy is suppressed and turned into a dynamic
copy.

Currently, `go build -gcflags=all=-d=staticcopy std` reports only four
instances:

```
encoding/xml/xml.go:1600:5: skipping static copy of HTMLEntity+0 with map[string]string{...}
encoding/xml/xml.go:1869:5: skipping static copy of HTMLAutoClose+0 with []string{...}
net/net.go:661:5: skipping static copy of .stmp_31+0 with poll.ErrNetClosing
net/http/transport.go:2566:5: skipping static copy of errRequestCanceled+0 with ~R0
```

Fixes #51913.

Change-Id: Iab41cf6f84c44f7f960e4e62c28a8aeaade4fbcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/395541
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
9 months agoruntime: avoid staticinit dependency with sigsetAllExiting
Matthew Dempsky [Wed, 11 May 2022 19:44:06 +0000 (12:44 -0700)]
runtime: avoid staticinit dependency with sigsetAllExiting

Currently, package runtime runs `osinit` before dynamic initialization
of package-scope variables; but on GOOS=linux, `osinit` involves
mutating `sigsetAllExiting`.

This currently works because cmd/compile and gccgo have
non-spec-conforming optimizations that statically initialize
`sigsetAllExiting`, but disabling that optimization causes
`sigsetAllExiting` to be dynamically initialized instead. This in turn
causes the mutations in `osinit` to get lost.

This CL moves the initialization of `sigsetAllExiting` from `osinit`
into its initialization expression, and then removes the special case
for continuing to perform the static-initialization optimization for
package runtime.

Updates #51913.

Change-Id: I3be31454277c103372c9701d227dc774b2311dad
Reviewed-on: https://go-review.googlesource.com/c/go/+/405549
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/ir: add missing SetTypecheck
Matthew Dempsky [Wed, 30 Aug 2023 11:19:35 +0000 (04:19 -0700)]
cmd/compile/internal/ir: add missing SetTypecheck

This was missed earlier, because NewConstAt is only used now to
construct the predeclared "true" and "false" constants. But these
constants are no longer actually accessed with unified IR.

For constant expressions, types2 (and go/types) sets
TypeAndValue.Value for the expression to the appropriate constant
value. The unified writer recognizes when expressions are constants,
and simply writes the underlying value, regardless of the original
expression. As a result, we never end up actually referencing the
*named* "true" and "false" constants; we just always construct
anonymous constant "true" and "false" values.

However, a manually constructed tree that includes an *ir.Name that
"Uses" the predeclared true/false Const Objects, yet doesn't set
TypeAndValue.Value will instead end up trying to use named constants
constructed with NewConstAt.

Thanks to Russ for reporting the issue on CL 510541, and to Cuong for
identifying the fix.

Change-Id: I0614105379d63ea76d7244ebd1e4db5c239d4670
Reviewed-on: https://go-review.googlesource.com/c/go/+/524357
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agonet/http: extended routing patterns
Jonathan Amsterdam [Fri, 8 Sep 2023 00:14:47 +0000 (20:14 -0400)]
net/http: extended routing patterns

This is the first of several CLs implementing the proposal
for enhanced ServeMux routing, https://go.dev/issue/61410.

Define a type to represent extended routing patterns and a function to
parse a string into one.

Updates #61410.

Change-Id: I779689acf1f14b20d12c9264251f7dc002b68c49
Reviewed-on: https://go-review.googlesource.com/c/go/+/526815
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile/internal/inline/inlheur: fixup tests for NewBasicLit change
Than McIntosh [Mon, 11 Sep 2023 16:27:17 +0000 (12:27 -0400)]
cmd/compile/internal/inline/inlheur: fixup tests for NewBasicLit change

Fix a regression test to use the correct new signature for
ir.NewBasicLit.

Change-Id: I06c849e83a5edfce784c780b5490f461f6c3b129
Reviewed-on: https://go-review.googlesource.com/c/go/+/527318
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoRevert "runtime: allow update of system stack bounds on callback from C thread"
Michael Pratt [Mon, 11 Sep 2023 16:18:51 +0000 (12:18 -0400)]
Revert "runtime: allow update of system stack bounds on callback from C thread"

This reverts CL 525455. The test fails to build on darwin, alpine, and
android.

For #62440.

Change-Id: I39c6b1e16499bd61e0f166de6c6efe7a07961e62
Reviewed-on: https://go-review.googlesource.com/c/go/+/527317
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agoRevert "runtime: set stackguard1 on extra M g0"
Michael Pratt [Mon, 11 Sep 2023 16:17:40 +0000 (12:17 -0400)]
Revert "runtime: set stackguard1 on extra M g0"

This reverts CL 527056.

CL 525455 breaks darwin, alpine, and android. This CL must be reverted
in order to revert that CL.

For #62440.

Change-Id: I4e1b16e384b475a605e0214ca36c918d50faa22c
Reviewed-on: https://go-review.googlesource.com/c/go/+/527316
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoruntime: don't clear procid on netbsd
Michael Pratt [Fri, 8 Sep 2023 21:59:02 +0000 (17:59 -0400)]
runtime: don't clear procid on netbsd

This is a partial revert of CL 526118.

NetBSD uses mp.procid in locking (semawake). unminit is called
surprisingly early in mexit, and there is definitely locking after that
point, so it isn't safe to clear procid so early.

Fixes #62524.
Fixes #62531.

Change-Id: Iefbef63e84fc0395e255970a301401e1187a910d
Reviewed-on: https://go-review.googlesource.com/c/go/+/527057
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agocmd/compile/internal/ir: add Type param to NewBasicLit
Matthew Dempsky [Fri, 8 Sep 2023 22:44:57 +0000 (15:44 -0700)]
cmd/compile/internal/ir: add Type param to NewBasicLit

This CL adds an explicit Type parameter to NewBasicLit so that callers
can directly construct typed OLITERAL nodes.

Change-Id: I0ab50ac3d7ddb7adcc903633a62ac496921165e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/527096
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agocmd/compile/internal/typecheck: fix closure field naming
Matthew Dempsky [Sat, 9 Sep 2023 01:04:31 +0000 (18:04 -0700)]
cmd/compile/internal/typecheck: fix closure field naming

When creating the struct type to hold variables captured by a function
literal, we currently reuse the captured variable names as fields.

However, there's no particular reason to do this: these struct types
aren't visible to users, and it adds extra complexity in making sure
fields belong to the correct packages.

Further, it turns out we were getting that subtly wrong. If two
function literals from different packages capture variables with
identical names starting with an uppercase letter (and in the same
order and with corresponding identical types) end up in the same
function (e.g., due to inlining), then we could end up creating
closure struct types that are "different" (i.e., not types.Identical)
yet end up with equal LinkString representations (which violates
LinkString's contract).

The easy fix is to just always use simple, exported, generated field
names in the struct. This should allow further struct reuse across
packages too, and shrink binary sizes slightly.

Fixes #62498.

Change-Id: I9c973f5087bf228649a8f74f7dc1522d84a26b51
Reviewed-on: https://go-review.googlesource.com/c/go/+/527135
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoruntime: set stackguard1 on extra M g0
Michael Pratt [Fri, 8 Sep 2023 18:54:29 +0000 (14:54 -0400)]
runtime: set stackguard1 on extra M g0

Standard Ms set g0.stackguard1 to the same value as stackguard0 in
mstart0. For consistency, extra Ms should do the same for their g0. Do
this in needm -> callbackUpdateSystemStack.

Background: getg().stackguard1 is used as the stack guard for the stack
growth prolouge in functions marked //go:systemstack [1]. User Gs set
stackguard1 to ^uintptr(0) so that the check always fail, calling
morestackc, which throws to report a //go:systemstack function call on a
user stack.

g0 setting stackguard1 is unnecessary for this functionality. 0 would be
sufficient, as g0 is always allowed to call //go:systemstack functions.
However, since we have the check anyway, setting stackguard1 to the
actual stack bound is useful to detect actual stack overflows on g0
(though morestackc doesn't detect this case and would report a
misleading message about user stacks).

[1] cmd/internal/obj calls //go:systemstack functions AttrCFunc. This is
a holdover from when the runtime contained actual C functions. But since
CL 2275, it has simply meant "pretend this is a C function, which would
thus need to use the system stack". Hence the name morestackc. At this
point, this terminology is pretty far removed from reality and should
probably be updated to something more intuitive.

Change-Id: I8d0e5628ce31ac6a189a7d7a4124be85aef89862
Reviewed-on: https://go-review.googlesource.com/c/go/+/527056
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agoruntime: allow update of system stack bounds on callback from C thread
Michael Pratt [Mon, 4 Sep 2023 13:55:01 +0000 (09:55 -0400)]
runtime: allow update of system stack bounds on callback from C thread

Since CL 495855, Ms are cached for C threads calling into Go, including
the stack bounds of the system stack.

Some C libraries (e.g., coroutine libraries) do manual stack management
and may change stacks between calls to Go on the same thread.

Changing the stack if there is more Go up the stack would be
problematic. But if the calls are completely independent there is no
particular reason for Go to care about the changing stack boundary.

Thus, this CL allows the stack bounds to change in such cases. The
primary downside here (besides additional complexity) is that normal
systems that do not manipulate the stack may not notice unintentional
stack corruption as quickly as before.

Note that callbackUpdateSystemStack is written to be usable for the
initial setup in needm as well as updating the stack in cgocallbackg.

Fixes #62440.
For #62130.

Change-Id: I7841b056acea1111bdae3b718345a3bd3961b4a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/525455
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile/internal/typecheck: use constant.MakeUnknown()
qiulaidongfeng [Sun, 10 Sep 2023 04:33:34 +0000 (04:33 +0000)]
cmd/compile/internal/typecheck: use constant.MakeUnknown()

Complete a TODO.

Change-Id: I1bd23f0be725c9dd81b8316a7abba1bceecc346f

Change-Id: I1bd23f0be725c9dd81b8316a7abba1bceecc346f
GitHub-Last-Rev: 51523084a3675b91cdf49491bbaa9e78f78e3742
GitHub-Pull-Request: golang/go#62553
Reviewed-on: https://go-review.googlesource.com/c/go/+/527178
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/go/internal/generate: error if failed to find a package
Kirill Che [Fri, 8 Sep 2023 07:45:12 +0000 (07:45 +0000)]
cmd/go/internal/generate: error if failed to find a package

Add check for package loader to print error and fail `go generate` command,
if package can not be found.

Fixes #60079

Change-Id: Ib9e730c2b69df6e5ac307c7bdfea0ee993ab6ed8
GitHub-Last-Rev: d93332425a980d0298c74f33f1d154e0afbf5373
GitHub-Pull-Request: golang/go#60178
Reviewed-on: https://go-review.googlesource.com/c/go/+/494836
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoall: calculate the median uniformly
Jes Cok [Thu, 7 Sep 2023 11:07:30 +0000 (11:07 +0000)]
all: calculate the median uniformly

Like sort.Search, use "h := int(uint(i+j) >> 1)" style code to calculate
the median.

Change-Id: Ifb1a19dde1c6ed6c1654bc642fc9565a8b6c5fc4
GitHub-Last-Rev: e2213b738832f1674948d6507f40e2c0b98cb972
GitHub-Pull-Request: golang/go#62503
Reviewed-on: https://go-review.googlesource.com/c/go/+/526496
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/compile/internal/inline/inlheur: delete ConstExpr case
Dmitri Shuralyov [Fri, 8 Sep 2023 23:28:58 +0000 (19:28 -0400)]
cmd/compile/internal/inline/inlheur: delete ConstExpr case

ir.ConstExpr was deleted in CL 526395, so no need to check for it.
Fixes the build error.

Change-Id: I642dab70d17369bc7c9ae880666ef42ff099b770
Reviewed-on: https://go-review.googlesource.com/c/go/+/526196
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agoRevert "cmd/cgo: silence unaligned-access"
Than McIntosh [Fri, 8 Sep 2023 23:07:12 +0000 (23:07 +0000)]
Revert "cmd/cgo: silence unaligned-access"

This reverts commit http://go.dev/cl/c/go/+/526915

Reason for revert: darwin builders unhappy with '-Wunaligned-access' C compiler flag

Change-Id: I5e6ca7c9a0ca08b7e758b7f603da70a2fca79b58
Reviewed-on: https://go-review.googlesource.com/c/go/+/526978
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoruntime: test change to adapt to new inliner
Than McIntosh [Mon, 14 Aug 2023 13:41:43 +0000 (09:41 -0400)]
runtime: test change to adapt to new inliner

The new inliner tries to de-prioritize inlining of call sites on panic
paths, e.g. for a call such as the one to "foo" below, the inliner
will use a much lower size threshold when deciding whether to inline,
since the path is very likely to be "cold".

   if mumble() {
      foo()           <<-- here
      panic("bad")
   }

This patch reworks one of the traceback tests is relying on the old
inliner's "inline F everywhere if F inlinable" strategy by tweaking
the code slightly (no change in test functionality).

Change-Id: I83a686b0cc4d94a6cfc63d1e84e45455c1afd5b9
Reviewed-on: https://go-review.googlesource.com/c/go/+/519196
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/compile/internal/inline/inlheur: assign scores to callsites
Than McIntosh [Tue, 18 Jul 2023 20:17:12 +0000 (16:17 -0400)]
cmd/compile/internal/inline/inlheur: assign scores to callsites

Assign scores to callsites based on previously computed function
properties and callsite properties. This currently works by taking the
size score for the function (as computed by CanInline) and then making
a series of adjustments, positive or negative based on various
function and callsite properties.

NB: much work also remaining on deciding what are the best score
adjustment values for specific heuristics. I've picked a bunch of
arbitrary constants, but they will almost certainly need tuning and
tweaking to arrive at something that has good performance.

Updates #61502.

Change-Id: I887403f95e76d7aa2708494b8686c6026861a6ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/511566
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/inline: add call site flag generation
Than McIntosh [Tue, 18 Jul 2023 15:45:42 +0000 (11:45 -0400)]
cmd/compile/internal/inline: add call site flag generation

Add code to detect call sites that are nested in loops, call sites
that are on an unconditional path to panic/exit, and call sites within
"init" functions. The panic-path processing reuses some of the
logic+state already present for the function flag version of "calls
panic/exit".

Updates #61502.

Change-Id: I1d728e0763282d3616a9cbc0a07c5cda115660f3
Reviewed-on: https://go-review.googlesource.com/c/go/+/511565
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/inline: build call site table
Than McIntosh [Wed, 12 Jul 2023 20:13:39 +0000 (16:13 -0400)]
cmd/compile/internal/inline: build call site table

Build up a table of (potentially) inlinable call sites during inline
heuristic analysis, and introduce a framework for analyzing each call
site to collect applicable flags (for example, is call nested in
loop). This patch doesn't include any of the flag analysis, just the
machinery to collect the callsites and a regression test harness.

Updates #61502.

Change-Id: Ieaf4a008ac9868e9762c63f5b59bd264dc71ab30
Reviewed-on: https://go-review.googlesource.com/c/go/+/511564
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/inline: extend flag calculation via export data
Than McIntosh [Tue, 11 Jul 2023 16:42:12 +0000 (12:42 -0400)]
cmd/compile/internal/inline: extend flag calculation via export data

Extend the code that computes various properties and parameter flags
to incorporate information from export data in addition to things we
can get from the current package. Specifically:

 - when deciding whether the current function always calls panic/exit,
   check to see whether it has an unconditional call to some other
   function that has that flag.

 - when computing "parameter feeds" properties, look not just for
   cases where a parameter feeds an interesting construct (if/switch,
   indirect/interface call, etc) but where it feeds a call whose
   corresponding param has that flag.

 - when computing return properties, if a given return is always the
   results of a call to X, then set the return properties to those
   of X.

Updates #61502.

Change-Id: I6472fe98759cccad05b8eed58e4fc568201d88ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/511563
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile: write "properties" to export data for inlinable funcs
Than McIntosh [Thu, 29 Jun 2023 17:22:26 +0000 (13:22 -0400)]
cmd/compile: write "properties" to export data for inlinable funcs

Augment the ir.Inline container to include an entry for function
properties (currently serialized as a string), and if
GOEXPERIMENT=newinliner is set, compute and store function
properties for all inline candidates processed by the inliner.

The idea here is that if the function properties are going to drive
inlining decisions, we'd like to have the same info from non-local /
imported functions as for local / in-package functions, hence we need
to include the properties in the export data.

Hand testing on the compiler itself and with k8s kubelet shows that
this increases the size of export data overall by about 2-3 percent,
so a pretty modest increase.

Updates #61502.

Change-Id: I9d1c311aa8418d02ffea3629c3dd9d8076886d15
Reviewed-on: https://go-review.googlesource.com/c/go/+/511562
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/compile/internal/inline: analyze function param properties
Than McIntosh [Fri, 30 Jun 2023 20:44:31 +0000 (16:44 -0400)]
cmd/compile/internal/inline: analyze function param properties

Add code to analyze properties of function params, specifically
heuristics to look for cases where unmodified params feed into "if"
and "switch" statements in ways that might enable constant folding
and/or dead code elimination if the call were inlined at a callsite
that passes a constant to the correct param. We also look for cases
where a function parameter feeds unmodified into an interface method
call or indirect call.

Updates #61502.

Change-Id: Iaf7297e19637daeabd0ec72be88d654b545546ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/511561
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/cgo: silence unaligned-access
Egon Elbre [Fri, 8 Sep 2023 08:17:59 +0000 (11:17 +0300)]
cmd/cgo: silence unaligned-access

Clang 14+ introduced a warning when using mixed packed and unpacked structs.
This can cause problems when taking an address of the unpacked struct, which
may end up having a different alignment than expected.

This is not a problem in cgo, which does not take pointers from the packed
struct.

Fixes #62480

Change-Id: If5879eea5e1b77bc6dc7430f68f8c916bff9b090
Reviewed-on: https://go-review.googlesource.com/c/go/+/526915
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agonet: synchronize calls to Close in the withTCPConnPair test helper
Bryan C. Mills [Fri, 8 Sep 2023 20:39:17 +0000 (16:39 -0400)]
net: synchronize calls to Close in the withTCPConnPair test helper

withTCPConnPair is supposed to return only when both peer functions
have completed. However, due to the use of "defer" it was closing the
peers' connections after the synchronization point instead of before.

Fixes #62542.

Change-Id: I3e06c78984664172ff2d28b0fc582b8182f710f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/526977
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Commit-Queue: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agotesting/slogtest: add Run to run cases as subtests
Jonathan Amsterdam [Fri, 4 Aug 2023 17:33:35 +0000 (13:33 -0400)]
testing/slogtest: add Run to run cases as subtests

This is an implementation of proposal #61758.

It adds a function to slogtest that runs each test case in a subtest,
instead of running them all at once.

That allows the caller to control which cases are run.

Fixes #61706.
Fixes #61758.

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

9 months agoruntime: dump rdx on windows
Michael Pratt [Fri, 8 Sep 2023 20:12:44 +0000 (16:12 -0400)]
runtime: dump rdx on windows

CL 177090043 accidentally dropped RDX when converting from C.

Change-Id: I6bf9dc1b1d0c2850967005c048245d1185dcede4
Reviewed-on: https://go-review.googlesource.com/c/go/+/526976
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

9 months agoruntime: unskip TestG0StackOverflow
Cherry Mui [Mon, 28 Aug 2023 18:59:13 +0000 (14:59 -0400)]
runtime: unskip TestG0StackOverflow

The stack bounds from pthread are not always accurate, and could
cause seg fault if we run out of the actual stack space before
reaching the bounds. Here we use an artificially small stack bounds
to check overflow without actually running out of the system stack.

Change-Id: I8067c5e1297307103b315d9d0c60120293b57aab
Reviewed-on: https://go-review.googlesource.com/c/go/+/523695
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/ssa: replace Frontend.Auto with Func.NewLocal
Matthew Dempsky [Thu, 7 Sep 2023 05:42:11 +0000 (22:42 -0700)]
cmd/compile/internal/ssa: replace Frontend.Auto with Func.NewLocal

Change-Id: I0858568d225daba1c318842dc0c9b5e652dff612
Reviewed-on: https://go-review.googlesource.com/c/go/+/526519
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agocmd/compile/internal/ssagen: call AllocFrame after ssa.Compile
Matthew Dempsky [Thu, 7 Sep 2023 05:33:24 +0000 (22:33 -0700)]
cmd/compile/internal/ssagen: call AllocFrame after ssa.Compile

This indirection is no longer necessary.

Change-Id: Ibb5eb1753febdc17a93ea9c35130e3d2b26c360e
Reviewed-on: https://go-review.googlesource.com/c/go/+/526518
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agoencoding: modernize Go documentation
Joe Tsai [Fri, 1 Sep 2023 08:54:25 +0000 (01:54 -0700)]
encoding: modernize Go documentation

Across all encoding packages, linkify declarations if possible.
In some cases, we convert a code block into a bulleted list,
which then further allows for more linkification.

Change-Id: I68fedf362615b34228bab5d4859b7d87d831c570
Reviewed-on: https://go-review.googlesource.com/c/go/+/524977
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/compile/internal/ssa: rename ssagen.TypeOK as CanSSA
Matthew Dempsky [Thu, 7 Sep 2023 05:03:07 +0000 (22:03 -0700)]
cmd/compile/internal/ssa: rename ssagen.TypeOK as CanSSA

No need to indirect through Frontend for this.

Change-Id: I5812eb4dadfda79267cabc9d13aeab126c1479e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/526517
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/ssa: remove Frontend.MyImportPath
Matthew Dempsky [Thu, 7 Sep 2023 04:48:28 +0000 (21:48 -0700)]
cmd/compile/internal/ssa: remove Frontend.MyImportPath

This method is only used to find the path of the function being
compiled for hash debugging, but it was instead returning the path of
the package being compiled. These are typically the same, but can be
different for certain functions compiled across package boundaries
(e.g., method value wrappers and generic functions).

It's redundant either with f.fe.Func().Sym().Pkg.Path (package path of
the function being compiled) or f.Config.ctxt.Pkgpath (package path of
the compilation unit), so just remove it instead.

Change-Id: I1daae09055043d0ecb1fcc874a0b0006a6f8bddf
Reviewed-on: https://go-review.googlesource.com/c/go/+/526516
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agocmd/compile/internal/ssa: simplify NewFunc API
Matthew Dempsky [Thu, 7 Sep 2023 04:43:58 +0000 (21:43 -0700)]
cmd/compile/internal/ssa: simplify NewFunc API

Add Config and Cache as params rather than documenting that the caller
has to set them manually.

Change-Id: I8d530be695a0c94bcc4211b496d6e57ec2fff029
Reviewed-on: https://go-review.googlesource.com/c/go/+/526515
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocmd/compile: cleanup uses of ir.Orig and ir.SepCopy
Matthew Dempsky [Wed, 6 Sep 2023 23:11:34 +0000 (16:11 -0700)]
cmd/compile: cleanup uses of ir.Orig and ir.SepCopy

Mostly automated refactoring with gofmt:

gofmt -r 'ir.Orig(n) -> n'
gofmt -r 'ir.SepCopy(n) -> ir.Copy(n)'

Followed by some manual cleanups.

Change-Id: Ib35abeba9e60b70ba463e161fb39358fb058a83e
Reviewed-on: https://go-review.googlesource.com/c/go/+/526398
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/ir: remove OrigNode
Matthew Dempsky [Wed, 6 Sep 2023 23:05:11 +0000 (16:05 -0700)]
cmd/compile/internal/ir: remove OrigNode

The OrigNode functionality used to be relevant to the typecheck
frontend, because we wanted to report errors using the same syntax as
the user originally wrote. However, now that types2 handles all
spec-required error diagnostics, there's no need to preserve original
nodes anymore.

Change-Id: I64a0540b8952513913021e7b84d165beb1f9f801
Reviewed-on: https://go-review.googlesource.com/c/go/+/526397
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile/internal/ir: simplify formatting of CompLitExpr
Matthew Dempsky [Wed, 6 Sep 2023 23:03:38 +0000 (16:03 -0700)]
cmd/compile/internal/ir: simplify formatting of CompLitExpr

Composite literals always have a type now, so the extra fallback code
isn't necessary. But also, to prepare for the upcoming removal of
OrigNode, we need to print OSLICELIT with Implicit set as
"... argument" to satisfy existing regress tests.

Change-Id: I365e879066903eebf1b78e10c1b505565cea3ce3
Reviewed-on: https://go-review.googlesource.com/c/go/+/526396
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agocmd/internal/ir: remove ConstExpr in favor of BasicLit
Matthew Dempsky [Wed, 6 Sep 2023 22:52:55 +0000 (15:52 -0700)]
cmd/internal/ir: remove ConstExpr in favor of BasicLit

OrigNode will be going away soon, which is the only reason for
ConstExpr to exist. Otherwise, it's identical to BasicLit.

To keep existing code working, change NewConstExpr to construct and
return a BasicLit instead.

Change-Id: I68b43ec1fcaa57e6723f289ce9f953996aeefb14
Reviewed-on: https://go-review.googlesource.com/c/go/+/526395
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/compile/internal/noder: stop preserving original const strings
Matthew Dempsky [Wed, 6 Sep 2023 21:00:30 +0000 (14:00 -0700)]
cmd/compile/internal/noder: stop preserving original const strings

One of the more tedious quirks of the original frontend (i.e.,
typecheck) to preserve was that it preserved the original
representation of constants into the backend. To fit into the unified
IR model, I ended up implementing a fairly heavyweight workaround:
simply record the original constant's string expression in the export
data, so that diagnostics could still report it back, and match the
old test expectations.

But now that there's just a single frontend to support, it's easy
enough to just update the test expectations and drop this support for
"raw" constant expressions.

Change-Id: I1d859c5109d679879d937a2b213e777fbddf4f2f
Reviewed-on: https://go-review.googlesource.com/c/go/+/526376
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agoruntime: increase g0 stack size in non-cgo case
Cherry Mui [Fri, 8 Sep 2023 16:14:30 +0000 (12:14 -0400)]
runtime: increase g0 stack size in non-cgo case

Currently, for non-cgo programs, the g0 stack size is 8 KiB on
most platforms. With PGO which could cause aggressive inlining in
the runtime, the runtime stack frames are larger and could
overflow the 8 KiB g0 stack. Increase it to 16 KiB. This is only
one per OS thread, so it shouldn't increase memory use much.

Fixes #62120.
Fixes #62489.

Change-Id: I565b154517021f1fd849424dafc3f0f26a755cac
Reviewed-on: https://go-review.googlesource.com/c/go/+/526995
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/internal/obj: mark unspill code in prologue preemptible
zhouguangyuan [Wed, 6 Sep 2023 16:09:31 +0000 (00:09 +0800)]
cmd/internal/obj: mark unspill code in prologue preemptible

The UnspillReg code should always be preemptible because all the arg registers will be saved by runtime.asyncpreempt.

Change-Id: Ie36b5d0cdd1275efcb95661354d83be2e1b00a86
Reviewed-on: https://go-review.googlesource.com/c/go/+/526235
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agosyscall: skip unshare tests if mount syscall is not available
Dmitri Shuralyov [Fri, 8 Sep 2023 00:21:44 +0000 (20:21 -0400)]
syscall: skip unshare tests if mount syscall is not available

CL 513779 added crude skips for tests that couldn't work when run under
'unshare --net --map-root-user' as used by the current iteration of the
no-network check in LUCI. Bryan suggested a more targeted way to detect
when the environment is insufficient, which makes it possible to remove
the builder-specific skip and its slightly incorrect explaining comment.

Updates #30612.

Change-Id: I0de79f44ab94d7f1018384c2e959ca7df3a1b0ae
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-amd64-longtest-race
Reviewed-on: https://go-review.googlesource.com/c/go/+/526835
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agoruntime: support for debugger function calls on linux/ppc64le
Archana [Mon, 24 Jul 2023 14:47:02 +0000 (20:17 +0530)]
runtime: support for debugger function calls on linux/ppc64le

This CL adds support for debugger function calls on linux ppc64le
platform. The protocol is basically the same as in CL 395754, except for
the following differences:
1, The abi differences which affect parameter passing and frame layout.
2, The closure register is R11.
3, Minimum framesize on pp64le is 32 bytes
4, Added functions to return parent context structure for general purpose
   registers in order to work with the way these structures are defined in
   ppc64le

Change-Id: I58e01fedad66a818ab322e2b2d8f5104cfa64f39
Reviewed-on: https://go-review.googlesource.com/c/go/+/512575
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Archana Ravindar <aravinda@redhat.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agofmt: adjust comment after CL 524940
Daniel Martí [Thu, 7 Sep 2023 07:42:50 +0000 (08:42 +0100)]
fmt: adjust comment after CL 524940

https://go.dev/cl/524940 swapped a call to Slice with Bytes,
but the comment below still referenced Slice.

Change-Id: Iedc772e1c49c4108bcd06f4cea0e637f011d053c
Reviewed-on: https://go-review.googlesource.com/c/go/+/526356
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: t hepudds <thepudds1460@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agodebug/elf,cmd/link: add additional MIPS64 relocation type
Joel Sing [Sat, 18 Feb 2023 05:41:25 +0000 (16:41 +1100)]
debug/elf,cmd/link: add additional MIPS64 relocation type

Add R_MIPS_PC32 which is a 32 bit PC relative relocation.

These are produced by LLVM on mips64.

Fixes #61974

Change-Id: I7b6c6848e40249e6d5ea474ea53c9d7e3ab23f88
Reviewed-on: https://go-review.googlesource.com/c/go/+/469395
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Junxian Zhu <zhujunxian@oss.cipunited.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/internal/obj/riscv: clean up error checking for encoding
Joel Sing [Sun, 27 Aug 2023 14:13:34 +0000 (00:13 +1000)]
cmd/internal/obj/riscv: clean up error checking for encoding

Replace a "fixme" with a more appropriate error. Also invert the condition
so that the error returns early, which is more Go idiomatic.

Change-Id: I03006572c4010fb47037bed3ee1fd7f92bfc20d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/523457
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: M Zhuo <mzh@golangcn.org>
9 months agocmd/internal/obj/riscv: correct message in regVal panic
Joel Sing [Sun, 27 Aug 2023 16:08:06 +0000 (02:08 +1000)]
cmd/internal/obj/riscv: correct message in regVal panic

Change-Id: I68be4110216145ad1fb2e5095e1f2b143f9e69ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/523456
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: M Zhuo <mzh@golangcn.org>
Run-TryBot: Joel Sing <joel@sing.id.au>

9 months agocmd/internal/obj/riscv: simplify instructionsForMOV
Joel Sing [Sun, 27 Aug 2023 16:14:22 +0000 (02:14 +1000)]
cmd/internal/obj/riscv: simplify instructionsForMOV

Rather than handling shift based scaling in two locations, rework logic
so there is a single exit path.

Change-Id: I832b4932d53183736050059a11019ced08281b3b
Reviewed-on: https://go-review.googlesource.com/c/go/+/523455
Reviewed-by: M Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/api: don't try to parse JSON from stderr of go list
Ian Lance Taylor [Thu, 7 Sep 2023 20:57:23 +0000 (13:57 -0700)]
cmd/api: don't try to parse JSON from stderr of go list

Just send the go list stderr to our stderr.

Change-Id: Iacda573bbe7accbcecb6a957e5d42b55afd10c58
Reviewed-on: https://go-review.googlesource.com/c/go/+/526775
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agoruntime: support nil libcall.args when calling stdcall on Windows
qmuntal [Thu, 7 Sep 2023 09:09:10 +0000 (11:09 +0200)]
runtime: support nil libcall.args when calling stdcall on Windows

Having to pass a dummy pointer to the libcall.args field is a bit
annoying. This change allows nil to be passed instead.

windows/arm and windows/arm64 already support nil libcall.args.

Change-Id: I07a2bdb7d1f76b13d125397ff5177337c43536a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/526016
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agosyscall: remove unused ptracePtr on darwin
Tobias Klauser [Thu, 7 Sep 2023 20:51:39 +0000 (22:51 +0200)]
syscall: remove unused ptracePtr on darwin

ptracePtr was introduced in CL 470299 for darwin but it's not used on
this platform. Also, the argument types for addr and data were swapped
in the generated ptrace1Ptr (probably because the change was not
generated but done manually).

For #58387

Change-Id: I429ab0c741e19020d98729c34efabce1d9003f56
Reviewed-on: https://go-review.googlesource.com/c/go/+/526475
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/link/internal/loong64: correct the glibc dynamic linker path.
limeidan [Wed, 6 Sep 2023 09:09:35 +0000 (17:09 +0800)]
cmd/link/internal/loong64: correct the glibc dynamic linker path.

Ref: https://loongson.github.io/LoongArch-Documentation/LoongArch-ELF-ABI-EN.html#_program_interpreter_path

Change-Id: Ic2598110cc091362cb09f877b6b86433cacf32c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/526535
Reviewed-by: Ian Lance Taylor <iant@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>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agoencoding/xml: use reflect.Value.Bytes on addressable arrays
Daniel Martí [Thu, 7 Sep 2023 09:29:14 +0000 (10:29 +0100)]
encoding/xml: use reflect.Value.Bytes on addressable arrays

Since #47066 was accepted and implemented,
reflect.Value.Bytes can be called directly on addressable arrays,
so there is no longer a need to go through a slice first.

Change-Id: I04d50ddb1b38e7a37fee3dc8be1bd03b22a06a1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/526357
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/internal/obj/ppc64: do not assemble non-constant rotate RLWMI
Paul E. Murphy [Fri, 11 Nov 2022 14:38:50 +0000 (08:38 -0600)]
cmd/internal/obj/ppc64: do not assemble non-constant rotate RLWMI

Unlike RLWNM, the ISA only supports an immediate rotate operand.

Update optab and opirrr to avoid quietly assembling this insn.

Change-Id: I1472a431cb8a870d55d5fff79ab905c4c459f630
Reviewed-on: https://go-review.googlesource.com/c/go/+/449835
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agosyscall: improve linux SysProcAttr documentation
Kir Kolyshkin [Sun, 3 Sep 2023 20:49:10 +0000 (13:49 -0700)]
syscall: improve linux SysProcAttr documentation

The SysProcAttr is OS-specific anyway, so it makes little sense to say
that some fields are Linux-specific (they all are anyway).

While at it, make sure to use complete sentences (add missing periods).

Change-Id: Ic0afe3920c2561fd9a657f4edab21939a8f56d57
Reviewed-on: https://go-review.googlesource.com/c/go/+/525395
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/doc: print bugs with -all flag
Pascal S. de Kloe [Fri, 21 Jul 2023 12:03:49 +0000 (14:03 +0200)]
cmd/doc: print bugs with -all flag

Includes cleanup and deduplication.

fixes: #33970

Change-Id: I7e84b3e5c8fb9c560cf0a1f8b7cbb7a6977666aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/511935
Reviewed-by: Rob Pike <r@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agosyscall: add support to get pidfd from ForkExec on Linux
Kir Kolyshkin [Thu, 17 Aug 2023 02:20:54 +0000 (19:20 -0700)]
syscall: add support to get pidfd from ForkExec on Linux

Add PidFD support, so that if the PidFD pointer in SysProcAttr is not
nil, ForkExec (and thus all its users) obtains a pidfd from the kernel
during clone(), and writes the result (or -1, if the functionality
is not supported by the kernel) into *PidFD.

The functionality to get pidfd is implemented for both clone3 and clone.
For the latter, an extra argument to rawVforkSyscall is needed, thus the
change in asm files.

Add a trivial test case checking the obtained pidfd can be used to send
a signal to a process, using pidfd_send_signal. To test clone3 code path,
add a flag available to tests only.

Updates #51246.

Change-Id: I2212b69e1a657163c31b4a6245b076bc495777a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/520266
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>

9 months agoencoding/gob: fix typo in comment for decAlloc
Jes Cok [Mon, 28 Aug 2023 12:41:02 +0000 (12:41 +0000)]
encoding/gob: fix typo in comment for decAlloc

Change-Id: I89c607ee40358d6d650ba0ea1f05ce7d1df698bd
GitHub-Last-Rev: e78a37118009dbd9468a0f656ad66b989f7c5ada
GitHub-Pull-Request: golang/go#62319
Reviewed-on: https://go-review.googlesource.com/c/go/+/523376
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoencoding/gob: make comment more idiomatic for *Encoder.writer
Jes Cok [Thu, 31 Aug 2023 11:58:16 +0000 (11:58 +0000)]
encoding/gob: make comment more idiomatic for *Encoder.writer

Change-Id: I89a4d7f4af8dfb67a35647283be6c1d2965595f5
GitHub-Last-Rev: f7c11c156cd0c1d7e9e811c5eb2d19d233c568dd
GitHub-Pull-Request: golang/go#62389
Reviewed-on: https://go-review.googlesource.com/c/go/+/524735
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Rob Pike <r@golang.org>
9 months agoencoding/gob: swap 'err, i' to correct verbs in decUint8Slice
Jes Cok [Wed, 30 Aug 2023 12:00:03 +0000 (12:00 +0000)]
encoding/gob: swap 'err, i' to correct verbs in decUint8Slice

Change-Id: I76b2dd45179f65e9ed4f1d0f597ca59e49b59a85
GitHub-Last-Rev: b4171e6b836f948ff2973d91a19f0fd58cc8faea
GitHub-Pull-Request: golang/go#62374
Reviewed-on: https://go-review.googlesource.com/c/go/+/524356
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Rob Pike <r@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoall: use io.{SeekStart, SeekCurrent, SeekEnd}
Jes Cok [Wed, 30 Aug 2023 04:57:57 +0000 (04:57 +0000)]
all: use io.{SeekStart, SeekCurrent, SeekEnd}

Currently we include these symbols in bootstrap code.

Change-Id: I19b504237b0344f0e87cda0fbe651811c72daba1
GitHub-Last-Rev: 5134baec387659c5e2ca8c4fc65a5e73c07f00ce
GitHub-Pull-Request: golang/go#62368
Reviewed-on: https://go-review.googlesource.com/c/go/+/524258
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agoruntime: remove slow time compatibility hacks for wine
qmuntal [Thu, 7 Sep 2023 14:02:11 +0000 (16:02 +0200)]
runtime: remove slow time compatibility hacks for wine

This reapplies CL 191759, which was reverted in CL 192622.

Wine fixed the compatibility issue more than 3 years
ago, in version 5.10 (see [1]). We no longer have to keep the compatibility hack on our side.

Updates #34021

[1]: https://github.com/wine-mirror/wine/commit/1ae10889647c1c84c36660749508a42e99e64a5e

Change-Id: I3b77701d01fdf58fbf350321fc0a957c0f247d32
Reviewed-on: https://go-review.googlesource.com/c/go/+/526358
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agolog/slog: use the general regex expression of datetime in TestPanics
Andy Pan [Tue, 5 Sep 2023 11:32:49 +0000 (19:32 +0800)]
log/slog: use the general regex expression of datetime in TestPanics

When I added this test in CL 514135, I missed the timeRE,
we should use it to make this test more precise.

Change-Id: I486f8e8bbbc3a17166107ef361d242ddf4ea2928
Reviewed-on: https://go-review.googlesource.com/c/go/+/525556
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agosync: deemphasize goroutines in RWMutex documentation
qiulaidongfeng [Tue, 15 Aug 2023 02:13:47 +0000 (02:13 +0000)]
sync: deemphasize goroutines in RWMutex documentation

Fixes #41555

Change-Id: I46b9535b1687d481d2ac76296e8ba7de26d6e2e2

Change-Id: I46b9535b1687d481d2ac76296e8ba7de26d6e2e2
GitHub-Last-Rev: 38af46c18922eea80e05c8ed9f5e10002ab7244d
GitHub-Pull-Request: golang/go#61977
Reviewed-on: https://go-review.googlesource.com/c/go/+/518859
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>

9 months agonet: remove unused _C_GoString
Tobias Klauser [Wed, 6 Sep 2023 16:31:00 +0000 (18:31 +0200)]
net: remove unused _C_GoString

It's unused since CL 466335.

Change-Id: I2750f478bd2a1cde270a6273551e1434cb38b5ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/526076
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoruntime: always lock OS thread in debugcall
Michael Anthony Knyszek [Thu, 3 Aug 2023 20:53:52 +0000 (20:53 +0000)]
runtime: always lock OS thread in debugcall

Right now debuggers like Delve rely on the new goroutine created to run
a debugcall function to run on the same thread it started on, up until
it hits itself with a SIGINT as part of the debugcall protocol.

That's all well and good, except debugCallWrap1 isn't particularly
careful about not growing the stack. For example, if the new goroutine
happens to have a stale preempt flag, then it's possible a stack growth
will cause a roundtrip into the scheduler, possibly causing the
goroutine to switch to another thread.

Previous attempts to just be more careful around debugCallWrap1 were
helpful, but insufficient. This change takes everything a step further
and always locks the debug call goroutine and the new goroutine it
creates to the OS thread.

For #61732.

Change-Id: I038f3a4df30072833e27e6a5a1ec01806a32891f
Reviewed-on: https://go-review.googlesource.com/c/go/+/515637
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agocmd/compile: absorb InvertFlags into Noov comparisons
Keith Randall [Wed, 6 Sep 2023 20:06:58 +0000 (13:06 -0700)]
cmd/compile: absorb InvertFlags into Noov comparisons

Unfortunately, there isn't a single op that provides the resulting
computation.
At least, I couldn't find one.

Fixes #62469

Change-Id: I236f3965b827aaeb3d70ef9fe89be66b116494f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/526276
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>