V8 Project
v8::internal::ProfilerEventsProcessor Class Reference

#include <cpu-profiler.h>

+ Inheritance diagram for v8::internal::ProfilerEventsProcessor:
+ Collaboration diagram for v8::internal::ProfilerEventsProcessor:

Public Member Functions

 ProfilerEventsProcessor (ProfileGenerator *generator, Sampler *sampler, base::TimeDelta period)
 
virtual ~ProfilerEventsProcessor ()
 
virtual void Run ()
 
void StopSynchronously ()
 
 INLINE (bool running())
 
void Enqueue (const CodeEventsContainer &event)
 
void AddCurrentStack (Isolate *isolate)
 
TickSampleStartTickSample ()
 
void FinishTickSample ()
 
void * operator new (size_t size)
 
void operator delete (void *ptr)
 
- Public Member Functions inherited from v8::base::Thread
 Thread (const Options &options)
 
virtual ~Thread ()
 
void Start ()
 
void StartSynchronously ()
 
void Join ()
 
const char * name () const
 
PlatformDatadata ()
 
void NotifyStartedAndRun ()
 

Private Types

enum  SampleProcessingResult { OneSampleProcessed , FoundSampleForNextCodeEvent , NoSamplesInQueue }
 

Private Member Functions

bool ProcessCodeEvent ()
 
SampleProcessingResult ProcessOneSample ()
 

Private Attributes

ProfileGeneratorgenerator_
 
Samplersampler_
 
bool running_
 
const base::TimeDelta period_
 
UnboundQueue< CodeEventsContainerevents_buffer_
 
SamplingCircularQueue< TickSampleEventRecord, kTickSampleQueueLengthticks_buffer_
 
UnboundQueue< TickSampleEventRecordticks_from_vm_buffer_
 
unsigned last_code_event_id_
 
unsigned last_processed_code_event_id_
 

Static Private Attributes

static const size_t kTickSampleBufferSize = 1 * MB
 
static const size_t kTickSampleQueueLength
 

Additional Inherited Members

- Public Types inherited from v8::base::Thread
typedef int32_t LocalStorageKey
 
- Static Public Member Functions inherited from v8::base::Thread
static LocalStorageKey CreateThreadLocalKey ()
 
static void DeleteThreadLocalKey (LocalStorageKey key)
 
static void * GetThreadLocal (LocalStorageKey key)
 
static int GetThreadLocalInt (LocalStorageKey key)
 
static void SetThreadLocal (LocalStorageKey key, void *value)
 
static void SetThreadLocalInt (LocalStorageKey key, int value)
 
static bool HasThreadLocal (LocalStorageKey key)
 
static void * GetExistingThreadLocal (LocalStorageKey key)
 
static void YieldCPU ()
 
- Static Public Attributes inherited from v8::base::Thread
static const int kMaxThreadNameLength = 16
 

Detailed Description

Definition at line 125 of file cpu-profiler.h.

Member Enumeration Documentation

◆ SampleProcessingResult

Enumerator
OneSampleProcessed 
FoundSampleForNextCodeEvent 
NoSamplesInQueue 

Definition at line 157 of file cpu-profiler.h.

Constructor & Destructor Documentation

◆ ProfilerEventsProcessor()

v8::internal::ProfilerEventsProcessor::ProfilerEventsProcessor ( ProfileGenerator generator,
Sampler sampler,
base::TimeDelta  period 
)

Definition at line 23 of file cpu-profiler.cc.

◆ ~ProfilerEventsProcessor()

virtual v8::internal::ProfilerEventsProcessor::~ProfilerEventsProcessor ( )
inlinevirtual

Definition at line 130 of file cpu-profiler.h.

130 {}

Member Function Documentation

◆ AddCurrentStack()

void v8::internal::ProfilerEventsProcessor::AddCurrentStack ( Isolate isolate)

Definition at line 42 of file cpu-profiler.cc.

42  {
43  TickSampleEventRecord record(last_code_event_id_);
44  RegisterState regs;
45  StackFrameIterator it(isolate);
46  if (!it.done()) {
47  StackFrame* frame = it.frame();
48  regs.sp = frame->sp();
49  regs.fp = frame->fp();
50  regs.pc = frame->pc();
51  }
52  record.sample.Init(isolate, regs);
53  ticks_from_vm_buffer_.Enqueue(record);
54 }
UnboundQueue< TickSampleEventRecord > ticks_from_vm_buffer_
Definition: cpu-profiler.h:175
HANDLE HANDLE LPSTACKFRAME64 StackFrame

References v8::internal::RegisterState::fp, v8::internal::StackFrameIterator::frame(), v8::internal::TickSample::Init(), last_code_event_id_, v8::internal::RegisterState::pc, v8::internal::TickSampleEventRecord::sample, v8::internal::RegisterState::sp, and ticks_from_vm_buffer_.

Referenced by v8::internal::CpuProfiler::StartProcessorIfNotStarted().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Enqueue()

void v8::internal::ProfilerEventsProcessor::Enqueue ( const CodeEventsContainer event)

◆ FinishTickSample()

void v8::internal::ProfilerEventsProcessor::FinishTickSample ( )
inline

Definition at line 75 of file cpu-profiler-inl.h.

75  {
76  ticks_buffer_.FinishEnqueue();
77 }
SamplingCircularQueue< TickSampleEventRecord, kTickSampleQueueLength > ticks_buffer_
Definition: cpu-profiler.h:174

References ticks_buffer_.

Referenced by v8::internal::CpuProfiler::FinishTickSample().

+ Here is the caller graph for this function:

◆ INLINE()

v8::internal::ProfilerEventsProcessor::INLINE ( bool   running())
inline

Definition at line 135 of file cpu-profiler.h.

135 { return running_; }

◆ operator delete()

void v8::internal::ProfilerEventsProcessor::operator delete ( void *  ptr)

Definition at line 141 of file cpu-profiler.cc.

141  {
142  AlignedFree(ptr);
143 }
void AlignedFree(void *ptr)
Definition: allocation.cc:104

References v8::internal::AlignedFree().

+ Here is the call graph for this function:

◆ operator new()

void * v8::internal::ProfilerEventsProcessor::operator new ( size_t  size)

Definition at line 136 of file cpu-profiler.cc.

136  {
138 }
ProfilerEventsProcessor(ProfileGenerator *generator, Sampler *sampler, base::TimeDelta period)
Definition: cpu-profiler.cc:23
enable harmony numeric enable harmony object literal extensions Optimize object size
void * AlignedAlloc(size_t size, size_t alignment)
Definition: allocation.cc:86
#define V8_ALIGNOF(type)
Definition: v8config.h:416

References v8::internal::AlignedAlloc(), size, and V8_ALIGNOF.

+ Here is the call graph for this function:

◆ ProcessCodeEvent()

bool v8::internal::ProfilerEventsProcessor::ProcessCodeEvent ( )
private

Definition at line 64 of file cpu-profiler.cc.

64  {
65  CodeEventsContainer record;
66  if (events_buffer_.Dequeue(&record)) {
67  switch (record.generic.type) {
68 #define PROFILER_TYPE_CASE(type, clss) \
69  case CodeEventRecord::type: \
70  record.clss##_.UpdateCodeMap(generator_->code_map()); \
71  break;
72 
74 
75 #undef PROFILER_TYPE_CASE
76  default: return true; // Skip record.
77  }
78  last_processed_code_event_id_ = record.generic.order;
79  return true;
80  }
81  return false;
82 }
#define PROFILER_TYPE_CASE(type, clss)
#define CODE_EVENTS_TYPE_LIST(V)
Definition: cpu-profiler.h:26

References CODE_EVENTS_TYPE_LIST, events_buffer_, v8::internal::CodeEventsContainer::generic, last_processed_code_event_id_, v8::internal::CodeEventRecord::order, PROFILER_TYPE_CASE, and v8::internal::CodeEventRecord::type.

Referenced by Run().

+ Here is the caller graph for this function:

◆ ProcessOneSample()

ProfilerEventsProcessor::SampleProcessingResult v8::internal::ProfilerEventsProcessor::ProcessOneSample ( )
private

Definition at line 85 of file cpu-profiler.cc.

85  {
86  if (!ticks_from_vm_buffer_.IsEmpty()
87  && ticks_from_vm_buffer_.Peek()->order ==
89  TickSampleEventRecord record;
90  ticks_from_vm_buffer_.Dequeue(&record);
91  generator_->RecordTickSample(record.sample);
92  return OneSampleProcessed;
93  }
94 
95  const TickSampleEventRecord* record = ticks_buffer_.Peek();
96  if (record == NULL) {
97  if (ticks_from_vm_buffer_.IsEmpty()) return NoSamplesInQueue;
99  }
100  if (record->order != last_processed_code_event_id_) {
102  }
103  generator_->RecordTickSample(record->sample);
104  ticks_buffer_.Remove();
105  return OneSampleProcessed;
106 }
void RecordTickSample(const TickSample &sample)
enable harmony numeric enable harmony object literal extensions Optimize object Array DOM strings and string trace pretenuring decisions of HAllocate instructions Enables optimizations which favor memory size over execution speed maximum source size in bytes considered for a single inlining maximum cumulative number of AST nodes considered for inlining trace the tracking of allocation sites deoptimize every n garbage collections perform array bounds checks elimination analyze liveness of environment slots and zap dead values flushes the cache of optimized code for closures on every GC allow uint32 values on optimize frames if they are used only in safe operations track concurrent recompilation artificial compilation delay in ms do not emit check maps for constant values that have a leaf deoptimize the optimized code if the layout of the maps changes enable context specialization in TurboFan execution budget before interrupt is triggered max percentage of megamorphic generic ICs to allow optimization enable use of SAHF instruction if enable use of VFP3 instructions if available enable use of NEON instructions if enable use of SDIV and UDIV instructions if enable use of MLS instructions if enable loading bit constant by means of movw movt instruction enable unaligned accesses for enable use of d16 d31 registers on ARM this requires VFP3 force all emitted branches to be in long enable alignment of csp to bytes on platforms which prefer the register to always be NULL

References FoundSampleForNextCodeEvent, generator_, last_processed_code_event_id_, NoSamplesInQueue, NULL, OneSampleProcessed, v8::internal::TickSampleEventRecord::order, v8::internal::ProfileGenerator::RecordTickSample(), v8::internal::TickSampleEventRecord::sample, ticks_buffer_, and ticks_from_vm_buffer_.

Referenced by Run().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ Run()

void v8::internal::ProfilerEventsProcessor::Run ( )
virtual

Implements v8::base::Thread.

Definition at line 109 of file cpu-profiler.cc.

109  {
110  while (running_) {
111  base::ElapsedTimer timer;
112  timer.Start();
113  // Keep processing existing events until we need to do next sample.
114  do {
116  // All ticks of the current last_processed_code_event_id_ are
117  // processed, proceed to the next code event.
119  }
120  } while (!timer.HasExpired(period_));
121 
122  // Schedule next sample. sampler_ is NULL in tests.
123  if (sampler_) sampler_->DoSample();
124  }
125 
126  // Process remaining tick events.
127  do {
128  SampleProcessingResult result;
129  do {
130  result = ProcessOneSample();
131  } while (result == OneSampleProcessed);
132  } while (ProcessCodeEvent());
133 }
SampleProcessingResult ProcessOneSample()
Definition: cpu-profiler.cc:85

References v8::internal::Sampler::DoSample(), FoundSampleForNextCodeEvent, OneSampleProcessed, period_, ProcessCodeEvent(), ProcessOneSample(), running_, and sampler_.

+ Here is the call graph for this function:

◆ StartTickSample()

TickSample * v8::internal::ProfilerEventsProcessor::StartTickSample ( )
inline

Definition at line 66 of file cpu-profiler-inl.h.

66  {
67  void* address = ticks_buffer_.StartEnqueue();
68  if (address == NULL) return NULL;
69  TickSampleEventRecord* evt =
70  new(address) TickSampleEventRecord(last_code_event_id_);
71  return &evt->sample;
72 }

References last_code_event_id_, NULL, v8::internal::TickSampleEventRecord::sample, and ticks_buffer_.

Referenced by v8::internal::CpuProfiler::StartTickSample().

+ Here is the caller graph for this function:

◆ StopSynchronously()

void v8::internal::ProfilerEventsProcessor::StopSynchronously ( )

Definition at line 57 of file cpu-profiler.cc.

57  {
58  if (!running_) return;
59  running_ = false;
60  Join();
61 }

References v8::base::Thread::Join(), and running_.

Referenced by v8::internal::CpuProfiler::StopProcessor().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ events_buffer_

UnboundQueue<CodeEventsContainer> v8::internal::ProfilerEventsProcessor::events_buffer_
private

Definition at line 169 of file cpu-profiler.h.

Referenced by Enqueue(), and ProcessCodeEvent().

◆ generator_

ProfileGenerator* v8::internal::ProfilerEventsProcessor::generator_
private

Definition at line 164 of file cpu-profiler.h.

Referenced by ProcessOneSample().

◆ kTickSampleBufferSize

const size_t v8::internal::ProfilerEventsProcessor::kTickSampleBufferSize = 1 * MB
staticprivate

Definition at line 170 of file cpu-profiler.h.

◆ kTickSampleQueueLength

const size_t v8::internal::ProfilerEventsProcessor::kTickSampleQueueLength
staticprivate
Initial value:
=
kTickSampleBufferSize / sizeof(TickSampleEventRecord)
static const size_t kTickSampleBufferSize
Definition: cpu-profiler.h:170

Definition at line 171 of file cpu-profiler.h.

◆ last_code_event_id_

unsigned v8::internal::ProfilerEventsProcessor::last_code_event_id_
private

Definition at line 176 of file cpu-profiler.h.

Referenced by AddCurrentStack(), Enqueue(), and StartTickSample().

◆ last_processed_code_event_id_

unsigned v8::internal::ProfilerEventsProcessor::last_processed_code_event_id_
private

Definition at line 177 of file cpu-profiler.h.

Referenced by ProcessCodeEvent(), and ProcessOneSample().

◆ period_

const base::TimeDelta v8::internal::ProfilerEventsProcessor::period_
private

Definition at line 168 of file cpu-profiler.h.

Referenced by Run().

◆ running_

bool v8::internal::ProfilerEventsProcessor::running_
private

Definition at line 166 of file cpu-profiler.h.

Referenced by Run(), and StopSynchronously().

◆ sampler_

Sampler* v8::internal::ProfilerEventsProcessor::sampler_
private

Definition at line 165 of file cpu-profiler.h.

Referenced by Run().

◆ ticks_buffer_

SamplingCircularQueue<TickSampleEventRecord, kTickSampleQueueLength> v8::internal::ProfilerEventsProcessor::ticks_buffer_
private

Definition at line 174 of file cpu-profiler.h.

Referenced by FinishTickSample(), ProcessOneSample(), and StartTickSample().

◆ ticks_from_vm_buffer_

UnboundQueue<TickSampleEventRecord> v8::internal::ProfilerEventsProcessor::ticks_from_vm_buffer_
private

Definition at line 175 of file cpu-profiler.h.

Referenced by AddCurrentStack(), and ProcessOneSample().


The documentation for this class was generated from the following files: