OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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_HEAP_GC_TRACER_H_ | 5 #ifndef V8_HEAP_GC_TRACER_H_ |
6 #define V8_HEAP_GC_TRACER_H_ | 6 #define V8_HEAP_GC_TRACER_H_ |
7 | 7 |
8 #include "src/base/platform/platform.h" | 8 #include "src/base/platform/platform.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
64 elements_[end_] = element; | 64 elements_[end_] = element; |
65 end_ = (end_ + 1) % (MAX_SIZE + 1); | 65 end_ = (end_ + 1) % (MAX_SIZE + 1); |
66 if (end_ == begin_) begin_ = (begin_ + 1) % (MAX_SIZE + 1); | 66 if (end_ == begin_) begin_ = (begin_ + 1) % (MAX_SIZE + 1); |
67 } | 67 } |
68 void push_front(const T& element) { | 68 void push_front(const T& element) { |
69 begin_ = (begin_ + MAX_SIZE) % (MAX_SIZE + 1); | 69 begin_ = (begin_ + MAX_SIZE) % (MAX_SIZE + 1); |
70 if (begin_ == end_) end_ = (end_ + MAX_SIZE) % (MAX_SIZE + 1); | 70 if (begin_ == end_) end_ = (end_ + MAX_SIZE) % (MAX_SIZE + 1); |
71 elements_[begin_] = element; | 71 elements_[begin_] = element; |
72 } | 72 } |
73 | 73 |
| 74 void reset() { |
| 75 begin_ = 0; |
| 76 end_ = 0; |
| 77 } |
| 78 |
74 private: | 79 private: |
75 T elements_[MAX_SIZE + 1]; | 80 T elements_[MAX_SIZE + 1]; |
76 size_t begin_; | 81 size_t begin_; |
77 size_t end_; | 82 size_t end_; |
78 | 83 |
79 DISALLOW_COPY_AND_ASSIGN(RingBuffer); | 84 DISALLOW_COPY_AND_ASSIGN(RingBuffer); |
80 }; | 85 }; |
81 | 86 |
82 | 87 |
83 // GCTracer collects and prints ONE line after each garbage collector | 88 // GCTracer collects and prints ONE line after each garbage collector |
(...skipping 299 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 double ContextDisposalRateInMilliseconds() const; | 388 double ContextDisposalRateInMilliseconds() const; |
384 | 389 |
385 // Computes the average survival rate based on the last recorded survival | 390 // Computes the average survival rate based on the last recorded survival |
386 // events. | 391 // events. |
387 // Returns 0 if no events have been recorded. | 392 // Returns 0 if no events have been recorded. |
388 double AverageSurvivalRate() const; | 393 double AverageSurvivalRate() const; |
389 | 394 |
390 // Returns true if at least one survival event was recorded. | 395 // Returns true if at least one survival event was recorded. |
391 bool SurvivalEventsRecorded() const; | 396 bool SurvivalEventsRecorded() const; |
392 | 397 |
| 398 // Discard all recorded survival events. |
| 399 void ResetSurvivalEvents(); |
| 400 |
393 private: | 401 private: |
394 // Print one detailed trace line in name=value format. | 402 // Print one detailed trace line in name=value format. |
395 // TODO(ernstm): Move to Heap. | 403 // TODO(ernstm): Move to Heap. |
396 void PrintNVP() const; | 404 void PrintNVP() const; |
397 | 405 |
398 // Print one trace line. | 406 // Print one trace line. |
399 // TODO(ernstm): Move to Heap. | 407 // TODO(ernstm): Move to Heap. |
400 void Print() const; | 408 void Print() const; |
401 | 409 |
402 // Compute the mean duration of the events in the given ring buffer. | 410 // Compute the mean duration of the events in the given ring buffer. |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
482 | 490 |
483 // Counts how many tracers were started without stopping. | 491 // Counts how many tracers were started without stopping. |
484 int start_counter_; | 492 int start_counter_; |
485 | 493 |
486 DISALLOW_COPY_AND_ASSIGN(GCTracer); | 494 DISALLOW_COPY_AND_ASSIGN(GCTracer); |
487 }; | 495 }; |
488 } | 496 } |
489 } // namespace v8::internal | 497 } // namespace v8::internal |
490 | 498 |
491 #endif // V8_HEAP_GC_TRACER_H_ | 499 #endif // V8_HEAP_GC_TRACER_H_ |
OLD | NEW |