OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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/log.h" | 5 #include "src/log.h" |
6 | 6 |
7 #include <cstdarg> | 7 #include <cstdarg> |
8 #include <sstream> | 8 #include <sstream> |
9 | 9 |
10 #include "src/bailout-reason.h" | 10 #include "src/bailout-reason.h" |
(...skipping 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
637 } | 637 } |
638 | 638 |
639 void ClearProfiler() { | 639 void ClearProfiler() { |
640 profiler_ = NULL; | 640 profiler_ = NULL; |
641 if (IsActive()) Stop(); | 641 if (IsActive()) Stop(); |
642 DecreaseProfilingDepth(); | 642 DecreaseProfilingDepth(); |
643 sampling_thread_->Join(); | 643 sampling_thread_->Join(); |
644 } | 644 } |
645 | 645 |
646 void SampleStack(const v8::RegisterState& state) override { | 646 void SampleStack(const v8::RegisterState& state) override { |
| 647 if (!profiler_) return; |
647 v8::Isolate* v8_isolate = isolate(); | 648 v8::Isolate* v8_isolate = isolate(); |
648 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 649 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
649 #if defined(USE_SIMULATOR) | 650 #if defined(USE_SIMULATOR) |
650 if (!SimulatorHelper::FillRegisters(isolate, | 651 if (!SimulatorHelper::FillRegisters(isolate, |
651 const_cast<v8::RegisterState*>(&state))) | 652 const_cast<v8::RegisterState*>(&state))) |
652 return; | 653 return; |
653 #endif | 654 #endif |
654 TickSample* sample = isolate->cpu_profiler()->StartTickSample(); | 655 TickSample sample; |
655 TickSample sample_obj; | 656 sample.Init(isolate, state, TickSample::kIncludeCEntryFrame, true); |
656 if (sample == NULL) sample = &sample_obj; | 657 profiler_->Insert(&sample); |
657 sample->Init(isolate, state, TickSample::kIncludeCEntryFrame, true); | |
658 if (is_counting_samples_ && !sample->timestamp.IsNull()) { | |
659 if (sample->state == JS) ++js_sample_count_; | |
660 if (sample->state == EXTERNAL) ++external_sample_count_; | |
661 } | |
662 if (profiler_) profiler_->Insert(sample); | |
663 if (sample != &sample_obj) { | |
664 isolate->cpu_profiler()->FinishTickSample(); | |
665 } | |
666 } | 658 } |
667 | 659 |
668 private: | 660 private: |
669 Profiler* profiler_; | 661 Profiler* profiler_; |
670 SamplingThread* sampling_thread_; | 662 SamplingThread* sampling_thread_; |
671 }; | 663 }; |
672 | 664 |
673 | 665 |
674 // | 666 // |
675 // Profiler implementation. | 667 // Profiler implementation. |
(...skipping 1201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1877 | 1869 |
1878 if (profiler_listener_.get() != nullptr) { | 1870 if (profiler_listener_.get() != nullptr) { |
1879 removeCodeEventListener(profiler_listener_.get()); | 1871 removeCodeEventListener(profiler_listener_.get()); |
1880 } | 1872 } |
1881 | 1873 |
1882 return log_->Close(); | 1874 return log_->Close(); |
1883 } | 1875 } |
1884 | 1876 |
1885 } // namespace internal | 1877 } // namespace internal |
1886 } // namespace v8 | 1878 } // namespace v8 |
OLD | NEW |