Commit df319447 authored by mlippautz's avatar mlippautz Committed by Commit bot

[heap] Cleanup: Untangle marking state and deque in incremental marking

BUG=v8:6325, v8:6330

Review-Url: https://codereview.chromium.org/2847953002
Cr-Commit-Position: refs/heads/master@{#44983}
parent 0cd4ab71
......@@ -3201,8 +3201,8 @@ FixedArrayBase* Heap::LeftTrimFixedArray(FixedArrayBase* object,
!Marking::IsBlack(ObjectMarking::MarkBitFrom(
HeapObject::FromAddress(new_start),
MarkingState::Internal(HeapObject::FromAddress(new_start))))) {
IncrementalMarking::TransferMark(this, object,
HeapObject::FromAddress(new_start));
incremental_marking()->TransferMark(this, object,
HeapObject::FromAddress(new_start));
}
// Technically in new space this write might be omitted (except for
......@@ -4287,7 +4287,7 @@ void Heap::RegisterReservationsForBlackAllocation(Reservation* reservations) {
void Heap::NotifyObjectLayoutChange(HeapObject* object,
const DisallowHeapAllocation&) {
if (FLAG_incremental_marking && incremental_marking()->IsMarking()) {
incremental_marking()->MarkGrey(this, object);
incremental_marking()->MarkGrey(object);
}
#ifdef VERIFY_HEAP
DCHECK(pending_layout_change_object_ == nullptr);
......@@ -4852,7 +4852,7 @@ class IterateAndScavengePromotedObjectsVisitor final : public ObjectVisitor {
// promoted objects.
if (heap_->incremental_marking()->black_allocation()) {
Code* code = Code::cast(Code::GetObjectFromEntryAddress(code_entry_slot));
IncrementalMarking::MarkGrey(heap_, code);
heap_->incremental_marking()->MarkGrey(code);
}
}
......@@ -4891,7 +4891,7 @@ void Heap::IterateAndScavengePromotedObject(HeapObject* target, int size,
// regular visiting and IteratePromotedObjectPointers.
if (!was_marked_black) {
if (incremental_marking()->black_allocation()) {
IncrementalMarking::MarkGrey(this, target->map());
incremental_marking()->MarkGrey(target->map());
incremental_marking()->IterateBlackObject(target);
}
}
......@@ -5494,7 +5494,6 @@ bool Heap::SetUp() {
store_buffer_ = new StoreBuffer(this);
incremental_marking_ = new IncrementalMarking(this);
concurrent_marking_ = new ConcurrentMarking(this);
for (int i = 0; i <= LAST_SPACE; i++) {
......@@ -5542,6 +5541,8 @@ bool Heap::SetUp() {
tracer_ = new GCTracer(this);
scavenge_collector_ = new Scavenger(this);
mark_compact_collector_ = new MarkCompactCollector(this);
incremental_marking_->set_marking_deque(
mark_compact_collector_->marking_deque());
if (FLAG_minor_mc)
minor_mark_compact_collector_ = new MinorMarkCompactCollector(this);
gc_idle_time_handler_ = new GCIdleTimeHandler();
......@@ -5653,7 +5654,7 @@ void Heap::RegisterExternallyReferencedObject(Object** object) {
HeapObject* heap_object = HeapObject::cast(*object);
DCHECK(Contains(heap_object));
if (FLAG_incremental_marking_wrappers && incremental_marking()->IsMarking()) {
IncrementalMarking::MarkGrey(this, heap_object);
incremental_marking()->MarkGrey(heap_object);
} else {
DCHECK(mark_compact_collector()->in_use());
mark_compact_collector()->MarkObject(heap_object);
......
This diff is collapsed.
......@@ -32,35 +32,41 @@ class V8_EXPORT_PRIVATE IncrementalMarking {
enum GCRequestType { NONE, COMPLETE_MARKING, FINALIZATION };
static void MarkGrey(Heap* heap, HeapObject* object);
static void Initialize();
explicit IncrementalMarking(Heap* heap);
MarkingState marking_state(HeapObject* object) const {
return MarkingState::Internal(object);
}
MarkingState marking_state(MemoryChunk* chunk) const {
return MarkingState::Internal(chunk);
}
static void MarkBlack(HeapObject* object, int size);
void MarkBlack(HeapObject* object, int size);
void MarkGrey(HeapObject* object);
// Transfers mark bits without requiring proper object headers.
static void TransferMark(Heap* heap, HeapObject* from, HeapObject* to);
void TransferMark(Heap* heap, HeapObject* from, HeapObject* to);
// Transfers color including live byte count, requiring properly set up
// objects.
template <MarkBit::AccessMode access_mode = MarkBit::NON_ATOMIC>
V8_INLINE static void TransferColor(HeapObject* from, HeapObject* to) {
if (ObjectMarking::IsBlack<access_mode>(to, MarkingState::Internal(to))) {
DCHECK(to->GetHeap()->incremental_marking()->black_allocation());
V8_INLINE void TransferColor(HeapObject* from, HeapObject* to) {
if (ObjectMarking::IsBlack<access_mode>(to, marking_state(to))) {
DCHECK(black_allocation());
return;
}
DCHECK(ObjectMarking::IsWhite<access_mode>(to, MarkingState::Internal(to)));
if (ObjectMarking::IsGrey<access_mode>(from,
MarkingState::Internal(from))) {
ObjectMarking::WhiteToGrey<access_mode>(to, MarkingState::Internal(to));
} else if (ObjectMarking::IsBlack<access_mode>(
from, MarkingState::Internal(from))) {
ObjectMarking::WhiteToBlack<access_mode>(to, MarkingState::Internal(to));
DCHECK(ObjectMarking::IsWhite<access_mode>(to, marking_state(to)));
if (ObjectMarking::IsGrey<access_mode>(from, marking_state(from))) {
ObjectMarking::WhiteToGrey<access_mode>(to, marking_state(to));
} else if (ObjectMarking::IsBlack<access_mode>(from, marking_state(from))) {
ObjectMarking::WhiteToBlack<access_mode>(to, marking_state(to));
}
}
explicit IncrementalMarking(Heap* heap);
static void Initialize();
State state() {
DCHECK(state_ == STOPPED || FLAG_incremental_marking);
......@@ -219,6 +225,15 @@ class V8_EXPORT_PRIVATE IncrementalMarking {
void AbortBlackAllocation();
MarkingDeque* marking_deque() {
SLOW_DCHECK(marking_deque_ != nullptr);
return marking_deque_;
}
void set_marking_deque(MarkingDeque* marking_deque) {
marking_deque_ = marking_deque;
}
private:
class Observer : public AllocationObserver {
public:
......@@ -276,6 +291,7 @@ class V8_EXPORT_PRIVATE IncrementalMarking {
size_t StepSizeToMakeProgress();
Heap* heap_;
MarkingDeque* marking_deque_;
double start_time_ms_;
size_t initial_old_generation_size_;
......
......@@ -148,7 +148,7 @@ class ScavengingVisitor : public StaticVisitorBase {
}
if (marks_handling == TRANSFER_MARKS) {
IncrementalMarking::TransferColor(source, target);
heap->incremental_marking()->TransferColor(source, target);
}
}
......
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