| 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 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 | 298 |
| 299 Monitor* tasks_lock() const { return tasks_lock_; } | 299 Monitor* tasks_lock() const { return tasks_lock_; } |
| 300 intptr_t tasks() const { return tasks_; } | 300 intptr_t tasks() const { return tasks_; } |
| 301 void set_tasks(intptr_t val) { | 301 void set_tasks(intptr_t val) { |
| 302 ASSERT(val >= 0); | 302 ASSERT(val >= 0); |
| 303 tasks_ = val; | 303 tasks_ = val; |
| 304 } | 304 } |
| 305 | 305 |
| 306 // Attempt to allocate from bump block rather than normal freelist. | 306 // Attempt to allocate from bump block rather than normal freelist. |
| 307 uword TryAllocateDataBump(intptr_t size, GrowthPolicy growth_policy); | 307 uword TryAllocateDataBump(intptr_t size, GrowthPolicy growth_policy); |
| 308 uword TryAllocateDataBumpLocked(intptr_t size, GrowthPolicy growth_policy); |
| 309 uword TryAllocatePromoLocked(intptr_t size, GrowthPolicy growth_policy); |
| 308 | 310 |
| 309 private: | 311 private: |
| 310 // Ids for time and data records in Heap::GCStats. | 312 // Ids for time and data records in Heap::GCStats. |
| 311 enum { | 313 enum { |
| 312 // Time | 314 // Time |
| 313 kMarkObjects = 0, | 315 kMarkObjects = 0, |
| 314 kResetFreeLists = 1, | 316 kResetFreeLists = 1, |
| 315 kSweepPages = 2, | 317 kSweepPages = 2, |
| 316 kSweepLargePages = 3, | 318 kSweepLargePages = 3, |
| 317 // Data | 319 // Data |
| 318 kGarbageRatio = 0, | 320 kGarbageRatio = 0, |
| 319 kGCTimeFraction = 1, | 321 kGCTimeFraction = 1, |
| 320 kPageGrowth = 2, | 322 kPageGrowth = 2, |
| 321 kAllowedGrowth = 3 | 323 kAllowedGrowth = 3 |
| 322 }; | 324 }; |
| 323 | 325 |
| 324 static const intptr_t kAllocatablePageSize = 64 * KB; | 326 static const intptr_t kAllocatablePageSize = 64 * KB; |
| 325 | 327 |
| 326 uword TryAllocateInternal(intptr_t size, | 328 uword TryAllocateInternal(intptr_t size, |
| 327 HeapPage::PageType type, | 329 HeapPage::PageType type, |
| 328 GrowthPolicy growth_policy, | 330 GrowthPolicy growth_policy, |
| 329 bool is_protected, | 331 bool is_protected, |
| 330 bool is_locked); | 332 bool is_locked); |
| 331 uword TryAllocateInFreshPage(intptr_t size, | 333 uword TryAllocateInFreshPage(intptr_t size, |
| 332 HeapPage::PageType type, | 334 HeapPage::PageType type, |
| 333 GrowthPolicy growth_policy, | 335 GrowthPolicy growth_policy, |
| 334 bool is_locked); | 336 bool is_locked); |
| 337 uword TryAllocateDataBumpInternal(intptr_t size, |
| 338 GrowthPolicy growth_policy, |
| 339 bool is_locked); |
| 335 HeapPage* AllocatePage(HeapPage::PageType type); | 340 HeapPage* AllocatePage(HeapPage::PageType type); |
| 336 void FreePage(HeapPage* page, HeapPage* previous_page); | 341 void FreePage(HeapPage* page, HeapPage* previous_page); |
| 337 HeapPage* AllocateLargePage(intptr_t size, HeapPage::PageType type); | 342 HeapPage* AllocateLargePage(intptr_t size, HeapPage::PageType type); |
| 338 void TruncateLargePage(HeapPage* page, intptr_t new_object_size_in_bytes); | 343 void TruncateLargePage(HeapPage* page, intptr_t new_object_size_in_bytes); |
| 339 void FreeLargePage(HeapPage* page, HeapPage* previous_page); | 344 void FreeLargePage(HeapPage* page, HeapPage* previous_page); |
| 340 void FreePages(HeapPage* pages); | 345 void FreePages(HeapPage* pages); |
| 341 HeapPage* NextPageAnySize(HeapPage* page) const { | 346 HeapPage* NextPageAnySize(HeapPage* page) const { |
| 342 ASSERT((pages_tail_ == NULL) || (pages_tail_->next() == NULL)); | 347 ASSERT((pages_tail_ == NULL) || (pages_tail_->next() == NULL)); |
| 343 ASSERT((exec_pages_tail_ == NULL) || (exec_pages_tail_->next() == NULL)); | 348 ASSERT((exec_pages_tail_ == NULL) || (exec_pages_tail_->next() == NULL)); |
| 344 if (page == pages_tail_) { | 349 if (page == pages_tail_) { |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 385 | 390 |
| 386 friend class PageSpaceController; | 391 friend class PageSpaceController; |
| 387 friend class SweeperTask; | 392 friend class SweeperTask; |
| 388 | 393 |
| 389 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); | 394 DISALLOW_IMPLICIT_CONSTRUCTORS(PageSpace); |
| 390 }; | 395 }; |
| 391 | 396 |
| 392 } // namespace dart | 397 } // namespace dart |
| 393 | 398 |
| 394 #endif // VM_PAGES_H_ | 399 #endif // VM_PAGES_H_ |
| OLD | NEW |