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

Side by Side Diff: src/profiler/sampler.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/sampler.h ('k') | test/cctest/test-cpu-profiler.cc » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/sampler.h" 5 #include "src/profiler/sampler.h"
6 6
7 #if V8_OS_POSIX && !V8_OS_CYGWIN 7 #if V8_OS_POSIX && !V8_OS_CYGWIN
8 8
9 #define USE_SIGNALS 9 #define USE_SIGNALS
10 10
(...skipping 639 matching lines...) Expand 10 before | Expand all | Expand 10 after
650 650
651 base::Mutex* SamplerThread::mutex_ = NULL; 651 base::Mutex* SamplerThread::mutex_ = NULL;
652 SamplerThread* SamplerThread::instance_ = NULL; 652 SamplerThread* SamplerThread::instance_ = NULL;
653 653
654 654
655 // 655 //
656 // StackTracer implementation 656 // StackTracer implementation
657 // 657 //
658 DISABLE_ASAN void TickSample::Init(Isolate* isolate, 658 DISABLE_ASAN void TickSample::Init(Isolate* isolate,
659 const v8::RegisterState& regs, 659 const v8::RegisterState& regs,
660 RecordCEntryFrame record_c_entry_frame) { 660 RecordCEntryFrame record_c_entry_frame,
661 bool update_stats) {
661 timestamp = base::TimeTicks::HighResolutionNow(); 662 timestamp = base::TimeTicks::HighResolutionNow();
662 pc = reinterpret_cast<Address>(regs.pc); 663 pc = reinterpret_cast<Address>(regs.pc);
663 state = isolate->current_vm_state(); 664 state = isolate->current_vm_state();
665 this->update_stats = update_stats;
664 666
665 // Avoid collecting traces while doing GC. 667 // Avoid collecting traces while doing GC.
666 if (state == GC) return; 668 if (state == GC) return;
667 669
668 Address js_entry_sp = isolate->js_entry_sp(); 670 Address js_entry_sp = isolate->js_entry_sp();
669 if (js_entry_sp == 0) return; // Not executing JS now. 671 if (js_entry_sp == 0) return; // Not executing JS now.
670 672
671 if (pc && IsNoFrameRegion(pc)) { 673 if (pc && IsNoFrameRegion(pc)) {
672 pc = 0; 674 pc = 0;
673 return; 675 return;
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
789 SignalHandler::DecreaseSamplerCount(); 791 SignalHandler::DecreaseSamplerCount();
790 #endif 792 #endif
791 base::NoBarrier_AtomicIncrement(&profiling_, -1); 793 base::NoBarrier_AtomicIncrement(&profiling_, -1);
792 } 794 }
793 795
794 796
795 void Sampler::SampleStack(const v8::RegisterState& state) { 797 void Sampler::SampleStack(const v8::RegisterState& state) {
796 TickSample* sample = isolate_->cpu_profiler()->StartTickSample(); 798 TickSample* sample = isolate_->cpu_profiler()->StartTickSample();
797 TickSample sample_obj; 799 TickSample sample_obj;
798 if (sample == NULL) sample = &sample_obj; 800 if (sample == NULL) sample = &sample_obj;
799 sample->Init(isolate_, state, TickSample::kIncludeCEntryFrame); 801 sample->Init(isolate_, state, TickSample::kIncludeCEntryFrame, true);
800 if (is_counting_samples_) { 802 if (is_counting_samples_) {
801 if (sample->state == JS || sample->state == EXTERNAL) { 803 if (sample->state == JS || sample->state == EXTERNAL) {
802 ++js_and_external_sample_count_; 804 ++js_and_external_sample_count_;
803 } 805 }
804 } 806 }
805 Tick(sample); 807 Tick(sample);
806 if (sample != &sample_obj) { 808 if (sample != &sample_obj) {
807 isolate_->cpu_profiler()->FinishTickSample(); 809 isolate_->cpu_profiler()->FinishTickSample();
808 } 810 }
809 } 811 }
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
852 SampleStack(state); 854 SampleStack(state);
853 } 855 }
854 ResumeThread(profiled_thread); 856 ResumeThread(profiled_thread);
855 } 857 }
856 858
857 #endif // USE_SIGNALS 859 #endif // USE_SIGNALS
858 860
859 861
860 } // namespace internal 862 } // namespace internal
861 } // namespace v8 863 } // namespace v8
OLDNEW
« no previous file with comments | « src/profiler/sampler.h ('k') | test/cctest/test-cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698