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/object.h" | 5 #include "vm/object.h" |
6 #include "vm/object_store.h" | 6 #include "vm/object_store.h" |
7 #include "vm/snapshot.h" | 7 #include "vm/snapshot.h" |
8 #include "vm/stub_code.h" | 8 #include "vm/stub_code.h" |
9 #include "vm/symbols.h" | 9 #include "vm/symbols.h" |
10 #include "vm/visitor.h" | 10 #include "vm/visitor.h" |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
61 cls.set_num_own_type_arguments(reader->Read<int16_t>()); | 61 cls.set_num_own_type_arguments(reader->Read<int16_t>()); |
62 cls.set_num_native_fields(reader->Read<uint16_t>()); | 62 cls.set_num_native_fields(reader->Read<uint16_t>()); |
63 cls.set_token_pos(reader->Read<int32_t>()); | 63 cls.set_token_pos(reader->Read<int32_t>()); |
64 cls.set_state_bits(reader->Read<uint16_t>()); | 64 cls.set_state_bits(reader->Read<uint16_t>()); |
65 | 65 |
66 // Set all the object fields. | 66 // Set all the object fields. |
67 // TODO(5411462): Need to assert No GC can happen here, even though | 67 // TODO(5411462): Need to assert No GC can happen here, even though |
68 // allocations may happen. | 68 // allocations may happen. |
69 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); | 69 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); |
70 for (intptr_t i = 0; i <= num_flds; i++) { | 70 for (intptr_t i = 0; i <= num_flds; i++) { |
71 *(cls.raw()->from() + i) = reader->ReadObjectRef(); | 71 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); |
72 cls.StorePointer((cls.raw()->from() + i), | |
73 reader->PassiveObjectHandle()->raw()); | |
72 } | 74 } |
73 } else { | 75 } else { |
74 cls ^= reader->ReadClassId(object_id); | 76 cls ^= reader->ReadClassId(object_id); |
75 } | 77 } |
76 return cls.raw(); | 78 return cls.raw(); |
77 } | 79 } |
78 | 80 |
79 | 81 |
80 void RawClass::WriteTo(SnapshotWriter* writer, | 82 void RawClass::WriteTo(SnapshotWriter* writer, |
81 intptr_t object_id, | 83 intptr_t object_id, |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
524 reader->AddBackRef(object_id, &cls, kIsDeserialized); | 526 reader->AddBackRef(object_id, &cls, kIsDeserialized); |
525 | 527 |
526 // Set the object tags. | 528 // Set the object tags. |
527 cls.set_tags(tags); | 529 cls.set_tags(tags); |
528 | 530 |
529 // Set all the object fields. | 531 // Set all the object fields. |
530 // TODO(5411462): Need to assert No GC can happen here, even though | 532 // TODO(5411462): Need to assert No GC can happen here, even though |
531 // allocations may happen. | 533 // allocations may happen. |
532 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); | 534 intptr_t num_flds = (cls.raw()->to() - cls.raw()->from()); |
533 for (intptr_t i = 0; i <= num_flds; i++) { | 535 for (intptr_t i = 0; i <= num_flds; i++) { |
534 *(cls.raw()->from() + i) = reader->ReadObjectRef(); | 536 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); |
537 cls.StorePointer((cls.raw()->from() + i), | |
538 reader->PassiveObjectHandle()->raw()); | |
535 } | 539 } |
536 | 540 |
537 return cls.raw(); | 541 return cls.raw(); |
538 } | 542 } |
539 | 543 |
540 | 544 |
541 void RawPatchClass::WriteTo(SnapshotWriter* writer, | 545 void RawPatchClass::WriteTo(SnapshotWriter* writer, |
542 intptr_t object_id, | 546 intptr_t object_id, |
543 Snapshot::Kind kind) { | 547 Snapshot::Kind kind) { |
544 ASSERT(writer != NULL); | 548 ASSERT(writer != NULL); |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
633 reader->AddBackRef(object_id, &data, kIsDeserialized); | 637 reader->AddBackRef(object_id, &data, kIsDeserialized); |
634 | 638 |
635 // Set the object tags. | 639 // Set the object tags. |
636 data.set_tags(tags); | 640 data.set_tags(tags); |
637 | 641 |
638 // Set all the object fields. | 642 // Set all the object fields. |
639 // TODO(5411462): Need to assert No GC can happen here, even though | 643 // TODO(5411462): Need to assert No GC can happen here, even though |
640 // allocations may happen. | 644 // allocations may happen. |
641 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); | 645 intptr_t num_flds = (data.raw()->to() - data.raw()->from()); |
642 for (intptr_t i = 0; i <= num_flds; i++) { | 646 for (intptr_t i = 0; i <= num_flds; i++) { |
643 *(data.raw()->from() + i) = reader->ReadObjectRef(); | 647 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); |
648 data.StorePointer((data.raw()->from() + i), | |
649 reader->PassiveObjectHandle()->raw()); | |
644 } | 650 } |
645 | 651 |
646 return data.raw(); | 652 return data.raw(); |
647 } | 653 } |
648 | 654 |
649 | 655 |
650 void RawRedirectionData::WriteTo(SnapshotWriter* writer, | 656 void RawRedirectionData::WriteTo(SnapshotWriter* writer, |
651 intptr_t object_id, | 657 intptr_t object_id, |
652 Snapshot::Kind kind) { | 658 Snapshot::Kind kind) { |
653 ASSERT(writer != NULL); | 659 ASSERT(writer != NULL); |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
694 func.set_deoptimization_counter(reader->Read<int16_t>()); | 700 func.set_deoptimization_counter(reader->Read<int16_t>()); |
695 func.set_kind_tag(reader->Read<uint32_t>()); | 701 func.set_kind_tag(reader->Read<uint32_t>()); |
696 func.set_optimized_instruction_count(reader->Read<uint16_t>()); | 702 func.set_optimized_instruction_count(reader->Read<uint16_t>()); |
697 func.set_optimized_call_site_count(reader->Read<uint16_t>()); | 703 func.set_optimized_call_site_count(reader->Read<uint16_t>()); |
698 | 704 |
699 // Set all the object fields. | 705 // Set all the object fields. |
700 // TODO(5411462): Need to assert No GC can happen here, even though | 706 // TODO(5411462): Need to assert No GC can happen here, even though |
701 // allocations may happen. | 707 // allocations may happen. |
702 intptr_t num_flds = (func.raw()->to_snapshot() - func.raw()->from()); | 708 intptr_t num_flds = (func.raw()->to_snapshot() - func.raw()->from()); |
703 for (intptr_t i = 0; i <= num_flds; i++) { | 709 for (intptr_t i = 0; i <= num_flds; i++) { |
704 *(func.raw()->from() + i) = reader->ReadObjectRef(); | 710 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); |
711 func.StorePointer((func.raw()->from() + i), | |
712 reader->PassiveObjectHandle()->raw()); | |
705 } | 713 } |
706 | 714 |
707 // Initialize all fields that are not part of the snapshot. | 715 // Initialize all fields that are not part of the snapshot. |
708 func.ClearCode(); | 716 func.ClearCode(); |
709 func.set_ic_data_array(Object::null_array()); | 717 func.set_ic_data_array(Object::null_array()); |
710 return func.raw(); | 718 return func.raw(); |
711 } | 719 } |
712 | 720 |
713 | 721 |
714 void RawFunction::WriteTo(SnapshotWriter* writer, | 722 void RawFunction::WriteTo(SnapshotWriter* writer, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
763 field.set_token_pos(reader->Read<int32_t>()); | 771 field.set_token_pos(reader->Read<int32_t>()); |
764 field.set_guarded_cid(reader->Read<int32_t>()); | 772 field.set_guarded_cid(reader->Read<int32_t>()); |
765 field.set_is_nullable(reader->Read<int32_t>()); | 773 field.set_is_nullable(reader->Read<int32_t>()); |
766 field.set_kind_bits(reader->Read<uint8_t>()); | 774 field.set_kind_bits(reader->Read<uint8_t>()); |
767 | 775 |
768 // Set all the object fields. | 776 // Set all the object fields. |
769 // TODO(5411462): Need to assert No GC can happen here, even though | 777 // TODO(5411462): Need to assert No GC can happen here, even though |
770 // allocations may happen. | 778 // allocations may happen. |
771 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); | 779 intptr_t num_flds = (field.raw()->to() - field.raw()->from()); |
772 for (intptr_t i = 0; i <= num_flds; i++) { | 780 for (intptr_t i = 0; i <= num_flds; i++) { |
773 *(field.raw()->from() + i) = reader->ReadObjectRef(); | 781 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); |
782 field.StorePointer((field.raw()->from() + i), | |
783 reader->PassiveObjectHandle()->raw()); | |
774 } | 784 } |
775 | 785 |
776 field.InitializeGuardedListLengthInObjectOffset(); | 786 field.InitializeGuardedListLengthInObjectOffset(); |
777 | 787 |
778 return field.raw(); | 788 return field.raw(); |
779 } | 789 } |
780 | 790 |
781 | 791 |
782 void RawField::WriteTo(SnapshotWriter* writer, | 792 void RawField::WriteTo(SnapshotWriter* writer, |
783 intptr_t object_id, | 793 intptr_t object_id, |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
817 LiteralToken& literal_token = LiteralToken::ZoneHandle( | 827 LiteralToken& literal_token = LiteralToken::ZoneHandle( |
818 reader->isolate(), NEW_OBJECT(LiteralToken)); | 828 reader->isolate(), NEW_OBJECT(LiteralToken)); |
819 reader->AddBackRef(object_id, &literal_token, kIsDeserialized); | 829 reader->AddBackRef(object_id, &literal_token, kIsDeserialized); |
820 | 830 |
821 // Set the object tags. | 831 // Set the object tags. |
822 literal_token.set_tags(tags); | 832 literal_token.set_tags(tags); |
823 | 833 |
824 // Read the token attributes. | 834 // Read the token attributes. |
825 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>()); | 835 Token::Kind token_kind = static_cast<Token::Kind>(reader->Read<int32_t>()); |
826 literal_token.set_kind(token_kind); | 836 literal_token.set_kind(token_kind); |
827 *reader->StringHandle() ^= reader->ReadObjectImpl(); | 837 |
828 literal_token.set_literal(*reader->StringHandle()); | 838 // Set all the object fields. |
829 *reader->PassiveObjectHandle() = reader->ReadObjectImpl(); | 839 // TODO(5411462): Need to assert No GC can happen here, even though |
830 literal_token.set_value(*reader->PassiveObjectHandle()); | 840 // allocations may happen. |
841 intptr_t num_flds = (literal_token.raw()->to() - literal_token.raw()->from()); | |
842 for (intptr_t i = 0; i <= num_flds; i++) { | |
843 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | |
844 literal_token.StorePointer((literal_token.raw()->from() + i), | |
845 reader->PassiveObjectHandle()->raw()); | |
846 } | |
831 | 847 |
832 return literal_token.raw(); | 848 return literal_token.raw(); |
833 } | 849 } |
834 | 850 |
835 | 851 |
836 void RawLiteralToken::WriteTo(SnapshotWriter* writer, | 852 void RawLiteralToken::WriteTo(SnapshotWriter* writer, |
837 intptr_t object_id, | 853 intptr_t object_id, |
838 Snapshot::Kind kind) { | 854 Snapshot::Kind kind) { |
839 ASSERT(writer != NULL); | 855 ASSERT(writer != NULL); |
840 ASSERT(kind != Snapshot::kMessage); | 856 ASSERT(kind != Snapshot::kMessage); |
841 | 857 |
842 // Write out the serialization header value for this object. | 858 // Write out the serialization header value for this object. |
843 writer->WriteInlinedObjectHeader(object_id); | 859 writer->WriteInlinedObjectHeader(object_id); |
844 | 860 |
845 // Write out the class and tags information. | 861 // Write out the class and tags information. |
846 writer->WriteVMIsolateObject(kLiteralTokenCid); | 862 writer->WriteVMIsolateObject(kLiteralTokenCid); |
847 writer->WriteTags(writer->GetObjectTags(this)); | 863 writer->WriteTags(writer->GetObjectTags(this)); |
848 | 864 |
849 // Write out the kind field. | 865 // Write out the kind field. |
850 writer->Write<int32_t>(ptr()->kind_); | 866 writer->Write<int32_t>(ptr()->kind_); |
851 | 867 |
852 // Write out literal and value fields. | 868 // Write out all the object pointer fields. |
853 writer->WriteObjectImpl(ptr()->literal_); | 869 SnapshotWriterVisitor visitor(writer); |
854 writer->WriteObjectImpl(ptr()->value_); | 870 visitor.VisitPointers(from(), to()); |
855 } | 871 } |
856 | 872 |
857 | 873 |
858 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, | 874 RawTokenStream* TokenStream::ReadFrom(SnapshotReader* reader, |
859 intptr_t object_id, | 875 intptr_t object_id, |
860 intptr_t tags, | 876 intptr_t tags, |
861 Snapshot::Kind kind) { | 877 Snapshot::Kind kind) { |
862 ASSERT(reader != NULL); | 878 ASSERT(reader != NULL); |
863 ASSERT(((kind == Snapshot::kScript) && | 879 ASSERT(((kind == Snapshot::kScript) && |
864 !RawObject::IsCreatedFromSnapshot(tags)) || | 880 !RawObject::IsCreatedFromSnapshot(tags)) || |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
931 !RawObject::IsCreatedFromSnapshot(tags)) || | 947 !RawObject::IsCreatedFromSnapshot(tags)) || |
932 (kind == Snapshot::kFull)); | 948 (kind == Snapshot::kFull)); |
933 | 949 |
934 // Allocate script object. | 950 // Allocate script object. |
935 Script& script = Script::ZoneHandle(reader->isolate(), NEW_OBJECT(Script)); | 951 Script& script = Script::ZoneHandle(reader->isolate(), NEW_OBJECT(Script)); |
936 reader->AddBackRef(object_id, &script, kIsDeserialized); | 952 reader->AddBackRef(object_id, &script, kIsDeserialized); |
937 | 953 |
938 // Set the object tags. | 954 // Set the object tags. |
939 script.set_tags(tags); | 955 script.set_tags(tags); |
940 | 956 |
941 // Set all the object fields. | |
942 // TODO(5411462): Need to assert No GC can happen here, even though | |
943 // allocations may happen. | |
944 *reader->StringHandle() ^= reader->ReadObjectImpl(); | |
945 script.set_url(*reader->StringHandle()); | |
946 *reader->StringHandle() ^= String::null(); | |
947 script.set_source(*reader->StringHandle()); | |
948 TokenStream& stream = TokenStream::Handle(); | |
949 stream ^= reader->ReadObjectImpl(); | |
950 script.set_tokens(stream); | |
951 | |
952 script.StoreNonPointer(&script.raw_ptr()->line_offset_, | 957 script.StoreNonPointer(&script.raw_ptr()->line_offset_, |
953 reader->Read<int32_t>()); | 958 reader->Read<int32_t>()); |
954 script.StoreNonPointer(&script.raw_ptr()->col_offset_, | 959 script.StoreNonPointer(&script.raw_ptr()->col_offset_, |
955 reader->Read<int32_t>()); | 960 reader->Read<int32_t>()); |
956 script.StoreNonPointer(&script.raw_ptr()->kind_, | 961 script.StoreNonPointer(&script.raw_ptr()->kind_, |
957 reader->Read<int8_t>()); | 962 reader->Read<int8_t>()); |
958 | 963 |
964 // Set all the object fields. | |
965 // TODO(5411462): Need to assert No GC can happen here, even though | |
966 // allocations may happen. | |
967 intptr_t num_flds = (script.raw()->to_snapshot() - script.raw()->from()); | |
968 for (intptr_t i = 0; i <= num_flds; i++) { | |
969 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | |
970 script.StorePointer((script.raw()->from() + i), | |
971 reader->PassiveObjectHandle()->raw()); | |
972 } | |
973 // Script wasn't allocated with nulls? | |
974 *reader->StringHandle() ^= String::null(); | |
975 script.set_source(*reader->StringHandle()); | |
976 | |
959 return script.raw(); | 977 return script.raw(); |
960 } | 978 } |
961 | 979 |
962 | 980 |
963 void RawScript::WriteTo(SnapshotWriter* writer, | 981 void RawScript::WriteTo(SnapshotWriter* writer, |
964 intptr_t object_id, | 982 intptr_t object_id, |
965 Snapshot::Kind kind) { | 983 Snapshot::Kind kind) { |
966 ASSERT(writer != NULL); | 984 ASSERT(writer != NULL); |
967 ASSERT(tokens_ != TokenStream::null()); | 985 ASSERT(tokens_ != TokenStream::null()); |
968 ASSERT(((kind == Snapshot::kScript) && | 986 ASSERT(((kind == Snapshot::kScript) && |
969 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | 987 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || |
970 (kind == Snapshot::kFull)); | 988 (kind == Snapshot::kFull)); |
971 | 989 |
972 // Write out the serialization header value for this object. | 990 // Write out the serialization header value for this object. |
973 writer->WriteInlinedObjectHeader(object_id); | 991 writer->WriteInlinedObjectHeader(object_id); |
974 | 992 |
975 // Write out the class and tags information. | 993 // Write out the class and tags information. |
976 writer->WriteVMIsolateObject(kScriptCid); | 994 writer->WriteVMIsolateObject(kScriptCid); |
977 writer->WriteTags(writer->GetObjectTags(this)); | 995 writer->WriteTags(writer->GetObjectTags(this)); |
978 | 996 |
979 // Write out all the object pointer fields. | 997 // Write out all the non object fields. |
980 writer->WriteObjectImpl(ptr()->url_); | |
981 writer->WriteObjectImpl(ptr()->tokens_); | |
982 | |
983 writer->Write<int32_t>(ptr()->line_offset_); | 998 writer->Write<int32_t>(ptr()->line_offset_); |
984 writer->Write<int32_t>(ptr()->col_offset_); | 999 writer->Write<int32_t>(ptr()->col_offset_); |
985 writer->Write<int8_t>(ptr()->kind_); | 1000 writer->Write<int8_t>(ptr()->kind_); |
1001 | |
1002 // Write out all the object pointer fields. | |
1003 SnapshotWriterVisitor visitor(writer); | |
1004 visitor.VisitPointers(from(), to_snapshot()); | |
986 } | 1005 } |
987 | 1006 |
988 | 1007 |
989 RawLibrary* Library::ReadFrom(SnapshotReader* reader, | 1008 RawLibrary* Library::ReadFrom(SnapshotReader* reader, |
990 intptr_t object_id, | 1009 intptr_t object_id, |
991 intptr_t tags, | 1010 intptr_t tags, |
992 Snapshot::Kind kind) { | 1011 Snapshot::Kind kind) { |
993 ASSERT(reader != NULL); | 1012 ASSERT(reader != NULL); |
994 ASSERT(kind != Snapshot::kMessage); | 1013 ASSERT(kind != Snapshot::kMessage); |
995 | 1014 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1034 ASSERT(symbol_resolver == NULL); | 1053 ASSERT(symbol_resolver == NULL); |
1035 library.set_native_entry_symbol_resolver(symbol_resolver); | 1054 library.set_native_entry_symbol_resolver(symbol_resolver); |
1036 // The cache of loaded scripts is not serialized. | 1055 // The cache of loaded scripts is not serialized. |
1037 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null()); | 1056 library.StorePointer(&library.raw_ptr()->loaded_scripts_, Array::null()); |
1038 | 1057 |
1039 // Set all the object fields. | 1058 // Set all the object fields. |
1040 // TODO(5411462): Need to assert No GC can happen here, even though | 1059 // TODO(5411462): Need to assert No GC can happen here, even though |
1041 // allocations may happen. | 1060 // allocations may happen. |
1042 intptr_t num_flds = (library.raw()->to() - library.raw()->from()); | 1061 intptr_t num_flds = (library.raw()->to() - library.raw()->from()); |
1043 for (intptr_t i = 0; i <= num_flds; i++) { | 1062 for (intptr_t i = 0; i <= num_flds; i++) { |
1044 *(library.raw()->from() + i) = reader->ReadObjectRef(); | 1063 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); |
1064 library.StorePointer((library.raw()->from() + i), | |
1065 reader->PassiveObjectHandle()->raw()); | |
1045 } | 1066 } |
1046 if (kind != Snapshot::kFull) { | 1067 if (kind != Snapshot::kFull) { |
1047 library.Register(); | 1068 library.Register(); |
1048 } | 1069 } |
1049 } | 1070 } |
1050 return library.raw(); | 1071 return library.raw(); |
1051 } | 1072 } |
1052 | 1073 |
1053 | 1074 |
1054 void RawLibrary::WriteTo(SnapshotWriter* writer, | 1075 void RawLibrary::WriteTo(SnapshotWriter* writer, |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1117 reader->Read<int32_t>()); | 1138 reader->Read<int32_t>()); |
1118 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, | 1139 prefix.StoreNonPointer(&prefix.raw_ptr()->is_deferred_load_, |
1119 reader->Read<bool>()); | 1140 reader->Read<bool>()); |
1120 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); | 1141 prefix.StoreNonPointer(&prefix.raw_ptr()->is_loaded_, reader->Read<bool>()); |
1121 | 1142 |
1122 // Set all the object fields. | 1143 // Set all the object fields. |
1123 // TODO(5411462): Need to assert No GC can happen here, even though | 1144 // TODO(5411462): Need to assert No GC can happen here, even though |
1124 // allocations may happen. | 1145 // allocations may happen. |
1125 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); | 1146 intptr_t num_flds = (prefix.raw()->to() - prefix.raw()->from()); |
1126 for (intptr_t i = 0; i <= num_flds; i++) { | 1147 for (intptr_t i = 0; i <= num_flds; i++) { |
1127 *(prefix.raw()->from() + i) = reader->ReadObjectRef(); | 1148 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); |
1149 prefix.StorePointer((prefix.raw()->from() + i), | |
1150 reader->PassiveObjectHandle()->raw()); | |
1128 } | 1151 } |
1129 | 1152 |
1130 return prefix.raw(); | 1153 return prefix.raw(); |
1131 } | 1154 } |
1132 | 1155 |
1133 | 1156 |
1134 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, | 1157 void RawLibraryPrefix::WriteTo(SnapshotWriter* writer, |
1135 intptr_t object_id, | 1158 intptr_t object_id, |
1136 Snapshot::Kind kind) { | 1159 Snapshot::Kind kind) { |
1137 ASSERT(writer != NULL); | 1160 ASSERT(writer != NULL); |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1172 reader->AddBackRef(object_id, &ns, kIsDeserialized); | 1195 reader->AddBackRef(object_id, &ns, kIsDeserialized); |
1173 | 1196 |
1174 // Set the object tags. | 1197 // Set the object tags. |
1175 ns.set_tags(tags); | 1198 ns.set_tags(tags); |
1176 | 1199 |
1177 // Set all the object fields. | 1200 // Set all the object fields. |
1178 // TODO(5411462): Need to assert No GC can happen here, even though | 1201 // TODO(5411462): Need to assert No GC can happen here, even though |
1179 // allocations may happen. | 1202 // allocations may happen. |
1180 intptr_t num_flds = (ns.raw()->to() - ns.raw()->from()); | 1203 intptr_t num_flds = (ns.raw()->to() - ns.raw()->from()); |
1181 for (intptr_t i = 0; i <= num_flds; i++) { | 1204 for (intptr_t i = 0; i <= num_flds; i++) { |
1182 *(ns.raw()->from() + i) = reader->ReadObjectRef(); | 1205 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); |
1206 ns.StorePointer((ns.raw()->from() + i), | |
1207 reader->PassiveObjectHandle()->raw()); | |
1183 } | 1208 } |
1184 | 1209 |
1185 return ns.raw(); | 1210 return ns.raw(); |
1186 } | 1211 } |
1187 | 1212 |
1188 | 1213 |
1189 void RawNamespace::WriteTo(SnapshotWriter* writer, | 1214 void RawNamespace::WriteTo(SnapshotWriter* writer, |
1190 intptr_t object_id, | 1215 intptr_t object_id, |
1191 Snapshot::Kind kind) { | 1216 Snapshot::Kind kind) { |
1192 ASSERT(writer != NULL); | 1217 ASSERT(writer != NULL); |
(...skipping 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1570 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1595 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1571 | 1596 |
1572 // Set the object tags. | 1597 // Set the object tags. |
1573 result.set_tags(tags); | 1598 result.set_tags(tags); |
1574 | 1599 |
1575 // Set all the object fields. | 1600 // Set all the object fields. |
1576 // TODO(5411462): Need to assert No GC can happen here, even though | 1601 // TODO(5411462): Need to assert No GC can happen here, even though |
1577 // allocations may happen. | 1602 // allocations may happen. |
1578 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); | 1603 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); |
1579 for (intptr_t i = 0; i <= num_flds; i++) { | 1604 for (intptr_t i = 0; i <= num_flds; i++) { |
1580 *(result.raw()->from() + i) = reader->ReadObjectRef(); | 1605 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); |
1606 result.StorePointer((result.raw()->from() + i), | |
1607 reader->PassiveObjectHandle()->raw()); | |
1581 } | 1608 } |
1609 | |
1582 return result.raw(); | 1610 return result.raw(); |
1583 } | 1611 } |
1584 | 1612 |
1585 | 1613 |
1586 void RawUnhandledException::WriteTo(SnapshotWriter* writer, | 1614 void RawUnhandledException::WriteTo(SnapshotWriter* writer, |
1587 intptr_t object_id, | 1615 intptr_t object_id, |
1588 Snapshot::Kind kind) { | 1616 Snapshot::Kind kind) { |
1589 // Write out the serialization header value for this object. | 1617 // Write out the serialization header value for this object. |
1590 writer->WriteInlinedObjectHeader(object_id); | 1618 writer->WriteInlinedObjectHeader(object_id); |
1591 | 1619 |
(...skipping 1065 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2657 | 2685 |
2658 | 2686 |
2659 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader, | 2687 RawStacktrace* Stacktrace::ReadFrom(SnapshotReader* reader, |
2660 intptr_t object_id, | 2688 intptr_t object_id, |
2661 intptr_t tags, | 2689 intptr_t tags, |
2662 Snapshot::Kind kind) { | 2690 Snapshot::Kind kind) { |
2663 if (kind == Snapshot::kFull) { | 2691 if (kind == Snapshot::kFull) { |
2664 Stacktrace& result = Stacktrace::ZoneHandle(reader->isolate(), | 2692 Stacktrace& result = Stacktrace::ZoneHandle(reader->isolate(), |
2665 reader->NewStacktrace()); | 2693 reader->NewStacktrace()); |
2666 reader->AddBackRef(object_id, &result, kIsDeserialized); | 2694 reader->AddBackRef(object_id, &result, kIsDeserialized); |
2667 | 2695 |
siva
2014/10/13 23:28:17
I think we should retain the comment that there ar
rmacnak
2014/10/14 00:49:44
There is a non-object field: the expand_inlined bo
| |
2668 // There are no non object pointer fields. | 2696 // Set all the object fields. |
2669 | 2697 // TODO(5411462): Need to assert No GC can happen here, even though |
2670 // Read all the object pointer fields. | 2698 // allocations may happen. |
2671 Array& array = Array::Handle(reader->isolate()); | 2699 intptr_t num_flds = (result.raw()->to() - result.raw()->from()); |
2672 array ^= reader->ReadObjectRef(); | 2700 for (intptr_t i = 0; i <= num_flds; i++) { |
2673 result.set_code_array(array); | 2701 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); |
2674 array ^= reader->ReadObjectRef(); | 2702 result.StorePointer((result.raw()->from() + i), |
2675 result.set_pc_offset_array(array); | 2703 reader->PassiveObjectHandle()->raw()); |
2676 | 2704 } |
2677 array ^= reader->ReadObjectRef(); | |
2678 result.set_catch_code_array(array); | |
2679 array ^= reader->ReadObjectRef(); | |
2680 result.set_catch_pc_offset_array(array); | |
2681 | 2705 |
2682 bool expand_inlined = reader->Read<bool>(); | 2706 bool expand_inlined = reader->Read<bool>(); |
2683 result.set_expand_inlined(expand_inlined); | 2707 result.set_expand_inlined(expand_inlined); |
2684 | 2708 |
2685 return result.raw(); | 2709 return result.raw(); |
2686 } | 2710 } |
2687 UNREACHABLE(); // Stacktraces are not sent in a snapshot. | 2711 UNREACHABLE(); // Stacktraces are not sent in a snapshot. |
2688 return Stacktrace::null(); | 2712 return Stacktrace::null(); |
2689 } | 2713 } |
2690 | 2714 |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2783 | 2807 |
2784 // Allocate the weak property object. | 2808 // Allocate the weak property object. |
2785 WeakProperty& weak_property = WeakProperty::ZoneHandle( | 2809 WeakProperty& weak_property = WeakProperty::ZoneHandle( |
2786 reader->isolate(), WeakProperty::New(HEAP_SPACE(kind))); | 2810 reader->isolate(), WeakProperty::New(HEAP_SPACE(kind))); |
2787 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); | 2811 reader->AddBackRef(object_id, &weak_property, kIsDeserialized); |
2788 | 2812 |
2789 // Set the object tags. | 2813 // Set the object tags. |
2790 weak_property.set_tags(tags); | 2814 weak_property.set_tags(tags); |
2791 | 2815 |
2792 // Set all the object fields. | 2816 // Set all the object fields. |
2793 weak_property.StorePointer(&weak_property.raw_ptr()->key_, | 2817 // TODO(5411462): Need to assert No GC can happen here, even though |
2794 reader->ReadObjectRef()); | 2818 // allocations may happen. |
2795 weak_property.StorePointer(&weak_property.raw_ptr()->value_, | 2819 intptr_t num_flds = (weak_property.raw()->to() - |
2796 reader->ReadObjectRef()); | 2820 weak_property.raw()->from()); |
2821 for (intptr_t i = 0; i <= num_flds; i++) { | |
2822 (*reader->PassiveObjectHandle()) = reader->ReadObjectRef(); | |
2823 weak_property.StorePointer((weak_property.raw()->from() + i), | |
2824 reader->PassiveObjectHandle()->raw()); | |
2825 } | |
2797 | 2826 |
2798 return weak_property.raw(); | 2827 return weak_property.raw(); |
2799 } | 2828 } |
2800 | 2829 |
2801 | 2830 |
2802 void RawWeakProperty::WriteTo(SnapshotWriter* writer, | 2831 void RawWeakProperty::WriteTo(SnapshotWriter* writer, |
2803 intptr_t object_id, | 2832 intptr_t object_id, |
2804 Snapshot::Kind kind) { | 2833 Snapshot::Kind kind) { |
2805 ASSERT(writer != NULL); | 2834 ASSERT(writer != NULL); |
2806 | 2835 |
2807 // Write out the serialization header value for this object. | 2836 // Write out the serialization header value for this object. |
2808 writer->WriteInlinedObjectHeader(object_id); | 2837 writer->WriteInlinedObjectHeader(object_id); |
2809 | 2838 |
2810 // Write out the class and tags information. | 2839 // Write out the class and tags information. |
2811 writer->WriteIndexedObject(kWeakPropertyCid); | 2840 writer->WriteIndexedObject(kWeakPropertyCid); |
2812 writer->WriteTags(writer->GetObjectTags(this)); | 2841 writer->WriteTags(writer->GetObjectTags(this)); |
2813 | 2842 |
2814 // Write out all the other fields. | 2843 // Write out all the object pointer fields. |
2815 writer->Write<RawObject*>(ptr()->key_); | 2844 SnapshotWriterVisitor visitor(writer); |
2816 writer->Write<RawObject*>(ptr()->value_); | 2845 visitor.VisitPointers(from(), to()); |
2817 } | 2846 } |
2818 | 2847 |
2819 | 2848 |
2820 RawMirrorReference* MirrorReference::ReadFrom(SnapshotReader* reader, | 2849 RawMirrorReference* MirrorReference::ReadFrom(SnapshotReader* reader, |
2821 intptr_t object_id, | 2850 intptr_t object_id, |
2822 intptr_t tags, | 2851 intptr_t tags, |
2823 Snapshot::Kind kind) { | 2852 Snapshot::Kind kind) { |
2824 UNREACHABLE(); | 2853 UNREACHABLE(); |
2825 return MirrorReference::null(); | 2854 return MirrorReference::null(); |
2826 } | 2855 } |
(...skipping 29 matching lines...) Expand all Loading... | |
2856 // We do not allow objects with native fields in an isolate message. | 2885 // We do not allow objects with native fields in an isolate message. |
2857 writer->SetWriteException(Exceptions::kArgument, | 2886 writer->SetWriteException(Exceptions::kArgument, |
2858 "Illegal argument in isolate message" | 2887 "Illegal argument in isolate message" |
2859 " : (object is a UserTag)"); | 2888 " : (object is a UserTag)"); |
2860 } else { | 2889 } else { |
2861 UNREACHABLE(); | 2890 UNREACHABLE(); |
2862 } | 2891 } |
2863 } | 2892 } |
2864 | 2893 |
2865 } // namespace dart | 2894 } // namespace dart |
OLD | NEW |