Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(868)

Side by Side Diff: src/log.cc

Issue 2105943002: Expose TickSample and its APIs in v8-profiler.h (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: rebase Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/log.h ('k') | src/profiler/cpu-profiler.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 603 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 if (!profiler_) return; 648 if (!profiler_) return;
648 v8::Isolate* v8_isolate = isolate(); 649 v8::Isolate* v8_isolate = isolate();
649 Isolate* isolate = reinterpret_cast<Isolate*>(v8_isolate); 650 Isolate* i_isolate = reinterpret_cast<Isolate*>(v8_isolate);
650 #if defined(USE_SIMULATOR) 651 #if defined(USE_SIMULATOR)
651 if (!SimulatorHelper::FillRegisters(isolate, 652 if (!SimulatorHelper::FillRegisters(i_isolate,
652 const_cast<v8::RegisterState*>(&state))) 653 const_cast<v8::RegisterState*>(&state)))
653 return; 654 return;
654 #endif 655 #endif
655 TickSample sample; 656 TickSample sample;
656 sample.Init(isolate, state, TickSample::kIncludeCEntryFrame, true); 657 sample.Init(i_isolate, state, TickSample::kIncludeCEntryFrame, true);
657 profiler_->Insert(&sample); 658 profiler_->Insert(&sample);
658 } 659 }
659 660
660 private: 661 private:
661 Profiler* profiler_; 662 Profiler* profiler_;
662 SamplingThread* sampling_thread_; 663 SamplingThread* sampling_thread_;
663 }; 664 };
664 665
665 666
666 // 667 //
(...skipping 699 matching lines...) Expand 10 before | Expand all | Expand 10 after
1366 msg.WriteToLogFile(); 1367 msg.WriteToLogFile();
1367 } 1368 }
1368 1369
1369 void Logger::TickEvent(TickSample* sample, bool overflow) { 1370 void Logger::TickEvent(TickSample* sample, bool overflow) {
1370 if (!log_->IsEnabled() || !FLAG_prof_cpp) return; 1371 if (!log_->IsEnabled() || !FLAG_prof_cpp) return;
1371 if (FLAG_runtime_call_stats) { 1372 if (FLAG_runtime_call_stats) {
1372 RuntimeCallTimerEvent(); 1373 RuntimeCallTimerEvent();
1373 } 1374 }
1374 Log::MessageBuilder msg(log_); 1375 Log::MessageBuilder msg(log_);
1375 msg.Append("%s,", kLogEventsNames[CodeEventListener::TICK_EVENT]); 1376 msg.Append("%s,", kLogEventsNames[CodeEventListener::TICK_EVENT]);
1376 msg.AppendAddress(sample->pc); 1377 msg.AppendAddress(reinterpret_cast<Address>(sample->pc));
1377 msg.Append(",%d", static_cast<int>(timer_.Elapsed().InMicroseconds())); 1378 msg.Append(",%d", static_cast<int>(timer_.Elapsed().InMicroseconds()));
1378 if (sample->has_external_callback) { 1379 if (sample->has_external_callback) {
1379 msg.Append(",1,"); 1380 msg.Append(",1,");
1380 msg.AppendAddress(sample->external_callback_entry); 1381 msg.AppendAddress(
1382 reinterpret_cast<Address>(sample->external_callback_entry));
1381 } else { 1383 } else {
1382 msg.Append(",0,"); 1384 msg.Append(",0,");
1383 msg.AppendAddress(sample->tos); 1385 msg.AppendAddress(reinterpret_cast<Address>(sample->tos));
1384 } 1386 }
1385 msg.Append(",%d", static_cast<int>(sample->state)); 1387 msg.Append(",%d", static_cast<int>(sample->state));
1386 if (overflow) { 1388 if (overflow) {
1387 msg.Append(",overflow"); 1389 msg.Append(",overflow");
1388 } 1390 }
1389 for (unsigned i = 0; i < sample->frames_count; ++i) { 1391 for (unsigned i = 0; i < sample->frames_count; ++i) {
1390 msg.Append(','); 1392 msg.Append(',');
1391 msg.AppendAddress(sample->stack[i]); 1393 msg.AppendAddress(reinterpret_cast<Address>(sample->stack[i]));
1392 } 1394 }
1393 msg.WriteToLogFile(); 1395 msg.WriteToLogFile();
1394 } 1396 }
1395 1397
1396 1398
1397 void Logger::StopProfiler() { 1399 void Logger::StopProfiler() {
1398 if (!log_->IsEnabled()) return; 1400 if (!log_->IsEnabled()) return;
1399 if (profiler_ != NULL) { 1401 if (profiler_ != NULL) {
1400 profiler_->pause(); 1402 profiler_->pause();
1401 is_logging_ = false; 1403 is_logging_ = false;
(...skipping 467 matching lines...) Expand 10 before | Expand all | Expand 10 after
1869 1871
1870 if (profiler_listener_.get() != nullptr) { 1872 if (profiler_listener_.get() != nullptr) {
1871 removeCodeEventListener(profiler_listener_.get()); 1873 removeCodeEventListener(profiler_listener_.get());
1872 } 1874 }
1873 1875
1874 return log_->Close(); 1876 return log_->Close();
1875 } 1877 }
1876 1878
1877 } // namespace internal 1879 } // namespace internal
1878 } // namespace v8 1880 } // namespace v8
OLDNEW
« no previous file with comments | « src/log.h ('k') | src/profiler/cpu-profiler.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698