]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: move sigprofNonGo
authorRhys Hiltner <rhys@justin.tv>
Thu, 23 Sep 2021 23:46:58 +0000 (16:46 -0700)
committerMichael Pratt <mpratt@google.com>
Mon, 27 Sep 2021 18:58:36 +0000 (18:58 +0000)
The sigprofNonGo and sigprofNonGoPC functions are only used on unix-like
platforms. In preparation for unix-specific changes to sigprofNonGo,
move it (plus its close relative) to a unix-specific file.

Updates #35057

Change-Id: I9c814127c58612ea9a9fbd28a992b04ace5c604d
Reviewed-on: https://go-review.googlesource.com/c/go/+/351790
Run-TryBot: Rhys Hiltner <rhys@justin.tv>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Michael Pratt <mpratt@google.com>
Trust: David Chase <drchase@google.com>

src/runtime/proc.go
src/runtime/signal_unix.go

index b744d0e71e1544ec9eedcf31a0807dcab09da49d..2f619f93d3d402eeeb32e744bab349edbe331946 100644 (file)
@@ -4705,45 +4705,6 @@ func sigprof(pc, sp, lr uintptr, gp *g, mp *m) {
        getg().m.mallocing--
 }
 
-// If the signal handler receives a SIGPROF signal on a non-Go thread,
-// it tries to collect a traceback into sigprofCallers.
-// sigprofCallersUse is set to non-zero while sigprofCallers holds a traceback.
-var sigprofCallers cgoCallers
-var sigprofCallersUse uint32
-
-// sigprofNonGo is called if we receive a SIGPROF signal on a non-Go thread,
-// and the signal handler collected a stack trace in sigprofCallers.
-// When this is called, sigprofCallersUse will be non-zero.
-// g is nil, and what we can do is very limited.
-//go:nosplit
-//go:nowritebarrierrec
-func sigprofNonGo() {
-       if prof.hz != 0 {
-               n := 0
-               for n < len(sigprofCallers) && sigprofCallers[n] != 0 {
-                       n++
-               }
-               cpuprof.addNonGo(sigprofCallers[:n])
-       }
-
-       atomic.Store(&sigprofCallersUse, 0)
-}
-
-// sigprofNonGoPC is called when a profiling signal arrived on a
-// non-Go thread and we have a single PC value, not a stack trace.
-// g is nil, and what we can do is very limited.
-//go:nosplit
-//go:nowritebarrierrec
-func sigprofNonGoPC(pc uintptr) {
-       if prof.hz != 0 {
-               stk := []uintptr{
-                       pc,
-                       abi.FuncPCABIInternal(_ExternalCode) + sys.PCQuantum,
-               }
-               cpuprof.addNonGo(stk)
-       }
-}
-
 // setcpuprofilerate sets the CPU profiling rate to hz times per second.
 // If hz <= 0, setcpuprofilerate turns off CPU profiling.
 func setcpuprofilerate(hz int32) {
index 228497c508f82139e21c6a8a62620495b1274c28..0b32598d54accc0a31f834d543643b72978e02d5 100644 (file)
@@ -10,6 +10,7 @@ package runtime
 import (
        "internal/abi"
        "runtime/internal/atomic"
+       "runtime/internal/sys"
        "unsafe"
 )
 
@@ -469,6 +470,45 @@ func sigtrampgo(sig uint32, info *siginfo, ctx unsafe.Pointer) {
        }
 }
 
+// If the signal handler receives a SIGPROF signal on a non-Go thread,
+// it tries to collect a traceback into sigprofCallers.
+// sigprofCallersUse is set to non-zero while sigprofCallers holds a traceback.
+var sigprofCallers cgoCallers
+var sigprofCallersUse uint32
+
+// sigprofNonGo is called if we receive a SIGPROF signal on a non-Go thread,
+// and the signal handler collected a stack trace in sigprofCallers.
+// When this is called, sigprofCallersUse will be non-zero.
+// g is nil, and what we can do is very limited.
+//go:nosplit
+//go:nowritebarrierrec
+func sigprofNonGo() {
+       if prof.hz != 0 {
+               n := 0
+               for n < len(sigprofCallers) && sigprofCallers[n] != 0 {
+                       n++
+               }
+               cpuprof.addNonGo(sigprofCallers[:n])
+       }
+
+       atomic.Store(&sigprofCallersUse, 0)
+}
+
+// sigprofNonGoPC is called when a profiling signal arrived on a
+// non-Go thread and we have a single PC value, not a stack trace.
+// g is nil, and what we can do is very limited.
+//go:nosplit
+//go:nowritebarrierrec
+func sigprofNonGoPC(pc uintptr) {
+       if prof.hz != 0 {
+               stk := []uintptr{
+                       pc,
+                       abi.FuncPCABIInternal(_ExternalCode) + sys.PCQuantum,
+               }
+               cpuprof.addNonGo(stk)
+       }
+}
+
 // adjustSignalStack adjusts the current stack guard based on the
 // stack pointer that is actually in use while handling a signal.
 // We do this in case some non-Go code called sigaltstack.