aboutsummaryrefslogtreecommitdiff
path: root/src/runtime
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2025-10-17 20:02:55 +0000
committerGopher Robot <gobot@golang.org>2025-10-20 20:28:55 -0700
commit79ae97fe9bf44814f7bed7e6a6297150070817f3 (patch)
tree85a8b3392a3958db55dc733aaac1e5d0f1b1503e /src/runtime
parentf838faffe21afd2d5c177c04df8836c93e273b4b (diff)
downloadgo-79ae97fe9bf44814f7bed7e6a6297150070817f3.tar.xz
runtime: make procyieldAsm no longer loop infinitely if passed 0
Change-Id: I9f01692373623687e09bee54efebaac0ee361f81 Reviewed-on: https://go-review.googlesource.com/c/go/+/712664 Auto-Submit: Michael Knyszek <mknyszek@google.com> Reviewed-by: Cherry Mui <cherryyz@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/runtime')
-rw-r--r--src/runtime/asm_386.s3
-rw-r--r--src/runtime/asm_amd64.s3
-rw-r--r--src/runtime/asm_arm64.s2
-rw-r--r--src/runtime/asm_ppc64x.s3
-rw-r--r--src/runtime/stubs.go7
5 files changed, 11 insertions, 7 deletions
diff --git a/src/runtime/asm_386.s b/src/runtime/asm_386.s
index a54ca110e5..03f1a46b55 100644
--- a/src/runtime/asm_386.s
+++ b/src/runtime/asm_386.s
@@ -599,10 +599,13 @@ CALLFN(·call1073741824, 1073741824)
TEXT runtime·procyieldAsm(SB),NOSPLIT,$0-0
MOVL cycles+0(FP), AX
+ TESTL AX, AX
+ JZ done
again:
PAUSE
SUBL $1, AX
JNZ again
+done:
RET
TEXT ·publicationBarrier(SB),NOSPLIT,$0-0
diff --git a/src/runtime/asm_amd64.s b/src/runtime/asm_amd64.s
index dbf54487a7..a4c6c53a90 100644
--- a/src/runtime/asm_amd64.s
+++ b/src/runtime/asm_amd64.s
@@ -817,10 +817,13 @@ CALLFN(·call1073741824, 1073741824)
TEXT runtime·procyieldAsm(SB),NOSPLIT,$0-0
MOVL cycles+0(FP), AX
+ TESTL AX, AX
+ JZ done
again:
PAUSE
SUBL $1, AX
JNZ again
+done:
RET
diff --git a/src/runtime/asm_arm64.s b/src/runtime/asm_arm64.s
index 94a5b9ee6c..8bbb6b8a87 100644
--- a/src/runtime/asm_arm64.s
+++ b/src/runtime/asm_arm64.s
@@ -1038,10 +1038,12 @@ aesloop:
TEXT runtime·procyieldAsm(SB),NOSPLIT,$0-0
MOVWU cycles+0(FP), R0
+ CBZ R0, done
again:
YIELD
SUBW $1, R0
CBNZ R0, again
+done:
RET
// Save state of caller into g->sched,
diff --git a/src/runtime/asm_ppc64x.s b/src/runtime/asm_ppc64x.s
index e461764e55..aaa2e4346c 100644
--- a/src/runtime/asm_ppc64x.s
+++ b/src/runtime/asm_ppc64x.s
@@ -614,6 +614,8 @@ CALLFN(·call1073741824, 1073741824)
TEXT runtime·procyieldAsm(SB),NOSPLIT|NOFRAME,$0-4
MOVW cycles+0(FP), R7
+ CMP $0, R7
+ BEQ done
// POWER does not have a pause/yield instruction equivalent.
// Instead, we can lower the program priority by setting the
// Program Priority Register prior to the wait loop and set it
@@ -625,6 +627,7 @@ again:
CMP $0, R7
BNE again
OR R6, R6, R6 // Set PPR priority back to medium-low
+done:
RET
// Save state of caller into g->sched,
diff --git a/src/runtime/stubs.go b/src/runtime/stubs.go
index 1692283541..d5a35d15b2 100644
--- a/src/runtime/stubs.go
+++ b/src/runtime/stubs.go
@@ -283,13 +283,6 @@ func procyield(cycles uint32) {
}
// procyieldAsm is the assembly implementation of procyield.
-//
-// It may loop infinitely if called with cycles == 0. Prefer
-// procyield, which will compile down to nothing in such cases,
-// instead.
-//
-// FIXME: The implementation really should not loop infinitely if
-// the number of cycles is 0.
func procyieldAsm(cycles uint32)
type neverCallThisFunction struct{}