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

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

Issue 2810893002: [heap] Implement simple concurrent marking deque. (Closed)
Patch Set: revert flags 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 4c671c9a2f5c70d3befb2e13ed52bc3b84bce136..359b9207a3a869ea3760df7d1e7ab2451346a792 100644
--- a/src/heap/incremental-marking.cc
+++ b/src/heap/incremental-marking.cc
@@ -551,10 +551,6 @@ void IncrementalMarking::StartMarking() {
if (FLAG_concurrent_marking) {
ConcurrentMarking* concurrent_marking = heap_->concurrent_marking();
- heap_->mark_compact_collector()->marking_deque()->Iterate(
- [concurrent_marking](HeapObject* obj) {
- concurrent_marking->AddRoot(obj);
- });
concurrent_marking->StartTask();
}
@@ -712,9 +708,6 @@ void IncrementalMarking::FinalizeIncrementally() {
double start = heap_->MonotonicallyIncreasingTimeInMs();
- int old_marking_deque_top =
- heap_->mark_compact_collector()->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.
@@ -731,11 +724,9 @@ void IncrementalMarking::FinalizeIncrementally() {
ProcessWeakCells();
int marking_progress =
- abs(old_marking_deque_top -
- heap_->mark_compact_collector()->marking_deque()->top());
-
- marking_progress += static_cast<int>(
- heap_->local_embedder_heap_tracer()->NumberOfCachedWrappersToTrace());
+ heap_->mark_compact_collector()->marking_deque()->Size() +
ulan 2017/04/27 17:49:39 This changes behavior.
+ static_cast<int>(
+ heap_->local_embedder_heap_tracer()->NumberOfCachedWrappersToTrace());
double end = heap_->MonotonicallyIncreasingTimeInMs();
double delta = end - start;
@@ -769,52 +760,40 @@ void IncrementalMarking::UpdateMarkingDequeAfterScavenge() {
MarkingDeque* marking_deque =
heap_->mark_compact_collector()->marking_deque();
- int current = marking_deque->bottom();
ulan 2017/04/27 17:49:39 We no longer can assume contiguous structure of th
- int mask = marking_deque->mask();
- int limit = marking_deque->top();
- HeapObject** array = marking_deque->array();
- int new_top = current;
-
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, MarkingState::Internal(dest)))
- continue;
- array[new_top] = dest;
- new_top = ((new_top + 1) & mask);
- DCHECK(new_top != marking_deque->bottom());
- DCHECK(ObjectMarking::IsGrey(obj, MarkingState::Internal(obj)) ||
- (obj->IsFiller() &&
- ObjectMarking::IsWhite(obj, MarkingState::Internal(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, MarkingState::Internal(obj)) ||
(obj->IsFiller() &&
ObjectMarking::IsWhite(obj, MarkingState::Internal(obj))) ||
(MemoryChunk::FromAddress(obj->address())
->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR) &&
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') | src/heap/mark-compact.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698