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 626 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 Loading... |
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) { |
| 751 // Read the code object and fixup entry point. |
752 func.ClearICDataArray(); | 752 func.ClearICDataArray(); |
753 func.ClearCode(); | 753 func.ClearCode(); |
754 // 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 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference); |
| 758 func.set_ic_data_array(*reader->ArrayHandle()); |
| 759 (*reader->CodeHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); |
| 760 func.set_unoptimized_code(*reader->CodeHandle()); |
| 761 if (!reader->CodeHandle()->IsNull()) { |
| 762 func.SetInstructions(*reader->CodeHandle()); |
| 763 func.set_was_compiled(true); |
| 764 } else { |
| 765 func.ClearCode(); |
| 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 Loading... |
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 Loading... |
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 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1429 void RawCode::WriteTo(SnapshotWriter* writer, | 1443 void RawCode::WriteTo(SnapshotWriter* writer, |
1430 intptr_t object_id, | 1444 intptr_t object_id, |
1431 Snapshot::Kind kind, | 1445 Snapshot::Kind kind, |
1432 bool as_reference) { | 1446 bool as_reference) { |
1433 ASSERT(Snapshot::IncludesCode(kind)); | 1447 ASSERT(Snapshot::IncludesCode(kind)); |
1434 ASSERT(Snapshot::IsFull(kind)); | 1448 ASSERT(Snapshot::IsFull(kind)); |
1435 | 1449 |
1436 intptr_t pointer_offsets_length = | 1450 intptr_t pointer_offsets_length = |
1437 Code::PtrOffBits::decode(ptr()->state_bits_); | 1451 Code::PtrOffBits::decode(ptr()->state_bits_); |
1438 if (pointer_offsets_length != 0) { | 1452 if (pointer_offsets_length != 0) { |
1439 // Should only be IA32. | |
1440 FATAL("Cannot serialize code with embedded pointers"); | 1453 FATAL("Cannot serialize code with embedded pointers"); |
1441 } | 1454 } |
| 1455 if (kind == Snapshot::kAppNoJIT) { |
| 1456 // No disabled code in precompilation. |
| 1457 ASSERT(ptr()->instructions_ == ptr()->active_instructions_); |
| 1458 } else { |
| 1459 ASSERT(kind == Snapshot::kAppWithJIT); |
| 1460 // We never include optimized code in JIT precompilation. Deoptimization |
| 1461 // requires code patching and we cannot patch code that is shared between |
| 1462 // isolates and should not mutate memory allocated by the embedder. |
| 1463 bool is_optimized = Code::PtrOffBits::decode(ptr()->state_bits_); |
| 1464 if (is_optimized) { |
| 1465 FATAL("Cannot include optimized code in a JIT snapshot"); |
| 1466 } |
| 1467 } |
1442 | 1468 |
1443 // Write out the serialization header value for this object. | 1469 // Write out the serialization header value for this object. |
1444 writer->WriteInlinedObjectHeader(object_id); | 1470 writer->WriteInlinedObjectHeader(object_id); |
1445 | 1471 |
1446 // Write out the class and tags information. | 1472 // Write out the class and tags information. |
1447 writer->WriteVMIsolateObject(kCodeCid); | 1473 writer->WriteVMIsolateObject(kCodeCid); |
1448 writer->WriteTags(writer->GetObjectTags(this)); | 1474 writer->WriteTags(writer->GetObjectTags(this)); |
1449 | 1475 |
1450 // Write out all the non object fields. | 1476 // Write out all the non object fields. |
1451 writer->Write<int32_t>(ptr()->state_bits_); | 1477 writer->Write<int32_t>(ptr()->state_bits_); |
1452 | 1478 |
1453 // No disabled code in precompilation. | |
1454 ASSERT(ptr()->instructions_ == ptr()->active_instructions_); | |
1455 | |
1456 RawInstructions* instr = ptr()->instructions_; | 1479 RawInstructions* instr = ptr()->instructions_; |
1457 int32_t text_offset = writer->GetInstructionsId(instr, this); | 1480 int32_t text_offset = writer->GetInstructionsId(instr, this); |
1458 writer->Write<int32_t>(text_offset); | 1481 writer->Write<int32_t>(text_offset); |
1459 | 1482 |
1460 #if defined(DEBUG) | 1483 #if defined(DEBUG) |
1461 uword entry = ptr()->entry_point_; | 1484 uword entry = ptr()->entry_point_; |
1462 intptr_t instructions_size = Utils::RoundUp(instr->size_, | 1485 intptr_t instructions_size = Utils::RoundUp(instr->size_, |
1463 OS::PreferredCodeAlignment()); | 1486 OS::PreferredCodeAlignment()); |
1464 uword check = Checksum(entry, instructions_size); | 1487 uword check = Checksum(entry, instructions_size); |
1465 writer->Write<uword>(check); | 1488 writer->Write<uword>(check); |
(...skipping 439 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1905 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader, | 1928 RawContextScope* ContextScope::ReadFrom(SnapshotReader* reader, |
1906 intptr_t object_id, | 1929 intptr_t object_id, |
1907 intptr_t tags, | 1930 intptr_t tags, |
1908 Snapshot::Kind kind, | 1931 Snapshot::Kind kind, |
1909 bool as_reference) { | 1932 bool as_reference) { |
1910 ASSERT(reader != NULL); | 1933 ASSERT(reader != NULL); |
1911 | 1934 |
1912 // Allocate context object. | 1935 // Allocate context object. |
1913 bool is_implicit = reader->Read<bool>(); | 1936 bool is_implicit = reader->Read<bool>(); |
1914 if (is_implicit) { | 1937 if (is_implicit) { |
1915 ContextScope& context_scope = ContextScope::ZoneHandle(); | 1938 ContextScope& context_scope = ContextScope::ZoneHandle(reader->zone()); |
1916 if (Snapshot::IsFull(kind)) { | 1939 if (Snapshot::IsFull(kind)) { |
1917 context_scope = reader->NewContextScope(1); | 1940 context_scope = reader->NewContextScope(1); |
1918 context_scope.set_is_implicit(true); | 1941 context_scope.set_is_implicit(true); |
1919 } else { | 1942 } else { |
1920 context_scope = ContextScope::New(1, true); | 1943 context_scope = ContextScope::New(1, true); |
1921 } | 1944 } |
1922 reader->AddBackRef(object_id, &context_scope, kIsDeserialized); | 1945 reader->AddBackRef(object_id, &context_scope, kIsDeserialized); |
1923 | 1946 |
1924 *reader->TypeHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); | 1947 *reader->TypeHandle() ^= reader->ReadObjectImpl(kAsInlinedObject); |
1925 | 1948 |
1926 // Create a descriptor for 'this' variable. | 1949 // Create a descriptor for 'this' variable. |
1927 context_scope.SetTokenIndexAt(0, TokenPosition::kMinSource); | 1950 context_scope.SetTokenIndexAt(0, TokenPosition::kMinSource); |
1928 context_scope.SetNameAt(0, Symbols::This()); | 1951 context_scope.SetNameAt(0, Symbols::This()); |
1929 context_scope.SetIsFinalAt(0, true); | 1952 context_scope.SetIsFinalAt(0, true); |
1930 context_scope.SetIsConstAt(0, false); | 1953 context_scope.SetIsConstAt(0, false); |
1931 context_scope.SetTypeAt(0, *reader->TypeHandle()); | 1954 context_scope.SetTypeAt(0, *reader->TypeHandle()); |
1932 context_scope.SetContextIndexAt(0, 0); | 1955 context_scope.SetContextIndexAt(0, 0); |
1933 context_scope.SetContextLevelAt(0, 0); | 1956 context_scope.SetContextLevelAt(0, 0); |
1934 return context_scope.raw(); | 1957 return context_scope.raw(); |
| 1958 } else if (kind == Snapshot::kAppWithJIT) { |
| 1959 int32_t num_vars = reader->Read<int32_t>(); |
| 1960 |
| 1961 ContextScope& context_scope = ContextScope::ZoneHandle(reader->zone()); |
| 1962 context_scope = reader->NewContextScope(num_vars); |
| 1963 context_scope.set_is_implicit(false); |
| 1964 reader->AddBackRef(object_id, &context_scope, kIsDeserialized); |
| 1965 |
| 1966 READ_OBJECT_FIELDS(context_scope, |
| 1967 context_scope.raw()->from(), |
| 1968 context_scope.raw()->to(num_vars), |
| 1969 kAsInlinedObject); |
| 1970 return context_scope.raw(); |
1935 } | 1971 } |
1936 UNREACHABLE(); | 1972 UNREACHABLE(); |
1937 return NULL; | 1973 return NULL; |
1938 } | 1974 } |
1939 | 1975 |
1940 | 1976 |
1941 void RawContextScope::WriteTo(SnapshotWriter* writer, | 1977 void RawContextScope::WriteTo(SnapshotWriter* writer, |
1942 intptr_t object_id, | 1978 intptr_t object_id, |
1943 Snapshot::Kind kind, | 1979 Snapshot::Kind kind, |
1944 bool as_reference) { | 1980 bool as_reference) { |
(...skipping 10 matching lines...) Expand all Loading... |
1955 writer->WriteVMIsolateObject(kContextScopeCid); | 1991 writer->WriteVMIsolateObject(kContextScopeCid); |
1956 writer->WriteTags(writer->GetObjectTags(this)); | 1992 writer->WriteTags(writer->GetObjectTags(this)); |
1957 | 1993 |
1958 // Write out is_implicit flag for the context scope. | 1994 // Write out is_implicit flag for the context scope. |
1959 writer->Write<bool>(true); | 1995 writer->Write<bool>(true); |
1960 | 1996 |
1961 // Write out the type of 'this' the variable. | 1997 // Write out the type of 'this' the variable. |
1962 writer->WriteObjectImpl(var->type, kAsInlinedObject); | 1998 writer->WriteObjectImpl(var->type, kAsInlinedObject); |
1963 | 1999 |
1964 return; | 2000 return; |
| 2001 } else if (kind == Snapshot::kAppWithJIT) { |
| 2002 // Write out the serialization header value for this object. |
| 2003 writer->WriteInlinedObjectHeader(object_id); |
| 2004 |
| 2005 // Write out the class and tags information. |
| 2006 writer->WriteVMIsolateObject(kContextScopeCid); |
| 2007 writer->WriteTags(writer->GetObjectTags(this)); |
| 2008 |
| 2009 // Write out is_implicit flag for the context scope. |
| 2010 writer->Write<bool>(false); |
| 2011 int32_t num_vars = ptr()->num_variables_; |
| 2012 writer->Write<int32_t>(num_vars); |
| 2013 |
| 2014 SnapshotWriterVisitor visitor(writer, kAsInlinedObject); |
| 2015 visitor.VisitPointers(from(), to(num_vars)); |
| 2016 |
| 2017 return; |
1965 } | 2018 } |
1966 UNREACHABLE(); | 2019 UNREACHABLE(); |
1967 } | 2020 } |
1968 | 2021 |
1969 | 2022 |
1970 RawICData* ICData::ReadFrom(SnapshotReader* reader, | 2023 RawICData* ICData::ReadFrom(SnapshotReader* reader, |
1971 intptr_t object_id, | 2024 intptr_t object_id, |
1972 intptr_t tags, | 2025 intptr_t tags, |
1973 Snapshot::Kind kind, | 2026 Snapshot::Kind kind, |
1974 bool as_reference) { | 2027 bool as_reference) { |
(...skipping 1728 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3703 // We do not allow objects with native fields in an isolate message. | 3756 // We do not allow objects with native fields in an isolate message. |
3704 writer->SetWriteException(Exceptions::kArgument, | 3757 writer->SetWriteException(Exceptions::kArgument, |
3705 "Illegal argument in isolate message" | 3758 "Illegal argument in isolate message" |
3706 " : (object is a UserTag)"); | 3759 " : (object is a UserTag)"); |
3707 } else { | 3760 } else { |
3708 UNREACHABLE(); | 3761 UNREACHABLE(); |
3709 } | 3762 } |
3710 } | 3763 } |
3711 | 3764 |
3712 } // namespace dart | 3765 } // namespace dart |
OLD | NEW |