Reviewers: Erik Corry,
Description:
Fix iteration in SetPagesToSweep for lazy sweeping.
Pages for which sweeping is postponed due to lazy sweeping need to be
marked with WAS_SWEPT_CONSERVATIVELY. However this should not be done
for pages which are swept by the evacuator. Moreover the iteration over
the pages list was buggy in PagedSpace::SetPagesToSweep.
[email protected]
Please review this at http://codereview.chromium.org/7720024/
SVN Base: https://v8.googlecode.com/svn/branches/experimental/gc
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
516787de1c4b9c2dd9e9767a3fc39aac30938024..18d9361aaf4ba5a3dbf0fb89742d7825a6e72361
100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -2711,6 +2711,10 @@ void
MarkCompactCollector::EvacuateNewSpaceAndCandidates() {
SlotsBuffer::SizeOfChain(p->slots_buffer()));
}
} else {
+ if (FLAG_gc_verbose) {
+ PrintF("Sweeping 0x%" V8PRIxPTR " during evacuation.\n",
+ reinterpret_cast<intptr_t>(p));
+ }
PagedSpace* space = static_cast<PagedSpace*>(p->owner());
p->ClearFlag(MemoryChunk::RESCAN_ON_EVACUATION);
SweepPrecisely(space, p, SWEEP_AND_UPDATE_SLOTS);
@@ -3203,6 +3207,12 @@ void MarkCompactCollector::SweepSpace(PagedSpace*
space,
continue;
}
+ if (FLAG_gc_verbose) {
+ PrintF("Sweeping 0x%" V8PRIxPTR " with sweeper %d.\n",
+ reinterpret_cast<intptr_t>(p),
+ sweeper);
+ }
+
switch (sweeper) {
case CONSERVATIVE: {
SweepConservatively(space, p);
Index: src/spaces.cc
diff --git a/src/spaces.cc b/src/spaces.cc
index
bc0d6989e27c379d7d218d905dc1cee3ecbd6288..afa36c277144843cc3909d2a32083657b1a72152
100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -1932,17 +1932,16 @@ void PagedSpace::PrepareForMarkCompact() {
// Stop lazy sweeping and clear marking bits for the space.
if (first_unswept_page_ != NULL) {
- int pages = 0;
Page* last = last_unswept_page_->next_page();
Page* p = first_unswept_page_;
do {
- pages++;
Bitmap::Clear(p);
+ if (FLAG_gc_verbose) {
+ PrintF("Sweeping 0x%" V8PRIxPTR " lazily abandoned.\n",
+ reinterpret_cast<intptr_t>(p));
+ }
p = p->next_page();
} while (p != last);
- if (FLAG_trace_gc) {
- PrintF("Abandoned %d unswept pages\n", pages);
- }
}
first_unswept_page_ = last_unswept_page_ = Page::FromAddress(NULL);
@@ -1997,10 +1996,11 @@ bool PagedSpace::AdvanceSweeper(intptr_t
bytes_to_sweep) {
Page* p = first_unswept_page_;
do {
Page* next_page = p->next_page();
- // Evacuation candidates were swept by evacuator.
- if (!p->IsEvacuationCandidate() &&
- !p->IsFlagSet(Page::RESCAN_ON_EVACUATION) &&
- !p->WasSwept()) {
+ if (ShouldBeSweptConservatively(p)) {
+ if (FLAG_gc_verbose) {
+ PrintF("Sweeping 0x%" V8PRIxPTR " lazily advanced.\n",
+ reinterpret_cast<intptr_t>(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
70b9a89a5129fbaa82d52673249281e1402e8c50..a9f649ddc4fa2302cd1c4debd040815b0d526cbf
100644
--- a/src/spaces.h
+++ b/src/spaces.h
@@ -1424,23 +1424,32 @@ class PagedSpace : public Space {
bool was_swept_conservatively() { return was_swept_conservatively_; }
void set_was_swept_conservatively(bool b) { was_swept_conservatively_ =
b; }
- void SetPagesToSweep(Page* first, Page* last) {
- first_unswept_page_ = first;
- last_unswept_page_ = last;
- int unswept_pages = 0;
+ static bool ShouldBeSweptConservatively(Page* p) {
+ // Evacuation candidates are swept by evacuator.
+ return !p->IsEvacuationCandidate() &&
+ !p->IsFlagSet(Page::RESCAN_ON_EVACUATION) &&
+ !p->WasSwept();
+ }
+
+ void SetPagesToSweep(Page* first_page, Page* last_page) {
+ first_unswept_page_ = first_page;
+ last_unswept_page_ = last_page;
- Page* p = first;
+ Page* last = last_page->next_page();
+ Page* p = first_page;
do {
- // The WAS_SWEPT_CONSERVATIVELY flag means that we can't iterate
over the
- // page. We have to set this flag on the pages to indicate this.
- p->SetFlag(MemoryChunk::WAS_SWEPT_CONSERVATIVELY);
+ if (ShouldBeSweptConservatively(p)) {
+ // The WAS_SWEPT_CONSERVATIVELY flag means that we can't iterate
over
+ // the page. We have to set this flag on the pages to indicate
this.
+ ASSERT(!p->IsFlagSet(Page::WAS_SWEPT_CONSERVATIVELY));
+ p->SetFlag(MemoryChunk::WAS_SWEPT_CONSERVATIVELY);
+ if (FLAG_gc_verbose) {
+ PrintF("Sweeping 0x%" V8PRIxPTR " lazily postponed.\n",
+ reinterpret_cast<intptr_t>(p));
+ }
+ }
p = p->next_page();
- unswept_pages++;
} while (p != last);
-
- if (FLAG_trace_gc_verbose) {
- PrintF("Postponing sweep for %d pages\n", unswept_pages);
- }
}
bool AdvanceSweeper(intptr_t bytes_to_sweep);
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev