aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
AgeCommit message (Collapse)Author
2026-02-28runtime/cgo: add abi_riscv64.h for callee-saved register macrosGeorge Adams
Add abi_riscv64.h with SAVE_GPR/SAVE_FPR macros for saving and restoring the RISC-V callee-saved registers, following the pattern established by the other abi_*.h headers. Refactor asm_riscv64.s (cgo crosscall2), asm_riscv64.s (runtime _rt0_riscv64_lib), and race_riscv64.s (racecallbackthunk) to use the new macros, replacing inline register save/restore sequences. Change-Id: I83cef17a35c57fc8b5e045e7181460283ae5b423 Reviewed-on: https://go-review.googlesource.com/c/go/+/749900 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Russ Cox <rsc@golang.org>
2026-02-27runtime: unified the calculate for max objects per spanTony
the freemark is used for mark the status for one span's slots. the size can be simplify by directly use the predefined constant of gc.MaxObjsPerSpan Change-Id: Ieb174655a829cceeb70b908d83b48c829cc08705 GitHub-Last-Rev: d36aa731754912a697d8ca3d82079a067e64acf8 GitHub-Pull-Request: golang/go#77841 Reviewed-on: https://go-review.googlesource.com/c/go/+/749760 Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Tony Tang <jianfeng.tony@gmail.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: David Chase <drchase@google.com>
2026-02-27runtime/cgo: avoid unused parameter warningTamir Duberstein
Annotate the unused parameter with `__attribute__((unused))` to avoid build failures in environments that treat unused parameters as errors. We see this when using `rules_go`: ``` @@rules_go+//:stdlib builder failed: error executing GoStdlib command (from stdlib rule target @@rules_go+//:stdlib) bazel-out/linux_host_platform-opt-exec-ST-f2d1f3f5d18d/bin/external/rules_go++go_sdk+main___download_0/builder_reset/builder stdlib -sdk external/rules_go++go_sdk+main___download_0 -goroot ... (remaining 16 arguments skipped) Use --sandbox_debug to see verbose messages from the sandbox and retain the sandbox build root for debugging stderr: # runtime/cgo gcc_clearenv.c:13:23: error: unused parameter '_unused' [-Werror,-Wunused-parameter] stdlib: error running subcommand external/rules_go++go_sdk+main___download_0/bin/go: exit status 1 ``` This matches the style used in `src/runtime/cgo/gcc_libinit.c` since dc2ae2886fbcd2297d2a0ea67a5d220ae2c74152 which fixed an identical issue. Change-Id: I8c805962b88af480839f8662a1fcf4ed1e5d574d GitHub-Last-Rev: b99fbda4f6fe7a199a59af425e997111137262a4 GitHub-Pull-Request: golang/go#77847 Reviewed-on: https://go-review.googlesource.com/c/go/+/749840 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> Reviewed-by: David Chase <drchase@google.com>
2026-02-27runtime: on android/arm64, don't read outside 16-byte regionsKeith Randall
Because MTE might be enforced. Update #59090 Update #27610 Change-Id: Idfaecbf3b7a93c5e371abcace666febfc303de9a Reviewed-on: https://go-review.googlesource.com/c/go/+/749062 Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com>
2026-02-27runtime: do signal stack clearing when parking MsDaniel Morsing
Clearing signal stacks during STW meant an added latency that was linear with respect to the number of Ms, parked or running. Since that number be quite high, we need an alternate scheme. Instead of clearing in the GC cycle, clear the signal stack whenever an M is parked and has the potential to stay parked until the end of the next GC cycle. This implements the wanted behavior for runtime/secret at the cost of a little bit of extra latency that will be dwarfed by the time it takes to perform a syscall. Change-Id: Ieb9618f46736c34486e17a3d6185661a98756d0d Reviewed-on: https://go-review.googlesource.com/c/go/+/724282 Auto-Submit: Daniel Morsing <daniel.morsing@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2026-02-26runtime: fix scan size calculation for small arrays of only pointersWang Deyu
When allocating arrays, scan size should be the position of the last pointer in the last object. Small array allocations containing only pointers (for example, the backing store for a []*int) have a fast path in the allocator for unrolling their bits. However, this fast path doesn't correctly calculate the scan size for the object, and the result is that only the first pointer is actually counted. This might lead the GC to think it has less work to do than it actually does. Fixes #77573 Change-Id: I4b9db6db069e3fb64e4fcbbbc89b68585a71d483 Reviewed-on: https://go-review.googlesource.com/c/go/+/744840 Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Wayne Zuo <wdvxdr1123@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-24internal/cpu: use IsProcessorFeaturePresent to calculate ARM64 on windowsAlex Brainman
This CL also adds internal/syscall/windows.IsProcessorFeaturePresent and all processor feature consts to test internal/cpu changes. For #76791 Change-Id: Iba9cc812f676b700e767a1ed7f194fcb4a67f61b Cq-Include-Trybots: luci.golang.try:gotip-windows-arm64 Reviewed-on: https://go-review.googlesource.com/c/go/+/745560 Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: David Chase <drchase@google.com>
2026-02-24runtime: simplify pprof labels in tracebacksDavid Finkel
Per discussion on #76349, move the traceback labels outside the goroutine status block and remove the quoting if the key and value strings are completely ASCII alphanumeric. Also allow [._/] because those are generally benign and may show up in a lot of use-cases if these goroutine labels become more visible. Updates #76349 Change-Id: I338e18d7ca48bbc7504f7c699f17adade2d291f9 Reviewed-on: https://go-review.googlesource.com/c/go/+/742580 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Florian Lehner <lehner.florian86@gmail.com> Auto-Submit: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alan Donovan <adonovan@google.com>
2026-02-24os/signal: completely ignore bogus signalsMichael Pratt
signal.Notify should ignore bogus signals (syscall.Signals with invalid signal numbers). Ignoring means Notify/Stop/Reset all work fine, but the channel will never receive any events. Today, Stop hangs if Notify has only ever been called with bogus signals because Stop assumes that runtime.signal_recv is running if a handler is present. Notify unconditionally registers the handler, but only starts signal_recv if the signal was valid. Address this by avoiding registering the handler at all if the signal is bogus. We additionally add a bogus signal check to cancel (used by Ignore/Reset). Currently those are calling into the runtime signal_ignore and signal_disable, which do ignore bogus signals, but is now inconsistent with the rest of the package. For #77076. Change-Id: I6a6a636c27c41a158e203bbf470be5f1f3f631bd Reviewed-on: https://go-review.googlesource.com/c/go/+/735040 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Alex Brainman <alex.brainman@gmail.com> Auto-Submit: Michael Pratt <mpratt@google.com>
2026-02-23runtime/cgo: fix setg_gcc call on aix/ppc64qmuntal
aix/ppc64 uses function descriptors instead of function pointers. CL 708235 assumed the latter, which caused a crash when calling setg_gcc. Fix the call by dereferencing the function descriptor to get the entry point and TOC. Tested using gomote, as LUCI builders still don't support aix/ppc64. Fixes #77753. Change-Id: I6a0a6e971341f18f400c044f47b0daa42b93599e Reviewed-on: https://go-review.googlesource.com/c/go/+/747960 Run-TryBot: Paul Murphy <paumurph@redhat.com> Reviewed-by: Paul Murphy <paumurph@redhat.com> TryBot-Result: Gopher Robot <gobot@golang.org> Reviewed-by: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: David Chase <drchase@google.com>
2026-02-23runtime: printquoted: fix decoderune callDavid Finkel
go.dev/cl/742305 had a stale signature for decoderune, which was updated in go.dev/cl/725101 (converting an argument and return value from int to uint). Add appropriate conversions. Change-Id: Ia4e5bcbab4275d5a988c9dce552cd7590474b995 Reviewed-on: https://go-review.googlesource.com/c/go/+/748300 Reviewed-by: Alan Donovan <adonovan@google.com> Reviewed-by: Nicholas Husin <nsh@golang.org> Auto-Submit: Alan Donovan <adonovan@google.com> Reviewed-by: Nicholas Husin <husin@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-23runtime: printquoted: preserve bytes of invalid UTF-8 encodingsDavid Finkel
Previously, printquoted would render each byte of an invalid UTF-8 sequence as "\uFFFD", which was lossy. This CL adjusts printquoted to distinguish valid encodings of U+FFFD from invalid encodings; each byte of the latter is now printed losslessly as "\xXX" Updates #76349 Change-Id: If9a877f01b497763425d9d11a58eb2a6e2c816b2 Reviewed-on: https://go-review.googlesource.com/c/go/+/742305 Reviewed-by: Alan Donovan <adonovan@google.com> Auto-Submit: Michael Pratt <mpratt@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-23runtime: remove write barriers from traceRegionAllocNick Ripley
The memory managed by traceRegionAlloc is off-heap by design. However, stores to the "current" pointer currently have a write barrier. This CL switches the stores to their write barrier-free equivalents. If the traceMap data structure gets extended and used elsewhere in the future, such as for runtime lock contention profiling, we might not have a P and thus won't be able to use a write barrier in this code. But for now this is just a cleanup and minor efficiency improvment. Change-Id: I3081c9d48a8471fd87534e5c4951823d6a6a6964 Reviewed-on: https://go-review.googlesource.com/c/go/+/748120 Reviewed-by: David Chase <drchase@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2026-02-21runtime/secret: run crash tests under memory validating modesDaniel Morsing
The crashing test for runtime/secret does not run afoul of the memory validators like the standard tests does. Pass through to the crashing binary to shake out as many problems as possible. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-asan-clang15,gotip-linux-amd64-msan-clang15,gotip-linux-arm64-asan-clang15 Change-Id: I1999fc2012ef520c80cf77d5b2d4bf4b1b8cb0b2 Reviewed-on: https://go-review.googlesource.com/c/go/+/724622 Reviewed-by: Mark Freeman <markfreeman@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2026-02-19runtime/cgo: remove unnecessary ARM_TP_ADDRESS check on FreeBSDqmuntal
ARM_TP_ADDRESS has not been used since https://golang.org/cl/89150043. There is no need to check that value anymore. Change-Id: I9772de3587aec562c9ab48d0def11e3714e5263a Reviewed-on: https://go-review.googlesource.com/c/go/+/745603 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2026-02-18runtime/cgo: deduplicate Android's fatalfqmuntal
Most of the fatalf code is shared between Android and other Unix-like platforms, but Android has some special handling for the case where the fatalf is called from an .apk file. Put the Android-specific code in the generic fatalf code, and implement the Android-specific handling using a #ifdef guard. Change-Id: Ic7a49792648260c83b213380b77c0c352e9486f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/745604 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com>
2026-02-18runtime/cgo: use pthreads to get stack bound on Solarisqmuntal
x_cgo_getstackbound already supports Solaris using pthread_getattr_np, which is more robust than getcontext. Cq-Include-Trybots: luci.golang.try:gotip-solaris-amd64 Change-Id: Ib96d9c30df3413b4c5044a1b2c392b25835c8004 Reviewed-on: https://go-review.googlesource.com/c/go/+/745602 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Quim Muntal <quimmuntal@gmail.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2026-02-18runtime/cgo: rename and update ppc64x and s390x croscall1 functionsqmuntal
crosscall1 has the same signature and behavior on all platforms except for ppc64x and s390x, fix that. Cq-Include-Trybots: luci.golang.try:gotip-linux-ppc64le_power9,gotip-linux-ppc64_power8,gotip-linux-s390x Change-Id: Iead8b578a45787bb1fb2dd2dcfcb181514595637 Reviewed-on: https://go-review.googlesource.com/c/go/+/708235 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com>
2026-02-18runtime: update comments about known g offsetsMichael Anthony Knyszek
I can't find any evidence that most of these offsets are hard-coded anymore, and the locations they reference (liblink, libmach) definitely don't exist anymore. The stackguards are much more obviously hard-coded into and referenced from cmd/internal/obj/*, so update that reference. Change-Id: I814584846a85353a6373193ea9cd802ace1ed5ad Reviewed-on: https://go-review.googlesource.com/c/go/+/741540 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2026-02-18runtime: tell the race detector about synchronization on mainInitDoneCherry Mui
CL 743940 puts an atomic bool initialization-done channel, which is a nice optimization. In race mode, however, the atomic bool does not have race instrumentation, so the race detector doesn't know the happens-before edge between the initialization and the cgo callback. To tell the race detector about this synchronization, just use the channel unconditionally in race mode. Channel operations have the proper race instrumentation. Alternatively, we could explicitly instrument the atomic boolean operations. TODO: write a test. Change-Id: I466b20a46cd39d2bbe2149a9009e1a01b15891e2 Reviewed-on: https://go-review.googlesource.com/c/go/+/746581 Reviewed-by: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2026-02-17runtime/cgo: remove clang mmap bug workaroundqmuntal
Clang 3.8 was released in 2016, that is 10 years ago. The issue that the workaround was addressing (a bug in the memory sanitizer) is no longer relevant. Change-Id: I277ea94cf1bfbc6a9da63841be8ac990c839d7b7 Reviewed-on: https://go-review.googlesource.com/c/go/+/745662 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Mark Freeman <markfreeman@google.com>
2026-02-17all: use LF line ending for C filesCherry Mui
For Go files, gofmt already converts CRLF line ending to LF. For C and assembly files, we don't enforce a format, but most files in tree are written with LF line ending, and the C toolchain can handle them file, even on Windows. Convert all to LF line ending for consistency. Will look into adding a test for them. Updates #9281. Change-Id: Idc0dc13f0ab90b8cd8ea118abf9cb195ec438fe7 Reviewed-on: https://go-review.googlesource.com/c/go/+/746220 Reviewed-by: Mark Freeman <markfreeman@google.com> Reviewed-by: Quim Muntal <quimmuntal@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-13runtime: delete deadcode in mheapTony Tang
this method seems implements for the old span's memory layout, and is not suitable for the new implements. Change-Id: I30d274bc18f4af440b003ade6f9342038783fc8a GitHub-Last-Rev: d8ac30e3ab32148ef7fd91df57a1590161124303 GitHub-Pull-Request: golang/go#77599 Reviewed-on: https://go-review.googlesource.com/c/go/+/745260 Reviewed-by: Tony Tang <jianfeng.tony@gmail.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Junyang Shao <shaojunyang@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Keith Randall <khr@golang.org>
2026-02-13runtime/cgo: deduplicate x_cgo_init and crosscall1qmuntal
Most platforms share the same implementation for x_cgo_init and crosscall1. Solaris diverges too much and is left for a future CL. Cq-Include-Trybots: luci.golang.try:gotip-freebsd-amd64,gotip-darwin-amd64_14,gotip-darwin-arm64_15,gotip-netbsd-arm64,gotip-openbsd-ppc64,gotip-solaris-amd64,gotip-linux-ppc64_power10 Change-Id: Ib2eeb6456caa5c055e1ac1907c2fdf63db58dafc Reviewed-on: https://go-review.googlesource.com/c/go/+/708035 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Junyang Shao <shaojunyang@google.com>
2026-02-13runtime/cgo: deduplicate pthreads-related functionsqmuntal
Almost all pthread-related functions are exactly the same for Unix OSes. Their implementation can be shared, taking into account the small differences using standard predefined macros. Cq-Include-Trybots: luci.golang.try:gotip-freebsd-amd64,gotip-darwin-amd64_14,gotip-darwin-arm64_15,gotip-netbsd-arm64,gotip-openbsd-amd64,gotip-openbsd-ppc64,gotip-solaris-amd64,gotip-linux-ppc64_power10 Change-Id: I8bee25f0619a5b315439cf12d94312c36c3e5a73 Reviewed-on: https://go-review.googlesource.com/c/go/+/707955 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2026-02-12cmd/link: handle runtime.type based on size, not GOOSIan Lance Taylor
When handling type descriptors, we add some space at the start to ensure that offset 0 does not refer to a valid type descriptor. AIX has an initial runtime.types symbol with a non-zero size, so we used that instead of adding some space. In some cases Darwin also has a runtime.types symbol with a non-zero size. Before CL 727021, this was always fine, because the 8 byte size of runtime.types was swamped by the 32-byte alignment of type descriptors. That didn't work for AIX with the external linker, because on AIX the external linker lays out each symbol separately. Darwin doesn't have that problem, so the layout of the internal linker was preserved. However, CL 727021 changed the alignment of type descriptors to 8. That means that on Darwin the 8 byte size of runtime.types was no longer hidden by the alignment. In effect we were skipping twice: once for runtime.types, and then again explicitly. This only failed when runtime.types has a non-zero size, which is only in a few specific cases. This CL cleans this up by not skipping explicitly in any case where runtime.types has a non-zero size. That handles both AIX and Darwin consistently. To make this clearer, I changed the skip from a single byte to the size of a pointer in all cases. I considered always giving runtime.types a non-zero size, but that is a bigger change, and potentially confusing since there really isn't any data associated with runtime.types. The cases where we must give it a non-zero size are special, and I think it's simpler to keep it that way. For #6853 For #36313 Fixes #77569 Change-Id: I22ebbd0194527ecca96d48849aa00a4fc899e55c Reviewed-on: https://go-review.googlesource.com/c/go/+/744820 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2026-02-11runtime: conservatively scan extended register stateAlexander Musman
Conservatively scan the extended register state when GC scans asynchronously preempted goroutines. This ensures that any pointers that appear only in vector registers at preemption time are kept alive. Using vector registers for small memory moves may load pointers into these registers. If async preemption occurs mid-move, with no write barrier (e.g., heap-to-stack copies) and the source register clobbered or source memory modified by a racing goroutine, the pointer may exist only in the vector register. Without scanning this state, GC could miss live pointers. This addresses concerns raised in CL 738261 and enables safe use of vector registers for operations that may involve pointers. Change-Id: I5f5ce98d6ed6f7cde34b33da0aea1f880c2fcf41 Reviewed-on: https://go-review.googlesource.com/c/go/+/740681 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> Reviewed-by: Austin Clements <austin@google.com>
2026-02-10cmd/compile, runtime: set alignment of type descriptorsIan Lance Taylor
This trivial change reduces the size of cmd/go by 88K. For #6853 For #36313 Change-Id: I5e74acf118bd1c63cbdd256879d8aa8d72a50505 Reviewed-on: https://go-review.googlesource.com/c/go/+/727021 Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2026-02-10runtime: put a bool in front of initialization-done channelIan Lance Taylor
Calls to Go functions from threads not started by Go have to wait for Go initialization to be complete. Before this CL they did this by receiving from a channel that is closed when initialization is done. That works well but introduces a channel operation into cgo calls. This is particularly frustrating because the channel is approximately always closed. This CL adds an atomic bool before the channel, so that in the normal case we are just adding a single locked memory load. We still use the channel as a fallback. For #77522 Change-Id: I8f609bf349bb0f836cefa5f6ad6d0c3c7bbfe5e0 Reviewed-on: https://go-review.googlesource.com/c/go/+/743940 Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2026-02-09runtime/pprof: fix missing Profile docsAustin Clements
CL 688335 accidentally introduced a blank line between the Profile doc comment and the type definition, causing the entire doc to get dropped. Change-Id: I97b1c0e57d142d7caea6e543a0138ed6dcd1c3fe Reviewed-on: https://go-review.googlesource.com/c/go/+/743660 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Auto-Submit: Austin Clements <austin@google.com>
2026-02-09runtime: add race instrumentation for moduleToTypelinksLockchressie
From Cherry Mui on the CL review: The reason why we need race instrumentation is tricky. The runtime package is not compiled with race instrumentation, therefore the race detector doesn't know about synchronizations within the runtime, and usually it doesn't care, as it also doesn't know about the concurrent data accesses in the runtime. However, in this case the concurrent access is in a map. Map accesses are always instrumented https://cs.opensource.google/go/go/+/master:src/internal/runtime/maps/runtime_fast64.go;l=25, even if the map is defined in the runtime. So the race detector does see the concurrent access. But it doesn't see the synchronization. So this CL adds them. Go maps are not common in the runtime. But I recall an issue like this did occur. Maybe we could make the compiler/runtime not to instrument map accesses for maps defined in the runtime (which would be a more involved change). --- The reproducer in src/runtime/testdata/testprog/typelinksrace.go was provided by Cherry Mui. Change-Id: I03b27c51b7278ee4b2939a1a0665169966999b33 Reviewed-on: https://go-review.googlesource.com/c/go/+/742740 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com>
2026-02-07runtime: use unsafe.Slice in itabInitIan Lance Taylor
As opposed to old style (*[1 << 16]T(p)[:n:n]. Change-Id: I6836f87741a2e2f6cef34f87cc839d15e309cc67 Reviewed-on: https://go-review.googlesource.com/c/go/+/726401 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> 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>
2026-02-07internal/abi, runtime: put type descriptor sizes in internal/abiIan Lance Taylor
Change-Id: I4ecfda9f85b00a228e8cf51d7ff4457ef7f83ce5 Reviewed-on: https://go-review.googlesource.com/c/go/+/726160 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@golang.org> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-06runtime: simplify the implementation of walltime and nanotime1 on loong64Guoqi Chen
goos: linux goarch: loong64 pkg: time cpu: Loongson-3A6000 @ 2500.00MHz | old.txt | new.txt | | sec/op | sec/op vs base | Now 34.82n ± 0% 34.24n ± 0% -1.67% (p=0.000 n=10) NowUnixNano 35.44n ± 0% 35.82n ± 0% +1.07% (p=0.000 n=10) NowUnixMilli 36.05n ± 0% 34.24n ± 0% -5.02% (p=0.000 n=10) NowUnixMicro 36.83n ± 0% 34.83n ± 0% -5.43% (p=0.000 n=10) geomean 35.78n 34.78n -2.80% Change-Id: I6ab143b61dbf94c91df2e9dfb80ec9b908219825 Reviewed-on: https://go-review.googlesource.com/c/go/+/741380 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: sophie zhao <zhaoxiaolin@loongson.cn> Reviewed-by: Meidan Li <limeidan@loongson.cn>
2026-02-06cmd/link: use correct alignment for type descriptors on AIXIan Lance Taylor
CL 724261 changed the linker to put all type descriptors that are used for typelinks in a single list. This caused trouble on AIX when linking externally, because the AIX linker aligns symbols individually, rather than honoring the layout of the object file generated by the internal linker. I fixed internal linking problems with CL 740220, but that just made things worse for the external linker. This CL rolls back 740220, and adds commentary. With this CL we force a smaller alignment for type descriptors, use the same alignment for runtime.types and type:*, and use a consistent size for runtime.types in all cases. With this change all the type descriptor related code passes again on AIX, except for the new TestTypePlacement test which I will fix in a followup CL. Fixes #77400 Change-Id: I9f25847eb0588001cb4ce453f211a655400d6a59 Reviewed-on: https://go-review.googlesource.com/c/go/+/740820 Reviewed-by: Michael Pratt <mpratt@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-02-06runtime: add explicit lower bounds check to decoderuneJonah Uellenberg
decoderune is only called by generated code, so we can guarantee that it's non-negative. This allows eliminating the automatic bounds check in it. To make this work, we need to expand the existing optimization to uints. This generally enables BCE for cases like this: ```go func test(list []int, idx uint64) int { if idx >= uint64(len(list)) { return 0 } list1 := list[idx:] return list1[0] } ``` Change-Id: I86a51b26ca0e63522dec99f7d6efe6bdcd2d6487 GitHub-Last-Rev: 82d44e0a080b53ee02c31ee1f92a8a0acd8d2621 GitHub-Pull-Request: golang/go#76610 Reviewed-on: https://go-review.googlesource.com/c/go/+/725101 Reviewed-by: Keith Randall <khr@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@golang.org>
2026-02-06runtime: clarify g object vs stack memory lifetime in HACKING.mdkovan
The documentation states that g objects are "never freed" but does not clarify that goroutine stack memory is managed separately. This can be confusing as it might imply that all goroutine memory (including stacks) is retained indefinitely. Add a paragraph in the Stacks section clarifying that: - Stack memory may be freed when a goroutine exits - Stacks at the starting size are retained for reuse - Grown stacks are freed and reallocated when needed - The g object itself is never freed, only its stack memory Fixes #65843 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> Change-Id: Icb3afbb5392401d695ab129c341ce10106e5a4f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/741505 Reviewed-by: Michael Knyszek <mknyszek@google.com> Auto-Submit: Keith Randall <khr@golang.org> 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>
2026-02-04reflect, runtime: adjust user-created GCData on AIXIan Lance Taylor
On AIX the runtime adjusts the GCData field in getGCMaskOnDemand to account for the AIX dynamic loader moving the data section. That works fine for statically generated types, but it breaks user generated types. The user generated type will have a normal, correct, pointer, and adjusting the pointer will make it point elsewhere. This all happens to work OK when doing an external link, because in that case we do have dynamic relocs and there is no adjustment. But it fails with an internal link. This CL fixes the problem by applying a reverse adjustment to user generated types, so that the adjustment winds up with the original pointer value. Change-Id: Ibf3199b9ffb36e79af134fbed41db2853297de74 Reviewed-on: https://go-review.googlesource.com/c/go/+/740800 Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Auto-Submit: Ian Lance Taylor <iant@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Roland Shoemaker <roland@golang.org>
2026-02-02internal/maps,cmd/compile/internal/walk: replace calls to mapaccess1* with ↵ArsenySamoylov
mapaccess2* mapaccess1* and mapaccess2* functions share the same implementation and differ only in whether the boolean "found" is returned. This change replaces mapaccess1* calls with mapaccess2*. We can do this transparently, since the call site can safely discard the second (boolean) result. Ideally, mapacces1* functions could be removed entirely, but this change keeps them as thin wrappers for compatibility. Fixes #73196 Change-Id: I07c3423d22ed1095ac3666d00e134c2747b2f9c1 Reviewed-on: https://go-review.googlesource.com/c/go/+/736020 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Michael Pratt <mpratt@google.com> Auto-Submit: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@golang.org>
2026-01-30runtime: delete unused parameter of userForcedTony Tang
delete unused parameter userForced Change-Id: I71c26ab5e3fadc532b6b1f266212c6f620769efd GitHub-Last-Rev: 6a32c8ff6e63f8b149c0803e8b6636022bd9d066 GitHub-Pull-Request: golang/go#76732 Reviewed-on: https://go-review.googlesource.com/c/go/+/727680 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Michael Knyszek <mknyszek@google.com> Reviewed-by: Tony Tang <jianfeng.tony@gmail.com>
2026-01-30runtime: align end of systemstack_switch prologue on amd64 for consistency ↵Vasily Leonenko
with gosave_systemstack_switch gosave_systemstack_switch saves PC with fixed offset of 8 bytes from systemstack_switch to bypass prologue. This commit makes this offset consistent with actual address of UNDEF instruction intended to be at that address. Fixes #71440 Change-Id: Ibe6458c5bcb0bdaec228a2f13d6aec7ecc0e319e Reviewed-on: https://go-review.googlesource.com/c/go/+/740360 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-01-30all: switch linux-ppc64 target to ELFv2 ABIPaul Murphy
Go is only capable of producing internally linked, static binaries on linux-ppc64. As such, binaries should run in either ELFv1 or ELFv2 ppc64 userspaces today. This opens the door to enabling cgo and external linking which will require ELFv2 support and userspace, eventually. Fixes #76244 Change-Id: I5ca15037cbe546f352e8693dcf14da51a308b8ca Reviewed-on: https://go-review.googlesource.com/c/go/+/734540 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-01-29runtime: use smaller max align for arm32Keith Randall
Maybe fixes a dashboard build failure for linux/arm32 casued by CL 724261. This value comes from cmd/link/internal/arm/l.go (and in general, maxAlign in cmd/link/internal/$ARCH/<something>.go). Change-Id: I4d02cd41072da1b6ad6c7405044bd7788626b013 Reviewed-on: https://go-review.googlesource.com/c/go/+/740101 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Ian Lance Taylor <iant@golang.org> Auto-Submit: Keith Randall <khr@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-01-29runtime, cmd/link: store type descriptor length, not endIan Lance Taylor
Storing the type descriptor length lets us save a relocation. It also avoids a problem for Darwin dynamic linking. For #6853 Fixes #77350 Change-Id: If5c94330fe10d75690325f3d0b0658060ef3eb2d Reviewed-on: https://go-review.googlesource.com/c/go/+/739681 Reviewed-by: Cherry Mui <cherryyz@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-01-28runtime/metrics: fix panic in Read with empty sliceAmol Yadav
Calling Read with a nil or empty slice previously caused a panic with "index out of range" because the function unconditionally accessed the first element of the slice (via &m[0]) to pass the pointer to the runtime. This change adds a check for len(m) == 0 to return early, preventing the panic when no samples are provided. Fixes #77231 Change-Id: I442635f5c61de432883c8d0efae9cc6aa1363cc9 GitHub-Last-Rev: 6f24f67b18c77a0b36b92017a3f4ef8aa3aa5229 GitHub-Pull-Request: golang/go#77233 Reviewed-on: https://go-review.googlesource.com/c/go/+/737380 Reviewed-by: Amol Yadav <amolyadav6125@gmail.com> Reviewed-by: Michael Pratt <mpratt@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Michael Pratt <mpratt@google.com> Commit-Queue: Michael Pratt <mpratt@google.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com>
2026-01-27cmd/link, runtime: remove typelinksIan Lance Taylor
Instead of adding a typelinks section to a Go binary, mark the start and end of the typelinked type descriptors. The runtime can then step through the descriptors to find them all, rather than relying on the extra linker-generated offset list. The runtime steps through the type descriptors lazily, as many Go programs don't need the typelinks list at all. This reduces the size of cmd/go by 15K bytes, which isn't much but it's not nothing. A future CL will change the reflect package to use the type pointers directly rather than converting to offsets and then back to type pointers. For #6853 Change-Id: Id0af4ce81c5b1cea899fc92b6ff9d2db8ce4c267 Reviewed-on: https://go-review.googlesource.com/c/go/+/724261 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Auto-Submit: Ian Lance Taylor <iant@golang.org>
2026-01-27runtime: rename aeshashbody to runtime.aeshashbodyMichael Pratt
Currently this is a raw symbol name with no package component, which is confusing when seen in profilers or similar tools. This function does not follow a Go ABI, and thus should not have a Go function declaration. go vet requires declaration for standard assembly functions. CL 176100 removed the package name as part of making vet pass on package runtime, but simply making the function static via the <> suffix is sufficient, there is no need to shorten the symbol name. Change-Id: I6a6a636c6030f1c9a4b8bb330978733bb336b08e Reviewed-on: https://go-review.googlesource.com/c/go/+/738521 LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com> Reviewed-by: Michael Knyszek <mknyszek@google.com>
2026-01-27cmd/compile, runtime: avoid improper control transfer instruction hints on ↵wangboyao
riscv64 On RISC-V the JAL and JALR instructions provide Return Address Stack(RAS) prediction hints based on the registers used (as per section 2.5.1 of the RISC-V ISA manual). When a JALR instruction uses X1 or X5 as the source register, it hints that a pop should occur. When making a function call, avoid the use of X5 as a source register since this results in the RAS performing a pop-then-push instead of a push, breaking call/return pairing and significantly degrading front-end branch prediction performance. Based on test result of golang.org/x/benchmarks/json on SpacemiT K1, fix version has a performance improvement of about 7% Fixes #76654 Change-Id: I867c8d7cfb54f5decbe176f3ab3bb3d78af1cf64 Reviewed-on: https://go-review.googlesource.com/c/go/+/726760 Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> 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: Joel Sing <joel@sing.id.au> Run-TryBot: Joel Sing <joel@sing.id.au>
2026-01-23cmd/compile: use equality signatures in hash function generationKeith Randall
There aren't a huge number of generated hash functions, so this probably won't save a whole lot of memory. But it means we can clean up a bunch of code by basing equality and hashing on the same underlying infrastructure. Change-Id: I36ed1e49044fecb33120d8736f1c0403a4a2554e Reviewed-on: https://go-review.googlesource.com/c/go/+/727500 Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com> Reviewed-by: Dmitri Shuralyov <dmitshur@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
2026-01-23runtime: speed up cheaprand and cheaprand64Gavin Lam
The current cheaprand performs 128-bit multiplication on 64-bit numbers and truncate the result to 32 bits, which is inefficient. A 32-bit specific implementation is more performant because it performs 64-bit multiplication on 32-bit numbers instead. The current cheaprand64 involves two cheaprand calls. Implementing it as 64-bit wyrand is significantly faster. Since cheaprand64 discards one bit, I have preserved this behavior. The underlying uint64 function is made available as cheaprandu64. │ old │ new │ │ sec/op │ sec/op vs base │ Cheaprand-8 1.358n ± 0% 1.218n ± 0% -10.31% (n=100) Cheaprand64-8 2.424n ± 0% 1.391n ± 0% -42.62% (n=100) Blocksampled-8 8.347n ± 0% 2.022n ± 0% -75.78% (n=100) Fixes #77149 Change-Id: Ib0b5da4a642cd34d0401b03c1d343041f8230d11 GitHub-Last-Rev: 549d8d407e2bbcaecdee0b52cbf3a513dda637fb GitHub-Pull-Request: golang/go#77150 Reviewed-on: https://go-review.googlesource.com/c/go/+/735480 Auto-Submit: Keith Randall <khr@golang.org> Reviewed-by: Carlos Amedee <carlos@golang.org> Reviewed-by: Keith Randall <khr@google.com> Reviewed-by: Keith Randall <khr@golang.org> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>