aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/mprof.go
diff options
context:
space:
mode:
authorMatthew Dempsky <mdempsky@google.com>2015-02-25 14:41:21 +0900
committerDmitry Vyukov <dvyukov@google.com>2015-02-26 08:59:24 +0000
commit3c8a89daf3a05a1dd98075a733db7a20bef2dc5c (patch)
treedb477dc0bc924ff94ea7b334c5a9233df9c65a17 /src/runtime/mprof.go
parenta32dd832530a176b5b45f06c3a97f52383227480 (diff)
downloadgo-3c8a89daf3a05a1dd98075a733db7a20bef2dc5c.tar.gz
go-3c8a89daf3a05a1dd98075a733db7a20bef2dc5c.zip
runtime: simplify CPU profiling code
This makes Go's CPU profiling code somewhat more idiomatic; e.g., using := instead of forward declaring variables, using "int" for element counts instead of "uintptr", and slices instead of C-style pointer+length. This makes the code easier to read and eliminates a lot of type conversion clutter. Additionally, in sigprof we can collect just maxCPUProfStack stack frames, as cpuprof won't use more than that anyway. Change-Id: I0235b5ae552191bcbb453b14add6d8c01381bd06 Reviewed-on: https://go-review.googlesource.com/6072 Run-TryBot: Matthew Dempsky <mdempsky@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Dmitry Vyukov <dvyukov@google.com>
Diffstat (limited to 'src/runtime/mprof.go')
-rw-r--r--src/runtime/mprof.go6
1 files changed, 3 insertions, 3 deletions
diff --git a/src/runtime/mprof.go b/src/runtime/mprof.go
index df7093a004..4544344780 100644
--- a/src/runtime/mprof.go
+++ b/src/runtime/mprof.go
@@ -232,7 +232,7 @@ func mProf_GC() {
// Called by malloc to record a profiled block.
func mProf_Malloc(p unsafe.Pointer, size uintptr) {
var stk [maxStack]uintptr
- nstk := callers(4, &stk[0], len(stk))
+ nstk := callers(4, stk[:])
lock(&proflock)
b := stkbucket(memProfile, size, stk[:nstk], true)
mp := b.mp()
@@ -300,9 +300,9 @@ func blockevent(cycles int64, skip int) {
var nstk int
var stk [maxStack]uintptr
if gp.m.curg == nil || gp.m.curg == gp {
- nstk = callers(skip, &stk[0], len(stk))
+ nstk = callers(skip, stk[:])
} else {
- nstk = gcallers(gp.m.curg, skip, &stk[0], len(stk))
+ nstk = gcallers(gp.m.curg, skip, stk[:])
}
lock(&proflock)
b := stkbucket(blockProfile, 0, stk[:nstk], true)