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

Unified Diff: src/snapshot/startup-serializer.h

Issue 2055203002: [snapshot] support multiple contexts in the same snapshot. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@sinkmember
Patch Set: fix test. again. Created 4 years, 6 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/snapshot/snapshot-common.cc ('k') | src/snapshot/startup-serializer.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/snapshot/startup-serializer.h
diff --git a/src/snapshot/startup-serializer.h b/src/snapshot/startup-serializer.h
index cf40e8dc4c8845802fb0c6899524a008c337530e..cc66f71ae9e3260660a2196b89ef527b6f2222f2 100644
--- a/src/snapshot/startup-serializer.h
+++ b/src/snapshot/startup-serializer.h
@@ -27,7 +27,34 @@ class StartupSerializer : public Serializer {
void SerializeStrongReferences();
void SerializeWeakReferencesAndDeferred();
+ int PartialSnapshotCacheIndex(HeapObject* o);
+
private:
+ class PartialCacheIndexMap : public AddressMapBase {
+ public:
+ PartialCacheIndexMap()
+ : map_(base::HashMap::PointersMatch), next_index_(0) {}
+
+ // Lookup object in the map. Return its index if found, or create
+ // a new entry with new_index as value, and return kInvalidIndex.
+ bool LookupOrInsert(HeapObject* obj, int* index_out) {
+ base::HashMap::Entry* entry = LookupEntry(&map_, obj, false);
+ if (entry != NULL) {
+ *index_out = GetValue(entry);
+ return true;
+ }
+ *index_out = next_index_;
+ SetValue(LookupEntry(&map_, obj, true), next_index_++);
+ return false;
+ }
+
+ private:
+ base::HashMap map_;
+ int next_index_;
+
+ DISALLOW_COPY_AND_ASSIGN(PartialCacheIndexMap);
+ };
+
// The StartupSerializer has to serialize the root array, which is slightly
// different.
void VisitPointers(Object** start, Object** end) override;
@@ -45,6 +72,7 @@ class StartupSerializer : public Serializer {
bool serializing_builtins_;
bool serializing_immortal_immovables_roots_;
std::bitset<Heap::kStrongRootListLength> root_has_been_serialized_;
+ PartialCacheIndexMap partial_cache_index_map_;
DISALLOW_COPY_AND_ASSIGN(StartupSerializer);
};
« no previous file with comments | « src/snapshot/snapshot-common.cc ('k') | src/snapshot/startup-serializer.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698