]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: implement cputicks with the stable counter on loong64
authorGuoqi Chen <chenguoqi@loongson.cn>
Fri, 5 Aug 2022 05:32:08 +0000 (13:32 +0800)
committerWayne Zuo <wdvxdr@golangcn.org>
Fri, 10 Mar 2023 12:47:42 +0000 (12:47 +0000)
The stable counter is described in Section 2.2.10.4, LoongArch Reference Manual Volume 1.

Ref: https://loongson.github.io/LoongArch-Documentation/LoongArch-Vol1-EN.html

Change-Id: I160b695a8c0e38ef49b21fb8b41460fd23d9538c
Reviewed-on: https://go-review.googlesource.com/c/go/+/421656
Reviewed-by: Meidan Li <limeidan@loongson.cn>
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Wayne Zuo <wdvxdr@golangcn.org>
Reviewed-by: WANG Xuerui <git@xen0n.name>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/asm_loong64.s
src/runtime/cputicks.go
src/runtime/os_linux_loong64.go

index 58e6286385b97b78a9437964535976a221363b6b..2513d2bb54bd63c31bce4ae1606e929039f0e18a 100644 (file)
@@ -86,6 +86,12 @@ TEXT runtime·mstart(SB),NOSPLIT|TOPFRAME,$0
         JAL     runtime·mstart0(SB)
         RET // not reached
 
+// func cputicks() int64
+TEXT runtime·cputicks(SB),NOSPLIT,$0-8
+       RDTIMED R0, R4
+       MOVV    R4, ret+0(FP)
+       RET
+
 /*
  *  go-routine
  */
index 91270617fc7705929313a7cd85c4cd070e6456fe..2cf324033338d5d8699a32eabb8258be10493b4c 100644 (file)
@@ -2,7 +2,7 @@
 // Use of this source code is governed by a BSD-style
 // license that can be found in the LICENSE file.
 
-//go:build !arm && !arm64 && !loong64 && !mips64 && !mips64le && !mips && !mipsle && !wasm
+//go:build !arm && !arm64 && !mips64 && !mips64le && !mips && !mipsle && !wasm
 
 package runtime
 
index 3d84e9accb804273764ec68c0bec4b1f5e6e0861..61213dadf85f88eb68c09e51930242a569e8cfae 100644 (file)
@@ -9,10 +9,3 @@ package runtime
 func archauxv(tag, val uintptr) {}
 
 func osArchInit() {}
-
-//go:nosplit
-func cputicks() int64 {
-       // Currently cputicks() is used in blocking profiler and to seed fastrand().
-       // nanotime() is a poor approximation of CPU ticks that is enough for the profiler.
-       return nanotime()
-}