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

Unified Diff: runtime/vm/raw_object_snapshot.cc

Issue 380333002: Add VM class for Map/LinkedHashMap. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 5 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 | « runtime/vm/raw_object.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: runtime/vm/raw_object_snapshot.cc
===================================================================
--- runtime/vm/raw_object_snapshot.cc (revision 38576)
+++ runtime/vm/raw_object_snapshot.cc (working copy)
@@ -2163,11 +2163,11 @@
reader->AddBackRef(object_id, &array, kIsDeserialized);
intptr_t length = reader->ReadSmiValue();
array.SetLength(length);
- Array& contents = Array::Handle();
+ Array& contents = Array::Handle(reader->isolate());
contents ^= reader->ReadObjectImpl();
array.SetData(contents);
const TypeArguments& type_arguments =
- TypeArguments::Handle(contents.GetTypeArguments());
+ TypeArguments::Handle(reader->isolate(), contents.GetTypeArguments());
array.SetTypeArguments(type_arguments);
return array.raw();
}
@@ -2193,6 +2193,56 @@
}
+RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader,
+ intptr_t object_id,
+ intptr_t tags,
+ Snapshot::Kind kind) {
+ ASSERT(reader != NULL);
+
+ LinkedHashMap& map = LinkedHashMap::ZoneHandle(
+ reader->isolate(), LinkedHashMap::null());
+ if (kind == Snapshot::kFull || kind == Snapshot::kScript) {
+ // The immutable maps that seed map literals are not yet VM-internal, so
+ // we don't reach this.
+ UNREACHABLE();
+ } else {
+ map = LinkedHashMap::New(HEAP_SPACE(kind));
+ }
+ reader->AddBackRef(object_id, &map, kIsDeserialized);
+ Array& contents = Array::Handle(reader->isolate());
+ contents ^= reader->ReadObjectImpl();
+ map.SetData(contents);
+ const TypeArguments& type_arguments =
+ TypeArguments::Handle(reader->isolate(), contents.GetTypeArguments());
+ map.SetTypeArguments(type_arguments);
+ return map.raw();
+}
+
+
+void RawLinkedHashMap::WriteTo(SnapshotWriter* writer,
+ intptr_t object_id,
+ Snapshot::Kind kind) {
+ if (kind == Snapshot::kFull || kind == Snapshot::kScript) {
+ // The immutable maps that seed map literals are not yet VM-internal, so
+ // we don't reach this.
+ UNREACHABLE();
+ }
+ ASSERT(writer != NULL);
+
+ // Write out the serialization header value for this object.
+ writer->WriteInlinedObjectHeader(object_id);
+
+ // Write out the class and tags information.
+ writer->WriteIndexedObject(kLinkedHashMapCid);
+ writer->WriteTags(writer->GetObjectTags(this));
+
+ // Write out the backing array.
+ // TODO(koda): Serialize as pairs (like ToArray) instead, to reduce space and
+ // support per-isolate salted hash codes.
+ writer->WriteObjectImpl(ptr()->data_);
+}
+
+
RawFloat32x4* Float32x4::ReadFrom(SnapshotReader* reader,
intptr_t object_id,
intptr_t tags,
« no previous file with comments | « runtime/vm/raw_object.cc ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698