1
0
mirror of https://github.com/golang/go synced 2024-09-30 16:08:36 -06:00
Commit Graph

54390 Commits

Author SHA1 Message Date
Cuong Manh Le
7ed6073da0 cmd/compile: update bottomUpVisitor.visit comments
Change-Id: I83a62b15c5946cfe61afc53c2c528aa3a62f815e
Reviewed-on: https://go-review.googlesource.com/c/go/+/429975
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-23 15:09:44 +00:00
Russ Cox
65deb9c3ce text/template/parse: fix confusion about markers near right delims
Fixes #52527.
Fixes #55336.

Change-Id: I8f5c521c693e74451a558788909e7e4ad1cc797a
Reviewed-on: https://go-review.googlesource.com/c/go/+/433036
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-23 15:03:43 +00:00
Joe Tsai
2551324cd0 path/filepath: optimize isReservedName
A linear search through a list of 22 strings takes ~80ns.
A quick check for 3-4 byte strings reduces this check to 2ns
for a vast majority of inputs.
In the event of a name match, the new logic is either just
as fast (for "CON") or 10x faster (for "LPT9").

Change-Id: I412fa73beebd7c81dc95f9ed12c35ca1d5d6baf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/433175
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-23 04:34:52 +00:00
Russ Cox
c2ede92a0d runtime/pprof: force use of 4-column profiles in pprof memprofile output
Pprof's converter from legacy text format to protobuf format
assumes that if the alloc and inuse stats are equal, then what's
really going on is that the program makes no distinction, and it
reads them as a two-column profile: objects and bytes.

Most of the time, some sampled object has been freed, and alloc != inuse.
In that case, pprof reads the profile as a four-column profile, with
alloc_objects, alloc_bytes, inuse_objects, inuse_bytes.

The 2-column form causes problems in a few ways. One is that if
you are reading the proto form and expect samples with the 4-column
names, they're not there. Another is that pprof's profile merger insists
on having the same number of columns and same names. This means
that

	pprof *.memprofile

works most of the time but fails if one of the memory profiles hit
the unlikely condition that alloc == inuse, since now its converted
form differs from the others.

Most programs should simply not be using this output form at all,
but cmd/compile and cmd/link still do, because x/tools/cmd/compilebench
reads some extra values from the text form that we have not yet added
to the proto form.

For the programs still writing this form, the easiest way to avoid the
column collapse issues is to ensure that the header never reports
alloc == inuse. The actual values in the header are ignored by pprof now,
except for the equality check (they should sum to the other values in the
file, so they are technically redundant). Because the actual values are not
used except for the equality check, we could hard-code different values
like 0 and 1, but just in case, to break as little as possible, this CL only
adjusts the values when they would otherwise be equal. In that case it
adds 1 to allocBytes. For most profiles, where alloc != inuse already, there
is no effect at all.

Change-Id: Ia563e402573d0f6eb81ae496645db27c08f9fe31
Reviewed-on: https://go-review.googlesource.com/c/go/+/432758
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Russ Cox <rsc@golang.org>
Run-TryBot: Russ Cox <rsc@golang.org>
2022-09-23 01:07:03 +00:00
Cherry Mui
ddaf68200a cmd/internal/objfile: read file/line information for ELF PIE binaries
For PIE binaries, the .gopclntab section doesn't have the usual
name, but .data.rel.ro.gopclntab. Try the relro version as well.
If both failed (e.g. for externally linked PIE binaries), try
runtime.pclntab symbol.

This should make cmd/objdump able to print the file/line
information for PIE binaries.

I attempted to do this a few years ago, but that wasn't enough,
because the pclntab itself contains dynamic relocations which are
not applied by the tool. As of Go 1.18 the pclntab is mostly
position independent and does not contain dynamic relocations, so
this should be possible now.

Fixes #17883.
Updates #46639.

Change-Id: I85dc3d50ffcc1a4b187a349479a6a162de1ab2b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/227483
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-22 23:46:28 +00:00
Cuong Manh Le
533cd80315 cmd/compile/internal/walk: remove reduceSlice
After CL 22425, there're two optimizations for slice expr which are
never applied during walk pass:

	s[i:len(s)]
        s[i:j:cap(s)]

The order pass have already rewritten len/cap expression to use autotmp,
thus the same safe expression check will never fire. The code can now be
simplified by moving the only case left from reduceSlice to walkSlice,
then removing reduceSlice entirely.

Passes toolstash-check.

Change-Id: Ia8cfb15c8e96c186a214c17b42d0fee51b0d3a1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/432695
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-22 21:36:44 +00:00
Bryan C. Mills
42a46206b9 cmd/go: omit VCS stamping during bootstrap
cmd/dist can't easily hard-code -buildvcs=false because not all
versions of cmd/go supported for bootstrapping recognize that flag.

However, we don't want to stamp the bootstrap binaries: the stamping
is redundant with the VERSION file writted during bootstrapping (which
is why it is normally omitted for standard-library packages and
commands), and it may also interfere with building the Go repo from a
source tarball or zip file.

Fixes #54852.

Change-Id: If223f094af137c4c202d6bf622619bd2da397ec4
Reviewed-on: https://go-review.googlesource.com/c/go/+/432435
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-22 18:55:06 +00:00
Kevin Chen
88a6a4d1ba cmd/compile/internal/syntax: remove TypeList syntax in comment
Change-Id: Ic4df6a8e198b069a9f3a28710fa40f29bd658b06
GitHub-Last-Rev: 51040eb5e5
GitHub-Pull-Request: golang/go#55345
Reviewed-on: https://go-review.googlesource.com/c/go/+/432795
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-09-22 18:43:28 +00:00
cuiweixie
ebaa5ff39e crypto/tls: convert Conn.activeCall to atomic type
Change-Id: I5b063070a17bdeed57e73bfb76125b94268b3bc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/426088
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2022-09-22 18:24:49 +00:00
Damien Neil
d7df872267 all: tidy std module
Change-Id: I7350a608a198073673fb9b7e9b91dae6f1c861b7
Reviewed-on: https://go-review.googlesource.com/c/go/+/432495
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Damien Neil <dneil@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
2022-09-21 20:59:10 +00:00
Damien Neil
4412230503 net/http: add tracing to TestTransportReuseConnection_Gzip_*
These tests are flaky; add some additional logging in hopes
it will aid in debugging.

For #53373

Change-Id: I971a2815f50932a9700ef8c2f684c5416951e6de
Reviewed-on: https://go-review.googlesource.com/c/go/+/432375
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-21 15:39:17 +00:00
Damien Neil
e246cf626d net/http: accept HEAD requests with a body
RFC 7231 permits HEAD requests to contain a body, although it does
state there are no defined semantics for payloads of HEAD requests
and that some servers may reject HEAD requests with a payload.

Accept HEAD requests with a body.

Fix a bug where a HEAD request with a chunked body would interpret
the body as the headers for the next request on the connection.

For #53960.

Change-Id: I83f7112fdedabd6d6291cd956151d718ee6942cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/418614
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-21 15:30:20 +00:00
Damien Neil
493ebc3590 all: update vendored golang.org/x/net
Pull in HTTP/2 fix needed for net/http test case.

	f8f703f979 http2: accept HEAD requests with a body

For #53960

Change-Id: I59bbd83977daced5ed21ec5345af8cdb607e532e
Reviewed-on: https://go-review.googlesource.com/c/go/+/432197
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-21 15:07:53 +00:00
Shulhan
68370187fa math: show value of integer constants in comments
Fixes #51282

Change-Id: I5b0d68165b727a427bd4a42663b2fa0070ced22f
Reviewed-on: https://go-review.googlesource.com/c/go/+/343990
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-21 14:07:39 +00:00
Cuong Manh Le
334984a92a spec: describe an edge case for slice expression of nil slice
Change-Id: I8c0e2b37e7e8cb4db6ad0b456fde7eb908ffbd04
Reviewed-on: https://go-review.googlesource.com/c/go/+/430836
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2022-09-21 14:06:17 +00:00
Cuong Manh Le
4b58b30778 spec: describe an edge case of slice-to-array conversions
Converting from nil slice to zero element array is ok, so explicitly
describe the behavior in the spec.

For #46505

Change-Id: I68f432deb6c21a7549bf7e870185fc62504b37f7
Reviewed-on: https://go-review.googlesource.com/c/go/+/430835
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-21 14:06:15 +00:00
Charlie Vieth
c70fd4b30a bytes, strings: add ASCII fast path to EqualFold
This commit adds an ASCII fast path to bytes/strings EqualFold that
roughly doubles performance when all characters are ASCII.

It also changes strings.EqualFold to use `for range` for the first
string since this is ~10% faster than using utf8.DecodeRuneInString for
both (see #31666).

Performance (similar results on arm64 and amd64):

name                        old time/op  new time/op  delta
EqualFold/Tests-10           238ns ± 0%   172ns ± 1%  -27.91%  (p=0.000 n=10+10)
EqualFold/ASCII-10          20.5ns ± 0%   9.7ns ± 0%  -52.73%  (p=0.000 n=10+10)
EqualFold/UnicodePrefix-10  86.5ns ± 0%  77.6ns ± 0%  -10.37%  (p=0.000 n=10+10)
EqualFold/UnicodeSuffix-10  86.8ns ± 2%  71.3ns ± 0%  -17.88%  (p=0.000 n=10+8)

Change-Id: I058f3f97a08dc04d65af895674d85420f920abe1
Reviewed-on: https://go-review.googlesource.com/c/go/+/425459
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-21 14:00:37 +00:00
Joe Tsai
9c916c7901 fmt: rely on utf8.AppendRune
This is both simpler and more performant.
The need for fmt.fmtC to manually check for utf8.MaxRune
is subtle to avoid overflow when converting uint64 to rune,
so a test case was added to exercise this edge case.

Change-Id: I0f2e6cce91dcd4cc6b88190c29807ca1c58e999d
Reviewed-on: https://go-review.googlesource.com/c/go/+/412335
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2022-09-21 13:54:31 +00:00
Ian Lance Taylor
d11c58eedb runtime: treat SI_TKILL like SI_USER on Linux
On Linux a signal sent using tgkill will have si_code == SI_TKILL,
not SI_USER. Treat the two cases the same. Add a Linux-specific test.

Change the test to use the C pause function rather than sleeping
for a second, as that achieves the same effect.

This is a roll forward of CL 431255 which was rolled back in CL 431715.
This new version skips flaky tests on more systems, and marks a new method
nosplit.

Change-Id: Ibf2d3e6fc43d63d0a71afa8fcca6a11fda03f291
Reviewed-on: https://go-review.googlesource.com/c/go/+/432136
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-21 01:56:24 +00:00
Keith Randall
fec83c8a7d Revert "cmd/compile: enable carry chain scheduling for arm64"
This reverts commit 4c414c7673.

Reason for revert: breaks ppc64 build (see issue 55254)

Change-Id: I096ffa0e6535d31d9dd4079b48bb201b20220d76
Reviewed-on: https://go-review.googlesource.com/c/go/+/432196
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2022-09-20 20:51:20 +00:00
Joe Tsai
bcd44b61d3 time: optimize Parse for []byte arguments
When one has a []byte on hand, but desires to call the Parse function,
the conversion from []byte to string would allocate.
This occurs frequently through UnmarshalText and UnmarshalJSON.

This changes it such that the input string never escapes from
any of the Parse functions. Together with the compiler optimization
where the compiler stack allocates any string smaller than 32B
this makes most valid inputs for Parse(layout, string(input))
not require an allocation for the input string.

This optimization works well for most RFC3339 timestamps.
All timestamps with second resolution
(e.g., 2000-01-01T00:00:00Z or 2000-01-01T00:00:00+23:59)
or timestamps with nanosecond resolution in UTC
(e.g., 2000-01-01T00:00:00.123456789Z)
are less than 32B and benefit from this optimization.
Unfortunately, nanosecond timestamps with non-UTC timezones
(e.g., 2000-01-01T00:00:00.123456789+23:59)
do not benefit since they are 35B long.

Previously, this was not possible since the input leaked
to the error and calls to FixedZone with the zone name,
which causes the prover to give up and heap copy the []byte.
We fix this by copying the input string in both cases.
The advantage of this change is that you can now call Parse
with a []byte without allocating (most of the times).
The detriment is that the timezone and error path has an extra allocation.
Handling of timezones were already expensive (3 allocations and 160B allocated),
so the additional cost of another string allocation is relatively minor.
We should optimize for the common case, rather than the exceptional case.

Performance:

    name                  old time/op  new time/op  delta
    ParseRFC3339UTCBytes  54.4ns ± 1%  40.3ns ± 1%  -25.91%  (p=0.000 n=9+10)

Now that parsing of RFC3339 has been heavily optimized in CL 425197,
the performance gains by this optimization becomes relatively more notable.

Related to CL 345488.

Change-Id: I2a8a9cd6354b3bd46c2f57818ed2646a2e485f36
Reviewed-on: https://go-review.googlesource.com/c/go/+/429862
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-20 16:21:31 +00:00
VRDighe
0bfa9f0435 spec: fix typo in a type parameter example
Fixes #54973

Change-Id: Ibad9dd124617a1bbc23abd17cbd6e9e9928e3ed9
GitHub-Last-Rev: 1c6affb967
GitHub-Pull-Request: golang/go#55021
Reviewed-on: https://go-review.googlesource.com/c/go/+/430316
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-20 15:50:36 +00:00
Tobias Klauser
1e96f42c2a syscall: drop compatibility for FreeBSD < 10.0
Change-Id: Idd8cee84215e61817a86915160c91242670798af
Reviewed-on: https://go-review.googlesource.com/c/go/+/431663
Reviewed-by: Yuval Pavel Zholkover <paulzhol@gmail.com>
Reviewed-by: Dmitri Goutnik <dgoutnik@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
2022-09-20 15:46:41 +00:00
Tobias Klauser
b5fcb35b31 cmd/cgo: mention //go:build line in godoc
Say "//go:build" instead of "// +build" in the package level godoc
comment.

Change-Id: I4700227a03197ffbe29e4de04d068b4c63bb5bf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/431856
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-09-20 15:46:03 +00:00
Erik Pellizzon
1eeb257b88 crypto: use encoding append functions
Replace custom append functions in the hash functions with the implementation of the encoding/binary package that do the same thing.
The binary bigendian functions are already used in other parts of the code in the crypto package.

Change-Id: I76d2dbe143fc72a3b4ac06be312caf72bd71378a
GitHub-Last-Rev: 1c6c68279e
GitHub-Pull-Request: golang/go#55085
Reviewed-on: https://go-review.googlesource.com/c/go/+/431035
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-20 02:58:09 +00:00
Andy Pan
f8c659b62f all: replace package ioutil with os and io in src
For #45557

Change-Id: I56824135d86452603dd4ed4bab0e24c201bb0683
Reviewed-on: https://go-review.googlesource.com/c/go/+/426257
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-20 02:13:02 +00:00
thinkofher
1e7e160d07 mime/multipart: use %w when wrapping error in NextPart
Use "%w" instead of "%v" as format verb for error value in the NextPart
method. This way it will be possible to use common go error utilities
from std library when parsing from custom io.Readers.

This issue was discovered during attempts to use
http.Request.ParseMultipartForm together with http.MaxBytesHandler.

Change-Id: Idb82510fb536b66b51ed1d943737c4828f07c2f2
GitHub-Last-Rev: 8bc49c945c
GitHub-Pull-Request: golang/go#55133
Reviewed-on: https://go-review.googlesource.com/c/go/+/431675
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2022-09-20 02:11:38 +00:00
eric fang
4c414c7673 cmd/compile: enable carry chain scheduling for arm64
This is a follow up of CL 393656 on arm64.

Benchmarks:
name                                  old time/op    new time/op    delta
ScalarMult/P256-8                       42.0µs ± 0%    42.0µs ± 0%   -0.13%  (p=0.032 n=5+5)
ScalarMult/P224-8                        135µs ± 0%      96µs ± 0%  -29.04%  (p=0.008 n=5+5)
ScalarMult/P384-8                        573µs ± 1%     355µs ± 0%  -38.05%  (p=0.008 n=5+5)
ScalarMult/P521-8                       1.50ms ± 4%    0.77ms ± 0%  -48.78%  (p=0.008 n=5+5)
MarshalUnmarshal/P256/Uncompressed-8     505ns ± 1%     506ns ± 0%     ~     (p=0.460 n=5+5)
MarshalUnmarshal/P256/Compressed-8      6.75µs ± 0%    6.73µs ± 0%   -0.27%  (p=0.016 n=5+5)
MarshalUnmarshal/P224/Uncompressed-8     927ns ± 0%     818ns ± 0%  -11.76%  (p=0.008 n=5+5)
MarshalUnmarshal/P224/Compressed-8       136µs ± 0%      96µs ± 0%  -29.58%  (p=0.008 n=5+5)
MarshalUnmarshal/P384/Uncompressed-8    1.77µs ± 0%    1.36µs ± 1%  -23.14%  (p=0.008 n=5+5)
MarshalUnmarshal/P384/Compressed-8      56.5µs ± 0%    31.9µs ± 0%  -43.59%  (p=0.016 n=5+4)
MarshalUnmarshal/P521/Uncompressed-8    2.91µs ± 0%    2.03µs ± 1%  -30.32%  (p=0.008 n=5+5)
MarshalUnmarshal/P521/Compressed-8       148µs ± 0%      68µs ± 1%  -54.28%  (p=0.008 n=5+5)

Change-Id: I33170360eb8279b998e3c559f7136717fe32e07d
Reviewed-on: https://go-review.googlesource.com/c/go/+/424907
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Eric Fang <eric.fang@arm.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-09-20 01:15:17 +00:00
eric fang
cf53990b18 cmd/compile: Add some CMP and CMN optimization rules on arm64
This CL adds some optimizaion rules:
1, Converts CMP to CMN, or vice versa, when comparing with a negative
number.
2, For equal and not equal comparisons, CMP can be converted to CMN in
some cases. In theory we could do the same optimization for LT, LE, GT
and GE, but need to account for overflow, this CL doesn't handle them.

There are no noticeable performance changes.

Change-Id: Ia49266c019ab7908ebc9510c2f02e121b1607869
Reviewed-on: https://go-review.googlesource.com/c/go/+/429795
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Eric Fang <eric.fang@arm.com>
2022-09-20 01:14:40 +00:00
cuiweixie
7db923fe56 net/http: convert Server.disableKeepAlives to atomic type
Change-Id: I87526520b519554ea344288cc0f0940d7b182e21
Reviewed-on: https://go-review.googlesource.com/c/go/+/428815
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2022-09-19 22:51:53 +00:00
Keith Randall
f1b7b2fc52 runtime: make mSpanStateBox accessors nosplit
get, at least, is called from typedmemclr which must not be interruptible.
These were previously nosplit by accident before CL 424395 (the only
call they had was an intrinsic, so they were leaf functions, so they had
no prologue). After CL 424395 they contained a call (in noinline builds),
thus had a prologue, thus had a suspension point.

I have no idea how we might test this.

This is another motivating use case for having a nosplitrec directive
in the runtime.

Fixes #55156
Fixes #54779
Fixes #54906
Fixes #54907

Change-Id: I851d733d71bda7172c4c96e027657e22b499ee00
Reviewed-on: https://go-review.googlesource.com/c/go/+/431919
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-19 21:57:04 +00:00
Rob Pike
2d741947d8 flag: test IsBoolFlag when creating the usage message
Although I can't think of any reason to do this, it is possible for
a user-defined flag to implement IsBoolFlag but return "false".
This is nuts because checking the interface is satisfied should
obviously be sufficient, but the documentation kinda implies it's
not. And if you try this, you'll discover that the usage message
ignores the return value even though the rest of the package plays
nice. Bother.

So we fix it, as the fix is trivial: call the method when creating
the usage message.

Fixes #53473

Change-Id: I1ac80a876ad5626eebfc5ef6cb972cd3007afaad
Reviewed-on: https://go-review.googlesource.com/c/go/+/431102
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-19 21:54:35 +00:00
Matthew Dempsky
d31f85009c cmd/compile: skip emitting dictionaries with missing method expressions
The nounified frontend currently tries to construct dictionaries that
correspond to invalid instantiations (i.e., instantiations T[X] where
X does not satisfy the constraints specified on T's type parameter).
As a consequence, we may fail to find method expressions needed by the
dictionary.

The real fix for this is to avoid creating those dictionaries in the
first place, because they should never actually be needed at runtime.
But that seems scary for a backport: we've repeatedly attempted to
backport generics fixes, which have fixed one issue but introduced
another.

This CL is a minimally invasive solution to #54225, which avoids the
ICE by instead skipping emitting the invalid dictionary. If the
dictionary ends up not being needed (which I believe will always be
the case), then the linker's reachability analysis will simply ignore
its absence.

Or worst case, if the dictionary *is* reachable somehow, we've simply
turned an ICE into a link-time missing symbol failure. That's not
great for user experience, but it seems like a small trade off to
avoid risking breaking any other currently working code.

Updates #54225.

Change-Id: Ic379696079f4729b1dd6a66994a58cca50281a84
Reviewed-on: https://go-review.googlesource.com/c/go/+/429655
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-19 19:37:22 +00:00
Joel Sing
7234c90352 cmd/compile: combine operations with immediate on riscv64
Replace two immediate operations with one, where possible.

Change-Id: Idc00e868155c9ca1d872aaaf70ea1f73e9eac4d6
Reviewed-on: https://go-review.googlesource.com/c/go/+/428497
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-19 19:01:45 +00:00
Joel Sing
83d94daec2 cmd/compile: avoid the use of XOR for boolean equality on riscv64
The use of SEQZ/SNEZ and SUB allows for other optimisations to be utilised,
particularly absorption into branch equality conditions.

Change-Id: I74e7d6a07a8decc1bdb651660c322bcc6eb6a10a
Reviewed-on: https://go-review.googlesource.com/c/go/+/428216
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-19 19:01:06 +00:00
Joel Sing
fd82718e06 internal/bytealg: correct alignment checks for compare/memequal on riscv64
On riscv64 we need 8 byte alignment for 8 byte loads - the existing check
was only ensuring 4 byte alignment, which potentially results in unaligned
loads being performed. Unaligned loads incur a significant performance penality
due to the resulting kernel traps and fix ups.

Adjust BenchmarkCompareBytesBigUnaligned so that this issue would have been
more readily visible.

Updates #50615

name                                 old time/op    new time/op      delta
CompareBytesBigUnaligned/offset=1-4    6.98ms _ 5%      6.84ms _ 3%       ~     (p=0.319 n=5+5)
CompareBytesBigUnaligned/offset=2-4    6.75ms _ 1%      6.99ms _ 4%       ~     (p=0.063 n=5+5)
CompareBytesBigUnaligned/offset=3-4    6.84ms _ 1%      6.74ms _ 1%     -1.48%  (p=0.003 n=5+5)
CompareBytesBigUnaligned/offset=4-4     146ms _ 1%         7ms _ 6%    -95.08%  (p=0.000 n=5+5)
CompareBytesBigUnaligned/offset=5-4    7.05ms _ 5%      6.75ms _ 1%       ~     (p=0.079 n=5+5)
CompareBytesBigUnaligned/offset=6-4    7.11ms _ 5%      6.89ms _ 5%       ~     (p=0.177 n=5+5)
CompareBytesBigUnaligned/offset=7-4    7.14ms _ 5%      6.91ms _ 6%       ~     (p=0.165 n=5+5)

name                                 old speed      new speed        delta
CompareBytesBigUnaligned/offset=1-4   150MB/s _ 5%     153MB/s _ 3%       ~     (p=0.336 n=5+5)
CompareBytesBigUnaligned/offset=2-4   155MB/s _ 1%     150MB/s _ 4%       ~     (p=0.058 n=5+5)
CompareBytesBigUnaligned/offset=3-4   153MB/s _ 1%     156MB/s _ 1%     +1.51%  (p=0.004 n=5+5)
CompareBytesBigUnaligned/offset=4-4  7.16MB/s _ 1%  145.79MB/s _ 6%  +1936.23%  (p=0.000 n=5+5)
CompareBytesBigUnaligned/offset=5-4   149MB/s _ 5%     155MB/s _ 1%       ~     (p=0.078 n=5+5)
CompareBytesBigUnaligned/offset=6-4   148MB/s _ 5%     152MB/s _ 5%       ~     (p=0.175 n=5+5)
CompareBytesBigUnaligned/offset=7-4   147MB/s _ 5%     152MB/s _ 6%       ~     (p=0.160 n=5+5)

Change-Id: I2c859e061919db482318ce63b85b808aa973a9ba
Reviewed-on: https://go-review.googlesource.com/c/go/+/431099
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-19 18:59:50 +00:00
Matthew Dempsky
ceffdc8545 cmd/compile: implement slice-to-array conversions
The conversion T(x) is implemented as *(*T)(x). Accordingly, runtime
panic messages for (*T)(x) are made more general.

Fixes #46505.

Change-Id: I76317c0878b6a5908299506d392eed50d7ef6523
Reviewed-on: https://go-review.googlesource.com/c/go/+/430415
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Jenny Rakoczy <jenny@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2022-09-19 18:58:26 +00:00
Matthew Dempsky
29153be757 go/internal/gcimporter: fix ureader.go handling of local defined types
In unified IR, local defined types are promoted to a global defined
type with a "vargen" suffix. These shouldn't actually be exposed to
go/types users, because they're only relevant within function bodies,
which go/types doesn't support importing.

Moreover, in the case of defined types that were declared within a
generic function, they can have ambient type parameters, which the
go/types importer doesn't know how to handle (because they shouldn't
be needed for that use case).

While here, prune the gcimporter_test.go skip list, because some of
the listed failures have actually been fixed and all of them are
specific to the Go 1.18 (nounified) frontend. They all work correctly
with GOEXPERIMENT=unified.

Fixes #55110.

Change-Id: I7dd8b86355d910dfed1d47edbad7695144c3f84d
Reviewed-on: https://go-review.googlesource.com/c/go/+/431495
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-19 18:47:11 +00:00
Matthew Dempsky
38cecb2290 test: add regress test for issue 55101
This test case already works with GOEXPERIMENT=unified, and it never
worked with Go 1.18 or Go 1.19. So this CL simply adds a regress test
to make sure it continues working.

Fixes #55101.

Change-Id: I7e06bfdc136ce124f65cdcf02d20a1050b841d42
Reviewed-on: https://go-review.googlesource.com/c/go/+/431455
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-19 18:47:00 +00:00
Tobias Klauser
d74bf73be0 os: use wait6 to avoid wait/kill race on netbsd
Resend of CL 315281 which was partially reverted by CL 354249 after the
original CL was suspected to cause test failures as reported in #48789.
It seems that both wait4 and wait6 lead to that particular deadlock, so
let's use wait6. That way we at least don't hit #13987 on netbsd.

Updates #13987
For #48789
For #50138

Change-Id: Iadc4a771217b7e9e821502e89afa07036e0dcb6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/431855
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-19 18:44:37 +00:00
Keith Randall
e283473ebb cmd/compile: avoid using destination pointer base type in memmove optimization
The type of the source and destination of a memmove call isn't
always accurate. It will always be a pointer (or an unsafe.Pointer), but
the base type might not be accurate. This comes about because multiple
copies of a pointer with different base types are coalesced into a single value.

In the failing example, the IData selector of the input argument is a
*[32]byte in one branch of the type switch, and a *[]byte in the other branch.
During the expand_calls pass both IDatas become just copies of the input
register. Those copies are deduped and an arbitrary one wins (in this case,
*[]byte is the unfortunate winner).

Generally an op v can rely on v.Type during rewrite rules. But relying
on v.Args[i].Type is discouraged.

Fixes #55122

Change-Id: I348fd9accf2058a87cd191eec01d39cda612f120
Reviewed-on: https://go-review.googlesource.com/c/go/+/431496
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
2022-09-19 18:21:06 +00:00
cuiweixie
0053ec452d reflect: rtype.MethodByName using binary search
Change-Id: If36e9fd7d6b1993ca2d0d382e7fa52212170c798
Reviewed-on: https://go-review.googlesource.com/c/go/+/425481
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-19 17:55:13 +00:00
Damien Neil
e7312b1005 net/http: correctly test for leading header spaces in TestReadRequest_Bad
TestReadRequest_Bad's tests for leading whitespace in the first header
were also exercising the test verifying that a HEAD request has no
Content-Length. Also, the test intended to test a leading tab was
actually testing for a leading \t (literal backslash, literal t).

Change-Id: I05b46d05851b49bf75f1d1257c421b953b66ea9c
Reviewed-on: https://go-review.googlesource.com/c/go/+/428134
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2022-09-19 17:14:09 +00:00
Roger Peppe
d8e6ed3262 time: implement Compare method
Fixes #50770.

Change-Id: If0104883bb409ec85827fa5b570f68099ad4fd1d
Reviewed-on: https://go-review.googlesource.com/c/go/+/382734
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: hopehook <hopehook@golangcn.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-09-19 17:10:49 +00:00
Zeke Lu
b6d5831caa debug/elf: validate shstrndx
Changes:

1. When e_shstrndx holds the value SHN_UNDEF (0), the file has no section
name string table. In this case, do not try to set section names .
2. e_shstrndx should point to an SHT_STRTAB section. If it does not, returns
an error.

Reference:
https://refspecs.linuxfoundation.org/elf/gabi4+/ch4.eheader.html

Updates #54967.

Change-Id: Ic8f228061d996fd7845dfa630719a1ba12d2bb60
GitHub-Last-Rev: aeb70ca8a0
GitHub-Pull-Request: golang/go#55001
Reviewed-on: https://go-review.googlesource.com/c/go/+/430155
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-19 17:01:22 +00:00
Michael Matloob
73c38f226e cmd/go: clear GOPATH from build context when importing from module
In module mode, we shouldn't handle packages under GOPATH any
differently from other packages. Clear GOPATH from the build context
before Importing to ensure that.

Fixes #37015.

Change-Id: I0203e25013716bca346fd4a67d80f1d05bbaea77
Reviewed-on: https://go-review.googlesource.com/c/go/+/412476
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Matloob <matloob@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-09-19 17:01:15 +00:00
Sasha Melentyev
0857633f8b runtime/pprof: set labelMap length
Change-Id: If09094e72161f2c5da9102706781524e32f87782
GitHub-Last-Rev: 89949bc6ee
GitHub-Pull-Request: golang/go#54855
Reviewed-on: https://go-review.googlesource.com/c/go/+/428234
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-19 16:58:39 +00:00
hopehook
c91b1009d5 misc/cgo: replace ioutil.ReadFile with os.ReadFile
For #45557

Change-Id: I25be5b437fa1c9b0e0c46802a9b37efc2d47bca0
Reviewed-on: https://go-review.googlesource.com/c/go/+/431097
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-19 16:55:59 +00:00
hopehook
351037d16c misc/cgo: replace os.SEEK_SET with io.SeekStart
Since os.SEEK_SET was deprecated, use io.SeekStart instead.

Change-Id: I11ae496b071ab35412403ff73e52f3da73d5b120
Reviewed-on: https://go-review.googlesource.com/c/go/+/431096
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: hopehook <hopehook@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-09-19 16:55:26 +00:00
Tobias Klauser
f4becf15bd internal/syscall/unix: reuse existing {Fstat,Open,Unlink}at on freebsd
Change-Id: I517e75faca18bf0fdcd4e6c837f50f824aa6348c
Reviewed-on: https://go-review.googlesource.com/c/go/+/431236
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-19 15:51:18 +00:00