Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: runtime/vm/pages.h

Issue 474913004: - Account for number of pending tasks in old-space collections. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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"
11 #include "vm/spaces.h" 11 #include "vm/spaces.h"
12 #include "vm/virtual_memory.h" 12 #include "vm/virtual_memory.h"
13 13
14 namespace dart { 14 namespace dart {
15 15
16 DECLARE_FLAG(bool, collect_code); 16 DECLARE_FLAG(bool, collect_code);
17 DECLARE_FLAG(bool, log_code_drop); 17 DECLARE_FLAG(bool, log_code_drop);
18 DECLARE_FLAG(bool, always_drop_code); 18 DECLARE_FLAG(bool, always_drop_code);
19 DECLARE_FLAG(bool, write_protect_code);
19 20
20 // Forward declarations. 21 // Forward declarations.
21 class Heap; 22 class Heap;
22 class JSONObject; 23 class JSONObject;
23 class ObjectPointerVisitor; 24 class ObjectPointerVisitor;
24 25
25 // A page containing old generation objects. 26 // A page containing old generation objects.
26 class HeapPage { 27 class HeapPage {
27 public: 28 public:
28 enum PageType { 29 enum PageType {
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
192 enum GrowthPolicy { 193 enum GrowthPolicy {
193 kControlGrowth, 194 kControlGrowth,
194 kForceGrowth 195 kForceGrowth
195 }; 196 };
196 197
197 PageSpace(Heap* heap, intptr_t max_capacity_in_words); 198 PageSpace(Heap* heap, intptr_t max_capacity_in_words);
198 ~PageSpace(); 199 ~PageSpace();
199 200
200 uword TryAllocate(intptr_t size, 201 uword TryAllocate(intptr_t size,
201 HeapPage::PageType type = HeapPage::kData, 202 HeapPage::PageType type = HeapPage::kData,
202 GrowthPolicy growth_policy = kControlGrowth); 203 GrowthPolicy growth_policy = kControlGrowth) {
204 bool is_protected =
205 (type == HeapPage::kExecutable) && FLAG_write_protect_code;
206 return TryAllocateInternal(size, type, growth_policy, is_protected, false);
koda 2014/08/20 00:10:21 Comment 'false' (or use a local).
Ivan Posva 2014/08/20 03:50:53 Done.
207 }
203 208
204 bool NeedsGarbageCollection() const { 209 bool NeedsGarbageCollection() const {
205 return page_space_controller_.NeedsGarbageCollection(usage_) || 210 return page_space_controller_.NeedsGarbageCollection(usage_) ||
206 NeedsExternalGC(); 211 NeedsExternalGC();
207 } 212 }
208 213
209 intptr_t UsedInWords() const { return usage_.used_in_words; } 214 intptr_t UsedInWords() const { return usage_.used_in_words; }
210 intptr_t CapacityInWords() const { return usage_.capacity_in_words; } 215 intptr_t CapacityInWords() const { return usage_.capacity_in_words; }
211 intptr_t ExternalInWords() const { 216 intptr_t ExternalInWords() const {
212 return usage_.external_in_words; 217 return usage_.external_in_words;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
269 intptr_t collections() const { 274 intptr_t collections() const {
270 return collections_; 275 return collections_;
271 } 276 }
272 277
273 void PrintToJSONObject(JSONObject* object); 278 void PrintToJSONObject(JSONObject* object);
274 void PrintHeapMapToJSONStream(Isolate* isolate, JSONStream* stream); 279 void PrintHeapMapToJSONStream(Isolate* isolate, JSONStream* stream);
275 280
276 void AllocateExternal(intptr_t size); 281 void AllocateExternal(intptr_t size);
277 void FreeExternal(intptr_t size); 282 void FreeExternal(intptr_t size);
278 283
284 // Bulk data allocation.
285 void AcquireDataLock();
286 void ReleaseDataLock();
287
288 uword TryAllocateDataLocked(intptr_t size, GrowthPolicy growth_policy) {
289 return TryAllocateInternal(size,
290 HeapPage::kData,
291 growth_policy,
292 false, true);
koda 2014/08/20 00:10:21 Comment 'false' and 'true'.
Ivan Posva 2014/08/20 03:50:54 Done.
293 }
294
279 private: 295 private:
280 // Ids for time and data records in Heap::GCStats. 296 // Ids for time and data records in Heap::GCStats.
281 enum { 297 enum {
282 // Time 298 // Time
283 kMarkObjects = 0, 299 kMarkObjects = 0,
284 kResetFreeLists = 1, 300 kResetFreeLists = 1,
285 kSweepPages = 2, 301 kSweepPages = 2,
286 kSweepLargePages = 3, 302 kSweepLargePages = 3,
287 // Data 303 // Data
288 kGarbageRatio = 0, 304 kGarbageRatio = 0,
289 kGCTimeFraction = 1, 305 kGCTimeFraction = 1,
290 kPageGrowth = 2, 306 kPageGrowth = 2,
291 kAllowedGrowth = 3 307 kAllowedGrowth = 3
292 }; 308 };
293 309
310 Monitor* tasks_lock() const { return tasks_lock_; }
311 intptr_t tasks() const { return tasks_; }
312 void set_tasks(intptr_t val) { tasks_ = val; }
313
294 static const intptr_t kAllocatablePageSize = 64 * KB; 314 static const intptr_t kAllocatablePageSize = 64 * KB;
295 315
316 uword TryAllocateInternal(intptr_t size,
317 HeapPage::PageType type,
318 GrowthPolicy growth_policy,
319 bool is_protected,
320 bool is_locked);
296 HeapPage* AllocatePage(HeapPage::PageType type); 321 HeapPage* AllocatePage(HeapPage::PageType type);
297 void FreePage(HeapPage* page, HeapPage* previous_page); 322 void FreePage(HeapPage* page, HeapPage* previous_page);
298 HeapPage* AllocateLargePage(intptr_t size, HeapPage::PageType type); 323 HeapPage* AllocateLargePage(intptr_t size, HeapPage::PageType type);
299 void TruncateLargePage(HeapPage* page, intptr_t new_object_size_in_bytes); 324 void TruncateLargePage(HeapPage* page, intptr_t new_object_size_in_bytes);
300 void FreeLargePage(HeapPage* page, HeapPage* previous_page); 325 void FreeLargePage(HeapPage* page, HeapPage* previous_page);
301 void FreePages(HeapPage* pages); 326 void FreePages(HeapPage* pages);
302 HeapPage* NextPageAnySize(HeapPage* page) const { 327 HeapPage* NextPageAnySize(HeapPage* page) const {
303 ASSERT(pages_tail_ == NULL || pages_tail_->next() == NULL); 328 ASSERT(pages_tail_ == NULL || pages_tail_->next() == NULL);
304 return page == pages_tail_ ? large_pages_ : page->next(); 329 return page == pages_tail_ ? large_pages_ : page->next();
305 } 330 }
(...skipping 10 matching lines...) Expand all
316 Heap* heap_; 341 Heap* heap_;
317 342
318 HeapPage* pages_; 343 HeapPage* pages_;
319 HeapPage* pages_tail_; 344 HeapPage* pages_tail_;
320 HeapPage* large_pages_; 345 HeapPage* large_pages_;
321 346
322 // Various sizes being tracked for this generation. 347 // Various sizes being tracked for this generation.
323 intptr_t max_capacity_in_words_; 348 intptr_t max_capacity_in_words_;
324 SpaceUsage usage_; 349 SpaceUsage usage_;
325 350
326 // Keep track whether a MarkSweep is currently running. 351 // Keep track of running MarkSweep tasks.
327 bool sweeping_; 352 Monitor* tasks_lock_;
353 intptr_t tasks_;
328 354
329 PageSpaceController page_space_controller_; 355 PageSpaceController page_space_controller_;
330 356
331 int64_t gc_time_micros_; 357 int64_t gc_time_micros_;
332 intptr_t collections_; 358 intptr_t collections_;
333 359
334 friend class PageSpaceController; 360 friend class PageSpaceController;
335 361
336 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); 362 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace);
337 }; 363 };
338 364
339 } // namespace dart 365 } // namespace dart
340 366
341 #endif // VM_PAGES_H_ 367 #endif // VM_PAGES_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698