| 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 26 matching lines...) Expand all Loading... |
| 91 intptr_t capacity() const { return capacity_; } | 92 intptr_t capacity() const { return capacity_; } |
| 92 | 93 |
| 93 bool Contains(uword addr) const; | 94 bool Contains(uword addr) const; |
| 94 bool IsValidAddress(uword addr) const { | 95 bool IsValidAddress(uword addr) const { |
| 95 return Contains(addr); | 96 return Contains(addr); |
| 96 } | 97 } |
| 97 static bool IsPageAllocatableSize(intptr_t size) { | 98 static bool IsPageAllocatableSize(intptr_t size) { |
| 98 return size <= kAllocatablePageSize; | 99 return size <= kAllocatablePageSize; |
| 99 } | 100 } |
| 100 | 101 |
| 102 void VisitObjects(ObjectVisitor* visitor) const; |
| 101 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 103 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
| 102 | 104 |
| 103 RawObject* FindObject(FindObjectVisitor* visitor) const; | 105 RawObject* FindObject(FindObjectVisitor* visitor) const; |
| 104 | 106 |
| 105 // Collect the garbage in the page space using mark-sweep. | 107 // Collect the garbage in the page space using mark-sweep. |
| 106 void MarkSweep(bool invoke_api_callbacks); | 108 void MarkSweep(bool invoke_api_callbacks); |
| 107 | 109 |
| 108 static HeapPage* PageFor(RawObject* raw_obj) { | 110 static HeapPage* PageFor(RawObject* raw_obj) { |
| 109 return reinterpret_cast<HeapPage*>( | 111 return reinterpret_cast<HeapPage*>( |
| 110 RawObject::ToAddr(raw_obj) & ~(kPageSize -1)); | 112 RawObject::ToAddr(raw_obj) & ~(kPageSize -1)); |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 155 | 157 |
| 156 // Keep track whether a MarkSweep is currently running. | 158 // Keep track whether a MarkSweep is currently running. |
| 157 bool sweeping_; | 159 bool sweeping_; |
| 158 | 160 |
| 159 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 161 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 160 }; | 162 }; |
| 161 | 163 |
| 162 } // namespace dart | 164 } // namespace dart |
| 163 | 165 |
| 164 #endif // VM_PAGES_H_ | 166 #endif // VM_PAGES_H_ |
| OLD | NEW |