Commit 26241740 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[heap] Unify MarkingDeque push and unshift operations.

R=hpayer@chromium.org

Review URL: https://codereview.chromium.org/1294093003

Cr-Commit-Position: refs/heads/master@{#30202}
parent 76dc58c9
...@@ -105,13 +105,13 @@ void IncrementalMarking::BlackToGreyAndUnshift(HeapObject* obj, ...@@ -105,13 +105,13 @@ void IncrementalMarking::BlackToGreyAndUnshift(HeapObject* obj,
} }
} }
heap_->mark_compact_collector()->marking_deque()->UnshiftGrey(obj); heap_->mark_compact_collector()->marking_deque()->Unshift(obj);
} }
void IncrementalMarking::WhiteToGreyAndPush(HeapObject* obj, MarkBit mark_bit) { void IncrementalMarking::WhiteToGreyAndPush(HeapObject* obj, MarkBit mark_bit) {
Marking::WhiteToGrey(mark_bit); Marking::WhiteToGrey(mark_bit);
heap_->mark_compact_collector()->marking_deque()->PushGrey(obj); heap_->mark_compact_collector()->marking_deque()->Push(obj);
} }
} }
} // namespace v8::internal } // namespace v8::internal
......
...@@ -197,7 +197,7 @@ class IncrementalMarkingMarkingVisitor ...@@ -197,7 +197,7 @@ class IncrementalMarkingMarkingVisitor
chunk->set_progress_bar(start_offset); chunk->set_progress_bar(start_offset);
if (start_offset < object_size) { if (start_offset < object_size) {
if (Marking::IsGrey(Marking::MarkBitFrom(object))) { if (Marking::IsGrey(Marking::MarkBitFrom(object))) {
heap->mark_compact_collector()->marking_deque()->UnshiftGrey(object); heap->mark_compact_collector()->marking_deque()->Unshift(object);
} else { } else {
DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object))); DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object)));
heap->mark_compact_collector()->UnshiftBlack(object); heap->mark_compact_collector()->UnshiftBlack(object);
......
...@@ -23,7 +23,8 @@ void MarkCompactCollector::SetFlags(int flags) { ...@@ -23,7 +23,8 @@ void MarkCompactCollector::SetFlags(int flags) {
void MarkCompactCollector::PushBlack(HeapObject* obj) { void MarkCompactCollector::PushBlack(HeapObject* obj) {
if (marking_deque_.PushBlack(obj)) { DCHECK(Marking::IsBlack(Marking::MarkBitFrom(obj)));
if (marking_deque_.Push(obj)) {
MemoryChunk::IncrementLiveBytesFromGC(obj, obj->Size()); MemoryChunk::IncrementLiveBytesFromGC(obj, obj->Size());
} else { } else {
Marking::BlackToGrey(obj); Marking::BlackToGrey(obj);
...@@ -32,7 +33,8 @@ void MarkCompactCollector::PushBlack(HeapObject* obj) { ...@@ -32,7 +33,8 @@ void MarkCompactCollector::PushBlack(HeapObject* obj) {
void MarkCompactCollector::UnshiftBlack(HeapObject* obj) { void MarkCompactCollector::UnshiftBlack(HeapObject* obj) {
if (!marking_deque_.UnshiftBlack(obj)) { DCHECK(Marking::IsBlack(Marking::MarkBitFrom(obj)));
if (!marking_deque_.Unshift(obj)) {
MemoryChunk::IncrementLiveBytesFromGC(obj, -obj->Size()); MemoryChunk::IncrementLiveBytesFromGC(obj, -obj->Size());
Marking::BlackToGrey(obj); Marking::BlackToGrey(obj);
} }
......
...@@ -205,9 +205,9 @@ class MarkingDeque { ...@@ -205,9 +205,9 @@ class MarkingDeque {
void SetOverflowed() { overflowed_ = true; } void SetOverflowed() { overflowed_ = true; }
// Push the (marked) object on the marking stack if there is room, otherwise // Push the object on the marking stack if there is room, otherwise mark the
// mark the deque as overflowed and wait for a rescan of the heap. // deque as overflowed and wait for a rescan of the heap.
INLINE(bool PushBlack(HeapObject* object)) { INLINE(bool Push(HeapObject* object)) {
DCHECK(object->IsHeapObject()); DCHECK(object->IsHeapObject());
if (IsFull()) { if (IsFull()) {
SetOverflowed(); SetOverflowed();
...@@ -219,16 +219,6 @@ class MarkingDeque { ...@@ -219,16 +219,6 @@ class MarkingDeque {
} }
} }
INLINE(void PushGrey(HeapObject* object)) {
DCHECK(object->IsHeapObject());
if (IsFull()) {
SetOverflowed();
} else {
array_[top_] = object;
top_ = ((top_ + 1) & mask_);
}
}
INLINE(HeapObject* Pop()) { INLINE(HeapObject* Pop()) {
DCHECK(!IsEmpty()); DCHECK(!IsEmpty());
top_ = ((top_ - 1) & mask_); top_ = ((top_ - 1) & mask_);
...@@ -237,19 +227,10 @@ class MarkingDeque { ...@@ -237,19 +227,10 @@ class MarkingDeque {
return object; return object;
} }
INLINE(void UnshiftGrey(HeapObject* object)) { // Unshift the object into the marking stack if there is room, otherwise mark
DCHECK(object->IsHeapObject()); // the deque as overflowed and wait for a rescan of the heap.
if (IsFull()) { INLINE(bool Unshift(HeapObject* object)) {
SetOverflowed();
} else {
bottom_ = ((bottom_ - 1) & mask_);
array_[bottom_] = object;
}
}
INLINE(bool UnshiftBlack(HeapObject* object)) {
DCHECK(object->IsHeapObject()); DCHECK(object->IsHeapObject());
DCHECK(Marking::IsBlack(Marking::MarkBitFrom(object)));
if (IsFull()) { if (IsFull()) {
SetOverflowed(); SetOverflowed();
return false; return false;
......
...@@ -59,7 +59,7 @@ TEST(MarkingDeque) { ...@@ -59,7 +59,7 @@ TEST(MarkingDeque) {
Address original_address = reinterpret_cast<Address>(&s); Address original_address = reinterpret_cast<Address>(&s);
Address current_address = original_address; Address current_address = original_address;
while (!s.IsFull()) { while (!s.IsFull()) {
s.PushBlack(HeapObject::FromAddress(current_address)); s.Push(HeapObject::FromAddress(current_address));
current_address += kPointerSize; current_address += kPointerSize;
} }
......
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