| 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 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 void PromoteExternal(intptr_t size); | 110 void PromoteExternal(intptr_t size); |
| 111 | 111 |
| 112 // Heap contains the specified address. | 112 // Heap contains the specified address. |
| 113 bool Contains(uword addr) const; | 113 bool Contains(uword addr) const; |
| 114 bool NewContains(uword addr) const; | 114 bool NewContains(uword addr) const; |
| 115 bool OldContains(uword addr) const; | 115 bool OldContains(uword addr) const; |
| 116 bool CodeContains(uword addr) const; | 116 bool CodeContains(uword addr) const; |
| 117 bool StubCodeContains(uword addr) const; | 117 bool StubCodeContains(uword addr) const; |
| 118 | 118 |
| 119 // Visit all pointers. | 119 // Visit all pointers. |
| 120 void IteratePointers(ObjectPointerVisitor* visitor); | 120 void IteratePointers(ObjectPointerVisitor* visitor) const; |
| 121 | 121 |
| 122 // Visit all pointers in the space. | 122 // Visit all pointers in the space. |
| 123 void IterateNewPointers(ObjectPointerVisitor* visitor); | 123 void IterateNewPointers(ObjectPointerVisitor* visitor) const; |
| 124 void IterateOldPointers(ObjectPointerVisitor* visitor); | 124 void IterateOldPointers(ObjectPointerVisitor* visitor) const; |
| 125 | 125 |
| 126 // Visit all objects. | 126 // Visit all objects. |
| 127 void IterateObjects(ObjectVisitor* visitor); | 127 void IterateObjects(ObjectVisitor* visitor) const; |
| 128 | 128 |
| 129 // Visit all object in the space. | 129 // Visit all object in the space. |
| 130 void IterateNewObjects(ObjectVisitor* visitor); | 130 void IterateNewObjects(ObjectVisitor* visitor) const; |
| 131 void IterateOldObjects(ObjectVisitor* visitor); | 131 void IterateOldObjects(ObjectVisitor* visitor) const; |
| 132 | 132 |
| 133 // Find an object by visiting all pointers in the specified heap space, | 133 // Find an object by visiting all pointers in the specified heap space, |
| 134 // the 'visitor' is used to determine if an object is found or not. | 134 // the 'visitor' is used to determine if an object is found or not. |
| 135 // The 'visitor' function should be set up to return true if the | 135 // The 'visitor' function should be set up to return true if the |
| 136 // object is found, traversal through the heap space stops at that | 136 // object is found, traversal through the heap space stops at that |
| 137 // point. | 137 // point. |
| 138 // The 'visitor' function should return false if the object is not found, | 138 // The 'visitor' function should return false if the object is not found, |
| 139 // traversal through the heap space continues. | 139 // traversal through the heap space continues. |
| 140 // Returns null object if nothing is found. Must be called within a NoGCScope. | 140 // Returns null object if nothing is found. Must be called within a NoGCScope. |
| 141 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor) const; | 141 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor) const; |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 return size <= kNewAllocatableSize; | 242 return size <= kNewAllocatableSize; |
| 243 } | 243 } |
| 244 | 244 |
| 245 void PrintToJSONObject(Space space, JSONObject* object) const; | 245 void PrintToJSONObject(Space space, JSONObject* object) const; |
| 246 | 246 |
| 247 // The heap map contains the sizes and class ids for the objects in each page. | 247 // The heap map contains the sizes and class ids for the objects in each page. |
| 248 void PrintHeapMapToJSONStream(Isolate* isolate, JSONStream* stream) const { | 248 void PrintHeapMapToJSONStream(Isolate* isolate, JSONStream* stream) const { |
| 249 return old_space_->PrintHeapMapToJSONStream(isolate, stream); | 249 return old_space_->PrintHeapMapToJSONStream(isolate, stream); |
| 250 } | 250 } |
| 251 | 251 |
| 252 Isolate* isolate() const { return isolate_; } |
| 253 |
| 252 private: | 254 private: |
| 253 class GCStats : public ValueObject { | 255 class GCStats : public ValueObject { |
| 254 public: | 256 public: |
| 255 GCStats() {} | 257 GCStats() {} |
| 256 intptr_t num_; | 258 intptr_t num_; |
| 257 Heap::Space space_; | 259 Heap::Space space_; |
| 258 Heap::GCReason reason_; | 260 Heap::GCReason reason_; |
| 259 | 261 |
| 260 class Data : public ValueObject { | 262 class Data : public ValueObject { |
| 261 public: | 263 public: |
| (...skipping 13 matching lines...) Expand all Loading... |
| 275 Data after_; | 277 Data after_; |
| 276 int64_t times_[kDataEntries]; | 278 int64_t times_[kDataEntries]; |
| 277 intptr_t data_[kDataEntries]; | 279 intptr_t data_[kDataEntries]; |
| 278 | 280 |
| 279 private: | 281 private: |
| 280 DISALLOW_COPY_AND_ASSIGN(GCStats); | 282 DISALLOW_COPY_AND_ASSIGN(GCStats); |
| 281 }; | 283 }; |
| 282 | 284 |
| 283 static const intptr_t kNewAllocatableSize = 256 * KB; | 285 static const intptr_t kNewAllocatableSize = 256 * KB; |
| 284 | 286 |
| 285 Heap(intptr_t max_new_gen_words, intptr_t max_old_gen_words); | 287 Heap(Isolate* isolate, |
| 288 intptr_t max_new_gen_words, |
| 289 intptr_t max_old_gen_words); |
| 286 | 290 |
| 287 uword AllocateNew(intptr_t size); | 291 uword AllocateNew(intptr_t size); |
| 288 uword AllocateOld(intptr_t size, HeapPage::PageType type); | 292 uword AllocateOld(intptr_t size, HeapPage::PageType type); |
| 289 | 293 |
| 290 // GC stats collection. | 294 // GC stats collection. |
| 291 void RecordBeforeGC(Space space, GCReason reason); | 295 void RecordBeforeGC(Space space, GCReason reason); |
| 292 void RecordAfterGC(); | 296 void RecordAfterGC(); |
| 293 void PrintStats(); | 297 void PrintStats(); |
| 294 void UpdateClassHeapStatsBeforeGC(Heap::Space space); | 298 void UpdateClassHeapStatsBeforeGC(Heap::Space space); |
| 295 | 299 |
| 296 // If this heap is non-empty, updates start and end to the smallest range that | 300 // If this heap is non-empty, updates start and end to the smallest range that |
| 297 // contains both the original [start, end) and the [lowest, highest) addresses | 301 // contains both the original [start, end) and the [lowest, highest) addresses |
| 298 // of this heap. | 302 // of this heap. |
| 299 void GetMergedAddressRange(uword* start, uword* end) const; | 303 void GetMergedAddressRange(uword* start, uword* end) const; |
| 300 | 304 |
| 305 Isolate* isolate_; |
| 306 |
| 301 // The different spaces used for allocation. | 307 // The different spaces used for allocation. |
| 302 Scavenger* new_space_; | 308 Scavenger* new_space_; |
| 303 PageSpace* old_space_; | 309 PageSpace* old_space_; |
| 304 | 310 |
| 305 WeakTable* new_weak_tables_[kNumWeakSelectors]; | 311 WeakTable* new_weak_tables_[kNumWeakSelectors]; |
| 306 WeakTable* old_weak_tables_[kNumWeakSelectors]; | 312 WeakTable* old_weak_tables_[kNumWeakSelectors]; |
| 307 | 313 |
| 308 // GC stats collection. | 314 // GC stats collection. |
| 309 GCStats stats_; | 315 GCStats stats_; |
| 310 | 316 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 342 NoHeapGrowthControlScope(); | 348 NoHeapGrowthControlScope(); |
| 343 ~NoHeapGrowthControlScope(); | 349 ~NoHeapGrowthControlScope(); |
| 344 private: | 350 private: |
| 345 bool current_growth_controller_state_; | 351 bool current_growth_controller_state_; |
| 346 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); | 352 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); |
| 347 }; | 353 }; |
| 348 | 354 |
| 349 } // namespace dart | 355 } // namespace dart |
| 350 | 356 |
| 351 #endif // VM_HEAP_H_ | 357 #endif // VM_HEAP_H_ |
| OLD | NEW |