Commit 1c5df4fb authored by hpayer's avatar hpayer Committed by Commit bot

[heap] New Dijkstra marking write barrier.

A.x = B
Change from mark grey A to mark grey B.

BUG=

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

Cr-Commit-Position: refs/heads/master@{#32765}
parent dddcd0ac
...@@ -47,39 +47,22 @@ IncrementalMarking::IncrementalMarking(Heap* heap) ...@@ -47,39 +47,22 @@ IncrementalMarking::IncrementalMarking(Heap* heap)
request_type_(COMPLETE_MARKING) {} request_type_(COMPLETE_MARKING) {}
bool IncrementalMarking::BaseRecordWrite(HeapObject* obj, Object** slot, bool IncrementalMarking::BaseRecordWrite(HeapObject* obj, Object* value) {
Object* value) {
HeapObject* value_heap_obj = HeapObject::cast(value); HeapObject* value_heap_obj = HeapObject::cast(value);
MarkBit value_bit = Marking::MarkBitFrom(value_heap_obj); MarkBit value_bit = Marking::MarkBitFrom(value_heap_obj);
if (Marking::IsWhite(value_bit)) {
MarkBit obj_bit = Marking::MarkBitFrom(obj);
if (Marking::IsBlack(obj_bit)) {
MemoryChunk* chunk = MemoryChunk::FromAddress(obj->address());
if (chunk->IsFlagSet(MemoryChunk::HAS_PROGRESS_BAR)) {
if (chunk->IsLeftOfProgressBar(slot)) {
WhiteToGreyAndPush(value_heap_obj, value_bit);
RestartIfNotMarking();
} else {
return false;
}
} else {
BlackToGreyAndUnshift(obj, obj_bit);
RestartIfNotMarking();
return false;
}
} else {
return false;
}
}
if (!is_compacting_) return false;
MarkBit obj_bit = Marking::MarkBitFrom(obj); MarkBit obj_bit = Marking::MarkBitFrom(obj);
return Marking::IsBlack(obj_bit); bool is_black = Marking::IsBlack(obj_bit);
if (is_black && Marking::IsWhite(value_bit)) {
WhiteToGreyAndPush(value_heap_obj, value_bit);
RestartIfNotMarking();
}
return is_compacting_ && is_black;
} }
void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot, void IncrementalMarking::RecordWriteSlow(HeapObject* obj, Object** slot,
Object* value) { Object* value) {
if (BaseRecordWrite(obj, slot, value) && slot != NULL) { if (BaseRecordWrite(obj, value) && slot != NULL) {
// Object is not going to be rescanned we need to record the slot. // Object is not going to be rescanned we need to record the slot.
heap_->mark_compact_collector()->RecordSlot(obj, slot, value); heap_->mark_compact_collector()->RecordSlot(obj, slot, value);
} }
...@@ -128,7 +111,7 @@ void IncrementalMarking::RecordCodeTargetPatch(Address pc, HeapObject* value) { ...@@ -128,7 +111,7 @@ void IncrementalMarking::RecordCodeTargetPatch(Address pc, HeapObject* value) {
void IncrementalMarking::RecordWriteOfCodeEntrySlow(JSFunction* host, void IncrementalMarking::RecordWriteOfCodeEntrySlow(JSFunction* host,
Object** slot, Object** slot,
Code* value) { Code* value) {
if (BaseRecordWrite(host, slot, value)) { if (BaseRecordWrite(host, value)) {
DCHECK(slot != NULL); DCHECK(slot != NULL);
heap_->mark_compact_collector()->RecordCodeEntrySlot( heap_->mark_compact_collector()->RecordCodeEntrySlot(
host, reinterpret_cast<Address>(slot), value); host, reinterpret_cast<Address>(slot), value);
...@@ -139,24 +122,10 @@ void IncrementalMarking::RecordWriteOfCodeEntrySlow(JSFunction* host, ...@@ -139,24 +122,10 @@ void IncrementalMarking::RecordWriteOfCodeEntrySlow(JSFunction* host,
void IncrementalMarking::RecordWriteIntoCodeSlow(HeapObject* obj, void IncrementalMarking::RecordWriteIntoCodeSlow(HeapObject* obj,
RelocInfo* rinfo, RelocInfo* rinfo,
Object* value) { Object* value) {
MarkBit value_bit = Marking::MarkBitFrom(HeapObject::cast(value)); if (BaseRecordWrite(obj, value)) {
if (Marking::IsWhite(value_bit)) {
MarkBit obj_bit = Marking::MarkBitFrom(obj);
if (Marking::IsBlack(obj_bit)) {
BlackToGreyAndUnshift(obj, obj_bit);
RestartIfNotMarking();
}
// Object is either grey or white. It will be scanned if survives.
return;
}
if (is_compacting_) {
MarkBit obj_bit = Marking::MarkBitFrom(obj);
if (Marking::IsBlack(obj_bit)) {
// Object is not going to be rescanned. We need to record the slot. // Object is not going to be rescanned. We need to record the slot.
heap_->mark_compact_collector()->RecordRelocSlot(rinfo, heap_->mark_compact_collector()->RecordRelocSlot(rinfo,
Code::cast(value)); Code::cast(value));
}
} }
} }
......
...@@ -159,7 +159,7 @@ class IncrementalMarking { ...@@ -159,7 +159,7 @@ class IncrementalMarking {
// No slots in white objects should be recorded, as some slots are typed and // No slots in white objects should be recorded, as some slots are typed and
// cannot be interpreted correctly if the underlying object does not survive // cannot be interpreted correctly if the underlying object does not survive
// the incremental cycle (stays white). // the incremental cycle (stays white).
INLINE(bool BaseRecordWrite(HeapObject* obj, Object** slot, Object* value)); INLINE(bool BaseRecordWrite(HeapObject* obj, Object* value));
INLINE(void RecordWrite(HeapObject* obj, Object** slot, Object* value)); INLINE(void RecordWrite(HeapObject* obj, Object** slot, Object* value));
INLINE(void RecordWriteIntoCode(HeapObject* obj, RelocInfo* rinfo, INLINE(void RecordWriteIntoCode(HeapObject* obj, RelocInfo* rinfo,
Object* value)); Object* value));
......
...@@ -631,13 +631,6 @@ class MemoryChunk { ...@@ -631,13 +631,6 @@ class MemoryChunk {
} }
} }
bool IsLeftOfProgressBar(Object** slot) {
Address slot_address = reinterpret_cast<Address>(slot);
DCHECK(slot_address > this->address());
return (slot_address - (this->address() + kObjectStartOffset)) <
progress_bar();
}
size_t size() const { return size_; } size_t size() const { return size_; }
void set_size(size_t size) { size_ = size; } void set_size(size_t size) { size_ = size; }
......
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