Index: src/heap/objects-visiting-inl.h |
diff --git a/src/heap/objects-visiting-inl.h b/src/heap/objects-visiting-inl.h |
index 29a5afc320a370d4e9ee2802865353eb8054fe80..24eab712fe70a3403a4e74ff30249fd1532798c4 100644 |
--- a/src/heap/objects-visiting-inl.h |
+++ b/src/heap/objects-visiting-inl.h |
@@ -354,9 +354,16 @@ void StaticMarkingVisitor<StaticVisitor>::VisitWeakCell(Map* map, |
// We can ignore weak cells with cleared values because they will always |
// contain smi zero. |
if (weak_cell->next_cleared() && !weak_cell->cleared()) { |
- weak_cell->set_next(heap->encountered_weak_cells(), |
- UPDATE_WEAK_WRITE_BARRIER); |
- heap->set_encountered_weak_cells(weak_cell); |
+ HeapObject* value = HeapObject::cast(weak_cell->value()); |
+ if (MarkCompactCollector::IsMarked(value)) { |
ulan
2015/09/22 11:30:46
Please add a comment explaining that this is done
Hannes Payer (out of office)
2015/09/22 13:22:57
Done.
|
+ Object** slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset); |
+ map->GetHeap()->mark_compact_collector()->RecordSlot(weak_cell, slot, |
+ *slot); |
+ } else { |
+ weak_cell->set_next(heap->encountered_weak_cells(), |
+ UPDATE_WEAK_WRITE_BARRIER); |
+ heap->set_encountered_weak_cells(weak_cell); |
+ } |
} |
} |