]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: save and restore fcc registers in async preempt on loong64
authorHuang Qiqi <huangqiqi@loongson.cn>
Mon, 13 Mar 2023 10:52:43 +0000 (18:52 +0800)
committerCherry Mui <cherryyz@google.com>
Wed, 22 Mar 2023 19:29:43 +0000 (19:29 +0000)
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>
src/runtime/mkpreempt.go
src/runtime/preempt_loong64.s

index b4915f3789aab06ec583cfc2d5274b59578ac33f..0bfbd379e03e3bca157609be72c0b259482656fa 100644 (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)
index f97a8860dc879822f3d0feb9cd4f8cd9d9a8414f..bb9c9483650147ab49986760bacb225b6e727d1e 100644 (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)