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 |
164 }; | 165 }; |
165 | 166 |
166 static const int kHeaderSize = 2 * sizeof(int64_t); | 167 static const int kHeaderSize = 2 * sizeof(int64_t); |
167 static const int kLengthIndex = 0; | 168 static const int kLengthIndex = 0; |
168 static const int kSnapshotFlagIndex = 1; | 169 static const int kSnapshotFlagIndex = 1; |
169 | 170 |
170 static const Snapshot* SetupFromBuffer(const void* raw_memory); | 171 static const Snapshot* SetupFromBuffer(const void* raw_memory); |
171 | 172 |
172 // Getters. | 173 // Getters. |
173 const uint8_t* content() const { OPEN_ARRAY_START(uint8_t, uint8_t); } | 174 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); | 913 DISALLOW_COPY_AND_ASSIGN(InstructionsWriter); |
913 }; | 914 }; |
914 | 915 |
915 | 916 |
916 class AssemblyInstructionsWriter : public InstructionsWriter { | 917 class AssemblyInstructionsWriter : public InstructionsWriter { |
917 public: | 918 public: |
918 AssemblyInstructionsWriter(uint8_t** assembly_buffer, | 919 AssemblyInstructionsWriter(uint8_t** assembly_buffer, |
919 ReAlloc alloc, | 920 ReAlloc alloc, |
920 intptr_t initial_size) | 921 intptr_t initial_size) |
921 : InstructionsWriter(), | 922 : InstructionsWriter(), |
922 assembly_stream_(assembly_buffer, alloc, initial_size) { | 923 assembly_stream_(assembly_buffer, alloc, initial_size), |
| 924 binary_size_(0) { |
923 } | 925 } |
924 | 926 |
925 virtual void Write(); | 927 virtual void Write(); |
926 virtual intptr_t binary_size() { return binary_size_; } | 928 virtual intptr_t binary_size() { return binary_size_; } |
927 | 929 |
928 intptr_t AssemblySize() const { return assembly_stream_.bytes_written(); } | 930 intptr_t AssemblySize() const { return assembly_stream_.bytes_written(); } |
929 | 931 |
930 private: | 932 private: |
931 void WriteWordLiteral(uword value) { | 933 void WriteWordLiteral(uword value) { |
932 // Padding is helpful for comparing the .S with --disassemble. | 934 // 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_; | 1174 ForwardList* forward_list_; |
1173 InstructionsWriter* instructions_writer_; | 1175 InstructionsWriter* instructions_writer_; |
1174 Array& scripts_; | 1176 Array& scripts_; |
1175 Array& symbol_table_; | 1177 Array& symbol_table_; |
1176 bool vm_isolate_is_symbolic_; | 1178 bool vm_isolate_is_symbolic_; |
1177 | 1179 |
1178 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter); | 1180 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter); |
1179 }; | 1181 }; |
1180 | 1182 |
1181 | 1183 |
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 { | 1184 class ScriptSnapshotWriter : public SnapshotWriter { |
1193 public: | 1185 public: |
1194 static const intptr_t kInitialSize = 64 * KB; | 1186 static const intptr_t kInitialSize = 64 * KB; |
1195 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc); | 1187 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc); |
1196 ~ScriptSnapshotWriter() { } | 1188 ~ScriptSnapshotWriter() { } |
1197 | 1189 |
1198 // Writes a partial snapshot of the script. | 1190 // Writes a partial snapshot of the script. |
1199 void WriteScriptSnapshot(const Library& lib); | 1191 void WriteScriptSnapshot(const Library& lib); |
1200 | 1192 |
1201 private: | 1193 private: |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 private: | 1226 private: |
1235 SnapshotWriter* writer_; | 1227 SnapshotWriter* writer_; |
1236 bool as_references_; | 1228 bool as_references_; |
1237 | 1229 |
1238 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 1230 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
1239 }; | 1231 }; |
1240 | 1232 |
1241 } // namespace dart | 1233 } // namespace dart |
1242 | 1234 |
1243 #endif // VM_SNAPSHOT_H_ | 1235 #endif // VM_SNAPSHOT_H_ |
OLD | NEW |