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/base/platform/time.h"
12 #include "src/globals.h"
13 #include "src/objects.h"
18 // StatsCounters is an interface for plugging into external
19 // counters for monitoring. Counters can be looked up and
20 // manipulated by name.
24 // Register an application-defined function where
25 // counters can be looked up.
26 void SetCounterFunction(CounterLookupCallback f) {
30 // Register an application-defined function to create
31 // a histogram for passing to the AddHistogramSample function
32 void SetCreateHistogramFunction(CreateHistogramCallback f) {
33 create_histogram_function_ = f;
36 // Register an application-defined function to add a sample
37 // to a histogram created with CreateHistogram function
38 void SetAddHistogramSampleFunction(AddHistogramSampleCallback f) {
39 add_histogram_sample_function_ = f;
42 bool HasCounterFunction() const {
43 return lookup_function_ != NULL;
46 // Lookup the location of a counter by name. If the lookup
47 // is successful, returns a non-NULL pointer for writing the
48 // value of the counter. Each thread calling this function
49 // may receive a different location to store it's counter.
50 // The return value must not be cached and re-used across
51 // threads, although a single thread is free to cache it.
52 int* FindLocation(const char* name) {
53 if (!lookup_function_) return NULL;
54 return lookup_function_(name);
57 // Create a histogram by name. If the create is successful,
58 // returns a non-NULL pointer for use with AddHistogramSample
59 // function. min and max define the expected minimum and maximum
60 // sample values. buckets is the maximum number of buckets
61 // that the samples will be grouped into.
62 void* CreateHistogram(const char* name,
66 if (!create_histogram_function_) return NULL;
67 return create_histogram_function_(name, min, max, buckets);
70 // Add a sample to a histogram created with the CreateHistogram
72 void AddHistogramSample(void* histogram, int sample) {
73 if (!add_histogram_sample_function_) return;
74 return add_histogram_sample_function_(histogram, sample);
80 CounterLookupCallback lookup_function_;
81 CreateHistogramCallback create_histogram_function_;
82 AddHistogramSampleCallback add_histogram_sample_function_;
86 DISALLOW_COPY_AND_ASSIGN(StatsTable);
89 // StatsCounters are dynamically created values which can be tracked in
90 // the StatsTable. They are designed to be lightweight to create and
93 // Internally, a counter represents a value in a row of a StatsTable.
94 // The row has a 32bit value for each process/thread in the table and also
95 // a name (stored in the table metadata). Since the storage location can be
96 // thread-specific, this class cannot be shared across threads.
100 explicit StatsCounter(Isolate* isolate, const char* name)
101 : isolate_(isolate), name_(name), ptr_(NULL), lookup_done_(false) { }
103 // Sets the counter to a specific value.
104 void Set(int value) {
106 if (loc) *loc = value;
109 // Increments the counter.
115 void Increment(int value) {
121 // Decrements the counter.
127 void Decrement(int value) {
129 if (loc) (*loc) -= value;
132 // Is this counter enabled?
133 // Returns false if table is full.
135 return GetPtr() != NULL;
138 // Get the internal pointer to the counter. This is used
139 // by the code generator to emit code that manipulates a
140 // given counter without calling the runtime system.
141 int* GetInternalPointer() {
147 // Reset the cached internal pointer.
148 void Reset() { lookup_done_ = false; }
151 // Returns the cached address of this counter location.
153 if (lookup_done_) return ptr_;
155 ptr_ = FindLocationInStatsTable();
160 int* FindLocationInStatsTable() const;
168 // A Histogram represents a dynamically created histogram in the StatsTable.
169 // It will be registered with the histogram system on first use.
173 Histogram(const char* name,
181 num_buckets_(num_buckets),
184 isolate_(isolate) { }
186 // Add a single sample to this histogram.
187 void AddSample(int sample);
189 // Returns true if this histogram is enabled.
191 return GetHistogram() != NULL;
194 // Reset the cached internal pointer.
196 lookup_done_ = false;
200 // Returns the handle to the histogram.
201 void* GetHistogram() {
204 histogram_ = CreateHistogram();
209 const char* name() { return name_; }
210 Isolate* isolate() const { return isolate_; }
213 void* CreateHistogram() const;
224 // A HistogramTimer allows distributions of results to be created.
225 class HistogramTimer : public Histogram {
233 HistogramTimer(const char* name, int min, int max, Resolution resolution,
234 int num_buckets, Isolate* isolate)
235 : Histogram(name, min, max, num_buckets, isolate),
236 resolution_(resolution) {}
241 // Stop the timer and record the results.
244 // Returns true if the timer is running.
246 return Enabled() && timer_.IsStarted();
249 // TODO(bmeurer): Remove this when HistogramTimerScope is fixed.
251 base::ElapsedTimer* timer() { return &timer_; }
255 base::ElapsedTimer timer_;
256 Resolution resolution_;
259 // Helper class for scoping a HistogramTimer.
260 // TODO(bmeurer): The ifdeffery is an ugly hack around the fact that the
261 // Parser is currently reentrant (when it throws an error, we call back
262 // into JavaScript and all bets are off), but ElapsedTimer is not
263 // reentry-safe. Fix this properly and remove |allow_nesting|.
264 class HistogramTimerScope BASE_EMBEDDED {
266 explicit HistogramTimerScope(HistogramTimer* timer,
267 bool allow_nesting = false)
270 skipped_timer_start_(false) {
271 if (timer_->timer()->IsStarted() && allow_nesting) {
272 skipped_timer_start_ = true;
282 ~HistogramTimerScope() {
284 if (!skipped_timer_start_) {
293 HistogramTimer* timer_;
295 bool skipped_timer_start_;
300 // A histogram timer that can aggregate events within a larger scope.
302 // Intended use of this timer is to have an outer (aggregating) and an inner
303 // (to be aggregated) scope, where the inner scope measure the time of events,
304 // and all those inner scope measurements will be summed up by the outer scope.
305 // An example use might be to aggregate the time spent in lazy compilation
306 // while running a script.
309 // - AggregatingHistogramTimerScope, the "outer" scope within which
310 // times will be summed up.
311 // - AggregatedHistogramTimerScope, the "inner" scope which defines the
312 // events to be timed.
313 class AggregatableHistogramTimer : public Histogram {
315 AggregatableHistogramTimer() {}
316 AggregatableHistogramTimer(const char* name, int min, int max,
317 int num_buckets, Isolate* isolate)
318 : Histogram(name, min, max, num_buckets, isolate) {}
320 // Start/stop the "outer" scope.
321 void Start() { time_ = base::TimeDelta(); }
322 void Stop() { AddSample(static_cast<int>(time_.InMicroseconds())); }
324 // Add a time value ("inner" scope).
325 void Add(base::TimeDelta other) { time_ += other; }
328 base::TimeDelta time_;
332 // A helper class for use with AggregatableHistogramTimer.
333 class AggregatingHistogramTimerScope {
335 explicit AggregatingHistogramTimerScope(AggregatableHistogramTimer* histogram)
336 : histogram_(histogram) {
339 ~AggregatingHistogramTimerScope() { histogram_->Stop(); }
342 AggregatableHistogramTimer* histogram_;
346 // A helper class for use with AggregatableHistogramTimer.
347 class AggregatedHistogramTimerScope {
349 explicit AggregatedHistogramTimerScope(AggregatableHistogramTimer* histogram)
350 : histogram_(histogram) {
353 ~AggregatedHistogramTimerScope() { histogram_->Add(timer_.Elapsed()); }
356 base::ElapsedTimer timer_;
357 AggregatableHistogramTimer* histogram_;
361 #define HISTOGRAM_RANGE_LIST(HR) \
362 /* Generic range histograms */ \
363 HR(detached_context_age_in_gc, V8.DetachedContextAgeInGC, 0, 20, 21) \
364 HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101) \
365 HR(gc_idle_time_limit_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \
366 HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, \
368 HR(code_cache_reject_reason, V8.CodeCacheRejectReason, 1, 6, 6)
370 #define HISTOGRAM_TIMER_LIST(HT) \
371 /* Garbage collection timers. */ \
372 HT(gc_compactor, V8.GCCompactor, 10000, MILLISECOND) \
373 HT(gc_scavenger, V8.GCScavenger, 10000, MILLISECOND) \
374 HT(gc_context, V8.GCContext, 10000, \
375 MILLISECOND) /* GC context cleanup time */ \
376 HT(gc_idle_notification, V8.GCIdleNotification, 10000, MILLISECOND) \
377 HT(gc_incremental_marking, V8.GCIncrementalMarking, 10000, MILLISECOND) \
378 HT(gc_low_memory_notification, V8.GCLowMemoryNotification, 10000, \
380 /* Parsing timers. */ \
381 HT(parse, V8.ParseMicroSeconds, 1000000, MICROSECOND) \
382 HT(parse_lazy, V8.ParseLazyMicroSeconds, 1000000, MICROSECOND) \
383 HT(pre_parse, V8.PreParseMicroSeconds, 1000000, MICROSECOND) \
384 /* Compilation times. */ \
385 HT(compile, V8.CompileMicroSeconds, 1000000, MICROSECOND) \
386 HT(compile_eval, V8.CompileEvalMicroSeconds, 1000000, MICROSECOND) \
387 /* Serialization as part of compilation (code caching) */ \
388 HT(compile_serialize, V8.CompileSerializeMicroSeconds, 100000, MICROSECOND) \
389 HT(compile_deserialize, V8.CompileDeserializeMicroSeconds, 1000000, \
391 /* Total compilation time incl. caching/parsing */ \
392 HT(compile_script, V8.CompileScriptMicroSeconds, 1000000, MICROSECOND)
395 #define AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT) \
396 AHT(compile_lazy, V8.CompileLazyMicroSeconds)
399 #define HISTOGRAM_PERCENTAGE_LIST(HP) \
400 /* Heap fragmentation. */ \
401 HP(external_fragmentation_total, V8.MemoryExternalFragmentationTotal) \
402 HP(external_fragmentation_old_pointer_space, \
403 V8.MemoryExternalFragmentationOldPointerSpace) \
404 HP(external_fragmentation_old_data_space, \
405 V8.MemoryExternalFragmentationOldDataSpace) \
406 HP(external_fragmentation_code_space, \
407 V8.MemoryExternalFragmentationCodeSpace) \
408 HP(external_fragmentation_map_space, V8.MemoryExternalFragmentationMapSpace) \
409 HP(external_fragmentation_cell_space, \
410 V8.MemoryExternalFragmentationCellSpace) \
411 HP(external_fragmentation_lo_space, V8.MemoryExternalFragmentationLoSpace) \
412 /* Percentages of heap committed to each space. */ \
413 HP(heap_fraction_new_space, V8.MemoryHeapFractionNewSpace) \
414 HP(heap_fraction_old_pointer_space, V8.MemoryHeapFractionOldPointerSpace) \
415 HP(heap_fraction_old_data_space, V8.MemoryHeapFractionOldDataSpace) \
416 HP(heap_fraction_code_space, V8.MemoryHeapFractionCodeSpace) \
417 HP(heap_fraction_map_space, V8.MemoryHeapFractionMapSpace) \
418 HP(heap_fraction_cell_space, V8.MemoryHeapFractionCellSpace) \
419 HP(heap_fraction_lo_space, V8.MemoryHeapFractionLoSpace) \
420 /* Percentage of crankshafted codegen. */ \
421 HP(codegen_fraction_crankshaft, V8.CodegenFractionCrankshaft)
424 #define HISTOGRAM_MEMORY_LIST(HM) \
425 HM(heap_sample_total_committed, V8.MemoryHeapSampleTotalCommitted) \
426 HM(heap_sample_total_used, V8.MemoryHeapSampleTotalUsed) \
427 HM(heap_sample_map_space_committed, \
428 V8.MemoryHeapSampleMapSpaceCommitted) \
429 HM(heap_sample_cell_space_committed, \
430 V8.MemoryHeapSampleCellSpaceCommitted) \
431 HM(heap_sample_code_space_committed, \
432 V8.MemoryHeapSampleCodeSpaceCommitted) \
433 HM(heap_sample_maximum_committed, \
434 V8.MemoryHeapSampleMaximumCommitted) \
437 // WARNING: STATS_COUNTER_LIST_* is a very large macro that is causing MSVC
438 // Intellisense to crash. It was broken into two macros (each of length 40
439 // lines) rather than one macro (of length about 80 lines) to work around
440 // this problem. Please avoid using recursive macros of this length when
442 #define STATS_COUNTER_LIST_1(SC) \
443 /* Global Handle Count*/ \
444 SC(global_handles, V8.GlobalHandles) \
445 /* OS Memory allocated */ \
446 SC(memory_allocated, V8.OsMemoryAllocated) \
447 SC(normalized_maps, V8.NormalizedMaps) \
448 SC(props_to_dictionary, V8.ObjectPropertiesToDictionary) \
449 SC(elements_to_dictionary, V8.ObjectElementsToDictionary) \
450 SC(alive_after_last_gc, V8.AliveAfterLastGC) \
451 SC(objs_since_last_young, V8.ObjsSinceLastYoung) \
452 SC(objs_since_last_full, V8.ObjsSinceLastFull) \
453 SC(string_table_capacity, V8.StringTableCapacity) \
454 SC(number_of_symbols, V8.NumberOfSymbols) \
455 SC(script_wrappers, V8.ScriptWrappers) \
456 SC(call_initialize_stubs, V8.CallInitializeStubs) \
457 SC(call_premonomorphic_stubs, V8.CallPreMonomorphicStubs) \
458 SC(call_normal_stubs, V8.CallNormalStubs) \
459 SC(call_megamorphic_stubs, V8.CallMegamorphicStubs) \
460 SC(inlined_copied_elements, V8.InlinedCopiedElements) \
461 SC(arguments_adaptors, V8.ArgumentsAdaptors) \
462 SC(compilation_cache_hits, V8.CompilationCacheHits) \
463 SC(compilation_cache_misses, V8.CompilationCacheMisses) \
464 SC(string_ctor_calls, V8.StringConstructorCalls) \
465 SC(string_ctor_conversions, V8.StringConstructorConversions) \
466 SC(string_ctor_cached_number, V8.StringConstructorCachedNumber) \
467 SC(string_ctor_string_value, V8.StringConstructorStringValue) \
468 SC(string_ctor_gc_required, V8.StringConstructorGCRequired) \
469 /* Amount of evaled source code. */ \
470 SC(total_eval_size, V8.TotalEvalSize) \
471 /* Amount of loaded source code. */ \
472 SC(total_load_size, V8.TotalLoadSize) \
473 /* Amount of parsed source code. */ \
474 SC(total_parse_size, V8.TotalParseSize) \
475 /* Amount of source code skipped over using preparsing. */ \
476 SC(total_preparse_skipped, V8.TotalPreparseSkipped) \
477 /* Number of symbol lookups skipped using preparsing */ \
478 SC(total_preparse_symbols_skipped, V8.TotalPreparseSymbolSkipped) \
479 /* Amount of compiled source code. */ \
480 SC(total_compile_size, V8.TotalCompileSize) \
481 /* Amount of source code compiled with the full codegen. */ \
482 SC(total_full_codegen_source_size, V8.TotalFullCodegenSourceSize) \
483 /* Number of contexts created from scratch. */ \
484 SC(contexts_created_from_scratch, V8.ContextsCreatedFromScratch) \
485 /* Number of contexts created by partial snapshot. */ \
486 SC(contexts_created_by_snapshot, V8.ContextsCreatedBySnapshot) \
487 /* Number of code objects found from pc. */ \
488 SC(pc_to_code, V8.PcToCode) \
489 SC(pc_to_code_cached, V8.PcToCodeCached) \
490 /* The store-buffer implementation of the write barrier. */ \
491 SC(store_buffer_compactions, V8.StoreBufferCompactions) \
492 SC(store_buffer_overflows, V8.StoreBufferOverflows)
495 #define STATS_COUNTER_LIST_2(SC) \
496 /* Number of code stubs. */ \
497 SC(code_stubs, V8.CodeStubs) \
498 /* Amount of stub code. */ \
499 SC(total_stubs_code_size, V8.TotalStubsCodeSize) \
500 /* Amount of (JS) compiled code. */ \
501 SC(total_compiled_code_size, V8.TotalCompiledCodeSize) \
502 SC(gc_compactor_caused_by_request, V8.GCCompactorCausedByRequest) \
503 SC(gc_compactor_caused_by_promoted_data, V8.GCCompactorCausedByPromotedData) \
504 SC(gc_compactor_caused_by_oldspace_exhaustion, \
505 V8.GCCompactorCausedByOldspaceExhaustion) \
506 SC(gc_last_resort_from_js, V8.GCLastResortFromJS) \
507 SC(gc_last_resort_from_handles, V8.GCLastResortFromHandles) \
508 /* How is the generic keyed-load stub used? */ \
509 SC(keyed_load_generic_smi, V8.KeyedLoadGenericSmi) \
510 SC(keyed_load_generic_symbol, V8.KeyedLoadGenericSymbol) \
511 SC(keyed_load_generic_lookup_cache, V8.KeyedLoadGenericLookupCache) \
512 SC(keyed_load_generic_slow, V8.KeyedLoadGenericSlow) \
513 SC(keyed_load_polymorphic_stubs, V8.KeyedLoadPolymorphicStubs) \
514 SC(keyed_load_external_array_slow, V8.KeyedLoadExternalArraySlow) \
515 /* How is the generic keyed-call stub used? */ \
516 SC(keyed_call_generic_smi_fast, V8.KeyedCallGenericSmiFast) \
517 SC(keyed_call_generic_smi_dict, V8.KeyedCallGenericSmiDict) \
518 SC(keyed_call_generic_lookup_cache, V8.KeyedCallGenericLookupCache) \
519 SC(keyed_call_generic_lookup_dict, V8.KeyedCallGenericLookupDict) \
520 SC(keyed_call_generic_slow, V8.KeyedCallGenericSlow) \
521 SC(keyed_call_generic_slow_load, V8.KeyedCallGenericSlowLoad) \
522 SC(named_load_global_stub, V8.NamedLoadGlobalStub) \
523 SC(named_store_global_inline, V8.NamedStoreGlobalInline) \
524 SC(named_store_global_inline_miss, V8.NamedStoreGlobalInlineMiss) \
525 SC(keyed_store_polymorphic_stubs, V8.KeyedStorePolymorphicStubs) \
526 SC(keyed_store_external_array_slow, V8.KeyedStoreExternalArraySlow) \
527 SC(store_normal_miss, V8.StoreNormalMiss) \
528 SC(store_normal_hit, V8.StoreNormalHit) \
529 SC(cow_arrays_created_stub, V8.COWArraysCreatedStub) \
530 SC(cow_arrays_created_runtime, V8.COWArraysCreatedRuntime) \
531 SC(cow_arrays_converted, V8.COWArraysConverted) \
532 SC(call_miss, V8.CallMiss) \
533 SC(keyed_call_miss, V8.KeyedCallMiss) \
534 SC(load_miss, V8.LoadMiss) \
535 SC(keyed_load_miss, V8.KeyedLoadMiss) \
536 SC(call_const, V8.CallConst) \
537 SC(call_const_fast_api, V8.CallConstFastApi) \
538 SC(call_const_interceptor, V8.CallConstInterceptor) \
539 SC(call_const_interceptor_fast_api, V8.CallConstInterceptorFastApi) \
540 SC(call_global_inline, V8.CallGlobalInline) \
541 SC(call_global_inline_miss, V8.CallGlobalInlineMiss) \
542 SC(constructed_objects, V8.ConstructedObjects) \
543 SC(constructed_objects_runtime, V8.ConstructedObjectsRuntime) \
544 SC(negative_lookups, V8.NegativeLookups) \
545 SC(negative_lookups_miss, V8.NegativeLookupsMiss) \
546 SC(megamorphic_stub_cache_probes, V8.MegamorphicStubCacheProbes) \
547 SC(megamorphic_stub_cache_misses, V8.MegamorphicStubCacheMisses) \
548 SC(megamorphic_stub_cache_updates, V8.MegamorphicStubCacheUpdates) \
549 SC(array_function_runtime, V8.ArrayFunctionRuntime) \
550 SC(array_function_native, V8.ArrayFunctionNative) \
551 SC(for_in, V8.ForIn) \
552 SC(enum_cache_hits, V8.EnumCacheHits) \
553 SC(enum_cache_misses, V8.EnumCacheMisses) \
554 SC(fast_new_closure_total, V8.FastNewClosureTotal) \
555 SC(fast_new_closure_try_optimized, V8.FastNewClosureTryOptimized) \
556 SC(fast_new_closure_install_optimized, V8.FastNewClosureInstallOptimized) \
557 SC(string_add_runtime, V8.StringAddRuntime) \
558 SC(string_add_native, V8.StringAddNative) \
559 SC(string_add_runtime_ext_to_one_byte, V8.StringAddRuntimeExtToOneByte) \
560 SC(sub_string_runtime, V8.SubStringRuntime) \
561 SC(sub_string_native, V8.SubStringNative) \
562 SC(string_add_make_two_char, V8.StringAddMakeTwoChar) \
563 SC(string_compare_native, V8.StringCompareNative) \
564 SC(string_compare_runtime, V8.StringCompareRuntime) \
565 SC(regexp_entry_runtime, V8.RegExpEntryRuntime) \
566 SC(regexp_entry_native, V8.RegExpEntryNative) \
567 SC(number_to_string_native, V8.NumberToStringNative) \
568 SC(number_to_string_runtime, V8.NumberToStringRuntime) \
569 SC(math_acos, V8.MathAcos) \
570 SC(math_asin, V8.MathAsin) \
571 SC(math_atan, V8.MathAtan) \
572 SC(math_atan2, V8.MathAtan2) \
573 SC(math_clz32, V8.MathClz32) \
574 SC(math_exp, V8.MathExp) \
575 SC(math_floor, V8.MathFloor) \
576 SC(math_log, V8.MathLog) \
577 SC(math_pow, V8.MathPow) \
578 SC(math_round, V8.MathRound) \
579 SC(math_sqrt, V8.MathSqrt) \
580 SC(stack_interrupts, V8.StackInterrupts) \
581 SC(runtime_profiler_ticks, V8.RuntimeProfilerTicks) \
582 SC(bounds_checks_eliminated, V8.BoundsChecksEliminated) \
583 SC(bounds_checks_hoisted, V8.BoundsChecksHoisted) \
584 SC(soft_deopts_requested, V8.SoftDeoptsRequested) \
585 SC(soft_deopts_inserted, V8.SoftDeoptsInserted) \
586 SC(soft_deopts_executed, V8.SoftDeoptsExecuted) \
587 /* Number of write barriers in generated code. */ \
588 SC(write_barriers_dynamic, V8.WriteBarriersDynamic) \
589 SC(write_barriers_static, V8.WriteBarriersStatic) \
590 SC(new_space_bytes_available, V8.MemoryNewSpaceBytesAvailable) \
591 SC(new_space_bytes_committed, V8.MemoryNewSpaceBytesCommitted) \
592 SC(new_space_bytes_used, V8.MemoryNewSpaceBytesUsed) \
593 SC(old_pointer_space_bytes_available, \
594 V8.MemoryOldPointerSpaceBytesAvailable) \
595 SC(old_pointer_space_bytes_committed, \
596 V8.MemoryOldPointerSpaceBytesCommitted) \
597 SC(old_pointer_space_bytes_used, V8.MemoryOldPointerSpaceBytesUsed) \
598 SC(old_data_space_bytes_available, V8.MemoryOldDataSpaceBytesAvailable) \
599 SC(old_data_space_bytes_committed, V8.MemoryOldDataSpaceBytesCommitted) \
600 SC(old_data_space_bytes_used, V8.MemoryOldDataSpaceBytesUsed) \
601 SC(code_space_bytes_available, V8.MemoryCodeSpaceBytesAvailable) \
602 SC(code_space_bytes_committed, V8.MemoryCodeSpaceBytesCommitted) \
603 SC(code_space_bytes_used, V8.MemoryCodeSpaceBytesUsed) \
604 SC(map_space_bytes_available, V8.MemoryMapSpaceBytesAvailable) \
605 SC(map_space_bytes_committed, V8.MemoryMapSpaceBytesCommitted) \
606 SC(map_space_bytes_used, V8.MemoryMapSpaceBytesUsed) \
607 SC(cell_space_bytes_available, V8.MemoryCellSpaceBytesAvailable) \
608 SC(cell_space_bytes_committed, V8.MemoryCellSpaceBytesCommitted) \
609 SC(cell_space_bytes_used, V8.MemoryCellSpaceBytesUsed) \
610 SC(lo_space_bytes_available, V8.MemoryLoSpaceBytesAvailable) \
611 SC(lo_space_bytes_committed, V8.MemoryLoSpaceBytesCommitted) \
612 SC(lo_space_bytes_used, V8.MemoryLoSpaceBytesUsed)
615 // This file contains all the v8 counters that are in use.
618 #define HR(name, caption, min, max, num_buckets) \
619 Histogram* name() { return &name##_; }
620 HISTOGRAM_RANGE_LIST(HR)
623 #define HT(name, caption, max, res) \
624 HistogramTimer* name() { return &name##_; }
625 HISTOGRAM_TIMER_LIST(HT)
628 #define AHT(name, caption) \
629 AggregatableHistogramTimer* name() { return &name##_; }
630 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT)
633 #define HP(name, caption) \
634 Histogram* name() { return &name##_; }
635 HISTOGRAM_PERCENTAGE_LIST(HP)
638 #define HM(name, caption) \
639 Histogram* name() { return &name##_; }
640 HISTOGRAM_MEMORY_LIST(HM)
643 #define SC(name, caption) \
644 StatsCounter* name() { return &name##_; }
645 STATS_COUNTER_LIST_1(SC)
646 STATS_COUNTER_LIST_2(SC)
650 StatsCounter* count_of_##name() { return &count_of_##name##_; } \
651 StatsCounter* size_of_##name() { return &size_of_##name##_; }
652 INSTANCE_TYPE_LIST(SC)
656 StatsCounter* count_of_CODE_TYPE_##name() \
657 { return &count_of_CODE_TYPE_##name##_; } \
658 StatsCounter* size_of_CODE_TYPE_##name() \
659 { return &size_of_CODE_TYPE_##name##_; }
664 StatsCounter* count_of_FIXED_ARRAY_##name() \
665 { return &count_of_FIXED_ARRAY_##name##_; } \
666 StatsCounter* size_of_FIXED_ARRAY_##name() \
667 { return &size_of_FIXED_ARRAY_##name##_; }
668 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(SC)
672 StatsCounter* count_of_CODE_AGE_##name() \
673 { return &count_of_CODE_AGE_##name##_; } \
674 StatsCounter* size_of_CODE_AGE_##name() \
675 { return &size_of_CODE_AGE_##name##_; }
676 CODE_AGE_LIST_COMPLETE(SC)
680 #define RATE_ID(name, caption, max, res) k_##name,
681 HISTOGRAM_TIMER_LIST(RATE_ID)
683 #define AGGREGATABLE_ID(name, caption) k_##name,
684 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AGGREGATABLE_ID)
685 #undef AGGREGATABLE_ID
686 #define PERCENTAGE_ID(name, caption) k_##name,
687 HISTOGRAM_PERCENTAGE_LIST(PERCENTAGE_ID)
689 #define MEMORY_ID(name, caption) k_##name,
690 HISTOGRAM_MEMORY_LIST(MEMORY_ID)
692 #define COUNTER_ID(name, caption) k_##name,
693 STATS_COUNTER_LIST_1(COUNTER_ID)
694 STATS_COUNTER_LIST_2(COUNTER_ID)
696 #define COUNTER_ID(name) kCountOf##name, kSizeOf##name,
697 INSTANCE_TYPE_LIST(COUNTER_ID)
699 #define COUNTER_ID(name) kCountOfCODE_TYPE_##name, \
700 kSizeOfCODE_TYPE_##name,
701 CODE_KIND_LIST(COUNTER_ID)
703 #define COUNTER_ID(name) kCountOfFIXED_ARRAY__##name, \
704 kSizeOfFIXED_ARRAY__##name,
705 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(COUNTER_ID)
707 #define COUNTER_ID(name) kCountOfCODE_AGE__##name, \
708 kSizeOfCODE_AGE__##name,
709 CODE_AGE_LIST_COMPLETE(COUNTER_ID)
714 void ResetCounters();
715 void ResetHistograms();
718 #define HR(name, caption, min, max, num_buckets) Histogram name##_;
719 HISTOGRAM_RANGE_LIST(HR)
722 #define HT(name, caption, max, res) HistogramTimer name##_;
723 HISTOGRAM_TIMER_LIST(HT)
726 #define AHT(name, caption) \
727 AggregatableHistogramTimer name##_;
728 AGGREGATABLE_HISTOGRAM_TIMER_LIST(AHT)
731 #define HP(name, caption) \
733 HISTOGRAM_PERCENTAGE_LIST(HP)
736 #define HM(name, caption) \
738 HISTOGRAM_MEMORY_LIST(HM)
741 #define SC(name, caption) \
742 StatsCounter name##_;
743 STATS_COUNTER_LIST_1(SC)
744 STATS_COUNTER_LIST_2(SC)
748 StatsCounter size_of_##name##_; \
749 StatsCounter count_of_##name##_;
750 INSTANCE_TYPE_LIST(SC)
754 StatsCounter size_of_CODE_TYPE_##name##_; \
755 StatsCounter count_of_CODE_TYPE_##name##_;
760 StatsCounter size_of_FIXED_ARRAY_##name##_; \
761 StatsCounter count_of_FIXED_ARRAY_##name##_;
762 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(SC)
766 StatsCounter size_of_CODE_AGE_##name##_; \
767 StatsCounter count_of_CODE_AGE_##name##_;
768 CODE_AGE_LIST_COMPLETE(SC)
771 friend class Isolate;
773 explicit Counters(Isolate* isolate);
775 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters);
778 } } // namespace v8::internal
780 #endif // V8_COUNTERS_H_