aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/sys_linux_mips64x.s
diff options
context:
space:
mode:
authorWang Xuerui <git@xen0n.name>2019-11-04 13:29:20 +0000
committerBrad Fitzpatrick <bradfitz@golang.org>2019-11-04 18:53:43 +0000
commit210e3677f997fcce48e749437853203358f1b7b4 (patch)
tree0a36c2bd7c03f557a99e2dfc54f48b970bf63ffb /src/runtime/sys_linux_mips64x.s
parentbf7e55b618ff4ec8e823b77c3c775d0fb4dba1ba (diff)
downloadgo-210e3677f997fcce48e749437853203358f1b7b4.tar.xz
runtime: use vDSO clock_gettime on linux/mips64x
Speed up nanotime1 and walltime1 on MIPS64 with vDSO, just like the other vDSO-enabled targets. Benchmark numbers on Loongson 3A3000 (GOARCH=mips64le, 1.4GHz) against current master: benchmark old ns/op new ns/op delta BenchmarkNow 868 293 -66.24% BenchmarkNowUnixNano 851 296 -65.22% Performance hit on fallback case, tested by using a wrong vDSO symbol name: benchmark old ns/op new ns/op delta BenchmarkNow 868 889 +2.42% BenchmarkNowUnixNano 851 893 +4.94% Change-Id: Ibfb48893cd060536359863ffee7624c00def646b GitHub-Last-Rev: 03a58ac2e4e036a4f61227cfd013082871e92863 GitHub-Pull-Request: golang/go#35181 Reviewed-on: https://go-review.googlesource.com/c/go/+/203578 Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Cherry Zhang <cherryyz@google.com>
Diffstat (limited to 'src/runtime/sys_linux_mips64x.s')
-rw-r--r--src/runtime/sys_linux_mips64x.s78
1 files changed, 74 insertions, 4 deletions
diff --git a/src/runtime/sys_linux_mips64x.s b/src/runtime/sys_linux_mips64x.s
index e4d02a3953..723cfe43d9 100644
--- a/src/runtime/sys_linux_mips64x.s
+++ b/src/runtime/sys_linux_mips64x.s
@@ -211,23 +211,88 @@ TEXT runtime·mincore(SB),NOSPLIT|NOFRAME,$0-28
// func walltime1() (sec int64, nsec int32)
TEXT runtime·walltime1(SB),NOSPLIT,$16
+ MOVV R29, R16 // R16 is unchanged by C code
+ MOVV R29, R1
+
+ MOVV g_m(g), R17 // R17 = m
+
+ // Set vdsoPC and vdsoSP for SIGPROF traceback.
+ MOVV R31, m_vdsoPC(R17)
+ MOVV R29, m_vdsoSP(R17)
+
+ MOVV m_curg(R17), R4
+ MOVV g, R5
+ BNE R4, R5, noswitch
+
+ MOVV m_g0(R17), R4
+ MOVV (g_sched+gobuf_sp)(R4), R1 // Set SP to g0 stack
+
+noswitch:
+ SUBV $16, R1
+ AND $~15, R1 // Align for C code
+ MOVV R1, R29
+
MOVW $0, R4 // CLOCK_REALTIME
MOVV $0(R29), R5
- MOVV $SYS_clock_gettime, R2
- SYSCALL
+
+ MOVV runtime·vdsoClockgettimeSym(SB), R25
+ BEQ R25, fallback
+
+ JAL (R25)
+
+finish:
MOVV 0(R29), R3 // sec
MOVV 8(R29), R5 // nsec
+
+ MOVV R16, R29 // restore SP
+ MOVV R0, m_vdsoSP(R17) // clear vdsoSP
+
MOVV R3, sec+0(FP)
MOVW R5, nsec+8(FP)
RET
+fallback:
+ MOVV $SYS_clock_gettime, R2
+ SYSCALL
+ JMP finish
+
TEXT runtime·nanotime1(SB),NOSPLIT,$16
+ MOVV R29, R16 // R16 is unchanged by C code
+ MOVV R29, R1
+
+ MOVV g_m(g), R17 // R17 = m
+
+ // Set vdsoPC and vdsoSP for SIGPROF traceback.
+ MOVV R31, m_vdsoPC(R17)
+ MOVV R29, m_vdsoSP(R17)
+
+ MOVV m_curg(R17), R4
+ MOVV g, R5
+ BNE R4, R5, noswitch
+
+ MOVV m_g0(R17), R4
+ MOVV (g_sched+gobuf_sp)(R4), R1 // Set SP to g0 stack
+
+noswitch:
+ SUBV $16, R1
+ AND $~15, R1 // Align for C code
+ MOVV R1, R29
+
MOVW $1, R4 // CLOCK_MONOTONIC
MOVV $0(R29), R5
- MOVV $SYS_clock_gettime, R2
- SYSCALL
+
+ MOVV runtime·vdsoClockgettimeSym(SB), R25
+ BEQ R25, fallback
+
+ JAL (R25)
+
+finish:
MOVV 0(R29), R3 // sec
MOVV 8(R29), R5 // nsec
+
+ MOVV R16, R29 // restore SP
+ MOVV R0, m_vdsoSP(R17) // clear vdsoSP
+
// sec is in R3, nsec in R5
// return nsec in R3
MOVV $1000000000, R4
@@ -237,6 +302,11 @@ TEXT runtime·nanotime1(SB),NOSPLIT,$16
MOVV R3, ret+0(FP)
RET
+fallback:
+ MOVV $SYS_clock_gettime, R2
+ SYSCALL
+ JMP finish
+
TEXT runtime·rtsigprocmask(SB),NOSPLIT|NOFRAME,$0-28
MOVW how+0(FP), R4
MOVV new+8(FP), R5