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/compiler-specific.h" | 8 #include "src/base/compiler-specific.h" |
9 #include "src/base/platform/platform.h" | 9 #include "src/base/platform/platform.h" |
10 #include "src/counters.h" | 10 #include "src/counters.h" |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
186 | 186 |
187 class Event { | 187 class Event { |
188 public: | 188 public: |
189 enum Type { | 189 enum Type { |
190 SCAVENGER = 0, | 190 SCAVENGER = 0, |
191 MARK_COMPACTOR = 1, | 191 MARK_COMPACTOR = 1, |
192 INCREMENTAL_MARK_COMPACTOR = 2, | 192 INCREMENTAL_MARK_COMPACTOR = 2, |
193 START = 3 | 193 START = 3 |
194 }; | 194 }; |
195 | 195 |
196 Event(Type type, const char* gc_reason, const char* collector_reason); | 196 Event(Type type, GarbageCollectionReason gc_reason, |
197 const char* collector_reason); | |
197 | 198 |
198 // Returns a string describing the event type. | 199 // Returns a string describing the event type. |
199 const char* TypeName(bool short_name) const; | 200 const char* TypeName(bool short_name) const; |
200 | 201 |
201 // Type of event | 202 // Type of event |
202 Type type; | 203 Type type; |
203 | 204 |
204 const char* gc_reason; | 205 GarbageCollectionReason gc_reason; |
205 const char* collector_reason; | 206 const char* collector_reason; |
206 | 207 |
207 // Timestamp set in the constructor. | 208 // Timestamp set in the constructor. |
208 double start_time; | 209 double start_time; |
209 | 210 |
210 // Timestamp set in the destructor. | 211 // Timestamp set in the destructor. |
211 double end_time; | 212 double end_time; |
212 | 213 |
213 // Memory reduction flag set. | 214 // Memory reduction flag set. |
214 bool reduce_memory; | 215 bool reduce_memory; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
264 // Holds details for incremental marking scopes. | 265 // Holds details for incremental marking scopes. |
265 IncrementalMarkingInfos | 266 IncrementalMarkingInfos |
266 incremental_marking_scopes[Scope::NUMBER_OF_INCREMENTAL_SCOPES]; | 267 incremental_marking_scopes[Scope::NUMBER_OF_INCREMENTAL_SCOPES]; |
267 }; | 268 }; |
268 | 269 |
269 static const int kThroughputTimeFrameMs = 5000; | 270 static const int kThroughputTimeFrameMs = 5000; |
270 | 271 |
271 explicit GCTracer(Heap* heap); | 272 explicit GCTracer(Heap* heap); |
272 | 273 |
273 // Start collecting data. | 274 // Start collecting data. |
274 void Start(GarbageCollector collector, const char* gc_reason, | 275 void Start(GarbageCollector collector, GarbageCollectionReason gc_reason, |
275 const char* collector_reason); | 276 const char* collector_reason); |
276 | 277 |
277 // Stop collecting data and print results. | 278 // Stop collecting data and print results. |
278 void Stop(GarbageCollector collector); | 279 void Stop(GarbageCollector collector); |
279 | 280 |
280 // Sample and accumulate bytes allocated since the last GC. | 281 // Sample and accumulate bytes allocated since the last GC. |
281 void SampleAllocation(double current_ms, size_t new_space_counter_bytes, | 282 void SampleAllocation(double current_ms, size_t new_space_counter_bytes, |
282 size_t old_generation_counter_bytes); | 283 size_t old_generation_counter_bytes); |
283 | 284 |
284 // Log the accumulated new space allocation bytes. | 285 // Log the accumulated new space allocation bytes. |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
387 V8_INLINE void AddScopeSample(Scope::ScopeId scope, double duration) { | 388 V8_INLINE void AddScopeSample(Scope::ScopeId scope, double duration) { |
388 DCHECK(scope < Scope::NUMBER_OF_SCOPES); | 389 DCHECK(scope < Scope::NUMBER_OF_SCOPES); |
389 if (scope >= Scope::FIRST_INCREMENTAL_SCOPE && | 390 if (scope >= Scope::FIRST_INCREMENTAL_SCOPE && |
390 scope <= Scope::LAST_INCREMENTAL_SCOPE) { | 391 scope <= Scope::LAST_INCREMENTAL_SCOPE) { |
391 incremental_marking_scopes_[scope].Update(duration); | 392 incremental_marking_scopes_[scope].Update(duration); |
392 } else { | 393 } else { |
393 current_.scopes[scope] += duration; | 394 current_.scopes[scope] += duration; |
394 } | 395 } |
395 } | 396 } |
396 | 397 |
398 static const char* GarbageCollectionReasonToString( | |
Michael Lippautz
2016/09/07 07:28:31
nit: I would move the function somewhere into heap
ulan
2016/09/07 09:25:12
Done.
| |
399 GarbageCollectionReason gc_reason); | |
400 | |
397 private: | 401 private: |
398 FRIEND_TEST(GCTracer, AverageSpeed); | 402 FRIEND_TEST(GCTracer, AverageSpeed); |
399 FRIEND_TEST(GCTracerTest, AllocationThroughput); | 403 FRIEND_TEST(GCTracerTest, AllocationThroughput); |
400 FRIEND_TEST(GCTracerTest, NewSpaceAllocationThroughput); | 404 FRIEND_TEST(GCTracerTest, NewSpaceAllocationThroughput); |
401 FRIEND_TEST(GCTracerTest, NewSpaceAllocationThroughputWithProvidedTime); | 405 FRIEND_TEST(GCTracerTest, NewSpaceAllocationThroughputWithProvidedTime); |
402 FRIEND_TEST(GCTracerTest, OldGenerationAllocationThroughputWithProvidedTime); | 406 FRIEND_TEST(GCTracerTest, OldGenerationAllocationThroughputWithProvidedTime); |
403 FRIEND_TEST(GCTracerTest, RegularScope); | 407 FRIEND_TEST(GCTracerTest, RegularScope); |
404 FRIEND_TEST(GCTracerTest, IncrementalMarkingDetails); | 408 FRIEND_TEST(GCTracerTest, IncrementalMarkingDetails); |
405 FRIEND_TEST(GCTracerTest, IncrementalScope); | 409 FRIEND_TEST(GCTracerTest, IncrementalScope); |
406 | 410 |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
509 RingBuffer<BytesAndDuration> recorded_old_generation_allocations_; | 513 RingBuffer<BytesAndDuration> recorded_old_generation_allocations_; |
510 RingBuffer<double> recorded_context_disposal_times_; | 514 RingBuffer<double> recorded_context_disposal_times_; |
511 RingBuffer<double> recorded_survival_ratios_; | 515 RingBuffer<double> recorded_survival_ratios_; |
512 | 516 |
513 DISALLOW_COPY_AND_ASSIGN(GCTracer); | 517 DISALLOW_COPY_AND_ASSIGN(GCTracer); |
514 }; | 518 }; |
515 } // namespace internal | 519 } // namespace internal |
516 } // namespace v8 | 520 } // namespace v8 |
517 | 521 |
518 #endif // V8_HEAP_GC_TRACER_H_ | 522 #endif // V8_HEAP_GC_TRACER_H_ |
OLD | NEW |