Fix corner-case in heap size estimation.

Empty but unswept pages could cause the unswept_free_bytes counter to
to be off in case heap gets shrunk and page gets released before it was
swept properly.

R=vegorov@chromium.org
BUG=v8:1893

Review URL: https://chromiumcodereview.appspot.com/9241010

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@10421 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 73ac9928
......@@ -3630,6 +3630,9 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) {
PrintF("Sweeping 0x%" V8PRIxPTR " released page.\n",
reinterpret_cast<intptr_t>(p));
}
// Adjust unswept free bytes because releasing a page expects said
// counter to be accurate for unswept pages.
space->IncreaseUnsweptFreeBytes(p);
space->ReleasePage(p);
continue;
}
......@@ -3641,7 +3644,7 @@ void MarkCompactCollector::SweepSpace(PagedSpace* space, SweeperType sweeper) {
PrintF("Sweeping 0x%" V8PRIxPTR " lazily postponed.\n",
reinterpret_cast<intptr_t>(p));
}
space->MarkPageForLazySweeping(p);
space->IncreaseUnsweptFreeBytes(p);
continue;
}
......
......@@ -765,6 +765,8 @@ void PagedSpace::ReleasePage(Page* page) {
intptr_t size = free_list_.EvictFreeListItems(page);
accounting_stats_.AllocateBytes(size);
ASSERT_EQ(Page::kObjectAreaSize, static_cast<int>(size));
} else {
DecreaseUnsweptFreeBytes(page);
}
if (Page::FromAllocationTop(allocation_info_.top) == page) {
......@@ -2112,7 +2114,7 @@ bool PagedSpace::AdvanceSweeper(intptr_t bytes_to_sweep) {
PrintF("Sweeping 0x%" V8PRIxPTR " lazily advanced.\n",
reinterpret_cast<intptr_t>(p));
}
unswept_free_bytes_ -= (Page::kObjectAreaSize - p->LiveBytes());
DecreaseUnsweptFreeBytes(p);
freed_bytes += MarkCompactCollector::SweepConservatively(this, p);
}
p = next_page;
......
......@@ -1563,10 +1563,16 @@ class PagedSpace : public Space {
first_unswept_page_ = first;
}
void MarkPageForLazySweeping(Page* p) {
void IncreaseUnsweptFreeBytes(Page* p) {
ASSERT(ShouldBeSweptLazily(p));
unswept_free_bytes_ += (Page::kObjectAreaSize - p->LiveBytes());
}
void DecreaseUnsweptFreeBytes(Page* p) {
ASSERT(ShouldBeSweptLazily(p));
unswept_free_bytes_ -= (Page::kObjectAreaSize - p->LiveBytes());
}
bool AdvanceSweeper(intptr_t bytes_to_sweep);
bool IsSweepingComplete() {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment