Chromium Code Reviews| Index: src/sampler.cc |
| diff --git a/src/sampler.cc b/src/sampler.cc |
| index 394efeb7640764870b6f768a9d11a1b879955416..df6ca8f59d838626672c15632ee4cea018972191 100644 |
| --- a/src/sampler.cc |
| +++ b/src/sampler.cc |
| @@ -226,13 +226,13 @@ class Sampler::PlatformData : public PlatformDataCommon { |
| #if defined(USE_SIMULATOR) |
| class SimulatorHelper { |
| public: |
| - inline bool Init(Sampler* sampler, Isolate* isolate) { |
| + inline bool Init(Isolate* isolate) { |
| simulator_ = isolate->thread_local_top()->simulator_; |
| // Check if there is active simulator. |
| return simulator_ != NULL; |
| } |
| - inline void FillRegisters(RegisterState* state) { |
| + inline void FillRegisters(v8::RegisterState* state) { |
| #if V8_TARGET_ARCH_ARM |
| state->pc = reinterpret_cast<Address>(simulator_->get_pc()); |
| state->sp = reinterpret_cast<Address>(simulator_->get_register( |
| @@ -241,9 +241,9 @@ class SimulatorHelper { |
| Simulator::r11)); |
| #elif V8_TARGET_ARCH_ARM64 |
| if (simulator_->sp() == 0 || simulator_->fp() == 0) { |
| - // It possible that the simulator is interrupted while it is updating |
| + // It's possible that the simulator is interrupted while it is updating |
| // the sp or fp register. ARM64 simulator does this in two steps: |
| - // first setting it to zero and then setting it to the new value. |
| + // first setting it to zero and then setting it to a new value. |
| // Bailout if sp/fp doesn't contain the new value. |
| return; |
| } |
| @@ -353,11 +353,11 @@ void SignalHandler::HandleProfilerSignal(int signal, siginfo_t* info, |
| Sampler* sampler = isolate->logger()->sampler(); |
| if (sampler == NULL) return; |
| - RegisterState state; |
| + v8::RegisterState state; |
| #if defined(USE_SIMULATOR) |
| SimulatorHelper helper; |
| - if (!helper.Init(sampler, isolate)) return; |
| + if (!helper.Init(isolate)) return; |
| helper.FillRegisters(&state); |
| // It possible that the simulator is interrupted while it is updating |
| // the sp or fp register. ARM64 simulator does this in two steps: |
| @@ -577,10 +577,10 @@ SamplerThread* SamplerThread::instance_ = NULL; |
| // StackTracer implementation |
| // |
| DISABLE_ASAN void TickSample::Init(Isolate* isolate, |
| - const RegisterState& regs) { |
| + const v8::RegisterState& regs) { |
| DCHECK(isolate->IsInitialized()); |
| timestamp = base::TimeTicks::HighResolutionNow(); |
| - pc = regs.pc; |
| + pc = reinterpret_cast<Address>(regs.pc); |
| state = isolate->current_vm_state(); |
| // Avoid collecting traces while doing GC. |
| @@ -603,18 +603,37 @@ DISABLE_ASAN void TickSample::Init(Isolate* isolate, |
| } else { |
| // Sample potential return address value for frameless invocation of |
| // stubs (we'll figure out later, if this value makes sense). |
| - tos = Memory::Address_at(regs.sp); |
| + tos = Memory::Address_at(reinterpret_cast<Address>(regs.sp)); |
| has_external_callback = false; |
| } |
| - SafeStackFrameIterator it(isolate, regs.fp, regs.sp, js_entry_sp); |
| + SafeStackFrameIterator it(isolate, reinterpret_cast<Address>(regs.fp), |
| + reinterpret_cast<Address>(regs.sp), js_entry_sp); |
| top_frame_type = it.top_frame_type(); |
| - unsigned i = 0; |
| - while (!it.done() && i < TickSample::kMaxFramesCount) { |
| - stack[i++] = it.frame()->pc(); |
| + |
| + frames_count = static_cast<unsigned>(GetStackSample( |
| + isolate, regs, reinterpret_cast<void**>(&stack[0]), kMaxFramesCount)); |
| +} |
| + |
| + |
| +size_t TickSample::GetStackSample(Isolate* isolate, |
| + const v8::RegisterState& regs, void** frames, |
| + size_t frames_limit) { |
| + DCHECK(isolate->IsInitialized()); |
| + Address js_entry_sp = isolate->js_entry_sp(); |
|
yurys
2014/09/23 09:32:03
I expected that we wouldn't collect call stack if
alph
2014/09/23 11:13:01
Done.
|
| + if (js_entry_sp == 0) { |
| + // Not executing JS now. |
| + return 0; |
| + } |
| + |
| + SafeStackFrameIterator it(isolate, reinterpret_cast<Address>(regs.fp), |
| + reinterpret_cast<Address>(regs.sp), js_entry_sp); |
| + size_t i = 0; |
| + while (!it.done() && i < frames_limit) { |
| + frames[i++] = it.frame()->pc(); |
| it.Advance(); |
| } |
| - frames_count = i; |
| + return i; |
| } |
| @@ -682,7 +701,7 @@ void Sampler::DecreaseProfilingDepth() { |
| } |
| -void Sampler::SampleStack(const RegisterState& state) { |
| +void Sampler::SampleStack(const v8::RegisterState& state) { |
| TickSample* sample = isolate_->cpu_profiler()->StartTickSample(); |
| TickSample sample_obj; |
| if (sample == NULL) sample = &sample_obj; |
| @@ -714,7 +733,7 @@ void Sampler::DoSample() { |
| #if defined(USE_SIMULATOR) |
| SimulatorHelper helper; |
| - if (!helper.Init(this, isolate())) return; |
| + if (!helper.Init(isolate())) return; |
| #endif |
| const DWORD kSuspendFailed = static_cast<DWORD>(-1); |
| @@ -725,7 +744,7 @@ void Sampler::DoSample() { |
| memset(&context, 0, sizeof(context)); |
| context.ContextFlags = CONTEXT_FULL; |
| if (GetThreadContext(profiled_thread, &context) != 0) { |
| - RegisterState state; |
| + v8::RegisterState state; |
| #if defined(USE_SIMULATOR) |
| helper.FillRegisters(&state); |
| #else |