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 RUNTIME_VM_PAGES_H_ | 5 #ifndef RUNTIME_VM_PAGES_H_ |
6 #define RUNTIME_VM_PAGES_H_ | 6 #define RUNTIME_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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 HeapPage* next_; | 75 HeapPage* next_; |
76 uword object_end_; | 76 uword object_end_; |
77 PageType type_; | 77 PageType type_; |
78 | 78 |
79 friend class PageSpace; | 79 friend class PageSpace; |
80 | 80 |
81 DISALLOW_ALLOCATION(); | 81 DISALLOW_ALLOCATION(); |
82 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapPage); | 82 DISALLOW_IMPLICIT_CONSTRUCTORS(HeapPage); |
83 }; | 83 }; |
84 | 84 |
85 | |
86 // The history holds the timing information of the last garbage collection | 85 // The history holds the timing information of the last garbage collection |
87 // runs. | 86 // runs. |
88 class PageSpaceGarbageCollectionHistory { | 87 class PageSpaceGarbageCollectionHistory { |
89 public: | 88 public: |
90 PageSpaceGarbageCollectionHistory() {} | 89 PageSpaceGarbageCollectionHistory() {} |
91 ~PageSpaceGarbageCollectionHistory() {} | 90 ~PageSpaceGarbageCollectionHistory() {} |
92 | 91 |
93 void AddGarbageCollectionTime(int64_t start, int64_t end); | 92 void AddGarbageCollectionTime(int64_t start, int64_t end); |
94 | 93 |
95 int GarbageCollectionTimeFraction(); | 94 int GarbageCollectionTimeFraction(); |
96 | 95 |
97 bool IsEmpty() const { return history_.Size() == 0; } | 96 bool IsEmpty() const { return history_.Size() == 0; } |
98 | 97 |
99 private: | 98 private: |
100 struct Entry { | 99 struct Entry { |
101 int64_t start; | 100 int64_t start; |
102 int64_t end; | 101 int64_t end; |
103 }; | 102 }; |
104 static const intptr_t kHistoryLength = 4; | 103 static const intptr_t kHistoryLength = 4; |
105 RingBuffer<Entry, kHistoryLength> history_; | 104 RingBuffer<Entry, kHistoryLength> history_; |
106 | 105 |
107 DISALLOW_ALLOCATION(); | 106 DISALLOW_ALLOCATION(); |
108 DISALLOW_COPY_AND_ASSIGN(PageSpaceGarbageCollectionHistory); | 107 DISALLOW_COPY_AND_ASSIGN(PageSpaceGarbageCollectionHistory); |
109 }; | 108 }; |
110 | 109 |
111 | |
112 // PageSpaceController controls the heap size. | 110 // PageSpaceController controls the heap size. |
113 class PageSpaceController { | 111 class PageSpaceController { |
114 public: | 112 public: |
115 // The heap is passed in for recording stats only. The controller does not | 113 // The heap is passed in for recording stats only. The controller does not |
116 // invoke GC by itself. | 114 // invoke GC by itself. |
117 PageSpaceController(Heap* heap, | 115 PageSpaceController(Heap* heap, |
118 int heap_growth_ratio, | 116 int heap_growth_ratio, |
119 int heap_growth_max, | 117 int heap_growth_max, |
120 int garbage_collection_time_ratio); | 118 int garbage_collection_time_ratio); |
121 ~PageSpaceController(); | 119 ~PageSpaceController(); |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
170 | 168 |
171 // The time in microseconds of the last time we tried to collect unused | 169 // The time in microseconds of the last time we tried to collect unused |
172 // code. | 170 // code. |
173 int64_t last_code_collection_in_us_; | 171 int64_t last_code_collection_in_us_; |
174 | 172 |
175 PageSpaceGarbageCollectionHistory history_; | 173 PageSpaceGarbageCollectionHistory history_; |
176 | 174 |
177 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpaceController); | 175 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpaceController); |
178 }; | 176 }; |
179 | 177 |
180 | |
181 class PageSpace { | 178 class PageSpace { |
182 public: | 179 public: |
183 // TODO(iposva): Determine heap sizes and tune the page size accordingly. | 180 // TODO(iposva): Determine heap sizes and tune the page size accordingly. |
184 static const intptr_t kPageSizeInWords = 256 * KBInWords; | 181 static const intptr_t kPageSizeInWords = 256 * KBInWords; |
185 | 182 |
186 enum GrowthPolicy { kControlGrowth, kForceGrowth }; | 183 enum GrowthPolicy { kControlGrowth, kForceGrowth }; |
187 | 184 |
188 PageSpace(Heap* heap, | 185 PageSpace(Heap* heap, |
189 intptr_t max_capacity_in_words, | 186 intptr_t max_capacity_in_words, |
190 intptr_t max_external_in_words); | 187 intptr_t max_external_in_words); |
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
432 friend class HeapIterationScope; | 429 friend class HeapIterationScope; |
433 friend class PageSpaceController; | 430 friend class PageSpaceController; |
434 friend class SweeperTask; | 431 friend class SweeperTask; |
435 | 432 |
436 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 433 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
437 }; | 434 }; |
438 | 435 |
439 } // namespace dart | 436 } // namespace dart |
440 | 437 |
441 #endif // RUNTIME_VM_PAGES_H_ | 438 #endif // RUNTIME_VM_PAGES_H_ |
OLD | NEW |