Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 #include "vm/pages.h" | 5 #include "vm/pages.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/gc_marker.h" | 8 #include "vm/gc_marker.h" |
| 9 #include "vm/gc_sweeper.h" | 9 #include "vm/gc_sweeper.h" |
| 10 #include "vm/object.h" | 10 #include "vm/object.h" |
| (...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 221 uword free_start = result + size; | 221 uword free_start = result + size; |
| 222 freelist_[type].Free(free_start, page->object_end() - free_start); | 222 freelist_[type].Free(free_start, page->object_end() - free_start); |
| 223 } | 223 } |
| 224 } else { | 224 } else { |
| 225 // Large page allocation. | 225 // Large page allocation. |
| 226 intptr_t page_size = LargePageSizeFor(size); | 226 intptr_t page_size = LargePageSizeFor(size); |
| 227 if (page_size < size) { | 227 if (page_size < size) { |
| 228 // On overflow we fail to allocate. | 228 // On overflow we fail to allocate. |
| 229 return 0; | 229 return 0; |
| 230 } | 230 } |
| 231 if (CanIncreaseCapacity(page_size)) { | 231 if ((page_space_controller_.CanGrowPageSpace(size) || |
| 232 growth_policy == kForceGrowth) && | |
| 233 CanIncreaseCapacity(page_size)) { | |
| 232 HeapPage* page = AllocateLargePage(size, type); | 234 HeapPage* page = AllocateLargePage(size, type); |
| 233 if (page != NULL) { | 235 if (page != NULL) { |
| 234 result = page->object_start(); | 236 result = page->object_start(); |
| 235 } | 237 } |
| 236 } | 238 } |
| 237 } | 239 } |
| 238 if (result != 0) { | 240 if (result != 0) { |
| 239 in_use_ += size; | 241 in_use_ += size; |
| 240 } | 242 } |
| 241 ASSERT((result & kObjectAlignmentMask) == kOldObjectAlignmentOffset); | 243 ASSERT((result & kObjectAlignmentMask) == kOldObjectAlignmentOffset); |
| (...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 561 if (!enough_free_space && !enough_free_time) { | 563 if (!enough_free_space && !enough_free_time) { |
| 562 OS::PrintErr(", "); | 564 OS::PrintErr(", "); |
| 563 } | 565 } |
| 564 if (!enough_free_time) { | 566 if (!enough_free_time) { |
| 565 OS::PrintErr("garbage collection time %d%% > %d%%", | 567 OS::PrintErr("garbage collection time %d%% > %d%%", |
| 566 garbage_collection_time_fraction, | 568 garbage_collection_time_fraction, |
| 567 garbage_collection_time_ratio_); | 569 garbage_collection_time_ratio_); |
| 568 } | 570 } |
| 569 OS::PrintErr("\n"); | 571 OS::PrintErr("\n"); |
| 570 } | 572 } |
| 571 if (!enough_free_space) { | 573 intptr_t growth_target = static_cast<intptr_t>(in_use_after / |
|
Ivan Posva
2012/11/30 18:32:27
This is a first step at cleaning up the policy. Th
| |
| 572 intptr_t growth_target = static_cast<intptr_t>(in_use_after / | 574 desired_utilization_); |
| 573 desired_utilization_); | 575 intptr_t growth_in_bytes = Utils::RoundUp(growth_target - in_use_after, |
| 574 intptr_t growth_in_bytes = Utils::RoundUp(growth_target - in_use_after, | 576 PageSpace::kPageSize); |
| 575 PageSpace::kPageSize); | 577 int growth_in_pages = growth_in_bytes / PageSpace::kPageSize; |
| 576 int growth_in_pages = growth_in_bytes / PageSpace::kPageSize; | 578 grow_heap_ = Utils::Maximum(growth_in_pages, heap_growth_rate_); |
| 577 grow_heap_ = Utils::Maximum(growth_in_pages, heap_growth_rate_); | |
| 578 } else { | |
| 579 grow_heap_ = heap_growth_rate_; | |
| 580 } | |
| 581 } | 579 } |
| 582 } | 580 } |
| 583 | 581 |
| 584 | 582 |
| 585 PageSpaceGarbageCollectionHistory::PageSpaceGarbageCollectionHistory() | 583 PageSpaceGarbageCollectionHistory::PageSpaceGarbageCollectionHistory() |
| 586 : index_(0) { | 584 : index_(0) { |
| 587 for (intptr_t i = 0; i < kHistoryLength; i++) { | 585 for (intptr_t i = 0; i < kHistoryLength; i++) { |
| 588 start_[i] = 0; | 586 start_[i] = 0; |
| 589 end_[i] = 0; | 587 end_[i] = 0; |
| 590 } | 588 } |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 619 return 0; | 617 return 0; |
| 620 } else { | 618 } else { |
| 621 ASSERT(total_time >= gc_time); | 619 ASSERT(total_time >= gc_time); |
| 622 int result= static_cast<int>((static_cast<double>(gc_time) / | 620 int result= static_cast<int>((static_cast<double>(gc_time) / |
| 623 static_cast<double>(total_time)) * 100); | 621 static_cast<double>(total_time)) * 100); |
| 624 return result; | 622 return result; |
| 625 } | 623 } |
| 626 } | 624 } |
| 627 | 625 |
| 628 } // namespace dart | 626 } // namespace dart |
| OLD | NEW |