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

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, 9 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 | « 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 5060)
+++ vm/raw_object_snapshot.cc (working copy)
@@ -1710,6 +1710,45 @@
}
+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.
+ GrowableObjectArray& array = GrowableObjectArray::ZoneHandle(
+ reader->isolate(), reader->NewGrowableObjectArray());
+ reader->AddBackwardReference(object_id, &array);
+ intptr_t length = reader->ReadSmiValue();
+ array.SetLength(length);
+ Array& contents = Array::Handle();
+ contents ^= reader->ReadObject();
+ array.SetData(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 used length field.
+ writer->Write<RawObject*>(ptr()->length_);
+
+ // Write out the Array object.
+ writer->WriteObject(ptr()->data_);
+}
+
+
RawByteArray* ByteArray::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
intptr_t tags,
« no previous file with comments | « vm/raw_object.cc ('k') | vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698