 Chromium Code Reviews
 Chromium Code Reviews Issue 2105943002:
  Expose TickSample and its APIs in v8-profiler.h  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master
    
  
    Issue 2105943002:
  Expose TickSample and its APIs in v8-profiler.h  (Closed) 
  Base URL: https://chromium.googlesource.com/v8/v8.git@master| 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 #include "include/v8-profiler.h" | |
| 16 | |
| 17 namespace v8 { | 15 namespace v8 { | 
| 18 namespace internal { | 16 namespace internal { | 
| 19 | 17 | 
| 20 static const int kProfilerStackSize = 64 * KB; | 18 static const int kProfilerStackSize = 64 * KB; | 
| 21 | 19 | 
| 22 | 20 | 
| 23 ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator, | 21 ProfilerEventsProcessor::ProfilerEventsProcessor(ProfileGenerator* generator, | 
| 24 sampler::Sampler* sampler, | 22 sampler::Sampler* sampler, | 
| 25 base::TimeDelta period) | 23 base::TimeDelta period) | 
| 26 : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)), | 24 : Thread(Thread::Options("v8:ProfEvntProc", kProfilerStackSize)), | 
| (...skipping 15 matching lines...) Expand all Loading... | |
| 42 | 40 | 
| 43 | 41 | 
| 44 void ProfilerEventsProcessor::AddDeoptStack(Isolate* isolate, Address from, | 42 void ProfilerEventsProcessor::AddDeoptStack(Isolate* isolate, Address from, | 
| 45 int fp_to_sp_delta) { | 43 int fp_to_sp_delta) { | 
| 46 TickSampleEventRecord record(last_code_event_id_.Value()); | 44 TickSampleEventRecord record(last_code_event_id_.Value()); | 
| 47 RegisterState regs; | 45 RegisterState regs; | 
| 48 Address fp = isolate->c_entry_fp(isolate->thread_local_top()); | 46 Address fp = isolate->c_entry_fp(isolate->thread_local_top()); | 
| 49 regs.sp = fp - fp_to_sp_delta; | 47 regs.sp = fp - fp_to_sp_delta; | 
| 50 regs.fp = fp; | 48 regs.fp = fp; | 
| 51 regs.pc = from; | 49 regs.pc = from; | 
| 52 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame, false); | 50 record.sample.Init(reinterpret_cast<v8::Isolate*>(isolate), regs, | 
| 51 TickSample::kSkipCEntryFrame, false); | |
| 52 record.sample.timestamp = record.sample.pc == nullptr | |
| 
alph
2016/07/01 00:38:13
nit: You can create internal::TickSample::Init and
 
lpy
2016/07/01 01:00:10
Done.
 | |
| 53 ? base::TimeTicks() | |
| 54 : base::TimeTicks::HighResolutionNow(); | |
| 53 ticks_from_vm_buffer_.Enqueue(record); | 55 ticks_from_vm_buffer_.Enqueue(record); | 
| 54 } | 56 } | 
| 55 | 57 | 
| 56 void ProfilerEventsProcessor::AddCurrentStack(Isolate* isolate, | 58 void ProfilerEventsProcessor::AddCurrentStack(Isolate* isolate, | 
| 57 bool update_stats) { | 59 bool update_stats) { | 
| 58 TickSampleEventRecord record(last_code_event_id_.Value()); | 60 TickSampleEventRecord record(last_code_event_id_.Value()); | 
| 59 RegisterState regs; | 61 RegisterState regs; | 
| 60 StackFrameIterator it(isolate); | 62 StackFrameIterator it(isolate); | 
| 61 if (!it.done()) { | 63 if (!it.done()) { | 
| 62 StackFrame* frame = it.frame(); | 64 StackFrame* frame = it.frame(); | 
| 63 regs.sp = frame->sp(); | 65 regs.sp = frame->sp(); | 
| 64 regs.fp = frame->fp(); | 66 regs.fp = frame->fp(); | 
| 65 regs.pc = frame->pc(); | 67 regs.pc = frame->pc(); | 
| 66 } | 68 } | 
| 67 record.sample.Init(isolate, regs, TickSample::kSkipCEntryFrame, update_stats); | 69 record.sample.Init(reinterpret_cast<v8::Isolate*>(isolate), regs, | 
| 70 TickSample::kSkipCEntryFrame, update_stats); | |
| 71 record.sample.timestamp = record.sample.pc == nullptr | |
| 72 ? base::TimeTicks() | |
| 73 : base::TimeTicks::HighResolutionNow(); | |
| 68 ticks_from_vm_buffer_.Enqueue(record); | 74 ticks_from_vm_buffer_.Enqueue(record); | 
| 69 } | 75 } | 
| 70 | 76 | 
| 71 | 77 | 
| 72 void ProfilerEventsProcessor::StopSynchronously() { | 78 void ProfilerEventsProcessor::StopSynchronously() { | 
| 73 if (!base::NoBarrier_AtomicExchange(&running_, 0)) return; | 79 if (!base::NoBarrier_AtomicExchange(&running_, 0)) return; | 
| 74 Join(); | 80 Join(); | 
| 75 } | 81 } | 
| 76 | 82 | 
| 77 | 83 | 
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 360 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 366 ReportBuiltinEventRecord* rec = &evt_rec.ReportBuiltinEventRecord_; | 
| 361 Builtins::Name id = static_cast<Builtins::Name>(i); | 367 Builtins::Name id = static_cast<Builtins::Name>(i); | 
| 362 rec->start = builtins->builtin(id)->address(); | 368 rec->start = builtins->builtin(id)->address(); | 
| 363 rec->builtin_id = id; | 369 rec->builtin_id = id; | 
| 364 processor_->Enqueue(evt_rec); | 370 processor_->Enqueue(evt_rec); | 
| 365 } | 371 } | 
| 366 } | 372 } | 
| 367 | 373 | 
| 368 } // namespace internal | 374 } // namespace internal | 
| 369 } // namespace v8 | 375 } // namespace v8 | 
| OLD | NEW |