| 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 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 | 105 |
| 106 static HeapPage* PageFor(RawObject* raw_obj) { | 106 static HeapPage* PageFor(RawObject* raw_obj) { |
| 107 return reinterpret_cast<HeapPage*>( | 107 return reinterpret_cast<HeapPage*>( |
| 108 RawObject::ToAddr(raw_obj) & ~(kPageSize -1)); | 108 RawObject::ToAddr(raw_obj) & ~(kPageSize -1)); |
| 109 } | 109 } |
| 110 | 110 |
| 111 private: | 111 private: |
| 112 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage); | 112 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage); |
| 113 | 113 |
| 114 void AllocatePage(); | 114 void AllocatePage(); |
| 115 void FreePage(HeapPage* page, HeapPage* previous_page); |
| 115 HeapPage* AllocateLargePage(intptr_t size); | 116 HeapPage* AllocateLargePage(intptr_t size); |
| 116 void FreeLargePage(HeapPage* page, HeapPage* previous_page); | 117 void FreeLargePage(HeapPage* page, HeapPage* previous_page); |
| 117 void FreePages(HeapPage* pages); | 118 void FreePages(HeapPage* pages); |
| 118 | 119 |
| 119 static intptr_t LargePageSizeFor(intptr_t size); | 120 static intptr_t LargePageSizeFor(intptr_t size); |
| 120 bool CanIncreaseCapacity(intptr_t increase) { | 121 bool CanIncreaseCapacity(intptr_t increase) { |
| 121 ASSERT(capacity_ <= max_capacity_); | 122 ASSERT(capacity_ <= max_capacity_); |
| 122 return increase <= (max_capacity_ - capacity_); | 123 return increase <= (max_capacity_ - capacity_); |
| 123 } | 124 } |
| 124 | 125 |
| 125 uword TryBumpAllocate(intptr_t size); | 126 uword TryBumpAllocate(intptr_t size); |
| 126 | 127 |
| 127 FreeList freelist_; | 128 FreeList freelist_; |
| 128 | 129 |
| 129 Heap* heap_; | 130 Heap* heap_; |
| 130 | 131 |
| 131 HeapPage* pages_; | 132 HeapPage* pages_; |
| 132 HeapPage* pages_tail_; | |
| 133 HeapPage* large_pages_; | 133 HeapPage* large_pages_; |
| 134 | 134 |
| 135 // Page being used for bump allocation. | 135 // Page being used for bump allocation. |
| 136 // The value has different meanings: | 136 // The value has different meanings: |
| 137 // NULL: Still bump allocating from last allocated fresh page. | 137 // NULL: Still bump allocating from last allocated fresh page. |
| 138 // !NULL: Last page that had enough room to bump allocate, when we reach the | 138 // !NULL: Last page that had enough room to bump allocate, when we reach the |
| 139 // tail page, we give up bump allocating. | 139 // tail page, we give up bump allocating. |
| 140 HeapPage* bump_page_; | 140 HeapPage* bump_page_; |
| 141 | 141 |
| 142 // Various sizes being tracked for this generation. | 142 // Various sizes being tracked for this generation. |
| 143 intptr_t max_capacity_; | 143 intptr_t max_capacity_; |
| 144 intptr_t capacity_; | 144 intptr_t capacity_; |
| 145 intptr_t in_use_; | 145 intptr_t in_use_; |
| 146 | 146 |
| 147 // Old-gen GC cycle count. | 147 // Old-gen GC cycle count. |
| 148 int count_; | 148 int count_; |
| 149 | 149 |
| 150 bool is_executable_; | 150 bool is_executable_; |
| 151 | 151 |
| 152 // Keep track whether a MarkSweep is currently running. | 152 // Keep track whether a MarkSweep is currently running. |
| 153 bool sweeping_; | 153 bool sweeping_; |
| 154 | 154 |
| 155 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 155 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 156 }; | 156 }; |
| 157 | 157 |
| 158 } // namespace dart | 158 } // namespace dart |
| 159 | 159 |
| 160 #endif // VM_PAGES_H_ | 160 #endif // VM_PAGES_H_ |
| OLD | NEW |