| 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 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 565 MaybeHandle<Object> DeserializePartial( | 565 MaybeHandle<Object> DeserializePartial( |
| 566 Isolate* isolate, Handle<JSGlobalProxy> global_proxy, | 566 Isolate* isolate, Handle<JSGlobalProxy> global_proxy, |
| 567 Handle<FixedArray>* outdated_contexts_out); | 567 Handle<FixedArray>* outdated_contexts_out); |
| 568 | 568 |
| 569 // Deserialize a shared function info. Fail gracefully. | 569 // Deserialize a shared function info. Fail gracefully. |
| 570 MaybeHandle<SharedFunctionInfo> DeserializeCode(Isolate* isolate); | 570 MaybeHandle<SharedFunctionInfo> DeserializeCode(Isolate* isolate); |
| 571 | 571 |
| 572 void FlushICacheForNewCodeObjects(); | 572 void FlushICacheForNewCodeObjects(); |
| 573 | 573 |
| 574 // Pass a vector of externally-provided objects referenced by the snapshot. | 574 // Pass a vector of externally-provided objects referenced by the snapshot. |
| 575 // The ownership to its backing store is handed over as well. | 575 // The ownership to its backing store is not handed over. |
| 576 void SetAttachedObjects(Vector<Handle<Object> > attached_objects) { | 576 void SetAttachedObjects(Vector<Handle<Object> > attached_objects) { |
| 577 attached_objects_ = attached_objects; | 577 attached_objects_ = attached_objects; |
| 578 } | 578 } |
| 579 | 579 |
| 580 private: | 580 private: |
| 581 virtual void VisitPointers(Object** start, Object** end); | 581 virtual void VisitPointers(Object** start, Object** end); |
| 582 | 582 |
| 583 virtual void VisitRuntimeEntry(RelocInfo* rinfo) { | 583 virtual void VisitRuntimeEntry(RelocInfo* rinfo) { |
| 584 UNREACHABLE(); | 584 UNREACHABLE(); |
| 585 } | 585 } |
| (...skipping 110 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 27 matching lines...) Expand all Loading... |
| 743 void Pad(); | 745 void Pad(); |
| 744 | 746 |
| 745 // Some roots should not be serialized, because their actual value depends on | 747 // Some roots should not be serialized, because their actual value depends on |
| 746 // absolute addresses and they are reset after deserialization, anyway. | 748 // absolute addresses and they are reset after deserialization, anyway. |
| 747 bool ShouldBeSkipped(Object** current); | 749 bool ShouldBeSkipped(Object** current); |
| 748 | 750 |
| 749 // We may not need the code address map for logging for every instance | 751 // We may not need the code address map for logging for every instance |
| 750 // of the serializer. Initialize it on demand. | 752 // of the serializer. Initialize it on demand. |
| 751 void InitializeCodeAddressMap(); | 753 void InitializeCodeAddressMap(); |
| 752 | 754 |
| 755 inline Address GetCodeBuffer(int size) { |
| 756 if (size > code_buffer_.length()) code_buffer_.Dispose(); |
| 757 code_buffer_ = Vector<byte>::New(size); |
| 758 return code_buffer_.start(); |
| 759 } |
| 760 |
| 753 inline uint32_t max_chunk_size(int space) const { | 761 inline uint32_t max_chunk_size(int space) const { |
| 754 DCHECK_LE(0, space); | 762 DCHECK_LE(0, space); |
| 755 DCHECK_LT(space, kNumberOfSpaces); | 763 DCHECK_LT(space, kNumberOfSpaces); |
| 756 return max_chunk_size_[space]; | 764 return max_chunk_size_[space]; |
| 757 } | 765 } |
| 758 | 766 |
| 759 SnapshotByteSink* sink() const { return sink_; } | 767 SnapshotByteSink* sink() const { return sink_; } |
| 760 | 768 |
| 761 Isolate* isolate_; | 769 Isolate* isolate_; |
| 762 | 770 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 777 // page. So we track the chunk size in pending_chunk_ of a space, but | 785 // page. So we track the chunk size in pending_chunk_ of a space, but |
| 778 // when it exceeds a page, we complete the current chunk and start a new one. | 786 // when it exceeds a page, we complete the current chunk and start a new one. |
| 779 uint32_t pending_chunk_[kNumberOfPreallocatedSpaces]; | 787 uint32_t pending_chunk_[kNumberOfPreallocatedSpaces]; |
| 780 List<uint32_t> completed_chunks_[kNumberOfPreallocatedSpaces]; | 788 List<uint32_t> completed_chunks_[kNumberOfPreallocatedSpaces]; |
| 781 uint32_t max_chunk_size_[kNumberOfPreallocatedSpaces]; | 789 uint32_t max_chunk_size_[kNumberOfPreallocatedSpaces]; |
| 782 | 790 |
| 783 // We map serialized large objects to indexes for back-referencing. | 791 // We map serialized large objects to indexes for back-referencing. |
| 784 uint32_t large_objects_total_size_; | 792 uint32_t large_objects_total_size_; |
| 785 uint32_t seen_large_objects_index_; | 793 uint32_t seen_large_objects_index_; |
| 786 | 794 |
| 795 Vector<byte> code_buffer_; |
| 796 |
| 787 DISALLOW_COPY_AND_ASSIGN(Serializer); | 797 DISALLOW_COPY_AND_ASSIGN(Serializer); |
| 788 }; | 798 }; |
| 789 | 799 |
| 790 | 800 |
| 791 class PartialSerializer : public Serializer { | 801 class PartialSerializer : public Serializer { |
| 792 public: | 802 public: |
| 793 PartialSerializer(Isolate* isolate, Serializer* startup_snapshot_serializer, | 803 PartialSerializer(Isolate* isolate, Serializer* startup_snapshot_serializer, |
| 794 SnapshotByteSink* sink) | 804 SnapshotByteSink* sink) |
| 795 : Serializer(isolate, sink), | 805 : Serializer(isolate, sink), |
| 796 startup_serializer_(startup_snapshot_serializer), | 806 startup_serializer_(startup_snapshot_serializer), |
| (...skipping 219 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1016 kNumInternalizedStringsOffset + kInt32Size; | 1026 kNumInternalizedStringsOffset + kInt32Size; |
| 1017 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; | 1027 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; |
| 1018 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; | 1028 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; |
| 1019 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; | 1029 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; |
| 1020 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; | 1030 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; |
| 1021 static const int kHeaderSize = kChecksum2Offset + kInt32Size; | 1031 static const int kHeaderSize = kChecksum2Offset + kInt32Size; |
| 1022 }; | 1032 }; |
| 1023 } } // namespace v8::internal | 1033 } } // namespace v8::internal |
| 1024 | 1034 |
| 1025 #endif // V8_SERIALIZE_H_ | 1035 #endif // V8_SERIALIZE_H_ |
| OLD | NEW |