Chromium Code Reviews| Index: runtime/vm/raw_object.h |
| =================================================================== |
| --- runtime/vm/raw_object.h (revision 41331) |
| +++ runtime/vm/raw_object.h (working copy) |
| @@ -403,6 +403,12 @@ |
| return result; |
| } |
| + bool Contains(uword addr) const { |
| + intptr_t this_size = Size(); |
| + uword this_addr = RawObject::ToAddr(this); |
| + return (addr >= this_addr) && (addr < (this_addr + this_size)); |
| + } |
| + |
| void Validate(Isolate* isolate) const; |
| intptr_t VisitPointers(ObjectPointerVisitor* visitor); |
| bool FindObject(FindObjectVisitor* visitor); |
| @@ -459,7 +465,7 @@ |
| class ReservedBits : public |
| BitField<intptr_t, kReservedTagPos, kReservedTagSize> {}; // NOLINT |
| - // TODO(koda): Return const*, like Object::raw_ptr(). |
| + // TODO(koda): After handling tags_, return const*, like Object::raw_ptr(). |
| RawObject* ptr() const { |
| ASSERT(IsHeapObject()); |
| return reinterpret_cast<RawObject*>( |
| @@ -473,6 +479,36 @@ |
| return ClassIdTag::decode(tags); |
| } |
| + // Start of field mutator guards. |
|
Ivan Posva
2014/10/29 06:17:34
Please remove superfluous comment.
koda
2014/10/29 19:30:16
Done.
|
| + // |
| + // All writes to heap objects should ultimately pass through one of the |
| + // methods below or their counterparts in Object, to ensure that the |
| + // write barrier is correctly applied. |
| + |
| + template<typename type> |
| + void StorePointer(type const* addr, type value) { |
| + // Ensure that this object contains the addr. |
| + ASSERT(Contains(reinterpret_cast<uword>(addr))); |
| + *const_cast<type*>(addr) = value; |
| + // Filter stores based on source and target. |
| + if (!value->IsHeapObject()) return; |
| + if (value->IsNewObject() && this->IsOldObject() && |
| + !this->IsRemembered()) { |
| + this->SetRememberedBit(); |
| + Isolate::Current()->store_buffer()->AddObject(this); |
| + } |
| + } |
| + |
| + // Use for storing into an explicitly Smi-typed field of an object |
| + // (i.e., both the previous and new value are Smis). |
| + void StoreSmi(RawSmi* const* addr, RawSmi* value) { |
| + // Can't use Contains, as array length is initialized through this method. |
| + ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(this)); |
| + *const_cast<RawSmi**>(addr) = value; |
| + } |
| + |
| + // End of field mutator guards. |
|
Ivan Posva
2014/10/29 06:17:34
ditto
koda
2014/10/29 19:30:16
Done.
|
| + |
| friend class Api; |
| friend class Array; |
| friend class ByteBuffer; |
| @@ -481,6 +517,7 @@ |
| friend class GCMarker; |
| friend class ExternalTypedData; |
| friend class ForwardList; |
| + friend class GrowableObjectArray; // StorePointer |
| friend class Heap; |
| friend class HeapMapAsJSONVisitor; |
| friend class ClassStatsVisitor; |
| @@ -498,6 +535,7 @@ |
| friend class String; |
| friend class TypedData; |
| friend class TypedDataView; |
| + friend class WeakProperty; // StorePointer |
| DISALLOW_ALLOCATION(); |
| DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject); |