aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHuang Qiqi <huangqiqi@loongson.cn>2023-03-13 18:52:43 +0800
committerCherry Mui <cherryyz@google.com>2023-03-22 19:29:43 +0000
commit48d61a46e28076bf0e41f50459fe0875ec5f4010 (patch)
tree41f92ad41845894fc4536081eabca77d32b0f2d7 /src
parent09e9a9eac9f3d347e3a204ae3ca309b5340028c4 (diff)
downloadgo-48d61a46e28076bf0e41f50459fe0875ec5f4010.tar.xz
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>
Diffstat (limited to 'src')
-rw-r--r--src/runtime/mkpreempt.go6
-rw-r--r--src/runtime/preempt_loong64.s12
2 files changed, 14 insertions, 4 deletions
diff --git a/src/runtime/mkpreempt.go b/src/runtime/mkpreempt.go
index b4915f3789..0bfbd379e0 100644
--- a/src/runtime/mkpreempt.go
+++ b/src/runtime/mkpreempt.go
@@ -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)
diff --git a/src/runtime/preempt_loong64.s b/src/runtime/preempt_loong64.s
index f97a8860dc..bb9c948365 100644
--- a/src/runtime/preempt_loong64.s
+++ b/src/runtime/preempt_loong64.s
@@ -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)