Chromium Code Reviews| 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/native_entry.h" | 5 #include "vm/native_entry.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/stub_code.h" | 9 #include "vm/stub_code.h" |
| 10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
| (...skipping 1089 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1100 library.StoreNonPointer(&library.raw_ptr()->debuggable_, | 1100 library.StoreNonPointer(&library.raw_ptr()->debuggable_, |
| 1101 reader->Read<bool>()); | 1101 reader->Read<bool>()); |
| 1102 if (kind == Snapshot::kFull) { | 1102 if (kind == Snapshot::kFull) { |
| 1103 is_in_fullsnapshot = true; | 1103 is_in_fullsnapshot = true; |
| 1104 } | 1104 } |
| 1105 library.StoreNonPointer(&library.raw_ptr()->is_in_fullsnapshot_, | 1105 library.StoreNonPointer(&library.raw_ptr()->is_in_fullsnapshot_, |
| 1106 is_in_fullsnapshot); | 1106 is_in_fullsnapshot); |
| 1107 // The native resolver and symbolizer are not serialized. | 1107 // The native resolver and symbolizer are not serialized. |
| 1108 library.set_native_entry_resolver(NULL); | 1108 library.set_native_entry_resolver(NULL); |
| 1109 library.set_native_entry_symbol_resolver(NULL); | 1109 library.set_native_entry_symbol_resolver(NULL); |
| 1110 // The cache of loaded scripts is not serialized. | |
| 1111 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null()); | |
| 1112 | 1110 |
| 1113 // Set all the object fields. | 1111 // Set all the object fields. |
| 1114 // TODO(5411462): Need to assert No GC can happen here, even though | 1112 // TODO(5411462): Need to assert No GC can happen here, even though |
| 1115 // allocations may happen. | 1113 // allocations may happen. |
| 1116 RawObject** toobj = (kind == Snapshot::kFull) ? | 1114 intptr_t num_flds = (library.raw()->to_snapshot() - library.raw()->from()); |
| 1117 library.raw()->to() : library.raw()->to_snapshot(); | |
| 1118 intptr_t num_flds = (toobj - library.raw()->from()); | |
| 1119 for (intptr_t i = 0; i <= num_flds; i++) { | 1115 for (intptr_t i = 0; i <= num_flds; i++) { |
| 1120 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 1116 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); |
| 1121 library.StorePointer((library.raw()->from() + i), | 1117 library.StorePointer((library.raw()->from() + i), |
| 1122 reader->PassiveObjectHandle()->raw()); | 1118 reader->PassiveObjectHandle()->raw()); |
| 1123 } | 1119 } |
| 1120 // Initialize cache of resolved names. | |
| 1121 const intptr_t kInitialNameCacheSize = 64; | |
| 1124 if (kind != Snapshot::kFull) { | 1122 if (kind != Snapshot::kFull) { |
| 1125 // The cache of resolved names in library scope is not serialized. | 1123 // The cache of resolved names in library scope is not serialized. |
| 1126 const intptr_t kInitialNameCacheSize = 64; | |
| 1127 library.InitResolvedNamesCache(kInitialNameCacheSize); | 1124 library.InitResolvedNamesCache(kInitialNameCacheSize); |
| 1128 library.Register(); | 1125 library.Register(); |
| 1126 } else { | |
| 1127 library.InitResolvedNamesCache(kInitialNameCacheSize, reader); | |
| 1129 } | 1128 } |
| 1129 // Initialize cache of loaded scripts. | |
| 1130 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null()); | |
| 1130 } | 1131 } |
| 1131 return library.raw(); | 1132 return library.raw(); |
| 1132 } | 1133 } |
| 1133 | 1134 |
| 1134 | 1135 |
| 1135 void RawLibrary::WriteTo(SnapshotWriter* writer, | 1136 void RawLibrary::WriteTo(SnapshotWriter* writer, |
| 1136 intptr_t object_id, | 1137 intptr_t object_id, |
| 1137 Snapshot::Kind kind, | 1138 Snapshot::Kind kind, |
| 1138 bool as_reference) { | 1139 bool as_reference) { |
| 1139 ASSERT(writer != NULL); | 1140 ASSERT(writer != NULL); |
| (...skipping 18 matching lines...) Expand all Loading... | |
| 1158 ASSERT((kind == Snapshot::kFull) || !ptr()->is_in_fullsnapshot_); | 1159 ASSERT((kind == Snapshot::kFull) || !ptr()->is_in_fullsnapshot_); |
| 1159 // Write out all non object fields. | 1160 // Write out all non object fields. |
| 1160 writer->WriteClassIDValue(ptr()->index_); | 1161 writer->WriteClassIDValue(ptr()->index_); |
| 1161 writer->Write<uint16_t>(ptr()->num_imports_); | 1162 writer->Write<uint16_t>(ptr()->num_imports_); |
| 1162 writer->Write<int8_t>(ptr()->load_state_); | 1163 writer->Write<int8_t>(ptr()->load_state_); |
| 1163 writer->Write<bool>(ptr()->corelib_imported_); | 1164 writer->Write<bool>(ptr()->corelib_imported_); |
| 1164 writer->Write<bool>(ptr()->is_dart_scheme_); | 1165 writer->Write<bool>(ptr()->is_dart_scheme_); |
| 1165 writer->Write<bool>(ptr()->debuggable_); | 1166 writer->Write<bool>(ptr()->debuggable_); |
| 1166 // We do not serialize the native resolver or symbolizer. These need to be | 1167 // We do not serialize the native resolver or symbolizer. These need to be |
| 1167 // explicitly set after deserialization. | 1168 // explicitly set after deserialization. |
| 1168 // We do not write the loaded_scripts_ cache to the snapshot. It gets | |
| 1169 // set to NULL when reading the library from the snapshot, and will | |
| 1170 // be rebuilt lazily. | |
| 1171 | 1169 |
| 1170 // We do not write the loaded_scripts_ and resolved_names_ caches to the | |
|
hausner
2016/01/13 23:58:11
Another option could be to call Library::Invalidat
siva
2016/01/14 00:03:31
True, I tried that initially but this piece of cod
| |
| 1171 // snapshot. They get initialized when reading the library from the | |
| 1172 // snapshot and will be rebuilt lazily. | |
| 1172 // Write out all the object pointer fields. | 1173 // Write out all the object pointer fields. |
| 1173 RawObject** toobj = (kind == Snapshot::kFull) ? to() : to_snapshot(); | |
| 1174 SnapshotWriterVisitor visitor(writer, kAsReference); | 1174 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 1175 visitor.VisitPointers(from(), toobj); | 1175 visitor.VisitPointers(from(), to_snapshot()); |
| 1176 } | 1176 } |
| 1177 } | 1177 } |
| 1178 | 1178 |
| 1179 | 1179 |
| 1180 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, | 1180 RawLibraryPrefix* LibraryPrefix::ReadFrom(SnapshotReader* reader, |
| 1181 intptr_t object_id, | 1181 intptr_t object_id, |
| 1182 intptr_t tags, | 1182 intptr_t tags, |
| 1183 Snapshot::Kind kind, | 1183 Snapshot::Kind kind, |
| 1184 bool as_reference) { | 1184 bool as_reference) { |
| 1185 ASSERT(reader != NULL); | 1185 ASSERT(reader != NULL); |
| (...skipping 2326 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3512 // We do not allow objects with native fields in an isolate message. | 3512 // We do not allow objects with native fields in an isolate message. |
| 3513 writer->SetWriteException(Exceptions::kArgument, | 3513 writer->SetWriteException(Exceptions::kArgument, |
| 3514 "Illegal argument in isolate message" | 3514 "Illegal argument in isolate message" |
| 3515 " : (object is a UserTag)"); | 3515 " : (object is a UserTag)"); |
| 3516 } else { | 3516 } else { |
| 3517 UNREACHABLE(); | 3517 UNREACHABLE(); |
| 3518 } | 3518 } |
| 3519 } | 3519 } |
| 3520 | 3520 |
| 3521 } // namespace dart | 3521 } // namespace dart |
| OLD | NEW |