blob: a8eb9d2a6bf4c3bd58d8011b195a0a1a963dddda [file] [log] [blame]
Steve Blocka7e24c12009-10-30 11:49:00 +00001// Copyright 2007-2008 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 "counters.h"
32
33namespace v8 {
34namespace internal {
35
36#define HISTOGRAM_TIMER_LIST(HT) \
37 /* Garbage collection timers. */ \
38 HT(gc_compactor, V8.GCCompactor) \
39 HT(gc_scavenger, V8.GCScavenger) \
40 HT(gc_context, V8.GCContext) /* GC context cleanup time */ \
41 /* Parsing timers. */ \
42 HT(parse, V8.Parse) \
43 HT(parse_lazy, V8.ParseLazy) \
44 HT(pre_parse, V8.PreParse) \
45 /* Total compilation times. */ \
46 HT(compile, V8.Compile) \
47 HT(compile_eval, V8.CompileEval) \
48 HT(compile_lazy, V8.CompileLazy) \
49 /* Individual compiler passes. */ \
50 HT(rewriting, V8.Rewriting) \
51 HT(usage_analysis, V8.UsageAnalysis) \
52 HT(variable_allocation, V8.VariableAllocation) \
53 HT(ast_optimization, V8.ASTOptimization) \
54 HT(code_generation, V8.CodeGeneration) \
Steve Block3ce2e202009-11-05 08:53:23 +000055 HT(deferred_code_generation, V8.DeferredCodeGeneration)
56
Steve Blocka7e24c12009-10-30 11:49:00 +000057
58// WARNING: STATS_COUNTER_LIST_* is a very large macro that is causing MSVC
59// Intellisense to crash. It was broken into two macros (each of length 40
60// lines) rather than one macro (of length about 80 lines) to work around
61// this problem. Please avoid using recursive macros of this length when
62// possible.
Leon Clarked91b9f72010-01-27 17:25:45 +000063#define STATS_COUNTER_LIST_1(SC) \
64 /* Global Handle Count*/ \
65 SC(global_handles, V8.GlobalHandles) \
66 /* Mallocs from PCRE */ \
67 SC(pcre_mallocs, V8.PcreMallocCount) \
68 /* OS Memory allocated */ \
69 SC(memory_allocated, V8.OsMemoryAllocated) \
Kristian Monsen80d68ea2010-09-08 11:05:35 +010070 SC(normalized_maps, V8.NormalizedMaps) \
Leon Clarked91b9f72010-01-27 17:25:45 +000071 SC(props_to_dictionary, V8.ObjectPropertiesToDictionary) \
72 SC(elements_to_dictionary, V8.ObjectElementsToDictionary) \
73 SC(alive_after_last_gc, V8.AliveAfterLastGC) \
74 SC(objs_since_last_young, V8.ObjsSinceLastYoung) \
75 SC(objs_since_last_full, V8.ObjsSinceLastFull) \
76 SC(symbol_table_capacity, V8.SymbolTableCapacity) \
77 SC(number_of_symbols, V8.NumberOfSymbols) \
78 SC(script_wrappers, V8.ScriptWrappers) \
79 SC(call_initialize_stubs, V8.CallInitializeStubs) \
80 SC(call_premonomorphic_stubs, V8.CallPreMonomorphicStubs) \
81 SC(call_normal_stubs, V8.CallNormalStubs) \
82 SC(call_megamorphic_stubs, V8.CallMegamorphicStubs) \
83 SC(arguments_adaptors, V8.ArgumentsAdaptors) \
84 SC(compilation_cache_hits, V8.CompilationCacheHits) \
85 SC(compilation_cache_misses, V8.CompilationCacheMisses) \
86 SC(regexp_cache_hits, V8.RegExpCacheHits) \
87 SC(regexp_cache_misses, V8.RegExpCacheMisses) \
Kristian Monsen80d68ea2010-09-08 11:05:35 +010088 SC(string_ctor_calls, V8.StringConstructorCalls) \
89 SC(string_ctor_conversions, V8.StringConstructorConversions) \
90 SC(string_ctor_cached_number, V8.StringConstructorCachedNumber) \
91 SC(string_ctor_string_value, V8.StringConstructorStringValue) \
92 SC(string_ctor_gc_required, V8.StringConstructorGCRequired) \
Leon Clarked91b9f72010-01-27 17:25:45 +000093 /* Amount of evaled source code. */ \
94 SC(total_eval_size, V8.TotalEvalSize) \
95 /* Amount of loaded source code. */ \
96 SC(total_load_size, V8.TotalLoadSize) \
97 /* Amount of parsed source code. */ \
98 SC(total_parse_size, V8.TotalParseSize) \
99 /* Amount of source code skipped over using preparsing. */ \
100 SC(total_preparse_skipped, V8.TotalPreparseSkipped) \
Iain Merrick9ac36c92010-09-13 15:29:50 +0100101 /* Number of symbol lookups skipped using preparsing */ \
102 SC(total_preparse_symbols_skipped, V8.TotalPreparseSymbolSkipped) \
Leon Clarked91b9f72010-01-27 17:25:45 +0000103 /* Amount of compiled source code. */ \
104 SC(total_compile_size, V8.TotalCompileSize) \
105 /* Amount of source code compiled with the old codegen. */ \
106 SC(total_old_codegen_source_size, V8.TotalOldCodegenSourceSize) \
107 /* Amount of source code compiled with the full codegen. */ \
Andrei Popescu31002712010-02-23 13:46:05 +0000108 SC(total_full_codegen_source_size, V8.TotalFullCodegenSourceSize) \
109 /* Number of contexts created from scratch. */ \
110 SC(contexts_created_from_scratch, V8.ContextsCreatedFromScratch) \
111 /* Number of contexts created by partial snapshot. */ \
Kristian Monsen80d68ea2010-09-08 11:05:35 +0100112 SC(contexts_created_by_snapshot, V8.ContextsCreatedBySnapshot) \
113 /* Number of code objects found from pc. */ \
114 SC(pc_to_code, V8.PcToCode) \
115 SC(pc_to_code_cached, V8.PcToCodeCached)
Andrei Popescu31002712010-02-23 13:46:05 +0000116
Steve Blocka7e24c12009-10-30 11:49:00 +0000117
Andrei Popescu402d9372010-02-26 13:31:12 +0000118#define STATS_COUNTER_LIST_2(SC) \
119 /* Number of code stubs. */ \
120 SC(code_stubs, V8.CodeStubs) \
121 /* Amount of stub code. */ \
122 SC(total_stubs_code_size, V8.TotalStubsCodeSize) \
123 /* Amount of (JS) compiled code. */ \
124 SC(total_compiled_code_size, V8.TotalCompiledCodeSize) \
125 SC(gc_compactor_caused_by_request, V8.GCCompactorCausedByRequest) \
126 SC(gc_compactor_caused_by_promoted_data, \
127 V8.GCCompactorCausedByPromotedData) \
128 SC(gc_compactor_caused_by_oldspace_exhaustion, \
129 V8.GCCompactorCausedByOldspaceExhaustion) \
130 SC(gc_compactor_caused_by_weak_handles, \
131 V8.GCCompactorCausedByWeakHandles) \
132 SC(gc_last_resort_from_js, V8.GCLastResortFromJS) \
133 SC(gc_last_resort_from_handles, V8.GCLastResortFromHandles) \
Iain Merrick75681382010-08-19 15:07:18 +0100134 SC(map_slow_to_fast_elements, V8.MapSlowToFastElements) \
135 SC(map_fast_to_slow_elements, V8.MapFastToSlowElements) \
Andrei Popescu402d9372010-02-26 13:31:12 +0000136 /* How is the generic keyed-load stub used? */ \
137 SC(keyed_load_generic_smi, V8.KeyedLoadGenericSmi) \
138 SC(keyed_load_generic_symbol, V8.KeyedLoadGenericSymbol) \
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100139 SC(keyed_load_generic_lookup_cache, V8.KeyedLoadGenericLookupCache) \
Andrei Popescu402d9372010-02-26 13:31:12 +0000140 SC(keyed_load_generic_slow, V8.KeyedLoadGenericSlow) \
141 SC(keyed_load_external_array_slow, V8.KeyedLoadExternalArraySlow) \
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100142 /* How is the generic keyed-call stub used? */ \
143 SC(keyed_call_generic_smi_fast, V8.KeyedCallGenericSmiFast) \
144 SC(keyed_call_generic_smi_dict, V8.KeyedCallGenericSmiDict) \
145 SC(keyed_call_generic_lookup_cache, V8.KeyedCallGenericLookupCache) \
146 SC(keyed_call_generic_lookup_dict, V8.KeyedCallGenericLookupDict) \
147 SC(keyed_call_generic_value_type, V8.KeyedCallGenericValueType) \
148 SC(keyed_call_generic_slow, V8.KeyedCallGenericSlow) \
149 SC(keyed_call_generic_slow_load, V8.KeyedCallGenericSlowLoad) \
Andrei Popescu402d9372010-02-26 13:31:12 +0000150 /* Count how much the monomorphic keyed-load stubs are hit. */ \
151 SC(keyed_load_function_prototype, V8.KeyedLoadFunctionPrototype) \
152 SC(keyed_load_string_length, V8.KeyedLoadStringLength) \
153 SC(keyed_load_array_length, V8.KeyedLoadArrayLength) \
154 SC(keyed_load_constant_function, V8.KeyedLoadConstantFunction) \
155 SC(keyed_load_field, V8.KeyedLoadField) \
156 SC(keyed_load_callback, V8.KeyedLoadCallback) \
157 SC(keyed_load_interceptor, V8.KeyedLoadInterceptor) \
158 SC(keyed_load_inline, V8.KeyedLoadInline) \
159 SC(keyed_load_inline_miss, V8.KeyedLoadInlineMiss) \
160 SC(named_load_inline, V8.NamedLoadInline) \
161 SC(named_load_inline_miss, V8.NamedLoadInlineMiss) \
162 SC(named_load_global_inline, V8.NamedLoadGlobalInline) \
163 SC(named_load_global_inline_miss, V8.NamedLoadGlobalInlineMiss) \
Kristian Monsen0d5e1162010-09-30 15:31:59 +0100164 SC(named_load_global_stub, V8.NamedLoadGlobalStub) \
165 SC(named_load_global_stub_miss, V8.NamedLoadGlobalStubMiss) \
Andrei Popescu402d9372010-02-26 13:31:12 +0000166 SC(keyed_store_field, V8.KeyedStoreField) \
167 SC(keyed_store_inline, V8.KeyedStoreInline) \
168 SC(keyed_store_inline_miss, V8.KeyedStoreInlineMiss) \
169 SC(named_store_global_inline, V8.NamedStoreGlobalInline) \
170 SC(named_store_global_inline_miss, V8.NamedStoreGlobalInlineMiss) \
Steve Block8defd9f2010-07-08 12:39:36 +0100171 SC(store_normal_miss, V8.StoreNormalMiss) \
172 SC(store_normal_hit, V8.StoreNormalHit) \
Iain Merrick75681382010-08-19 15:07:18 +0100173 SC(cow_arrays_created_stub, V8.COWArraysCreatedStub) \
174 SC(cow_arrays_created_runtime, V8.COWArraysCreatedRuntime) \
175 SC(cow_arrays_converted, V8.COWArraysConverted) \
Steve Block8defd9f2010-07-08 12:39:36 +0100176 SC(call_miss, V8.CallMiss) \
177 SC(keyed_call_miss, V8.KeyedCallMiss) \
178 SC(load_miss, V8.LoadMiss) \
179 SC(keyed_load_miss, V8.KeyedLoadMiss) \
Andrei Popescu402d9372010-02-26 13:31:12 +0000180 SC(call_const, V8.CallConst) \
181 SC(call_const_fast_api, V8.CallConstFastApi) \
182 SC(call_const_interceptor, V8.CallConstInterceptor) \
183 SC(call_const_interceptor_fast_api, V8.CallConstInterceptorFastApi) \
184 SC(call_global_inline, V8.CallGlobalInline) \
185 SC(call_global_inline_miss, V8.CallGlobalInlineMiss) \
186 SC(constructed_objects, V8.ConstructedObjects) \
187 SC(constructed_objects_runtime, V8.ConstructedObjectsRuntime) \
188 SC(constructed_objects_stub, V8.ConstructedObjectsStub) \
Steve Block8defd9f2010-07-08 12:39:36 +0100189 SC(negative_lookups, V8.NegativeLookups) \
Kristian Monsen50ef84f2010-07-29 15:18:00 +0100190 SC(negative_lookups_miss, V8.NegativeLookupsMiss) \
Andrei Popescu402d9372010-02-26 13:31:12 +0000191 SC(array_function_runtime, V8.ArrayFunctionRuntime) \
192 SC(array_function_native, V8.ArrayFunctionNative) \
193 SC(for_in, V8.ForIn) \
Ben Murdoch7f4d5bd2010-06-15 11:15:29 +0100194 SC(memcopy_aligned, V8.MemCopyAligned) \
195 SC(memcopy_unaligned, V8.MemCopyUnaligned) \
196 SC(memcopy_noxmm, V8.MemCopyNoXMM) \
Andrei Popescu402d9372010-02-26 13:31:12 +0000197 SC(enum_cache_hits, V8.EnumCacheHits) \
198 SC(enum_cache_misses, V8.EnumCacheMisses) \
199 SC(reloc_info_count, V8.RelocInfoCount) \
200 SC(reloc_info_size, V8.RelocInfoSize) \
201 SC(zone_segment_bytes, V8.ZoneSegmentBytes) \
202 SC(compute_entry_frame, V8.ComputeEntryFrame) \
203 SC(generic_binary_stub_calls, V8.GenericBinaryStubCalls) \
204 SC(generic_binary_stub_calls_regs, V8.GenericBinaryStubCallsRegs) \
205 SC(string_add_runtime, V8.StringAddRuntime) \
206 SC(string_add_native, V8.StringAddNative) \
Steve Block6ded16b2010-05-10 14:33:55 +0100207 SC(string_add_runtime_ext_to_ascii, V8.StringAddRuntimeExtToAscii) \
Andrei Popescu402d9372010-02-26 13:31:12 +0000208 SC(sub_string_runtime, V8.SubStringRuntime) \
209 SC(sub_string_native, V8.SubStringNative) \
Iain Merrick9ac36c92010-09-13 15:29:50 +0100210 SC(string_add_make_two_char, V8.StringAddMakeTwoChar) \
Andrei Popescu402d9372010-02-26 13:31:12 +0000211 SC(string_compare_native, V8.StringCompareNative) \
212 SC(string_compare_runtime, V8.StringCompareRuntime) \
213 SC(regexp_entry_runtime, V8.RegExpEntryRuntime) \
214 SC(regexp_entry_native, V8.RegExpEntryNative) \
215 SC(number_to_string_native, V8.NumberToStringNative) \
216 SC(number_to_string_runtime, V8.NumberToStringRuntime) \
Andrei Popescu402d9372010-02-26 13:31:12 +0000217 SC(math_acos, V8.MathAcos) \
218 SC(math_asin, V8.MathAsin) \
219 SC(math_atan, V8.MathAtan) \
220 SC(math_atan2, V8.MathAtan2) \
221 SC(math_ceil, V8.MathCeil) \
222 SC(math_cos, V8.MathCos) \
223 SC(math_exp, V8.MathExp) \
224 SC(math_floor, V8.MathFloor) \
225 SC(math_log, V8.MathLog) \
226 SC(math_pow, V8.MathPow) \
227 SC(math_round, V8.MathRound) \
228 SC(math_sin, V8.MathSin) \
229 SC(math_sqrt, V8.MathSqrt) \
230 SC(math_tan, V8.MathTan) \
231 SC(transcendental_cache_hit, V8.TranscendentalCacheHit) \
232 SC(transcendental_cache_miss, V8.TranscendentalCacheMiss)
Steve Blocka7e24c12009-10-30 11:49:00 +0000233
Steve Blocka7e24c12009-10-30 11:49:00 +0000234
235// This file contains all the v8 counters that are in use.
236class Counters : AllStatic {
237 public:
238#define HT(name, caption) \
239 static HistogramTimer name;
240 HISTOGRAM_TIMER_LIST(HT)
241#undef HT
242
243#define SC(name, caption) \
244 static StatsCounter name;
245 STATS_COUNTER_LIST_1(SC)
246 STATS_COUNTER_LIST_2(SC)
247#undef SC
248
249 enum Id {
250#define RATE_ID(name, caption) k_##name,
251 HISTOGRAM_TIMER_LIST(RATE_ID)
252#undef RATE_ID
253#define COUNTER_ID(name, caption) k_##name,
254 STATS_COUNTER_LIST_1(COUNTER_ID)
255 STATS_COUNTER_LIST_2(COUNTER_ID)
256#undef COUNTER_ID
257#define COUNTER_ID(name) k_##name,
258 STATE_TAG_LIST(COUNTER_ID)
259#undef COUNTER_ID
260 stats_counter_count
261 };
262
263 // Sliding state window counters.
264 static StatsCounter state_counters[];
265};
266
267} } // namespace v8::internal
268
269#endif // V8_V8_COUNTERS_H_