| 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 590 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 601 }; | 601 }; |
| 602 | 602 |
| 603 | 603 |
| 604 class CodeAddressMap; | 604 class CodeAddressMap; |
| 605 | 605 |
| 606 // There can be only one serializer per V8 process. | 606 // There can be only one serializer per V8 process. |
| 607 class Serializer : public SerializerDeserializer { | 607 class Serializer : public SerializerDeserializer { |
| 608 public: | 608 public: |
| 609 Serializer(Isolate* isolate, SnapshotByteSink* sink); | 609 Serializer(Isolate* isolate, SnapshotByteSink* sink); |
| 610 ~Serializer(); | 610 ~Serializer(); |
| 611 void VisitPointers(Object** start, Object** end) OVERRIDE; | 611 void VisitPointers(Object** start, Object** end) override; |
| 612 | 612 |
| 613 void EncodeReservations(List<SerializedData::Reservation>* out) const; | 613 void EncodeReservations(List<SerializedData::Reservation>* out) const; |
| 614 | 614 |
| 615 Isolate* isolate() const { return isolate_; } | 615 Isolate* isolate() const { return isolate_; } |
| 616 | 616 |
| 617 BackReferenceMap* back_reference_map() { return &back_reference_map_; } | 617 BackReferenceMap* back_reference_map() { return &back_reference_map_; } |
| 618 RootIndexMap* root_index_map() { return &root_index_map_; } | 618 RootIndexMap* root_index_map() { return &root_index_map_; } |
| 619 | 619 |
| 620 #ifdef OBJECT_PRINT | 620 #ifdef OBJECT_PRINT |
| 621 void CountInstanceType(Map* map, int size); | 621 void CountInstanceType(Map* map, int size); |
| (...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 771 outdated_contexts_(0), | 771 outdated_contexts_(0), |
| 772 global_object_(NULL) { | 772 global_object_(NULL) { |
| 773 InitializeCodeAddressMap(); | 773 InitializeCodeAddressMap(); |
| 774 } | 774 } |
| 775 | 775 |
| 776 ~PartialSerializer() { OutputStatistics("PartialSerializer"); } | 776 ~PartialSerializer() { OutputStatistics("PartialSerializer"); } |
| 777 | 777 |
| 778 // Serialize the objects reachable from a single object pointer. | 778 // Serialize the objects reachable from a single object pointer. |
| 779 void Serialize(Object** o); | 779 void Serialize(Object** o); |
| 780 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, | 780 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, |
| 781 WhereToPoint where_to_point, int skip) OVERRIDE; | 781 WhereToPoint where_to_point, int skip) override; |
| 782 | 782 |
| 783 private: | 783 private: |
| 784 int PartialSnapshotCacheIndex(HeapObject* o); | 784 int PartialSnapshotCacheIndex(HeapObject* o); |
| 785 bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { | 785 bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { |
| 786 // Scripts should be referred only through shared function infos. We can't | 786 // Scripts should be referred only through shared function infos. We can't |
| 787 // allow them to be part of the partial snapshot because they contain a | 787 // allow them to be part of the partial snapshot because they contain a |
| 788 // unique ID, and deserializing several partial snapshots containing script | 788 // unique ID, and deserializing several partial snapshots containing script |
| 789 // would cause dupes. | 789 // would cause dupes. |
| 790 DCHECK(!o->IsScript()); | 790 DCHECK(!o->IsScript()); |
| 791 return o->IsName() || o->IsSharedFunctionInfo() || o->IsHeapNumber() || | 791 return o->IsName() || o->IsSharedFunctionInfo() || o->IsHeapNumber() || |
| (...skipping 21 matching lines...) Expand all Loading... |
| 813 // which will repopulate the cache with objects needed by that partial | 813 // which will repopulate the cache with objects needed by that partial |
| 814 // snapshot. | 814 // snapshot. |
| 815 isolate->partial_snapshot_cache()->Clear(); | 815 isolate->partial_snapshot_cache()->Clear(); |
| 816 InitializeCodeAddressMap(); | 816 InitializeCodeAddressMap(); |
| 817 } | 817 } |
| 818 | 818 |
| 819 ~StartupSerializer() { OutputStatistics("StartupSerializer"); } | 819 ~StartupSerializer() { OutputStatistics("StartupSerializer"); } |
| 820 | 820 |
| 821 // The StartupSerializer has to serialize the root array, which is slightly | 821 // The StartupSerializer has to serialize the root array, which is slightly |
| 822 // different. | 822 // different. |
| 823 void VisitPointers(Object** start, Object** end) OVERRIDE; | 823 void VisitPointers(Object** start, Object** end) override; |
| 824 | 824 |
| 825 // Serialize the current state of the heap. The order is: | 825 // Serialize the current state of the heap. The order is: |
| 826 // 1) Strong references. | 826 // 1) Strong references. |
| 827 // 2) Partial snapshot cache. | 827 // 2) Partial snapshot cache. |
| 828 // 3) Weak references (e.g. the string table). | 828 // 3) Weak references (e.g. the string table). |
| 829 virtual void SerializeStrongReferences(); | 829 virtual void SerializeStrongReferences(); |
| 830 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, | 830 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, |
| 831 WhereToPoint where_to_point, int skip) OVERRIDE; | 831 WhereToPoint where_to_point, int skip) override; |
| 832 void SerializeWeakReferences(); | 832 void SerializeWeakReferences(); |
| 833 void Serialize() { | 833 void Serialize() { |
| 834 SerializeStrongReferences(); | 834 SerializeStrongReferences(); |
| 835 SerializeWeakReferences(); | 835 SerializeWeakReferences(); |
| 836 Pad(); | 836 Pad(); |
| 837 } | 837 } |
| 838 | 838 |
| 839 private: | 839 private: |
| 840 intptr_t root_index_wave_front_; | 840 intptr_t root_index_wave_front_; |
| 841 DISALLOW_COPY_AND_ASSIGN(StartupSerializer); | 841 DISALLOW_COPY_AND_ASSIGN(StartupSerializer); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 870 : Serializer(isolate, sink), | 870 : Serializer(isolate, sink), |
| 871 source_(source), | 871 source_(source), |
| 872 main_code_(main_code), | 872 main_code_(main_code), |
| 873 num_internalized_strings_(0) { | 873 num_internalized_strings_(0) { |
| 874 back_reference_map_.AddSourceString(source); | 874 back_reference_map_.AddSourceString(source); |
| 875 } | 875 } |
| 876 | 876 |
| 877 ~CodeSerializer() { OutputStatistics("CodeSerializer"); } | 877 ~CodeSerializer() { OutputStatistics("CodeSerializer"); } |
| 878 | 878 |
| 879 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, | 879 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, |
| 880 WhereToPoint where_to_point, int skip) OVERRIDE; | 880 WhereToPoint where_to_point, int skip) override; |
| 881 | 881 |
| 882 void SerializeBuiltin(int builtin_index, HowToCode how_to_code, | 882 void SerializeBuiltin(int builtin_index, HowToCode how_to_code, |
| 883 WhereToPoint where_to_point); | 883 WhereToPoint where_to_point); |
| 884 void SerializeIC(Code* ic, HowToCode how_to_code, | 884 void SerializeIC(Code* ic, HowToCode how_to_code, |
| 885 WhereToPoint where_to_point); | 885 WhereToPoint where_to_point); |
| 886 void SerializeCodeStub(uint32_t stub_key, HowToCode how_to_code, | 886 void SerializeCodeStub(uint32_t stub_key, HowToCode how_to_code, |
| 887 WhereToPoint where_to_point); | 887 WhereToPoint where_to_point); |
| 888 void SerializeGeneric(HeapObject* heap_object, HowToCode how_to_code, | 888 void SerializeGeneric(HeapObject* heap_object, HowToCode how_to_code, |
| 889 WhereToPoint where_to_point); | 889 WhereToPoint where_to_point); |
| 890 int AddCodeStubKey(uint32_t stub_key); | 890 int AddCodeStubKey(uint32_t stub_key); |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 995 kNumInternalizedStringsOffset + kInt32Size; | 995 kNumInternalizedStringsOffset + kInt32Size; |
| 996 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; | 996 static const int kNumCodeStubKeysOffset = kNumReservationsOffset + kInt32Size; |
| 997 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; | 997 static const int kPayloadLengthOffset = kNumCodeStubKeysOffset + kInt32Size; |
| 998 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; | 998 static const int kChecksum1Offset = kPayloadLengthOffset + kInt32Size; |
| 999 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; | 999 static const int kChecksum2Offset = kChecksum1Offset + kInt32Size; |
| 1000 static const int kHeaderSize = kChecksum2Offset + kInt32Size; | 1000 static const int kHeaderSize = kChecksum2Offset + kInt32Size; |
| 1001 }; | 1001 }; |
| 1002 } } // namespace v8::internal | 1002 } } // namespace v8::internal |
| 1003 | 1003 |
| 1004 #endif // V8_SERIALIZE_H_ | 1004 #endif // V8_SERIALIZE_H_ |
| OLD | NEW |