OLD | NEW |
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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
694 } | 694 } |
695 | 695 |
696 SafeStackFrameIterator it(isolate, reinterpret_cast<Address>(regs.fp), | 696 SafeStackFrameIterator it(isolate, reinterpret_cast<Address>(regs.fp), |
697 reinterpret_cast<Address>(regs.sp), js_entry_sp); | 697 reinterpret_cast<Address>(regs.sp), js_entry_sp); |
698 top_frame_type = it.top_frame_type(); | 698 top_frame_type = it.top_frame_type(); |
699 | 699 |
700 SampleInfo info; | 700 SampleInfo info; |
701 GetStackSample(isolate, regs, record_c_entry_frame, | 701 GetStackSample(isolate, regs, record_c_entry_frame, |
702 reinterpret_cast<void**>(&stack[0]), kMaxFramesCount, &info); | 702 reinterpret_cast<void**>(&stack[0]), kMaxFramesCount, &info); |
703 frames_count = static_cast<unsigned>(info.frames_count); | 703 frames_count = static_cast<unsigned>(info.frames_count); |
| 704 if (!frames_count) { |
| 705 // It is executing JS but failed to collect a stack trace. |
| 706 // Mark the sample as spoiled. |
| 707 pc = 0; |
| 708 } |
704 } | 709 } |
705 | 710 |
706 | 711 |
707 void TickSample::GetStackSample(Isolate* isolate, const v8::RegisterState& regs, | 712 void TickSample::GetStackSample(Isolate* isolate, const v8::RegisterState& regs, |
708 RecordCEntryFrame record_c_entry_frame, | 713 RecordCEntryFrame record_c_entry_frame, |
709 void** frames, size_t frames_limit, | 714 void** frames, size_t frames_limit, |
710 v8::SampleInfo* sample_info) { | 715 v8::SampleInfo* sample_info) { |
711 sample_info->frames_count = 0; | 716 sample_info->frames_count = 0; |
712 sample_info->vm_state = isolate->current_vm_state(); | 717 sample_info->vm_state = isolate->current_vm_state(); |
713 if (sample_info->vm_state == GC) return; | 718 if (sample_info->vm_state == GC) return; |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
790 #endif | 795 #endif |
791 base::NoBarrier_AtomicIncrement(&profiling_, -1); | 796 base::NoBarrier_AtomicIncrement(&profiling_, -1); |
792 } | 797 } |
793 | 798 |
794 | 799 |
795 void Sampler::SampleStack(const v8::RegisterState& state) { | 800 void Sampler::SampleStack(const v8::RegisterState& state) { |
796 TickSample* sample = isolate_->cpu_profiler()->StartTickSample(); | 801 TickSample* sample = isolate_->cpu_profiler()->StartTickSample(); |
797 TickSample sample_obj; | 802 TickSample sample_obj; |
798 if (sample == NULL) sample = &sample_obj; | 803 if (sample == NULL) sample = &sample_obj; |
799 sample->Init(isolate_, state, TickSample::kIncludeCEntryFrame, true); | 804 sample->Init(isolate_, state, TickSample::kIncludeCEntryFrame, true); |
800 if (is_counting_samples_) { | 805 if (is_counting_samples_ && sample->pc) { |
801 if (sample->state == JS) ++js_sample_count_; | 806 if (sample->state == JS) ++js_sample_count_; |
802 if (sample->state == EXTERNAL) ++external_sample_count_; | 807 if (sample->state == EXTERNAL) ++external_sample_count_; |
803 } | 808 } |
804 Tick(sample); | 809 Tick(sample); |
805 if (sample != &sample_obj) { | 810 if (sample != &sample_obj) { |
806 isolate_->cpu_profiler()->FinishTickSample(); | 811 isolate_->cpu_profiler()->FinishTickSample(); |
807 } | 812 } |
808 } | 813 } |
809 | 814 |
810 | 815 |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
851 SampleStack(state); | 856 SampleStack(state); |
852 } | 857 } |
853 ResumeThread(profiled_thread); | 858 ResumeThread(profiled_thread); |
854 } | 859 } |
855 | 860 |
856 #endif // USE_SIGNALS | 861 #endif // USE_SIGNALS |
857 | 862 |
858 | 863 |
859 } // namespace internal | 864 } // namespace internal |
860 } // namespace v8 | 865 } // namespace v8 |
OLD | NEW |