1
0
mirror of https://github.com/golang/go synced 2024-11-05 17:26:11 -07:00
Commit Graph

46107 Commits

Author SHA1 Message Date
Kir Kolyshkin
a73506cff5 internal/syscall/unix: consolidate kernelVersion implementations
Currently, there are 3 functions returning Linux kernel version numbers.

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

(both were later fixed by commit 66c0264506).

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

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

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

Change-Id: I4a34d9ca47257743c16def30e4dd634e36056091
Reviewed-on: https://go-review.googlesource.com/c/go/+/424896
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-03 18:39:45 +00:00
Robert Griesemer
2392b7061c go/types, types2: use strings.Builder instead of bytes.Buffer where possible
Also, consistently use declaration: var buf strings.Builder.
We don't change exported signatures to match go/types (where we
can't change the exported signatures for backward-compatibility).

Change-Id: I75350886aa231889ae2fd5c4008dd4be9ed6e09f
Reviewed-on: https://go-review.googlesource.com/c/go/+/428094
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-03 18:29:30 +00:00
Sasha Melentyev
7a86ef2ad8 all: use strings.Builder instead of bytes.Buffer
Change-Id: I6d7213d29ade591b8366d5640833bd5a20474165
GitHub-Last-Rev: 9419583287
GitHub-Pull-Request: golang/go#54834
Reviewed-on: https://go-review.googlesource.com/c/go/+/427814
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: hopehook <hopehook@golangcn.org>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2022-09-03 18:23:33 +00:00
Kir Kolyshkin
a0f05823e4 syscall: fix skipping some tests on Linux
The kernel knob /proc/sys/kernel/unprivileged_userns_clone is
only available in Debian (and Ubuntu) kernels, so if the tests
are run on e.g. Fedora, skipUnprivilegedUserClone() skips a lot
of tests.

Modify it to treat ENOENT as "it should work".

Change-Id: I959201ede139ede989cc8ab646c9bf51e0539ada
Reviewed-on: https://go-review.googlesource.com/c/go/+/417694
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-09-03 18:21:45 +00:00
Bryan C. Mills
32964f9dce net: skip TestLookupPTR when LookupAddr fails with "DNS server failure"
For #38111.

Change-Id: I43bdd756bde0adcd156cf9750b49b3b989304df7
Reviewed-on: https://go-review.googlesource.com/c/go/+/427915
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-09-03 18:19:12 +00:00
Carlo Alberto Ferraris
f798dc6825 fmt: recycle printers with large buffers
Previously when a printer had a large buffer we dropped both
the buffer and the printer. There is no need to drop the printer
in this case, as a printer with a nil buffer is valid. So we
just drop the buffer and recycle the printer anyway.
This saves one allocation in case the buffer is over the limit.

Also tighten some of the tests for other unrelated cases.

Change-Id: Iba1b6a71ca4691464b8c68ab0b6ab0d4d5d6168c
Reviewed-on: https://go-review.googlesource.com/c/go/+/427395
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Rob Pike <r@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Rob Pike <r@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-03 15:45:36 +00:00
Matthew Dempsky
9fc09d2ffb cmd/compile/internal/noder: optimize itabs section of runtime dicts
Currently, the itabs section for runtime dictionaries includes its own
redundant *runtime._type pointers for typ and iface, which were
sometimes necessary. This simplified the initial implementation, but
is a little wasteful of space when the same type or interface appeared
across multiple (typ, iface) pairs.

This CL instead reuses the pointers from the rtypes section.

Change-Id: I48448515c319c0403c1a8e7706794d443176f0a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/427754
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2022-09-03 06:26:16 +00:00
Joel Sing
3e11e61f3c cmd/compile: optimise subtraction with const on riscv64
Convert subtraction from const to a negated ADDI with negative const
value, where possible. At worst this avoids a register load and uses
the same number of instructions. At best, this allows for further
optimisation to occur, particularly where equality is involved.

For example, this sequence:

   li      t0,-1
   sub     t1,t0,a0
   snez    t1,t1

Becomes:

   addi    t0,a0,1
   snez    t0,t0

Removes more than 2000 instructions from the Go binary on linux/riscv64.

Change-Id: I68f3be897bc645d4a8fa3ab3cef165a00a74df19
Reviewed-on: https://go-review.googlesource.com/c/go/+/426263
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
2022-09-02 20:14:40 +00:00
Joel Sing
646c3eee06 cmd/compile: negate comparision with FNES/FNED on riscv64
The FNES and FNED instructions are pseudo-instructions, which the
assembler expands to FEQS/NEG or FEQD/NEG - if we're comparing the
result via a branch instruction, we can avoid an instruction by
negating both the branch comparision and the floating point
comparision.

This only removes a handful of instructions from the Go binary,
however, it will provide benefit to floating point intensive code.

Change-Id: I4e3124440b7659acc4d9bc9948b755a4900a422f
Reviewed-on: https://go-review.googlesource.com/c/go/+/426261
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joel Sing <joel@sing.id.au>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-09-02 20:14:16 +00:00
Michael Pratt
e406112011 runtime: document implicit fields at the end of _func
Currently these are only implicitly documented by the code that
generates and consumes them. Add explicit documentation.

Change-Id: I25a1294f04dc11785242643bec83370c66ff7a20
Reviewed-on: https://go-review.googlesource.com/c/go/+/427954
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
2022-09-02 19:38:45 +00:00
Wayne Zuo
b226cc5ca0 cmd/internal/obj/riscv: fix comment typo
Change-Id: Ica74977898f0af8c9abf42a003d8f02dbdc03d34
Reviewed-on: https://go-review.googlesource.com/c/go/+/427994
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-09-02 19:32:40 +00:00
Robert Griesemer
0fda8b1932 go/types, types2: consistently write "x | y" rather than "x|y" for unions
Use the same spacing convention ("x | y") for union terms everythere,
matching the gofmt precedent.

Fixes #53279.

Change-Id: Ic3ccd7433b5f62402ba41cf05a75f9a1d99a8086
Reviewed-on: https://go-review.googlesource.com/c/go/+/410955
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-02 19:22:26 +00:00
Austin Clements
55ca6a20af runtime: simplify stkframe.argMapInternal
Use an early return to reduce indentation and clarify flow.

For #54466.

Change-Id: I12ce810bea0f22b8707a175dc5ba66241c0a9a21
Reviewed-on: https://go-review.googlesource.com/c/go/+/425936
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-02 19:09:03 +00:00
Austin Clements
35026f3732 runtime: consolidate stkframe and its methods into stkframe.go
The stkframe struct and its methods are strewn across different source
files. Since they actually have a pretty coherent theme at this point,
migrate it all into a new file, stkframe.go. There are no code changes
in this CL.

For #54466, albeit rather indirectly.

Change-Id: Ibe53fc4b1106d131005e1c9d491be838a8f14211
Reviewed-on: https://go-review.googlesource.com/c/go/+/424516
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
Auto-Submit: Austin Clements <austin@google.com>
2022-09-02 19:08:58 +00:00
Austin Clements
b91e373729 runtime: make getStackMap a method of stkframe
This places getStackMap alongside argBytes and argMapInternal as
another method of stkframe.

For #54466, albeit rather indirectly.

Change-Id: I411dda3605dd7f996983706afcbefddf29a68a85
Reviewed-on: https://go-review.googlesource.com/c/go/+/424515
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Auto-Submit: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-02 19:08:56 +00:00
Austin Clements
dbf442b1b2 runtime: replace stkframe.arglen/argmap with methods
Currently, stkframe.arglen and stkframe.argmap are populated by
gentraceback under a particular set of circumstances. But because they
can be constructed from other fields in stkframe, they don't need to
be computed eagerly at all. They're also rather misleading, as they're
only part of computing the actual argument map and most callers should
be using getStackMap, which does the rest of the work.

This CL drops these fields from stkframe. It shifts the functions that
used to compute them, getArgInfoFast and getArgInfo, into
corresponding methods stkframe.argBytes and stkframe.argMapInternal.
argBytes is expected to be used by callers that need to know only the
argument frame size, while argMapInternal is used only by argBytes and
getStackMap.

We also move some of the logic from getStackMap into argMapInternal
because the previous split of responsibilities didn't make much sense.
This lets us return just a bitvector from argMapInternal, rather than
both a bitvector, which carries a size, and an "actually use this
size".

The getArgInfoFast function was inlined before (and inl_test checked
this). We drop that requirement from stkframe.argBytes because the
uses of this have shifted and now it's only called from heap dumping
(which never happens) and conservative stack frame scanning (which
very, very rarely happens).

There will be a few follow-up clean-up CLs.

For #54466. This is a nice clean-up on its own, but it also serves to
remove pointers from the traceback state that would eventually become
troublesome write barriers once we stack-rip gentraceback.

Change-Id: I107f98ed8e7b00185c081de425bbf24af02a4163
Reviewed-on: https://go-review.googlesource.com/c/go/+/424514
Run-TryBot: Austin Clements <austin@google.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-02 19:08:53 +00:00
Austin Clements
511cd9b8af runtime: switch gp when jumping stacks during traceback
Currently, when traceback jumps from the system stack to a user stack
(e.g., during profiling tracebacks), it leaves gp pointing at the g0.
This is currently harmless since it's only used during profiling, so
the code paths in gentraceback that care about gp aren't used, but
it's really confusing and would certainly break if _TraceJumpStack
were ever used in a context other than profiling.

Fix this by updating gp to point to the user g when we switch stacks.

For #54466.

Change-Id: I1541e004667a52e37671803ce45c91d8c5308830
Reviewed-on: https://go-review.googlesource.com/c/go/+/424257
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Austin Clements <austin@google.com>
2022-09-02 19:08:50 +00:00
Austin Clements
f00fa0b98d runtime: document stkframe
The meaning of some of the fields in stkframe is actually quite
subtle.

Change-Id: Iac765ff6fbf4c3b7c9f2453f5b4a2e5e640f5750
Reviewed-on: https://go-review.googlesource.com/c/go/+/424256
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Austin Clements <austin@google.com>
2022-09-02 19:07:18 +00:00
Austin Clements
5063056bd1 runtime: drop redundant argument to getArgInfo
The f funcInfo argument is always the same as frame.fn, so we don't
need to pass it. I suspect that was there to make the signatures of
getArgInfoFast and getArgInfo more similar, but it's not necessary.

For #54466.

Change-Id: Idc717f4df09e97cad49d52c5b7edf28090908cba
Reviewed-on: https://go-review.googlesource.com/c/go/+/424255
Run-TryBot: Austin Clements <austin@google.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-02 19:04:51 +00:00
Austin Clements
8be94b82ab runtime: drop function context from traceback
Currently, gentraceback tracks the closure context of the outermost
frame. This used to be important for "unstarted" calls to reflect
function stubs, where "unstarted" calls are either deferred functions
or the entry-point of a goroutine that hasn't run. Because reflect
function stubs have a dynamic argument map, we have to reach into
their closure context to fetch to map, and how to do this differs
depending on whether the function has started. This was discovered in
issue #25897.

However, as part of the register ABI, "go" and "defer" were made much
simpler, and any "go" or "defer" of a function that takes arguments or
returns results gets wrapped in a closure that provides those
arguments (and/or discards the results). Hence, we'll see that closure
instead of a direct call to a reflect stub, and can get its static
argument map without any trouble.

The one case where we may still see an unstarted reflect stub is if
the function takes no arguments and has no results, in which case the
compiler can optimize away the wrapper closure. But in this case we
know the argument map is empty: the compiler can apply this
optimization precisely because the target function has no argument
frame.

As a result, we no longer need to track the closure context during
traceback, so this CL drops all of that mechanism.

We still have to be careful about the unstarted case because we can't
reach into the function's locals frame to pull out its context
(because it has no locals frame). We double-check that in this case
we're at the function entry.

I would prefer to do this with some in-code PCDATA annotations of
where to find the dynamic argument map, but that's a lot of mechanism
to introduce for just this. It might make sense to consider this along
with #53609.

Finally, we beef up the test for this so it more reliably forces the
runtime down this path. It's fundamentally probabilistic, but this
tweak makes it better. Scheduler testing hooks (#54475) would make it
possible to write a reliable test for this.

For #54466, but it's a nice clean-up all on its own.

Change-Id: I16e4f2364ba2ea4b1fec1e27f971b06756e7b09f
Reviewed-on: https://go-review.googlesource.com/c/go/+/424254
Run-TryBot: Austin Clements <austin@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Auto-Submit: Austin Clements <austin@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-09-02 19:04:48 +00:00
Mateusz Poliwczak
2efb5792c3 net: rfc number typo
Change-Id: I9cde2a82a395546d7620b5138cf922b2ac1c94b5
GitHub-Last-Rev: 25b8e972b0
GitHub-Pull-Request: golang/go#54835
Reviewed-on: https://go-review.googlesource.com/c/go/+/427834
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-09-02 19:00:13 +00:00
Keith Randall
5b1fbfba1c cmd/compile: rewrite >>c<<c to &^(1<<c-1)
Fixes #54496

Change-Id: I3c2ed8cd55836d5b07c8cdec00d3b584885aca79
Reviewed-on: https://go-review.googlesource.com/c/go/+/424856
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Martin Möhrmann <martin@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Martin Möhrmann <martin@golang.org>
2022-09-02 18:51:37 +00:00
Matthew Dempsky
34f0029a85 cmd/compile/internal/noder: allow OCONVNOP for identical iface conversions
In go.dev/cl/421821, I included a hack to force OCONVNOP back to
OCONVIFACE for conversions involving shape types and non-empty
interfaces. The comment correctly noted that this was only needed for
conversions between non-identical types, but the code was conservative
and applied to even conversions between identical types.

This CL adds an extra bool to record whether the conversion is between
identical types, so we can keep OCONVNOP instead of forcing back to
OCONVIFACE. This has a small improvement to generated code, because we
no longer need a convI2I call (as demonstrated by codegen/ifaces.go).

But more usefully, this is relevant to pruning unnecessary itab slots
in runtime dictionaries (next CL).

Change-Id: I94f89e961cd26629b925037fea58d283140766ff
Reviewed-on: https://go-review.googlesource.com/c/go/+/427678
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-02 18:26:02 +00:00
Matthew Dempsky
8af6c3348e cmd/compile/internal/noder: refactor exprConvert code
This CL deduplicates the explicit and implicit exprConvert code paths
to have a single common function, so they're easier to keep in sync.

Change-Id: I2b145d2ce6de6018ffc2db5cdb9d891f4e223381
Reviewed-on: https://go-review.googlesource.com/c/go/+/427677
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-02 18:25:53 +00:00
Cuong Manh Le
8bbb362f4c cmd/compile: remove go:notinheap pragma
Updates #46731

Change-Id: I247fa9c7ca97feb9053665da7ff56e7f5b571f74
Reviewed-on: https://go-review.googlesource.com/c/go/+/422815
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joedian Reid <joedian@golang.org>
2022-09-02 18:24:59 +00:00
Cuong Manh Le
0ee0bb1003 cmd/compile: make runtime/internal/sys.NotInHeap intrinsic
So next CL can get rid of go:notinheap pragma.

Updates #46731

Change-Id: Ib2e2f2d381767e11cec10f76261b516188ddaa6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/422814
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-02 18:24:50 +00:00
Cuong Manh Le
0cf996a9c1 cmd/compile/internal/abt: use strings.Builder
Since go1.17 is now used for bootstrapping.

Change-Id: I5692ff4b38b7d9a279b20662ce5348ff34a2dde6
Reviewed-on: https://go-review.googlesource.com/c/go/+/427134
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: hopehook <hopehook@golangcn.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
2022-09-02 17:59:27 +00:00
Tobias Klauser
553f02c6ae debug/macho: use saferio to allocate load command slice
Avoid allocating large amounts of memory for corrupt input.

No test case because the problem can only happen for invalid data.
Let the fuzzer find cases like this.

Fixes #54780

Change-Id: Icdacb16bef7d29ef431da52e6d1da4e883a3e050
Reviewed-on: https://go-review.googlesource.com/c/go/+/427434
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
2022-09-02 17:48:30 +00:00
Derek Parker
6605686e3b cmd/compile: new inline heuristic for struct compares
This CL changes the heuristic used to determine whether we can inline a
struct equality check or if we must generate a function and call that
function for equality.

The old method was to count struct fields, but this can lead to poor
in lining decisions. We should really be determining the cost of the
equality check and use that to determine if we should inline or generate
a function.

The new benchmark provided in this CL returns the following when compared
against tip:

```
name         old time/op  new time/op  delta
EqStruct-32  2.46ns ± 4%  0.25ns ±10%  -89.72%  (p=0.000 n=39+39)
```

Fixes #38494

Change-Id: Ie06b80a2b2a03a3fd0978bcaf7715f9afb66e0ab
GitHub-Last-Rev: e9a18d9389
GitHub-Pull-Request: golang/go#53326
Reviewed-on: https://go-review.googlesource.com/c/go/+/411674
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-09-02 17:48:22 +00:00
Tobias Klauser
19a4804854 runtime: support MADV_DONTNEED on the BSDs and Solaris/Illumos
Like on Linux, use GODEBUG=madvdontneed=1 to enable madvise with
MADV_DONTNEED instead of MADV_FREE.

Based on previous work by Marcelo Araujo in CL 181498.

Fixes #32519

Change-Id: Ib49faf05c42a65591b90e75f663146f213030529
Reviewed-on: https://go-review.googlesource.com/c/go/+/266937
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-09-02 17:48:16 +00:00
ruinan
121344ac33 cmd/compile: optimize RotateLeft8/16 on arm64
This CL optimizes RotateLeft8/16 on arm64.

For 16 bits, we form a 32 bits register by duplicating two 16 bits
registers, then use RORW instruction to do the rotate shift.

For 8 bits, we just use LSR and LSL instead of RORW because the code is
simpler.

Benchmark          Old          ThisCL       delta
RotateLeft8-46     2.16 ns/op   1.73 ns/op   -19.70%
RotateLeft16-46    2.16 ns/op   1.54 ns/op   -28.53%

Change-Id: I09cde4383d12e31876a57f8cdfd3bb4f324fadb0
Reviewed-on: https://go-review.googlesource.com/c/go/+/420976
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
2022-09-02 17:46:31 +00:00
Cuong Manh Le
f45c2d7e47 go/types,types2: move notinheap tests to fixedbugs directory
So they can be added to ignored list, since the tests now require
cgo.Incomplete, which is not recognized by go/types and types2.

Updates #46731

Change-Id: I9f24e3c8605424d1f5f42ae4409437198f4c1326
Reviewed-on: https://go-review.googlesource.com/c/go/+/427142
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-09-02 17:46:15 +00:00
Tobias Klauser
274528eca1 cmd/compile/internal/base: use runtime.KeepAlive in MapFile
Go 1.17 will be used instead of Go 1.4 as minimum required version for
bootstrap, so runtime.KeepAlive introduced in Go 1.7 can be used in
cmd/compile.

For #44505

Change-Id: I96bd6619c4476e36ee1d93ca049da622a3a78f97
Reviewed-on: https://go-review.googlesource.com/c/go/+/427114
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-02 17:45:18 +00:00
ruinan
54c7bc9cff cmd/compile: optimize shift ops on arm64 when the shift value is v&63
For the following code case:

  var x uint64
  x >> (shift & 63)

We can directly genereta `x >> shift` on arm64, since the hardware will
only use the bottom 6 bits of the shift amount.

Benchmark               old time/op  new time/op    delta
ShiftArithmeticRight-8  0.40ns       0.31ns        -21.7%

Change-Id: Id58c8a5b2f6dd5c30c3876f4a36e11b4d81e2dc9
Reviewed-on: https://go-review.googlesource.com/c/go/+/425294
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-09-02 17:44:29 +00:00
Robert Griesemer
5befb24bb5 go/types: use function name position for init errors
This seems more sensible than the func keyword. With this change,
go/types uses the same error position as types2 and we can narrow
the error tolerance a bit.

(The types2 change doesn't change its position, but it makes the
code clearer and symmetric to go/types.)

Change-Id: Iedea7c80caa7239a4343c8748cb779ec545e84d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/427775
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2022-09-02 16:43:15 +00:00
Cherry Mui
321a220d50 cmd/link: only add dummy XCOFF reference if the symbol exists
On AIX when external linking, for some symbols we need to add
dummy references to prevent the external linker from discarding
them. Currently we add the reference unconditionally. But if the
symbol doesn't exist, the linking fails in a later stage for
generating external relocation of a nonexistent symbol. The
symbols are special symbols that almost always exist, except that
go:buildid may not exist if the linker is invoked without the
-buildid flag. The go command invokes the linker with the flag, so
this can only happen with manual linker invocation. Specifically,
test/run.go does this in some cases.

Fix this by checking the symbol existence before adding the
reference. Re-enable tests on AIX.

Perhaps the linker should always emit a dummy buildid even if the
flag is not set...

Fixes #54814.

Change-Id: I43d81587151595309e189e38960cbda9a1c5ca32
Reviewed-on: https://go-review.googlesource.com/c/go/+/427620
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2022-09-02 15:27:18 +00:00
RenKanai
202b7e7e76 encoding/asn1: fix doc for BitString.At's return value
Fixes #53287

Change-Id: If983ae34850d9b1b29764156a38628fa53897573
Reviewed-on: https://go-review.googlesource.com/c/go/+/411134
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: hopehook <hopehook@golangcn.org>
Reviewed-by: Rob Pike <r@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: hopehook <hopehook@golangcn.org>
Reviewed-by: Subham <sarkar.subhams2@gmail.com>
2022-09-02 09:14:48 +00:00
Cuong Manh Le
ec2ea40b31 cmd/compile: restrict //go:notinheap to runtime/internal/sys
So it won't be visible outside of runtime package. There are changes to
make tests happy:

 - For test/directive*.go files, using "go:noinline" for testing misplaced
 directives instead.
 - Restrict test/fixedbugs/bug515.go for gccgo only.
 - For test/notinheap{2,3}.go, using runtime/cgo.Incomplete for marking
 the type as not-in-heap. Though it's somewhat clumsy, it's the easiest
 way to keep the test errors for not-in-heap types until we can cleanup
 further.
 - test/typeparam/mdempsky/11.go is about defined type in user code marked
 as go:notinheap, which can't happen after this CL, though.

Fixes #46731

Change-Id: I869f5b2230c8a2a363feeec042e7723bbc416e8e
Reviewed-on: https://go-review.googlesource.com/c/go/+/421882
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Joedian Reid <joedian@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
2022-09-02 06:22:23 +00:00
cuiweixie
134cd34c07 hash: convert haveCastagnoli to atomic type
Change-Id: I313fff5684d89ee737572d11b1b697c5575866a8
Reviewed-on: https://go-review.googlesource.com/c/go/+/426083
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2022-09-02 06:06:53 +00:00
Jonathan FOng
8e35910640 math/rand: document that Source returned by NewSource implements Source64
Fixes #44488

Change-Id: I570950799788678b9dc6e9ddad894973b4611e09
Reviewed-on: https://go-review.googlesource.com/c/go/+/425974
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: David Chase <drchase@google.com>
2022-09-02 05:05:13 +00:00
Robert Griesemer
ccab2fbc30 internal/types: add a test for empty string import path
Follow-up on comment in CL 427154.

Change-Id: Ib44a8e9b9129d68b794f91788c9b8c971d6c5436
Reviewed-on: https://go-review.googlesource.com/c/go/+/427774
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2022-09-02 02:58:40 +00:00
Robert Griesemer
57ade1fd0b go/types, types2: move shared tests into internal/types/testdata
This CL moves the directories check, examples, fixedbugs, and spec
from inside go/types/testdata to internal/types/testdata. Except
for the directory adjustments to check_test.go files, this is a
pure file move.

With this CL, both type checkers now share identical tests in an
independent location.

Fixes #54511.

Change-Id: Ib335692d927e93867a158b338f105c2b87e74dbe
Reviewed-on: https://go-review.googlesource.com/c/go/+/427674
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2022-09-02 02:58:32 +00:00
Robert Griesemer
e2d2d3a4a6 go/types: test shifts that are disabled in shared test file
CL 425735 consolidated the testdata/check/shifts.go files between
go/types and types2. Because some shifts don't work correctly with
types2, the corresponding tests were disabled in the shared file.
Make sure we keep testing those shifts for go/types by adding a
local test file.

For #52080.
For #54511.

Change-Id: I53507e535bf83b204eaf18fc6c2efefcebf5ebf7
Reviewed-on: https://go-review.googlesource.com/c/go/+/426661
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-02 02:47:14 +00:00
Robert Griesemer
157aae6eed go/types, types2: establish type-checker specific local tests
Establish testdata/local directory for tests that are not (yet)
shared between the go/types and types2. Move issue47996.go into
that directory.

For #54511.

Change-Id: I274b119990a93cc3657bdddc5246948699226c21
Reviewed-on: https://go-review.googlesource.com/c/go/+/426660
Reviewed-by: Robert Findley <rfindley@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-02 02:15:21 +00:00
Robert Griesemer
29e360274a cmd/compile/internal/types2: use go/types/testdata/fixedbugs tests
Since the fixedbugs tests are now identical between the two type checkers,
remove the local copy of the fixedbugs tests and (for now) use the tests
in go/types/testdata/fixedbugs instead. Eventually we may decide to move
all tests out of the type checker directories and place them in a
shared space (e.g. internal/types/testdata).

For #54511.

Change-Id: I451c20c784710c36fa50b1d24ac97af554c572af
Reviewed-on: https://go-review.googlesource.com/c/go/+/426658
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-02 02:15:19 +00:00
Robert Griesemer
9649a4119c go/types, types2: consolidate testdata/fixedbugs test files
Use the go/types version of testdata/fixedbugs tests where diffs
are only in the error positions (the types2 test harness allows
for some position tolerance). Consolidate files where there are
other minor differences.

Add files to respective directories if they only existed for
one of the type checkers.

Move types2-only test issue47996.go out of testdata/fixedbugs
into testdata. Making it work for both type checkers requires
some more work.

With this CL, the testdata/fixedbugs files are identical between
the two type checkers.

For #54511.

Change-Id: I0d67f0db75ad1743c62da9181a6d0032c8bdb728
Reviewed-on: https://go-review.googlesource.com/c/go/+/427236
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-02 02:15:01 +00:00
Robert Griesemer
1be8fcdcdc cmd/compile/internal/syntax: more strict parsing of type instances
Report a syntax error if the first element of a type instance is
not actually a type (but some other expression), rather then relying
on the type checker error in this case. This matches the behavior of
go/parser. Adjust the corresponding types2 test case.

For #54511.

Change-Id: Ia82b3a7d444738c56955ce6c15609470b3431fd1
Reviewed-on: https://go-review.googlesource.com/c/go/+/426657
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-02 02:14:57 +00:00
Robert Griesemer
d98bf7d015 go/types, types2: consolidate testdata/fixedbugs/issue46404.go
Rename .../issue46404.go1 to .../issue46404.go so that it is
not skipped anymore when running tests, and copy for types2.

Disable the code for now due to a difference in error
reporting due to the slightly different handling of index
expressions. This allows us to make progress with test
consolidation.

For #54511.

Change-Id: Ib5c9ffa49b1b24ec680ddb5001bc3dcb1df7eb1f
Reviewed-on: https://go-review.googlesource.com/c/go/+/426656
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-02 02:14:56 +00:00
Robert Griesemer
4e32472e79 go/parser: match syntax parser error for unnamed type parameters
For #54511.

Change-Id: I1ae391b5f157bf688f9f31b1577c90e681b6df26
Reviewed-on: https://go-review.googlesource.com/c/go/+/426655
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
2022-09-02 02:14:54 +00:00
Robert Griesemer
d394f99f49 go/parser: more tolerant parsing of import declarations
This is a port of CL 427156 from the syntax package's parser
to go/parser.

While at it, remove an unused token.Pos parameter from
parseSpecFunction and dependent declarations.

Also, consolidate the respective test file.

For #54511.

Change-Id: Id6a28eb3d23a46fa5fa1d85d2c4e634b7015513c
Reviewed-on: https://go-review.googlesource.com/c/go/+/427157
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2022-09-02 02:09:06 +00:00
Robert Griesemer
a330ca5c54 cmd/compile/internal/syntax: more tolerant parsing of import declarations
Change-Id: I114548640d51bf69833259578609901fa1602510
Reviewed-on: https://go-review.googlesource.com/c/go/+/427156
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
2022-09-02 02:09:04 +00:00
Robert Griesemer
a31c062c9f go/parser: parse import specs the same way as the syntax parser
This results in better error recovery and allows us to use the
same tests for go/types and types2.

For #54511.

Change-Id: Ic11a9dafb8c62e0cb952b3924d55a28b438241c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/427154
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-02 02:09:03 +00:00
Robert Griesemer
042f051c03 go/types, types2: consolidate a test file with different syntax errors
For #54511.

Change-Id: I317c5f9beed7f1de4979ec12c6ec8d5de71bac1c
Reviewed-on: https://go-review.googlesource.com/c/go/+/426554
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2022-09-02 02:08:58 +00:00
Robert Griesemer
cb357835d9 cmd/compile/internal/types2: match go/types error for invalid instantiations
Also: add a missing test.

For #54511.

Change-Id: Ie9828c6ba5186feb5a79db0d58beb2cda2beae56
Reviewed-on: https://go-review.googlesource.com/c/go/+/426478
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-02 02:08:56 +00:00
Robert Griesemer
6b555dc29e go/types: use singular in version error messages
This matches the majority use case as well as types2.

For #54511.

Change-Id: If800afc35db8d32cca8329ed9d6a80b4a15c4878
Reviewed-on: https://go-review.googlesource.com/c/go/+/426477
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2022-09-02 01:40:02 +00:00
hopehook
0592ce5f69 types2: use strings.Builder in infer.go
Permissible now because go1.17 is used for bootstrapping.

Change-Id: Ic97b0706190c3eb907da69003bc94448c90e5af7
Reviewed-on: https://go-review.googlesource.com/c/go/+/427556
Run-TryBot: Robert Griesemer <gri@google.com>
Run-TryBot: hopehook <hopehook@golangcn.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-02 00:06:00 +00:00
hopehook
b2110bcdde types2: use strings.Builder in errors.go
Permissible now because go1.17 is used for bootstrapping.

Change-Id: Ia6f314f9314eda1cc42002dcbdfa551196df76f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/427554
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: hopehook <hopehook@golangcn.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-09-01 23:22:30 +00:00
Robert Griesemer
1280ae7856 go/parser: leave checking of LHS in short var decls to type checker
Instead of checking at parse-time that the LHS of a short variable
declaration contains only identifiers, leave the check to the the
type checker which tests this already.

This removes a duplicate error and matches the behavior of the
syntax package.

For #54511.

Change-Id: I4c68f2bd8a0e015133685f9308beb98e714a83fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/426476
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2022-09-01 23:18:06 +00:00
Robert Griesemer
a74d46d8ff go/parser: check that go/defer expressions are not parenthesized
Logic matches the code in the syntax package.
This error was missing from go/parser and go/types.
Added some tests.

For #54511.

Change-Id: I418de4bd4c7169457b424366caae70227a92a761
Reviewed-on: https://go-review.googlesource.com/c/go/+/425795
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-01 23:18:01 +00:00
Robert Griesemer
489f508ccf cmd/compile: avoid "not used" errors due to bad go/defer statements
The syntax for go and defer specifies an arbitrary expression, not
a call; the call requirement is spelled out in prose. Don't to the
call check in the parser; instead move it to the type checker. This
is simpler and also allows the type checker to check expressions that
are not calls, and avoid "not used" errors due to such expressions.

We would like to make the same change in go/parser and go/types
but the change requires Go/DeferStmt nodes to hold an ast.Expr
rather than an *ast.CallExpr. We cannot change that for backward-
compatibility reasons. Since we don't test this behavior for the
type checkers alone (only for the compiler), we get away with it
for now.

Follow-up on CL 425675 which introduced the extra errors in the
first place.

Change-Id: I90890b3079d249bdeeb76d5673246ba44bec1a7b
Reviewed-on: https://go-review.googlesource.com/c/go/+/425794
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-09-01 23:17:52 +00:00
Robert Griesemer
330282a3a9 cmd/compile/internal/types2: use go/types/testdata/check tests
Since the check tests are now identical between the two type checkers,
remove the local copy of the check tests and (for now) use the tests
in go/types/testdata/check instead. Eventually we may decide to move
all tests out of the type checker directories and place them in a
shared space (e.g. internal/types/testdata).

For #54511.

Change-Id: Id3a97593f6c705c5eda4566089ddc7aeb7b47337
Reviewed-on: https://go-review.googlesource.com/c/go/+/425736
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-01 23:17:45 +00:00
Robert Griesemer
bbaf0a514e go/types, types2: consolidate testdata/check test files
Use the go/types version of testdata/check tests where the diffs
are only in the error positions (the types2 test harness allows
for some position tolerance). Consolidate files where there are
other minor differences.

Comment out a couple of tests that are different between the two
type checkers.

With this CL, the testdata/check files are identical between the
two type checkers.

For #54511.

Change-Id: Ibdff2ca3ec9bdaca3aa84029a7883bb83d2d2060
Reviewed-on: https://go-review.googlesource.com/c/go/+/425735
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-01 23:17:30 +00:00
Robert Griesemer
aa5ff29dab go/parser: adjustments to error messages
- Use "expected X" rather then "expecting X".
- Report a better error when a type argument list is expected.
- Adjust various tests.

For #54511.

Change-Id: I0c5ca66ecbbdcae1a8f67377682aae6b0b6ab89a
Reviewed-on: https://go-review.googlesource.com/c/go/+/425734
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2022-09-01 22:37:04 +00:00
Robert Griesemer
c801e4b10f cmd/compile/internal/syntax: use BadExpr instead of fake CallExpr in bad go/defer
If the go/defer syntax is bad, using a fake CallExpr may produce
a follow-on error in the type checker. Instead store a BadExpr
in the syntax tree (since an error has already been reported).

Adjust various tests.

For #54511.

Change-Id: Ib2d25f8eab7d5745275188d83d11620cad6ef47c
Reviewed-on: https://go-review.googlesource.com/c/go/+/425675
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-09-01 22:37:03 +00:00
Robert Griesemer
9b80d3d3db go/parser: remove validation of expression syntax, leave to type checker
Remove the code that verifies that an expression is a type or non-type
expression. For one, it cannot be done perfectly accurate
(e.g., consider *p which could be an indirection or a pointer type),
it also unnecessarily slows down parsing. It's simpler to leave the
verification to the type checker which has all the information needed.

Remove short compiler tests that tested the expression/type property.
Adjust a couple of go/types tests which now trigger because the parser
doesn't complain anymore.

Change file for benchmark from "parser.go" to "../printer/nodes.go"
to avoid a moving target when benchmarking.

The parser may be marginally faster when tested on nodes.go:

name          old time/op    new time/op    delta
ParseOnly-12    1.35ms ± 0%    1.31ms ± 0%   ~     (p=0.100 n=3+3)

name          old speed      new speed      delta
ParseOnly-12  39.9MB/s ± 0%  41.0MB/s ± 0%   ~     (p=0.100 n=3+3)

For #54511.

Change-Id: I9a32c24c2c6e843c3d1af4587651c352f378b490
Reviewed-on: https://go-review.googlesource.com/c/go/+/425716
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2022-09-01 22:35:46 +00:00
Kir Kolyshkin
4048f3ffb6 syscall: Faccessat: use faccessat2 on linux
Linux kernel 5.8 added the faccessat2 syscall taking a flags argument.
Attempt to use it in Faccessat and fall back to the existing
implementation mimicking glibc faccessat.

Do not export the new syscall value so we keep syscall API intact.

Part of this commit is generated by:

	GOOS=linux ./mkall.sh -syscalls zsyscall_linux_*.go

This is similar to [1] amended by [2]. Required for [3].

[1] https://go-review.googlesource.com/c/sys/+/246537
[2] https://go-review.googlesource.com/c/sys/+/246817
[3] https://go-review.googlesource.com/c/go/+/414824

Co-authored-by: Tobias Klauser <tklauser@distanz.ch>
Change-Id: Ib7fe5ba853c15d92e869df9a16b56b79b96e43a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/416115
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-09-01 22:00:28 +00:00
Kir Kolyshkin
36f191abcd syscall: make mkall.sh accept file list
Amend the "mkall.sh -syscalls" implementation to
 - prepend ./ before mksyscalls.pl;
 - accept the optional file list argument.

This is a preparation for CL 416115.

Change-Id: Ib4dc2b4aa0d2dd22a256414864e92f2d2fd957a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/423676
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
2022-09-01 22:00:15 +00:00
Keith Randall
dd323fe205 cmd/compile,runtime: redo growslice calling convention
Instead of passing the original length and the new length, pass
the new length and the length increment. Also use the new length
in all the post-growslice calculations so that the original length
is dead and does not need to be spilled/restored around the growslice.

old: growslice(typ, oldPtr, oldLen, oldCap, newLen) (newPtr, newLen, newCap)
new: growslice(oldPtr, newLen, oldCap, inc, typ) (newPtr, newLen, newCap)

where inc = # of elements added = newLen-oldLen

Also move the element type to the end of the call. This makes register
allocation more efficient, as oldPtr and newPtr can often be in the
same register (e.g. AX on amd64) and thus the phi takes no instructions.

Makes the go binary 0.3% smaller.

Change-Id: I7295a60227dbbeecec2bf039eeef2950a72df760
Reviewed-on: https://go-review.googlesource.com/c/go/+/418554
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Heschi Kreinick <heschi@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-01 21:28:35 +00:00
hopehook
1e7f535475 cmd/compile: use (*strings.Reader).Reset
Since when go1.17 is now used for bootstraping.

Change-Id: If28338fc82e6c61f057d7eb3a4c2ed77846167df
Reviewed-on: https://go-review.googlesource.com/c/go/+/427558
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: hopehook <hopehook@golangcn.org>
2022-09-01 21:27:29 +00:00
hopehook
dced3461ee cmd/internal/pkgpath: use strings.Builder
Since when go1.17 is now used for bootstraping.

Change-Id: I5f763dec1cb152f94ab1c677d3fa26da17abf097
Reviewed-on: https://go-review.googlesource.com/c/go/+/427557
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Run-TryBot: hopehook <hopehook@golangcn.org>
Reviewed-by: Keith Randall <khr@google.com>
2022-09-01 21:27:01 +00:00
hopehook
d31c4bc2de cmd/internal/objabi: use strings.Builder
Since when go1.17 is now used for bootstraping.

Change-Id: I5ee65aff72500a04e243238cffeae92ea659627b
Reviewed-on: https://go-review.googlesource.com/c/go/+/427555
Auto-Submit: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: hopehook <hopehook@golangcn.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
2022-09-01 21:26:43 +00:00
Michael Pratt
ef8414101f Revert "runtime: convert ncgocall to atomic type"
This reverts CL 426075.

Reason for revert: Import missing from cgocall.go.

Change-Id: Iac17e914045b83da30484dbe2a624cde526fb175
Reviewed-on: https://go-review.googlesource.com/c/go/+/427614
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-09-01 18:08:05 +00:00
cuiweixie
5a6db7c48f runtime: convert ncgocall to atomic type
For #53821

Change-Id: Ib0d62ee36487b3ed68e063976968f3cac6499e4b
Reviewed-on: https://go-review.googlesource.com/c/go/+/426075
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-01 18:02:28 +00:00
Wayne Zuo
af991a6d28 cmd/compile: reorder rotate lowering rules in AMD64.rules
These rules should belong to lowering rules not optimizations.

Change-Id: I964d2c4b1d9bef0ede572978aff01cb11bf050ac
Reviewed-on: https://go-review.googlesource.com/c/go/+/426197
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
2022-09-01 17:08:37 +00:00
cuiweixie
1f8e94e9f6 crypto/internal/boring/fipstls: convert required to atomic type
Change-Id: I73081b85e763122be1f5c0dbab25cecc9cf809df
Reviewed-on: https://go-review.googlesource.com/c/go/+/426087
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
2022-09-01 17:06:14 +00:00
Daniel Martí
5bc8fa74f5 cmd/go: support long commands in asm and cgo
We have supported passing lists of arguments to the compiler and linker
for some time, since https://go.dev/issue/18468 was fixed.
The reason behind it is that some systems like Windows have relatively
small limits for commands, and some Go packages contain many source files.

This wasn't done for other Go toolchain programs like cgo and asm,
as there wasn't an initial need for it. A TODO was left for them.
The need has now arisen in the form of a bug report for a build of a
large Go package involving cgo.

Do asm as well, which could be triggered by lots of asm files.

I rebuilt Go itself with some basic logging to tell if any other
commands were being run with moderately large command lengths.
I only found one other: gcc being invoked with 300-500 bytes.

I didn't spot any length close to 1KiB, and we can't safely assume that
a user's CC compiler supports these "response files", so leave that as
another TODO for the future. Just like cgo and asm, we can revisit this
if any user reports a bug on the issue tracker.

Fixes #47235.

Change-Id: Ifcc099d7c0dfac3ed2c4e9e7a2d6e3d69b0ccb63
Reviewed-on: https://go-review.googlesource.com/c/go/+/427015
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-09-01 16:55:25 +00:00
Cuong Manh Le
b5b2cf519f go/types,types2: exclude tests that need cgo.Incomplete
Since when go/types,types2 do not know about build constraints, and
runtime/cgo.Incomplete is only available on platforms that support cgo.

These tests are also failing on aix with failure from linker, so disable
them on aix to make builder green. The fix for aix is tracked in #54814

Updates #46731
Updates #54814

Change-Id: I5d6f6e29a8196efc6c457ea64525350fc6b20309
Reviewed-on: https://go-review.googlesource.com/c/go/+/427394
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2022-09-01 15:27:07 +00:00
Joe Tsai
91ef076562 reflect: fix Value.SetIterXXX to check for the read-only bit
v.SetIterXXX(i) is semantically identical to v.Set(i.XXX()).
If the latter panics for unexported values, so should the former.

This change may breaking some programs, but the change is justified
under the "Go 1 and the Future of Go Programs" document because
the "library has a bug that violates the specification".
In this case, the "reflect" package does not accurately match
the behavior of the Go language specification.
Also, this API was recently released, so the number of users
who could be depending on this behavior is hopefully lower.

Fixes #54628

Change-Id: If86ede51f286e38093f6697944c089f616525115
Reviewed-on: https://go-review.googlesource.com/c/go/+/425184
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: David Chase <drchase@google.com>
2022-09-01 02:24:14 +00:00
Matthew Dempsky
ca634fa2c5 cmd/compile: reject not-in-heap types as type arguments
After running the types2 type checker, walk info.Instances to reject
any not-in-heap type arguments. This is feasible to check using the
types2 API now, thanks to #46731.

Fixes #54765.

Change-Id: Idd2acc124d102d5a76f128f13c21a6e593b6790b
Reviewed-on: https://go-review.googlesource.com/c/go/+/427235
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2022-08-31 23:52:00 +00:00
Matthew Dempsky
e4b624eae5 cmd/compile: use HaveInlineBody for unified IR
In go.dev/cl/419674 I added a mechanism to the inliner to allow
inlining to fail gracefully when a function body is missing, but I
missed we already have a mechanism for that: typecheck.HaveInlineBody.

This CL makes it overridable so that unified IR can plug in its
appropriate logic, like it does with the logic for building the
ir.InlinedCallExpr node.

While here, rename inline.NewInline to inline.InlineCall, because the
name "NewInline" is now a misnomer since we initialize it to oldInline
(now named oldInlineCall).

Change-Id: I4e65618d3725919f69e6f43cf409699d20fb797c
Reviewed-on: https://go-review.googlesource.com/c/go/+/427234
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2022-08-31 22:22:43 +00:00
Keith Randall
33a7e5a4b4 cmd/compile: combine multiple rotate instructions
Rotating by c, then by d, is the same as rotating by c+d.

Change-Id: I36df82261460ff80f7c6d39bcdf0e840cef1c91a
Reviewed-on: https://go-review.googlesource.com/c/go/+/424894
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ruinan Sun <Ruinan.Sun@arm.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-08-31 22:10:52 +00:00
Keith Randall
5f5c018ca4 cmd/compile: redo mknode.go
The current mknode has a few problems:
1) It tends not to run successfully if the tree is in a broken state.
2) It requires that it be run by the go tool in the tree (somewhat related to 1)
3) It requires setting GOROOT
4) It imports code outside the tree (x/packages)

This makes mknode.go very fragile. In particular, I've spent lots of
time fighting mknode when adding or removing code, related to 1.

Rewrite to just use go/ast and friends. No typechecking, no importing,
etc. It can run with any go version, it doesn't need to be the one
corresponding to the code in which it is run. (e.g. you can use go
1.16 to run mknode). It will work as long as the ir package is parseable.

When run, it generates identical output to the old mknode.

Fixes #53959

Change-Id: I5ce0b55572ebcd2fcd11af57a5f29bbf9fa4ed33
Reviewed-on: https://go-review.googlesource.com/c/go/+/418375
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-08-31 22:09:44 +00:00
Keith Randall
69aed4712d cmd/compile: use better splitting condition for string binary search
Currently we use a full cmpstring to do the comparison for each
split in the binary search for a string switch.

Instead, split by comparing a single byte of the input string with a
constant. That will give us a much faster split (although it might be
not quite as good a split).

Fixes #53333

R=go1.20

Change-Id: I28c7209342314f367071e4aa1f2beb6ec9ff7123
Reviewed-on: https://go-review.googlesource.com/c/go/+/414894
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-08-31 22:08:26 +00:00
Keith Randall
af7f067e0d cmd/compile: tighten bounds for induction variables in strided loops
for i := 0; i < 9; i += 3

Currently we compute bounds of [0,8]. Really we know that it is [0,6].

CL 415874 computed the better bound as part of overflow detection.
This CL just incorporates that better info to the prove pass.

R=go1.20

Change-Id: Ife82cc415321f6652c2b5d132a40ec23e3385766
Reviewed-on: https://go-review.googlesource.com/c/go/+/415937
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
2022-08-31 22:04:55 +00:00
cuiweixie
52d9e7f543 runtime: convert consistentHeapStats.gen to atomic type
For #53821

Change-Id: I9f57b84f6a2c29d750fb20420daef903a9311a83
Reviewed-on: https://go-review.googlesource.com/c/go/+/425781
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-31 21:10:41 +00:00
Cuong Manh Le
ce77a46405 cmd/dist: disable cgo when testing internal linking of PIE
Since when internal linking cgo on some platforms, like android, is not
fully supported.

Updates #46731

Change-Id: I344a763f8dfb0cce04371d9305eee634bfd9ee77
Reviewed-on: https://go-review.googlesource.com/c/go/+/426199
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-08-31 20:33:16 +00:00
Wayne Zuo
da6556968f cmd/compile: simplify bounded shift on riscv64
The prove pass will mark some shifts bounded, and then we can use that
information to generate better code on riscv64.

Change-Id: Ia22f43d0598453c9417adac7017db28d7240948b
Reviewed-on: https://go-review.googlesource.com/c/go/+/422616
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-08-31 20:21:00 +00:00
Joel Sing
971373f56a cmd/compile: remove NEG when used with SEQZ/SNEZ on riscv64
The negation does not change the comparison to zero.

Also remove unnecessary x.Uses == 1 condition from equivalent BEQZ/BNEZ rules.

Change-Id: I62dd8e383e42bfe5c46d11bbf78d8e5ff862a1d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/426262
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-08-31 20:08:03 +00:00
Joel Sing
239115c3ef cmd/compile: avoid extending floating point comparision on riscv64
The result of these operations are already extended.

Change-Id: Ifc8ba362dda7035d8fd0d40046a96f61d3082877
Reviewed-on: https://go-review.googlesource.com/c/go/+/426260
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-08-31 20:05:46 +00:00
Joel Sing
9085ff5859 cmd/compile: avoid extending when already sufficiently masked on riscv64
Removes more than 2000 instructions from the Go binary on linux/risv64.

Change-Id: I6db3e3b1c93f29f00869adcba7c6192bfb90b25c
Reviewed-on: https://go-review.googlesource.com/c/go/+/426259
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Meng Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-08-31 20:05:06 +00:00
cuiweixie
3f65ddbfd3 runtime: convert rwmutex.{readerCount,readerWait} to atomic type
For #53821

Change-Id: Ib10a745799e8bc0dc1d02a9c3e5d00b2842a9edd
Reviewed-on: https://go-review.googlesource.com/c/go/+/425779
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-31 19:54:04 +00:00
cuiweixie
c708532936 cmd/compile: add support for unsafe.{String,StringData,SliceData}
For #53003

Change-Id: I13a761daca8b433b271a1feb711c103d9820772d
Reviewed-on: https://go-review.googlesource.com/c/go/+/423774
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: hopehook <hopehook@golangcn.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-31 17:15:15 +00:00
cuiweixie
301ca7513f runtime: convert worldIsStopped to atomic type
For #53821

Change-Id: I246b65ddb1171d2cab42f98092c64f20ecef392a
Reviewed-on: https://go-review.googlesource.com/c/go/+/425778
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-31 17:15:13 +00:00
Tobias Klauser
0d6a7f9d2e internal/poll, internal/syscall/unix, net, runtime: convert openbsd (except mips64) to direct libc calls
Call libc wrappers directly rather than calling using syscall(2).

Updates golang/go#36435

Change-Id: I40be410c7472f7d89cbec2ebdc7c841c7726ca4a
Reviewed-on: https://go-review.googlesource.com/c/go/+/425637
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
2022-08-31 16:59:38 +00:00
Archana R
59b15726d1 cmd/asm: fix condition check to work on ppc64
A condition check was added to parse.go in CL 405542 to prevent
usage of scaled operands on ppc64. However while trying to improve
the error notification message, an if-condition was left out by
oversight. This CL corrects that.

Change-Id: I8cef3dd194c75343354ffe888b5e639e694badde
Reviewed-on: https://go-review.googlesource.com/c/go/+/426994
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-31 16:39:34 +00:00
eric fang
ebc75ac1c6 cmd/internal/obj/arm64: allow transition from $0 to ZR for MSR
Previously the first operand of MSR could be $0, which would be
converted to the ZR register. This is prohibited by CL 404316,
this CL restores this instruction format.

Change-Id: I5b5be59e76aa58423a0fb96942d1b2a9de62e311
Reviewed-on: https://go-review.googlesource.com/c/go/+/426198
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Eric Fang <eric.fang@arm.com>
2022-08-31 16:37:20 +00:00
bqyang
bc0a033266 runtime: fix comment typo in mpagealloc.go
leve --> level

Change-Id: Ia5ff46c79c4dda2df426ec75d69e8fcede909b47
GitHub-Last-Rev: e57cad22d9
GitHub-Pull-Request: golang/go#54788
Reviewed-on: https://go-review.googlesource.com/c/go/+/426974
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Keith Randall <khr@google.com>
2022-08-31 16:27:09 +00:00
cuiweixie
fa0e3bffb4 runtime: convert semaRoot.nwait to atomic type
For #53821

Change-Id: I686fe81268f70acc6a4c3e6b1d3ed0e07bb0d61c
Reviewed-on: https://go-review.googlesource.com/c/go/+/425775
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
2022-08-31 15:33:00 +00:00
Andy Pan
6e74c4116a runtime: convert p.numTimers and p.deletedTimers to internal atomic types
Note that this changes the non-atomic operations in p.destroy() to atomic operations.

For #53821

Change-Id: I7bba77c9a2287ba697c87cce2c79293e4d1b3334
Reviewed-on: https://go-review.googlesource.com/c/go/+/425774
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-08-31 15:31:21 +00:00
cuiweixie
d01200e772 runtime: convert sig.{state,delivering} to atomic type
For #53821

Change-Id: I1c8df255ce9e2345d4fa45bd4d1761b73b9fa064
Reviewed-on: https://go-review.googlesource.com/c/go/+/425780
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-31 15:30:57 +00:00
cuiweixie
a25a34abe9 runtime: convert mcache.flushGen to atomic type
For #53821

Change-Id: I90ab52a45b7fb6b9e3ff1d6ea97251549306c7aa
Reviewed-on: https://go-review.googlesource.com/c/go/+/425435
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-31 15:30:26 +00:00
Andy Pan
d3b35a4242 runtime: convert mOS.profileTimerValid to internal atomic type
For #53821

Change-Id: I6ef90867e918d4907baa83c5a811f1f93e8c09a5
Reviewed-on: https://go-review.googlesource.com/c/go/+/426196
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-31 15:12:21 +00:00
Andy Pan
28e388589b runtime: convert workType.cycles to internal atomic types
Note that this changes a non-atomic operation to atomic operation in gcStart().

For #53821

Change-Id: I754d254f6f190855144ff62151b6bae673b47867
Reviewed-on: https://go-review.googlesource.com/c/go/+/425776
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
2022-08-31 15:12:18 +00:00
Andy Pan
5634629f0b runtime: convert extram and extraMWaiters to internal atomic type
Updates #53821

Change-Id: Id579b2f8e48dfbe9f37e02d2fa8c94354f9887a4
Reviewed-on: https://go-review.googlesource.com/c/go/+/425480
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: hopehook <hopehook@golangcn.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-31 15:01:49 +00:00
Sean Liao
3486735bf2 net/http/pprof: link docs to runtime/pprof
And add some documentation for the debug query param.

Fixes #27737
Fixes #53971

Change-Id: I629aaa2d4a43175381eb04872f1caad238519a41
Reviewed-on: https://go-review.googlesource.com/c/go/+/421635
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-31 09:38:38 +00:00
Wayne Zuo
3680b5e9c4 cmd/compile: teach prove about bitwise OR operation
Fixes #45928.

Change-Id: Ifbb0effbca4ab7c0eb56069fee40edb564553c35
Reviewed-on: https://go-review.googlesource.com/c/go/+/410336
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-31 09:35:45 +00:00
Wayne Zuo
d2e0587f77 cmd/compile: derive relation between x+delta and x in prove
If x+delta cannot overflow/underflow, we can derive:
  x+delta < x if delta<0 (this CL included)
  x+delta > x if delta>0 (this CL not included due to
  a recursive stack overflow)

Remove 95 bounds checks during ./make.bat

Fixes #51622

Change-Id: I60d9bd84c5d7e81bbf808508afd09be596644f09
Reviewed-on: https://go-review.googlesource.com/c/go/+/406175
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-08-31 09:35:10 +00:00
Khaled Yakdan
6b113c0fec cmd/compile: avoid excessive libfuzzer instrumentation of int compares
Do not intercept integer compares that are used to increment libFuzzer's
8-bit counters. This is unnecessary and has a negative impact on the
fuzzing performance. This fixes #53760.

Change-Id: Id22efac968b18014eedabb6f0762e1456897024e
GitHub-Last-Rev: 52f69fd68c
GitHub-Pull-Request: golang/go#53786
Reviewed-on: https://go-review.googlesource.com/c/go/+/416796
Run-TryBot: Keith Randall <khr@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2022-08-31 07:49:01 +00:00
shaoliming
2f103873c5 cmd/compile/internal/noder: reuse package scope's names
Change-Id: I2cc62efb7bb3b47f1ee3ed0bb77e35c47e2df9a1
GitHub-Last-Rev: 106cb494de
GitHub-Pull-Request: golang/go#54718
Reviewed-on: https://go-review.googlesource.com/c/go/+/426297
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-08-31 06:12:44 +00:00
Cuong Manh Le
ee0e40aaef reflect: use cgo.Incomplete instead of go:notinheap in tests
go:notinheap will be replaced by runtime/internal/sys.NotInHeap, and for
longer term, we want to restrict all of its usages inside the runtime
package only.

Updates #46731

Change-Id: I267adc2a19f0dc8a1ed29b5b4aeec1a7dc7318d5
Reviewed-on: https://go-review.googlesource.com/c/go/+/421880
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-31 01:16:54 +00:00
Keith Randall
bd56cb90a7 cmd/compile: regenerate node_gen.go
Looks like CL 413361 which added CaseClause.RTypes missed the need
to regenerate this file.

Also CL 413357 added DynamicTypeAssertExpr.SrcRType, same issue.

Change-Id: I45e4d0685cc2f9bdcef1fad2cfc92e7005ef363e
Reviewed-on: https://go-review.googlesource.com/c/go/+/426675
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-08-30 21:30:15 +00:00
cuiweixie
8a3d167f5b testing: increment tempDirSeq non-atomically
It's unnecessary to to call atomic.AddInt32 since there is a mutex lock.

Change-Id: I31fcece17c34f99a95772d744aebd3f6a8cf1d23
Reviewed-on: https://go-review.googlesource.com/c/go/+/426081
Reviewed-by: Michael Pratt <mpratt@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: Heschi Kreinick <heschi@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
2022-08-30 19:42:56 +00:00
Zeke Lu
3c6a5cdb9a cmd/go/internal/imports: recognize "unix" build tag
For #20322
For #51572
Fixes #54712

Change-Id: I22fcfa820e83323bfdf1a40deee7286240f02b3e
GitHub-Last-Rev: cd2c6536b0
GitHub-Pull-Request: golang/go#54716
Reviewed-on: https://go-review.googlesource.com/c/go/+/426296
Run-TryBot: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-08-30 19:01:26 +00:00
Cuong Manh Le
f21514c7f8 cmd/compile: only inline method wrapper if method don't contain closures
CL 327871 changes methodWrapper to always perform inlining after global
escape analysis. However, inlining the method may reveal closures, which
require walking all function bodies to decide whether to capture free
variables by value or by ref.

To fix it, just not doing inline if the method contains any closures.

Fixes #53702

Change-Id: I4b0255b86257cc6fe7e5fafbc545cc5cff9113e1
Reviewed-on: https://go-review.googlesource.com/c/go/+/426334
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-08-30 18:02:22 +00:00
Cuong Manh Le
ddc93a536f cmd/compile: fix unified IR shapifying recursive instantiated types
Shape-based stenciling in unified IR is done by converting type argument
to its underlying type. So it agressively check that type argument is
not a TFORW. However, for recursive instantiated type argument, it may
still be a TFORW when shapifying happens. Thus the assertion failed,
causing the compiler crashing.

To fix it, just allow fully instantiated type when shapifying.

Fixes #54512
Fixes #54722

Change-Id: I527e3fd696388c8a37454e738f0324f0c2ec16cb
Reviewed-on: https://go-review.googlesource.com/c/go/+/426335
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>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-08-30 17:23:27 +00:00
cuiweixie
c22865fcfa cmd/go: go clean should not accept flags like -modcache with packages
For #53725

Change-Id: I99a85b437d5f918dba74c4eccefcf8087193646a
Reviewed-on: https://go-review.googlesource.com/c/go/+/425874
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-08-30 17:22:49 +00:00
Archana R
67d85ad00f cmd/asm: add new classification for index memory operands on PPC64
When a base+displacement kind of operand is given in an index-mode
instruction, the assembler does not flag it as an invalid instruction
causing the user to get an incorrect encoding of that instruction
leading to incorrect execution of the program.
Enable assembler to recognize valid and invalid operands used in index
mode instructions by classifying SOREG type into two further types
XOREG (used uniquely in index addressing mode instructions) and SOREG
for instructions working on base+displacement operands.
Also cleaned up usage of obj.Addr.Scale on PPC64.

Change-Id: Ib4d84343ae57477c6c074f44c4c2749496e11b91
Reviewed-on: https://go-review.googlesource.com/c/go/+/405542
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>
2022-08-30 12:42:54 +00:00
Meng Zhuo
4381c61c58 crypto/sha512: optimize ARM64 sha512 implemention
This CL enable sha512 for arm64 and ~390% performance
improvement.

Contributed under the Go License with permission of
Linaro by Carlos Eduardo Seo <carlos.seo@linaro.org>

https://perf.golang.org/search?q=upload:20220526.18

Hash8Bytes/New		16.0MB/s ± 0%	61.3MB/s ± 0%	+283.97% (p=0.000 n=9+9)
Hash8Bytes/Sum384	16.4MB/s ± 0%	64.8MB/s ± 0%	+295.31% (p=0.000 n=8+9)
Hash8Bytes/Sum512	16.3MB/s ± 0%	64.2MB/s ± 0%	+293.37% (p=0.000 n=10+10)
Hash1K/New		252MB/s ± 0%	1217MB/s ± 0%	+383.00% (p=0.000 n=9+10)
Hash1K/Sum384		253MB/s ± 0%	1237MB/s ± 0%	+389.25% (p=0.000 n=10+10)
Hash1K/Sum512		253MB/s ± 0%	1231MB/s ± 0%	+387.37% (p=0.000 n=10+8)
Hash8K/New		284MB/s ± 0%	1405MB/s ± 2%	+395.19% (p=0.000 n=9+8)
Hash8K/Sum384		284MB/s ± 0%	1413MB/s ± 0%	+397.76% (p=0.000 n=10+8)
Hash8K/Sum512		284MB/s ± 0%	1411MB/s ± 0%	+397.19% (p=0.000 n=10+10)

Change-Id: I4476da23d8cd376bf1f75d946d6b0c58470df1b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/180257
Reviewed-by: Carlos Eduardo Seo <carlos.seo@linaro.org>
Reviewed-by: Ard Biesheuvel <ardb@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Filippo Valsorda <filippo@golang.org>
Run-TryBot: Meng Zhuo <mzh@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-30 03:43:15 +00:00
Wayne Zuo
e8f0340fa4 cmd/compile: intrinsify RotateLeft{32,64} on loong64
Benchmark on crypto/sha256 (provided by Xiaodong Liu):
name               old time/op    new time/op    delta
Hash8Bytes/New       1.19µs ± 0%    0.97µs ± 0%  -18.75%  (p=0.000 n=9+9)
Hash8Bytes/Sum224    1.21µs ± 0%    0.97µs ± 0%  -20.04%  (p=0.000 n=9+10)
Hash8Bytes/Sum256    1.21µs ± 0%    0.98µs ± 0%  -19.16%  (p=0.000 n=10+7)
Hash1K/New           15.9µs ± 0%    12.4µs ± 0%  -22.10%  (p=0.000 n=10+10)
Hash1K/Sum224        15.9µs ± 0%    12.4µs ± 0%  -22.18%  (p=0.000 n=8+10)
Hash1K/Sum256        15.9µs ± 0%    12.4µs ± 0%  -22.15%  (p=0.000 n=10+9)
Hash8K/New            119µs ± 0%      92µs ± 0%  -22.40%  (p=0.000 n=10+9)
Hash8K/Sum224         119µs ± 0%      92µs ± 0%  -22.41%  (p=0.000 n=9+10)
Hash8K/Sum256         119µs ± 0%      92µs ± 0%  -22.40%  (p=0.000 n=9+9)

name               old speed      new speed      delta
Hash8Bytes/New     6.70MB/s ± 0%  8.25MB/s ± 0%  +23.13%  (p=0.000 n=10+10)
Hash8Bytes/Sum224  6.60MB/s ± 0%  8.26MB/s ± 0%  +25.06%  (p=0.000 n=10+10)
Hash8Bytes/Sum256  6.59MB/s ± 0%  8.15MB/s ± 0%  +23.67%  (p=0.000 n=10+7)
Hash1K/New         64.3MB/s ± 0%  82.5MB/s ± 0%  +28.36%  (p=0.000 n=10+10)
Hash1K/Sum224      64.3MB/s ± 0%  82.6MB/s ± 0%  +28.51%  (p=0.000 n=10+10)
Hash1K/Sum256      64.3MB/s ± 0%  82.6MB/s ± 0%  +28.46%  (p=0.000 n=9+9)
Hash8K/New         69.0MB/s ± 0%  89.0MB/s ± 0%  +28.87%  (p=0.000 n=10+8)
Hash8K/Sum224      69.0MB/s ± 0%  89.0MB/s ± 0%  +28.88%  (p=0.000 n=9+10)
Hash8K/Sum256      69.0MB/s ± 0%  88.9MB/s ± 0%  +28.87%  (p=0.000 n=8+9)

Benchmark on crypto/sha512 (provided by Xiaodong Liu):
name               old time/op    new time/op     delta
Hash8Bytes/New       1.55µs ± 0%     1.31µs ± 0%  -15.67%  (p=0.000 n=10+10)
Hash8Bytes/Sum384    1.59µs ± 0%     1.35µs ± 0%  -14.97%  (p=0.000 n=10+10)
Hash8Bytes/Sum512    1.62µs ± 0%     1.39µs ± 0%  -14.02%  (p=0.000 n=10+10)
Hash1K/New           10.7µs ± 0%      8.6µs ± 0%  -19.60%  (p=0.000 n=8+8)
Hash1K/Sum384        10.8µs ± 0%      8.7µs ± 0%  -19.40%  (p=0.000 n=9+9)
Hash1K/Sum512        10.8µs ± 0%      8.7µs ± 0%  -19.35%  (p=0.000 n=9+10)
Hash8K/New           74.6µs ± 0%     59.6µs ± 0%  -20.08%  (p=0.000 n=10+9)
Hash8K/Sum384        74.7µs ± 0%     59.7µs ± 0%  -20.04%  (p=0.000 n=9+8)
Hash8K/Sum512        74.7µs ± 0%     59.7µs ± 0%  -20.01%  (p=0.000 n=10+10)

name               old speed      new speed       delta
Hash8Bytes/New     5.16MB/s ± 0%   6.12MB/s ± 0%  +18.60%  (p=0.000 n=10+8)
Hash8Bytes/Sum384  5.02MB/s ± 0%   5.90MB/s ± 0%  +17.56%  (p=0.000 n=10+10)
Hash8Bytes/Sum512  4.94MB/s ± 0%   5.74MB/s ± 0%  +16.29%  (p=0.000 n=10+9)
Hash1K/New         95.4MB/s ± 0%  118.6MB/s ± 0%  +24.38%  (p=0.000 n=10+10)
Hash1K/Sum384      95.0MB/s ± 0%  117.9MB/s ± 0%  +24.06%  (p=0.000 n=8+9)
Hash1K/Sum512      94.8MB/s ± 0%  117.5MB/s ± 0%  +23.99%  (p=0.000 n=8+9)
Hash8K/New          110MB/s ± 0%    137MB/s ± 0%  +25.11%  (p=0.000 n=9+6)
Hash8K/Sum384       110MB/s ± 0%    137MB/s ± 0%  +25.07%  (p=0.000 n=9+8)
Hash8K/Sum512       110MB/s ± 0%    137MB/s ± 0%  +25.01%  (p=0.000 n=10+10)

Change-Id: I28ccfce634659305a336c8e0a3f8589f7361d661
Reviewed-on: https://go-review.googlesource.com/c/go/+/422317
Reviewed-by: Keith Randall <khr@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: David Chase <drchase@google.com>
2022-08-30 03:21:44 +00:00
Wayne Zuo
7d574466a9 cmd/internal/obj/loong64: add ROTR, ROTRV instructions support
Reference: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Change-Id: I29adb84eb70bffd963c79ed6957a5197896fb2bf
Reviewed-on: https://go-review.googlesource.com/c/go/+/422316
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-08-30 03:21:06 +00:00
Cuong Manh Le
629ae1cee6 cmd/compile: fix wrong position when rewriting to OpArg/OpArgXXX
When spilling arg to stack or register, if it's a newly created value,
the arg position should be preserved. Otherwise, we may end up using
position information from deadcode lines.

This fixes the minimized test case in #54625 by mdempsky@, and make
building std successfully. However, the inline trees for these tests
still be corrupted:

 - fixedbugs/issue53982.go
 - typeparam/issue47775.go
 - typeparam/issue47775b.go
 - typeparam/issue49432.go

We probably still mess up the inline position somewhere else.

Updates #54625

Change-Id: I0d87e26b9ab451b85b6e79787da74a2b79a16209
Reviewed-on: https://go-review.googlesource.com/c/go/+/425785
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2022-08-30 00:49:19 +00:00
Cuong Manh Le
47f8db368c reflect: clarify Value.Equal behavior for non-comparable values
The current implementation always returns false for non-comparable
values, update the doc to reflect that.

Change-Id: I87f2da408874b0a209c8f51949e3310da15c5904
Reviewed-on: https://go-review.googlesource.com/c/go/+/426195
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: hopehook <hopehook@golangcn.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-08-30 00:37:15 +00:00
Bryan C. Mills
65535581aa cmd/go: skip gccgo cgo tests in TestScript/build_overlay
cgo builds with -compiler=gccgo are broken as of CL 421879.

For #54761.
Updates #46731.

Change-Id: I0306b0bd96669f70279fc96814cc72d934a1ad6e
Reviewed-on: https://go-review.googlesource.com/c/go/+/426496
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-08-29 22:04:21 +00:00
Bryan C. Mills
7b689dcbef cmd/go/internal/modfetch: distinguish "unsupported" errors from RecentTag
CL 426079 started checking errors from RecentTag.
Unfortunately, we forgot to run "-longtest" SlowBots, and it turns out
to have broken non-short tests for non-git VCS implementations,
because those don't implement the RecentTag method.

Updates #53935.

Change-Id: I5935f2f4b3f684515e99e8bf70a840154c36249f
Reviewed-on: https://go-review.googlesource.com/c/go/+/426495
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-29 21:29:04 +00:00
cuiweixie
2113fefe7d context: convert goroutines to atomic type
Change-Id: I021fbc9786a3e3f858770fe3e109a0de487390d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/426089
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: xie cui <523516579@qq.com>
Reviewed-by: Damien Neil <dneil@google.com>
2022-08-29 20:21:48 +00:00
cuiweixie
fd2ac5ef96 testing: convert common.hasSub to atomic type
Change-Id: I3d8a9b901efabe62f432c06361826f46c78d2605
Reviewed-on: https://go-review.googlesource.com/c/go/+/426080
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-29 20:19:15 +00:00
Joe Tsai
b0144b3843 sync: switch Map to use atomic.Pointer
There was no noticeable change in performance.

Change-Id: I9c57bf836c8b6066e0620afb3d536ce99e4b9d87
Reviewed-on: https://go-review.googlesource.com/c/go/+/426074
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-29 20:09:02 +00:00
Dan Kortschak
36d1f23661 debug/macho: use saferio to allocate Load and Symbol slices
Avoid allocating large amounts of memory for corrupt input.

No test case because the problem can only happen for invalid data.
Let the fuzzer find cases like this.

Change-Id: I2d1745200611f0af06ca58adcc3e2309ad6742d8
Reviewed-on: https://go-review.googlesource.com/c/go/+/425882
Run-TryBot: Dan Kortschak <dan@kortschak.io>
Auto-Submit: Dan Kortschak <dan@kortschak.io>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-08-29 20:08:15 +00:00
byarbrough
f3a1f9220a testing: explain using a _test package
The existing documentation did not explain the difference between
placing a _test.go file in the same package as what is being
tested vs. adding it to a separate _test package. This explains the
distinction and adds an example.

Concept is explained well here:  https://stackoverflow.com/a/31443271

Fixes #25223

Change-Id: Iebaba15207d8aa24f0b370d8dd4062eadb504b5c
GitHub-Last-Rev: 7f49c5f462
GitHub-Pull-Request: golang/go#54160
Reviewed-on: https://go-review.googlesource.com/c/go/+/420415
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-08-29 20:08:10 +00:00
Andy Pan
c108a682ff internal/poll: use sync.Once instead to guard CopyFileRange() with kernel 5.3
The existing implementation creates more branches with more states: -1, 0, 1,
which makes it not very intuitive to understand, let's use sync.Once and boolean
instead to make it more straightforward.

Change-Id: I05766e5fdf7dba37d6565f84d3db4373f9342fe5
Reviewed-on: https://go-review.googlesource.com/c/go/+/425880
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-08-29 20:06:09 +00:00
Tobias Klauser
9da49a7d2e time: use internal/itoa
In initLocal for GOOS=js, use internal/itoa introduced in CL 301549
instead of a local implementation.

Change-Id: If107d5cf0ce56f4d926507db2cbd6da422c6d15a
Reviewed-on: https://go-review.googlesource.com/c/go/+/425302
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-29 20:05:34 +00:00
Dan Kortschak
dbd0ce84d7 debug/elf: validate offset and file size ranges
Change-Id: Iebe31b91c6e81438120f50a8089a8efca3d5339d
Reviewed-on: https://go-review.googlesource.com/c/go/+/426115
Run-TryBot: Dan Kortschak <dan@kortschak.io>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-29 20:04:56 +00:00
Andy Pan
59bdbb3eff net: add the missing OS Darwin in the comment of sendFile
Change-Id: Ice7e3762d4a1d71e23d619be699697f5c6523cc5
Reviewed-on: https://go-review.googlesource.com/c/go/+/425879
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-29 20:04:53 +00:00
Zeke Lu
5cfeaed4de cmd/go/internal/modfetch: report error on failing to derive pseudo version from recent tag
The current implementation ignores the error when it tries to get
the recent tag on revisions, which results in incorrect pseudo
version (v0.0.0-) is derived.

Fixes #53935

Change-Id: I153d851eb913fb7e40051e194c92b9ca5bf0e906
GitHub-Last-Rev: 6ba1d90df5
GitHub-Pull-Request: golang/go#54701
Reviewed-on: https://go-review.googlesource.com/c/go/+/426079
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-08-29 19:38:15 +00:00
Joe Tsai
4029124cf4 time: add fuzz test for Time.appendFormatRFC3339
Time.appendFormatRFC3339 is a specialized implementation of
Time.appendFormat. We expect the two to be identical.
Add a fuzz test to ensure this property.

Updates #54093

Change-Id: I0bc41ee6e016d3dac75d1ac372d8c9c7266d0299
Reviewed-on: https://go-review.googlesource.com/c/go/+/425100
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
2022-08-29 19:29:37 +00:00
Ikko Ashimine
68b10c2bb8 internal/trace: fix typo in goroutines.go
assosciated -> associated

Change-Id: Id1cbbdea12f0239a9e173ece934c18cc9ffcf0f4
GitHub-Last-Rev: 7fea9de6c2
GitHub-Pull-Request: golang/go#54739
Reviewed-on: https://go-review.googlesource.com/c/go/+/425596
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
2022-08-29 19:23:57 +00:00
Pascal S. de Kloe
0e16d67a56 net/http: FileServer method check + minimal OPTIONS implementation
FileServer provides a read-only service. Methods other than GET or HEAD should
be denied with an Allow header.

Fixes #53501

Change-Id: I1d31b405eefd90565ecd474ac3f8d8d6e3b15072
Reviewed-on: https://go-review.googlesource.com/c/go/+/413554
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2022-08-29 17:12:01 +00:00
eric fang
eeb1ba7a89 cmd/compile/obj/arm64: fix encoding error of FMOVD/FMOVS $0|ZR
Previously the first operand of FMOVD and FMOVS could be $0, which
would be converted to the ZR register. This is prohibited by CL 404316,
also it broken the encoding of "FMOVD/FMOVS ZR, Rn", this CL restores
this instruction format and fixes the encoding issue.

Fixes #54655.
Fixes #54729.

Change-Id: I9c42cd41296bed7ffd601609bd8ecaa27d11e659
Reviewed-on: https://go-review.googlesource.com/c/go/+/425188
Run-TryBot: Eric Fang <eric.fang@arm.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-29 17:03:10 +00:00
Cuong Manh Le
7393049780 reflect: simplify array value comparable check
If array element is not interface, array or struct, we just need to
check whether the array element type is comparable.

Change-Id: I1ab94cfa17ae86feb6cd3fbdf878af5a776e7bec
Reviewed-on: https://go-review.googlesource.com/c/go/+/426194
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-29 16:39:37 +00:00
Nigel Tao
63e129ba1c image/png: allow both PLTE and tRNS chunks for TrueColor
Prior to this commit, png.Decode would allow TrueColor PNG images that
have one but not both of PLTE and tRNS chunks.

Fixes #54142

Change-Id: I259c1fff86a0aa5640dbadf7ad834e05fbd1430c
Reviewed-on: https://go-review.googlesource.com/c/go/+/424916
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Nigel Tao (INACTIVE; USE @golang.org INSTEAD) <nigeltao@google.com>
2022-08-29 15:11:31 +00:00
cuiweixie
a1c9783ca1 testing: convert numFailed to atomic type
Change-Id: Ic3464e95ad8901df5477d7717760b8c6d08ce97b
Reviewed-on: https://go-review.googlesource.com/c/go/+/426078
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-29 14:52:44 +00:00
ianwoolf
863d57cc7d cmd/go/internal/modload: return error when duplicate module paths among modules in go.work
Fixes #54048

Change-Id: I27350af451ff50532856092f2d99b6cc6dc6743d
Reviewed-on: https://go-review.googlesource.com/c/go/+/419557
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-29 14:48:48 +00:00
David Chase
7f92ccea5c debug/pe: check size in uint64 to avoid overflow
uint32(sz) != n*uint32(ddSz) can go wrong if
the RHS overflows, so do it in wider precision.

Fixes #54640.

Change-Id: I776563330e46de6cdacd4055f6ff08e7de67797f
Reviewed-on: https://go-review.googlesource.com/c/go/+/425364
Reviewed-by: Dan Kortschak <dan@kortschak.io>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-29 01:35:52 +00:00
Cuong Manh Le
846c378b8c cmd/cgo: add and use runtime/cgo.Incomplete instead of //go:notinheap
Updates #46731

Change-Id: Ia83f27c177cc2f57e240cb5c6708d4552423f5be
Reviewed-on: https://go-review.googlesource.com/c/go/+/421879
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-28 16:04:49 +00:00
Wayne Zuo
a6219737e3 cmd/compile: intrinsify Sub64 on riscv64
After this CL, the performance difference in crypto/elliptic
benchmarks on linux/riscv64 are:

name                 old time/op    new time/op    delta
ScalarBaseMult/P256    1.64ms ± 1%    1.60ms ± 1%   -2.36%  (p=0.008 n=5+5)
ScalarBaseMult/P224    1.53ms ± 1%    1.47ms ± 2%   -4.24%  (p=0.008 n=5+5)
ScalarBaseMult/P384    5.12ms ± 2%    5.03ms ± 2%     ~     (p=0.095 n=5+5)
ScalarBaseMult/P521    22.3ms ± 2%    13.8ms ± 1%  -37.89%  (p=0.008 n=5+5)
ScalarMult/P256        4.49ms ± 2%    4.26ms ± 2%   -5.13%  (p=0.008 n=5+5)
ScalarMult/P224        4.33ms ± 1%    4.09ms ± 1%   -5.59%  (p=0.008 n=5+5)
ScalarMult/P384        16.3ms ± 1%    15.5ms ± 2%   -4.78%  (p=0.008 n=5+5)
ScalarMult/P521         101ms ± 0%      47ms ± 2%  -53.36%  (p=0.008 n=5+5)

Change-Id: I31cf0506e27f9d85f576af1813630a19c20dda8a
Reviewed-on: https://go-review.googlesource.com/c/go/+/420095
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-27 05:43:59 +00:00
Wayne Zuo
969f48a3a2 cmd/compile: intrinsify Add64 on riscv64
According to RISCV instruction set manual v2.2 Sec 2.4, we can
implement overflowing check for unsigned addition cheaply using
SLTU instructions.

After this CL, the performance difference in crypto/elliptic
benchmarks on linux/riscv64 are:

name                 old time/op    new time/op    delta
ScalarBaseMult/P256    1.93ms ± 1%    1.64ms ± 1%  -14.96%  (p=0.008 n=5+5)
ScalarBaseMult/P224    1.80ms ± 2%    1.53ms ± 1%  -14.89%  (p=0.008 n=5+5)
ScalarBaseMult/P384    6.15ms ± 2%    5.12ms ± 2%  -16.73%  (p=0.008 n=5+5)
ScalarBaseMult/P521    25.9ms ± 1%    22.3ms ± 2%  -13.78%  (p=0.008 n=5+5)
ScalarMult/P256        5.59ms ± 1%    4.49ms ± 2%  -19.79%  (p=0.008 n=5+5)
ScalarMult/P224        5.42ms ± 1%    4.33ms ± 1%  -20.01%  (p=0.008 n=5+5)
ScalarMult/P384        19.9ms ± 2%    16.3ms ± 1%  -18.15%  (p=0.008 n=5+5)
ScalarMult/P521        97.3ms ± 1%   100.7ms ± 0%   +3.48%  (p=0.008 n=5+5)

Change-Id: Ic4c82ced4b072a4a6575343fa9f29dd09b0cabc4
Reviewed-on: https://go-review.googlesource.com/c/go/+/420094
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-27 05:43:32 +00:00
Jianwei Mao
a2d2e6e7cb net: add FlagRunning to exactly reflect the states of an interface.
Correctly set this flag while parsing the syscall result.

The FlagUp flag can not distinguish the following situations:
1. interface is plugged, automatically up, and in running(UP) state
2. interface is not plugged, administratively or manually set to up,
but in DOWN state

So, We can't distinguish the state of a NIC by the FlagUp flag alone.

Fixes #53482

Change-Id: I43796bea1a7f72d1fddfef914efe603c81995e1b
GitHub-Last-Rev: 686b5d888e
GitHub-Pull-Request: golang/go#53484
Reviewed-on: https://go-review.googlesource.com/c/go/+/413454
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ryan Schuster <shuey19831@gmail.com>
Reviewed-by: Jianwei Mao <maojianwei2020@gmail.com>
Reviewed-by: Damien Neil <dneil@google.com>
2022-08-27 05:42:03 +00:00
Paul E. Murphy
a0948493ac debug/elf: fix reloc number of R_PPC64_SECTOFF_LO_DS
R_PPC64_SECTOFF_LO_DS is defined as reloc 62 on all PPC64 ELF ABIs.

Fixes #53356

Change-Id: I5fabf6be32f3310c5aed47d4d654e05fb7bc9de0
Reviewed-on: https://go-review.googlesource.com/c/go/+/411915
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-27 02:36:28 +00:00
ianwoolf
333681d6a8 net: Resolver.LookupIP return error for empty string
Fixes #53995

Change-Id: Ib0de237b57382feb6b8070f2310945aef6c7db01
Reviewed-on: https://go-review.googlesource.com/c/go/+/419734
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
2022-08-26 22:52:50 +00:00
cuiweixie
acabf87127 reflect: add Value.{Comparable,Equal}
For #46746

Change-Id: I879124974cdb55932cd9d07d3b384d49d5059857
Reviewed-on: https://go-review.googlesource.com/c/go/+/423794
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2022-08-26 20:56:48 +00:00
Lynn Boger
897ad2fe90 cmd/compile: fix score for Select{0,1} with type flags
A recent change was made for ppc64x to treat ANDCCconst as
a tuple, allowing ANDconst to be removed from the list
of ops. Included in that change were some improvements to the
rules to avoid some extra code, mainly the elimination of a
cmp 0 following an andi. and in some cases the following
isel. While those changes worked for most cases, in a few
cases some extra unnecessary code was generated.

Currently the snippet appears in archive/zip.(*FileHeader).Mode:

        ANDCC R4,$1,R5                       // andi. r5,r4,1
        ANDCC R4,$16,R5                      // andi. r5,r4,16
        CMPW R5,R0                           // cmpw r5,r0
        ADDIS $0,$-32768,R5                  // lis r5,-32768
        OR R5,$511,R5                        // ori r5,r5,511
        MOVD $438,R6                         // li r6,438
        ISEL $2,R6,R5,R5                     // isel r5,r6,r5,eq
        MOVD $-147,R6                        // li r6,-147
        AND R6,R5,R6                         // and r6,r5,r6
        ANDCC R4,$1,R4                       // andi. r4,r4,1
        ISEL $2,R5,R6,R4                     // isel r4,r5,r6,eq

The first ANDCC is never used and should not be there.
From the ssa.html file, the scheduler is not putting the Select1
close to the ISEL, which results in the flag being clobbered
before it can be used. By changing the score for a Select0 or Select1
with type Flags, the extra ANDCC does not occur.

Change-Id: I82f4bc7c02afb1c2b1c048dc6995e0b3f9363fb3
Reviewed-on: https://go-review.googlesource.com/c/go/+/424294
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
2022-08-26 19:15:02 +00:00
cuiweixie
3d6ba27f4f net/http: don't panic on very large MaxBytesReaderLimit
Fixes #54408

Change-Id: I454199ae5bcd087b8fc4169b7622412105e71113
GitHub-Last-Rev: a33fe7e206
GitHub-Pull-Request: golang/go#54415
Reviewed-on: https://go-review.googlesource.com/c/go/+/423314
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Run-TryBot: xie cui <523516579@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: hopehook <hopehook@qq.com>
2022-08-26 18:17:27 +00:00
Archana R
9e810997c0 runtime: add address sanitizer support for ppc64le
updates #44853

Change-Id: I71905ee1bcb99ce7300bbed2daad3617d2643c53
Reviewed-on: https://go-review.googlesource.com/c/go/+/408814
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Benny Siegert <bsiegert@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Archana Ravindar <aravind5@in.ibm.com>
2022-08-26 18:13:33 +00:00
Lynn Boger
62125c9b79 cmd/compile: remove branch in atomicCas{32,64} sequence on ppc64x.
This removes one of the branches in the atomicCas sequences for
ppc64/ppc64le.

Change-Id: Ibb46fbfdce052889c69e3da298f28caff540d99b
Reviewed-on: https://go-review.googlesource.com/c/go/+/422014
Reviewed-by: Archana Ravindar <aravind5@in.ibm.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
2022-08-26 18:09:56 +00:00
Alex Studer
afd792feb5 net/http: mention io.Seeker requirement in FS documentation
Both FileServer and NewFileTransport can try to seek a file, specifically
when MIME type sniffing is performed. This can be somewhat surprising to an
implementer of an fs.FS, as their filesystem will appear to work until a
user tries to access a file with an unrecognized extension (which requires
type sniffing and therefore seeking). With FileServer, this results in a
"seeker can't seek" message, which is not very clear for the developer.

The issue arises because fs.FS does not require Seek, while http.FileSystem
does. Therefore, this change adds a line to the documentation of net/http's
adapter function mentioning the requirement.

Change-Id: Ieb955b7a7f34e2be39dd696cb712513c70100b3a
GitHub-Last-Rev: fddccdae36
GitHub-Pull-Request: golang/go#48781
Reviewed-on: https://go-review.googlesource.com/c/go/+/353874
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
Run-TryBot: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-08-26 18:05:21 +00:00
Akshay Shah
4d13aabdf6 net/http: add errors.As support for x/net/http2.StreamError
To make it easier to extract the HTTP/2 error code (if any) from
net/http errors, implement an As method on the vendored copy of
golang.org/x/net/http2.StreamError. The new As method lets users work
with the vendored error type as though it were the x/net/http2
StreamError.

Fixes #53896.

Change-Id: Ib18eb428adc05a3c0e19a946ece936e2378e1c7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/425104
Run-TryBot: Damien Neil <dneil@google.com>
Auto-Submit: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
2022-08-26 18:03:42 +00:00
Cuong Manh Le
bcd1ac7120 runtime: drop padding alignment field for timeHistogram
After CL 419449, timeHistogram always have 8-byte alignment.

Change-Id: I93145502bcafa1712b811b1a6d62da5d54d0db42
Reviewed-on: https://go-review.googlesource.com/c/go/+/425777
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-08-26 18:01:35 +00:00
Paschalis Tsilias
dba9323f76 mime: allow duplicate media type parameters with equivalent values
Fixes #48866

Change-Id: I2bd2c806e44eb4064b1fb9a6509d79cecbbef013
Reviewed-on: https://go-review.googlesource.com/c/go/+/363094
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: Tim King <taking@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: David Chase <drchase@google.com>
2022-08-26 17:58:37 +00:00
Andy Pan
296c40dbbe runtime: mark all methods of atomic types with go:nosplit
Atomic types may be used anywhere in the runtime,
so they must omit its usual stack overflow checks to avoid errors from stack splits.

Change-Id: Icb497334c860bcaa284a2d5a3edc47ee89844301
Reviewed-on: https://go-review.googlesource.com/c/go/+/425484
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-26 17:48:20 +00:00
Andy Pan
c8bb3cff9e internal/poll: optimize the maximum amount of bytes that can be transferred by one splice(2) call
Fixes #40222

name                          old time/op    new time/op    delta
Splice/tcp-to-tcp/1024-4        5.16µs ± 1%    5.17µs ± 4%     ~     (p=0.481 n=10+10)
Splice/tcp-to-tcp/2048-4        5.46µs ± 2%    5.48µs ± 2%     ~     (p=0.617 n=10+10)
Splice/tcp-to-tcp/4096-4        6.07µs ± 3%    6.09µs ± 5%     ~     (p=0.927 n=10+10)
Splice/tcp-to-tcp/8192-4        7.07µs ± 5%    7.16µs ± 3%     ~     (p=0.324 n=10+10)
Splice/tcp-to-tcp/16384-4       8.82µs ±10%    8.83µs ±11%     ~     (p=1.000 n=10+10)
Splice/tcp-to-tcp/32768-4       12.3µs ±12%    12.7µs ± 4%     ~     (p=0.268 n=10+9)
Splice/tcp-to-tcp/65536-4       22.1µs ± 3%    22.0µs ± 3%     ~     (p=0.912 n=10+10)
Splice/tcp-to-tcp/131072-4      40.0µs ± 4%    39.9µs ± 4%     ~     (p=1.000 n=9+8)
Splice/tcp-to-tcp/262144-4      69.1µs ± 3%    67.9µs ± 2%   -1.67%  (p=0.010 n=9+10)
Splice/tcp-to-tcp/524288-4       128µs ± 3%     124µs ± 2%   -2.67%  (p=0.001 n=9+10)
Splice/tcp-to-tcp/1048576-4      242µs ± 3%     242µs ± 2%     ~     (p=0.912 n=10+10)
Splice/unix-to-tcp/1024-4       1.97µs ± 3%    1.96µs ± 2%     ~     (p=0.342 n=10+10)
Splice/unix-to-tcp/2048-4       2.19µs ± 2%    2.21µs ± 2%     ~     (p=0.150 n=9+10)
Splice/unix-to-tcp/4096-4       2.52µs ± 5%    2.50µs ± 1%     ~     (p=0.393 n=10+10)
Splice/unix-to-tcp/8192-4       3.27µs ± 4%    3.24µs ± 7%     ~     (p=0.968 n=9+10)
Splice/unix-to-tcp/16384-4      4.68µs ± 9%    4.79µs ± 8%     ~     (p=0.739 n=10+10)
Splice/unix-to-tcp/32768-4      7.82µs ±12%    7.76µs ±12%     ~     (p=0.912 n=10+10)
Splice/unix-to-tcp/65536-4      17.9µs ± 3%    17.3µs ±10%     ~     (p=0.661 n=9+10)
Splice/unix-to-tcp/131072-4     35.9µs ± 1%    31.3µs ± 4%  -12.88%  (p=0.000 n=10+9)
Splice/unix-to-tcp/262144-4     72.4µs ± 3%    55.4µs ± 2%  -23.55%  (p=0.000 n=10+10)
Splice/unix-to-tcp/524288-4      146µs ± 3%     113µs ± 1%  -22.87%  (p=0.000 n=9+9)
Splice/unix-to-tcp/1048576-4     288µs ± 3%     223µs ± 3%  -22.49%  (p=0.000 n=10+9)

name                          old speed      new speed      delta
Splice/tcp-to-tcp/1024-4       198MB/s ± 1%   198MB/s ± 4%     ~     (p=0.481 n=10+10)
Splice/tcp-to-tcp/2048-4       375MB/s ± 2%   374MB/s ± 2%     ~     (p=0.631 n=10+10)
Splice/tcp-to-tcp/4096-4       674MB/s ± 3%   673MB/s ± 5%     ~     (p=0.912 n=10+10)
Splice/tcp-to-tcp/8192-4      1.16GB/s ± 6%  1.15GB/s ± 3%     ~     (p=0.315 n=10+10)
Splice/tcp-to-tcp/16384-4     1.86GB/s ±10%  1.84GB/s ±13%     ~     (p=0.720 n=10+9)
Splice/tcp-to-tcp/32768-4     2.68GB/s ±13%  2.57GB/s ± 7%     ~     (p=0.165 n=10+10)
Splice/tcp-to-tcp/65536-4     2.97GB/s ± 3%  2.98GB/s ± 3%     ~     (p=0.912 n=10+10)
Splice/tcp-to-tcp/131072-4    3.28GB/s ± 4%  3.29GB/s ± 4%     ~     (p=1.000 n=9+8)
Splice/tcp-to-tcp/262144-4    3.80GB/s ± 3%  3.86GB/s ± 2%   +1.70%  (p=0.010 n=9+10)
Splice/tcp-to-tcp/524288-4    4.10GB/s ± 3%  4.21GB/s ± 2%   +2.74%  (p=0.001 n=9+10)
Splice/tcp-to-tcp/1048576-4   4.34GB/s ± 3%  4.33GB/s ± 2%     ~     (p=0.912 n=10+10)
Splice/unix-to-tcp/1024-4      519MB/s ± 3%   523MB/s ± 2%     ~     (p=0.353 n=10+10)
Splice/unix-to-tcp/2048-4      934MB/s ± 2%   926MB/s ± 2%     ~     (p=0.156 n=9+10)
Splice/unix-to-tcp/4096-4     1.63GB/s ± 5%  1.64GB/s ± 1%     ~     (p=0.393 n=10+10)
Splice/unix-to-tcp/8192-4     2.51GB/s ± 3%  2.53GB/s ± 7%     ~     (p=0.968 n=9+10)
Splice/unix-to-tcp/16384-4    3.52GB/s ± 8%  3.43GB/s ± 8%     ~     (p=0.739 n=10+10)
Splice/unix-to-tcp/32768-4    4.21GB/s ±14%  4.24GB/s ±13%     ~     (p=0.912 n=10+10)
Splice/unix-to-tcp/65536-4    3.65GB/s ± 5%  3.81GB/s ±11%     ~     (p=0.436 n=10+10)
Splice/unix-to-tcp/131072-4   3.65GB/s ± 1%  4.19GB/s ± 4%  +14.81%  (p=0.000 n=10+9)
Splice/unix-to-tcp/262144-4   3.62GB/s ± 3%  4.73GB/s ± 2%  +30.78%  (p=0.000 n=10+10)
Splice/unix-to-tcp/524288-4   3.59GB/s ± 3%  4.66GB/s ± 1%  +29.64%  (p=0.000 n=9+9)
Splice/unix-to-tcp/1048576-4  3.65GB/s ± 3%  4.70GB/s ± 3%  +29.01%  (p=0.000 n=10+9)

name                          old alloc/op   new alloc/op   delta
Splice/tcp-to-tcp/1024-4         0.00B          0.00B          ~     (all equal)
Splice/tcp-to-tcp/2048-4         0.00B          0.00B          ~     (all equal)
Splice/tcp-to-tcp/4096-4         0.00B          0.00B          ~     (all equal)
Splice/tcp-to-tcp/8192-4         0.00B          0.00B          ~     (all equal)
Splice/tcp-to-tcp/16384-4        0.00B          0.00B          ~     (all equal)
Splice/tcp-to-tcp/32768-4        0.00B          0.00B          ~     (all equal)
Splice/tcp-to-tcp/65536-4        0.00B          0.00B          ~     (all equal)
Splice/tcp-to-tcp/131072-4       0.00B          0.00B          ~     (all equal)
Splice/tcp-to-tcp/262144-4       0.00B          0.00B          ~     (all equal)
Splice/tcp-to-tcp/524288-4       0.00B          0.00B          ~     (all equal)
Splice/tcp-to-tcp/1048576-4      0.00B          0.00B          ~     (all equal)
Splice/unix-to-tcp/1024-4        0.00B          0.00B          ~     (all equal)
Splice/unix-to-tcp/2048-4        0.00B          0.00B          ~     (all equal)
Splice/unix-to-tcp/4096-4        0.00B          0.00B          ~     (all equal)
Splice/unix-to-tcp/8192-4        0.00B          0.00B          ~     (all equal)
Splice/unix-to-tcp/16384-4       0.00B          0.00B          ~     (all equal)
Splice/unix-to-tcp/32768-4       0.00B          0.00B          ~     (all equal)
Splice/unix-to-tcp/65536-4       0.00B          0.00B          ~     (all equal)
Splice/unix-to-tcp/131072-4      0.00B          0.00B          ~     (all equal)
Splice/unix-to-tcp/262144-4      0.00B          0.00B          ~     (all equal)
Splice/unix-to-tcp/524288-4      0.00B          0.00B          ~     (all equal)
Splice/unix-to-tcp/1048576-4     0.00B          0.00B          ~     (all equal)

name                          old allocs/op  new allocs/op  delta
Splice/tcp-to-tcp/1024-4          0.00           0.00          ~     (all equal)
Splice/tcp-to-tcp/2048-4          0.00           0.00          ~     (all equal)
Splice/tcp-to-tcp/4096-4          0.00           0.00          ~     (all equal)
Splice/tcp-to-tcp/8192-4          0.00           0.00          ~     (all equal)
Splice/tcp-to-tcp/16384-4         0.00           0.00          ~     (all equal)
Splice/tcp-to-tcp/32768-4         0.00           0.00          ~     (all equal)
Splice/tcp-to-tcp/65536-4         0.00           0.00          ~     (all equal)
Splice/tcp-to-tcp/131072-4        0.00           0.00          ~     (all equal)
Splice/tcp-to-tcp/262144-4        0.00           0.00          ~     (all equal)
Splice/tcp-to-tcp/524288-4        0.00           0.00          ~     (all equal)
Splice/tcp-to-tcp/1048576-4       0.00           0.00          ~     (all equal)
Splice/unix-to-tcp/1024-4         0.00           0.00          ~     (all equal)
Splice/unix-to-tcp/2048-4         0.00           0.00          ~     (all equal)
Splice/unix-to-tcp/4096-4         0.00           0.00          ~     (all equal)
Splice/unix-to-tcp/8192-4         0.00           0.00          ~     (all equal)
Splice/unix-to-tcp/16384-4        0.00           0.00          ~     (all equal)
Splice/unix-to-tcp/32768-4        0.00           0.00          ~     (all equal)
Splice/unix-to-tcp/65536-4        0.00           0.00          ~     (all equal)
Splice/unix-to-tcp/131072-4       0.00           0.00          ~     (all equal)
Splice/unix-to-tcp/262144-4       0.00           0.00          ~     (all equal)
Splice/unix-to-tcp/524288-4       0.00           0.00          ~     (all equal)
Splice/unix-to-tcp/1048576-4      0.00           0.00          ~     (all equal)

Change-Id: I899c1fdcb3f7b9997faf2b0d2336016a3f1fd3ea
Reviewed-on: https://go-review.googlesource.com/c/go/+/425051
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-08-26 17:47:23 +00:00
Cuong Manh Le
a52f4952cb runtime: remove gcCPULimiterState padding for atomic fields alignment
assistTimePool and lastUpdate are now atomic.Int64, so they are
guaranteed to have 64-bit alignment, even on 32-bit platforms.

Change-Id: Ib6062a47c3a92d46d43899e1ae9d119e7f5b8bb0
Reviewed-on: https://go-review.googlesource.com/c/go/+/425460
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-08-26 17:46:00 +00:00
hopehook
78aef56062 cmd/go/internal/modload: convert atomicLoadPkgFlags.bits to atomic type
Change-Id: I9e59530953439dec6f4524c5a7adc75c98c12b8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/425456
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-08-26 17:45:20 +00:00
hopehook
48ecc152e4 cmd/go/internal/trace: convert traceStarted to atomic type
Change-Id: Ia4214a29775f1178273b9b7dc84c0420bfa968de
Reviewed-on: https://go-review.googlesource.com/c/go/+/425457
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-26 17:44:58 +00:00
Dan Kortschak
297e3de7a1 debug/macho: use saferio to read segment and section data
Avoid allocating large amounts of memory for corrupt input.

No test case because the problem can only happen for invalid data.
Let the fuzzer find cases like this.

Change-Id: Ib09d5fea54aabcb6941e541b42689222fba69632
Reviewed-on: https://go-review.googlesource.com/c/go/+/425303
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Dan Kortschak <dan@kortschak.io>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: hopehook <hopehook@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-26 17:44:36 +00:00
Zeke Lu
6ba2674ddc cmd/go/internal/imports: include ToolTags in the Tags map
This fixes a regression introduced when the "race" mode tag was moved to
the ToolTags field in CL 358539.

Fixes #54468

Change-Id: I107771948a4fe9d743cc13d1c15f324212b08e03
GitHub-Last-Rev: d211e351ef
GitHub-Pull-Request: golang/go#54618
Reviewed-on: https://go-review.googlesource.com/c/go/+/425154
Reviewed-by: David Chase <drchase@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-26 17:43:59 +00:00
Ludi Rehak
f50e47308d cmd/go/internal/par: change cacheEntry.done type to atomic.Bool
Change-Id: I95c941f83f74d57dfdd2d6803c9059691fb649b8
Reviewed-on: https://go-review.googlesource.com/c/go/+/422176
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: hopehook <hopehook@qq.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-08-26 17:41:34 +00:00
ianwoolf
f1f9e45143 cmd/test2json: add signal handler
Updates #53563

Change-Id: I35a3fd56718e198f68cbf73075a78b2fbc66bd7d
Reviewed-on: https://go-review.googlesource.com/c/go/+/419295
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Ryan Schuster <shuey19831@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
2022-08-26 17:38:40 +00:00
Joe Tsai
bc1d0d8eb1 reflect: add Value.SetZero
The v.SetZero method is a faster equivalent of v.Set(Zero(v.Type())).

Performance:

	                     Direct         CachedZero     NewZero
	SetZero/Bool         2.20ns ± 0%    8.97ns ± 5%    11.4ns ± 1%
	SetZero/Int          3.08ns ± 1%    9.06ns ± 1%    11.5ns ± 0%
	SetZero/Uint         2.88ns ± 1%    9.04ns ± 1%    11.7ns ± 5%
	SetZero/Float        2.65ns ± 2%    9.05ns ± 1%    11.5ns ± 1%
	SetZero/Complex      2.68ns ± 3%    9.31ns ± 1%    11.7ns ± 1%
	SetZero/Array        6.69ns ± 4%    9.32ns ± 1%    11.8ns ± 1%
	SetZero/Chan         3.31ns ± 1%    6.19ns ± 1%    8.20ns ± 1%
	SetZero/Func         3.32ns ± 1%    6.20ns ± 0%    8.24ns ± 1%
	SetZero/Interface    2.66ns ± 1%    9.31ns ± 1%    11.8ns ± 1%
	SetZero/Map          3.31ns ± 1%    6.21ns ± 2%    8.19ns ± 1%
	SetZero/Pointer      3.30ns ± 1%    6.22ns ± 1%    8.17ns ± 1%
	SetZero/Slice        2.90ns ± 4%    9.13ns ± 1%    11.6ns ± 1%
	SetZero/String       3.11ns ± 1%    9.30ns ± 1%    11.8ns ± 2%
	SetZero/Struct       6.37ns ± 1%    9.18ns ± 4%    11.5ns ± 1%

where:

	* Direct is measuring Value.SetZero
	* CachedZero is measuring Value.Set with a cached Zero value
	* NewZero is measuring Value.Set with a new Zero value

Fixes #52376

Change-Id: I793ca723aa97627824c5f5b356b2da30c8e46d71
Reviewed-on: https://go-review.googlesource.com/c/go/+/411476
Auto-Submit: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Dan Kortschak <dan@kortschak.io>
2022-08-26 17:15:08 +00:00
Andy Pan
e0ec1d6770 runtime: convert forcegcstate.idle to internal atomic type
Note that this changes a few unsynchronized operations of forcegcstate.idle to synchronized operations.

Updates #53821

Change-Id: I041654cc84a188fad45e2df7abce3a434f9a1f15
Reviewed-on: https://go-review.googlesource.com/c/go/+/425361
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-26 16:35:29 +00:00
hopehook
951d2c657d runtime: convert g.selectDone to atomic type
On the write side, g.selectDone has been converted
from non-atomic to atomic access.

For #53821.

Change-Id: Iac46bc6acce7eed51dfd990285dd57f0d58b4ae2
Reviewed-on: https://go-review.googlesource.com/c/go/+/425414
Run-TryBot: hopehook <hopehook@qq.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-26 15:36:36 +00:00
hopehook
7a1ae605eb runtime: convert notifyList.wait to atomic type
For #53821

Change-Id: Ib096332fe6111bbcd2f5c4cbb29c2fef7a808e7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/425784
Run-TryBot: hopehook <hopehook@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-08-26 15:36:07 +00:00
hopehook
2af9ee0727 runtime: convert dlogger.owned to atomic type
Note that this changes a non-atomic operation to atomic operation.

For #53821

Change-Id: I798914f505c8d7f85f9d7629fdc6493363a20aa1
Reviewed-on: https://go-review.googlesource.com/c/go/+/425782
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: hopehook <hopehook@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-26 15:35:46 +00:00
hopehook
2883af63c2 runtime: convert p.statsSeq to internal atomic type
For #53821.

Change-Id: I1cab3671a29c218b8a927aba9064e63b65900173
Reviewed-on: https://go-review.googlesource.com/c/go/+/425416
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Run-TryBot: hopehook <hopehook@qq.com>
2022-08-26 15:35:13 +00:00
Cherry Mui
1211a62bdc cmd/compile: align stack offset to alignment larger than PtrSize
In typebits.Set we check that the offset is a multiple of the
alignment, which makes perfect sense. But for values like
atomic.Int64, which has 8-byte alignment even on 32-bit platforms
(i.e. the alignment is larger than PtrSize), if it is on stack it
may be under-aligned, as the stack frame is only PtrSize aligned.

Normally we would prevent such values on stack, as the escape
analysis force values with higher alignment to heap. But for a
composite literal assignment like x = AlignedType{...}, the
compiler creates an autotmp for the RHS then copies it to the LHS.
The autotmp is on stack and may be under-aligned. Currently this
may cause an ICE in the typebits.Set check.

This CL makes it align the _offset_ of the autotmp to 8 bytes,
which satisfies the check. Note that this is actually lying: the
actual address at run time may not necessarily be 8-byte
aligned as we only align SP to 4 bytes.

The under-alignment is probably okay. The only purpose for the
autotmp is to copy the value to the LHS, and the copying code we
generate (at least currently) doesn't care the alignment beyond
stack alignment.

Fixes #54638.

Change-Id: I13c16afde2eea017479ff11dfc24092bcb8aba6a
Reviewed-on: https://go-review.googlesource.com/c/go/+/425256
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: David Chase <drchase@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-26 15:24:31 +00:00
cuiweixie
d7a3fa120d reflect: FuncOf support more than 50 arguments
Fixes #54669

Change-Id: I34cbe729d187437ddeafbaa910af6ed001b2603f
Reviewed-on: https://go-review.googlesource.com/c/go/+/425461
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2022-08-26 14:32:13 +00:00
Robert Griesemer
2eba2ff8a1 go/types: provide a better error message for [...] array types
This matches types2 behavior.

For #54511.

Change-Id: Iea906e9fec7e334b7aa7f481de87373fa93d1c7c
Reviewed-on: https://go-review.googlesource.com/c/go/+/425715
Reviewed-by: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-26 03:34:25 +00:00
Robert Griesemer
27006657fa go/types: avoid declared but not used error for a couple of cases
The change in typexpr.go matches types2 behavior.

For #54511.

Change-Id: I79c922a94f2ee0440c1814140935c321439c7d25
Reviewed-on: https://go-review.googlesource.com/c/go/+/425714
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-08-26 03:34:24 +00:00
Andy Pan
aab8d2b448 runtime: convert netpollWaiters to internal atomic type
Updates #53821

Change-Id: I8776382b3eb0b7752cfc0d9287b707039d3f05c6
Reviewed-on: https://go-review.googlesource.com/c/go/+/425358
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: hopehook <hopehook@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-08-25 21:52:20 +00:00
Robert Griesemer
73a55c1704 go/types: remove support for "ERROR HERE" error markers in tests
There are only two tests that rely on the "ERROR HERE" markers;
yet those tests are trivialy adjustable (by adding an explicit
semicolon) such that they can just use the "ERROR" markers.

For #54511.

Change-Id: Idbb96ca8d35ae2584d195a4ac7c92640b8b492c5
Reviewed-on: https://go-review.googlesource.com/c/go/+/425674
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
2022-08-25 21:07:24 +00:00
hitzhangjie
04eb35998a cmd/trace: display goroutines (PC=0) with clearer description
This PR fixes: #54425 #49994

Change-Id: Id60a3ba6930f8e29b12b6d8f80945decd2ce31bc
GitHub-Last-Rev: 60a040aa2f
GitHub-Pull-Request: golang/go#54575
Reviewed-on: https://go-review.googlesource.com/c/go/+/425042
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-25 20:44:19 +00:00
Michael Anthony Knyszek
56bdf7f7d9 runtime: update gctrace docs and print lastStackScan instead of max
This change updates the gctrace docs to include stacks and globals in
the format line, and prints lastStackScan for "# MB stacks" instead of
maxStackScan, which is more accurate.

Fixes #54649.

Change-Id: Ibff2c390c9c9bf2b24b5b4e98ca346cc98d7cb2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/425366
Run-TryBot: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-25 20:37:28 +00:00
Filippo Valsorda
f64f12f0b3 crypto/x509: don't panic marshaling invalid ECDSA keys
MarshalPKIXPublicKey, CreateCertificate, CreateCertificateRequest,
MarshalECPrivateKey, and MarshalPKCS8PrivateKey started raising a panic
when encoding an invalid ECDSA key in Go 1.19. Since they have an error
return value, they should return an error instead.

Fixes #54288

Change-Id: Iba132cd2f890ece36bb7d0396eb9a9a77bdb81df
Reviewed-on: https://go-review.googlesource.com/c/go/+/422298
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Run-TryBot: Filippo Valsorda <filippo@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-08-25 19:17:14 +00:00
Robert Griesemer
b9bf824655 go/parser: match go/defer error message of syntax package
Adjust corresponding type checker tests accordingly.

For #54511.

Change-Id: Ieaf29f26c0877973fc0acbde35292cd69a4b709c
Reviewed-on: https://go-review.googlesource.com/c/go/+/425007
Auto-Submit: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-25 19:10:01 +00:00
Paschalis Tsilias
95a786da12 path/filepath, io/fs: add SkipAll
Fixes #47209

Change-Id: If75b0dd38f2c30a23517205d80c7a6683a5c921c
Reviewed-on: https://go-review.googlesource.com/c/go/+/363814
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
Run-TryBot: Daniel Martí <mvdan@mvdan.cc>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-08-25 18:50:37 +00:00
Matthew Dempsky
6a801d3082 cmd/compile/internal/noder: fix inlined function literal positions
When inlining function calls, we rewrite the position information on
all of the nodes to keep track of the inlining context. This is
necessary so that at runtime, we can synthesize additional stack
frames so that the inlining is transparent to the user.

However, for function literals, we *don't* want to apply this
rewriting to the underlying function. Because within the function
literal (when it's not itself inlined), the inlining context (if any)
will have already be available at the caller PC instead.

Unified IR was already getting this right in the case of user-written
statements within the function literal, which is what the unit test
for #46234 tested. However, it was still using inline-adjusted
positions for the function declaration and its parameters, which
occasionally end up getting used for generated code (e.g., loading
captured values from the closure record).

I've manually verified that this fixes the hang in
https://go.dev/play/p/avQ0qgRzOgt, and spot-checked the
-d=pctab=pctoinline output for kube-apiserver and kubelet and they
seem better.

However, I'm still working on a more robust test for this (hence
"Updates" not "Fixes") and internal assertions to verify that we're
emitting correct inline trees. In particular, there are still other
cases (even in the non-unified frontend) where we're producing
corrupt (but at least acyclic) inline trees.

Updates #54625.

Change-Id: Iacfd2e1eb06ae8dc299c0679f377461d3d46c15a
Reviewed-on: https://go-review.googlesource.com/c/go/+/425395
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-08-25 18:46:22 +00:00
hopehook
396b153ec4 testing: add Elapsed method to testing.B
Elapsed returns the measured elapsed time of the benchmark,
but does not change the running state of the timer.

Fixes #43620.

Change-Id: Idd9f64c4632518eec759d2ffccbf0050d84fcc03
Reviewed-on: https://go-review.googlesource.com/c/go/+/420254
Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: hopehook <hopehook@qq.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2022-08-25 17:58:32 +00:00
Robert Griesemer
83b5fe6351 go/types: match types2 string when printing composite literals
Given a composite literal type S, rather than always printing
(S literal) for a composite literals, print S{} if the literal
has no elements, and print S{…} as a short form (suitable for
error messages) if there are elements. This matches types2 and
also Go1.17 compiler behavior (except that the original compiler
would print ... rather than …). Using … rather than ... makes
it clearer that we don't have real Go syntax, and it's also more
compact.

For #54511.

Change-Id: I5991e8060232f16ecbf4a1fe4ae091598fc76b68
Reviewed-on: https://go-review.googlesource.com/c/go/+/425006
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2022-08-25 17:31:33 +00:00
Filippo Valsorda
1df2a03b17 crypto/tls: support ECDHE when ec_point_formats is missing
Fixes #49126

Change-Id: I9d6f6392b1a6748bdac1d2c6371b22d75829a2b6
Reviewed-on: https://go-review.googlesource.com/c/go/+/425295
Run-TryBot: Filippo Valsorda <filippo@golang.org>
Auto-Submit: Filippo Valsorda <filippo@golang.org>
Reviewed-by: Alex Scheel <alex.scheel@hashicorp.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Roland Shoemaker <roland@golang.org>
Reviewed-by: David Chase <drchase@google.com>
2022-08-25 16:35:38 +00:00
Cherry Mui
e4be2ac79f runtime: mark morestack_noctxt SPWRITE on LR architectures
On LR architectures, morestack (and morestack_noctxt) are called
with a special calling convention, where the caller doesn't save
LR on stack but passes it as a register, which morestack will save
to g.sched.lr. The stack unwinder currently doesn't understand it,
and would fail to unwind from it. morestack already writes SP (as
it switches stack), but morestack_noctxt (which tailcalls
morestack) doesn't. If a profiling signal lands right in
morestack_noctxt, the unwinder will try to unwind the stack and
go off, and possibly crash.

Marking morestack_noctxt SPWRITE stops the unwinding.

Ideally we could teach the unwinder about the special calling
convention, or change the calling convention to be less special
(so the unwinder doesn't need to fetch a register from the signal
context). This is a stop-gap solution, to stop the unwinder from
crashing.

Fixes #54332.

Change-Id: I75295f2e27ddcf05f1ea0b541aedcb9000ae7576
Reviewed-on: https://go-review.googlesource.com/c/go/+/425396
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Cherry Mui <cherryyz@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
2022-08-25 14:56:18 +00:00
Robert Griesemer
8c8429fe41 go/types, types2: add more tests for unsafe.Slice/SliceData/String/StringData
Also:
- fine-tune the implementation for some of the new builtin functions
- make sure the go/types code is an exact as possible copy of the
  types2 code
- fix the description and examples for errorcodes.go

Follow-up on CL 423754.

For #53003.

Change-Id: I5c70b74e90c724cf6c842cedc6f8ace26fde372b
Reviewed-on: https://go-review.googlesource.com/c/go/+/425454
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-08-25 04:00:07 +00:00
cuiweixie
ba5deb408f go/types,types2: add support for unsafe.{String,StringData,SliceData}
For #53003
Change-Id: Id3125268523fed855ffac20cde6128010e3513f0
Reviewed-on: https://go-review.googlesource.com/c/go/+/423754
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Robert Griesemer <gri@google.com>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-24 22:39:01 +00:00
Matthew Dempsky
e4bed415ea go/internal/gcimporter: call Complete on cloned Interfaces too
For "type T interface{ M() }", go/types users expect T's underlying
interface type to specify T as the receiver parameter type (#49906).
The unified importer handles this by cloning the interface to rewrite
the receiver parameters before calling SetUnderlying.

I missed in CL 425360 that these interfaces would need to have
Complete called too.

Manually tested to confirm that this actually fixes "go test -race
golang.org/x/tools/go/analysis/internal/checker" now (when both CLs
are ported to the x/tools importer).

Updates #54653.

Change-Id: I51e6db925db56947cd39dbe880230f14734ca01c
Reviewed-on: https://go-review.googlesource.com/c/go/+/425365
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-08-24 21:09:24 +00:00
Matthew Dempsky
bdf2db7255 go/internal/gcimporter: call Interface.Complete in unified importer
To support concurrent use of the go/types API, importers need to call
Interface.Complete on constructed interfaces before returning.

There's an issue that the interfaces may contain embedded defined
types, whose underlying type isn't known yet. This issue will
eventually go away once CL 424876 lands, but that CL needs to wait for
CL 424854 to re-land, which needs to wait for CL 421879 to land...

In the mean time, this CL implements the same solution used by the
indexed importer: maintaining a list of constructed interfaces, and
calling Interface.Complete on them after the SetUnderlying loop and
just before returning the imported package.

Updates #54653.

Change-Id: I0f42c915a4b7d28c628bbab7ac2eab2415c7858f
Reviewed-on: https://go-review.googlesource.com/c/go/+/425360
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
2022-08-24 19:39:31 +00:00
Wayne Zuo
b60432df14 cmd/compile: deadcode for LoweredMuluhilo on riscv64
This is a follow up of CL 425101 on RISCV64.

According to RISCV Volume 1, Unprivileged Spec v. 20191213 Chapter 7.1:
If both the high and low bits of the same product are required, then the
recommended code sequence is: MULH[[S]U] rdh, rs1, rs2; MUL rdl, rs1, rs2
(source register specifiers must be in same order and rdh cannot be the
same as rs1 or rs2). Microarchitectures can then fuse these into a single
multiply operation instead of performing two separate multiplies.

So we should not split Muluhilo to separate instructions.

Updates #54607

Change-Id: If47461f3aaaf00e27cd583a9990e144fb8bcdb17
Reviewed-on: https://go-review.googlesource.com/c/go/+/425203
Auto-Submit: Keith Randall <khr@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2022-08-24 18:08:33 +00:00
Alexander Yastrebov
8a86b94aef net/http: remove unused doneChan
The https://golang.org/cl/43230 removed use of `getDoneChan`.

Change-Id: I33390c0e3aea6d98367363773ebe39d9c1f64ae9
GitHub-Last-Rev: fe1e4154ea
GitHub-Pull-Request: golang/go#53172
Reviewed-on: https://go-review.googlesource.com/c/go/+/409538
Run-TryBot: Damien Neil <dneil@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
Reviewed-by: hopehook <hopehook@qq.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2022-08-24 17:12:07 +00:00
Bryan C. Mills
2fc21b50e4 cmd/go: skip link_syso tests in short mode
These tests invoke the system C compiler and linker.
Skipping them saves a little over half a second of time in short mode.

Updates #54423.

Change-Id: I3e8aa7b53c0c91f7d1e001ec2cd5f7b4954de52d
Reviewed-on: https://go-review.googlesource.com/c/go/+/425206
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-08-24 16:06:46 +00:00
Bryan C. Mills
55d96f98ef cmd/go/internal/work: make NewBuilder safe for concurrent and repeated use
Ever since 'go build' was added (in CL 5483069), it has used an atexit
handler to clean up working directories. At some point (prior to CL
95900044), Init was called multiple times per builder, registering
potentially many atexit handlers that execute asynchronously and make
debugging more difficult.

The use of an AtExit handler also makes the Builder (and anything that
uses it) prone to races: the base.AtExit API is not designed for
concurrent use, but cmd/go is becoming increasingly concurrent over
time. The AtExit handler also makes the Builder inappropriate to use
within a unit-test, since the handlers do not run during the test
function and accumulate over time.

This change makes NewBuilder safe for concurrent use by registering
the AtExit handler only once (during BuildInit, which was already not
safe for concurrent use), and using a sync.Map to store the set of
builders that need cleanup in case of an unclean exit. In addition, it
causes the test variant of cmd/go to fail if any Builder instance
leaks from a clean exit, helping to ensure that functions that create
Builders do not leak them indefinitely, especially in tests.

Updates #54423.

Change-Id: Ia227b15b8fa53c33177c71271d756ac0858feebe
Reviewed-on: https://go-review.googlesource.com/c/go/+/425254
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
2022-08-24 16:06:13 +00:00
Bryan C. Mills
3083529367 cmd/go: avoid overwriting cached Origin metadata
Fixes #54631.

Change-Id: I17d2fa282642aeb1ae2a6e29a0756b8960bea34b
Reviewed-on: https://go-review.googlesource.com/c/go/+/425255
Run-TryBot: 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>
2022-08-24 16:00:07 +00:00
Bryan C. Mills
d5aa088d82 cmd/go: avoid registering AtExit handlers in tests
Ever since 'go build' was added (in CL 5483069), it has used an atexit
handler to clean up working directories.

CL 154109 introduced 'cc' command to the script test framework that
called Init on a builder once per invocation. Unfortunately, since
base.AtExit is unsynchronized, the Init added there caused any script
that invokes that command to be unsafe for concurrent use.

This change fixes the race by having the 'cc' command pass in its
working directory instead of allowing the Builder to allocate one.
Following modern Go best practices, it also replaces the in-place Init
method (which is prone to typestate and aliasing bugs) with a
NewBuilder constructor function.

Fixes #54423.

Change-Id: I8fc2127a7d877bb39a1174e398736bb51d03d4d2
Reviewed-on: https://go-review.googlesource.com/c/go/+/425205
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2022-08-24 15:37:38 +00:00
Matthew Dempsky
f983a9340d cmd/compile: defer transitive inlining until after AST is edited
This CL changes the inliner to process transitive inlining iteratively
after the AST has actually been edited, rather than recursively and
immediately. This is important for handling indirect function calls
correctly, because ir.reassigned walks the function body looking for
reassignments; whereas previously the inlined reassignments might not
have been actually added to the AST yet.

Fixes #54632.

Change-Id: I0dd69813c8a70b965174e0072335bc00afedf286
Reviewed-on: https://go-review.googlesource.com/c/go/+/425257
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
2022-08-24 14:31:08 +00:00