V8 Project
v8::internal::ProfileGenerator Class Reference

#include <profile-generator.h>

+ Collaboration diagram for v8::internal::ProfileGenerator:

Public Member Functions

 ProfileGenerator (CpuProfilesCollection *profiles)
 
void RecordTickSample (const TickSample &sample)
 
CodeMapcode_map ()
 

Static Public Attributes

static const char *const kProgramEntryName
 
static const char *const kIdleEntryName
 
static const char *const kGarbageCollectorEntryName
 
static const char *const kUnresolvedFunctionName
 

Private Member Functions

CodeEntryEntryForVMState (StateTag tag)
 
 DISALLOW_COPY_AND_ASSIGN (ProfileGenerator)
 

Private Attributes

CpuProfilesCollectionprofiles_
 
CodeMap code_map_
 
CodeEntryprogram_entry_
 
CodeEntryidle_entry_
 
CodeEntrygc_entry_
 
CodeEntryunresolved_entry_
 

Detailed Description

Definition at line 307 of file profile-generator.h.

Constructor & Destructor Documentation

◆ ProfileGenerator()

v8::internal::ProfileGenerator::ProfileGenerator ( CpuProfilesCollection profiles)
explicit

Definition at line 560 of file profile-generator.cc.

561  : profiles_(profiles),
563  profiles->NewCodeEntry(Logger::FUNCTION_TAG, kProgramEntryName)),
564  idle_entry_(
565  profiles->NewCodeEntry(Logger::FUNCTION_TAG, kIdleEntryName)),
566  gc_entry_(
567  profiles->NewCodeEntry(Logger::BUILTIN_TAG,
570  profiles->NewCodeEntry(Logger::FUNCTION_TAG,
572 }
CpuProfilesCollection * profiles_
static const char *const kProgramEntryName
static const char *const kUnresolvedFunctionName
static const char *const kIdleEntryName
static const char *const kGarbageCollectorEntryName

Member Function Documentation

◆ code_map()

CodeMap* v8::internal::ProfileGenerator::code_map ( )
inline

Definition at line 313 of file profile-generator.h.

313 { return &code_map_; }

References code_map_.

◆ DISALLOW_COPY_AND_ASSIGN()

v8::internal::ProfileGenerator::DISALLOW_COPY_AND_ASSIGN ( ProfileGenerator  )
private

◆ EntryForVMState()

CodeEntry * v8::internal::ProfileGenerator::EntryForVMState ( StateTag  tag)
private

Definition at line 651 of file profile-generator.cc.

651  {
652  switch (tag) {
653  case GC:
654  return gc_entry_;
655  case JS:
656  case COMPILER:
657  // DOM events handlers are reported as OTHER / EXTERNAL entries.
658  // To avoid confusing people, let's put all these entries into
659  // one bucket.
660  case OTHER:
661  case EXTERNAL:
662  return program_entry_;
663  case IDLE:
664  return idle_entry_;
665  default: return NULL;
666  }
667 }
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 v8::internal::COMPILER, v8::internal::EXTERNAL, v8::internal::GC, gc_entry_, v8::internal::IDLE, idle_entry_, v8::internal::JS, NULL, v8::internal::OTHER, and program_entry_.

Referenced by RecordTickSample().

+ Here is the caller graph for this function:

◆ RecordTickSample()

void v8::internal::ProfileGenerator::RecordTickSample ( const TickSample sample)

Definition at line 575 of file profile-generator.cc.

575  {
576  // Allocate space for stack frames + pc + function + vm-state.
577  ScopedVector<CodeEntry*> entries(sample.frames_count + 3);
578  // As actual number of decoded code entries may vary, initialize
579  // entries vector with NULL values.
580  CodeEntry** entry = entries.start();
581  memset(entry, 0, entries.length() * sizeof(*entry));
582  if (sample.pc != NULL) {
583  if (sample.has_external_callback && sample.state == EXTERNAL &&
584  sample.top_frame_type == StackFrame::EXIT) {
585  // Don't use PC when in external callback code, as it can point
586  // inside callback's code, and we will erroneously report
587  // that a callback calls itself.
588  *entry++ = code_map_.FindEntry(sample.external_callback);
589  } else {
590  Address start;
591  CodeEntry* pc_entry = code_map_.FindEntry(sample.pc, &start);
592  // If pc is in the function code before it set up stack frame or after the
593  // frame was destroyed SafeStackFrameIterator incorrectly thinks that
594  // ebp contains return address of the current function and skips caller's
595  // frame. Check for this case and just skip such samples.
596  if (pc_entry) {
597  List<OffsetRange>* ranges = pc_entry->no_frame_ranges();
598  if (ranges) {
599  Code* code = Code::cast(HeapObject::FromAddress(start));
600  int pc_offset = static_cast<int>(
601  sample.pc - code->instruction_start());
602  for (int i = 0; i < ranges->length(); i++) {
603  OffsetRange& range = ranges->at(i);
604  if (range.from <= pc_offset && pc_offset < range.to) {
605  return;
606  }
607  }
608  }
609  *entry++ = pc_entry;
610 
611  if (pc_entry->builtin_id() == Builtins::kFunctionCall ||
612  pc_entry->builtin_id() == Builtins::kFunctionApply) {
613  // When current function is FunctionCall or FunctionApply builtin the
614  // top frame is either frame of the calling JS function or internal
615  // frame. In the latter case we know the caller for sure but in the
616  // former case we don't so we simply replace the frame with
617  // 'unresolved' entry.
618  if (sample.top_frame_type == StackFrame::JAVA_SCRIPT) {
619  *entry++ = unresolved_entry_;
620  }
621  }
622  }
623  }
624 
625  for (const Address* stack_pos = sample.stack,
626  *stack_end = stack_pos + sample.frames_count;
627  stack_pos != stack_end;
628  ++stack_pos) {
629  *entry++ = code_map_.FindEntry(*stack_pos);
630  }
631  }
632 
633  if (FLAG_prof_browser_mode) {
634  bool no_symbolized_entries = true;
635  for (CodeEntry** e = entries.start(); e != entry; ++e) {
636  if (*e != NULL) {
637  no_symbolized_entries = false;
638  break;
639  }
640  }
641  // If no frames were symbolized, put the VM state entry in.
642  if (no_symbolized_entries) {
643  *entry++ = EntryForVMState(sample.state);
644  }
645  }
646 
647  profiles_->AddPathToCurrentProfiles(sample.timestamp, entries);
648 }
List< OffsetRange > * no_frame_ranges() const
CodeEntry * FindEntry(Address addr, Address *start=NULL)
void AddPathToCurrentProfiles(base::TimeTicks timestamp, const Vector< CodeEntry * > &path)
static HeapObject * FromAddress(Address address)
Definition: objects-inl.h:1464
CodeEntry * EntryForVMState(StateTag tag)
byte * Address
Definition: globals.h:101

References v8::internal::CpuProfilesCollection::AddPathToCurrentProfiles(), v8::internal::List< T, AllocationPolicy >::at(), v8::internal::CodeEntry::builtin_id(), code_map_, EntryForVMState(), v8::internal::EXTERNAL, v8::internal::TickSample::external_callback, v8::internal::CodeMap::FindEntry(), v8::internal::TickSample::frames_count, v8::internal::OffsetRange::from, v8::internal::HeapObject::FromAddress(), v8::internal::TickSample::has_external_callback, v8::internal::Code::instruction_start(), v8::internal::Vector< T >::length(), v8::internal::CodeEntry::no_frame_ranges(), NULL, v8::internal::TickSample::pc, profiles_, v8::internal::TickSample::stack, v8::internal::Vector< T >::start(), v8::internal::TickSample::state, v8::internal::TickSample::timestamp, v8::internal::OffsetRange::to, v8::internal::TickSample::top_frame_type, and unresolved_entry_.

Referenced by v8::internal::ProfilerEventsProcessor::ProcessOneSample().

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

Member Data Documentation

◆ code_map_

CodeMap v8::internal::ProfileGenerator::code_map_
private

Definition at line 326 of file profile-generator.h.

Referenced by code_map(), and RecordTickSample().

◆ gc_entry_

CodeEntry* v8::internal::ProfileGenerator::gc_entry_
private

Definition at line 329 of file profile-generator.h.

Referenced by EntryForVMState().

◆ idle_entry_

CodeEntry* v8::internal::ProfileGenerator::idle_entry_
private

Definition at line 328 of file profile-generator.h.

Referenced by EntryForVMState().

◆ kGarbageCollectorEntryName

const char *const v8::internal::ProfileGenerator::kGarbageCollectorEntryName
static
Initial value:
=
"(garbage collector)"

Definition at line 317 of file profile-generator.h.

◆ kIdleEntryName

const char *const v8::internal::ProfileGenerator::kIdleEntryName
static
Initial value:
=
"(idle)"

Definition at line 316 of file profile-generator.h.

◆ kProgramEntryName

const char *const v8::internal::ProfileGenerator::kProgramEntryName
static
Initial value:
=
"(program)"

Definition at line 315 of file profile-generator.h.

◆ kUnresolvedFunctionName

const char *const v8::internal::ProfileGenerator::kUnresolvedFunctionName
static
Initial value:
=
"(unresolved function)"

Definition at line 320 of file profile-generator.h.

◆ profiles_

CpuProfilesCollection* v8::internal::ProfileGenerator::profiles_
private

Definition at line 325 of file profile-generator.h.

Referenced by RecordTickSample().

◆ program_entry_

CodeEntry* v8::internal::ProfileGenerator::program_entry_
private

Definition at line 327 of file profile-generator.h.

Referenced by EntryForVMState().

◆ unresolved_entry_

CodeEntry* v8::internal::ProfileGenerator::unresolved_entry_
private

Definition at line 330 of file profile-generator.h.

Referenced by RecordTickSample().


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