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

Unified Diff: runtime/vm/raw_object_snapshot.cc

Issue 1151523002: VM-internalize the default Map implementation. (Closed) Base URL: https://github.com/dart-lang/sdk.git@master
Patch Set: Fix fingerprints. Created 5 years, 7 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.h ('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
diff --git a/runtime/vm/raw_object_snapshot.cc b/runtime/vm/raw_object_snapshot.cc
index 838145c485dbc1b8869a827f8aab7359da9f3881..d99d9433a1646c9cdff2249bd326b081c7a5b3fa 100644
--- a/runtime/vm/raw_object_snapshot.cc
+++ b/runtime/vm/raw_object_snapshot.cc
@@ -2218,13 +2218,19 @@ RawLinkedHashMap* LinkedHashMap::ReadFrom(SnapshotReader* reader,
// we don't reach this.
UNREACHABLE();
} else {
- map = LinkedHashMap::New(HEAP_SPACE(kind));
+ // Since the map might contain itself as a key or value, allocate first.
+ map = LinkedHashMap::NewUninitialized(HEAP_SPACE(kind));
}
reader->AddBackRef(object_id, &map, kIsDeserialized);
- *(reader->ArrayHandle()) ^= reader->ReadObjectImpl();
- map.SetData(*(reader->ArrayHandle()));
- *(reader->TypeArgumentsHandle()) = reader->ArrayHandle()->GetTypeArguments();
- map.SetTypeArguments(*(reader->TypeArgumentsHandle()));
+ // Set the object tags.
+ map.set_tags(tags);
+ // Read and set the fields.
+ intptr_t num_flds = (map.raw()->to() - map.raw()->from());
+ for (intptr_t i = 0; i <= num_flds; i++) {
+ (*reader->PassiveObjectHandle()) = reader->ReadObjectRef();
+ map.StorePointer((map.raw()->from() + i),
+ reader->PassiveObjectHandle()->raw());
+ }
return map.raw();
}
@@ -2246,10 +2252,12 @@ void RawLinkedHashMap::WriteTo(SnapshotWriter* writer,
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_);
+ // Write out all the object pointer fields.
+ // TODO(koda): Serialize only used parts of data_ (after compaction), to
+ // reduce space and support per-isolate salted hash codes. All allowed keys
+ // have types for which we can rehash without running Dart code.
+ SnapshotWriterVisitor visitor(writer);
+ visitor.VisitPointers(from(), to());
}
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698