| 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_PAGES_H_ | 5 #ifndef VM_PAGES_H_ |
| 6 #define VM_PAGES_H_ | 6 #define VM_PAGES_H_ |
| 7 | 7 |
| 8 #include "vm/freelist.h" | 8 #include "vm/freelist.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/virtual_memory.h" | 10 #include "vm/virtual_memory.h" |
| (...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 81 // TODO(iposva): Determine heap sizes and tune the page size accordingly. | 81 // TODO(iposva): Determine heap sizes and tune the page size accordingly. |
| 82 static const intptr_t kPageSize = 256 * KB; | 82 static const intptr_t kPageSize = 256 * KB; |
| 83 static const intptr_t kPageAlignment = kPageSize; | 83 static const intptr_t kPageAlignment = kPageSize; |
| 84 | 84 |
| 85 PageSpace(Heap* heap, intptr_t max_capacity, bool is_executable = false); | 85 PageSpace(Heap* heap, intptr_t max_capacity, bool is_executable = false); |
| 86 ~PageSpace(); | 86 ~PageSpace(); |
| 87 | 87 |
| 88 uword TryAllocate(intptr_t size); | 88 uword TryAllocate(intptr_t size); |
| 89 | 89 |
| 90 intptr_t in_use() const { return in_use_; } | 90 intptr_t in_use() const { return in_use_; } |
| 91 intptr_t capacity() const { return capacity_; } |
| 92 |
| 91 bool Contains(uword addr) const; | 93 bool Contains(uword addr) const; |
| 92 bool IsValidAddress(uword addr) const { | 94 bool IsValidAddress(uword addr) const { |
| 93 return Contains(addr); | 95 return Contains(addr); |
| 94 } | 96 } |
| 95 static bool IsPageAllocatableSize(intptr_t size) { | 97 static bool IsPageAllocatableSize(intptr_t size) { |
| 96 return size <= kAllocatablePageSize; | 98 return size <= kAllocatablePageSize; |
| 97 } | 99 } |
| 98 | 100 |
| 99 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 101 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
| 100 | 102 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 111 private: | 113 private: |
| 112 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage); | 114 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage); |
| 113 | 115 |
| 114 void AllocatePage(); | 116 void AllocatePage(); |
| 115 void FreePage(HeapPage* page, HeapPage* previous_page); | 117 void FreePage(HeapPage* page, HeapPage* previous_page); |
| 116 HeapPage* AllocateLargePage(intptr_t size); | 118 HeapPage* AllocateLargePage(intptr_t size); |
| 117 void FreeLargePage(HeapPage* page, HeapPage* previous_page); | 119 void FreeLargePage(HeapPage* page, HeapPage* previous_page); |
| 118 void FreePages(HeapPage* pages); | 120 void FreePages(HeapPage* pages); |
| 119 | 121 |
| 120 static intptr_t LargePageSizeFor(intptr_t size); | 122 static intptr_t LargePageSizeFor(intptr_t size); |
| 123 |
| 121 bool CanIncreaseCapacity(intptr_t increase) { | 124 bool CanIncreaseCapacity(intptr_t increase) { |
| 122 ASSERT(capacity_ <= max_capacity_); | 125 ASSERT(capacity_ <= max_capacity_); |
| 123 return increase <= (max_capacity_ - capacity_); | 126 return increase <= (max_capacity_ - capacity_); |
| 124 } | 127 } |
| 125 | 128 |
| 126 uword TryBumpAllocate(intptr_t size); | 129 uword TryBumpAllocate(intptr_t size); |
| 127 | 130 |
| 128 FreeList freelist_; | 131 FreeList freelist_; |
| 129 | 132 |
| 130 Heap* heap_; | 133 Heap* heap_; |
| (...skipping 21 matching lines...) Expand all Loading... |
| 152 | 155 |
| 153 // Keep track whether a MarkSweep is currently running. | 156 // Keep track whether a MarkSweep is currently running. |
| 154 bool sweeping_; | 157 bool sweeping_; |
| 155 | 158 |
| 156 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 159 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 157 }; | 160 }; |
| 158 | 161 |
| 159 } // namespace dart | 162 } // namespace dart |
| 160 | 163 |
| 161 #endif // VM_PAGES_H_ | 164 #endif // VM_PAGES_H_ |
| OLD | NEW |