| 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/spaces.h" | 10 #include "vm/spaces.h" |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 129 // the heap will grow. | 129 // the heap will grow. |
| 130 void EvaluateGarbageCollection(SpaceUsage before, | 130 void EvaluateGarbageCollection(SpaceUsage before, |
| 131 SpaceUsage after, | 131 SpaceUsage after, |
| 132 int64_t start, int64_t end); | 132 int64_t start, int64_t end); |
| 133 | 133 |
| 134 int64_t last_code_collection_in_us() { return last_code_collection_in_us_; } | 134 int64_t last_code_collection_in_us() { return last_code_collection_in_us_; } |
| 135 void set_last_code_collection_in_us(int64_t t) { | 135 void set_last_code_collection_in_us(int64_t t) { |
| 136 last_code_collection_in_us_ = t; | 136 last_code_collection_in_us_ = t; |
| 137 } | 137 } |
| 138 | 138 |
| 139 void set_is_enabled(bool state) { | 139 void Enable(SpaceUsage current) { |
| 140 is_enabled_ = state; | 140 last_usage_ = current; |
| 141 is_enabled_ = true; |
| 142 } |
| 143 void Disable() { |
| 144 is_enabled_ = false; |
| 141 } | 145 } |
| 142 bool is_enabled() { | 146 bool is_enabled() { |
| 143 return is_enabled_; | 147 return is_enabled_; |
| 144 } | 148 } |
| 145 | 149 |
| 146 private: | 150 private: |
| 147 bool is_enabled_; | 151 bool is_enabled_; |
| 148 | 152 |
| 149 // Usage after last evaluated GC. | 153 // Usage after last evaluated GC or last enabled. |
| 150 SpaceUsage last_usage_; | 154 SpaceUsage last_usage_; |
| 151 | 155 |
| 152 // Heap growth control variable. | 156 // Pages of capacity growth allowed before next GC is advised. |
| 153 intptr_t grow_heap_; | 157 intptr_t grow_heap_; |
| 154 | 158 |
| 155 // If the garbage collector was not able to free more than heap_growth_ratio_ | 159 // If the garbage collector was not able to free more than heap_growth_ratio_ |
| 156 // memory, then the heap is grown. Otherwise garbage collection is performed. | 160 // memory, then the heap is grown. Otherwise garbage collection is performed. |
| 157 int heap_growth_ratio_; | 161 int heap_growth_ratio_; |
| 158 | 162 |
| 159 // The desired percent of heap in-use after a garbage collection. | 163 // The desired percent of heap in-use after a garbage collection. |
| 160 // Equivalent to \frac{100-heap_growth_ratio_}{100}. | 164 // Equivalent to \frac{100-heap_growth_ratio_}{100}. |
| 161 double desired_utilization_; | 165 double desired_utilization_; |
| 162 | 166 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 220 // Checks if enough time has elapsed since the last attempt to collect | 224 // Checks if enough time has elapsed since the last attempt to collect |
| 221 // code. | 225 // code. |
| 222 bool ShouldCollectCode(); | 226 bool ShouldCollectCode(); |
| 223 | 227 |
| 224 // Collect the garbage in the page space using mark-sweep. | 228 // Collect the garbage in the page space using mark-sweep. |
| 225 void MarkSweep(bool invoke_api_callbacks); | 229 void MarkSweep(bool invoke_api_callbacks); |
| 226 | 230 |
| 227 void StartEndAddress(uword* start, uword* end) const; | 231 void StartEndAddress(uword* start, uword* end) const; |
| 228 | 232 |
| 229 void SetGrowthControlState(bool state) { | 233 void SetGrowthControlState(bool state) { |
| 230 page_space_controller_.set_is_enabled(state); | 234 if (state) { |
| 235 page_space_controller_.Enable(usage_); |
| 236 } else { |
| 237 page_space_controller_.Disable(); |
| 238 } |
| 231 } | 239 } |
| 232 | 240 |
| 233 bool GrowthControlState() { | 241 bool GrowthControlState() { |
| 234 return page_space_controller_.is_enabled(); | 242 return page_space_controller_.is_enabled(); |
| 235 } | 243 } |
| 236 | 244 |
| 237 bool NeedExternalGC() { | 245 bool NeedExternalGC() { |
| 238 return UsedInWords() + ExternalInWords() > max_capacity_in_words_; | 246 return UsedInWords() + ExternalInWords() > max_capacity_in_words_; |
| 239 } | 247 } |
| 240 | 248 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 313 intptr_t collections_; | 321 intptr_t collections_; |
| 314 | 322 |
| 315 friend class PageSpaceController; | 323 friend class PageSpaceController; |
| 316 | 324 |
| 317 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 325 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 318 }; | 326 }; |
| 319 | 327 |
| 320 } // namespace dart | 328 } // namespace dart |
| 321 | 329 |
| 322 #endif // VM_PAGES_H_ | 330 #endif // VM_PAGES_H_ |
| OLD | NEW |