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_HEAP_H_ | 5 #ifndef VM_HEAP_H_ |
6 #define VM_HEAP_H_ | 6 #define VM_HEAP_H_ |
7 | 7 |
8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
10 #include "vm/flags.h" | 10 #include "vm/flags.h" |
(...skipping 25 matching lines...) Expand all Loading... | |
36 | 36 |
37 enum ApiCallbacks { | 37 enum ApiCallbacks { |
38 kIgnoreApiCallbacks, | 38 kIgnoreApiCallbacks, |
39 kInvokeApiCallbacks | 39 kInvokeApiCallbacks |
40 }; | 40 }; |
41 | 41 |
42 enum GCReason { | 42 enum GCReason { |
43 kNewSpace, | 43 kNewSpace, |
44 kPromotionFailure, | 44 kPromotionFailure, |
45 kOldSpace, | 45 kOldSpace, |
46 kCodeSpace, | |
47 kFull, | 46 kFull, |
48 kGCAtAlloc, | 47 kGCAtAlloc, |
49 kGCTestCase, | 48 kGCTestCase, |
50 }; | 49 }; |
51 | 50 |
52 // Default allocation sizes in MB for the old gen and code heaps. | 51 // Default allocation sizes in MB for the old gen and code heaps. |
53 static const intptr_t kHeapSizeInMB = 512; | 52 static const intptr_t kHeapSizeInMB = 512; |
54 static const intptr_t kCodeHeapSizeInMB = 18; | 53 static const intptr_t kCodeHeapSizeInMB = 18; |
55 | 54 |
56 ~Heap(); | 55 ~Heap(); |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
171 // replaced. A value of NULL disassociate an object from its peer. | 170 // replaced. A value of NULL disassociate an object from its peer. |
172 void SetPeer(RawObject* raw_obj, void* peer); | 171 void SetPeer(RawObject* raw_obj, void* peer); |
173 | 172 |
174 // Retrieves the peer associated with an object. Returns NULL if | 173 // Retrieves the peer associated with an object. Returns NULL if |
175 // there is no association. | 174 // there is no association. |
176 void* GetPeer(RawObject* raw_obj); | 175 void* GetPeer(RawObject* raw_obj); |
177 | 176 |
178 // Returns the number of objects with a peer. | 177 // Returns the number of objects with a peer. |
179 int64_t PeerCount() const; | 178 int64_t PeerCount() const; |
180 | 179 |
180 // Stats collection. | |
181 void RecordTime(int id, int64_t micros) { | |
182 ASSERT((id > 0) && (id < GCStats::kDataEntries)); | |
siva
2013/01/04 01:40:12
This asserts here that id should be > 0 but I see
Ivan Posva
2013/01/04 02:14:31
Done.
| |
183 stats_.times_[id] = micros; | |
184 } | |
185 | |
186 void RecordData(int id, intptr_t value) { | |
187 ASSERT((id > 0) && (id < GCStats::kDataEntries)); | |
siva
2013/01/04 01:40:12
This asserts here that id should be > 0 but I see
Ivan Posva
2013/01/04 02:14:31
Done.
Ivan Posva
2013/01/04 02:14:31
Done.
| |
188 stats_.data_[id] = value; | |
189 } | |
190 | |
181 private: | 191 private: |
192 class GCStats : public ValueObject { | |
193 public: | |
194 GCStats() {} | |
195 intptr_t num_; | |
196 Heap::Space space_; | |
197 Heap::GCReason reason_; | |
198 | |
199 class Data : public ValueObject { | |
200 public: | |
201 Data() {} | |
202 int64_t micros_; | |
203 intptr_t new_used_; | |
204 intptr_t new_capacity_; | |
205 intptr_t old_used_; | |
206 intptr_t old_capacity_; | |
207 | |
208 DISALLOW_COPY_AND_ASSIGN(Data); | |
209 }; | |
210 | |
211 enum { | |
212 kDataEntries = 4 | |
213 }; | |
214 | |
215 Data before_; | |
216 Data after_; | |
217 int64_t times_[kDataEntries]; | |
218 intptr_t data_[kDataEntries]; | |
219 | |
220 DISALLOW_COPY_AND_ASSIGN(GCStats); | |
221 }; | |
222 | |
182 Heap(); | 223 Heap(); |
183 | 224 |
184 uword AllocateNew(intptr_t size); | 225 uword AllocateNew(intptr_t size); |
185 uword AllocateOld(intptr_t size, HeapPage::PageType type); | 226 uword AllocateOld(intptr_t size, HeapPage::PageType type); |
186 | 227 |
228 // GC stats collection. | |
229 void RecordBeforeGC(Space space, GCReason reason); | |
230 void RecordAfterGC(); | |
231 void PrintStats(); | |
232 | |
187 // The different spaces used for allocation. | 233 // The different spaces used for allocation. |
188 Scavenger* new_space_; | 234 Scavenger* new_space_; |
189 PageSpace* old_space_; | 235 PageSpace* old_space_; |
190 | 236 |
237 // GC stats collection. | |
238 GCStats stats_; | |
239 | |
191 // The active heap trace. | 240 // The active heap trace. |
192 HeapTrace* heap_trace_; | 241 HeapTrace* heap_trace_; |
193 | 242 |
194 // This heap is in read-only mode: No allocation is allowed. | 243 // This heap is in read-only mode: No allocation is allowed. |
195 bool read_only_; | 244 bool read_only_; |
196 | 245 |
197 friend class GCTestHelper; | 246 friend class GCTestHelper; |
198 DISALLOW_COPY_AND_ASSIGN(Heap); | 247 DISALLOW_COPY_AND_ASSIGN(Heap); |
199 }; | 248 }; |
200 | 249 |
(...skipping 11 matching lines...) Expand all Loading... | |
212 public: | 261 public: |
213 NoGCScope() {} | 262 NoGCScope() {} |
214 private: | 263 private: |
215 DISALLOW_COPY_AND_ASSIGN(NoGCScope); | 264 DISALLOW_COPY_AND_ASSIGN(NoGCScope); |
216 }; | 265 }; |
217 #endif // defined(DEBUG) | 266 #endif // defined(DEBUG) |
218 | 267 |
219 } // namespace dart | 268 } // namespace dart |
220 | 269 |
221 #endif // VM_HEAP_H_ | 270 #endif // VM_HEAP_H_ |
OLD | NEW |