Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(260)

Side by Side Diff: runtime/vm/snapshot.h

Issue 1944213002: Support for taking full snapshots from 'dart', not just 'dart_bootstrap'. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 971 matching lines...) Expand 10 before | Expand all | Expand 10 after
982 class SnapshotWriter : public BaseWriter { 982 class SnapshotWriter : public BaseWriter {
983 protected: 983 protected:
984 SnapshotWriter(Thread* thread, 984 SnapshotWriter(Thread* thread,
985 Snapshot::Kind kind, 985 Snapshot::Kind kind,
986 uint8_t** buffer, 986 uint8_t** buffer,
987 ReAlloc alloc, 987 ReAlloc alloc,
988 intptr_t initial_size, 988 intptr_t initial_size,
989 ForwardList* forward_list, 989 ForwardList* forward_list,
990 InstructionsWriter* instructions_writer, 990 InstructionsWriter* instructions_writer,
991 bool can_send_any_object, 991 bool can_send_any_object,
992 bool vm_isolate_is_symbolic); 992 bool writing_vm_isolate);
993 993
994 public: 994 public:
995 // Snapshot kind. 995 // Snapshot kind.
996 Snapshot::Kind kind() const { return kind_; } 996 Snapshot::Kind kind() const { return kind_; }
997 Thread* thread() const { return thread_; } 997 Thread* thread() const { return thread_; }
998 Zone* zone() const { return thread_->zone(); } 998 Zone* zone() const { return thread_->zone(); }
999 Isolate* isolate() const { return thread_->isolate(); } 999 Isolate* isolate() const { return thread_->isolate(); }
1000 Heap* heap() const { return isolate()->heap(); } 1000 Heap* heap() const { return isolate()->heap(); }
1001 1001
1002 // Serialize an object into the buffer. 1002 // Serialize an object into the buffer.
1003 void WriteObject(RawObject* raw); 1003 void WriteObject(RawObject* raw);
1004 1004
1005 uword GetObjectTags(RawObject* raw); 1005 uword GetObjectTags(RawObject* raw);
1006 1006
1007 Exceptions::ExceptionType exception_type() const { 1007 Exceptions::ExceptionType exception_type() const {
1008 return exception_type_; 1008 return exception_type_;
1009 } 1009 }
1010 void set_exception_type(Exceptions::ExceptionType type) { 1010 void set_exception_type(Exceptions::ExceptionType type) {
1011 exception_type_ = type; 1011 exception_type_ = type;
1012 } 1012 }
1013 const char* exception_msg() const { return exception_msg_; } 1013 const char* exception_msg() const { return exception_msg_; }
1014 void set_exception_msg(const char* msg) { 1014 void set_exception_msg(const char* msg) {
1015 exception_msg_ = msg; 1015 exception_msg_ = msg;
1016 } 1016 }
1017 bool can_send_any_object() const { return can_send_any_object_; } 1017 bool can_send_any_object() const { return can_send_any_object_; }
1018 bool vm_isolate_is_symbolic() const { return vm_isolate_is_symbolic_; } 1018 bool writing_vm_isolate() const { return writing_vm_isolate_; }
1019 void ThrowException(Exceptions::ExceptionType type, const char* msg); 1019 void ThrowException(Exceptions::ExceptionType type, const char* msg);
1020 1020
1021 // Write a version string for the snapshot. 1021 // Write a version string for the snapshot.
1022 void WriteVersion(); 1022 void WriteVersion();
1023 1023
1024 static intptr_t FirstObjectId(); 1024 static intptr_t FirstObjectId();
1025 1025
1026 int32_t GetInstructionsId(RawInstructions* instructions, RawCode* code) { 1026 int32_t GetInstructionsId(RawInstructions* instructions, RawCode* code) {
1027 return instructions_writer_->GetOffsetFor(instructions, code); 1027 return instructions_writer_->GetOffsetFor(instructions, code);
1028 } 1028 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1061 void CheckForNativeFields(RawClass* cls); 1061 void CheckForNativeFields(RawClass* cls);
1062 void SetWriteException(Exceptions::ExceptionType type, const char* msg); 1062 void SetWriteException(Exceptions::ExceptionType type, const char* msg);
1063 void WriteInstance(RawObject* raw, 1063 void WriteInstance(RawObject* raw,
1064 RawClass* cls, 1064 RawClass* cls,
1065 intptr_t tags, 1065 intptr_t tags,
1066 intptr_t object_id, 1066 intptr_t object_id,
1067 bool as_reference); 1067 bool as_reference);
1068 bool AllowObjectsInDartLibrary(RawLibrary* library); 1068 bool AllowObjectsInDartLibrary(RawLibrary* library);
1069 intptr_t FindVmSnapshotObject(RawObject* rawobj); 1069 intptr_t FindVmSnapshotObject(RawObject* rawobj);
1070 1070
1071 void InitializeForwardList(ForwardList* forward_list) {
1072 ASSERT(forward_list_ == NULL);
1073 forward_list_ = forward_list;
1074 }
1075 void ResetForwardList() {
1076 ASSERT(forward_list_ != NULL);
1077 forward_list_ = NULL;
1078 }
1079
1080 ObjectStore* object_store() const { return object_store_; } 1071 ObjectStore* object_store() const { return object_store_; }
1081 1072
1082 private: 1073 private:
1083 Thread* thread_; 1074 Thread* thread_;
1084 Snapshot::Kind kind_; 1075 Snapshot::Kind kind_;
1085 ObjectStore* object_store_; // Object store for common classes. 1076 ObjectStore* object_store_; // Object store for common classes.
1086 ClassTable* class_table_; // Class table for the class index to class lookup. 1077 ClassTable* class_table_; // Class table for the class index to class lookup.
1087 ForwardList* forward_list_; 1078 ForwardList* forward_list_;
1088 InstructionsWriter* instructions_writer_; 1079 InstructionsWriter* instructions_writer_;
1089 Exceptions::ExceptionType exception_type_; // Exception type. 1080 Exceptions::ExceptionType exception_type_; // Exception type.
1090 const char* exception_msg_; // Message associated with exception. 1081 const char* exception_msg_; // Message associated with exception.
1091 bool unmarked_objects_; // True if marked objects have been unmarked. 1082 bool unmarked_objects_; // True if marked objects have been unmarked.
1092 bool can_send_any_object_; // True if any Dart instance can be sent. 1083 bool can_send_any_object_; // True if any Dart instance can be sent.
1093 bool vm_isolate_is_symbolic_; 1084 bool writing_vm_isolate_;
1094 1085
1095 friend class FullSnapshotWriter; 1086 friend class FullSnapshotWriter;
1096 friend class RawArray; 1087 friend class RawArray;
1097 friend class RawClass; 1088 friend class RawClass;
1098 friend class RawClosureData; 1089 friend class RawClosureData;
1099 friend class RawCode; 1090 friend class RawCode;
1100 friend class RawContextScope; 1091 friend class RawContextScope;
1101 friend class RawExceptionHandlers; 1092 friend class RawExceptionHandlers;
1102 friend class RawField; 1093 friend class RawField;
1103 friend class RawFunction; 1094 friend class RawFunction;
(...skipping 20 matching lines...) Expand all
1124 }; 1115 };
1125 1116
1126 1117
1127 class FullSnapshotWriter { 1118 class FullSnapshotWriter {
1128 public: 1119 public:
1129 static const intptr_t kInitialSize = 64 * KB; 1120 static const intptr_t kInitialSize = 64 * KB;
1130 FullSnapshotWriter(Snapshot::Kind kind, 1121 FullSnapshotWriter(Snapshot::Kind kind,
1131 uint8_t** vm_isolate_snapshot_buffer, 1122 uint8_t** vm_isolate_snapshot_buffer,
1132 uint8_t** isolate_snapshot_buffer, 1123 uint8_t** isolate_snapshot_buffer,
1133 ReAlloc alloc, 1124 ReAlloc alloc,
1134 InstructionsWriter* instructions_writer, 1125 InstructionsWriter* instructions_writer);
1135 bool vm_isolate_is_symbolic);
1136 ~FullSnapshotWriter(); 1126 ~FullSnapshotWriter();
1137 1127
1138 uint8_t** vm_isolate_snapshot_buffer() { 1128 uint8_t** vm_isolate_snapshot_buffer() {
1139 return vm_isolate_snapshot_buffer_; 1129 return vm_isolate_snapshot_buffer_;
1140 } 1130 }
1141 1131
1142 uint8_t** isolate_snapshot_buffer() { 1132 uint8_t** isolate_snapshot_buffer() {
1143 return isolate_snapshot_buffer_; 1133 return isolate_snapshot_buffer_;
1144 } 1134 }
1145 1135
(...skipping 22 matching lines...) Expand all
1168 Thread* thread_; 1158 Thread* thread_;
1169 Snapshot::Kind kind_; 1159 Snapshot::Kind kind_;
1170 uint8_t** vm_isolate_snapshot_buffer_; 1160 uint8_t** vm_isolate_snapshot_buffer_;
1171 uint8_t** isolate_snapshot_buffer_; 1161 uint8_t** isolate_snapshot_buffer_;
1172 ReAlloc alloc_; 1162 ReAlloc alloc_;
1173 intptr_t vm_isolate_snapshot_size_; 1163 intptr_t vm_isolate_snapshot_size_;
1174 intptr_t isolate_snapshot_size_; 1164 intptr_t isolate_snapshot_size_;
1175 ForwardList* forward_list_; 1165 ForwardList* forward_list_;
1176 InstructionsWriter* instructions_writer_; 1166 InstructionsWriter* instructions_writer_;
1177 Array& scripts_; 1167 Array& scripts_;
1178 Array& symbol_table_; 1168 Array& saved_symbol_table_;
1179 bool vm_isolate_is_symbolic_; 1169 Array& new_vm_symbol_table_;
1180 1170
1181 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter); 1171 DISALLOW_COPY_AND_ASSIGN(FullSnapshotWriter);
1182 }; 1172 };
1183 1173
1184 1174
1185 class ScriptSnapshotWriter : public SnapshotWriter { 1175 class ScriptSnapshotWriter : public SnapshotWriter {
1186 public: 1176 public:
1187 static const intptr_t kInitialSize = 64 * KB; 1177 static const intptr_t kInitialSize = 64 * KB;
1188 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc); 1178 ScriptSnapshotWriter(uint8_t** buffer, ReAlloc alloc);
1189 ~ScriptSnapshotWriter() { } 1179 ~ScriptSnapshotWriter() { }
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1227 private: 1217 private:
1228 SnapshotWriter* writer_; 1218 SnapshotWriter* writer_;
1229 bool as_references_; 1219 bool as_references_;
1230 1220
1231 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor); 1221 DISALLOW_COPY_AND_ASSIGN(SnapshotWriterVisitor);
1232 }; 1222 };
1233 1223
1234 } // namespace dart 1224 } // namespace dart
1235 1225
1236 #endif // VM_SNAPSHOT_H_ 1226 #endif // VM_SNAPSHOT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698