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 #include "vm/bigint_operations.h" | 5 #include "vm/bigint_operations.h" |
6 #include "vm/object.h" | 6 #include "vm/object.h" |
7 #include "vm/object_store.h" | 7 #include "vm/object_store.h" |
8 #include "vm/snapshot.h" | 8 #include "vm/snapshot.h" |
9 #include "vm/symbols.h" | 9 #include "vm/symbols.h" |
10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
(...skipping 993 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1004 | 1004 |
1005 // Set the object tags. | 1005 // Set the object tags. |
1006 library.set_tags(tags); | 1006 library.set_tags(tags); |
1007 | 1007 |
1008 // Set all non object fields. | 1008 // Set all non object fields. |
1009 library.raw_ptr()->index_ = reader->ReadIntptrValue(); | 1009 library.raw_ptr()->index_ = reader->ReadIntptrValue(); |
1010 library.raw_ptr()->num_imports_ = reader->ReadIntptrValue(); | 1010 library.raw_ptr()->num_imports_ = reader->ReadIntptrValue(); |
1011 library.raw_ptr()->num_anonymous_ = reader->ReadIntptrValue(); | 1011 library.raw_ptr()->num_anonymous_ = reader->ReadIntptrValue(); |
1012 library.raw_ptr()->corelib_imported_ = reader->Read<bool>(); | 1012 library.raw_ptr()->corelib_imported_ = reader->Read<bool>(); |
1013 library.raw_ptr()->debuggable_ = reader->Read<bool>(); | 1013 library.raw_ptr()->debuggable_ = reader->Read<bool>(); |
| 1014 library.raw_ptr()->deferred_load_ = reader->Read<bool>(); |
1014 library.raw_ptr()->load_state_ = reader->Read<int8_t>(); | 1015 library.raw_ptr()->load_state_ = reader->Read<int8_t>(); |
1015 // The native resolver is not serialized. | 1016 // The native resolver is not serialized. |
1016 Dart_NativeEntryResolver resolver = | 1017 Dart_NativeEntryResolver resolver = |
1017 reader->Read<Dart_NativeEntryResolver>(); | 1018 reader->Read<Dart_NativeEntryResolver>(); |
1018 ASSERT(resolver == NULL); | 1019 ASSERT(resolver == NULL); |
1019 library.set_native_entry_resolver(resolver); | 1020 library.set_native_entry_resolver(resolver); |
1020 // The cache of loaded scripts is not serialized. | 1021 // The cache of loaded scripts is not serialized. |
1021 library.raw_ptr()->loaded_scripts_ = Array::null(); | 1022 library.raw_ptr()->loaded_scripts_ = Array::null(); |
1022 | 1023 |
1023 // Set all the object fields. | 1024 // Set all the object fields. |
(...skipping 29 matching lines...) Expand all Loading... |
1053 ASSERT(kind != Snapshot::kFull); | 1054 ASSERT(kind != Snapshot::kFull); |
1054 // Write out library URL so that it can be looked up when reading. | 1055 // Write out library URL so that it can be looked up when reading. |
1055 writer->WriteObjectImpl(ptr()->url_); | 1056 writer->WriteObjectImpl(ptr()->url_); |
1056 } else { | 1057 } else { |
1057 // Write out all non object fields. | 1058 // Write out all non object fields. |
1058 writer->WriteIntptrValue(ptr()->index_); | 1059 writer->WriteIntptrValue(ptr()->index_); |
1059 writer->WriteIntptrValue(ptr()->num_imports_); | 1060 writer->WriteIntptrValue(ptr()->num_imports_); |
1060 writer->WriteIntptrValue(ptr()->num_anonymous_); | 1061 writer->WriteIntptrValue(ptr()->num_anonymous_); |
1061 writer->Write<bool>(ptr()->corelib_imported_); | 1062 writer->Write<bool>(ptr()->corelib_imported_); |
1062 writer->Write<bool>(ptr()->debuggable_); | 1063 writer->Write<bool>(ptr()->debuggable_); |
| 1064 writer->Write<bool>(ptr()->deferred_load_); |
1063 writer->Write<int8_t>(ptr()->load_state_); | 1065 writer->Write<int8_t>(ptr()->load_state_); |
1064 // We do not serialize the native resolver over, this needs to be explicitly | 1066 // We do not serialize the native resolver over, this needs to be explicitly |
1065 // set after deserialization. | 1067 // set after deserialization. |
1066 writer->Write<Dart_NativeEntryResolver>(NULL); | 1068 writer->Write<Dart_NativeEntryResolver>(NULL); |
1067 // We do not write the loaded_scripts_ cache to the snapshot. It gets | 1069 // We do not write the loaded_scripts_ cache to the snapshot. It gets |
1068 // set to NULL when reading the library from the snapshot, and will | 1070 // set to NULL when reading the library from the snapshot, and will |
1069 // be rebuilt lazily. | 1071 // be rebuilt lazily. |
1070 | 1072 |
1071 // Write out all the object pointer fields. | 1073 // Write out all the object pointer fields. |
1072 SnapshotWriterVisitor visitor(writer); | 1074 SnapshotWriterVisitor visitor(writer); |
(...skipping 14 matching lines...) Expand all Loading... |
1087 // Allocate library prefix object. | 1089 // Allocate library prefix object. |
1088 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( | 1090 LibraryPrefix& prefix = LibraryPrefix::ZoneHandle( |
1089 reader->isolate(), NEW_OBJECT(LibraryPrefix)); | 1091 reader->isolate(), NEW_OBJECT(LibraryPrefix)); |
1090 reader->AddBackRef(object_id, &prefix, kIsDeserialized); | 1092 reader->AddBackRef(object_id, &prefix, kIsDeserialized); |
1091 | 1093 |
1092 // Set the object tags. | 1094 // Set the object tags. |
1093 prefix.set_tags(tags); | 1095 prefix.set_tags(tags); |
1094 | 1096 |
1095 // Set all non object fields. | 1097 // Set all non object fields. |
1096 prefix.raw_ptr()->num_imports_ = reader->ReadIntptrValue(); | 1098 prefix.raw_ptr()->num_imports_ = reader->ReadIntptrValue(); |
| 1099 prefix.raw_ptr()->is_deferred_load_ = reader->Read<bool>(); |
| 1100 prefix.raw_ptr()->is_loaded_ = reader->Read<bool>(); |
1097 | 1101 |
1098 // Set all the object fields. | 1102 // Set all the object fields. |
1099 // TODO(5411462): Need to assert No GC can happen here, even though | 1103 // TODO(5411462): Need to assert No GC can happen here, even though |
1100 // allocations may happen. | 1104 // allocations may happen. |
1101 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); | 1105 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); |
1102 for (intptr_t i = 0; i <= num_flds; i++) { | 1106 for (intptr_t i = 0; i <= num_flds; i++) { |
1103 *(prefix.raw()->from() + i) = reader->ReadObjectRef(); | 1107 *(prefix.raw()->from() + i) = reader->ReadObjectRef(); |
1104 } | 1108 } |
1105 | 1109 |
1106 return prefix.raw(); | 1110 return prefix.raw(); |
1107 } | 1111 } |
1108 | 1112 |
1109 | 1113 |
1110 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, | 1114 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, |
1111 intptr_t object_id, | 1115 intptr_t object_id, |
1112 Snapshot::Kind kind) { | 1116 Snapshot::Kind kind) { |
1113 ASSERT(writer != NULL); | 1117 ASSERT(writer != NULL); |
1114 ASSERT(((kind == Snapshot::kScript) && | 1118 ASSERT(((kind == Snapshot::kScript) && |
1115 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | 1119 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || |
1116 (kind == Snapshot::kFull)); | 1120 (kind == Snapshot::kFull)); |
1117 | 1121 |
1118 // Write out the serialization header value for this object. | 1122 // Write out the serialization header value for this object. |
1119 writer->WriteInlinedObjectHeader(object_id); | 1123 writer->WriteInlinedObjectHeader(object_id); |
1120 | 1124 |
1121 // Write out the class and tags information. | 1125 // Write out the class and tags information. |
1122 writer->WriteVMIsolateObject(kLibraryPrefixCid); | 1126 writer->WriteIndexedObject(kLibraryPrefixCid); |
1123 writer->WriteIntptrValue(writer->GetObjectTags(this)); | 1127 writer->WriteIntptrValue(writer->GetObjectTags(this)); |
1124 | 1128 |
1125 // Write out all non object fields. | 1129 // Write out all non object fields. |
1126 writer->WriteIntptrValue(ptr()->num_imports_); | 1130 writer->WriteIntptrValue(ptr()->num_imports_); |
| 1131 writer->Write<bool>(ptr()->is_deferred_load_); |
| 1132 writer->Write<bool>(ptr()->is_loaded_); |
1127 | 1133 |
1128 // Write out all the object pointer fields. | 1134 // Write out all the object pointer fields. |
1129 SnapshotWriterVisitor visitor(writer); | 1135 SnapshotWriterVisitor visitor(writer); |
1130 visitor.VisitPointers(from(), to()); | 1136 visitor.VisitPointers(from(), to()); |
1131 } | 1137 } |
1132 | 1138 |
1133 | 1139 |
1134 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader, | 1140 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader, |
1135 intptr_t object_id, | 1141 intptr_t object_id, |
1136 intptr_t tags, | 1142 intptr_t tags, |
(...skipping 1538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2675 // We do not allow objects with native fields in an isolate message. | 2681 // We do not allow objects with native fields in an isolate message. |
2676 writer->SetWriteException(Exceptions::kArgument, | 2682 writer->SetWriteException(Exceptions::kArgument, |
2677 "Illegal argument in isolate message" | 2683 "Illegal argument in isolate message" |
2678 " : (object is a MirrorReference)"); | 2684 " : (object is a MirrorReference)"); |
2679 } else { | 2685 } else { |
2680 UNREACHABLE(); | 2686 UNREACHABLE(); |
2681 } | 2687 } |
2682 } | 2688 } |
2683 | 2689 |
2684 } // namespace dart | 2690 } // namespace dart |
OLD | NEW |