| 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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 154 kCore = 0, // Full snapshot of core libraries. No root library, no code. | 154 kCore = 0, // Full snapshot of core libraries. No root library, no code. |
| 155 kAppWithJIT, // Full snapshot of core libraries and application. Has some | 155 kAppWithJIT, // Full snapshot of core libraries and application. Has some |
| 156 // code, but may compile in the future because we haven't | 156 // code, but may compile in the future because we haven't |
| 157 // necessarily included code for every function or to | 157 // necessarily included code for every function or to |
| 158 // (de)optimize. | 158 // (de)optimize. |
| 159 kAppNoJIT, // Full snapshot of core libraries and application. Has | 159 kAppNoJIT, // Full snapshot of core libraries and application. Has |
| 160 // complete code for the application that never deopts. Will | 160 // complete code for the application that never deopts. Will |
| 161 // not compile in the future. | 161 // not compile in the future. |
| 162 kScript, // A partial snapshot of only the application script. | 162 kScript, // A partial snapshot of only the application script. |
| 163 kMessage, // A partial snapshot used only for isolate messaging. | 163 kMessage, // A partial snapshot used only for isolate messaging. |
| 164 kNone, // dart_bootstrap/gen_snapshot |
| 165 kInvalid |
| 164 }; | 166 }; |
| 165 | 167 |
| 166 static const int kHeaderSize = 2 * sizeof(int64_t); | 168 static const int kHeaderSize = 2 * sizeof(int64_t); |
| 167 static const int kLengthIndex = 0; | 169 static const int kLengthIndex = 0; |
| 168 static const int kSnapshotFlagIndex = 1; | 170 static const int kSnapshotFlagIndex = 1; |
| 169 | 171 |
| 170 static const Snapshot* SetupFromBuffer(const void* raw_memory); | 172 static const Snapshot* SetupFromBuffer(const void* raw_memory); |
| 171 | 173 |
| 172 // Getters. | 174 // Getters. |
| 173 const uint8_t* content() const { OPEN_ARRAY_START(uint8_t, uint8_t); } | 175 const uint8_t* content() const { OPEN_ARRAY_START(uint8_t, uint8_t); } |
| (...skipping 738 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 912 DISALLOW_COPY_AND_ASSIGN(InstructionsWriter); | 914 DISALLOW_COPY_AND_ASSIGN(InstructionsWriter); |
| 913 }; | 915 }; |
| 914 | 916 |
| 915 | 917 |
| 916 class AssemblyInstructionsWriter : public InstructionsWriter { | 918 class AssemblyInstructionsWriter : public InstructionsWriter { |
| 917 public: | 919 public: |
| 918 AssemblyInstructionsWriter(uint8_t** assembly_buffer, | 920 AssemblyInstructionsWriter(uint8_t** assembly_buffer, |
| 919 ReAlloc alloc, | 921 ReAlloc alloc, |
| 920 intptr_t initial_size) | 922 intptr_t initial_size) |
| 921 : InstructionsWriter(), | 923 : InstructionsWriter(), |
| 922 assembly_stream_(assembly_buffer, alloc, initial_size) { | 924 assembly_stream_(assembly_buffer, alloc, initial_size), |
| 925 binary_size_(0) { |
| 923 } | 926 } |
| 924 | 927 |
| 925 virtual void Write(); | 928 virtual void Write(); |
| 926 virtual intptr_t binary_size() { return binary_size_; } | 929 virtual intptr_t binary_size() { return binary_size_; } |
| 927 | 930 |
| 928 intptr_t AssemblySize() const { return assembly_stream_.bytes_written(); } | 931 intptr_t AssemblySize() const { return assembly_stream_.bytes_written(); } |
| 929 | 932 |
| 930 private: | 933 private: |
| 931 void WriteWordLiteral(uword value) { | 934 void WriteWordLiteral(uword value) { |
| 932 // Padding is helpful for comparing the .S with --disassemble. | 935 // Padding is helpful for comparing the .S with --disassemble. |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1172 ForwardList* forward_list_; | 1175 ForwardList* forward_list_; |
| 1173 InstructionsWriter* instructions_writer_; | 1176 InstructionsWriter* instructions_writer_; |
| 1174 Array& scripts_; | 1177 Array& scripts_; |
| 1175 Array& symbol_table_; | 1178 Array& symbol_table_; |
| 1176 bool vm_isolate_is_symbolic_; | 1179 bool vm_isolate_is_symbolic_; |
| 1177 | 1180 |
| 1178 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter); | 1181 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter); |
| 1179 }; | 1182 }; |
| 1180 | 1183 |
| 1181 | 1184 |
| 1182 class PrecompiledSnapshotWriter : public FullSnapshotWriter { | |
| 1183 public: | |
| 1184 PrecompiledSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, | |
| 1185 uint8_t** isolate_snapshot_buffer, | |
| 1186 ReAlloc alloc, | |
| 1187 InstructionsWriter* instructions_writer); | |
| 1188 ~PrecompiledSnapshotWriter(); | |
| 1189 }; | |
| 1190 | |
| 1191 | |
| 1192 class ScriptSnapshotWriter : public SnapshotWriter { | 1185 class ScriptSnapshotWriter : public SnapshotWriter { |
| 1193 public: | 1186 public: |
| 1194 static const intptr_t kInitialSize = 64 * KB; | 1187 static const intptr_t kInitialSize = 64 * KB; |
| 1195 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc); | 1188 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc); |
| 1196 ~ScriptSnapshotWriter() { } | 1189 ~ScriptSnapshotWriter() { } |
| 1197 | 1190 |
| 1198 // Writes a partial snapshot of the script. | 1191 // Writes a partial snapshot of the script. |
| 1199 void WriteScriptSnapshot(const Library& lib); | 1192 void WriteScriptSnapshot(const Library& lib); |
| 1200 | 1193 |
| 1201 private: | 1194 private: |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1234 private: | 1227 private: |
| 1235 SnapshotWriter* writer_; | 1228 SnapshotWriter* writer_; |
| 1236 bool as_references_; | 1229 bool as_references_; |
| 1237 | 1230 |
| 1238 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 1231 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
| 1239 }; | 1232 }; |
| 1240 | 1233 |
| 1241 } // namespace dart | 1234 } // namespace dart |
| 1242 | 1235 |
| 1243 #endif // VM_SNAPSHOT_H_ | 1236 #endif // VM_SNAPSHOT_H_ |
| OLD | NEW |