]> Cypherpunks.ru repositories - gostls13.git/log
gostls13.git
9 months agoos: add tests for UserCacheDir and UserConfigDir
Josh Kraft [Thu, 17 Aug 2023 00:36:46 +0000 (18:36 -0600)]
os: add tests for UserCacheDir and UserConfigDir

Adds basic test scenarios for UserCacheDir and
UserConfigDir.

Fixes #57638

Change-Id: Ieb86e95faff44287bfa13daa0cb26e7b5401373b
Reviewed-on: https://go-review.googlesource.com/c/go/+/520262
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Bypass: Bryan Mills <bcmills@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>

9 months agoruntime: document maxStack and m.createstack in more details
Andy Pan [Thu, 10 Aug 2023 06:02:03 +0000 (14:02 +0800)]
runtime: document maxStack and m.createstack in more details

Change-Id: If93b6cfa5a598a5f4101c879a0cd88a194e4a6aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/518116
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Andy Pan <panjf2000@gmail.com>

9 months agoos: avoid allocating a string for ReadDir skipped entries on Windows
qmuntal [Thu, 17 Aug 2023 08:26:36 +0000 (10:26 +0200)]
os: avoid allocating a string for ReadDir skipped entries on Windows

Shave off a few allocations while reading a directory by checking
if the entry name is "." or ".." before allocating a string for it.

Change-Id: I05a87d7572bd4fc191db70aaa9e22a6102f68b4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/520415
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoruntime: add self-check mode to cache in pcvalue
Austin Clements [Wed, 16 Aug 2023 16:30:10 +0000 (12:30 -0400)]
runtime: add self-check mode to cache in pcvalue

This would have helped with debugging the failures caused by CL 515276.

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

9 months agocmd/compile/internal/typecheck: add selector helpers
Matthew Dempsky [Sat, 19 Aug 2023 02:40:33 +0000 (19:40 -0700)]
cmd/compile/internal/typecheck: add selector helpers

This CL refactors common patterns for constructing field and method
selector expressions. Notably, XDotField and XDotMethod are now the
only two functions where a SelecterExpr with OXDOT is constructed.

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

9 months agocmd/compile/internal/typecheck: simplify NewMethodExpr
Matthew Dempsky [Sat, 19 Aug 2023 01:13:58 +0000 (18:13 -0700)]
cmd/compile/internal/typecheck: simplify NewMethodExpr

This CL changes NewMethodExpr to directly construct the OMETHEXPR
node, instead of running through the generic OXDOT typechecking
machinery.

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

9 months agocmd/compile/internal/typecheck: add NewMethodExpr helper
Matthew Dempsky [Sat, 19 Aug 2023 01:03:24 +0000 (18:03 -0700)]
cmd/compile/internal/typecheck: add NewMethodExpr helper

This CL refactors the common pattern for constructing OMETHEXPR nodes,
which is the most common use of ir.TypeNode currently.

Change-Id: I446a21af97ab5a4bc2f04bbd581c1ede8a5ede60
Reviewed-on: https://go-review.googlesource.com/c/go/+/520978
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>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agocmd/compile/internal/typecheck: refactor and simplify DeclFunc
Matthew Dempsky [Sat, 19 Aug 2023 00:43:15 +0000 (17:43 -0700)]
cmd/compile/internal/typecheck: refactor and simplify DeclFunc

This CL refactors typecheck.DeclFunc to require the caller to have
already constructed the ir.Func and signature type using ir.NewFunc
and types.NewSignature, and simplifies typecheck.DeclFunc to simply
return the slices of param and results ONAMEs.

typecheck.DeclFunc was the last reason that ir.Field still exists, so
this CL also gets rid of that.

Change-Id: Ib398420bac2fd135a235810b8af1635fa754965c
Reviewed-on: https://go-review.googlesource.com/c/go/+/520977
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 agoslices: simplify Clone a bit
Brad Fitzpatrick [Sat, 19 Aug 2023 16:08:38 +0000 (09:08 -0700)]
slices: simplify Clone a bit

No need for an explicit nil check. Slicing the input slice
down to zero capacity also preserves nil.

Change-Id: I1f53cc485373d0e65971cd87b6243650ac72612c
Reviewed-on: https://go-review.googlesource.com/c/go/+/521037
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agonet: return "cannot unmarshal" error while parsing DNS messages
Mateusz Poliwczak [Sat, 19 Aug 2023 07:52:34 +0000 (07:52 +0000)]
net: return "cannot unmarshal" error while parsing DNS messages

Change-Id: I407f5d3d3a3e8b3d43ff154f731d885e831971e9
GitHub-Last-Rev: d6a400d1ba6a09e726c9b4e4774a7e8a611611e8
GitHub-Pull-Request: golang/go#62155
Reviewed-on: https://go-review.googlesource.com/c/go/+/520980
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Mateusz Poliwczak <mpoliwczak34@gmail.com>

9 months agocmd/compile/internal/gc: remove unused reflectdata import
Dmitri Shuralyov [Sat, 19 Aug 2023 22:59:04 +0000 (18:59 -0400)]
cmd/compile/internal/gc: remove unused reflectdata import

CL 521036 was prepared and tested before the revert CL 521155,
and it so happens that the reflectdata import ended up unused.
Drop it to fix the build.

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

9 months agoexpvar: emit valid JSON strings
Joe Tsai [Tue, 14 Mar 2023 22:35:36 +0000 (15:35 -0700)]
expvar: emit valid JSON strings

Map.String and expvarHandler used the %q flag with fmt.Fprintf
to escape Go strings, which does so according to the Go grammar,
which is not always compatible with JSON strings.

Rather than calling json.Marshal for every string,
which will always allocate, declare a local appendJSONQuote
function that does basic string escaping.
Also, we declare an unexported appendJSON method on every
concrete Var type so that the final JSON output can be
constructed with far fewer allocations.

The resulting logic is both more correct and also much faster.
This does not alter the whitespace style of Map.String or expvarHandler,
but may alter the representation of JSON strings.

Performance:

name         old time/op    new time/op    delta
MapString    5.10µs ± 1%    1.56µs ± 1%  -69.33%  (p=0.000 n=10+9)

name         old alloc/op   new alloc/op   delta
MapString    1.21kB ± 0%    0.66kB ± 0%  -45.12%  (p=0.000 n=10+10)

name         old allocs/op  new allocs/op  delta
MapString      37.0 ± 0%       7.0 ± 0%  -81.08%  (p=0.000 n=10+10)

Fixes #59040

Change-Id: I46a2125f43550b91d52019e5edc003d9dd19590f
Reviewed-on: https://go-review.googlesource.com/c/go/+/476336
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

9 months agoencoding/csv: correct Column docs
Ian Lance Taylor [Fri, 18 Aug 2023 23:34:29 +0000 (16:34 -0700)]
encoding/csv: correct Column docs

For #44221
Fixes #62147

Change-Id: Ibcc0d11c8253f51a8f5771791ea4173a38a61950
Reviewed-on: https://go-review.googlesource.com/c/go/+/520917
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agoencoding/gob: prevent panic from index out of range in Decoder.typeString
Andy Pan [Fri, 18 Aug 2023 05:39:57 +0000 (13:39 +0800)]
encoding/gob: prevent panic from index out of range in Decoder.typeString

I believe this bug is introduced by CL 460543 which optimizes the allocations
by changing the type of `idToType` from map to slice, but didn't update the
access code in `Decoder.typeString` that is safe for map but not for slice.

Fixes #62117

Change-Id: I0f2e4cc2f34c54dada1f83458ba512a6fde6dcbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/520757
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

9 months agocmd/compile/internal/typecheck: remove NeedRuntimeType
Matthew Dempsky [Fri, 18 Aug 2023 08:14:50 +0000 (01:14 -0700)]
cmd/compile/internal/typecheck: remove NeedRuntimeType

The only remaining use for typecheck.NeedRuntimeType is to make sure
that method expressions with anonymous receiver types (e.g.,
"struct{T}.M") have the promoted-method wrapper generated. But the
unified frontend takes care of arranging for this now.

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

9 months agoencoding: optimize growth behavior in Encoding.AppendDecode
Joe Tsai [Thu, 17 Aug 2023 04:27:15 +0000 (21:27 -0700)]
encoding: optimize growth behavior in Encoding.AppendDecode

The Encoding.DecodedLen API only returns the maximum length of the
expected decoded output, since it does not know about padding.
Since we have the input, we can do better by computing the
input length without padding, and then perform the DecodedLen
calculation as if there were no padding.

This avoids over-growing the destination slice if possible.
Over-growth is still possible since the input may contain
ignore characters like newlines and carriage returns,
but those a rarely encountered in practice.

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

9 months agoRevert "cmd/compile/internal/gc: steps towards work-queue"
Matthew Dempsky [Sat, 19 Aug 2023 20:09:05 +0000 (20:09 +0000)]
Revert "cmd/compile/internal/gc: steps towards work-queue"

This reverts commit CL 520611.

Reason for revert: #62156.

Change-Id: Iebd17bdfc00824de3d5011a74d071a41c4fa06f1
Reviewed-on: https://go-review.googlesource.com/c/go/+/521155
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
9 months agotime: make Duration.String inlineable
Joe Tsai [Fri, 18 Aug 2023 01:13:01 +0000 (18:13 -0700)]
time: make Duration.String inlineable

Perform the [32]byte to string conversion in an inlinable method.
Thus, if the result does not escape in the context of the caller,
we can entirely avoid a call to runtime.slicebytetostring.

Change-Id: Iae8ec2a532776ed6cf99597f19e3f7f21c694c3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/520602
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agoerrors: optimize Is and As by reusing reflection of target
j178 [Fri, 18 Aug 2023 04:04:35 +0000 (12:04 +0800)]
errors: optimize Is and As by reusing reflection of target

goos: darwin
goarch: amd64
pkg: errors
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
        │     old     │                 new                 │
        │   sec/op    │   sec/op     vs base                │
Is-12     133.4n ± 0%   126.8n ± 3%   -4.91% (p=0.001 n=10)
As-12     464.1n ± 1%   307.2n ± 0%  -33.80% (p=0.000 n=10)
geomean   248.8n        197.4n       -20.66%

        │    old     │                 new                 │
        │    B/op    │    B/op     vs base                 │
Is-12     24.00 ± 0%   24.00 ± 0%       ~ (p=1.000 n=10) ¹
As-12     40.00 ± 0%   40.00 ± 0%       ~ (p=1.000 n=10) ¹
geomean   30.98        30.98       +0.00%
¹ all samples are equal

        │    old     │                 new                 │
        │ allocs/op  │ allocs/op   vs base                 │
Is-12     1.000 ± 0%   1.000 ± 0%       ~ (p=1.000 n=10) ¹
As-12     2.000 ± 0%   2.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean   1.414        1.414       +0.00%
¹ all samples are equal

Change-Id: I0844f3ab77e63b5f773594157dcffaffffd5e70d
Reviewed-on: https://go-review.googlesource.com/c/go/+/520756
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>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/compile: construct more IR nodes as typed
Matthew Dempsky [Fri, 18 Aug 2023 07:54:28 +0000 (00:54 -0700)]
cmd/compile: construct more IR nodes as typed

As of this CL, all OLITERAL, OLINKSYMOFFSET, ONIL, and OTYPE nodes are
constructed as typed and typechecked.

Change-Id: I39b2ad772a9b0419c701890a505a0949f9ea456e
Reviewed-on: https://go-review.googlesource.com/c/go/+/520795
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
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>
9 months agocmd/compile/internal/gc: steps towards work-queue
Matthew Dempsky [Fri, 18 Aug 2023 07:32:11 +0000 (00:32 -0700)]
cmd/compile/internal/gc: steps towards work-queue

This CL reorganizes the top-level functions for handling package-level
declarations, runtime type descriptors, and SSA compilation to work in
a loop. This generalizes the loop that previously existed in dumpdata.

Change-Id: I0e51e60f6ef9e7f96a4a3ccd5801f7baf83eba9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/520611
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/compile/internal/ir: remove AsNode
Matthew Dempsky [Fri, 18 Aug 2023 07:09:06 +0000 (00:09 -0700)]
cmd/compile/internal/ir: remove AsNode

Except for a single call site in escape analysis, every use of
ir.AsNode involves a types.Object that's known to contain
an *ir.Name. Asserting directly to that type makes the code simpler
and more efficient.

The one use in escape analysis is extended to handle nil correctly
without it.

Change-Id: I694ae516903e541341d82c2f65a9155e4b0a9809
Reviewed-on: https://go-review.googlesource.com/c/go/+/520775
TryBot-Bypass: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/compile/internal/typecheck: remove DeclContext
Matthew Dempsky [Fri, 18 Aug 2023 06:28:32 +0000 (23:28 -0700)]
cmd/compile/internal/typecheck: remove DeclContext

The last use of this was removed in go.dev/cl/518757.

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

9 months agocmd/compile/internal/ir: remove Ntype
Matthew Dempsky [Fri, 18 Aug 2023 06:23:40 +0000 (23:23 -0700)]
cmd/compile/internal/ir: remove Ntype

This type used to provide extra type safety around which syntactic
nodes could also represent types, but now the only remaining use is
ir.TypeNode, and it always ends up as an ir.Node anyway. So we might
as well use Node instead.

Change-Id: Ia0842864794365b0e155dc5af154c673ffa2967b
Reviewed-on: https://go-review.googlesource.com/c/go/+/520609
Run-TryBot: 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>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/compile/internal/ir: remove OFUNCINST and InstExpr
Matthew Dempsky [Fri, 18 Aug 2023 06:04:08 +0000 (23:04 -0700)]
cmd/compile/internal/ir: remove OFUNCINST and InstExpr

These were only ever used by the pre-unified generics frontend. I
initially kept them because I thought they'd be useful for the unified
frontend eventually too, but that hasn't manifested.

Change-Id: Iaa31a76ac4d62533ec269d2a7141442b8e344180
Reviewed-on: https://go-review.googlesource.com/c/go/+/520608
Auto-Submit: Matthew Dempsky <mdempsky@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>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/compile/internal/typecheck: prune some useless code
Matthew Dempsky [Fri, 18 Aug 2023 06:01:42 +0000 (23:01 -0700)]
cmd/compile/internal/typecheck: prune some useless code

This error checking code is all obsolete by types2.

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

9 months agocmd/compile: remove some uses of ir.CurFunc
Matthew Dempsky [Fri, 18 Aug 2023 05:13:22 +0000 (22:13 -0700)]
cmd/compile: remove some uses of ir.CurFunc

This CL updates several frontend passes to stop relying on
ir.CurFunc (at least directly).

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

9 months agocmd/compile/internal/typecheck: replace Temp calls with TempAt
Matthew Dempsky [Fri, 18 Aug 2023 05:19:10 +0000 (22:19 -0700)]
cmd/compile/internal/typecheck: replace Temp calls with TempAt

Steps towards eliminating implicit dependencies on base.Pos and
ir.CurFunc. Mechanical CL produced with gofmt -r.

Change-Id: I070015513cb955cbe87f9a148d81db8c0d4b0dc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/520605
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: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>

9 months agocmd/compile/internal/reflectdata: remove special case for init
Matthew Dempsky [Fri, 18 Aug 2023 05:16:07 +0000 (22:16 -0700)]
cmd/compile/internal/reflectdata: remove special case for init

Now that package initialization ordering is handled by types2 instead
of pkginit, we can get rid of this special case.

Change-Id: I4b94df02813b662498ae7d2e829119e3bb932d6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/520604
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: 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: prune some deadcode around ODCLFUNC
Matthew Dempsky [Fri, 18 Aug 2023 05:04:49 +0000 (22:04 -0700)]
cmd/compile: prune some deadcode around ODCLFUNC

An *ir.Func is always ODCLFUNC, so no need to double-check this
anymore. The type system statically ensures we have the right Op.

Also, pkginit.initRequiredForCoverage appears to be unused, so we can
get rid of it completely.

Change-Id: If1abb35672b40f705f23c365ad2a828c2661e9c0
Reviewed-on: https://go-review.googlesource.com/c/go/+/520603
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
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>
9 months agoencoding/json: use base64.Encoding.AppendEncode
Andy Pan [Fri, 18 Aug 2023 03:54:48 +0000 (11:54 +0800)]
encoding/json: use base64.Encoding.AppendEncode

For #53693

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

9 months agospec: correct type parameter name used in example
Ian Lance Taylor [Fri, 18 Aug 2023 16:44:16 +0000 (09:44 -0700)]
spec: correct type parameter name used in example

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

9 months agoruntime/internal/wasitest: skip racy TCP echo test
Chris O'Hara [Wed, 16 Aug 2023 01:14:53 +0000 (11:14 +1000)]
runtime/internal/wasitest: skip racy TCP echo test

The wasip1 TCP echo test introduced in CL 493358 has a race
condition with port selection. The test runner probes for a free
port and then asks the WASM runtime to listen on the port, which
may be taken by another process in the interim.

Due to limitations with WASI preview 1, the guest is unable to
query the port it's listening on. The test cannot ask the WASM
runtime to listen on port 0 (choose a free port) since there's
currently no way for the test to query the selected port and
connect to it.

Given the race condition is unavoidable, this test is now disabled
by default and requires opt-in via an environment variable.

This commit also eliminates the hard-coded connection timeout.

Fixes #61820.

Change-Id: I375145c1a1d03ad45c44f528da3347397e6dcb01
Reviewed-on: https://go-review.googlesource.com/c/go/+/519895
Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
9 months agoruntime/pprof: increase contention upper bound in TestMutexProfile
Michael Anthony Knyszek [Thu, 17 Aug 2023 18:36:00 +0000 (18:36 +0000)]
runtime/pprof: increase contention upper bound in TestMutexProfile

Currently TestMutexProfile expects contention to reported as somewhere
between 0.9x and 2.0x the expected amount introduced. While bounding
from below is fine (especially since the goroutine holding the mutex
doesn't even start to sleep until the required number of goroutines are
blocked on a mutex), bounding from above can easily lead to flakiness.
Delays and non-determinism can come from anywhere in the system,
and nevertheless clocks keep ticking. The result is that goroutines
could easily appear to be blocked on a mutex much longer than just the
sleep time.

However, the contention upper bound is still useful, especially for
identifying wildly incorrect values. Set the contention total to be
proportional to the total wall-time spent in the actual sampling mutex
block sampling portion of the code. This should be a generous
upper-bound on how much contention there could be, because it should in
theory capture any delays from the environment in it as well.

Still, rounding errors could be an issue, and on Windows the time
granularity is quite low (~15ms, or 15% of what each goroutine is
supposed to add to the mutex profile), so getting unlucky with where
time measurements fall within each tick could also be a problem. Add an
extra 10%, which seems to make it much less likely to fail in a Windows
gomote.

Fixes #62094.

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

9 months agocmd/link: don't mangle string symbol names
Cherry Mui [Fri, 18 Aug 2023 15:10:23 +0000 (11:10 -0400)]
cmd/link: don't mangle string symbol names

String symbol names could contain weird characters as we put the
string literal into the symbol name. So it may appear to need
mangling. However, as string symbols are grouped into a single
"go:string.*" symbol, the individual symbol names actually don't
matter. So don't mangle them.

Also make the mangling code more defensive in case of weird
symbol names.

Fixes #62098.

Change-Id: I533012567a9fffab69debda934f426421c7abb04
Reviewed-on: https://go-review.googlesource.com/c/go/+/520856
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: enable -d=zerocopy by default
Matthew Dempsky [Fri, 18 Aug 2023 00:04:10 +0000 (17:04 -0700)]
cmd/compile: enable -d=zerocopy by default

Fixes #2205.

Change-Id: Ib0802fee2b274798b35f0ebbd0b736b1be5ae00a
Reviewed-on: https://go-review.googlesource.com/c/go/+/520600
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@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>
9 months agocmd/compile: restore zero-copy string->[]byte optimization
Matthew Dempsky [Thu, 17 Aug 2023 21:15:04 +0000 (14:15 -0700)]
cmd/compile: restore zero-copy string->[]byte optimization

This CL implements the remainder of the zero-copy string->[]byte
conversion optimization initially attempted in go.dev/cl/520395, but
fixes the tracking of mutations due to ODEREF/ODOTPTR assignments, and
adds more comprehensive tests that I should have included originally.

However, this CL also keeps it behind the -d=zerocopy flag. The next
CL will enable it by default (for easier rollback).

Updates #2205.

Change-Id: Ic330260099ead27fc00e2680a59c6ff23cb63c2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/520599
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
9 months agoencoding: require unique alphabet for base32 and base64
Joe Tsai [Thu, 22 Jun 2023 18:44:55 +0000 (11:44 -0700)]
encoding: require unique alphabet for base32 and base64

In order for decoding to faithfully reproduce the encoded input,
the symbols must be unique (i.e., provide a bijective mapping).
Thus, reject duplicate symbols in NewEncoding.

As a minor optimization, modify WithPadding to use the decodeMap
to quickly check whether the padding character is used in O(1)
instead of O(32) or O(64).

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

9 months agogo/types, types2: disable interface inference for versions before Go 1.21
Robert Griesemer [Tue, 15 Aug 2023 23:37:00 +0000 (16:37 -0700)]
go/types, types2: disable interface inference for versions before Go 1.21

Change the internal constant enableInterfaceInference to a unifier
field that can be controlled dynamically and set it for Go 1.21
or later.

This restores Go 1.20 unification behavior for interfaces.

Fixes #61903.

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

9 months agoRevert "go/types, types2: remove internal constant enableInterfaceInference"
Robert Griesemer [Wed, 16 Aug 2023 18:17:01 +0000 (11:17 -0700)]
Revert "go/types, types2: remove internal constant enableInterfaceInference"

This reverts CL 514715.

This will make it easier to make interface inference conditional
based on the current language version.

For #61903.

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

9 months agospec: fix unification rule for inexact interface unification
Robert Griesemer [Mon, 14 Aug 2023 21:21:53 +0000 (14:21 -0700)]
spec: fix unification rule for inexact interface unification

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).

This change matches the fix https://go.dev/cl/519435.

For #61879.

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

9 months agocmd/compile/internal/ssagen: fix race added in CL 510539
Matthew Dempsky [Thu, 17 Aug 2023 21:18:06 +0000 (14:18 -0700)]
cmd/compile/internal/ssagen: fix race added in CL 510539

The ssagen pass runs concurrently, so it's not safe to mutate global
variables like this.

Instead, turn it into a constant and add an assertion that the
constant has the correct value.

Fixes #62095.

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

9 months agointernal/sysinfo: print cpu type from cpuinfo when internal cpu name is empty on...
Guoqi Chen [Mon, 10 Jul 2023 21:11:26 +0000 (05:11 +0800)]
internal/sysinfo: print cpu type from cpuinfo when internal cpu name is empty on Linux

Supports all linux operating systems. currently tested on x86, mips64le and loong64.

Example output:
$ go test -bench=.*
goos: linux
goarch: loong64
pkg: runtime
cpu: Loongson-3A5000-HV @ 2500.00MHz
BenchmarkSemTable/OneAddrCollision/n=1000             19261      62302 ns/op
    ...

Change-Id: I02db12d70c11327e4625bb6e59f30dfaf37c2db0
Reviewed-on: https://go-review.googlesource.com/c/go/+/508735
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Bypass: Russ Cox <rsc@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>

9 months agolog/slog: rename receiver name for the Value struct from a to v
Artem Teleshev [Tue, 15 Aug 2023 18:48:59 +0000 (18:48 +0000)]
log/slog: rename receiver name for the Value struct from a to v

Change-Id: Ib06234e781ed2faf5fa36efeda75c5ae439890ba
GitHub-Last-Rev: 760af943675ee5d44cae97ed6c33b92259d9956f
GitHub-Pull-Request: golang/go#61886
Reviewed-on: https://go-review.googlesource.com/c/go/+/517556
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
9 months agocmd/internal/buildid: don't crash on 0 phdr.p_align field
Ian Lance Taylor [Thu, 17 Aug 2023 20:03:21 +0000 (13:03 -0700)]
cmd/internal/buildid: don't crash on 0 phdr.p_align field

A 0 in phdr.p_align is the same as 1, meaning no alignment.

Fixes #62097

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

9 months agoRevert "cmd/compile: enable zero-copy string->[]byte conversions"
Matthew Dempsky [Thu, 17 Aug 2023 19:43:21 +0000 (19:43 +0000)]
Revert "cmd/compile: enable zero-copy string->[]byte conversions"

This reverts CL 520395.

Reason for revert: thanm@ pointed out failure cases.

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

9 months agocmd/compile/internal/pkginit: use typecheck.LookupRuntime for asan
Matthew Dempsky [Thu, 17 Aug 2023 08:53:16 +0000 (01:53 -0700)]
cmd/compile/internal/pkginit: use typecheck.LookupRuntime for asan

Change-Id: Ie9c90aa4560c982902738659737ae125cfcb6ba9
Reviewed-on: https://go-review.googlesource.com/c/go/+/520397
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>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/compile: enable zero-copy string->[]byte conversions
Matthew Dempsky [Thu, 17 Aug 2023 05:57:12 +0000 (22:57 -0700)]
cmd/compile: enable zero-copy string->[]byte conversions

This CL enables the latent support for string->[]byte conversions
added go.dev/cl/520259.

One catch is that we need to make sure []byte("") evaluates to a
non-nil slice, even if "" is (nil, 0). This CL addresses that by
adding a "ptr != nil" check for OSTR2BYTESTMP, unless the NonNil flag
is set.

The existing uses of OSTR2BYTESTMP (which aren't concerned about
[]byte("") evaluating to nil) are updated to set this flag.

Fixes #2205.

Change-Id: I35a9cb16c164cd86156b7560915aba5108d8b523
Reviewed-on: https://go-review.googlesource.com/c/go/+/520395
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 agocmd/compile/internal/escape: cleanup go/defer normalization cruft
Matthew Dempsky [Wed, 16 Aug 2023 22:16:19 +0000 (15:16 -0700)]
cmd/compile/internal/escape: cleanup go/defer normalization cruft

This CL removes the extra complexity from escape analysis that was
only needed to support go/defer normalization. It does not affect
analysis results at all.

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

10 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>
10 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>

10 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>
10 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>
10 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>
10 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>
10 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>

10 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>

10 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>
10 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>
10 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>
10 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>
10 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>

10 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>
10 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>
10 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>
10 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>

10 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>

10 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>
10 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>

10 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>

10 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>

10 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>
10 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>
10 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>

10 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>

10 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>
10 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>
10 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>

10 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>

10 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>

10 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>

10 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>

10 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>

10 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>
10 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>

10 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>
10 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>
10 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>
10 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>

10 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>
10 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>
10 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>

10 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>