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

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

Issue 1584443002: VM: Precompiled rodata snapshot. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: win32, android build Created 4 years, 11 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 1327 matching lines...) Expand 10 before | Expand all | Expand 10 after
1338 1338
1339 1339
1340 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader, 1340 RawInstructions* Instructions::ReadFrom(SnapshotReader* reader,
1341 intptr_t object_id, 1341 intptr_t object_id,
1342 intptr_t tags, 1342 intptr_t tags,
1343 Snapshot::Kind kind, 1343 Snapshot::Kind kind,
1344 bool as_reference) { 1344 bool as_reference) {
1345 ASSERT(reader->snapshot_code()); 1345 ASSERT(reader->snapshot_code());
1346 ASSERT(kind == Snapshot::kFull); 1346 ASSERT(kind == Snapshot::kFull);
1347 1347
1348 #ifdef DEBUG
1348 intptr_t full_tags = static_cast<uword>(reader->Read<intptr_t>()); 1349 intptr_t full_tags = static_cast<uword>(reader->Read<intptr_t>());
1350 #else
1351 intptr_t full_tags = 0; // unused in release mode
1352 #endif
1349 intptr_t offset = reader->Read<int32_t>(); 1353 intptr_t offset = reader->Read<int32_t>();
1350 Instructions& result = 1354 Instructions& result =
1351 Instructions::ZoneHandle(reader->zone(), 1355 Instructions::ZoneHandle(reader->zone(),
1352 reader->GetInstructionsAt(offset, full_tags)); 1356 reader->GetInstructionsAt(offset, full_tags));
1353 reader->AddBackRef(object_id, &result, kIsDeserialized); 1357 reader->AddBackRef(object_id, &result, kIsDeserialized);
1354 1358
1355 return result.raw(); 1359 return result.raw();
1356 } 1360 }
1357 1361
1358 1362
1359 void RawInstructions::WriteTo(SnapshotWriter* writer, 1363 void RawInstructions::WriteTo(SnapshotWriter* writer,
1360 intptr_t object_id, 1364 intptr_t object_id,
1361 Snapshot::Kind kind, 1365 Snapshot::Kind kind,
1362 bool as_reference) { 1366 bool as_reference) {
1363 ASSERT(writer->snapshot_code()); 1367 ASSERT(writer->snapshot_code());
1364 ASSERT(kind == Snapshot::kFull); 1368 ASSERT(kind == Snapshot::kFull);
1365 1369
1366 writer->WriteInlinedObjectHeader(object_id); 1370 writer->WriteInlinedObjectHeader(object_id);
1367 writer->WriteVMIsolateObject(kInstructionsCid); 1371 writer->WriteVMIsolateObject(kInstructionsCid);
1368 writer->WriteTags(writer->GetObjectTags(this)); 1372 writer->WriteTags(writer->GetObjectTags(this));
1369 1373
1374 #ifdef DEBUG
1370 // Instructions will be written pre-marked and in the VM heap. Write out 1375 // Instructions will be written pre-marked and in the VM heap. Write out
1371 // the tags we expect to find when reading the snapshot for a sanity check 1376 // the tags we expect to find when reading the snapshot for a sanity check
1372 // that our offsets/alignment didn't get out of sync. 1377 // that our offsets/alignment didn't get out of sync.
1373 uword written_tags = writer->GetObjectTags(this); 1378 uword written_tags = writer->GetObjectTags(this);
1374 written_tags = RawObject::VMHeapObjectTag::update(true, written_tags); 1379 written_tags = RawObject::VMHeapObjectTag::update(true, written_tags);
1375 written_tags = RawObject::MarkBit::update(true, written_tags); 1380 written_tags = RawObject::MarkBit::update(true, written_tags);
1376 writer->Write<intptr_t>(written_tags); 1381 writer->Write<intptr_t>(written_tags);
1382 #endif
1377 1383
1378 writer->Write<int32_t>(writer->GetInstructionsId(this)); 1384 writer->Write<int32_t>(writer->GetInstructionsId(this));
1379 } 1385 }
1380 1386
1381 1387
1382 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader, 1388 RawObjectPool* ObjectPool::ReadFrom(SnapshotReader* reader,
1383 intptr_t object_id, 1389 intptr_t object_id,
1384 intptr_t tags, 1390 intptr_t tags,
1385 Snapshot::Kind kind, 1391 Snapshot::Kind kind,
1386 bool as_reference) { 1392 bool as_reference) {
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
1504 1510
1505 1511
1506 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader, 1512 RawPcDescriptors* PcDescriptors::ReadFrom(SnapshotReader* reader,
1507 intptr_t object_id, 1513 intptr_t object_id,
1508 intptr_t tags, 1514 intptr_t tags,
1509 Snapshot::Kind kind, 1515 Snapshot::Kind kind,
1510 bool as_reference) { 1516 bool as_reference) {
1511 ASSERT(reader->snapshot_code()); 1517 ASSERT(reader->snapshot_code());
1512 ASSERT(kind == Snapshot::kFull); 1518 ASSERT(kind == Snapshot::kFull);
1513 1519
1514 const int32_t length = reader->Read<int32_t>(); 1520 intptr_t offset = reader->Read<int32_t>();
1515 PcDescriptors& result = 1521 PcDescriptors& result = PcDescriptors::ZoneHandle(reader->zone());
1516 PcDescriptors::ZoneHandle(reader->zone(), 1522 result ^= reader->GetObjectAt(offset);
1517 NEW_OBJECT_WITH_LEN(PcDescriptors, length));
1518 reader->AddBackRef(object_id, &result, kIsDeserialized); 1523 reader->AddBackRef(object_id, &result, kIsDeserialized);
1519 1524
1520 if (result.Length() > 0) {
1521 NoSafepointScope no_safepoint;
1522 intptr_t len = result.Length();
1523 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data());
1524 reader->ReadBytes(data, len);
1525 }
1526
1527 return result.raw(); 1525 return result.raw();
1528 } 1526 }
1529 1527
1530 1528
1531 void RawPcDescriptors::WriteTo(SnapshotWriter* writer, 1529 void RawPcDescriptors::WriteTo(SnapshotWriter* writer,
1532 intptr_t object_id, 1530 intptr_t object_id,
1533 Snapshot::Kind kind, 1531 Snapshot::Kind kind,
1534 bool as_reference) { 1532 bool as_reference) {
1535 ASSERT(writer->snapshot_code()); 1533 ASSERT(writer->snapshot_code());
1536 ASSERT(kind == Snapshot::kFull); 1534 ASSERT(kind == Snapshot::kFull);
1537 1535
1538 // Write out the serialization header value for this object. 1536 // Write out the serialization header value for this object.
1539 writer->WriteInlinedObjectHeader(object_id); 1537 writer->WriteInlinedObjectHeader(object_id);
1540 writer->WriteIndexedObject(kPcDescriptorsCid); 1538 writer->WriteIndexedObject(kPcDescriptorsCid);
1541 writer->WriteTags(writer->GetObjectTags(this)); 1539 writer->WriteTags(writer->GetObjectTags(this));
1542 writer->Write<int32_t>(ptr()->length_); 1540
1543 if (ptr()->length_ > 0) { 1541 writer->Write<int32_t>(writer->GetObjectId(this));
1544 intptr_t len = ptr()->length_;
1545 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data());
1546 writer->WriteBytes(data, len);
1547 }
1548 } 1542 }
1549 1543
1550 1544
1551 RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader, 1545 RawStackmap* Stackmap::ReadFrom(SnapshotReader* reader,
1552 intptr_t object_id, 1546 intptr_t object_id,
1553 intptr_t tags, 1547 intptr_t tags,
1554 Snapshot::Kind kind, 1548 Snapshot::Kind kind,
1555 bool as_reference) { 1549 bool as_reference) {
1556 ASSERT(reader->snapshot_code()); 1550 ASSERT(reader->snapshot_code());
1557 ASSERT(kind == Snapshot::kFull); 1551 ASSERT(kind == Snapshot::kFull);
1558 1552
1559 const int32_t length = reader->Read<int32_t>(); 1553 intptr_t offset = reader->Read<int32_t>();
1560 Stackmap& result = 1554 Stackmap& result = Stackmap::ZoneHandle(reader->zone());
1561 Stackmap::ZoneHandle(reader->zone(), 1555 result ^= reader->GetObjectAt(offset);
1562 reader->NewStackmap(length));
1563 reader->AddBackRef(object_id, &result, kIsDeserialized); 1556 reader->AddBackRef(object_id, &result, kIsDeserialized);
1564 1557
1565 result.SetRegisterBitCount(reader->Read<int32_t>());
1566 result.SetPcOffset(reader->Read<uint32_t>());
1567
1568 if (length > 0) {
1569 NoSafepointScope no_safepoint;
1570 intptr_t len = (result.Length() + 7) / 8;
1571 uint8_t* data = result.UnsafeMutableNonPointer(result.raw_ptr()->data());
1572 reader->ReadBytes(data, len);
1573 }
1574
1575 return result.raw(); 1558 return result.raw();
1576 } 1559 }
1577 1560
1578 1561
1579 void RawStackmap::WriteTo(SnapshotWriter* writer, 1562 void RawStackmap::WriteTo(SnapshotWriter* writer,
1580 intptr_t object_id, 1563 intptr_t object_id,
1581 Snapshot::Kind kind, 1564 Snapshot::Kind kind,
1582 bool as_reference) { 1565 bool as_reference) {
1583 ASSERT(writer->snapshot_code()); 1566 ASSERT(writer->snapshot_code());
1584 ASSERT(kind == Snapshot::kFull); 1567 ASSERT(kind == Snapshot::kFull);
1585 1568
1586 // Write out the serialization header value for this object. 1569 // Write out the serialization header value for this object.
1587 writer->WriteInlinedObjectHeader(object_id); 1570 writer->WriteInlinedObjectHeader(object_id);
1588 writer->WriteIndexedObject(kStackmapCid); 1571 writer->WriteIndexedObject(kStackmapCid);
1589 writer->WriteTags(writer->GetObjectTags(this)); 1572 writer->WriteTags(writer->GetObjectTags(this));
1590 1573
1591 writer->Write<int32_t>(ptr()->length_); 1574 writer->Write<int32_t>(writer->GetObjectId(this));
1592 writer->Write<int32_t>(ptr()->register_bit_count_);
1593 writer->Write<uint32_t>(ptr()->pc_offset_);
1594 if (ptr()->length_ > 0) {
1595 intptr_t len = (ptr()->length_ + 7) / 8;
1596 uint8_t* data = reinterpret_cast<uint8_t*>(ptr()->data());
1597 writer->WriteBytes(data, len);
1598 }
1599 } 1575 }
1600 1576
1601 1577
1602 RawLocalVarDescriptors* LocalVarDescriptors::ReadFrom(SnapshotReader* reader, 1578 RawLocalVarDescriptors* LocalVarDescriptors::ReadFrom(SnapshotReader* reader,
1603 intptr_t object_id, 1579 intptr_t object_id,
1604 intptr_t tags, 1580 intptr_t tags,
1605 Snapshot::Kind kind, 1581 Snapshot::Kind kind,
1606 bool as_reference) { 1582 bool as_reference) {
1607 ASSERT(reader->snapshot_code()); 1583 ASSERT(reader->snapshot_code());
1608 ASSERT(kind == Snapshot::kFull); 1584 ASSERT(kind == Snapshot::kFull);
(...skipping 1903 matching lines...) Expand 10 before | Expand all | Expand 10 after
3512 // We do not allow objects with native fields in an isolate message. 3488 // We do not allow objects with native fields in an isolate message.
3513 writer->SetWriteException(Exceptions::kArgument, 3489 writer->SetWriteException(Exceptions::kArgument,
3514 "Illegal argument in isolate message" 3490 "Illegal argument in isolate message"
3515 " : (object is a UserTag)"); 3491 " : (object is a UserTag)");
3516 } else { 3492 } else {
3517 UNREACHABLE(); 3493 UNREACHABLE();
3518 } 3494 }
3519 } 3495 }
3520 3496
3521 } // namespace dart 3497 } // namespace dart
OLDNEW
« runtime/vm/pages.cc ('K') | « runtime/vm/raw_object.h ('k') | runtime/vm/snapshot.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698