| 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/lockers.h" | 10 #include "vm/lockers.h" |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 // Should be called after each collection to update the controller state. | 134 // Should be called after each collection to update the controller state. |
| 135 void EvaluateGarbageCollection(SpaceUsage before, | 135 void EvaluateGarbageCollection(SpaceUsage before, |
| 136 SpaceUsage after, | 136 SpaceUsage after, |
| 137 int64_t start, int64_t end); | 137 int64_t start, int64_t end); |
| 138 | 138 |
| 139 int64_t last_code_collection_in_us() { return last_code_collection_in_us_; } | 139 int64_t last_code_collection_in_us() { return last_code_collection_in_us_; } |
| 140 void set_last_code_collection_in_us(int64_t t) { | 140 void set_last_code_collection_in_us(int64_t t) { |
| 141 last_code_collection_in_us_ = t; | 141 last_code_collection_in_us_ = t; |
| 142 } | 142 } |
| 143 | 143 |
| 144 void Enable(SpaceUsage current) { | 144 void set_last_usage(SpaceUsage current) { |
| 145 last_usage_ = current; | 145 last_usage_ = current; |
| 146 } |
| 147 |
| 148 void Enable() { |
| 146 is_enabled_ = true; | 149 is_enabled_ = true; |
| 147 } | 150 } |
| 148 void Disable() { | 151 void Disable() { |
| 149 is_enabled_ = false; | 152 is_enabled_ = false; |
| 150 } | 153 } |
| 151 bool is_enabled() { | 154 bool is_enabled() { |
| 152 return is_enabled_; | 155 return is_enabled_; |
| 153 } | 156 } |
| 154 | 157 |
| 155 private: | 158 private: |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 261 |
| 259 // Checks if enough time has elapsed since the last attempt to collect | 262 // Checks if enough time has elapsed since the last attempt to collect |
| 260 // code. | 263 // code. |
| 261 bool ShouldCollectCode(); | 264 bool ShouldCollectCode(); |
| 262 | 265 |
| 263 // Collect the garbage in the page space using mark-sweep. | 266 // Collect the garbage in the page space using mark-sweep. |
| 264 void MarkSweep(bool invoke_api_callbacks); | 267 void MarkSweep(bool invoke_api_callbacks); |
| 265 | 268 |
| 266 void StartEndAddress(uword* start, uword* end) const; | 269 void StartEndAddress(uword* start, uword* end) const; |
| 267 | 270 |
| 271 void InitGrowthControl() { |
| 272 page_space_controller_.set_last_usage(usage_); |
| 273 page_space_controller_.Enable(); |
| 274 } |
| 275 |
| 268 void SetGrowthControlState(bool state) { | 276 void SetGrowthControlState(bool state) { |
| 269 if (state) { | 277 if (state) { |
| 270 page_space_controller_.Enable(usage_); | 278 page_space_controller_.Enable(); |
| 271 } else { | 279 } else { |
| 272 page_space_controller_.Disable(); | 280 page_space_controller_.Disable(); |
| 273 } | 281 } |
| 274 } | 282 } |
| 275 | 283 |
| 276 bool GrowthControlState() { | 284 bool GrowthControlState() { |
| 277 return page_space_controller_.is_enabled(); | 285 return page_space_controller_.is_enabled(); |
| 278 } | 286 } |
| 279 | 287 |
| 280 bool NeedsExternalGC() const { | 288 bool NeedsExternalGC() const { |
| (...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 friend class HeapIterationScope; | 456 friend class HeapIterationScope; |
| 449 friend class PageSpaceController; | 457 friend class PageSpaceController; |
| 450 friend class SweeperTask; | 458 friend class SweeperTask; |
| 451 | 459 |
| 452 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 460 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 453 }; | 461 }; |
| 454 | 462 |
| 455 } // namespace dart | 463 } // namespace dart |
| 456 | 464 |
| 457 #endif // VM_PAGES_H_ | 465 #endif // VM_PAGES_H_ |
| OLD | NEW |