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

Unified Diff: runtime/vm/raw_object.h

Issue 685583002: Add more missing StorePointer/StoreSmi calls. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 2 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 | « runtime/vm/object.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698