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

Unified Diff: runtime/vm/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
Index: runtime/vm/object.h
===================================================================
--- runtime/vm/object.h (revision 41331)
+++ runtime/vm/object.h (working copy)
@@ -589,29 +589,17 @@
return Utils::RoundUp(size, kObjectAlignment);
}
- bool Contains(uword addr) const {
- intptr_t this_size = raw()->Size();
- uword this_addr = RawObject::ToAddr(raw());
- return (addr >= this_addr) && (addr < (this_addr + this_size));
- }
+ bool Contains(uword addr) const { return raw()->Contains(addr); }
// Start of field mutator guards.
//
// All writes to heap objects should ultimately pass through one of the
- // methods below, to ensure that the write barrier is correctly applied.
+ // methods below or their counterparts in RawObject, to ensure that the
+ // write barrier is correctly applied.
template<typename type>
void StorePointer(type const* addr, type value) const {
- // 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() && raw()->IsOldObject() &&
- !raw()->IsRemembered()) {
- raw()->SetRememberedBit();
- Isolate::Current()->store_buffer()->AddObject(raw());
- }
+ raw()->StorePointer(addr, value);
}
// Store a range of pointers [from, from + count) into [to, to + count).
@@ -632,9 +620,7 @@
// 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) const {
- // Can't use Contains, as array length is initialized through this method.
- ASSERT(reinterpret_cast<uword>(addr) >= RawObject::ToAddr(raw()));
- *const_cast<RawSmi**>(addr) = value;
+ raw()->StoreSmi(addr, value);
}
template<typename FieldType>
@@ -6485,22 +6471,8 @@
ASSERT((index >= 0) && (index < Length()));
return &(DataArray()->data()[index]);
}
- bool DataContains(uword addr) const {
- intptr_t data_size = data()->Size();
- uword data_addr = RawObject::ToAddr(data());
- return (addr >= data_addr) && (addr < (data_addr + data_size));
- }
void DataStorePointer(RawObject** addr, RawObject* value) const {
- // Ensure that the backing array object contains the addr.
- ASSERT(DataContains(reinterpret_cast<uword>(addr)));
- *addr = value;
- // Filter stores based on source and target.
- if (!value->IsHeapObject()) return;
- if (value->IsNewObject() && data()->IsOldObject() &&
- !data()->IsRemembered()) {
- data()->SetRememberedBit();
- Isolate::Current()->store_buffer()->AddObject(data());
- }
+ data()->StorePointer(addr, value);
}
static const int kDefaultInitialCapacity = 4;
@@ -7325,8 +7297,8 @@
}
static void Clear(RawWeakProperty* raw_weak) {
- raw_weak->ptr()->key_ = Object::null();
- raw_weak->ptr()->value_ = Object::null();
+ raw_weak->StorePointer(&(raw_weak->ptr()->key_), Object::null());
+ raw_weak->StorePointer(&(raw_weak->ptr()->value_), Object::null());
}
private:
« no previous file with comments | « runtime/vm/gc_marker.cc ('k') | runtime/vm/object.cc » ('j') | runtime/vm/raw_object.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698