| 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 20 matching lines...) Expand all Loading... |
| 31 kNew, | 31 kNew, |
| 32 kOld, | 32 kOld, |
| 33 kCode, | 33 kCode, |
| 34 }; | 34 }; |
| 35 | 35 |
| 36 enum ApiCallbacks { | 36 enum ApiCallbacks { |
| 37 kIgnoreApiCallbacks, | 37 kIgnoreApiCallbacks, |
| 38 kInvokeApiCallbacks | 38 kInvokeApiCallbacks |
| 39 }; | 39 }; |
| 40 | 40 |
| 41 enum GCReason { |
| 42 kNewSpace, |
| 43 kPromotionFailure, |
| 44 kOldSpace, |
| 45 kCodeSpace, |
| 46 kFull, |
| 47 kGCAtAlloc, |
| 48 kGCTestCase, |
| 49 }; |
| 50 |
| 41 // 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. |
| 42 static const intptr_t kHeapSizeInMB = 512; | 52 static const intptr_t kHeapSizeInMB = 512; |
| 43 static const intptr_t kCodeHeapSizeInMB = 12; | 53 static const intptr_t kCodeHeapSizeInMB = 12; |
| 44 | 54 |
| 45 ~Heap(); | 55 ~Heap(); |
| 46 | 56 |
| 47 uword Allocate(intptr_t size, Space space) { | 57 uword Allocate(intptr_t size, Space space) { |
| 48 ASSERT(!read_only_); | 58 ASSERT(!read_only_); |
| 49 switch (space) { | 59 switch (space) { |
| 50 case kNew: | 60 case kNew: |
| (...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 void PrintSizes() const; | 147 void PrintSizes() const; |
| 138 | 148 |
| 139 // Returns the [lowest, highest) addresses in the heap. | 149 // Returns the [lowest, highest) addresses in the heap. |
| 140 void StartEndAddress(uword* start, uword* end) const; | 150 void StartEndAddress(uword* start, uword* end) const; |
| 141 | 151 |
| 142 ObjectSet* CreateAllocatedObjectSet() const; | 152 ObjectSet* CreateAllocatedObjectSet() const; |
| 143 | 153 |
| 144 // Generates a profile of the current and VM isolate heaps. | 154 // Generates a profile of the current and VM isolate heaps. |
| 145 void Profile(Dart_HeapProfileWriteCallback callback, void* stream) const; | 155 void Profile(Dart_HeapProfileWriteCallback callback, void* stream) const; |
| 146 | 156 |
| 157 static const char* GCReasonToString(GCReason gc_reason); |
| 158 |
| 147 private: | 159 private: |
| 148 Heap(); | 160 Heap(); |
| 149 | 161 |
| 150 uword AllocateNew(intptr_t size); | 162 uword AllocateNew(intptr_t size); |
| 151 uword AllocateOld(intptr_t size); | 163 uword AllocateOld(intptr_t size); |
| 152 uword AllocateCode(PageSpace* space, intptr_t size); | 164 uword AllocateCode(PageSpace* space, intptr_t size); |
| 153 | 165 |
| 154 // The different spaces used for allocation. | 166 // The different spaces used for allocation. |
| 155 Scavenger* new_space_; | 167 Scavenger* new_space_; |
| 156 PageSpace* old_space_; | 168 PageSpace* old_space_; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 177 public: | 189 public: |
| 178 NoGCScope() {} | 190 NoGCScope() {} |
| 179 private: | 191 private: |
| 180 DISALLOW_COPY_AND_ASSIGN(NoGCScope); | 192 DISALLOW_COPY_AND_ASSIGN(NoGCScope); |
| 181 }; | 193 }; |
| 182 #endif // defined(DEBUG) | 194 #endif // defined(DEBUG) |
| 183 | 195 |
| 184 } // namespace dart | 196 } // namespace dart |
| 185 | 197 |
| 186 #endif // VM_HEAP_H_ | 198 #endif // VM_HEAP_H_ |
| OLD | NEW |