v8  3.25.30(node0.11.13)
V8 is Google's open source JavaScript engine
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
v8-counters.h
Go to the documentation of this file.
1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are
4 // met:
5 //
6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided
11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission.
15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 
28 #ifndef V8_V8_COUNTERS_H_
29 #define V8_V8_COUNTERS_H_
30 
31 #include "allocation.h"
32 #include "counters.h"
33 #include "objects.h"
34 #include "v8globals.h"
35 
36 namespace v8 {
37 namespace internal {
38 
39 #define HISTOGRAM_TIMER_LIST(HT) \
40  /* Garbage collection timers. */ \
41  HT(gc_compactor, V8.GCCompactor) \
42  HT(gc_scavenger, V8.GCScavenger) \
43  HT(gc_context, V8.GCContext) /* GC context cleanup time */ \
44  /* Parsing timers. */ \
45  HT(parse, V8.Parse) \
46  HT(parse_lazy, V8.ParseLazy) \
47  HT(pre_parse, V8.PreParse) \
48  /* Total compilation times. */ \
49  HT(compile, V8.Compile) \
50  HT(compile_eval, V8.CompileEval) \
51  HT(compile_lazy, V8.CompileLazy)
52 
53 #define HISTOGRAM_PERCENTAGE_LIST(HP) \
54  /* Heap fragmentation. */ \
55  HP(external_fragmentation_total, \
56  V8.MemoryExternalFragmentationTotal) \
57  HP(external_fragmentation_old_pointer_space, \
58  V8.MemoryExternalFragmentationOldPointerSpace) \
59  HP(external_fragmentation_old_data_space, \
60  V8.MemoryExternalFragmentationOldDataSpace) \
61  HP(external_fragmentation_code_space, \
62  V8.MemoryExternalFragmentationCodeSpace) \
63  HP(external_fragmentation_map_space, \
64  V8.MemoryExternalFragmentationMapSpace) \
65  HP(external_fragmentation_cell_space, \
66  V8.MemoryExternalFragmentationCellSpace) \
67  HP(external_fragmentation_property_cell_space, \
68  V8.MemoryExternalFragmentationPropertyCellSpace) \
69  HP(external_fragmentation_lo_space, \
70  V8.MemoryExternalFragmentationLoSpace) \
71  /* Percentages of heap committed to each space. */ \
72  HP(heap_fraction_new_space, \
73  V8.MemoryHeapFractionNewSpace) \
74  HP(heap_fraction_old_pointer_space, \
75  V8.MemoryHeapFractionOldPointerSpace) \
76  HP(heap_fraction_old_data_space, \
77  V8.MemoryHeapFractionOldDataSpace) \
78  HP(heap_fraction_code_space, \
79  V8.MemoryHeapFractionCodeSpace) \
80  HP(heap_fraction_map_space, \
81  V8.MemoryHeapFractionMapSpace) \
82  HP(heap_fraction_cell_space, \
83  V8.MemoryHeapFractionCellSpace) \
84  HP(heap_fraction_property_cell_space, \
85  V8.MemoryHeapFractionPropertyCellSpace) \
86  HP(heap_fraction_lo_space, \
87  V8.MemoryHeapFractionLoSpace) \
88  /* Percentage of crankshafted codegen. */ \
89  HP(codegen_fraction_crankshaft, \
90  V8.CodegenFractionCrankshaft) \
91 
92 
93 #define HISTOGRAM_MEMORY_LIST(HM) \
94  HM(heap_sample_total_committed, V8.MemoryHeapSampleTotalCommitted) \
95  HM(heap_sample_total_used, V8.MemoryHeapSampleTotalUsed) \
96  HM(heap_sample_map_space_committed, \
97  V8.MemoryHeapSampleMapSpaceCommitted) \
98  HM(heap_sample_cell_space_committed, \
99  V8.MemoryHeapSampleCellSpaceCommitted) \
100  HM(heap_sample_property_cell_space_committed, \
101  V8.MemoryHeapSamplePropertyCellSpaceCommitted) \
102  HM(heap_sample_code_space_committed, \
103  V8.MemoryHeapSampleCodeSpaceCommitted) \
104  HM(heap_sample_maximum_committed, \
105  V8.MemoryHeapSampleMaximumCommitted) \
106 
107 
108 // WARNING: STATS_COUNTER_LIST_* is a very large macro that is causing MSVC
109 // Intellisense to crash. It was broken into two macros (each of length 40
110 // lines) rather than one macro (of length about 80 lines) to work around
111 // this problem. Please avoid using recursive macros of this length when
112 // possible.
113 #define STATS_COUNTER_LIST_1(SC) \
114  /* Global Handle Count*/ \
115  SC(global_handles, V8.GlobalHandles) \
116  /* OS Memory allocated */ \
117  SC(memory_allocated, V8.OsMemoryAllocated) \
118  SC(normalized_maps, V8.NormalizedMaps) \
119  SC(props_to_dictionary, V8.ObjectPropertiesToDictionary) \
120  SC(elements_to_dictionary, V8.ObjectElementsToDictionary) \
121  SC(alive_after_last_gc, V8.AliveAfterLastGC) \
122  SC(objs_since_last_young, V8.ObjsSinceLastYoung) \
123  SC(objs_since_last_full, V8.ObjsSinceLastFull) \
124  SC(string_table_capacity, V8.StringTableCapacity) \
125  SC(number_of_symbols, V8.NumberOfSymbols) \
126  SC(script_wrappers, V8.ScriptWrappers) \
127  SC(call_initialize_stubs, V8.CallInitializeStubs) \
128  SC(call_premonomorphic_stubs, V8.CallPreMonomorphicStubs) \
129  SC(call_normal_stubs, V8.CallNormalStubs) \
130  SC(call_megamorphic_stubs, V8.CallMegamorphicStubs) \
131  SC(arguments_adaptors, V8.ArgumentsAdaptors) \
132  SC(compilation_cache_hits, V8.CompilationCacheHits) \
133  SC(compilation_cache_misses, V8.CompilationCacheMisses) \
134  SC(string_ctor_calls, V8.StringConstructorCalls) \
135  SC(string_ctor_conversions, V8.StringConstructorConversions) \
136  SC(string_ctor_cached_number, V8.StringConstructorCachedNumber) \
137  SC(string_ctor_string_value, V8.StringConstructorStringValue) \
138  SC(string_ctor_gc_required, V8.StringConstructorGCRequired) \
139  /* Amount of evaled source code. */ \
140  SC(total_eval_size, V8.TotalEvalSize) \
141  /* Amount of loaded source code. */ \
142  SC(total_load_size, V8.TotalLoadSize) \
143  /* Amount of parsed source code. */ \
144  SC(total_parse_size, V8.TotalParseSize) \
145  /* Amount of source code skipped over using preparsing. */ \
146  SC(total_preparse_skipped, V8.TotalPreparseSkipped) \
147  /* Number of symbol lookups skipped using preparsing */ \
148  SC(total_preparse_symbols_skipped, V8.TotalPreparseSymbolSkipped) \
149  /* Amount of compiled source code. */ \
150  SC(total_compile_size, V8.TotalCompileSize) \
151  /* Amount of source code compiled with the full codegen. */ \
152  SC(total_full_codegen_source_size, V8.TotalFullCodegenSourceSize) \
153  /* Number of contexts created from scratch. */ \
154  SC(contexts_created_from_scratch, V8.ContextsCreatedFromScratch) \
155  /* Number of contexts created by partial snapshot. */ \
156  SC(contexts_created_by_snapshot, V8.ContextsCreatedBySnapshot) \
157  /* Number of code objects found from pc. */ \
158  SC(pc_to_code, V8.PcToCode) \
159  SC(pc_to_code_cached, V8.PcToCodeCached) \
160  /* The store-buffer implementation of the write barrier. */ \
161  SC(store_buffer_compactions, V8.StoreBufferCompactions) \
162  SC(store_buffer_overflows, V8.StoreBufferOverflows)
163 
164 
165 #define STATS_COUNTER_LIST_2(SC) \
166  /* Number of code stubs. */ \
167  SC(code_stubs, V8.CodeStubs) \
168  /* Amount of stub code. */ \
169  SC(total_stubs_code_size, V8.TotalStubsCodeSize) \
170  /* Amount of (JS) compiled code. */ \
171  SC(total_compiled_code_size, V8.TotalCompiledCodeSize) \
172  SC(gc_compactor_caused_by_request, V8.GCCompactorCausedByRequest) \
173  SC(gc_compactor_caused_by_promoted_data, \
174  V8.GCCompactorCausedByPromotedData) \
175  SC(gc_compactor_caused_by_oldspace_exhaustion, \
176  V8.GCCompactorCausedByOldspaceExhaustion) \
177  SC(gc_last_resort_from_js, V8.GCLastResortFromJS) \
178  SC(gc_last_resort_from_handles, V8.GCLastResortFromHandles) \
179  /* How is the generic keyed-load stub used? */ \
180  SC(keyed_load_generic_smi, V8.KeyedLoadGenericSmi) \
181  SC(keyed_load_generic_symbol, V8.KeyedLoadGenericSymbol) \
182  SC(keyed_load_generic_lookup_cache, V8.KeyedLoadGenericLookupCache) \
183  SC(keyed_load_generic_slow, V8.KeyedLoadGenericSlow) \
184  SC(keyed_load_polymorphic_stubs, V8.KeyedLoadPolymorphicStubs) \
185  SC(keyed_load_external_array_slow, V8.KeyedLoadExternalArraySlow) \
186  /* How is the generic keyed-call stub used? */ \
187  SC(keyed_call_generic_smi_fast, V8.KeyedCallGenericSmiFast) \
188  SC(keyed_call_generic_smi_dict, V8.KeyedCallGenericSmiDict) \
189  SC(keyed_call_generic_lookup_cache, V8.KeyedCallGenericLookupCache) \
190  SC(keyed_call_generic_lookup_dict, V8.KeyedCallGenericLookupDict) \
191  SC(keyed_call_generic_slow, V8.KeyedCallGenericSlow) \
192  SC(keyed_call_generic_slow_load, V8.KeyedCallGenericSlowLoad) \
193  SC(named_load_global_stub, V8.NamedLoadGlobalStub) \
194  SC(named_store_global_inline, V8.NamedStoreGlobalInline) \
195  SC(named_store_global_inline_miss, V8.NamedStoreGlobalInlineMiss) \
196  SC(keyed_store_polymorphic_stubs, V8.KeyedStorePolymorphicStubs) \
197  SC(keyed_store_external_array_slow, V8.KeyedStoreExternalArraySlow) \
198  SC(store_normal_miss, V8.StoreNormalMiss) \
199  SC(store_normal_hit, V8.StoreNormalHit) \
200  SC(cow_arrays_created_stub, V8.COWArraysCreatedStub) \
201  SC(cow_arrays_created_runtime, V8.COWArraysCreatedRuntime) \
202  SC(cow_arrays_converted, V8.COWArraysConverted) \
203  SC(call_miss, V8.CallMiss) \
204  SC(keyed_call_miss, V8.KeyedCallMiss) \
205  SC(load_miss, V8.LoadMiss) \
206  SC(keyed_load_miss, V8.KeyedLoadMiss) \
207  SC(call_const, V8.CallConst) \
208  SC(call_const_fast_api, V8.CallConstFastApi) \
209  SC(call_const_interceptor, V8.CallConstInterceptor) \
210  SC(call_const_interceptor_fast_api, V8.CallConstInterceptorFastApi) \
211  SC(call_global_inline, V8.CallGlobalInline) \
212  SC(call_global_inline_miss, V8.CallGlobalInlineMiss) \
213  SC(constructed_objects, V8.ConstructedObjects) \
214  SC(constructed_objects_runtime, V8.ConstructedObjectsRuntime) \
215  SC(negative_lookups, V8.NegativeLookups) \
216  SC(negative_lookups_miss, V8.NegativeLookupsMiss) \
217  SC(megamorphic_stub_cache_probes, V8.MegamorphicStubCacheProbes) \
218  SC(megamorphic_stub_cache_misses, V8.MegamorphicStubCacheMisses) \
219  SC(megamorphic_stub_cache_updates, V8.MegamorphicStubCacheUpdates) \
220  SC(array_function_runtime, V8.ArrayFunctionRuntime) \
221  SC(array_function_native, V8.ArrayFunctionNative) \
222  SC(for_in, V8.ForIn) \
223  SC(enum_cache_hits, V8.EnumCacheHits) \
224  SC(enum_cache_misses, V8.EnumCacheMisses) \
225  SC(zone_segment_bytes, V8.ZoneSegmentBytes) \
226  SC(fast_new_closure_total, V8.FastNewClosureTotal) \
227  SC(fast_new_closure_try_optimized, V8.FastNewClosureTryOptimized) \
228  SC(fast_new_closure_install_optimized, V8.FastNewClosureInstallOptimized) \
229  SC(string_add_runtime, V8.StringAddRuntime) \
230  SC(string_add_native, V8.StringAddNative) \
231  SC(string_add_runtime_ext_to_ascii, V8.StringAddRuntimeExtToAscii) \
232  SC(sub_string_runtime, V8.SubStringRuntime) \
233  SC(sub_string_native, V8.SubStringNative) \
234  SC(string_add_make_two_char, V8.StringAddMakeTwoChar) \
235  SC(string_compare_native, V8.StringCompareNative) \
236  SC(string_compare_runtime, V8.StringCompareRuntime) \
237  SC(regexp_entry_runtime, V8.RegExpEntryRuntime) \
238  SC(regexp_entry_native, V8.RegExpEntryNative) \
239  SC(number_to_string_native, V8.NumberToStringNative) \
240  SC(number_to_string_runtime, V8.NumberToStringRuntime) \
241  SC(math_acos, V8.MathAcos) \
242  SC(math_asin, V8.MathAsin) \
243  SC(math_atan, V8.MathAtan) \
244  SC(math_atan2, V8.MathAtan2) \
245  SC(math_exp, V8.MathExp) \
246  SC(math_floor, V8.MathFloor) \
247  SC(math_log, V8.MathLog) \
248  SC(math_pow, V8.MathPow) \
249  SC(math_round, V8.MathRound) \
250  SC(math_sqrt, V8.MathSqrt) \
251  SC(stack_interrupts, V8.StackInterrupts) \
252  SC(runtime_profiler_ticks, V8.RuntimeProfilerTicks) \
253  SC(bounds_checks_eliminated, V8.BoundsChecksEliminated) \
254  SC(bounds_checks_hoisted, V8.BoundsChecksHoisted) \
255  SC(soft_deopts_requested, V8.SoftDeoptsRequested) \
256  SC(soft_deopts_inserted, V8.SoftDeoptsInserted) \
257  SC(soft_deopts_executed, V8.SoftDeoptsExecuted) \
258  /* Number of write barriers in generated code. */ \
259  SC(write_barriers_dynamic, V8.WriteBarriersDynamic) \
260  SC(write_barriers_static, V8.WriteBarriersStatic) \
261  SC(new_space_bytes_available, V8.MemoryNewSpaceBytesAvailable) \
262  SC(new_space_bytes_committed, V8.MemoryNewSpaceBytesCommitted) \
263  SC(new_space_bytes_used, V8.MemoryNewSpaceBytesUsed) \
264  SC(old_pointer_space_bytes_available, \
265  V8.MemoryOldPointerSpaceBytesAvailable) \
266  SC(old_pointer_space_bytes_committed, \
267  V8.MemoryOldPointerSpaceBytesCommitted) \
268  SC(old_pointer_space_bytes_used, V8.MemoryOldPointerSpaceBytesUsed) \
269  SC(old_data_space_bytes_available, V8.MemoryOldDataSpaceBytesAvailable) \
270  SC(old_data_space_bytes_committed, V8.MemoryOldDataSpaceBytesCommitted) \
271  SC(old_data_space_bytes_used, V8.MemoryOldDataSpaceBytesUsed) \
272  SC(code_space_bytes_available, V8.MemoryCodeSpaceBytesAvailable) \
273  SC(code_space_bytes_committed, V8.MemoryCodeSpaceBytesCommitted) \
274  SC(code_space_bytes_used, V8.MemoryCodeSpaceBytesUsed) \
275  SC(map_space_bytes_available, V8.MemoryMapSpaceBytesAvailable) \
276  SC(map_space_bytes_committed, V8.MemoryMapSpaceBytesCommitted) \
277  SC(map_space_bytes_used, V8.MemoryMapSpaceBytesUsed) \
278  SC(cell_space_bytes_available, V8.MemoryCellSpaceBytesAvailable) \
279  SC(cell_space_bytes_committed, V8.MemoryCellSpaceBytesCommitted) \
280  SC(cell_space_bytes_used, V8.MemoryCellSpaceBytesUsed) \
281  SC(property_cell_space_bytes_available, \
282  V8.MemoryPropertyCellSpaceBytesAvailable) \
283  SC(property_cell_space_bytes_committed, \
284  V8.MemoryPropertyCellSpaceBytesCommitted) \
285  SC(property_cell_space_bytes_used, \
286  V8.MemoryPropertyCellSpaceBytesUsed) \
287  SC(lo_space_bytes_available, V8.MemoryLoSpaceBytesAvailable) \
288  SC(lo_space_bytes_committed, V8.MemoryLoSpaceBytesCommitted) \
289  SC(lo_space_bytes_used, V8.MemoryLoSpaceBytesUsed)
290 
291 
292 // This file contains all the v8 counters that are in use.
293 class Counters {
294  public:
295 #define HT(name, caption) \
296  HistogramTimer* name() { return &name##_; }
298 #undef HT
299 
300 #define HP(name, caption) \
301  Histogram* name() { return &name##_; }
303 #undef HP
304 
305 #define HM(name, caption) \
306  Histogram* name() { return &name##_; }
308 #undef HM
309 
310 #define SC(name, caption) \
311  StatsCounter* name() { return &name##_; }
314 #undef SC
315 
316 #define SC(name) \
317  StatsCounter* count_of_##name() { return &count_of_##name##_; } \
318  StatsCounter* size_of_##name() { return &size_of_##name##_; }
320 #undef SC
321 
322 #define SC(name) \
323  StatsCounter* count_of_CODE_TYPE_##name() \
324  { return &count_of_CODE_TYPE_##name##_; } \
325  StatsCounter* size_of_CODE_TYPE_##name() \
326  { return &size_of_CODE_TYPE_##name##_; }
328 #undef SC
329 
330 #define SC(name) \
331  StatsCounter* count_of_FIXED_ARRAY_##name() \
332  { return &count_of_FIXED_ARRAY_##name##_; } \
333  StatsCounter* size_of_FIXED_ARRAY_##name() \
334  { return &size_of_FIXED_ARRAY_##name##_; }
336 #undef SC
337 
338 #define SC(name) \
339  StatsCounter* count_of_CODE_AGE_##name() \
340  { return &count_of_CODE_AGE_##name##_; } \
341  StatsCounter* size_of_CODE_AGE_##name() \
342  { return &size_of_CODE_AGE_##name##_; }
344 #undef SC
345 
346  enum Id {
347 #define RATE_ID(name, caption) k_##name,
349 #undef RATE_ID
350 #define PERCENTAGE_ID(name, caption) k_##name,
352 #undef PERCENTAGE_ID
353 #define MEMORY_ID(name, caption) k_##name,
355 #undef MEMORY_ID
356 #define COUNTER_ID(name, caption) k_##name,
359 #undef COUNTER_ID
360 #define COUNTER_ID(name) kCountOf##name, kSizeOf##name,
362 #undef COUNTER_ID
363 #define COUNTER_ID(name) kCountOfCODE_TYPE_##name, \
364  kSizeOfCODE_TYPE_##name,
366 #undef COUNTER_ID
367 #define COUNTER_ID(name) kCountOfFIXED_ARRAY__##name, \
368  kSizeOfFIXED_ARRAY__##name,
370 #undef COUNTER_ID
371 #define COUNTER_ID(name) kCountOfCODE_AGE__##name, \
372  kSizeOfCODE_AGE__##name,
374 #undef COUNTER_ID
376  };
377 
378  void ResetHistograms();
379 
380  private:
381 #define HT(name, caption) \
382  HistogramTimer name##_;
384 #undef HT
385 
386 #define HP(name, caption) \
387  Histogram name##_;
389 #undef HP
390 
391 #define HM(name, caption) \
392  Histogram name##_;
394 #undef HM
395 
396 #define SC(name, caption) \
397  StatsCounter name##_;
400 #undef SC
401 
402 #define SC(name) \
403  StatsCounter size_of_##name##_; \
404  StatsCounter count_of_##name##_;
406 #undef SC
407 
408 #define SC(name) \
409  StatsCounter size_of_CODE_TYPE_##name##_; \
410  StatsCounter count_of_CODE_TYPE_##name##_;
412 #undef SC
413 
414 #define SC(name) \
415  StatsCounter size_of_FIXED_ARRAY_##name##_; \
416  StatsCounter count_of_FIXED_ARRAY_##name##_;
418 #undef SC
419 
420 #define SC(name) \
421  StatsCounter size_of_CODE_AGE_##name##_; \
422  StatsCounter count_of_CODE_AGE_##name##_;
424 #undef SC
425 
426  friend class Isolate;
427 
428  explicit Counters(Isolate* isolate);
429 
431 };
432 
433 } } // namespace v8::internal
434 
435 #endif // V8_V8_COUNTERS_H_
#define HT(name, caption)
Definition: v8-counters.h:381
#define SC(name, caption)
Definition: v8-counters.h:420
#define CODE_AGE_LIST_COMPLETE(V)
Definition: builtins.h:53
#define PERCENTAGE_ID(name, caption)
Definition: v8-counters.h:350
#define INSTANCE_TYPE_LIST(V)
Definition: objects.h:342
#define MEMORY_ID(name, caption)
Definition: v8-counters.h:353
#define STATS_COUNTER_LIST_2(SC)
Definition: v8-counters.h:165
#define HISTOGRAM_MEMORY_LIST(HM)
Definition: v8-counters.h:93
#define HISTOGRAM_PERCENTAGE_LIST(HP)
Definition: v8-counters.h:53
#define DISALLOW_IMPLICIT_CONSTRUCTORS(TypeName)
Definition: globals.h:370
#define HP(name, caption)
Definition: v8-counters.h:386
#define FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(V)
Definition: objects.h:863
#define CODE_KIND_LIST(V)
Definition: objects.h:5204
#define HM(name, caption)
Definition: v8-counters.h:391
#define HISTOGRAM_TIMER_LIST(HT)
Definition: v8-counters.h:39
#define RATE_ID(name, caption)
Definition: v8-counters.h:347
#define STATS_COUNTER_LIST_1(SC)
Definition: v8-counters.h:113
#define COUNTER_ID(name, caption)
Definition: v8-counters.h:371