| 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,32 @@
|
| return ClassIdTag::decode(tags);
|
| }
|
|
|
| + // 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;
|
| + }
|
| +
|
| friend class Api;
|
| friend class Array;
|
| friend class ByteBuffer;
|
| @@ -481,11 +513,13 @@
|
| friend class GCMarker;
|
| friend class ExternalTypedData;
|
| friend class ForwardList;
|
| + friend class GrowableObjectArray; // StorePointer
|
| friend class Heap;
|
| friend class HeapMapAsJSONVisitor;
|
| friend class ClassStatsVisitor;
|
| friend class MarkingVisitor;
|
| friend class Object;
|
| + friend class OneByteString; // StoreSmi
|
| friend class RawExternalTypedData;
|
| friend class RawInstructions;
|
| friend class RawInstance;
|
| @@ -498,6 +532,7 @@
|
| friend class String;
|
| friend class TypedData;
|
| friend class TypedDataView;
|
| + friend class WeakProperty; // StorePointer
|
|
|
| DISALLOW_ALLOCATION();
|
| DISALLOW_IMPLICIT_CONSTRUCTORS(RawObject);
|
|
|