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
// ===========================================================================
int VisitFixedArray(Map* map, FixedArray* object) override {
int length = object->length();
int length = object->synchronized_length();
int size = FixedArray::SizeFor(length);
if (!ShouldVisit(object)) return 0;
VisitMapPointer(object, object->map_slot());
......@@ -256,9 +256,10 @@ void ConcurrentMarking::Run() {
base::Mutex* relocation_mutex = heap_->relocation_mutex();
{
TimedScope scope(&time_ms);
HeapObject* object;
while ((object = deque_->Pop(MarkingThread::kConcurrent)) != nullptr) {
while (true) {
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_limit = heap_->new_space()->original_limit();
Address addr = object->address();
......
......@@ -905,10 +905,9 @@ void IncrementalMarking::VisitObject(Map* map, HeapObject* obj, int size) {
intptr_t IncrementalMarking::ProcessMarkingDeque(
intptr_t bytes_to_process, ForceCompletionAction completion) {
intptr_t bytes_processed = 0;
while (!marking_deque()->IsEmpty() && (bytes_processed < bytes_to_process ||
completion == FORCE_COMPLETION)) {
while (bytes_processed < bytes_to_process || completion == FORCE_COMPLETION) {
HeapObject* obj = marking_deque()->Pop();
if (obj == nullptr) break;
// Left trimming may result in white, grey, or black filler objects on the
// marking deque. Ignore these objects.
if (obj->IsFiller()) {
......
......@@ -2038,9 +2038,8 @@ void MarkCompactCollector::MarkRoots(RootMarkingVisitor* visitor) {
// After: the marking stack is empty, and all objects reachable from the
// marking stack have been marked, or are overflowed in the heap.
void MarkCompactCollector::EmptyMarkingDeque() {
while (!marking_deque()->IsEmpty()) {
HeapObject* object = marking_deque()->Pop();
HeapObject* object;
while ((object = marking_deque()->Pop()) != nullptr) {
DCHECK(!object->IsFiller());
DCHECK(object->IsHeapObject());
DCHECK(heap()->Contains(object));
......@@ -2051,6 +2050,7 @@ void MarkCompactCollector::EmptyMarkingDeque() {
MarkObject(map);
MarkCompactMarkingVisitor::IterateBody(map, object);
}
DCHECK(marking_deque()->IsEmpty());
}
......
......@@ -72,7 +72,7 @@ class SequentialMarkingDeque {
}
INLINE(HeapObject* Pop()) {
DCHECK(!IsEmpty());
if (IsEmpty()) return nullptr;
top_ = ((top_ - 1) & mask_);
HeapObject* object = array_[top_];
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