]> Cypherpunks repositories - gostls13.git/log
gostls13.git
8 months agocmd/compile: handle boolean and pointer relations
khr@golang.org [Sun, 7 Jul 2024 21:58:47 +0000 (14:58 -0700)]
cmd/compile: handle boolean and pointer relations

The constant lattice for these types is pretty simple.
We no longer need the old-style facts table, as the ordering
table now has all that information.

Change-Id: If0e118c27a4de8e9bfd727b78942185c2eb50c4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/599097
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
8 months agocmd/compile: propagate constant ranges through multiplies and shifts
khr@golang.org [Thu, 27 Jun 2024 22:53:24 +0000 (15:53 -0700)]
cmd/compile: propagate constant ranges through multiplies and shifts

Fixes #40704
Fixes #66826

Change-Id: Ia9c356e29b2ed6f2e3bc6e5eb9304cd4dccb4263
Reviewed-on: https://go-review.googlesource.com/c/go/+/599256
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
8 months agocmd/compile: rewrite the constant parts of the prove pass
khr@golang.org [Sat, 15 Jun 2024 05:29:09 +0000 (22:29 -0700)]
cmd/compile: rewrite the constant parts of the prove pass

Handles a lot more cases where constant ranges can eliminate
various (mostly bounds failure) paths.

Fixes #66826
Fixes #66692
Fixes #48213
Update #57959

TODO: remove constant logic from poset code, no longer needed.

Change-Id: Id196436fcd8a0c84c7d59c04f93bd92e26a0fd7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/599096
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
8 months agocmd/compile: move limit fact table in prove pass to dense encoding
khr@golang.org [Sat, 18 May 2024 15:01:27 +0000 (08:01 -0700)]
cmd/compile: move limit fact table in prove pass to dense encoding

Here begins a pretty major rewrite of the prove pass. The fundamental
observation is that although keeping facts about relations between
two SSA values could use O(n^2) space, keeping facts about relations
between an SSA value and constants needs only O(n) space. We can just
keep track of min/max for every SSA value at little cost.

Redo the limit table to just keep track of limits for all SSA values.
Use just a slice instead of a map. It may use more space (but still
just O(n) space), but accesses are a lot faster. And with the cache
in the compiler, that space will be reused quickly.

This is part of my planning to add lots more constant limits in the
prove pass.

Change-Id: Ie36819fad5631a8b79c3630fe0e819521796551a
Reviewed-on: https://go-review.googlesource.com/c/go/+/599255
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
8 months agocmd/compile, math: make math.{Abs,Copysign} intrinsics on loong64
Xiaolin Zhao [Mon, 1 Apr 2024 09:13:42 +0000 (17:13 +0800)]
cmd/compile, math: make math.{Abs,Copysign} intrinsics on loong64

goos: linux
goarch: loong64
pkg: math
cpu: Loongson-3A6000 @ 2500.00MHz
         │  old.bench   │              new.bench               │
         │    sec/op    │    sec/op     vs base                │
Copysign   1.9710n ± 0%   0.8006n ± 0%  -59.38% (p=0.000 n=10)
Abs        1.8745n ± 0%   0.8006n ± 0%  -57.29% (p=0.000 n=10)
geomean     1.922n        0.8006n       -58.35%

goos: linux
goarch: loong64
pkg: math
cpu: Loongson-3A5000 @ 2500.00MHz
         │  old.bench   │              new.bench               │
         │    sec/op    │    sec/op     vs base                │
Copysign   2.4020n ± 0%   0.9006n ± 0%  -62.51% (p=0.000 n=10)
Abs        2.4020n ± 0%   0.8005n ± 0%  -66.67% (p=0.000 n=10)
geomean     2.402n        0.8491n       -64.65%

Updates #59120.

Change-Id: Ic409e1f4d15ad15cb3568a5aaa100046e9302842
Reviewed-on: https://go-review.googlesource.com/c/go/+/580280
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
8 months agocmd/compile, math: improve implementation of math.{Max,Min} on loong64
Xiaolin Zhao [Wed, 10 Apr 2024 03:48:11 +0000 (11:48 +0800)]
cmd/compile, math: improve implementation of math.{Max,Min} on loong64

Make math.{Min,Max} intrinsics and implement math.{archMax,archMin}
in hardware.

goos: linux
goarch: loong64
pkg: math
cpu: Loongson-3A6000 @ 2500.00MHz
         │  old.bench   │              new.bench              │
         │    sec/op    │   sec/op     vs base                │
Max         7.606n ± 0%   3.087n ± 0%  -59.41% (p=0.000 n=20)
Min         7.205n ± 0%   2.904n ± 0%  -59.69% (p=0.000 n=20)
MinFloat   37.220n ± 0%   4.802n ± 0%  -87.10% (p=0.000 n=20)
MaxFloat   33.620n ± 0%   4.802n ± 0%  -85.72% (p=0.000 n=20)
geomean     16.18n        3.792n       -76.57%

goos: linux
goarch: loong64
pkg: runtime
cpu: Loongson-3A5000 @ 2500.00MHz
         │  old.bench   │              new.bench              │
         │    sec/op    │   sec/op     vs base                │
Max        10.010n ± 0%   7.196n ± 0%  -28.11% (p=0.000 n=20)
Min         8.806n ± 0%   7.155n ± 0%  -18.75% (p=0.000 n=20)
MinFloat   60.010n ± 0%   7.976n ± 0%  -86.71% (p=0.000 n=20)
MaxFloat   56.410n ± 0%   7.980n ± 0%  -85.85% (p=0.000 n=20)
geomean     23.37n        7.566n       -67.63%

Updates #59120.

Change-Id: I6815d20bc304af3cbf5d6ca8fe0ca1c2ddebea2d
Reviewed-on: https://go-review.googlesource.com/c/go/+/580283
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
8 months agoruntime: add padding to Linux kernel structures sigcontext on loong64
Guoqi Chen [Fri, 7 Jun 2024 01:36:53 +0000 (09:36 +0800)]
runtime: add padding to Linux kernel structures sigcontext on loong64

On linux/loong64, the sc_extcontext member in the sigcontext structure is
required to be 16-byte aligned [1], although sc_extcontext is not currently
used anywhere, it still needs to be padded to the specified alignment.

[1] https://github.com/torvalds/linux/blob/master/arch/loongarch/include/uapi/asm/sigcontext.h

Change-Id: I98d30e921730314835c9469a6f28e186c9808e34
Reviewed-on: https://go-review.googlesource.com/c/go/+/591855
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
8 months agogo/types, types2: avoid spurious "undefined" errors" for invalid identifiers
Robert Griesemer [Thu, 1 Aug 2024 18:16:27 +0000 (11:16 -0700)]
go/types, types2: avoid spurious "undefined" errors" for invalid identifiers

The syntax parser complains about invalid identifiers.
Don't report a typechecker error when such an identifier
cannot be found in the current scope.

For now add a local test for types2 only because the
go/parser behaves differently than the syntax parser
which leads to slightly different error positions.

Fixes #68183.

Change-Id: Idbfe62fafcd704886069182744ec5e6b37ffc4e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/602476
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Tim King <taking@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
8 months agocmd/go/internal/load: make check for path in import error more robust
Michael Matloob [Tue, 6 Aug 2024 16:42:34 +0000 (12:42 -0400)]
cmd/go/internal/load: make check for path in import error more robust

When producing an ImportPathError from ImportErrorf, we check to see
whether the error string contains the path for the error. The issue is
that we were checking for the exact path string when sometimes the
string is quoted when the error is constructed, and the escaping in the
quote may not match the path string. Check for both the path string, and
the quoted path string.

Fixes #68737

Change-Id: I01bf4e495056e929570bc11bc1f2000ce6d2802b
Reviewed-on: https://go-review.googlesource.com/c/go/+/603475
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
8 months agoos: remove non-constant format string in t.Errorf call
Tim King [Tue, 6 Aug 2024 17:06:39 +0000 (10:06 -0700)]
os: remove non-constant format string in t.Errorf call

Fixes #68744

Change-Id: I12db785fc21c18db69d57cf91e2190b4a3df2484
Reviewed-on: https://go-review.googlesource.com/c/go/+/603515
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agocmd/internal/objabi, cmd/link/internal: add new relocations used in internal linking
limeidan [Wed, 10 Jan 2024 02:49:52 +0000 (10:49 +0800)]
cmd/internal/objabi, cmd/link/internal: add new relocations used in internal linking

Change-Id: I1b7c258f0ea3b847a92ccd6644b653e11e7a5ef0
Reviewed-on: https://go-review.googlesource.com/c/go/+/555115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: David Chase <drchase@google.com>
8 months agocmd/internal/obj: minor refactor of wasmimport code
Cherry Mui [Mon, 5 Aug 2024 17:40:18 +0000 (13:40 -0400)]
cmd/internal/obj: minor refactor of wasmimport code

This CL does some minor refactoring of the code handling
wasmimport.
- Put the WasmImport aux reading and writing code together for
  symmetry.
- Define WasmFuncType, embedded in WasmImport. WasmFuncType could
  also be used (later) for wasmexport.
- Move code generation code to a separate function. The containing
  function is already pretty large.
- Simplify linker code a little bit. The loader convention is to
  return the 0 Sym for nonexistent symbol, instead of a separate
  boolean.

No change in generated code. Passes toolstash -cmp
(GOARCH=wasm GOOS=wasip1 go build -toolexec "toolstash -cmp" -a std cmd).

Change-Id: Idc2514f84a08621333841ae4034b81130e0ce411
Reviewed-on: https://go-review.googlesource.com/c/go/+/603135
Reviewed-by: Than McIntosh <thanm@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
8 months agomaps: add examples for All, Keys, Values, Insert, and Collect functions
aimuz [Mon, 5 Aug 2024 03:14:45 +0000 (03:14 +0000)]
maps: add examples for All, Keys, Values, Insert, and Collect functions

Change-Id: I4ee61bea9997b822aa1ec2cc3d01b4db5f101e4c
GitHub-Last-Rev: d88282a92ec86721356696108898e06924ec89c9
GitHub-Pull-Request: golang/go#68696
Reviewed-on: https://go-review.googlesource.com/c/go/+/602315
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agocrypto/internal/boring: use internal/byteorder
Mateusz Poliwczak [Sat, 3 Aug 2024 07:51:45 +0000 (07:51 +0000)]
crypto/internal/boring: use internal/byteorder

Change-Id: I882dd4160fb24b1d605af28bca01227716dac717
GitHub-Last-Rev: c631b19068aa95dcebed29a9a68cda5644a973b8
GitHub-Pull-Request: golang/go#68697
Reviewed-on: https://go-review.googlesource.com/c/go/+/602179
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Zxilly Chou <zxilly@outlook.com>
Auto-Submit: Roland Shoemaker <roland@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Roland Shoemaker <roland@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

8 months agointernal/bytealg: optimize Equal for arm64 target
Vasily Leonenko [Tue, 23 Jul 2024 20:23:33 +0000 (23:23 +0300)]
internal/bytealg: optimize Equal for arm64 target

Remove redundant intermediate jump in runtime.memequal
Remove redundant a.ptr==b.ptr check in runtime.memequal_varlen
Add 16-bytes alignment before some labels in runtime.memequal

goos: linux
goarch: arm64
pkg: bytes
                                │ ./master.log │              ./opt.log              │
                                │    sec/op    │    sec/op     vs base               │
Equal/0-4                         0.8342n ± 0%   0.5254n ± 3%  -37.01% (p=0.000 n=8)
Equal/same/1-4                     2.720n ± 0%    2.720n ± 2%        ~ (p=0.779 n=8)
Equal/same/6-4                     2.720n ± 5%    2.720n ± 2%        ~ (p=0.908 n=8)
Equal/same/9-4                     2.722n ± 2%    2.721n ± 2%        ~ (p=0.779 n=8)
Equal/same/15-4                    2.719n ± 0%    2.719n ± 0%        ~ (p=0.641 n=8)
Equal/same/16-4                    2.721n ± 2%    2.719n ± 0%   -0.07% (p=0.014 n=8)
Equal/same/20-4                    2.720n ± 0%    2.721n ± 2%        ~ (p=0.236 n=8)
Equal/same/32-4                    2.720n ± 1%    2.720n ± 0%        ~ (p=0.396 n=8)
Equal/same/4K-4                    2.719n ± 0%    2.720n ± 0%        ~ (p=0.663 n=8)
Equal/same/4M-4                    2.721n ± 0%    2.720n ± 0%        ~ (p=0.075 n=8)
Equal/same/64M-4                   2.720n ± 0%    2.720n ± 2%        ~ (p=0.806 n=8)
Equal/1-4                          6.671n ± 0%    5.449n ± 0%  -18.33% (p=0.000 n=8)
Equal/6-4                          8.761n ± 2%    7.508n ± 0%  -14.30% (p=0.000 n=8)
Equal/9-4                          8.343n ± 0%    7.091n ± 0%  -15.01% (p=0.000 n=8)
Equal/15-4                         8.339n ± 2%    7.090n ± 0%  -14.98% (p=0.000 n=8)
Equal/16-4                         9.173n ± 0%    7.925n ± 2%  -13.61% (p=0.000 n=8)
Equal/20-4                         11.26n ± 0%    10.01n ± 0%  -11.10% (p=0.000 n=8)
Equal/32-4                        10.425n ± 0%    9.176n ± 0%  -11.98% (p=0.000 n=8)
Equal/4K-4                         192.9n ± 0%    192.7n ± 0%   -0.10% (p=0.044 n=8)
Equal/4M-4                         191.3µ ± 0%    191.3µ ± 0%        ~ (p=0.798 n=8)
Equal/64M-4                        3.066m ± 2%    3.065m ± 0%        ~ (p=0.083 n=8)
EqualBothUnaligned/64_0-4          7.506n ± 2%    7.090n ± 2%   -5.55% (p=0.000 n=8)
EqualBothUnaligned/64_1-4          7.850n ± 1%    7.423n ± 0%   -5.43% (p=0.000 n=8)
EqualBothUnaligned/64_4-4          7.505n ± 0%    7.088n ± 0%   -5.56% (p=0.000 n=8)
EqualBothUnaligned/64_7-4          7.840n ± 0%    7.413n ± 0%   -5.44% (p=0.000 n=8)
EqualBothUnaligned/4096_0-4        193.0n ± 4%    190.9n ± 0%   -1.09% (p=0.004 n=8)
EqualBothUnaligned/4096_1-4        223.9n ± 0%    223.1n ± 0%   -0.36% (p=0.000 n=8)
EqualBothUnaligned/4096_4-4        191.9n ± 2%    191.5n ± 0%   -0.21% (p=0.004 n=8)
EqualBothUnaligned/4096_7-4        223.8n ± 0%    223.1n ± 1%        ~ (p=0.098 n=8)
EqualBothUnaligned/4194304_0-4     191.8µ ± 0%    191.8µ ± 0%        ~ (p=0.504 n=8)
EqualBothUnaligned/4194304_1-4     225.4µ ± 2%    225.5µ ± 0%        ~ (p=0.065 n=8)
EqualBothUnaligned/4194304_4-4     192.6µ ± 0%    192.7µ ± 2%   +0.06% (p=0.041 n=8)
EqualBothUnaligned/4194304_7-4     225.4µ ± 0%    225.5µ ± 0%   +0.05% (p=0.050 n=8)
EqualBothUnaligned/67108864_0-4    3.069m ± 0%    3.069m ± 0%        ~ (p=0.314 n=8)
EqualBothUnaligned/67108864_1-4    3.589m ± 0%    3.588m ± 0%        ~ (p=0.959 n=8)
EqualBothUnaligned/67108864_4-4    3.083m ± 0%    3.083m ± 2%        ~ (p=0.505 n=8)
EqualBothUnaligned/67108864_7-4    3.588m ± 0%    3.588m ± 0%        ~ (p=1.000 n=8)
geomean                            199.9n         190.5n        -4.70%

Change-Id: Ib8d0d4006dd39162a600ac98a5f44a0f05136ed3
Reviewed-on: https://go-review.googlesource.com/c/go/+/601135
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>

8 months agotest: add test that caused gofrontend to crash
Ian Lance Taylor [Mon, 5 Aug 2024 18:54:51 +0000 (11:54 -0700)]
test: add test that caused gofrontend to crash

Apparently people don't tend to pass untyped constant expressions
to panic.

For #68734

Change-Id: I6fff8137a0f001391de9e61860b67026a9db08c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/603096
Reviewed-by: David Chase <drchase@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>
Commit-Queue: Ian Lance Taylor <iant@google.com>

8 months agobytes, strings: replace reflect.DeepEqual and custom eq with slices.Equal in tests
aimuz [Mon, 5 Aug 2024 03:00:42 +0000 (03:00 +0000)]
bytes, strings: replace reflect.DeepEqual and custom eq with slices.Equal in tests

Change-Id: I016672af79d49a00ddc2d0449cdaac61e98b4ba0
GitHub-Last-Rev: 38d15d9a03e5bd29e4b25f1d767e40cf7165a7a6
GitHub-Pull-Request: golang/go#68730
Reviewed-on: https://go-review.googlesource.com/c/go/+/602698
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
8 months agocmd/internal/testdir: fix failure when GOAMD64=v3 is specified in goenv file
khr@golang.org [Mon, 22 Jul 2024 20:27:09 +0000 (13:27 -0700)]
cmd/internal/testdir: fix failure when GOAMD64=v3 is specified in goenv file

Fixes #68548

Add GOENV=off, GOFLAGS= to the build of the stdlib, so that it matches
what runcmd does. This ensures that the runtime and the test are built
with the same flags. As opposed to before this CL, where flags were used
in the stdlib build but not the runcmd build.

(Part of the problem here is that cmd/internal/testdir/testdir_test.go
plays fast and loose with the build cache to make the tests run faster.
Maybe some of that fast-and-loose mechanism can be removed now that we
have a better build cache? I'm not sure.)

Change-Id: I449d4ff517c69311d0aa4411e7fb96c0cca49269
Reviewed-on: https://go-review.googlesource.com/c/go/+/600276
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/internal/obj/loong64: add FLDX,FSTX,LDX.STX instructions support
Guoqi Chen [Thu, 23 May 2024 05:43:20 +0000 (13:43 +0800)]
cmd/internal/obj/loong64: add FLDX,FSTX,LDX.STX instructions support

The LDX.{B,BU,H,HU,W,WU,D},STX.{B,H,W,D}, FLDX.{S,D}, FSTX.{S,D} instruction
on Loong64 implements memory access operations using register offset

Go asm syntax:
MOV{B,BU,H,HU,W,WU,V} (RJ)(RK), RD
MOV{B,H,W,V} RD, (RJ)(RK)
MOV{F,D} (RJ)(RK), FD
MOV{F,D} FD, (RJ)(RK)

Equivalent platform assembler syntax:
        ldx.{b,bu,h,hu,w,wu,d} rd, rj, rk
        stx.{b,h,w,d} rd, rj, rk
        fldx.{s,d} fd, rj, rk
        fstx.{s,d} fd, rj, rk

Ref: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Change-Id: Ic7d13bf45dab8342f034b6469465e6337a087144
Reviewed-on: https://go-review.googlesource.com/c/go/+/588215
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>

9 months agocmd/internal/obj/loong64: add support for instructions FTINT{RM/RP/RZ/RNE}.{W/L}...
Xiaolin Zhao [Thu, 6 Jun 2024 06:25:38 +0000 (14:25 +0800)]
cmd/internal/obj/loong64: add support for instructions FTINT{RM/RP/RZ/RNE}.{W/L}.{S/D}

These instructions convert floating-point numbers to fixed-point numbers
with the specified rounding pattern.

Go asm syntax:
            FTINT{RM/RP/RZ/RNE}{W/V}{F/D} FJ, FD

Equivalent platform assembler syntax:
            ftint{rm/rp/rz/rne}.{w/l}.{s/d} fd, fj

Ref: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Change-Id: I6d650d1b48b10296d01a98fadf9d806206f9b96e
Reviewed-on: https://go-review.googlesource.com/c/go/+/590995
Auto-Submit: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
9 months agocmd/internal/obj/loong64: add support for instructions FFINT.{S/D}.{W/L} and FTINT...
Xiaolin Zhao [Thu, 6 Jun 2024 08:06:39 +0000 (16:06 +0800)]
cmd/internal/obj/loong64: add support for instructions FFINT.{S/D}.{W/L} and FTINT.{W/L}.{S/D}

Go asm syntax:
FFINT{F/D}{W/V} FJ, FD
FTINT{W/V}{F/D} FJ, FD

Equivalent platform assembler syntax:
ffint.{s/d}.{w/l} fd, fj
ftint.{w/l}.{s/d} fd, fj

Ref: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Change-Id: Ie7646c5d49645c63b274b34b66539f10370f4930
Reviewed-on: https://go-review.googlesource.com/c/go/+/590996
Reviewed-by: Meidan Li <limeidan@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/internal/obj/loong64: add support for instructions FCOPYSIGN.{S/D} and FCLASS...
Xiaolin Zhao [Wed, 5 Jun 2024 02:52:08 +0000 (10:52 +0800)]
cmd/internal/obj/loong64: add support for instructions FCOPYSIGN.{S/D} and FCLASS.{S/D}

Go asm syntax:
FCOPYSG{F/D} FK, FJ, FD
FCLASSF{F/D} FJ, FD

Equivalent platform assembler syntax:
fcopysign.{s/d} fd, fj, fk
fclass.{s/d} fd, fj

Ref: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Change-Id: Ied34b71c9d0b34456ac5782a59d29d2d0229e326
Reviewed-on: https://go-review.googlesource.com/c/go/+/590675
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agotime: restore support for large negative days in Date
Ian Lance Taylor [Fri, 2 Aug 2024 18:33:34 +0000 (11:33 -0700)]
time: restore support for large negative days in Date

CL 586257 converted days to uint32 which is usually fine but fails for
negative days close to cycle boundaries.

Fixes #68718

Change-Id: I8dc5b8fe0c7c1921beb204da1913b9a1ab39280d
Reviewed-on: https://go-review.googlesource.com/c/go/+/602815
Reviewed-by: Rob Pike <r@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoarchive/zip,cmd/compile: simplify the split function
apocelipes [Fri, 2 Aug 2024 11:33:30 +0000 (11:33 +0000)]
archive/zip,cmd/compile: simplify the split function

Use strings to simplify the code.

This is a follow-up for the CL 586715.

Change-Id: I9e5470ec271e8af1ad4ddbb5f01f43a8a4879557
GitHub-Last-Rev: b95d6179781053ea8ec9fc8ad2e18607fd35c5bb
GitHub-Pull-Request: golang/go#68713
Reviewed-on: https://go-review.googlesource.com/c/go/+/602697
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agomime: add available godoc link
pgxiaolianzi [Fri, 2 Aug 2024 14:50:23 +0000 (14:50 +0000)]
mime: add available godoc link

Change-Id: Ic5454758c87e9f84a829aed8a72b5ad977878585
GitHub-Last-Rev: 2eb8ced71286a3bc3b53b35c809164b07ef28a16
GitHub-Pull-Request: golang/go#68605
Reviewed-on: https://go-review.googlesource.com/c/go/+/601295
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoruntime: benchmark mutex handoffs
Rhys Hiltner [Wed, 31 Jul 2024 20:45:53 +0000 (13:45 -0700)]
runtime: benchmark mutex handoffs

The speed of handing off a mutex to a waiting thread is sensitive to the
configuration of the spinning section of lock2. Measure that latency
directly, to complement our existing benchmarks of mutex throughput.

For #68578

Change-Id: I7637684bcff62eb05cc008491f095f653d13af4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/602176
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocrypto/tls: fix testHandshake close flakes
Filippo Valsorda [Thu, 1 Aug 2024 21:41:13 +0000 (23:41 +0200)]
crypto/tls: fix testHandshake close flakes

The flakes were introduced by me in CL 586655. It's unclear why only
FreeBSD seems affected, maybe other TCP stacks handle sending on a
half-closed connection differently, or aren't as quick to propagate the
RST over localhost.

Fixes #68155

Change-Id: I32a1b474a7d6531dbab93910c23568b867629e8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/602615
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoos: clarify Rename docs for renaming to a directory
Ian Lance Taylor [Thu, 1 Aug 2024 03:35:47 +0000 (20:35 -0700)]
os: clarify Rename docs for renaming to a directory

Fixes #68690

Change-Id: Iebc27d5f385d787e568550a863f59f16c7a79fd7
Reviewed-on: https://go-review.googlesource.com/c/go/+/602178
Auto-Submit: Ian Lance Taylor <iant@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Rob Pike <r@golang.org>
9 months agocmd/compile,runtime: disable swissmap fast variants
Michael Pratt [Mon, 22 Apr 2024 18:17:35 +0000 (14:17 -0400)]
cmd/compile,runtime: disable swissmap fast variants

Temporary measure to reduce the required MVP code.

For #54766.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-swissmap
Change-Id: I44dc8acd0dc8280c6beb40451998e84bc85c238a
Reviewed-on: https://go-review.googlesource.com/c/go/+/580915
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>
9 months agoall: split old and swiss map abi and compiler integration
Michael Pratt [Fri, 19 Apr 2024 17:52:31 +0000 (13:52 -0400)]
all: split old and swiss map abi and compiler integration

The two map implementations are still identical, but now the compiler
targets the appropriate ABI depending on GOEXPERIMENT.

For #54766.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-linux-amd64-longtest-swissmap
Change-Id: I8438f64f044ba9de30ddbf2b8ceb9b4edd2d5614
Reviewed-on: https://go-review.googlesource.com/c/go/+/580779
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>

9 months agoall: create swissmap experiment and fork files
Michael Pratt [Fri, 19 Apr 2024 15:46:54 +0000 (11:46 -0400)]
all: create swissmap experiment and fork files

The _swiss.go files are identical to the originals (except build tag).
Later CLs will change them.

For #54766.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest-swissmap
Change-Id: I9943e2d6f1cfa227ffbf27c9ddc9ce853695d225
Reviewed-on: https://go-review.googlesource.com/c/go/+/580778
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
Commit-Queue: Michael Pratt <mpratt@google.com>
Reviewed-by: Keith Randall <khr@google.com>
9 months agocrypto/internal/cryptotest: add tests for the cipher.Stream interface
Manuel Sabin [Thu, 27 Jun 2024 19:06:55 +0000 (15:06 -0400)]
crypto/internal/cryptotest: add tests for the cipher.Stream interface

This CL creates tests for the cipher.Stream interface in the new
cryptotest package.  This set of tests is called from the tests of
implementations of the Stream interface e.g. ctr_test.go, ofb_test.go,
rc4_test.go, etc.

Updates #25309

Change-Id: I57204ef9f4c0ec09b94e88466deb03c6715e411d
Reviewed-on: https://go-review.googlesource.com/c/go/+/595564
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Russell Webb <russell.webb@protonmail.com>
9 months agocmd/internal/obj/loong64: adjust the order of class names
limeidan [Fri, 12 Jan 2024 02:46:57 +0000 (10:46 +0800)]
cmd/internal/obj/loong64: adjust the order of class names

Change-Id: I0ff9a4f7b4758f44eaedfd821ad80a86b58e55a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/565625
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agoruntime: add debug call injection support on loong64
limeidan [Tue, 21 May 2024 11:23:44 +0000 (19:23 +0800)]
runtime: add debug call injection support on loong64

Change-Id: Iaf2bd9da0b35c20c5b57db2eb9b2eea2b662140c
Reviewed-on: https://go-review.googlesource.com/c/go/+/587055
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>

9 months agotime: fix some typos in CL 512355
Jes Cok [Thu, 1 Aug 2024 23:42:58 +0000 (23:42 +0000)]
time: fix some typos in CL 512355

Change-Id: Id0fb180a2d7910cdff7f4ab7154d9ceeb2f1cb71
GitHub-Last-Rev: 03658dd9747684f69ea238a8d1d7f7d15446099e
GitHub-Pull-Request: golang/go#68709
Reviewed-on: https://go-review.googlesource.com/c/go/+/602675
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agocmd/internal/obj/loong64: add support for instructions F{MAX/NIN}.{S/D}
Xiaolin Zhao [Wed, 10 Apr 2024 03:37:56 +0000 (11:37 +0800)]
cmd/internal/obj/loong64: add support for instructions F{MAX/NIN}.{S/D}

Go asm syntax:
F{MAX/MIN}{F/D} FK, FJ, FD

Equivalent platform assembler syntax:
f{max/min}.{s/d} fd, fj, fk

Ref: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Change-Id: Ib11fed1fe3700be5ebba33b5818661c4071b7b7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/590676
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>

9 months agomath/big: implement addVV in riscv64 assembly
Joel Sing [Thu, 27 Jun 2024 09:52:30 +0000 (19:52 +1000)]
math/big: implement addVV in riscv64 assembly

This provides an assembly implementation of addVV for riscv64,
processing up to four words per loop, resulting in a significant
performance gain.

On a StarFive VisionFive 2:

               │   addvv.1    │               addvv.2               │
               │    sec/op    │   sec/op     vs base                │
AddVV/1-4         73.45n ± 0%   48.08n ± 0%  -34.54% (p=0.000 n=10)
AddVV/2-4         88.14n ± 0%   58.76n ± 0%  -33.33% (p=0.000 n=10)
AddVV/3-4        102.80n ± 0%   69.44n ± 0%  -32.45% (p=0.000 n=10)
AddVV/4-4        117.50n ± 0%   72.18n ± 0%  -38.57% (p=0.000 n=10)
AddVV/5-4        132.20n ± 0%   82.79n ± 0%  -37.38% (p=0.000 n=10)
AddVV/10-4        216.3n ± 0%   126.8n ± 0%  -41.35% (p=0.000 n=10)
AddVV/100-4      1659.0n ± 0%   885.2n ± 0%  -46.64% (p=0.000 n=10)
AddVV/1000-4     16.089µ ± 0%   8.400µ ± 0%  -47.79% (p=0.000 n=10)
AddVV/10000-4     245.3µ ± 0%   176.9µ ± 0%  -27.88% (p=0.000 n=10)
AddVV/100000-4    2.537m ± 0%   1.873m ± 0%  -26.17% (p=0.000 n=10)
geomean           1.435µ        904.5n       -36.99%

               │   addvv.1    │                addvv.2                │
               │     B/s      │      B/s       vs base                │
AddVV/1-4        830.9Mi ± 0%   1269.5Mi ± 0%  +52.78% (p=0.000 n=10)
AddVV/2-4        1.353Gi ± 0%    2.029Gi ± 0%  +50.00% (p=0.000 n=10)
AddVV/3-4        1.739Gi ± 0%    2.575Gi ± 0%  +48.09% (p=0.000 n=10)
AddVV/4-4        2.029Gi ± 0%    3.303Gi ± 0%  +62.82% (p=0.000 n=10)
AddVV/5-4        2.254Gi ± 0%    3.600Gi ± 0%  +59.69% (p=0.000 n=10)
AddVV/10-4       2.755Gi ± 0%    4.699Gi ± 0%  +70.54% (p=0.000 n=10)
AddVV/100-4      3.594Gi ± 0%    6.734Gi ± 0%  +87.37% (p=0.000 n=10)
AddVV/1000-4     3.705Gi ± 0%    7.096Gi ± 0%  +91.54% (p=0.000 n=10)
AddVV/10000-4    2.430Gi ± 0%    3.369Gi ± 0%  +38.65% (p=0.000 n=10)
AddVV/100000-4   2.350Gi ± 0%    3.183Gi ± 0%  +35.44% (p=0.000 n=10)
geomean          2.119Gi         3.364Gi       +58.71%

Change-Id: I727b3d9f8ab01eada7270046480b1430d56d0a96
Reviewed-on: https://go-review.googlesource.com/c/go/+/595395
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: M Zhuo <mengzhuo1203@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
9 months agocmd/internal/obj/loong64: add support for MOV{GR2FCSR/FCSR2GR/FR2CF/CF2FR} instructions
Xiaolin Zhao [Mon, 1 Apr 2024 07:05:45 +0000 (15:05 +0800)]
cmd/internal/obj/loong64: add support for MOV{GR2FCSR/FCSR2GR/FR2CF/CF2FR} instructions

Go asm syntax example:
MOVV R4, FCSR0
MOVV FCSR1, R5
MOVV F4, FCC0
MOVV FCC1, F5

Equivalent platform assembler syntax:
movgr2fcsr fcsr0, r4
movfcsr2gr r5, fcsr1
movfr2cf fcc0, f4
movcf2fr f5, fcc1

Ref: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

This change also merges the case of floating point move instructions
and add checks for the range of special registers.

Change-Id: Ib08fbce83e7a31dc0ab4857bf9ba959855241d1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/580279
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agobytes,slices,strings: optimize Repeat a bit
Jes Cok [Thu, 1 Aug 2024 16:18:06 +0000 (16:18 +0000)]
bytes,slices,strings: optimize Repeat a bit

Like slices.Repeat, use math/bits.Mul to detect overflow in order to
avoid a divide which is slow.

While here, also use builtin min/max to simplify code.

Change-Id: I4a6d8cd5df97fa75f4e324d4be1405ce53c03d31
GitHub-Last-Rev: 54ba5c7126b1d4a301e95d664b5f6deee6d579d9
GitHub-Pull-Request: golang/go#68704
Reviewed-on: https://go-review.googlesource.com/c/go/+/602475
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: Michael Knyszek <mknyszek@google.com>
9 months agoruntime: avoid futile mark worker acquisition
Rhys Hiltner [Thu, 1 Aug 2024 18:15:30 +0000 (11:15 -0700)]
runtime: avoid futile mark worker acquisition

During the GC mark phase, one of the first behaviors of findRunnable is
to check if it should execute a GC mark worker. Mark workers often run
for many milliseconds in a row, so programs that invoke the scheduler
more frequently will see that condition trigger only a tiny fraction of
the time.

Obtaining a mark worker from the gcBgMarkWorkerPool involves a CAS on a
single memory location that's shared across the process. When GOMAXPROCS
is large, the resulting contention can waste a significant amount of CPU
time. But a sufficiently large GOMAXPROCS also means there's no need for
fractional mark workers, making it easier to check ahead of time if we
need to run a worker.

Check, without committing to a particular worker, whether we would even
want to run one.

For #68399

Change-Id: I5d8578c2101ee20a8a4156a029584356095ea118
Reviewed-on: https://go-review.googlesource.com/c/go/+/602477
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Rhys Hiltner <rhys.hiltner@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoruntime: don't use maps in js note implementation
Michael Pratt [Thu, 27 Jun 2024 21:18:51 +0000 (17:18 -0400)]
runtime: don't use maps in js note implementation

notes are used in sensitive locations in the runtime, such as those with
write barriers forbidden. Maps aren't designed for this sort of internal
use.

Notably, newm -> notewakeup doesn't allow write barriers, but mapaccess1
-> panic contains write barriers. The js runtime only builds right now
because the map access is optimized to mapaccess1_fast64, which happens
to not have a panic call.

The initial swisstable map implementation doesn't have a fast64 variant.
While we could add one, it is a bad idea in general to use a map in such
a fragile location. Simplify the implementation by storing the metadata
directly in the note, and using a linked list for checkTimeouts.

For #54766.

Cq-Include-Trybots: luci.golang.try:gotip-js-wasm
Change-Id: Ib9d39f064ae4ad32dcc873f799428717eb6c2d5a
Reviewed-on: https://go-review.googlesource.com/c/go/+/595558
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agodebug/buildid: treat too large string as "not a Go executable"
Michael Pratt [Thu, 1 Aug 2024 14:17:14 +0000 (10:17 -0400)]
debug/buildid: treat too large string as "not a Go executable"

If the length does not fit in int, saferio.ReadDataAt returns
io.ErrUnexpectedEOF. Treat is as an invalid format.

Fixes #68692.
For #68592.

Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest
Change-Id: Ie856f29c907fd10e6d9b7dfbb6f0d8008a75a1c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/602435
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocrypto: implement encoding.BinaryAppender for all crypto hashes
Mateusz Poliwczak [Thu, 1 Aug 2024 06:26:48 +0000 (06:26 +0000)]
crypto: implement encoding.BinaryAppender for all crypto hashes

For #62384

Change-Id: I6fc7a7b8b85e02c880f1d16e0467f5076d477f0f
GitHub-Last-Rev: 90ba7bae6aa9ddfbcd622682314c05e5f65cbb56
GitHub-Pull-Request: golang/go#68651
Reviewed-on: https://go-review.googlesource.com/c/go/+/601776
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile: add race instrumentation during walkCompare
Cuong Manh Le [Fri, 25 Aug 2023 15:10:38 +0000 (22:10 +0700)]
cmd/compile: add race instrumentation during walkCompare

So the racy usage could be detected after re-writing "==" to
runtime.memequal call.

Updates #61204

Change-Id: Idb4ac37e55813cc87f9d16aa656fb447edf69ea1
Reviewed-on: https://go-review.googlesource.com/c/go/+/601117
Reviewed-by: Egon Elbre <egonelbre@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agogo/types: fix typo in comment
Xin Hao [Thu, 1 Aug 2024 02:47:35 +0000 (02:47 +0000)]
go/types: fix typo in comment

Change-Id: Ic0ea0f0de3f94e2d89bf76176c51f42e87b1bad7
GitHub-Last-Rev: 29517a07f9af17d3dfea9a1d242d734040bc575e
GitHub-Pull-Request: golang/go#68695
Reviewed-on: https://go-review.googlesource.com/c/go/+/602177
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@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agoruntime: measure speed of procyield and osyield
Rhys Hiltner [Fri, 26 Jul 2024 17:14:20 +0000 (10:14 -0700)]
runtime: measure speed of procyield and osyield

These are delay primitives for lock2. If a mutex isn't immediately
available, we can use procyield to tell the processor to wait for a
moment, or osyield to allow the OS to run a different process or thread
if one is waiting. We expect a processor-level yield to be faster than
an os-level yield, and for both of them to be fast relative to entering
a full sleep (via futexsleep or semasleep).

Each architecture has its own way of hinting to the processor that it's
in a spin-wait loop, so procyield presents an architecture-independent
interface for use in lock_futex.go and lock_sema.go.

Measure the (single-threaded) speed of these to confirm.

For #68578

Change-Id: I90cd46ea553f2990395aceb048206285558c877e
Reviewed-on: https://go-review.googlesource.com/c/go/+/601396
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agocmd/internal/obj/loong64: remove Class C_LEXT and C_SEXT
limeidan [Thu, 4 Jan 2024 12:39:57 +0000 (20:39 +0800)]
cmd/internal/obj/loong64: remove Class C_LEXT and C_SEXT

There is no need to check whether the symbol is empty, since we have already
checked it before. In addition, it is enough to use C_ADDR to represent memory
access, C_LEXT and C_SEXT are not needed.

Change-Id: I7158d6b549482b35cd9ac5fba781648fb3f21922
Reviewed-on: https://go-review.googlesource.com/c/go/+/565615
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
9 months agocmd/compiler,internal/runtime/atomic: optimize Load{64,32,8} on loong64
Guoqi Chen [Tue, 23 Apr 2024 09:01:28 +0000 (17:01 +0800)]
cmd/compiler,internal/runtime/atomic: optimize Load{64,32,8} on loong64

The LoadAcquire barrier on Loong64 is "dbar 0x14", using the correct
barrier in Load{8,32,64} implementation can improve performance.

goos: linux
goarch: loong64
pkg: internal/runtime/atomic
cpu: Loongson-3A6000-HV @ 2500.00MHz
                |  bench.old   | bench.new                           |
                |  sec/op      |  sec/op        vs base              |
AtomicLoad64      17.210n ± 0%   4.402n ± 0%   -74.42% (p=0.000 n=20)
AtomicLoad64-2    17.210n ± 0%   4.402n ± 0%   -74.42% (p=0.000 n=20)
AtomicLoad64-4    17.210n ± 0%   4.402n ± 0%   -74.42% (p=0.000 n=20)
AtomicLoad        17.220n ± 0%   4.402n ± 0%   -74.44% (p=0.000 n=20)
AtomicLoad-2      17.210n ± 0%   4.402n ± 0%   -74.42% (p=0.000 n=20)
AtomicLoad-4      17.210n ± 0%   4.402n ± 0%   -74.42% (p=0.000 n=20)
AtomicLoad8       17.210n ± 0%   4.402n ± 0%   -74.42% (p=0.000 n=20)
AtomicLoad8-2     17.210n ± 0%   4.402n ± 0%   -74.42% (p=0.000 n=20)
AtomicLoad8-4     17.210n ± 0%   4.402n ± 0%   -74.42% (p=0.000 n=20)
geomean           17.21n         4.402n        -74.42%

goos: linux
goarch: loong64
pkg: internal/runtime/atomic
cpu: Loongson-3A5000 @ 2500.00MHz
                |  bench.old   | bench.new                           |
                |  sec/op      |  sec/op        vs base              |
AtomicLoad64      18.82n ± 0%    10.41n ± 0%   -44.69% (p=0.000 n=20)
AtomicLoad64-2    18.81n ± 0%    10.41n ± 0%   -44.66% (p=0.000 n=20)
AtomicLoad64-4    18.82n ± 0%    10.41n ± 0%   -44.69% (p=0.000 n=20)
AtomicLoad        18.81n ± 0%    10.41n ± 0%   -44.66% (p=0.000 n=20)
AtomicLoad-2      18.82n ± 0%    10.41n ± 0%   -44.69% (p=0.000 n=20)
AtomicLoad-4      18.81n ± 0%    10.42n ± 0%   -44.63% (p=0.000 n=20)
AtomicLoad8       18.82n ± 0%    10.41n ± 0%   -44.69% (p=0.000 n=20)
AtomicLoad8-2     18.82n ± 0%    10.41n ± 0%   -44.70% (p=0.000 n=20)
AtomicLoad8-4     18.82n ± 0%    10.41n ± 0%   -44.69% (p=0.000 n=20)
geomean           18.82n         10.41n        -44.68%

Change-Id: I9d47c9d6f359c4f2e41035ca656429aade2e7847
Reviewed-on: https://go-review.googlesource.com/c/go/+/581357
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/internal/obj/loong64: optimize the code logic of jump instructions
limeidan [Wed, 17 Jan 2024 09:49:37 +0000 (17:49 +0800)]
cmd/internal/obj/loong64: optimize the code logic of jump instructions

If p.To.Sym is nil, that means we can get the target offset from
p.To.Target().pc - c.pc,only when p.To.Sym is not nil, we need relocation
to get the true address of target symbol.

Change-Id: Ied52f675c6aa6e8fb8d972b7699f5cadd1ecb268
Reviewed-on: https://go-review.googlesource.com/c/go/+/565627
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Meidan Li <limeidan@loongson.cn>
9 months agocmd/internal/obj/loong64: merge two branch classes into one
limeidan [Tue, 16 Jan 2024 09:42:48 +0000 (17:42 +0800)]
cmd/internal/obj/loong64: merge two branch classes into one

When the kind of the operand is TYPE_BRANCH, we cannot determine
whether it is a long branch or a short branch, so we merge these
two classes into one.

Change-Id: I7d7fa8f62ff02791ec3de4e3e3f7610bc9cb1743
Reviewed-on: https://go-review.googlesource.com/c/go/+/565626
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agocmd/internal/obj/loong64: reclassify three-register operation instructions and two...
limeidan [Fri, 5 Jan 2024 02:33:42 +0000 (10:33 +0800)]
cmd/internal/obj/loong64: reclassify three-register operation instructions and two-register operation instructions

The instructions belonging to case 32 have the same structure as the
instructions in case 2.

The instructions in case 33 are actually two-register operation
instructions. We move their definitions from function oprrr to oprr and
merge their implementation into case 9.

Change-Id: Id04aaa497e78d8198a58f8d406876d16b3f393a7
Reviewed-on: https://go-review.googlesource.com/c/go/+/565616
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agogo/types: generate recording.go
Robert Griesemer [Wed, 31 Jul 2024 20:12:50 +0000 (13:12 -0700)]
go/types: generate recording.go

Change-Id: I530df137bcb5094a828f97ecbe204265b50c8546
Reviewed-on: https://go-review.googlesource.com/c/go/+/602118
Auto-Submit: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Tim King <taking@google.com>
9 months agocrypto/internal/cryptotest: add tests for the cipher.BlockMode interface
Manuel Sabin [Mon, 24 Jun 2024 17:58:35 +0000 (13:58 -0400)]
crypto/internal/cryptotest: add tests for the cipher.BlockMode interface

This CL creates tests for the cipher.BlockMode interface in the new
cryptotest package.  This set of tests is called from the tests of
implementations of the BlockMode interface e.g. cbc_test.go

Updates #25309

Change-Id: I3685bbee24d08d66f5bb4b7f001cbf520c844881
Reviewed-on: https://go-review.googlesource.com/c/go/+/595120
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Russell Webb <russell.webb@protonmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/cgo: document workaround for C struct_stat function
Ian Lance Taylor [Wed, 31 Jul 2024 20:16:23 +0000 (13:16 -0700)]
cmd/cgo: document workaround for C struct_stat function

For #68682

Change-Id: I13b61f915925a9ee510e0a42e95da7a83678b3b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/602215
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agogo/types: add go1.23 iterator methods for 10 exported types
Alan Donovan [Sun, 31 Mar 2024 22:37:12 +0000 (18:37 -0400)]
go/types: add go1.23 iterator methods for 10 exported types

These methods will not be mirrored in types2 until the
bootstrap compiler reaches go1.23; therefore range-over-func
statements must not be used in code common to types + types2.

Fixes #66626

Change-Id: I3c2c15e3652ee95d9aff208d8a188b912ed5bc9a
Reviewed-on: https://go-review.googlesource.com/c/go/+/575455
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
9 months agocmd/compile: keep internal/runtime packages sorted
Michael Pratt [Wed, 26 Jun 2024 18:58:12 +0000 (14:58 -0400)]
cmd/compile: keep internal/runtime packages sorted

This is a minor cleanup from CL 600436.

For #65355.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-darwin-amd64-longtest
Change-Id: I8e27f0c6ba6bd35f4aa2b9d53c394fb5f1eb433d
Reviewed-on: https://go-review.googlesource.com/c/go/+/595116
Reviewed-by: Austin Clements <austin@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agonet: replace sort with slices for address and DNS record sorting
aimuz [Tue, 28 May 2024 13:53:53 +0000 (13:53 +0000)]
net: replace sort with slices for address and DNS record sorting

This change replaces the usage of the "sort" package with the "slices"
package for sorting IP addresses and DNS records. The new approach
simplifies the code and improves readability by leveraging the
slices.SortFunc and slices.SortStableFunc functions.

- Updated addrselect.go to use slices.SortStableFunc for sorting IP
  addresses based on RFC 6724.
- Refactored dnsclient.go to use slices.SortFunc for sorting SRV and MX
  records by priority and weight.

This change also reduces the dependency tree for the package by
removing the dependency on "sort" and its transitive dependencies,
resulting in a leaner build.

Change-Id: I436dacc8dd1e8f2f7eeac44d6719ce248394d8a9
GitHub-Last-Rev: 3720a490815e2dc2fad06b107f21c67f5ad6c6c8
GitHub-Pull-Request: golang/go#67503
Reviewed-on: https://go-review.googlesource.com/c/go/+/586635
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>

9 months agogo/types, types2: factor out typechecker-specific code from recording.go
Robert Griesemer [Wed, 31 Jul 2024 16:59:28 +0000 (09:59 -0700)]
go/types, types2: factor out typechecker-specific code from recording.go

With this CL, the go/types and types2 recording.go files are
mostly identical except for the use of different syntax trees.
Preparation for generating go/types/recording.go from types2
sources.

Change-Id: Iea85f8554ee04f1e1f7da63f8019725ac8f6caf5
Reviewed-on: https://go-review.googlesource.com/c/go/+/602117
Reviewed-by: Tim King <taking@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>

9 months agotime: optimize time <-> date conversions
Russ Cox [Thu, 16 May 2024 17:09:51 +0000 (13:09 -0400)]
time: optimize time <-> date conversions

Optimize the time -> date and date -> time conversions using the
methods outlined in:

    Cassio Neri and Lorenz Schneider,
    “Euclidean affine functions and their
    application to calendar algorithms,”
    SP&E 2023. https://doi.org/10.1002/spe.3172

I took the opportunity to introduce some types to make the code
significantly clearer and optimize a few other parts I noticed along
the way. The result is noticeably faster across the board.

Probably this doesn't matter much in real programs, but all the other
languages are picking this up, and it is less code than what we had
before.

Proposal #63844 suggested adopting this algorithm and simultaneously
restricting the range of valid years supported by the package from its
current ±292277022399 (plenty for anyone) to a mere ±32767.
This CL does NOT make any such restriction. The range of valid years
is almost exactly what it was before. (It is the same size but shifted
10 months earlier, which no one will ever care about.)

This CL removes any real need to consider the proposal, since it
would be a breaking change for truly insignificant benefit.

Thanks to Normandes Junior and Cassio Neri for CL 548155
and for discussion on #63844, which prompted me to write this CL.
This CL is all new code and does not include code from CL 548155
except as noted in the isLeap function implementation.

For #63844.

goos: linux
goarch: amd64
pkg: time
cpu: AMD Ryzen 9 7950X 16-Core Processor
                        │ timeold.txt  │             timenew.txt              │
                        │    sec/op    │   sec/op     vs base                 │
Format-32                  156.5n ± 1%   148.1n ± 1%   -5.37% (n=125)
FormatRFC3339-32           118.5n ± 1%   112.1n ± 1%   -5.40% (n=125)
FormatRFC3339Nano-32       119.2n ± 1%   113.0n ± 1%   -5.20% (n=125)
FormatNow-32               96.88n ± 2%   97.22n ± 1%        ~ (p=0.173 n=125)
MarshalJSON-32             79.77n ± 1%   75.82n ± 1%   -4.95% (n=125)
MarshalText-32             79.25n ± 1%   76.18n ± 1%   -3.87% (p=0.000 n=125)
Parse-32                   79.80n ± 1%   78.28n ± 1%   -1.90% (p=0.000 n=125)
ParseRFC3339UTC-32         29.10n ± 1%   28.90n ± 0%        ~ (p=0.094 n=125)
ParseRFC3339UTCBytes-32    30.72n ± 1%   30.88n ± 1%        ~ (p=0.894 n=125)
ParseRFC3339TZ-32          92.29n ± 0%   90.27n ± 1%   -2.19% (p=0.000 n=125)
ParseRFC3339TZBytes-32     133.4n ± 1%   132.0n ± 1%        ~ (p=0.004 n=125)
ParseDuration-32           41.11n ± 3%   44.08n ± 2%        ~ (p=0.088 n=125)
Hour-32                    2.834n ± 0%   2.829n ± 1%        ~ (p=0.891 n=125)
Second-32                  2.811n ± 1%   2.828n ± 1%        ~ (p=0.208 n=125)
Date-32                    9.228n ± 1%   5.788n ± 0%  -37.28% (n=125)
Year-32                    6.404n ± 1%   4.673n ± 1%  -27.03% (n=125)
YearDay-32                 6.399n ± 1%   5.802n ± 0%   -9.33% (n=125)
Month-32                   9.108n ± 1%   4.700n ± 1%  -48.40% (n=125)
Day-32                     9.106n ± 1%   4.686n ± 1%  -48.54% (n=125)
ISOWeek-32                10.060n ± 0%   7.998n ± 1%  -20.50% (n=125)
GoString-32                84.59n ± 1%   83.82n ± 1%        ~ (p=0.027 n=125)
DateFunc-32                6.993n ± 0%   6.144n ± 1%  -12.14% (n=125)
UnmarshalText-32           94.78n ± 2%   89.49n ± 1%   -5.58% (n=125)
geomean                    29.60n        26.13n       -11.70%

goos: darwin
goarch: arm64
pkg: time
cpu: Apple M3 Pro
                        │ timeold-m3.txt │            timenew-m3.txt            │
                        │     sec/op     │   sec/op     vs base                 │
Format-12                    152.6n ± 0%   147.4n ± 0%   -3.41% (n=125)
FormatRFC3339-12            101.50n ± 0%   92.02n ± 0%   -9.34% (n=125)
FormatRFC3339Nano-12        101.30n ± 0%   92.68n ± 0%   -8.51% (n=125)
FormatNow-12                 93.50n ± 0%   94.65n ± 0%   +1.23% (p=0.000 n=125)
MarshalJSON-12               50.06n ± 0%   48.25n ± 0%   -3.62% (n=125)
MarshalText-12               49.70n ± 0%   47.51n ± 0%   -4.41% (n=125)
Parse-12                     97.91n ± 0%   95.90n ± 0%   -2.05% (n=125)
ParseRFC3339UTC-12           36.45n ± 0%   35.78n ± 1%   -1.84% (n=125)
ParseRFC3339UTCBytes-12      38.11n ± 0%   37.42n ± 0%   -1.81% (n=125)
ParseRFC3339TZ-12           100.80n ± 1%   97.58n ± 0%   -3.19% (n=125)
ParseRFC3339TZBytes-12       111.8n ± 1%   107.4n ± 0%   -3.94% (n=125)
ParseDuration-12             52.70n ± 0%   52.84n ± 0%        ~ (p=0.028 n=125)
Hour-12                      2.657n ± 0%   2.655n ± 0%        ~ (p=0.018 n=125)
Second-12                    2.656n ± 0%   2.654n ± 0%        ~ (p=0.084 n=125)
Date-12                      8.201n ± 0%   5.055n ± 0%  -38.36% (n=125)
Year-12                      5.694n ± 0%   4.086n ± 0%  -28.24% (n=125)
YearDay-12                   5.693n ± 0%   4.828n ± 0%  -15.19% (n=125)
Month-12                     8.206n ± 0%   4.231n ± 0%  -48.44% (n=125)
Day-12                       8.199n ± 0%   4.551n ± 0%  -44.49% (n=125)
ISOWeek-12                   9.032n ± 0%   7.298n ± 0%  -19.20% (n=125)
GoString-12                  62.78n ± 0%   60.61n ± 0%   -3.46% (n=125)
DateFunc-12                  7.318n ± 0%   6.431n ± 0%  -12.12% (n=125)
UnmarshalText-12             99.66n ± 0%   95.64n ± 0%   -4.03% (n=125)

Change-Id: I089a072a731914702f8087018d00960e129f86b0
Reviewed-on: https://go-review.googlesource.com/c/go/+/586257
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agogo/types, types2: move type recording functionality in its own files
Robert Griesemer [Wed, 31 Jul 2024 16:40:33 +0000 (09:40 -0700)]
go/types, types2: move type recording functionality in its own files

This CL simply moves recording functions into recording.go and
adjust the imports as needed. There are no other code changes.
Preparation for generating go/types/recording.go from types2
sources.

Change-Id: Idc5850462a78afb1bfce78ba216722d07c8bca1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/602116
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Tim King <taking@google.com>
9 months agoreflect: add flag tests for MapOf
Michael Pratt [Mon, 24 Jun 2024 21:17:13 +0000 (17:17 -0400)]
reflect: add flag tests for MapOf

Add two tests that verify that MapOf sets the map NeedsKeyUpdate and
HashMightPanic flags in the created map. Missing these flags would cause
correctness issues not otherwise caught in the reflect tests.

For #54766.

Change-Id: Icd5f117e0794e7b4d1b70fa94e5afbe97c4543e3
Reviewed-on: https://go-review.googlesource.com/c/go/+/594656
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agogo/types, types2: record type parameters in receiver expressions as uses
Robert Griesemer [Wed, 31 Jul 2024 02:35:27 +0000 (19:35 -0700)]
go/types, types2: record type parameters in receiver expressions as uses

CL 594740 rewrote type checking of method receiver types. Because that
CL takes apart receivers "manually" rather than using the regular code
for type checking type expressions, type parameters in receiver type
expressions were only recorded as definitions (in Info.Defs).

Before that CL, such type parameters were simultaneously considered
definitions (they are declared by the receiver type expression) and
uses (they are used to instantiate the receiver type expression).

Adjust the receiver type checking code accordingly and record its
type parameters also in Info.Uses and Info.Types.

While at it, in go/types, replace declareTypeParams (plural) with
declareTypeParam (singular) to more closely match types2 code.
No functionality or semantic change.

Fixes #68670.
For #51343.

Change-Id: Ibbca1a9b92e31b0dc972052a2827deeab49da98b
Reviewed-on: https://go-review.googlesource.com/c/go/+/601935
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Tim King <taking@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Robert Griesemer <gri@google.com>
9 months agocmd/compile: add comment for the context on mismatch import path
Cuong Manh Le [Wed, 3 Jul 2024 15:46:30 +0000 (22:46 +0700)]
cmd/compile: add comment for the context on mismatch import path

Follow up suggestion in CL 596396.

Updates #54542

Change-Id: I47bf66684bb8397dc1cfbc4479e2279e59a40cfb
Reviewed-on: https://go-review.googlesource.com/c/go/+/596515
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>

9 months agocmd/go: fix windows test failure for test_buildinfo_godebug_issue68053
Sam Thanawalla [Wed, 31 Jul 2024 14:55:51 +0000 (14:55 +0000)]
cmd/go: fix windows test failure for test_buildinfo_godebug_issue68053

Fix required adding $GOEXE because windows will produce a .exe file.

Fixes: #68673
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: I25206de362ee4be6a9c54bd1baa405f325d79313
Reviewed-on: https://go-review.googlesource.com/c/go/+/602095
Reviewed-by: Michael Matloob <matloob@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocrypto/internal/cryptotest: add tests for the cipher.Block interface
Manuel Sabin [Wed, 19 Jun 2024 16:49:32 +0000 (12:49 -0400)]
crypto/internal/cryptotest: add tests for the cipher.Block interface

This CL creates tests for the cipher.Block interface in the cryptotest
package.  This set of tests is called from the tests of implementation
of the Block interface e.g. aes_test.go and des_test.go.

Updates #25309

Change-Id: Ieea3752147c8163fc73a849cfcb8fa011205d2c2
Reviewed-on: https://go-review.googlesource.com/c/go/+/594018
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Russell Webb <russell.webb@protonmail.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/internal/obj/loong64: optimize instruction implementation
limeidan [Thu, 11 Jan 2024 07:12:50 +0000 (15:12 +0800)]
cmd/internal/obj/loong64: optimize instruction implementation

The plan9 instructions ASLLV and -ASLLV are translated into the same assembly
instructions, so -ASLLV can be removed and replaced with ASLLV in the
corresponding position.

ASRLV and -ASRLV have the same reason as the above two instructions.

Change-Id: I4bd79ca7bb070f7a924a0205ef2f19cf2b9ae2c9
Reviewed-on: https://go-review.googlesource.com/c/go/+/565623
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
9 months agocmd/internal/obj/loong64: remove case 17 in func asmout
limeidan [Sat, 6 Jan 2024 03:34:34 +0000 (11:34 +0800)]
cmd/internal/obj/loong64: remove case 17 in func asmout

There is no relative optab item case 17, remove it.

Change-Id: I3ceaa3283c3641afafd46362737ff847a1d80665
Reviewed-on: https://go-review.googlesource.com/c/go/+/565617
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agocmd/internal/obj/loong64: rename Class to represent the external symbol address
limeidan [Fri, 12 Jan 2024 01:58:35 +0000 (09:58 +0800)]
cmd/internal/obj/loong64: rename Class to represent the external symbol address

There is no need to define another C_SECON Class to express short
external symbol address, because the external symbol address is unknown
in assembler, relocate it in linker.

Change-Id: Id9fbd848c43ca63a21f2b6640e947140c26eeaf7
Reviewed-on: https://go-review.googlesource.com/c/go/+/565624
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: abner chenc <chenguoqi@loongson.cn>

9 months agocmd/compile: fix order of map iteration in deadlocals
David Chase [Wed, 31 Jul 2024 13:55:14 +0000 (09:55 -0400)]
cmd/compile: fix order of map iteration in deadlocals

This makes builds reproducible again.

Fixes #68672
Updates #65158

Change-Id: I260180f52e992c702ab89050deb6484087ae265f
Reviewed-on: https://go-review.googlesource.com/c/go/+/602075
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
9 months agodebug/buildinfo: reuse buffer in searchMagic
Michael Pratt [Fri, 26 Jul 2024 19:57:27 +0000 (15:57 -0400)]
debug/buildinfo: reuse buffer in searchMagic

Allocating a new buffer for each chunk in searchMagic is very
inefficient. Refactor reading to allow us to reuse the same buffer for
each iteration.

This reduces the runtime of `go version` on a 2.5GB non-Go binary from
~1s and ~25MB RSS to ~250ms and ~15MB RSS.

For #68592.

Change-Id: Idae5c2c9b3b8a7158d5cc7f2f008998be75fd7af
Reviewed-on: https://go-review.googlesource.com/c/go/+/601460
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agodebug/buildinfo: read data in chunks
Michael Pratt [Fri, 26 Jul 2024 17:41:12 +0000 (13:41 -0400)]
debug/buildinfo: read data in chunks

Rather than reading the entire data segment into memory, read it in
smaller chunks to keep memory usage low.

For typically Go binaries, this doesn't matter much. For those, we read
the .go.buildinfo section, which should be quite small. But for non-Go
binaries (or Go binaries with section headers stripped), we search the
entire loadable data segment, which could be quite large.

This reduces the time for `go version` on a 2.5GB non-Go binary from
~1.2s and 1GB RSS (!!) to ~1s and ~25MB RSS.

Fixes #68592.

Change-Id: I9218854c5b6f2aa1331f561ab0850a9fd62ef23b
Reviewed-on: https://go-review.googlesource.com/c/go/+/601459
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd: add README generation for compiler + linker script tests
Than McIntosh [Tue, 30 Jul 2024 14:20:53 +0000 (14:20 +0000)]
cmd: add README generation for compiler + linker script tests

Add in automatic README generation and README consistency checking for
the cmd/compile and cmd/link script tests. This code is adapted from
the similar facility in cmd/go (e.g. scriptreadme_test.go); the README
helps folks writing new tests understand the mechanics.

Updates #68606.

Change-Id: I8ff7ff8e814abd4385bd670440511b2c60a4cef6
Reviewed-on: https://go-review.googlesource.com/c/go/+/601756
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/internal/script: new hook for adding in toolchain script conditions
Than McIntosh [Mon, 29 Jul 2024 17:40:10 +0000 (17:40 +0000)]
cmd/internal/script: new hook for adding in toolchain script conditions

Introduce a new function AddToolChainScriptConditions that augments a
default "script.Cond" set with a collection of useful conditions,
including godebug/goexperiment, cgo, race support, buildmode, asan,
msan, and so on. Having these conditions available makes it easier to
write script tests that deal with specific build-flavor corner cases.
The functions backing the new conditions are helper functions migrated
over from the Go command's script test setup.

Updates #68606.

Change-Id: I14def1115b54dc47529c983abcd2c5ea9326b9de
Reviewed-on: https://go-review.googlesource.com/c/go/+/601715
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agogo/types: record pointer and parentheses in receiver expressions
Robert Griesemer [Mon, 29 Jul 2024 22:29:08 +0000 (15:29 -0700)]
go/types: record pointer and parentheses in receiver expressions

CL 594740 rewrote type checking of method receiver types. Because that
CL takes apart receivers "manually" rather than using the regular code
for type checking type expressions, pointer and parenthesized receiver
type expressions were not recorded anymore.

Adjust the code that typechecks method receivers to a) use ordinary
type expression checking for non-generic receivers, and b) to record
a missing pointer and any intermediate parenthesized expressions in
case of a generic receiver.

Add many extra tests verifying that the correct types for parenthesized
and pointer type expressions are recorded in various source positions.

Note that the parser used by the compiler and types2 doesn't encode
unnecessary parentheses in type expressions in its syntax tree.
As a result, the tests that explicitly test parentheses don't work
in types2 and are commented out.

This CL adds code (disabled by default) to the parser to encode
parentheses in type expressions in the syntax tree. When enabled,
the commented out types2 tests pass like in go/types.

Fixes #68639.
For #51343.

Change-Id: Icf3d6c76f7540ee53e229660be8d78bb25380539
Reviewed-on: https://go-review.googlesource.com/c/go/+/601657
Reviewed-by: Tim King <taking@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>

9 months agonet/http: match os.File.Readdir behavior in DotFileHiding
Sean Liao [Fri, 12 Jul 2024 19:14:23 +0000 (20:14 +0100)]
net/http: match os.File.Readdir behavior in DotFileHiding

Fixes #67697

Change-Id: I26b26262d885d0704851c08c79e7b2b4872b65ad
Reviewed-on: https://go-review.googlesource.com/c/go/+/598075
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agocmd/cgo/internal/testsanitizers: avoid clang error in msan8.go
Ian Lance Taylor [Tue, 30 Jul 2024 18:48:10 +0000 (11:48 -0700)]
cmd/cgo/internal/testsanitizers: avoid clang error in msan8.go

In clang 16 the option -fsanitize-memory-param-retval was turned on by
default. That option causes MSAN to issue a warning when calling a
function with an uninitialized value. The msan8 test relies on being
able to do this, in order to get uninitialized values into registers.

This CL fixes the test by adding maybe_undef attributes that tell
clang that it's OK to pass an uninitialized variable. The docs for
maybe_undef say: "Please note that this is an attribute that is used as
an internal implementation detail and not intended to be used by
external users." So this may break in the future, but it does work for now.

Fixes #64616

Change-Id: I0ac8c0520fce8c32e26d2a5efb7ae5e02461c1ce
Reviewed-on: https://go-review.googlesource.com/c/go/+/601779
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agogo/printer: correct cindex meaning in commentInfo comments
Mateusz Poliwczak [Tue, 30 Jul 2024 19:01:10 +0000 (19:01 +0000)]
go/printer: correct cindex meaning in commentInfo comments

(*printer).nextComment increases cindex by one after each call
and it always points to the next element.

Change-Id: I65754ab6e30e10dc7473882e39737d2e0dc29070
GitHub-Last-Rev: f859283324af6ddf9fdc75ef08ee42ae26bc581b
GitHub-Pull-Request: golang/go#68032
Reviewed-on: https://go-review.googlesource.com/c/go/+/592557
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/go/internal/load: recompute test variant's build info if necessary
Michael Matloob [Mon, 1 Jul 2024 20:34:08 +0000 (16:34 -0400)]
cmd/go/internal/load: recompute test variant's build info if necessary

The buildinfo used for a testmain is a copy from the buildinfo produced
for the package under test, and that in turn is only computed if the
package under test is package main. If there are //go:debug directives
in a test file for package main, the godebugs for the testmain (which
are computed using the regular package files as well as the test files'
//go:debug directives) will be different from those used to produce the
buildinfo of the package under test (computed using the //go:debug
directives only in the main package). In that case, recompute the
buildinfo for the testmain to incorporate the new godebug information.

Since we've only been generating buildinfo for tests on package main, in
this CL we'll only recompute the buildinfo if the test is for package
main. It's not clear to me though if we should be computing the
buildinfo for all test mains (or none of them?)

Fixes #68053

Change-Id: Ib6cdb118e2f233de483c33e171c0cd03df1fc7be
Reviewed-on: https://go-review.googlesource.com/c/go/+/595961
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Sam Thanawalla <samthanawalla@google.com>
9 months agoruntime: make TestDebugLogInterleaving much more robust
Austin Clements [Wed, 24 Jul 2024 03:09:07 +0000 (23:09 -0400)]
runtime: make TestDebugLogInterleaving much more robust

The current test often doesn't actually generate enough interleaving
to result in multiple log shards. This CL rewrites this test to
forcibly create at least 10 log shards with interleaved log messages.
It also tests dlog's robustness to being held across M and P switches.

Change-Id: Ia913b17c0392384ff679832047f359945669bb15
Reviewed-on: https://go-review.googlesource.com/c/go/+/600699
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
Auto-Submit: Austin Clements <austin@google.com>

9 months agocmd/compile: add "deadlocals" pass to remove unused locals
David Chase [Wed, 22 May 2024 21:00:43 +0000 (14:00 -0700)]
cmd/compile: add "deadlocals" pass to remove unused locals

This CL adds a "deadlocals" pass, which runs after inlining and before
escape analysis, to prune any unneeded local variables and
assignments. In particular, this helps avoid unnecessary Addrtaken
markings from unreachable closures.

Deadlocals is sensitive to "_ = ..." as a signal of explicit
use for testing.  This signal occurs only if the entire
left-hand-side is "_" targets; if it is
  `_, ok := someInlinedFunc(args)`
then the first return value is eligible for dead code elimination.

Use this (`_ = x`) to fix tests broken by deadlocals elimination.

Includes a test, based on one of the tests that required modification.

Matthew Dempsky wrote this, changing ownership to allow rebases, commits, tweaks.

Fixes #65158.

Old-Change-Id: I723fb69ccd7baadaae04d415702ce6c8901eaf4e
Change-Id: I1f25f4293b19527f305c18c3680b214237a7714c
Reviewed-on: https://go-review.googlesource.com/c/go/+/600498
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: David Chase <drchase@google.com>
Commit-Queue: David Chase <drchase@google.com>

9 months agocmd/compile/internal/ir: add DoChildrenWithHidden
David Chase [Wed, 22 May 2024 22:00:20 +0000 (15:00 -0700)]
cmd/compile/internal/ir: add DoChildrenWithHidden

Analogous to EditChildrenWithHidden.
A commit written by Matthew Dempsky

Old-Change-Id: I9fe0d3ee98d9dbe5f77eb02d666b9f317ee5b6af
Change-Id: I41aacb1545ab3142862b156bd1767fe4a3df4ca0
Reviewed-on: https://go-review.googlesource.com/c/go/+/600497
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile: verify that rangefunc assigning to no vars works
David Chase [Tue, 2 Jul 2024 16:45:30 +0000 (12:45 -0400)]
cmd/compile: verify that rangefunc assigning to no vars works

This adds a test for
   for range seq2rangefunc { ... }
and
   for onevar := range seq2rangefunc { ... }

For #65236.

Change-Id: I083f8e4c19eb4ba0d6024d5314ac29d941141778
Reviewed-on: https://go-review.googlesource.com/c/go/+/596135
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
9 months agoencoding: add TextAppender and BinaryAppender
Mateusz Poliwczak [Mon, 29 Jul 2024 18:39:02 +0000 (18:39 +0000)]
encoding: add TextAppender and BinaryAppender

For #62384

Change-Id: I54707a29653df72ad9cd5633f434b87e0f630b94
GitHub-Last-Rev: 4f78947ac563d78f862c5c8de1c2e1578a8d6e08
GitHub-Pull-Request: golang/go#68620
Reviewed-on: https://go-review.googlesource.com/c/go/+/601595
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: Michael Knyszek <mknyszek@google.com>
9 months agocmd/go/internal/test: update documentation for the "go test" command
Julian Dax [Mon, 15 Jul 2024 14:36:07 +0000 (16:36 +0200)]
cmd/go/internal/test: update documentation for the "go test" command

The documentation referred to the package's source root as $GOPATH, which is no longer correct.

Fixes #64303

Change-Id: I2ea113497975726468d4ee4f85e2cfcbea9a76d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/598235
Reviewed-by: Julian Dax <julian.dax@posteo.de>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
9 months agointernal/coverage: add internal/stringslite to hard-coded coverpkg ID list
Than McIntosh [Tue, 30 Jul 2024 13:47:58 +0000 (13:47 +0000)]
internal/coverage: add internal/stringslite to hard-coded coverpkg ID list

Add internal/stringslite to the list of hard-coded package IDs to be
special cased in coverage package registration. This patch fixes
a new -coverpkg=all failure on the darwin longtest builders.

Change-Id: I56357572f215fab09f46226fe205924136322d9e
Reviewed-on: https://go-review.googlesource.com/c/go/+/601755
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/link: add variable_parameter attr to functype outparams
Than McIntosh [Thu, 27 Jun 2024 14:54:06 +0000 (14:54 +0000)]
cmd/link: add variable_parameter attr to functype outparams

When generating DW_TAG_subroutine_type DIEs during linker DWARF type
synthesis, ensure that in the list of children of the subroutine type
DIE (correspondings to input/output params) the output params are
marked with the DW_AT_variable_parameter attribute. In addition, fix
up the generated types of the output params: prior to this patch for a
given output parameter of type T, we would emit the DIE type as *T
(presumably due to how parameter passing/returning worked prior to the
register ABI); with this patch the emitted type will just be T, not *T.

Fixes #59977.

Change-Id: I5b5600be86473695663c75b85baeecad667b9245
Reviewed-on: https://go-review.googlesource.com/c/go/+/595715
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agoruntime: delete TestDebugLogBuild
Austin Clements [Tue, 23 Jul 2024 21:54:34 +0000 (17:54 -0400)]
runtime: delete TestDebugLogBuild

Now that we're actually testing debuglog in the regular build
configuration, it's far less important that we take the time to
rebuild with the debuglog tag.

Change-Id: I62bfd494ccb99087f35851c4476238b39ef40dec
Reviewed-on: https://go-review.googlesource.com/c/go/+/600698
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoruntime: run debuglog tests when debuglog tag is *not* set
Austin Clements [Tue, 23 Jul 2024 21:28:09 +0000 (17:28 -0400)]
runtime: run debuglog tests when debuglog tag is *not* set

Currently, the debuglog tests only run when the debuglog build tag is
set because, until the last few CLs, all of debuglog was compiled away
without that build tag. This causes two annoying problems:

1. The tests basically never run, because we don't regularly test this
configuration.

2. If you do turn on the debuglog build tag, it's probably because
you're adding debuglogs into the runtime, which are very likely to
mess up these tests, so you wind up disabling the tests and they,
again, don't get coverage.

Now we've set things up so the debuglog implementation is always
accessible, if you ask nicely enough. So we can switch these tests to
run when the tag is *not* set, and turn off when the tag *is* set (and
you're probably adding actual log statements).

Change-Id: Ib68d7a5022d4f5db96e9c7c8010cbef21d11fe11
Reviewed-on: https://go-review.googlesource.com/c/go/+/600697
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
9 months agoruntime: switch debuglog from const-toggled to type-toggled
Austin Clements [Tue, 23 Jul 2024 19:39:51 +0000 (15:39 -0400)]
runtime: switch debuglog from const-toggled to type-toggled

Currently, the debuglog build tag controls the dlogEnabled const, and
all methods of dlogger first check this const and immediately return
if dlog is not enabled. With constant folding and inlining, this makes
the whole dlog implementation compile away if it's not enabled.

However, we want to be able to test debuglog even when the build tag
isn't set. For that to work, we need a different mechanism.

This CL changes this mechanism so the debuglog build tag instead
controls the type alias for dlogger to be either dloggerImpl or
dloggerFake. These two types have the same method set, but one is just
stubs. This way, the methods of dloggerImpl don't need to be
conditional dlogEnabled, which sets us up to use the now
fully-functional dloggerImpl type in the test.

I confirmed that this change has no effect on the final size of the
cmd/go binary. It does increase the size of the runtime.a file by 0.9%
and make the runtime take ever so slightly longer to compile because
the compiler can no longer simply eliminate the bodies of the all of
dlogger during early deadcode. However, this all gets eliminated by
the linker. I consider this worth it to always get build and test
coverage of debuglog.

Change-Id: I81759e9e1411b7d369a23383a18b022ab7451421
Reviewed-on: https://go-review.googlesource.com/c/go/+/600696
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agoruntime: rename dlogger to dloggerImpl
Austin Clements [Tue, 23 Jul 2024 19:11:14 +0000 (15:11 -0400)]
runtime: rename dlogger to dloggerImpl

This is a mechanical change, other than adding the type alias for dlogger.

This is a step in preparing us to make debuglog testable without the
debuglog build tag.

Change-Id: Ief12f0eaf5db98a8b006c759fd325dabcc9a52d4
Reviewed-on: https://go-review.googlesource.com/c/go/+/600695
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/internal/obj/loong64, cmd/asm: remove useless instructions
limeidan [Sat, 6 Jan 2024 03:35:48 +0000 (11:35 +0800)]
cmd/internal/obj/loong64, cmd/asm: remove useless instructions

Change-Id: I180c40898672a757d72cd0ef38e6e8cc20dc4c3d
Reviewed-on: https://go-review.googlesource.com/c/go/+/565618
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
Reviewed-by: Cherry Mui <cherryyz@google.com>
9 months agocmd/internal/obj/loong64: remove unuseless functions
limeidan [Sat, 6 Jan 2024 08:59:56 +0000 (16:59 +0800)]
cmd/internal/obj/loong64: remove unuseless functions

Change-Id: Ieee97a9477090d4273e54a6667b0a051bb0c1e9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/565619
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
9 months agocmd/internal/obj/loong64: fixed operand assignment error for BFPT/BFPF instructions
limeidan [Sat, 6 Jan 2024 09:26:37 +0000 (17:26 +0800)]
cmd/internal/obj/loong64: fixed operand assignment error for BFPT/BFPF instructions

The BFPT correspond to BCNEZ instruction of LoongArch64 which structure
is:
| op-p1 | offs[15:0] | op-p2 | cj | offs[20:16] |
The register REG_FCC0 should be assigned to the source operand cj which named rj here.

Change-Id: I696d0a46028924da1cd7e240fbb40a1913f1a757
Reviewed-on: https://go-review.googlesource.com/c/go/+/565620
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
9 months agocmd/internal/obj: add stmt prologueEnd to DWARF for loong64
limeidan [Thu, 18 Jan 2024 02:41:09 +0000 (10:41 +0800)]
cmd/internal/obj: add stmt prologueEnd to DWARF for loong64

Change-Id: Ib477b2402e32ebb3c7623caf4e9d62f3afdee92f
Reviewed-on: https://go-review.googlesource.com/c/go/+/556615
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
9 months agocmd/internal/obj/loong64: return an error when getting address of tls variable
limeidan [Thu, 11 Jan 2024 02:48:12 +0000 (10:48 +0800)]
cmd/internal/obj/loong64: return an error when getting address of tls variable

The tls variable is thread local variable, an operation to get its address
is not supported, so we should return an error here.

Change-Id: Ia6a637f549cb886fdb643bdc04eeb269849d1096
Reviewed-on: https://go-review.googlesource.com/c/go/+/565621
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Qiqi Huang <huangqiqi@loongson.cn>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn>
9 months agonet/http: don't write HEAD response body in ResponseWriter.ReadFrom
Damien Neil [Fri, 26 Jul 2024 20:23:09 +0000 (13:23 -0700)]
net/http: don't write HEAD response body in ResponseWriter.ReadFrom

Responses to HEAD requests don't have a body.

The ResponseWriter automatically discards writes to the response body
when responding to a HEAD request. ResponseWriter.ReadFrom was failing
to discard writes under some circumstances; fix it to do so.

Fixes #68609

Change-Id: I912f6b2b2a535df28ae37b875fcf15b10da1af2b
Reviewed-on: https://go-review.googlesource.com/c/go/+/601475
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
9 months agocmd,log,net,runtime: simplify string prefix and suffix processing
apocelipes [Mon, 29 Jul 2024 10:23:14 +0000 (10:23 +0000)]
cmd,log,net,runtime: simplify string prefix and suffix processing

Use the TrimPrefix, TrimSuffix and CutPrefix to simplify the code.

Change-Id: I3e2b271ec0d3f9ce664b830e2b0c21ab47337ed0
GitHub-Last-Rev: 4bd1577d2496173800d609da75b08f6de177aba9
GitHub-Pull-Request: golang/go#68629
Reviewed-on: https://go-review.googlesource.com/c/go/+/601675
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
9 months agonet/http: don't write body for HEAD responses in Response.Write
Damien Neil [Fri, 26 Jul 2024 22:34:03 +0000 (15:34 -0700)]
net/http: don't write body for HEAD responses in Response.Write

Fixes #62015

Change-Id: I88c5427f85e740d5b956942bb1c2727dac2935ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/601238
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

9 months agocmd/compile: add script testing facility for compiler use
Than McIntosh [Fri, 26 Jul 2024 12:58:29 +0000 (12:58 +0000)]
cmd/compile: add script testing facility for compiler use

Add support for running script tests as part of the compiler's suite
of tests, hooking in the script test engine packages recently moved
from cmd/go to cmd/internal. These script tests will use the test
binary itself as the compile tool for Go builds, and can also run the
C compiler if needed. New script test cases (*.txt files) should be
added to the directory cmd/compile/testdata/script.

Updates #68606.

Change-Id: I9b056a07024b0a72320a89ad734e4b4a51f1c10c
Reviewed-on: https://go-review.googlesource.com/c/go/+/601361
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>

9 months agocmd/link: add script testing facility for linker use
Than McIntosh [Thu, 25 Jul 2024 18:42:21 +0000 (18:42 +0000)]
cmd/link: add script testing facility for linker use

Add support for running script tests as part of the linker's suite of
tests, hooking in the script test engine packages recently moved from
cmd/go to cmd/internal. Linker script tests will use the test binary
itself as the linker for Go builds, and can also run the C compiler if
needed. New script test cases (*.txt files) should be added to the
directory cmd/link/testdata/script.

For demo purposes, this patch also adds a new "randlayout_option.txt"
script test that replicates the existing linker's TestRandLayout
testpoint in script form.

Updates #68606.

Change-Id: Icf26bf657850e39548d6ea819f2542fc68a3899b
Reviewed-on: https://go-review.googlesource.com/c/go/+/601360
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: David Chase <drchase@google.com>