Commit 6738bbeb authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Refactor marking deque processing.

This makes popping from the marking deque safe for concurrent marking.

BUG=chromium:694255

Change-Id: I3edf8ece3d3c3dd8f045b3ea2f8196b322a56a54
Reviewed-on: https://chromium-review.googlesource.com/527154
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Reviewed-by: 's avatarHannes Payer <hpayer@chromium.org>
Cr-Commit-Position: refs/heads/master@{#45806}
parent 8edef78d
...@@ -98,7 +98,7 @@ class ConcurrentMarkingVisitor final ...@@ -98,7 +98,7 @@ class ConcurrentMarkingVisitor final
// =========================================================================== // ===========================================================================
int VisitFixedArray(Map* map, FixedArray* object) override { int VisitFixedArray(Map* map, FixedArray* object) override {
int length = object->length(); int length = object->synchronized_length();
int size = FixedArray::SizeFor(length); int size = FixedArray::SizeFor(length);
if (!ShouldVisit(object)) return 0; if (!ShouldVisit(object)) return 0;
VisitMapPointer(object, object->map_slot()); VisitMapPointer(object, object->map_slot());
...@@ -256,9 +256,10 @@ void ConcurrentMarking::Run() { ...@@ -256,9 +256,10 @@ void ConcurrentMarking::Run() {
base::Mutex* relocation_mutex = heap_->relocation_mutex(); base::Mutex* relocation_mutex = heap_->relocation_mutex();
{ {
TimedScope scope(&time_ms); TimedScope scope(&time_ms);
HeapObject* object; while (true) {
while ((object = deque_->Pop(MarkingThread::kConcurrent)) != nullptr) {
base::LockGuard<base::Mutex> guard(relocation_mutex); base::LockGuard<base::Mutex> guard(relocation_mutex);
HeapObject* object = deque_->Pop(MarkingThread::kConcurrent);
if (object == nullptr) break;
Address new_space_top = heap_->new_space()->original_top(); Address new_space_top = heap_->new_space()->original_top();
Address new_space_limit = heap_->new_space()->original_limit(); Address new_space_limit = heap_->new_space()->original_limit();
Address addr = object->address(); Address addr = object->address();
......
...@@ -905,10 +905,9 @@ void IncrementalMarking::VisitObject(Map* map, HeapObject* obj, int size) { ...@@ -905,10 +905,9 @@ void IncrementalMarking::VisitObject(Map* map, HeapObject* obj, int size) {
intptr_t IncrementalMarking::ProcessMarkingDeque( intptr_t IncrementalMarking::ProcessMarkingDeque(
intptr_t bytes_to_process, ForceCompletionAction completion) { intptr_t bytes_to_process, ForceCompletionAction completion) {
intptr_t bytes_processed = 0; intptr_t bytes_processed = 0;
while (!marking_deque()->IsEmpty() && (bytes_processed < bytes_to_process || while (bytes_processed < bytes_to_process || completion == FORCE_COMPLETION) {
completion == FORCE_COMPLETION)) {
HeapObject* obj = marking_deque()->Pop(); HeapObject* obj = marking_deque()->Pop();
if (obj == nullptr) break;
// Left trimming may result in white, grey, or black filler objects on the // Left trimming may result in white, grey, or black filler objects on the
// marking deque. Ignore these objects. // marking deque. Ignore these objects.
if (obj->IsFiller()) { if (obj->IsFiller()) {
......
...@@ -2038,9 +2038,8 @@ void MarkCompactCollector::MarkRoots(RootMarkingVisitor* visitor) { ...@@ -2038,9 +2038,8 @@ void MarkCompactCollector::MarkRoots(RootMarkingVisitor* visitor) {
// After: the marking stack is empty, and all objects reachable from the // After: the marking stack is empty, and all objects reachable from the
// marking stack have been marked, or are overflowed in the heap. // marking stack have been marked, or are overflowed in the heap.
void MarkCompactCollector::EmptyMarkingDeque() { void MarkCompactCollector::EmptyMarkingDeque() {
while (!marking_deque()->IsEmpty()) { HeapObject* object;
HeapObject* object = marking_deque()->Pop(); while ((object = marking_deque()->Pop()) != nullptr) {
DCHECK(!object->IsFiller()); DCHECK(!object->IsFiller());
DCHECK(object->IsHeapObject()); DCHECK(object->IsHeapObject());
DCHECK(heap()->Contains(object)); DCHECK(heap()->Contains(object));
...@@ -2051,6 +2050,7 @@ void MarkCompactCollector::EmptyMarkingDeque() { ...@@ -2051,6 +2050,7 @@ void MarkCompactCollector::EmptyMarkingDeque() {
MarkObject(map); MarkObject(map);
MarkCompactMarkingVisitor::IterateBody(map, object); MarkCompactMarkingVisitor::IterateBody(map, object);
} }
DCHECK(marking_deque()->IsEmpty());
} }
......
...@@ -72,7 +72,7 @@ class SequentialMarkingDeque { ...@@ -72,7 +72,7 @@ class SequentialMarkingDeque {
} }
INLINE(HeapObject* Pop()) { INLINE(HeapObject* Pop()) {
DCHECK(!IsEmpty()); if (IsEmpty()) return nullptr;
top_ = ((top_ - 1) & mask_); top_ = ((top_ - 1) & mask_);
HeapObject* object = array_[top_]; HeapObject* object = array_[top_];
return object; return object;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment