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

Unified Diff: src/serialize.cc

Issue 952933002: Use a hashmap to lookup items in the partial snapshot cache when serializing. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
« no previous file with comments | « src/serialize.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/serialize.cc
diff --git a/src/serialize.cc b/src/serialize.cc
index f30c8e046a699179ae0c3d8806ae7b1e1becc5b9..05a54188b86cfbeef9bc010a083fcad001d9adb5 100644
--- a/src/serialize.cc
+++ b/src/serialize.cc
@@ -1523,19 +1523,20 @@ void SerializerDeserializer::Iterate(Isolate* isolate,
int PartialSerializer::PartialSnapshotCacheIndex(HeapObject* heap_object) {
Isolate* isolate = this->isolate();
List<Object*>* cache = isolate->partial_snapshot_cache();
- for (int i = 0; i < cache->length(); ++i) {
- Object* entry = cache->at(i);
- if (entry == heap_object) return i;
- }
-
- // We didn't find the object in the cache. So we add it to the cache and
- // then visit the pointer so that it becomes part of the startup snapshot
- // and we can refer to it from the partial snapshot.
- cache->Add(heap_object);
- startup_serializer_->VisitPointer(reinterpret_cast<Object**>(&heap_object));
- // We don't recurse from the startup snapshot generator into the partial
- // snapshot generator.
- return cache->length() - 1;
+ int new_index = cache->length();
+
+ int index = partial_cache_index_map_.LookupOrInsert(heap_object, new_index);
+ if (index == PartialCacheIndexMap::kInvalidIndex) {
+ // We didn't find the object in the cache. So we add it to the cache and
+ // then visit the pointer so that it becomes part of the startup snapshot
+ // and we can refer to it from the partial snapshot.
+ cache->Add(heap_object);
+ startup_serializer_->VisitPointer(reinterpret_cast<Object**>(&heap_object));
+ // We don't recurse from the startup snapshot generator into the partial
+ // snapshot generator.
+ return new_index;
+ }
+ return index;
}
« no previous file with comments | « src/serialize.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698