Commit graph

58062 commits

Author SHA1 Message Date
Bryan C. Mills 36facaa1f9 os/exec: avoid writing to Cmd.Path in Cmd.Start on Windows
Fixes #62596.

Change-Id: I9003318ac1c4e3036f32383e62e9ba08c383d5c2
Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-race,gotip-windows-amd64-race,gotip-windows-amd64-longtest
Reviewed-on: https://go-review.googlesource.com/c/go/+/527820
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-13 19:25:41 +00:00
Mauri de Souza Meneguzzo 6ecd5f7504 runtime/internal/atomic: add wasm And/Or operators
In the WebAssembly version of these operators we avoid using
a CAS loop since the Go wasm implementation is single-threaded.

A new test file has been added that has build tags in order to
only test this feature on implemented architectures.

This is part of a series of CLs aimed to add the primitives
for And/Or atomic operations that will be used by the public
sync/atomic apis.

For #61395

Change-Id: Ic67ffefc9cfb626915ea86b6b21b500117710327
GitHub-Last-Rev: bbec3a5f35
GitHub-Pull-Request: golang/go#62517
Reviewed-on: https://go-review.googlesource.com/c/go/+/526656
Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
2023-09-13 18:36:37 +00:00
doujiang24 bfa8a8586f runtime: silently allow pinning of non-Go pointers in runtime.Pinner.Pin
People may not know the details of a pointer, this makes the
runtime.Pinner.Pin API easier to use.

Fixes #62356

Change-Id: I071df44e01320648a6df5e2a1e65afd6ea52e274
GitHub-Last-Rev: 560a581b63
GitHub-Pull-Request: golang/go#62549
Reviewed-on: https://go-review.googlesource.com/c/go/+/527156
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2023-09-13 18:36:12 +00:00
Li Gang b45b00162b runtime: resolve false sharing for frequent memory allocate workloads
False sharing observed inside mheap struct, between arenas and preceding
variables.Pad mheap.arenas and preceding variables to avoid false sharing

This false-sharing getting worse and impact performance on multi core
system and frequent memory allocate workloads. While running MinIO On a
2 socket system(56 Core per socket) and GOGC=1000, we observed HITM>8%
(perf c2c) on this cacheline.

After resolve this false-sharing issue, we got performance 17% improved.

Improvement verified on MinIO:
Server: https://github.com/minio/minio
Client: https://github.com/minio/warp
Config: Single node MinIO Server with 6 ramdisk, without TLS enabled,
        Run warp GET request, 128KB object and 512 concurrent

Fixes #62472

Signed-off-by: Li Gang<gang.g.li@intel.com>
Change-Id: I9a4a3c97f5bc8cd014c627f92d59d9187ebaaab5
Reviewed-on: https://go-review.googlesource.com/c/go/+/525955
Reviewed-by: Heschi Kreinick <heschi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
2023-09-13 18:36:09 +00:00
Abhinav Gupta 794e7ea15b net/http: use new Go Doc list syntax
This tweaks the documentation for http.Client
to use the list syntax introduced in Go 1.19.

Change-Id: I1f7e0256c13f57e04fc76e5e2362608c8f9f524d
GitHub-Last-Rev: 11d384f9ad
GitHub-Pull-Request: golang/go#62574
Reviewed-on: https://go-review.googlesource.com/c/go/+/527335
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
2023-09-13 18:35:12 +00:00
Tobias Klauser 2c74018d7b path: use bytealg.LastIndexByteString
While strings.LastIndex{,Byte} cannot be used in package path, the
respective internal/bytealg function can be used.

Change-Id: If0ecc36484308221f50875c8609913f6f2887fba
Reviewed-on: https://go-review.googlesource.com/c/go/+/527855
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2023-09-13 18:34:40 +00:00
Alexander Yastrebov 3e1db32657 internal/zstd: fix window resizing
Incorrect window resizing led to checksum error and invalid result.
To demonstrate the problem bigData must be a bit bigger, 3x is enough.

This change fixes window resizing, increases bigData size and decouples
TestLargeXXHash from bigData because it uses hardcoded hash value.

Change-Id: I50f74315b083f42e1ccd7ab2093e084f44631bb6
GitHub-Last-Rev: dbc90ba7a5
GitHub-Pull-Request: golang/go#62543
Reviewed-on: https://go-review.googlesource.com/c/go/+/527115
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-09-13 18:34:35 +00:00
Matthew Dempsky dc0d126e37 cmd/compile/internal/abi: replace types.Object with *ir.Name
types.Object only exists to avoid a circular dependency between
package types and ir.

Change-Id: I35196aff765d6977ca1e69fe482edbc987c381c1
Reviewed-on: https://go-review.googlesource.com/c/go/+/527340
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-09-13 18:34:03 +00:00
Matthew Dempsky c0e2a9dffd cmd/compile/internal/abi: use Type.Registers
Now that types can self-report how many registers they need, it's much
easier to determine whether a parameter will fit into the available
registers: simply compare the number of registers needed against the
number of registers still available.

This also eliminates the need for the NumParamRegs cache.

Also, the new code in NumParamRegs is stricter in only allowing it to
be called on types that can actually be passed in registers, which
requires a test to be corrected for that. While here, change mkstruct
to a variadic function, so the call sites require less boilerplate.

Change-Id: Iebe1a0456a8053a10e551e5da796014e5b1b695b
Reviewed-on: https://go-review.googlesource.com/c/go/+/527339
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2023-09-13 18:34:00 +00:00
Matthew Dempsky c80a9f172b cmd/compile/internal/types: add Type.Registers
To be used by package abi in the following CL.

Change-Id: Ic2470069e65f8d9b01ec161c28e5b86dca2ec141
Reviewed-on: https://go-review.googlesource.com/c/go/+/527338
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-13 18:33:58 +00:00
Tobias Klauser 65c407b405 syscall: use SYS_SETRLIMIT in //sysnb setrlimit1 on linux/arm64
Otherwise the setrlimit1 wrapper would be generated using the inexistent
SYS_GETRLIMIT1 syscall number.

This was likely missed in CL 476097.

For #476097

Change-Id: I5cfa2ebacb58aeeaddd3db3639a45cf368fbe0ab
Reviewed-on: https://go-review.googlesource.com/c/go/+/527555
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-09-13 18:29:13 +00:00
Bryan C. Mills 105f9d5169 os/exec: simplify Windows-specific tests
- Use the test binary itself for printing paths instead of building a
  separate binary and running it through additional subprocesses.

- Factor out a common chdir helper.

- Use t.Setenv where appropriate.

- Reduce indirection in test helpers.

- Set NoDefaultCurrentDirectoryInExePath consistently in the
  environment.

Also add a test case demonstrating an interesting behavior for
relative paths that may interact with #62596.

Fixes #62594.
For #62596.

Change-Id: I19b9325034edf78cd0ca747594476cd7432bb451
Reviewed-on: https://go-review.googlesource.com/c/go/+/528035
Reviewed-by: Ian Lance Taylor <iant@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-13 18:19:21 +00:00
Tobias Klauser dd2279ee34 testing: use strings.LastIndexAny in (*common).decorate
Change-Id: I14c521f4e599e14c71a52342b0ead5d0d4007f1e
Reviewed-on: https://go-review.googlesource.com/c/go/+/527655
Auto-Submit: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Kirill Kolyshkin <kolyshkin@gmail.com>
Reviewed-by: Bryan Mills <bcmills@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-09-13 18:06:09 +00:00
Than McIntosh 3251006291 cmd/link: fix malformed .shstrtab section
For ELF targets, the code in the go linker that generates the
".shstrtab" section was using a loader symbol to accumulate the
contents of the section, then setting the section type to
sym.SELFROSECT. This resulted in a section whose offset indicated that
it fell into a loadable ELF segment, which is not how the .shstrtab is
supposed to work (it should be outside of all loadable segments,
similar to .strtab and .symtab). The peculiar .shstrtab caused
confusion in third party tools that operate on ELF files, notably
llvm-strip.

This patch rewrites the .shstrtab generation code to avoid using a
loader.Symbol and instead accumulate the contents of the section into
a regular byte slice, then emit the section's data in the same way
that .strtab is handled.

Fixes #62600.

Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest
Change-Id: Ie54020d7b2d779d3ac9f5465fd505217d0681f79
Reviewed-on: https://go-review.googlesource.com/c/go/+/528036
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-13 16:29:40 +00:00
qiulaidongfeng 584aad5c57 go/doc/comment: use slices.BinarySearch
Change-Id: Ifb28dd08faa59d9186a4a2337aab0c536d9a885e

Change-Id: Ifb28dd08faa59d9186a4a2337aab0c536d9a885e
GitHub-Last-Rev: dba95de0fb
GitHub-Pull-Request: golang/go#62610
Reviewed-on: https://go-review.googlesource.com/c/go/+/527956
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: Robert Griesemer <gri@google.com>
2023-09-13 15:48:13 +00:00
Mauri de Souza Meneguzzo e5600f063d archive/tar: add AddFS method to Writer
The method AddFS can be used to add the contents of a fs.FS filesystem
to a tar archive. This method walks the directory tree starting at the root
of the filesystem and adds each file to the archive.

Fixes #58000

Change-Id: I0e6abac76b76bc5d95b74b7e5b37634ce3f76c85
GitHub-Last-Rev: 11a62bfd7e
GitHub-Pull-Request: golang/go#61599
Reviewed-on: https://go-review.googlesource.com/c/go/+/513316
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-09-13 13:59:01 +00:00
Jes Cok 0460c61e5f go/doc/comment: update TODO for isStdPkg
Even better is slices.BinarySearch, leave a TODO to update to that when possible.

Change-Id: Ie1ec75c34c0329c536725b45e520693790f0520e
GitHub-Last-Rev: 6cd811b186
GitHub-Pull-Request: golang/go#62585
Reviewed-on: https://go-review.googlesource.com/c/go/+/527341
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
2023-09-13 00:59:13 +00:00
Yi Yang 4ee1d542ed cmd/compile: sparse conditional constant propagation
sparse conditional constant propagation can discover optimization
opportunities that cannot be found by just combining constant folding
and constant propagation and dead code elimination separately.

This is a re-submit of PR#59575, which fix a broken dominance relationship caught by ssacheck

Updates https://github.com/golang/go/issues/59399

Change-Id: I57482dee38f8e80a610aed4f64295e60c38b7a47
GitHub-Last-Rev: 830016f24e
GitHub-Pull-Request: golang/go#60469
Reviewed-on: https://go-review.googlesource.com/c/go/+/498795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Keith Randall <khr@golang.org>
2023-09-12 21:01:50 +00:00
Michael Pratt a843991fdd runtime: set _XOPEN_SORUCE_EXTENDED to 1 for aix
aix requires that _XOPEN_SOURCE_EXTENDED is set to a number, not simply
defined.

For #62440.

Change-Id: Iee221d558b5ad5b8dcb874d4d9fdf94593f7d0a1
Reviewed-on: https://go-review.googlesource.com/c/go/+/527797
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Pratt <mpratt@google.com>
Run-TryBot: Michael Pratt <mpratt@google.com>
2023-09-12 20:41:08 +00:00
thepudds bc1d71ff64 cmd/compile: add a 'Tips' section to README to help new contributors
This CL adds a new 'Tips' section to the cmd/compile README.

The primary intent is to help new-ish contributors.

It includes some basics on getting started, testing changes,
viewing coverage, juggling different compiler versions,
some links to additional tools, and so on.

Updates #30074

Change-Id: I393bf1137db9d2bb851f7e254b08455273ccad8c
Reviewed-on: https://go-review.googlesource.com/c/go/+/503895
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Run-TryBot: t hepudds <thepudds1460@gmail.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
2023-09-12 20:35:02 +00:00
mstmdev 5f04ef752b io/fs, path/filepath, cmd/gofmt: replace statDirEntry with fs.FileInfoToDirEntry
Change-Id: Ie914367314ca72fab34c4d4529755dea853cf325
GitHub-Last-Rev: bc61665d33
GitHub-Pull-Request: golang/go#62342
Reviewed-on: https://go-review.googlesource.com/c/go/+/523876
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: qiulaidongfeng <2645477756@qq.com>
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Commit-Queue: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Daniel Martí <mvdan@mvdan.cc>
2023-09-12 20:27:28 +00:00
Kir Kolyshkin 2be7b1a4ac os: fix TestRenameCaseDifference
Saw this failing on windows like this:

	--- FAIL: TestRenameCaseDifference (2.96s)
	--- FAIL: TestRenameCaseDifference/dir (1.64s)
	    testing.go:1226: TempDir RemoveAll cleanup: remove C:\Users\gopher\AppData\Local\Temp\1\TestRenameCaseDifferencedir1375918868\001: The process cannot access the file because it is being used by another process.
	--- FAIL: TestRenameCaseDifference/file (1.32s)
	    testing.go:1226: TempDir RemoveAll cleanup: remove C:\Users\gopher\AppData\Local\Temp\1\TestRenameCaseDifferencefile3272269402\001: The process cannot access the file because it is being used by another process.
	FAIL

The reason might be the directory fd is not closed. This may be
mitigated by retries in removeAll function from testing package,
but apparently it does not succeed all the time.

A link to the failed run which made me look into this: https://ci.chromium.org/ui/p/golang/builders/try/gotip-windows-386/b8770439049015378129/overview

Change-Id: Ibebe94958d1aef8d1d0eca8a969675708cd27a7e
Reviewed-on: https://go-review.googlesource.com/c/go/+/527175
TryBot-Result: Gopher Robot <gobot@golang.org>
Run-TryBot: Kirill Kolyshkin <kolyshkin@gmail.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Rob Pike <r@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-09-12 20:24:06 +00:00
Jes Cok ca102e5c4a all: calculate the median uniformly
This is a follow up of CL 526496.

Change-Id: I9f351951bf975e31befd36b9c951d195d2f8f9f7
GitHub-Last-Rev: 4307adafbf
GitHub-Pull-Request: golang/go#62590
Reviewed-on: https://go-review.googlesource.com/c/go/+/527576
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
Auto-Submit: Ian Lance Taylor <iant@google.com>
Auto-Submit: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-09-12 20:16:26 +00:00
Jonathan Amsterdam d8b349ea60 net/http: routing tree
This CL implements a decision tree for efficient routing.
The tree holds all the registered patterns. To match
a request, we walk the tree looking for a match.

Change-Id: I7ed1cdf585fc95b73ef5ca2f942f278100a90583
Reviewed-on: https://go-review.googlesource.com/c/go/+/527315
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Damien Neil <dneil@google.com>
Run-TryBot: Jonathan Amsterdam <jba@google.com>
2023-09-12 19:33:35 +00:00
Matthew Dempsky c8396b5188 cmd/compile/internal/ir: add NewZero
This constructs a zero value of any type, which helps address some
corner case scenarios.

It should also eventually handle the predeclared "zero" value, at
least as currently implemented in go.dev/cl/520336.

For #61372.

Change-Id: I3a86a94fd8fa388c9c6bf281da8aa532b3da00fc
Reviewed-on: https://go-review.googlesource.com/c/go/+/527696
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-12 18:53:26 +00:00
Matthew Dempsky 661e3be497 cmd/compile/internal/dwarfgen: remove unversion
The unified export data format doesn't rely on embedding version
numbers in local variable names anymore, so there's no need to look
for them.

While here, simplify the checking for "~r" or "~b" to just "~",
because the next commit is going to eliminate "~b", but introduce
"~p".

Change-Id: I3ac73150ee561c66356a0c4aee5290b44a4893ee
Reviewed-on: https://go-review.googlesource.com/c/go/+/527695
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-09-12 18:52:49 +00:00
Michael Pratt 4b17b36b3f cmd/compile/internal/devirtualize: sort equal weight CallStat.Hottest by name
When two callees have equal weight, we need to sort by another criteria
to ensure that we get stable output.

Note that this is only for the CallStat debug JSON output. The actual
callee selection already does this secondary sort in
findHotConcreteCallee.

Change-Id: I0de105623c5ccc793ca6f5799ea25e57bc286722
Reviewed-on: https://go-review.googlesource.com/c/go/+/527796
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-12 18:40:16 +00:00
Michael Pratt e8ba0579e2 runtime: set _XOPEN_SOURCE_EXTENDED for netbsd
If _XOPEN_SOURCE is defined, then netbsd also requires
_XOPEN_SOURCE_EXTENDED to define stack_t.

For #62440.

Change-Id: Ib05658c3ca7fae1f6b051566e713ce7bc7c037a0
Reviewed-on: https://go-review.googlesource.com/c/go/+/527775
Run-TryBot: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-12 18:26:38 +00:00
Cherry Mui 5cc1e99f94 runtime: fix off-by-1 error in textOff
The code meant to check if it is the last section, which is
i === len(md.textsectmap)-1. The -1 was missing.

Change-Id: Ifbb9e40df730abe3bec20fde5f56f5c75dfd9e8f
Reviewed-on: https://go-review.googlesource.com/c/go/+/527795
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-09-12 18:14:29 +00:00
Jonathan Amsterdam 9f5a2cf61c net/http: mapping data structure
Our goal for the new ServeMux patterns is to match the routing
performance of the existing ServeMux patterns. To achieve that
we needed to optimize lookup for small maps.

This CL introduces a simple data structure called a mapping that
optimizes lookup by using a slice for small collections of key-value
pairs, switching to a map when the collection gets large.

Mappings are a core part of the routing algorithm, which uses a
decision tree to match path elements.   The children of a tree node are
held in a mapping.

Change-Id: I923b3ad1376ace2c3e3421aa9b802ad12d47c871
Reviewed-on: https://go-review.googlesource.com/c/go/+/526617
Run-TryBot: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
2023-09-12 17:47:07 +00:00
Jonathan Amsterdam 3602465954 net/http: pattern.conflictsWith
Add the conflictsWith method, which determines whether two patterns
conflict with each other.

Updates #61410.

Change-Id: Id4f9a471dc9d0420d927a68d2864128a096b74f4
Reviewed-on: https://go-review.googlesource.com/c/go/+/526616
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Eli Bendersky <eliben@google.com>
Reviewed-by: Damien Neil <dneil@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-12 17:45:33 +00:00
Michael Pratt 4f9fe6d509 runtime: allow update of system stack bounds on callback from C thread
[This is a redo of CL 525455 with the test fixed on darwin by defining
_XOPEN_SOURCE, and disabled with android, musl, and openbsd, which do
not provide getcontext.]

Since CL 495855, Ms are cached for C threads calling into Go, including
the stack bounds of the system stack.

Some C libraries (e.g., coroutine libraries) do manual stack management
and may change stacks between calls to Go on the same thread.

Changing the stack if there is more Go up the stack would be
problematic. But if the calls are completely independent there is no
particular reason for Go to care about the changing stack boundary.

Thus, this CL allows the stack bounds to change in such cases. The
primary downside here (besides additional complexity) is that normal
systems that do not manipulate the stack may not notice unintentional
stack corruption as quickly as before.

Note that callbackUpdateSystemStack is written to be usable for the
initial setup in needm as well as updating the stack in cgocallbackg.

Fixes #62440.
For #62130.

Change-Id: I0fe0134f865932bbaff1fc0da377c35c013bd768
Reviewed-on: https://go-review.googlesource.com/c/go/+/527715
Run-TryBot: Michael Pratt <mpratt@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Auto-Submit: Michael Pratt <mpratt@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-09-12 17:08:55 +00:00
Than McIntosh 2399302a25 cmd/compile/internal/base: keep Ctxt.Flag_optimize in sync with Flag.N
This patch fixes an inconsistency in compiler flag handling introduced
accidentally in CL 521699. In the compiler we have both base.Flag.N
(which records whether the user has supplied the "-N" flag to disable
optimization) and base.Ctxt.Flag_optimize (which tracks whether
optimization is turned on). In this case Flag.N was updated without a
corresponding change to Ctxt.Flag_optimize, which led to problems with
DWARF generation for the runtime.

This CL doesn't include a regression test; a test will be added later
in the x/debug repo in a subsequent CL.

Updates #62523.

Change-Id: I0c383bb43ec0a0e7c12e7e2852c0590731416d6f
Reviewed-on: https://go-review.googlesource.com/c/go/+/527319
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Alessandro Arzilli <alessandro.arzilli@gmail.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-12 17:01:03 +00:00
qmuntal 94200bf85c all: fix Microsoft links
This CL fixes the links to Microsoft documentation in the Go source
code. Some links were broken and some others were outdated.

Change-Id: I4c3bcd3aa3c07a31be1b7f94c25339dcc2e771e8
Reviewed-on: https://go-review.googlesource.com/c/go/+/527556
Reviewed-by: Heschi Kreinick <heschi@google.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>
Run-TryBot: Quim Muntal <quimmuntal@gmail.com>
Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2023-09-12 16:42:41 +00:00
Cuong Manh Le e50bbae2de cmd/compile: remove typecheck.Orig* functions
Same as CL 526397, but for typecheck.

Change-Id: Ia8f19a54ffaa2ae3b86a4c66cbe6d973482796cd
Reviewed-on: https://go-review.googlesource.com/c/go/+/526236
Auto-Submit: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-12 16:07:23 +00:00
Matthew Dempsky aa381c538a cmd/compile/internal/types: remove Type.vargen
The unified frontend diasmbiguates local types by putting vargen
directly into their symbol name instead. We no longer need a separate
int field for it.

Change-Id: I556c588ed68c5e2cb324cd46abd934894b5aaef9
Reviewed-on: https://go-review.googlesource.com/c/go/+/527517
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Than McIntosh <thanm@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-12 15:41:17 +00:00
Matthew Dempsky d9aca84da0 cmd/compile: stop changing Field.Sym for parameters
Field.Sym now always contains the original symbol as it appeared in Go
source, so we don't need OrigSym anymore.

Instead, when the mangled name is desired, Field.Nname.Sym() can be
used instead, which is always non-nil if Nname is non-nil.

Change-Id: I96cd61db6458d4a2e07ec5810239236e3dfba747
Reviewed-on: https://go-review.googlesource.com/c/go/+/527516
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Than McIntosh <thanm@google.com>
2023-09-12 15:41:15 +00:00
Cherry Mui e924ea03cc cmd/link: disable DWARF by default in c-shared mode on darwin
Currently, linking a Go c-shared object with C code using Apple's
new linker, it fails with

% cc a.c go.so
ld: segment '__DWARF' filesize exceeds vmsize in 'go.so'

Apple's new linker has more checks for unmapped segments. It is
very hard to make it accept a Mach-O shared object with an
additional DWARF segment.

We may want to stop combinding DWARF into the shared object (see
also #62577). For now, disable DWARF by default in c-shared mode
on darwin. (One can still enable it with -ldflags=-w=0, which will
contain DWARF, but it will need the old C linker to link against
with.)

For #61229.

Change-Id: I4cc77da54fac10e2c2cbcffa92779cba82706d75
Reviewed-on: https://go-review.googlesource.com/c/go/+/527415
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Than McIntosh <thanm@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-12 15:31:24 +00:00
Matthew Dempsky 905b58b537 cmd/compile/internal/typecheck: remove HasNamedResults check
types2 has already checked for us that bare returns are valid, so no
need to duplicate the effort in typecheck.

Change-Id: I13b2387173966ba44058fbc841327896e04184e2
Reviewed-on: https://go-review.googlesource.com/c/go/+/527515
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-12 04:52:25 +00:00
Matthew Dempsky 70fc87ee24 cmd/compile: rename OEFACE to OMAKEFACE and remove OCONVIDATA
The "eface" in OEFACE suggests it's only for empty interfaces, and the
documentation suggests that too. But it's actually used for both empty
and non-empty interfaces, so rename to OMAKEFACE and adjust docs
accordingly.

Also, remove OCONVIDATA. This was used by the 1.18 frontend for
constructing interfaces containing derived types, but the unified
frontend always uses OCONVIFACE instead, so this is unused now.

Change-Id: I6ec5c62f909b26027f2804e5b3373b7a00029246
Reviewed-on: https://go-review.googlesource.com/c/go/+/527336
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Robert Griesemer <gri@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-12 04:50:32 +00:00
Meng Zhuo 5e31f78c8a internal/cpu: fix wrong cache line size of riscv64
All of riscv CPU using 64B for cache-line size.
i.e. U540 of Hifive Unleashed (https://www.sifive.com/boards/hifive-unleashed)

Change-Id: I0d72d88ac026f45383c3b3eb3a77233d3c2e4004
Reviewed-on: https://go-review.googlesource.com/c/go/+/526659
Run-TryBot: M Zhuo <mzh@golangcn.org>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-12 01:18:38 +00:00
Ian Lance Taylor 8221f90f13 Revert "os/exec: avoid calling LookPath in cmd.Start for resolved paths"
This reverts CL 512155.

Reason for revert: CL 512155 introduced a race in that it caused
cmd.Start to set cmd.Path. Previously it was fine if code looked
at cmd.Path in one goroutine while calling cmd.Start in a different
goroutine.

A test case for this race is in CL 527495.

Change-Id: Ic18fdadf6763727f8ea748280d5f0e601b9bf374
Reviewed-on: https://go-review.googlesource.com/c/go/+/527337
Auto-Submit: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2023-09-12 00:57:26 +00:00
Matthew Dempsky 06138963a2 cmd/compile/internal/ir: remove OSIZEOF, etc
These are no longer needed after the previous CL, which moved handling
of unsafe.Sizeof, etc. directly into the unified frontend.

Change-Id: Ieb35ffca0bc25319e58132fb5d035c5b441acea7
Reviewed-on: https://go-review.googlesource.com/c/go/+/527098
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
2023-09-11 20:48:10 +00:00
Matthew Dempsky 2e457b3868 cmd/compile/internal/noder: handle unsafe.Sizeof, etc in unified IR
Previously, the unified frontend implemented unsafe.Sizeof, etc that
involved derived types by constructing a normal OSIZEOF, etc
expression, including fully instantiating their argument. (When
unsafe.Sizeof is applied to a non-generic type, types2 handles
constant folding it.)

This worked, but involves unnecessary work, since all we really need
to track is the argument type (and the field selections, for
unsafe.Offsetof).

Further, the argument expression could generate temporary variables,
which would then go unused after typecheck replaced the OSIZEOF
expression with an OLITERAL. This results in compiler failures after
CL 523315, which made later passes stricter about expecting the
frontend to not construct unused temporaries.

Fixes #62515.

Change-Id: I37baed048fd2e35648c59243f66c97c24413aa94
Reviewed-on: https://go-review.googlesource.com/c/go/+/527097
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Keith Randall <khr@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
2023-09-11 20:48:07 +00:00
Andy Pan f72693d3e9 log/slog: generate valid JSON string with empty attributes in Groups
Fixes #62152

Change-Id: I1f76ab26eae3a44292ebe6003006258d5e31d50f
Reviewed-on: https://go-review.googlesource.com/c/go/+/521135
Reviewed-by: Heschi Kreinick <heschi@google.com>
Run-TryBot: Andy Pan <panjf2000@gmail.com>
Reviewed-by: Jonathan Amsterdam <jba@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
2023-09-11 20:29:15 +00:00
David Anderson 94f24fd054 net/netip: add AddrPort.Compare and Prefix.Compare
Fixes #61642

Change-Id: I2262855dbe75135f70008e5df4634d2cfff76550
GitHub-Last-Rev: 949685a9e4
GitHub-Pull-Request: golang/go#62387
Reviewed-on: https://go-review.googlesource.com/c/go/+/524616
Reviewed-by: Joseph Tsai <joetsai@digital-static.net>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2023-09-11 20:26:41 +00:00
qiulaidongfeng dfb2e4265b cmd/go: cache results of exec.LookPath
This CL package exec.LookPath to internal/cfg.LookPath and adds cache.

BenchmarkLookPath-4     24149096                50.48 ns/op            0 B/op          0 allocs/op

Fixes #36768

Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9

Change-Id: I199a780d1eab9bd5397bb3759bb42191fff716e9
GitHub-Last-Rev: d67aa826f4
GitHub-Pull-Request: golang/go#61464
Reviewed-on: https://go-review.googlesource.com/c/go/+/511458
Run-TryBot: Bryan Mills <bcmills@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-11 20:12:18 +00:00
Matthew Dempsky afa3f8e104 cmd/compile/internal/staticinit: make staticopy safe
Currently, cmd/compile optimizes `var a = true; var b = a` into `var a
= true; var b = true`. But this may not be safe if we need to
initialize any other global variables between `a` and `b`, and the
initialization involves calling a user-defined function that reassigns
`a`.

This CL changes staticinit to keep track of the initialization
expressions that we've seen so far, and to stop applying the
staticcopy optimization once we've seen an initialization expression
that might have modified another global variable within this package.

To help identify affected initializers, this CL adds a -d=staticcopy
flag to warn when a staticcopy is suppressed and turned into a dynamic
copy.

Currently, `go build -gcflags=all=-d=staticcopy std` reports only four
instances:

```
encoding/xml/xml.go:1600:5: skipping static copy of HTMLEntity+0 with map[string]string{...}
encoding/xml/xml.go:1869:5: skipping static copy of HTMLAutoClose+0 with []string{...}
net/net.go:661:5: skipping static copy of .stmp_31+0 with poll.ErrNetClosing
net/http/transport.go:2566:5: skipping static copy of errRequestCanceled+0 with ~R0
```

Fixes #51913.

Change-Id: Iab41cf6f84c44f7f960e4e62c28a8aeaade4fbcf
Reviewed-on: https://go-review.googlesource.com/c/go/+/395541
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
2023-09-11 20:12:05 +00:00
Matthew Dempsky 1cdabf0c8b runtime: avoid staticinit dependency with sigsetAllExiting
Currently, package runtime runs `osinit` before dynamic initialization
of package-scope variables; but on GOOS=linux, `osinit` involves
mutating `sigsetAllExiting`.

This currently works because cmd/compile and gccgo have
non-spec-conforming optimizations that statically initialize
`sigsetAllExiting`, but disabling that optimization causes
`sigsetAllExiting` to be dynamically initialized instead. This in turn
causes the mutations in `osinit` to get lost.

This CL moves the initialization of `sigsetAllExiting` from `osinit`
into its initialization expression, and then removes the special case
for continuing to perform the static-initialization optimization for
package runtime.

Updates #51913.

Change-Id: I3be31454277c103372c9701d227dc774b2311dad
Reviewed-on: https://go-review.googlesource.com/c/go/+/405549
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: Heschi Kreinick <heschi@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-11 20:10:52 +00:00
Matthew Dempsky 3556d3b9bf cmd/compile/internal/ir: add missing SetTypecheck
This was missed earlier, because NewConstAt is only used now to
construct the predeclared "true" and "false" constants. But these
constants are no longer actually accessed with unified IR.

For constant expressions, types2 (and go/types) sets
TypeAndValue.Value for the expression to the appropriate constant
value. The unified writer recognizes when expressions are constants,
and simply writes the underlying value, regardless of the original
expression. As a result, we never end up actually referencing the
*named* "true" and "false" constants; we just always construct
anonymous constant "true" and "false" values.

However, a manually constructed tree that includes an *ir.Name that
"Uses" the predeclared true/false Const Objects, yet doesn't set
TypeAndValue.Value will instead end up trying to use named constants
constructed with NewConstAt.

Thanks to Russ for reporting the issue on CL 510541, and to Cuong for
identifying the fix.

Change-Id: I0614105379d63ea76d7244ebd1e4db5c239d4670
Reviewed-on: https://go-review.googlesource.com/c/go/+/524357
Reviewed-by: Heschi Kreinick <heschi@google.com>
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Auto-Submit: Matthew Dempsky <mdempsky@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-09-11 20:08:58 +00:00