Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: src/counters.h

Issue 827993003: Integrate Chrome tracing with V8 (WIP) (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Cleanup Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « include/v8-tracing.h ('k') | src/counters.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_COUNTERS_H_ 5 #ifndef V8_COUNTERS_H_
6 #define V8_COUNTERS_H_ 6 #define V8_COUNTERS_H_
7 7
8 #include "include/v8.h" 8 #include "include/v8.h"
9 #include "src/allocation.h" 9 #include "src/allocation.h"
10 #include "src/base/platform/elapsed-timer.h" 10 #include "src/base/platform/elapsed-timer.h"
11 #include "src/globals.h" 11 #include "src/globals.h"
12 #include "src/log.h"
12 #include "src/objects.h" 13 #include "src/objects.h"
13 14
14 namespace v8 { 15 namespace v8 {
15 namespace internal { 16 namespace internal {
16 17
17 // StatsCounters is an interface for plugging into external 18 // StatsCounters is an interface for plugging into external
18 // counters for monitoring. Counters can be looked up and 19 // counters for monitoring. Counters can be looked up and
19 // manipulated by name. 20 // manipulated by name.
20 21
21 class StatsTable { 22 class StatsTable {
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 int num_buckets_; 218 int num_buckets_;
218 void* histogram_; 219 void* histogram_;
219 bool lookup_done_; 220 bool lookup_done_;
220 Isolate* isolate_; 221 Isolate* isolate_;
221 }; 222 };
222 223
223 // A HistogramTimer allows distributions of results to be created. 224 // A HistogramTimer allows distributions of results to be created.
224 class HistogramTimer : public Histogram { 225 class HistogramTimer : public Histogram {
225 public: 226 public:
226 HistogramTimer() { } 227 HistogramTimer() { }
227 HistogramTimer(const char* name, 228 HistogramTimer(const char* name, int min, int max, int num_buckets,
228 int min, 229 Isolate* isolate, Logger::Overhead overhead)
229 int max, 230 : Histogram(name, min, max, num_buckets, isolate), overhead_(overhead) {}
230 int num_buckets,
231 Isolate* isolate)
232 : Histogram(name, min, max, num_buckets, isolate) {}
233 231
234 // Start the timer. 232 // Start the timer.
235 void Start(); 233 void Start();
236 234
237 // Stop the timer and record the results. 235 // Stop the timer and record the results.
238 void Stop(); 236 void Stop();
239 237
240 // Returns true if the timer is running. 238 // Returns true if the timer is running.
241 bool Running() { 239 bool Running() {
242 return Enabled() && timer_.IsStarted(); 240 return Enabled() && timer_.IsStarted();
243 } 241 }
244 242
243 Logger::Overhead overhead() { return overhead_; }
244
245 // TODO(bmeurer): Remove this when HistogramTimerScope is fixed. 245 // TODO(bmeurer): Remove this when HistogramTimerScope is fixed.
246 #ifdef DEBUG 246 #ifdef DEBUG
247 base::ElapsedTimer* timer() { return &timer_; } 247 base::ElapsedTimer* timer() { return &timer_; }
248 #endif 248 #endif
249 249
250 private: 250 private:
251 base::ElapsedTimer timer_; 251 base::ElapsedTimer timer_;
252 Logger::Overhead overhead_;
252 }; 253 };
253 254
254 // Helper class for scoping a HistogramTimer. 255 // Helper class for scoping a HistogramTimer.
255 // TODO(bmeurer): The ifdeffery is an ugly hack around the fact that the 256 // 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 // 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 // into JavaScript and all bets are off), but ElapsedTimer is not
258 // reentry-safe. Fix this properly and remove |allow_nesting|. 259 // reentry-safe. Fix this properly and remove |allow_nesting|.
259 class HistogramTimerScope BASE_EMBEDDED { 260 class HistogramTimerScope BASE_EMBEDDED {
260 public: 261 public:
261 explicit HistogramTimerScope(HistogramTimer* timer, 262 explicit HistogramTimerScope(HistogramTimer* timer,
(...skipping 28 matching lines...) Expand all
290 bool skipped_timer_start_; 291 bool skipped_timer_start_;
291 #endif 292 #endif
292 }; 293 };
293 294
294 #define HISTOGRAM_RANGE_LIST(HR) \ 295 #define HISTOGRAM_RANGE_LIST(HR) \
295 /* Generic range histograms */ \ 296 /* Generic range histograms */ \
296 HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101) \ 297 HR(gc_idle_time_allotted_in_ms, V8.GCIdleTimeAllottedInMS, 0, 10000, 101) \
297 HR(gc_idle_time_limit_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \ 298 HR(gc_idle_time_limit_overshot, V8.GCIdleTimeLimit.Overshot, 0, 10000, 101) \
298 HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, 101) 299 HR(gc_idle_time_limit_undershot, V8.GCIdleTimeLimit.Undershot, 0, 10000, 101)
299 300
300 #define HISTOGRAM_TIMER_LIST(HT) \ 301 #define HISTOGRAM_TIMER_LIST(HT) \
301 /* Garbage collection timers. */ \ 302 /* Garbage collection timers. */ \
302 HT(gc_compactor, V8.GCCompactor) \ 303 HT(gc_compactor, V8.GCCompactor, LOW) \
303 HT(gc_scavenger, V8.GCScavenger) \ 304 HT(gc_scavenger, V8.GCScavenger, LOW) \
304 HT(gc_context, V8.GCContext) /* GC context cleanup time */ \ 305 HT(gc_context, V8.GCContext, NORMAL) /* GC context cleanup time */ \
305 HT(gc_idle_notification, V8.GCIdleNotification) \ 306 HT(gc_idle_notification, V8.GCIdleNotification, LOW) \
306 HT(gc_incremental_marking, V8.GCIncrementalMarking) \ 307 HT(gc_incremental_marking, V8.GCIncrementalMarking, LOW) \
307 HT(gc_low_memory_notification, V8.GCLowMemoryNotification) \ 308 HT(gc_low_memory_notification, V8.GCLowMemoryNotification, NORMAL) \
308 /* Parsing timers. */ \ 309 /* Parsing timers. */ \
309 HT(parse, V8.Parse) \ 310 HT(parse, V8.Parse, NORMAL) \
310 HT(parse_lazy, V8.ParseLazy) \ 311 HT(parse_lazy, V8.ParseLazy, NORMAL) \
311 HT(pre_parse, V8.PreParse) \ 312 HT(pre_parse, V8.PreParse, NORMAL) \
312 /* Total compilation times. */ \ 313 /* Total compilation times. */ \
313 HT(compile, V8.Compile) \ 314 HT(compile, V8.Compile, NORMAL) \
314 HT(compile_eval, V8.CompileEval) \ 315 HT(compile_eval, V8.CompileEval, NORMAL) \
315 /* Serialization as part of compilation (code caching) */ \ 316 /* Serialization as part of compilation (code caching) */ \
316 HT(compile_serialize, V8.CompileSerialize) \ 317 HT(compile_serialize, V8.CompileSerialize, NORMAL) \
317 HT(compile_deserialize, V8.CompileDeserialize) 318 HT(compile_deserialize, V8.CompileDeserialize, NORMAL)
318
319 319
320 #define HISTOGRAM_PERCENTAGE_LIST(HP) \ 320 #define HISTOGRAM_PERCENTAGE_LIST(HP) \
321 /* Heap fragmentation. */ \ 321 /* Heap fragmentation. */ \
322 HP(external_fragmentation_total, \ 322 HP(external_fragmentation_total, \
323 V8.MemoryExternalFragmentationTotal) \ 323 V8.MemoryExternalFragmentationTotal) \
324 HP(external_fragmentation_old_pointer_space, \ 324 HP(external_fragmentation_old_pointer_space, \
325 V8.MemoryExternalFragmentationOldPointerSpace) \ 325 V8.MemoryExternalFragmentationOldPointerSpace) \
326 HP(external_fragmentation_old_data_space, \ 326 HP(external_fragmentation_old_data_space, \
327 V8.MemoryExternalFragmentationOldDataSpace) \ 327 V8.MemoryExternalFragmentationOldDataSpace) \
328 HP(external_fragmentation_code_space, \ 328 HP(external_fragmentation_code_space, \
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after
555 555
556 556
557 // This file contains all the v8 counters that are in use. 557 // This file contains all the v8 counters that are in use.
558 class Counters { 558 class Counters {
559 public: 559 public:
560 #define HR(name, caption, min, max, num_buckets) \ 560 #define HR(name, caption, min, max, num_buckets) \
561 Histogram* name() { return &name##_; } 561 Histogram* name() { return &name##_; }
562 HISTOGRAM_RANGE_LIST(HR) 562 HISTOGRAM_RANGE_LIST(HR)
563 #undef HR 563 #undef HR
564 564
565 #define HT(name, caption) \ 565 #define HT(name, caption, overhead) \
566 HistogramTimer* name() { return &name##_; } 566 HistogramTimer* name() { return &name##_; }
567 HISTOGRAM_TIMER_LIST(HT) 567 HISTOGRAM_TIMER_LIST(HT)
568 #undef HT 568 #undef HT
569 569
570 #define HP(name, caption) \ 570 #define HP(name, caption) \
571 Histogram* name() { return &name##_; } 571 Histogram* name() { return &name##_; }
572 HISTOGRAM_PERCENTAGE_LIST(HP) 572 HISTOGRAM_PERCENTAGE_LIST(HP)
573 #undef HP 573 #undef HP
574 574
575 #define HM(name, caption) \ 575 #define HM(name, caption) \
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 607
608 #define SC(name) \ 608 #define SC(name) \
609 StatsCounter* count_of_CODE_AGE_##name() \ 609 StatsCounter* count_of_CODE_AGE_##name() \
610 { return &count_of_CODE_AGE_##name##_; } \ 610 { return &count_of_CODE_AGE_##name##_; } \
611 StatsCounter* size_of_CODE_AGE_##name() \ 611 StatsCounter* size_of_CODE_AGE_##name() \
612 { return &size_of_CODE_AGE_##name##_; } 612 { return &size_of_CODE_AGE_##name##_; }
613 CODE_AGE_LIST_COMPLETE(SC) 613 CODE_AGE_LIST_COMPLETE(SC)
614 #undef SC 614 #undef SC
615 615
616 enum Id { 616 enum Id {
617 #define RATE_ID(name, caption) k_##name, 617 #define RATE_ID(name, caption, overhead) k_##name,
618 HISTOGRAM_TIMER_LIST(RATE_ID) 618 HISTOGRAM_TIMER_LIST(RATE_ID)
619 #undef RATE_ID 619 #undef RATE_ID
620 #define PERCENTAGE_ID(name, caption) k_##name, 620 #define PERCENTAGE_ID(name, caption) k_##name,
621 HISTOGRAM_PERCENTAGE_LIST(PERCENTAGE_ID) 621 HISTOGRAM_PERCENTAGE_LIST(PERCENTAGE_ID)
622 #undef PERCENTAGE_ID 622 #undef PERCENTAGE_ID
623 #define MEMORY_ID(name, caption) k_##name, 623 #define MEMORY_ID(name, caption) k_##name,
624 HISTOGRAM_MEMORY_LIST(MEMORY_ID) 624 HISTOGRAM_MEMORY_LIST(MEMORY_ID)
625 #undef MEMORY_ID 625 #undef MEMORY_ID
626 #define COUNTER_ID(name, caption) k_##name, 626 #define COUNTER_ID(name, caption) k_##name,
627 STATS_COUNTER_LIST_1(COUNTER_ID) 627 STATS_COUNTER_LIST_1(COUNTER_ID)
(...skipping 18 matching lines...) Expand all
646 }; 646 };
647 647
648 void ResetCounters(); 648 void ResetCounters();
649 void ResetHistograms(); 649 void ResetHistograms();
650 650
651 private: 651 private:
652 #define HR(name, caption, min, max, num_buckets) Histogram name##_; 652 #define HR(name, caption, min, max, num_buckets) Histogram name##_;
653 HISTOGRAM_RANGE_LIST(HR) 653 HISTOGRAM_RANGE_LIST(HR)
654 #undef HR 654 #undef HR
655 655
656 #define HT(name, caption) \ 656 #define HT(name, caption, overhead) \
657 HistogramTimer name##_; 657 HistogramTimer name##_;
658 HISTOGRAM_TIMER_LIST(HT) 658 HISTOGRAM_TIMER_LIST(HT)
659 #undef HT 659 #undef HT
660 660
661 #define HP(name, caption) \ 661 #define HP(name, caption) \
662 Histogram name##_; 662 Histogram name##_;
663 HISTOGRAM_PERCENTAGE_LIST(HP) 663 HISTOGRAM_PERCENTAGE_LIST(HP)
664 #undef HP 664 #undef HP
665 665
666 #define HM(name, caption) \ 666 #define HM(name, caption) \
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 friend class Isolate; 701 friend class Isolate;
702 702
703 explicit Counters(Isolate* isolate); 703 explicit Counters(Isolate* isolate);
704 704
705 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters); 705 DISALLOW_IMPLICIT_CONSTRUCTORS(Counters);
706 }; 706 };
707 707
708 } } // namespace v8::internal 708 } } // namespace v8::internal
709 709
710 #endif // V8_COUNTERS_H_ 710 #endif // V8_COUNTERS_H_
OLDNEW
« no previous file with comments | « include/v8-tracing.h ('k') | src/counters.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698