]> Cypherpunks repositories - gostls13.git/log
gostls13.git
2 years agocmd/asm,cmd/internal/obj/ppc64: recognize ppc64 ISA 3.1 MMA registers
Paul E. Murphy [Tue, 10 Aug 2021 14:59:00 +0000 (09:59 -0500)]
cmd/asm,cmd/internal/obj/ppc64: recognize ppc64 ISA 3.1 MMA registers

Allow the assembler frontend to match MMA register arguments added by
ISA 3.1. The prefix "A" (for accumulator) is chosen to identify them.

Updates #44549

Change-Id: I363e7d1103aee19d7966829d2079c3d876621efc
Reviewed-on: https://go-review.googlesource.com/c/go/+/419534
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agocmd/compile: Add shiftIsBounded check for logic shifts of arm64
ruinan [Fri, 1 Jul 2022 06:25:12 +0000 (06:25 +0000)]
cmd/compile: Add shiftIsBounded check for logic shifts of arm64

This CL adds shiftIsBounded checks for the Lsh* and Rsh* rules in arm64.
There is no need to check the shift value again with CMP + CSEL when the
shift value is valid.

Change-Id: I54620de64f02a1b5a11089add237248ae2de01b4
Reviewed-on: https://go-review.googlesource.com/c/go/+/417714
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2 years agoos/exec: skip TestFindExecutableVsNoexec if mount failed
Kir Kolyshkin [Wed, 7 Sep 2022 17:30:46 +0000 (10:30 -0700)]
os/exec: skip TestFindExecutableVsNoexec if mount failed

Apparently, some testing environments do not allow root to mount tmpfs
(due to e.g. AppArmor profile disallowing mount(2) syscall).

Always skip the test if the mount has failed.

Fixes the test issue introduced by CL 414824.

Change-Id: Ic565d2e6f277f2926d85a351be7df2498ffba656
Reviewed-on: https://go-review.googlesource.com/c/go/+/429175
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agocmd/compile/internal/noder: fix type switch case vars package
Matthew Dempsky [Wed, 7 Sep 2022 02:30:30 +0000 (19:30 -0700)]
cmd/compile/internal/noder: fix type switch case vars package

When naming case variables, the unified frontend was using
typecheck.Lookup, which uses the current package, rather than
localIdent, which uses the package the variable was originally
declared in. When inlining across package boundaries, this could cause
the case variables to be associated with the wrong package.

In practice, I don't believe this has any negative consequences, but
it's inconsistent and triggered an ICE in typecheck.ClosureType, which
expected all captured variables to be declared in the same package.

Easy fix is to ensure case variables are declared in the correct
package by using localIdent.

Fixes #54912.

Change-Id: I7a429c708ad95723f46a67872cb0cf0c53a6a0d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/428918
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2 years agotest: add failing test case for inlined type switches
Matthew Dempsky [Wed, 7 Sep 2022 02:28:11 +0000 (19:28 -0700)]
test: add failing test case for inlined type switches

The unified frontend ICEs when inlining a function that contains a
function literal, which captures both a type switch case variable and
another variable.

Updates #54912.

Change-Id: I0e16d371ed5df48a70823beb0bf12110a5a17266
Reviewed-on: https://go-review.googlesource.com/c/go/+/428917
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agotest: fix typo in escape_unsafe.go
Matthew Dempsky [Wed, 7 Sep 2022 09:04:13 +0000 (02:04 -0700)]
test: fix typo in escape_unsafe.go

The toStringData test was meant to test reflect.StringHeader, not
reflect.SliceHeader. It's not supported to convert *string to
*reflect.SliceHeader anyway.

Change-Id: Iaa4912eafd241886c6337bd7607cdf2412a15ead
Reviewed-on: https://go-review.googlesource.com/c/go/+/428995
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agoreflect: fix stale Value.kind documentation
Joe Tsai [Wed, 24 Aug 2022 02:27:49 +0000 (19:27 -0700)]
reflect: fix stale Value.kind documentation

The lowests fives bits are the kind, and the next five bits are attributes,
not the other way around.

Change-Id: I5e1d13b195b766e99f66bb1227cc7f84e85dc49d
Reviewed-on: https://go-review.googlesource.com/c/go/+/425185
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>

2 years agodebug/gosym: rename nameoff to nameOff to match runtime
Michael Pratt [Tue, 6 Sep 2022 22:02:13 +0000 (18:02 -0400)]
debug/gosym: rename nameoff to nameOff to match runtime

Change-Id: Id33526e56bb25bc06746355f95045c5ef3c795c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/428660
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

2 years agocmd/link/internal/ld: update _func names to match runtime
Michael Pratt [Tue, 6 Sep 2022 22:00:35 +0000 (18:00 -0400)]
cmd/link/internal/ld: update _func names to match runtime

Change-Id: I4a47f676c0e533f7612fc3eb1b5dd8039f72782f
Reviewed-on: https://go-review.googlesource.com/c/go/+/428659
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>

2 years ago.github: update issue label for pkgsite-removal
Sean Liao [Sun, 5 Jun 2022 17:28:51 +0000 (18:28 +0100)]
.github: update issue label for pkgsite-removal

Change-Id: Ie90013077068b8e61bd651f2e686b06b6dad9fc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/410454
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Jamal Carvalho <jamal@golang.org>
Reviewed-by: Jamal Carvalho <jamal@golang.org>
Run-TryBot: Jamal Carvalho <jamal@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: rename _func.entryoff to entryOff
Michael Pratt [Tue, 6 Sep 2022 22:03:30 +0000 (18:03 -0400)]
runtime: rename _func.entryoff to entryOff

To match _func.nameOff.

Change-Id: I75e71cadaa0f7ca8844d1b49950673797b227074
Reviewed-on: https://go-review.googlesource.com/c/go/+/428658
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>

2 years agocmd/vet: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 12:16:04 +0000 (20:16 +0800)]
cmd/vet: use strings.Builder

Change-Id: I583e167dac033037e82e55a9ae6c6f0c47a34c7f
Reviewed-on: https://go-review.googlesource.com/c/go/+/428293
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tim King <taking@google.com>
Run-TryBot: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoruntime: rename _func.nameoff and friends to nameOff
Michael Pratt [Tue, 6 Sep 2022 21:57:07 +0000 (17:57 -0400)]
runtime: rename _func.nameoff and friends to nameOff

Switch to the more Go-style name to match inlinedCall.nameOff.

Change-Id: I2115b27af8309e1ead7d61ecc65fe4fc966030f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/428657
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2 years agoruntime: rename inlinedCall.func_ to inlinedCall.nameOff
Michael Pratt [Fri, 2 Sep 2022 20:59:07 +0000 (16:59 -0400)]
runtime: rename inlinedCall.func_ to inlinedCall.nameOff

The meaning of this field is unchanged, this CL simply gives it a more
descriptive name, as func_ makes it sound like a reference to the _func.

Change-Id: I70e54f34bede7636ce4d7b9dd0f7557308f02143
Reviewed-on: https://go-review.googlesource.com/c/go/+/427961
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agodatabase/sql: simplify retry logic when the connection is bad
Jinzhu [Mon, 5 Sep 2022 09:02:11 +0000 (09:02 +0000)]
database/sql: simplify retry logic when the connection is bad

Simplify retry logic when got bad connection

Change-Id: I92494c6c020576ec01bc4868334ee920ded7aa57
GitHub-Last-Rev: 7499b0c9419a31c9adce6d5096a1924aa3612f1d
GitHub-Pull-Request: golang/go#54043
Reviewed-on: https://go-review.googlesource.com/c/go/+/419182
Reviewed-by: Daniel Theophanes <kardianos@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: hopehook <hopehook@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoos: fix wrong error msg from TestReadClosed
Kir Kolyshkin [Wed, 7 Sep 2022 00:48:26 +0000 (17:48 -0700)]
os: fix wrong error msg from TestReadClosed

If test would fail, the error message will have wrong error and its
type, because e is used after the failed type assertion.

To fix, use the original err.

While at it,
 - combine the checks for error type and value into one statement;
 - use the standard "got ..., want ..." format.

Fixes: 212d2f82e050 ("os: add ErrClosed, return for use of closed File")
Change-Id: I862a96607b461ab89cce6bed2443b28aa2c16468
Reviewed-on: https://go-review.googlesource.com/c/go/+/428915
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agotest: add regression test for issue 54911
Cuong Manh Le [Wed, 7 Sep 2022 03:20:57 +0000 (10:20 +0700)]
test: add regression test for issue 54911

It was fixed by CL 422196, and have been already worked in unified IR.

Fixes #54911

Change-Id: Ie69044a64b296f6961e667e7661d8c4d1a24d84e
Reviewed-on: https://go-review.googlesource.com/c/go/+/428758
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2 years agogo/parser: use strings.Builder
cui fliter [Wed, 7 Sep 2022 04:06:46 +0000 (04:06 +0000)]
go/parser: use strings.Builder

Change-Id: Ic8078543eb80470505a3cc2da8ea9fb8fb1369aa
GitHub-Last-Rev: 7b358c685aec10afcdb98eb7de703e8e46ff0ecf
GitHub-Pull-Request: golang/go#54919
Reviewed-on: https://go-review.googlesource.com/c/go/+/428922
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoreflect: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:48:51 +0000 (18:48 +0800)]
reflect: use strings.Builder

Change-Id: Ie100a2a6f272b84fa2da6ac7b64452985242d788
Reviewed-on: https://go-review.googlesource.com/c/go/+/428275
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agonet/textproto: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:43:28 +0000 (18:43 +0800)]
net/textproto: use strings.Builder

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

2 years agoRevert "sync: convert Once.done to atomic type"
Ian Lance Taylor [Wed, 7 Sep 2022 01:14:31 +0000 (01:14 +0000)]
Revert "sync: convert Once.done to atomic type"

This reverts commit CL 427140.

Reason for revert: Comments say that done should be the first field.

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

2 years agotesting: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 11:18:50 +0000 (19:18 +0800)]
testing: use strings.Builder

Change-Id: Ied8a3019f1e21c0e74c798d2b1b279a606a38554
Reviewed-on: https://go-review.googlesource.com/c/go/+/428279
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agoruntime: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:53:24 +0000 (18:53 +0800)]
runtime: use strings.Builder

Change-Id: I9274d36ca983fdf59088b71a97b139ea262370dd
Reviewed-on: https://go-review.googlesource.com/c/go/+/428276
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agoos: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:45:00 +0000 (18:45 +0800)]
os: use strings.Builder

Change-Id: I610509aa35c345ff7fbb1fc94bf177ffbe934731
Reviewed-on: https://go-review.googlesource.com/c/go/+/428274
Reviewed-by: Ian Lance Taylor <iant@google.com>
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: Benny Siegert <bsiegert@gmail.com>
2 years agonet/smtp: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:41:58 +0000 (18:41 +0800)]
net/smtp: use strings.Builder

Change-Id: I0d1195fcb4eceb12c4be3190b05a82079dc496a3
Reviewed-on: https://go-review.googlesource.com/c/go/+/428272
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agounicode/utf8: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 11:20:31 +0000 (19:20 +0800)]
unicode/utf8: use strings.Builder

Change-Id: I88b55f61eccb5764cac2a9397fd99a62f8735a9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/428281
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2 years agocmd/compile: remove redundant SEQZ/SNEZ on riscv64
Joel Sing [Sat, 27 Aug 2022 20:11:43 +0000 (06:11 +1000)]
cmd/compile: remove redundant SEQZ/SNEZ on riscv64

In particular, (SEQZ (SNEZ x)) can arise from (Not (IsNonNil x)).

Change-Id: Ie249cd1934d71087e0f774cf8f6c937ceeed7ad5
Reviewed-on: https://go-review.googlesource.com/c/go/+/428215
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agocmd/compile: avoid zero extension after properly typed atomic operation on riscv64
Joel Sing [Mon, 29 Aug 2022 20:32:09 +0000 (06:32 +1000)]
cmd/compile: avoid zero extension after properly typed atomic operation on riscv64

LoweredAtomicLoad8 is implemented using MOVBU, hence it is already zero
extended. LoweredAtomicCas32 and LoweredAtomicCas64 return a properly
typed boolean.

Change-Id: Ie0acbaa19403d59c7e5f76d060cc13ee51eb7834
Reviewed-on: https://go-review.googlesource.com/c/go/+/428214
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>

2 years agocmd/compile: improve Slicemask on riscv64
Joel Sing [Mon, 29 Aug 2022 10:36:51 +0000 (20:36 +1000)]
cmd/compile: improve Slicemask on riscv64

Implement Slicemask the same way every other architecture does - negate
then arithmetic right shift. This sets or clears the sign bit, before
extending it to the entire register.

Removes around 2,500 instructions from the Go binary on linux/riscv64.

Change-Id: I4d675b826e7eb23fe2b1e6e46b95dcd49ab49733
Reviewed-on: https://go-review.googlesource.com/c/go/+/426354
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agosyscall: simplify code using unsafe.Slice
cuiweixie [Sat, 3 Sep 2022 10:18:30 +0000 (18:18 +0800)]
syscall: simplify code using unsafe.Slice

Updates #54854

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

2 years agoruntime: simplify code using unsafe.{Slice,String}
cuiweixie [Sat, 3 Sep 2022 06:29:35 +0000 (14:29 +0800)]
runtime: simplify code using unsafe.{Slice,String}

Updates #54854

Change-Id: Ie18665e93e477b6f220acf4c6c070b2af4343064
Reviewed-on: https://go-review.googlesource.com/c/go/+/428157
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: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agostrings: simplify code using unsafe.StringData
cuiweixie [Sat, 3 Sep 2022 06:35:41 +0000 (14:35 +0800)]
strings: simplify code using unsafe.StringData

Updates #54854

Change-Id: I93396dc92bd2decba895f2d059e1aeffcd22312c
Reviewed-on: https://go-review.googlesource.com/c/go/+/428158
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2 years agointernal/fuzz: simplify code using unsafe.{SliceData,Slice}
cuiweixie [Sat, 3 Sep 2022 06:28:35 +0000 (14:28 +0800)]
internal/fuzz: simplify code using unsafe.{SliceData,Slice}

Updates #54854

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

2 years agobytes: simplify code using unsafe.SliceData
cuiweixie [Sat, 3 Sep 2022 06:20:20 +0000 (14:20 +0800)]
bytes: simplify code using unsafe.SliceData

Updates #54854

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

2 years agocmd/compile/internal/ssagen: use strings.Builder
cuiweixie [Mon, 5 Sep 2022 07:05:27 +0000 (15:05 +0800)]
cmd/compile/internal/ssagen: use strings.Builder

Change-Id: I840262eefff1073a452a243b9e31f61b53362fcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/428360
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile/internal/ssa: use strings.Builder
cuiweixie [Mon, 5 Sep 2022 07:03:02 +0000 (15:03 +0800)]
cmd/compile/internal/ssa: use strings.Builder

Change-Id: Ieb15b54d36f18d1fbccbafe5451a4758df797718
Reviewed-on: https://go-review.googlesource.com/c/go/+/428359
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agocmd/compile/internal/pkginit: use strings.Builder
cuiweixie [Mon, 5 Sep 2022 06:57:40 +0000 (14:57 +0800)]
cmd/compile/internal/pkginit: use strings.Builder

Change-Id: If675277e17b97500100e46ec6fe471260131bafc
Reviewed-on: https://go-review.googlesource.com/c/go/+/428358
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2 years agocmd/compile/internal/ir: use strings.Builder
cuiweixie [Mon, 5 Sep 2022 06:56:27 +0000 (14:56 +0800)]
cmd/compile/internal/ir: use strings.Builder

Change-Id: I24fb36a0591782c07f26c3289265aa41a643666d
Reviewed-on: https://go-review.googlesource.com/c/go/+/428357
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>

2 years agocrypto/x509/internal/macos: simplify code using unsafe.{SliceData,StringData}
cuiweixie [Sat, 3 Sep 2022 06:18:13 +0000 (14:18 +0800)]
crypto/x509/internal/macos: simplify code using unsafe.{SliceData,StringData}

Updates #54854

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

2 years agonet: fix a typo in BenchmarkSendFile
Andy Pan [Tue, 6 Sep 2022 17:16:14 +0000 (01:16 +0800)]
net: fix a typo in BenchmarkSendFile

Change-Id: Ic463bd6d52e7d1d50d2dbd2122b4d514e0b4af60
Reviewed-on: https://go-review.googlesource.com/c/go/+/428755
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agonet/rpc/jsonrpc: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:39:48 +0000 (18:39 +0800)]
net/rpc/jsonrpc: use strings.Builder

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

2 years agoos/exec: LookPath: use eaccess for exec check on linux
Kir Kolyshkin [Tue, 28 Jun 2022 22:40:29 +0000 (15:40 -0700)]
os/exec: LookPath: use eaccess for exec check on linux

Having an executable bit set for a binary is not enough for it to be
executable -- there might be more checks in the kernel. For example,
binaries on a filesystem mounted with "noexec" flag couldn't be
executed. There might be other scenarios involving ACLs, SELinux,
file capabilities, and so on.

As a result, LookPath might either find a non-executable (while going
over $PATH elements), or return a false positive that the argument
provided is an executable.

One possible fix would be to perform the check by using access(2)
syscall with X_OK flag.

Now, since access(2) uses real (rather than effective) uid and gid,
when used by a setuid or setgid binary, it checks permissions of the
(real) user who started the binary, rather than the actual effective
permissions. Therefore, using access with X_OK won't work as expected
for setuid/setgid binaries.

To fix this, modern platforms added ways to check against effective uid
and gid, with the most common being the faccessat(2) call with the
AT_EACCESS flag, as described by POSIX.1-2008 (in Linux, only
faccessat2(2) supports flags such as AT_EACCESS). Let's use it, and fall
back to checking permission bits if faccessat is not available.

Wrap the logic into unix.Eaccess, which is currently only implemented on
Linux. While many other OSes (Free/Net/OpenBSD, AIX, Solaris/Illumos, and
Darwin) do implement faccessat(2) with AT_EACCESS, it is not wired in
syscall package (except for AIX), so these platforms are left out for now.
In the future, eaccess can be implemented for these OSes, too.

Alas, a call to unix.Eaccess is not enough since we have to filter out
directories, so use both stat and Eaccess.

One minor change introduced by this commit is that LookPath and Command
now returns "is a directory" error when the argument contains a slash
and is a directory.  This is similar to what e.g. bash does on Linux:

$ bash -c /etc
bash: line 1: /etc: Is a directory

Add a test case, which, unfortunately, requires root, is specific to
Linux, and needs a relatively new kernel (supporting faccessat2).  Other
platforms either have different semantics for tmpfs with noexec, or have
different ways to set up a binary which has x bit set but nevertheless
could not be executed.

Change-Id: If49b6ef6bf4dd23b2c32bebec8832d83e511a4bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/414824
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2 years agonet/http: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:30:29 +0000 (18:30 +0800)]
net/http: use strings.Builder

Change-Id: I754edcf21e003a3f4037fb2c5d8d06f2cd5f2fa3
Reviewed-on: https://go-review.googlesource.com/c/go/+/428267
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2 years agonet: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:17:40 +0000 (18:17 +0800)]
net: use strings.Builder

Change-Id: I3861a73d6b9d1d454c42bec50099b916bf30f1cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/428266
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
2 years agoall: update vendored golang.org/x/net
Damien Neil [Tue, 6 Sep 2022 16:58:29 +0000 (09:58 -0700)]
all: update vendored golang.org/x/net

Pull in security fix:

    f3363e06e7 http2: handle server errors after sending GOAWAY

Fixes CVE-2022-27664
Fixes golang/go#54658

Change-Id: Ie1f58a8d769c7fd75c67d202c611a3abfd7dbb35
Reviewed-on: https://go-review.googlesource.com/c/go/+/428717
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Damien Neil <dneil@google.com>

2 years agocmd/link,runtime: remove unused fields from inlinedCall
Michael Pratt [Fri, 2 Sep 2022 20:50:41 +0000 (16:50 -0400)]
cmd/link,runtime: remove unused fields from inlinedCall

The parent, file, and line fields are no longer used now that we have
parentPc to find the parent and NOPs in the parent to attach file/line
pcdata to.

Removing these fields reduces the binary size of cmd/go on linux-amd64
by 1.1%.

Fixes #54849.

Change-Id: If58f08622736b2b322288608776f8bedf0c3fd17
Reviewed-on: https://go-review.googlesource.com/c/go/+/427960
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agocmd/compile: do not devirtualize defer/go calls
Cuong Manh Le [Tue, 6 Sep 2022 05:54:54 +0000 (12:54 +0700)]
cmd/compile: do not devirtualize defer/go calls

For defer/go calls, the function/method value are evaluated immediately.
So after devirtualizing, it may trigger a panic when implicitly deref
a nil pointer receiver, causing the program behaves unexpectedly.

It's safer to not devirtualizing defer/go calls at all.

Fixes #52072

Change-Id: I562c2860e3e577b36387dc0a12ae5077bc0766bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/428495
Reviewed-by: Michael Knyszek <mknyszek@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>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

2 years agocmd/compile: gofmt comments
zhangyunhao [Tue, 6 Sep 2022 10:39:52 +0000 (18:39 +0800)]
cmd/compile: gofmt comments

Change-Id: I79634efbd8d0189afdfe22e147d63c889e8047ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/427964
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agonet/http: clarify proxy selection from environment
Sean Liao [Tue, 6 Sep 2022 17:22:44 +0000 (18:22 +0100)]
net/http: clarify proxy selection from environment

For #40909
Fixes #54890

Change-Id: I00218bc1606eedb6194a3a7b81fd4d3f75325280
Reviewed-on: https://go-review.googlesource.com/c/go/+/428775
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>

2 years agocmd/compile/internal/syntax: use strings.Builder
cuiweixie [Mon, 5 Sep 2022 07:06:38 +0000 (15:06 +0800)]
cmd/compile/internal/syntax: use strings.Builder

Change-Id: Ic18d12b3d1c2f4819f2656371537df797e9970ef
Reviewed-on: https://go-review.googlesource.com/c/go/+/428361
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agonet/http: using strings.Builder
cuiweixie [Fri, 2 Sep 2022 23:14:29 +0000 (07:14 +0800)]
net/http: using strings.Builder

Change-Id: I5d4c89a8d87a8697d038bf91b17d7ffc847a49c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/428137
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agogo/doc: using strings.Builder
cuiweixie [Fri, 2 Sep 2022 23:09:54 +0000 (07:09 +0800)]
go/doc: using strings.Builder

Change-Id: I9658c37a548a386c57d83dc13d5e9925a9c13211
Reviewed-on: https://go-review.googlesource.com/c/go/+/428140
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agogo/ast: using strings.Builder
cuiweixie [Fri, 2 Sep 2022 23:06:19 +0000 (07:06 +0800)]
go/ast: using strings.Builder

Change-Id: I05ebaf4e11b5b6ca7d9bbb0b2241def7773b11cc
Reviewed-on: https://go-review.googlesource.com/c/go/+/428138
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: xie cui <523516579@qq.com>

2 years agoall: make sure *Pointer[T]'s methods are inlined as intended
Cuong Manh Le [Mon, 5 Sep 2022 12:07:02 +0000 (19:07 +0700)]
all: make sure *Pointer[T]'s methods are inlined as intended

Updates #50860

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

2 years agointernal/poll, internal/syscall/unix, net: enable writev on solaris
Tobias Klauser [Mon, 5 Sep 2022 13:38:18 +0000 (15:38 +0200)]
internal/poll, internal/syscall/unix, net: enable writev on solaris

The writev syscall is available since at least Solaris 11.3.

Reuse the existing illumos writev wrapper on solaris to implement
internal/poll.writev for net.(*netFD).writeBuffers.

Change-Id: I23adc3bb4637740c72bfb61bfa9697b432dfe3db
Reviewed-on: https://go-review.googlesource.com/c/go/+/427714
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: Michael Knyszek <mknyszek@google.com>
2 years agomime: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:10:07 +0000 (18:10 +0800)]
mime: use strings.Builder

Change-Id: I2756fab046154a2df49435ba1978a32176de830a
Reviewed-on: https://go-review.googlesource.com/c/go/+/428265
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2 years agonet/http/cgi: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:32:05 +0000 (18:32 +0800)]
net/http/cgi: use strings.Builder

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

2 years agonet/http/httptrace: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:36:22 +0000 (18:36 +0800)]
net/http/httptrace: use strings.Builder

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

2 years agonet/http/httputil: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:37:30 +0000 (18:37 +0800)]
net/http/httputil: use strings.Builder

Change-Id: Ifb51413894791154489bd1d4f529088958212c62
Reviewed-on: https://go-review.googlesource.com/c/go/+/428270
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agocmd/doc: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 12:07:22 +0000 (20:07 +0800)]
cmd/doc: use strings.Builder

Change-Id: Ib33d1f1c2e9aed0cb9e00bd699c4ae4a2df5dfca
Reviewed-on: https://go-review.googlesource.com/c/go/+/428288
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Rob Pike <r@golang.org>
Auto-Submit: Rob Pike <r@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoruntime: remove unused parameter on runOpenDeferFrame
Daniel Martí [Wed, 31 Aug 2022 10:27:52 +0000 (11:27 +0100)]
runtime: remove unused parameter on runOpenDeferFrame

Found via unparam.

Change-Id: I21126405beaf0be84e14ac165ecb68aeb0c9c823
Reviewed-on: https://go-review.googlesource.com/c/go/+/427014
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: hopehook <hopehook@golangcn.org>
2 years agonet/http: make triv.go example less insecure
Damien Neil [Sun, 4 Sep 2022 02:51:48 +0000 (19:51 -0700)]
net/http: make triv.go example less insecure

The triv.go example serves the entire contents of $HOME by default.
That seems bad, let's not do that.

Also change it to listen on localhost only.

Change-Id: I8f1b7bd6b7d737852273e2ba82deabc4a2d11f6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/428237
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Tatiana Bradley <tatiana@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agonet: mark withTCPConnPair as test helper
Tobias Klauser [Mon, 5 Sep 2022 13:38:57 +0000 (15:38 +0200)]
net: mark withTCPConnPair as test helper

Noticed while analyzing test failures on go.dev/cl/427714 that were
pointing to withTCPConnPair instead of the failing tests.

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

2 years agodebug/buildinfo: remove redundant type conversion
Sasha Melentyev [Sat, 3 Sep 2022 20:08:12 +0000 (20:08 +0000)]
debug/buildinfo: remove redundant type conversion

Change-Id: Ia8ffc9a17646ad2c74f633610aaf34fef006c023
GitHub-Last-Rev: 6ab0d107393c9bdfeaed5c539efb452942c00394
GitHub-Pull-Request: golang/go#54856
Reviewed-on: https://go-review.googlesource.com/c/go/+/428235
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agonet: add benchmark test for SendFile
Andy Pan [Fri, 26 Aug 2022 17:55:05 +0000 (01:55 +0800)]
net: add benchmark test for SendFile

BenchmarkSendFile/1024-4                  716760              1582 ns/op         647.31 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/2048-4                  624632              2057 ns/op         995.55 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/4096-4                  429459              2665 ns/op        1537.06 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/8192-4                  275941              4996 ns/op        1639.56 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/16384-4                 149577              8522 ns/op        1922.58 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/32768-4                  75427             14791 ns/op        2215.47 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/65536-4                  43912             28402 ns/op        2307.41 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/131072-4                 23509             48657 ns/op        2693.82 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/262144-4                 12512             91791 ns/op        2855.87 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/524288-4                  5760            579891 ns/op         904.12 MB/s           0 B/op          0 allocs/op
BenchmarkSendFile/1048576-4                 3020            344129 ns/op        3047.05 MB/s           0 B/op          0 allocs/op

Change-Id: Iaf75e19c9ae8d77b89b3eabb2e9142f59c124536
Reviewed-on: https://go-review.googlesource.com/c/go/+/425878
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agoos: delete unused errClosed
Andy Pan [Wed, 31 Aug 2022 13:59:29 +0000 (21:59 +0800)]
os: delete unused errClosed

errClosed was introduced by CL 163058 and was supposed to be removed by CL 243906,
but somehow it was left out, now we should get it deleted.

Change-Id: I74c4b36b8bbc4844e1860acb022a16b0aa3272b2
Reviewed-on: https://go-review.googlesource.com/c/go/+/427035
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoruntime: add missing copyright header to signal_windows_test.go
Tobias Klauser [Fri, 2 Sep 2022 12:28:11 +0000 (14:28 +0200)]
runtime: add missing copyright header to signal_windows_test.go

The file was added in CL 181839 which was submitted in 2019.

Also delete the superfluous //go:build windows build constraint which is
already part of the file name.

Change-Id: Iecdf3d75848a7b8e2a76cd18c9fff4fb90acdac2
Reviewed-on: https://go-review.googlesource.com/c/go/+/427854
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agosync: convert Once.done to atomic type
cuiweixie [Fri, 2 Sep 2022 03:06:58 +0000 (11:06 +0800)]
sync: convert Once.done to atomic type

Change-Id: I49f8c764d49cabaad4d6859c219ba7220a389c1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/427140
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2 years agomath/big: replace dead link in a comment with link to an archive.org copy
Alok Menghrajani [Sat, 3 Sep 2022 21:16:49 +0000 (21:16 +0000)]
math/big: replace dead link in a comment with link to an archive.org copy

Happy to use another service if web.archive.org isn't suitable.

Note: the original page redirects and then links to some nsfw content.

Change-Id: Ie93ca0c6aad871881f35b7e5609b96da5c14cfc0
GitHub-Last-Rev: ced5a97eb5c1d954a04d4bb61d36d955ca45a6ab
GitHub-Pull-Request: golang/go#54857
Reviewed-on: https://go-review.googlesource.com/c/go/+/428236
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2 years agoruntime: in traceback, only jump stack if M doesn't change
Austin Clements [Tue, 6 Sep 2022 15:42:12 +0000 (11:42 -0400)]
runtime: in traceback, only jump stack if M doesn't change

CL 424257 modified gentraceback to switch gp when jumping from a
system stack to a user stack to simplify reasoning through the rest of
the function. This has the unintended side-effect of also switching
all references to gp.m. The vast majority of the time, g0.m and curg.m
are the same across a stack switch, making this a no-op, but there's
at least one case where this isn't true: if a profiling signal happens
in execute between setting mp.curg and setting gp.m. In this case,
mp.curg.m is briefly nil, which can cause gentraceback to crash with a
nil pointer dereference. We see this failure (surprisingly
frequently!) in profiling tests in the morestack=mayMoreStackPreempt
testing mode (#48297).

Fix this by making only jumping stacks if doing so will not switch Ms.
This restores the original property that gp.m doesn't change across
the stack jump, and makes gentraceback a little more conservative
about jumping stacks.

Fixes #54885.

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

2 years agolog: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:06:50 +0000 (18:06 +0800)]
log: use strings.Builder

Change-Id: I02c4664f1ba72623a5470e92bbebabb2f4862428
Reviewed-on: https://go-review.googlesource.com/c/go/+/428264
Reviewed-by: Robert Griesemer <gri@google.com>
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: Ian Lance Taylor <iant@google.com>
2 years agoio: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:05:12 +0000 (18:05 +0800)]
io: use strings.Builder

Change-Id: Ibab20627ccd1f79e77e3972e2bc6ca42c2c7de13
Reviewed-on: https://go-review.googlesource.com/c/go/+/428263
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoimage/jpeg: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:02:06 +0000 (18:02 +0800)]
image/jpeg: use strings.Builder

Change-Id: I0a51aa9e7800689c123ce3eaf74742a4641b7681
Reviewed-on: https://go-review.googlesource.com/c/go/+/428261
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agohtml/template: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 09:59:50 +0000 (17:59 +0800)]
html/template: use strings.Builder

Change-Id: Iab6ef8c6c74c09e8358f7d7088a82089725479ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/428260
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agoflag: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 09:47:17 +0000 (17:47 +0800)]
flag: use strings.Builder

Change-Id: Iee846c4ac0f111ff97aa618dd42f6b2d14aa4342
Reviewed-on: https://go-review.googlesource.com/c/go/+/428259
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>

2 years agoencoding: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 09:44:30 +0000 (17:44 +0800)]
encoding: use strings.Builder

Change-Id: Ib07699df8ea41fd8d1bca8ad050859fac24623de
Reviewed-on: https://go-review.googlesource.com/c/go/+/428258
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agodebug: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 09:31:08 +0000 (17:31 +0800)]
debug: use strings.Builder

Change-Id: I59db11212758b478248f34c031501a167335348c
Reviewed-on: https://go-review.googlesource.com/c/go/+/428257
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: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agobufio: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 09:26:48 +0000 (17:26 +0800)]
bufio: use strings.Builder

Change-Id: Ief82f12a5c48c46165c28140997d5fc83700c758
Reviewed-on: https://go-review.googlesource.com/c/go/+/428256
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>

2 years agoarchive: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 09:22:48 +0000 (17:22 +0800)]
archive: use strings.Builder

Change-Id: I07e022ffc022bca6aa12165871e723db3ed83141
Reviewed-on: https://go-review.googlesource.com/c/go/+/428255
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2 years agomisc: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 09:21:08 +0000 (17:21 +0800)]
misc: use strings.Builder

Change-Id: Icb53d32f2de13287b1b4f4f67dab90fe5ee7a3df
Reviewed-on: https://go-review.googlesource.com/c/go/+/428254
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>

2 years agoRevert "runtime: convert local var stop,ready at TestDebugCallUnsafePoint to atomic...
Daniel Martí [Mon, 5 Sep 2022 08:30:02 +0000 (08:30 +0000)]
Revert "runtime: convert local var stop,ready at TestDebugCallUnsafePoint to atomic type"

This reverts https://go.dev/cl/427135.

Reason for revert: broke the test it modified on linux-amd64-noopt.

    --- FAIL: TestDebugCallUnsafePoint (0.00s)
        debug_test.go:265: want "call not at safe point", got %!s(<nil>)

Change-Id: I044c9720aed2d5e48b56bd7ab2781462270dcae9
Reviewed-on: https://go-review.googlesource.com/c/go/+/428395
Reviewed-by: xie cui <523516579@qq.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: hopehook <hopehook@golangcn.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agointernal/trace: use strings.Builder
cuiweixie [Sun, 4 Sep 2022 10:02:51 +0000 (18:02 +0800)]
internal/trace: use strings.Builder

Change-Id: Ic7f827b8ee758c991ed76be65026b0330207deea
Reviewed-on: https://go-review.googlesource.com/c/go/+/428262
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agoRevert "internal/poll: drop redundant ENOSYS and EXDEV error checks in CopyFileRange()"
Daniel Martí [Mon, 5 Sep 2022 08:37:48 +0000 (08:37 +0000)]
Revert "internal/poll: drop redundant ENOSYS and EXDEV error checks in CopyFileRange()"

This reverts https://go.dev/cl/425881.

Reason for revert: broke make.bash on linux/amd64 with Linux 5.19.6.

[...]
Building Go toolchain2 using go_bootstrap and Go toolchain1.
go install internal/unsafeheader: copying /tmp/go-build4206185186/b007/_pkg_.a to /home/mvdan/tip/pkg/linux_amd64/internal/unsafeheader.a: write /home/mvdan/tip/pkg/linux_amd64/internal/unsafeheader.a: copy_file_range: invalid cross-device link
go install internal/goarch: copying /tmp/go-build4206185186/b006/_pkg_.a to /home/mvdan/tip/pkg/linux_amd64/internal/goarch.a: write /home/mvdan/tip/pkg/linux_amd64/internal/goarch.a: copy_file_range: invalid cross-device link
[...]

Change-Id: I793856935d4315a870c2d31da46be00cc342b5f8
Reviewed-on: https://go-review.googlesource.com/c/go/+/428396
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: hopehook <hopehook@golangcn.org>
Reviewed-by: Andy Pan <panjf2000@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agointernal/syscall/unix: KernelVersion nitpicks
Kir Kolyshkin [Thu, 1 Sep 2022 21:50:26 +0000 (14:50 -0700)]
internal/syscall/unix: KernelVersion nitpicks

A few minor improvements for KernelVersion for the sake of readability.

Change-Id: I06d2df60ecee8ee0ae603952470fb73e7dcd5d74
Reviewed-on: https://go-review.googlesource.com/c/go/+/427676
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>

2 years agointernal/syscall/unix: simplify KernelVersion
Kir Kolyshkin [Thu, 1 Sep 2022 21:43:39 +0000 (14:43 -0700)]
internal/syscall/unix: simplify KernelVersion

Since values[2] elements are initialized with 0, the switch statement
doesn't do anything. Remove it.

Change-Id: I41176692cdf0c01fe8e85315f0c0dc8b0f3d41fd
Reviewed-on: https://go-review.googlesource.com/c/go/+/427675
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2 years agoruntime: refactor finalizer goroutine status
Leonard Wang [Wed, 13 Apr 2022 13:14:22 +0000 (21:14 +0800)]
runtime: refactor finalizer goroutine status

Use an atomic.Uint32 to represent the state of finalizer goroutine.
fingStatus will only be changed to fingWake in non fingWait state,
so it is safe to set fingRunningFinalizer status in runfinq.

name            old time/op  new time/op  delta
Finalizer-8      592µs ± 4%   561µs ± 1%  -5.22%  (p=0.000 n=10+10)
FinalizerRun-8   694ns ± 6%   675ns ± 7%    ~     (p=0.059 n=9+8)

Change-Id: I7e4da30cec98ce99f7d8cf4c97f933a8a2d1cae1
Reviewed-on: https://go-review.googlesource.com/c/go/+/400134
Reviewed-by: Joedian Reid <joedian@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Michael Pratt <mpratt@google.com>
2 years agogo/ast: add Range token.Pos to RangeStmt
cuiweixie [Sat, 27 Aug 2022 07:21:29 +0000 (15:21 +0800)]
go/ast: add Range token.Pos to RangeStmt

For #50429

Change-Id: Idb027244f901d9f482c894b5b979a054d0f07de5
Reviewed-on: https://go-review.googlesource.com/c/go/+/426091
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Findley <rfindley@google.com>

2 years agointernal/poll: drop redundant ENOSYS and EXDEV error checks in CopyFileRange()
Andy Pan [Sat, 27 Aug 2022 02:44:25 +0000 (10:44 +0800)]
internal/poll: drop redundant ENOSYS and EXDEV error checks in CopyFileRange()

The initial CL 229101 didn't limit the kernel version, but relies on error checking to
ensure the kernel version >= 4.5 or >= 5.3 when it's calling copy_file_range(2) to copy data across file systems.

Since we have now put the kernel version checking at the beginning of the function, introduced by CL 268338,
which returns early instead of going forward to the code behind when the kernel verion is older than 5.3,
therefore, those subsequent related error checks are no longer needed.

Change-Id: Ifc4a530723e21f0bde91d6420cde9cb676081922
Reviewed-on: https://go-review.googlesource.com/c/go/+/425881
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: hopehook <hopehook@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2 years agoruntime: convert local var stop at TestAfterStress to atomic type
cuiweixie [Fri, 2 Sep 2022 02:53:13 +0000 (10:53 +0800)]
runtime: convert local var stop at TestAfterStress to atomic type

For #53821

Change-Id: I7e86dac34691f7752f68879ff379061f3435cd45
Reviewed-on: https://go-review.googlesource.com/c/go/+/427139
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2 years agoruntime: convert local var started,progress at TestStackGrowth to atomic type
cuiweixie [Fri, 2 Sep 2022 02:44:46 +0000 (10:44 +0800)]
runtime: convert local var started,progress at TestStackGrowth to atomic type

For #53821

Change-Id: I9c777ff642ea4b70073335279551cea6a2394569
Reviewed-on: https://go-review.googlesource.com/c/go/+/427138
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2 years agoruntime: convert local var cunlock at doTestParallelReaders to atomic type
cuiweixie [Fri, 2 Sep 2022 02:37:16 +0000 (10:37 +0800)]
runtime: convert local var cunlock at doTestParallelReaders to atomic type

For #53821

Change-Id: I17440ea30827976a8d3755851a2496f26aea13b1
Reviewed-on: https://go-review.googlesource.com/c/go/+/427137
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2 years agoruntime: convert local var ready at TestMemmoveAtomicity to atomic type
cuiweixie [Fri, 2 Sep 2022 02:31:34 +0000 (10:31 +0800)]
runtime: convert local var ready at TestMemmoveAtomicity to atomic type

For #53821

Change-Id: I2487b8d18a4cd3fc6e64fbbb531419812bfe0f08
Reviewed-on: https://go-review.googlesource.com/c/go/+/427136
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2 years agoruntime: convert local var stop,ready at TestDebugCallUnsafePoint to atomic type
cuiweixie [Fri, 2 Sep 2022 02:18:51 +0000 (10:18 +0800)]
runtime: convert local var stop,ready at TestDebugCallUnsafePoint to atomic type

For #53821

Change-Id: Id972d4ccadc72de69dea46f8be146c9843d1d095
Reviewed-on: https://go-review.googlesource.com/c/go/+/427135
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>

2 years agonet/http: don't time out idle server connections after ReadHeaderTimeout
Eliza Weisman [Wed, 31 Aug 2022 19:16:18 +0000 (19:16 +0000)]
net/http: don't time out idle server connections after ReadHeaderTimeout

Consistently wait for idle connections to become readable before
starting the ReadHeaderTimeout timer. Previously, connections with no
idle timeout skipped directly to reading headers, so the
ReadHeaderTimeout also included time spent idle.

Fixes #54784

Change-Id: Iff1a876f00311d03dfa0fbef5b577506c62f7c41
GitHub-Last-Rev: 09332743ad6d5a9eb1137adaade2810c583d38ca
GitHub-Pull-Request: golang/go#54785
Reviewed-on: https://go-review.googlesource.com/c/go/+/426895
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2 years agonet: precompute rfc6724policyTable in addrselect
Tomasz Jezierski [Sun, 24 Jul 2022 21:02:53 +0000 (23:02 +0200)]
net: precompute rfc6724policyTable in addrselect

As net package has one of the biggest init time in standard library, I have tried to improve performance by doing two things in net/addrselect.go:
1. Precompute slice with RFC rules. Currently the rules are computed and sorted in init() function. We could save the time and allocations by using prepopulated values in sorted manner. The rules haven't changed since 2015. To be extra safe we could move order validation as test case. It should slightly speed up startup of each binary with "net" package and go dns resolver. It also saves 38 allocations, ~50% of allocations in init phase of `net` module.
2. Replace internal net.IP usage with netip.Addr in `sortByRFC6724` function. It results in ~40% performance improvement on samples from tests.

The only risk is the difference between net.IP and netip.Addr behaviour.

Init benchmark:
Init-8               1.89µs ± 2%    0.12µs ± 3%  -93.79%  (p=0.000 n=5+5)

name               old alloc/op   new alloc/op   delta
Init-8               1.05kB ± 0%    0.38kB ± 0%     ~     (zero variance)

name               old allocs/op  new allocs/op  delta
Init-8                 39.0 ± 0%       1.0 ± 0%     ~     (zero variance)

Whole sortByRFC6724 function benchmark:
name               old time/op    new time/op    delta
SortByRFC6724/0-8     463ns ± 3%     303ns ± 4%  -34.72%  (p=0.000 n=5+5)
SortByRFC6724/1-8     481ns ± 8%     306ns ± 1%  -36.46%  (p=0.000 n=5+5)
SortByRFC6724/2-8     470ns ± 4%     307ns ± 4%  -34.77%  (p=0.000 n=5+5)
SortByRFC6724/3-8     567ns ± 3%     367ns ± 3%  -35.28%  (p=0.000 n=5+5)
SortByRFC6724/4-8     918ns ± 3%     560ns ± 2%  -38.93%  (p=0.000 n=5+5)

Updates #54032

Change-Id: Ic18df1ea73805cb184c6ceb73470ca7f0b922032
Reviewed-on: https://go-review.googlesource.com/c/go/+/419356
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2 years agoruntime: convert g.atomicstatus to internal atomic type
Andy Pan [Wed, 24 Aug 2022 19:27:02 +0000 (03:27 +0800)]
runtime: convert g.atomicstatus to internal atomic type

Note that this changes some unsynchronized operations of g.atomicstatus to synchronized operations.

Updates #53821

Change-Id: If249d62420ea09fbec39b570942f96c63669c333
Reviewed-on: https://go-review.googlesource.com/c/go/+/425363
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2 years agocmd/go: make cfg.BuildContext.ToolTags same order with build.Default.ToolTags
Cuong Manh Le [Wed, 10 Aug 2022 15:52:58 +0000 (22:52 +0700)]
cmd/go: make cfg.BuildContext.ToolTags same order with build.Default.ToolTags

So it's consistent when running "go list -f '{{context.ToolTags}}'" and
printing the content of "build.Default.ToolTags".

Updates #45454

Change-Id: I7a3cbf3cdf9a6ce2b8c89e9bcf5fc5e9086d48e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/422615
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>

2 years agoruntime: fast clock_gettime on FreeBSD, use physical/virtual ARM timer
Yuval Pavel Zholkover [Fri, 12 Aug 2022 18:57:28 +0000 (21:57 +0300)]
runtime: fast clock_gettime on FreeBSD, use physical/virtual ARM timer

as setup by the kernel on GOARCH=arm64.

Update #50947

Change-Id: I2f44be9b36e9ce8d264eccc0aa3df10825c5f4f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/422977
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Dmitri Goutnik <dgoutnik@gmail.com>
Run-TryBot: Yuval Pavel Zholkover <paulzhol@gmail.com>

2 years agointernal/syscall/unix: consolidate kernelVersion implementations
Kir Kolyshkin [Thu, 18 Aug 2022 20:43:47 +0000 (13:43 -0700)]
internal/syscall/unix: consolidate kernelVersion implementations

Currently, there are 3 functions returning Linux kernel version numbers.

Two of them are identical:
 - in net, initially added by commit 0a9dd47dd817904e;
 - in internal/poll, initially added by commit 1c7650aa93bd53;

(both were later fixed by commit 66c02645062561a).

The third one is a more complex, regexp-based implementation in
runtime/pprof, which is only used for a test.

Instead of adding one more, let's consolidate existing ones.

Remove the complex implementation, and move the simple one into
internal/syscall/unix. Use it from all the three places mentioned above.

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

2 years agogo/types, types2: use strings.Builder instead of bytes.Buffer where possible
Robert Griesemer [Fri, 2 Sep 2022 19:10:24 +0000 (12:10 -0700)]
go/types, types2: use strings.Builder instead of bytes.Buffer where possible

Also, consistently use declaration: var buf strings.Builder.
We don't change exported signatures to match go/types (where we
can't change the exported signatures for backward-compatibility).

Change-Id: I75350886aa231889ae2fd5c4008dd4be9ed6e09f
Reviewed-on: https://go-review.googlesource.com/c/go/+/428094
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>