mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
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>
This commit is contained in:
parent
f838faffe2
commit
79ae97fe9b
5 changed files with 11 additions and 7 deletions
|
|
@ -599,10 +599,13 @@ CALLFN(·call1073741824, 1073741824)
|
||||||
|
|
||||||
TEXT runtime·procyieldAsm(SB),NOSPLIT,$0-0
|
TEXT runtime·procyieldAsm(SB),NOSPLIT,$0-0
|
||||||
MOVL cycles+0(FP), AX
|
MOVL cycles+0(FP), AX
|
||||||
|
TESTL AX, AX
|
||||||
|
JZ done
|
||||||
again:
|
again:
|
||||||
PAUSE
|
PAUSE
|
||||||
SUBL $1, AX
|
SUBL $1, AX
|
||||||
JNZ again
|
JNZ again
|
||||||
|
done:
|
||||||
RET
|
RET
|
||||||
|
|
||||||
TEXT ·publicationBarrier(SB),NOSPLIT,$0-0
|
TEXT ·publicationBarrier(SB),NOSPLIT,$0-0
|
||||||
|
|
|
||||||
|
|
@ -817,10 +817,13 @@ CALLFN(·call1073741824, 1073741824)
|
||||||
|
|
||||||
TEXT runtime·procyieldAsm(SB),NOSPLIT,$0-0
|
TEXT runtime·procyieldAsm(SB),NOSPLIT,$0-0
|
||||||
MOVL cycles+0(FP), AX
|
MOVL cycles+0(FP), AX
|
||||||
|
TESTL AX, AX
|
||||||
|
JZ done
|
||||||
again:
|
again:
|
||||||
PAUSE
|
PAUSE
|
||||||
SUBL $1, AX
|
SUBL $1, AX
|
||||||
JNZ again
|
JNZ again
|
||||||
|
done:
|
||||||
RET
|
RET
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1038,10 +1038,12 @@ aesloop:
|
||||||
|
|
||||||
TEXT runtime·procyieldAsm(SB),NOSPLIT,$0-0
|
TEXT runtime·procyieldAsm(SB),NOSPLIT,$0-0
|
||||||
MOVWU cycles+0(FP), R0
|
MOVWU cycles+0(FP), R0
|
||||||
|
CBZ R0, done
|
||||||
again:
|
again:
|
||||||
YIELD
|
YIELD
|
||||||
SUBW $1, R0
|
SUBW $1, R0
|
||||||
CBNZ R0, again
|
CBNZ R0, again
|
||||||
|
done:
|
||||||
RET
|
RET
|
||||||
|
|
||||||
// Save state of caller into g->sched,
|
// Save state of caller into g->sched,
|
||||||
|
|
|
||||||
|
|
@ -614,6 +614,8 @@ CALLFN(·call1073741824, 1073741824)
|
||||||
|
|
||||||
TEXT runtime·procyieldAsm(SB),NOSPLIT|NOFRAME,$0-4
|
TEXT runtime·procyieldAsm(SB),NOSPLIT|NOFRAME,$0-4
|
||||||
MOVW cycles+0(FP), R7
|
MOVW cycles+0(FP), R7
|
||||||
|
CMP $0, R7
|
||||||
|
BEQ done
|
||||||
// POWER does not have a pause/yield instruction equivalent.
|
// POWER does not have a pause/yield instruction equivalent.
|
||||||
// Instead, we can lower the program priority by setting the
|
// Instead, we can lower the program priority by setting the
|
||||||
// Program Priority Register prior to the wait loop and set it
|
// Program Priority Register prior to the wait loop and set it
|
||||||
|
|
@ -625,6 +627,7 @@ again:
|
||||||
CMP $0, R7
|
CMP $0, R7
|
||||||
BNE again
|
BNE again
|
||||||
OR R6, R6, R6 // Set PPR priority back to medium-low
|
OR R6, R6, R6 // Set PPR priority back to medium-low
|
||||||
|
done:
|
||||||
RET
|
RET
|
||||||
|
|
||||||
// Save state of caller into g->sched,
|
// Save state of caller into g->sched,
|
||||||
|
|
|
||||||
|
|
@ -283,13 +283,6 @@ func procyield(cycles uint32) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// procyieldAsm is the assembly implementation of procyield.
|
// 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)
|
func procyieldAsm(cycles uint32)
|
||||||
|
|
||||||
type neverCallThisFunction struct{}
|
type neverCallThisFunction struct{}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue