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 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
696 | 696 |
697 enum ReturnSkip { kCanReturnSkipInsteadOfSkipping, kIgnoringReturn }; | 697 enum ReturnSkip { kCanReturnSkipInsteadOfSkipping, kIgnoringReturn }; |
698 // This function outputs or skips the raw data between the last pointer and | 698 // This function outputs or skips the raw data between the last pointer and |
699 // up to the current position. It optionally can just return the number of | 699 // up to the current position. It optionally can just return the number of |
700 // bytes to skip instead of performing a skip instruction, in case the skip | 700 // bytes to skip instead of performing a skip instruction, in case the skip |
701 // can be merged into the next instruction. | 701 // can be merged into the next instruction. |
702 int OutputRawData(Address up_to, ReturnSkip return_skip = kIgnoringReturn); | 702 int OutputRawData(Address up_to, ReturnSkip return_skip = kIgnoringReturn); |
703 // External strings are serialized in a way to resemble sequential strings. | 703 // External strings are serialized in a way to resemble sequential strings. |
704 void SerializeExternalString(); | 704 void SerializeExternalString(); |
705 | 705 |
| 706 Address PrepareCode(); |
| 707 |
706 Serializer* serializer_; | 708 Serializer* serializer_; |
707 HeapObject* object_; | 709 HeapObject* object_; |
708 SnapshotByteSink* sink_; | 710 SnapshotByteSink* sink_; |
709 int reference_representation_; | 711 int reference_representation_; |
710 int bytes_processed_so_far_; | 712 int bytes_processed_so_far_; |
711 bool code_object_; | 713 bool code_object_; |
712 bool code_has_been_output_; | 714 bool code_has_been_output_; |
713 }; | 715 }; |
714 | 716 |
715 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, | 717 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, |
(...skipping 26 matching lines...) Expand all Loading... |
742 void Pad(); | 744 void Pad(); |
743 | 745 |
744 // Some roots should not be serialized, because their actual value depends on | 746 // Some roots should not be serialized, because their actual value depends on |
745 // absolute addresses and they are reset after deserialization, anyway. | 747 // absolute addresses and they are reset after deserialization, anyway. |
746 bool ShouldBeSkipped(Object** current); | 748 bool ShouldBeSkipped(Object** current); |
747 | 749 |
748 // We may not need the code address map for logging for every instance | 750 // We may not need the code address map for logging for every instance |
749 // of the serializer. Initialize it on demand. | 751 // of the serializer. Initialize it on demand. |
750 void InitializeCodeAddressMap(); | 752 void InitializeCodeAddressMap(); |
751 | 753 |
| 754 Code* CopyCode(Code* code); |
| 755 |
752 inline uint32_t max_chunk_size(int space) const { | 756 inline uint32_t max_chunk_size(int space) const { |
753 DCHECK_LE(0, space); | 757 DCHECK_LE(0, space); |
754 DCHECK_LT(space, kNumberOfSpaces); | 758 DCHECK_LT(space, kNumberOfSpaces); |
755 return max_chunk_size_[space]; | 759 return max_chunk_size_[space]; |
756 } | 760 } |
757 | 761 |
758 SnapshotByteSink* sink() const { return sink_; } | 762 SnapshotByteSink* sink() const { return sink_; } |
759 | 763 |
760 Isolate* isolate_; | 764 Isolate* isolate_; |
761 | 765 |
(...skipping 14 matching lines...) Expand all Loading... |
776 // page. So we track the chunk size in pending_chunk_ of a space, but | 780 // page. So we track the chunk size in pending_chunk_ of a space, but |
777 // when it exceeds a page, we complete the current chunk and start a new one. | 781 // when it exceeds a page, we complete the current chunk and start a new one. |
778 uint32_t pending_chunk_[kNumberOfPreallocatedSpaces]; | 782 uint32_t pending_chunk_[kNumberOfPreallocatedSpaces]; |
779 List<uint32_t> completed_chunks_[kNumberOfPreallocatedSpaces]; | 783 List<uint32_t> completed_chunks_[kNumberOfPreallocatedSpaces]; |
780 uint32_t max_chunk_size_[kNumberOfPreallocatedSpaces]; | 784 uint32_t max_chunk_size_[kNumberOfPreallocatedSpaces]; |
781 | 785 |
782 // We map serialized large objects to indexes for back-referencing. | 786 // We map serialized large objects to indexes for back-referencing. |
783 uint32_t large_objects_total_size_; | 787 uint32_t large_objects_total_size_; |
784 uint32_t seen_large_objects_index_; | 788 uint32_t seen_large_objects_index_; |
785 | 789 |
| 790 List<byte> code_buffer_; |
| 791 |
786 DISALLOW_COPY_AND_ASSIGN(Serializer); | 792 DISALLOW_COPY_AND_ASSIGN(Serializer); |
787 }; | 793 }; |
788 | 794 |
789 | 795 |
790 class PartialSerializer : public Serializer { | 796 class PartialSerializer : public Serializer { |
791 public: | 797 public: |
792 PartialSerializer(Isolate* isolate, Serializer* startup_snapshot_serializer, | 798 PartialSerializer(Isolate* isolate, Serializer* startup_snapshot_serializer, |
793 SnapshotByteSink* sink) | 799 SnapshotByteSink* sink) |
794 : Serializer(isolate, sink), | 800 : Serializer(isolate, sink), |
795 startup_serializer_(startup_snapshot_serializer), | 801 startup_serializer_(startup_snapshot_serializer), |
(...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1015 kNumInternalizedStringsOffset + kInt32Size; | 1021 kNumInternalizedStringsOffset + kInt32Size; |
1016 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; | 1022 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; |
1017 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; | 1023 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; |
1018 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; | 1024 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; |
1019 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; | 1025 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; |
1020 static const int kHeaderSize = kChecksum2Offset + kInt32Size; | 1026 static const int kHeaderSize = kChecksum2Offset + kInt32Size; |
1021 }; | 1027 }; |
1022 } } // namespace v8::internal | 1028 } } // namespace v8::internal |
1023 | 1029 |
1024 #endif // V8_SERIALIZE_H_ | 1030 #endif // V8_SERIALIZE_H_ |
OLD | NEW |