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

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
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 1155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1283 // help the reader decide how the rest of the information needs 1284 // help the reader decide how the rest of the information needs
1284 // to be interpreted. 1285 // to be interpreted.
1285 writer->Write<bool>(ptr()->is_in_fullsnapshot_); 1286 writer->Write<bool>(ptr()->is_in_fullsnapshot_);
1286 1287
1287 if ((kind == Snapshot::kScript) && ptr()->is_in_fullsnapshot_) { 1288 if ((kind == Snapshot::kScript) && ptr()->is_in_fullsnapshot_) {
1288 // Write out library URL so that it can be looked up when reading. 1289 // Write out library URL so that it can be looked up when reading.
1289 writer->WriteObjectImpl(ptr()->url_, kAsInlinedObject); 1290 writer->WriteObjectImpl(ptr()->url_, kAsInlinedObject);
1290 } else { 1291 } else {
1291 ASSERT((kind == Snapshot::kFull) || !ptr()->is_in_fullsnapshot_); 1292 ASSERT((kind == Snapshot::kFull) || !ptr()->is_in_fullsnapshot_);
1292 // Write out all non object fields. 1293 // Write out all non object fields.
1294 ASSERT(ptr()->index_ != static_cast<classid_t>(-1));
1293 writer->WriteClassIDValue(ptr()->index_); 1295 writer->WriteClassIDValue(ptr()->index_);
1294 writer->Write<uint16_t>(ptr()->num_imports_); 1296 writer->Write<uint16_t>(ptr()->num_imports_);
1295 writer->Write<int8_t>(ptr()->load_state_); 1297 writer->Write<int8_t>(ptr()->load_state_);
1296 writer->Write<bool>(ptr()->corelib_imported_); 1298 writer->Write<bool>(ptr()->corelib_imported_);
1297 writer->Write<bool>(ptr()->is_dart_scheme_); 1299 writer->Write<bool>(ptr()->is_dart_scheme_);
1298 writer->Write<bool>(ptr()->debuggable_); 1300 writer->Write<bool>(ptr()->debuggable_);
1299 // We do not serialize the native resolver or symbolizer. These need to be 1301 // We do not serialize the native resolver or symbolizer. These need to be
1300 // explicitly set after deserialization. 1302 // explicitly set after deserialization.
1301 1303
1302 // We do not write the loaded_scripts_ and resolved_names_ caches to the 1304 // We do not write the loaded_scripts_ and resolved_names_ caches to the
(...skipping 20 matching lines...) Expand all
1323 reader->AddBackRef(object_id, &prefix, kIsDeserialized); 1325 reader->AddBackRef(object_id, &prefix, kIsDeserialized);
1324 1326
1325 // Set all non object fields. 1327 // Set all non object fields.
1326 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_, 1328 prefix.StoreNonPointer(&prefix.raw_ptr()->num_imports_,
1327 reader->Read<int16_t>()); 1329 reader->Read<int16_t>());
1328 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, 1330 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_,
1329 reader->Read<bool>()); 1331 reader->Read<bool>());
1330 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); 1332 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>());
1331 1333
1332 // Set all the object fields. 1334 // Set all the object fields.
1335 RawObject** toobj = reader->snapshot_code()
1336 ? prefix.raw()->to_precompiled_snapshot()
1337 : prefix.raw()->to();
1333 READ_OBJECT_FIELDS(prefix, 1338 READ_OBJECT_FIELDS(prefix,
1334 prefix.raw()->from(), prefix.raw()->to(), 1339 prefix.raw()->from(), toobj,
1335 kAsReference); 1340 kAsReference);
1341 if (reader->snapshot_code()) {
1342 prefix.StorePointer(&prefix.raw_ptr()->imports_,
1343 Array::null());
1344 prefix.StorePointer(&prefix.raw_ptr()->dependent_code_,
1345 Array::null());
1346 }
1336 1347
1337 return prefix.raw(); 1348 return prefix.raw();
1338 } 1349 }
1339 1350
1340 1351
1341 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, 1352 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer,
1342 intptr_t object_id, 1353 intptr_t object_id,
1343 Snapshot::Kind kind, 1354 Snapshot::Kind kind,
1344 bool as_reference) { 1355 bool as_reference) {
1345 ASSERT(writer != NULL); 1356 ASSERT(writer != NULL);
1346 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1357 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
1347 1358
1348 // Write out the serialization header value for this object. 1359 // Write out the serialization header value for this object.
1349 writer->WriteInlinedObjectHeader(object_id); 1360 writer->WriteInlinedObjectHeader(object_id);
1350 1361
1351 // Write out the class and tags information. 1362 // Write out the class and tags information.
1352 writer->WriteIndexedObject(kLibraryPrefixCid); 1363 writer->WriteIndexedObject(kLibraryPrefixCid);
1353 writer->WriteTags(writer->GetObjectTags(this)); 1364 writer->WriteTags(writer->GetObjectTags(this));
1354 1365
1355 // Write out all non object fields. 1366 // Write out all non object fields.
1356 writer->Write<int16_t>(ptr()->num_imports_); 1367 writer->Write<int16_t>(ptr()->num_imports_);
1357 writer->Write<bool>(ptr()->is_deferred_load_); 1368 writer->Write<bool>(ptr()->is_deferred_load_);
1358 writer->Write<bool>(ptr()->is_loaded_); 1369 writer->Write<bool>(ptr()->is_loaded_);
1359 1370
1360 // Write out all the object pointer fields. 1371 // Write out all the object pointer fields.
1361 SnapshotWriterVisitor visitor(writer, kAsReference); 1372 SnapshotWriterVisitor visitor(writer, kAsReference);
1362 visitor.VisitPointers(from(), to()); 1373 RawObject** toobj = writer->snapshot_code() ? to_precompiled_snapshot()
1374 : to();
1375 visitor.VisitPointers(from(), toobj);
1363 } 1376 }
1364 1377
1365 1378
1366 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader, 1379 RawNamespace* Namespace::ReadFrom(SnapshotReader* reader,
1367 intptr_t object_id, 1380 intptr_t object_id,
1368 intptr_t tags, 1381 intptr_t tags,
1369 Snapshot::Kind kind, 1382 Snapshot::Kind kind,
1370 bool as_reference) { 1383 bool as_reference) {
1371 ASSERT(reader != NULL); 1384 ASSERT(reader != NULL);
1372 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 1385 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
(...skipping 623 matching lines...) Expand 10 before | Expand all | Expand 10 after
1996 result.set_deopt_id(reader->Read<int32_t>()); 2009 result.set_deopt_id(reader->Read<int32_t>());
1997 result.set_state_bits(reader->Read<uint32_t>()); 2010 result.set_state_bits(reader->Read<uint32_t>());
1998 2011
1999 // Set all the object fields. 2012 // Set all the object fields.
2000 RawObject** toobj = reader->snapshot_code() 2013 RawObject** toobj = reader->snapshot_code()
2001 ? result.raw()->to_precompiled_snapshot() 2014 ? result.raw()->to_precompiled_snapshot()
2002 : result.raw()->to(); 2015 : result.raw()->to();
2003 READ_OBJECT_FIELDS(result, 2016 READ_OBJECT_FIELDS(result,
2004 result.raw()->from(), toobj, 2017 result.raw()->from(), toobj,
2005 kAsReference); 2018 kAsReference);
2019 if (reader->snapshot_code()) {
2020 result.set_owner(Function::Handle(reader->zone()));
2021 }
2006 2022
2007 return result.raw(); 2023 return result.raw();
2008 } 2024 }
2009 2025
2010 2026
2011 void RawICData::WriteTo(SnapshotWriter* writer, 2027 void RawICData::WriteTo(SnapshotWriter* writer,
2012 intptr_t object_id, 2028 intptr_t object_id,
2013 Snapshot::Kind kind, 2029 Snapshot::Kind kind,
2014 bool as_reference) { 2030 bool as_reference) {
2015 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); 2031 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull));
(...skipping 1683 matching lines...) Expand 10 before | Expand all | Expand 10 after
3699 // We do not allow objects with native fields in an isolate message. 3715 // We do not allow objects with native fields in an isolate message.
3700 writer->SetWriteException(Exceptions::kArgument, 3716 writer->SetWriteException(Exceptions::kArgument,
3701 "Illegal argument in isolate message" 3717 "Illegal argument in isolate message"
3702 " : (object is a UserTag)"); 3718 " : (object is a UserTag)");
3703 } else { 3719 } else {
3704 UNREACHABLE(); 3720 UNREACHABLE();
3705 } 3721 }
3706 } 3722 }
3707 3723
3708 } // namespace dart 3724 } // namespace dart
OLDNEW
« runtime/vm/precompiler.h ('K') | « 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