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

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

Issue 1413763018: Omit unused code metadata from precompiled snapshots. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 1 month 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') | no next file » | 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 650 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 bool is_in_fullsnapshot = reader->Read<bool>(); 661 bool is_in_fullsnapshot = reader->Read<bool>();
662 if ((kind == Snapshot::kFull) || !is_in_fullsnapshot) { 662 if ((kind == Snapshot::kFull) || !is_in_fullsnapshot) {
663 // Allocate function object. 663 // Allocate function object.
664 Function& func = Function::ZoneHandle( 664 Function& func = Function::ZoneHandle(
665 reader->zone(), NEW_OBJECT(Function)); 665 reader->zone(), NEW_OBJECT(Function));
666 reader->AddBackRef(object_id, &func, kIsDeserialized); 666 reader->AddBackRef(object_id, &func, kIsDeserialized);
667 667
668 // Set all the non object fields. 668 // Set all the non object fields.
669 func.set_token_pos(reader->Read<int32_t>()); 669 func.set_token_pos(reader->Read<int32_t>());
670 func.set_end_token_pos(reader->Read<int32_t>()); 670 func.set_end_token_pos(reader->Read<int32_t>());
671 func.set_usage_counter(reader->Read<int32_t>());
672 func.set_num_fixed_parameters(reader->Read<int16_t>()); 671 func.set_num_fixed_parameters(reader->Read<int16_t>());
673 func.set_num_optional_parameters(reader->Read<int16_t>()); 672 func.set_num_optional_parameters(reader->Read<int16_t>());
674 func.set_deoptimization_counter(reader->Read<int16_t>());
675 func.set_kind_tag(reader->Read<uint32_t>()); 673 func.set_kind_tag(reader->Read<uint32_t>());
676 func.set_optimized_instruction_count(reader->Read<uint16_t>()); 674 if (!reader->snapshot_code()) {
677 func.set_optimized_call_site_count(reader->Read<uint16_t>()); 675 func.set_usage_counter(reader->Read<int32_t>());
676 func.set_deoptimization_counter(reader->Read<int16_t>());
677 func.set_optimized_instruction_count(reader->Read<uint16_t>());
678 func.set_optimized_call_site_count(reader->Read<uint16_t>());
679 } else {
680 func.set_usage_counter(0);
681 func.set_deoptimization_counter(0);
682 func.set_optimized_instruction_count(0);
683 func.set_optimized_call_site_count(0);
684 }
678 685
679 // Set all the object fields. 686 // Set all the object fields.
680 READ_OBJECT_FIELDS(func, 687 READ_OBJECT_FIELDS(func,
681 func.raw()->from(), func.raw()->to_snapshot(), 688 func.raw()->from(), func.raw()->to_snapshot(),
682 kAsReference); 689 kAsReference);
683 // Initialize all fields that are not part of the snapshot. 690 // Initialize all fields that are not part of the snapshot.
684 if (reader->snapshot_code()) { 691 if (reader->snapshot_code()) {
685 func.ClearICDataArray(); 692 func.ClearICDataArray();
686 func.ClearCode(); 693 func.ClearCode();
687 // Read the code object and fixup entry point. 694 // Read the code object and fixup entry point.
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
734 // help the reader decide how the rest of the information needs 741 // help the reader decide how the rest of the information needs
735 // to be interpreted. 742 // to be interpreted.
736 writer->Write<bool>(is_in_fullsnapshot); 743 writer->Write<bool>(is_in_fullsnapshot);
737 744
738 if (kind == Snapshot::kFull || !is_in_fullsnapshot) { 745 if (kind == Snapshot::kFull || !is_in_fullsnapshot) {
739 bool is_optimized = Code::IsOptimized(ptr()->code_); 746 bool is_optimized = Code::IsOptimized(ptr()->code_);
740 747
741 // Write out all the non object fields. 748 // Write out all the non object fields.
742 writer->Write<int32_t>(ptr()->token_pos_); 749 writer->Write<int32_t>(ptr()->token_pos_);
743 writer->Write<int32_t>(ptr()->end_token_pos_); 750 writer->Write<int32_t>(ptr()->end_token_pos_);
744 if (is_optimized) {
745 writer->Write<int32_t>(FLAG_optimization_counter_threshold);
746 } else {
747 writer->Write<int32_t>(0);
748 }
749 writer->Write<int16_t>(ptr()->num_fixed_parameters_); 751 writer->Write<int16_t>(ptr()->num_fixed_parameters_);
750 writer->Write<int16_t>(ptr()->num_optional_parameters_); 752 writer->Write<int16_t>(ptr()->num_optional_parameters_);
751 writer->Write<int16_t>(ptr()->deoptimization_counter_);
752 writer->Write<uint32_t>(ptr()->kind_tag_); 753 writer->Write<uint32_t>(ptr()->kind_tag_);
753 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); 754 if (!writer->snapshot_code()) {
srdjan 2015/11/13 21:14:02 ditto
rmacnak 2015/11/13 21:56:02 Done.
754 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); 755 if (is_optimized) {
756 writer->Write<int32_t>(FLAG_optimization_counter_threshold);
757 } else {
758 writer->Write<int32_t>(0);
759 }
760 writer->Write<int16_t>(ptr()->deoptimization_counter_);
761 writer->Write<uint16_t>(ptr()->optimized_instruction_count_);
762 writer->Write<uint16_t>(ptr()->optimized_call_site_count_);
763 }
755 764
756 // Write out all the object pointer fields. 765 // Write out all the object pointer fields.
757 SnapshotWriterVisitor visitor(writer, kAsReference); 766 SnapshotWriterVisitor visitor(writer, kAsReference);
758 visitor.VisitPointers(from(), to_snapshot()); 767 visitor.VisitPointers(from(), to_snapshot());
759 if (writer->snapshot_code()) { 768 if (writer->snapshot_code()) {
760 ASSERT(ptr()->ic_data_array_ == Array::null()); 769 ASSERT(ptr()->ic_data_array_ == Array::null());
761 ASSERT((ptr()->code_ == ptr()->unoptimized_code_) || 770 ASSERT((ptr()->code_ == ptr()->unoptimized_code_) ||
762 (ptr()->unoptimized_code_ == Code::null())); 771 (ptr()->unoptimized_code_ == Code::null()));
763 // Write out the code object as we are generating a precompiled snapshot. 772 // Write out the code object as we are generating a precompiled snapshot.
764 writer->WriteObjectImpl(ptr()->code_, kAsInlinedObject); 773 writer->WriteObjectImpl(ptr()->code_, kAsInlinedObject);
(...skipping 482 matching lines...) Expand 10 before | Expand all | Expand 10 after
1247 intptr_t object_id, 1256 intptr_t object_id,
1248 intptr_t tags, 1257 intptr_t tags,
1249 Snapshot::Kind kind, 1258 Snapshot::Kind kind,
1250 bool as_reference) { 1259 bool as_reference) {
1251 ASSERT(reader->snapshot_code()); 1260 ASSERT(reader->snapshot_code());
1252 ASSERT(kind == Snapshot::kFull); 1261 ASSERT(kind == Snapshot::kFull);
1253 1262
1254 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0)); 1263 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0));
1255 reader->AddBackRef(object_id, &result, kIsDeserialized); 1264 reader->AddBackRef(object_id, &result, kIsDeserialized);
1256 1265
1257 result.set_compile_timestamp(reader->Read<int64_t>()); 1266 result.set_compile_timestamp(0);
1258 result.set_state_bits(reader->Read<int32_t>()); 1267 result.set_state_bits(reader->Read<int32_t>());
1259 result.set_lazy_deopt_pc_offset(reader->Read<int32_t>()); 1268 result.set_lazy_deopt_pc_offset(-1);
1260 1269
1261 // Set all the object fields. 1270 // Set all the object fields.
1262 READ_OBJECT_FIELDS(result, 1271 READ_OBJECT_FIELDS(result,
1263 result.raw()->from(), result.raw()->to(), 1272 result.raw()->from(), result.raw()->to_snapshot(),
1264 kAsReference); 1273 kAsReference);
1274 for (RawObject** ptr = result.raw()->to();
1275 ptr > result.raw()->to_snapshot();
1276 ptr--) {
1277 result.StorePointer(ptr, Object::null());
1278 }
1265 1279
1266 // Fix entry point. 1280 // Fix entry point.
1267 uword new_entry = result.EntryPoint(); 1281 uword new_entry = result.EntryPoint();
1268 ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry)); 1282 ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry));
1269 result.StoreNonPointer(&result.raw_ptr()->entry_point_, new_entry); 1283 result.StoreNonPointer(&result.raw_ptr()->entry_point_, new_entry);
1270 1284
1271 return result.raw(); 1285 return result.raw();
1272 } 1286 }
1273 1287
1274 1288
1275 void RawCode::WriteTo(SnapshotWriter* writer, 1289 void RawCode::WriteTo(SnapshotWriter* writer,
1276 intptr_t object_id, 1290 intptr_t object_id,
1277 Snapshot::Kind kind, 1291 Snapshot::Kind kind,
1278 bool as_reference) { 1292 bool as_reference) {
1279 ASSERT(writer->snapshot_code()); 1293 ASSERT(writer->snapshot_code());
1280 ASSERT(kind == Snapshot::kFull); 1294 ASSERT(kind == Snapshot::kFull);
1281 1295
1282 intptr_t pointer_offsets_length = 1296 intptr_t pointer_offsets_length =
1283 Code::PtrOffBits::decode(ptr()->state_bits_); 1297 Code::PtrOffBits::decode(ptr()->state_bits_);
1284 if (pointer_offsets_length != 0) { 1298 if (pointer_offsets_length != 0) {
1285 // Should only be IA32. 1299 // Should only be IA32.
1286 FATAL("Serializing embedded pointer offsets unimplemented"); 1300 FATAL("Cannot serialize code with embedded pointers");
1287 } 1301 }
1288 1302
1289 // Write out the serialization header value for this object. 1303 // Write out the serialization header value for this object.
1290 writer->WriteInlinedObjectHeader(object_id); 1304 writer->WriteInlinedObjectHeader(object_id);
1291 1305
1292 // Write out the class and tags information. 1306 // Write out the class and tags information.
1293 writer->WriteVMIsolateObject(kCodeCid); 1307 writer->WriteVMIsolateObject(kCodeCid);
1294 writer->WriteTags(writer->GetObjectTags(this)); 1308 writer->WriteTags(writer->GetObjectTags(this));
1295 1309
1296 // Write out all the non object fields. 1310 // Write out all the non object fields.
1297 writer->Write<int64_t>(ptr()->compile_timestamp_);
1298 writer->Write<int32_t>(ptr()->state_bits_); 1311 writer->Write<int32_t>(ptr()->state_bits_);
1299 writer->Write<int32_t>(ptr()->lazy_deopt_pc_offset_);
1300 1312
1301 // Write out all the object pointer fields. 1313 // Write out all the object pointer fields.
1302 SnapshotWriterVisitor visitor(writer, kAsReference); 1314 SnapshotWriterVisitor visitor(writer, kAsReference);
1303 visitor.VisitPointers(from(), to()); 1315 visitor.VisitPointers(from(), to_snapshot());
1304 1316
1305 writer->SetInstructionsCode(ptr()->instructions_, this); 1317 writer->SetInstructionsCode(ptr()->instructions_, this);
1306 } 1318 }
1307 1319
1308 1320
1309 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader, 1321 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader,
1310 intptr_t object_id, 1322 intptr_t object_id,
1311 intptr_t tags, 1323 intptr_t tags,
1312 Snapshot::Kind kind, 1324 Snapshot::Kind kind,
1313 bool as_reference) { 1325 bool as_reference) {
(...skipping 2167 matching lines...) Expand 10 before | Expand all | Expand 10 after
3481 // We do not allow objects with native fields in an isolate message. 3493 // We do not allow objects with native fields in an isolate message.
3482 writer->SetWriteException(Exceptions::kArgument, 3494 writer->SetWriteException(Exceptions::kArgument,
3483 "Illegal argument in isolate message" 3495 "Illegal argument in isolate message"
3484 " : (object is a UserTag)"); 3496 " : (object is a UserTag)");
3485 } else { 3497 } else {
3486 UNREACHABLE(); 3498 UNREACHABLE();
3487 } 3499 }
3488 } 3500 }
3489 3501
3490 } // namespace dart 3502 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/vm/raw_object.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698