| 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 587 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 598 Pad(); | 598 Pad(); |
| 599 } | 599 } |
| 600 | 600 |
| 601 private: | 601 private: |
| 602 DISALLOW_COPY_AND_ASSIGN(StartupSerializer); | 602 DISALLOW_COPY_AND_ASSIGN(StartupSerializer); |
| 603 }; | 603 }; |
| 604 | 604 |
| 605 | 605 |
| 606 class CodeSerializer : public Serializer { | 606 class CodeSerializer : public Serializer { |
| 607 public: | 607 public: |
| 608 CodeSerializer(Isolate* isolate, SnapshotByteSink* sink, String* source) | |
| 609 : Serializer(isolate, sink), source_(source) { | |
| 610 set_root_index_wave_front(Heap::kStrongRootListLength); | |
| 611 InitializeCodeAddressMap(); | |
| 612 } | |
| 613 | |
| 614 static ScriptData* Serialize(Isolate* isolate, | 608 static ScriptData* Serialize(Isolate* isolate, |
| 615 Handle<SharedFunctionInfo> info, | 609 Handle<SharedFunctionInfo> info, |
| 616 Handle<String> source); | 610 Handle<String> source); |
| 617 | 611 |
| 618 virtual void SerializeObject(Object* o, HowToCode how_to_code, | |
| 619 WhereToPoint where_to_point, int skip); | |
| 620 | |
| 621 static Handle<SharedFunctionInfo> Deserialize(Isolate* isolate, | 612 static Handle<SharedFunctionInfo> Deserialize(Isolate* isolate, |
| 622 ScriptData* data, | 613 ScriptData* data, |
| 623 Handle<String> source); | 614 Handle<String> source); |
| 624 | 615 |
| 625 static const int kSourceObjectIndex = 0; | 616 static const int kSourceObjectIndex = 0; |
| 626 static const int kCodeStubsBaseIndex = 1; | 617 static const int kCodeStubsBaseIndex = 1; |
| 627 | 618 |
| 628 String* source() { | 619 String* source() { |
| 629 DCHECK(!AllowHeapAllocation::IsAllowed()); | 620 DCHECK(!AllowHeapAllocation::IsAllowed()); |
| 630 return source_; | 621 return source_; |
| 631 } | 622 } |
| 632 | 623 |
| 633 List<uint32_t>* stub_keys() { return &stub_keys_; } | 624 List<uint32_t>* stub_keys() { return &stub_keys_; } |
| 634 | 625 |
| 635 private: | 626 private: |
| 627 CodeSerializer(Isolate* isolate, SnapshotByteSink* sink, String* source, |
| 628 Code* main_code) |
| 629 : Serializer(isolate, sink), source_(source), main_code_(main_code) { |
| 630 set_root_index_wave_front(Heap::kStrongRootListLength); |
| 631 InitializeCodeAddressMap(); |
| 632 } |
| 633 |
| 634 virtual void SerializeObject(Object* o, HowToCode how_to_code, |
| 635 WhereToPoint where_to_point, int skip); |
| 636 |
| 636 void SerializeBuiltin(Code* builtin, HowToCode how_to_code, | 637 void SerializeBuiltin(Code* builtin, HowToCode how_to_code, |
| 637 WhereToPoint where_to_point, int skip); | 638 WhereToPoint where_to_point); |
| 638 void SerializeCodeStub(Code* stub, HowToCode how_to_code, | 639 void SerializeCodeStub(Code* stub, HowToCode how_to_code, |
| 639 WhereToPoint where_to_point, int skip); | 640 WhereToPoint where_to_point); |
| 640 void SerializeSourceObject(HowToCode how_to_code, WhereToPoint where_to_point, | 641 void SerializeSourceObject(HowToCode how_to_code, |
| 641 int skip); | 642 WhereToPoint where_to_point); |
| 642 void SerializeHeapObject(HeapObject* heap_object, HowToCode how_to_code, | 643 void SerializeHeapObject(HeapObject* heap_object, HowToCode how_to_code, |
| 643 WhereToPoint where_to_point, int skip); | 644 WhereToPoint where_to_point); |
| 644 int AddCodeStubKey(uint32_t stub_key); | 645 int AddCodeStubKey(uint32_t stub_key); |
| 645 | 646 |
| 646 DisallowHeapAllocation no_gc_; | 647 DisallowHeapAllocation no_gc_; |
| 647 String* source_; | 648 String* source_; |
| 649 Code* main_code_; |
| 648 List<uint32_t> stub_keys_; | 650 List<uint32_t> stub_keys_; |
| 649 DISALLOW_COPY_AND_ASSIGN(CodeSerializer); | 651 DISALLOW_COPY_AND_ASSIGN(CodeSerializer); |
| 650 }; | 652 }; |
| 651 | 653 |
| 652 | 654 |
| 653 // Wrapper around ScriptData to provide code-serializer-specific functionality. | 655 // Wrapper around ScriptData to provide code-serializer-specific functionality. |
| 654 class SerializedCodeData { | 656 class SerializedCodeData { |
| 655 public: | 657 public: |
| 656 // Used by when consuming. | 658 // Used by when consuming. |
| 657 explicit SerializedCodeData(ScriptData* data, String* source) | 659 explicit SerializedCodeData(ScriptData* data, String* source) |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 734 // Following the header, we store, in sequential order | 736 // Following the header, we store, in sequential order |
| 735 // - code stub keys | 737 // - code stub keys |
| 736 // - serialization payload | 738 // - serialization payload |
| 737 | 739 |
| 738 ScriptData* script_data_; | 740 ScriptData* script_data_; |
| 739 bool owns_script_data_; | 741 bool owns_script_data_; |
| 740 }; | 742 }; |
| 741 } } // namespace v8::internal | 743 } } // namespace v8::internal |
| 742 | 744 |
| 743 #endif // V8_SERIALIZE_H_ | 745 #endif // V8_SERIALIZE_H_ |
| OLD | NEW |