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

Unified Diff: src/objects-inl.h

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/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/objects-inl.h
diff --git a/src/objects-inl.h b/src/objects-inl.h
index 9e9bd591b112a3cee24c911cc8ec50bca0f21ec1..05155441d2db023f69ba787a9ef336197fbb87cc 100644
--- a/src/objects-inl.h
+++ b/src/objects-inl.h
@@ -1949,22 +1949,42 @@ void PropertyCell::set_type_raw(Object* val, WriteBarrierMode ignored) {
}
-Object* WeakCell::value() const { return READ_FIELD(this, kValueOffset); }
+Object* WeakCell::value(Heap* heap) {
+ Object* pointer = READ_FIELD(this, kValueOffsetDontForgetTheReadBarrier);
+ NOBARRIER_WRITE_FIELD(this, kMapOffset, GetHeap()->used_weak_cell_map());
+ return pointer;
+}
+
+
+Object* WeakCell::ValueNoReadBarrier() {
+ return READ_FIELD(this, kValueOffsetDontForgetTheReadBarrier);
+}
+
+
+void WeakCell::TriggerReadBarrier(Object* possible_weak_cell) {
+ if (possible_weak_cell->IsWeakCell()) {
+ WeakCell* weak_cell = reinterpret_cast<WeakCell*>(possible_weak_cell);
+ weak_cell->value(weak_cell->GetHeap());
+ }
+}
void WeakCell::clear() {
DCHECK(GetHeap()->gc_state() == Heap::MARK_COMPACT);
- WRITE_FIELD(this, kValueOffset, Smi::FromInt(0));
+ WRITE_FIELD(this, kValueOffsetDontForgetTheReadBarrier, Smi::FromInt(0));
}
void WeakCell::initialize(HeapObject* val) {
- WRITE_FIELD(this, kValueOffset, val);
- WRITE_BARRIER(GetHeap(), this, kValueOffset, val);
+ WRITE_FIELD(this, kValueOffsetDontForgetTheReadBarrier, val);
+ WRITE_BARRIER(GetHeap(), this, kValueOffsetDontForgetTheReadBarrier, val);
}
-bool WeakCell::cleared() const { return value() == Smi::FromInt(0); }
+bool WeakCell::cleared() const {
+ Object* pointer = READ_FIELD(this, kValueOffsetDontForgetTheReadBarrier);
+ return pointer == Smi::FromInt(0);
+}
Object* WeakCell::next() const { return READ_FIELD(this, kNextOffset); }
@@ -2368,16 +2388,26 @@ void FixedDoubleArray::FillWithHoles(int from, int to) {
}
-Object* WeakFixedArray::Get(int index) const {
+Object* WeakFixedArray::Get(Heap* heap, int index) const {
Object* raw = FixedArray::cast(this)->get(index + kFirstIndex);
if (raw->IsSmi()) return raw;
- return WeakCell::cast(raw)->value();
+ return WeakCell::cast(raw)->value(heap);
+}
+
+
+bool WeakFixedArray::EqualAt(int index, Object* object) const {
+ DCHECK(index < Length());
+ Object* raw = FixedArray::cast(this)->get(index + kFirstIndex);
+ if (raw->IsSmi()) return raw == object;
+ return WeakCell::cast(raw)->ValueNoReadBarrier() == object;
}
bool WeakFixedArray::IsEmptySlot(int index) const {
DCHECK(index < Length());
- return Get(index)->IsSmi();
+ Object* raw = FixedArray::cast(this)->get(index + kFirstIndex);
+ if (raw->IsSmi()) return true;
+ return WeakCell::cast(raw)->cleared();
}
@@ -7605,7 +7635,6 @@ String::SubStringRange::iterator String::SubStringRange::end() {
#undef FIELD_ADDR
#undef FIELD_ADDR_CONST
#undef READ_FIELD
-#undef NOBARRIER_READ_FIELD
#undef WRITE_FIELD
#undef NOBARRIER_WRITE_FIELD
#undef WRITE_BARRIER
« no previous file with comments | « src/objects-debug.cc ('k') | src/objects-printer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698