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 #include "src/counters.h" | 9 #include "src/counters.h" |
10 #include "src/globals.h" | 10 #include "src/globals.h" |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
51 }; | 51 }; |
52 | 52 |
53 typedef std::pair<uint64_t, double> BytesAndDuration; | 53 typedef std::pair<uint64_t, double> BytesAndDuration; |
54 | 54 |
55 inline BytesAndDuration MakeBytesAndDuration(uint64_t bytes, double duration) { | 55 inline BytesAndDuration MakeBytesAndDuration(uint64_t bytes, double duration) { |
56 return std::make_pair(bytes, duration); | 56 return std::make_pair(bytes, duration); |
57 } | 57 } |
58 | 58 |
59 enum ScavengeSpeedMode { kForAllObjects, kForSurvivedObjects }; | 59 enum ScavengeSpeedMode { kForAllObjects, kForSurvivedObjects }; |
60 | 60 |
| 61 #define TRACER_SCOPES(F) \ |
| 62 F(EXTERNAL_WEAK_GLOBAL_HANDLES) \ |
| 63 F(MC_CLEAR) \ |
| 64 F(MC_CLEAR_CODE_FLUSH) \ |
| 65 F(MC_CLEAR_DEPENDENT_CODE) \ |
| 66 F(MC_CLEAR_GLOBAL_HANDLES) \ |
| 67 F(MC_CLEAR_MAPS) \ |
| 68 F(MC_CLEAR_SLOTS_BUFFER) \ |
| 69 F(MC_CLEAR_STORE_BUFFER) \ |
| 70 F(MC_CLEAR_STRING_TABLE) \ |
| 71 F(MC_CLEAR_WEAK_CELLS) \ |
| 72 F(MC_CLEAR_WEAK_COLLECTIONS) \ |
| 73 F(MC_CLEAR_WEAK_LISTS) \ |
| 74 F(MC_EVACUATE) \ |
| 75 F(MC_EVACUATE_CANDIDATES) \ |
| 76 F(MC_EVACUATE_CLEAN_UP) \ |
| 77 F(MC_EVACUATE_COPY) \ |
| 78 F(MC_EVACUATE_UPDATE_POINTERS) \ |
| 79 F(MC_EVACUATE_UPDATE_POINTERS_BETWEEN_EVACUATED) \ |
| 80 F(MC_EVACUATE_UPDATE_POINTERS_TO_EVACUATED) \ |
| 81 F(MC_EVACUATE_UPDATE_POINTERS_TO_NEW) \ |
| 82 F(MC_EVACUATE_UPDATE_POINTERS_WEAK) \ |
| 83 F(MC_EXTERNAL_EPILOGUE) \ |
| 84 F(MC_EXTERNAL_PROLOGUE) \ |
| 85 F(MC_FINISH) \ |
| 86 F(MC_INCREMENTAL_FINALIZE) \ |
| 87 F(MC_INCREMENTAL_EXTERNAL_EPILOGUE) \ |
| 88 F(MC_INCREMENTAL_EXTERNAL_PROLOGUE) \ |
| 89 F(MC_MARK) \ |
| 90 F(MC_MARK_FINISH_INCREMENTAL) \ |
| 91 F(MC_MARK_PREPARE_CODE_FLUSH) \ |
| 92 F(MC_MARK_ROOTS) \ |
| 93 F(MC_MARK_WEAK_CLOSURE) \ |
| 94 F(MC_MARK_WEAK_CLOSURE_EPHEMERAL) \ |
| 95 F(MC_MARK_WEAK_CLOSURE_WEAK_HANDLES) \ |
| 96 F(MC_MARK_WEAK_CLOSURE_WEAK_ROOTS) \ |
| 97 F(MC_MARK_WEAK_CLOSURE_HARMONY) \ |
| 98 F(MC_SWEEP) \ |
| 99 F(MC_SWEEP_CODE) \ |
| 100 F(MC_SWEEP_MAP) \ |
| 101 F(MC_SWEEP_OLD) \ |
| 102 F(SCAVENGER_CODE_FLUSH_CANDIDATES) \ |
| 103 F(SCAVENGER_EXTERNAL_EPILOGUE) \ |
| 104 F(SCAVENGER_EXTERNAL_PROLOGUE) \ |
| 105 F(SCAVENGER_OBJECT_GROUPS) \ |
| 106 F(SCAVENGER_OLD_TO_NEW_POINTERS) \ |
| 107 F(SCAVENGER_ROOTS) \ |
| 108 F(SCAVENGER_SCAVENGE) \ |
| 109 F(SCAVENGER_SEMISPACE) \ |
| 110 F(SCAVENGER_WEAK) |
| 111 |
| 112 #define TRACE_GC(tracer, scope_id) \ |
| 113 GCTracer::Scope::ScopeId gc_tracer_scope_id(scope_id); \ |
| 114 GCTracer::Scope gc_tracer_scope(tracer, gc_tracer_scope_id); \ |
| 115 TRACE_EVENT0(TRACE_DISABLED_BY_DEFAULT("v8"), \ |
| 116 GCTracer::Scope::Name(gc_tracer_scope_id)) |
| 117 |
61 // GCTracer collects and prints ONE line after each garbage collector | 118 // GCTracer collects and prints ONE line after each garbage collector |
62 // invocation IFF --trace_gc is used. | 119 // invocation IFF --trace_gc is used. |
63 // TODO(ernstm): Unit tests. | 120 // TODO(ernstm): Unit tests. |
64 class GCTracer { | 121 class GCTracer { |
65 public: | 122 public: |
66 class Scope { | 123 class Scope { |
67 public: | 124 public: |
68 enum ScopeId { | 125 enum ScopeId { |
69 EXTERNAL_WEAK_GLOBAL_HANDLES, | 126 #define DEFINE_SCOPE(scope) scope, |
70 MC_CLEAR, | 127 TRACER_SCOPES(DEFINE_SCOPE) |
71 MC_CLEAR_CODE_FLUSH, | 128 #undef DEFINE_SCOPE |
72 MC_CLEAR_DEPENDENT_CODE, | 129 NUMBER_OF_SCOPES |
73 MC_CLEAR_GLOBAL_HANDLES, | |
74 MC_CLEAR_MAPS, | |
75 MC_CLEAR_SLOTS_BUFFER, | |
76 MC_CLEAR_STORE_BUFFER, | |
77 MC_CLEAR_STRING_TABLE, | |
78 MC_CLEAR_WEAK_CELLS, | |
79 MC_CLEAR_WEAK_COLLECTIONS, | |
80 MC_CLEAR_WEAK_LISTS, | |
81 MC_EVACUATE, | |
82 MC_EVACUATE_CANDIDATES, | |
83 MC_EVACUATE_CLEAN_UP, | |
84 MC_EVACUATE_COPY, | |
85 MC_EVACUATE_UPDATE_POINTERS, | |
86 MC_EVACUATE_UPDATE_POINTERS_BETWEEN_EVACUATED, | |
87 MC_EVACUATE_UPDATE_POINTERS_TO_EVACUATED, | |
88 MC_EVACUATE_UPDATE_POINTERS_TO_NEW, | |
89 MC_EVACUATE_UPDATE_POINTERS_WEAK, | |
90 MC_EXTERNAL_EPILOGUE, | |
91 MC_EXTERNAL_PROLOGUE, | |
92 MC_FINISH, | |
93 MC_INCREMENTAL_FINALIZE, | |
94 MC_INCREMENTAL_EXTERNAL_EPILOGUE, | |
95 MC_INCREMENTAL_EXTERNAL_PROLOGUE, | |
96 MC_MARK, | |
97 MC_MARK_FINISH_INCREMENTAL, | |
98 MC_MARK_PREPARE_CODE_FLUSH, | |
99 MC_MARK_ROOTS, | |
100 MC_MARK_WEAK_CLOSURE, | |
101 MC_MARK_WEAK_CLOSURE_EPHEMERAL, | |
102 MC_MARK_WEAK_CLOSURE_WEAK_HANDLES, | |
103 MC_MARK_WEAK_CLOSURE_WEAK_ROOTS, | |
104 MC_MARK_WEAK_CLOSURE_HARMONY, | |
105 MC_SWEEP, | |
106 MC_SWEEP_CODE, | |
107 MC_SWEEP_MAP, | |
108 MC_SWEEP_OLD, | |
109 SCAVENGER_CODE_FLUSH_CANDIDATES, | |
110 SCAVENGER_EXTERNAL_EPILOGUE, | |
111 SCAVENGER_EXTERNAL_PROLOGUE, | |
112 SCAVENGER_OBJECT_GROUPS, | |
113 SCAVENGER_OLD_TO_NEW_POINTERS, | |
114 SCAVENGER_ROOTS, | |
115 SCAVENGER_SCAVENGE, | |
116 SCAVENGER_SEMISPACE, | |
117 SCAVENGER_WEAK, | |
118 NUMBER_OF_SCOPES | |
119 }; | 130 }; |
120 | 131 |
121 Scope(GCTracer* tracer, ScopeId scope); | 132 Scope(GCTracer* tracer, ScopeId scope); |
122 ~Scope(); | 133 ~Scope(); |
| 134 static const char* Name(ScopeId id); |
123 | 135 |
124 private: | 136 private: |
125 GCTracer* tracer_; | 137 GCTracer* tracer_; |
126 ScopeId scope_; | 138 ScopeId scope_; |
127 double start_time_; | 139 double start_time_; |
128 RuntimeCallTimer timer_; | 140 RuntimeCallTimer timer_; |
129 | 141 |
130 DISALLOW_COPY_AND_ASSIGN(Scope); | 142 DISALLOW_COPY_AND_ASSIGN(Scope); |
131 }; | 143 }; |
132 | 144 |
(...skipping 345 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 RingBuffer<BytesAndDuration> recorded_old_generation_allocations_; | 490 RingBuffer<BytesAndDuration> recorded_old_generation_allocations_; |
479 RingBuffer<double> recorded_context_disposal_times_; | 491 RingBuffer<double> recorded_context_disposal_times_; |
480 RingBuffer<double> recorded_survival_ratios_; | 492 RingBuffer<double> recorded_survival_ratios_; |
481 | 493 |
482 DISALLOW_COPY_AND_ASSIGN(GCTracer); | 494 DISALLOW_COPY_AND_ASSIGN(GCTracer); |
483 }; | 495 }; |
484 } // namespace internal | 496 } // namespace internal |
485 } // namespace v8 | 497 } // namespace v8 |
486 | 498 |
487 #endif // V8_HEAP_GC_TRACER_H_ | 499 #endif // V8_HEAP_GC_TRACER_H_ |
OLD | NEW |