Skip to content

Commit 48d61a4

Browse files
Huang Qiqicherrymui
Huang Qiqi
authored andcommitted
runtime: save and restore fcc registers in async preempt on loong64
During the context switch of goroutine scheduling, the value of the fcc0 register needs to be saved on the stack. Fixs #59000. Change-Id: Ie80dbae738f60df6c11a3fe31fc57de817d76afc Reviewed-on: https://go-review.googlesource.com/c/go/+/475577 Reviewed-by: Cherry Mui <[email protected]> Run-TryBot: Cherry Mui <[email protected]> TryBot-Result: Gopher Robot <[email protected]> Reviewed-by: abner chenc <[email protected]> Reviewed-by: Michael Knyszek <[email protected]> Reviewed-by: WANG Xuerui <[email protected]>
1 parent 09e9a9e commit 48d61a4

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

src/runtime/mkpreempt.go

+6
Original file line numberDiff line numberDiff line change
@@ -481,6 +481,12 @@ func genLoong64() {
481481
l.add(movf, reg, regsize)
482482
}
483483

484+
// save/restore FCC0
485+
l.addSpecial(
486+
mov+" FCC0, R4\n"+mov+" R4, %d(R3)",
487+
mov+" %d(R3), R4\n"+mov+" R4, FCC0",
488+
regsize)
489+
484490
// allocate frame, save PC of interrupted instruction (in LR)
485491
p(mov+" R1, -%d(R3)", l.stack)
486492
p(sub+" $%d, R3", l.stack)

src/runtime/preempt_loong64.s

+8-4
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
#include "textflag.h"
55

66
TEXT ·asyncPreempt(SB),NOSPLIT|NOFRAME,$0-0
7-
MOVV R1, -472(R3)
8-
SUBV $472, R3
7+
MOVV R1, -480(R3)
8+
SUBV $480, R3
99
MOVV R4, 8(R3)
1010
MOVV R5, 16(R3)
1111
MOVV R6, 24(R3)
@@ -64,7 +64,11 @@ TEXT ·asyncPreempt(SB),NOSPLIT|NOFRAME,$0-0
6464
MOVD F29, 448(R3)
6565
MOVD F30, 456(R3)
6666
MOVD F31, 464(R3)
67+
MOVV FCC0, R4
68+
MOVV R4, 472(R3)
6769
CALL ·asyncPreempt2(SB)
70+
MOVV 472(R3), R4
71+
MOVV R4, FCC0
6872
MOVD 464(R3), F31
6973
MOVD 456(R3), F30
7074
MOVD 448(R3), F29
@@ -123,7 +127,7 @@ TEXT ·asyncPreempt(SB),NOSPLIT|NOFRAME,$0-0
123127
MOVV 24(R3), R6
124128
MOVV 16(R3), R5
125129
MOVV 8(R3), R4
126-
MOVV 472(R3), R1
130+
MOVV 480(R3), R1
127131
MOVV (R3), R30
128-
ADDV $480, R3
132+
ADDV $488, R3
129133
JMP (R30)

0 commit comments

Comments
 (0)