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 <cherryyz@google.com>
Run-TryBot: Cherry Mui <cherryyz@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: abner chenc <chenguoqi@loongson.cn>
Reviewed-by: Michael Knyszek <mknyszek@google.com>
Reviewed-by: WANG Xuerui <git@xen0n.name>
This commit is contained in:
Huang Qiqi 2023-03-13 18:52:43 +08:00 committed by Cherry Mui
parent 09e9a9eac9
commit 48d61a46e2
2 changed files with 14 additions and 4 deletions

View File

@ -481,6 +481,12 @@ func genLoong64() {
l.add(movf, reg, regsize)
}
// save/restore FCC0
l.addSpecial(
mov+" FCC0, R4\n"+mov+" R4, %d(R3)",
mov+" %d(R3), R4\n"+mov+" R4, FCC0",
regsize)
// allocate frame, save PC of interrupted instruction (in LR)
p(mov+" R1, -%d(R3)", l.stack)
p(sub+" $%d, R3", l.stack)

View File

@ -4,8 +4,8 @@
#include "textflag.h"
TEXT ·asyncPreempt(SB),NOSPLIT|NOFRAME,$0-0
MOVV R1, -472(R3)
SUBV $472, R3
MOVV R1, -480(R3)
SUBV $480, R3
MOVV R4, 8(R3)
MOVV R5, 16(R3)
MOVV R6, 24(R3)
@ -64,7 +64,11 @@ TEXT ·asyncPreempt(SB),NOSPLIT|NOFRAME,$0-0
MOVD F29, 448(R3)
MOVD F30, 456(R3)
MOVD F31, 464(R3)
MOVV FCC0, R4
MOVV R4, 472(R3)
CALL ·asyncPreempt2(SB)
MOVV 472(R3), R4
MOVV R4, FCC0
MOVD 464(R3), F31
MOVD 456(R3), F30
MOVD 448(R3), F29
@ -123,7 +127,7 @@ TEXT ·asyncPreempt(SB),NOSPLIT|NOFRAME,$0-0
MOVV 24(R3), R6
MOVV 16(R3), R5
MOVV 8(R3), R4
MOVV 472(R3), R1
MOVV 480(R3), R1
MOVV (R3), R30
ADDV $480, R3
ADDV $488, R3
JMP (R30)