| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 enum GCReason { | 52 enum GCReason { |
| 53 kNewSpace, | 53 kNewSpace, |
| 54 kPromotion, | 54 kPromotion, |
| 55 kOldSpace, | 55 kOldSpace, |
| 56 kFull, | 56 kFull, |
| 57 kGCAtAlloc, | 57 kGCAtAlloc, |
| 58 kGCTestCase, | 58 kGCTestCase, |
| 59 }; | 59 }; |
| 60 | 60 |
| 61 // Default allocation sizes in MB for the old gen and code heaps. | |
| 62 static const intptr_t kHeapSizeInMWords = 128; | |
| 63 static const intptr_t kHeapSizeInMB = kHeapSizeInMWords * kWordSize; | |
| 64 static const intptr_t kCodeHeapSizeInMB = 18; | |
| 65 | |
| 66 #if defined(DEBUG) | 61 #if defined(DEBUG) |
| 67 // Pattern for unused new space and swept old space. | 62 // Pattern for unused new space and swept old space. |
| 68 static const uint64_t kZap64Bits = 0xf3f3f3f3f3f3f3f3; | 63 static const uint64_t kZap64Bits = 0xf3f3f3f3f3f3f3f3; |
| 69 static const uint32_t kZap32Bits = static_cast<uint32_t>(kZap64Bits); | 64 static const uint32_t kZap32Bits = static_cast<uint32_t>(kZap64Bits); |
| 70 static const uint8_t kZapByte = static_cast<uint8_t>(kZap64Bits); | 65 static const uint8_t kZapByte = static_cast<uint8_t>(kZap64Bits); |
| 71 #endif // DEBUG | 66 #endif // DEBUG |
| 72 | 67 |
| 73 ~Heap(); | 68 ~Heap(); |
| 74 | 69 |
| 75 Scavenger* new_space() const { return new_space_; } | 70 Scavenger* new_space() const { return new_space_; } |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 } | 149 } |
| 155 | 150 |
| 156 // Accessors for inlined allocation in generated code. | 151 // Accessors for inlined allocation in generated code. |
| 157 uword TopAddress(Space space); | 152 uword TopAddress(Space space); |
| 158 uword EndAddress(Space space); | 153 uword EndAddress(Space space); |
| 159 Space SpaceForAllocation(intptr_t class_id) const; | 154 Space SpaceForAllocation(intptr_t class_id) const; |
| 160 | 155 |
| 161 // Initialize the heap and register it with the isolate. | 156 // Initialize the heap and register it with the isolate. |
| 162 static void Init(Isolate* isolate, | 157 static void Init(Isolate* isolate, |
| 163 intptr_t max_new_gen_words, | 158 intptr_t max_new_gen_words, |
| 164 intptr_t max_old_gen_words); | 159 intptr_t max_old_gen_words, |
| 160 intptr_t max_external_words); |
| 165 | 161 |
| 166 // Verify that all pointers in the heap point to the heap. | 162 // Verify that all pointers in the heap point to the heap. |
| 167 bool Verify(MarkExpectation mark_expectation = kForbidMarked) const; | 163 bool Verify(MarkExpectation mark_expectation = kForbidMarked) const; |
| 168 | 164 |
| 169 // Print heap sizes. | 165 // Print heap sizes. |
| 170 void PrintSizes() const; | 166 void PrintSizes() const; |
| 171 | 167 |
| 172 // Return amount of memory used and capacity in a space, excluding external. | 168 // Return amount of memory used and capacity in a space, excluding external. |
| 173 intptr_t UsedInWords(Space space) const; | 169 intptr_t UsedInWords(Space space) const; |
| 174 intptr_t CapacityInWords(Space space) const; | 170 intptr_t CapacityInWords(Space space) const; |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 277 intptr_t data_[kDataEntries]; | 273 intptr_t data_[kDataEntries]; |
| 278 | 274 |
| 279 private: | 275 private: |
| 280 DISALLOW_COPY_AND_ASSIGN(GCStats); | 276 DISALLOW_COPY_AND_ASSIGN(GCStats); |
| 281 }; | 277 }; |
| 282 | 278 |
| 283 static const intptr_t kNewAllocatableSize = 256 * KB; | 279 static const intptr_t kNewAllocatableSize = 256 * KB; |
| 284 | 280 |
| 285 Heap(Isolate* isolate, | 281 Heap(Isolate* isolate, |
| 286 intptr_t max_new_gen_semi_words, // Max capacity of new semi-space. | 282 intptr_t max_new_gen_semi_words, // Max capacity of new semi-space. |
| 287 intptr_t max_old_gen_words); | 283 intptr_t max_old_gen_words, |
| 284 intptr_t max_external_words); |
| 288 | 285 |
| 289 uword AllocateNew(intptr_t size); | 286 uword AllocateNew(intptr_t size); |
| 290 uword AllocateOld(intptr_t size, HeapPage::PageType type); | 287 uword AllocateOld(intptr_t size, HeapPage::PageType type); |
| 291 uword AllocatePretenured(intptr_t size); | 288 uword AllocatePretenured(intptr_t size); |
| 292 | 289 |
| 293 // GC stats collection. | 290 // GC stats collection. |
| 294 void RecordBeforeGC(Space space, GCReason reason); | 291 void RecordBeforeGC(Space space, GCReason reason); |
| 295 void RecordAfterGC(); | 292 void RecordAfterGC(); |
| 296 void PrintStats(); | 293 void PrintStats(); |
| 297 void UpdateClassHeapStatsBeforeGC(Heap::Space space); | 294 void UpdateClassHeapStatsBeforeGC(Heap::Space space); |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 361 NoHeapGrowthControlScope(); | 358 NoHeapGrowthControlScope(); |
| 362 ~NoHeapGrowthControlScope(); | 359 ~NoHeapGrowthControlScope(); |
| 363 private: | 360 private: |
| 364 bool current_growth_controller_state_; | 361 bool current_growth_controller_state_; |
| 365 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); | 362 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); |
| 366 }; | 363 }; |
| 367 | 364 |
| 368 } // namespace dart | 365 } // namespace dart |
| 369 | 366 |
| 370 #endif // VM_HEAP_H_ | 367 #endif // VM_HEAP_H_ |
| OLD | NEW |