V8 Project
v8::internal::Instrument Class Reference

#include <instrument-arm64.h>

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

Public Member Functions

 Instrument (const char *datafile=NULL, uint64_t sample_period=kDefaultInstrumentationSamplingPeriod)
 
 ~Instrument ()
 
- Public Member Functions inherited from v8::internal::DecoderVisitor
virtual ~DecoderVisitor ()
 

Private Member Functions

void Update ()
 
void Enable ()
 
void Disable ()
 
void DumpCounters ()
 
void DumpCounterNames ()
 
void DumpEventMarker (unsigned marker)
 
void HandleInstrumentationEvent (unsigned event)
 
CounterGetCounter (const char *name)
 
void InstrumentLoadStore (Instruction *instr)
 
void InstrumentLoadStorePair (Instruction *instr)
 

Private Attributes

std::list< Counter * > counters_
 
FILE * output_stream_
 
uint64_t sample_period_
 

Detailed Description

Definition at line 53 of file instrument-arm64.h.

Constructor & Destructor Documentation

◆ Instrument()

v8::internal::Instrument::Instrument ( const char *  datafile = NULL,
uint64_t  sample_period = kDefaultInstrumentationSamplingPeriod 
)
explicit

Definition at line 97 of file instrument-arm64.cc.

98  : output_stream_(stderr), sample_period_(sample_period) {
99 
100  // Set up the output stream. If datafile is non-NULL, use that file. If it
101  // can't be opened, or datafile is NULL, use stderr.
102  if (datafile != NULL) {
103  output_stream_ = fopen(datafile, "w");
104  if (output_stream_ == NULL) {
105  fprintf(stderr, "Can't open output file %s. Using stderr.\n", datafile);
106  output_stream_ = stderr;
107  }
108  }
109 
110  static const int num_counters = arraysize(kCounterList);
111 
112  // Dump an instrumentation description comment at the top of the file.
113  fprintf(output_stream_, "# counters=%d\n", num_counters);
114  fprintf(output_stream_, "# sample_period=%" PRIu64 "\n", sample_period_);
115 
116  // Construct Counter objects from counter description array.
117  for (int i = 0; i < num_counters; i++) {
118  Counter* counter = new Counter(kCounterList[i].name, kCounterList[i].type);
119  counters_.push_back(counter);
120  }
121 
123 }
std::list< Counter * > counters_
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 expose gc extension under the specified name show built in functions in stack traces use random jit cookie to mask large constants minimum length for automatic enable preparsing CPU profiler sampling interval in microseconds trace out of bounds accesses to external arrays default size of stack region v8 is allowed to maximum length of function source code printed in a stack trace min size of a semi the new space consists of two semi spaces print one trace line following each garbage collection do not print trace line after scavenger collection print cumulative GC statistics in name
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
#define arraysize(array)
Definition: macros.h:86
static const CounterDescriptor kCounterList[]

References arraysize, counters_, DumpCounterNames(), v8::internal::kCounterList, name, NULL, output_stream_, and sample_period_.

+ Here is the call graph for this function:

◆ ~Instrument()

v8::internal::Instrument::~Instrument ( )

Definition at line 126 of file instrument-arm64.cc.

126  {
127  // Dump any remaining instruction data to the output file.
128  DumpCounters();
129 
130  // Free all the counter objects.
131  std::list<Counter*>::iterator it;
132  for (it = counters_.begin(); it != counters_.end(); it++) {
133  delete *it;
134  }
135 
136  if (output_stream_ != stderr) {
137  fclose(output_stream_);
138  }
139 }

References counters_, DumpCounters(), and output_stream_.

+ Here is the call graph for this function:

Member Function Documentation

◆ Disable()

void v8::internal::Instrument::Disable ( )
private

Definition at line 225 of file instrument-arm64.cc.

225  {
226  std::list<Counter*>::iterator it;
227  for (it = counters_.begin(); it != counters_.end(); it++) {
228  (*it)->Disable();
229  }
230 }

References counters_.

Referenced by HandleInstrumentationEvent().

+ Here is the caller graph for this function:

◆ DumpCounterNames()

void v8::internal::Instrument::DumpCounterNames ( )
private

Definition at line 167 of file instrument-arm64.cc.

167  {
168  // Iterate through the counter objects, dumping the counter names to the
169  // output stream.
170  std::list<Counter*>::const_iterator it;
171  for (it = counters_.begin(); it != counters_.end(); it++) {
172  fprintf(output_stream_, "%s,", (*it)->name());
173  }
174  fprintf(output_stream_, "\n");
175  fflush(output_stream_);
176 }

References counters_, and output_stream_.

Referenced by Instrument().

+ Here is the caller graph for this function:

◆ DumpCounters()

void v8::internal::Instrument::DumpCounters ( )
private

Definition at line 155 of file instrument-arm64.cc.

155  {
156  // Iterate through the counter objects, dumping their values to the output
157  // stream.
158  std::list<Counter*>::const_iterator it;
159  for (it = counters_.begin(); it != counters_.end(); it++) {
160  fprintf(output_stream_, "%" PRIu64 ",", (*it)->count());
161  }
162  fprintf(output_stream_, "\n");
163  fflush(output_stream_);
164 }

References counters_, and output_stream_.

Referenced by Update(), and ~Instrument().

+ Here is the caller graph for this function:

◆ DumpEventMarker()

void v8::internal::Instrument::DumpEventMarker ( unsigned  marker)
private

Definition at line 188 of file instrument-arm64.cc.

188  {
189  // Dumpan event marker to the output stream as a specially formatted comment
190  // line.
191  static Counter* counter = GetCounter("Instruction");
192 
193  fprintf(output_stream_, "# %c%c @ %" PRId64 "\n", marker & 0xff,
194  (marker >> 8) & 0xff, counter->count());
195 }
Counter * GetCounter(const char *name)

References v8::internal::Counter::count(), GetCounter(), and output_stream_.

Referenced by HandleInstrumentationEvent().

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

◆ Enable()

void v8::internal::Instrument::Enable ( )
private

Definition at line 217 of file instrument-arm64.cc.

217  {
218  std::list<Counter*>::iterator it;
219  for (it = counters_.begin(); it != counters_.end(); it++) {
220  (*it)->Enable();
221  }
222 }

References counters_.

Referenced by HandleInstrumentationEvent().

+ Here is the caller graph for this function:

◆ GetCounter()

Counter * v8::internal::Instrument::GetCounter ( const char *  name)
private

Definition at line 198 of file instrument-arm64.cc.

198  {
199  // Get a Counter object by name from the counter list.
200  std::list<Counter*>::const_iterator it;
201  for (it = counters_.begin(); it != counters_.end(); it++) {
202  if (strcmp((*it)->name(), name) == 0) {
203  return *it;
204  }
205  }
206 
207  // A Counter by that name does not exist: print an error message to stderr
208  // and the output file, and exit.
209  static const char* error_message =
210  "# Error: Unknown counter \"%s\". Exiting.\n";
211  fprintf(stderr, error_message, name);
212  fprintf(output_stream_, error_message, name);
213  exit(1);
214 }

References counters_, name, and output_stream_.

Referenced by DumpEventMarker(), InstrumentLoadStore(), InstrumentLoadStorePair(), and Update().

+ Here is the caller graph for this function:

◆ HandleInstrumentationEvent()

void v8::internal::Instrument::HandleInstrumentationEvent ( unsigned  event)
private

Definition at line 179 of file instrument-arm64.cc.

179  {
180  switch (event) {
181  case InstrumentStateEnable: Enable(); break;
182  case InstrumentStateDisable: Disable(); break;
183  default: DumpEventMarker(event);
184  }
185 }
void DumpEventMarker(unsigned marker)

References Disable(), DumpEventMarker(), Enable(), v8::internal::InstrumentStateDisable, and v8::internal::InstrumentStateEnable.

+ Here is the call graph for this function:

◆ InstrumentLoadStore()

void v8::internal::Instrument::InstrumentLoadStore ( Instruction instr)
private

Definition at line 380 of file instrument-arm64.cc.

380  {
381  static Counter* load_int_counter = GetCounter("Load Integer");
382  static Counter* store_int_counter = GetCounter("Store Integer");
383  static Counter* load_fp_counter = GetCounter("Load FP");
384  static Counter* store_fp_counter = GetCounter("Store FP");
385 
386  switch (instr->Mask(LoadStoreOpMask)) {
387  case STRB_w: // Fall through.
388  case STRH_w: // Fall through.
389  case STR_w: // Fall through.
390  case STR_x: store_int_counter->Increment(); break;
391  case STR_s: // Fall through.
392  case STR_d: store_fp_counter->Increment(); break;
393  case LDRB_w: // Fall through.
394  case LDRH_w: // Fall through.
395  case LDR_w: // Fall through.
396  case LDR_x: // Fall through.
397  case LDRSB_x: // Fall through.
398  case LDRSH_x: // Fall through.
399  case LDRSW_x: // Fall through.
400  case LDRSB_w: // Fall through.
401  case LDRSH_w: load_int_counter->Increment(); break;
402  case LDR_s: // Fall through.
403  case LDR_d: load_fp_counter->Increment(); break;
404  default: UNREACHABLE();
405  }
406 }
#define UNREACHABLE()
Definition: logging.h:30

References GetCounter(), v8::internal::Counter::Increment(), v8::internal::LoadStoreOpMask, v8::internal::Instruction::Mask(), and UNREACHABLE.

+ Here is the call graph for this function:

◆ InstrumentLoadStorePair()

void v8::internal::Instrument::InstrumentLoadStorePair ( Instruction instr)
private

Definition at line 338 of file instrument-arm64.cc.

338  {
339  static Counter* load_pair_counter = GetCounter("Load Pair");
340  static Counter* store_pair_counter = GetCounter("Store Pair");
341  if (instr->Mask(LoadStorePairLBit) != 0) {
342  load_pair_counter->Increment();
343  } else {
344  store_pair_counter->Increment();
345  }
346 }

References GetCounter(), v8::internal::Counter::Increment(), v8::internal::LoadStorePairLBit, and v8::internal::Instruction::Mask().

+ Here is the call graph for this function:

◆ Update()

void v8::internal::Instrument::Update ( )
private

Definition at line 142 of file instrument-arm64.cc.

142  {
143  // Increment the instruction counter, and dump all counters if a sample period
144  // has elapsed.
145  static Counter* counter = GetCounter("Instruction");
146  DCHECK(counter->type() == Cumulative);
147  counter->Increment();
148 
149  if (counter->IsEnabled() && (counter->count() % sample_period_) == 0) {
150  DumpCounters();
151  }
152 }
#define DCHECK(condition)
Definition: logging.h:205

References v8::internal::Counter::count(), v8::internal::Cumulative, DCHECK, DumpCounters(), GetCounter(), v8::internal::Counter::Increment(), v8::internal::Counter::IsEnabled(), sample_period_, and v8::internal::Counter::type().

+ Here is the call graph for this function:

Member Data Documentation

◆ counters_

std::list<Counter*> v8::internal::Instrument::counters_
private

◆ output_stream_

FILE* v8::internal::Instrument::output_stream_
private

◆ sample_period_

uint64_t v8::internal::Instrument::sample_period_
private

Definition at line 80 of file instrument-arm64.h.

Referenced by Instrument(), and Update().


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