1
0
mirror of https://github.com/golang/go synced 2024-11-15 06:20:21 -07:00
Commit Graph

59903 Commits

Author SHA1 Message Date
Alan Donovan
6defff5005 cmd/vet: add stdversion analyzer
+ release note, test

Fixes #46136

Change-Id: Ib157c5343dde379f8d6f67bdfa64b3f6a6432bab
Reviewed-on: https://go-review.googlesource.com/c/go/+/582556
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2024-05-03 01:02:40 +00:00
Olivier Mengué
344075d936 spec: clarify when range expression is evaluated
Clarify that the range expression of a "for" loop is called *just* once to
rule out that it might be re-evaluated after each iteration.

Change-Id: Iedb61cd29e5238ac0168b8ac01c34d6208cc4312
Reviewed-on: https://go-review.googlesource.com/c/go/+/582775
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-05-02 22:43:51 +00:00
Ian Lance Taylor
e602625c5e cmd/go: pass -Wl,-z,nodelete for c-shared mode with gccgo
This is the gccgo version of CL 15605.

For https://gcc.gnu.org/PR114699

For #11100
For #12582
For #12873

Change-Id: I30e23130737022d772971f0bd629b57269174886
Reviewed-on: https://go-review.googlesource.com/c/go/+/582975
Reviewed-by: Than McIntosh <thanm@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2024-05-02 22:18:34 +00:00
Tobias Klauser
b64e5e38ab net: use stringslite.HasPrefix
Change-Id: Ib14c70f580d0891b3fbedf9e4cde93077409d4e6
Reviewed-on: https://go-review.googlesource.com/c/go/+/582915
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-05-02 22:14:43 +00:00
Russ Cox
8f71c7633f runtime: remove note about goid reuse
Goids are designed to be big enough that they will never be reused:
a uint64 is enough to generate a new goroutine every nanosecond
for 500+ years before wrapping around, and after 500 years you
should probably stop and pick up some security updates.

This note was added in CL 70993 and appears to have just been
a misunderstanding by the CL author.

Change-Id: Ida7099b5191a4e5dbb1e3e9e44b4b86d7779fd6d
Reviewed-on: https://go-review.googlesource.com/c/go/+/582895
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Russ Cox <rsc@golang.org>
2024-05-02 21:10:56 +00:00
Jorropo
865cf5c5f6 testing: improve the documentation around b.N
Fixes #67137

- Make it clear the benchmark function is called multiple times.
- Demonstrate range over int.

Change-Id: I7e993d938b0351012cdd4aed8528951e0ad406ae
Reviewed-on: https://go-review.googlesource.com/c/go/+/582835
Auto-Submit: Alan Donovan <adonovan@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-05-02 18:41:57 +00:00
Michael Matloob
660a071906 cmd/internal/telemetry: add NewStackCounter functions
This CL adds a wrapper for the golang.org/x/telemetry/counter.NewStack
function so that it can be used by the compiler.

Also add build constraints for compiler_bootstrap to build the stubs
when we're bootstrapping the compiler.

For #58894

Change-Id: Icdbdd7aa6d2a3f1147112739c6939e14414f5ee9
Cq-Include-Trybots: luci.golang.try:gotip-linux-arm64-longtest,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/582695
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
2024-05-01 17:37:58 +00:00
cui fliter
c5698e3155 cmd/pprof: fix exception when file or path contains colon
Fixes #63924

Change-Id: I4ea17979faaca04eb6b046abffca2dd77397e0cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/539595
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-05-01 03:56:37 +00:00
Daniel Martí
959e65c41c bytes: fix up godoc link errors
[Reader.Reader] does not exist in this package.
These docs most likely meant to refer to [Reader] itself.

Change-Id: I4fa117e8541573e0be7c13751fdfc102d5f2d604
Reviewed-on: https://go-review.googlesource.com/c/go/+/582515
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-04-30 19:45:36 +00:00
Jonathan Amsterdam
cf05873029 net/http: represent multi wildcards properly
The routing tree used for matching ServeMux patterns used the
key "*" to hold a child node for a multi-segment wildcard.
The problem is that "*" is a valid path segment, which confused
the matching algorithm: it would fetch the multi wildcard child
when looking for the literal child for "*".

Eschew clever encodings. Use a separate field in the node to
represent the multi wildcard child.

Fixes #67067.

Change-Id: I300ca08b8628f5367626cf41979f6c238ed8c831
Reviewed-on: https://go-review.googlesource.com/c/go/+/582115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-04-30 15:43:24 +00:00
qmuntal
8509f6939c os: use filepathlite.FromSlash
Change-Id: Id15ebd9e97a8626e64665f6830a662e62432a619
Reviewed-on: https://go-review.googlesource.com/c/go/+/582500
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-30 15:38:38 +00:00
qmuntal
5616ab6025 os: use filepathlite.VolumeName
It is better to have a single implementation of VolumeName, which is
quite tricky to get right on Windows.

Change-Id: Ibba82dd71fe10b594cb6f782582430aa422e7078
Reviewed-on: https://go-review.googlesource.com/c/go/+/582499
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-30 15:38:09 +00:00
qmuntal
d95fa7aca7 os: use filepathlite.IsAbs
It is better to have a single implementation of IsAbs, which is quite
tricky to get right on Windows.

Change-Id: I45933b0ceff2920d9eddb61e62aacb2602c3dc8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/582498
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-30 15:37:05 +00:00
Tobias Klauser
150f45b2c4 os: use stringslite.HasPrefix
Change-Id: I791bdfecc6c94ee9dac592d60d95e97182bf0120
Reviewed-on: https://go-review.googlesource.com/c/go/+/582496
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-04-30 15:35:30 +00:00
The Backend Grip
3206a9b562 http: fix some comments typo in server.go
Change-Id: I826412175876a84ab978aba9418be28593484fba
GitHub-Last-Rev: d35753c7e0
GitHub-Pull-Request: golang/go#67112
Reviewed-on: https://go-review.googlesource.com/c/go/+/582435
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-30 15:35:05 +00:00
Tobias Klauser
476a352522 syscall: use stringslite.Has{Prefix,Suffix}
Change-Id: I393191b95eeb8e17345ce28cfa1fb54a3ef13951
Reviewed-on: https://go-review.googlesource.com/c/go/+/582237
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2024-04-30 15:34:18 +00:00
qmuntal
dc164eade1 os: remove ineffective else branch
Change-Id: Ic9cf871d862aec54ab8f491b8bc8d2820aecc875
Reviewed-on: https://go-review.googlesource.com/c/go/+/582497
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-30 12:44:22 +00:00
David du Colombier
16ce8b3925 net: fix lookupHost on Plan 9
CL 532217 added the newDNSError function.

However, the implementation was not correct on
Plan 9, which lead TestLookupNoSuchHost to fail.

This change fixes lookupHost on Plan 9.

Fixes #67096.

Change-Id: I39271f7d588b19c1b1608f18a24d871460be09cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/582236
Reviewed-by: Joedian Reid <joedian@google.com>
Run-TryBot: David du Colombier <0intro@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-29 14:35:28 +00:00
Jes Cok
cf164403d1 slices: reduce code nesting depth for Compact and CompactFunc
To make it easier to read.

Change-Id: I2fa1eb78d879b9d86b4dc839be7ede37c7c864f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/581976
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joedian Reid <joedian@google.com>
2024-04-29 14:01:59 +00:00
aimuz
9e0685f9c2 encoding/json: optimize field sorting with slices and cmp
Refactor field sorting in typeFields to use slices.SortFunc and cmp.Compare,
resulting in performance improvements in cache misses and slight increases in
hit latency. Memory allocation and operation counts also reduced significantly
for cache misses.

goos: darwin
goarch: arm64
pkg: encoding/json
cpu: Apple M2 Max
                                    │   old.txt    │              new.txt               │
                                    │    sec/op    │   sec/op     vs base               │
TypeFieldsCache/MissTypes1-12          5.068µ ± 2%   5.032µ ± 1%       ~ (p=0.055 n=10)
TypeFieldsCache/MissTypes10-12         15.22µ ± 2%   14.79µ ± 2%  -2.84% (p=0.000 n=10)
TypeFieldsCache/MissTypes100-12        98.40µ ± 3%   94.72µ ± 1%  -3.73% (p=0.002 n=10)
TypeFieldsCache/MissTypes1000-12       860.3µ ± 3%   840.7µ ± 1%       ~ (p=0.105 n=10)
TypeFieldsCache/MissTypes10000-12      8.092m ± 3%   7.987m ± 4%       ~ (p=0.280 n=10)
TypeFieldsCache/MissTypes100000-12     80.90m ± 9%   80.62m ± 2%       ~ (p=0.631 n=10)
TypeFieldsCache/MissTypes1000000-12   1009.5m ± 7%   933.8m ± 7%  -7.50% (p=0.011 n=10)
TypeFieldsCache/HitTypes1-12           1.554n ± 3%   1.617n ± 3%  +4.05% (p=0.004 n=10)
TypeFieldsCache/HitTypes10-12          1.575n ± 1%   1.624n ± 6%  +3.14% (p=0.000 n=10)
TypeFieldsCache/HitTypes100-12         1.566n ± 1%   1.627n ± 5%  +3.86% (p=0.000 n=10)
TypeFieldsCache/HitTypes1000-12        1.526n ± 4%   1.596n ± 3%  +4.55% (p=0.001 n=10)
TypeFieldsCache/HitTypes10000-12       1.506n ± 0%   1.573n ± 3%  +4.41% (p=0.000 n=10)
TypeFieldsCache/HitTypes100000-12      1.480n ± 1%   1.529n ± 7%  +3.35% (p=0.001 n=10)
TypeFieldsCache/HitTypes1000000-12     1.473n ± 2%   1.468n ± 2%       ~ (p=0.739 n=10)
geomean                                1.371µ        1.374µ       +0.25%

                                    │     old.txt     │                new.txt                 │
                                    │      B/op       │     B/op       vs base                 │
TypeFieldsCache/MissTypes1-12          2.023Ki ± 0%      2.000Ki ± 0%  -1.16% (p=0.000 n=10)
TypeFieldsCache/MissTypes10-12         10.95Ki ± 0%      10.71Ki ± 0%  -2.17% (p=0.000 n=10)
TypeFieldsCache/MissTypes100-12       101.91Ki ± 0%      99.53Ki ± 0%  -2.34% (p=0.000 n=10)
TypeFieldsCache/MissTypes1000-12      1044.3Ki ± 0%     1020.8Ki ± 0%  -2.25% (p=0.000 n=10)
TypeFieldsCache/MissTypes10000-12      9.957Mi ± 0%      9.730Mi ± 0%  -2.29% (p=0.000 n=10)
TypeFieldsCache/MissTypes100000-12     97.79Mi ± 0%      95.50Mi ± 0%  -2.34% (p=0.000 n=10)
TypeFieldsCache/MissTypes1000000-12   1018.4Mi ± 0%      995.5Mi ± 0%  -2.25% (p=0.000 n=10)
TypeFieldsCache/HitTypes1-12             0.000 ± 0%        0.000 ± 0%       ~ (p=1.000 n=10) ¹
TypeFieldsCache/HitTypes10-12            0.000 ± 0%        0.000 ± 0%       ~ (p=1.000 n=10) ¹
TypeFieldsCache/HitTypes100-12           0.000 ± 0%        0.000 ± 0%       ~ (p=1.000 n=10) ¹
TypeFieldsCache/HitTypes1000-12          0.000 ± 0%        0.000 ± 0%       ~ (p=1.000 n=10) ¹
TypeFieldsCache/HitTypes10000-12         0.000 ± 0%        0.000 ± 0%       ~ (p=1.000 n=10) ¹
TypeFieldsCache/HitTypes100000-12        0.000 ± 0%        0.000 ± 0%       ~ (p=1.000 n=10) ¹
TypeFieldsCache/HitTypes1000000-12       0.000 ± 0%        0.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                                             ²                  -1.06%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

                                    │    old.txt    │               new.txt                │
                                    │   allocs/op   │  allocs/op   vs base                 │
TypeFieldsCache/MissTypes1-12          46.00 ± 0%      45.00 ± 0%  -2.17% (p=0.000 n=10)
TypeFieldsCache/MissTypes10-12         215.0 ± 0%      205.0 ± 0%  -4.65% (p=0.000 n=10)
TypeFieldsCache/MissTypes100-12       1.845k ± 0%     1.745k ± 0%  -5.42% (p=0.000 n=10)
TypeFieldsCache/MissTypes1000-12      18.08k ± 0%     17.08k ± 0%  -5.53% (p=0.000 n=10)
TypeFieldsCache/MissTypes10000-12     180.3k ± 0%     170.3k ± 0%  -5.55% (p=0.000 n=10)
TypeFieldsCache/MissTypes100000-12    1.804M ± 0%     1.704M ± 0%  -5.54% (p=0.000 n=10)
TypeFieldsCache/MissTypes1000000-12   18.04M ± 0%     17.04M ± 0%  -5.54% (p=0.000 n=10)
TypeFieldsCache/HitTypes1-12           0.000 ± 0%      0.000 ± 0%       ~ (p=1.000 n=10) ¹
TypeFieldsCache/HitTypes10-12          0.000 ± 0%      0.000 ± 0%       ~ (p=1.000 n=10) ¹
TypeFieldsCache/HitTypes100-12         0.000 ± 0%      0.000 ± 0%       ~ (p=1.000 n=10) ¹
TypeFieldsCache/HitTypes1000-12        0.000 ± 0%      0.000 ± 0%       ~ (p=1.000 n=10) ¹
TypeFieldsCache/HitTypes10000-12       0.000 ± 0%      0.000 ± 0%       ~ (p=1.000 n=10) ¹
TypeFieldsCache/HitTypes100000-12      0.000 ± 0%      0.000 ± 0%       ~ (p=1.000 n=10) ¹
TypeFieldsCache/HitTypes1000000-12     0.000 ± 0%      0.000 ± 0%       ~ (p=1.000 n=10) ¹
geomean                                           ²                -2.49%                ²
¹ all samples are equal
² summaries must be >0 to compute geomean

Change-Id: I62b8f524f5747f4f1b9241a1d849efeef1851049
GitHub-Last-Rev: d16772d4fb
GitHub-Pull-Request: golang/go#67046
Reviewed-on: https://go-review.googlesource.com/c/go/+/581895
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joedian Reid <joedian@google.com>
2024-04-29 14:01:21 +00:00
plasmatium
f6e6b637c0 time: add notes about monotonic time paused
See #66870

Change-Id: I781265355a3dbd0d9538bc9dcafaa83b482ec3f8
GitHub-Last-Rev: 9d92f116b0
GitHub-Pull-Request: golang/go#66922
Reviewed-on: https://go-review.googlesource.com/c/go/+/580515
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joedian Reid <joedian@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-29 14:01:17 +00:00
Koya IWAMURA
a81c8b3bf2 net/url: improve URL.String performance
URL.String performs memory allocation many times, but it can improve
performance by allocating memory that it clearly knows it needs.
This CL achieves 24.6% speedup, 18.3% memory reduction, and 46.7% fewer memory
allocations on existing benchmarks.

          │ string_old.txt │           string_new2.txt           │
          │     sec/op     │   sec/op     vs base                │
String-16      3.622µ ± 5%   2.730µ ± 2%  -24.63% (p=0.000 n=10)

          │ string_old.txt │           string_new2.txt            │
          │      B/op      │     B/op      vs base                │
String-16     1.406Ki ± 0%   1.148Ki ± 0%  -18.33% (p=0.000 n=10)

          │ string_old.txt │          string_new2.txt           │
          │   allocs/op    │ allocs/op   vs base                │
String-16       60.00 ± 0%   32.00 ± 0%  -46.67% (p=0.000 n=10)

Change-Id: I70199be952eddc44134945077e52740e8921088f
Reviewed-on: https://go-review.googlesource.com/c/go/+/581155
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Emmanuel Odeke <emmanuel@orijtech.com>
Reviewed-by: Joedian Reid <joedian@google.com>
2024-04-29 13:58:27 +00:00
Egon Elbre
99ee616250 internal/runtime/atomic: fix TestAnd64 and TestOr64
The local variable may not be 64bit aligned, which caused arm tests
to fail.

Fixes #67077

Change-Id: Ia3ae4abcc90319cb10cd593bdc7994cc6eeb3a28
Reviewed-on: https://go-review.googlesource.com/c/go/+/581916
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2024-04-27 20:49:32 +00:00
Egon Elbre
644a4ff333 testing: use time.Since in highPrecisionTime
time.Since has optimizations for measuring monotonic time.

For #31160.

Change-Id: I0529b9f69b9f008e3414b8e386b6faa64af4a008
Reviewed-on: https://go-review.googlesource.com/c/go/+/582135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2024-04-27 19:42:36 +00:00
Russ Cox
774d5b366c make.bash: avoid ksh bug in nogoenv
ksh handles make.bash surprisingly well and is a smaller
supply chain attack surface, so it's reasonable to want
to use "ksh make.bash" to build Go.

The only place where ksh and bash disagree in running
make.bash is an arguable bug in ksh that

	X=Y foo

accidentally changes the real value of X following that
command when foo is a shell function. (It correctly preserves
the original value of X when foo is a command being invoked.)

More specifically,

	GOROOT=$GOROOT_BOOTSTRAP nogoenv foo

incorrectly changes $GOROOT in the rest of the script.

CL 580020 suggested using a subshell, but subshells
historically have lost "set -e", so we'd have to use (...) || exit 1.
Instead of that, this CL refactors nogoenv into bootstrapenv,
putting it in charge of changing $GOROOT the same way it
changes all the other environment variables.

This CL also updates make.rc for parallelism.
It does not bother updating make.bat: that part is already
a bit different, and attempting to change it is all risk, no reward.

Change-Id: I5923a6fb5016a3862363363859365d1cd4f61a1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/582076
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Eric Grosse <grosse@gmail.com>
2024-04-27 11:30:21 +00:00
Damien Neil
ceef0633b3 path/filepath, internal/filepathlite: move parts of filepath to filepathlite
The path/filepath package needs to depend on the os package to
implement Abs, Walk, and other functions. Move the implementation
of purely lexical functions from path/filepath into
internal/filepathlite, so they can be used by os and
other low-level packages.

Change-Id: Id211e547d6f1f58c82419695ff2d75cd6cd14a12
Reviewed-on: https://go-review.googlesource.com/c/go/+/566556
Reviewed-by: Behroz Karimpor <behrozkarimpor201@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-26 23:07:50 +00:00
Damien Neil
ad22356ec6 all: rename internal/safefilepath to internal/filepathlite
The safefilepath package was originally added to contain
the FromFS function. We subsequently added FromFS to path/filepath
as Localize. The safefilepath package now exists only to permit
the os package to import Localize.

Rename safefilepath to filepathlite to better indicate that it's
a low-dependency version of filepath.

Change-Id: I4c5f9b28e8581f841947b48c5cac9954cd0c9535
Reviewed-on: https://go-review.googlesource.com/c/go/+/581517
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-26 23:07:37 +00:00
Damien Neil
d69f87445c strings, internal/stringslite: lite version of strings package
To be used by internal/filepathlite, which is to be used by os.
There are probably other places where it would be convenient
to have strings functions accessible to RUNTIME level packages.

Change-Id: Icda59e7a9e26d9e8f3692db0ea4fb7b3dbf570d7
Reviewed-on: https://go-review.googlesource.com/c/go/+/581516
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-26 23:07:25 +00:00
Egon Elbre
1c4704991a testing: use QueryPerformanceCounter on Windows
Windows time.Now granularity is around 0.5ms on modern systems,
which introduces a significant noise into benchmark results.
Instead of relying time.Now use QueryPerformanceCounter, which
has significantly better granularity compared to time.Now.

 │ TimeNow-32  │        HighPrecisionTimeNow-32        │
 │   sec/op    │    sec/op     vs base                 │
   4.812n ± 0%   30.580n ± 0%  +535.43% (p=0.000 n=20)

Fixes #31160

Change-Id: Ib2a574d638c9c6762a2524212def02265574e267
Reviewed-on: https://go-review.googlesource.com/c/go/+/557315
Reviewed-by: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2024-04-26 22:55:25 +00:00
Dmitriy Matrenichev
9effeeab27 internal/weak: remove unnecessary conversion, fix typo
Remove unnecessary conversion from unsafe.Pointer to unsafe.Pointer.
Also fix small typo in weak.Pointer.Strong method documentation.

Change-Id: I84791fba244581bd6218c589827a61914f0797b4
GitHub-Last-Rev: 7978d07d5b
GitHub-Pull-Request: golang/go#66977
Reviewed-on: https://go-review.googlesource.com/c/go/+/580936
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Commit-Queue: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joedian Reid <joedian@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2024-04-26 22:13:25 +00:00
Jes Cok
b439f32859 all: make use of sync.Map.Clear
Since CL 515015 added sync.Map.Clear method, we can use it to make
the code simpler and clearer.

Change-Id: I29edc969431b4fd95cd5fd864953a71ca1538dd3
Reviewed-on: https://go-review.googlesource.com/c/go/+/582015
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joedian Reid <joedian@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-04-26 21:32:11 +00:00
Jonathan Amsterdam
0e7f5cf30b doc/README.md: discourage RELNOTE in CLs
Release notes should always be files under doc/next. Make it clear that
this is the only way to add them: RELNOTE markers in CLs are no longer
supported.

Change-Id: I34d77eb876f57b84ecdc7e5ecbf3eb5c91e6fed8
Reviewed-on: https://go-review.googlesource.com/c/go/+/582075
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Bypass: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
2024-04-26 21:24:36 +00:00
Damien Neil
b384ee7ceb net, os, internal/poll: test for use of sendfile
The net package's sendfile tests exercise various paths where
we expect sendfile to be used, but don't verify that sendfile
was in fact used.

Add a hook to internal/poll.SendFile to let us verify that
sendfile was called when expected. Update os package tests
(which use their own hook mechanism) to use this hook as well.

For #66988

Change-Id: I7afb130dcfe0063d60c6ea0f8560cf8665ad5a81
Reviewed-on: https://go-review.googlesource.com/c/go/+/581778
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-26 18:12:56 +00:00
Philipp Wollermann
196916299d net: fix sendfile regression with io.Copy on macOS
Since CL 472475, io.Copy can no longer use sendfile on macOS for copying
files to a socket due to a too strict type assertion. This CL fixes the
issue by checking for the necessary interfaces instead of the concrete
os.File type in sendfile_unix_alt.go.

Fixes #66988

Change-Id: Ia0dd190f6575016a191c34a935132907147c8e10
Reviewed-on: https://go-review.googlesource.com/c/go/+/581035
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
2024-04-26 17:08:30 +00:00
Than McIntosh
deeebf5655 cmd/link/internal/ld: more fixes to TestElfBindNow readonly .got check
Second try at fixing the TestElfBindNow testpoint: don't try to check
for readonly ".got" section when using the external linker, since
there is code in some linkers (BFD in particular) that will skip
placing ".got" in relro if the section is below a specific size
threshold. Revised version of the test checks only for readonly
".dynamic" in the external linking case.

Fixes #67063.

Change-Id: Idb6b82ec7893baddf171654775587f6050fc6258
Reviewed-on: https://go-review.googlesource.com/c/go/+/581995
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-26 15:38:14 +00:00
apocelipes
2dd82d97b6 compress: reordering fields to reduce struct sizes
Overall, there are 32 bytes reduced.

Change-Id: I455bf0874b33fa47719f42618e4800c7ff2a9e88
GitHub-Last-Rev: 7670344c4a
GitHub-Pull-Request: golang/go#67010
Reviewed-on: https://go-review.googlesource.com/c/go/+/581355
Reviewed-by: Joedian Reid <joedian@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
2024-04-26 13:32:40 +00:00
go101
4370cfbdf9 slices: optimize Compact and CompactFunc
Try to save a comparison in the loop bodies of Compact and CompactFunc.

Note: due to #64272, some bound checks still fail to be removed.

                            │ old.txt  │             new.txt              │
                            │   sec/op    │   sec/op     vs base                │
Compact/nil-4                 4.191n ± 9%   3.402n ± 1%  -18.84% (p=0.000 n=10)
Compact/one-4                 5.289n ± 2%   4.553n ± 2%  -13.93% (p=0.000 n=10)
Compact/sorted-4              9.865n ± 0%   6.882n ± 1%  -30.24% (p=0.000 n=10)
Compact/2_items-4             11.10n ± 2%   12.11n ± 2%   +9.00% (p=0.000 n=10)
Compact/unsorted-4            9.831n ± 3%   6.918n ± 2%  -29.62% (p=0.000 n=10)
Compact/many-4                16.40n ± 4%   14.90n ± 1%   -9.20% (p=0.000 n=10)
Compact/dup_start-4           29.87n ± 0%   28.06n ± 3%   -6.04% (p=0.001 n=10)
Compact_Large/all_dup-4       13.11µ ± 0%   13.12µ ± 0%        ~ (p=0.971 n=10)
Compact_Large/no_dup-4        6.972µ ± 0%   5.806µ ± 0%  -16.73% (p=0.000 n=10)
CompactFunc/nil-4             5.300n ± 0%   5.309n ± 1%        ~ (p=0.289 n=10)
CompactFunc/one-4             6.051n ± 1%   6.442n ± 3%   +6.46% (p=0.000 n=10)
CompactFunc/sorted-4          16.24n ± 1%   12.79n ± 2%  -21.24% (p=0.000 n=10)
CompactFunc/2_items-4         17.89n ± 1%   17.75n ± 0%   -0.75% (p=0.000 n=10)
CompactFunc/unsorted-4        16.26n ± 0%   12.83n ± 1%  -21.07% (p=0.000 n=10)
CompactFunc/many-4            30.71n ± 1%   29.07n ± 0%   -5.32% (p=0.000 n=10)
CompactFunc/dup_start-4       78.94n ± 1%   67.19n ± 1%  -14.89% (p=0.000 n=10)
CompactFunc_Large/all_dup-4   3.277m ± 0%   3.692m ± 2%  +12.67% (p=0.000 n=10)
CompactFunc_Large/no_dup-4    4.019m ± 0%   2.826m ± 1%  -29.68% (p=0.000 n=10)
geomean                       109.6n        96.99n       -11.47%

Change-Id: Ia4c78fa62e7e9f4ff6a39d0e0a0a84cecf79b9cb
GitHub-Last-Rev: cea3d93155
GitHub-Pull-Request: golang/go#64273
Reviewed-on: https://go-review.googlesource.com/c/go/+/543661
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Joedian Reid <joedian@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
2024-04-26 13:32:06 +00:00
qmuntal
5ff0b53174 bytes: skip TestNewBufferShallow if optimization is disabled
TestNewBufferShallow should be skipped if optimization is disabled.

It is currently failing on no-opt builders.

Change-Id: Ib5e62022a56a4e5f158f247d69a6229d2cb4d99e
Reviewed-on: https://go-review.googlesource.com/c/go/+/581915
Auto-Submit: Than McIntosh <thanm@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joedian Reid <joedian@google.com>
2024-04-26 13:31:36 +00:00
Robert Griesemer
5419f652b6 spec: clarify prose for range over numeric range expressions
Fixes #66967.

Change-Id: I7b9d62dcb83bad60b2ce74e2e2bf1a36c6a8ae38
Reviewed-on: https://go-review.googlesource.com/c/go/+/581256
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
2024-04-26 00:39:16 +00:00
Than McIntosh
1ca31eac40 cmd/link/internal/ld: revised bindnow/relro test for ELF
This patch re-enables the portion of the TestElfBindNow test that
verifies that selected sections are in a read-only segment. Turns out
we can't always check for read-only ".got" on all architectures (on
ppc64le for example ".got" will only turn up if there is CGO use), so
always look for readonly ".dynamic", but only look for readonly ".got"
if the section is present.

Updates #45681.

Change-Id: I4687ae3cf9a81818268925e17700170ba34204a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/581115
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-25 20:23:29 +00:00
Derek Parker
57026007c8 cmd/compile: teach dse about equivalent LocalAddrs
This patch teaches DSE that two LocalAddrs of the same variable
are equal, even if they are from different memory states. This avoids
dependance on a store into the same LocalAddr being added to
loadUse even though the store is unnecessary and is in fact
shadowed.

Fixes #59021

Change-Id: I0ef128b783c4ad6fd2236fa5ff20345b4d31eddb
GitHub-Last-Rev: b80a6b28fb
GitHub-Pull-Request: golang/go#66793
Reviewed-on: https://go-review.googlesource.com/c/go/+/578376
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Joedian Reid <joedian@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
2024-04-25 20:07:26 +00:00
qmuntal
a8ba163695 runtime: fix mcall unwinding on Windows
The Windows native stack unwinder incorrectly classifies the next
instruction after the mcall callback call as being part of the function
epilogue, producing a wrong call stack.

Add a NOP after the callback call to work around this issue.

Fixes #67007.

Change-Id: I6017635da895b272b1852391db9a255ca69e335d
Reviewed-on: https://go-review.googlesource.com/c/go/+/581335
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-25 18:50:21 +00:00
Robert Griesemer
fd99157f9d go/types, types2: refactor Checker.rangeStmt for clarity
Change-Id: I0c2f921389416ab222b84f77699fd4b3246ef0e0
Reviewed-on: https://go-review.googlesource.com/c/go/+/581776
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2024-04-25 17:49:48 +00:00
guoguangwu
a4031ea1f5 all: fix typos in comments
Change-Id: Ib2e77cff4c10f66316295cbd67f52606cbf9972b
GitHub-Last-Rev: 088c033b2d
GitHub-Pull-Request: golang/go#67032
Reviewed-on: https://go-review.googlesource.com/c/go/+/581675
Auto-Submit: Keith Randall <khr@golang.org>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2024-04-25 17:41:54 +00:00
Robert Griesemer
06478e4b46 go/types, types2: simplify Default function
Change-Id: Ie2b7c1324ec7947c6ff43187dda99b83bcb64f08
Reviewed-on: https://go-review.googlesource.com/c/go/+/581775
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-04-25 17:07:36 +00:00
Sam Thanawalla
8c0da423f7 cmd/go: go env GOMOD should not download newer toolchain
It is not neccessary to download a newer toolchain to display the path
to GOMOD or GOWORK.

Fixes: #61455

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: I0b031651ad9bfeb5565361ecaff6908640ccf9c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/581275
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
2024-04-25 16:05:39 +00:00
Russ Cox
8960925ad8 time: deflake TestChan/asynctimerchan=1 tests
The overall time package tests increase from 3.85s to 4.85s on my laptop.
But they should be less flaky, and the time is spent sleeping, so it won't
slow down the overall machine running multiple package tests in
parallel.

For #66322.

Change-Id: I66d6647c389c943b53045e8836ede4ba3d4670c7
Reviewed-on: https://go-review.googlesource.com/c/go/+/581315
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-04-25 11:28:32 +00:00
Robert Griesemer
db5f2b4153 spec: clarify when a range expression is evaluated
If the range expression is a numeric constant, the
range expression is also not evaluated.

Change-Id: I97201e5c136d3d1a87ed1500b19b7199b30bc9ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/581298
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2024-04-25 01:05:15 +00:00
Jes Cok
4351af68eb net/http: improve continue statements for tests
Change-Id: I302368c17fbb6983bd14ab72784076e548ed8829
Reviewed-on: https://go-review.googlesource.com/c/go/+/581475
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-04-25 01:02:12 +00:00
Nigel Tao
e7aeeae0c8 image/jpeg: ignore garbage bytes before a RST marker
Well-formed JPEG images will not have garbage bytes. However, for
corrupted JPEG images, the RST (restart) mechanism is specifically
designed so that a decoder can re-synchronize to an upcoming restartable
MCU (Minimum Coded Unit, e.g. 16x16 block of pixels) boundary and resume
decoding. Even if the resultant image isn't perfect, a 98%-good image is
better than a fatal error.

Every JPEG marker is encoded in two bytes, the first of which is 0xFF.
There are 8 possible RST markers, cycling as "0xFF 0xD0", "0xFF 0xD1",
..., "0xFF 0xD7". Suppose that, our decoder is expecting "0xFF 0xD1".

Before this commit, Go's image/jpeg package would accept only two
possible inputs: a well-formed "0xFF 0xD1" or one very specific pattern
of spec non-compliance, "0xFF 0x00 0xFF 0xD1".

After this commit, it is more lenient, similar to libjpeg's jdmarker.c's
next_marker function.
2dfe6c0fe9/jdmarker.c (L892-L935)

The new testdata file was created by:

$ convert video-001.png a.ppm
$ cjpeg -restart 2 a.ppm > video-001.restart2.jpeg
$ rm a.ppm

Fixes #40130

Change-Id: Ic598a5f489f110d6bd63e0735200fb6acac3aca3
Reviewed-on: https://go-review.googlesource.com/c/go/+/580755
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Joedian Reid <joedian@google.com>
2024-04-25 00:46:29 +00:00