Reviewers: Erik Corry,
Description:
Clear mark bits while sweeping and not explicitly.
[email protected]
BUG=v8:1463
Please review this at http://codereview.chromium.org/7712026/
SVN Base: https://v8.googlecode.com/svn/branches/experimental/gc
Affected files:
M src/mark-compact.cc
M src/spaces.cc
Index: src/mark-compact.cc
diff --git a/src/mark-compact.cc b/src/mark-compact.cc
index
af720f5773262c047abc200d7d284b9f3bfbf496..fc32435789528771642917f09f1f165968b90704
100644
--- a/src/mark-compact.cc
+++ b/src/mark-compact.cc
@@ -309,35 +309,6 @@ static void VerifyMarkbitsAreClean(Heap* heap) {
#endif
-static void ClearMarkbits(PagedSpace* space) {
- PageIterator it(space);
-
- while (it.has_next()) {
- Bitmap::Clear(it.next());
- }
-}
-
-
-static void ClearMarkbits(NewSpace* space) {
- NewSpacePageIterator it(space->ToSpaceStart(), space->ToSpaceEnd());
-
- while (it.has_next()) {
- Bitmap::Clear(it.next());
- }
-}
-
-
-static void ClearMarkbits(Heap* heap) {
- // TODO(gc): Clean the mark bits while sweeping.
- ClearMarkbits(heap->code_space());
- ClearMarkbits(heap->map_space());
- ClearMarkbits(heap->old_pointer_space());
- ClearMarkbits(heap->old_data_space());
- ClearMarkbits(heap->cell_space());
- ClearMarkbits(heap->new_space());
-}
-
-
bool Marking::TransferMark(Address old_start, Address new_start) {
// This is only used when resizing an object.
ASSERT(MemoryChunk::FromAddress(old_start) ==
@@ -445,12 +416,11 @@ void MarkCompactCollector::Prepare(GCTracer* tracer) {
space->PrepareForMarkCompact();
}
- if (!heap()->incremental_marking()->IsMarking()) {
- ClearMarkbits(heap_);
#ifdef DEBUG
+ if (!heap()->incremental_marking()->IsMarking()) {
VerifyMarkbitsAreClean(heap_);
-#endif
}
+#endif
#ifdef DEBUG
live_bytes_ = 0;
@@ -2663,6 +2633,8 @@ static void SweepPrecisely(PagedSpace* space, Page*
p, SweepingMode mode) {
}
free_start = free_end + size;
}
+ // Clear marking bits for current cell.
+ cells[cell_index] = 0;
}
if (free_start != p->ObjectAreaEnd()) {
space->Free(free_start, static_cast<int>(p->ObjectAreaEnd() -
free_start));
@@ -3174,6 +3146,8 @@ intptr_t
MarkCompactCollector::SweepConservatively(PagedSpace* space, Page* p) {
// Update our undigested record of where the current free area
started.
free_start = block_address;
free_start_cell = cell;
+ // Clear marking bits for current cell.
+ cells[cell_index] = 0;
}
}
Index: src/spaces.cc
diff --git a/src/spaces.cc b/src/spaces.cc
index
ae5f414eaccaa7bce127b05c9535db4eb7708b74..fcd66788e6f51e53d5bc047048c35c0efeeb3f84
100644
--- a/src/spaces.cc
+++ b/src/spaces.cc
@@ -1930,22 +1930,26 @@ void PagedSpace::PrepareForMarkCompact() {
Free(top(), old_linear_size);
SetTop(NULL, NULL);
- // Stop lazy sweeping for the space.
- if (FLAG_trace_gc && first_unswept_page_ != NULL) {
+ // Stop lazy sweeping and clear marking bits for the space.
+ if (first_unswept_page_ != NULL) {
int pages = 0;
- Page* p = last_unswept_page_;
+ Page* last = last_unswept_page_->next_page();
+ Page* p = first_unswept_page_;
do {
pages++;
+ Bitmap::Clear(p);
p = p->next_page();
- } while (p != last_unswept_page_);
- PrintF("Abandoned %d unswept pages\n", pages);
+ } while (p != last);
+ if (FLAG_trace_gc) {
+ PrintF("Abandoned %d unswept pages\n", pages);
+ }
}
first_unswept_page_ = last_unswept_page_ = Page::FromAddress(NULL);
// Clear the free list before a full GC---it will be rebuilt afterward.
free_list_.Reset();
- // Clear EVACUATED flag from all pages.
+ // Clear WAS_SWEPT flag from all pages.
PageIterator it(this);
while (it.has_next()) {
Page* page = it.next();
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev