| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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_SERIALIZE_H_ | 5 #ifndef V8_SERIALIZE_H_ |
| 6 #define V8_SERIALIZE_H_ | 6 #define V8_SERIALIZE_H_ |
| 7 | 7 |
| 8 #include "src/hashmap.h" | 8 #include "src/hashmap.h" |
| 9 #include "src/heap-profiler.h" | 9 #include "src/heap-profiler.h" |
| 10 #include "src/isolate.h" | 10 #include "src/isolate.h" |
| (...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 179 return kInvalidRootIndex; | 179 return kInvalidRootIndex; |
| 180 } | 180 } |
| 181 | 181 |
| 182 private: | 182 private: |
| 183 HashMap* map_; | 183 HashMap* map_; |
| 184 | 184 |
| 185 DISALLOW_COPY_AND_ASSIGN(RootIndexMap); | 185 DISALLOW_COPY_AND_ASSIGN(RootIndexMap); |
| 186 }; | 186 }; |
| 187 | 187 |
| 188 | 188 |
| 189 class PartialCacheIndexMap : public AddressMapBase { |
| 190 public: |
| 191 PartialCacheIndexMap() : map_(HashMap::PointersMatch) {} |
| 192 |
| 193 static const int kInvalidIndex = -1; |
| 194 |
| 195 // Lookup object in the map. Return its index if found, or create |
| 196 // a new entry with new_index as value, and return kInvalidIndex. |
| 197 int LookupOrInsert(HeapObject* obj, int new_index) { |
| 198 HashMap::Entry* entry = LookupEntry(&map_, obj, true); |
| 199 if (entry->value != NULL) return GetValue(entry); |
| 200 SetValue(entry, static_cast<uint32_t>(new_index)); |
| 201 return kInvalidIndex; |
| 202 } |
| 203 |
| 204 private: |
| 205 HashMap map_; |
| 206 |
| 207 DISALLOW_COPY_AND_ASSIGN(PartialCacheIndexMap); |
| 208 }; |
| 209 |
| 210 |
| 189 class BackReference { | 211 class BackReference { |
| 190 public: | 212 public: |
| 191 explicit BackReference(uint32_t bitfield) : bitfield_(bitfield) {} | 213 explicit BackReference(uint32_t bitfield) : bitfield_(bitfield) {} |
| 192 | 214 |
| 193 BackReference() : bitfield_(kInvalidValue) {} | 215 BackReference() : bitfield_(kInvalidValue) {} |
| 194 | 216 |
| 195 static BackReference SourceReference() { return BackReference(kSourceValue); } | 217 static BackReference SourceReference() { return BackReference(kSourceValue); } |
| 196 | 218 |
| 197 static BackReference GlobalProxyReference() { | 219 static BackReference GlobalProxyReference() { |
| 198 return BackReference(kGlobalProxyValue); | 220 return BackReference(kGlobalProxyValue); |
| (...skipping 596 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 795 o->IsScopeInfo() || | 817 o->IsScopeInfo() || |
| 796 o->map() == | 818 o->map() == |
| 797 startup_serializer_->isolate()->heap()->fixed_cow_array_map(); | 819 startup_serializer_->isolate()->heap()->fixed_cow_array_map(); |
| 798 } | 820 } |
| 799 | 821 |
| 800 void SerializeOutdatedContextsAsFixedArray(); | 822 void SerializeOutdatedContextsAsFixedArray(); |
| 801 | 823 |
| 802 Serializer* startup_serializer_; | 824 Serializer* startup_serializer_; |
| 803 List<BackReference> outdated_contexts_; | 825 List<BackReference> outdated_contexts_; |
| 804 Object* global_object_; | 826 Object* global_object_; |
| 827 PartialCacheIndexMap partial_cache_index_map_; |
| 805 DISALLOW_COPY_AND_ASSIGN(PartialSerializer); | 828 DISALLOW_COPY_AND_ASSIGN(PartialSerializer); |
| 806 }; | 829 }; |
| 807 | 830 |
| 808 | 831 |
| 809 class StartupSerializer : public Serializer { | 832 class StartupSerializer : public Serializer { |
| 810 public: | 833 public: |
| 811 StartupSerializer(Isolate* isolate, SnapshotByteSink* sink) | 834 StartupSerializer(Isolate* isolate, SnapshotByteSink* sink) |
| 812 : Serializer(isolate, sink), root_index_wave_front_(0) { | 835 : Serializer(isolate, sink), root_index_wave_front_(0) { |
| 813 // Clear the cache of objects used by the partial snapshot. After the | 836 // Clear the cache of objects used by the partial snapshot. After the |
| 814 // strong roots have been serialized we can create a partial snapshot | 837 // strong roots have been serialized we can create a partial snapshot |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 993 kNumInternalizedStringsOffset + kInt32Size; | 1016 kNumInternalizedStringsOffset + kInt32Size; |
| 994 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; | 1017 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; |
| 995 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; | 1018 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; |
| 996 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; | 1019 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; |
| 997 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; | 1020 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; |
| 998 static const int kHeaderSize = kChecksum2Offset + kInt32Size; | 1021 static const int kHeaderSize = kChecksum2Offset + kInt32Size; |
| 999 }; | 1022 }; |
| 1000 } } // namespace v8::internal | 1023 } } // namespace v8::internal |
| 1001 | 1024 |
| 1002 #endif // V8_SERIALIZE_H_ | 1025 #endif // V8_SERIALIZE_H_ |
| OLD | NEW |