Chromium Code Reviews| 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 601 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 612 bool paused_; | 612 bool paused_; |
| 613 }; | 613 }; |
| 614 | 614 |
| 615 | 615 |
| 616 // | 616 // |
| 617 // Ticker used to provide ticks to the profiler and the sliding state | 617 // Ticker used to provide ticks to the profiler and the sliding state |
| 618 // window. | 618 // window. |
| 619 // | 619 // |
| 620 class Ticker: public sampler::Sampler { | 620 class Ticker: public sampler::Sampler { |
| 621 public: | 621 public: |
| 622 Ticker(Isolate* isolate, int interval): | 622 Ticker(Isolate* isolate, int interval) |
| 623 sampler::Sampler(reinterpret_cast<v8::Isolate*>(isolate)), | 623 : sampler::Sampler(reinterpret_cast<v8::Isolate*>(isolate)), |
| 624 profiler_(NULL), | 624 profiler_(nullptr), |
| 625 sampling_thread_(new SamplingThread(this, interval)) {} | 625 sampling_thread_(new SamplingThread(this, interval)) {} |
| 626 | 626 |
| 627 ~Ticker() { | 627 ~Ticker() { |
| 628 if (IsActive()) Stop(); | 628 if (IsActive()) Stop(); |
| 629 delete sampling_thread_; | 629 delete sampling_thread_; |
| 630 } | 630 } |
| 631 | 631 |
| 632 void SetProfiler(Profiler* profiler) { | 632 void SetProfiler(Profiler* profiler) { |
| 633 DCHECK(profiler_ == NULL); | 633 DCHECK(profiler_ == nullptr); |
| 634 profiler_ = profiler; | 634 profiler_ = profiler; |
| 635 IncreaseProfilingDepth(); | 635 IncreaseProfilingDepth(); |
| 636 if (!IsActive()) Start(); | 636 if (!IsActive()) Start(); |
| 637 sampling_thread_->StartSynchronously(); | 637 sampling_thread_->StartSynchronously(); |
| 638 } | 638 } |
| 639 | 639 |
| 640 void ClearProfiler() { | 640 void ClearProfiler() { |
| 641 profiler_ = NULL; | 641 profiler_ = nullptr; |
| 642 if (IsActive()) Stop(); | 642 if (IsActive()) Stop(); |
| 643 DecreaseProfilingDepth(); | 643 DecreaseProfilingDepth(); |
| 644 sampling_thread_->Join(); | 644 sampling_thread_->Join(); |
| 645 } | 645 } |
| 646 | 646 |
| 647 void SampleStack(const v8::RegisterState& state) override { | 647 void SampleStack(const v8::RegisterState& state) override { |
| 648 if (!profiler_) return; | 648 if (!profiler_) return; |
| 649 v8::Isolate* v8_isolate = isolate(); | 649 Isolate* isolate = reinterpret_cast<Isolate*>(this->isolate()); |
|
lpy
2016/07/07 17:57:56
Since sampler has a method called isolate(), shoul
alph
2016/07/07 18:05:29
What's wrong with it? I'm not aware of a policy/ru
Yang
2016/07/08 08:40:47
I think this is fine. We do this elsewhere too.
| |
| 650 Isolate* i_isolate = reinterpret_cast<Isolate*>(v8_isolate); | |
| 651 #if defined(USE_SIMULATOR) | |
| 652 if (!SimulatorHelper::FillRegisters(i_isolate, | |
| 653 const_cast<v8::RegisterState*>(&state))) | |
| 654 return; | |
| 655 #endif | |
| 656 TickSample sample; | 650 TickSample sample; |
| 657 sample.Init(i_isolate, state, TickSample::kIncludeCEntryFrame, true); | 651 sample.Init(isolate, state, TickSample::kIncludeCEntryFrame, true); |
| 658 profiler_->Insert(&sample); | 652 profiler_->Insert(&sample); |
| 659 } | 653 } |
| 660 | 654 |
| 661 private: | 655 private: |
| 662 Profiler* profiler_; | 656 Profiler* profiler_; |
| 663 SamplingThread* sampling_thread_; | 657 SamplingThread* sampling_thread_; |
| 664 }; | 658 }; |
| 665 | 659 |
| 666 | 660 |
| 667 // | 661 // |
| (...skipping 1203 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1871 | 1865 |
| 1872 if (profiler_listener_.get() != nullptr) { | 1866 if (profiler_listener_.get() != nullptr) { |
| 1873 removeCodeEventListener(profiler_listener_.get()); | 1867 removeCodeEventListener(profiler_listener_.get()); |
| 1874 } | 1868 } |
| 1875 | 1869 |
| 1876 return log_->Close(); | 1870 return log_->Close(); |
| 1877 } | 1871 } |
| 1878 | 1872 |
| 1879 } // namespace internal | 1873 } // namespace internal |
| 1880 } // namespace v8 | 1874 } // namespace v8 |
| OLD | NEW |