Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(223)

Delta Between Two Patch Sets: src/pkg/runtime/cpuprof.go

Issue 140870044: code review 140870044: runtime: introduce, use funcPC to convert Go func to PC (Closed)
Left Patch Set: Created 9 years, 6 months ago
Right Patch Set: diff -r 2008238cdc04dc6419ab75310eb8e6ee17098481 https://code.google.com/p/go/ Created 9 years, 6 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Right: Side by side diff | Download
« no previous file with change/comment | « src/pkg/runtime/chan.go ('k') | src/pkg/runtime/export_test.go » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
(no file at all)
1 // Copyright 2011 The Go Authors. All rights reserved. 1 // Copyright 2011 The Go Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style 2 // Use of this source code is governed by a BSD-style
3 // license that can be found in the LICENSE file. 3 // license that can be found in the LICENSE file.
4 4
5 // CPU profiling. 5 // CPU profiling.
6 // Based on algorithms and data structures used in 6 // Based on algorithms and data structures used in
7 // http://code.google.com/p/google-perftools/. 7 // http://code.google.com/p/google-perftools/.
8 // 8 //
9 // The main difference between this code and the google-perftools 9 // The main difference between this code and the google-perftools
10 // code is that this code is written to allow copying the profile data 10 // code is that this code is written to allow copying the profile data
(...skipping 271 matching lines...) Expand 10 before | Expand all | Expand 10 after
282 func (p *cpuProfile) flushlog() bool { 282 func (p *cpuProfile) flushlog() bool {
283 if !cas(&p.handoff, 0, uint32(p.nlog)) { 283 if !cas(&p.handoff, 0, uint32(p.nlog)) {
284 return false 284 return false
285 } 285 }
286 notewakeup(&p.wait) 286 notewakeup(&p.wait)
287 287
288 p.toggle = 1 - p.toggle 288 p.toggle = 1 - p.toggle
289 log := &p.log[p.toggle] 289 log := &p.log[p.toggle]
290 q := uintptr(0) 290 q := uintptr(0)
291 if p.lost > 0 { 291 if p.lost > 0 {
292 » » f := lostProfileData 292 » » lostPC := funcPC(lostProfileData)
293 » » lostPC := **(**uintptr)(unsafe.Pointer(&f))
294 log[0] = p.lost 293 log[0] = p.lost
295 log[1] = 1 294 log[1] = 1
296 log[2] = lostPC 295 log[2] = lostPC
297 q = 3 296 q = 3
298 p.lost = 0 297 p.lost = 0
299 } 298 }
300 p.nlog = q 299 p.nlog = q
301 return true 300 return true
302 } 301 }
303 302
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 // blocking until data is available. If profiling is turned off and all the pro file 414 // blocking until data is available. If profiling is turned off and all the pro file
416 // data accumulated while it was on has been returned, CPUProfile returns nil. 415 // data accumulated while it was on has been returned, CPUProfile returns nil.
417 // The caller must save the returned data before calling CPUProfile again. 416 // The caller must save the returned data before calling CPUProfile again.
418 // 417 //
419 // Most clients should use the runtime/pprof package or 418 // Most clients should use the runtime/pprof package or
420 // the testing package's -test.cpuprofile flag instead of calling 419 // the testing package's -test.cpuprofile flag instead of calling
421 // CPUProfile directly. 420 // CPUProfile directly.
422 func CPUProfile() []byte { 421 func CPUProfile() []byte {
423 return cpuprof.getprofile() 422 return cpuprof.getprofile()
424 } 423 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b