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 968 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
979 class SnapshotWriter : public BaseWriter { | 979 class SnapshotWriter : public BaseWriter { |
980 protected: | 980 protected: |
981 SnapshotWriter(Thread* thread, | 981 SnapshotWriter(Thread* thread, |
982 Snapshot::Kind kind, | 982 Snapshot::Kind kind, |
983 uint8_t** buffer, | 983 uint8_t** buffer, |
984 ReAlloc alloc, | 984 ReAlloc alloc, |
985 intptr_t initial_size, | 985 intptr_t initial_size, |
986 ForwardList* forward_list, | 986 ForwardList* forward_list, |
987 InstructionsWriter* instructions_writer, | 987 InstructionsWriter* instructions_writer, |
988 bool can_send_any_object, | 988 bool can_send_any_object, |
989 bool vm_isolate_is_symbolic); | 989 bool writing_vm_isolate); |
990 | 990 |
991 public: | 991 public: |
992 // Snapshot kind. | 992 // Snapshot kind. |
993 Snapshot::Kind kind() const { return kind_; } | 993 Snapshot::Kind kind() const { return kind_; } |
994 Thread* thread() const { return thread_; } | 994 Thread* thread() const { return thread_; } |
995 Zone* zone() const { return thread_->zone(); } | 995 Zone* zone() const { return thread_->zone(); } |
996 Isolate* isolate() const { return thread_->isolate(); } | 996 Isolate* isolate() const { return thread_->isolate(); } |
997 Heap* heap() const { return isolate()->heap(); } | 997 Heap* heap() const { return isolate()->heap(); } |
998 | 998 |
999 // Serialize an object into the buffer. | 999 // Serialize an object into the buffer. |
1000 void WriteObject(RawObject* raw); | 1000 void WriteObject(RawObject* raw); |
1001 | 1001 |
1002 uword GetObjectTags(RawObject* raw); | 1002 uword GetObjectTags(RawObject* raw); |
1003 | 1003 |
1004 Exceptions::ExceptionType exception_type() const { | 1004 Exceptions::ExceptionType exception_type() const { |
1005 return exception_type_; | 1005 return exception_type_; |
1006 } | 1006 } |
1007 void set_exception_type(Exceptions::ExceptionType type) { | 1007 void set_exception_type(Exceptions::ExceptionType type) { |
1008 exception_type_ = type; | 1008 exception_type_ = type; |
1009 } | 1009 } |
1010 const char* exception_msg() const { return exception_msg_; } | 1010 const char* exception_msg() const { return exception_msg_; } |
1011 void set_exception_msg(const char* msg) { | 1011 void set_exception_msg(const char* msg) { |
1012 exception_msg_ = msg; | 1012 exception_msg_ = msg; |
1013 } | 1013 } |
1014 bool can_send_any_object() const { return can_send_any_object_; } | 1014 bool can_send_any_object() const { return can_send_any_object_; } |
1015 bool vm_isolate_is_symbolic() const { return vm_isolate_is_symbolic_; } | 1015 bool writing_vm_isolate() const { return writing_vm_isolate_; } |
1016 void ThrowException(Exceptions::ExceptionType type, const char* msg); | 1016 void ThrowException(Exceptions::ExceptionType type, const char* msg); |
1017 | 1017 |
1018 // Write a version string for the snapshot. | 1018 // Write a version string for the snapshot. |
1019 void WriteVersion(); | 1019 void WriteVersion(); |
1020 | 1020 |
1021 static intptr_t FirstObjectId(); | 1021 static intptr_t FirstObjectId(); |
1022 | 1022 |
1023 int32_t GetInstructionsId(RawInstructions* instructions, RawCode* code) { | 1023 int32_t GetInstructionsId(RawInstructions* instructions, RawCode* code) { |
1024 return instructions_writer_->GetOffsetFor(instructions, code); | 1024 return instructions_writer_->GetOffsetFor(instructions, code); |
1025 } | 1025 } |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1058 void CheckForNativeFields(RawClass* cls); | 1058 void CheckForNativeFields(RawClass* cls); |
1059 void SetWriteException(Exceptions::ExceptionType type, const char* msg); | 1059 void SetWriteException(Exceptions::ExceptionType type, const char* msg); |
1060 void WriteInstance(RawObject* raw, | 1060 void WriteInstance(RawObject* raw, |
1061 RawClass* cls, | 1061 RawClass* cls, |
1062 intptr_t tags, | 1062 intptr_t tags, |
1063 intptr_t object_id, | 1063 intptr_t object_id, |
1064 bool as_reference); | 1064 bool as_reference); |
1065 bool AllowObjectsInDartLibrary(RawLibrary* library); | 1065 bool AllowObjectsInDartLibrary(RawLibrary* library); |
1066 intptr_t FindVmSnapshotObject(RawObject* rawobj); | 1066 intptr_t FindVmSnapshotObject(RawObject* rawobj); |
1067 | 1067 |
1068 void InitializeForwardList(ForwardList* forward_list) { | |
1069 ASSERT(forward_list_ == NULL); | |
1070 forward_list_ = forward_list; | |
1071 } | |
1072 void ResetForwardList() { | |
1073 ASSERT(forward_list_ != NULL); | |
1074 forward_list_ = NULL; | |
1075 } | |
1076 | |
1077 ObjectStore* object_store() const { return object_store_; } | 1068 ObjectStore* object_store() const { return object_store_; } |
1078 | 1069 |
1079 private: | 1070 private: |
1080 Thread* thread_; | 1071 Thread* thread_; |
1081 Snapshot::Kind kind_; | 1072 Snapshot::Kind kind_; |
1082 ObjectStore* object_store_; // Object store for common classes. | 1073 ObjectStore* object_store_; // Object store for common classes. |
1083 ClassTable* class_table_; // Class table for the class index to class lookup. | 1074 ClassTable* class_table_; // Class table for the class index to class lookup. |
1084 ForwardList* forward_list_; | 1075 ForwardList* forward_list_; |
1085 InstructionsWriter* instructions_writer_; | 1076 InstructionsWriter* instructions_writer_; |
1086 Exceptions::ExceptionType exception_type_; // Exception type. | 1077 Exceptions::ExceptionType exception_type_; // Exception type. |
1087 const char* exception_msg_; // Message associated with exception. | 1078 const char* exception_msg_; // Message associated with exception. |
1088 bool unmarked_objects_; // True if marked objects have been unmarked. | 1079 bool unmarked_objects_; // True if marked objects have been unmarked. |
1089 bool can_send_any_object_; // True if any Dart instance can be sent. | 1080 bool can_send_any_object_; // True if any Dart instance can be sent. |
1090 bool vm_isolate_is_symbolic_; | 1081 bool writing_vm_isolate_; |
1091 | 1082 |
1092 friend class FullSnapshotWriter; | 1083 friend class FullSnapshotWriter; |
1093 friend class RawArray; | 1084 friend class RawArray; |
1094 friend class RawClass; | 1085 friend class RawClass; |
1095 friend class RawClosureData; | 1086 friend class RawClosureData; |
1096 friend class RawCode; | 1087 friend class RawCode; |
1097 friend class RawContextScope; | 1088 friend class RawContextScope; |
1098 friend class RawExceptionHandlers; | 1089 friend class RawExceptionHandlers; |
1099 friend class RawField; | 1090 friend class RawField; |
1100 friend class RawFunction; | 1091 friend class RawFunction; |
(...skipping 20 matching lines...) Expand all Loading... |
1121 }; | 1112 }; |
1122 | 1113 |
1123 | 1114 |
1124 class FullSnapshotWriter { | 1115 class FullSnapshotWriter { |
1125 public: | 1116 public: |
1126 static const intptr_t kInitialSize = 64 * KB; | 1117 static const intptr_t kInitialSize = 64 * KB; |
1127 FullSnapshotWriter(Snapshot::Kind kind, | 1118 FullSnapshotWriter(Snapshot::Kind kind, |
1128 uint8_t** vm_isolate_snapshot_buffer, | 1119 uint8_t** vm_isolate_snapshot_buffer, |
1129 uint8_t** isolate_snapshot_buffer, | 1120 uint8_t** isolate_snapshot_buffer, |
1130 ReAlloc alloc, | 1121 ReAlloc alloc, |
1131 InstructionsWriter* instructions_writer, | 1122 InstructionsWriter* instructions_writer); |
1132 bool vm_isolate_is_symbolic); | |
1133 ~FullSnapshotWriter(); | 1123 ~FullSnapshotWriter(); |
1134 | 1124 |
1135 uint8_t** vm_isolate_snapshot_buffer() { | 1125 uint8_t** vm_isolate_snapshot_buffer() { |
1136 return vm_isolate_snapshot_buffer_; | 1126 return vm_isolate_snapshot_buffer_; |
1137 } | 1127 } |
1138 | 1128 |
1139 uint8_t** isolate_snapshot_buffer() { | 1129 uint8_t** isolate_snapshot_buffer() { |
1140 return isolate_snapshot_buffer_; | 1130 return isolate_snapshot_buffer_; |
1141 } | 1131 } |
1142 | 1132 |
(...skipping 22 matching lines...) Expand all Loading... |
1165 Thread* thread_; | 1155 Thread* thread_; |
1166 Snapshot::Kind kind_; | 1156 Snapshot::Kind kind_; |
1167 uint8_t** vm_isolate_snapshot_buffer_; | 1157 uint8_t** vm_isolate_snapshot_buffer_; |
1168 uint8_t** isolate_snapshot_buffer_; | 1158 uint8_t** isolate_snapshot_buffer_; |
1169 ReAlloc alloc_; | 1159 ReAlloc alloc_; |
1170 intptr_t vm_isolate_snapshot_size_; | 1160 intptr_t vm_isolate_snapshot_size_; |
1171 intptr_t isolate_snapshot_size_; | 1161 intptr_t isolate_snapshot_size_; |
1172 ForwardList* forward_list_; | 1162 ForwardList* forward_list_; |
1173 InstructionsWriter* instructions_writer_; | 1163 InstructionsWriter* instructions_writer_; |
1174 Array& scripts_; | 1164 Array& scripts_; |
1175 Array& symbol_table_; | 1165 Array& saved_symbol_table_; |
1176 bool vm_isolate_is_symbolic_; | 1166 Array& new_vm_symbol_table_; |
1177 | 1167 |
1178 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter); | 1168 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter); |
1179 }; | 1169 }; |
1180 | 1170 |
1181 | 1171 |
1182 class PrecompiledSnapshotWriter : public FullSnapshotWriter { | 1172 class PrecompiledSnapshotWriter : public FullSnapshotWriter { |
1183 public: | 1173 public: |
1184 PrecompiledSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, | 1174 PrecompiledSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, |
1185 uint8_t** isolate_snapshot_buffer, | 1175 uint8_t** isolate_snapshot_buffer, |
1186 ReAlloc alloc, | 1176 ReAlloc alloc, |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1234 private: | 1224 private: |
1235 SnapshotWriter* writer_; | 1225 SnapshotWriter* writer_; |
1236 bool as_references_; | 1226 bool as_references_; |
1237 | 1227 |
1238 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); | 1228 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); |
1239 }; | 1229 }; |
1240 | 1230 |
1241 } // namespace dart | 1231 } // namespace dart |
1242 | 1232 |
1243 #endif // VM_SNAPSHOT_H_ | 1233 #endif // VM_SNAPSHOT_H_ |
OLD | NEW |