| 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 14 matching lines...) Expand all Loading... |
| 25 DECLARE_FLAG(bool, gc_at_alloc); | 25 DECLARE_FLAG(bool, gc_at_alloc); |
| 26 | 26 |
| 27 class Heap { | 27 class Heap { |
| 28 public: | 28 public: |
| 29 enum Space { | 29 enum Space { |
| 30 kNew, | 30 kNew, |
| 31 kOld, | 31 kOld, |
| 32 kExecutable | 32 kExecutable |
| 33 }; | 33 }; |
| 34 | 34 |
| 35 enum ApiCallbacks { |
| 36 kIgnoreApiCallbacks, |
| 37 kInvokeApiCallbacks |
| 38 }; |
| 39 |
| 35 // Default allocation sizes in MB for the old gen and code heaps. | 40 // Default allocation sizes in MB for the old gen and code heaps. |
| 36 static const intptr_t kHeapSizeInMB = 512; | 41 static const intptr_t kHeapSizeInMB = 512; |
| 37 static const intptr_t kCodeHeapSizeInMB = 8; | 42 static const intptr_t kCodeHeapSizeInMB = 8; |
| 38 | 43 |
| 39 ~Heap(); | 44 ~Heap(); |
| 40 | 45 |
| 41 uword Allocate(intptr_t size, Space space) { | 46 uword Allocate(intptr_t size, Space space) { |
| 42 switch (space) { | 47 switch (space) { |
| 43 case kNew: | 48 case kNew: |
| 44 // Do not attempt to allocate very large objects in new space. | 49 // Do not attempt to allocate very large objects in new space. |
| (...skipping 28 matching lines...) Expand all Loading... |
| 73 // Heap contains the specified address. | 78 // Heap contains the specified address. |
| 74 bool Contains(uword addr) const; | 79 bool Contains(uword addr) const; |
| 75 bool CodeContains(uword addr) const; | 80 bool CodeContains(uword addr) const; |
| 76 | 81 |
| 77 // Visit all pointers in the space. | 82 // Visit all pointers in the space. |
| 78 void IterateNewPointers(ObjectPointerVisitor* visitor); | 83 void IterateNewPointers(ObjectPointerVisitor* visitor); |
| 79 void IterateOldPointers(ObjectPointerVisitor* visitor); | 84 void IterateOldPointers(ObjectPointerVisitor* visitor); |
| 80 void IterateCodePointers(ObjectPointerVisitor* visitor); | 85 void IterateCodePointers(ObjectPointerVisitor* visitor); |
| 81 | 86 |
| 82 void CollectGarbage(Space space); | 87 void CollectGarbage(Space space); |
| 88 void CollectGarbage(Space space, ApiCallbacks api_callbacks); |
| 83 void CollectAllGarbage(); | 89 void CollectAllGarbage(); |
| 84 | 90 |
| 85 // Accessors for inlined allocation in generated code. | 91 // Accessors for inlined allocation in generated code. |
| 86 uword TopAddress(); | 92 uword TopAddress(); |
| 87 uword EndAddress(); | 93 uword EndAddress(); |
| 88 static intptr_t new_space_offset() { return OFFSET_OF(Heap, new_space_); } | 94 static intptr_t new_space_offset() { return OFFSET_OF(Heap, new_space_); } |
| 89 | 95 |
| 90 // Initialize the heap and register it with the isolate. | 96 // Initialize the heap and register it with the isolate. |
| 91 static void Init(Isolate* isolate); | 97 static void Init(Isolate* isolate); |
| 92 | 98 |
| (...skipping 29 matching lines...) Expand all Loading... |
| 122 public: | 128 public: |
| 123 NoGCScope() {} | 129 NoGCScope() {} |
| 124 private: | 130 private: |
| 125 DISALLOW_COPY_AND_ASSIGN(NoGCScope); | 131 DISALLOW_COPY_AND_ASSIGN(NoGCScope); |
| 126 }; | 132 }; |
| 127 #endif // defined(DEBUG) | 133 #endif // defined(DEBUG) |
| 128 | 134 |
| 129 } // namespace dart | 135 } // namespace dart |
| 130 | 136 |
| 131 #endif // VM_HEAP_H_ | 137 #endif // VM_HEAP_H_ |
| OLD | NEW |