Index: runtime/vm/pages.cc |
=================================================================== |
--- runtime/vm/pages.cc (revision 37758) |
+++ runtime/vm/pages.cc (working copy) |
@@ -182,6 +182,22 @@ |
} |
+void PageSpace::TruncateLargePage(HeapPage* page, |
+ intptr_t new_object_size_in_bytes) { |
+ const intptr_t old_object_size_in_bytes = |
+ page->object_end() - page->object_start(); |
+ ASSERT(new_object_size_in_bytes < old_object_size_in_bytes); |
+ const intptr_t new_page_size_in_words = |
+ LargePageSizeInWordsFor(new_object_size_in_bytes); |
+ VirtualMemory* memory = page->memory_; |
+ const intptr_t old_page_size_in_words = (memory->size() >> kWordSizeLog2); |
+ memory->Truncate(memory->start(), (new_page_size_in_words << kWordSizeLog2)); |
+ usage_.capacity_in_words -= old_page_size_in_words; |
+ usage_.capacity_in_words += new_page_size_in_words; |
+ page->set_object_end(page->object_start() + new_object_size_in_bytes); |
+} |
+ |
+ |
void PageSpace::FreePage(HeapPage* page, HeapPage* previous_page) { |
usage_.capacity_in_words -= (page->memory_->size() >> kWordSizeLog2); |
// Remove the page from the list. |
@@ -538,11 +554,14 @@ |
page = large_pages_; |
while (page != NULL) { |
HeapPage* next_page = page->next(); |
- bool page_in_use = sweeper.SweepLargePage(page); |
- if (page_in_use) { |
+ const intptr_t bytes_to_end = sweeper.SweepLargePage(page); |
+ if (bytes_to_end == 0) { |
+ FreeLargePage(page, prev_page); |
+ } else { |
+ if (bytes_to_end < (page->object_end() - page->object_start())) { |
Ivan Posva
2014/06/30 05:51:05
I am wondering whether we want to move the logic h
koda
2014/06/30 22:57:49
Done.
|
+ TruncateLargePage(page, bytes_to_end); |
+ } |
prev_page = page; |
- } else { |
- FreeLargePage(page, prev_page); |
} |
// Advance to the next page. |
page = next_page; |