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

Unified Diff: vm/object.h

Issue 10012042: Wire GrowableArray to use the internal VM object. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 8 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: vm/object.h
===================================================================
--- vm/object.h (revision 6293)
+++ vm/object.h (working copy)
@@ -3493,7 +3493,17 @@
ASSERT(!IsNull());
return Smi::Value(raw_ptr()->length_);
}
+ void SetLength(intptr_t value) const {
+ // This is only safe because we create a new Smi, which does not cause
+ // heap allocation.
+ raw_ptr()->length_ = Smi::New(value);
+ }
+ RawArray* data() const { return raw_ptr()->data_; }
+ void SetData(const Array& value) const {
+ StorePointer(&raw_ptr()->data_, value.raw());
+ }
+
RawObject* At(intptr_t index) const {
NoGCScope no_gc;
ASSERT(!IsNull());
@@ -3508,6 +3518,7 @@
}
void Add(const Object& value, Heap::Space space = Heap::kNew) const;
+ void Grow(intptr_t new_capacity, Heap::Space space = Heap::kNew) const;
RawObject* RemoveLast() const;
virtual RawAbstractTypeArguments* GetTypeArguments() const {
@@ -3517,10 +3528,15 @@
virtual void SetTypeArguments(const AbstractTypeArguments& value) const {
const Array& contents = Array::Handle(data());
contents.SetTypeArguments(value);
+ raw_ptr()->type_arguments_ = value.Canonicalize();
}
virtual bool Equals(const Instance& other) const;
+ static intptr_t type_arguments_offset() {
+ return OFFSET_OF(RawGrowableObjectArray, type_arguments_);
+ }
+
static intptr_t length_offset() {
return OFFSET_OF(RawGrowableObjectArray, length_);
}
@@ -3537,17 +3553,10 @@
}
static RawGrowableObjectArray* New(intptr_t capacity,
Heap::Space space = Heap::kNew);
+ static RawGrowableObjectArray* New(const Array& array,
+ Heap::Space space = Heap::kNew);
private:
- RawArray* data() const { return raw_ptr()->data_; }
- void SetLength(intptr_t value) const {
- // This is only safe because we create a new Smi, which does not cause
- // heap allocation.
- raw_ptr()->length_ = Smi::New(value);
- }
- void SetData(const Array& value) const {
- StorePointer(&raw_ptr()->data_, value.raw());
- }
RawArray* DataArray() const { return data()->ptr(); }
RawObject** ObjectAddr(intptr_t index) const {
ASSERT((index >= 0) && (index < Length()));

Powered by Google App Engine
This is Rietveld 408576698