| 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 1288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1299 | 1299 |
| 1300 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader, | 1300 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader, |
| 1301 intptr_t object_id, | 1301 intptr_t object_id, |
| 1302 intptr_t tags, | 1302 intptr_t tags, |
| 1303 Snapshot::Kind kind) { | 1303 Snapshot::Kind kind) { |
| 1304 ASSERT(reader->snapshot_code()); | 1304 ASSERT(reader->snapshot_code()); |
| 1305 ASSERT(kind == Snapshot::kFull); | 1305 ASSERT(kind == Snapshot::kFull); |
| 1306 | 1306 |
| 1307 intptr_t length = reader->Read<intptr_t>(); | 1307 intptr_t length = reader->Read<intptr_t>(); |
| 1308 | 1308 |
| 1309 ObjectPool& result = | 1309 ObjectPool* result = |
| 1310 ObjectPool::ZoneHandle(reader->zone(), | 1310 reinterpret_cast<ObjectPool*>(reader->GetBackRef(object_id)); |
| 1311 NEW_OBJECT_WITH_LEN(ObjectPool, length)); | 1311 if (result == NULL) { |
| 1312 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1312 result = |
| 1313 &(ObjectPool::ZoneHandle(reader->zone(), |
| 1314 NEW_OBJECT_WITH_LEN(ObjectPool, length))); |
| 1315 reader->AddBackRef(object_id, result, kIsDeserialized); |
| 1316 } |
| 1313 | 1317 |
| 1314 const TypedData& info_array = | 1318 const TypedData& info_array = |
| 1315 TypedData::Handle(reader->NewTypedData(kTypedDataInt8ArrayCid, length)); | 1319 TypedData::Handle(reader->NewTypedData(kTypedDataInt8ArrayCid, length)); |
| 1316 result.set_info_array(info_array); | 1320 result->set_info_array(info_array); |
| 1317 | 1321 |
| 1318 NoSafepointScope no_safepoint; | 1322 NoSafepointScope no_safepoint; |
| 1319 for (intptr_t i = 0; i < length; i++) { | 1323 for (intptr_t i = 0; i < length; i++) { |
| 1320 ObjectPool::EntryType entry_type = | 1324 ObjectPool::EntryType entry_type = |
| 1321 static_cast<ObjectPool::EntryType>(reader->Read<int8_t>()); | 1325 static_cast<ObjectPool::EntryType>(reader->Read<int8_t>()); |
| 1322 *reinterpret_cast<int8_t*>(info_array.DataAddr(i)) = entry_type; | 1326 *reinterpret_cast<int8_t*>(info_array.DataAddr(i)) = entry_type; |
| 1323 switch (entry_type) { | 1327 switch (entry_type) { |
| 1324 case ObjectPool::kTaggedObject: { | 1328 case ObjectPool::kTaggedObject: { |
| 1325 (*reader->PassiveObjectHandle()) = | 1329 (*reader->PassiveObjectHandle()) = |
| 1326 reader->ReadObjectImpl(kAsInlinedObject); | 1330 reader->ReadObjectImpl(kAsReference); |
| 1327 result.SetObjectAt(i, *(reader->PassiveObjectHandle())); | 1331 result->SetObjectAt(i, *(reader->PassiveObjectHandle())); |
| 1328 break; | 1332 break; |
| 1329 } | 1333 } |
| 1330 case ObjectPool::kImmediate: { | 1334 case ObjectPool::kImmediate: { |
| 1331 intptr_t raw_value = reader->Read<intptr_t>(); | 1335 intptr_t raw_value = reader->Read<intptr_t>(); |
| 1332 result.SetRawValueAt(i, raw_value); | 1336 result->SetRawValueAt(i, raw_value); |
| 1333 break; | 1337 break; |
| 1334 } | 1338 } |
| 1335 case ObjectPool::kNativeEntry: { | 1339 case ObjectPool::kNativeEntry: { |
| 1336 // Read nothing. Initialize with the lazy link entry. | 1340 // Read nothing. Initialize with the lazy link entry. |
| 1337 uword new_entry = NativeEntry::LinkNativeCallEntry(); | 1341 uword new_entry = NativeEntry::LinkNativeCallEntry(); |
| 1338 result.SetRawValueAt(i, static_cast<intptr_t>(new_entry)); | 1342 result->SetRawValueAt(i, static_cast<intptr_t>(new_entry)); |
| 1339 break; | 1343 break; |
| 1340 } | 1344 } |
| 1341 default: | 1345 default: |
| 1342 UNREACHABLE(); | 1346 UNREACHABLE(); |
| 1343 } | 1347 } |
| 1344 } | 1348 } |
| 1345 | 1349 |
| 1346 return result.raw(); | 1350 return result->raw(); |
| 1347 } | 1351 } |
| 1348 | 1352 |
| 1349 | 1353 |
| 1350 void RawObjectPool::WriteTo(SnapshotWriter* writer, | 1354 void RawObjectPool::WriteTo(SnapshotWriter* writer, |
| 1351 intptr_t object_id, | 1355 intptr_t object_id, |
| 1352 Snapshot::Kind kind) { | 1356 Snapshot::Kind kind) { |
| 1353 ASSERT(writer->snapshot_code()); | 1357 ASSERT(writer->snapshot_code()); |
| 1354 ASSERT(kind == Snapshot::kFull); | 1358 ASSERT(kind == Snapshot::kFull); |
| 1355 | 1359 |
| 1356 // Write out the serialization header value for this object. | 1360 // Write out the serialization header value for this object. |
| 1357 writer->WriteInlinedObjectHeader(object_id); | 1361 writer->WriteInlinedObjectHeader(object_id); |
| 1358 | 1362 |
| 1359 // Write out the class and tags information. | 1363 // Write out the class and tags information. |
| 1360 writer->WriteVMIsolateObject(kObjectPoolCid); | 1364 writer->WriteVMIsolateObject(kObjectPoolCid); |
| 1361 writer->WriteTags(writer->GetObjectTags(this)); | 1365 writer->WriteTags(writer->GetObjectTags(this)); |
| 1362 | 1366 |
| 1363 intptr_t length = ptr()->length_; | 1367 intptr_t length = ptr()->length_; |
| 1364 RawTypedData* info_array = ptr()->info_array_->ptr(); | 1368 RawTypedData* info_array = ptr()->info_array_->ptr(); |
| 1365 ASSERT(info_array != TypedData::null()); | 1369 ASSERT(info_array != TypedData::null()); |
| 1366 | 1370 |
| 1367 writer->Write<intptr_t>(length); | 1371 writer->Write<intptr_t>(length); |
| 1368 for (intptr_t i = 0; i < length; i++) { | 1372 for (intptr_t i = 0; i < length; i++) { |
| 1369 ObjectPool::EntryType entry_type = | 1373 ObjectPool::EntryType entry_type = |
| 1370 static_cast<ObjectPool::EntryType>(info_array->data()[i]); | 1374 static_cast<ObjectPool::EntryType>(info_array->data()[i]); |
| 1371 writer->Write<int8_t>(entry_type); | 1375 writer->Write<int8_t>(entry_type); |
| 1372 Entry& entry = ptr()->data()[i]; | 1376 Entry& entry = ptr()->data()[i]; |
| 1373 switch (entry_type) { | 1377 switch (entry_type) { |
| 1374 case ObjectPool::kTaggedObject: { | 1378 case ObjectPool::kTaggedObject: { |
| 1375 writer->WriteObjectImpl(entry.raw_obj_, kAsInlinedObject); | 1379 writer->WriteObjectImpl(entry.raw_obj_, kAsReference); |
| 1376 break; | 1380 break; |
| 1377 } | 1381 } |
| 1378 case ObjectPool::kImmediate: { | 1382 case ObjectPool::kImmediate: { |
| 1379 writer->Write<intptr_t>(entry.raw_value_); | 1383 writer->Write<intptr_t>(entry.raw_value_); |
| 1380 break; | 1384 break; |
| 1381 } | 1385 } |
| 1382 case ObjectPool::kNativeEntry: { | 1386 case ObjectPool::kNativeEntry: { |
| 1383 // Write nothing. Will initialize with the lazy link entry. | 1387 // Write nothing. Will initialize with the lazy link entry. |
| 1384 break; | 1388 break; |
| 1385 } | 1389 } |
| (...skipping 327 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1713 | 1717 |
| 1714 ICData& result = ICData::ZoneHandle(reader->zone(), NEW_OBJECT(ICData)); | 1718 ICData& result = ICData::ZoneHandle(reader->zone(), NEW_OBJECT(ICData)); |
| 1715 reader->AddBackRef(object_id, &result, kIsDeserialized); | 1719 reader->AddBackRef(object_id, &result, kIsDeserialized); |
| 1716 | 1720 |
| 1717 result.set_deopt_id(reader->Read<int32_t>()); | 1721 result.set_deopt_id(reader->Read<int32_t>()); |
| 1718 result.set_state_bits(reader->Read<uint32_t>()); | 1722 result.set_state_bits(reader->Read<uint32_t>()); |
| 1719 | 1723 |
| 1720 // Set all the object fields. | 1724 // Set all the object fields. |
| 1721 READ_OBJECT_FIELDS(result, | 1725 READ_OBJECT_FIELDS(result, |
| 1722 result.raw()->from(), result.raw()->to(), | 1726 result.raw()->from(), result.raw()->to(), |
| 1723 kAsInlinedObject); | 1727 kAsReference); |
| 1724 | 1728 |
| 1725 return result.raw(); | 1729 return result.raw(); |
| 1726 } | 1730 } |
| 1727 | 1731 |
| 1728 | 1732 |
| 1729 void RawICData::WriteTo(SnapshotWriter* writer, | 1733 void RawICData::WriteTo(SnapshotWriter* writer, |
| 1730 intptr_t object_id, | 1734 intptr_t object_id, |
| 1731 Snapshot::Kind kind) { | 1735 Snapshot::Kind kind) { |
| 1732 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); | 1736 ASSERT((kind == Snapshot::kScript) || (kind == Snapshot::kFull)); |
| 1733 | 1737 |
| 1734 // Write out the serialization header value for this object. | 1738 // Write out the serialization header value for this object. |
| 1735 writer->WriteInlinedObjectHeader(object_id); | 1739 writer->WriteInlinedObjectHeader(object_id); |
| 1736 | 1740 |
| 1737 // Write out the class and tags information. | 1741 // Write out the class and tags information. |
| 1738 writer->WriteVMIsolateObject(kICDataCid); | 1742 writer->WriteVMIsolateObject(kICDataCid); |
| 1739 writer->WriteTags(writer->GetObjectTags(this)); | 1743 writer->WriteTags(writer->GetObjectTags(this)); |
| 1740 | 1744 |
| 1741 // Write out all the non object fields. | 1745 // Write out all the non object fields. |
| 1742 writer->Write<int32_t>(ptr()->deopt_id_); | 1746 writer->Write<int32_t>(ptr()->deopt_id_); |
| 1743 writer->Write<uint32_t>(ptr()->state_bits_); | 1747 writer->Write<uint32_t>(ptr()->state_bits_); |
| 1744 | 1748 |
| 1745 // Write out all the object pointer fields. | 1749 // Write out all the object pointer fields. |
| 1746 SnapshotWriterVisitor visitor(writer, kAsInlinedObject); | 1750 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 1747 visitor.VisitPointers(from(), to()); | 1751 visitor.VisitPointers(from(), to()); |
| 1748 } | 1752 } |
| 1749 | 1753 |
| 1750 | 1754 |
| 1751 RawMegamorphicCache* MegamorphicCache::ReadFrom(SnapshotReader* reader, | 1755 RawMegamorphicCache* MegamorphicCache::ReadFrom(SnapshotReader* reader, |
| 1752 intptr_t object_id, | 1756 intptr_t object_id, |
| 1753 intptr_t tags, | 1757 intptr_t tags, |
| 1754 Snapshot::Kind kind) { | 1758 Snapshot::Kind kind) { |
| 1755 ASSERT(reader->snapshot_code()); | 1759 ASSERT(reader->snapshot_code()); |
| 1756 ASSERT(kind == Snapshot::kFull); | 1760 ASSERT(kind == Snapshot::kFull); |
| (...skipping 1535 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3292 // We do not allow objects with native fields in an isolate message. | 3296 // We do not allow objects with native fields in an isolate message. |
| 3293 writer->SetWriteException(Exceptions::kArgument, | 3297 writer->SetWriteException(Exceptions::kArgument, |
| 3294 "Illegal argument in isolate message" | 3298 "Illegal argument in isolate message" |
| 3295 " : (object is a UserTag)"); | 3299 " : (object is a UserTag)"); |
| 3296 } else { | 3300 } else { |
| 3297 UNREACHABLE(); | 3301 UNREACHABLE(); |
| 3298 } | 3302 } |
| 3299 } | 3303 } |
| 3300 | 3304 |
| 3301 } // namespace dart | 3305 } // namespace dart |
| OLD | NEW |