1
0
mirror of https://github.com/golang/go synced 2024-11-17 14:24:50 -07:00
Commit Graph

58613 Commits

Author SHA1 Message Date
Kir Kolyshkin
3548f9a01f os: remove useless if from Wait on unix
Back in the day, Wait used to accept options argument.

CL 4962042 fixed the issue of setting process.done flag when WNOHANG
option was used.

Later, CL 5688046 removed options argument from Wait, but did not remove
pid1 != 0 check which was meant to be used with WNOHANG only.

Remove the check, which is useless and also confusing.

Change-Id: I73b9ef4a0dbe35466e659ca58b896d515ba86d02
Reviewed-on: https://go-review.googlesource.com/c/go/+/543736
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2023-11-21 20:39:17 +00:00
Matthew Dempsky
00715d089d cmd/compile/internal/walk: copy SSA-able variables
order.go ensures expressions that are passed to the runtime by address
are in fact addressable. However, in the case of local variables, if the
variable hasn't already been marked as addrtaken, then taking its
address here will effectively prevent the variable from being converted
to SSA form.

Instead, it's better to just copy the variable into a new temporary,
which we can pass by address instead. This ensures the original variable
can still be converted to SSA form.

Fixes #63332.

Change-Id: I182376d98d419df8bf07c400d84c344c9b82c0fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/541715
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-11-21 20:34:12 +00:00
Guoqi Chen
e5615ad876 cmd/compile, internal/buildcfg: enable regABI on loong64, and add loong64 in test func hasRegisterABI
goos: linux
goarch: loong64
pkg: test/bench/go1
cpu: Loongson-3A5000 @ 2500.00MHz
                      │    bench.old   │    bench.new                         │
                      │    sec/op      │    sec/op      vs base               │
Template                  116.4m ± 1%     101.3m ± 0%   -12.94% (p=0.000 n=20)
Gzip                      417.2m ± 0%     419.4m ± 0%    +0.53% (p=0.000 n=20)
Gunzip                    87.41m ± 0%     84.61m ± 0%    -3.20% (p=0.000 n=20)
FmtFprintfEmpty           97.87n ± 0%     81.05n ± 0%   -17.19% (p=0.000 n=20)
FmtFprintfString          151.1n ± 0%     140.9n ± 0%    -6.75% (p=0.000 n=20)
FmtFprintfInt             155.6n ± 0%     143.0n ± 0%    -8.10% (p=0.000 n=20)
FmtFprintfIntInt          236.9n ± 0%     225.1n ± 0%    -5.00% (p=0.000 n=20)
FmtFprintfPrefixedInt     316.8n ± 0%     331.9n ± 0%    +4.77% (p=0.000 n=20)
FmtFprintfFloat           401.5n ± 0%     380.0n ± 0%    -5.35% (p=0.000 n=20)
FmtManyArgs               925.3n ± 0%     910.1n ± 0%    -1.64% (p=0.000 n=20)
BinaryTree17               14.04 ± 1%      12.84 ± 0%    -8.52% (p=0.000 n=20)
RegexpMatchEasy0_32       133.1n ± 0%     121.3n ± 0%    -8.87% (p=0.000 n=20)
RegexpMatchEasy0_1K       1.363µ ± 0%     1.337µ ± 0%    -1.91% (p=0.000 n=20)
RegexpMatchEasy1_32       162.7n ± 0%     152.6n ± 0%    -6.24% (p=0.000 n=20)
RegexpMatchEasy1_1K       1.505µ ± 0%     1.740µ ± 0%   +15.61% (p=0.000 n=20)
RegexpMatchMedium_32      1.429µ ± 0%     1.299µ ± 0%    -9.10% (p=0.000 n=20)
RegexpMatchMedium_1K      41.76µ ± 0%     38.16µ ± 0%    -8.61% (p=0.000 n=20)
RegexpMatchHard_32        2.094µ ± 0%     2.157µ ± 0%    +3.01% (p=0.000 n=20)
RegexpMatchHard_1K        63.25µ ± 0%     64.72µ ± 0%    +2.33% (p=0.000 n=20)
JSONEncode                18.00m ± 1%     17.46m ± 1%    -3.05% (p=0.000 n=20)
JSONDecode                79.49m ± 0%     72.42m ± 0%    -8.89% (p=0.000 n=20)
Revcomp                    1.147 ± 0%      1.255 ± 0%    +9.39% (p=0.000 n=20)
Fannkuch11                 3.623 ± 0%      3.410 ± 0%    -5.87% (p=0.000 n=20)
Fannkuch11                 3.623 ± 0%      3.410 ± 0%    -5.87% (p=0.000 n=20)
GobDecode                 14.26m ± 0%     12.92m ± 0%    -9.36% (p=0.000 n=20)
GobEncode                 16.86m ± 1%     14.96m ± 0%   -11.28% (p=0.000 n=20)
GoParse                   8.721m ± 0%     8.125m ± 1%    -6.84% (p=0.000 n=20)
Mandelbrot200             7.203m ± 0%     7.171m ± 0%    -0.44% (p=0.000 n=20)
HTTPClientServer          83.96µ ± 0%     80.83µ ± 0%    -3.72% (p=0.000 n=20)
TimeParse                 415.3n ± 0%     389.1n ± 0%    -6.31% (p=0.000 n=20)
TimeFormat                506.4n ± 0%     495.9n ± 0%    -2.06% (p=0.000 n=20)
geomean                   102.6µ          98.04µ         -4.40%

                      │   bench.old    │   bench.new                          │
                      │      B/s       │     B/s        vs base               │
Template                 15.90Mi ± 1%    18.26Mi ± 0%   +14.88% (p=0.000 n=20)
Gzip                     44.36Mi ± 0%    44.12Mi ± 0%    -0.53% (p=0.000 n=20)
Gunzip                   211.7Mi ± 0%    218.7Mi ± 0%    +3.31% (p=0.000 n=20)
RegexpMatchEasy0_32      229.3Mi ± 0%    251.6Mi ± 0%    +9.72% (p=0.000 n=20)
RegexpMatchEasy0_1K      716.4Mi ± 0%    730.3Mi ± 0%    +1.94% (p=0.000 n=20)
RegexpMatchEasy1_32      187.6Mi ± 0%    200.0Mi ± 0%    +6.64% (p=0.000 n=20)
RegexpMatchEasy1_1K      649.1Mi ± 0%    561.3Mi ± 0%   -13.52% (p=0.000 n=20)
RegexpMatchMedium_32     21.35Mi ± 0%    23.50Mi ± 0%   +10.05% (p=0.000 n=20)
RegexpMatchMedium_1K     23.38Mi ± 0%    25.59Mi ± 0%    +9.42% (p=0.000 n=20)
RegexpMatchHard_32       14.57Mi ± 0%    14.14Mi ± 0%    -2.95% (p=0.000 n=20)
RegexpMatchHard_1K       15.44Mi ± 0%    15.09Mi ± 0%    -2.29% (p=0.000 n=20)
JSONEncode               102.8Mi ± 1%    106.0Mi ± 1%    +3.15% (p=0.000 n=20)
JSONDecode               23.28Mi ± 0%    25.55Mi ± 0%    +9.75% (p=0.000 n=20)
Revcomp                  211.3Mi ± 0%    193.1Mi ± 0%    -8.58% (p=0.000 n=20)
GobDecode                51.34Mi ± 0%    56.64Mi ± 0%   +10.33% (p=0.000 n=20)
GobEncode                43.42Mi ± 1%    48.93Mi ± 0%   +12.71% (p=0.000 n=20)
GoParse                  6.337Mi ± 0%    6.800Mi ± 1%    +7.30% (p=0.000 n=20)
geomean                  61.24Mi         63.63Mi         +3.91%

Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: I5993460da8c5926c70cb6fbe551b8e4655dea9d0
Reviewed-on: https://go-review.googlesource.com/c/go/+/521790
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2023-11-21 20:24:52 +00:00
Kir Kolyshkin
f7b2779086 syscall: fix getting pidfd when using CLONE_NEWUSER
While working on CL 528798, I found out that sys.PidFD field (added
in CL 520266) is not filled in when CLONE_NEWUSER is used.

This happens because the code assumed that the parent and the child
run in the same memory space. This assumption is right only when
CLONE_VM is used for clone syscall, and the code only sets CLONE_VM
when CLONE_NEWUSER is not used.

Fix this, and add a test case (which fails before the fix).

Updates #51246.

Change-Id: I805203c1369cadd63d769568b132a9ffd92cc184
Reviewed-on: https://go-review.googlesource.com/c/go/+/542698
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
2023-11-21 20:13:01 +00:00
Than McIntosh
cfb281754e cmd/compile/internal/inline: revise -m=2 status messages
This patch revises the compiler's "-m=2" status messages related to
inlining. The "can inline" remarks will continue to use the same
format, but the remarks when a specific call site is inlined will be
changed to refer to the score used; before we had

  runtime/traceback.go:1131:28: inlining call to gotraceback
  runtime/traceback.go:1183:25: inlining call to readgstatus

and with GOEXPERIMENT=newinliner the new messages will be:

  runtime/traceback.go:1131:28: inlining call to gotraceback with score 62
  runtime/traceback.go:1183:25: inlining call to readgstatus with score 9

Change-Id: Ia86cf5351d29eda64a5426ca0a2a2ec0c2900d81
Reviewed-on: https://go-review.googlesource.com/c/go/+/540775
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-21 20:07:48 +00:00
Guoqi Chen
2e77b51df5 runtime/internal/syscall: use ABIInternal for Syscall6 on loong64
Updates #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: Ifcc2de35a797fd987a10f564206b14b54d736d1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/521789
Auto-Submit: David Chase <drchase@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-21 19:26:27 +00:00
Guoqi Chen
b3b442449b cmd/compile: fix If lowering on loong64
Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: I44477e32db765e0299d8361bd2b8d2c95564ed28
Reviewed-on: https://go-review.googlesource.com/c/go/+/521788
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-11-21 19:26:25 +00:00
Guoqi Chen
e58c9baa9f cmd/internal/obj: set morestack arg spilling and regabi prologue on loong64
Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: Ie92da57e29bae0e5cccb2a49a7cbeaf02cbf3a8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/521787
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: David Chase <drchase@google.com>
2023-11-21 19:22:18 +00:00
Guoqi Chen
c83b5fefab runtime: add regABI support in memclr and memmove functions on loong64
Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: I55c78bab5c697ea6c30f9d81f5f8fb75abb3987c
Reviewed-on: https://go-review.googlesource.com/c/go/+/521786
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Run-TryBot: David Chase <drchase@google.com>
Auto-Submit: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
2023-11-21 19:22:16 +00:00
Guoqi Chen
1052d09dd7 internal/bytealg: add regABI support in bytealg functions on loong64
Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: I4a7392afd7238d44e7d09aaca7e0d733649926ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/521785
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: David Chase <drchase@google.com>
2023-11-21 19:21:41 +00:00
Guoqi Chen
4e6bbbe61f reflect, runtime: add reflect support for regABI on loong64
Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: I0549fd1a2192ffb041034ff41bf0cc4be0b1662c
Reviewed-on: https://go-review.googlesource.com/c/go/+/521784
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-21 19:04:25 +00:00
Guoqi Chen
f6f141ab80 runtime: support regABI and add spill functions in runtime for loong64
Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: I709b818ef15c33f95251186d749ac13260ad36be
Reviewed-on: https://go-review.googlesource.com/c/go/+/521783
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Run-TryBot: David Chase <drchase@google.com>
Auto-Submit: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-21 19:04:23 +00:00
Guoqi Chen
3107fa99ac runtime: make duff device as ABIInternal for loong64
Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: I243e60489dc5fd162ad91d6426bf32cf0e13d9e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/521782
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: David Chase <drchase@google.com>
2023-11-21 19:04:21 +00:00
Guoqi Chen
6b77d1b736 cmd/compile: update loong64 CALL* ops
allow the loong64 CALL* ops to take variable number of args

Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: I4706d9651fcbf9a0f201af6820c97b1a924f14e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/521781
Auto-Submit: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: David Chase <drchase@google.com>
2023-11-21 19:04:19 +00:00
Guoqi Chen
bd224fa522 cmd/compile/internal: add spill support for loong64 regABI
Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: Ic01d59bd81420b89c6d4b90c5975bf069d08e7cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/521780
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2023-11-21 19:04:16 +00:00
Guoqi Chen
ebca52eeb7 cmd/compile/internal: add register info for loong64 regABI
Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: Ifd7d94147b01e4fc83978b53dca2bcc0ad1ac4e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/521779
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
2023-11-21 19:04:14 +00:00
Mauri de Souza Meneguzzo
4bfed5ce74 runtime/internal/atomic: deduplicate And/Or code on arm
Turns out after adding the generic implementation for And/Or we ended up
with duplicated ops that are exactly the same for arm.

Apologies for the oversight, this CL removes the redundant arm code and
adds arm to the generic build flags.

For #61395

Change-Id: Id5e5a5cf113774948f8e772592e898d0810ad1f6
GitHub-Last-Rev: 4d8c857d15
GitHub-Pull-Request: golang/go#64299
Reviewed-on: https://go-review.googlesource.com/c/go/+/544017
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
2023-11-21 18:57:31 +00:00
WANG Xuerui
d7fcb5cf80 cmd/dist, cmd/link, internal, runtime: implement buildmode=plugin for linux/loong64
According to review, buildmode=shared has unfixed shortcomings and
should be considered legacy at this time. So only buildmode=plugin is
going to be added for loong64 which is a relatively new platform.

Change-Id: Iac0b9f57e4ee01755458e180bb24d1b2a146fdf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/480878
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
2023-11-21 18:56:21 +00:00
Guoqi Chen
7b26cb9540 internal/abi: define loong64 regABI constants
Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: Id580d9e22a562adee2ae02a467ac38a54949e737
Reviewed-on: https://go-review.googlesource.com/c/go/+/521778
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: David Chase <drchase@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2023-11-21 17:59:39 +00:00
Guoqi Chen
070139a130 cmd/compile,cmd/internal,runtime: change registers on loong64 to avoid regABI arguments
Update #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: Ic7e2e7fb4c1d3670e6abbfb817aa6e4e654e08d3
Reviewed-on: https://go-review.googlesource.com/c/go/+/521777
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
2023-11-21 17:59:37 +00:00
Guoqi Chen
945c2bc74e cmd/compile: add ABI register definations for loong64
Updates #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: I56f7382dda58a565b8c3256f1c7845a3031f67de
Reviewed-on: https://go-review.googlesource.com/c/go/+/521776
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: David Chase <drchase@google.com>
Auto-Submit: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2023-11-21 17:59:35 +00:00
WANG Xuerui
08b9640333 cmd/compile: teach regalloc to rightly do nothing on loong64 in case of dynlinking
This is needed before actual support for buildmode=plugin is added.
Should not affect current behavior.

Change-Id: I86371d7e373fd529cb8710850d7b0fbbf1eb52ca
Reviewed-on: https://go-review.googlesource.com/c/go/+/480877
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: WANG Xuerui <git@xen0n.name>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-21 17:49:56 +00:00
Guoqi Chen
346e06c46d cmd/internal/obj,cmd/link: access global data via GOT in -dynlink mode on loong64
Updates #58784

Change-Id: Ic98d10a512fea0c3ca321ab52693d9f6775126a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/480875
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: WANG Xuerui <git@xen0n.name>
Reviewed-by: WANG Xuerui <git@xen0n.name>
2023-11-21 17:49:21 +00:00
Guoqi Chen
f43581131e cmd/compile, cmd/internal, runtime: change the registers used by the duff device for loong64
Add R21 to the allocatable registers, use R20 and R21 in duff
device. This CL is in preparation for subsequent regABI support.

Updates #40724

Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn>
Change-Id: If1661adc0f766925fbe74827a369797f95fa28a9
Reviewed-on: https://go-review.googlesource.com/c/go/+/521775
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-21 17:42:40 +00:00
Carlo Alberto Ferraris
4f55a5af5e sync: do not unnecessarily keep alive functions wrapped by Once(Func|Value|Values)
The function passed to OnceFunc/OnceValue/OnceValues may transitively
keep more allocations alive. As the passed function is guaranteed to be
called at most once, it is safe to drop it after the first call is
complete. This avoids keeping the passed function (and anything it
transitively references) alive until the returned function is GCed.

Change-Id: I2faf397b481d2f693ab3aea8e2981b02adbc7a21
Reviewed-on: https://go-review.googlesource.com/c/go/+/481515
Reviewed-by: Austin Clements <austin@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: qiulaidongfeng <2645477756@qq.com>
2023-11-21 17:31:33 +00:00
Than McIntosh
5239c91351 cmd/compile/internal/inline: minor compile time improvements in func flags
Some small changes to help reduce compile time for function flags
computation. The current implementation of panic path detection adds
an entry to a map for every node in the function, which is wasteful
(and shows up in cpu profiles). Switch to only adding entries where
they are useful. This is especially important for functions with large
map literals and other constructs with many non-statement nodes.

Change-Id: I9cfb2cd1cbf480f21298e6102aa99e2d77219f3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/539696
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-21 17:28:17 +00:00
Than McIntosh
3255fca993 cmd/compile/internal/inline: fix bug in param flags heuristics
Fix a bug in the code that analyzes how function parameters are used,
which wasn't properly handling certain types of closures. The code
in question has support for deriving flags for a given parameter based
on whether it is passed to a call. Example:

    func foo(f1 func(int)) {
       bar(32, f1)
    }
    func bar(x int, f2 func()) {
       f2(x)
    }

When analyzing "bar", we can derive the "FeedsIndirectCall" flag for
parameter "f1" by virtue of the fact that it is passed directly to
"bar", and bar's corresponding parameter "f2" has the flag set. For
a more complex example such as

    func foo(f1 func(int)) func() int {
       return func(q int) int {            <<-- HERE
         bar(99, f1)
	 return q
       }
    }
    func bar(x int, f2 func()) {
       f2(x)
    }

The heuristics code would panic when examining the closure marked above
due to the fact that the call to "bar" was passing an ir.Name with class
PPARAM, but no such param was present in the enclosing function.

Change-Id: I30436ce716b51bfb03e42e7abe76a4514e6b9285
Reviewed-on: https://go-review.googlesource.com/c/go/+/539320
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-11-21 17:27:50 +00:00
Bryan C. Mills
0cb45bac01 testing: use subprocesses in TestTBHelper and TestTBHelperParallel
These tests are checking the output of test functions that call the
Helper methods. However, they were reaching into package internals
instead of running those test functions as actual tests.

That not only produced significant differences in formatting (such as
indentation for subtests), but also caused test flags such as
"-failfast" passed for the overall test run to interfere with the
output formatting.

Now, we run the test functions as real tests in a subprocess,
so that we get the real output and formatting of those tests.
This makes the tests not only more realistic, but also less
sensitive to otherwise-irrelevant implementation details
(such as the names and signatures of unexported types and
functions in the testing package).

Fixes #61016.

Change-Id: I646fbbd7cfeb00382054677f726c05fc9d35d0dc
Reviewed-on: https://go-review.googlesource.com/c/go/+/506955
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-21 17:24:47 +00:00
Than McIntosh
bbcd85528c cmd/compile/internal/inline: rework use of ir.StaticValue
When running the code to compute function properties that feed
inlining heuristics, the existing heuristics implementation makes
fairly extensive use of ir.StaticValue and ir.Reassigned to sharpen
the analysis. These calls turn out to cause a significant compile time
increase, due to the fact that each call can potentially walk every
node in the IR for the function. To help with this problem, switch the
heuristics code over to using the new "batch mode" reassignment helper
added in the previous CL.

Change-Id: Ib15a62416134386e34b7cfa1130a4b413a37b225
Reviewed-on: https://go-review.googlesource.com/c/go/+/537977
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-11-21 16:30:33 +00:00
Filippo Valsorda
8eecf26e3f crypto/tls: disable ExportKeyingMaterial without EMS
Fixes #43922

Change-Id: Idaad7daa6784807ae3a5e4d944e88e13d01fd0b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/544155
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
2023-11-21 16:29:49 +00:00
qiulaidongfeng
78d037b0e0 os: avoid TestFileChdir fail when GOROOT is a symbolic link
If GOROOT is a symbolic link,
the paths obtained from the
first and second Getwd of TestFileChdir are different,
and this CL fixes the test failure in this situation.

Fixes #64281

Change-Id: I53026b6c54a54be08833396e2c7081ca3ab8c282
GitHub-Last-Rev: 5cc418e625
GitHub-Pull-Request: golang/go#64001
Reviewed-on: https://go-review.googlesource.com/c/go/+/540521
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-21 16:29:21 +00:00
Than McIntosh
8be8bfeaa2 cmd/compile/internal/ir: add batch-mode reassignment detection oracle
Add a new helper type 'ReassignOracle', useful for doing "batch mode"
reassignment analysis, e.g. deciding whether a given ir.Name or (chain
of connected names) has a single definition and is never reassigned.

The intended usage model is for clients to create/initialize a
ReassignOracle for a given function, then make a series of queries
using it (with the understanding that changing/mutating the func body
IR can invalidate the info cached in the oracle). This oracle is
intended to provide the same sort of analysis that ir.StaticValue and
ir.Reassigned carry out, but at a much reduced cost in compile
time.

Notes:
- the new helper isn't actually used for anything useful in this
  patch; it will be hooked into the inline heuristics code as part of
  a subsequent CL.
- this is probably not an ideal long-term solution; it would be better
  to switch to a scheme based a flag on ir.Name, as opposed to a
  side table.

Change-Id: I283e748e440a9f595df495f6aa48ee9c498702d9
Reviewed-on: https://go-review.googlesource.com/c/go/+/539319
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-21 16:20:36 +00:00
Jes Cok
515f3c0da6 reflect: tweak logic for 'case Array' in IsZero
For 'case Array' in IsZero, check 'v.flag&flagIndir == 0' in the
first place, rename 'array' to 'typ' for consistency, and remove
stale comment.

Add line breaks for long sentence in isZero.

Change-Id: Id06d01fd61eefd205bf4626e6b920ae82b459455
GitHub-Last-Rev: 7225ca3f7b
GitHub-Pull-Request: golang/go#64270
Reviewed-on: https://go-review.googlesource.com/c/go/+/543656
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Jes Cok <xigua67damn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-11-21 14:46:08 +00:00
Cherry Mui
dc094f9c96 runtime: disable crash stack on Windows
Apparently, on Windows, throwing an exception on a non-system-
allocated crash stack causes EXCEPTION_STACK_OVERFLOW and hangs
the process (see issue #63938). Disable crash stack for now, which
gets us back the the behavior of Go 1.21.

Fixes #63938.

Change-Id: I4c090315b93b484e756b242f0de7a9e02f199261
Reviewed-on: https://go-review.googlesource.com/c/go/+/543996
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2023-11-21 02:06:54 +00:00
Jorropo
195c88b202 net/http: use pointers to array for copyBufPool
This is inspired by CL 539915, I'm only submitting now that
CL 456435 has been merged.

This divide the number of objects kept alive by the heap by two
and remove the slice header allocation in New and in the put back.

Change-Id: Ibcd5166bac5a37f365a533e09a28f3b79f81ad58
Reviewed-on: https://go-review.googlesource.com/c/go/+/543515
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-11-21 00:52:06 +00:00
Anton Telyshev
cc7b4b3c36 cmd/vet: add lost checks in doc
Change-Id: Iacbcb582e263149fede734822cba2df4b8162968
Reviewed-on: https://go-review.googlesource.com/c/go/+/544015
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-21 00:17:30 +00:00
Bryan C. Mills
841e63e480 cmd/go: don't warn about GOROOT equal to GOPATH when both are the empty string
As of Go 1.19, runtime.GOROOT() reports the empty string if the binary
was built with -trimpath. cmd/go/internal/cfg uses the path of the go
command executable to reverse-engineer the correct GOROOT setting,
but that means that cmd/go's "GOPATH set to GOROOT" warning needs to
use cfg.GOROOT instead of runtime.GOROOT().

In addition, if we fail to find the GOROOT then there is no point in
complaining about GOPATH also being empty: the missing GOROOT will stop
everything right away anyway, so there is no point confusing the user
with an additional warning about GOPATH.

Updates #51461.
Updates #18678.
Updates #3207.

Change-Id: Id7d0f4dc2f229c202dfda4e6e8af5dea909bb16f
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/543955
Reviewed-by: Michael Matloob <matloob@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-20 22:45:34 +00:00
Tim King
af1242932e cmd: go get golang.org/x/tools@8966034e and revendor
go get golang.org/x/tools@8966034e # CL 542639
go mod tidy
go mod vendor

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Change-Id: Id2a7322006ff3985e3c97482cd78c8963c4df140
Reviewed-on: https://go-review.googlesource.com/c/go/+/543975
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2023-11-20 21:52:54 +00:00
Mauri de Souza Meneguzzo
369ce90d2c runtime: add crash stack support for wasm
Currently if morestack on g0 happens the wasm runtime prints
"RuntimeError: memory access out of bounds", which is quite misleading.
By switching to a crash stack we can get better stacktraces
for the error.

There is no way to automate tests for this feature on wasm, since
TestG0StackOverflow relies on spawning a subprocess which is not
supported by the wasm port.

The way I got this tested manually is to comment everything in
TestG0StackOverflow, leaving just runtime.G0StackOverflow().

Then it is a matter of invoking the test:

    GOOS=js GOARCH=wasm go test runtime -v -run=TestG0StackOverflow

Change-Id: If450f3ee5209bb32efc1abd0a34b1cc4a29d0c46
GitHub-Last-Rev: 0d7c396e4c
GitHub-Pull-Request: golang/go#63956
Reviewed-on: https://go-review.googlesource.com/c/go/+/539995
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-11-20 21:26:51 +00:00
Matthew Dempsky
ddb38c3f54 cmd/compile/internal/devirtualize: use CallExpr.GoDefer for PGO
CL 543657 dedup'd the go/defer statement recognition between the
inliner and static devirtualizer. This CL extends that for PGO-based
devirtualization too.

Change-Id: I998753132af1ef17329676f4e17515f16e0acb03
Reviewed-on: https://go-review.googlesource.com/c/go/+/543775
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2023-11-20 18:59:37 +00:00
Michael Knyszek
82fc03f9c9 Revert "math/rand/v2: add ChaCha8"
This reverts commit 6382893890.

Reason for revert: Causes failures on big endian platforms and riscv64.
Possibly a bug in the generic implementation.

For #64284.
For #64285.

Change-Id: Ic1bb8533d9641fae28d0337b36d434b9a575cd7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/543895
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Bypass: Michael Knyszek <mknyszek@google.com>
2023-11-20 18:39:03 +00:00
Matthew Dempsky
4a90cdb03d cmd/compile: interleave devirtualization and inlining
This CL interleaves devirtualization and inlining, so that
devirtualized calls can be inlined.

Fixes #52193.

Change-Id: I681e7c55bdb90ebf6df315d334e7a58f05110d9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/528321
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Bypass: Matthew Dempsky <mdempsky@google.com>
2023-11-20 18:09:45 +00:00
Ludi Rehak
ee6b34797b all: add floating point option for ARM targets
This change introduces new options to set the floating point
mode on ARM targets. The GOARM version number can optionally be
followed by ',hardfloat' or ',softfloat' to select whether to
use hardware instructions or software emulation for floating
point computations, respectively. For example,
GOARM=7,softfloat.

Previously, software floating point support was limited to
GOARM=5. With these options, software floating point is now
extended to all ARM versions, including GOARM=6 and 7. This
change also extends hardware floating point to GOARM=5.

GOARM=5 defaults to softfloat and GOARM=6 and 7 default to
hardfloat.

For #61588

Change-Id: I23dc86fbd0733b262004a2ed001e1032cf371e94
Reviewed-on: https://go-review.googlesource.com/c/go/+/514907
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2023-11-20 17:19:36 +00:00
Andrei Matei
e6b154defb ssa: clarify semantics of ID-to-PC translation function
Make it clear that the `block` argument is not always used, and stop
passing it in a case where it didn't really make sense - at the end of a
function.

Change-Id: I2fa86bed6ceb53a1b1cbfda5c3392e7e9da9579d
Reviewed-on: https://go-review.googlesource.com/c/go/+/502115
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: David Chase <drchase@google.com>
2023-11-20 16:21:26 +00:00
Jes Cok
d33ad2d8f3 syscall: support O_SYNC flag for os.OpenFile on windows
os.OpenFile on windows did not use the O_SYNC flag. This meant
that even if the user set O_SYNC, os.OpenFile would ignore it.

This change adds a new flag FILE_FLAG_WRITE_THROUGH, which is
the equivalent of O_SYNC flag on Linux and is documented in
https://docs.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-createfilea

Fixes #35358

Change-Id: Ib338caed5bb2f215723bfe30a2551a83998d92c9
GitHub-Last-Rev: 82c6275cb4
GitHub-Pull-Request: golang/go#64027
Reviewed-on: https://go-review.googlesource.com/c/go/+/541015
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Run-TryBot: Jes Cok <xigua67damn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
2023-11-20 16:08:51 +00:00
Ville Skyttä
1d187fd0be src: a/an grammar fixes
Change-Id: I179b50ae8e73677d4d408b83424afbbfe6aa17a1
GitHub-Last-Rev: 2e2d9c1e45
GitHub-Pull-Request: golang/go#63478
Reviewed-on: https://go-review.googlesource.com/c/go/+/534015
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-11-20 15:56:08 +00:00
Cherry Mui
752379113b runtime/race: update race syso for PPC64LE
Following CL 543035, this CL updates race syso for Linux/PPC64LE.
Now we have update all of them (except OpenBSD).

For #61395.
Fixes #62624.

Change-Id: I9e1d758355114a50ff206e5d78dc4ea8a06367d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/543397
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-20 15:19:32 +00:00
Matthew Dempsky
95712fe70b cmd/compile/internal/inline: remove useless code
There doesn't appear to be any need for this code. EditChildren won't
recurse into the closure body anyway.

Split out into a separate commit in case I'm overlooking something.

Change-Id: I004d1aa04865896de972bf3323b1622cc08a0d18
Reviewed-on: https://go-review.googlesource.com/c/go/+/543659
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-11-20 15:13:42 +00:00
Matthew Dempsky
28a8896d57 cmd/compile/internal/inline: allow inlining of checkptr arguments
The early return here is meant to suppress inlining of the function
call itself. However, it also suppresses recursing to visit the call
arguments, which are safe to inline.

Change-Id: I75887574c00931cb622277d04a822bc84c29bfa2
Reviewed-on: https://go-review.googlesource.com/c/go/+/543658
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-11-20 15:12:49 +00:00
Matthew Dempsky
0709f1bb00 cmd/compile/internal/ir: add CallExpr.GoDefer
The devirtualizer and inliner both want to recognize call expressions
that are part of a go or defer statement. This CL refactors them to
use a single CallExpr.GoDefer flag, which gets set during
normalization of go/defer statements during typecheck.

While here, drop some OCALLMETH assertions. Typecheck has been
responsible for desugaring them into OCALLFUNC for a while now, and
ssagen will check this again for us later anyway.

Change-Id: I3fc370f4417431aae97239313da6fe523f512a2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/543657
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-11-20 15:10:54 +00:00