Reviewers: Michael Lippautz,
Description:
Don't filter store buffer after sweeping.
Additionally, this CL moves a bit of code around to free up more memory
before
compaction starts.
BUG=
Please review this at https://codereview.chromium.org/1305733003/
Base URL:
https://chromium.googlesource.com/v8/v8.git@store-buffer-filtering-for-free
Affected files (+37, -24 lines):
M src/heap/heap.h
M src/heap/heap.cc
M src/heap/mark-compact.cc
M src/heap/spaces.h
M src/heap/spaces.cc
Index: src/heap/heap.cc
diff --git a/src/heap/heap.cc b/src/heap/heap.cc
index
c29224fffb68a5b8329ed28579ae737f6d75678e..4cc0d3e9d79114b2e55441b6395b1ecacd69deaa
100644
--- a/src/heap/heap.cc
+++ b/src/heap/heap.cc
@@ -6661,7 +6661,7 @@ void Heap::QueueMemoryChunkForFree(MemoryChunk*
chunk) {
}
-void Heap::FreeQueuedChunks() {
+void Heap::FilterStoreBufferEntriesOnAboutToBeFreedPages() {
if (chunks_queued_for_free_ == NULL) return;
MemoryChunk* next;
MemoryChunk* chunk;
@@ -6671,6 +6671,12 @@ void Heap::FreeQueuedChunks() {
}
isolate_->heap()->store_buffer()->Compact();
isolate_->heap()->store_buffer()->Filter(MemoryChunk::ABOUT_TO_BE_FREED);
+}
+
+
+void Heap::FreeQueuedChunks() {
+ MemoryChunk* next;
+ MemoryChunk* chunk;
for (chunk = chunks_queued_for_free_; chunk != NULL; chunk = next) {
next = chunk->next_chunk();
isolate_->memory_allocator()->Free(chunk);
Index: src/heap/heap.h
diff --git a/src/heap/heap.h b/src/heap/heap.h
index
a4e3256e94c4fe6e7c94b10c856c5c7a808991cc..be2d14c56e952a3bc011019e6fdf5088235c482f
100644
--- a/src/heap/heap.h
+++ b/src/heap/heap.h
@@ -1429,6 +1429,7 @@ class Heap {
inline bool OldGenerationAllocationLimitReached();
void QueueMemoryChunkForFree(MemoryChunk* chunk);
+ void FilterStoreBufferEntriesOnAboutToBeFreedPages();
void FreeQueuedChunks();
int gc_count() const { return gc_count_; }
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index
6a0c9d58cd3d852f7a8f4228d339b3127a1e99fa..ab00782ca9905d90978a200b953e630997e52369
100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -3760,6 +3760,7 @@ void
MarkCompactCollector::ReleaseEvacuationCandidates() {
}
evacuation_candidates_.Rewind(0);
compacting_ = false;
+ heap()->FilterStoreBufferEntriesOnAboutToBeFreedPages();
heap()->FreeQueuedChunks();
}
@@ -4312,9 +4313,6 @@ void MarkCompactCollector::SweepSpace(PagedSpace*
space, SweeperType sweeper) {
PrintF("SweepSpace: %s (%d pages swept)\n",
AllocationSpaceName(space->identity()), pages_swept);
}
-
- // Give pages that are queued to be freed back to the OS.
- heap()->FreeQueuedChunks();
}
@@ -4331,11 +4329,6 @@ void MarkCompactCollector::SweepSpaces() {
MoveEvacuationCandidatesToEndOfPagesList();
- // Noncompacting collections simply sweep the spaces to clear the mark
- // bits and free the nonlive blocks (for old and map spaces). We sweep
- // the map space last because freeing non-live maps overwrites them and
- // the other spaces rely on possibly non-live maps to get the sizes for
- // non-live objects.
{
{
GCTracer::Scope sweep_scope(heap()->tracer(),
@@ -4358,12 +4351,19 @@ void MarkCompactCollector::SweepSpaces() {
}
}
- EvacuateNewSpaceAndCandidates();
+ // Deallocate unmarked large objects.
+ heap_->lo_space()->FreeUnmarkedObjects();
+
+ // Give pages that are queued to be freed back to the OS. Invalid store
+ // buffer entries are already filter out. We can just release the memory.
+ heap()->FreeQueuedChunks();
heap()->FreeDeadArrayBuffers(false);
- // Deallocate unmarked objects and clear marked bits for marked objects.
- heap_->lo_space()->FreeUnmarkedObjects();
+ EvacuateNewSpaceAndCandidates();
+
+ // Clear the marking state of live large objects.
+ heap_->lo_space()->ClearMarkingStateOfLiveObjects();
// Deallocate evacuated candidate pages.
ReleaseEvacuationCandidates();
Index: src/heap/spaces.cc
diff --git a/src/heap/spaces.cc b/src/heap/spaces.cc
index
e66fd3944cf57c91911013c137c6a91318edf243..1f8194562a1e9ed948d8d9caff464ee43622d4c1
100644
--- a/src/heap/spaces.cc
+++ b/src/heap/spaces.cc
@@ -2933,19 +2933,27 @@ LargePage* LargeObjectSpace::FindPage(Address a) {
}
+void LargeObjectSpace::ClearMarkingStateOfLiveObjects() {
+ LargePage* current = first_page_;
+ while (current != NULL) {
+ HeapObject* object = current->GetObject();
+ MarkBit mark_bit = Marking::MarkBitFrom(object);
+ DCHECK(Marking::IsBlackOrGrey(mark_bit));
+ Marking::BlackToWhite(mark_bit);
+ Page::FromAddress(object->address())->ResetProgressBar();
+ Page::FromAddress(object->address())->ResetLiveBytes();
+ current = current->next_page();
+ }
+}
+
+
void LargeObjectSpace::FreeUnmarkedObjects() {
LargePage* previous = NULL;
LargePage* current = first_page_;
while (current != NULL) {
HeapObject* object = current->GetObject();
- // Can this large page contain pointers to non-trivial objects. No
other
- // pointer object is this big.
- bool is_pointer_object = object->IsFixedArray();
MarkBit mark_bit = Marking::MarkBitFrom(object);
if (Marking::IsBlackOrGrey(mark_bit)) {
- Marking::BlackToWhite(mark_bit);
- Page::FromAddress(object->address())->ResetProgressBar();
- Page::FromAddress(object->address())->ResetLiveBytes();
previous = current;
current = current->next_page();
} else {
@@ -2976,14 +2984,9 @@ void LargeObjectSpace::FreeUnmarkedObjects() {
static_cast<uint32_t>(key));
}
- if (is_pointer_object) {
- heap()->QueueMemoryChunkForFree(page);
- } else {
- heap()->isolate()->memory_allocator()->Free(page);
- }
+ heap()->QueueMemoryChunkForFree(page);
}
}
- heap()->FreeQueuedChunks();
}
Index: src/heap/spaces.h
diff --git a/src/heap/spaces.h b/src/heap/spaces.h
index
2ea2e909aa0c9b567da8e0d280a56a84e48cc977..c00a84fb9b8a55c5da92ddd823b98918aea3097a
100644
--- a/src/heap/spaces.h
+++ b/src/heap/spaces.h
@@ -2744,6 +2744,9 @@ class LargeObjectSpace : public Space {
// if such a page doesn't exist.
LargePage* FindPage(Address a);
+ // Clears the marking state of live objects.
+ void ClearMarkingStateOfLiveObjects();
+
// Frees unmarked objects.
void FreeUnmarkedObjects();
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.