V8 Project
counters.cc
Go to the documentation of this file.
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
3 // found in the LICENSE file.
4 
5 #include "src/v8.h"
6 
8 #include "src/counters.h"
9 #include "src/isolate.h"
10 
11 namespace v8 {
12 namespace internal {
13 
15  : lookup_function_(NULL),
16  create_histogram_function_(NULL),
17  add_histogram_sample_function_(NULL) {}
18 
19 
22 }
23 
24 
25 void Histogram::AddSample(int sample) {
26  if (Enabled()) {
28  }
29 }
30 
32  return isolate()->stats_table()->
34 }
35 
36 
37 // Start the timer.
39  if (Enabled()) {
40  timer_.Start();
41  }
42  isolate()->event_logger()(name(), Logger::START);
43 }
44 
45 
46 // Stop the timer and record the results.
48  if (Enabled()) {
49  // Compute the delta between start and stop, in milliseconds.
50  AddSample(static_cast<int>(timer_.Elapsed().InMilliseconds()));
51  timer_.Stop();
52  }
53  isolate()->event_logger()(name(), Logger::END);
54 }
55 
56 
58 #define HR(name, caption, min, max, num_buckets) \
59  name##_ = Histogram(#caption, min, max, num_buckets, isolate);
61 #undef HR
62 
63 #define HT(name, caption) \
64  name##_ = HistogramTimer(#caption, 0, 10000, 50, isolate);
66 #undef HT
67 
68 #define HP(name, caption) \
69  name##_ = Histogram(#caption, 0, 101, 100, isolate);
71 #undef HP
72 
73 #define HM(name, caption) \
74  name##_ = Histogram(#caption, 1000, 500000, 50, isolate);
76 #undef HM
77 
78 #define SC(name, caption) \
79  name##_ = StatsCounter(isolate, "c:" #caption);
80 
83 #undef SC
84 
85 #define SC(name) \
86  count_of_##name##_ = StatsCounter(isolate, "c:" "V8.CountOf_" #name); \
87  size_of_##name##_ = StatsCounter(isolate, "c:" "V8.SizeOf_" #name);
89 #undef SC
90 
91 #define SC(name) \
92  count_of_CODE_TYPE_##name##_ = \
93  StatsCounter(isolate, "c:" "V8.CountOf_CODE_TYPE-" #name); \
94  size_of_CODE_TYPE_##name##_ = \
95  StatsCounter(isolate, "c:" "V8.SizeOf_CODE_TYPE-" #name);
97 #undef SC
98 
99 #define SC(name) \
100  count_of_FIXED_ARRAY_##name##_ = \
101  StatsCounter(isolate, "c:" "V8.CountOf_FIXED_ARRAY-" #name); \
102  size_of_FIXED_ARRAY_##name##_ = \
103  StatsCounter(isolate, "c:" "V8.SizeOf_FIXED_ARRAY-" #name);
105 #undef SC
106 
107 #define SC(name) \
108  count_of_CODE_AGE_##name##_ = \
109  StatsCounter(isolate, "c:" "V8.CountOf_CODE_AGE-" #name); \
110  size_of_CODE_AGE_##name##_ = \
111  StatsCounter(isolate, "c:" "V8.SizeOf_CODE_AGE-" #name);
113 #undef SC
114 }
115 
116 
118 #define SC(name, caption) name##_.Reset();
121 #undef SC
122 
123 #define SC(name) \
124  count_of_##name##_.Reset(); \
125  size_of_##name##_.Reset();
127 #undef SC
128 
129 #define SC(name) \
130  count_of_CODE_TYPE_##name##_.Reset(); \
131  size_of_CODE_TYPE_##name##_.Reset();
133 #undef SC
134 
135 #define SC(name) \
136  count_of_FIXED_ARRAY_##name##_.Reset(); \
137  size_of_FIXED_ARRAY_##name##_.Reset();
139 #undef SC
140 
141 #define SC(name) \
142  count_of_CODE_AGE_##name##_.Reset(); \
143  size_of_CODE_AGE_##name##_.Reset();
145 #undef SC
146 }
147 
148 
150 #define HR(name, caption, min, max, num_buckets) name##_.Reset();
152 #undef HR
153 
154 #define HT(name, caption) name##_.Reset();
156 #undef HT
157 
158 #define HP(name, caption) name##_.Reset();
160 #undef HP
161 
162 #define HM(name, caption) name##_.Reset();
164 #undef HM
165 }
166 
167 } } // namespace v8::internal
#define CODE_AGE_LIST_COMPLETE(V)
Definition: builtins.h:30
Counters(Isolate *isolate)
Definition: counters.cc:57
base::ElapsedTimer timer_
Definition: counters.h:251
void * CreateHistogram() const
Definition: counters.cc:31
void AddSample(int sample)
Definition: counters.cc:25
const char * name()
Definition: counters.h:208
Isolate * isolate() const
Definition: counters.h:209
const char * name_
Definition: counters.h:214
StatsTable * stats_table()
Definition: isolate.cc:2039
int * FindLocationInStatsTable() const
Definition: counters.cc:20
void AddHistogramSample(void *histogram, int sample)
Definition: counters.h:71
int * FindLocation(const char *name)
Definition: counters.h:51
#define HT(name, caption)
#define HR(name, caption, min, max, num_buckets)
#define HP(name, caption)
#define HM(name, caption)
#define SC(name, caption)
#define STATS_COUNTER_LIST_1(SC)
Definition: counters.h:380
#define HISTOGRAM_TIMER_LIST(HT)
Definition: counters.h:300
#define HISTOGRAM_PERCENTAGE_LIST(HP)
Definition: counters.h:320
#define HISTOGRAM_MEMORY_LIST(HM)
Definition: counters.h:360
#define HISTOGRAM_RANGE_LIST(HR)
Definition: counters.h:294
#define STATS_COUNTER_LIST_2(SC)
Definition: counters.h:433
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
Debugger support for the V8 JavaScript engine.
Definition: accessors.cc:20
#define INSTANCE_TYPE_LIST(V)
Definition: objects.h:339
#define CODE_KIND_LIST(V)
Definition: objects.h:4950
#define FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(V)
Definition: objects.h:800