| 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 30 matching lines...) Expand all Loading... |
| 41 kNumWeakSelectors | 41 kNumWeakSelectors |
| 42 }; | 42 }; |
| 43 | 43 |
| 44 enum ApiCallbacks { | 44 enum ApiCallbacks { |
| 45 kIgnoreApiCallbacks, | 45 kIgnoreApiCallbacks, |
| 46 kInvokeApiCallbacks | 46 kInvokeApiCallbacks |
| 47 }; | 47 }; |
| 48 | 48 |
| 49 enum GCReason { | 49 enum GCReason { |
| 50 kNewSpace, | 50 kNewSpace, |
| 51 kPromotionFailure, | 51 kPromotion, |
| 52 kOldSpace, | 52 kOldSpace, |
| 53 kFull, | 53 kFull, |
| 54 kGCAtAlloc, | 54 kGCAtAlloc, |
| 55 kGCTestCase, | 55 kGCTestCase, |
| 56 }; | 56 }; |
| 57 | 57 |
| 58 // Default allocation sizes in MB for the old gen and code heaps. | 58 // Default allocation sizes in MB for the old gen and code heaps. |
| 59 static const intptr_t kHeapSizeInMWords = 128; | 59 static const intptr_t kHeapSizeInMWords = 128; |
| 60 static const intptr_t kHeapSizeInMB = kHeapSizeInMWords * kWordSize; | 60 static const intptr_t kHeapSizeInMB = kHeapSizeInMWords * kWordSize; |
| 61 static const intptr_t kCodeHeapSizeInMB = 18; | 61 static const intptr_t kCodeHeapSizeInMB = 18; |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 99 growth_policy); | 99 growth_policy); |
| 100 default: | 100 default: |
| 101 UNREACHABLE(); | 101 UNREACHABLE(); |
| 102 } | 102 } |
| 103 return 0; | 103 return 0; |
| 104 } | 104 } |
| 105 | 105 |
| 106 // Track external data. | 106 // Track external data. |
| 107 void AllocateExternal(intptr_t size, Space space); | 107 void AllocateExternal(intptr_t size, Space space); |
| 108 void FreeExternal(intptr_t size, Space space); | 108 void FreeExternal(intptr_t size, Space space); |
| 109 // Move external size from new to old space. Does not by itself trigger GC. |
| 110 void PromoteExternal(intptr_t size); |
| 109 | 111 |
| 110 // Heap contains the specified address. | 112 // Heap contains the specified address. |
| 111 bool Contains(uword addr) const; | 113 bool Contains(uword addr) const; |
| 112 bool NewContains(uword addr) const; | 114 bool NewContains(uword addr) const; |
| 113 bool OldContains(uword addr) const; | 115 bool OldContains(uword addr) const; |
| 114 bool CodeContains(uword addr) const; | 116 bool CodeContains(uword addr) const; |
| 115 bool StubCodeContains(uword addr) const; | 117 bool StubCodeContains(uword addr) const; |
| 116 | 118 |
| 117 // Visit all pointers. | 119 // Visit all pointers. |
| 118 void IteratePointers(ObjectPointerVisitor* visitor); | 120 void IteratePointers(ObjectPointerVisitor* visitor); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 135 // point. | 137 // point. |
| 136 // 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, |
| 137 // traversal through the heap space continues. | 139 // traversal through the heap space continues. |
| 138 // 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. |
| 139 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor) const; | 141 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor) const; |
| 140 RawObject* FindOldObject(FindObjectVisitor* visitor) const; | 142 RawObject* FindOldObject(FindObjectVisitor* visitor) const; |
| 141 RawObject* FindNewObject(FindObjectVisitor* visitor) const; | 143 RawObject* FindNewObject(FindObjectVisitor* visitor) const; |
| 142 RawObject* FindObject(FindObjectVisitor* visitor) const; | 144 RawObject* FindObject(FindObjectVisitor* visitor) const; |
| 143 | 145 |
| 144 void CollectGarbage(Space space); | 146 void CollectGarbage(Space space); |
| 145 void CollectGarbage(Space space, ApiCallbacks api_callbacks); | 147 void CollectGarbage(Space space, ApiCallbacks api_callbacks, GCReason reason); |
| 146 void CollectAllGarbage(); | 148 void CollectAllGarbage(); |
| 147 | 149 |
| 148 // Enables growth control on the page space heaps. This should be | 150 // Enables growth control on the page space heaps. This should be |
| 149 // called before any user code is executed. | 151 // called before any user code is executed. |
| 150 void EnableGrowthControl() { SetGrowthControlState(true); } | 152 void EnableGrowthControl() { SetGrowthControlState(true); } |
| 151 void DisableGrowthControl() { SetGrowthControlState(false); } | 153 void DisableGrowthControl() { SetGrowthControlState(false); } |
| 152 void SetGrowthControlState(bool state); | 154 void SetGrowthControlState(bool state); |
| 153 bool GrowthControlState(); | 155 bool GrowthControlState(); |
| 154 | 156 |
| 155 // Protect access to the heap. | 157 // Protect access to the heap. |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 335 NoHeapGrowthControlScope(); | 337 NoHeapGrowthControlScope(); |
| 336 ~NoHeapGrowthControlScope(); | 338 ~NoHeapGrowthControlScope(); |
| 337 private: | 339 private: |
| 338 bool current_growth_controller_state_; | 340 bool current_growth_controller_state_; |
| 339 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); | 341 DISALLOW_COPY_AND_ASSIGN(NoHeapGrowthControlScope); |
| 340 }; | 342 }; |
| 341 | 343 |
| 342 } // namespace dart | 344 } // namespace dart |
| 343 | 345 |
| 344 #endif // VM_HEAP_H_ | 346 #endif // VM_HEAP_H_ |
| OLD | NEW |