| 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 <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "vm/freelist.h" | 10 #include "vm/freelist.h" |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 | 120 |
| 121 bool CanGrowPageSpace(intptr_t size_in_bytes); | 121 bool CanGrowPageSpace(intptr_t size_in_bytes); |
| 122 | 122 |
| 123 // A garbage collection is considered as successful if more than | 123 // A garbage collection is considered as successful if more than |
| 124 // heap_growth_ratio % of memory got deallocated by the garbage collector. | 124 // heap_growth_ratio % of memory got deallocated by the garbage collector. |
| 125 // In this case garbage collection will be performed next time. Otherwise | 125 // In this case garbage collection will be performed next time. Otherwise |
| 126 // the heap will grow. | 126 // the heap will grow. |
| 127 void EvaluateGarbageCollection(intptr_t in_use_before, intptr_t in_use_after, | 127 void EvaluateGarbageCollection(intptr_t in_use_before, intptr_t in_use_after, |
| 128 int64_t start, int64_t end); | 128 int64_t start, int64_t end); |
| 129 | 129 |
| 130 void Enable() { | 130 void set_is_enabled(bool state) { |
| 131 is_enabled_ = true; | 131 is_enabled_ = state; |
| 132 } |
| 133 bool is_enabled() { |
| 134 return is_enabled_; |
| 132 } | 135 } |
| 133 | 136 |
| 134 private: | 137 private: |
| 135 bool is_enabled_; | 138 bool is_enabled_; |
| 136 | 139 |
| 137 // Heap growth control variable. | 140 // Heap growth control variable. |
| 138 intptr_t grow_heap_; | 141 intptr_t grow_heap_; |
| 139 | 142 |
| 140 // If the garbage collector was not able to free more than heap_growth_ratio_ | 143 // If the garbage collector was not able to free more than heap_growth_ratio_ |
| 141 // memory, then the heap is grown. Otherwise garbage collection is performed. | 144 // memory, then the heap is grown. Otherwise garbage collection is performed. |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 197 // Collect the garbage in the page space using mark-sweep. | 200 // Collect the garbage in the page space using mark-sweep. |
| 198 void MarkSweep(bool invoke_api_callbacks); | 201 void MarkSweep(bool invoke_api_callbacks); |
| 199 | 202 |
| 200 static HeapPage* PageFor(RawObject* raw_obj) { | 203 static HeapPage* PageFor(RawObject* raw_obj) { |
| 201 return reinterpret_cast<HeapPage*>( | 204 return reinterpret_cast<HeapPage*>( |
| 202 RawObject::ToAddr(raw_obj) & ~(kPageSize -1)); | 205 RawObject::ToAddr(raw_obj) & ~(kPageSize -1)); |
| 203 } | 206 } |
| 204 | 207 |
| 205 void StartEndAddress(uword* start, uword* end) const; | 208 void StartEndAddress(uword* start, uword* end) const; |
| 206 | 209 |
| 207 void EnableGrowthControl() { | 210 void SetGrowthControlState(bool state) { |
| 208 page_space_controller_.Enable(); | 211 page_space_controller_.set_is_enabled(state); |
| 212 } |
| 213 |
| 214 bool GrowthControlState() { |
| 215 return page_space_controller_.is_enabled(); |
| 209 } | 216 } |
| 210 | 217 |
| 211 void WriteProtect(bool read_only); | 218 void WriteProtect(bool read_only); |
| 212 | 219 |
| 213 typedef std::map<RawObject*, void*> PeerTable; | 220 typedef std::map<RawObject*, void*> PeerTable; |
| 214 | 221 |
| 215 void SetPeer(RawObject* raw_obj, void* peer); | 222 void SetPeer(RawObject* raw_obj, void* peer); |
| 216 | 223 |
| 217 void* GetPeer(RawObject* raw_obj); | 224 void* GetPeer(RawObject* raw_obj); |
| 218 | 225 |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 PageSpaceController page_space_controller_; | 278 PageSpaceController page_space_controller_; |
| 272 | 279 |
| 273 friend class PageSpaceController; | 280 friend class PageSpaceController; |
| 274 | 281 |
| 275 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 282 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 276 }; | 283 }; |
| 277 | 284 |
| 278 } // namespace dart | 285 } // namespace dart |
| 279 | 286 |
| 280 #endif // VM_PAGES_H_ | 287 #endif // VM_PAGES_H_ |
| OLD | NEW |