| Index: src/log.cc
|
| diff --git a/src/log.cc b/src/log.cc
|
| index f5eea2bd9acb234a2d0e89641a7907d376d849f0..f7607783e3180ee1cdf5906dec6e1da3e49cf1c4 100644
|
| --- a/src/log.cc
|
| +++ b/src/log.cc
|
| @@ -7,7 +7,6 @@
|
| #include <cstdarg>
|
| #include <sstream>
|
|
|
| -#include "include/v8-profiler.h"
|
| #include "src/bailout-reason.h"
|
| #include "src/base/platform/platform.h"
|
| #include "src/bootstrapper.h"
|
| @@ -22,7 +21,9 @@
|
| #include "src/log-utils.h"
|
| #include "src/macro-assembler.h"
|
| #include "src/perf-jit.h"
|
| +#include "src/profiler/cpu-profiler-inl.h"
|
| #include "src/profiler/profiler-listener.h"
|
| +#include "src/profiler/tick-sample.h"
|
| #include "src/runtime-profiler.h"
|
| #include "src/string-stream.h"
|
| #include "src/vm-state-inl.h"
|
| @@ -30,6 +31,7 @@
|
| namespace v8 {
|
| namespace internal {
|
|
|
| +
|
| #define DECLARE_EVENT(ignore1, name) name,
|
| static const char* kLogEventsNames[CodeEventListener::NUMBER_OF_LOG_EVENTS] = {
|
| LOG_EVENTS_AND_TAGS_LIST(DECLARE_EVENT)};
|
| @@ -555,7 +557,7 @@ class Profiler: public base::Thread {
|
| void Disengage();
|
|
|
| // Inserts collected profiling data into buffer.
|
| - void Insert(v8::TickSample* sample) {
|
| + void Insert(TickSample* sample) {
|
| if (paused_)
|
| return;
|
|
|
| @@ -576,7 +578,7 @@ class Profiler: public base::Thread {
|
|
|
| private:
|
| // Waits for a signal and removes profiling data.
|
| - bool Remove(v8::TickSample* sample) {
|
| + bool Remove(TickSample* sample) {
|
| buffer_semaphore_.Wait(); // Wait for an element.
|
| *sample = buffer_[base::NoBarrier_Load(&tail_)];
|
| bool result = overflow_;
|
| @@ -593,7 +595,7 @@ class Profiler: public base::Thread {
|
| // Cyclic buffer for communicating profiling samples
|
| // between the signal handler and the worker thread.
|
| static const int kBufferSize = 128;
|
| - v8::TickSample buffer_[kBufferSize]; // Buffer storage.
|
| + TickSample buffer_[kBufferSize]; // Buffer storage.
|
| int head_; // Index to the buffer head.
|
| base::Atomic32 tail_; // Index to the buffer tail.
|
| bool overflow_; // Tell whether a buffer overflow has occurred.
|
| @@ -617,10 +619,10 @@ class Profiler: public base::Thread {
|
| //
|
| class Ticker: public sampler::Sampler {
|
| public:
|
| - Ticker(Isolate* isolate, int interval)
|
| - : sampler::Sampler(reinterpret_cast<v8::Isolate*>(isolate)),
|
| - profiler_(nullptr),
|
| - sampling_thread_(new SamplingThread(this, interval)) {}
|
| + Ticker(Isolate* isolate, int interval):
|
| + sampler::Sampler(reinterpret_cast<v8::Isolate*>(isolate)),
|
| + profiler_(NULL),
|
| + sampling_thread_(new SamplingThread(this, interval)) {}
|
|
|
| ~Ticker() {
|
| if (IsActive()) Stop();
|
| @@ -628,7 +630,7 @@ class Ticker: public sampler::Sampler {
|
| }
|
|
|
| void SetProfiler(Profiler* profiler) {
|
| - DCHECK(profiler_ == nullptr);
|
| + DCHECK(profiler_ == NULL);
|
| profiler_ = profiler;
|
| IncreaseProfilingDepth();
|
| if (!IsActive()) Start();
|
| @@ -636,7 +638,7 @@ class Ticker: public sampler::Sampler {
|
| }
|
|
|
| void ClearProfiler() {
|
| - profiler_ = nullptr;
|
| + profiler_ = NULL;
|
| if (IsActive()) Stop();
|
| DecreaseProfilingDepth();
|
| sampling_thread_->Join();
|
| @@ -644,8 +646,15 @@ class Ticker: public sampler::Sampler {
|
|
|
| void SampleStack(const v8::RegisterState& state) override {
|
| if (!profiler_) return;
|
| - v8::TickSample sample;
|
| - sample.Init(isolate(), state, v8::TickSample::kIncludeCEntryFrame, true);
|
| + v8::Isolate* v8_isolate = isolate();
|
| + Isolate* i_isolate = reinterpret_cast<Isolate*>(v8_isolate);
|
| +#if defined(USE_SIMULATOR)
|
| + if (!SimulatorHelper::FillRegisters(i_isolate,
|
| + const_cast<v8::RegisterState*>(&state)))
|
| + return;
|
| +#endif
|
| + TickSample sample;
|
| + sample.Init(i_isolate, state, TickSample::kIncludeCEntryFrame, true);
|
| profiler_->Insert(&sample);
|
| }
|
|
|
| @@ -705,7 +714,7 @@ void Profiler::Disengage() {
|
| // inserting a fake element in the queue and then wait for
|
| // the thread to terminate.
|
| base::NoBarrier_Store(&running_, 0);
|
| - v8::TickSample sample;
|
| + TickSample sample;
|
| // Reset 'paused_' flag, otherwise semaphore may not be signalled.
|
| resume();
|
| Insert(&sample);
|
| @@ -716,7 +725,7 @@ void Profiler::Disengage() {
|
|
|
|
|
| void Profiler::Run() {
|
| - v8::TickSample sample;
|
| + TickSample sample;
|
| bool overflow = Remove(&sample);
|
| while (base::NoBarrier_Load(&running_)) {
|
| LOG(isolate_, TickEvent(&sample, overflow));
|
| @@ -1358,7 +1367,7 @@ void Logger::RuntimeCallTimerEvent() {
|
| msg.WriteToLogFile();
|
| }
|
|
|
| -void Logger::TickEvent(v8::TickSample* sample, bool overflow) {
|
| +void Logger::TickEvent(TickSample* sample, bool overflow) {
|
| if (!log_->IsEnabled() || !FLAG_prof_cpp) return;
|
| if (FLAG_runtime_call_stats) {
|
| RuntimeCallTimerEvent();
|
|
|