]> Cypherpunks repositories - gostls13.git/commit
runtime: wrap procyield assembly and check for 0
authorMichael Anthony Knyszek <mknyszek@google.com>
Fri, 17 Oct 2025 19:53:36 +0000 (19:53 +0000)
committerGopher Robot <gobot@golang.org>
Tue, 21 Oct 2025 03:28:51 +0000 (20:28 -0700)
commitf838faffe21afd2d5c177c04df8836c93e273b4b
tree77d4e366f6d88360fa6f65ccaf741884ca03edbf
parentee4d2c312de90296a6b6f687f6a7ea8b9916af54
runtime: wrap procyield assembly and check for 0

procyield will currently loop infinitely if passed 0 on several
platforms. This change sidesteps this bug by renaming procyield to
procyieldAsm, and adding a wrapper named procyield that checks for
cycles == 0. The benefit of this structure is that procyield called
with a constant cycle count of 0 will be inlined and constant folded
away, the expected behavior of a procyield of 0 cycles.

A follow-up change will fix the assembly to not have this footgun
anymore.

Change-Id: I7068abfeb961bc0fa475e216836f7c0e46b38373
Reviewed-on: https://go-review.googlesource.com/c/go/+/712663
Reviewed-by: Michael Pratt <mpratt@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Cherry Mui <cherryyz@google.com>
Auto-Submit: Michael Knyszek <mknyszek@google.com>
12 files changed:
src/runtime/asm_386.s
src/runtime/asm_amd64.s
src/runtime/asm_arm.s
src/runtime/asm_arm64.s
src/runtime/asm_loong64.s
src/runtime/asm_mips64x.s
src/runtime/asm_mipsx.s
src/runtime/asm_ppc64x.s
src/runtime/asm_riscv64.s
src/runtime/asm_s390x.s
src/runtime/asm_wasm.s
src/runtime/stubs.go