Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(518)

Unified Diff: runtime/vm/pages.cc

Issue 355123002: If a large object is truncated, also truncate the page. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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;
« runtime/vm/gc_sweeper.cc ('K') | « runtime/vm/pages.h ('k') | runtime/vm/virtual_memory.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698