| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef VM_SNAPSHOT_H_ | 5 #ifndef VM_SNAPSHOT_H_ |
| 6 #define VM_SNAPSHOT_H_ | 6 #define VM_SNAPSHOT_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/allocation.h" | 9 #include "vm/allocation.h" |
| 10 #include "vm/bitfield.h" | 10 #include "vm/bitfield.h" |
| (...skipping 733 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 744 instructions_(), | 744 instructions_(), |
| 745 objects_() { | 745 objects_() { |
| 746 } | 746 } |
| 747 virtual ~InstructionsWriter() { } | 747 virtual ~InstructionsWriter() { } |
| 748 | 748 |
| 749 int32_t GetOffsetFor(RawInstructions* instructions, RawCode* code); | 749 int32_t GetOffsetFor(RawInstructions* instructions, RawCode* code); |
| 750 | 750 |
| 751 int32_t GetObjectOffsetFor(RawObject* raw_object); | 751 int32_t GetObjectOffsetFor(RawObject* raw_object); |
| 752 | 752 |
| 753 virtual void Write() = 0; | 753 virtual void Write() = 0; |
| 754 virtual intptr_t binary_size() = 0; | 754 virtual intptr_t text_size() = 0; |
| 755 virtual intptr_t data_size() = 0; |
| 755 | 756 |
| 756 protected: | 757 protected: |
| 757 struct InstructionsData { | 758 struct InstructionsData { |
| 758 explicit InstructionsData(RawInstructions* insns, | 759 explicit InstructionsData(RawInstructions* insns, |
| 759 RawCode* code, | 760 RawCode* code, |
| 760 intptr_t offset) | 761 intptr_t offset) |
| 761 : raw_insns_(insns), raw_code_(code), offset_(offset) { } | 762 : raw_insns_(insns), raw_code_(code), offset_(offset) { } |
| 762 | 763 |
| 763 union { | 764 union { |
| 764 RawInstructions* raw_insns_; | 765 RawInstructions* raw_insns_; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 791 }; | 792 }; |
| 792 | 793 |
| 793 | 794 |
| 794 class AssemblyInstructionsWriter : public InstructionsWriter { | 795 class AssemblyInstructionsWriter : public InstructionsWriter { |
| 795 public: | 796 public: |
| 796 AssemblyInstructionsWriter(uint8_t** assembly_buffer, | 797 AssemblyInstructionsWriter(uint8_t** assembly_buffer, |
| 797 ReAlloc alloc, | 798 ReAlloc alloc, |
| 798 intptr_t initial_size) | 799 intptr_t initial_size) |
| 799 : InstructionsWriter(), | 800 : InstructionsWriter(), |
| 800 assembly_stream_(assembly_buffer, alloc, initial_size), | 801 assembly_stream_(assembly_buffer, alloc, initial_size), |
| 801 binary_size_(0) { | 802 text_size_(0), |
| 803 data_size_(0) { |
| 802 } | 804 } |
| 803 | 805 |
| 804 virtual void Write(); | 806 virtual void Write(); |
| 805 virtual intptr_t binary_size() { return binary_size_; } | 807 virtual intptr_t text_size() { return text_size_; } |
| 808 virtual intptr_t data_size() { return data_size_; } |
| 806 | 809 |
| 807 intptr_t AssemblySize() const { return assembly_stream_.bytes_written(); } | 810 intptr_t AssemblySize() const { return assembly_stream_.bytes_written(); } |
| 808 | 811 |
| 809 private: | 812 private: |
| 810 void WriteWordLiteral(uword value) { | 813 void WriteWordLiteralText(uword value) { |
| 811 // Padding is helpful for comparing the .S with --disassemble. | 814 // Padding is helpful for comparing the .S with --disassemble. |
| 812 #if defined(ARCH_IS_64_BIT) | 815 #if defined(ARCH_IS_64_BIT) |
| 813 assembly_stream_.Print(".quad 0x%0.16" Px "\n", value); | 816 assembly_stream_.Print(".quad 0x%0.16" Px "\n", value); |
| 814 #else | 817 #else |
| 815 assembly_stream_.Print(".long 0x%0.8" Px "\n", value); | 818 assembly_stream_.Print(".long 0x%0.8" Px "\n", value); |
| 816 #endif | 819 #endif |
| 817 binary_size_ += sizeof(value); | 820 text_size_ += sizeof(value); |
| 821 } |
| 822 |
| 823 void WriteWordLiteralData(uword value) { |
| 824 // Padding is helpful for comparing the .S with --disassemble. |
| 825 #if defined(ARCH_IS_64_BIT) |
| 826 assembly_stream_.Print(".quad 0x%0.16" Px "\n", value); |
| 827 #else |
| 828 assembly_stream_.Print(".long 0x%0.8" Px "\n", value); |
| 829 #endif |
| 830 data_size_ += sizeof(value); |
| 818 } | 831 } |
| 819 | 832 |
| 820 WriteStream assembly_stream_; | 833 WriteStream assembly_stream_; |
| 821 intptr_t binary_size_; | 834 intptr_t text_size_; |
| 835 intptr_t data_size_; |
| 822 | 836 |
| 823 DISALLOW_COPY_AND_ASSIGN(AssemblyInstructionsWriter); | 837 DISALLOW_COPY_AND_ASSIGN(AssemblyInstructionsWriter); |
| 824 }; | 838 }; |
| 825 | 839 |
| 826 | 840 |
| 827 class BlobInstructionsWriter : public InstructionsWriter { | 841 class BlobInstructionsWriter : public InstructionsWriter { |
| 828 public: | 842 public: |
| 829 BlobInstructionsWriter(uint8_t** instructions_blob_buffer, | 843 BlobInstructionsWriter(uint8_t** instructions_blob_buffer, |
| 830 uint8_t** rodata_blob_buffer, | 844 uint8_t** rodata_blob_buffer, |
| 831 ReAlloc alloc, | 845 ReAlloc alloc, |
| 832 intptr_t initial_size) | 846 intptr_t initial_size) |
| 833 : InstructionsWriter(), | 847 : InstructionsWriter(), |
| 834 instructions_blob_stream_(instructions_blob_buffer, alloc, initial_size), | 848 instructions_blob_stream_(instructions_blob_buffer, alloc, initial_size), |
| 835 rodata_blob_stream_(rodata_blob_buffer, alloc, initial_size) { | 849 rodata_blob_stream_(rodata_blob_buffer, alloc, initial_size) { |
| 836 } | 850 } |
| 837 | 851 |
| 838 virtual void Write(); | 852 virtual void Write(); |
| 839 virtual intptr_t binary_size() { | 853 virtual intptr_t text_size() { return InstructionsBlobSize(); } |
| 840 return InstructionsBlobSize() + RodataBlobSize(); | 854 virtual intptr_t data_size() { return RodataBlobSize(); } |
| 841 } | |
| 842 | 855 |
| 843 intptr_t InstructionsBlobSize() const { | 856 intptr_t InstructionsBlobSize() const { |
| 844 return instructions_blob_stream_.bytes_written(); | 857 return instructions_blob_stream_.bytes_written(); |
| 845 } | 858 } |
| 846 intptr_t RodataBlobSize() const { | 859 intptr_t RodataBlobSize() const { |
| 847 return rodata_blob_stream_.bytes_written(); | 860 return rodata_blob_stream_.bytes_written(); |
| 848 } | 861 } |
| 849 | 862 |
| 850 private: | 863 private: |
| 851 WriteStream instructions_blob_stream_; | 864 WriteStream instructions_blob_stream_; |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 private: | 1034 private: |
| 1022 SnapshotWriter* writer_; | 1035 SnapshotWriter* writer_; |
| 1023 bool as_references_; | 1036 bool as_references_; |
| 1024 | 1037 |
| 1025 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 1038 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
| 1026 }; | 1039 }; |
| 1027 | 1040 |
| 1028 } // namespace dart | 1041 } // namespace dart |
| 1029 | 1042 |
| 1030 #endif // VM_SNAPSHOT_H_ | 1043 #endif // VM_SNAPSHOT_H_ |
| OLD | NEW |