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

Side by Side Diff: src/snapshot/startup-serializer.h

Issue 2490783004: [serializer] small fixes for blink snapshot. (Closed)
Patch Set: rebase and fix Created 4 years, 1 month 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 unified diff | Download patch
« no previous file with comments | « src/snapshot/serializer-common.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_SNAPSHOT_STARTUP_SERIALIZER_H_ 5 #ifndef V8_SNAPSHOT_STARTUP_SERIALIZER_H_
6 #define V8_SNAPSHOT_STARTUP_SERIALIZER_H_ 6 #define V8_SNAPSHOT_STARTUP_SERIALIZER_H_
7 7
8 #include <bitset> 8 #include <bitset>
9 #include "include/v8.h" 9 #include "include/v8.h"
10 #include "src/snapshot/serializer.h" 10 #include "src/snapshot/serializer.h"
(...skipping 12 matching lines...) Expand all
23 // 1) Immortal immovable roots 23 // 1) Immortal immovable roots
24 // 2) Remaining strong references. 24 // 2) Remaining strong references.
25 // 3) Partial snapshot cache. 25 // 3) Partial snapshot cache.
26 // 4) Weak references (e.g. the string table). 26 // 4) Weak references (e.g. the string table).
27 void SerializeStrongReferences(); 27 void SerializeStrongReferences();
28 void SerializeWeakReferencesAndDeferred(); 28 void SerializeWeakReferencesAndDeferred();
29 29
30 int PartialSnapshotCacheIndex(HeapObject* o); 30 int PartialSnapshotCacheIndex(HeapObject* o);
31 31
32 private: 32 private:
33 class PartialCacheIndexMap : public AddressMapBase { 33 class PartialCacheIndexMap {
34 public: 34 public:
35 PartialCacheIndexMap() : map_(), next_index_(0) {} 35 PartialCacheIndexMap() : map_(), next_index_(0) {}
36 36
37 // Lookup object in the map. Return its index if found, or create 37 // Lookup object in the map. Return its index if found, or create
38 // a new entry with new_index as value, and return kInvalidIndex. 38 // a new entry with new_index as value, and return kInvalidIndex.
39 bool LookupOrInsert(HeapObject* obj, int* index_out) { 39 bool LookupOrInsert(HeapObject* obj, int* index_out) {
40 base::HashMap::Entry* entry = LookupEntry(&map_, obj, false); 40 Maybe<uint32_t> maybe_index = map_.Get(obj);
41 if (entry != NULL) { 41 if (maybe_index.IsJust()) {
42 *index_out = GetValue(entry); 42 *index_out = maybe_index.FromJust();
43 return true; 43 return true;
44 } 44 }
45 *index_out = next_index_; 45 *index_out = next_index_;
46 SetValue(LookupEntry(&map_, obj, true), next_index_++); 46 map_.Set(obj, next_index_++);
47 return false; 47 return false;
48 } 48 }
49 49
50 private: 50 private:
51 base::HashMap map_; 51 DisallowHeapAllocation no_allocation_;
52 HeapObjectToIndexHashMap map_;
52 int next_index_; 53 int next_index_;
53 54
54 DISALLOW_COPY_AND_ASSIGN(PartialCacheIndexMap); 55 DISALLOW_COPY_AND_ASSIGN(PartialCacheIndexMap);
55 }; 56 };
56 57
57 // The StartupSerializer has to serialize the root array, which is slightly 58 // The StartupSerializer has to serialize the root array, which is slightly
58 // different. 59 // different.
59 void VisitPointers(Object** start, Object** end) override; 60 void VisitPointers(Object** start, Object** end) override;
60 void SerializeObject(HeapObject* o, HowToCode how_to_code, 61 void SerializeObject(HeapObject* o, HowToCode how_to_code,
61 WhereToPoint where_to_point, int skip) override; 62 WhereToPoint where_to_point, int skip) override;
(...skipping 10 matching lines...) Expand all
72 bool serializing_immortal_immovables_roots_; 73 bool serializing_immortal_immovables_roots_;
73 std::bitset<Heap::kStrongRootListLength> root_has_been_serialized_; 74 std::bitset<Heap::kStrongRootListLength> root_has_been_serialized_;
74 PartialCacheIndexMap partial_cache_index_map_; 75 PartialCacheIndexMap partial_cache_index_map_;
75 DISALLOW_COPY_AND_ASSIGN(StartupSerializer); 76 DISALLOW_COPY_AND_ASSIGN(StartupSerializer);
76 }; 77 };
77 78
78 } // namespace internal 79 } // namespace internal
79 } // namespace v8 80 } // namespace v8
80 81
81 #endif // V8_SNAPSHOT_STARTUP_SERIALIZER_H_ 82 #endif // V8_SNAPSHOT_STARTUP_SERIALIZER_H_
OLDNEW
« no previous file with comments | « src/snapshot/serializer-common.cc ('k') | test/cctest/test-serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698