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