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" |
| 11 #include "src/base/platform/platform.h" | 11 #include "src/base/platform/platform.h" |
| 12 #include "src/bootstrapper.h" | 12 #include "src/bootstrapper.h" |
| 13 #include "src/code-stubs.h" | 13 #include "src/code-stubs.h" |
| 14 #include "src/counters.h" | 14 #include "src/counters.h" |
| 15 #include "src/deoptimizer.h" | 15 #include "src/deoptimizer.h" |
| 16 #include "src/global-handles.h" | 16 #include "src/global-handles.h" |
| 17 #include "src/interpreter/bytecodes.h" | 17 #include "src/interpreter/bytecodes.h" |
| 18 #include "src/interpreter/interpreter.h" | 18 #include "src/interpreter/interpreter.h" |
| 19 #include "src/libsampler/v8-sampler.h" | 19 #include "src/libsampler/v8-sampler.h" |
| 20 #include "src/log-inl.h" | 20 #include "src/log-inl.h" |
| 21 #include "src/log-utils.h" | 21 #include "src/log-utils.h" |
| 22 #include "src/macro-assembler.h" | 22 #include "src/macro-assembler.h" |
| 23 #include "src/perf-jit.h" | 23 #include "src/perf-jit.h" |
| 24 #include "src/profiler/cpu-profiler-inl.h" | 24 #include "src/profiler/cpu-profiler-inl.h" |
| 25 #include "src/profiler/profiler-listener.h" | 25 #include "src/profiler/profiler-listener.h" |
| 26 #include "src/profiler/tick-sample.h" | |
| 26 #include "src/runtime-profiler.h" | 27 #include "src/runtime-profiler.h" |
| 27 #include "src/string-stream.h" | 28 #include "src/string-stream.h" |
| 28 #include "src/vm-state-inl.h" | 29 #include "src/vm-state-inl.h" |
| 29 | 30 |
| 30 namespace v8 { | 31 namespace v8 { |
| 31 namespace internal { | 32 namespace internal { |
| 32 | 33 |
| 33 | 34 |
| 34 #define DECLARE_EVENT(ignore1, name) name, | 35 #define DECLARE_EVENT(ignore1, name) name, |
| 35 static const char* kLogEventsNames[CodeEventListener::NUMBER_OF_LOG_EVENTS] = { | 36 static const char* kLogEventsNames[CodeEventListener::NUMBER_OF_LOG_EVENTS] = { |
| (...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 638 | 639 |
| 639 void ClearProfiler() { | 640 void ClearProfiler() { |
| 640 profiler_ = NULL; | 641 profiler_ = NULL; |
| 641 if (IsActive()) Stop(); | 642 if (IsActive()) Stop(); |
| 642 DecreaseProfilingDepth(); | 643 DecreaseProfilingDepth(); |
| 643 sampling_thread_->Join(); | 644 sampling_thread_->Join(); |
| 644 } | 645 } |
| 645 | 646 |
| 646 void SampleStack(const v8::RegisterState& state) override { | 647 void SampleStack(const v8::RegisterState& state) override { |
| 647 v8::Isolate* v8_isolate = isolate(); | 648 v8::Isolate* v8_isolate = isolate(); |
| 648 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); | 649 Isolate* i_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(i_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 = i_isolate->cpu_profiler()->StartTickSample(); |
| 655 TickSample sample_obj; | 656 TickSample sample_obj; |
| 656 if (sample == NULL) sample = &sample_obj; | 657 if (sample == NULL) sample = &sample_obj; |
| 657 sample->Init(isolate, state, TickSample::kIncludeCEntryFrame, true); | 658 sample->Init(i_isolate, state, TickSample::kIncludeCEntryFrame, true); |
| 658 if (is_counting_samples_ && !sample->timestamp.IsNull()) { | 659 if (sample->pc == nullptr) return; |
| 660 sample->timestamp = base::TimeTicks::HighResolutionNow(); | |
|
alph
2016/07/01 01:08:57
not needed?
lpy
2016/07/01 17:33:38
Done.
| |
| 661 if (is_counting_samples_) { | |
| 659 if (sample->state == JS) ++js_sample_count_; | 662 if (sample->state == JS) ++js_sample_count_; |
| 660 if (sample->state == EXTERNAL) ++external_sample_count_; | 663 if (sample->state == EXTERNAL) ++external_sample_count_; |
| 661 } | 664 } |
| 662 if (profiler_) profiler_->Insert(sample); | 665 if (profiler_) profiler_->Insert(sample); |
| 663 if (sample != &sample_obj) { | 666 if (sample != &sample_obj) { |
| 664 isolate->cpu_profiler()->FinishTickSample(); | 667 i_isolate->cpu_profiler()->FinishTickSample(); |
| 665 } | 668 } |
| 666 } | 669 } |
| 667 | 670 |
| 668 private: | 671 private: |
| 669 Profiler* profiler_; | 672 Profiler* profiler_; |
| 670 SamplingThread* sampling_thread_; | 673 SamplingThread* sampling_thread_; |
| 671 }; | 674 }; |
| 672 | 675 |
| 673 | 676 |
| 674 // | 677 // |
| (...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1374 msg.WriteToLogFile(); | 1377 msg.WriteToLogFile(); |
| 1375 } | 1378 } |
| 1376 | 1379 |
| 1377 void Logger::TickEvent(TickSample* sample, bool overflow) { | 1380 void Logger::TickEvent(TickSample* sample, bool overflow) { |
| 1378 if (!log_->IsEnabled() || !FLAG_prof_cpp) return; | 1381 if (!log_->IsEnabled() || !FLAG_prof_cpp) return; |
| 1379 if (FLAG_runtime_call_stats) { | 1382 if (FLAG_runtime_call_stats) { |
| 1380 RuntimeCallTimerEvent(); | 1383 RuntimeCallTimerEvent(); |
| 1381 } | 1384 } |
| 1382 Log::MessageBuilder msg(log_); | 1385 Log::MessageBuilder msg(log_); |
| 1383 msg.Append("%s,", kLogEventsNames[CodeEventListener::TICK_EVENT]); | 1386 msg.Append("%s,", kLogEventsNames[CodeEventListener::TICK_EVENT]); |
| 1384 msg.AppendAddress(sample->pc); | 1387 msg.AppendAddress(reinterpret_cast<Address>(sample->pc)); |
| 1385 msg.Append(",%d", static_cast<int>(timer_.Elapsed().InMicroseconds())); | 1388 msg.Append(",%d", static_cast<int>(timer_.Elapsed().InMicroseconds())); |
| 1386 if (sample->has_external_callback) { | 1389 if (sample->has_external_callback) { |
| 1387 msg.Append(",1,"); | 1390 msg.Append(",1,"); |
| 1388 msg.AppendAddress(sample->external_callback_entry); | 1391 msg.AppendAddress( |
| 1392 reinterpret_cast<Address>(sample->external_callback_entry)); | |
| 1389 } else { | 1393 } else { |
| 1390 msg.Append(",0,"); | 1394 msg.Append(",0,"); |
| 1391 msg.AppendAddress(sample->tos); | 1395 msg.AppendAddress(reinterpret_cast<Address>(sample->tos)); |
| 1392 } | 1396 } |
| 1393 msg.Append(",%d", static_cast<int>(sample->state)); | 1397 msg.Append(",%d", static_cast<int>(sample->state)); |
| 1394 if (overflow) { | 1398 if (overflow) { |
| 1395 msg.Append(",overflow"); | 1399 msg.Append(",overflow"); |
| 1396 } | 1400 } |
| 1397 for (unsigned i = 0; i < sample->frames_count; ++i) { | 1401 for (unsigned i = 0; i < sample->frames_count; ++i) { |
| 1398 msg.Append(','); | 1402 msg.Append(','); |
| 1399 msg.AppendAddress(sample->stack[i]); | 1403 msg.AppendAddress(reinterpret_cast<Address>(sample->stack[i])); |
| 1400 } | 1404 } |
| 1401 msg.WriteToLogFile(); | 1405 msg.WriteToLogFile(); |
| 1402 } | 1406 } |
| 1403 | 1407 |
| 1404 | 1408 |
| 1405 void Logger::StopProfiler() { | 1409 void Logger::StopProfiler() { |
| 1406 if (!log_->IsEnabled()) return; | 1410 if (!log_->IsEnabled()) return; |
| 1407 if (profiler_ != NULL) { | 1411 if (profiler_ != NULL) { |
| 1408 profiler_->pause(); | 1412 profiler_->pause(); |
| 1409 is_logging_ = false; | 1413 is_logging_ = false; |
| (...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1877 | 1881 |
| 1878 if (profiler_listener_.get() != nullptr) { | 1882 if (profiler_listener_.get() != nullptr) { |
| 1879 removeCodeEventListener(profiler_listener_.get()); | 1883 removeCodeEventListener(profiler_listener_.get()); |
| 1880 } | 1884 } |
| 1881 | 1885 |
| 1882 return log_->Close(); | 1886 return log_->Close(); |
| 1883 } | 1887 } |
| 1884 | 1888 |
| 1885 } // namespace internal | 1889 } // namespace internal |
| 1886 } // namespace v8 | 1890 } // namespace v8 |
| OLD | NEW |