| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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/profiler/cpu-profiler.h" | 5 #include "src/profiler/cpu-profiler.h" |
| 6 | 6 |
| 7 #include "src/debug/debug.h" | 7 #include "src/debug/debug.h" |
| 8 #include "src/deoptimizer.h" | 8 #include "src/deoptimizer.h" |
| 9 #include "src/frames-inl.h" | 9 #include "src/frames-inl.h" |
| 10 #include "src/locked-queue-inl.h" | 10 #include "src/locked-queue-inl.h" |
| 11 #include "src/log-inl.h" | 11 #include "src/log-inl.h" |
| 12 #include "src/profiler/cpu-profiler-inl.h" | 12 #include "src/profiler/cpu-profiler-inl.h" |
| 13 #include "src/vm-state-inl.h" | 13 #include "src/vm-state-inl.h" |
| 14 | 14 |
| 15 namespace v8 { | 15 namespace v8 { |
| 16 namespace internal { | 16 namespace internal { |
| 17 | 17 |
| 18 static const int kProfilerStackSize = 64 * KB; | 18 static const int kProfilerStackSize = 64 * KB; |
| 19 | 19 |
| 20 class CpuSampler : public sampler::Sampler { | 20 class CpuSampler : public sampler::Sampler { |
| 21 public: | 21 public: |
| 22 CpuSampler(Isolate* isolate, ProfilerEventsProcessor* processor) | 22 CpuSampler(Isolate* isolate, ProfilerEventsProcessor* processor) |
| 23 : sampler::Sampler(reinterpret_cast<v8::Isolate*>(isolate)), | 23 : sampler::Sampler(reinterpret_cast<v8::Isolate*>(isolate)), |
| 24 processor_(processor) {} | 24 processor_(processor) {} |
| 25 | 25 |
| 26 void SampleStack(const v8::RegisterState& state) override { | 26 void SampleStack(const v8::RegisterState& regs) override { |
| 27 v8::Isolate* v8_isolate = isolate(); | |
| 28 Isolate* i_isolate = reinterpret_cast<Isolate*>(v8_isolate); | |
| 29 #if defined(USE_SIMULATOR) | |
| 30 v8::RegisterState regs; | |
| 31 if (!SimulatorHelper::FillRegisters(i_isolate, ®s)) return; | |
| 32 #else | |
| 33 const v8::RegisterState& regs = state; | |
| 34 #endif | |
| 35 TickSample* sample = processor_->StartTickSample(); | 27 TickSample* sample = processor_->StartTickSample(); |
| 36 if (sample == NULL) return; | 28 if (sample == nullptr) return; |
| 37 sample->Init(i_isolate, regs, TickSample::kIncludeCEntryFrame, true); | 29 Isolate* isolate = reinterpret_cast<Isolate*>(this->isolate()); |
| 30 v8::RegisterState updated_regs; |
| 31 sample->Init(isolate, regs, updated_regs, TickSample::kIncludeCEntryFrame, |
| 32 true); |
| 38 if (is_counting_samples_ && !sample->timestamp.IsNull()) { | 33 if (is_counting_samples_ && !sample->timestamp.IsNull()) { |
| 39 if (sample->state == JS) ++js_sample_count_; | 34 if (sample->state == JS) ++js_sample_count_; |
| 40 if (sample->state == EXTERNAL) ++external_sample_count_; | 35 if (sample->state == EXTERNAL) ++external_sample_count_; |
| 41 } | 36 } |
| 42 processor_->FinishTickSample(); | 37 processor_->FinishTickSample(); |
| 43 } | 38 } |
| 44 | 39 |
| 45 private: | 40 private: |
| 46 ProfilerEventsProcessor* processor_; | 41 ProfilerEventsProcessor* processor_; |
| 47 }; | 42 }; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 70 | 65 |
| 71 | 66 |
| 72 void ProfilerEventsProcessor::AddDeoptStack(Isolate* isolate, Address from, | 67 void ProfilerEventsProcessor::AddDeoptStack(Isolate* isolate, Address from, |
| 73 int fp_to_sp_delta) { | 68 int fp_to_sp_delta) { |
| 74 TickSampleEventRecord record(last_code_event_id_.Value()); | 69 TickSampleEventRecord record(last_code_event_id_.Value()); |
| 75 RegisterState regs; | 70 RegisterState regs; |
| 76 Address fp = isolate->c_entry_fp(isolate->thread_local_top()); | 71 Address fp = isolate->c_entry_fp(isolate->thread_local_top()); |
| 77 regs.sp = fp - fp_to_sp_delta; | 72 regs.sp = fp - fp_to_sp_delta; |
| 78 regs.fp = fp; | 73 regs.fp = fp; |
| 79 regs.pc = from; | 74 regs.pc = from; |
| 80 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame, false); | 75 RegisterState updated_regs; |
| 76 record.sample.Init(isolate, regs, updated_regs, TickSample::kSkipCEntryFrame, |
| 77 false, true); |
| 81 ticks_from_vm_buffer_.Enqueue(record); | 78 ticks_from_vm_buffer_.Enqueue(record); |
| 82 } | 79 } |
| 83 | 80 |
| 84 void ProfilerEventsProcessor::AddCurrentStack(Isolate* isolate, | 81 void ProfilerEventsProcessor::AddCurrentStack(Isolate* isolate, |
| 85 bool update_stats) { | 82 bool update_stats) { |
| 86 TickSampleEventRecord record(last_code_event_id_.Value()); | 83 TickSampleEventRecord record(last_code_event_id_.Value()); |
| 87 RegisterState regs; | 84 RegisterState regs; |
| 88 StackFrameIterator it(isolate); | 85 StackFrameIterator it(isolate); |
| 89 if (!it.done()) { | 86 if (!it.done()) { |
| 90 StackFrame* frame = it.frame(); | 87 StackFrame* frame = it.frame(); |
| 91 regs.sp = frame->sp(); | 88 regs.sp = frame->sp(); |
| 92 regs.fp = frame->fp(); | 89 regs.fp = frame->fp(); |
| 93 regs.pc = frame->pc(); | 90 regs.pc = frame->pc(); |
| 94 } | 91 } |
| 95 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame, update_stats); | 92 RegisterState updated_regs; |
| 93 record.sample.Init(isolate, regs, updated_regs, TickSample::kSkipCEntryFrame, |
| 94 update_stats, true); |
| 96 ticks_from_vm_buffer_.Enqueue(record); | 95 ticks_from_vm_buffer_.Enqueue(record); |
| 97 } | 96 } |
| 98 | 97 |
| 99 | 98 |
| 100 void ProfilerEventsProcessor::StopSynchronously() { | 99 void ProfilerEventsProcessor::StopSynchronously() { |
| 101 if (!base::NoBarrier_AtomicExchange(&running_, 0)) return; | 100 if (!base::NoBarrier_AtomicExchange(&running_, 0)) return; |
| 102 Join(); | 101 Join(); |
| 103 } | 102 } |
| 104 | 103 |
| 105 | 104 |
| (...skipping 275 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 381 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 380 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; |
| 382 Builtins::Name id = static_cast<Builtins::Name>(i); | 381 Builtins::Name id = static_cast<Builtins::Name>(i); |
| 383 rec->start = builtins->builtin(id)->address(); | 382 rec->start = builtins->builtin(id)->address(); |
| 384 rec->builtin_id = id; | 383 rec->builtin_id = id; |
| 385 processor_->Enqueue(evt_rec); | 384 processor_->Enqueue(evt_rec); |
| 386 } | 385 } |
| 387 } | 386 } |
| 388 | 387 |
| 389 } // namespace internal | 388 } // namespace internal |
| 390 } // namespace v8 | 389 } // namespace v8 |
| OLD | NEW |