| 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 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 93 // point. | 93 // point. |
| 94 // The 'visitor' function should return false if the object is not found, | 94 // The 'visitor' function should return false if the object is not found, |
| 95 // traversal through the heap space continues. | 95 // traversal through the heap space continues. |
| 96 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor); | 96 RawInstructions* FindObjectInCodeSpace(FindObjectVisitor* visitor); |
| 97 RawInstructions* FindObjectInStubCodeSpace(FindObjectVisitor* visitor); | 97 RawInstructions* FindObjectInStubCodeSpace(FindObjectVisitor* visitor); |
| 98 | 98 |
| 99 void CollectGarbage(Space space); | 99 void CollectGarbage(Space space); |
| 100 void CollectGarbage(Space space, ApiCallbacks api_callbacks); | 100 void CollectGarbage(Space space, ApiCallbacks api_callbacks); |
| 101 void CollectAllGarbage(); | 101 void CollectAllGarbage(); |
| 102 | 102 |
| 103 // Enables growth control on the page space heaps. This should be |
| 104 // called before any user code is executed. |
| 105 void EnableGrowthControl(); |
| 106 |
| 103 // Accessors for inlined allocation in generated code. | 107 // Accessors for inlined allocation in generated code. |
| 104 uword TopAddress(); | 108 uword TopAddress(); |
| 105 uword EndAddress(); | 109 uword EndAddress(); |
| 106 static intptr_t new_space_offset() { return OFFSET_OF(Heap, new_space_); } | 110 static intptr_t new_space_offset() { return OFFSET_OF(Heap, new_space_); } |
| 107 | 111 |
| 108 // Initialize the heap and register it with the isolate. | 112 // Initialize the heap and register it with the isolate. |
| 109 static void Init(Isolate* isolate); | 113 static void Init(Isolate* isolate); |
| 110 | 114 |
| 111 // Verify that all pointers in the heap point to the heap. | 115 // Verify that all pointers in the heap point to the heap. |
| 112 bool Verify() const; | 116 bool Verify() const; |
| 113 | 117 |
| 114 // Print heap sizes. | 118 // Print heap sizes. |
| 115 void PrintSizes() const; | 119 void PrintSizes() const; |
| 116 | 120 |
| 117 private: | 121 private: |
| 118 Heap(); | 122 Heap(); |
| 119 | 123 |
| 120 uword AllocateNew(intptr_t size); | 124 uword AllocateNew(intptr_t size); |
| 121 uword AllocateOld(intptr_t size); | 125 uword AllocateOld(intptr_t size); |
| 122 uword AllocateCode(PageSpace* space, intptr_t size); | 126 uword AllocateCode(PageSpace* space, intptr_t size); |
| 123 | 127 |
| 124 // The different spaces used for allocation. | 128 // The different spaces used for allocation. |
| 125 Scavenger* new_space_; | 129 Scavenger* new_space_; |
| 126 PageSpace* old_space_; | 130 PageSpace* old_space_; |
| 127 PageSpace* code_space_; | 131 PageSpace* code_space_; |
| 128 PageSpace* stub_code_space_; | |
| 129 | 132 |
| 130 DISALLOW_COPY_AND_ASSIGN(Heap); | 133 DISALLOW_COPY_AND_ASSIGN(Heap); |
| 131 }; | 134 }; |
| 132 | 135 |
| 133 | 136 |
| 134 #if defined(DEBUG) | 137 #if defined(DEBUG) |
| 135 class NoGCScope : public StackResource { | 138 class NoGCScope : public StackResource { |
| 136 public: | 139 public: |
| 137 NoGCScope(); | 140 NoGCScope(); |
| 138 ~NoGCScope(); | 141 ~NoGCScope(); |
| 139 private: | 142 private: |
| 140 DISALLOW_COPY_AND_ASSIGN(NoGCScope); | 143 DISALLOW_COPY_AND_ASSIGN(NoGCScope); |
| 141 }; | 144 }; |
| 142 #else // defined(DEBUG) | 145 #else // defined(DEBUG) |
| 143 class NoGCScope : public ValueObject { | 146 class NoGCScope : public ValueObject { |
| 144 public: | 147 public: |
| 145 NoGCScope() {} | 148 NoGCScope() {} |
| 146 private: | 149 private: |
| 147 DISALLOW_COPY_AND_ASSIGN(NoGCScope); | 150 DISALLOW_COPY_AND_ASSIGN(NoGCScope); |
| 148 }; | 151 }; |
| 149 #endif // defined(DEBUG) | 152 #endif // defined(DEBUG) |
| 150 | 153 |
| 151 } // namespace dart | 154 } // namespace dart |
| 152 | 155 |
| 153 #endif // VM_HEAP_H_ | 156 #endif // VM_HEAP_H_ |
| OLD | NEW |