| Index: runtime/vm/pages.cc
|
| ===================================================================
|
| --- runtime/vm/pages.cc (revision 37116)
|
| +++ runtime/vm/pages.cc (working copy)
|
| @@ -225,17 +225,17 @@
|
| ASSERT(size >= kObjectAlignment);
|
| ASSERT(Utils::IsAligned(size, kObjectAlignment));
|
| uword result = 0;
|
| - SpaceUsage after_allocation = usage_;
|
| - after_allocation.used_in_words += size >> kWordSizeLog2;
|
| + intptr_t after_capacity_in_words = usage_.capacity_in_words;
|
| if (size < kAllocatablePageSize) {
|
| const bool is_protected = (type == HeapPage::kExecutable)
|
| && FLAG_write_protect_code;
|
| result = freelist_[type].TryAllocate(size, is_protected);
|
| if (result == 0) {
|
| // Can we grow by one page?
|
| - after_allocation.capacity_in_words += kPageSizeInWords;
|
| - if ((!page_space_controller_.NeedsGarbageCollection(after_allocation) ||
|
| - growth_policy == kForceGrowth) &&
|
| + after_capacity_in_words += kPageSizeInWords;
|
| + const bool needs_gc = page_space_controller_.NeedsGarbageCollection(
|
| + after_capacity_in_words);
|
| + if ((!needs_gc || growth_policy == kForceGrowth) &&
|
| CanIncreaseCapacityInWords(kPageSizeInWords)) {
|
| HeapPage* page = AllocatePage(type);
|
| ASSERT(page != NULL);
|
| @@ -256,9 +256,10 @@
|
| // On overflow we fail to allocate.
|
| return 0;
|
| }
|
| - after_allocation.capacity_in_words += page_size_in_words;
|
| - if ((!page_space_controller_.NeedsGarbageCollection(after_allocation) ||
|
| - growth_policy == kForceGrowth) &&
|
| + after_capacity_in_words += page_size_in_words;
|
| + const bool needs_gc = page_space_controller_.NeedsGarbageCollection(
|
| + after_capacity_in_words);
|
| + if ((!needs_gc || growth_policy == kForceGrowth) &&
|
| CanIncreaseCapacityInWords(page_size_in_words)) {
|
| HeapPage* page = AllocateLargePage(size, type);
|
| if (page != NULL) {
|
| @@ -267,7 +268,8 @@
|
| }
|
| }
|
| if (result != 0) {
|
| - usage_ = after_allocation;
|
| + usage_.used_in_words += (size >> kWordSizeLog2);
|
| + usage_.capacity_in_words = after_capacity_in_words;
|
| if (FLAG_compiler_stats && (type == HeapPage::kExecutable)) {
|
| CompilerStats::code_allocated += size;
|
| }
|
| @@ -585,7 +587,8 @@
|
| PageSpaceController::~PageSpaceController() {}
|
|
|
|
|
| -bool PageSpaceController::NeedsGarbageCollection(SpaceUsage after) const {
|
| +bool PageSpaceController::NeedsGarbageCollection(
|
| + intptr_t after_capacity_in_words) const {
|
| if (!is_enabled_) {
|
| return false;
|
| }
|
| @@ -593,7 +596,7 @@
|
| return false;
|
| }
|
| intptr_t capacity_increase_in_words =
|
| - after.capacity_in_words - last_usage_.capacity_in_words;
|
| + after_capacity_in_words - last_usage_.capacity_in_words;
|
| ASSERT(capacity_increase_in_words >= 0);
|
| capacity_increase_in_words =
|
| Utils::RoundUp(capacity_increase_in_words, PageSpace::kPageSizeInWords);
|
|
|