V8 Project
basic-block-profiler.cc
Go to the documentation of this file.
1 // Copyright 2014 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
6 
7 namespace v8 {
8 namespace internal {
9 
11  : n_blocks_(n_blocks), block_ids_(n_blocks_, -1), counts_(n_blocks_, 0) {}
12 
13 
15 
16 
17 static void InsertIntoString(OStringStream* os, std::string* string) {
18  string->insert(string->begin(), os->c_str(), &os->c_str()[os->size()]);
19 }
20 
21 
23  InsertIntoString(os, &code_);
24 }
25 
26 
28  InsertIntoString(os, &function_name_);
29 }
30 
31 
33  InsertIntoString(os, &schedule_);
34 }
35 
36 
37 void BasicBlockProfiler::Data::SetBlockId(size_t offset, int block_id) {
38  DCHECK(offset < n_blocks_);
39  block_ids_[offset] = block_id;
40 }
41 
42 
44  DCHECK(offset < n_blocks_);
45  return &counts_[offset];
46 }
47 
48 
50  for (size_t i = 0; i < n_blocks_; ++i) {
51  counts_[i] = 0;
52  }
53 }
54 
55 
57 
58 
60  Data* data = new Data(n_blocks);
61  data_list_.push_back(data);
62  return data;
63 }
64 
65 
67  for (DataList::iterator i = data_list_.begin(); i != data_list_.end(); ++i) {
68  delete (*i);
69  }
70 }
71 
72 
74  for (DataList::iterator i = data_list_.begin(); i != data_list_.end(); ++i) {
75  (*i)->ResetCounts();
76  }
77 }
78 
79 
81  os << "---- Start Profiling Data ----" << endl;
82  typedef BasicBlockProfiler::DataList::const_iterator iterator;
83  for (iterator i = p.data_list_.begin(); i != p.data_list_.end(); ++i) {
84  os << **i;
85  }
86  os << "---- End Profiling Data ----" << endl;
87  return os;
88 }
89 
90 
92  const char* name = "unknown function";
93  if (!d.function_name_.empty()) {
94  name = d.function_name_.c_str();
95  }
96  if (!d.schedule_.empty()) {
97  os << "schedule for " << name << endl;
98  os << d.schedule_.c_str() << endl;
99  }
100  os << "block counts for " << name << ":" << endl;
101  for (size_t i = 0; i < d.n_blocks_; ++i) {
102  os << "block " << d.block_ids_[i] << " : " << d.counts_[i] << endl;
103  }
104  os << endl;
105  if (!d.code_.empty()) {
106  os << d.code_.c_str() << endl;
107  }
108  return os;
109 }
110 
111 } // namespace internal
112 } // namespace v8
void SetBlockId(size_t offset, int block_id)
friend OStream & operator<<(OStream &os, const BasicBlockProfiler &s)
const char * c_str() const
Definition: ostreams.h:84
size_t size() const
Definition: ostreams.h:79
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
#define DCHECK(condition)
Definition: logging.h:205
OStream & endl(OStream &os)
Definition: ostreams.cc:112
static void InsertIntoString(OStringStream *os, std::string *string)
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20