Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1018)

Unified Diff: src/heap/mark-compact.cc

Issue 893073006: Add map-based read barrier to WeakCell Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix merge Created 5 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/heap/heap.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/heap/mark-compact.cc
diff --git a/src/heap/mark-compact.cc b/src/heap/mark-compact.cc
index 1992c23925a061d7d334d12dc69b43dbc25b162e..9a462dcc98bbb96d5b67ffef2ed969d2aae87abe 100644
--- a/src/heap/mark-compact.cc
+++ b/src/heap/mark-compact.cc
@@ -2679,14 +2679,21 @@ void MarkCompactCollector::ProcessAndClearWeakCells() {
Object* weak_cell_obj = heap()->encountered_weak_cells();
while (weak_cell_obj != Smi::FromInt(0)) {
WeakCell* weak_cell = reinterpret_cast<WeakCell*>(weak_cell_obj);
- // We do not insert cleared weak cells into the list, so the value
- // cannot be a Smi here.
- HeapObject* value = HeapObject::cast(weak_cell->value());
- if (!MarkCompactCollector::IsMarked(value)) {
- weak_cell->clear();
- } else {
- Object** slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset);
- heap()->mark_compact_collector()->RecordSlot(slot, slot, value);
+ // Raw read avoids read barrier.
+ Object* value = weak_cell->ValueNoReadBarrier();
+ if (value != Smi::FromInt(0)) {
+ HeapObject* heap_value = HeapObject::cast(value);
+ // TODO(erikcorry): Also check whether the cell has been used.
+ if (!MarkCompactCollector::IsMarked(heap_value)) {
+ weak_cell->clear();
+ } else {
+ Object** slot = HeapObject::RawField(
+ weak_cell, WeakCell::kValueOffsetDontForgetTheReadBarrier);
+ heap()->mark_compact_collector()->RecordSlot(slot, slot, value);
+ }
+ // Tag for the next round of GC.
+ *HeapObject::RawField(weak_cell, HeapObject::kMapOffset) =
+ heap()->unused_weak_cell_map();
}
weak_cell_obj = weak_cell->next();
weak_cell->set_next(undefined, SKIP_WRITE_BARRIER);
« no previous file with comments | « src/heap/heap.cc ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698