Commit a7ab836a authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[heap] Fix atomicity of IncrementalMarking::TransferColor.

Bug: chromium:694255
TBR: mlippautz@chromium.org
Change-Id: Ie9f2f7bff8ada297b1d078947f073eaf62ac0649
Reviewed-on: https://chromium-review.googlesource.com/610782Reviewed-by: 's avatarUlan Degenbaev <ulan@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#47293}
parent 7adbb4a2
......@@ -49,6 +49,7 @@ IncrementalMarking::IncrementalMarking(Heap* heap)
new_generation_observer_(*this, kAllocatedThreshold),
old_generation_observer_(*this, kAllocatedThreshold),
marking_state_(nullptr),
atomic_marking_state_(nullptr),
non_atomic_marking_state_(nullptr) {
SetState(STOPPED);
}
......@@ -471,6 +472,8 @@ void IncrementalMarking::Start(GarbageCollectionReason gc_reason) {
DCHECK(heap_->gc_state() == Heap::NOT_IN_GC);
DCHECK(!heap_->isolate()->serializer_enabled());
marking_state_ = heap_->mark_compact_collector()->marking_state();
atomic_marking_state_ =
heap_->mark_compact_collector()->atomic_marking_state();
non_atomic_marking_state_ =
heap_->mark_compact_collector()->non_atomic_marking_state();
......
......@@ -60,6 +60,11 @@ class V8_EXPORT_PRIVATE IncrementalMarking {
return marking_state_;
}
MarkCompactCollector::AtomicMarkingState* atomic_marking_state() const {
DCHECK_NOT_NULL(atomic_marking_state_);
return atomic_marking_state_;
}
MarkCompactCollector::NonAtomicMarkingState* non_atomic_marking_state()
const {
DCHECK_NOT_NULL(non_atomic_marking_state_);
......@@ -69,18 +74,18 @@ class V8_EXPORT_PRIVATE IncrementalMarking {
void NotifyLeftTrimming(HeapObject* from, HeapObject* to);
V8_INLINE void TransferColor(HeapObject* from, HeapObject* to) {
if (marking_state()->IsBlack(to)) {
if (atomic_marking_state()->IsBlack(to)) {
DCHECK(black_allocation());
return;
}
DCHECK(marking_state()->IsWhite(to));
if (marking_state()->IsGrey(from)) {
bool success = marking_state()->WhiteToGrey(to);
DCHECK(atomic_marking_state()->IsWhite(to));
if (atomic_marking_state()->IsGrey(from)) {
bool success = atomic_marking_state()->WhiteToGrey(to);
DCHECK(success);
USE(success);
} else if (marking_state()->IsBlack(from)) {
bool success = marking_state()->WhiteToBlack(to);
} else if (atomic_marking_state()->IsBlack(from)) {
bool success = atomic_marking_state()->WhiteToBlack(to);
DCHECK(success);
USE(success);
}
......@@ -352,6 +357,7 @@ class V8_EXPORT_PRIVATE IncrementalMarking {
Observer old_generation_observer_;
MarkCompactCollector::MarkingState* marking_state_;
MarkCompactCollector::AtomicMarkingState* atomic_marking_state_;
MarkCompactCollector::NonAtomicMarkingState* non_atomic_marking_state_;
DISALLOW_IMPLICIT_CONSTRUCTORS(IncrementalMarking);
......
......@@ -1568,7 +1568,7 @@ class YoungGenerationMigrationObserver final : public MigrationObserver {
// Migrate color to old generation marking in case the object survived young
// generation garbage collection.
if (heap_->incremental_marking()->IsMarking()) {
DCHECK(mark_compact_collector_->marking_state()->IsWhite(dst));
DCHECK(mark_compact_collector_->atomic_marking_state()->IsWhite(dst));
heap_->incremental_marking()->TransferColor(src, dst);
}
}
......
......@@ -486,6 +486,7 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
using MarkingState = MajorNonAtomicMarkingState;
#endif
using NonAtomicMarkingState = MajorNonAtomicMarkingState;
using AtomicMarkingState = MajorMarkingState;
static const int kMainThread = 0;
// Wrapper for the shared and bailout worklists.
......@@ -674,6 +675,8 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
MarkingState* marking_state() { return &marking_state_; }
AtomicMarkingState* atomic_marking_state() { return &atomic_marking_state_; }
NonAtomicMarkingState* non_atomic_marking_state() {
return &non_atomic_marking_state_;
}
......@@ -948,6 +951,7 @@ class MarkCompactCollector final : public MarkCompactCollectorBase {
Sweeper sweeper_;
MarkingState marking_state_;
AtomicMarkingState atomic_marking_state_;
NonAtomicMarkingState non_atomic_marking_state_;
friend class FullEvacuator;
......
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