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 v8::Isolate* v8_isolate = isolate(); | 647 v8::Isolate* v8_isolate = isolate(); |
alph
2016/06/30 21:01:48
if (!profiler_) return;
lpy
2016/06/30 21:13:04
Done.
| |
648 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 648 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); |
649 #if defined(USE_SIMULATOR) | 649 #if defined(USE_SIMULATOR) |
650 if (!SimulatorHelper::FillRegisters(isolate, | 650 if (!SimulatorHelper::FillRegisters(isolate, |
651 const_cast<v8::RegisterState*>(&state))) | 651 const_cast<v8::RegisterState*>(&state))) |
652 return; | 652 return; |
653 #endif | 653 #endif |
654 TickSample* sample = isolate->cpu_profiler()->StartTickSample(); | 654 TickSample sample; |
655 TickSample sample_obj; | 655 sample.Init(isolate, state, TickSample::kIncludeCEntryFrame, true); |
656 if (sample == NULL) sample = &sample_obj; | 656 if (profiler_) 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 } | 657 } |
667 | 658 |
668 private: | 659 private: |
669 Profiler* profiler_; | 660 Profiler* profiler_; |
670 SamplingThread* sampling_thread_; | 661 SamplingThread* sampling_thread_; |
671 }; | 662 }; |
672 | 663 |
673 | 664 |
674 // | 665 // |
675 // Profiler implementation. | 666 // Profiler implementation. |
(...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1879 | 1870 |
1880 if (profiler_listener_.get() != nullptr) { | 1871 if (profiler_listener_.get() != nullptr) { |
1881 removeCodeEventListener(profiler_listener_.get()); | 1872 removeCodeEventListener(profiler_listener_.get()); |
1882 } | 1873 } |
1883 | 1874 |
1884 return log_->Close(); | 1875 return log_->Close(); |
1885 } | 1876 } |
1886 | 1877 |
1887 } // namespace internal | 1878 } // namespace internal |
1888 } // namespace v8 | 1879 } // namespace v8 |
OLD | NEW |