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.
8 #include "include/v8.h"
9 #include "src/allocation.h"
10 #include "src/base/platform/elapsed-timer.h"
11 #include "src/globals.h"
12 #include "src/objects.h"
17 // StatsCounters is an interface for plugging into external
18 // counters for monitoring. Counters can be looked up and
19 // manipulated by name.
23 // Register an application-defined function where
24 // counters can be looked up.
25 void SetCounterFunction(CounterLookupCallback f) {
29 // Register an application-defined function to create
30 // a histogram for passing to the AddHistogramSample function
31 void SetCreateHistogramFunction(CreateHistogramCallback f) {
32 create_histogram_function_ = f;
35 // Register an application-defined function to add a sample
36 // to a histogram created with CreateHistogram function
37 void SetAddHistogramSampleFunction(AddHistogramSampleCallback f) {
38 add_histogram_sample_function_ = f;
41 bool HasCounterFunction() const {
42 return lookup_function_ != NULL;
45 // Lookup the location of a counter by name. If the lookup
46 // is successful, returns a non-NULL pointer for writing the
47 // value of the counter. Each thread calling this function
48 // may receive a different location to store it's counter.
49 // The return value must not be cached and re-used across
50 // threads, although a single thread is free to cache it.
51 int* FindLocation(const char* name) {
52 if (!lookup_function_) return NULL;
53 return lookup_function_(name);
56 // Create a histogram by name. If the create is successful,
57 // returns a non-NULL pointer for use with AddHistogramSample
58 // function. min and max define the expected minimum and maximum
59 // sample values. buckets is the maximum number of buckets
60 // that the samples will be grouped into.
61 void* CreateHistogram(const char* name,
65 if (!create_histogram_function_) return NULL;
66 return create_histogram_function_(name, min, max, buckets);
69 // Add a sample to a histogram created with the CreateHistogram
71 void AddHistogramSample(void* histogram, int sample) {
72 if (!add_histogram_sample_function_) return;
73 return add_histogram_sample_function_(histogram, sample);
79 CounterLookupCallback lookup_function_;
80 CreateHistogramCallback create_histogram_function_;
81 AddHistogramSampleCallback add_histogram_sample_function_;
85 DISALLOW_COPY_AND_ASSIGN(StatsTable);
88 // StatsCounters are dynamically created values which can be tracked in
89 // the StatsTable. They are designed to be lightweight to create and
92 // Internally, a counter represents a value in a row of a StatsTable.
93 // The row has a 32bit value for each process/thread in the table and also
94 // a name (stored in the table metadata). Since the storage location can be
95 // thread-specific, this class cannot be shared across threads.
99 explicit StatsCounter(Isolate* isolate, const char* name)
100 : isolate_(isolate), name_(name), ptr_(NULL), lookup_done_(false) { }
102 // Sets the counter to a specific value.
103 void Set(int value) {
105 if (loc) *loc = value;
108 // Increments the counter.
114 void Increment(int value) {
120 // Decrements the counter.
126 void Decrement(int value) {
128 if (loc) (*loc) -= value;
131 // Is this counter enabled?
132 // Returns false if table is full.
134 return GetPtr() != NULL;
137 // Get the internal pointer to the counter. This is used
138 // by the code generator to emit code that manipulates a
139 // given counter without calling the runtime system.
140 int* GetInternalPointer() {
146 // Reset the cached internal pointer.
147 void Reset() { lookup_done_ = false; }
150 // Returns the cached address of this counter location.
152 if (lookup_done_) return ptr_;
154 ptr_ = FindLocationInStatsTable();
159 int* FindLocationInStatsTable() const;
167 // A Histogram represents a dynamically created histogram in the StatsTable.
168 // It will be registered with the histogram system on first use.
172 Histogram(const char* name,
180 num_buckets_(num_buckets),
183 isolate_(isolate) { }
185 // Add a single sample to this histogram.
186 void AddSample(int sample);
188 // Returns true if this histogram is enabled.
190 return GetHistogram() != NULL;
193 // Reset the cached internal pointer.
195 lookup_done_ = false;
199 // Returns the handle to the histogram.
200 void* GetHistogram() {
203 histogram_ = CreateHistogram();
208 const char* name() { return name_; }
209 Isolate* isolate() const { return isolate_; }
212 void* CreateHistogram() const;
223 // A HistogramTimer allows distributions of results to be created.
224 class HistogramTimer : public Histogram {
227 HistogramTimer(const char* name,
232 : Histogram(name, min, max, num_buckets, isolate) {}
237 // Stop the timer and record the results.
240 // Returns true if the timer is running.
242 return Enabled() && timer_.IsStarted();
245 // TODO(bmeurer): Remove this when HistogramTimerScope is fixed.
247 base::ElapsedTimer* timer() { return &timer_; }
251 base::ElapsedTimer timer_;
254 // Helper class for scoping a HistogramTimer.
255 // TODO(bmeurer): The ifdeffery is an ugly hack around the fact that the
256 // Parser is currently reentrant (when it throws an error, we call back
257 // into JavaScript and all bets are off), but ElapsedTimer is not
258 // reentry-safe. Fix this properly and remove |allow_nesting|.
259 class HistogramTimerScope BASE_EMBEDDED {
261 explicit HistogramTimerScope(HistogramTimer* timer,
262 bool allow_nesting = false)
265 skipped_timer_start_(false) {
266 if (timer_->timer()->IsStarted() && allow_nesting) {
267 skipped_timer_start_ = true;
277 ~HistogramTimerScope() {
279 if (!skipped_timer_start_) {
288 HistogramTimer* timer_;
290 bool skipped_timer_start_;
294 #define HISTOGRAM_RANGE_LIST(HR) \
295 /* Generic range histograms */ \
296 HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101)
298 #define HISTOGRAM_TIMER_LIST(HT) \
299 /* Garbage collection timers. */ \
300 HT(gc_compactor, V8.GCCompactor) \
301 HT(gc_scavenger, V8.GCScavenger) \
302 HT(gc_context, V8.GCContext) /* GC context cleanup time */ \
303 HT(gc_idle_notification, V8.GCIdleNotification) \
304 HT(gc_incremental_marking, V8.GCIncrementalMarking) \
305 HT(gc_low_memory_notification, V8.GCLowMemoryNotification) \
306 /* Parsing timers. */ \
307 HT(parse, V8.Parse) \
308 HT(parse_lazy, V8.ParseLazy) \
309 HT(pre_parse, V8.PreParse) \
310 /* Total compilation times. */ \
311 HT(compile, V8.Compile) \
312 HT(compile_eval, V8.CompileEval) \
313 HT(compile_lazy, V8.CompileLazy)
315 #define HISTOGRAM_PERCENTAGE_LIST(HP) \
316 /* Heap fragmentation. */ \
317 HP(external_fragmentation_total, \
318 V8.MemoryExternalFragmentationTotal) \
319 HP(external_fragmentation_old_pointer_space, \
320 V8.MemoryExternalFragmentationOldPointerSpace) \
321 HP(external_fragmentation_old_data_space, \
322 V8.MemoryExternalFragmentationOldDataSpace) \
323 HP(external_fragmentation_code_space, \
324 V8.MemoryExternalFragmentationCodeSpace) \
325 HP(external_fragmentation_map_space, \
326 V8.MemoryExternalFragmentationMapSpace) \
327 HP(external_fragmentation_cell_space, \
328 V8.MemoryExternalFragmentationCellSpace) \
329 HP(external_fragmentation_property_cell_space, \
330 V8.MemoryExternalFragmentationPropertyCellSpace) \
331 HP(external_fragmentation_lo_space, \
332 V8.MemoryExternalFragmentationLoSpace) \
333 /* Percentages of heap committed to each space. */ \
334 HP(heap_fraction_new_space, \
335 V8.MemoryHeapFractionNewSpace) \
336 HP(heap_fraction_old_pointer_space, \
337 V8.MemoryHeapFractionOldPointerSpace) \
338 HP(heap_fraction_old_data_space, \
339 V8.MemoryHeapFractionOldDataSpace) \
340 HP(heap_fraction_code_space, \
341 V8.MemoryHeapFractionCodeSpace) \
342 HP(heap_fraction_map_space, \
343 V8.MemoryHeapFractionMapSpace) \
344 HP(heap_fraction_cell_space, \
345 V8.MemoryHeapFractionCellSpace) \
346 HP(heap_fraction_property_cell_space, \
347 V8.MemoryHeapFractionPropertyCellSpace) \
348 HP(heap_fraction_lo_space, \
349 V8.MemoryHeapFractionLoSpace) \
350 /* Percentage of crankshafted codegen. */ \
351 HP(codegen_fraction_crankshaft, \
352 V8.CodegenFractionCrankshaft) \
355 #define HISTOGRAM_MEMORY_LIST(HM) \
356 HM(heap_sample_total_committed, V8.MemoryHeapSampleTotalCommitted) \
357 HM(heap_sample_total_used, V8.MemoryHeapSampleTotalUsed) \
358 HM(heap_sample_map_space_committed, \
359 V8.MemoryHeapSampleMapSpaceCommitted) \
360 HM(heap_sample_cell_space_committed, \
361 V8.MemoryHeapSampleCellSpaceCommitted) \
362 HM(heap_sample_property_cell_space_committed, \
363 V8.MemoryHeapSamplePropertyCellSpaceCommitted) \
364 HM(heap_sample_code_space_committed, \
365 V8.MemoryHeapSampleCodeSpaceCommitted) \
366 HM(heap_sample_maximum_committed, \
367 V8.MemoryHeapSampleMaximumCommitted) \
370 // WARNING: STATS_COUNTER_LIST_* is a very large macro that is causing MSVC
371 // Intellisense to crash. It was broken into two macros (each of length 40
372 // lines) rather than one macro (of length about 80 lines) to work around
373 // this problem. Please avoid using recursive macros of this length when
375 #define STATS_COUNTER_LIST_1(SC) \
376 /* Global Handle Count*/ \
377 SC(global_handles, V8.GlobalHandles) \
378 /* OS Memory allocated */ \
379 SC(memory_allocated, V8.OsMemoryAllocated) \
380 SC(normalized_maps, V8.NormalizedMaps) \
381 SC(props_to_dictionary, V8.ObjectPropertiesToDictionary) \
382 SC(elements_to_dictionary, V8.ObjectElementsToDictionary) \
383 SC(alive_after_last_gc, V8.AliveAfterLastGC) \
384 SC(objs_since_last_young, V8.ObjsSinceLastYoung) \
385 SC(objs_since_last_full, V8.ObjsSinceLastFull) \
386 SC(string_table_capacity, V8.StringTableCapacity) \
387 SC(number_of_symbols, V8.NumberOfSymbols) \
388 SC(script_wrappers, V8.ScriptWrappers) \
389 SC(call_initialize_stubs, V8.CallInitializeStubs) \
390 SC(call_premonomorphic_stubs, V8.CallPreMonomorphicStubs) \
391 SC(call_normal_stubs, V8.CallNormalStubs) \
392 SC(call_megamorphic_stubs, V8.CallMegamorphicStubs) \
393 SC(inlined_copied_elements, V8.InlinedCopiedElements) \
394 SC(arguments_adaptors, V8.ArgumentsAdaptors) \
395 SC(compilation_cache_hits, V8.CompilationCacheHits) \
396 SC(compilation_cache_misses, V8.CompilationCacheMisses) \
397 SC(string_ctor_calls, V8.StringConstructorCalls) \
398 SC(string_ctor_conversions, V8.StringConstructorConversions) \
399 SC(string_ctor_cached_number, V8.StringConstructorCachedNumber) \
400 SC(string_ctor_string_value, V8.StringConstructorStringValue) \
401 SC(string_ctor_gc_required, V8.StringConstructorGCRequired) \
402 /* Amount of evaled source code. */ \
403 SC(total_eval_size, V8.TotalEvalSize) \
404 /* Amount of loaded source code. */ \
405 SC(total_load_size, V8.TotalLoadSize) \
406 /* Amount of parsed source code. */ \
407 SC(total_parse_size, V8.TotalParseSize) \
408 /* Amount of source code skipped over using preparsing. */ \
409 SC(total_preparse_skipped, V8.TotalPreparseSkipped) \
410 /* Number of symbol lookups skipped using preparsing */ \
411 SC(total_preparse_symbols_skipped, V8.TotalPreparseSymbolSkipped) \
412 /* Amount of compiled source code. */ \
413 SC(total_compile_size, V8.TotalCompileSize) \
414 /* Amount of source code compiled with the full codegen. */ \
415 SC(total_full_codegen_source_size, V8.TotalFullCodegenSourceSize) \
416 /* Number of contexts created from scratch. */ \
417 SC(contexts_created_from_scratch, V8.ContextsCreatedFromScratch) \
418 /* Number of contexts created by partial snapshot. */ \
419 SC(contexts_created_by_snapshot, V8.ContextsCreatedBySnapshot) \
420 /* Number of code objects found from pc. */ \
421 SC(pc_to_code, V8.PcToCode) \
422 SC(pc_to_code_cached, V8.PcToCodeCached) \
423 /* The store-buffer implementation of the write barrier. */ \
424 SC(store_buffer_compactions, V8.StoreBufferCompactions) \
425 SC(store_buffer_overflows, V8.StoreBufferOverflows)
428 #define STATS_COUNTER_LIST_2(SC) \
429 /* Number of code stubs. */ \
430 SC(code_stubs, V8.CodeStubs) \
431 /* Amount of stub code. */ \
432 SC(total_stubs_code_size, V8.TotalStubsCodeSize) \
433 /* Amount of (JS) compiled code. */ \
434 SC(total_compiled_code_size, V8.TotalCompiledCodeSize) \
435 SC(gc_compactor_caused_by_request, V8.GCCompactorCausedByRequest) \
436 SC(gc_compactor_caused_by_promoted_data, \
437 V8.GCCompactorCausedByPromotedData) \
438 SC(gc_compactor_caused_by_oldspace_exhaustion, \
439 V8.GCCompactorCausedByOldspaceExhaustion) \
440 SC(gc_last_resort_from_js, V8.GCLastResortFromJS) \
441 SC(gc_last_resort_from_handles, V8.GCLastResortFromHandles) \
442 /* How is the generic keyed-load stub used? */ \
443 SC(keyed_load_generic_smi, V8.KeyedLoadGenericSmi) \
444 SC(keyed_load_generic_symbol, V8.KeyedLoadGenericSymbol) \
445 SC(keyed_load_generic_lookup_cache, V8.KeyedLoadGenericLookupCache) \
446 SC(keyed_load_generic_slow, V8.KeyedLoadGenericSlow) \
447 SC(keyed_load_polymorphic_stubs, V8.KeyedLoadPolymorphicStubs) \
448 SC(keyed_load_external_array_slow, V8.KeyedLoadExternalArraySlow) \
449 /* How is the generic keyed-call stub used? */ \
450 SC(keyed_call_generic_smi_fast, V8.KeyedCallGenericSmiFast) \
451 SC(keyed_call_generic_smi_dict, V8.KeyedCallGenericSmiDict) \
452 SC(keyed_call_generic_lookup_cache, V8.KeyedCallGenericLookupCache) \
453 SC(keyed_call_generic_lookup_dict, V8.KeyedCallGenericLookupDict) \
454 SC(keyed_call_generic_slow, V8.KeyedCallGenericSlow) \
455 SC(keyed_call_generic_slow_load, V8.KeyedCallGenericSlowLoad) \
456 SC(named_load_global_stub, V8.NamedLoadGlobalStub) \
457 SC(named_store_global_inline, V8.NamedStoreGlobalInline) \
458 SC(named_store_global_inline_miss, V8.NamedStoreGlobalInlineMiss) \
459 SC(keyed_store_polymorphic_stubs, V8.KeyedStorePolymorphicStubs) \
460 SC(keyed_store_external_array_slow, V8.KeyedStoreExternalArraySlow) \
461 SC(store_normal_miss, V8.StoreNormalMiss) \
462 SC(store_normal_hit, V8.StoreNormalHit) \
463 SC(cow_arrays_created_stub, V8.COWArraysCreatedStub) \
464 SC(cow_arrays_created_runtime, V8.COWArraysCreatedRuntime) \
465 SC(cow_arrays_converted, V8.COWArraysConverted) \
466 SC(call_miss, V8.CallMiss) \
467 SC(keyed_call_miss, V8.KeyedCallMiss) \
468 SC(load_miss, V8.LoadMiss) \
469 SC(keyed_load_miss, V8.KeyedLoadMiss) \
470 SC(call_const, V8.CallConst) \
471 SC(call_const_fast_api, V8.CallConstFastApi) \
472 SC(call_const_interceptor, V8.CallConstInterceptor) \
473 SC(call_const_interceptor_fast_api, V8.CallConstInterceptorFastApi) \
474 SC(call_global_inline, V8.CallGlobalInline) \
475 SC(call_global_inline_miss, V8.CallGlobalInlineMiss) \
476 SC(constructed_objects, V8.ConstructedObjects) \
477 SC(constructed_objects_runtime, V8.ConstructedObjectsRuntime) \
478 SC(negative_lookups, V8.NegativeLookups) \
479 SC(negative_lookups_miss, V8.NegativeLookupsMiss) \
480 SC(megamorphic_stub_cache_probes, V8.MegamorphicStubCacheProbes) \
481 SC(megamorphic_stub_cache_misses, V8.MegamorphicStubCacheMisses) \
482 SC(megamorphic_stub_cache_updates, V8.MegamorphicStubCacheUpdates) \
483 SC(array_function_runtime, V8.ArrayFunctionRuntime) \
484 SC(array_function_native, V8.ArrayFunctionNative) \
485 SC(for_in, V8.ForIn) \
486 SC(enum_cache_hits, V8.EnumCacheHits) \
487 SC(enum_cache_misses, V8.EnumCacheMisses) \
488 SC(zone_segment_bytes, V8.ZoneSegmentBytes) \
489 SC(fast_new_closure_total, V8.FastNewClosureTotal) \
490 SC(fast_new_closure_try_optimized, V8.FastNewClosureTryOptimized) \
491 SC(fast_new_closure_install_optimized, V8.FastNewClosureInstallOptimized) \
492 SC(string_add_runtime, V8.StringAddRuntime) \
493 SC(string_add_native, V8.StringAddNative) \
494 SC(string_add_runtime_ext_to_ascii, V8.StringAddRuntimeExtToAscii) \
495 SC(sub_string_runtime, V8.SubStringRuntime) \
496 SC(sub_string_native, V8.SubStringNative) \
497 SC(string_add_make_two_char, V8.StringAddMakeTwoChar) \
498 SC(string_compare_native, V8.StringCompareNative) \
499 SC(string_compare_runtime, V8.StringCompareRuntime) \
500 SC(regexp_entry_runtime, V8.RegExpEntryRuntime) \
501 SC(regexp_entry_native, V8.RegExpEntryNative) \
502 SC(number_to_string_native, V8.NumberToStringNative) \
503 SC(number_to_string_runtime, V8.NumberToStringRuntime) \
504 SC(math_acos, V8.MathAcos) \
505 SC(math_asin, V8.MathAsin) \
506 SC(math_atan, V8.MathAtan) \
507 SC(math_atan2, V8.MathAtan2) \
508 SC(math_exp, V8.MathExp) \
509 SC(math_floor, V8.MathFloor) \
510 SC(math_log, V8.MathLog) \
511 SC(math_pow, V8.MathPow) \
512 SC(math_round, V8.MathRound) \
513 SC(math_sqrt, V8.MathSqrt) \
514 SC(stack_interrupts, V8.StackInterrupts) \
515 SC(runtime_profiler_ticks, V8.RuntimeProfilerTicks) \
516 SC(bounds_checks_eliminated, V8.BoundsChecksEliminated) \
517 SC(bounds_checks_hoisted, V8.BoundsChecksHoisted) \
518 SC(soft_deopts_requested, V8.SoftDeoptsRequested) \
519 SC(soft_deopts_inserted, V8.SoftDeoptsInserted) \
520 SC(soft_deopts_executed, V8.SoftDeoptsExecuted) \
521 /* Number of write barriers in generated code. */ \
522 SC(write_barriers_dynamic, V8.WriteBarriersDynamic) \
523 SC(write_barriers_static, V8.WriteBarriersStatic) \
524 SC(new_space_bytes_available, V8.MemoryNewSpaceBytesAvailable) \
525 SC(new_space_bytes_committed, V8.MemoryNewSpaceBytesCommitted) \
526 SC(new_space_bytes_used, V8.MemoryNewSpaceBytesUsed) \
527 SC(old_pointer_space_bytes_available, \
528 V8.MemoryOldPointerSpaceBytesAvailable) \
529 SC(old_pointer_space_bytes_committed, \
530 V8.MemoryOldPointerSpaceBytesCommitted) \
531 SC(old_pointer_space_bytes_used, V8.MemoryOldPointerSpaceBytesUsed) \
532 SC(old_data_space_bytes_available, V8.MemoryOldDataSpaceBytesAvailable) \
533 SC(old_data_space_bytes_committed, V8.MemoryOldDataSpaceBytesCommitted) \
534 SC(old_data_space_bytes_used, V8.MemoryOldDataSpaceBytesUsed) \
535 SC(code_space_bytes_available, V8.MemoryCodeSpaceBytesAvailable) \
536 SC(code_space_bytes_committed, V8.MemoryCodeSpaceBytesCommitted) \
537 SC(code_space_bytes_used, V8.MemoryCodeSpaceBytesUsed) \
538 SC(map_space_bytes_available, V8.MemoryMapSpaceBytesAvailable) \
539 SC(map_space_bytes_committed, V8.MemoryMapSpaceBytesCommitted) \
540 SC(map_space_bytes_used, V8.MemoryMapSpaceBytesUsed) \
541 SC(cell_space_bytes_available, V8.MemoryCellSpaceBytesAvailable) \
542 SC(cell_space_bytes_committed, V8.MemoryCellSpaceBytesCommitted) \
543 SC(cell_space_bytes_used, V8.MemoryCellSpaceBytesUsed) \
544 SC(property_cell_space_bytes_available, \
545 V8.MemoryPropertyCellSpaceBytesAvailable) \
546 SC(property_cell_space_bytes_committed, \
547 V8.MemoryPropertyCellSpaceBytesCommitted) \
548 SC(property_cell_space_bytes_used, \
549 V8.MemoryPropertyCellSpaceBytesUsed) \
550 SC(lo_space_bytes_available, V8.MemoryLoSpaceBytesAvailable) \
551 SC(lo_space_bytes_committed, V8.MemoryLoSpaceBytesCommitted) \
552 SC(lo_space_bytes_used, V8.MemoryLoSpaceBytesUsed)
555 // This file contains all the v8 counters that are in use.
558 #define HR(name, caption, min, max, num_buckets) \
559 Histogram* name() { return &name##_; }
560 HISTOGRAM_RANGE_LIST(HR)
563 #define HT(name, caption) \
564 HistogramTimer* name() { return &name##_; }
565 HISTOGRAM_TIMER_LIST(HT)
568 #define HP(name, caption) \
569 Histogram* name() { return &name##_; }
570 HISTOGRAM_PERCENTAGE_LIST(HP)
573 #define HM(name, caption) \
574 Histogram* name() { return &name##_; }
575 HISTOGRAM_MEMORY_LIST(HM)
578 #define SC(name, caption) \
579 StatsCounter* name() { return &name##_; }
580 STATS_COUNTER_LIST_1(SC)
581 STATS_COUNTER_LIST_2(SC)
585 StatsCounter* count_of_##name() { return &count_of_##name##_; } \
586 StatsCounter* size_of_##name() { return &size_of_##name##_; }
587 INSTANCE_TYPE_LIST(SC)
591 StatsCounter* count_of_CODE_TYPE_##name() \
592 { return &count_of_CODE_TYPE_##name##_; } \
593 StatsCounter* size_of_CODE_TYPE_##name() \
594 { return &size_of_CODE_TYPE_##name##_; }
599 StatsCounter* count_of_FIXED_ARRAY_##name() \
600 { return &count_of_FIXED_ARRAY_##name##_; } \
601 StatsCounter* size_of_FIXED_ARRAY_##name() \
602 { return &size_of_FIXED_ARRAY_##name##_; }
603 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(SC)
607 StatsCounter* count_of_CODE_AGE_##name() \
608 { return &count_of_CODE_AGE_##name##_; } \
609 StatsCounter* size_of_CODE_AGE_##name() \
610 { return &size_of_CODE_AGE_##name##_; }
611 CODE_AGE_LIST_COMPLETE(SC)
615 #define RATE_ID(name, caption) k_##name,
616 HISTOGRAM_TIMER_LIST(RATE_ID)
618 #define PERCENTAGE_ID(name, caption) k_##name,
619 HISTOGRAM_PERCENTAGE_LIST(PERCENTAGE_ID)
621 #define MEMORY_ID(name, caption) k_##name,
622 HISTOGRAM_MEMORY_LIST(MEMORY_ID)
624 #define COUNTER_ID(name, caption) k_##name,
625 STATS_COUNTER_LIST_1(COUNTER_ID)
626 STATS_COUNTER_LIST_2(COUNTER_ID)
628 #define COUNTER_ID(name) kCountOf##name, kSizeOf##name,
629 INSTANCE_TYPE_LIST(COUNTER_ID)
631 #define COUNTER_ID(name) kCountOfCODE_TYPE_##name, \
632 kSizeOfCODE_TYPE_##name,
633 CODE_KIND_LIST(COUNTER_ID)
635 #define COUNTER_ID(name) kCountOfFIXED_ARRAY__##name, \
636 kSizeOfFIXED_ARRAY__##name,
637 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(COUNTER_ID)
639 #define COUNTER_ID(name) kCountOfCODE_AGE__##name, \
640 kSizeOfCODE_AGE__##name,
641 CODE_AGE_LIST_COMPLETE(COUNTER_ID)
646 void ResetCounters();
647 void ResetHistograms();
650 #define HR(name, caption, min, max, num_buckets) Histogram name##_;
651 HISTOGRAM_RANGE_LIST(HR)
654 #define HT(name, caption) \
655 HistogramTimer name##_;
656 HISTOGRAM_TIMER_LIST(HT)
659 #define HP(name, caption) \
661 HISTOGRAM_PERCENTAGE_LIST(HP)
664 #define HM(name, caption) \
666 HISTOGRAM_MEMORY_LIST(HM)
669 #define SC(name, caption) \
670 StatsCounter name##_;
671 STATS_COUNTER_LIST_1(SC)
672 STATS_COUNTER_LIST_2(SC)
676 StatsCounter size_of_##name##_; \
677 StatsCounter count_of_##name##_;
678 INSTANCE_TYPE_LIST(SC)
682 StatsCounter size_of_CODE_TYPE_##name##_; \
683 StatsCounter count_of_CODE_TYPE_##name##_;
688 StatsCounter size_of_FIXED_ARRAY_##name##_; \
689 StatsCounter count_of_FIXED_ARRAY_##name##_;
690 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(SC)
694 StatsCounter size_of_CODE_AGE_##name##_; \
695 StatsCounter count_of_CODE_AGE_##name##_;
696 CODE_AGE_LIST_COMPLETE(SC)
699 friend class Isolate;
701 explicit Counters(Isolate* isolate);
703 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters);
706 } } // namespace v8::internal
708 #endif // V8_COUNTERS_H_