| 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 716 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 // We may not need the code address map for logging for every instance | 727 // We may not need the code address map for logging for every instance |
| 728 // of the serializer. Initialize it on demand. | 728 // of the serializer. Initialize it on demand. |
| 729 void InitializeCodeAddressMap(); | 729 void InitializeCodeAddressMap(); |
| 730 | 730 |
| 731 inline uint32_t max_chunk_size(int space) const { | 731 inline uint32_t max_chunk_size(int space) const { |
| 732 DCHECK_LE(0, space); | 732 DCHECK_LE(0, space); |
| 733 DCHECK_LT(space, kNumberOfSpaces); | 733 DCHECK_LT(space, kNumberOfSpaces); |
| 734 return max_chunk_size_[space]; | 734 return max_chunk_size_[space]; |
| 735 } | 735 } |
| 736 | 736 |
| 737 SnapshotByteSink* sink() const { return sink_; } |
| 738 |
| 737 Isolate* isolate_; | 739 Isolate* isolate_; |
| 738 | 740 |
| 739 SnapshotByteSink* sink_; | 741 SnapshotByteSink* sink_; |
| 740 ExternalReferenceEncoder* external_reference_encoder_; | 742 ExternalReferenceEncoder* external_reference_encoder_; |
| 741 | 743 |
| 742 BackReferenceMap back_reference_map_; | 744 BackReferenceMap back_reference_map_; |
| 743 RootIndexMap root_index_map_; | 745 RootIndexMap root_index_map_; |
| 744 | 746 |
| 747 friend class Deserializer; |
| 745 friend class ObjectSerializer; | 748 friend class ObjectSerializer; |
| 746 friend class Deserializer; | 749 friend class SnapshotData; |
| 747 | 750 |
| 748 private: | 751 private: |
| 749 CodeAddressMap* code_address_map_; | 752 CodeAddressMap* code_address_map_; |
| 750 // Objects from the same space are put into chunks for bulk-allocation | 753 // Objects from the same space are put into chunks for bulk-allocation |
| 751 // when deserializing. We have to make sure that each chunk fits into a | 754 // when deserializing. We have to make sure that each chunk fits into a |
| 752 // page. So we track the chunk size in pending_chunk_ of a space, but | 755 // page. So we track the chunk size in pending_chunk_ of a space, but |
| 753 // when it exceeds a page, we complete the current chunk and start a new one. | 756 // when it exceeds a page, we complete the current chunk and start a new one. |
| 754 uint32_t pending_chunk_[kNumberOfPreallocatedSpaces]; | 757 uint32_t pending_chunk_[kNumberOfPreallocatedSpaces]; |
| 755 List<uint32_t> completed_chunks_[kNumberOfPreallocatedSpaces]; | 758 List<uint32_t> completed_chunks_[kNumberOfPreallocatedSpaces]; |
| 756 uint32_t max_chunk_size_[kNumberOfPreallocatedSpaces]; | 759 uint32_t max_chunk_size_[kNumberOfPreallocatedSpaces]; |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 890 int num_internalized_strings_; | 893 int num_internalized_strings_; |
| 891 List<uint32_t> stub_keys_; | 894 List<uint32_t> stub_keys_; |
| 892 DISALLOW_COPY_AND_ASSIGN(CodeSerializer); | 895 DISALLOW_COPY_AND_ASSIGN(CodeSerializer); |
| 893 }; | 896 }; |
| 894 | 897 |
| 895 | 898 |
| 896 // Wrapper around reservation sizes and the serialization payload. | 899 // Wrapper around reservation sizes and the serialization payload. |
| 897 class SnapshotData : public SerializedData { | 900 class SnapshotData : public SerializedData { |
| 898 public: | 901 public: |
| 899 // Used when producing. | 902 // Used when producing. |
| 900 SnapshotData(const SnapshotByteSink& sink, const Serializer& ser); | 903 explicit SnapshotData(const Serializer& ser); |
| 901 | 904 |
| 902 // Used when consuming. | 905 // Used when consuming. |
| 903 explicit SnapshotData(const Vector<const byte> snapshot) | 906 explicit SnapshotData(const Vector<const byte> snapshot) |
| 904 : SerializedData(const_cast<byte*>(snapshot.begin()), snapshot.length()) { | 907 : SerializedData(const_cast<byte*>(snapshot.begin()), snapshot.length()) { |
| 905 CHECK(IsSane()); | 908 CHECK(IsSane()); |
| 906 } | 909 } |
| 907 | 910 |
| 908 Vector<const Reservation> Reservations() const; | 911 Vector<const Reservation> Reservations() const; |
| 909 Vector<const byte> Payload() const; | 912 Vector<const byte> Payload() const; |
| 910 | 913 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 990 kNumInternalizedStringsOffset + kInt32Size; | 993 kNumInternalizedStringsOffset + kInt32Size; |
| 991 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; | 994 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; |
| 992 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; | 995 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; |
| 993 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; | 996 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; |
| 994 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; | 997 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; |
| 995 static const int kHeaderSize = kChecksum2Offset + kInt32Size; | 998 static const int kHeaderSize = kChecksum2Offset + kInt32Size; |
| 996 }; | 999 }; |
| 997 } } // namespace v8::internal | 1000 } } // namespace v8::internal |
| 998 | 1001 |
| 999 #endif // V8_SERIALIZE_H_ | 1002 #endif // V8_SERIALIZE_H_ |
| OLD | NEW |