| 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 26 matching lines...) Expand all Loading... |
| 37 } | 37 } |
| 38 | 38 |
| 39 void set_used(uword used) { used_ = used; } | 39 void set_used(uword used) { used_ = used; } |
| 40 uword used() const { return used_; } | 40 uword used() const { return used_; } |
| 41 void AddUsed(uword size) { | 41 void AddUsed(uword size) { |
| 42 used_ += size; | 42 used_ += size; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 45 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
| 46 | 46 |
| 47 RawObject* FindObject(FindObjectVisitor* visitor) const; |
| 48 |
| 47 private: | 49 private: |
| 48 static HeapPage* Initialize(VirtualMemory* memory, bool is_executable); | 50 static HeapPage* Initialize(VirtualMemory* memory, bool is_executable); |
| 49 static HeapPage* Allocate(intptr_t size, bool is_executable); | 51 static HeapPage* Allocate(intptr_t size, bool is_executable); |
| 50 | 52 |
| 51 // Deallocate the virtual memory backing this page. The page pointer to this | 53 // Deallocate the virtual memory backing this page. The page pointer to this |
| 52 // page becomes immediately inaccessible. | 54 // page becomes immediately inaccessible. |
| 53 void Deallocate(); | 55 void Deallocate(); |
| 54 | 56 |
| 55 VirtualMemory* memory_; | 57 VirtualMemory* memory_; |
| 56 HeapPage* next_; | 58 HeapPage* next_; |
| (...skipping 22 matching lines...) Expand all Loading... |
| 79 bool Contains(uword addr) const; | 81 bool Contains(uword addr) const; |
| 80 bool IsValidAddress(uword addr) const { | 82 bool IsValidAddress(uword addr) const { |
| 81 return Contains(addr); | 83 return Contains(addr); |
| 82 } | 84 } |
| 83 static bool IsPageAllocatableSize(intptr_t size) { | 85 static bool IsPageAllocatableSize(intptr_t size) { |
| 84 return size <= kAllocatablePageSize; | 86 return size <= kAllocatablePageSize; |
| 85 } | 87 } |
| 86 | 88 |
| 87 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; | 89 void VisitObjectPointers(ObjectPointerVisitor* visitor) const; |
| 88 | 90 |
| 91 RawObject* FindObject(FindObjectVisitor* visitor) const; |
| 92 |
| 89 // Collect the garbage in the page space using mark-sweep. | 93 // Collect the garbage in the page space using mark-sweep. |
| 90 void MarkSweep(bool invoke_api_callbacks); | 94 void MarkSweep(bool invoke_api_callbacks); |
| 91 | 95 |
| 92 static HeapPage* PageFor(RawObject* raw_obj) { | 96 static HeapPage* PageFor(RawObject* raw_obj) { |
| 93 return reinterpret_cast<HeapPage*>( | 97 return reinterpret_cast<HeapPage*>( |
| 94 RawObject::ToAddr(raw_obj) & ~(kPageSize -1)); | 98 RawObject::ToAddr(raw_obj) & ~(kPageSize -1)); |
| 95 } | 99 } |
| 96 | 100 |
| 97 private: | 101 private: |
| 98 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage); | 102 static const intptr_t kAllocatablePageSize = kPageSize - sizeof(HeapPage); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 130 | 134 |
| 131 // Keep track whether a MarkSweep is currently running. | 135 // Keep track whether a MarkSweep is currently running. |
| 132 bool sweeping_; | 136 bool sweeping_; |
| 133 | 137 |
| 134 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 138 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 135 }; | 139 }; |
| 136 | 140 |
| 137 } // namespace dart | 141 } // namespace dart |
| 138 | 142 |
| 139 #endif // VM_PAGES_H_ | 143 #endif // VM_PAGES_H_ |
| OLD | NEW |