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

Side by Side Diff: runtime/vm/raw_object_snapshot.cc

Issue 1686773002: Precompilation: drop unused types and type arguments and empty classes and libraries. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 10 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
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // Write out the boolean is_in_fullsnapshot first as this will 108 // Write out the boolean is_in_fullsnapshot first as this will
109 // help the reader decide how the rest of the information needs 109 // help the reader decide how the rest of the information needs
110 // to be interpreted. 110 // to be interpreted.
111 writer->Write<bool>(is_in_fullsnapshot); 111 writer->Write<bool>(is_in_fullsnapshot);
112 112
113 if ((kind == Snapshot::kFull) || 113 if ((kind == Snapshot::kFull) ||
114 (kind == Snapshot::kScript && !is_in_fullsnapshot)) { 114 (kind == Snapshot::kScript && !is_in_fullsnapshot)) {
115 // Write out all the non object pointer fields. 115 // Write out all the non object pointer fields.
116 // NOTE: cpp_vtable_ is not written. 116 // NOTE: cpp_vtable_ is not written.
117 classid_t class_id = ptr()->id_; 117 classid_t class_id = ptr()->id_;
118 ASSERT(class_id != kIllegalCid);
118 writer->Write<classid_t>(class_id); 119 writer->Write<classid_t>(class_id);
119 if (!RawObject::IsInternalVMdefinedClassId(class_id)) { 120 if (!RawObject::IsInternalVMdefinedClassId(class_id)) {
120 // We don't write the instance size of VM defined classes as they 121 // We don't write the instance size of VM defined classes as they
121 // are already setup during initialization as part of pre populating 122 // are already setup during initialization as part of pre populating
122 // the class table. 123 // the class table.
123 writer->Write<int32_t>(ptr()->instance_size_in_words_); 124 writer->Write<int32_t>(ptr()->instance_size_in_words_);
124 writer->Write<int32_t>(ptr()->next_field_offset_in_words_); 125 writer->Write<int32_t>(ptr()->next_field_offset_in_words_);
125 } 126 }
126 writer->Write<int32_t>(ptr()->type_arguments_field_offset_in_words_); 127 writer->Write<int32_t>(ptr()->type_arguments_field_offset_in_words_);
127 writer->Write<uint16_t>(ptr()->num_type_arguments_); 128 writer->Write<uint16_t>(ptr()->num_type_arguments_);
(...skipping 1159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1287 // help the reader decide how the rest of the information needs 1288 // help the reader decide how the rest of the information needs
1288 // to be interpreted. 1289 // to be interpreted.
1289 writer->Write<bool>(ptr()->is_in_fullsnapshot_); 1290 writer->Write<bool>(ptr()->is_in_fullsnapshot_);
1290 1291
1291 if ((kind == Snapshot::kScript) && ptr()->is_in_fullsnapshot_) { 1292 if ((kind == Snapshot::kScript) && ptr()->is_in_fullsnapshot_) {
1292 // Write out library URL so that it can be looked up when reading. 1293 // Write out library URL so that it can be looked up when reading.
1293 writer->WriteObjectImpl(ptr()->url_, kAsInlinedObject); 1294 writer->WriteObjectImpl(ptr()->url_, kAsInlinedObject);
1294 } else { 1295 } else {
1295 ASSERT((kind == Snapshot::kFull) || !ptr()->is_in_fullsnapshot_); 1296 ASSERT((kind == Snapshot::kFull) || !ptr()->is_in_fullsnapshot_);
1296 // Write out all non object fields. 1297 // Write out all non object fields.
1298 ASSERT(ptr()->index_ != static_cast<classid_t>(-1));
1297 writer->WriteClassIDValue(ptr()->index_); 1299 writer->WriteClassIDValue(ptr()->index_);
1298 writer->Write<uint16_t>(ptr()->num_imports_); 1300 writer->Write<uint16_t>(ptr()->num_imports_);
1299 writer->Write<int8_t>(ptr()->load_state_); 1301 writer->Write<int8_t>(ptr()->load_state_);
1300 writer->Write<bool>(ptr()->corelib_imported_); 1302 writer->Write<bool>(ptr()->corelib_imported_);
1301 writer->Write<bool>(ptr()->is_dart_scheme_); 1303 writer->Write<bool>(ptr()->is_dart_scheme_);
1302 writer->Write<bool>(ptr()->debuggable_); 1304 writer->Write<bool>(ptr()->debuggable_);
1303 // We do not serialize the native resolver or symbolizer. These need to be 1305 // We do not serialize the native resolver or symbolizer. These need to be
1304 // explicitly set after deserialization. 1306 // explicitly set after deserialization.
1305 1307
1306 // We do not write the loaded_scripts_ and resolved_names_ caches to the 1308 // We do not write the loaded_scripts_ and resolved_names_ caches to the
(...skipping 20 matching lines...) Expand all
1327 reader->AddBackRef(object_id, &prefix, kIsDeserialized); 1329 reader->AddBackRef(object_id, &prefix, kIsDeserialized);
1328 1330
1329 // Set all non object fields. 1331 // Set all non object fields.
1330 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_, 1332 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_,
1331 reader->Read<int16_t>()); 1333 reader->Read<int16_t>());
1332 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, 1334 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_,
1333 reader->Read<bool>()); 1335 reader->Read<bool>());
1334 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); 1336 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>());
1335 1337
1336 // Set all the object fields. 1338 // Set all the object fields.
1339 RawObject** toobj = reader->snapshot_code()
1340 ? prefix.raw()->to_precompiled_snapshot()
1341 : prefix.raw()->to();
1337 READ_OBJECT_FIELDS(prefix, 1342 READ_OBJECT_FIELDS(prefix,
1338 prefix.raw()->from(), prefix.raw()->to(), 1343 prefix.raw()->from(), toobj,
1339 kAsReference); 1344 kAsReference);
1345 if (reader->snapshot_code()) {
1346 prefix.StorePointer(&prefix.raw_ptr()->imports_,
1347 Array::null());
1348 prefix.StorePointer(&prefix.raw_ptr()->dependent_code_,
1349 Array::null());
1350 }
1340 1351
1341 return prefix.raw(); 1352 return prefix.raw();
1342 } 1353 }
1343 1354
1344 1355
1345 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, 1356 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer,
1346 intptr_t object_id, 1357 intptr_t object_id,
1347 Snapshot::Kind kind, 1358 Snapshot::Kind kind,
1348 bool as_reference) { 1359 bool as_reference) {
1349 ASSERT(writer != NULL); 1360 ASSERT(writer != NULL);
1350 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1361 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
1351 1362
1352 // Write out the serialization header value for this object. 1363 // Write out the serialization header value for this object.
1353 writer->WriteInlinedObjectHeader(object_id); 1364 writer->WriteInlinedObjectHeader(object_id);
1354 1365
1355 // Write out the class and tags information. 1366 // Write out the class and tags information.
1356 writer->WriteIndexedObject(kLibraryPrefixCid); 1367 writer->WriteIndexedObject(kLibraryPrefixCid);
1357 writer->WriteTags(writer->GetObjectTags(this)); 1368 writer->WriteTags(writer->GetObjectTags(this));
1358 1369
1359 // Write out all non object fields. 1370 // Write out all non object fields.
1360 writer->Write<int16_t>(ptr()->num_imports_); 1371 writer->Write<int16_t>(ptr()->num_imports_);
1361 writer->Write<bool>(ptr()->is_deferred_load_); 1372 writer->Write<bool>(ptr()->is_deferred_load_);
1362 writer->Write<bool>(ptr()->is_loaded_); 1373 writer->Write<bool>(ptr()->is_loaded_);
1363 1374
1364 // Write out all the object pointer fields. 1375 // Write out all the object pointer fields.
1365 SnapshotWriterVisitor visitor(writer, kAsReference); 1376 SnapshotWriterVisitor visitor(writer, kAsReference);
1366 visitor.VisitPointers(from(), to()); 1377 RawObject** toobj = writer->snapshot_code() ? to_precompiled_snapshot()
1378 : to();
1379 visitor.VisitPointers(from(), toobj);
1367 } 1380 }
1368 1381
1369 1382
1370 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader, 1383 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader,
1371 intptr_t object_id, 1384 intptr_t object_id,
1372 intptr_t tags, 1385 intptr_t tags,
1373 Snapshot::Kind kind, 1386 Snapshot::Kind kind,
1374 bool as_reference) { 1387 bool as_reference) {
1375 ASSERT(reader != NULL); 1388 ASSERT(reader != NULL);
1376 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1389 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
2000 result.set_deopt_id(reader->Read<int32_t>()); 2013 result.set_deopt_id(reader->Read<int32_t>());
2001 result.set_state_bits(reader->Read<uint32_t>()); 2014 result.set_state_bits(reader->Read<uint32_t>());
2002 2015
2003 // Set all the object fields. 2016 // Set all the object fields.
2004 RawObject** toobj = reader->snapshot_code() 2017 RawObject** toobj = reader->snapshot_code()
2005 ? result.raw()->to_precompiled_snapshot() 2018 ? result.raw()->to_precompiled_snapshot()
2006 : result.raw()->to(); 2019 : result.raw()->to();
2007 READ_OBJECT_FIELDS(result, 2020 READ_OBJECT_FIELDS(result,
2008 result.raw()->from(), toobj, 2021 result.raw()->from(), toobj,
2009 kAsReference); 2022 kAsReference);
2023 if (reader->snapshot_code()) {
2024 result.set_owner(Function::Handle(reader->zone()));
2025 }
2010 2026
2011 return result.raw(); 2027 return result.raw();
2012 } 2028 }
2013 2029
2014 2030
2015 void RawICData::WriteTo(SnapshotWriter* writer, 2031 void RawICData::WriteTo(SnapshotWriter* writer,
2016 intptr_t object_id, 2032 intptr_t object_id,
2017 Snapshot::Kind kind, 2033 Snapshot::Kind kind,
2018 bool as_reference) { 2034 bool as_reference) {
2019 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 2035 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
(...skipping 1698 matching lines...) Expand 10 before | Expand all | Expand 10 after
3718 // We do not allow objects with native fields in an isolate message. 3734 // We do not allow objects with native fields in an isolate message.
3719 writer->SetWriteException(Exceptions::kArgument, 3735 writer->SetWriteException(Exceptions::kArgument,
3720 "Illegal argument in isolate message" 3736 "Illegal argument in isolate message"
3721 " : (object is a UserTag)"); 3737 " : (object is a UserTag)");
3722 } else { 3738 } else {
3723 UNREACHABLE(); 3739 UNREACHABLE();
3724 } 3740 }
3725 } 3741 }
3726 3742
3727 } // namespace dart 3743 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698