aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/internal
AgeCommit message (Collapse)Author
2025-03-11runtime/internal: clean up completelyJes Cok
We've been slowly moving packages from runtime/internal to internal/runtime. For now, runtime/internal only has test packages. It's a good chance to clean up the references to runtime/internal in the toolchain. For #65355. Change-Id: Ie6f9091a44511d0db9946ea6de7a78d3afe9f063 GitHub-Last-Rev: fad32e2e81d11508e734c3c3d3b0c1da583f89f5 GitHub-Pull-Request: golang/go#72137 Reviewed-on: https://go-review.googlesource.com/c/go/+/655515 Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2025-02-25all: use testenv.GoToolPath instead of hardcoding goqmuntal
Change-Id: I84ec73d3ddef913a87cb9b48147c44ac3e7c8a8d Reviewed-on: https://go-review.googlesource.com/c/go/+/651957 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-07-23runtime,internal: move runtime/internal/sys to internal/runtime/sysDavid Chase
Cleanup and friction reduction For #65355. Change-Id: Ia14c9dc584a529a35b97801dd3e95b9acc99a511 Reviewed-on: https://go-review.googlesource.com/c/go/+/600436 Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
2024-07-23runtime,internal: move runtime/internal/math to internal/runtime/mathDavid Chase
Cleanup and friction reduction. Updates #65355. Change-Id: I6c4fcd409d044c00d16561fe9ed2257877d73f5b Reviewed-on: https://go-review.googlesource.com/c/go/+/600435 Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
2024-03-25runtime: migrate internal/atomic to internal/runtimeAndy Pan
For #65355 Change-Id: I65dd090fb99de9b231af2112c5ccb0eb635db2be Reviewed-on: https://go-review.googlesource.com/c/go/+/560155 Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ibrahim Bazoka <ibrahimbazoka729@gmail.com> Auto-Submit: Emmanuel Odeke <emmanuel@orijtech.com>
2024-03-21cmd/compile,cmd/go,cmd/internal,runtime: remove dynamic checks for atomics ↵Andrey Bokhanko
for ARM64 targets that support LSE Remove dynamic checks for atomic instructions for ARM64 targets that support LSE extension. For #66131 Change-Id: I0ec1b183a3f4ea4c8a537430646e6bc4b4f64271 Reviewed-on: https://go-review.googlesource.com/c/go/+/569536 Reviewed-by: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Fannie Zhang <Fannie.Zhang@arm.com> Reviewed-by: Shu-Chun Weng <scw@google.com>
2024-02-26std: fix more nilness findingsAlan Donovan
(found with x/tools/go/analysis/passes/nilness) Change-Id: I1bdc7811efbecea95608e634f894cb6c656e3a5b Reviewed-on: https://go-review.googlesource.com/c/go/+/564221 Reviewed-by: Robert Griesemer <gri@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2024-02-21runtime: migrate internal/syscall to internal/runtimeAndy Pan
For #65355 Change-Id: I5fefe30dcb520159de565e61dafc74a740fc8730 Reviewed-on: https://go-review.googlesource.com/c/go/+/559715 Reviewed-by: 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>
2024-02-20runtime/internal/atomic: add s390x operators for And/OrMauri de Souza Meneguzzo
These primitives will be used by the new And/Or sync/atomic apis. For #61395 Change-Id: Ia9b4877048002d3d7d1dffa2311d0ec5f38e4ee5 GitHub-Last-Rev: 20dea110c824913c0c3d9c259e3e21e7ff8e4ba9 GitHub-Pull-Request: golang/go#63318 Reviewed-on: https://go-review.googlesource.com/c/go/+/531678 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2024-02-20runtime/internal/syscall: merge duplicate constantsAndy Pan
Change-Id: Ifdc6e22d52317cdb90a607ac4d72437d4d6b33e8 Reviewed-on: https://go-review.googlesource.com/c/go/+/564716 Auto-Submit: Ian Lance Taylor <iant@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-20runtime: use eventfd as the event wait/notify mechanism for epollAndy Pan
Fixes #65443 Change-Id: I9ad4689b36e87ee930d35a38322a8797896483b4 Reviewed-on: https://go-review.googlesource.com/c/go/+/560615 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Than McIntosh <thanm@google.com> Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Jorropo <jorropo.pgm@gmail.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2024-02-16runtime/internal/atomic: correct GOARM=7 guard at a DMB instructionCherry Mui
CL 525637 changed to the guard of DMB instruction from the compiled-in runtime.goarm value to GOARM_7 macro and CPU feature detection. It missed a place where runtime.goarm is loaded to a register and reused later. This CL corrects the condition. Fixes #65601. Change-Id: I2ddefd03a1eb1048dbec0254c6e234c65b054279 Reviewed-on: https://go-review.googlesource.com/c/go/+/564855 Run-TryBot: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2024-02-05runtime/internal/atomic: add loong64 operators for And/OrMauri de Souza Meneguzzo
These primitives will be used by the new And/Or sync/atomic apis. For #61395 Change-Id: I64b2e599e4f91412e0342aa01f5fd53271e9a333 GitHub-Last-Rev: 9755db5406b84dd84fa5432382bfabc801a34ed3 GitHub-Pull-Request: golang/go#63314 Reviewed-on: https://go-review.googlesource.com/c/go/+/531895 Reviewed-by: abner chenc <chenguoqi@loongson.cn> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org>
2023-11-22runtime/internal/atomic: deduplicate And/Or code on wasmMauri de Souza Meneguzzo
When I initially added the wasm code for these ops I did not saw that wasm actually has the Cas operations implemented, although they are merely pointer assignments since wasm is single threaded. Now with a generic implementation for And/Or we can add wasm to the build tags. For #61395 Change-Id: I997dc90477c772882d6703df1b795dfc0d90a699 GitHub-Last-Rev: 92736a6e34104a9d234c791673fe0bb79fc97b0b GitHub-Pull-Request: golang/go#64300 Reviewed-on: https://go-review.googlesource.com/c/go/+/544116 Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-21runtime/internal/syscall: use ABIInternal for Syscall6 on loong64Guoqi Chen
Updates #40724 Co-authored-by: Xiaolin Zhao <zhaoxiaolin@loongson.cn> Change-Id: Ifcc2de35a797fd987a10f564206b14b54d736d1d Reviewed-on: https://go-review.googlesource.com/c/go/+/521789 Auto-Submit: David Chase <drchase@google.com> Reviewed-by: Meidan Li <limeidan@loongson.cn> Reviewed-by: Cherry Mui <cherryyz@google.com> Run-TryBot: David Chase <drchase@google.com> Reviewed-by: David Chase <drchase@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-11-21runtime/internal/atomic: deduplicate And/Or code on armMauri de Souza Meneguzzo
Turns out after adding the generic implementation for And/Or we ended up with duplicated ops that are exactly the same for arm. Apologies for the oversight, this CL removes the redundant arm code and adds arm to the generic build flags. For #61395 Change-Id: Id5e5a5cf113774948f8e772592e898d0810ad1f6 GitHub-Last-Rev: 4d8c857d15f0267ee0c8bb88a202afd49a6075dc GitHub-Pull-Request: golang/go#64299 Reviewed-on: https://go-review.googlesource.com/c/go/+/544017 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
2023-11-20runtime/internal/atomic: add generic implementation for And/OrMauri de Souza Meneguzzo
Without having all the architectures implementing the And/Or operators merged I can't proceed with the public sync/atomic apis. This CL adds a generic implementation that should work for all the remaining arches, while waiting for the native assembly implementations in CL 531835, CL 531678, CL 531895. I regret the oversight of not pushing this earlier. For #61395 Change-Id: Ib2d67f359fe324b4743eb79e9c8e52e8f6f5476c GitHub-Last-Rev: d350927ba1c51d1f708be2f2904f826fdb79b8cd GitHub-Pull-Request: golang/go#64214 Reviewed-on: https://go-review.googlesource.com/c/go/+/543175 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
2023-11-17all: add missing copyright headerJes Cok
Change-Id: Ic61fb181923159e80a86a41582e83ec466ab9bc4 GitHub-Last-Rev: 92469845665fa1f864d257c8bc175201a43b4d43 GitHub-Pull-Request: golang/go#64080 Reviewed-on: https://go-review.googlesource.com/c/go/+/541741 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Jes Cok <xigua67damn@gmail.com>
2023-11-07runtime/internal/atomic: add arm/arm64 operators for And/OrMauri de Souza Meneguzzo
This CL continues adding support for And/Or primitives to more architectures, this time for arm/arm64. For #61395 Change-Id: Icc44ea65884c825698a345299d8f9511392aceb6 GitHub-Last-Rev: 8267665a0348faa0a10ac63b18909a1b13f9971d GitHub-Pull-Request: golang/go#62674 Reviewed-on: https://go-review.googlesource.com/c/go/+/528797 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com>
2023-11-06runtime/internal/atomic: add 386/amd64 And/Or operatorsMauri de Souza Meneguzzo
This CL adds the atomic primitives for the And/Or operators on x86-64. It also includes missing benchmarks for the ops. For #61395 Change-Id: I23ef5192866d21fc3a479d0159edeafc3aeb5c47 GitHub-Last-Rev: df800be1925a9f3929456844b4e6d1524e627990 GitHub-Pull-Request: golang/go#62621 Reviewed-on: https://go-review.googlesource.com/c/go/+/528315 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com>
2023-10-31runtime: on arm32, detect whether we have sync instructionsKeith Randall
Make the choice of using these instructions dynamic (triggered by cpu feature detection) rather than static (trigered by GOARM setting). if GOARM>=7, we know we have them. For GOARM=5/6, dynamically dispatch based on auxv information. Update #17082 Update #61588 Change-Id: I8a50481d942f62cf36348998a99225d0d242f8af Reviewed-on: https://go-review.googlesource.com/c/go/+/525637 TryBot-Result: Gopher Robot <gobot@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Run-TryBot: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2023-10-25runtime/internal/atomic: add riscv64 operators for And/OrMauri de Souza Meneguzzo
These primitives will be used by the new And/Or sync/atomic apis. For #61395 Change-Id: I4062d6317e01afd94d3588f5425237723ab15ade GitHub-Last-Rev: c0a8d8f34dc355997fa697d4d8da7d45a00bb3c7 GitHub-Pull-Request: golang/go#63272 Reviewed-on: https://go-review.googlesource.com/c/go/+/531575 Reviewed-by: Than McIntosh <thanm@google.com> Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com> Reviewed-by: Mark Ryan <markdryan@rivosinc.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Joel Sing <joel@sing.id.au> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-10-24runtime/internal/atomic: add memory barrier for mips Cas on failureMauri de Souza Meneguzzo
Add a memory barrier on the failure case of the compare-and-swap for mips, this avoids potential race conditions. For #63506 Change-Id: I3df1479d1438ba72aa72567eb3dea76ff745e98d GitHub-Last-Rev: 2101b9fd446f28f856986b27d20f92cd4a1f4fef GitHub-Pull-Request: golang/go#63604 Reviewed-on: https://go-review.googlesource.com/c/go/+/536116 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-19all: drop old +build linesDmitri Shuralyov
Running 'go fix' on the cmd+std packages handled much of this change. Also update code generators to use only the new go:build lines, not the old +build ones. For #41184. For #60268. Change-Id: If35532abe3012e7357b02c79d5992ff5ac37ca23 Cq-Include-Trybots: luci.golang.try:gotip-linux-386-longtest,gotip-linux-amd64-longtest,gotip-windows-amd64-longtest Reviewed-on: https://go-review.googlesource.com/c/go/+/536237 Reviewed-by: Ian Lance Taylor <iant@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Dmitri Shuralyov <dmitshur@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2023-10-11cmd/compile, runtime/internal/atomic: add lwsync for false ppc64 casIan Lance Taylor
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-03runtime/internal/atomic: add ppc64x operators for And/OrMauri de Souza Meneguzzo
These primitives will be used by the new And/Or sync/atomic apis. For #61395 Change-Id: I9ad92634add0357092e49b5a4a40c177e242a0b6 GitHub-Last-Rev: cf3fb0dce6a462b5d63fe8fe974573ab86df0b66 GitHub-Pull-Request: golang/go#63294 Reviewed-on: https://go-review.googlesource.com/c/go/+/531716 Reviewed-by: Eli Bendersky <eliben@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com> Run-TryBot: Mauri de Souza Meneguzzo <mauri870@gmail.com> Auto-Submit: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Paul Murphy <murp@ibm.com>
2023-09-13runtime/internal/atomic: add wasm And/Or operatorsMauri de Souza Meneguzzo
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: bbec3a5f356c55185af0357b929e76a9dfac230e 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-08-18runtime/internal/wasitest: skip racy TCP echo testChris O'Hara
The wasip1 TCP echo test introduced in CL 493358 has a race condition with port selection. The test runner probes for a free port and then asks the WASM runtime to listen on the port, which may be taken by another process in the interim. Due to limitations with WASI preview 1, the guest is unable to query the port it's listening on. The test cannot ask the WASM runtime to listen on port 0 (choose a free port) since there's currently no way for the test to query the selected port and connect to it. Given the race condition is unavoidable, this test is now disabled by default and requires opt-in via an environment variable. This commit also eliminates the hard-coded connection timeout. Fixes #61820. Change-Id: I375145c1a1d03ad45c44f528da3347397e6dcb01 Reviewed-on: https://go-review.googlesource.com/c/go/+/519895 Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com>
2023-08-16runtime/internal/math: add Add64Russ Cox
This makes the intrinsic available on 64-bit platforms, since the runtime cannot import math/bits. Change-Id: I5296cc6a97d1cb4756ab369d96dc9605df9f8247 Reviewed-on: https://go-review.googlesource.com/c/go/+/516861 Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Russ Cox <rsc@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Russ Cox <rsc@golang.org> TryBot-Bypass: Russ Cox <rsc@golang.org>
2023-08-03runtime/internal: switch GOWASIRUNTIME defaultJohan Brandhorst-Satzkorn
CL 513235 switched the default wasip1 runtime in the misc/wasm executable script, but it missed this use of the GOWASIRUNTIME environment variable. Update this instance to make the default runtime choice consistent. Change-Id: Iff7f96231422747a38d65d13a940f6e9d04d835d Reviewed-on: https://go-review.googlesource.com/c/go/+/515115 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Achille Roussel <achille.roussel@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2023-06-29runtime: run wasip1 tests with wazeroChris O'Hara
The latest wazero release supports non-blocking I/O and pre-opened sockets. Unmask the relevant wasip1 tests so that there are multiple WebAssembly runtimes exercising these code paths. Change-Id: I8506ab35186f98fde2cd3ce84634d5fcb7b053f1 Reviewed-on: https://go-review.googlesource.com/c/go/+/503595 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Run-TryBot: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com>
2023-05-26syscall: implement wasip1 FcntlChris O'Hara
CL 494915 broke non-blocking I/O on wasip1 for files opened with os.NewFile. This is fixed by providing an implementation of fcntl(F_GETFL) for wasip1. Change-Id: I78979076b95495fd4b94814552e5f5b043270cd0 Reviewed-on: https://go-review.googlesource.com/c/go/+/498195 Auto-Submit: Ian Lance Taylor <iant@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Achille Roussel <achille.roussel@gmail.com> Run-TryBot: Ian Lance Taylor <iant@google.com>
2023-05-25all: fix buildall.bashRuss Cox
Disable the android and ios builds since cross-compiling fails there. Also make runtime/internal/wasitest not build on systems that don't have syscall.Mkfifo for it to use (including, ironically, wasm itself). Change-Id: I28eb1f216f9952f81a107056e97ee38e350f9287 Reviewed-on: https://go-review.googlesource.com/c/go/+/498255 Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-05-25net: implement wasip1 FileListener and FileConnChris O'Hara
Implements net.FileListener and net.FileConn for wasip1. net.FileListener can be used with a pre-opened socket. If the WASM module knows the file descriptor, a listener can be constructed with: l, err := net.FileListener(os.NewFile(fd, "")) If the WASM module does not know the file descriptor, but knows that at least one of the preopens is a socket, it can find the file descriptor and construct a listener like so: func findListener() (net.Listener, error) { // We start looking for pre-opened sockets at fd=3 because 0, 1, // and 2 are reserved for stdio. Pre-opened directories also // start at fd=3, so we skip fds that aren't sockets. Once we // reach EBADF we know there are no more pre-opens. for preopenFd := uintptr(3); ; preopenFd++ { l, err := net.FileListener(os.NewFile(preopenFd, "")) var se syscall.Errno switch errors.As(err, &se); se { case syscall.ENOTSOCK: continue case syscall.EBADF: err = nil } return l, err } } A similar strategy can be used with net.FileConn and pre-opened connection sockets. The wasmtime runtime supports pre-opening listener sockets: $ wasmtime --tcplisten 127.0.0.1:8080 module.wasm Change-Id: Iec6ae4ffa84b3753cce4f56a2817e150445db643 Reviewed-on: https://go-review.googlesource.com/c/go/+/493358 Reviewed-by: Matthew Dempsky <mdempsky@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Bypass: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2023-05-25runtime: implement wasip1 netpollChris O'Hara
Implements netpoll using WASI's poll_oneoff system call. This enables non-blocking I/O support for wasip1. Change-Id: Ie395fa49d651c8b8262d485e2847dd65b0a10bc6 Reviewed-on: https://go-review.googlesource.com/c/go/+/493357 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Reviewed-by: Julien Fabre <ju.pryz@gmail.com> Auto-Submit: Johan Brandhorst-Satzkorn <johan.brandhorst@gmail.com> Run-TryBot: Ian Lance Taylor <iant@golang.org>
2023-05-20runtime: consolidate on a single closeonexec definitionIan Lance Taylor
Now that we implement fcntl on all Unix systems, we can write closeonexec that uses it. This lets us remove a bunch of assembler code. Change-Id: If35591df535ccfc67292086a9492f0a8920e3681 Reviewed-on: https://go-review.googlesource.com/c/go/+/496081 Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Run-TryBot: Ian Lance Taylor <iant@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-03-28runtime: clean atomic_loong64.s of unnecessary package referencesGuoqi Chen
The symbols are all defined within the same file, no need to reference through package names. Change-Id: I81c27831e85666ebd26d346aeb8f023e52d98acc Reviewed-on: https://go-review.googlesource.com/c/go/+/479497 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Ian Lance Taylor <iant@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Auto-Submit: Ian Lance Taylor <iant@google.com> Run-TryBot: Keith Randall <khr@golang.org> Run-TryBot: Ian Lance Taylor <iant@google.com> Reviewed-by: WANG Xuerui <git@xen0n.name>
2023-03-20all: gofmtDamien Neil
Change-Id: I926388ee5aeeff11f765cbd4558b66645d1bbc08 Reviewed-on: https://go-review.googlesource.com/c/go/+/477836 Run-TryBot: Damien Neil <dneil@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com>
2023-03-14runtime/internal/sys: remove 386 assembly codeWayne Zuo
Change-Id: Ia4f8638d626c30b91729caa0c58a96451c627f67 Reviewed-on: https://go-review.googlesource.com/c/go/+/475736 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org> TryBot-Result: Gopher Robot <gobot@golang.org>
2023-02-08runtime/internal/sys: remove Bswap{32|64} assembly for 386Wayne Zuo
CL 465515 instrinsify these functions, so that we can remove them. Change-Id: I81c9eb62ecf56d5a292dc5aced542b36b53847dc Reviewed-on: https://go-review.googlesource.com/c/go/+/465516 Reviewed-by: Keith Randall <khr@golang.org> Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-12-22runtime/internal/startlinetest: work around shared buildmode linking issueCherry Mui
The runtime/internal/startlinetest package contains a call to a function defined in runtime_test. Generally this is fine as this package is only linked in for runtime_test. Except that for "go install -buildmode=shared std", which include all packages in std, including this test-only internal package. In this mode, the caller is included in the linking but the callee is not, causing linking error. Work around it by calling runtime_test.callerStartLine via a function pointer. The function pointer is only set in runtime_test. In the shared std build, the function pointer will not be set, and this is fine. Fixes #57334. Change-Id: I7d871c50ce6599c6ea2802cf6e14bb749deab220 Reviewed-on: https://go-review.googlesource.com/c/go/+/458696 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Ian Lance Taylor <iant@google.com> Run-TryBot: Cherry Mui <cherryyz@google.com>
2022-12-17cmd/compile: sign-extend the 2nd argument of the LoweredAtomicCas32 on ↵Guoqi Chen
loong64,mips64x,riscv64 The function LoweredAtomicCas32 is implemented using the LL-SC instruction pair on loong64, mips64x, riscv64. However,the LL instruction on loong64, mips64x, riscv64 is sign-extended, so it is necessary to sign-extend the 2nd parameter "old" of the LoweredAtomicCas32, so that the instruction BNE after LL can get the desired result. The function prototype of LoweredAtomicCas32 in golang: func Cas32(ptr *uint32, old, new uint32) bool When using an intrinsify implementation: case 1: (*ptr) <= 0x80000000 && old < 0x80000000 E.g: (*ptr) = 0x7FFFFFFF, old = Rarg1= 0x7FFFFFFF After run the instruction "LL (Rarg0), Rtmp": Rtmp = 0x7FFFFFFF Rtmp ! = Rarg1(old) is false, the result we expect case 2: (*ptr) >= 0x80000000 && old >= 0x80000000 E.g: (*ptr) = 0x80000000, old = Rarg1= 0x80000000 After run the instruction "LL (Rarg0), Rtmp": Rtmp = 0xFFFFFFFF_80000000 Rtmp ! = Rarg1(old) is true, which we do not expect When using an non-intrinsify implementation: Because Rarg1 is loaded from the stack using sign-extended instructions ld.w, the situation described in Case 2 above does not occur Benchmarks on linux/loong64: name old time/op new time/op delta Cas 50.0ns ± 0% 50.1ns ± 0% ~ (p=1.000 n=1+1) Cas64 50.0ns ± 0% 50.1ns ± 0% ~ (p=1.000 n=1+1) Cas-4 56.0ns ± 0% 56.0ns ± 0% ~ (p=1.000 n=1+1) Cas64-4 56.0ns ± 0% 56.0ns ± 0% ~ (p=1.000 n=1+1) Benchmarks on Loongson 3A4000 (GOARCH=mips64le, 1.8GHz) name old time/op new time/op delta Cas 70.4ns ± 0% 70.3ns ± 0% ~ (p=1.000 n=1+1) Cas64 70.7ns ± 0% 70.6ns ± 0% ~ (p=1.000 n=1+1) Cas-4 81.1ns ± 0% 80.8ns ± 0% ~ (p=1.000 n=1+1) Cas64-4 80.9ns ± 0% 80.9ns ± 0% ~ (p=1.000 n=1+1) Fixes #57282 Change-Id: I190a7fc648023b15fa392f7fdda5ac18c1561bac Reviewed-on: https://go-review.googlesource.com/c/go/+/457135 Run-TryBot: Than McIntosh <thanm@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org> Reviewed-by: Than McIntosh <thanm@google.com> Reviewed-by: David Chase <drchase@google.com>
2022-11-24syscall, runtime/internal/syscall: zero r2 before mips linux syscallsRongrong
All mips variant perform syscalls similarly. R2 (v0) holds r1 and R3 (v1) holds r2 of a syscall. The latter is only used by 2-ret syscalls. A 1-ret syscall would not touch R3 but keeps it as is, making r2 be a random value. Always reset it to 0 before SYSCALL to fix the issue. Fixes #56426 Change-Id: Ie49965c0c3c224c4a895703ac659205cd040ff56 Reviewed-on: https://go-review.googlesource.com/c/go/+/452975 TryBot-Result: Gopher Robot <gobot@golang.org> Run-TryBot: Meng Zhuo <mzh@golangcn.org> Reviewed-by: Austin Clements <austin@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Meng Zhuo <mzh@golangcn.org>
2022-11-18runtime,cmd/link: increase stack guard space when building with -raceKeith Randall
More stuff to do = more stack needed. Bump up the guard space when building with the race detector. Fixes #54291 Change-Id: I701bc8800507921bed568047d35b8f49c26e7df7 Reviewed-on: https://go-review.googlesource.com/c/go/+/451217 Run-TryBot: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2022-11-07runtime: fix a few function names on commentscui fliter
Change-Id: I9ef4898d68dfd06618c0bd8e23f81a1d2c77a836 Signed-off-by: cui fliter <imcusg@gmail.com> Reviewed-on: https://go-review.googlesource.com/c/go/+/447460 Auto-Submit: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Run-TryBot: Michael Pratt <mpratt@google.com>
2022-10-29runtime/internal/atomic: enable atomic 64bit types for all functions on ↵Guoqi Chen
linux/loong64 ref. CL 356169 Change-Id: I813750d3fe191afe50d4029024ba97800211f688 Reviewed-on: https://go-review.googlesource.com/c/go/+/414414 Reviewed-by: WANG Xuerui <git@xen0n.name> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org> Reviewed-by: Heschi Kreinick <heschi@google.com> TryBot-Result: Gopher Robot <gobot@golang.org>
2022-10-26runtime/internal/syscall: use ABIInternal for Syscall6 on riscv64Wayne Zuo
Change-Id: Iceed0f55038c87f261b60309e025132142946364 Reviewed-on: https://go-review.googlesource.com/c/go/+/443557 Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org> Reviewed-by: Michael Pratt <mpratt@google.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Wayne Zuo <wdvxdr@golangcn.org>
2022-10-25runtime/internal/syscall: convert PPC64 Syscall6 to ABIInternalPaul E. Murphy
This avoids a lot of stacking. Change-Id: If5c5cf33335ffdcb7eecbd3f2db7858a415d817d Reviewed-on: https://go-review.googlesource.com/c/go/+/443736 TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: David Chase <drchase@google.com> Run-TryBot: Paul Murphy <murp@ibm.com> Reviewed-by: Bryan Mills <bcmills@google.com> Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2022-10-18runtime: replace all uses of CtzXX with TrailingZerosXXYoulin Feng
Replace all uses of Ctz64/32/8 with TrailingZeros64/32/8, because they are the same and maybe duplicated. Also renamed CtzXX functions in 386 assembly code. Change-Id: I19290204858083750f4be589bb0923393950ae6d Reviewed-on: https://go-review.googlesource.com/c/go/+/438935 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Bryan Mills <bcmills@google.com> Auto-Submit: Keith Randall <khr@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Keith Randall <khr@google.com> Run-TryBot: Keith Randall <khr@golang.org>
2022-10-18runtime/internal/atomic: add write barrier-enabled pointer atomicsRuss Cox
UnsafePointer.Store, UnsafePointer.CompareAndSwap were missing, although .StoreNoWB and .CompareAndSwapNoWB existed. Same for Pointer[T}. Do the linkname tricks necessary to add those methods. Change-Id: I925ee27673288accb15ebe93898f9eb01ab46a98 Reviewed-on: https://go-review.googlesource.com/c/go/+/443379 Auto-Submit: Russ Cox <rsc@golang.org> Reviewed-by: Austin Clements <austin@google.com> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Gopher Robot <gobot@golang.org>