Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1154)

Unified Diff: src/heap/incremental-marking.cc

Issue 2810893002: [heap] Implement simple concurrent marking deque. (Closed)
Patch Set: rebase Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: src/heap/incremental-marking.cc
diff --git a/src/heap/incremental-marking.cc b/src/heap/incremental-marking.cc
index 4ce5db2928df471f87ff654db80e8b5ea90f4d3d..327d8636e029a894adcb89b5a608ee3ee409dee6 100644
--- a/src/heap/incremental-marking.cc
+++ b/src/heap/incremental-marking.cc
@@ -551,9 +551,6 @@ void IncrementalMarking::StartMarking() {
if (FLAG_concurrent_marking) {
ConcurrentMarking* concurrent_marking = heap_->concurrent_marking();
- marking_deque()->Iterate([concurrent_marking](HeapObject* obj) {
- concurrent_marking->AddRoot(obj);
- });
concurrent_marking->StartTask();
}
@@ -711,8 +708,6 @@ void IncrementalMarking::FinalizeIncrementally() {
double start = heap_->MonotonicallyIncreasingTimeInMs();
- int old_marking_deque_top = marking_deque()->top();
-
// After finishing incremental marking, we try to discover all unmarked
// objects to reduce the marking load in the final pause.
// 1) We scan and mark the roots again to find all changes to the root set.
@@ -728,10 +723,10 @@ void IncrementalMarking::FinalizeIncrementally() {
}
ProcessWeakCells();
- int marking_progress = abs(old_marking_deque_top - marking_deque()->top());
-
- marking_progress += static_cast<int>(
- heap_->local_embedder_heap_tracer()->NumberOfCachedWrappersToTrace());
+ int marking_progress =
+ heap_->mark_compact_collector()->marking_deque()->Size() +
+ static_cast<int>(
+ heap_->local_embedder_heap_tracer()->NumberOfCachedWrappersToTrace());
double end = heap_->MonotonicallyIncreasingTimeInMs();
double delta = end - start;
@@ -763,51 +758,42 @@ void IncrementalMarking::FinalizeIncrementally() {
void IncrementalMarking::UpdateMarkingDequeAfterScavenge() {
if (!IsMarking()) return;
- int current = marking_deque()->bottom();
- int mask = marking_deque()->mask();
- int limit = marking_deque()->top();
- HeapObject** array = marking_deque()->array();
- int new_top = current;
-
+ MarkingDeque* marking_deque =
+ heap_->mark_compact_collector()->marking_deque();
Map* filler_map = heap_->one_pointer_filler_map();
-
- while (current != limit) {
- HeapObject* obj = array[current];
+ Heap* heap = heap_;
+ marking_deque->Update([heap, filler_map](HeapObject* obj) -> HeapObject* {
DCHECK(obj->IsHeapObject());
- current = ((current + 1) & mask);
// Only pointers to from space have to be updated.
- if (heap_->InFromSpace(obj)) {
+ if (heap->InFromSpace(obj)) {
MapWord map_word = obj->map_word();
// There may be objects on the marking deque that do not exist anymore,
// e.g. left trimmed objects or objects from the root set (frames).
// If these object are dead at scavenging time, their marking deque
// entries will not point to forwarding addresses. Hence, we can discard
// them.
- if (map_word.IsForwardingAddress()) {
- HeapObject* dest = map_word.ToForwardingAddress();
- if (ObjectMarking::IsBlack(dest, marking_state(dest))) continue;
- array[new_top] = dest;
- new_top = ((new_top + 1) & mask);
- DCHECK(new_top != marking_deque()->bottom());
- DCHECK(ObjectMarking::IsGrey(obj, marking_state(obj)) ||
- (obj->IsFiller() &&
- ObjectMarking::IsWhite(obj, marking_state(obj))));
+ if (!map_word.IsForwardingAddress()) return nullptr;
+ HeapObject* dest = map_word.ToForwardingAddress();
+ if (ObjectMarking::IsBlack(dest, MarkingState::Internal(dest))) {
+ // The object is already processed by the marker.
+ return nullptr;
}
- } else if (obj->map() != filler_map) {
+ DCHECK(ObjectMarking::IsGrey(obj, MarkingState::Internal(obj)) ||
+ (obj->IsFiller() &&
+ ObjectMarking::IsWhite(obj, MarkingState::Internal(obj))));
+ return dest;
+ } else {
// Skip one word filler objects that appear on the
// stack when we perform in place array shift.
- array[new_top] = obj;
- new_top = ((new_top + 1) & mask);
- DCHECK(new_top != marking_deque()->bottom());
- DCHECK(ObjectMarking::IsGrey(obj, marking_state(obj)) ||
+ DCHECK(ObjectMarking::IsGrey(obj, MarkingState::Internal(obj)) ||
(obj->IsFiller() &&
ObjectMarking::IsWhite(obj, marking_state(obj))) ||
(MemoryChunk::FromAddress(obj->address())
->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) &&
- ObjectMarking::IsBlack(obj, marking_state(obj))));
+ ObjectMarking::IsBlack(obj, MarkingState::Internal(obj))));
+ return (obj->map() == filler_map) ? nullptr : obj;
}
- }
- marking_deque()->set_top(new_top);
+ });
}
« no previous file with comments | « src/heap/heap.cc ('k') | src/heap/mark-compact.h » ('j') | test/cctest/heap/test-mark-compact.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698