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

Unified Diff: vm/raw_object_snapshot.cc

Issue 9594028: Add a first class GrowableObjectArray type in the VM and use it internally in the VM at all spots w… (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/runtime/
Patch Set: Created 8 years, 10 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
« vm/raw_object.h ('K') | « vm/raw_object.cc ('k') | vm/snapshot.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: vm/raw_object_snapshot.cc
===================================================================
--- vm/raw_object_snapshot.cc (revision 4983)
+++ vm/raw_object_snapshot.cc (working copy)
@@ -1710,6 +1710,48 @@
}
+RawGrowableObjectArray* GrowableObjectArray::ReadFrom(SnapshotReader* reader,
+ intptr_t object_id,
+ intptr_t tags,
+ Snapshot::Kind kind) {
+ ASSERT(reader != NULL);
+
+ // Read the length so that we can determine instance size to allocate.
cshapiro 2012/03/06 00:56:31 Maybe use the common array reader. See my comment
siva 2012/03/06 23:32:33 See my comment below. On 2012/03/06 00:56:31, csh
+ intptr_t capacity = reader->ReadIntptrValue();
+ intptr_t length = reader->ReadIntptrValue();
+ GrowableObjectArray& array = GrowableObjectArray::ZoneHandle(
+ reader->isolate(), reader->NewGrowableObjectArray());
+ reader->AddBackwardReference(object_id, &array);
+ array.set_capacity(capacity);
+ array.set_length(length);
+ Array& contents = Array::Handle();
+ contents ^= reader->ReadObject();
+ array.set_data(contents);
+ return array.raw();
+}
+
+
+void RawGrowableObjectArray::WriteTo(SnapshotWriter* writer,
+ intptr_t object_id,
+ Snapshot::Kind kind) {
+ ASSERT(writer != NULL);
+
+ // Write out the serialization header value for this object.
+ writer->WriteSerializationMarker(kInlined, object_id);
+
+ // Write out the class and tags information.
+ writer->WriteObjectHeader(ObjectStore::kGrowableObjectArrayClass,
+ ptr()->tags_);
+
+ // Write out the capacity and length fields.
+ writer->WriteIntptrValue(ptr()->capacity_);
cshapiro 2012/03/06 00:56:31 Hmm... if you get rid of the capacity member you c
siva 2012/03/06 23:32:33 I got rid of the capacity_ field. I prefer to wri
+ writer->WriteIntptrValue(ptr()->length_);
+
+ // Write out the Array object.
+ writer->WriteObject(ptr()->data_);
+}
+
+
RawByteArray* ByteArray::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
intptr_t tags,
« vm/raw_object.h ('K') | « vm/raw_object.cc ('k') | vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698