| OLD | NEW |
| 1 // Copyright (c) 2011, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2011, 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 "vm/allocation.h" | 8 #include "vm/allocation.h" |
| 9 #include "vm/assert.h" |
| 9 #include "vm/flags.h" | 10 #include "vm/flags.h" |
| 10 #include "vm/globals.h" | 11 #include "vm/globals.h" |
| 11 #include "vm/pages.h" | 12 #include "vm/pages.h" |
| 13 #include "vm/scavenger.h" |
| 12 | 14 |
| 13 namespace dart { | 15 namespace dart { |
| 14 | 16 |
| 15 // Forward declarations. | 17 // Forward declarations. |
| 16 class Isolate; | 18 class Isolate; |
| 17 class ObjectPointerVisitor; | 19 class ObjectPointerVisitor; |
| 18 class PageSpace; | |
| 19 class Scavenger; | |
| 20 class VirtualMemory; | 20 class VirtualMemory; |
| 21 | 21 |
| 22 DECLARE_FLAG(bool, verbose_gc); | 22 DECLARE_FLAG(bool, verbose_gc); |
| 23 DECLARE_FLAG(bool, verify_before_gc); | 23 DECLARE_FLAG(bool, verify_before_gc); |
| 24 DECLARE_FLAG(bool, verify_after_gc); | 24 DECLARE_FLAG(bool, verify_after_gc); |
| 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 { |
| (...skipping 19 matching lines...) Expand all Loading... |
| 49 case kOld: | 49 case kOld: |
| 50 return AllocateOld(size); | 50 return AllocateOld(size); |
| 51 case kExecutable: | 51 case kExecutable: |
| 52 return AllocateCode(size); | 52 return AllocateCode(size); |
| 53 default: | 53 default: |
| 54 UNREACHABLE(); | 54 UNREACHABLE(); |
| 55 } | 55 } |
| 56 return 0; | 56 return 0; |
| 57 } | 57 } |
| 58 | 58 |
| 59 uword TryAllocate(intptr_t size, Space space) { |
| 60 switch (space) { |
| 61 case kNew: |
| 62 return new_space_->TryAllocate(size); |
| 63 case kOld: |
| 64 return old_space_->TryAllocate(size); |
| 65 case kExecutable: |
| 66 return code_space_->TryAllocate(size); |
| 67 default: |
| 68 UNREACHABLE(); |
| 69 } |
| 70 } |
| 71 |
| 59 // Heap contains the specified address. | 72 // Heap contains the specified address. |
| 60 bool Contains(uword addr) const; | 73 bool Contains(uword addr) const; |
| 61 bool CodeContains(uword addr) const; | 74 bool CodeContains(uword addr) const; |
| 62 | 75 |
| 63 // Visit all pointers in the space. | 76 // Visit all pointers in the space. |
| 64 void IterateNewPointers(ObjectPointerVisitor* visitor); | 77 void IterateNewPointers(ObjectPointerVisitor* visitor); |
| 65 void IterateOldPointers(ObjectPointerVisitor* visitor); | 78 void IterateOldPointers(ObjectPointerVisitor* visitor); |
| 66 void IterateCodePointers(ObjectPointerVisitor* visitor); | 79 void IterateCodePointers(ObjectPointerVisitor* visitor); |
| 67 | 80 |
| 68 void CollectGarbage(Space space); | 81 void CollectGarbage(Space space); |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 108 public: | 121 public: |
| 109 NoGCScope() {} | 122 NoGCScope() {} |
| 110 private: | 123 private: |
| 111 DISALLOW_COPY_AND_ASSIGN(NoGCScope); | 124 DISALLOW_COPY_AND_ASSIGN(NoGCScope); |
| 112 }; | 125 }; |
| 113 #endif // defined(DEBUG) | 126 #endif // defined(DEBUG) |
| 114 | 127 |
| 115 } // namespace dart | 128 } // namespace dart |
| 116 | 129 |
| 117 #endif // VM_HEAP_H_ | 130 #endif // VM_HEAP_H_ |
| OLD | NEW |