| 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/compiler_stats.h" | 8 #include "vm/compiler_stats.h" |
| 9 #include "vm/gc_marker.h" | 9 #include "vm/gc_marker.h" |
| 10 #include "vm/gc_sweeper.h" | 10 #include "vm/gc_sweeper.h" |
| (...skipping 215 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 226 freelist_[type].Free(free_start, free_size); | 226 freelist_[type].Free(free_start, free_size); |
| 227 } | 227 } |
| 228 } | 228 } |
| 229 } else { | 229 } else { |
| 230 // Large page allocation. | 230 // Large page allocation. |
| 231 intptr_t page_size = LargePageSizeFor(size); | 231 intptr_t page_size = LargePageSizeFor(size); |
| 232 if (page_size < size) { | 232 if (page_size < size) { |
| 233 // On overflow we fail to allocate. | 233 // On overflow we fail to allocate. |
| 234 return 0; | 234 return 0; |
| 235 } | 235 } |
| 236 if (CanIncreaseCapacity(page_size)) { | 236 if ((page_space_controller_.CanGrowPageSpace(size) || |
| 237 growth_policy == kForceGrowth) && |
| 238 CanIncreaseCapacity(page_size)) { |
| 237 HeapPage* page = AllocateLargePage(size, type); | 239 HeapPage* page = AllocateLargePage(size, type); |
| 238 if (page != NULL) { | 240 if (page != NULL) { |
| 239 result = page->object_start(); | 241 result = page->object_start(); |
| 240 } | 242 } |
| 241 } | 243 } |
| 242 } | 244 } |
| 243 if (result != 0) { | 245 if (result != 0) { |
| 244 in_use_ += size; | 246 in_use_ += size; |
| 245 if (FLAG_compiler_stats && (type == HeapPage::kExecutable)) { | 247 if (FLAG_compiler_stats && (type == HeapPage::kExecutable)) { |
| 246 CompilerStats::code_allocated += size; | 248 CompilerStats::code_allocated += size; |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 577 if (!enough_free_space && !enough_free_time) { | 579 if (!enough_free_space && !enough_free_time) { |
| 578 OS::PrintErr(", "); | 580 OS::PrintErr(", "); |
| 579 } | 581 } |
| 580 if (!enough_free_time) { | 582 if (!enough_free_time) { |
| 581 OS::PrintErr("garbage collection time %d%% > %d%%", | 583 OS::PrintErr("garbage collection time %d%% > %d%%", |
| 582 garbage_collection_time_fraction, | 584 garbage_collection_time_fraction, |
| 583 garbage_collection_time_ratio_); | 585 garbage_collection_time_ratio_); |
| 584 } | 586 } |
| 585 OS::PrintErr("\n"); | 587 OS::PrintErr("\n"); |
| 586 } | 588 } |
| 587 if (!enough_free_space) { | 589 intptr_t growth_target = static_cast<intptr_t>(in_use_after / |
| 588 intptr_t growth_target = static_cast<intptr_t>(in_use_after / | 590 desired_utilization_); |
| 589 desired_utilization_); | 591 intptr_t growth_in_bytes = Utils::RoundUp(growth_target - in_use_after, |
| 590 intptr_t growth_in_bytes = Utils::RoundUp(growth_target - in_use_after, | 592 PageSpace::kPageSize); |
| 591 PageSpace::kPageSize); | 593 int growth_in_pages = growth_in_bytes / PageSpace::kPageSize; |
| 592 int growth_in_pages = growth_in_bytes / PageSpace::kPageSize; | 594 grow_heap_ = Utils::Maximum(growth_in_pages, heap_growth_rate_); |
| 593 grow_heap_ = Utils::Maximum(growth_in_pages, heap_growth_rate_); | |
| 594 } else { | |
| 595 grow_heap_ = heap_growth_rate_; | |
| 596 } | |
| 597 } | 595 } |
| 598 } | 596 } |
| 599 | 597 |
| 600 | 598 |
| 601 PageSpaceGarbageCollectionHistory::PageSpaceGarbageCollectionHistory() | 599 PageSpaceGarbageCollectionHistory::PageSpaceGarbageCollectionHistory() |
| 602 : index_(0) { | 600 : index_(0) { |
| 603 for (intptr_t i = 0; i < kHistoryLength; i++) { | 601 for (intptr_t i = 0; i < kHistoryLength; i++) { |
| 604 start_[i] = 0; | 602 start_[i] = 0; |
| 605 end_[i] = 0; | 603 end_[i] = 0; |
| 606 } | 604 } |
| (...skipping 28 matching lines...) Expand all Loading... |
| 635 return 0; | 633 return 0; |
| 636 } else { | 634 } else { |
| 637 ASSERT(total_time >= gc_time); | 635 ASSERT(total_time >= gc_time); |
| 638 int result= static_cast<int>((static_cast<double>(gc_time) / | 636 int result= static_cast<int>((static_cast<double>(gc_time) / |
| 639 static_cast<double>(total_time)) * 100); | 637 static_cast<double>(total_time)) * 100); |
| 640 return result; | 638 return result; |
| 641 } | 639 } |
| 642 } | 640 } |
| 643 | 641 |
| 644 } // namespace dart | 642 } // namespace dart |
| OLD | NEW |