OLD | NEW |
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #ifndef VM_SCAVENGER_H_ | 5 #ifndef VM_SCAVENGER_H_ |
6 #define VM_SCAVENGER_H_ | 6 #define VM_SCAVENGER_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "platform/utils.h" | 9 #include "platform/utils.h" |
10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
11 #include "vm/globals.h" | 11 #include "vm/globals.h" |
12 #include "vm/raw_object.h" | 12 #include "vm/raw_object.h" |
13 #include "vm/virtual_memory.h" | 13 #include "vm/virtual_memory.h" |
14 #include "vm/visitor.h" | 14 #include "vm/visitor.h" |
15 | 15 |
16 namespace dart { | 16 namespace dart { |
17 | 17 |
18 // Forward declarations. | 18 // Forward declarations. |
19 class Heap; | 19 class Heap; |
20 class Isolate; | 20 class Isolate; |
| 21 class JSONObject; |
21 class ScavengerVisitor; | 22 class ScavengerVisitor; |
22 | 23 |
23 DECLARE_FLAG(bool, gc_at_alloc); | 24 DECLARE_FLAG(bool, gc_at_alloc); |
24 | 25 |
25 class Scavenger { | 26 class Scavenger { |
26 public: | 27 public: |
27 Scavenger(Heap* heap, intptr_t max_capacity_in_words, uword object_alignment); | 28 Scavenger(Heap* heap, intptr_t max_capacity_in_words, uword object_alignment); |
28 ~Scavenger(); | 29 ~Scavenger(); |
29 | 30 |
30 // Check whether this Scavenger contains this address. | 31 // Check whether this Scavenger contains this address. |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 *end = to_->end(); | 83 *end = to_->end(); |
83 } | 84 } |
84 | 85 |
85 // Returns true if the last scavenge had a promotion failure. | 86 // Returns true if the last scavenge had a promotion failure. |
86 bool HadPromotionFailure() { | 87 bool HadPromotionFailure() { |
87 return had_promotion_failure_; | 88 return had_promotion_failure_; |
88 } | 89 } |
89 | 90 |
90 void WriteProtect(bool read_only); | 91 void WriteProtect(bool read_only); |
91 | 92 |
| 93 void AddGCTime(int64_t micros) { |
| 94 gc_time_micros_ += micros; |
| 95 } |
| 96 |
| 97 int64_t gc_time_micros() const { |
| 98 return gc_time_micros_; |
| 99 } |
| 100 |
| 101 void IncrementCollections() { |
| 102 collections_++; |
| 103 } |
| 104 |
| 105 intptr_t collections() const { |
| 106 return collections_; |
| 107 } |
| 108 |
| 109 void PrintToJSONObject(JSONObject* object); |
| 110 |
92 private: | 111 private: |
93 // Ids for time and data records in Heap::GCStats. | 112 // Ids for time and data records in Heap::GCStats. |
94 enum { | 113 enum { |
95 // Time | 114 // Time |
96 kVisitIsolateRoots = 0, | 115 kVisitIsolateRoots = 0, |
97 kIterateStoreBuffers = 1, | 116 kIterateStoreBuffers = 1, |
98 kProcessToSpace = 2, | 117 kProcessToSpace = 2, |
99 kIterateWeaks = 3, | 118 kIterateWeaks = 3, |
100 // Data | 119 // Data |
101 kStoreBufferEntries = 0, | 120 kStoreBufferEntries = 0, |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
165 uword survivor_end_; | 184 uword survivor_end_; |
166 | 185 |
167 // All object are aligned to this value. | 186 // All object are aligned to this value. |
168 uword object_alignment_; | 187 uword object_alignment_; |
169 | 188 |
170 // Keep track whether a scavenge is currently running. | 189 // Keep track whether a scavenge is currently running. |
171 bool scavenging_; | 190 bool scavenging_; |
172 // Keep track whether the scavenge had a promotion failure. | 191 // Keep track whether the scavenge had a promotion failure. |
173 bool had_promotion_failure_; | 192 bool had_promotion_failure_; |
174 | 193 |
| 194 int64_t gc_time_micros_; |
| 195 intptr_t collections_; |
| 196 |
175 friend class ScavengerVisitor; | 197 friend class ScavengerVisitor; |
176 friend class ScavengerWeakVisitor; | 198 friend class ScavengerWeakVisitor; |
177 | 199 |
178 DISALLOW_COPY_AND_ASSIGN(Scavenger); | 200 DISALLOW_COPY_AND_ASSIGN(Scavenger); |
179 }; | 201 }; |
180 | 202 |
181 } // namespace dart | 203 } // namespace dart |
182 | 204 |
183 #endif // VM_SCAVENGER_H_ | 205 #endif // VM_SCAVENGER_H_ |
OLD | NEW |