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/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/hashmap.h" | 9 #include "src/hashmap.h" |
10 #include "src/heap-profiler.h" | 10 #include "src/heap-profiler.h" |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
623 Serializer* startup_snapshot_serializer, | 623 Serializer* startup_snapshot_serializer, |
624 SnapshotByteSink* sink) | 624 SnapshotByteSink* sink) |
625 : Serializer(isolate, sink), | 625 : Serializer(isolate, sink), |
626 startup_serializer_(startup_snapshot_serializer) { | 626 startup_serializer_(startup_snapshot_serializer) { |
627 InitializeCodeAddressMap(); | 627 InitializeCodeAddressMap(); |
628 } | 628 } |
629 | 629 |
630 // Serialize the objects reachable from a single object pointer. | 630 // Serialize the objects reachable from a single object pointer. |
631 void Serialize(Object** o); | 631 void Serialize(Object** o); |
632 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, | 632 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, |
633 WhereToPoint where_to_point, int skip); | 633 WhereToPoint where_to_point, int skip) OVERRIDE; |
634 | 634 |
635 private: | 635 private: |
636 int PartialSnapshotCacheIndex(HeapObject* o); | 636 int PartialSnapshotCacheIndex(HeapObject* o); |
637 bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { | 637 bool ShouldBeInThePartialSnapshotCache(HeapObject* o) { |
638 // Scripts should be referred only through shared function infos. We can't | 638 // Scripts should be referred only through shared function infos. We can't |
639 // allow them to be part of the partial snapshot because they contain a | 639 // allow them to be part of the partial snapshot because they contain a |
640 // unique ID, and deserializing several partial snapshots containing script | 640 // unique ID, and deserializing several partial snapshots containing script |
641 // would cause dupes. | 641 // would cause dupes. |
642 DCHECK(!o->IsScript()); | 642 DCHECK(!o->IsScript()); |
643 return o->IsName() || o->IsSharedFunctionInfo() || | 643 return o->IsName() || o->IsSharedFunctionInfo() || |
(...skipping 24 matching lines...) Expand all Loading... |
668 // The StartupSerializer has to serialize the root array, which is slightly | 668 // The StartupSerializer has to serialize the root array, which is slightly |
669 // different. | 669 // different. |
670 virtual void VisitPointers(Object** start, Object** end) OVERRIDE; | 670 virtual void VisitPointers(Object** start, Object** end) OVERRIDE; |
671 | 671 |
672 // Serialize the current state of the heap. The order is: | 672 // Serialize the current state of the heap. The order is: |
673 // 1) Strong references. | 673 // 1) Strong references. |
674 // 2) Partial snapshot cache. | 674 // 2) Partial snapshot cache. |
675 // 3) Weak references (e.g. the string table). | 675 // 3) Weak references (e.g. the string table). |
676 virtual void SerializeStrongReferences(); | 676 virtual void SerializeStrongReferences(); |
677 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, | 677 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, |
678 WhereToPoint where_to_point, int skip); | 678 WhereToPoint where_to_point, int skip) OVERRIDE; |
679 void SerializeWeakReferences(); | 679 void SerializeWeakReferences(); |
680 void Serialize() { | 680 void Serialize() { |
681 SerializeStrongReferences(); | 681 SerializeStrongReferences(); |
682 SerializeWeakReferences(); | 682 SerializeWeakReferences(); |
683 Pad(); | 683 Pad(); |
684 } | 684 } |
685 | 685 |
686 private: | 686 private: |
687 intptr_t root_index_wave_front_; | 687 intptr_t root_index_wave_front_; |
688 DISALLOW_COPY_AND_ASSIGN(StartupSerializer); | 688 DISALLOW_COPY_AND_ASSIGN(StartupSerializer); |
(...skipping 24 matching lines...) Expand all Loading... |
713 CodeSerializer(Isolate* isolate, SnapshotByteSink* sink, String* source, | 713 CodeSerializer(Isolate* isolate, SnapshotByteSink* sink, String* source, |
714 Code* main_code) | 714 Code* main_code) |
715 : Serializer(isolate, sink), | 715 : Serializer(isolate, sink), |
716 source_(source), | 716 source_(source), |
717 main_code_(main_code), | 717 main_code_(main_code), |
718 num_internalized_strings_(0) { | 718 num_internalized_strings_(0) { |
719 back_reference_map_.AddSourceString(source); | 719 back_reference_map_.AddSourceString(source); |
720 } | 720 } |
721 | 721 |
722 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, | 722 virtual void SerializeObject(HeapObject* o, HowToCode how_to_code, |
723 WhereToPoint where_to_point, int skip); | 723 WhereToPoint where_to_point, int skip) OVERRIDE; |
724 | 724 |
725 void SerializeBuiltin(int builtin_index, HowToCode how_to_code, | 725 void SerializeBuiltin(int builtin_index, HowToCode how_to_code, |
726 WhereToPoint where_to_point); | 726 WhereToPoint where_to_point); |
727 void SerializeIC(Code* ic, HowToCode how_to_code, | 727 void SerializeIC(Code* ic, HowToCode how_to_code, |
728 WhereToPoint where_to_point); | 728 WhereToPoint where_to_point); |
729 void SerializeCodeStub(uint32_t stub_key, HowToCode how_to_code, | 729 void SerializeCodeStub(uint32_t stub_key, HowToCode how_to_code, |
730 WhereToPoint where_to_point); | 730 WhereToPoint where_to_point); |
731 void SerializeSourceObject(HowToCode how_to_code, | 731 void SerializeSourceObject(HowToCode how_to_code, |
732 WhereToPoint where_to_point); | 732 WhereToPoint where_to_point); |
733 void SerializeGeneric(HeapObject* heap_object, HowToCode how_to_code, | 733 void SerializeGeneric(HeapObject* heap_object, HowToCode how_to_code, |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
844 // Following the header, we store, in sequential order | 844 // Following the header, we store, in sequential order |
845 // - code stub keys | 845 // - code stub keys |
846 // - serialization payload | 846 // - serialization payload |
847 | 847 |
848 ScriptData* script_data_; | 848 ScriptData* script_data_; |
849 bool owns_script_data_; | 849 bool owns_script_data_; |
850 }; | 850 }; |
851 } } // namespace v8::internal | 851 } } // namespace v8::internal |
852 | 852 |
853 #endif // V8_SERIALIZE_H_ | 853 #endif // V8_SERIALIZE_H_ |
OLD | NEW |