1
0
mirror of https://github.com/golang/go synced 2024-10-01 09:28:37 -06:00
Commit Graph

57718 Commits

Author SHA1 Message Date
Tobias Klauser
21481a3c52 net: remove unused ipv4AddrToInterface
It's unused since CL 6497044.

Change-Id: Iee07e7af7b80fc3f00146b64cebead844daee087
Reviewed-on: https://go-review.googlesource.com/c/go/+/522196
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-08-25 15:06:47 +00:00
korzhao
ddad9b618c encoding/json: avoid allocation when decoding number types
In CL 345488, we optimized strconv.ParseXXX for []byte arguments.
That allows immediate casting of a []byte to a string that does not escape to be copied on the stack.

Performance:

	goos: darwin
	goarch: arm64
	pkg: encoding/json
				old sec/op	new sec/op	delta
	CodeUnmarshal-10        3.019m ± 6%   2.865m ± 10%   -5.10% (p=0.043 n=10)
	CodeUnmarshalReuse-10   2.528m ± 4%   2.274m ± 13%  -10.03% (p=0.009 n=10)
	geomean                 2.762m        2.553m         -7.60%

				old B/s		new B/s		delta
	CodeUnmarshal-10        613.1Mi ± 5%   646.0Mi ±  9%   +5.37% (p=0.043 n=10)
	CodeUnmarshalReuse-10   732.1Mi ± 4%   813.7Mi ± 12%  +11.15% (p=0.009 n=10)
	geomean                 669.9Mi        725.0Mi         +8.22%

				old B/op	new B/op	delta
	CodeUnmarshal-10         2.782Mi ± 0%   1.918Mi ± 0%  -31.04% (p=0.000 n=10)
	CodeUnmarshalReuse-10   1600.8Ki ± 0%   713.3Ki ± 0%  -55.44% (p=0.000 n=10)
	geomean                  2.085Mi        1.156Mi       -44.57%

				old allocs/op 	new allocs/op 	delta
	CodeUnmarshal-10        91.31k ± 0%   39.99k ± 0%  -56.20% (p=0.000 n=10)
	CodeUnmarshalReuse-10   76.58k ± 0%   25.23k ± 0%  -67.06% (p=0.000 n=10)
	geomean                 83.62k        31.76k       -62.02%

Change-Id: I208c57089040daee0f9d979d1df725e3acf34f81
Reviewed-on: https://go-review.googlesource.com/c/go/+/518277
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2023-08-25 08:50:27 +00:00
korzhao
4c5dac7202 encoding/json: optimize Marshal for maps
Optimize marshaling of maps by using slices.SortFunc.

This drops an unnecessary field from reflectWithString,
which also reduces the cost of each swap operation.

benchmark                  old ns/op     new ns/op     delta
BenchmarkMarshalMap-10     228           139           -39.24%

benchmark                  old allocs     new allocs     delta
BenchmarkMarshalMap-10     11             8              -27.27%

benchmark                  old bytes     new bytes     delta
BenchmarkMarshalMap-10     432           232           -46.30%

Change-Id: Ic2ba7a1590863c7536305c6f6536372b26ec9b0c
Reviewed-on: https://go-review.googlesource.com/c/go/+/515176
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-08-25 08:50:07 +00:00
qmuntal
dd38ade8d1 os: omit existence check for GetFinalPathNameByHandle
GetFinalPathNameByHandle exists since Windows Vista, which we no longer
support, so we don't need to prove that it exists before using it.

Updates #57003

Change-Id: Iff2bbe51d3baa3aabcaacf39ea3cbeda0088b9d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/522195
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-08-25 08:48:18 +00:00
Joel Sing
0a17b2c174 cmd/internal/obj/arm64: load large constants into vector registers from rodata
Load large constants into vector registers from rodata, instead of placing them
in the literal pool. This treats VMOVQ/VMOVD/VMOVS the same as FMOVD/FMOVS and
makes use of the existing mechanism for storing values in rodata. Two additional
instructions are required for a load, however these instructions are used
infrequently and already have a high latency.

Updates #59615

Change-Id: I54226730267689963d73321e548733ae2d66740e
Reviewed-on: https://go-review.googlesource.com/c/go/+/515617
Reviewed-by: Eric Fang <eric.fang@arm.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-08-25 06:31:28 +00:00
Ian Lance Taylor
a5ab4a9471 net/http: use reflect.TypeFor for known types
For #60088

Change-Id: I9e4044d9c2694fe86aab1f5220622c8d952b1a90
Reviewed-on: https://go-review.googlesource.com/c/go/+/522338
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-08-24 23:54:51 +00:00
Matthew Dempsky
88cb17e106 cmd/compile: create "init" function during noding
This CL arranges for package-scope initialization statements to be
constructed directly into their eventual "init" function, so we can
eliminate the roundabout solution of using InitTodoFunc.

While here, somewhat simplify and generalize the logic for outlining
map initialization statements.

Change-Id: I8aff042e6b266f7024de436424ec6711b8b69129
Reviewed-on: https://go-review.googlesource.com/c/go/+/522318
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@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>
2023-08-24 23:19:42 +00:00
Matthew Dempsky
cf68384674 cmd/compile/internal/gc: steps towards work-queue
[This is a reattempt of go.dev/cl/520611.]

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: I7502798a8662b3cec92d3001169f3af4f804df2a
Reviewed-on: https://go-review.googlesource.com/c/go/+/522339
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-24 23:18:16 +00:00
Tobias Klauser
96b6e78ea9 cmd/compile/internal/syntax: use strings.LastIndexByte in trailingDigits
Previously, strings.LastIndexByte couldn't be used because it was only
added in Go 1.5 but Go 1.4 was required for bootstrapping. In Go 1.18,
the bootstrap toolchain was bumped to Go 1.17 (see #44505), thus
strings.LastIndexByte can be used now.

Change-Id: I01a70a59dbfc853cf03d49747a2dd62d21ba74e9
Reviewed-on: https://go-review.googlesource.com/c/go/+/522197
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2023-08-24 20:39:18 +00:00
Austin Clements
e63be91667 cmd/go: clarify promotion of C warnings to errors
CL 23005 (back in 2016!) added logic to promote C compiler warnings to
errors when running on the Go builders.

CL 437298 kept the logic to promote warnings to errors on the
builders, but dropped the explanatory message, I believe
unintentionally. Indeed, now there isn't even a comment in the code
explaining what's going on.

This CL adds back an explanatory message to the printed output, which
also serves as a explanation in the code as to why we're checking
$GO_BUILDER_NAME.

Change-Id: I769c55d213f96f73d20a41ab926fb91e71a5a22c
Reviewed-on: https://go-review.googlesource.com/c/go/+/522775
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-24 19:48:50 +00:00
mstmdev
f0b05092fd cmd/internal/goobj: fix the size of Header
Missed the length of the Fingerprint field.

Change-Id: I690955466895e73821dc1e30f8400efc30338ae6
GitHub-Last-Rev: 87bd06d805
GitHub-Pull-Request: golang/go#62174
Reviewed-on: https://go-review.googlesource.com/c/go/+/521495
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Carlos Amedee <carlos@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-08-24 18:14:04 +00:00
Luka Krmpotić
7497ccb9b4 strconv: add missing function name, avoid unnecessary raw string
Change-Id: Iecd68f69f5265f1a4ea41b90aa819ce68fe55908
GitHub-Last-Rev: 4d1f4a1bc2
GitHub-Pull-Request: golang/go#62177
Reviewed-on: https://go-review.googlesource.com/c/go/+/521277
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-08-24 18:08:43 +00:00
Damien Neil
99a174f06e net/http: remove arbitrary timeout from TestTransportGCRequest
This test expects a *Request to be garbage collected
within five seconds. Some slow builders take longer.
Drop the arbitrary timeout.

Fixes #56809

Change-Id: I4b5bdce09002a5b52b7b5d0b33e7876d48740bc3
Reviewed-on: https://go-review.googlesource.com/c/go/+/522615
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-24 18:02:42 +00:00
Bryan C. Mills
5374c1aaf5 cmd/internal/testdir: parse past gofmt'd //go:build lines
Also gofmt a test file to make sure the parser works.

Fixes #62267.

Change-Id: I9b9f12b06bae7df626231000879b5ed7df3cd9ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/522635
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-08-24 17:52:48 +00:00
Tobias Klauser
65c133506f runtime: remove unused F_{GET,SET}FL cgo constants on solaris and openbsd
The generated constants were already removed by CL 497076, so the cgo
constants used to generate them are no longer needed as well.

Change-Id: I37dabd800461d134424af8bd72fb0c1b8504d604
Reviewed-on: https://go-review.googlesource.com/c/go/+/509676
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2023-08-24 17:47:39 +00:00
Bryan C. Mills
db24f63b10 syscall: skip TestUnshareMountNameSpaceChroot on platforms that require external linking
TestUnshareMountNameSpaceChroot attempts to build a statically-linked
binary to run in a chroot, and sets CGO_ENABLED=0 in order to do so.
Rather than trying to figure out some other way to coax the linker
into building a static binary, let's just skip the test on Linux
platforms that require external linking (namely android/arm).

This should fix the build failure reported in
https://build.golang.org/log/1ea245a9c2e916c81043db177be76778bab00058.

While we're here, let's also fix the failure logging to make the text
readable!

Updates #46330.

Change-Id: I4fa07640ce012ac141bf4698bc3215a7f146062c
Reviewed-on: https://go-review.googlesource.com/c/go/+/522182
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-24 17:32:08 +00:00
Bryan C. Mills
fe2c686b63 test/fixedbugs: require cgo for issue10607.go
This test passes "-linkmode=external" to 'go run' to link the binary
using the system C linker.

CGO_ENABLED=0 explicitly tells cmd/go not to use the C toolchain,
so the test should not be run in that configuration.

Updates #46330.

Change-Id: I16ac66aac91178045f9decaeb28134061e9711f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/522495
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-08-24 17:19:11 +00:00
Matthew Dempsky
d5c5808534 cmd/compile/internal/syntax: add Unparen and UnpackListExpr helpers
We've added Unparen to go/ast, so add syntax.Unparen to be
consistent (and because it's similarly useful).

Also, types2 and noder both have similar functions for unpacking
ListExprs, so might as well add a common implementation in package
syntax too.

Finally, addressing the TODO: UnpackListExpr is small enough to be
inlined (when default optimizations are enabled), and for typical uses
of UnpackListExpr (e.g., "range UnpackListExpr(x)") the single-element
slice result is stack allocated in the caller. This CL adds a test
using testing.AllocsPerRun to ensure this remains so in the future.

Change-Id: I96a5591d202193ed5bf1ce6f290919107e3dc01b
Reviewed-on: https://go-review.googlesource.com/c/go/+/522336
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2023-08-24 07:17:27 +00:00
cui fliter
43e69b330a cmd/compile/internal: fix receiver names are different
Change-Id: I78a7d34a6e2558ecff0274170bffaa51e038d0bc
Reviewed-on: https://go-review.googlesource.com/c/go/+/522415
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Auto-Submit: Keith Randall <khr@golang.org>
2023-08-24 06:39:50 +00:00
Cuong Manh Le
86f0f08461 cmd/compile: use s.temp for creating defer struct
Follow discussion in go.dev/cl/521676.

Change-Id: Ie5c0ce66b60fcbfd59385e8c2c45d431133ab53a
Reviewed-on: https://go-review.googlesource.com/c/go/+/522115
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-23 22:40:36 +00:00
Bryan C. Mills
079dfdcac0 cmd/go: error out of linking package main if cgo is required but not enabled
Fixes #46330.
Fixes #62123.
Updates #31544.

Change-Id: I023aa2bdb5a24e126a0de5192a077e8cf1a0a67c
Reviewed-on: https://go-review.googlesource.com/c/go/+/522239
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-23 21:55:28 +00:00
Joe Tsai
2763146099 encoding/json: encode \b and \f as '\b' and '\f' in JSON strings
According to RFC 8259, there are exactly 5 control characters
that have a shorter escape sequence than the generic \uXXXX format.

Over the years, we added ad-hoc support for the short sequences:
* https://go.dev/cl/4678046 supports \r and \n
* https://go.dev/cl/162340043 supports \t

This CL completes the set by supporting \b and \f.

This may change the encoding of strings in relatively rare cases,
but is a permissible change since the Go 1 compatibility document does
not guarantee that "json" produces byte-for-byte identical outputs.

In fact, we have made even more observable output changes in the past
such as with https://go.dev/cl/30371 which changes the representation
of many JSON numbers.

This change is to prepare the path forward for a potential
v2 "json" package, which has more consistent encoding of JSON strings.

Change-Id: I11102a0602dfb1a0c14eaad82ed23e8df7553c6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/521675
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-08-23 21:37:55 +00:00
Bryan C. Mills
738d2d9068 os: use testenv.Command and os.Executable in tests
On Unix platforms, testenv.Command sends SIGQUIT to stuck commands
before the test times out. For subprocesses that are written in Go,
that causes the runtime to dump running goroutines, and in other
languages it triggers similar behavior (such as a core dump).
If the subprocess is stuck due to a bug (such as #57999), that may
help to diagnose it.

For #57999.

Change-Id: I00f381b8052cbbb1a7eea90e7f102a3f68c842d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/521817
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2023-08-23 19:03:28 +00:00
Matthew Dempsky
f92741b1d8 cmd/compile/internal/noder: elide statically known "if" statements
In go.dev/cl/517775, I moved the frontend's deadcode elimination pass
into unified IR. But I also made a small enhancement: a branch like
"if x || true" is now detected as always taken, so the else branch can
be eliminated.

However, the inliner also has an optimization for delaying the
introduction of the result temporary variables when there's a single
return statement (added in go.dev/cl/266199). Consequently, the
inliner turns "if x || true { return true }; return true" into:

	if x || true {
		~R0 := true
		goto .i0
	}
	.i0:
	// code that uses ~R0

In turn, this confuses phi insertion, because it doesn't recognize
that the "if" statement is always taken, and so ~R0 will always be
initialized.

With this CL, after inlining we instead produce:

	_ = x || true
	~R0 := true
	goto .i0
	.i0:

Fixes #62211.

Change-Id: Ic8a12c9eb85833ee4e5d114f60e6c47817fce538
Reviewed-on: https://go-review.googlesource.com/c/go/+/522096
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-08-23 18:01:55 +00:00
Tobias Klauser
aa0ba4dcaf net: use internal/bytealg.CountString
On platforms that provide a native implementation this might be slightly
faster. On other platforms it is equivalent to the count func.

Change-Id: If46cc65598993e64084cc98533cb8c1e9679a6fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/522136
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2023-08-23 16:39:35 +00:00
Tobias Klauser
a97f71578f net: remove unused func appendHex
It's unused since CL 463987.

Change-Id: Ic28fd3b4a613cd7b43f817118841d40e3005a5fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/522135
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2023-08-23 16:39:32 +00:00
Alexander Yastrebov
184540e955 net/http: revert fix request canceler leak on connection close
This reverts CL 515796 due to a flaking test.

Updates #61708
Fixes #62224

Change-Id: I53911a07677d08c3196daaaa2708269593baf472
GitHub-Last-Rev: 3544648ecc
GitHub-Pull-Request: golang/go#62233
Reviewed-on: https://go-review.googlesource.com/c/go/+/522097
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-08-23 15:58:12 +00:00
Michael Anthony Knyszek
081d27a2e5 runtime: create wrappers for gcDrain to identify time in profiles
Currently it's impossible to identify in profiles where gcDrain-related
time is coming from. More specifically, what kind of worker. Create
trivial wrappers for each worker so that the difference shows up in
stack traces.

Also, clarify why gcDrain disables write barriers.

Change-Id: I966e3c0b1c583994e691f486bf0ed8cabb91dbbb
Reviewed-on: https://go-review.googlesource.com/c/go/+/521815
Reviewed-by: Austin Clements <austin@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-23 15:49:39 +00:00
Joel Sing
e68c027204 cmd/internal/obj/riscv,cmd/link: add support for internal cgo linking on riscv64
Make it possible to internally link cgo on riscv64, which also adds
support for SDYNIMPORT calls without external linking being required.

This reduces the time of an ./all.bash run on a Sifive Hifive Unleashed by
approximately 20% (~140 minutes down to ~110 minutes).

Change-Id: I43f1348de31672718ae8676cc82f6fdc1dfee054
Reviewed-on: https://go-review.googlesource.com/c/go/+/431104
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-08-23 05:58:20 +00:00
Joel Sing
70a8a41e97 cmd/go/testdata/mod: add golang toolchain test data for openbsd/ppc64
Updates #56001

Change-Id: Ic7b4ecb2e471292894c54610e8acda8822c890fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/518275
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-23 05:14:41 +00:00
Joel Sing
7f92dcc88d cmd/link: add support for openbsd/ppc64
Add linker support for the openbsd/ppc64 port.

Updates #56001

Change-Id: I18bc19b4086599996aebfbe68f2e85e1200589ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/475619
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Eric Grosse <grosse@gmail.com>
2023-08-23 05:14:11 +00:00
Keith Randall
4711299661 cmd/compile: use jump tables for large type switches
For large interface -> concrete type switches, we can use a jump
table on some bits of the type hash instead of a binary search on
the type hash.

name                        old time/op  new time/op  delta
SwitchTypePredictable-24    1.99ns ± 2%  1.78ns ± 5%  -10.87%  (p=0.000 n=10+10)
SwitchTypeUnpredictable-24  11.0ns ± 1%   9.1ns ± 2%  -17.55%  (p=0.000 n=7+9)

Change-Id: Ida4768e5d62c3ce1c2701288b72664aaa9e64259
Reviewed-on: https://go-review.googlesource.com/c/go/+/521497
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
2023-08-23 00:30:54 +00:00
Keith Randall
556e9c5f3e cmd/compile: allow non-pointer writes in the middle of a write barrier
This lets us combine more write barriers, getting rid of some of the
test+branch and gcWriteBarrier* calls.
With the new write barriers, it's easy to add a few non-pointer writes
to the set of values written.

We allow up to 2 non-pointer writes between pointer writes. This is enough
for, for example, adjacent slice fields.

Fixes #62126

Change-Id: I872d0fa9cc4eb855e270ffc0223b39fde1723c4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/521498
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2023-08-23 00:16:06 +00:00
cui fliter
0163b3b32c all: remove redundant string conversions when formatting []byte with %s
Change-Id: I603051a3174b139ffb81d20d42979c7f3f04a09a
Reviewed-on: https://go-review.googlesource.com/c/go/+/521136
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-22 22:52:37 +00:00
Alexander Yastrebov
291a32aa4b net/http: fix request canceler leak on connection close
Due to a race condition persistConn could be closed without removing request canceler.

Note that without the fix test occasionally passes and to demonstrate the issue it has to be run multiple times, e.g. using -count=10.

Fixes #61708

Change-Id: I9029d7d65cf602dd29ee1b2a87a77a73e99d9c92
GitHub-Last-Rev: 6b31f9826d
GitHub-Pull-Request: golang/go#61745
Reviewed-on: https://go-review.googlesource.com/c/go/+/515796
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-08-22 22:22:23 +00:00
Bryan C. Mills
4dc2564933 cmd/go: retry ETXTBSY errors when running test binaries
An ETXTBSY error when starting a test binary is almost certainly
caused by the race reported in #22315. That race will resolve quickly
on its own, so we should just retry the command instead of reporting a
spurious failure.

Fixes #62221.

Change-Id: I408f3eaa7ab5d7efbc7a2b1c8bea3dbc459fc794
Reviewed-on: https://go-review.googlesource.com/c/go/+/522015
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-08-22 22:09:34 +00:00
Ian Lance Taylor
52e17c2e4d runtime/cgo: get getstackbound for set_stacklo
Change-Id: Ia63a4604449b5e460e6f54c962fb7d6db2bc6a43
Reviewed-on: https://go-review.googlesource.com/c/go/+/519457
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-08-22 22:06:46 +00:00
Matthew Dempsky
21293b6b87 cmd/compile/internal/typecheck: use types.IsMethodApplicable
In checking whether a type implements an interface, there's this
complex predicate spanning multiple lines, which is very obtuse.

So let's just use the helper function we already have in package types
instead.

Change-Id: I80f69d41c2bee8d6807601cf913840fa4f042b5e
Reviewed-on: https://go-review.googlesource.com/c/go/+/521435
Run-TryBot: 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>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-08-22 21:18:01 +00:00
Matthew Dempsky
08a08083c1 cmd/compile/internal/typecheck: merge SubstArgTypes into LookupRuntime
LookupRuntime is the only reason for using SubstArgTypes, and most
callers to LookupRuntime need to immediately call it anyway. So might
as well fuse them together.

Change-Id: Ie0724ed164b949040e898a2a77bea632801b64fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/521415
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-08-22 21:17:13 +00:00
Matthew Dempsky
c6dd97e533 cmd/compile: simplify various signature type handling code
Make more use of RecvParams and RecvParamsResults helper methods.

Also, correct misuse of Go spec terminology ("return" is a statement;
"result" is the class of parameters that appear in a function type).

Change-Id: I94807a747c494c9daa5441da7d9e3aea77aae33b
Reviewed-on: https://go-review.googlesource.com/c/go/+/521395
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: Than McIntosh <thanm@google.com>
2023-08-22 21:17:10 +00:00
Matthew Dempsky
3d15bfaa3e cmd/compile/internal/types: simplify iterating all parameters
The types.RecvsParamsResults, etc. helpers existed to make it "easier"
to iterate over all parameters, or recvs+params, or params+results;
but they end up still being quite clumsy to use due to the design goal
of not allocating temporary slices.

Now that recvs+params+results are stored in a single consecutive slice
anyway, we can just return different subslices and simplify the loops.

Change-Id: I84791b80dc099dfbfbbe6eddbc006135528c23b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/521375
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: Than McIntosh <thanm@google.com>
2023-08-22 20:57:01 +00:00
Matthew Dempsky
4b9a70a3b7 cmd/compile/internal/types: simpler signature type representation
Now that all of the uses of signature types have been cleaned up, we
can simplify the internal representation significantly.

In particular, instead of 3 separate struct objects each with 3
separate slices of fields, we can store all of the parameters in a
single slice and track the boundaries between them.

We still need a results tuple struct for representing the type of
multi-value call expressions, but just a single one and it can safely
reuse the results subsection of the full parameters slice.

Note: while Sizeof(Func) has increased (e.g., 32->56 on amd64), we're
saving on the allocation of 2 Types, 2 Structs, and 2 []*Field (288
bytes total on amd64), not counting any extra GC size class padding
from using a single shared []*Field instead of 3 separate ones.

Change-Id: I119b5e960e715b3bc4f1f726e58b910a098659da
Reviewed-on: https://go-review.googlesource.com/c/go/+/521335
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
TryBot-Bypass: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-08-22 20:56:59 +00:00
Matthew Dempsky
b0a17c0489 cmd/compile/internal/types: replace BOGUS_FUNARG_OFFSET with BADWIDTH
We already have a magic constant to represent fields that haven't had
their offsets calculated. We don't need two.

Change-Id: Ibfa95a3a15a5cd43e1e5ec7d0971d3e61d47fb3c
Reviewed-on: https://go-review.googlesource.com/c/go/+/521317
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2023-08-22 20:54:55 +00:00
Jakub Ciolek
a65b4904fc cmd/compile: use MOVQ + MOVL for 11 byte moves
Instead of using two MOVQ, use a shorter MOVL for the remaining 3 bytes.

compilecmp (linux/amd64):

runtime/pprof
runtime/pprof.printCountProfile.func1 875 -> 869  (-0.69%)

fmt [cmd/compile]
fmt.Sprintf 5009 -> 4977  (-0.64%)

runtime/pprof [cmd/compile]
runtime/pprof.printCountProfile.func1 875 -> 869  (-0.69%)

cmd/vendor/github.com/ianlancetaylor/demangle
cmd/vendor/github.com/ianlancetaylor/demangle.(*GlobalCDtor).print 957 -> 938  (-1.99%)
cmd/vendor/github.com/ianlancetaylor/demangle.(*ImaginaryType).printInner 270 -> 261  (-3.33%)
cmd/vendor/github.com/ianlancetaylor/demangle.(*TemplateTemplateParam).print 876 -> 874  (-0.23%)

cmd/cgo/internal/test
cmd/cgo/internal/test.test18146.func1 73 -> 66  (-9.59%)

cmd/go/internal/work
cmd/go/internal/work.(*Builder).gccSupportsFlag 3469 -> 3461  (-0.23%)

file                                            before   after    Δ       %
runtime/pprof.s                                 79729    79723    -6      -0.008%
fmt [cmd/compile].s                             83679    83647    -32     -0.038%
runtime/pprof [cmd/compile].s                   79729    79723    -6      -0.008%
cmd/vendor/github.com/ianlancetaylor/demangle.s 254999   254969   -30     -0.012%
cmd/cgo/internal/test.s                         212272   212265   -7      -0.003%
cmd/go/internal/work.s                          287700   287692   -8      -0.003%
cmd/compile/internal/ssa.s                      3193233  3193553  +320    +0.010%
cmd/compile/internal/ssa [cmd/compile].s        3362126  3362446  +320    +0.010%
total                                           30810158 30810709 +551    +0.002%

Change-Id: Iad09a42fb247c85ca1c649c367aaf75a620dbbc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/521475
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2023-08-22 20:48:59 +00:00
Jakub Ciolek
3d4f41aea8 cmd/compile: use shorter MOVs for clears of 9, 10, 11 and 12 bytes
Instead of using two MOVQ, use a smaller MOV(B|W|L) for the remainder.

compilecmp:

vendor/golang.org/x/net/dns/dnsmessage
vendor/golang.org/x/net/dns/dnsmessage.(*SRVResource).GoString 1263 -> 1231  (-2.53%)
vendor/golang.org/x/net/dns/dnsmessage.(*OpCode).GoString 285 -> 279  (-2.11%)
vendor/golang.org/x/net/dns/dnsmessage.(*MXResource).GoString 603 -> 581  (-3.65%)
vendor/golang.org/x/net/dns/dnsmessage.(*Option).GoString 485 -> 478  (-1.44%)

os/signal
os/signal.cancel.func1 378 -> 346  (-8.47%)

fmt
fmt.newPrinter 145 -> 138  (-4.83%)
fmt.(*pp).catchPanic 1369 -> 1357  (-0.88%)
fmt.(*fmt).clearflags 17 -> 13  (-23.53%)
fmt.(*fmt).init 85 -> 81  (-4.71%)

vendor/golang.org/x/crypto/chacha20poly1305
vendor/golang.org/x/crypto/chacha20poly1305.(*xchacha20poly1305).Seal 527 -> 526  (-0.19%)

cmd/vendor/golang.org/x/sys/unix
cmd/vendor/golang.org/x/sys/unix.(*TIPCSocketAddr).tipcAddr 88 -> 86  (-2.27%)
cmd/vendor/golang.org/x/sys/unix.(*TIPCServiceRange).tipcAddr 95 -> 93  (-2.11%)
cmd/vendor/golang.org/x/sys/unix.(*TIPCServiceName).tipcAddr 95 -> 93  (-2.11%)

fmt [cmd/compile]
fmt.(*fmt).clearflags 17 -> 13  (-23.53%)
fmt.newPrinter 304 -> 298  (-1.97%)
fmt.(*pp).catchPanic 1369 -> 1357  (-0.88%)
fmt.Fprint 536 -> 535  (-0.19%)
fmt.Sprintf 5009 -> 4945  (-1.28%)
fmt.(*fmt).init 85 -> 81  (-4.71%)

net/http
net/http.http2FrameHeader.Header 89 -> 88  (-1.12%)
net/http.http2HeadersFrame.Header 95 -> 94  (-1.05%)
net/http.http2RSTStreamFrame.Header 120 -> 119  (-0.83%)
net/http.http2WindowUpdateFrame.Header 120 -> 119  (-0.83%)
net/http.http2Frame.Header 181 -> 179  (-1.10%)
net/http.http2PingFrame.Header 95 -> 94  (-1.05%)
net/http.(*http2FrameHeader).Header 119 -> 113  (-5.04%)
net/http.http2GoAwayFrame.Header 95 -> 94  (-1.05%)
net/http.http2MetaHeadersFrame.Header 133 -> 132  (-0.75%)

cmd/vendor/golang.org/x/term
cmd/vendor/golang.org/x/term.(*Terminal).clearLineToRight 338 -> 337  (-0.30%)

cmd/link/internal/ld
cmd/link/internal/ld.appendString 424 -> 421  (-0.71%)

cmd/compile/internal/reflectdata [cmd/compile]
cmd/compile/internal/reflectdata.dnameData 1574 -> 1561  (-0.83%)

file                                             before   after    Δ       %
vendor/golang.org/x/net/dns/dnsmessage.s         74536    74469    -67     -0.090%
os/signal.s                                      7192     7160     -32     -0.445%
fmt.s                                            70428    70401    -27     -0.038%
vendor/golang.org/x/crypto/chacha20poly1305.s    7103     7102     -1      -0.014%
cmd/vendor/golang.org/x/sys/unix.s               118033   118027   -6      -0.005%
fmt [cmd/compile].s                              83679    83588    -91     -0.109%
net/http.s                                       536737   536722   -15     -0.003%
cmd/vendor/golang.org/x/term.s                   23505    23504    -1      -0.004%
cmd/link/internal/ld.s                           571046   571043   -3      -0.001%
cmd/compile/internal/reflectdata [cmd/compile].s 72645    72632    -13     -0.018%
cmd/compile/internal/ssa.s                       3193233  3193841  +608    +0.019%
cmd/compile/internal/ssa [cmd/compile].s         3362126  3362734  +608    +0.018%
total                                            30810158 30811118 +960    +0.003%

Change-Id: Iade49c590027c0a09a6e546a3b94d2dccd5b7116
Reviewed-on: https://go-review.googlesource.com/c/go/+/521455
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-08-22 20:48:57 +00:00
mstmdev
52ebd1624d cmd/asm: add more flags to the documentation
Add the flags -e and -v.

Change-Id: I48c22141ea0bc634f30625214b1a277e686bb98e
GitHub-Last-Rev: 4a12fe4f44
GitHub-Pull-Request: golang/go#62208
Reviewed-on: https://go-review.googlesource.com/c/go/+/521679
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-08-22 20:46:45 +00:00
Matthew Dempsky
6f7caf8894 cmd/compile/internal/types: separate printing of structs and tuples
This CL changes the pretty printer to not rely on parameter lists
being represented as TSTRUCTs.

Change-Id: Ie2b8192ee07b96ffbe224e5d98a335368f47abc2
Reviewed-on: https://go-review.googlesource.com/c/go/+/521316
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2023-08-22 20:43:37 +00:00
Matthew Dempsky
98195ed057 cmd/compile/internal/types: remove Funarg
There's no need for the Funarg type anymore. A simple boolean suffices
to indicate whether a TSTRUCT represents a parameter tuple.

While here, rename Struct.Funarg to ParamTuple.

Change-Id: I657512d4ba10e51ec4cfd7c7d77e0194bdb0853b
Reviewed-on: https://go-review.googlesource.com/c/go/+/521315
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
2023-08-22 20:43:28 +00:00
Matthew Dempsky
1f544ef0eb cmd/compile/internal/types: refactor struct size calculation
This CL simplifies how struct sizes and field offsets are calculated.

Change-Id: If4af778cb49218d295277df596e45bdd8b23ed9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/521276
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-08-22 20:43:19 +00:00
Austin Clements
56b3b244fd cmd/internal/objabi,cmd/compile: move NoInstrumentPkgs and NoRacePkgs to PkgSpecials
This consolidates the NoInstrumentPkgs and NoRacePkgs lists into the
objabi.LookupPkgSpecial mechanism.

Change-Id: I411654afdd690fb01c412e7e8b57ddfbe85415e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/521702
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Austin Clements <austin@google.com>
2023-08-22 19:18:34 +00:00