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

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: Ready for review. 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
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..f3407ed8782d36caedbfb74f2931473bbebc7d7a 100644
--- a/runtime/vm/raw_object_snapshot.cc
+++ b/runtime/vm/raw_object_snapshot.cc
@@ -2218,13 +2218,28 @@ 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->TypeArgumentsHandle()) ^= reader->ReadObjectImpl();
+ map.SetTypeArguments(*(reader->TypeArgumentsHandle()));
+ // Note: If the map is too big for a 32-bit VM, then Array::New will FATAL.
*(reader->ArrayHandle()) ^= reader->ReadObjectImpl();
map.SetData(*(reader->ArrayHandle()));
- *(reader->TypeArgumentsHandle()) = reader->ArrayHandle()->GetTypeArguments();
- map.SetTypeArguments(*(reader->TypeArgumentsHandle()));
+ *(reader->TypedDataHandle()) ^= reader->ReadObjectImpl();
+ map.SetIndex(*(reader->TypedDataHandle()));
+ map.SetHashMask(reader->ReadSmiValue());
+ map.SetUsedData(reader->ReadSmiValue());
+ map.SetDeletedKeys(reader->ReadSmiValue());
+ /*
+ *(reader->SmiHandle()) ^= reader->ReadObjectImpl();
+ map.SetHashMask(reader->SmiHandle()->Value());
+ *(reader->SmiHandle()) ^= reader->ReadObjectImpl();
+ map.SetUsedData(reader->SmiHandle()->Value());
+ *(reader->SmiHandle()) ^= reader->ReadObjectImpl();
+ map.SetDeletedKeys(reader->SmiHandle()->Value());
+ */
siva 2015/05/22 16:27:11 Why is this done this way and not using the from/t
koda 2015/05/26 12:22:05 Done.
return map.raw();
}
@@ -2246,10 +2261,16 @@ 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.
+ // Write out the 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.
+ writer->WriteObjectImpl(ptr()->type_arguments_);
writer->WriteObjectImpl(ptr()->data_);
+ writer->WriteObjectImpl(ptr()->index_);
+ writer->Write<RawObject*>(ptr()->hash_mask_);
+ writer->Write<RawObject*>(ptr()->used_data_);
+ writer->Write<RawObject*>(ptr()->deleted_keys_);
siva 2015/05/22 16:27:11 Ditto question.
koda 2015/05/26 12:22:05 Done.
}
« runtime/vm/raw_object.h ('K') | « 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