| 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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 uword TryBumpAllocate(intptr_t size) { | 45 uword TryBumpAllocate(intptr_t size) { |
| 46 uword result = top(); | 46 uword result = top(); |
| 47 intptr_t remaining_space = end() - result; | 47 intptr_t remaining_space = end() - result; |
| 48 if (remaining_space < size) { | 48 if (remaining_space < size) { |
| 49 return 0; | 49 return 0; |
| 50 } | 50 } |
| 51 set_top(result + size); | 51 set_top(result + size); |
| 52 return result; | 52 return result; |
| 53 } | 53 } |
| 54 | 54 |
| 55 void VisitObjects(ObjectVisitor* visitor) const; |
| 55 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 56 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
| 56 | 57 |
| 57 RawObject* FindObject(FindObjectVisitor* visitor) const; | 58 RawObject* FindObject(FindObjectVisitor* visitor) const; |
| 58 | 59 |
| 59 private: | 60 private: |
| 60 static HeapPage* Initialize(VirtualMemory* memory, bool is_executable); | 61 static HeapPage* Initialize(VirtualMemory* memory, bool is_executable); |
| 61 static HeapPage* Allocate(intptr_t size, bool is_executable); | 62 static HeapPage* Allocate(intptr_t size, bool is_executable); |
| 62 | 63 |
| 63 // Deallocate the virtual memory backing this page. The page pointer to this | 64 // Deallocate the virtual memory backing this page. The page pointer to this |
| 64 // page becomes immediately inaccessible. | 65 // page becomes immediately inaccessible. |
| (...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 intptr_t capacity() const { return capacity_; } | 167 intptr_t capacity() const { return capacity_; } |
| 167 | 168 |
| 168 bool Contains(uword addr) const; | 169 bool Contains(uword addr) const; |
| 169 bool IsValidAddress(uword addr) const { | 170 bool IsValidAddress(uword addr) const { |
| 170 return Contains(addr); | 171 return Contains(addr); |
| 171 } | 172 } |
| 172 static bool IsPageAllocatableSize(intptr_t size) { | 173 static bool IsPageAllocatableSize(intptr_t size) { |
| 173 return size <= kAllocatablePageSize; | 174 return size <= kAllocatablePageSize; |
| 174 } | 175 } |
| 175 | 176 |
| 177 void VisitObjects(ObjectVisitor* visitor) const; |
| 176 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 178 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
| 177 | 179 |
| 178 RawObject* FindObject(FindObjectVisitor* visitor) const; | 180 RawObject* FindObject(FindObjectVisitor* visitor) const; |
| 179 | 181 |
| 180 // Collect the garbage in the page space using mark-sweep. | 182 // Collect the garbage in the page space using mark-sweep. |
| 181 void MarkSweep(bool invoke_api_callbacks); | 183 void MarkSweep(bool invoke_api_callbacks); |
| 182 | 184 |
| 183 static HeapPage* PageFor(RawObject* raw_obj) { | 185 static HeapPage* PageFor(RawObject* raw_obj) { |
| 184 return reinterpret_cast<HeapPage*>( | 186 return reinterpret_cast<HeapPage*>( |
| 185 RawObject::ToAddr(raw_obj) & ~(kPageSize -1)); | 187 RawObject::ToAddr(raw_obj) & ~(kPageSize -1)); |
| (...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 bool sweeping_; | 238 bool sweeping_; |
| 237 | 239 |
| 238 PageSpaceController page_space_controller_; | 240 PageSpaceController page_space_controller_; |
| 239 | 241 |
| 240 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 242 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 241 }; | 243 }; |
| 242 | 244 |
| 243 } // namespace dart | 245 } // namespace dart |
| 244 | 246 |
| 245 #endif // VM_PAGES_H_ | 247 #endif // VM_PAGES_H_ |
| OLD | NEW |