Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(65)

Side by Side Diff: src/profiler/cpu-profiler.cc

Issue 1631043002: Add CollectSample API function to CpuProfiler (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix tests. Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/profiler/cpu-profiler.h ('k') | src/profiler/profile-generator.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/profiler/cpu-profiler.h" 5 #include "src/profiler/cpu-profiler.h"
6 6
7 #include "src/debug/debug.h" 7 #include "src/debug/debug.h"
8 #include "src/deoptimizer.h" 8 #include "src/deoptimizer.h"
9 #include "src/frames-inl.h" 9 #include "src/frames-inl.h"
10 #include "src/locked-queue-inl.h" 10 #include "src/locked-queue-inl.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 42
43 43
44 void ProfilerEventsProcessor::AddDeoptStack(Isolate* isolate, Address from, 44 void ProfilerEventsProcessor::AddDeoptStack(Isolate* isolate, Address from,
45 int fp_to_sp_delta) { 45 int fp_to_sp_delta) {
46 TickSampleEventRecord record(last_code_event_id_.Value()); 46 TickSampleEventRecord record(last_code_event_id_.Value());
47 RegisterState regs; 47 RegisterState regs;
48 Address fp = isolate->c_entry_fp(isolate->thread_local_top()); 48 Address fp = isolate->c_entry_fp(isolate->thread_local_top());
49 regs.sp = fp - fp_to_sp_delta; 49 regs.sp = fp - fp_to_sp_delta;
50 regs.fp = fp; 50 regs.fp = fp;
51 regs.pc = from; 51 regs.pc = from;
52 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame); 52 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame, false);
53 ticks_from_vm_buffer_.Enqueue(record); 53 ticks_from_vm_buffer_.Enqueue(record);
54 } 54 }
55 55
56 56 void ProfilerEventsProcessor::AddCurrentStack(Isolate* isolate,
57 void ProfilerEventsProcessor::AddCurrentStack(Isolate* isolate) { 57 bool update_stats) {
58 TickSampleEventRecord record(last_code_event_id_.Value()); 58 TickSampleEventRecord record(last_code_event_id_.Value());
59 RegisterState regs; 59 RegisterState regs;
60 StackFrameIterator it(isolate); 60 StackFrameIterator it(isolate);
61 if (!it.done()) { 61 if (!it.done()) {
62 StackFrame* frame = it.frame(); 62 StackFrame* frame = it.frame();
63 regs.sp = frame->sp(); 63 regs.sp = frame->sp();
64 regs.fp = frame->fp(); 64 regs.fp = frame->fp();
65 regs.pc = frame->pc(); 65 regs.pc = frame->pc();
66 } 66 }
67 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame); 67 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame, update_stats);
68 ticks_from_vm_buffer_.Enqueue(record); 68 ticks_from_vm_buffer_.Enqueue(record);
69 } 69 }
70 70
71 71
72 void ProfilerEventsProcessor::StopSynchronously() { 72 void ProfilerEventsProcessor::StopSynchronously() {
73 if (!base::NoBarrier_AtomicExchange(&running_, 0)) return; 73 if (!base::NoBarrier_AtomicExchange(&running_, 0)) return;
74 Join(); 74 Join();
75 } 75 }
76 76
77 77
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after
422 DCHECK(!is_profiling_); 422 DCHECK(!is_profiling_);
423 sampling_interval_ = value; 423 sampling_interval_ = value;
424 } 424 }
425 425
426 426
427 void CpuProfiler::ResetProfiles() { 427 void CpuProfiler::ResetProfiles() {
428 delete profiles_; 428 delete profiles_;
429 profiles_ = new CpuProfilesCollection(isolate()->heap()); 429 profiles_ = new CpuProfilesCollection(isolate()->heap());
430 } 430 }
431 431
432 void CpuProfiler::CollectSample() {
433 if (processor_ != NULL) {
434 processor_->AddCurrentStack(isolate_);
435 }
436 }
432 437
433 void CpuProfiler::StartProfiling(const char* title, bool record_samples) { 438 void CpuProfiler::StartProfiling(const char* title, bool record_samples) {
434 if (profiles_->StartProfiling(title, record_samples)) { 439 if (profiles_->StartProfiling(title, record_samples)) {
435 StartProcessorIfNotStarted(); 440 StartProcessorIfNotStarted();
436 } 441 }
437 } 442 }
438 443
439 444
440 void CpuProfiler::StartProfiling(String* title, bool record_samples) { 445 void CpuProfiler::StartProfiling(String* title, bool record_samples) {
441 StartProfiling(profiles_->GetName(title), record_samples); 446 StartProfiling(profiles_->GetName(title), record_samples);
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 Builtins::Name id = static_cast<Builtins::Name>(i); 526 Builtins::Name id = static_cast<Builtins::Name>(i);
522 rec->start = builtins->builtin(id)->address(); 527 rec->start = builtins->builtin(id)->address();
523 rec->builtin_id = id; 528 rec->builtin_id = id;
524 processor_->Enqueue(evt_rec); 529 processor_->Enqueue(evt_rec);
525 } 530 }
526 } 531 }
527 532
528 533
529 } // namespace internal 534 } // namespace internal
530 } // namespace v8 535 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/cpu-profiler.h ('k') | src/profiler/profile-generator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698