1
0
mirror of https://github.com/golang/go synced 2024-07-05 09:50:19 +00:00
Commit Graph

59651 Commits

Author SHA1 Message Date
Alan Donovan
b24ec88bb9 cmd/compile: export/import materialized aliases
This CL changes the compiler's type import/export logic
to create and preserve materialized Alias types
when GODEBUG=gotypesaliases=1.

In conjunction with CL 574717, it allows the x/tools
tests to pass with GODEBUG=gotypesaliases=1.

Updates #65294
Updates #64581
Fixes #66550

Change-Id: I70b9279f4e0ae7a1f95ad153c4e6909a878915a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/574737
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2024-04-05 16:29:58 +00:00
Daniel Martí
2e064cf144 encoding/csv: port the go-fuzz function to native fuzzing
Beyond the required file move and refactor to use the testing package,
a number of changes were made to get the fuzzing working properly.

First, add more logs to see what is going on.

Second, some option combinations set Comma to the null character,
which simply never worked at all. I suspect the author meant to leave
the comma character as the default instead.
This was spotted thanks to the added logging.

Third, the round-trip DeepEqual check did not work at all
when any comments were involved, as the writer does not support them.

Fourth and last, massage the first and second parsed records before
comparing them with DeepEqual, as the nature of Reader and Writer
causes empty quoted records and CRLF sequences to change.

With all the changes above, the fuzzing function appears to work
normally on my laptop now. I fuzzed for a solid five minutes and
could no longer encounter any errors or panics.

Change-Id: Ie27f65f66099bdaa076343cee18b480803d2e4d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/576375
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-05 01:26:13 +00:00
Emma Haruka Iwao
fd999fda59 strings: intrinsify and optimize Compare
slices.SortFunc requires a three-way comparison and we need an
efficient strings.Compare to perform three-way string comparisons.
This new implementation adds bytealg.CompareString as a wrapper of
runtime_cmpstring and changes Compare to use bytealg.CompareString.

The new implementation of Compare with runtime_cmpstring is about
28% faster than the previous one.

Fixes #61725

                           │ /tmp/gobench-sort-cmp.txt │    /tmp/gobench-sort-strings.txt    │
                           │          sec/op           │   sec/op     vs base                │
SortFuncStruct/Size16-48                   918.8n ± 1%   726.6n ± 0%  -20.92% (p=0.000 n=10)
SortFuncStruct/Size32-48                   2.666µ ± 1%   2.003µ ± 1%  -24.85% (p=0.000 n=10)
SortFuncStruct/Size64-48                   1.934µ ± 1%   1.331µ ± 1%  -31.22% (p=0.000 n=10)
SortFuncStruct/Size128-48                  3.560µ ± 1%   2.423µ ± 0%  -31.94% (p=0.000 n=10)
SortFuncStruct/Size512-48                 13.019µ ± 0%   9.071µ ± 0%  -30.33% (p=0.000 n=10)
SortFuncStruct/Size1024-48                 25.61µ ± 0%   17.75µ ± 0%  -30.70% (p=0.000 n=10)
geomean                                    4.217µ        3.018µ       -28.44%

Change-Id: I2513b6f8c1b9b273ef2d23f0a86f691e2d097eb6
Reviewed-on: https://go-review.googlesource.com/c/go/+/532195
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Reviewed-by: Keith Randall <khr@google.com>
2024-04-04 23:39:07 +00:00
Andy Pan
99b65ae930 net: update the doc for TCPConn.SetKeepAlivePeriod on Windows
The method comment of TCPConn.SetKeepAlivePeriod had become
obsolete and inaccurate since CL 565495 and CL 570077 were merged.

For #65817

Change-Id: Ide99b2949676d452a505ba6fd634088f05c9df44
Reviewed-on: https://go-review.googlesource.com/c/go/+/576435
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
2024-04-04 22:54:49 +00:00
Andy Pan
7e9894449e internal/poll: eliminate the redundant conditional branch for isKernelVersionGE53
Follow up CL 573755

Change-Id: I27c7571d3ef1274cf2c6892e678f946f9b65de33
Reviewed-on: https://go-review.googlesource.com/c/go/+/576416
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2024-04-04 17:40:10 +00:00
Paul E. Murphy
ebf7747dbe cmd/internal/obj/ppc64: on Power10, use xxspltidp for float constants
Any normal float32 constant can be generated by this instruction;
use xxspltidp when possible. This prefixed instruction is much
faster than the two instruction load sequence from the
float32/float64 constant pool.

Change-Id: Id751d9ffdae71463adbde66427b986f0b2ef74c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/575555
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2024-04-04 15:24:29 +00:00
apocelipes
0f10ffec13 expvar: add the missing deletion step for keys
In CL575777 I forgot to remove the key from the "sync.Map".
This did not cause the test to fail due to the lack of an associated
testcase. Now delete the key correctly and add the testcase.

Change-Id: I26f770966a828caa02f1766675756b67894dc195
GitHub-Last-Rev: a351ce095b
GitHub-Pull-Request: golang/go#66675
Reviewed-on: https://go-review.googlesource.com/c/go/+/576395
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
2024-04-04 14:46:19 +00:00
cui fliter
7dd8f39eba all: fix some comments
Change-Id: I0ee85161846c13d938213ef04d3a34f690a93e48
Reviewed-on: https://go-review.googlesource.com/c/go/+/553435
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2024-04-04 14:29:45 +00:00
Liam Miller-Cushon
da6cc218cb archive/zip: fix a broken URL in a comment in writeDataDescriptor
The comment contains a dead link to a OpenJDK bug ID 7073588
this change fixes the link.

Change-Id: Ib9b10362c707507e59bb6f340d52a0025f65e292
GitHub-Last-Rev: 37af15b947
GitHub-Pull-Request: golang/go#66669
Reviewed-on: https://go-review.googlesource.com/c/go/+/576335
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-04 14:28:57 +00:00
cui fliter
deb2f89eb1 time: add available godoc link
Change-Id: Idfe9cf2f2e4750d6673455f98deef2efc2d292a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/539837
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2024-04-04 14:21:30 +00:00
cui fliter
397453f6ad strconv: add available godoc link
Change-Id: Iad58155f29a101fb72768b170c0c2c9d76b6041a
Reviewed-on: https://go-review.googlesource.com/c/go/+/539357
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: qiu laidongfeng2 <2645477756@qq.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-04-04 14:21:28 +00:00
Alan Donovan
8121604559 go/types: don't fail fast on Go version errors
Many tools (especially in the IDE) rely on type information
being computed even for packages that have some type errors.
Previously, there were two early (error) exits in checkFiles
that violated this invariant, one related to FakeImportC
and one related to a too-new Config.GoVersion.
(The FakeImportC one is rarely encountered in practice,
but the GoVersion one, which was recently downgraded from
a panic by CL 507975, was a source of crashes
due to incomplete type information.)

This change moves both of those errors out of checkFiles
so that they report localized errors and don't obstruct
type checking. A test exercises the errors, and that
type annotations are produced.

Also, we restructure and document checkFiles to make clear
that it is never supposed to stop early.

Updates #66525

Change-Id: I9c6210e30bbf619f32a21157f17864b09cfb5cf2
Reviewed-on: https://go-review.googlesource.com/c/go/+/574495
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-03 22:50:48 +00:00
Tobias Klauser
af43932c20 errors: return early for Is(nil, ...)
If err is nil it wouldn't match any given target error except for nil,
so we can return early to speed up cases where Is is used without a
preceding err != nil check.

Change-Id: Ib33cff50453fe070f06871ce8074694c81ab787b
Reviewed-on: https://go-review.googlesource.com/c/go/+/576015
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-03 22:49:49 +00:00
Felix Geisendörfer
a4440e3d23 net/http: speed up go test
Optimize the execution speed of go test ./net/http from ~38s to ~28s.
This is achieved by shortening the sleep interval utilized for
identifying goroutine leaks.

This optimization is motivated by noticing significant periods of
inactivity in the -trace output. Even after applying this CL, many
Off-CPU wait periods seem to remain:

$ go test ./net/http
ok      net/http        27.744s

real    0m28.204s
user    0m4.991s
sys     0m1.797s

Change-Id: I6108ebbb715c33900f1506d810c0a8f8ed674d35
Reviewed-on: https://go-review.googlesource.com/c/go/+/575975
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Damien Neil <dneil@google.com>
2024-04-03 22:49:46 +00:00
Jes Cok
4b2db7f60d slices: update doc for Repeat
To use (len(x) * count) consistently.

Change-Id: I45fa4383de7e05846152a8090ea5c04bc72a1727
Reviewed-on: https://go-review.googlesource.com/c/go/+/575955
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-04-03 22:46:15 +00:00
Cuong Manh Le
23fc917060 reflect: add missing String case in Value.UnsafePointer doc
CL 516596 changes Value.UnsafePointer to handle String case. However,
the method's doc comment is not updated to reflect this change.

Updates #61308

Change-Id: I84e02fd969ae0244184e1a2f05cac4651cdf7bff
Reviewed-on: https://go-review.googlesource.com/c/go/+/575956
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-03 22:44:07 +00:00
Ian Lance Taylor
968e1ce1e4 os: convert poll.ErrFileClosed to ErrClosed for Stat
Fixes #66665

Change-Id: I3e3b7433d245daa997d7d502c2ef8978af6664fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/576119
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2024-04-03 22:38:03 +00:00
apocelipes
885fdfc082 expvar: use slices to simplify the code
No effect on benchmarks.

Change-Id: I7454c21b25d5e44b9c4a39922ed470522f81872d
GitHub-Last-Rev: 5801b30dac
GitHub-Pull-Request: golang/go#66660
Reviewed-on: https://go-review.googlesource.com/c/go/+/575777
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-04-03 21:36:09 +00:00
Alan Donovan
61a3ee5441 go/types: ObjectString: remove only 1 Alias for "type A = RHS"
As we migrate towards materialized Alias types, the ObjectString
for a type A such as
   type A = B
   type B = int
should be "type A = B", removing exactly one Alias constructor
from the type of A. (The previous behavior was "type A = int".)

I suspect the existing Alias.{Unalias,Underlying} API is
inadequate and that we will need an Alias.RHS accessor that
removes exactly one Alias. Other clients such as the import/
export packages will need it, because aliases are not
isomorphic to defined types, in which, given
   type A B
   type B int
the Underlying of A is indeed int. See #66559.

Change-Id: I11a4aacbe6dbeeafc3aee31b3c096296b5970cd8
Reviewed-on: https://go-review.googlesource.com/c/go/+/574716
Auto-Submit: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-04-03 18:49:21 +00:00
Alan Donovan
6ffbcd8249 go/types: include link to source in generated files
This makes navigation a little easier.
Also, make the "inconsistent generated files" test's
error message more explicit about which file is which.

Change-Id: Iae1fb9e496fb68325448d807469a5b0c55ceda99
Reviewed-on: https://go-review.googlesource.com/c/go/+/574715
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2024-04-03 18:48:38 +00:00
Jes Cok
170862d683 slices: simplify slice expression for Replace
A slice expression of the form:
	s[a:len(s)]
will be simplified to:
	s[a:]
This is one of the simplifications that "gofmt -s" applies.

See https://pkg.go.dev/golang.org/x/tools/gopls/internal/analysis/simplifyslice

Change-Id: Ib3c01ecf24b84333fd1993a343450fc57fb8ac84
Reviewed-on: https://go-review.googlesource.com/c/go/+/575335
Reviewed-by: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Valentin Deleplace <deleplace@google.com>
2024-04-03 17:01:23 +00:00
cui fliter
d8e47e257e fmt: add available godoc link
Change-Id: Ia7eaa654b44625983d09284d906a7b67ef589696
Reviewed-on: https://go-review.googlesource.com/c/go/+/535082
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-02 21:56:20 +00:00
Olivier Mengué
cf8010d221 text/template: more godoc links
Change-Id: Ib8ea569b3cd92bbc9fa8a54f7da61207ba978bbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/574796
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-02 21:54:08 +00:00
Cuong Manh Le
d08a957298 all: add reflect.SliceAt function
Fixes #61308

Change-Id: Ic17d737fda055a60779985d5da497745c80d5cfa
Reviewed-on: https://go-review.googlesource.com/c/go/+/516597
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2024-04-02 21:51:18 +00:00
Cuong Manh Le
3d61f24835 reflect: handle String kind in Value.{Pointer,UnsafePointer}
Updates #61308

Change-Id: I92d459383c520d137787ce5c8f135d205af74e5d
Reviewed-on: https://go-review.googlesource.com/c/go/+/516596
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-02 21:51:14 +00:00
Tobias Klauser
e074fcc945 internal/poll, net, os: remove poll.Splice syscall name return value
The sc return value of internal/poll.Splice is always set to the same
value "splice" in the error case and then passed to wrapSyscallError.
Move that value to the wrapSyscallError calls to simplify the code a
bit.

Change-Id: I98104d755da68ff9f301fabc43c2618fda21a175
Reviewed-on: https://go-review.googlesource.com/c/go/+/575655
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2024-04-02 21:49:26 +00:00
guoguangwu
b6efc3b755 cmd/go/internal/modload: close modules.txt
Change-Id: Ieb4cf76f4d7050d2f3052c2f90e47901de74d641
GitHub-Last-Rev: 1e8dcfd651
GitHub-Pull-Request: golang/go#66629
Reviewed-on: https://go-review.googlesource.com/c/go/+/575475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
2024-04-02 20:07:23 +00:00
Cuong Manh Le
5038ce82b6 cmd/compile: add missing OASOP case in mayModifyPkgVar
CL 395541 made staticopy safe, stop applying the optimization once
seeing an expression that may modify global variables. However, it
misses the case for OASOP expression, causing the static init
mis-recognizes the modification and think it's safe.

Fixing this by adding missing OASOP case.

Fixes #66585

Change-Id: I603cec018d3b5a09825c14e1f066a0e16f8bde23
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/575216
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-02 17:16:14 +00:00
Cuong Manh Le
973befe714 cmd/compile: check ODEREF for safe lhs in assignment during static init
For #66585

Change-Id: Iddc407e3ef4c3b6ecf5173963b66b3e65e43c92d
Reviewed-on: https://go-review.googlesource.com/c/go/+/575336
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-04-02 17:12:59 +00:00
Austin Clements
94dba61276 internal/abi: clean up type of Kind and Type.Kind_
Currently, Type.Kind_ is a uint8, Kind is a uint, and some of the
abi.Kind consts are not of type Kind. Clean this all up by making Kind
a uint8, then making Type.Kind a Kind, and finally making all Kind
consts actually have type Kind. This has some ripple effect, but I
think all of the changes are improvements.

Change-Id: If39be74699c2cdb52bf0ad7092d392bc8fb68d15
Reviewed-on: https://go-review.googlesource.com/c/go/+/575579
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-02 16:25:18 +00:00
guoguangwu
cb6d15a747 cmd/compile/internal/ssa: fix typos in comment and log
Change-Id: Ic872bac2989ea1c83f31456eb334e6d756ebd7d1
GitHub-Last-Rev: d409884979
GitHub-Pull-Request: golang/go#66612
Reviewed-on: https://go-review.googlesource.com/c/go/+/575296
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
2024-04-02 16:11:47 +00:00
cui fliter
e0cd90528e reflect: add available godoc link
Change-Id: Ib199ce1a781e8e3a66d3dc8bda617e6bc30b290e
Reviewed-on: https://go-review.googlesource.com/c/go/+/539578
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
2024-04-02 15:20:05 +00:00
qiulaidongfeng
daaf1f2220 all: use kind* of abi
For #59670

Change-Id: Id66e102f13e529dd041b68ce869026a56f0a1b9b
GitHub-Last-Rev: 43aa9376f7
GitHub-Pull-Request: golang/go#65564
Reviewed-on: https://go-review.googlesource.com/c/go/+/562298
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Austin Clements <austin@google.com>
2024-04-02 15:10:48 +00:00
Tobias Klauser
e3ec1ca17e os: define wrapSyscallError only on linux
wrapSyscallError by now is only used on linux in the methods defined in
os/zero_copy_linux.go. Move the definition there.

Change-Id: I0ca5749adaac44e8d095b8452458b647f595d3c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/575595
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2024-04-02 15:01:40 +00:00
Shengyu Zhang
88b1d6115a encoding/json: prevent duplicate slicebytetostring
When storing literal to JSON number v, if s is valid number, the slicebytetostring operation will be performed twice. In fact, the operation is unavoidable on any code path, so just perform it at the very beginning.

This is not a big optimization, but better than nothing:

    $ ../bin/go test ./encoding/json/ -bench UnmarshalNumber -run NOTEST -benchtime 10000000x -count 16  > old.txt
    $ ../bin/go test ./encoding/json/ -bench UnmarshalNumber -run NOTEST -benchtime 10000000x -count 16  > new.txt
    $ benchstat old.txt new.txt
                      │   old.txt   │              new.txt               │
                      │   sec/op    │   sec/op     vs base               │
    UnmarshalNumber-8   234.5n ± 3%   228.2n ± 4%  -2.67% (p=0.033 n=16)

                      │  old.txt   │            new.txt             │
                      │    B/op    │    B/op     vs base            │
    UnmarshalNumber-8   168.0 ± 0%   168.0 ± 0%  ~ (p=1.000 n=16) ¹
    ¹ all samples are equal

                      │  old.txt   │            new.txt             │
                      │ allocs/op  │ allocs/op   vs base            │
    UnmarshalNumber-8   2.000 ± 0%   2.000 ± 0%  ~ (p=1.000 n=16) ¹
    ¹ all samples are equal

Change-Id: I1dfdb1ed0883e385f753b2046b7f047c792aa4e3
GitHub-Last-Rev: d236dd7265
GitHub-Pull-Request: golang/go#61242
Reviewed-on: https://go-review.googlesource.com/c/go/+/508556
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-04-02 15:00:17 +00:00
Olivier Mengué
0611816216 regexp/syntax: cleanup code generation in perl_groups.go
Cleanup code generation of perl_groups.go:
* Fix the generated code header to follow the standard https://go.dev/s/generatedcode
* Apply gofmt as last step of code generation
* Add //go:generate lines in parse.go to trigger code generation
* Adapt make_perl_groups.pl to handle writing directly to the output
  file (as we can't use shell redirection in go:generate lines)
* use strict; use warnings;

Change-Id: I675241da03dd3f6facc9eb9de00999bd9203ad70
Reviewed-on: https://go-review.googlesource.com/c/go/+/555995
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-02 13:59:01 +00:00
aimuz
be50b58d70 internal/zstd: optimize window reset using make for buffer allocation
Optimize the zstd window's reset function to use `make` for buffer
allocation when needed. This ensures efficient memory usage by
conditionally reallocating the buffer based on its capacity, improving
performance in scenarios where the existing buffer is insufficient.

```
goos: darwin
goarch: amd64
pkg: internal/zstd
cpu: Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
         │   old.out   │            new.out            │
         │   sec/op    │   sec/op     vs base          │
Large-12   7.299m ± 5%   7.235m ± 1%  ~ (p=0.353 n=10)

         │   old.out    │            new.out             │
         │     B/s      │     B/s       vs base          │
Large-12   35.56Mi ± 4%   35.87Mi ± 1%  ~ (p=0.353 n=10)

         │   old.out    │               new.out                │
         │     B/op     │     B/op      vs base                │
Large-12   68.86Ki ± 4%   15.87Ki ± 1%  -76.95% (p=0.000 n=10)

         │  old.out   │            new.out             │
         │ allocs/op  │ allocs/op   vs base            │
Large-12   0.000 ± 0%   0.000 ± 0%  ~ (p=1.000 n=10) ¹
¹ all samples are equal
```

Change-Id: Icd9c278b42ea149107a9861d006f40129c59831b
GitHub-Last-Rev: c00344cca4
GitHub-Pull-Request: golang/go#64221
Reviewed-on: https://go-review.googlesource.com/c/go/+/543375
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-04-02 13:49:23 +00:00
Alan Donovan
3b29222ffd cmd: update vendored x/tools to 904c6ba
This fixes one of the many obstacles to enabling
types.Alias by updating vet.

The 'loopclosure' checker (formerly 'rangeloop') no longer
reports any findings with go1.22, so the test needed work
to ensure that it still runs on files with go1.21 semantics.

Updates #65294

Change-Id: I987ff529d4e165b56b7241563c6003e63bf92bb1
Reviewed-on: https://go-review.googlesource.com/c/go/+/575315
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-02 02:20:05 +00:00
Mohammad Abbasi
e565720e49 database/sql: refactor unused variables to use blank identifiers
Hi
I've replaced unused variables in database/sql with blank identifiers to improve code readability.

This change has no impact on the functionality of the code, but makes it easier to read and understand.

Change-Id: I701e93fd9bf86725f411085bf2e8f8e6b235af14
GitHub-Last-Rev: eb40bd5e2e
GitHub-Pull-Request: golang/go#58986
Reviewed-on: https://go-review.googlesource.com/c/go/+/475675
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-02 01:32:55 +00:00
Michael Matloob
cd294f55ca cmd: update and vendor golang.org/x/telemetry@3640ba5
Commands run:
	go get golang.org/x/telemetry@3640ba5
	go mod vendor
	go mod tidy

This pulls in golang.org/cl/574815, fixing #66344

Fixes #66344

Change-Id: Ib5a0c4fc1e0bd44dbc13453ec1dade89a8d96f70
Reviewed-on: https://go-review.googlesource.com/c/go/+/575575
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
2024-04-01 20:28:41 +00:00
Paul E. Murphy
dfb17c126c cmd/compile: support float min/max instructions on PPC64
This enables efficient use of the builtin min/max function
for float64 and float32 types on GOPPC64 >= power9.

Extend the assembler to support xsminjdp/xsmaxjdp and use
them to implement float min/max.

Simplify the VSX xx3 opcode rules to allow FPR arguments,
if all arguments are an FPR.

Change-Id: I15882a4ce5dc46eba71d683cf1d184dc4236a328
Reviewed-on: https://go-review.googlesource.com/c/go/+/574535
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2024-04-01 18:50:29 +00:00
guoguangwu
a49952445f cmd/compile: close files in the startProfile function
Change-Id: I803d625249890c88fbf35394a85e0b2952123620
GitHub-Last-Rev: 239b28e857
GitHub-Pull-Request: golang/go#66532
Reviewed-on: https://go-review.googlesource.com/c/go/+/574336
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-04-01 17:19:20 +00:00
qmuntal
7c89ad6a80 os: support relative paths in fixLongPath
(This CL takes the tests and some ideas from the abandoned CL 263538).

fixLongPath is used on Windows to process all path names
before syscalls to switch them to extended-length format
(with prefix \\?\) to workaround a historical limit
of 260-ish characters.

This CL updates fixLongPath to convert relative paths to absolute
paths if the working directory plus the relative path exceeds
MAX_PATH. This is necessary because the Windows API does not
support extended-length paths for relative paths.

This CL also adds support for fixing device paths (\\.\-prefixed),
which were not previously normalized.

Fixes #41734
Fixes #21782
Fixes #36375

Cq-Include-Trybots: luci.golang.try:gotip-windows-amd64-longtest,gotip-windows-amd64-race,gotip-windows-arm64
Co-authored-by: Giovanni Bajo <rasky@develer.com>
Change-Id: I63cfb79f3ae6b9d42e07deac435b730d97a6f492
Reviewed-on: https://go-review.googlesource.com/c/go/+/574695
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2024-04-01 14:34:38 +00:00
apocelipes
6bfaafd3c3 database/sql: use slices to simplify the code
Change-Id: Ia198272330626271ee7d4e1ae46afca819ab2933
GitHub-Last-Rev: e713ac3163
GitHub-Pull-Request: golang/go#66572
Reviewed-on: https://go-review.googlesource.com/c/go/+/574995
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
2024-04-01 12:38:07 +00:00
Kévin Dunglas
d49a14c609 cmd/cgo: update outdated docs about cgocheck2
Setting GODEBUG=cgocheck=2 now panics with a message
such as "fatal error: cgocheck > 1 mode is no longer supported at runtime.
Use GOEXPERIMENT=cgocheck2 at build time instead."

Change-Id: If9a5a96933973e14a1a60b8e9fb6a1f4a818cf59
GitHub-Last-Rev: 787d62454c
GitHub-Pull-Request: golang/go#65224
Reviewed-on: https://go-review.googlesource.com/c/go/+/557597
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-31 09:02:45 +00:00
guoguangwu
ba9c445f16 cmd/go: close elf file in the readpkglist function
Change-Id: Ief08e311598152f047878fc0fe6a6e37df372ee9
GitHub-Last-Rev: daec402b39
GitHub-Pull-Request: golang/go#66588
Reviewed-on: https://go-review.googlesource.com/c/go/+/575156
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-03-30 00:20:35 +00:00
Cuong Manh Le
0bf6071066 Revert "cmd/compile/internal: merge stack slots for selected local auto vars"
This reverts CL 553055.

Reason for revert: causes crypto/ecdsa failures on linux ppc64/s390x builders

Change-Id: I9266b030693a5b6b1e667a009de89d613755b048
Reviewed-on: https://go-review.googlesource.com/c/go/+/575236
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-30 00:11:00 +00:00
Than McIntosh
89f7805c2e cmd/compile/internal: merge stack slots for selected local auto vars
Preliminary compiler support for merging/overlapping stack
slots of local variables whose access patterns are disjoint.

This patch includes changes in AllocFrame to do the actual
merging/overlapping based on information returned from a new
liveness.MergeLocals helper. The MergeLocals helper identifies
candidates by looking for sets of AUTO variables that either A) have
the same size and GC shape (if types contain pointers), or B) have the
same size (but potentially different types as long as those types have
no pointers). Variables must be greater than (3*types.PtrSize) in size
to be considered for merging.

After forming candidates, MergeLocals collects variables into "can be
overlapped" equivalence classes or partitions; this process is driven
by an additional liveness analysis pass. Ideally it would be nice to
move the existing stackmap liveness pass up before AllocFrame
and "widen" it to include merge candidates so that we can do just a
single liveness as opposed to two passes, however this may be difficult
given that the merge-locals liveness has to take into account
writes corresponding to dead stores.

This patch also required a change to the way ssa.OpVarDef pseudo-ops
are generated; prior to this point they would only be created for
variables whose type included pointers; if stack slot merging is
enabled then the ssagen code creates OpVarDef ops for all auto vars
that are merge candidates.

Note that some temporaries created late in the compilation process
(e.g. during ssa backend) are difficult to reason about, especially in
cases where we take the address of a temp and pass it to the runtime.
For the time being we mark most of the vars created post-ssagen as
"not a merge candidate".

Stack slot merging for locals/autos is enabled by default if "-N" is
not in effect, and can be disabled via "-gcflags=-d=mergelocals=0".

Fixmes/todos/restrictions:
- try lowering size restrictions
- re-evaluate the various skips that happen in SSA-created autotmps

Fixes #62737.
Updates #65532.
Updates #65495.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Change-Id: Ibc22e8a76c87e47bc9fafe4959804d9ea923623d
Reviewed-on: https://go-review.googlesource.com/c/go/+/553055
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-29 23:09:29 +00:00
Daniel Martí
754f870381 crypto/tls,regexp: remove always-nil error results
These were harmless, but added unnecessary verbosity to the code.
This can happen as a result of refactors: for example,
the method sessionState used to return errors in some cases.

Change-Id: I4e6dacc01ae6a49b528c672979f95cbb86795a85
Reviewed-on: https://go-review.googlesource.com/c/go/+/528995
Reviewed-by: Leo Isla <islaleo93@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Olivier Mengué <olivier.mengue@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2024-03-29 22:22:45 +00:00
Than McIntosh
dcf046f021 cmd/compile/internal: refactor coverage ir.Name flags
Minor refactoring to eliminate one of the ir.Name flag values used
when building in coverage mode (no changes to functionality). This is
intended to free up a bit in the uint16 flags field to be used in a
subsequent patch.

Change-Id: I4aedb9a55fde24c808ff3f7b077ee0552aa979af
Reviewed-on: https://go-review.googlesource.com/c/go/+/572055
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-03-29 21:55:46 +00:00