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 523 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
534 Snapshot::Kind kind) { | 534 Snapshot::Kind kind) { |
535 ASSERT(reader != NULL); | 535 ASSERT(reader != NULL); |
536 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 536 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
537 | 537 |
538 // Allocate closure data object. | 538 // Allocate closure data object. |
539 ClosureData& data = ClosureData::ZoneHandle( | 539 ClosureData& data = ClosureData::ZoneHandle( |
540 reader->zone(), NEW_OBJECT(ClosureData)); | 540 reader->zone(), NEW_OBJECT(ClosureData)); |
541 reader->AddBackRef(object_id, &data, kIsDeserialized); | 541 reader->AddBackRef(object_id, &data, kIsDeserialized); |
542 | 542 |
543 // Set all the object fields. | 543 // Set all the object fields. |
544 READ_OBJECT_FIELDS(data, data.raw()->from(), data.raw()->to(), kAsReference); | 544 READ_OBJECT_FIELDS(data, |
545 data.raw()->from(), data.raw()->to(), | |
546 kAsInlinedObject); | |
545 | 547 |
546 return data.raw(); | 548 return data.raw(); |
547 } | 549 } |
548 | 550 |
549 | 551 |
550 void RawClosureData::WriteTo(SnapshotWriter* writer, | 552 void RawClosureData::WriteTo(SnapshotWriter* writer, |
551 intptr_t object_id, | 553 intptr_t object_id, |
552 Snapshot::Kind kind) { | 554 Snapshot::Kind kind) { |
553 ASSERT(writer != NULL); | 555 ASSERT(writer != NULL); |
554 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 556 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
590 Snapshot::Kind kind) { | 592 Snapshot::Kind kind) { |
591 ASSERT(reader != NULL); | 593 ASSERT(reader != NULL); |
592 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 594 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
593 | 595 |
594 // Allocate redirection data object. | 596 // Allocate redirection data object. |
595 RedirectionData& data = RedirectionData::ZoneHandle( | 597 RedirectionData& data = RedirectionData::ZoneHandle( |
596 reader->zone(), NEW_OBJECT(RedirectionData)); | 598 reader->zone(), NEW_OBJECT(RedirectionData)); |
597 reader->AddBackRef(object_id, &data, kIsDeserialized); | 599 reader->AddBackRef(object_id, &data, kIsDeserialized); |
598 | 600 |
599 // Set all the object fields. | 601 // Set all the object fields. |
600 READ_OBJECT_FIELDS(data, data.raw()->from(), data.raw()->to(), kAsReference); | 602 READ_OBJECT_FIELDS(data, |
603 data.raw()->from(), data.raw()->to(), | |
604 kAsReference); | |
601 | 605 |
602 return data.raw(); | 606 return data.raw(); |
603 } | 607 } |
604 | 608 |
605 | 609 |
606 void RawRedirectionData::WriteTo(SnapshotWriter* writer, | 610 void RawRedirectionData::WriteTo(SnapshotWriter* writer, |
607 intptr_t object_id, | 611 intptr_t object_id, |
608 Snapshot::Kind kind) { | 612 Snapshot::Kind kind) { |
609 ASSERT(writer != NULL); | 613 ASSERT(writer != NULL); |
610 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 614 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
647 func.set_optimized_instruction_count(reader->Read<uint16_t>()); | 651 func.set_optimized_instruction_count(reader->Read<uint16_t>()); |
648 func.set_optimized_call_site_count(reader->Read<uint16_t>()); | 652 func.set_optimized_call_site_count(reader->Read<uint16_t>()); |
649 | 653 |
650 // Set all the object fields. | 654 // Set all the object fields. |
651 bool is_optimized = func.usage_counter() != 0; | 655 bool is_optimized = func.usage_counter() != 0; |
652 RawObject** toobj = reader->snapshot_code() ? func.raw()->to() : | 656 RawObject** toobj = reader->snapshot_code() ? func.raw()->to() : |
653 (is_optimized ? func.raw()->to_optimized_snapshot() : | 657 (is_optimized ? func.raw()->to_optimized_snapshot() : |
654 func.raw()->to_snapshot()); | 658 func.raw()->to_snapshot()); |
655 READ_OBJECT_FIELDS(func, | 659 READ_OBJECT_FIELDS(func, |
656 func.raw()->from(), toobj, | 660 func.raw()->from(), toobj, |
657 kAsInlinedObject); | 661 kAsReference); |
658 if (!reader->snapshot_code()) { | 662 if (!reader->snapshot_code()) { |
659 // Initialize all fields that are not part of the snapshot. | 663 // Initialize all fields that are not part of the snapshot. |
660 if (!is_optimized) { | 664 if (!is_optimized) { |
661 func.ClearICDataArray(); | 665 func.ClearICDataArray(); |
662 } | 666 } |
663 func.ClearCode(); | 667 func.ClearCode(); |
664 } else { | 668 } else { |
665 // Fix entry point. | 669 // Fix entry point. |
666 (*reader->CodeHandle()) = func.CurrentCode(); | 670 (*reader->CodeHandle()) = func.CurrentCode(); |
667 uword new_entry = (*reader->CodeHandle()).EntryPoint(); | 671 uword new_entry = (*reader->CodeHandle()).EntryPoint(); |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
719 writer->Write<int16_t>(ptr()->num_optional_parameters_); | 723 writer->Write<int16_t>(ptr()->num_optional_parameters_); |
720 writer->Write<int16_t>(ptr()->deoptimization_counter_); | 724 writer->Write<int16_t>(ptr()->deoptimization_counter_); |
721 writer->Write<uint32_t>(ptr()->kind_tag_); | 725 writer->Write<uint32_t>(ptr()->kind_tag_); |
722 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); | 726 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); |
723 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); | 727 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); |
724 | 728 |
725 // Write out all the object pointer fields. | 729 // Write out all the object pointer fields. |
726 RawObject** toobj = | 730 RawObject** toobj = |
727 writer->snapshot_code() ? to() : | 731 writer->snapshot_code() ? to() : |
728 (is_optimized ? to_optimized_snapshot() : to_snapshot()); | 732 (is_optimized ? to_optimized_snapshot() : to_snapshot()); |
729 SnapshotWriterVisitor visitor(writer, kAsInlinedObject); | 733 SnapshotWriterVisitor visitor(writer, kAsReference); |
730 visitor.VisitPointers(from(), toobj); | 734 visitor.VisitPointers(from(), toobj); |
731 } else { | 735 } else { |
732 writer->WriteFunctionId(this, owner_is_class); | 736 writer->WriteFunctionId(this, owner_is_class); |
733 } | 737 } |
734 } | 738 } |
735 | 739 |
736 | 740 |
737 RawField* Field::ReadFrom(SnapshotReader* reader, | 741 RawField* Field::ReadFrom(SnapshotReader* reader, |
738 intptr_t object_id, | 742 intptr_t object_id, |
739 intptr_t tags, | 743 intptr_t tags, |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1193 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0)); | 1197 Code& result = Code::ZoneHandle(reader->zone(), NEW_OBJECT_WITH_LEN(Code, 0)); |
1194 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1198 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1195 | 1199 |
1196 result.set_compile_timestamp(reader->Read<int64_t>()); | 1200 result.set_compile_timestamp(reader->Read<int64_t>()); |
1197 result.set_state_bits(reader->Read<int32_t>()); | 1201 result.set_state_bits(reader->Read<int32_t>()); |
1198 result.set_lazy_deopt_pc_offset(reader->Read<int32_t>()); | 1202 result.set_lazy_deopt_pc_offset(reader->Read<int32_t>()); |
1199 | 1203 |
1200 // Set all the object fields. | 1204 // Set all the object fields. |
1201 READ_OBJECT_FIELDS(result, | 1205 READ_OBJECT_FIELDS(result, |
1202 result.raw()->from(), result.raw()->to(), | 1206 result.raw()->from(), result.raw()->to(), |
1203 kAsInlinedObject); | 1207 kAsReference); |
1204 | 1208 |
1205 // Fix entry point. | 1209 // Fix entry point. |
1206 uword new_entry = result.EntryPoint(); | 1210 uword new_entry = result.EntryPoint(); |
1207 ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry)); | 1211 ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry)); |
1208 result.StoreNonPointer(&result.raw_ptr()->entry_point_, new_entry); | 1212 result.StoreNonPointer(&result.raw_ptr()->entry_point_, new_entry); |
1209 | 1213 |
1210 return result.raw(); | 1214 return result.raw(); |
1211 } | 1215 } |
1212 | 1216 |
1213 | 1217 |
(...skipping 16 matching lines...) Expand all Loading... | |
1230 // Write out the class and tags information. | 1234 // Write out the class and tags information. |
1231 writer->WriteVMIsolateObject(kCodeCid); | 1235 writer->WriteVMIsolateObject(kCodeCid); |
1232 writer->WriteTags(writer->GetObjectTags(this)); | 1236 writer->WriteTags(writer->GetObjectTags(this)); |
1233 | 1237 |
1234 // Write out all the non object fields. | 1238 // Write out all the non object fields. |
1235 writer->Write<int64_t>(ptr()->compile_timestamp_); | 1239 writer->Write<int64_t>(ptr()->compile_timestamp_); |
1236 writer->Write<int32_t>(ptr()->state_bits_); | 1240 writer->Write<int32_t>(ptr()->state_bits_); |
1237 writer->Write<int32_t>(ptr()->lazy_deopt_pc_offset_); | 1241 writer->Write<int32_t>(ptr()->lazy_deopt_pc_offset_); |
1238 | 1242 |
1239 // Write out all the object pointer fields. | 1243 // Write out all the object pointer fields. |
1240 SnapshotWriterVisitor visitor(writer, kAsInlinedObject); | 1244 SnapshotWriterVisitor visitor(writer, kAsReference); |
1241 visitor.VisitPointers(from(), to()); | 1245 visitor.VisitPointers(from(), to()); |
1242 | 1246 |
1243 writer->SetInstructionsCode(ptr()->instructions_, this); | 1247 writer->SetInstructionsCode(ptr()->instructions_, this); |
1244 } | 1248 } |
1245 | 1249 |
1246 | 1250 |
1247 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader, | 1251 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader, |
1248 intptr_t object_id, | 1252 intptr_t object_id, |
1249 intptr_t tags, | 1253 intptr_t tags, |
1250 Snapshot::Kind kind) { | 1254 Snapshot::Kind kind) { |
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1302 TypedData::Handle(reader->NewTypedData(kTypedDataInt8ArrayCid, length)); | 1306 TypedData::Handle(reader->NewTypedData(kTypedDataInt8ArrayCid, length)); |
1303 result.set_info_array(info_array); | 1307 result.set_info_array(info_array); |
1304 | 1308 |
1305 NoSafepointScope no_safepoint; | 1309 NoSafepointScope no_safepoint; |
1306 for (intptr_t i = 0; i < length; i++) { | 1310 for (intptr_t i = 0; i < length; i++) { |
1307 ObjectPool::EntryType entry_type = | 1311 ObjectPool::EntryType entry_type = |
1308 static_cast<ObjectPool::EntryType>(reader->Read<int8_t>()); | 1312 static_cast<ObjectPool::EntryType>(reader->Read<int8_t>()); |
1309 *reinterpret_cast<int8_t*>(info_array.DataAddr(i)) = entry_type; | 1313 *reinterpret_cast<int8_t*>(info_array.DataAddr(i)) = entry_type; |
1310 switch (entry_type) { | 1314 switch (entry_type) { |
1311 case ObjectPool::kTaggedObject: { | 1315 case ObjectPool::kTaggedObject: { |
1312 (*reader->PassiveObjectHandle()) = reader->ReadObjectImpl(kAsReference); | 1316 (*reader->PassiveObjectHandle()) = |
1317 reader->ReadObjectImpl(kAsInlinedObject); | |
1313 result.SetObjectAt(i, *(reader->PassiveObjectHandle())); | 1318 result.SetObjectAt(i, *(reader->PassiveObjectHandle())); |
1314 break; | 1319 break; |
1315 } | 1320 } |
1316 case ObjectPool::kImmediate: { | 1321 case ObjectPool::kImmediate: { |
1317 intptr_t raw_value = reader->Read<intptr_t>(); | 1322 intptr_t raw_value = reader->Read<intptr_t>(); |
1318 result.SetRawValueAt(i, raw_value); | 1323 result.SetRawValueAt(i, raw_value); |
1319 break; | 1324 break; |
1320 } | 1325 } |
1321 case ObjectPool::kNativeEntry: { | 1326 case ObjectPool::kNativeEntry: { |
1322 // Read nothing. Initialize with the lazy link entry. | 1327 // Read nothing. Initialize with the lazy link entry. |
(...skipping 28 matching lines...) Expand all Loading... | |
1351 ASSERT(info_array != TypedData::null()); | 1356 ASSERT(info_array != TypedData::null()); |
1352 | 1357 |
1353 writer->Write<intptr_t>(length); | 1358 writer->Write<intptr_t>(length); |
1354 for (intptr_t i = 0; i < length; i++) { | 1359 for (intptr_t i = 0; i < length; i++) { |
1355 ObjectPool::EntryType entry_type = | 1360 ObjectPool::EntryType entry_type = |
1356 static_cast<ObjectPool::EntryType>(info_array->data()[i]); | 1361 static_cast<ObjectPool::EntryType>(info_array->data()[i]); |
1357 writer->Write<int8_t>(entry_type); | 1362 writer->Write<int8_t>(entry_type); |
1358 Entry& entry = ptr()->data()[i]; | 1363 Entry& entry = ptr()->data()[i]; |
1359 switch (entry_type) { | 1364 switch (entry_type) { |
1360 case ObjectPool::kTaggedObject: { | 1365 case ObjectPool::kTaggedObject: { |
1361 writer->WriteObjectImpl(entry.raw_obj_, kAsReference); | 1366 writer->WriteObjectImpl(entry.raw_obj_, kAsInlinedObject); |
1362 break; | 1367 break; |
1363 } | 1368 } |
1364 case ObjectPool::kImmediate: { | 1369 case ObjectPool::kImmediate: { |
1365 writer->Write<intptr_t>(entry.raw_value_); | 1370 writer->Write<intptr_t>(entry.raw_value_); |
1366 break; | 1371 break; |
1367 } | 1372 } |
1368 case ObjectPool::kNativeEntry: { | 1373 case ObjectPool::kNativeEntry: { |
1369 // Write nothing. Will initialize with the lazy link entry. | 1374 // Write nothing. Will initialize with the lazy link entry. |
1370 break; | 1375 break; |
1371 } | 1376 } |
(...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1699 | 1704 |
1700 ICData& result = ICData::ZoneHandle(reader->zone(), NEW_OBJECT(ICData)); | 1705 ICData& result = ICData::ZoneHandle(reader->zone(), NEW_OBJECT(ICData)); |
1701 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1706 reader->AddBackRef(object_id, &result, kIsDeserialized); |
1702 | 1707 |
1703 result.set_deopt_id(reader->Read<int32_t>()); | 1708 result.set_deopt_id(reader->Read<int32_t>()); |
1704 result.set_state_bits(reader->Read<uint32_t>()); | 1709 result.set_state_bits(reader->Read<uint32_t>()); |
1705 | 1710 |
1706 // Set all the object fields. | 1711 // Set all the object fields. |
1707 READ_OBJECT_FIELDS(result, | 1712 READ_OBJECT_FIELDS(result, |
1708 result.raw()->from(), result.raw()->to(), | 1713 result.raw()->from(), result.raw()->to(), |
1709 kAsReference); | 1714 kAsInlinedObject); |
1710 | 1715 |
1711 return result.raw(); | 1716 return result.raw(); |
1712 } | 1717 } |
1713 | 1718 |
1714 | 1719 |
1715 void RawICData::WriteTo(SnapshotWriter* writer, | 1720 void RawICData::WriteTo(SnapshotWriter* writer, |
1716 intptr_t object_id, | 1721 intptr_t object_id, |
1717 Snapshot::Kind kind) { | 1722 Snapshot::Kind kind) { |
1718 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 1723 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
1719 | 1724 |
1720 // Write out the serialization header value for this object. | 1725 // Write out the serialization header value for this object. |
1721 writer->WriteInlinedObjectHeader(object_id); | 1726 writer->WriteInlinedObjectHeader(object_id); |
1722 | 1727 |
1723 // Write out the class and tags information. | 1728 // Write out the class and tags information. |
1724 writer->WriteVMIsolateObject(kICDataCid); | 1729 writer->WriteVMIsolateObject(kICDataCid); |
1725 writer->WriteTags(writer->GetObjectTags(this)); | 1730 writer->WriteTags(writer->GetObjectTags(this)); |
1726 | 1731 |
1727 // Write out all the non object fields. | 1732 // Write out all the non object fields. |
1728 writer->Write<int32_t>(ptr()->deopt_id_); | 1733 writer->Write<int32_t>(ptr()->deopt_id_); |
1729 writer->Write<uint32_t>(ptr()->state_bits_); | 1734 writer->Write<uint32_t>(ptr()->state_bits_); |
1730 | 1735 |
1731 // Write out all the object pointer fields. | 1736 // Write out all the object pointer fields. |
1732 SnapshotWriterVisitor visitor(writer); | 1737 SnapshotWriterVisitor visitor(writer, kAsInlinedObject); |
Florian Schneider
2015/09/23 12:23:39
I think it would be safer to get rid of the defaul
rmacnak
2015/09/23 18:12:04
Done.
| |
1733 visitor.VisitPointers(from(), to()); | 1738 visitor.VisitPointers(from(), to()); |
1734 } | 1739 } |
1735 | 1740 |
1736 | 1741 |
1737 RawMegamorphicCache* MegamorphicCache::ReadFrom(SnapshotReader* reader, | 1742 RawMegamorphicCache* MegamorphicCache::ReadFrom(SnapshotReader* reader, |
1738 intptr_t object_id, | 1743 intptr_t object_id, |
1739 intptr_t tags, | 1744 intptr_t tags, |
1740 Snapshot::Kind kind) { | 1745 Snapshot::Kind kind) { |
1741 ASSERT(reader->snapshot_code()); | 1746 ASSERT(reader->snapshot_code()); |
1742 ASSERT(kind == Snapshot::kFull); | 1747 ASSERT(kind == Snapshot::kFull); |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2110 ASSERT(writer != NULL); | 2115 ASSERT(writer != NULL); |
2111 | 2116 |
2112 // Write out the serialization header value for this object. | 2117 // Write out the serialization header value for this object. |
2113 writer->WriteInlinedObjectHeader(object_id); | 2118 writer->WriteInlinedObjectHeader(object_id); |
2114 | 2119 |
2115 // Write out the class and tags information. | 2120 // Write out the class and tags information. |
2116 writer->WriteIndexedObject(kBigintCid); | 2121 writer->WriteIndexedObject(kBigintCid); |
2117 writer->WriteTags(writer->GetObjectTags(this)); | 2122 writer->WriteTags(writer->GetObjectTags(this)); |
2118 | 2123 |
2119 // Write out all the object pointer fields. | 2124 // Write out all the object pointer fields. |
2120 SnapshotWriterVisitor visitor(writer, false); | 2125 SnapshotWriterVisitor visitor(writer, false); |
Florian Schneider
2015/09/23 12:23:39
s/false/kInlinedObject/
rmacnak
2015/09/23 18:12:04
Done.
| |
2121 visitor.VisitPointers(from(), to()); | 2126 visitor.VisitPointers(from(), to()); |
2122 } | 2127 } |
2123 | 2128 |
2124 | 2129 |
2125 RawDouble* Double::ReadFrom(SnapshotReader* reader, | 2130 RawDouble* Double::ReadFrom(SnapshotReader* reader, |
2126 intptr_t object_id, | 2131 intptr_t object_id, |
2127 intptr_t tags, | 2132 intptr_t tags, |
2128 Snapshot::Kind kind) { | 2133 Snapshot::Kind kind) { |
2129 ASSERT(reader != NULL); | 2134 ASSERT(reader != NULL); |
2130 ASSERT(kind != Snapshot::kMessage); | 2135 ASSERT(kind != Snapshot::kMessage); |
(...skipping 1147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3278 // We do not allow objects with native fields in an isolate message. | 3283 // We do not allow objects with native fields in an isolate message. |
3279 writer->SetWriteException(Exceptions::kArgument, | 3284 writer->SetWriteException(Exceptions::kArgument, |
3280 "Illegal argument in isolate message" | 3285 "Illegal argument in isolate message" |
3281 " : (object is a UserTag)"); | 3286 " : (object is a UserTag)"); |
3282 } else { | 3287 } else { |
3283 UNREACHABLE(); | 3288 UNREACHABLE(); |
3284 } | 3289 } |
3285 } | 3290 } |
3286 | 3291 |
3287 } // namespace dart | 3292 } // namespace dart |
OLD | NEW |