1
0
mirror of https://github.com/golang/go synced 2024-11-24 02:20:18 -07:00
Commit Graph

55639 Commits

Author SHA1 Message Date
Joe Tsai
21ff6704bc encoding/json: use append for Compact and Indent
This is part of the effort to reduce direct reliance on bytes.Buffer
so that we can use a buffer with better pooling characteristics.

Avoid direct use of bytes.Buffer in Compact and Indent and
instead modify the logic to rely only on append.
This avoids reliance on the bytes.Buffer.Truncate method,
which makes switching to a custom buffer implementation easier.

Performance:

	name                old time/op    new time/op    delta
	EncodeMarshaler    25.5ns ± 8%    25.7ns ± 9%   ~     (p=0.724 n=10+10)

	name                old alloc/op   new alloc/op   delta
	EncodeMarshaler     4.00B ± 0%     4.00B ± 0%   ~     (all equal)

	name                old allocs/op  new allocs/op  delta
	EncodeMarshaler      1.00 ± 0%      1.00 ± 0%   ~     (all equal)

Updates #27735

Change-Id: I8cded03fab7651d43b5a238ee721f3472530868e
Reviewed-on: https://go-review.googlesource.com/c/go/+/469555
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-02-24 19:00:14 +00:00
Joel Sing
e7c7f33263 cmd/internal/obj/arm64: factor out code generation for addition of 12 bit immediates
Factor out and simplify code that generates the addition of a 12 bit immediate
(the addition of a negative value is still handled via subtraction). This also
fixes the mishandling of the case where v is 0.

Change-Id: I6040f33d2fec87b772272531b3bf02390ae7f200
Reviewed-on: https://go-review.googlesource.com/c/go/+/461141
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eric Fang <eric.fang@arm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-02-24 17:53:36 +00:00
qmuntal
f76fc28c6b runtime: use explicit NOFRAME on netbsd/amd64
This CL marks some netbsd assembly functions as NOFRAME to avoid
relying on the implicit amd64 NOFRAME heuristic, where NOSPLIT functions
without stack were also marked as NOFRAME.

While here, and thanks to CL 466355, `asm_netbsd_amd64.s` can
be deleted in favor of `asm9_unix2_amd64.s`, which makes better
use of the frame pointer.

Updates #58378

Change-Id: Iff554b664ec25f2bb6ec198c0f684590b359c383
Reviewed-on: https://go-review.googlesource.com/c/go/+/466396
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
2023-02-24 16:59:50 +00:00
Mateusz Poliwczak
b87c8c3523 net/url: simplify values Get
Checking if v == nil is unnecessary, nil map always return the zero value of the value type.

Change-Id: I9c5499bc7db72c4c62e02013ba7f9a6ee4795c09
GitHub-Last-Rev: 03fc2330e2
GitHub-Pull-Request: golang/go#58662
Reviewed-on: https://go-review.googlesource.com/c/go/+/470736
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-02-24 12:38:08 +00:00
qmuntal
ddb423a7da runtime: use explicit NOFRAME on freebsd/amd64
This CL marks some freebsd assembly functions as NOFRAME to avoid
relying on the implicit amd64 NOFRAME heuristic, where NOSPLIT functions
without stack were also marked as NOFRAME.

Updates #58378

Change-Id: Ibd00748946f1137e165293df7da73278cb673bbd
Reviewed-on: https://go-review.googlesource.com/c/go/+/466395
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
2023-02-24 07:13:54 +00:00
Keith Randall
21d82e6ac8 cmd/compile: batch write barrier calls
Have the write barrier call return a pointer to a buffer into which
the generated code records pointers that need write barrier treatment.

Change-Id: I7871764298e0aa1513de417010c8d46b296b199e
Reviewed-on: https://go-review.googlesource.com/c/go/+/447781
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
TryBot-Bypass: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-02-24 00:21:13 +00:00
Alexander Yastrebov
f684f3dc43 image/jpeg: return io.ErrUnexpectedEOF on truncated data
Decoder calls fill from readFull, ignore and readByte and
readByte did not check returned io.EOF.

This change moves io.EOF translation inside fill.

name                 old speed      new speed      delta
DecodeBaseline-8     67.4MB/s ± 0%  67.3MB/s ± 0%  -0.20%  (p=0.000 n=16+19)
DecodeProgressive-8  43.7MB/s ± 0%  43.6MB/s ± 0%  -0.06%  (p=0.013 n=17+19)

Fixes #56724

Change-Id: Ia0d5cc561f3c2050e25ec3f2b5e6866c3b4941c7
GitHub-Last-Rev: 470154373b
GitHub-Pull-Request: golang/go#56863
Reviewed-on: https://go-review.googlesource.com/c/go/+/452335
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Nigel Tao <nigeltao@golang.org>
Reviewed-by: Nigel Tao (INACTIVE; USE @golang.org INSTEAD) <nigeltao@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-24 00:03:48 +00:00
Adin Scannell
52fea4b3d9 runtime: fix linkname signature for godebug
This signature uses the wrong type for the passed function, which
will be saved in the internal runtime map. Since the functions are
likely compatible (uint64 return versus int64), this may work but
should generally be fixed.

This is other instance of #58440.

Change-Id: Ied82e554745ef72eefeb5be540605809ffa06533
Reviewed-on: https://go-review.googlesource.com/c/go/+/470915
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
2023-02-23 23:09:10 +00:00
Paul E. Murphy
f98dd29910 cmd/compile: rework unbounded shift lowering on PPC64
This reduces unbounded shift latency by one cycle, and may
generate less instructions in some cases.

When there is a choice whether to use doubleword or word shifts, use
doubleword shifts. Doubleword shifts have fewer hardware scheduling
restrictions across P8/P9/P10.

Likewise, rework the shift sequence to allow the compare/shift/overshift
values to compute in parallel, then choose the correct value.

Some ANDCCconst rules also need reworked to ensure they simplify when
used for their flag value. This commonly occurs when prove fails to
identify a bounded shift (e.g foo32<<uint(x&31)).

Change-Id: Ifc6ff4a865d68675e57745056db414b0eb6f2d34
Reviewed-on: https://go-review.googlesource.com/c/go/+/442597
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-02-23 22:26:39 +00:00
Michael Pratt
f60a2a9c94 cmd/compile: adjust inlined DW_AT_call_line by //line
insertInlCall mistakenly uses the absolute line number of the call
rather than the relative line number (adjusted by //line). Switch to the
correct line number.

The call filename was already correct.

Fixes #58648

Change-Id: Id8d1848895233e972d8cfe9c5789a88e62d06556
Reviewed-on: https://go-review.googlesource.com/c/go/+/470876
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-02-23 22:08:33 +00:00
Michael Pratt
778a60c103 cmd/link/internal/ld: split TestInlinedRoutineRecords
A later CL will add additional test cases for CallFile and CallLine with
a //line directive. The parameter/variable checks have nothing to do
with line numbers and will only serve to make the test more difficult to
follow, so split this single mega-test into two: one for testing
file/line and the other for testing parameters/variables.

There are a few additional minor changes:

1. A missing AttrName is now an error.
2. Check added for AttrCallLine, which was previously untested.

For #58648.

Change-Id: I35e75ead766bcf910c58eb20541769349841f2b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/470875
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-02-23 21:40:21 +00:00
Than McIntosh
20da76da91 Revert "cmd/link: default to external linking with cgo std packages"
This reverts CL 470298.

Reason for revert: causes issues with Google internal testing.

Updates #58619.
Updates #58620.

Change-Id: Ic6601820ba8758ef96b71e32d9ffc549c36d5c98
Reviewed-on: https://go-review.googlesource.com/c/go/+/470835
Reviewed-by: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Than McIntosh <thanm@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-02-23 20:44:29 +00:00
Lynn Boger
ebe49f98c8 cmd/compile: inline constant sized memclrNoHeapPointers calls on PPC64
Update the function isInlinableMemclr for ppc64 and ppc64le
to enable inlining for the constant sized cases < 512.

Larger cases can use dcbz which performs better but requires
alignment checking so it is best to continue using memclrNoHeapPointers
for those cases.

Results on p10:

MemclrKnownSize1         2.07ns ± 0%     0.57ns ± 0%   -72.59%
MemclrKnownSize2         2.56ns ± 5%     0.57ns ± 0%   -77.82%
MemclrKnownSize4         5.15ns ± 0%     0.57ns ± 0%   -89.00%
MemclrKnownSize8         2.23ns ± 0%     0.57ns ± 0%   -74.57%
MemclrKnownSize16        2.23ns ± 0%     0.50ns ± 0%   -77.74%
MemclrKnownSize32        2.28ns ± 0%     0.56ns ± 0%   -75.28%
MemclrKnownSize64        2.49ns ± 0%     0.72ns ± 0%   -70.95%
MemclrKnownSize112       2.97ns ± 2%     1.14ns ± 0%   -61.72%
MemclrKnownSize128       4.64ns ± 6%     2.45ns ± 1%   -47.17%
MemclrKnownSize192       5.45ns ± 5%     2.79ns ± 0%   -48.87%
MemclrKnownSize248       4.51ns ± 0%     2.83ns ± 0%   -37.12%
MemclrKnownSize256       6.34ns ± 1%     3.58ns ± 0%   -43.53%
MemclrKnownSize512       3.64ns ± 0%     3.64ns ± 0%    -0.03%
MemclrKnownSize1024      4.73ns ± 0%     4.73ns ± 0%    +0.01%
MemclrKnownSize4096      17.1ns ± 0%     17.1ns ± 0%    +0.07%
MemclrKnownSize512KiB    2.12µs ± 0%     2.12µs ± 0%      ~     (all equal)

Change-Id: If1abf5749f4802c64523a41fe0058bd144d0ea46
Reviewed-on: https://go-review.googlesource.com/c/go/+/464340
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Jakub Ciolek <jakub@ciolek.dev>
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-02-23 18:57:27 +00:00
Russ Cox
612c00bf4d cmd/dist: default to GOARM=7 on all non-arm systems
If you run make.bash on an arm system without GOARM set,
we sniff the local system to find the maximum default GOARM
that will actually work on that system. That's fine, and we can
keep doing that.

But the story for cross-compiling is weirder.
If we build a windows/amd64 toolchain and then use it to
cross-compile linux/arm binaries, we get GOARM=7 binaries.
Do the same on a linux/amd64 system and you get GOARM=5 binaries.
This clearly makes no sense, and worse it makes the builds
non-reproducible in a subtle way.

This CL simplifies the logic and improves reproducibility by
defaulting to GOARM=7 any time we wouldn't sniff the local system.

On go.dev/dl we serve a linux-armv6l distribution with a default GOARM=6.
That is built by setting GOARM=6 during make.bash, so it is unaffected
by this CL and will continue to be GOARM=6.

For #24904.

Change-Id: I4331709876d5948fd33ec6e4a7b18b3cef12f240
Reviewed-on: https://go-review.googlesource.com/c/go/+/470695
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-23 17:50:29 +00:00
qmuntal
516753278d runtime: use explicit NOFRAME on dragonfly/amd64
This CL marks some dragonfly assembly functions as NOFRAME to avoid
relying on the implicit amd64 NOFRAME heuristic, where NOSPLIT functions
without stack were also marked as NOFRAME.

Updates #58378

Change-Id: I832a1a78d68a49f11df3b03fa9d50d4796bcac03
Reviewed-on: https://go-review.googlesource.com/c/go/+/466355
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-02-23 16:32:43 +00:00
Frank Viernau
c0ac33c006 cmd/go: don't compute Embed fields if they're not needed
If the user provides the -json flag to explicitly specify fields, but doesn't specify any *Embed* field, skip computing the embed fields.

This enhances the initial implementation of #29666.

Change-Id: I60e86fb25a445689aecbcc7f3f3f88e0f37a0fc5
GitHub-Last-Rev: 2795c195bf
GitHub-Pull-Request: golang/go#58522
Reviewed-on: https://go-review.googlesource.com/c/go/+/468075
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2023-02-23 15:24:16 +00:00
Dmitri Goutnik
4c5d6edeb2 syscall: add ptracePtr that accepts pointer arg as unsafe.Pointer
The existing ptrace wrapper accepts pointer argument as an uintptr which
often points to the memory allocated in Go. This violates unsafe.Pointer safety
rules.

Fixes #58387

Change-Id: Iab12122c495953f94ea00c2a61654a818a464205
Reviewed-on: https://go-review.googlesource.com/c/go/+/470299
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Dmitri Goutnik <dgoutnik@gmail.com>
2023-02-23 11:28:51 +00:00
Russ Cox
6af9635fb8 cmd/go: enable vet directive analyzer during 'go test'
For #56986, run the new directive analyzer during 'go test',
to diagnose problems that would otherwise be missed,
like //go:debug appearing in the wrong place in a file
or in the wrong files.

Change-Id: I1ac230c3c67e58b5e584128e0ec6ff482cb225f9
Reviewed-on: https://go-review.googlesource.com/c/go/+/464135
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
2023-02-23 10:55:24 +00:00
Russ Cox
d54aeeeea3 cmd/go: set default GODEBUG for main packages
For #56986, change the go command to compute and set the
default GODEBUG settings for each main package, based on
the work module's go version and the //go:debug lines in the
main package.

Change-Id: I2118cf0ae6d981138138661e02120c05af648872
Reviewed-on: https://go-review.googlesource.com/c/go/+/453605
Run-TryBot: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-23 10:55:13 +00:00
Russ Cox
bd8ec78b08 cmd/go, go/build: parse directives in file headers
For #56986, go/build needs to report up to cmd/go
about //go:debug lines found in the source code.
Rather than make a special case for //go:debug,
this change gathers all top-level directives above the
package line and includes them in the result.

The go command's module index must match go/build,
so this CL contains the code to update the index as well.

A future CL will use the //go:debug lines to prepare the default
GODEBUG settings, as well as rejecting such lines in non-main
packages.

Change-Id: I66ab8dc72f9cd65c503b10b744367caca233f8a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/453603
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Russ Cox <rsc@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-23 10:10:21 +00:00
Joel Sing
f07fafacef cmd/internal/obj/arm64: use more appropriate types for olsr12u
This allows for a large number of casts to be removed at call sites.

Change-Id: Id929f6c7155b0b59a2bcdf43144de95a007b8a48
Reviewed-on: https://go-review.googlesource.com/c/go/+/461139
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Eric Fang <eric.fang@arm.com>
2023-02-23 06:10:33 +00:00
Joel Sing
ecff9c9335 cmd/internal/obj/arm64: invert SP check
Check for REGSP use before checking for invalid instructions. This simplifies
the code and avoids duplicated op generation.

Change-Id: I302e3b54a29742f2c48024b25162200f5966cfaa
Reviewed-on: https://go-review.googlesource.com/c/go/+/461138
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eric Fang <eric.fang@arm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-02-23 06:09:10 +00:00
Joel Sing
8f3a13de9a cmd/internal/obj/arm64: use obj.REG_NONE where appropriate
When referring to an unspecified register, use obj.REG_NONE rather than 0.
This has the same result but is more readable.

Change-Id: I56b541a3abc3c2c0e3ce1de21a624da0b21c485a
Reviewed-on: https://go-review.googlesource.com/c/go/+/461137
Reviewed-by: Eric Fang <eric.fang@arm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-02-23 06:08:28 +00:00
Joel Sing
8aa0175368 cmd/internal/obj/arm64: remove bogus omovlit return value check
omovlit never returns zero, so it does not make any sense to check for that.
Additionally, no other call site does this.

Change-Id: I5769dcdb557bed4ec4d727abe0869a1549fcf04c
Reviewed-on: https://go-review.googlesource.com/c/go/+/461136
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Eric Fang <eric.fang@arm.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-23 06:08:12 +00:00
Joel Sing
71c02bed67 cmd/internal/obj/arm64: remove spurious assignments with OR
Use = rather than |= when assigning to an op variable.

Change-Id: I142c9fb3aa6f4b48875710100c05ab640e21933a
Reviewed-on: https://go-review.googlesource.com/c/go/+/461135
Reviewed-by: Eric Fang <eric.fang@arm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-02-23 06:07:52 +00:00
Ian Lance Taylor
e7cfcda67d debug/macho: don't crash if dynamic symtab with no symtab
No test case because the problem can only happen for invalid data. Let
the fuzzer find cases like this.

For #47653
Fixes #58642

Change-Id: I19fee0dc9bd6239b520c15182b8f1e57bb0049bb
Reviewed-on: https://go-review.googlesource.com/c/go/+/470397
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-02-22 23:19:29 +00:00
Cherry Mui
06b67591e7 cmd/link: default to external linking with cgo std packages
Previously, when a program depends on cgo packages in the standard
library (e.g. net, os/user) but not otherwise use cgo, we default
to internal linking mode. As we shipped pre-built cgo-using packages
in Go distributions, we don't require a C compiler to build those
packages. Then, by using internal linking we can link programs
using those packages without requiring a C toolchain.

As of Go 1.20, we stopped shipping those pre-built packages. If a
user doesn't have a C toolchain, they will use the non-cgo version
of the package. If they have a C toolchain, they can get cgo-using
packages but they can link with the external linker as well. So
there is no strong need to be able to link the cgo version of the
packages without a C toolchain. This CL makes it default to
external linking mode.

Fixes #58619.
Fixes #58620.

Change-Id: I62d3744c2b82ce734813c0e303e417d85dd29868
Reviewed-on: https://go-review.googlesource.com/c/go/+/470298
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-02-22 21:40:45 +00:00
qmuntal
521d2614df runtime: use explicit NOFRAME on linux/amd64
This CL marks some linux assembly functions as NOFRAME to avoid relying
on the implicit amd64 NOFRAME heuristic, where NOSPLIT functions
without stack were also marked as NOFRAME.

Updates #58378

Change-Id: I7792cff4f6e539bfa56c02868f2965088ca1975a
Reviewed-on: https://go-review.googlesource.com/c/go/+/466316
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-22 21:35:26 +00:00
Damien Neil
133e0bca0b net/http: remove warning when parsing a query containing a semicolon
It's been years since the behavior here was changed, and there's
little point in continuing to warn users of it.

Fixes #49399

Change-Id: I95f64ca14cacb64ebe78296593b1cc3d837e6b77
Reviewed-on: https://go-review.googlesource.com/c/go/+/470315
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-02-22 21:08:59 +00:00
Cherry Mui
4304529a16 cmd/link: make Exitf panic under -h
If the -h flag is specified, currently it makes Errorf panic, but
not Exitf. Do so for Exitf as well.

Change-Id: I3e8d8899fd439f7299be3f9e9a63993b04852a93
Reviewed-on: https://go-review.googlesource.com/c/go/+/470297
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-02-22 20:39:11 +00:00
Harald Böhm
e0e2685c80 syscall: add jail support to ForkExec on FreeBSD
Introduce a new SysProcAttr member called Jail on FreeBSD. This allows
supplying an existing jail's ID to which the child process is attached
before calling the exec system call.

Fixes #46259

Change-Id: Ie282e5b83429131f9a9e1e27cfcb3bcc995d1d4d
Reviewed-on: https://go-review.googlesource.com/c/go/+/458335
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Goutnik <dgoutnik@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Samuel Karp <samuelkarp@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-02-22 20:38:48 +00:00
Archana R
e6faa375b4 runtime: improve memclr on ppc64x/power10
Rewrite memclr asm function to use the new power10 instruction stxvl
or the store vector with length which can specify the number of bytes
to be stored in a register, thereby avoiding loops to store the tail
end bytes.
On power9 and power8 the code remains unchanged.
The performance for all sizes<16 improve on power10 with this change.

name          old time/op    new time/op     delta
Memclr/1        2.59ns ± 1%     2.80ns ± 9%      ~
Memclr/2        2.77ns ± 0%     2.90ns ± 8%      ~
Memclr/3        3.70ns ± 1%     3.00ns ± 1%   -19.02%
Memclr/4        4.56ns ± 5%     2.98ns ± 1%   -34.56%
Memclr/5        10.1ns ± 8%      2.9ns ± 4%   -70.82%
Memclr/6        6.99ns ± 4%     2.84ns ± 9%   -59.40%
Memclr/7        8.66ns ± 5%     2.92ns ± 4%   -66.27%
Memclr/8        2.75ns ± 1%     2.75ns ± 0%      ~
Memclr/9        3.43ns ± 1%     2.75ns ± 0%   -19.78%
Memclr/10       3.30ns ± 0%     2.77ns ± 0%   -15.81%
Memclr/12       5.09ns ± 0%     2.78ns ± 0%   -45.49%
Memclr/15       9.79ns ± 0%     2.78ns ± 0%   -71.64%
Memclr/16       2.65ns ± 1%     2.77ns ± 0%    +4.77%
GoMemclr/1      2.46ns ± 3%     2.46ns ± 3%      ~
GoMemclr/2      2.91ns ± 0%     2.46ns ± 1%   -15.38%
GoMemclr/3      4.85ns ± 6%     2.45ns ± 1%   -49.50%
GoMemclr/4      5.44ns ± 5%     2.47ns ± 1%   -54.63%
GoMemclr/5      6.48ns ± 0%     2.45ns ± 1%   -62.20%
GoMemclr/6      9.33ns ±20%     2.45ns ± 1%   -73.76%
GoMemclr/7      8.79ns ± 2%     2.46ns ± 1%   -72.03%
GoMemclr/8      2.91ns ± 0%     2.84ns ± 0%    -2.35%
GoMemclr/9      5.04ns ± 0%     2.84ns ± 0%   -43.67%
GoMemclr/10     5.17ns ± 1%     2.84ns ± 0%   -44.99%
GoMemclr/12     6.22ns ± 0%     2.84ns ± 0%   -54.41%
GoMemclr/15     10.1ns ± 0%      2.8ns ± 0%   -72.04%
GoMemclr/16     2.90ns ± 0%     2.92ns ± 0%    +0.83%

Change-Id: I2b7e1a9ceafba11c57c04a2e8cbd12b5ac87ec9b
Reviewed-on: https://go-review.googlesource.com/c/go/+/467635
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>
2023-02-22 18:53:31 +00:00
Than McIntosh
cad872f75a doc: start draft Go 1.21 release notes
This initial release notes template is based on previous releases.

For #58645.

Change-Id: I8bae25d6dd9778a69963b8b4903a6dc1c180e15f
Reviewed-on: https://go-review.googlesource.com/c/go/+/470296
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-02-22 18:53:00 +00:00
Ian Lance Taylor
494aeba5bb Revert "internal/poll: drop redundant ENOSYS in CopyFileRange"
This reverts CL 428555.

Reason for revert: It appears that even a newer kernel can get
ENOSYS from copy_file_range.

Fixes #58592

Change-Id: Ib8dd1be61544f54bf652a99dc0b449109f8f50ed
Reviewed-on: https://go-review.googlesource.com/c/go/+/470016
Reviewed-by: Andy Pan <panjf2000@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2023-02-22 17:34:03 +00:00
Hossein Zolfi
81316ff50a testing: add -fullpath to go test
When -test.fullpath flag is provided to go test,
go test displays the full file names in error messages.

Fixes #37708

Change-Id: I6096e75ed816fd42205810f20624e495047a73a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/463837
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2023-02-22 16:42:04 +00:00
rohnnyjoy
c17f8057b0 cmd/go: return an early error from queryImport when in vendor mode
The current behavior for -mod=vendor is to let QueryPackages run and
fail from queryImport: "cannot query module due to -mod=vendor".
This has the side effect of allowing "go: finding module for package"
to be printed to stderr. Instead of this, return an error before
running QueryPackages.

Fixes #58417

Change-Id: Idc0ed33d1dd1bd185348da3a18ba8eb2dd225909
GitHub-Last-Rev: dd09deec0a
GitHub-Pull-Request: golang/go#58471
Reviewed-on: https://go-review.googlesource.com/c/go/+/467517
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-02-22 16:11:33 +00:00
Joel Sing
4a1829b65a cmd/link: add internal linking support for calling SDYNIMPORT on mips64
Add internal linking support for calling SDYNIMPORT symbols on mips64. This adds
code to generate appropriate PLT and GOT entries, along with the various dynamic
entries needed for the dynamic loader.

Updates #36435, #46178

Change-Id: I783e0d028510ca2bca82bcbc745f2375770813fe
Reviewed-on: https://go-review.googlesource.com/c/go/+/415815
Reviewed-by: Rong Zhang <rongrong@oss.cipunited.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-02-22 14:55:07 +00:00
Robert Griesemer
5e6ccd1223 go/types, types2: point out type parameters with predeclared names in errors
If a type parameter has the same name as a predeclared type, error
messages can be very confusing. In these rare cases, explicitly
point out where the type parameter is declared (types2) or that it
is a type parameter (go/types).

(We can't point out where the type parameter is declared in go/types
because we don't have access to the file set in the type writer at
the moment.)

Fixes #58611.

Change-Id: I5c150c2b0afae5fad320821e7e5935090dc2ef4c
Reviewed-on: https://go-review.googlesource.com/c/go/+/470075
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-02-22 00:40:19 +00:00
Robert Griesemer
22a65ba7b7 go/types, types2: avoid unused variable error in invalid x.(type) expression
This change removes one of the two follow-on errors in the issue below.

For #58612.

Change-Id: If1eec5031e524bad33caa4a914f52e6a1e273b60
Reviewed-on: https://go-review.googlesource.com/c/go/+/470015
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2023-02-22 00:37:45 +00:00
Dmitri Goutnik
feb355c427 syscall: introduce IoctlPtr for exec_unix tests
Avoid passing Go pointers as uintptr in exec_unix_test.go by introducing
syscall.IoctlPtr() which accepts arg as unsafe.Pointer.

For #44834
Fixes #58609

Change-Id: I6d0ded023e5f3c9989783aee7075bb88100d9ec2
Reviewed-on: https://go-review.googlesource.com/c/go/+/469675
Run-TryBot: Dmitri Goutnik <dgoutnik@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-21 23:33:24 +00:00
Ian Lance Taylor
ed33ae10a0 debug/macho: use saferio to read symbol table strings
No test case because the problem can only happen for invalid data. Let
the fuzzer find cases like this.

For #47653
Fixes #58603

Change-Id: I67fc45365c1a5b0b4b381f541bf2fee8ce8ddc3a
Reviewed-on: https://go-review.googlesource.com/c/go/+/469895
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-02-21 23:27:49 +00:00
cui fliter
dd87e33d88 os: use testenv.Command instead of exec.Command in tests
testenv.Command sets a default timeout based on the test's deadline
and sends SIGQUIT (where supported) in case of a hang.

Change-Id: I84d469d12ca1f39175b713ca41e7cd2202d11d96
Reviewed-on: https://go-review.googlesource.com/c/go/+/451895
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-02-21 23:07:55 +00:00
Damien Neil
34e701ece2 path/filepath: document that Clean does not change Windows volume names
Fixes #58348

Change-Id: I4aac0285f11618a45aca6b13c2da2a10a803a9b5
Reviewed-on: https://go-review.googlesource.com/c/go/+/469955
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
2023-02-21 20:38:30 +00:00
Wayne Zuo
481a6beba5 cmd/internal/obj/riscv: optimize loading large immediate with trailing zeros
This CL can avoid a memory load for some immediate.
Reduce binary size slightly.

compilecmp HEAD~1 -> HEAD
HEAD~1 (9860faa512): math/big: remove underscores from Binomial docs
HEAD (ac85312f10): cmd/internal/obj/riscv: optimize loading large immediate with many trailing zeros
platform: linux/riscv64

file      before    after     Δ       %
addr2line 3892904   3889844   -3060   -0.079%
api       5558527   5555073   -3454   -0.062%
asm       5191725   5187853   -3872   -0.075%
buildid   2631958   2629356   -2602   -0.099%
cgo       4722642   4718516   -4126   -0.087%
compile   25579930  25564496  -15434  -0.060%
cover     4989560   4985580   -3980   -0.080%
dist      3538991   3536299   -2692   -0.076%
doc       3990845   3987605   -3240   -0.081%
fix       3410945   3407097   -3848   -0.113%
link      6701702   6697926   -3776   -0.056%
nm        3802030   3798664   -3366   -0.089%
objdump   4211373   4207651   -3722   -0.088%
pack      2423248   2421048   -2200   -0.091%
pprof     14302052  14296714  -5338   -0.037%
test2json 2724359   2721881   -2478   -0.091%
trace     13598607  13590879  -7728   -0.057%
vet       7612108   7607722   -4386   -0.058%
go        15092773  15087323  -5450   -0.036%
total     133976279 133891527 -84752  -0.063%

Change-Id: I8615c7830ebfee0386f95d0c0fc4d29dc0b4c7fb
Reviewed-on: https://go-review.googlesource.com/c/go/+/448635
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
2023-02-21 18:34:13 +00:00
Nick Ripley
51225f6fc6 runtime: record parent goroutine ID, and print it in stack traces
Fixes #38651

Change-Id: Id46d684ee80e208c018791a06c26f304670ed159
Reviewed-on: https://go-review.googlesource.com/c/go/+/435337
Run-TryBot: Nick Ripley <nick.ripley@datadoghq.com>
Reviewed-by: Ethan Reesor <ethan.reesor@gmail.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-21 17:35:22 +00:00
Joe Tsai
81eda3a339 Revert "hex: fix panic in Decode when len(src) > 2*len(dst)"
This reverts CL 461958 and CL 465855.

Reason for revert: This introduced an irreconcilable inconsistency with Encode

Fixes #58391.

Change-Id: Ifd01a04d433b24c092b73e627b8149a5851c2bca
Reviewed-on: https://go-review.googlesource.com/c/go/+/469615
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-02-21 15:35:11 +00:00
Anuraag Agrawal
7f59bea53c strconv: add Atoi test cases with characters less than '0'
Change-Id: I35c0fe4e7e11b694ef07687d5e0532a2ab9ba213
GitHub-Last-Rev: e0a28f4236
GitHub-Pull-Request: golang/go#58575
Reviewed-on: https://go-review.googlesource.com/c/go/+/469035
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2023-02-21 05:09:21 +00:00
Cuong Manh Le
99bc53f5e8 doc: add clear builtin to spec
Fixes #56351

Change-Id: Ia87bf594553b7d0464b591106840f849571c5f39
Reviewed-on: https://go-review.googlesource.com/c/go/+/467755
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Bypass: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-20 02:28:50 +00:00
Cuong Manh Le
2baf8ad831 doc: do not use "==" in slice examples
There's no slice comparison in Go.

Change-Id: I5de1766c2adeb56ed12a577a4c46c12b2582b1c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/469015
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-02-19 23:51:51 +00:00
Joel Sing
169203f3ee runtime/cgo: restore correct build tags for linux/mips*
The linux build tags were incorrectly removed from these files by CL 460538.
Restore the correct build tags so that they are only included in builds
for linux/mips* platforms.

Change-Id: I21d8802b0252688d8e2228cf904b47d90b253485
Reviewed-on: https://go-review.googlesource.com/c/go/+/469175
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-02-18 05:22:26 +00:00