Reviewers: Vyacheslav Egorov,
Description:
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.
[email protected]
BUG=v8:1893
Please review this at http://codereview.chromium.org/9241010/
SVN Base: https://v8.googlecode.com/svn/branches/bleeding_edge
Affected files:
M src/mark-compact.cc
M src/spaces.h
M src/spaces.cc
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index
f2f649b86610ec71ef58cbd04ea734fa09f47a1f..a05f93a8a800b4436b7e310bf8eb2af1e6a8db64
100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -3633,6 +3633,7 @@ void MarkCompactCollector::SweepSpace(PagedSpace*
space, SweeperType sweeper) {
PrintF("Sweeping 0x%" V8PRIxPTR " released page.\n",
reinterpret_cast<intptr_t>(p));
}
+ space->MarkPageForLazySweeping(p);
space->ReleasePage(p);
continue;
}
Index: src/spaces.cc
diff --git a/src/spaces.cc b/src/spaces.cc
index
c96388b238293c148a7e24c72d760a4b539d5cb2..ce62f5530544a43e465a0890952854a3420675a6
100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -881,6 +881,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 {
+ UnmarkPageForLazySweeping(page);
}
if (Page::FromAllocationTop(allocation_info_.top) == page) {
@@ -2280,7 +2282,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());
+ UnmarkPageForLazySweeping(p);
freed_bytes += MarkCompactCollector::SweepConservatively(this, p);
}
p = next_page;
Index: src/spaces.h
diff --git a/src/spaces.h b/src/spaces.h
index
f067398f50db54723293f4f05286ecda98c8783d..92bd91208b0cbb5af67f1c8e5391b78562e0a022
100644
--- a/src/spaces.h
+++ b/src/spaces.h
@@ -1587,9 +1587,15 @@ class PagedSpace : public Space {
}
void MarkPageForLazySweeping(Page* p) {
+ ASSERT(ShouldBeSweptLazily(p));
unswept_free_bytes_ += (Page::kObjectAreaSize - p->LiveBytes());
}
+ void UnmarkPageForLazySweeping(Page* p) {
+ ASSERT(ShouldBeSweptLazily(p));
+ unswept_free_bytes_ -= (Page::kObjectAreaSize - p->LiveBytes());
+ }
+
bool AdvanceSweeper(intptr_t bytes_to_sweep);
bool IsSweepingComplete() {
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev