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

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

Issue 1938653002: JIT precompilated snapshots. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 4 years, 7 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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after
637 // Write out the serialization header value for this object. 637 // Write out the serialization header value for this object.
638 writer->WriteInlinedObjectHeader(object_id); 638 writer->WriteInlinedObjectHeader(object_id);
639 639
640 // Write out the class and tags information. 640 // Write out the class and tags information.
641 writer->WriteVMIsolateObject(kClosureDataCid); 641 writer->WriteVMIsolateObject(kClosureDataCid);
642 writer->WriteTags(writer->GetObjectTags(this)); 642 writer->WriteTags(writer->GetObjectTags(this));
643 643
644 // Context scope. 644 // Context scope.
645 if (ptr()->context_scope_ == Object::empty_context_scope().raw()) { 645 if (ptr()->context_scope_ == Object::empty_context_scope().raw()) {
646 writer->WriteVMIsolateObject(kEmptyContextScopeObject); 646 writer->WriteVMIsolateObject(kEmptyContextScopeObject);
647 } else if (ptr()->context_scope_->ptr()->is_implicit_ ||
648 (kind == Snapshot::kAppWithJIT)) {
649 writer->WriteObjectImpl(ptr()->context_scope_, kAsInlinedObject);
647 } else { 650 } else {
648 if (ptr()->context_scope_->ptr()->is_implicit_) { 651 // We don't write non implicit context scopes in the snapshot.
649 writer->WriteObjectImpl(ptr()->context_scope_, kAsInlinedObject); 652 writer->WriteVMIsolateObject(kNullObject);
650 } else {
651 // We don't write non implicit context scopes in the snapshot.
652 writer->WriteVMIsolateObject(kNullObject);
653 }
654 } 653 }
655 654
656 // Parent function. 655 // Parent function.
657 writer->WriteObjectImpl(ptr()->parent_function_, kAsInlinedObject); 656 writer->WriteObjectImpl(ptr()->parent_function_, kAsInlinedObject);
658 657
659 // Signature type. 658 // Signature type.
660 writer->WriteObjectImpl(ptr()->signature_type_, kAsInlinedObject); 659 writer->WriteObjectImpl(ptr()->signature_type_, kAsInlinedObject);
661 660
662 // Canonical static closure. 661 // Canonical static closure.
663 writer->WriteObjectImpl(ptr()->closure_, kAsInlinedObject); 662 writer->WriteObjectImpl(ptr()->closure_, kAsInlinedObject);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
723 722
724 // Set all the non object fields. Read the token positions now but 723 // Set all the non object fields. Read the token positions now but
725 // don't set them until after setting the kind. 724 // don't set them until after setting the kind.
726 const int32_t token_pos = reader->Read<int32_t>(); 725 const int32_t token_pos = reader->Read<int32_t>();
727 const int32_t end_token_pos = reader->Read<uint32_t>(); 726 const int32_t end_token_pos = reader->Read<uint32_t>();
728 func.set_num_fixed_parameters(reader->Read<int16_t>()); 727 func.set_num_fixed_parameters(reader->Read<int16_t>());
729 func.set_num_optional_parameters(reader->Read<int16_t>()); 728 func.set_num_optional_parameters(reader->Read<int16_t>());
730 func.set_kind_tag(reader->Read<uint32_t>()); 729 func.set_kind_tag(reader->Read<uint32_t>());
731 func.set_token_pos(TokenPosition::SnapshotDecode(token_pos)); 730 func.set_token_pos(TokenPosition::SnapshotDecode(token_pos));
732 func.set_end_token_pos(TokenPosition::SnapshotDecode(end_token_pos)); 731 func.set_end_token_pos(TokenPosition::SnapshotDecode(end_token_pos));
733 if (Snapshot::IncludesCode(kind)) { 732 if (kind == Snapshot::kAppNoJIT) {
734 func.set_usage_counter(0); 733 func.set_usage_counter(0);
735 func.set_deoptimization_counter(0); 734 func.set_deoptimization_counter(0);
736 func.set_optimized_instruction_count(0); 735 func.set_optimized_instruction_count(0);
737 func.set_optimized_call_site_count(0); 736 func.set_optimized_call_site_count(0);
738 } else { 737 } else {
739 func.set_usage_counter(reader->Read<int32_t>()); 738 func.set_usage_counter(reader->Read<int32_t>());
740 func.set_deoptimization_counter(reader->Read<int8_t>()); 739 func.set_deoptimization_counter(reader->Read<int8_t>());
741 func.set_optimized_instruction_count(reader->Read<uint16_t>()); 740 func.set_optimized_instruction_count(reader->Read<uint16_t>());
742 func.set_optimized_call_site_count(reader->Read<uint16_t>()); 741 func.set_optimized_call_site_count(reader->Read<uint16_t>());
743 } 742 }
744 func.set_was_compiled(false); 743 func.set_was_compiled(false);
745 744
746 // Set all the object fields. 745 // Set all the object fields.
747 READ_OBJECT_FIELDS(func, 746 READ_OBJECT_FIELDS(func,
748 func.raw()->from(), func.raw()->to_snapshot(), 747 func.raw()->from(), func.raw()->to_snapshot(),
749 kAsReference); 748 kAsReference);
750 // Initialize all fields that are not part of the snapshot. 749 // Initialize all fields that are not part of the snapshot.
751 if (Snapshot::IncludesCode(kind)) { 750 if (kind == Snapshot::kAppNoJIT) {
752 func.ClearICDataArray(); 751 func.ClearICDataArray();
753 func.ClearCode(); 752 func.ClearCode();
754 // Read the code object and fixup entry point. 753 // Read the code object and fixup entry point.
755 (*reader->CodeHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); 754 (*reader->CodeHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject);
756 func.SetInstructions(*reader->CodeHandle()); 755 func.SetInstructions(*reader->CodeHandle());
756 } else if (kind == Snapshot::kAppWithJIT) {
757 func.ClearICDataArray();
758 func.ClearCode();
759 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference);
760 func.set_ic_data_array(*reader->ArrayHandle());
761 (*reader->CodeHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject);
762 func.set_unoptimized_code(*reader->CodeHandle());
763 if (!reader->CodeHandle()->IsNull()) {
764 func.SetInstructions(*reader->CodeHandle());
765 func.set_was_compiled(true);
766 }
757 } else { 767 } else {
758 bool is_optimized = func.usage_counter() != 0; 768 bool is_optimized = func.usage_counter() != 0;
759 if (is_optimized) { 769 if (is_optimized) {
760 // Read the ic data array as the function is an optimized one. 770 // Read the ic data array as the function is an optimized one.
761 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference); 771 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference);
762 func.set_ic_data_array(*reader->ArrayHandle()); 772 func.set_ic_data_array(*reader->ArrayHandle());
763 } else { 773 } else {
764 func.ClearICDataArray(); 774 func.ClearICDataArray();
765 } 775 }
766 func.ClearCode(); 776 func.ClearCode();
(...skipping 10 matching lines...) Expand all
777 Snapshot::Kind kind, 787 Snapshot::Kind kind,
778 bool as_reference) { 788 bool as_reference) {
779 ASSERT(writer != NULL); 789 ASSERT(writer != NULL);
780 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind))); 790 ASSERT((kind == Snapshot::kScript) || (Snapshot::IsFull(kind)));
781 bool is_in_fullsnapshot = false; 791 bool is_in_fullsnapshot = false;
782 bool owner_is_class = false; 792 bool owner_is_class = false;
783 if ((kind == Snapshot::kScript) && !Function::IsSignatureFunction(this)) { 793 if ((kind == Snapshot::kScript) && !Function::IsSignatureFunction(this)) {
784 intptr_t tags = writer->GetObjectTags(ptr()->owner_); 794 intptr_t tags = writer->GetObjectTags(ptr()->owner_);
785 intptr_t cid = ClassIdTag::decode(tags); 795 intptr_t cid = ClassIdTag::decode(tags);
786 owner_is_class = (cid == kClassCid); 796 owner_is_class = (cid == kClassCid);
787 is_in_fullsnapshot = owner_is_class ? 797 is_in_fullsnapshot = owner_is_class ?
788 Class::IsInFullSnapshot(reinterpret_cast<RawClass*>(ptr()->owner_)) : 798 Class::IsInFullSnapshot(reinterpret_cast<RawClass*>(ptr()->owner_)) :
789 PatchClass::IsInFullSnapshot( 799 PatchClass::IsInFullSnapshot(
790 reinterpret_cast<RawPatchClass*>(ptr()->owner_)); 800 reinterpret_cast<RawPatchClass*>(ptr()->owner_));
791 } 801 }
792 802
793 // Write out the serialization header value for this object. 803 // Write out the serialization header value for this object.
794 writer->WriteInlinedObjectHeader(object_id); 804 writer->WriteInlinedObjectHeader(object_id);
795 805
796 // Write out the class and tags information. 806 // Write out the class and tags information.
797 writer->WriteVMIsolateObject(kFunctionCid); 807 writer->WriteVMIsolateObject(kFunctionCid);
798 writer->WriteTags(writer->GetObjectTags(this)); 808 writer->WriteTags(writer->GetObjectTags(this));
799 809
800 // Write out the boolean is_in_fullsnapshot first as this will 810 // Write out the boolean is_in_fullsnapshot first as this will
801 // help the reader decide how the rest of the information needs 811 // help the reader decide how the rest of the information needs
802 // to be interpreted. 812 // to be interpreted.
803 writer->Write<bool>(is_in_fullsnapshot); 813 writer->Write<bool>(is_in_fullsnapshot);
804 814
805 if (Snapshot::IsFull(kind) || !is_in_fullsnapshot) { 815 if (Snapshot::IsFull(kind) || !is_in_fullsnapshot) {
806 bool is_optimized = Code::IsOptimized(ptr()->code_); 816 bool is_optimized = Code::IsOptimized(ptr()->code_);
807 817
808 // Write out all the non object fields. 818 // Write out all the non object fields.
809 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode()); 819 writer->Write<int32_t>(ptr()->token_pos_.SnapshotEncode());
810 writer->Write<int32_t>(ptr()->end_token_pos_.SnapshotEncode()); 820 writer->Write<int32_t>(ptr()->end_token_pos_.SnapshotEncode());
811 writer->Write<int16_t>(ptr()->num_fixed_parameters_); 821 writer->Write<int16_t>(ptr()->num_fixed_parameters_);
812 writer->Write<int16_t>(ptr()->num_optional_parameters_); 822 writer->Write<int16_t>(ptr()->num_optional_parameters_);
813 writer->Write<uint32_t>(ptr()->kind_tag_); 823 writer->Write<uint32_t>(ptr()->kind_tag_);
814 if (Snapshot::IncludesCode(kind)) { 824 if (kind == Snapshot::kAppNoJIT) {
815 // Omit fields used to support de/reoptimization. 825 // Omit fields used to support de/reoptimization.
816 } else { 826 } else {
817 if (is_optimized) { 827 if (is_optimized) {
818 writer->Write<int32_t>(FLAG_optimization_counter_threshold); 828 writer->Write<int32_t>(FLAG_optimization_counter_threshold);
819 } else { 829 } else {
820 writer->Write<int32_t>(0); 830 writer->Write<int32_t>(0);
821 } 831 }
822 writer->Write<int8_t>(ptr()->deoptimization_counter_); 832 writer->Write<int8_t>(ptr()->deoptimization_counter_);
823 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); 833 writer->Write<uint16_t>(ptr()->optimized_instruction_count_);
824 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); 834 writer->Write<uint16_t>(ptr()->optimized_call_site_count_);
825 } 835 }
826 836
827 // Write out all the object pointer fields. 837 // Write out all the object pointer fields.
828 SnapshotWriterVisitor visitor(writer, kAsReference); 838 SnapshotWriterVisitor visitor(writer, kAsReference);
829 visitor.VisitPointers(from(), to_snapshot()); 839 visitor.VisitPointers(from(), to_snapshot());
830 if (Snapshot::IncludesCode(kind)) { 840 if (kind == Snapshot::kAppNoJIT) {
831 ASSERT(ptr()->ic_data_array_ == Array::null()); 841 ASSERT(ptr()->ic_data_array_ == Array::null());
832 ASSERT((ptr()->code_ == ptr()->unoptimized_code_) || 842 ASSERT((ptr()->code_ == ptr()->unoptimized_code_) ||
833 (ptr()->unoptimized_code_ == Code::null())); 843 (ptr()->unoptimized_code_ == Code::null()));
834 // Write out the code object as we are generating a precompiled snapshot.
835 writer->WriteObjectImpl(ptr()->code_, kAsInlinedObject); 844 writer->WriteObjectImpl(ptr()->code_, kAsInlinedObject);
845 } else if (kind == Snapshot::kAppWithJIT) {
846 writer->WriteObjectImpl(ptr()->ic_data_array_, kAsReference);
847 writer->WriteObjectImpl(ptr()->unoptimized_code_, kAsInlinedObject);
836 } else if (is_optimized) { 848 } else if (is_optimized) {
837 // Write out the ic data array as the function is optimized or 849 // Write out the ic data array as the function is optimized.
838 // we are generating a precompiled snapshot.
839 writer->WriteObjectImpl(ptr()->ic_data_array_, kAsReference); 850 writer->WriteObjectImpl(ptr()->ic_data_array_, kAsReference);
840 } 851 }
841 } else { 852 } else {
842 writer->WriteFunctionId(this, owner_is_class); 853 writer->WriteFunctionId(this, owner_is_class);
843 } 854 }
844 } 855 }
845 856
846 857
847 RawField* Field::ReadFrom(SnapshotReader* reader, 858 RawField* Field::ReadFrom(SnapshotReader* reader,
848 intptr_t object_id, 859 intptr_t object_id,
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
915 // Write out the owner. 926 // Write out the owner.
916 writer->WriteObjectImpl(ptr()->owner_, kAsReference); 927 writer->WriteObjectImpl(ptr()->owner_, kAsReference);
917 // Write out the type. 928 // Write out the type.
918 writer->WriteObjectImpl(ptr()->type_, kAsReference); 929 writer->WriteObjectImpl(ptr()->type_, kAsReference);
919 // Write out the initial static value or field offset. 930 // Write out the initial static value or field offset.
920 if (Field::StaticBit::decode(ptr()->kind_bits_)) { 931 if (Field::StaticBit::decode(ptr()->kind_bits_)) {
921 if (kind == Snapshot::kAppNoJIT) { 932 if (kind == Snapshot::kAppNoJIT) {
922 // For precompiled static fields, the value was already reset and 933 // For precompiled static fields, the value was already reset and
923 // initializer_ now contains a Function. 934 // initializer_ now contains a Function.
924 writer->WriteObjectImpl(ptr()->value_.static_value_, kAsReference); 935 writer->WriteObjectImpl(ptr()->value_.static_value_, kAsReference);
936 } else if (Field::ConstBit::decode(ptr()->kind_bits_)) {
937 // Do not reset const fields.
938 writer->WriteObjectImpl(ptr()->value_.static_value_, kAsReference);
925 } else { 939 } else {
926 // Otherwise, for static fields we write out the initial static value. 940 // Otherwise, for static fields we write out the initial static value.
927 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference); 941 writer->WriteObjectImpl(ptr()->initializer_.saved_value_, kAsReference);
928 } 942 }
929 } else { 943 } else {
930 writer->WriteObjectImpl(ptr()->value_.offset_, kAsReference); 944 writer->WriteObjectImpl(ptr()->value_.offset_, kAsReference);
931 } 945 }
932 // Write out the initializer function or saved initial value. 946 // Write out the initializer function or saved initial value.
933 if (kind == Snapshot::kAppNoJIT) { 947 if (kind == Snapshot::kAppNoJIT) {
934 writer->WriteObjectImpl(ptr()->initializer_.precompiled_, kAsReference); 948 writer->WriteObjectImpl(ptr()->initializer_.precompiled_, kAsReference);
(...skipping 419 matching lines...) Expand 10 before | Expand all | Expand 10 after
1354 ASSERT(Snapshot::IsFull(kind)); 1368 ASSERT(Snapshot::IsFull(kind));
1355 1369
1356 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0)); 1370 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0));
1357 reader->AddBackRef(object_id, &result, kIsDeserialized); 1371 reader->AddBackRef(object_id, &result, kIsDeserialized);
1358 1372
1359 result.set_compile_timestamp(0); 1373 result.set_compile_timestamp(0);
1360 result.set_state_bits(reader->Read<int32_t>()); 1374 result.set_state_bits(reader->Read<int32_t>());
1361 result.set_lazy_deopt_pc_offset(-1); 1375 result.set_lazy_deopt_pc_offset(-1);
1362 1376
1363 int32_t text_offset = reader->Read<int32_t>(); 1377 int32_t text_offset = reader->Read<int32_t>();
1364 int32_t instructions_size = reader->Read<int32_t>(); 1378 RawInstructions* instr = reinterpret_cast<RawInstructions*>(
1365 uword entry_point = reader->GetInstructionsAt(text_offset); 1379 reader->GetInstructionsAt(text_offset) + kHeapObjectTag);
1380 uword entry_point = Instructions::EntryPoint(instr);
1366 1381
1367 #if defined(DEBUG) 1382 #if defined(DEBUG)
1383 ASSERT(instr->IsMarked());
1384 ASSERT(instr->IsVMHeapObject());
1368 uword expected_check = reader->Read<uword>(); 1385 uword expected_check = reader->Read<uword>();
1386 intptr_t instructions_size = Utils::RoundUp(instr->size_,
1387 OS::PreferredCodeAlignment());
1369 uword actual_check = Checksum(entry_point, instructions_size); 1388 uword actual_check = Checksum(entry_point, instructions_size);
1370 ASSERT(expected_check == actual_check); 1389 ASSERT(expected_check == actual_check);
1371 #endif 1390 #endif
1372 1391
1373 result.StoreNonPointer(&result.raw_ptr()->entry_point_, entry_point); 1392 result.StoreNonPointer(&result.raw_ptr()->entry_point_, entry_point);
1374 1393
1375 result.StorePointer(reinterpret_cast<RawSmi*const*>( 1394 result.StorePointer(&result.raw_ptr()->active_instructions_, instr);
1376 &result.raw_ptr()->instructions_), 1395 result.StorePointer(&result.raw_ptr()->instructions_, instr);
1377 Smi::New(instructions_size));
1378 1396
1379 (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference); 1397 (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference);
1380 result.StorePointer(reinterpret_cast<RawObject*const*>( 1398 result.StorePointer(reinterpret_cast<RawObject*const*>(
1381 &result.raw_ptr()->object_pool_), 1399 &result.raw_ptr()->object_pool_),
1382 reader->PassiveObjectHandle()->raw()); 1400 reader->PassiveObjectHandle()->raw());
1383 1401
1384 (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference); 1402 (*reader->PassiveObjectHandle()) ^= reader->ReadObjectImpl(kAsReference);
1385 result.StorePointer(&result.raw_ptr()->owner_, 1403 result.StorePointer(&result.raw_ptr()->owner_,
1386 reader->PassiveObjectHandle()->raw()); 1404 reader->PassiveObjectHandle()->raw());
1387 1405
(...skipping 23 matching lines...) Expand all
1411 Array::null()); 1429 Array::null());
1412 result.StorePointer(&result.raw_ptr()->var_descriptors_, 1430 result.StorePointer(&result.raw_ptr()->var_descriptors_,
1413 LocalVarDescriptors::null()); 1431 LocalVarDescriptors::null());
1414 result.StorePointer(&result.raw_ptr()->inlined_metadata_, 1432 result.StorePointer(&result.raw_ptr()->inlined_metadata_,
1415 Array::null()); 1433 Array::null());
1416 result.StorePointer(&result.raw_ptr()->comments_, 1434 result.StorePointer(&result.raw_ptr()->comments_,
1417 Array::null()); 1435 Array::null());
1418 result.StorePointer(&result.raw_ptr()->return_address_metadata_, 1436 result.StorePointer(&result.raw_ptr()->return_address_metadata_,
1419 Object::null()); 1437 Object::null());
1420 1438
1421 ASSERT(result.Size() == instructions_size);
1422 ASSERT(result.EntryPoint() == entry_point);
1423
1424 return result.raw(); 1439 return result.raw();
1425 } 1440 }
1426 1441
1427 1442
1428 void RawCode::WriteTo(SnapshotWriter* writer, 1443 void RawCode::WriteTo(SnapshotWriter* writer,
1429 intptr_t object_id, 1444 intptr_t object_id,
1430 Snapshot::Kind kind, 1445 Snapshot::Kind kind,
1431 bool as_reference) { 1446 bool as_reference) {
1432 ASSERT(Snapshot::IncludesCode(kind)); 1447 ASSERT(Snapshot::IncludesCode(kind));
1433 ASSERT(Snapshot::IsFull(kind)); 1448 ASSERT(Snapshot::IsFull(kind));
1434 1449
1435 intptr_t pointer_offsets_length = 1450 intptr_t pointer_offsets_length =
1436 Code::PtrOffBits::decode(ptr()->state_bits_); 1451 Code::PtrOffBits::decode(ptr()->state_bits_);
1437 if (pointer_offsets_length != 0) { 1452 // Cannot serialize code with embedded pointers (IA32).
1438 // Should only be IA32. 1453 ASSERT(pointer_offsets_length == 0);
1439 FATAL("Cannot serialize code with embedded pointers"); 1454 if (kind == Snapshot::kAppNoJIT) {
1455 // No disabled code in precompilation.
1456 ASSERT(ptr()->instructions_ == ptr()->active_instructions_);
1457 } else {
1458 ASSERT(kind == Snapshot::kAppWithJIT);
1459 // We never include optimized code in JIT precompilation. Deoptimization
1460 // requires code patching and we cannot patch code that is shared between
1461 // isolates and should not mutate memory allocated by the embedder.
1462 bool is_optimized = Code::PtrOffBits::decode(ptr()->state_bits_);
1463 ASSERT(!is_optimized);
1440 } 1464 }
1441 1465
1442 // Write out the serialization header value for this object. 1466 // Write out the serialization header value for this object.
1443 writer->WriteInlinedObjectHeader(object_id); 1467 writer->WriteInlinedObjectHeader(object_id);
1444 1468
1445 // Write out the class and tags information. 1469 // Write out the class and tags information.
1446 writer->WriteVMIsolateObject(kCodeCid); 1470 writer->WriteVMIsolateObject(kCodeCid);
1447 writer->WriteTags(writer->GetObjectTags(this)); 1471 writer->WriteTags(writer->GetObjectTags(this));
1448 1472
1449 // Write out all the non object fields. 1473 // Write out all the non object fields.
1450 writer->Write<int32_t>(ptr()->state_bits_); 1474 writer->Write<int32_t>(ptr()->state_bits_);
1451 1475
1452 RawInstructions* instr = ptr()->instructions_; 1476 RawInstructions* instr = ptr()->instructions_;
1453 intptr_t size = instr->ptr()->size_;
1454 int32_t text_offset = writer->GetInstructionsId(instr, this); 1477 int32_t text_offset = writer->GetInstructionsId(instr, this);
1455 writer->Write<int32_t>(text_offset); 1478 writer->Write<int32_t>(text_offset);
1456 writer->Write<int32_t>(size); 1479
1457 #if defined(DEBUG) 1480 #if defined(DEBUG)
1458 uword entry = ptr()->entry_point_; 1481 uword entry = ptr()->entry_point_;
1459 uword check = Checksum(entry, size); 1482 intptr_t instructions_size = Utils::RoundUp(instr->size_,
1483 OS::PreferredCodeAlignment());
1484 uword check = Checksum(entry, instructions_size);
1460 writer->Write<uword>(check); 1485 writer->Write<uword>(check);
1461 #endif 1486 #endif
1462 1487
1463 writer->WriteObjectImpl(ptr()->object_pool_, kAsReference); 1488 writer->WriteObjectImpl(ptr()->object_pool_, kAsReference);
1464 writer->WriteObjectImpl(ptr()->owner_, kAsReference); 1489 writer->WriteObjectImpl(ptr()->owner_, kAsReference);
1465 writer->WriteObjectImpl(ptr()->exception_handlers_, kAsReference); 1490 writer->WriteObjectImpl(ptr()->exception_handlers_, kAsReference);
1466 writer->WriteObjectImpl(ptr()->pc_descriptors_, kAsReference); 1491 writer->WriteObjectImpl(ptr()->pc_descriptors_, kAsReference);
1467 writer->WriteObjectImpl(ptr()->code_source_map_, kAsReference); 1492 writer->WriteObjectImpl(ptr()->code_source_map_, kAsReference);
1468 writer->WriteObjectImpl(ptr()->stackmaps_, kAsReference); 1493 writer->WriteObjectImpl(ptr()->stackmaps_, kAsReference);
1469 } 1494 }
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after
1920 1945
1921 // Create a descriptor for 'this' variable. 1946 // Create a descriptor for 'this' variable.
1922 context_scope.SetTokenIndexAt(0, TokenPosition::kMinSource); 1947 context_scope.SetTokenIndexAt(0, TokenPosition::kMinSource);
1923 context_scope.SetNameAt(0, Symbols::This()); 1948 context_scope.SetNameAt(0, Symbols::This());
1924 context_scope.SetIsFinalAt(0, true); 1949 context_scope.SetIsFinalAt(0, true);
1925 context_scope.SetIsConstAt(0, false); 1950 context_scope.SetIsConstAt(0, false);
1926 context_scope.SetTypeAt(0, *reader->TypeHandle()); 1951 context_scope.SetTypeAt(0, *reader->TypeHandle());
1927 context_scope.SetContextIndexAt(0, 0); 1952 context_scope.SetContextIndexAt(0, 0);
1928 context_scope.SetContextLevelAt(0, 0); 1953 context_scope.SetContextLevelAt(0, 0);
1929 return context_scope.raw(); 1954 return context_scope.raw();
1955 } else if (kind == Snapshot::kAppWithJIT) {
1956 int32_t num_vars = reader->Read<int32_t>();
1957
1958 ContextScope& context_scope = ContextScope::ZoneHandle();
1959 context_scope = reader->NewContextScope(num_vars);
1960 context_scope.set_is_implicit(false);
1961 reader->AddBackRef(object_id, &context_scope, kIsDeserialized);
1962
1963 READ_OBJECT_FIELDS(context_scope,
1964 context_scope.raw()->from(),
1965 context_scope.raw()->to(num_vars),
1966 kAsInlinedObject);
1967 return context_scope.raw();
1930 } 1968 }
1931 UNREACHABLE(); 1969 UNREACHABLE();
1932 return NULL; 1970 return NULL;
1933 } 1971 }
1934 1972
1935 1973
1936 void RawContextScope::WriteTo(SnapshotWriter* writer, 1974 void RawContextScope::WriteTo(SnapshotWriter* writer,
1937 intptr_t object_id, 1975 intptr_t object_id,
1938 Snapshot::Kind kind, 1976 Snapshot::Kind kind,
1939 bool as_reference) { 1977 bool as_reference) {
(...skipping 10 matching lines...) Expand all
1950 writer->WriteVMIsolateObject(kContextScopeCid); 1988 writer->WriteVMIsolateObject(kContextScopeCid);
1951 writer->WriteTags(writer->GetObjectTags(this)); 1989 writer->WriteTags(writer->GetObjectTags(this));
1952 1990
1953 // Write out is_implicit flag for the context scope. 1991 // Write out is_implicit flag for the context scope.
1954 writer->Write<bool>(true); 1992 writer->Write<bool>(true);
1955 1993
1956 // Write out the type of 'this' the variable. 1994 // Write out the type of 'this' the variable.
1957 writer->WriteObjectImpl(var->type, kAsInlinedObject); 1995 writer->WriteObjectImpl(var->type, kAsInlinedObject);
1958 1996
1959 return; 1997 return;
1998 } else if (kind == Snapshot::kAppWithJIT) {
1999 // Write out the serialization header value for this object.
2000 writer->WriteInlinedObjectHeader(object_id);
2001
2002 // Write out the class and tags information.
2003 writer->WriteVMIsolateObject(kContextScopeCid);
2004 writer->WriteTags(writer->GetObjectTags(this));
2005
2006 // Write out is_implicit flag for the context scope.
2007 writer->Write<bool>(false);
2008 int32_t num_vars = ptr()->num_variables_;
2009 writer->Write<int32_t>(num_vars);
2010
2011 SnapshotWriterVisitor visitor(writer, kAsInlinedObject);
2012 visitor.VisitPointers(from(), to(num_vars));
2013
2014 return;
1960 } 2015 }
1961 UNREACHABLE(); 2016 UNREACHABLE();
1962 } 2017 }
1963 2018
1964 2019
1965 RawICData* ICData::ReadFrom(SnapshotReader* reader, 2020 RawICData* ICData::ReadFrom(SnapshotReader* reader,
1966 intptr_t object_id, 2021 intptr_t object_id,
1967 intptr_t tags, 2022 intptr_t tags,
1968 Snapshot::Kind kind, 2023 Snapshot::Kind kind,
1969 bool as_reference) { 2024 bool as_reference) {
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after
3698 // We do not allow objects with native fields in an isolate message. 3753 // We do not allow objects with native fields in an isolate message.
3699 writer->SetWriteException(Exceptions::kArgument, 3754 writer->SetWriteException(Exceptions::kArgument,
3700 "Illegal argument in isolate message" 3755 "Illegal argument in isolate message"
3701 " : (object is a UserTag)"); 3756 " : (object is a UserTag)");
3702 } else { 3757 } else {
3703 UNREACHABLE(); 3758 UNREACHABLE();
3704 } 3759 }
3705 } 3760 }
3706 3761
3707 } // namespace dart 3762 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698