1
0
mirror of https://github.com/golang/go synced 2024-11-16 21:54:51 -07:00
Commit Graph

58209 Commits

Author SHA1 Message Date
Michael Pratt
696fb5ead0 cmd/internal/objabi: add inverse of PathToPrefix
Add PrefixToPath, which can be used to convert a package path in a
symbol name back to the original package path.

For #61577.

Change-Id: Ifbe8c852a7f41ff9b81ad48b92a26a0e1b046777
Reviewed-on: https://go-review.googlesource.com/c/go/+/529557
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-10-13 13:56:25 +00:00
Joel Sing
d1ef967306 cmd/link/internal/ld: assign temporary addresses to per-package text
If trampolines may be required, the current text addressing second
pass resets all assigned addresses, before assigning addresses and
laying down trampolines in a linear fashion. However, this approach
means that intra-package calls are to a symbol that has not yet
been assigned an address, when the symbol is ahead of the current
function.

In the case of RISC-V the JAL instruction is limited to +/-1MiB.
As such, if a call is to a symbol with no address currently assigned,
we have to assume that a trampoline will be required. During the
relocation phase we can fix up and avoid trampolines in some cases,
however this results in unused trampolines that are still present
in the binary (since removing them would change text addresses).

In order to significantly reduce the number of unused trampolines,
assign temporary addresses to functions within the same package,
based on the maximum number of trampolines that may be required by
a function. This allows for better decisions to be made regarding
the requirement for intra-package trampolines, as we reset the
addressing for a function, assign its final address and lay down
any resulting trampolines.

This results in ~2,300 unused trampolines being removed from the
Go binary and ~5,600 unused trampolines being removed from the
compile binary, on linux/riscv64.

This reapplies CL 349650, however does not pass big to assignAddress
when assigning temporary addresses, as this can result in side
effects such as section splitting.

Change-Id: Id7febdb65d962d6b1297a91294a8dc27c94d8696
Reviewed-on: https://go-review.googlesource.com/c/go/+/534760
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Joel Sing <joel@sing.id.au>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-10-13 05:45:53 +00:00
apocelipes
cc13161a0d encoding/xml: use reflect.Value.IsZero
IsZero does the same thing, using this rather than writing it again.

Change-Id: I62810ac2d1a6e189feac03b022c8931fb6993e19
GitHub-Last-Rev: 1d5fd10d96
GitHub-Pull-Request: golang/go#63519
Reviewed-on: https://go-review.googlesource.com/c/go/+/534935
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-10-12 20:48:17 +00:00
Cherry Mui
15a274b621 runtime: don't print "unexpected SPWRITE" when printing traceback
The system stack often starts with a stack transition function
like "systemstack" or "mcall", which is marked as SPWRITE. When
unwinding a system stack for printing, we want the traceback stop
at the stack switching frame, but not print the "unexpected
SPWRITE" message.

Previously before CL 525835, we don't print the "unexpected
SPWRITE" message if unwindPrintErrors is set, i.e. printing a
stack trace. This CL restores this behavior.

Another possibility is not printing the message only on the system
stack. We don't expect a stack transition function to appear in a
user G.

Change-Id: I173e89ead2cd4fbf1f0f8cca225f28718b5baebe
Reviewed-on: https://go-review.googlesource.com/c/go/+/531815
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-10-12 20:11:47 +00:00
Michael Pratt
b56645a87b cmd/compile: synchronize inlinability logic between hairyVisitor and mkinlcall
When computing function cost, hairyVisitor.doNode has two primary cases
for determining the cost of a call inside the function:

* Normal calls are simply cost 57.
* Calls that can be inlined have the cost of the inlined function body,
  since that body will end up in this function.

Determining which "calls can be inlined" is where this breaks down.
doNode simply assumes that any function with `fn.Inl != nil` will get
inlined. However, this are more complex in mkinlcall, which has a
variety of cases where it may not inline.

For standard builds, most of these reasons are fairly rare (recursive
calls, calls to runtime functions in instrumented builds, etc), so this
simplification isn't too build.

However, for PGO builds, any function involved in at least one inlinable
hot callsite will have `fn.Inl != nil`, even though mkinlcall will only
inline at the hot callsites. As a result, cold functions calling hot
functions will use the (potentially very large) hot function inline body
cost in their call budget. This could make these functions too expensive
to inline even though they won't actually inline the hot function.

Handle this case plus the other inlinability cases (recursive calls,
etc) by consolidating mkinlcall's inlinability logic into
canInlineCallExpr, which is shared by doNode.

mkinlcall and doNode now have identical logic, except for one case: we
check for recursive cycles via inlined functions by looking at the
inline tree. Since we haven't actually done any inlining yet when in
doNode, we will miss those cases.

This CL doesn't change any inlining decisions in a standard build of the
compiler.

In the new inliner, the inlining decision is also based on the call
site, so this synchronization is also helpful.

Fixes #59484

Change-Id: I6ace66e37d50526535972215497ef75cd71f8b9d
Reviewed-on: https://go-review.googlesource.com/c/go/+/483196
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-10-12 18:12:19 +00:00
Keith Randall
657c885fb9 cmd/compile: when combining stores, use line number of first store
var p *[2]uint32 = ...
p[0] = 0
p[1] = 0

When we combine these two 32-bit stores into a single 64-bit store,
use the line number of the first store, not the second one.
This differs from the default behavior because usually with the combining
that the compiler does, we use the line number of the last instruction
in the combo (e.g. load+add, we use the line number of the add).

This is the same behavior that gcc does in C (picking the line
number of the first of a set of combined stores).

Change-Id: Ie70bf6151755322d33ecd50e4d9caf62f7881784
Reviewed-on: https://go-review.googlesource.com/c/go/+/521678
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: David Chase <drchase@google.com>
2023-10-12 18:09:26 +00:00
cui fliter
e4f72f7736 compress: add available godoc link
Change-Id: Ia6e88aec59cb294e8b303a00fcd69f4cbf0dc09a
Reviewed-on: https://go-review.googlesource.com/c/go/+/534759
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
2023-10-12 14:39:39 +00:00
cui fliter
ade730a96c container/heap: add available godoc link
Change-Id: I886a8869ba885286ac8219bc7e245c9237ad4c99
Reviewed-on: https://go-review.googlesource.com/c/go/+/534777
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-10-12 14:39:10 +00:00
cui fliter
cf97cd317b bufio: add available godoc link
Change-Id: Id32bae57c9fcc2074f82089ba9c69be9a601f128
Reviewed-on: https://go-review.googlesource.com/c/go/+/534758
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-10-12 14:39:08 +00:00
Ian Lance Taylor
a762ea17ec runtime: don't use atomic store in noteclear on AIX
In CL 163624 we added an atomic store in noteclear on AIX only.
In the discussion on issue #63384 we think we figured out that the
real problem was in the implementation of compare-and-swap on ppc64.
That is fixed by CL 533118, so the atomic store is no longer required.

For #30189
For #63384

Change-Id: I60f4f2fac75106f2bee51a8d9663259dcde2029c
Reviewed-on: https://go-review.googlesource.com/c/go/+/534517
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Joel Sing <joel@sing.id.au>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-10-12 14:16:07 +00:00
David Chase
eb832afb23 cmd/compiler: make decompose shortcuts apply for PtrShaped, not just Ptr
The immediate-data interface shortcuts also apply to pointer-shaped
things like maps, channels, and functions.

Fixes #63505.

Change-Id: I43982441bf523f53e9e5d183e95aea7c6655dd6b
Reviewed-on: https://go-review.googlesource.com/c/go/+/534657
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: David Chase <drchase@google.com>
Auto-Submit: David Chase <drchase@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-10-12 00:48:31 +00:00
Cherry Mui
872d7181f4 runtime/cgo: avoid taking the address of crosscall2 in code
Currently, set_crosscall2 takes the address of crosscall2 without
using the GOT, which, on some architectures, results in a
PC-relative relocation (e.g. R_AARCH64_ADR_PREL_PG_HI21 on ARM64)
to the crosscall2 symbol. But crosscall2 is dynamically exported,
so the C linker thinks it may bind to a symbol from a different
DSO. Some C linker may not like a PC-relative relocation to such a
symbol. Using a local trampoline to avoid taking the address of a
dynamically exported symbol.

It may be possible to not dynamically export crosscall2. But this
CL is safer for backport. Later we may remove the trampolines
after unexport crosscall2, if they are not needed.

Fixes #62556.

Change-Id: Id28457f65ef121d3f87d8189803abc65ed453283
Reviewed-on: https://go-review.googlesource.com/c/go/+/533535
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-10-12 00:43:51 +00:00
Ian Lance Taylor
3b0fc5a51f net: clear malloc'ed memory in cgoResSearch
For #61666

Change-Id: I7a0a849fba0abebe28804bdd6d364b154456e399
Reviewed-on: https://go-review.googlesource.com/c/go/+/534516
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-10-11 22:40:01 +00:00
Ian Lance Taylor
655155d0a7 cmd/compile, runtime/internal/atomic: add lwsync for false ppc64 cas
This CL changes ppc64 atomic compare-and-swap (cas). Before this CL,
if the cas failed--if the value in memory was not the value expected
by the cas call--the atomic function would not synchronize memory.

In the note code in runtime/lock_sema.go, used on BSD systems,
notesleep and notetsleep first try a cas on the key. If that cas fails,
something has already called notewakeup, and the sleep completes.
However, because the cas did not synchronize memory on failure,
this meant that notesleep/notetsleep could return to a core that was
unable to see the memory changes that the notewakeup was reporting.

Fixes #30189
Fixes #63384

Change-Id: I9b921de5c1c09b10a37df6b3206b9003c3f32986
Reviewed-on: https://go-review.googlesource.com/c/go/+/533118
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-10-11 21:04:25 +00:00
Ian Lance Taylor
e7c142a19d cmd/compile: use absolute file name in isCgo check
For #23672
Fixes #63211
Fixes CVE-2023-39323

Change-Id: I4586a69e1b2560036afec29d53e53cf25e6c7352
Reviewed-on: https://team-review.git.corp.google.com/c/golang/go-private/+/2032884
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Roland Shoemaker <bracewell@google.com>
Reviewed-on: https://go-review.googlesource.com/c/go/+/534158
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-10-11 20:40:57 +00:00
Olivier Mengué
a5943e9de1 io/fs: add godoc links
Change-Id: Icde42bd33d58f75acdede439f7525f9d06554140
Reviewed-on: https://go-review.googlesource.com/c/go/+/534096
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-10-11 20:25:50 +00:00
Olivier Mengué
eff7aef4eb regexp: add godoc links
Change-Id: I087162f866e781258f9fbb96215c1ff6a5c315a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/507776
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-10-11 20:23:37 +00:00
cui fliter
2470d05872 maps: add examples for Clone,Copy and Equal
Change-Id: I72adaf48588e7d6cffbc0ee8005decda06808e84
Reviewed-on: https://go-review.googlesource.com/c/go/+/534055
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-10-11 20:21:56 +00:00
Olivier Mengué
53d000d75b testing/fstest: add godoc links
Change-Id: I611f04f12bb93197fea5ae40a08e5f60426f1c00
Reviewed-on: https://go-review.googlesource.com/c/go/+/534076
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-11 20:21:27 +00:00
Olivier Mengué
09aada24aa testing/fstest: MapFS: set perm 0555 on synthetized dirs
As MapFS ignores filemodes and always grant read and traverse access on
directories, let's make synthetized directory entries to expose filemode
0555 instead of 0000.
Fixes #63468.

Change-Id: I5d64a6bf2f2ac6082ca5dde55b3062669fb50b8d
Reviewed-on: https://go-review.googlesource.com/c/go/+/534075
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-11 20:20:55 +00:00
Michael Pratt
7241fee9b0 runtime: remove write-only sweepdata fields
Change-Id: Ia238889a704812473b838b20efedfe9d24b1e26f
Reviewed-on: https://go-review.googlesource.com/c/go/+/534160
Auto-Submit: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
2023-10-11 16:55:22 +00:00
Michael Pratt
47a71d1ec9 runtime: remove stale non-atomic access comment
CL 397014 converted this into an atomic access.

Change-Id: Ib97716cd19ecd7d6bf8601baf0391755a5baf378
Reviewed-on: https://go-review.googlesource.com/c/go/+/534159
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-11 16:55:20 +00:00
Austin Clements
ee8b8e988c cmd/go: clean up "cover" debug output
Currently, the two places that run the cover tool manually construct a
terse command description. However, this actually prevents Builder.run
from constructing a more detailed description from the actual command
being run. Fix this by passing "" as the description to get the
default behavior.

Change-Id: I27d42cb1fda9bba70c631dc43417a03b8bddec92
Reviewed-on: https://go-review.googlesource.com/c/go/+/534157
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Austin Clements <austin@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-10-11 16:39:44 +00:00
Cuong Manh Le
e12bdc80f2 types2, go/types: remove doc link from Func.Pkg comment
The documentation link only works with exported identifiers. Further,
the built-in error interface lives in pseudo package "builtin" only,
thus it's not a real package that can be referred using doc links.

Change-Id: I2116beb27fc73ba33f8352301fe77b4b6abc3ec1
Reviewed-on: https://go-review.googlesource.com/c/go/+/534436
Reviewed-by: Robert Findley <rfindley@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
2023-10-11 12:48:03 +00:00
Jonathan Amsterdam
dacf1f1e10 go/types: clarify the documentation for Func.Pkg
Change-Id: Ia695960ba652143f4a48c1ca3495a043097acbb7
Reviewed-on: https://go-review.googlesource.com/c/go/+/534298
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Reviewed-by: Alan Donovan <adonovan@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
2023-10-10 22:48:41 +00:00
Than McIntosh
7c446bab63 Revert "cmd/link/internal/ld: assign temporary addresses to per-package text"
This reverts commit http://go.dev/cl/349650

Reason for revert: CL breaks multiple builders with failure in TestLargeTextSectionSplitting

Change-Id: I4894ffd101b2757a6e6359212d5b8a64da1fcdf0
Reviewed-on: https://go-review.googlesource.com/c/go/+/534299
Run-TryBot: Than McIntosh <thanm@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Than McIntosh <thanm@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-10-10 20:47:17 +00:00
qmuntal
e7015c9327 runtime: quote -ex and -iex gdb arguments on Windows
On Windows, some gdb flavors expect -ex and -iex arguments containing
spaces to be double quoted.

Change-Id: I2891e115f98c1df3a7a481bd9f9d9215bfbecd44
Reviewed-on: https://go-review.googlesource.com/c/go/+/534097
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
2023-10-10 18:22:05 +00:00
Joel Sing
7e1713e93c cmd/link/internal/ld: assign temporary addresses to per-package text
If trampolines may be required, the current text addressing second
pass resets all assigned addresses, before assigning addresses and
laying down trampolines in a linear fashion. However, this approach
means that intra-package calls are to a symbol that has not yet
been assigned an address, when the symbol is ahead of the current
function.

In the case of RISC-V the JAL instruction is limited to +/-1MiB.
As such, if a call is to a symbol with no address currently assigned,
we have to assume that a trampoline will be required. During the
relocation phase we can fix up and avoid trampolines in some cases,
however this results in unused trampolines that are still present
in the binary (since removing them would change text addresses).

In order to significantly reduce the number of unused trampolines,
assign temporary addresses to functions within the same package,
based on the maximum number of trampolines that may be required by
a function. This allows for better decisions to be made regarding
the requirement for intra-package trampolines, as we reset the
addressing for a function, assign its final address and lay down
any resulting trampolines.

This results in ~2,300 unused trampolines being removed from the
Go binary and ~5,600 unused trampolines being removed from the
compile binary, on linux/riscv64.

Change-Id: I8a9cf035dea82e1e1e66ae5b1093dce78e4ff0d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/349650
Run-TryBot: Joel Sing <joel@sing.id.au>
Reviewed-by: Than McIntosh <thanm@google.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-10-10 17:14:22 +00:00
David Chase
1493dd3cfc cmd/compile: get rid of zero-sized values in call expansion
Do this by removing all stores of zero-sized anything.

Fixes #63433.

Change-Id: I5d8271edab992d15d02005fa3fe31835f2eff8fa
Reviewed-on: https://go-review.googlesource.com/c/go/+/534296
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: David Chase <drchase@google.com>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-10-10 16:50:46 +00:00
Dmitri Shuralyov
f34964a5cf all: pull in x/net v0.17.0 and its dependencies
Pull in a security fix from x/net/http2:
http2: limit maximum handler goroutines to MaxConcurrentStreams

Fixes #63417.
Fixes CVE-2023-39325.

Change-Id: I01e7774912e81007a7cf70f33e5989fb50a0b708
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/534295
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-10 16:32:44 +00:00
Robert Griesemer
574a7f71a5 go/types: update FileVersions API to match proposal changes
For #62605.

Change-Id: I6e9032eb92db758bf359e7cc9c4cedc1e0fb2309
Reviewed-on: https://go-review.googlesource.com/c/go/+/534018
Auto-Submit: Robert Griesemer <gri@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
2023-10-10 16:00:49 +00:00
Jes Cok
aa8e4c5e61 runtime: fix some comments
Change-Id: I06403cf217a4d2645e13115e7ca358b7f3d3f2ef
GitHub-Last-Rev: e2b4e5326a
GitHub-Pull-Request: golang/go#63474
Reviewed-on: https://go-review.googlesource.com/c/go/+/533875
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-10-10 00:34:58 +00:00
Ville Skyttä
b201cf4afa testing: remove unnecessary TempDir implementation detail from its doc
The "by Cleanup" detail about the removal mechanism is not necessary for
users. The previous wording could even cause confusion whether they
should do something for Cleanup to occur.

Change-Id: I617a7a4e118a70a3ad8a83a2d81cd911dde8ee08
GitHub-Last-Rev: fba4cde636
GitHub-Pull-Request: golang/go#63479
Reviewed-on: https://go-review.googlesource.com/c/go/+/534016
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-10-10 00:25:53 +00:00
Cuong Manh Le
ad9e6edfdd cmd/compile: fix wrong argument of OpSelectN during expand_calls
Fixes #63462

Change-Id: I5ddf831eab630e23156f8f27a079b4ca4bb3a261
Reviewed-on: https://go-review.googlesource.com/c/go/+/533795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: David Chase <drchase@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
2023-10-09 22:23:06 +00:00
Mark Ryan
fce6be15cc cmd/compile: regenerate rewriteRISCV64.go to match cl 528975
The final revision of

https://go-review.googlesource.com/c/go/+/528975

made a small change to the RISCV64.rules file but neglected to update
the regenerated rewriteRISCV64.go file.

Change-Id: I04599f4e3b0dac7102c54166c9bae6fc9b6621d1
Reviewed-on: https://go-review.googlesource.com/c/go/+/533815
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-09 22:19:13 +00:00
Jes Cok
025e8ad6e9 go/token: use "// Output:" instead of "//Output:" in examples
Change-Id: I86eb365650749bb4f41e9ae62123674581dffe2b
GitHub-Last-Rev: 7a9d6800ab
GitHub-Pull-Request: golang/go#63449
Reviewed-on: https://go-review.googlesource.com/c/go/+/533120
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-10-09 22:09:31 +00:00
cui fliter
51bdd3bdcc os: use strings.EqualFold in os_test.go
strings.EqualFold has no memory overhead and has better performance than strings.ToLower.

This is a performance test:

package bench

import (
	"strings"
	"testing"
)

func BenchmarkToLower(b *testing.B) {

	str1 := "Windows"
	str2 := "windows"

	for i := 0; i < b.N; i++ {
		if strings.ToLower(str1) == strings.ToLower(str2) {
		}
	}
}

func BenchmarkEqualFold(b *testing.B) {

	str1 := "Windows"
	str2 := "windows"

	for i := 0; i < b.N; i++ {
		if strings.EqualFold(str1, str2) {
		}
	}
}

The result:

goos: darwin
goarch: arm64
BenchmarkToLower-8      31404808                36.99 ns/op            8 B/op          1 allocs/op
BenchmarkEqualFold-8    194780793                5.989 ns/op           0 B/op          0 allocs/op
PASS

Change-Id: Id3d92534942d3eb0bdc1d01359324030ad0e434f
Reviewed-on: https://go-review.googlesource.com/c/go/+/533635
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-10-09 22:06:42 +00:00
cui fliter
8f61fab618 bytes,strings: add example for ContainsFunc
Change-Id: I340e892aa4ecc780905be984016efc86699a45a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/533556
Run-TryBot: shuang cui <imcusg@gmail.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-10-09 22:05:38 +00:00
Carlo Alberto Ferraris
1ce8a3f081 io: add (*SectionReader).Outer()
Fixes #61870
Updates #61727

Change-Id: Iaef9b59c402d68f6bf64be212db2b6746abe8900
Reviewed-on: https://go-review.googlesource.com/c/go/+/526855
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Dmitri Shuralyov <dmitshur@google.com>
2023-10-09 22:04:41 +00:00
Jes Cok
5955a03e9c reflect: compute the median h uniformly
Like sort.Search, use "h := int(uint(i+j) >> 1)" to compute the median h.

Change-Id: I62c1e67533657e2b56af872676e5dc4ed4d49c55
GitHub-Last-Rev: cbfba7ee9a
GitHub-Pull-Request: golang/go#63439
Reviewed-on: https://go-review.googlesource.com/c/go/+/533595
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-09 21:56:00 +00:00
qmuntal
5da31049a6 runtime: normalize line endings in TestGdbPython
TestGdbPython fails on some Windows setups because the line endings in
the output of the gdb command can potentially be CRLF, but the test
expects LF.

This CL changes the test to normalize the line endings.

Change-Id: Iada9c37dc98249ac3c5f1edca4a657c51d4382a2
Reviewed-on: https://go-review.googlesource.com/c/go/+/532816
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2023-10-09 21:49:03 +00:00
Austin Clements
262b8050da cmd/go: remove unnecessary b.Print setting
The Builder returned by work.NewBuilder is already setup to print to
os.Stderr, so it's not necessary for runRun to set b.Print to a
different function that does exactly the same thing.

This b.Print assignment was introduced in CL 5591045. At the time, the
builder type defaulted to printing to os.Stdout, so this was necessary
to make "go run" print build errors to stderr.

Change-Id: I0c07984616c5efc37ba681f4cf69e83542566bab
Reviewed-on: https://go-review.googlesource.com/c/go/+/522796
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
2023-10-09 20:51:16 +00:00
Alan Donovan
8222423e03 go/types: document unfixable bug at Selection.Indirect
Updates #8353

Change-Id: I80cdbfccb8f7db00e04c293a68aaebc7c71bbbe9
Reviewed-on: https://go-review.googlesource.com/c/go/+/533935
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-09 18:55:34 +00:00
Lynn Boger
a8ca649bbe crypto/aes,crypto/cipher: improve gcm performance on ppc64x
This improves performance for AES-GCM. The function
counterCrypt is written in assembler so the loop can
be unrolled and the stitched approach used for the
encryption.

This implementation works on ppc64le and ppc64. The use
of GOPPC64=power9 generates the best performance,
goos: linux
goarch: ppc64le
pkg: crypto/cipher
cpu: POWER10
                     │ gcmx8.cpu1.out │         gcmx8.new.cpu1.out         │
                     │     sec/op     │   sec/op     vs base               │
AESGCM/Open-128-64        180.5n ± 0%   152.7n ± 1%  -15.43% (p=0.000 n=8)
AESGCM/Seal-128-64        166.8n ± 0%   147.2n ± 0%  -11.72% (p=0.000 n=8)
AESGCM/Open-256-64        194.9n ± 0%   156.6n ± 1%  -19.65% (p=0.000 n=8)
AESGCM/Seal-256-64        183.7n ± 0%   157.0n ± 0%  -14.51% (p=0.000 n=8)
AESGCM/Open-128-1350     1769.5n ± 0%   454.5n ± 0%  -74.31% (p=0.000 n=8)
AESGCM/Seal-128-1350     1759.0n ± 0%   453.7n ± 0%  -74.21% (p=0.000 n=8)
AESGCM/Open-256-1350     2104.0n ± 0%   504.4n ± 1%  -76.03% (p=0.000 n=8)
AESGCM/Seal-256-1350     2092.0n ± 0%   503.0n ± 0%  -75.96% (p=0.000 n=8)
AESGCM/Open-128-8192     10.054µ ± 0%   1.961µ ± 0%  -80.50% (p=0.000 n=8)
AESGCM/Seal-128-8192     10.050µ ± 0%   1.965µ ± 0%  -80.45% (p=0.000 n=8)
AESGCM/Open-256-8192     12.080µ ± 0%   2.232µ ± 0%  -81.52% (p=0.000 n=8)
AESGCM/Seal-256-8192     12.069µ ± 0%   2.238µ ± 0%  -81.46% (p=0.000 n=8)
geomean                   1.566µ        535.5n       -65.80%

                     │ gcmx8.cpu1.out │          gcmx8.new.cpu1.out           │
                     │      B/s       │      B/s       vs base                │
AESGCM/Open-128-64       338.1Mi ± 0%    399.8Mi ± 1%   +18.27% (p=0.000 n=8)
AESGCM/Seal-128-64       366.1Mi ± 0%    414.6Mi ± 0%   +13.28% (p=0.000 n=8)
AESGCM/Open-256-64       313.1Mi ± 0%    389.7Mi ± 0%   +24.47% (p=0.000 n=8)
AESGCM/Seal-256-64       332.3Mi ± 0%    388.5Mi ± 0%   +16.93% (p=0.000 n=8)
AESGCM/Open-128-1350     727.6Mi ± 0%   2832.8Mi ± 0%  +289.33% (p=0.000 n=8)
AESGCM/Seal-128-1350     732.0Mi ± 0%   2837.8Mi ± 0%  +287.70% (p=0.000 n=8)
AESGCM/Open-256-1350     611.9Mi ± 0%   2552.6Mi ± 0%  +317.18% (p=0.000 n=8)
AESGCM/Seal-256-1350     615.3Mi ± 0%   2559.6Mi ± 0%  +315.97% (p=0.000 n=8)
AESGCM/Open-128-8192     777.1Mi ± 0%   3983.5Mi ± 0%  +412.63% (p=0.000 n=8)
AESGCM/Seal-128-8192     777.3Mi ± 0%   3975.9Mi ± 0%  +411.47% (p=0.000 n=8)
AESGCM/Open-256-8192     646.7Mi ± 0%   3500.6Mi ± 0%  +441.27% (p=0.000 n=8)
AESGCM/Seal-256-8192     647.3Mi ± 0%   3491.1Mi ± 0%  +439.30% (p=0.000 n=8)
geomean                  542.7Mi         1.550Gi       +192.42%

Change-Id: I3600831a263ec8a99b5e3bdd495eb36e966d8075
Reviewed-on: https://go-review.googlesource.com/c/go/+/484575
Reviewed-by: Roland Shoemaker <roland@golang.org>
TryBot-Result: Gopher Robot <gobot@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Run-TryBot: Lynn Boger <laboger@linux.vnet.ibm.com>
Reviewed-by: Paul Murphy <murp@ibm.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-10-09 18:53:44 +00:00
Keith Randall
e0948d825d cmd/compile: use type hash from itab field instead of type field
It is one less dependent load away, and right next to another
field in the itab we also load as part of the type switch or
type assert.

Change-Id: If7aaa7814c47bd79a6c7ed4232ece0bc1d63550e
Reviewed-on: https://go-review.googlesource.com/c/go/+/533117
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-10-09 18:39:50 +00:00
Cuong Manh Le
778880b008 cmd/compile: fix typecheck range over negative integer
Before range over integer, types2 leaves constant expression in RHS of
non-constant shift untyped, so idealType do the validation to ensure
that constant value must be an int >= 0.

With range over int, the range expression can also be left untyped, and
can be an negative integer, causing the validation false.

Fixing this by relaxing the validation in idealType, and moving the
check to Unified IR reader.

Fixes #63378

Change-Id: I43042536c09afd98d52c5981adff5dbc5e7d882a
Reviewed-on: https://go-review.googlesource.com/c/go/+/532835
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
2023-10-09 18:09:34 +00:00
Alan Donovan
ede27fb4ac go/types: clarify semantics of Selection
This is one of the more complex areas of the (pre-generics)
spec, and I'm probably not the only person who can never
remember all the details each time I need them.

Change-Id: I25b3c46311df4db33357af5601c5e3586327dac2
Reviewed-on: https://go-review.googlesource.com/c/go/+/533736
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Alan Donovan <adonovan@google.com>
2023-10-09 17:59:27 +00:00
Lynn Boger
e6990b7629 crypto/cipher: update GCM test
This adds more variations for sizes of the input text
to the gcm tests.

Change-Id: I39dba5f08c77f04f94278200c3ce9234f977506f
Reviewed-on: https://go-review.googlesource.com/c/go/+/532635
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: Dmitri Shuralyov <dmitshur@google.com>
2023-10-09 17:48:32 +00:00
Keith Randall
afd7c15c7f cmd/compile: use cache in front of convI2I
This is the last of the getitab users to receive a cache.
We should now no longer see getitab (and callees) in profiles.
Hopefully.

Change-Id: I2ed72b9943095bbe8067c805da7f08e00706c98c
Reviewed-on: https://go-review.googlesource.com/c/go/+/531055
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-10-09 17:28:22 +00:00
Keith Randall
7fcc626b57 cmd/compile: use internal/abi types in the compiler
It is tricky to use those types directly, because the layout of those
types in the compiler may not be the same as the layout of those
types in target binary (typically because of 32 vs 64 bit differences).

Instead, translate an internal/abi type into a cmd/compile/internal/types
type, which will then be laid out for the target machine.

Along with the translation, keep track of where all the bits of the
type are so we can reference their locations symbolically instead of
hardcoding them.

Change-Id: I2694c58968d4dc7ead63a2b1b29adfedd90ddd2e
Reviewed-on: https://go-review.googlesource.com/c/go/+/532155
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Keith Randall <khr@google.com>
Reviewed-by: Keith Randall <khr@google.com>
2023-10-09 16:00:14 +00:00