| 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/ring_buffer.h" | 10 #include "vm/ring_buffer.h" |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 107 RingBuffer<Entry, kHistoryLength> history_; | 107 RingBuffer<Entry, kHistoryLength> history_; |
| 108 | 108 |
| 109 DISALLOW_ALLOCATION(); | 109 DISALLOW_ALLOCATION(); |
| 110 DISALLOW_COPY_AND_ASSIGN(PageSpaceGarbageCollectionHistory); | 110 DISALLOW_COPY_AND_ASSIGN(PageSpaceGarbageCollectionHistory); |
| 111 }; | 111 }; |
| 112 | 112 |
| 113 | 113 |
| 114 // PageSpaceController controls the heap size. | 114 // PageSpaceController controls the heap size. |
| 115 class PageSpaceController { | 115 class PageSpaceController { |
| 116 public: | 116 public: |
| 117 PageSpaceController(int heap_growth_ratio, | 117 // The heap is passed in for recording stats only. The controller does not |
| 118 // invoke GC by itself. |
| 119 PageSpaceController(Heap* heap, |
| 120 int heap_growth_ratio, |
| 118 int heap_growth_max, | 121 int heap_growth_max, |
| 119 int garbage_collection_time_ratio); | 122 int garbage_collection_time_ratio); |
| 120 ~PageSpaceController(); | 123 ~PageSpaceController(); |
| 121 | 124 |
| 122 // Returns whether growing to 'after' should trigger a GC. | 125 // Returns whether growing to 'after' should trigger a GC. |
| 123 // This method can be called before allocation (e.g., pretenuring) or after | 126 // This method can be called before allocation (e.g., pretenuring) or after |
| 124 // (e.g., promotion), as it does not change the state of the controller. | 127 // (e.g., promotion), as it does not change the state of the controller. |
| 125 bool NeedsGarbageCollection(SpaceUsage after) const; | 128 bool NeedsGarbageCollection(SpaceUsage after) const; |
| 126 | 129 |
| 127 // Should be called after each collection to update the controller state. | 130 // Should be called after each collection to update the controller state. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 139 is_enabled_ = true; | 142 is_enabled_ = true; |
| 140 } | 143 } |
| 141 void Disable() { | 144 void Disable() { |
| 142 is_enabled_ = false; | 145 is_enabled_ = false; |
| 143 } | 146 } |
| 144 bool is_enabled() { | 147 bool is_enabled() { |
| 145 return is_enabled_; | 148 return is_enabled_; |
| 146 } | 149 } |
| 147 | 150 |
| 148 private: | 151 private: |
| 152 Heap* heap_; |
| 153 |
| 149 bool is_enabled_; | 154 bool is_enabled_; |
| 150 | 155 |
| 151 // Usage after last evaluated GC or last enabled. | 156 // Usage after last evaluated GC or last enabled. |
| 152 SpaceUsage last_usage_; | 157 SpaceUsage last_usage_; |
| 153 | 158 |
| 154 // Pages of capacity growth allowed before next GC is advised. | 159 // Pages of capacity growth allowed before next GC is advised. |
| 155 intptr_t grow_heap_; | 160 intptr_t grow_heap_; |
| 156 | 161 |
| 157 // If the garbage collector was not able to free more than heap_growth_ratio_ | 162 // If the garbage collector was not able to free more than heap_growth_ratio_ |
| 158 // memory, then the heap is grown. Otherwise garbage collection is performed. | 163 // memory, then the heap is grown. Otherwise garbage collection is performed. |
| (...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 320 intptr_t collections_; | 325 intptr_t collections_; |
| 321 | 326 |
| 322 friend class PageSpaceController; | 327 friend class PageSpaceController; |
| 323 | 328 |
| 324 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 329 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 325 }; | 330 }; |
| 326 | 331 |
| 327 } // namespace dart | 332 } // namespace dart |
| 328 | 333 |
| 329 #endif // VM_PAGES_H_ | 334 #endif // VM_PAGES_H_ |
| OLD | NEW |