| 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 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 // invoke GC by itself. | 118 // invoke GC by itself. |
| 119 PageSpaceController(Heap* heap, | 119 PageSpaceController(Heap* heap, |
| 120 int heap_growth_ratio, | 120 int heap_growth_ratio, |
| 121 int heap_growth_max, | 121 int heap_growth_max, |
| 122 int garbage_collection_time_ratio); | 122 int garbage_collection_time_ratio); |
| 123 ~PageSpaceController(); | 123 ~PageSpaceController(); |
| 124 | 124 |
| 125 // Returns whether growing to 'after' should trigger a GC. | 125 // Returns whether growing to 'after' should trigger a GC. |
| 126 // 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 |
| 127 // (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. |
| 128 bool NeedsGarbageCollection(SpaceUsage after) const; | 128 bool NeedsGarbageCollection(intptr_t after_capacity_in_words) const; |
| 129 | 129 |
| 130 // Should be called after each collection to update the controller state. | 130 // Should be called after each collection to update the controller state. |
| 131 void EvaluateGarbageCollection(SpaceUsage before, | 131 void EvaluateGarbageCollection(SpaceUsage before, |
| 132 SpaceUsage after, | 132 SpaceUsage after, |
| 133 int64_t start, int64_t end); | 133 int64_t start, int64_t end); |
| 134 | 134 |
| 135 int64_t last_code_collection_in_us() { return last_code_collection_in_us_; } | 135 int64_t last_code_collection_in_us() { return last_code_collection_in_us_; } |
| 136 void set_last_code_collection_in_us(int64_t t) { | 136 void set_last_code_collection_in_us(int64_t t) { |
| 137 last_code_collection_in_us_ = t; | 137 last_code_collection_in_us_ = t; |
| 138 } | 138 } |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 195 }; | 195 }; |
| 196 | 196 |
| 197 PageSpace(Heap* heap, intptr_t max_capacity_in_words); | 197 PageSpace(Heap* heap, intptr_t max_capacity_in_words); |
| 198 ~PageSpace(); | 198 ~PageSpace(); |
| 199 | 199 |
| 200 uword TryAllocate(intptr_t size, | 200 uword TryAllocate(intptr_t size, |
| 201 HeapPage::PageType type = HeapPage::kData, | 201 HeapPage::PageType type = HeapPage::kData, |
| 202 GrowthPolicy growth_policy = kControlGrowth); | 202 GrowthPolicy growth_policy = kControlGrowth); |
| 203 | 203 |
| 204 bool NeedsGarbageCollection() const { | 204 bool NeedsGarbageCollection() const { |
| 205 return page_space_controller_.NeedsGarbageCollection(usage_) || | 205 const bool needs_gc = |
| 206 NeedsExternalGC(); | 206 page_space_controller_.NeedsGarbageCollection(usage_.capacity_in_words); |
| 207 return needs_gc || NeedsExternalGC(); |
| 207 } | 208 } |
| 208 | 209 |
| 209 intptr_t UsedInWords() const { return usage_.used_in_words; } | 210 intptr_t UsedInWords() const { return usage_.used_in_words; } |
| 210 intptr_t CapacityInWords() const { return usage_.capacity_in_words; } | 211 intptr_t CapacityInWords() const { return usage_.capacity_in_words; } |
| 211 intptr_t ExternalInWords() const { | 212 intptr_t ExternalInWords() const { |
| 212 return usage_.external_in_words; | 213 return usage_.external_in_words; |
| 213 } | 214 } |
| 214 SpaceUsage GetCurrentUsage() const { return usage_; } | 215 SpaceUsage GetCurrentUsage() const { return usage_; } |
| 215 | 216 |
| 216 bool Contains(uword addr) const; | 217 bool Contains(uword addr) const; |
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 intptr_t collections_; | 332 intptr_t collections_; |
| 332 | 333 |
| 333 friend class PageSpaceController; | 334 friend class PageSpaceController; |
| 334 | 335 |
| 335 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 336 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 336 }; | 337 }; |
| 337 | 338 |
| 338 } // namespace dart | 339 } // namespace dart |
| 339 | 340 |
| 340 #endif // VM_PAGES_H_ | 341 #endif // VM_PAGES_H_ |
| OLD | NEW |