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

Unified Diff: vm/object.h

Issue 11443024: Restructure Add and SetAt to not create a Handle. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years 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 | « lib/string.cc ('k') | vm/object.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/object.h
===================================================================
--- vm/object.h (revision 15744)
+++ vm/object.h (working copy)
@@ -4429,14 +4429,12 @@
void SetAt(intptr_t index, const Object& value) const {
ASSERT(!IsNull());
ASSERT(index < Length());
- const Array& arr = Array::Handle(data());
- arr.SetAt(index, value);
+
+ // TODO(iposva): Add storing NoGCScope.
+ DataStorePointer(ObjectAddr(index), value.raw());
}
void Add(const Object& value, Heap::Space space = Heap::kNew) const;
- void Add(Isolate* isolate,
- const Object& value,
- Heap::Space space = Heap::kNew) const;
void Grow(intptr_t new_capacity, Heap::Space space = Heap::kNew) const;
RawObject* RemoveLast() const;
@@ -4485,6 +4483,22 @@
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()) {
+ uword ptr = reinterpret_cast<uword>(addr);
+ Isolate::Current()->store_buffer()->AddPointer(ptr);
+ }
+ }
static const int kDefaultInitialCapacity = 4;
« no previous file with comments | « lib/string.cc ('k') | vm/object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698