[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}
This commit is contained in:
hpayer 2015-12-10 09:28:54 -08:00 committed by Commit bot
parent dddcd0ac17
commit 1c5df4fb62
3 changed files with 11 additions and 49 deletions

View File

@ -47,39 +47,22 @@ IncrementalMarking::IncrementalMarking(Heap* heap)
request_type_(COMPLETE_MARKING) {}
bool IncrementalMarking::BaseRecordWrite(HeapObject* obj, Object** slot,
Object* value) {
bool IncrementalMarking::BaseRecordWrite(HeapObject* obj, Object* value) {
HeapObject* value_heap_obj = HeapObject::cast(value);
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);
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,
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.
heap_->mark_compact_collector()->RecordSlot(obj, slot, value);
}
@ -128,7 +111,7 @@ void IncrementalMarking::RecordCodeTargetPatch(Address pc, HeapObject* value) {
void IncrementalMarking::RecordWriteOfCodeEntrySlow(JSFunction* host,
Object** slot,
Code* value) {
if (BaseRecordWrite(host, slot, value)) {
if (BaseRecordWrite(host, value)) {
DCHECK(slot != NULL);
heap_->mark_compact_collector()->RecordCodeEntrySlot(
host, reinterpret_cast<Address>(slot), value);
@ -139,24 +122,10 @@ void IncrementalMarking::RecordWriteOfCodeEntrySlow(JSFunction* host,
void IncrementalMarking::RecordWriteIntoCodeSlow(HeapObject* obj,
RelocInfo* rinfo,
Object* value) {
MarkBit value_bit = Marking::MarkBitFrom(HeapObject::cast(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)) {
if (BaseRecordWrite(obj, value)) {
// Object is not going to be rescanned. We need to record the slot.
heap_->mark_compact_collector()->RecordRelocSlot(rinfo,
Code::cast(value));
}
}
}

View File

@ -159,7 +159,7 @@ class IncrementalMarking {
// 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
// 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 RecordWriteIntoCode(HeapObject* obj, RelocInfo* rinfo,
Object* value));

View File

@ -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_; }
void set_size(size_t size) { size_ = size; }