]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
9 months agocmd/compile/internal/typecheck: push ONEW into go/defer wrappers
Matthew Dempsky [Thu, 17 Aug 2023 05:37:42 +0000 (22:37 -0700)]
cmd/compile/internal/typecheck: push ONEW into go/defer wrappers

Currently, we rewrite:

go f(new(T))

into:

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

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

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

This CL does that.

Change-Id: Iae16a476368da35123052ca9ff41c49159980458
Reviewed-on: https://go-review.googlesource.com/c/go/+/520340
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/compile/internal/typecheck: normalize go/defer statements earlier
Matthew Dempsky [Wed, 16 Aug 2023 21:39:47 +0000 (14:39 -0700)]
cmd/compile/internal/typecheck: normalize go/defer statements earlier

Normalizing go/defer statements to always use functions with zero
parameters and zero results was added to escape analysis, because that
was the earliest point at which all three frontends converged. Now
that we only have the unified frontend, we can do it during typecheck,
which is where we perform all other desugaring and normalization
rewrites.

Change-Id: Iebf7679b117fd78b1dffee2974bbf85ebc923b23
Reviewed-on: https://go-review.googlesource.com/c/go/+/520260
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile/internal/noder: remove inlined closure naming hack
Matthew Dempsky [Thu, 17 Aug 2023 04:16:29 +0000 (21:16 -0700)]
cmd/compile/internal/noder: remove inlined closure naming hack

I previously used a clumsy hack to copy Closgen back and forth while
inlining, to handle when an inlined function contains closures, which
need to each be uniquely numbered.

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

Change-Id: I510553b5d7a8f6581ea1d21604e834fd6338cb06
Reviewed-on: https://go-review.googlesource.com/c/go/+/520339
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agocmd/compile: cleanup Func construction
Matthew Dempsky [Thu, 17 Aug 2023 02:45:12 +0000 (19:45 -0700)]
cmd/compile: cleanup Func construction

This CL moves more common Func-setup logic into ir.NewFunc. In
particular, it now handles constructing the Name and wiring them
together, setting the Typecheck bit, and setting Sym.Func.

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

Change-Id: Ifa0aded8df0517188eb295d0dccc107af85f1e8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/520338
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/compile: always construct typechecked closures
Matthew Dempsky [Thu, 17 Aug 2023 01:56:41 +0000 (18:56 -0700)]
cmd/compile: always construct typechecked closures

This CL extends ir.NewClosureFunc to take the signature type argument,
and to handle naming the closure and adding it to typecheck.Target.

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

Change-Id: Iabde4557d33051ee470a3bc4fd49599490024cba
Reviewed-on: https://go-review.googlesource.com/c/go/+/520337
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agocmd/compile/internal/ir: add typ parameter to NewNameAt
Matthew Dempsky [Thu, 17 Aug 2023 00:23:52 +0000 (17:23 -0700)]
cmd/compile/internal/ir: add typ parameter to NewNameAt

Start making progress towards constructing IR with proper types.

Change-Id: Iad32c1cf60f30ceb8e07c31c8871b115570ac3bd
Reviewed-on: https://go-review.googlesource.com/c/go/+/520263
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agolog/slog: simplify and optimize RFC3339 handling
Joe Tsai [Thu, 23 Mar 2023 08:01:46 +0000 (01:01 -0700)]
log/slog: simplify and optimize RFC3339 handling

In CL 421877 and CL 444278, time.Time.AppendFormat has been
specially optimized for the time.RFC3339Nano representation.
Relying on that optimization and modify the output to obtain the
fixed-width millisecond resolution that slog uses.

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

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

Change-Id: I61e8f4476c111443e3e2098a45b2c21a76137345
Reviewed-on: https://go-review.googlesource.com/c/go/+/478757
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>

9 months agomath/big, math/rand: use the built-in max function
chanxuehong [Thu, 17 Aug 2023 01:58:22 +0000 (01:58 +0000)]
math/big, math/rand: use the built-in max function

Change-Id: I71a38dd20bfaf2b1aed18892d54eeb017d3d7d66
GitHub-Last-Rev: 8da43b2cbd563ed123690709e519c9f84272b332
GitHub-Pull-Request: golang/go#61955
Reviewed-on: https://go-review.googlesource.com/c/go/+/518595
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
9 months agocmd/compile/internal/ir: remove ODCLCONST and ODCLTYPE
Matthew Dempsky [Thu, 17 Aug 2023 00:29:41 +0000 (17:29 -0700)]
cmd/compile/internal/ir: remove ODCLCONST and ODCLTYPE

These aren't constructed by the unified frontend.

Change-Id: Ied87baa9656920bd11055464bc605933ff448e21
Reviewed-on: https://go-review.googlesource.com/c/go/+/520264
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile/internal/escape: optimize indirect closure calls
Matthew Dempsky [Tue, 15 Aug 2023 23:45:52 +0000 (16:45 -0700)]
cmd/compile/internal/escape: optimize indirect closure calls

This CL extends escape analysis in two ways.

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

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

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

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

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

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

Updates #2205.

Change-Id: I610f9c531e135129c947684833e288ce64406f35
Reviewed-on: https://go-review.googlesource.com/c/go/+/520259
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agofmt: amend comment for getField
Jes Cok [Wed, 16 Aug 2023 10:53:49 +0000 (10:53 +0000)]
fmt: amend comment for getField

Change-Id: I52c9ed0c1a178f3ae3eb4f135d8f11018075fe3b
GitHub-Last-Rev: 407aa89c88fc7bb3e4ad9ef55c2a0c5c2f92642c
GitHub-Pull-Request: golang/go#62061
Reviewed-on: https://go-review.googlesource.com/c/go/+/519935
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agosyscall: don't check non-existent return code in GetStartupInfo
Tobias Klauser [Wed, 16 Aug 2023 22:03:13 +0000 (00:03 +0200)]
syscall: don't check non-existent return code in GetStartupInfo

Fixes #31316

Change-Id: I1ca5968836e7bcad91496e4ed3cf1a0caf1375f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/520275
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agoencoding: reject negative runes in Encoding.WithPadding
Joe Tsai [Thu, 22 Jun 2023 18:03:17 +0000 (11:03 -0700)]
encoding: reject negative runes in Encoding.WithPadding

A negative rune (other than NoPadding) makes no semantic sense.
Doing so relies on integer overflow of converting a rune to a byte
and would thus be equivalent to passing the positive byte value
of byte(padding).

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

Change-Id: I02499705519581598adc0c8525d90e25278dc056
Reviewed-on: https://go-review.googlesource.com/c/go/+/505236
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agoio: reduce allocations in Pipe constructor
Joe Tsai [Sun, 5 Mar 2023 03:53:14 +0000 (19:53 -0800)]
io: reduce allocations in Pipe constructor

Rather than having PipeWriter and PipeReader a wrapper type on pipe,
make them have the same underlying memory representation and
rely instead of simply casting the same *pipe pointer
as either a *PipeReader or *PipeWriter to control the set of methods.

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

Change-Id: I09207a00c4b7afb44c7773d752c5628a07e24fda
Reviewed-on: https://go-review.googlesource.com/c/go/+/473535
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoencoding: add AppendEncode and AppendDecode
Joe Tsai [Mon, 20 Feb 2023 07:19:20 +0000 (23:19 -0800)]
encoding: add AppendEncode and AppendDecode

Implement append-like equivalent of Encode and Decode functions.

Fixes #53693

Change-Id: I79d8d834e3c8f77fad32be2fd391e33d4d1527ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/504884
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>

9 months agofmt: fix receiver names are different
ch3nnn [Wed, 16 Aug 2023 12:28:11 +0000 (12:28 +0000)]
fmt: fix receiver names are different

"buffer" call the receiver "b" in other method, don't call it "bp" in
another. Keep the same receiver names, as prescribed in Go Code Review
Comments (https://go.dev/s/style#receiver-names).

Change-Id: I9fafc799a9e4102419ed743b941bca74e908f5c0
GitHub-Last-Rev: c8b851d372f3966e3c5eec7c331ad05aacb1ebda
GitHub-Pull-Request: golang/go#62066
Reviewed-on: https://go-review.googlesource.com/c/go/+/520016
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agocmd: go get golang.org/x/tools@74c255b and revendor
Cuong Manh Le [Thu, 17 Aug 2023 08:30:04 +0000 (15:30 +0700)]
cmd: go get golang.org/x/tools@74c255b and revendor

go get golang.org/x/tools@74c255b # CL 519295
go mod tidy
go mod vendor

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

Updates #61035

Change-Id: Ifb04bab060343b6a849980db6bb65da9889b4665
Reviewed-on: https://go-review.googlesource.com/c/go/+/520435
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/compile/internal/escape: change escapes and persists into bitset
Matthew Dempsky [Tue, 15 Aug 2023 21:20:50 +0000 (14:20 -0700)]
cmd/compile/internal/escape: change escapes and persists into bitset

This CL introduces a locAttr bitset type, which will make it easier to
add additional attributes in the near future.

Change-Id: I2689aa623097279dc1e7b7cf2adf5184d710c5a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/520258
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agocmd/compile/internal/escape: flip transient to !persists
Matthew Dempsky [Tue, 15 Aug 2023 21:02:37 +0000 (14:02 -0700)]
cmd/compile/internal/escape: flip transient to !persists

I want to add more location properties (e.g., to track indirect stores
and calls), and it's easier to reason about them if they're all
consistent that "true" means more consequences than less.

Change-Id: I3f8674bb11877ba33082a0f5f7d8e55ad6d7a4cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/520257
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
9 months agocmd/compile/internal/escape: mark blankLoc as transient
Matthew Dempsky [Tue, 15 Aug 2023 21:11:37 +0000 (14:11 -0700)]
cmd/compile/internal/escape: mark blankLoc as transient

Discarded values never persist, so they can be transiently allocated
too.

Change-Id: I036ce0c1eea45e437142497bb7df3ecb44b56e52
Reviewed-on: https://go-review.googlesource.com/c/go/+/520256
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

9 months agostrconv: rely on utf8.AppendRune
Joe Tsai [Thu, 16 Jun 2022 00:39:59 +0000 (17:39 -0700)]
strconv: rely on utf8.AppendRune

This is both simpler and more performant.

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

Change-Id: Ib0ee332e970d4986026c05e5e0e368f41eff7977
Reviewed-on: https://go-review.googlesource.com/c/go/+/412338
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Robert Griesemer <gri@google.com>
9 months agoruntime: change mutex profile to count every blocked goroutine
Russ Cox [Mon, 26 Jun 2023 21:12:44 +0000 (17:12 -0400)]
runtime: change mutex profile to count every blocked goroutine

The pprof mutex profile was meant to match the Google C++ (now Abseil)
mutex profiler, originally designed and implemented by Mike Burrows.
When we worked on the Go version, pjw and I missed that C++ counts the
time each thread is blocked, even if multiple threads are blocked on a
mutex. That is, if 100 threads are blocked on the same mutex for the
same 10ms, that still counts as 1000ms of contention in C++. In Go, to
date, /debug/pprof/mutex has counted that as only 10ms of contention.
If 100 goroutines are blocked on one mutex and only 1 goroutine is
blocked on another mutex, we probably do want to see the first mutex
as being more contended, so the Abseil approach is the more useful one.

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

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

Fixes #61015.

Change-Id: I7eb9e706867ffa8c0abb5b26a1b448f6eba49331
Reviewed-on: https://go-review.googlesource.com/c/go/+/506415
Run-TryBot: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agocmd/compile: use types2.Sizes instead of compiler own implementation
Cuong Manh Le [Wed, 28 Jun 2023 05:03:22 +0000 (12:03 +0700)]
cmd/compile: use types2.Sizes instead of compiler own implementation

With #61035 fixed, types2.Sizes matches the compiler behavior, so use its
Sizes implementation instead of rolling our own copy.

Updates #61035

Change-Id: I7b9efd27a01f729a04c79cd6b4ee5f417fe6e664
Reviewed-on: https://go-review.googlesource.com/c/go/+/506716
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
9 months agogo/types, types2: add Sizes computation to match gc behavior
Cuong Manh Le [Wed, 28 Jun 2023 17:41:32 +0000 (00:41 +0700)]
go/types, types2: add Sizes computation to match gc behavior

Fixes #60431
Fixes #60734
Fixes #61035

Change-Id: I82513da3e1714e8271fae220fe242bf2bfb4eb9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/506856
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>

9 months agoos: skip Chown tests for auxiliary groups that fail due to permission errors
Bryan C. Mills [Tue, 15 Aug 2023 22:01:16 +0000 (18:01 -0400)]
os: skip Chown tests for auxiliary groups that fail due to permission errors

This addresses the failure mode described in
https://git.alpinelinux.org/aports/commit/community/go/tests-filter-overflow-gid.patch?id=9851dde0f5d2a5a50f7f3b5323d1b2ff22e1d028,
but without special-casing an implementation-specific group ID.

For #62053.

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

9 months agolog/slog: remove redundant dot in doc
Jes Cok [Wed, 16 Aug 2023 10:59:58 +0000 (10:59 +0000)]
log/slog: remove redundant dot in doc

Change-Id: Ic4fcfe7335dab219790c19ded3bbb7265857404f
GitHub-Last-Rev: afc69c79b2f8d71441eb4cabaefe8cca9acc8231
GitHub-Pull-Request: golang/go#62062
Reviewed-on: https://go-review.googlesource.com/c/go/+/519955
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
9 months agosyscall: remove deprecation notice
Ian Lance Taylor [Wed, 16 Aug 2023 18:39:06 +0000 (11:39 -0700)]
syscall: remove deprecation notice

The syscall package isn't getting new system call support,
but it is not deprecated.

Fixes #60797

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

9 months agocmd/link: suppress -bind_at_load deprecation warning for ld-prime
Cherry Mui [Mon, 10 Jul 2023 22:50:06 +0000 (18:50 -0400)]
cmd/link: suppress -bind_at_load deprecation warning for ld-prime

ld-prime emits a deprecation warning for -bind_at_load. The flag
is needed for plugins to not deadlock (#38824) when linking with
older darwin linker. It is supposedly not needed with newer linker
when chained fixups are used. For now, we always pass it, and
suppress the warning.

For #61229.

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

9 months agoruntime: guard against runtime/sema* ops on Darwin signal stack.
David Chase [Mon, 14 Aug 2023 17:20:45 +0000 (13:20 -0400)]
runtime: guard against runtime/sema* ops on Darwin signal stack.

These operations misbehave and cause hangs and flakes.
Fail hard if they are attempted.

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

Updates #61768

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

9 months agogo/types: update generate_test.go (cleanup)
Robert Griesemer [Wed, 16 Aug 2023 00:08:44 +0000 (17:08 -0700)]
go/types: update generate_test.go (cleanup)

Adjust some rewrite code to match current code base.

Change-Id: I7d3b79b764b95d664dd95e1057725f15a94973d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/519856
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
9 months agoruntime: add support for range-over-func
Russ Cox [Wed, 12 Jul 2023 19:40:11 +0000 (15:40 -0400)]
runtime: add support for range-over-func

Add runtime support for range over functions, specifically
for defer in the loop body. The defer is running in one
function but needs to append to the deferred function list
for a parent function. This CL implements the runtime
support for that, in the form of two new functions:
deferrangefunc, which obtains a token representing the
current frame, and deferprocat, which is like deferproc
but adds to the list for frame denoted by the token.

Preparation for proposal #61405. The actual logic in the
compiler will be guarded by a GOEXPERIMENT; this code
will only run if the compiler emits calls to deferprocat.

Change-Id: I08adf359100856d21d7ff4b493afa229c9471e70
Reviewed-on: https://go-review.googlesource.com/c/go/+/510540
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agoruntime/testdata/testprog: use testenv.SyscallIsNotSupported to check syscall.Unshare
Bryan C. Mills [Wed, 16 Aug 2023 14:46:11 +0000 (10:46 -0400)]
runtime/testdata/testprog: use testenv.SyscallIsNotSupported to check syscall.Unshare

syscall.Unshare is the sort of system call that may be blocked in a
container environment, and experience has shown that different
container implementations choose from a variety of different error
codes for blocked syscalls.

In particular, the patch in
https://git.alpinelinux.org/aports/tree/community/go/tests-unshare-enosys.patch
seems to suggest that the container environment used to test the Go
distribution on Alpine Linux returns ENOSYS instead of EPERM.

The existing testenv.SyscallIsNotSupported helper checks for
the kinds of error codes we have seen from containers in practice, so
let's use that here.

For #62053.
Updates #29366.

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

9 months agocmd/go: skip gccgo_link_c when cross-compiling
Bryan C. Mills [Tue, 15 Aug 2023 22:07:51 +0000 (18:07 -0400)]
cmd/go: skip gccgo_link_c when cross-compiling

I don't understand the rationale given in
https://git.alpinelinux.org/aports/commit/community/go/tests-unset-GCCGO.patch?id=a10e9a5e48507198e26a8cf19709e4059da4c79f,
but I suspect that it may be working around test failures when
cross-compiling, since we have a lot of other gccgo tests that need to
skip in that circumstance.

Alternatively, that may just be a stale patch working around #53815.
I can't fine any issue filed against the Go project for this patch,
so it's hard to be sure.

Either way, adding this skip should make the test more robust.

For #62053.

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

9 months agocmd/compile, runtime: make room for rangefunc defers
Russ Cox [Fri, 30 Jun 2023 20:18:44 +0000 (16:18 -0400)]
cmd/compile, runtime: make room for rangefunc defers

This is subtle and the compiler and runtime be in sync.
It is easier to develop the rest of the changes (especially when using
toolstash save/restore) if this change is separated out and done first.

Preparation for proposal #61405. The actual logic in the
compiler will be guarded by a GOEXPERIMENT, but it is
easier not to have GOEXPERIMENT-specific data structures
in the runtime, so just make the field always.

Change-Id: I7ec7049b99ae98bf0db365d42966baeec56e3774
Reviewed-on: https://go-review.googlesource.com/c/go/+/510539
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agocmd/compile: trim range typechecking
Russ Cox [Wed, 14 Jun 2023 15:29:59 +0000 (11:29 -0400)]
cmd/compile: trim range typechecking

Most of the code is not necessary anymore.
Before we start changing how range works,
delete this code so it won't need updating.

Preparation for proposal #61405.

Change-Id: Ia6c6cc62b156e38a871279350a2e60c189967cac
Reviewed-on: https://go-review.googlesource.com/c/go/+/510536
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
9 months agoruntime/internal/math: add Add64
Russ Cox [Mon, 7 Aug 2023 19:52:18 +0000 (15:52 -0400)]
runtime/internal/math: add Add64

This makes the intrinsic available on 64-bit platforms,
since the runtime cannot import math/bits.

Change-Id: I5296cc6a97d1cb4756ab369d96dc9605df9f8247
Reviewed-on: https://go-review.googlesource.com/c/go/+/516861
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>

9 months agoregexp/syntax: use more compact Regexp.String output
Russ Cox [Wed, 28 Jun 2023 21:45:26 +0000 (17:45 -0400)]
regexp/syntax: use more compact Regexp.String output

Compact the Regexp.String output. It was only ever intended for debugging,
but there are at least some uses in the wild where regexps are built up
using regexp/syntax and then formatted using the String method.
Compact the output to help that use case. Specifically:

 - Compact 2-element character class ranges: [a-b] -> [ab].
 - Aggregate flags: (?i:A)(?i:B)*(?i:C)|(?i:D)?(?i:E) -> (?i:AB*C|D?E).

Fixes #57950.

Change-Id: I1161d0e3aa6c3ae5a302677032bb7cd55caae5fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/507015
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>

9 months agocmd/api: rename api.go to main_test.go
Russ Cox [Wed, 16 Aug 2023 15:18:02 +0000 (11:18 -0400)]
cmd/api: rename api.go to main_test.go

This makes cmd/api no longer an importable package.
In CL 453258 I forgot that there was no direct prohibition
on importing packages from cmd - we just rely on the
fact that cmd/* is all package main and everything else
is cmd/internal.

Fixes #62069.

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

9 months agocmd/go: clean internal/vcs slightly
Russ Cox [Wed, 16 Aug 2023 14:39:34 +0000 (10:39 -0400)]
cmd/go: clean internal/vcs slightly

Delete CheckNested, which was for GOPATH get.
Unexport CheckGOVCS, which was only exported for GOPATH get.

Change-Id: I6d3f772bfea70f4a3ec197d48b74c3d6d58bcdce
Reviewed-on: https://go-review.googlesource.com/c/go/+/520037
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>

9 months agocmd/compile: in expandCalls, move all arg marshalling into call block
David Chase [Tue, 15 Aug 2023 21:45:50 +0000 (17:45 -0400)]
cmd/compile: in expandCalls, move all arg marshalling into call block

For aggregate-typed arguments passed to a call, expandCalls
decomposed them into parts in the same block where the value
was created.  This is not necessarily the call block, and in
the case where stores are involved, can change the memory
leaving that block, and getting that right is problematic.

Instead, do all the expanding in the same block as the call,
which avoids the problems of (1) not being able to reorder
loads/stores across a block boundary to conform to memory
order and (2) (incorrectly, not) exposing the new memory to
consumers in other blocks.  Putting it all in the same block
as the call allows reordering, and the call creates its own
new memory (which is already dealt with correctly).

Fixes #61992.

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

9 months agosync: document why copyChecker checks the condition twice
qiulaidongfeng [Tue, 15 Aug 2023 02:14:00 +0000 (02:14 +0000)]
sync: document why copyChecker checks the condition twice

Fixes #40924

Change-Id: I249a278be1ec3c67088819af4456e6c393431724

Change-Id: I249a278be1ec3c67088819af4456e6c393431724
GitHub-Last-Rev: 772c7ae7e140ebd3896fc7786aae8b43ab3128c3
GitHub-Pull-Request: golang/go#61978
Reviewed-on: https://go-review.googlesource.com/c/go/+/518961
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Auto-Submit: Austin Clements <austin@google.com>

9 months agoos: support file systems without file IDs when reading directories on windows
qmuntal [Thu, 10 Aug 2023 09:17:25 +0000 (11:17 +0200)]
os: support file systems without file IDs when reading directories on windows

Some file systems do not support file IDs. We should not use
FILE_ID_BOTH_DIR_INFO when reading directories on these file systems,
as it will fail. Instead, we should use FILE_ID_FULL_DIR_INFO,
which doesn't require file ID support.

Fixes #61907
Fixes #61918

Change-Id: I83d0a898f8eb254dffe5b8fc68a4ca4ef21c0d85
Reviewed-on: https://go-review.googlesource.com/c/go/+/518195
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agocmd/go: remove conversion of legacy pre-module dependency configs
Russ Cox [Fri, 11 Aug 2023 15:24:07 +0000 (11:24 -0400)]
cmd/go: remove conversion of legacy pre-module dependency configs

This kind of worked, kind of didn't, but by now no one is running into
those configs anymore during "go mod init", the code is complex,
and the tests are slow. Not worth the trouble of maintaining anymore.

Change-Id: I02d4188d531c68334d17b2462bafec4c5dd49777
Reviewed-on: https://go-review.googlesource.com/c/go/+/518776
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>

9 months agocmd/go: delete GOPATH-mode get
Russ Cox [Tue, 18 Jul 2023 18:01:13 +0000 (14:01 -0400)]
cmd/go: delete GOPATH-mode get

We've decided to keep basic GOPATH mode running
for trees that already exist, but GOPATH-mode get is
being removed. It is old and not useful and probably
full of security holes. See #60915 for more details.

Fixes #60915.

Change-Id: I9db4c445579bf0b79f6543624602652555b66c1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/518775
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agoerrors: add a colon after Output to make the Example in the document display correctly
cui fliter [Tue, 15 Aug 2023 15:07:18 +0000 (23:07 +0800)]
errors: add a colon after Output to make the Example in the document display correctly

Change-Id: Iaa1751c6ac0df9d5b2cb74efb16996f4eaea0503
Reviewed-on: https://go-review.googlesource.com/c/go/+/519236
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: shuang cui <imcusg@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agobufio: clarify the maximum token size
qiulaidongfeng [Wed, 16 Aug 2023 02:04:19 +0000 (02:04 +0000)]
bufio: clarify the maximum token size

Fixes #43183.

Change-Id: I50d99ef8ed513bba47166a25ea5c7c80cd8bd799
GitHub-Last-Rev: 684d70e9a3dbc0ce280e1112105d666cd5754e9f
GitHub-Pull-Request: golang/go#61979
Reviewed-on: https://go-review.googlesource.com/c/go/+/518860
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
9 months agodoc/go1.22: mention new sql.Null[T]
Inada Naoki [Tue, 15 Aug 2023 04:33:37 +0000 (04:33 +0000)]
doc/go1.22: mention new sql.Null[T]

For #60370.

Change-Id: Idae906ec7027be6d95f78bf43f7ce8f9d07e6c00
GitHub-Last-Rev: c645f0cf82ac595855fa154ce342869262932770
GitHub-Pull-Request: golang/go#62033
Reviewed-on: https://go-review.googlesource.com/c/go/+/519555
TryBot-Bypass: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agogo/types, types2: don't verify infer result if no Config.Error is given
Robert Griesemer [Tue, 15 Aug 2023 21:17:02 +0000 (14:17 -0700)]
go/types, types2: don't verify infer result if no Config.Error is given

With no error handler installed, an error leads to an (internal panic
and) immediate abort of type checking. Not all invariants hold up in
this case, but it also doesn't matter.

In Checker.infer, verify result conditions always if an error handler
is installed, but only then.

Fixes #61938.

Change-Id: I4d3d61bbccc696a75639fee5010f5d3cef17e855
Reviewed-on: https://go-review.googlesource.com/c/go/+/519775
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
9 months agogo/types, types2: use correct parameter list when checking argument passing
Robert Griesemer [Mon, 14 Aug 2023 22:56:08 +0000 (15:56 -0700)]
go/types, types2: use correct parameter list when checking argument passing

The existing code was simply wrong: we cannot ever use the result
signature parameter list (rsig.params) if sigParams was adjusted
for variadic functions. If it was adjusted, we always must either
use sigParams or its separately instantiated version.

In the condition "n > 0 && adjusted", the "n > 0" should have
been in either of the respective "if statement" branches.

Simplified the code by merging with the result signature parameter
update.

Fixes #61931.

Change-Id: I5d39bc8bbc4dd85c7c985055d29532b4b176955e
Reviewed-on: https://go-review.googlesource.com/c/go/+/519456
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
9 months agocmd/compile: improve ir.StaticValue and extract ir.StaticCalleeName
Matthew Dempsky [Sat, 12 Aug 2023 01:21:22 +0000 (18:21 -0700)]
cmd/compile: improve ir.StaticValue and extract ir.StaticCalleeName

This CL extends ir.StaticValue to also work on closure variables.

Also, it extracts the code from escape analysis that's responsible for
determining the static callee of a function. This will be useful when
go/defer statement normalization is moved to typecheck.

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

9 months agogo/types, types2: move emode computation closer to use (cleanup)
Robert Griesemer [Mon, 14 Aug 2023 21:15:23 +0000 (14:15 -0700)]
go/types, types2: move emode computation closer to use (cleanup)

Follow-up on https://go.dev/cl/519435.

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

9 months agogo/types, types2: use exact unification when comparing interface methods
Robert Griesemer [Mon, 14 Aug 2023 21:07:56 +0000 (14:07 -0700)]
go/types, types2: use exact unification when comparing interface methods

Irrespective of whether unification is exact or inexact, method
signatures of interfaces must always match exactly: a type never
satisfies/implements an interface if relevant method signatures
are different (i.e., not identical, possibly after substitution).

Fixes #61879.

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

9 months agointernal/syscall/unix: fix gofmt
sivchari [Mon, 14 Aug 2023 16:01:46 +0000 (01:01 +0900)]
internal/syscall/unix: fix gofmt

Change-Id: I24203c4e52bf4d55a6391d10fb4d30771c2674b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/518637
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agodoc: fix broken x509sha1 setting link
Cian Ruane [Tue, 15 Aug 2023 14:34:18 +0000 (14:34 +0000)]
doc: fix broken x509sha1 setting link

The link was missing the /pkg/ prefix.

Fixes #62034.

Change-Id: I96c43f06621e30241e140948129e90f0bd5f8d13
GitHub-Last-Rev: c1e7413f76a25ea18a460fb3af732532429d7ff9
GitHub-Pull-Request: golang/go#62040
Reviewed-on: https://go-review.googlesource.com/c/go/+/519575
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agocmd/go/testdata/script: ensure go test -skip skips ExampleTest1
Tobias Klauser [Tue, 15 Aug 2023 13:32:42 +0000 (15:32 +0200)]
cmd/go/testdata/script: ensure go test -skip skips ExampleTest1

CL 511837 added a check for go test -skip Example but it currently
doesn't verify that the example doesn't show up in the command output.
Add such a check.

For #61482

Change-Id: I3a8f82fc137739bf291f39bf7719ff92cfc74f9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/519595
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/pprof: update vendored github.com/google/pprof
Dmitri Shuralyov [Tue, 15 Aug 2023 15:45:57 +0000 (11:45 -0400)]
cmd/pprof: update vendored github.com/google/pprof

Pull in the latest published version of github.com/google/pprof
as part of the continuous process of keeping Go's dependencies
up to date. Done with:

go get github.com/google/pprof
go mod tidy
go mod vendor

For #36905.

Change-Id: I2a48e912712bc916c9d749acb1550682f919477e
Reviewed-on: https://go-review.googlesource.com/c/go/+/519657
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>

9 months agocmd/internal/archive: skip sentinel archive entries created by Go cmd
Than McIntosh [Tue, 15 Aug 2023 14:24:41 +0000 (10:24 -0400)]
cmd/internal/archive: skip sentinel archive entries created by Go cmd

When reading an archive, check for the presence of sentinel entries
created by the Go command. These zero-sized marker entries don't contain
any useful symbols, but rather are there to communicate info to the
linker; ignore them during symbol dumping.

Fixes #62036.

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

9 months agoruntime/cgo: use fatalf on solaris
Joel Sing [Fri, 11 Aug 2023 13:08:25 +0000 (23:08 +1000)]
runtime/cgo: use fatalf on solaris

Change-Id: I3302cc2f0e03014e9497976e36d1c7a381a2f962
Reviewed-on: https://go-review.googlesource.com/c/go/+/518623
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agoruntime: restore caller's frame pointer when recovering from panic
Nick Ripley [Fri, 4 Aug 2023 21:31:43 +0000 (17:31 -0400)]
runtime: restore caller's frame pointer when recovering from panic

When recovering from a panic, restore the caller's frame pointer before
returning control to the caller. Otherwise, if the function proceeds to
run more deferred calls before returning, the deferred functions will
get invalid frame pointers pointing to an address lower in the stack.
This can cause frame pointer unwinding to crash, such as if an execution
trace event is recorded during the deferred call on architectures which
support frame pointer unwinding.

Fixes #61766

Change-Id: I45f41aedcc397133560164ab520ca638bbd93c4e
Reviewed-on: https://go-review.googlesource.com/c/go/+/516157
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
9 months agoruntime: zero saved frame pointer when reusing goroutine stack on arm64
Nick Ripley [Mon, 3 Apr 2023 13:32:05 +0000 (09:32 -0400)]
runtime: zero saved frame pointer when reusing goroutine stack on arm64

When a goroutine stack is reused on arm64, the spot on the stack where
the "caller's" frame pointer goes for the topmost frame should be
explicitly zeroed. Otherwise, the frame pointer check in adjustframe
with debugCheckBP enabled will fail on the topmost frame of a call stack
the first time a reused stack is grown.

Updates #39524, #58432

Change-Id: Ic1210dc005e3ecdbf9cd5d7b98846566e56df8f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/481636
Reviewed-by: Felix Geisendörfer <felix.geisendoerfer@datadoghq.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>

9 months agocrypto/internal/bigmod: provide assembly addMulVVW* for riscv64
Joel Sing [Mon, 7 Aug 2023 15:18:17 +0000 (01:18 +1000)]
crypto/internal/bigmod: provide assembly addMulVVW* for riscv64

This provides an assembly implementation of addMulVVW* for riscv64,
processing four words per loop, resulting in a performance gain
of 23%+ for RSA decryption/signing on a StarFive VisionFive 2:

                       │    rsa1     │                rsa2                 │
                       │   sec/op    │   sec/op     vs base                │
DecryptPKCS1v15/2048-4   24.29m ± 0%   18.65m ± 0%  -23.24% (p=0.000 n=10)
DecryptPKCS1v15/3072-4   73.28m ± 0%   54.08m ± 0%  -26.20% (p=0.000 n=10)
DecryptPKCS1v15/4096-4   163.5m ± 0%   119.1m ± 0%  -27.17% (p=0.000 n=10)
EncryptPKCS1v15/2048-4   1.505m ± 0%   1.446m ± 0%   -3.93% (p=0.000 n=10)
DecryptOAEP/2048-4       24.37m ± 0%   18.72m ± 0%  -23.17% (p=0.000 n=10)
EncryptOAEP/2048-4       1.570m ± 0%   1.510m ± 0%   -3.84% (p=0.000 n=10)
SignPKCS1v15/2048-4      24.52m ± 0%   18.80m ± 0%  -23.36% (p=0.000 n=10)
VerifyPKCS1v15/2048-4    1.491m ± 0%   1.431m ± 0%   -4.00% (p=0.000 n=10)
SignPSS/2048-4           24.60m ± 0%   18.89m ± 0%  -23.21% (p=0.000 n=10)
VerifyPSS/2048-4         1.565m ± 0%   1.504m ± 0%   -3.87% (p=0.000 n=10)
geomean                  10.90m        9.066m       -16.79%

Change-Id: I8414ba0028b0781a945610abe02c285d2387aef3
Reviewed-on: https://go-review.googlesource.com/c/go/+/516536
Reviewed-by: Mark Ryan <markdryan@rivosinc.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: M Zhuo <mzh@golangcn.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoruntime/cgo: consolidate openbsd cgo code
Joel Sing [Fri, 11 Aug 2023 13:02:32 +0000 (23:02 +1000)]
runtime/cgo: consolidate openbsd cgo code

All openbsd architectures now use the same code, deduplicate accordingly.

Change-Id: I65f1d9bd78c97dbdf552ec95ebba7ec4d04c8d2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/518622
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoruntime/cgo: consolidate netbsd cgo code
Joel Sing [Fri, 11 Aug 2023 12:46:32 +0000 (22:46 +1000)]
runtime/cgo: consolidate netbsd cgo code

All netbsd architectures now use the same code, deduplicate accordingly.

Change-Id: Ieb179fd76885b7af6d388d7f2aee0f9fac6f1264
Reviewed-on: https://go-review.googlesource.com/c/go/+/518621
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>

9 months agoruntime/cgo: consolidate linux cgo code
Joel Sing [Fri, 11 Aug 2023 08:54:52 +0000 (18:54 +1000)]
runtime/cgo: consolidate linux cgo code

Much of the gcc_linux_*.c code is identical and duplicated across
architectures. Consolidate code for 386, arm, loong64, mips* and
riscv64, where the only difference is the build tags (386 also
has some non-functional ordering differences).

Change-Id: I14ee9a4cc6b72e165239d196b68b6343efaddf0a
Reviewed-on: https://go-review.googlesource.com/c/go/+/518620
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agoruntime/cgo: consolidate freebsd cgo code
Joel Sing [Fri, 11 Aug 2023 12:53:30 +0000 (22:53 +1000)]
runtime/cgo: consolidate freebsd cgo code

Most freebsd architectures now use the same code, deduplicate accordingly.

The arm code differs slightly in that it has a compile time check for
ARM_TP_ADDRESS, however this is written in a way that it can be included
for all architectures.

Change-Id: I7f6032b63521d24d0c3b5e0e08d57e32b4f9ddc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/518619
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agoruntime/cgo: rename crosscall_arm1 to crosscall1
Joel Sing [Fri, 11 Aug 2023 09:49:38 +0000 (19:49 +1000)]
runtime/cgo: rename crosscall_arm1 to crosscall1

This reduces inconsistency with other architectures and will allow
for further code deduplication.

Change-Id: Icf0d02f765546c3193cccaa22c79e632e12d6bba
Reviewed-on: https://go-review.googlesource.com/c/go/+/518616
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agoruntime/cgo: use fatalf on dragonfly, freebsd, netbsd and openbsd
Joel Sing [Fri, 11 Aug 2023 08:20:21 +0000 (18:20 +1000)]
runtime/cgo: use fatalf on dragonfly, freebsd, netbsd and openbsd

Use fatalf consistently on freebsd. Also use it on dragonfly, netbsd
and openbsd.

Change-Id: I8643c0b7bc13c3cb5173209d311d6d297913955b
Reviewed-on: https://go-review.googlesource.com/c/go/+/518615
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile: sign or zero extend for 32 bit equality on riscv64
Joel Sing [Wed, 19 Oct 2022 05:43:22 +0000 (16:43 +1100)]
cmd/compile: sign or zero extend for 32 bit equality on riscv64

For 32 bit equality (Eq32), rather than always zero extending to 64 bits,
sign extend for signed types and zero extend for unsigned types. This makes
no difference to the equality test (via SUB), however it increases the
likelihood of avoiding unnecessary sign or zero extension simply for the
purpose of equality testing.

While here, replace the Neq* rules with (Not (Eq*)) - this makes no
difference to the generated code (as the intermediates get expanded and
eliminated), however it means that changes to the equality rules also
reflect in the inequality rules.

As an example, the following:

   lw      t0,956(t0)
   slli    t0,t0,0x20
   srli    t0,t0,0x20
   li      t1,1
   bne     t1,t0,278fc

Becomes:

   lw      t0,1024(t0)
   li      t1,1
   bne     t1,t0,278b0

Removes almost 1000 instructions from the Go binary on riscv64.

Change-Id: Iac60635f494f6db87faa47752bd1cc16e6b5967f
Reviewed-on: https://go-review.googlesource.com/c/go/+/516595
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: M Zhuo <mzh@golangcn.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agoruntime: mark traceEnabled and traceShuttingDown as no:split
Mauri de Souza Meneguzzo [Sun, 13 Aug 2023 14:04:53 +0000 (14:04 +0000)]
runtime: mark traceEnabled and traceShuttingDown as no:split

This fixes a regression from CL 494181.
The traceEnabled function splits the stack and is being
called by reentersyscall that shouldn't call anything
that splits the stack. Same with traceShuttingDown.

Fixes #61975

Change-Id: I5eca0ba74cfa6acb0259e8400b03c2093cd59dd1
GitHub-Last-Rev: 9e55ae9d7cc700de9757d32a7905127a349d973a
GitHub-Pull-Request: golang/go#61981
Reviewed-on: https://go-review.googlesource.com/c/go/+/519055
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@google.com>

9 months agoencoding/json: declare hex as a const
Jes Cok [Mon, 14 Aug 2023 11:53:26 +0000 (11:53 +0000)]
encoding/json: declare hex as a const

hex is in fact immutable, declare it as a const to avoid accidental
modification, also for consistency with other packages.

Change-Id: I99f292e98c82d4c4526e46c9897d154d0c073da5
GitHub-Last-Rev: d2f06965e7e03df470d8c3c8882619187abf1609
GitHub-Pull-Request: golang/go#62011
Reviewed-on: https://go-review.googlesource.com/c/go/+/519155
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd: fix mismatched symbols
cui fliter [Mon, 31 Jul 2023 13:40:45 +0000 (21:40 +0800)]
cmd: fix mismatched symbols

Change-Id: I8852c0a29dffec9635d61b7670cfed78ebed07f5
Reviewed-on: https://go-review.googlesource.com/c/go/+/514315
Run-TryBot: shuang cui <imcusg@gmail.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agointernal/fuzz: use the built-in min function
cui fliter [Fri, 11 Aug 2023 03:00:44 +0000 (11:00 +0800)]
internal/fuzz: use the built-in min function

Change-Id: I26be9a9faa27c6c03cf8b9dec5908d8617d61312
Reviewed-on: https://go-review.googlesource.com/c/go/+/518276
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/compile/internal: add RLDICR opcode for PPC64
Paul E. Murphy [Tue, 27 Jun 2023 16:30:29 +0000 (11:30 -0500)]
cmd/compile/internal: add RLDICR opcode for PPC64

This is encoded similarly to RLDICL, but can clear the least
significant bits.

Likewise, update the auxint encoding of RLDICL to match those
used by the rotate and mask word ssa opcodes for easier usage
within lowering rules. The RLDICL ssa opcode is not used yet.

Change-Id: I42486dd95714a3e8e2f19ab237a6cf3af520c905
Reviewed-on: https://go-review.googlesource.com/c/go/+/515575
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agointernal/bytealg: optimize Count/CountString for PPC64/Power10
Paul E. Murphy [Mon, 17 Jul 2023 20:23:28 +0000 (15:23 -0500)]
internal/bytealg: optimize Count/CountString for PPC64/Power10

Power10 adds a handful of new instructions which make this
noticeably quicker for smaller values.

Likewise, since the vector loop requires 32B to enter,
unroll it once to count 32B per iteration. This
improvement benefits all PPC64 cpus.

On Power10 comparing a binary built with GOPPC64=power8

CountSingle/10     8.99ns ± 0%    5.55ns ± 3%   -38.24%
CountSingle/16     7.55ns ± 0%    5.56ns ± 3%   -26.37%
CountSingle/17     7.45ns ± 0%    5.25ns ± 0%   -29.52%
CountSingle/31     18.4ns ± 0%     6.2ns ± 0%   -66.41%
CountSingle/32     6.17ns ± 0%    5.04ns ± 0%   -18.37%
CountSingle/33     7.13ns ± 0%    5.99ns ± 0%   -15.94%
CountSingle/4K      198ns ± 0%     115ns ± 0%   -42.08%
CountSingle/4M      190µs ± 0%     109µs ± 0%   -42.49%
CountSingle/64M    3.28ms ± 0%    2.08ms ± 0%   -36.53%

Furthermore, comparing the new tail implementation on
GOPPC64=power8 with GOPPC64=power10:

CountSingle/10     5.55ns ± 3%    4.52ns ± 1%  -18.66%
CountSingle/16     5.56ns ± 3%    4.80ns ± 0%  -13.65%
CountSingle/17     5.25ns ± 0%    4.79ns ± 0%   -8.78%
CountSingle/31     6.17ns ± 0%    4.82ns ± 0%  -21.79%
CountSingle/32     5.04ns ± 0%    5.09ns ± 6%   +1.01%
CountSingle/33     5.99ns ± 0%    5.42ns ± 2%   -9.54%

Change-Id: I62d80be3b5d706e1abbb4bec7d6278a939a5eed4
Reviewed-on: https://go-review.googlesource.com/c/go/+/512695
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/go/internal/cache: use == to test for io.EOF
Jes Cok [Mon, 14 Aug 2023 11:16:48 +0000 (11:16 +0000)]
cmd/go/internal/cache: use == to test for io.EOF

The documentation of io.EOF: Read must return EOF itself, not an error
wrapping EOF, because callers will test for EOF using ==.

encoding/json package provides an example "ExampleDecoder" which uses
"err == io.EOF" as well, so I think it's more idiomatic to use == to test for io.EOF.

Change-Id: I8a9f06d655ca63b3ec3e7dbbdfc519a2686980e1
GitHub-Last-Rev: 665929e2a20bff231bcb5bad1384998379b41165
GitHub-Pull-Request: golang/go#62012
Reviewed-on: https://go-review.googlesource.com/c/go/+/519156
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
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: Bryan Mills <bcmills@google.com>
9 months agocmd/compile: desugar ORECOVER during typecheck
Matthew Dempsky [Sat, 12 Aug 2023 00:29:08 +0000 (17:29 -0700)]
cmd/compile: desugar ORECOVER during typecheck

This never belonged in escape analysis, but the non-unified generics
frontend didn't use typecheck. That frontend is gone, so now we can
desugar it earlier.

Change-Id: I70f34a851f27fce1133777c5eeca0f549fc60ede
Reviewed-on: https://go-review.googlesource.com/c/go/+/518958
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/compile: move IsDeadcodeClosure check into enqueueFunc
Matthew Dempsky [Fri, 11 Aug 2023 22:16:12 +0000 (15:16 -0700)]
cmd/compile: move IsDeadcodeClosure check into enqueueFunc

Keeps the top-level loop in Main slightly cleaner.

Change-Id: I9c8d38d4bbb34d53edc0796893534763e9eef2f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/518957
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
9 months agocmd/compile: remove reflectdata.{TypePtr,ITabAddr} wrappers
Matthew Dempsky [Fri, 11 Aug 2023 21:35:23 +0000 (14:35 -0700)]
cmd/compile: remove reflectdata.{TypePtr,ITabAddr} wrappers

Remove these in favor of the explicit *At variants that take a
src.XPos.

Change-Id: I2c095b75e43b58fe31e3e1b15c811a66ac5a0f83
Reviewed-on: https://go-review.googlesource.com/c/go/+/518956
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/compile: mark generated eq/hash functions as //go:noinline
Matthew Dempsky [Fri, 11 Aug 2023 21:22:56 +0000 (14:22 -0700)]
cmd/compile: mark generated eq/hash functions as //go:noinline

Instead of having the inliner specially recognize that eq/hash
functions can't be inlined, change the geneq and genhash to mark them
as //go:noinline.

This is a prereq for a subsequent CL that will move more logic for
handling rtypes from package types to package reflectdata.

Change-Id: I091a9ededcc083fe8305cf5443a9af7d3a9053b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/518955
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/go: skip gotoolchain_net script test for new-ish go experiments
Than McIntosh [Mon, 14 Aug 2023 14:51:57 +0000 (10:51 -0400)]
cmd/go: skip gotoolchain_net script test for new-ish go experiments

Skip the gotoolchain_net script test if any new-ish GOEXPERIMENT is
set, since it will fail under these circumstances.

Updates #62106.

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

9 months agoruntime: profiling on Darwin cannot use blocking reads
David Chase [Fri, 11 Aug 2023 18:38:19 +0000 (14:38 -0400)]
runtime: profiling on Darwin cannot use blocking reads

On Darwin (and assume also on iOS but not sure), notetsleepg
cannot be called in a signal-handling context.  Avoid this
by disabling block reads on Darwin.

An alternate approach was to add "sigNote" with a pipe-based
implementation on Darwin, but that ultimately would have required
at least one more linkname between runtime and syscall to avoid
racing with fork and opening the pipe, so, not.

Fixes #61768.

Change-Id: I0e8dd4abf9a606a3ff73fc37c3bd75f55924e07e
Reviewed-on: https://go-review.googlesource.com/c/go/+/518836
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agointernal/coverage: separate out cmd defs to separate package
Than McIntosh [Wed, 9 Aug 2023 12:50:41 +0000 (08:50 -0400)]
internal/coverage: separate out cmd defs to separate package

Relocate the definitions in cmddefs.go (used by the compiler and
the cover tool) to a separate package "covcmd". No change
in functionality, this is a pure refactoring, in preparation
for a subsequent change that will require updating the
imports for the package.

Change-Id: Ic1d277c94d9a574de0a11ec5ed77e892302b9a47
Reviewed-on: https://go-review.googlesource.com/c/go/+/517696
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Than McIntosh <thanm@google.com>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: David Chase <drchase@google.com>
9 months agoruntime/cgo: rename crosscall_386 to crosscall1 and standardise API
Joel Sing [Fri, 11 Aug 2023 10:19:59 +0000 (20:19 +1000)]
runtime/cgo: rename crosscall_386 to crosscall1 and standardise API

Most architectures have a crosscall1 function that takes a function
pointer, a setg_gcc function pointer and a g pointer. However,
crosscall_386 only takes a function pointer and the call to setg_gcc
is performed in the thread entry function.

Rename crosscall_386 to crosscall1 for consistency with other
architectures, as well as standardising the API - while not strictly
necessary, it will allow for further deduplication as the calling
code becomes more consistent.

Change-Id: I77cf42e1e15e0a4c5802359849a849c32cebd92f
Reviewed-on: https://go-review.googlesource.com/c/go/+/518618
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agoruntime/cgo: rename crosscall_amd64 to crosscall1
Joel Sing [Fri, 11 Aug 2023 09:58:26 +0000 (19:58 +1000)]
runtime/cgo: rename crosscall_amd64 to crosscall1

This reduces inconsistency with other architectures and will allow
for further code deduplication.

Change-Id: I5becbf29af2ef714974b5e338f869281f2b4de8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/518617
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agonet/http: disallow empty Content-Length header
Mauri de Souza Meneguzzo [Thu, 10 Aug 2023 20:56:27 +0000 (20:56 +0000)]
net/http: disallow empty Content-Length header

The Content-Length must be a valid numeric value, empty values should not be accepted.

See: https://www.rfc-editor.org/rfc/rfc9110.html#name-content-length

Fixes #61679

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

9 months agocmd/compile: simplify asmhdr and plugin exports handling
Matthew Dempsky [Fri, 11 Aug 2023 19:04:22 +0000 (12:04 -0700)]
cmd/compile: simplify asmhdr and plugin exports handling

This CL removes a bunch of obsolete code, which made the overall
possible data flow of the compiler much harder to understand. In
particular, it:

1. Removes typecheck.Declare by inlining its only two remaining uses,
and simplifying them down to just the couple of relevant assignments
for each remaining caller.

2. Renames ir.Package.{Asms,Exports} to {AsmHdrDecls,PluginExports},
respectively, to better describe what they're used for. In particular,
PluginExports now actually holds only the subset of Exports that used
to be confusingly called "ptabs" in package reflectdata.

3. Renames reflectdata.WriteTabs to reflectdata.WritePluginTable, to
make it clearer what it does.

4. Removes the consistency checks on len(Exports) and len(ptabs),
since now it's plainly obvious that only the unified importer ever
appends to PluginExports.

Change-Id: Iedc9d0a4e7648de4e734f7e3e7df302580fed542
Reviewed-on: https://go-review.googlesource.com/c/go/+/518757
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/asm: add KDSA instruction support
Srinivas Pokala [Wed, 14 Jun 2023 05:13:37 +0000 (07:13 +0200)]
cmd/asm: add KDSA instruction support

KDSA(Compute Digital Signature Authentication) instruction provides
support for the signing and verification of elliptic curves

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

9 months agocmd/compile: separate out unsafe mark for end-of-block instructions
Keith Randall [Fri, 11 Aug 2023 04:09:33 +0000 (21:09 -0700)]
cmd/compile: separate out unsafe mark for end-of-block instructions

Even if a block is empty, we need to keep track of whether the
end-of-block instructions are preemptible.

This CL allows us to not mark the load+compare in instruction
sequences like

CMPL $0, runtime·writeBarrier(SB)
JEQ  ...

Before, we had to mark the CMPL as uninterruptible because there
was no way to mark just the JEQ. Now there is, so there is no need
to mark the CMPL itself.

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

9 months agoruntime: test that write barriers are correctly marked unpreemptible
Keith Randall [Thu, 10 Aug 2023 22:07:43 +0000 (15:07 -0700)]
runtime: test that write barriers are correctly marked unpreemptible

Followon to CL 518055.

Change-Id: I05c4b429f49feb7012070e467fefbf3392260915
Reviewed-on: https://go-review.googlesource.com/c/go/+/518538
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocmd/compile/internal/coverage: merge Fixup{Vars,Init} into Fixup
Matthew Dempsky [Wed, 9 Aug 2023 16:21:56 +0000 (09:21 -0700)]
cmd/compile/internal/coverage: merge Fixup{Vars,Init} into Fixup

There's no need for separate fixups phases anymore.

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

9 months agocmd/compile: cleanup ir.Package
Matthew Dempsky [Wed, 9 Aug 2023 15:39:47 +0000 (08:39 -0700)]
cmd/compile: cleanup ir.Package

Decls used to contain initializer statement for package-level
variables, but now it only contains ir.Funcs. So we might as well
rename it to Funcs and tighten its type to []*ir.Func.

Similarly, Externs always contains *ir.Names, so its type can be
constrained too.

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

9 months agocmd/compile: move early deadcode into unified writer
Matthew Dempsky [Wed, 9 Aug 2023 11:05:35 +0000 (04:05 -0700)]
cmd/compile: move early deadcode into unified writer

This CL moves the early deadcode elimination pass into the unified
writer. This allows shrinking the export data, by simplifying
expressions and removing unreachable statements. It also means we
don't need to repeatedly apply deadcode elimination on inlined calls
or instantiated generics.

Change-Id: I19bdb04861e50815fccdab39790f4aaa076121fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/517775
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agocmd/compile: make use of types2.InitOrder
Matthew Dempsky [Wed, 9 Aug 2023 08:43:47 +0000 (01:43 -0700)]
cmd/compile: make use of types2.InitOrder

types2 already computes the order that package-level variables need to
be initialized in. Start using it.

Change-Id: Idf2740f963b8146f7c927f57effdbf245f41d355
Reviewed-on: https://go-review.googlesource.com/c/go/+/517617
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agocmd/distpack: include directory entries in tar files
Russ Cox [Thu, 10 Aug 2023 03:47:27 +0000 (23:47 -0400)]
cmd/distpack: include directory entries in tar files

Various tools expect tar files to contain entries for directories.
I dropped them when writing cmd/distpack because they're not
strictly necessary and omitting them saves space, but it also
turns out to break some things, so add them back.

We will backport this to release-branch.go1.21 so that Go 1.21.1
will include the directory entries. We can't do anything about
Go 1.21.0 retroactively.

% tar tzvf go1.22rsc1.src.tar.gz | sed 10q
drwxr-xr-x  0 0      0           0 Aug 10 10:07 go/
-rw-r--r--  0 0      0        1337 Aug 10 10:07 go/CONTRIBUTING.md
-rw-r--r--  0 0      0        1479 Aug 10 10:07 go/LICENSE
-rw-r--r--  0 0      0        1303 Aug 10 10:07 go/PATENTS
-rw-r--r--  0 0      0        1455 Aug 10 10:07 go/README.md
-rw-r--r--  0 0      0         419 Aug 10 10:07 go/SECURITY.md
-rw-r--r--  0 0      0          42 Aug 10 10:07 go/VERSION
drwxr-xr-x  0 0      0           0 Aug 10 10:07 go/api/
-rw-r--r--  0 0      0        1142 Aug 10 10:07 go/api/README
-rw-r--r--  0 0      0       35424 Aug 10 10:07 go/api/except.txt
% tar tzvf go1.22rsc1.darwin-amd64.tar.gz | sed 10q
drwxr-xr-x  0 0      0           0 Aug 10 10:07 go/
-rw-r--r--  0 0      0        1337 Aug 10 10:07 go/CONTRIBUTING.md
-rw-r--r--  0 0      0        1479 Aug 10 10:07 go/LICENSE
-rw-r--r--  0 0      0        1303 Aug 10 10:07 go/PATENTS
-rw-r--r--  0 0      0        1455 Aug 10 10:07 go/README.md
-rw-r--r--  0 0      0         419 Aug 10 10:07 go/SECURITY.md
-rw-r--r--  0 0      0          42 Aug 10 10:07 go/VERSION
drwxr-xr-x  0 0      0           0 Aug 10 10:07 go/api/
-rw-r--r--  0 0      0        1142 Aug 10 10:07 go/api/README
-rw-r--r--  0 0      0       35424 Aug 10 10:07 go/api/except.txt
%

Fixes #61862.

Change-Id: Iecd9ba893015295e88715b031b79a104236b9ced
Reviewed-on: https://go-review.googlesource.com/c/go/+/518335
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>

9 months agotime: make time.Since a few nanoseconds faster
Russ Cox [Thu, 10 Aug 2023 15:56:53 +0000 (11:56 -0400)]
time: make time.Since a few nanoseconds faster

time.Since(base) is an idiom that can be used to read the system
monotonic time as efficiently as possible, when that matters.
The current code structure adds a few nanoseconds on top of
the 15-20ns the time read already takes. Remove those few.

After this CL, there is no reason at all for anyone to
//go:linkname runtime.nanotime1 instead.

Came up while investigating #61765.

Change-Id: Ic9e688af039babfc2a5a8e67dcbb02847a5eb686
Reviewed-on: https://go-review.googlesource.com/c/go/+/518336
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
9 months agostrconv: use the built-in min/max function
qiulaidongfeng [Thu, 10 Aug 2023 02:00:54 +0000 (02:00 +0000)]
strconv: use the built-in min/max function

Change-Id: Iab170943e6e80ffe08bb061e563c106b53740372

Change-Id: Iab170943e6e80ffe08bb061e563c106b53740372
GitHub-Last-Rev: 2964e03f1fbc499247bb6c3365475a91ef64547a
GitHub-Pull-Request: golang/go#61828
Reviewed-on: https://go-review.googlesource.com/c/go/+/516875
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agointernal/itoa, os: move os.uitox to itoa.Uitox
Tobias Klauser [Thu, 10 Aug 2023 19:48:58 +0000 (21:48 +0200)]
internal/itoa, os: move os.uitox to itoa.Uitox

This packages already contains other similar functions. Also add a test
for it.

Change-Id: Iafa8c14f5cb1f5ef89a0e16ccc855c568a3b5727
Reviewed-on: https://go-review.googlesource.com/c/go/+/518317
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoos: remove unused func itox
Tobias Klauser [Thu, 10 Aug 2023 19:42:00 +0000 (21:42 +0200)]
os: remove unused func itox

It was added by CL 288792 but was never used.

Change-Id: I0c21237c0c32ee5df2ebe99b6ecd8831f9c28649
Reviewed-on: https://go-review.googlesource.com/c/go/+/518316
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agomath/big: using the min built-in function
qiulaidongfeng [Thu, 10 Aug 2023 02:01:04 +0000 (02:01 +0000)]
math/big: using the min built-in function

Change-Id: I9e95806116a8547ec782f66226d1b1382c6156de

Change-Id: I9e95806116a8547ec782f66226d1b1382c6156de
GitHub-Last-Rev: 5b4ce994c162775e91aa00c942571bc0ac8b1eca
GitHub-Pull-Request: golang/go#61829
Reviewed-on: https://go-review.googlesource.com/c/go/+/516895
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agocmd/go: enter vendor mode depending on new modules.txt workspace line
Michael Matloob [Wed, 26 Jul 2023 18:09:06 +0000 (14:09 -0400)]
cmd/go: enter vendor mode depending on new modules.txt workspace line

modules.txt gets a new ## workspace line at the start of the file if
it's generated in workspace mode. Then, when deciding whether the go
command runs in mod=vendor, we only do so if we're in the same mode
(workspace or not) as the modules.txt specifies.

For #60056

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