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

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

Issue 1290933002: Toward precompiled snapshots. (Closed) Base URL: git@github.com:dart-lang/sdk.git@master
Patch Set: Created 5 years, 4 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/snapshot.h" 5 #include "vm/snapshot.h"
6 6
7 #include "platform/assert.h" 7 #include "platform/assert.h"
8 #include "vm/bootstrap.h" 8 #include "vm/bootstrap.h"
9 #include "vm/class_finalizer.h" 9 #include "vm/class_finalizer.h"
10 #include "vm/dart.h" 10 #include "vm/dart.h"
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
170 170
171 SnapshotReader::SnapshotReader( 171 SnapshotReader::SnapshotReader(
172 const uint8_t* buffer, 172 const uint8_t* buffer,
173 intptr_t size, 173 intptr_t size,
174 Snapshot::Kind kind, 174 Snapshot::Kind kind,
175 ZoneGrowableArray<BackRefNode>* backward_refs, 175 ZoneGrowableArray<BackRefNode>* backward_refs,
176 Isolate* isolate, 176 Isolate* isolate,
177 Zone* zone) 177 Zone* zone)
178 : BaseReader(buffer, size), 178 : BaseReader(buffer, size),
179 kind_(kind), 179 kind_(kind),
180 snapshot_code_(false),
180 isolate_(isolate), 181 isolate_(isolate),
181 zone_(zone), 182 zone_(zone),
182 heap_(isolate->heap()), 183 heap_(isolate->heap()),
183 old_space_(isolate->heap()->old_space()), 184 old_space_(isolate->heap()->old_space()),
184 cls_(Class::Handle(isolate)), 185 cls_(Class::Handle(isolate)),
185 obj_(Object::Handle(isolate)), 186 obj_(Object::Handle(isolate)),
186 pobj_(PassiveObject::Handle(isolate)), 187 pobj_(PassiveObject::Handle(isolate)),
187 array_(Array::Handle(isolate)), 188 array_(Array::Handle(isolate)),
188 field_(Field::Handle(isolate)), 189 field_(Field::Handle(isolate)),
189 str_(String::Handle(isolate)), 190 str_(String::Handle(isolate)),
(...skipping 728 matching lines...) Expand 10 before | Expand all | Expand 10 after
918 RawRedirectionData* SnapshotReader::NewRedirectionData() { 919 RawRedirectionData* SnapshotReader::NewRedirectionData() {
919 ALLOC_NEW_OBJECT(RedirectionData); 920 ALLOC_NEW_OBJECT(RedirectionData);
920 } 921 }
921 922
922 923
923 RawFunction* SnapshotReader::NewFunction() { 924 RawFunction* SnapshotReader::NewFunction() {
924 ALLOC_NEW_OBJECT(Function); 925 ALLOC_NEW_OBJECT(Function);
925 } 926 }
926 927
927 928
929 RawCode* SnapshotReader::NewCode(intptr_t pointer_offsets_length) {
930 ASSERT(pointer_offsets_length == 0);
931 ALLOC_NEW_OBJECT(Code);
932 }
933
934
935 RawObjectPool* SnapshotReader::NewObjectPool(intptr_t length) {
936 ALLOC_NEW_OBJECT(ObjectPool);
937 }
938
939
940 RawICData* SnapshotReader::NewICData() {
941 ALLOC_NEW_OBJECT(ICData);
942 }
943
944
945 RawMegamorphicCache* SnapshotReader::NewMegamorphicCache() {
946 ALLOC_NEW_OBJECT(MegamorphicCache);
947 }
948
949
950 RawSubtypeTestCache* SnapshotReader::NewSubtypeTestCache() {
951 ALLOC_NEW_OBJECT(SubtypeTestCache);
952 }
953
954
928 RawField* SnapshotReader::NewField() { 955 RawField* SnapshotReader::NewField() {
929 ALLOC_NEW_OBJECT(Field); 956 ALLOC_NEW_OBJECT(Field);
930 } 957 }
931 958
932 959
933 RawLibrary* SnapshotReader::NewLibrary() { 960 RawLibrary* SnapshotReader::NewLibrary() {
934 ALLOC_NEW_OBJECT(Library); 961 ALLOC_NEW_OBJECT(Library);
935 } 962 }
936 963
937 964
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
1025 } 1052 }
1026 return Mint::NewCanonical(value); 1053 return Mint::NewCanonical(value);
1027 } 1054 }
1028 1055
1029 1056
1030 RawStacktrace* SnapshotReader::NewStacktrace() { 1057 RawStacktrace* SnapshotReader::NewStacktrace() {
1031 ALLOC_NEW_OBJECT(Stacktrace); 1058 ALLOC_NEW_OBJECT(Stacktrace);
1032 } 1059 }
1033 1060
1034 1061
1062 RawInstructions* SnapshotReader::GetInstructionsById(int32_t id) {
1063 // TODO(rmacnak): Read from shared library.
1064 return Instructions::null();
1065 }
1066
1067
1035 intptr_t SnapshotReader::LookupInternalClass(intptr_t class_header) { 1068 intptr_t SnapshotReader::LookupInternalClass(intptr_t class_header) {
1036 // If the header is an object Id, lookup singleton VM classes or classes 1069 // If the header is an object Id, lookup singleton VM classes or classes
1037 // stored in the object store. 1070 // stored in the object store.
1038 if (IsVMIsolateObject(class_header)) { 1071 if (IsVMIsolateObject(class_header)) {
1039 intptr_t class_id = GetVMIsolateObjectId(class_header); 1072 intptr_t class_id = GetVMIsolateObjectId(class_header);
1040 ASSERT(IsSingletonClassId(class_id)); 1073 ASSERT(IsSingletonClassId(class_id));
1041 return class_id; 1074 return class_id;
1042 } 1075 }
1043 ASSERT(SerializedHeaderTag::decode(class_header) == kObjectId); 1076 ASSERT(SerializedHeaderTag::decode(class_header) == kObjectId);
1044 intptr_t class_id = SerializedHeaderData::decode(class_header); 1077 intptr_t class_id = SerializedHeaderData::decode(class_header);
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
1082 1115
1083 RawObject* SnapshotReader::ReadVMIsolateObject(intptr_t header_value) { 1116 RawObject* SnapshotReader::ReadVMIsolateObject(intptr_t header_value) {
1084 intptr_t object_id = GetVMIsolateObjectId(header_value); 1117 intptr_t object_id = GetVMIsolateObjectId(header_value);
1085 if (object_id == kNullObject) { 1118 if (object_id == kNullObject) {
1086 // This is a singleton null object, return it. 1119 // This is a singleton null object, return it.
1087 return Object::null(); 1120 return Object::null();
1088 } 1121 }
1089 if (object_id == kSentinelObject) { 1122 if (object_id == kSentinelObject) {
1090 return Object::sentinel().raw(); 1123 return Object::sentinel().raw();
1091 } 1124 }
1125 if (object_id == kTransitionSentinelObject) {
1126 return Object::transition_sentinel().raw();
1127 }
1092 if (object_id == kEmptyArrayObject) { 1128 if (object_id == kEmptyArrayObject) {
1093 return Object::empty_array().raw(); 1129 return Object::empty_array().raw();
1094 } 1130 }
1095 if (object_id == kZeroArrayObject) { 1131 if (object_id == kZeroArrayObject) {
1096 return Object::zero_array().raw(); 1132 return Object::zero_array().raw();
1097 } 1133 }
1098 if (object_id == kDynamicType) { 1134 if (object_id == kDynamicType) {
1099 return Object::dynamic_type(); 1135 return Object::dynamic_type();
1100 } 1136 }
1101 if (object_id == kVoidType) { 1137 if (object_id == kVoidType) {
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
1346 MessageSnapshotReader::~MessageSnapshotReader() { 1382 MessageSnapshotReader::~MessageSnapshotReader() {
1347 ResetBackwardReferenceTable(); 1383 ResetBackwardReferenceTable();
1348 } 1384 }
1349 1385
1350 1386
1351 SnapshotWriter::SnapshotWriter(Snapshot::Kind kind, 1387 SnapshotWriter::SnapshotWriter(Snapshot::Kind kind,
1352 uint8_t** buffer, 1388 uint8_t** buffer,
1353 ReAlloc alloc, 1389 ReAlloc alloc,
1354 intptr_t initial_size, 1390 intptr_t initial_size,
1355 ForwardList* forward_list, 1391 ForwardList* forward_list,
1356 bool can_send_any_object) 1392 bool can_send_any_object,
1393 bool snapshot_code)
1357 : BaseWriter(buffer, alloc, initial_size), 1394 : BaseWriter(buffer, alloc, initial_size),
1358 kind_(kind), 1395 kind_(kind),
1359 isolate_(Isolate::Current()), 1396 isolate_(Isolate::Current()),
1360 object_store_(isolate_->object_store()), 1397 object_store_(isolate_->object_store()),
1361 class_table_(isolate_->class_table()), 1398 class_table_(isolate_->class_table()),
1362 forward_list_(forward_list), 1399 forward_list_(forward_list),
1363 exception_type_(Exceptions::kNone), 1400 exception_type_(Exceptions::kNone),
1364 exception_msg_(NULL), 1401 exception_msg_(NULL),
1365 unmarked_objects_(false), 1402 unmarked_objects_(false),
1366 can_send_any_object_(can_send_any_object) { 1403 can_send_any_object_(can_send_any_object),
1404 snapshot_code_(snapshot_code) {
1367 ASSERT(forward_list_ != NULL); 1405 ASSERT(forward_list_ != NULL);
1368 } 1406 }
1369 1407
1370 1408
1371 void SnapshotWriter::WriteObject(RawObject* rawobj) { 1409 void SnapshotWriter::WriteObject(RawObject* rawobj) {
1372 WriteObjectImpl(rawobj, kAsInlinedObject); 1410 WriteObjectImpl(rawobj, kAsInlinedObject);
1373 WriteForwardedObjects(); 1411 WriteForwardedObjects();
1374 } 1412 }
1375 1413
1376 #define VM_OBJECT_CLASS_LIST(V) \ 1414 #define VM_OBJECT_CLASS_LIST(V) \
(...skipping 16 matching lines...) Expand all
1393 WriteVMIsolateObject(kNullObject); 1431 WriteVMIsolateObject(kNullObject);
1394 return; 1432 return;
1395 } 1433 }
1396 1434
1397 // Check if it is a singleton sentinel object. 1435 // Check if it is a singleton sentinel object.
1398 if (rawobj == Object::sentinel().raw()) { 1436 if (rawobj == Object::sentinel().raw()) {
1399 WriteVMIsolateObject(kSentinelObject); 1437 WriteVMIsolateObject(kSentinelObject);
1400 return; 1438 return;
1401 } 1439 }
1402 1440
1441 // Check if it is a singleton sentinel object.
1442 if (rawobj == Object::transition_sentinel().raw()) {
1443 WriteVMIsolateObject(kTransitionSentinelObject);
1444 return;
1445 }
1446
1403 // Check if it is a singleton empty array object. 1447 // Check if it is a singleton empty array object.
1404 if (rawobj == Object::empty_array().raw()) { 1448 if (rawobj == Object::empty_array().raw()) {
1405 WriteVMIsolateObject(kEmptyArrayObject); 1449 WriteVMIsolateObject(kEmptyArrayObject);
1406 return; 1450 return;
1407 } 1451 }
1408 1452
1409 // Check if it is a singleton zero array object. 1453 // Check if it is a singleton zero array object.
1410 if (rawobj == Object::zero_array().raw()) { 1454 if (rawobj == Object::zero_array().raw()) {
1411 WriteVMIsolateObject(kZeroArrayObject); 1455 WriteVMIsolateObject(kZeroArrayObject);
1412 return; 1456 return;
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
1479 RawTypedData* raw_obj = reinterpret_cast<RawTypedData*>(rawobj); 1523 RawTypedData* raw_obj = reinterpret_cast<RawTypedData*>(rawobj);
1480 raw_obj->WriteTo(this, object_id, kind()); 1524 raw_obj->WriteTo(this, object_id, kind());
1481 return; 1525 return;
1482 } 1526 }
1483 default: 1527 default:
1484 OS::Print("class id = %" Pd "\n", id); 1528 OS::Print("class id = %" Pd "\n", id);
1485 break; 1529 break;
1486 } 1530 }
1487 } 1531 }
1488 } 1532 }
1489 UNREACHABLE(); 1533
1534 const Object& obj = Object::Handle(rawobj);
1535 FATAL1("Unexpected reference to object in VM isolate: %s\n", obj.ToCString());
1490 } 1536 }
1491 1537
1492 #undef VM_OBJECT_WRITE 1538 #undef VM_OBJECT_WRITE
1493 1539
1494 1540
1495 // An object visitor which will iterate over all the script objects in the heap 1541 // An object visitor which will iterate over all the script objects in the heap
1496 // and either count them or collect them into an array. This is used during 1542 // and either count them or collect them into an array. This is used during
1497 // full snapshot generation of the VM isolate to write out all script 1543 // full snapshot generation of the VM isolate to write out all script
1498 // objects and their accompanying token streams. 1544 // objects and their accompanying token streams.
1499 class ScriptVisitor : public ObjectVisitor { 1545 class ScriptVisitor : public ObjectVisitor {
(...skipping 24 matching lines...) Expand all
1524 1570
1525 private: 1571 private:
1526 Object& objHandle_; 1572 Object& objHandle_;
1527 intptr_t count_; 1573 intptr_t count_;
1528 const Array* scripts_; 1574 const Array* scripts_;
1529 }; 1575 };
1530 1576
1531 1577
1532 FullSnapshotWriter::FullSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer, 1578 FullSnapshotWriter::FullSnapshotWriter(uint8_t** vm_isolate_snapshot_buffer,
1533 uint8_t** isolate_snapshot_buffer, 1579 uint8_t** isolate_snapshot_buffer,
1534 ReAlloc alloc) 1580 ReAlloc alloc,
1581 bool snapshot_code)
1535 : isolate_(Isolate::Current()), 1582 : isolate_(Isolate::Current()),
1536 vm_isolate_snapshot_buffer_(vm_isolate_snapshot_buffer), 1583 vm_isolate_snapshot_buffer_(vm_isolate_snapshot_buffer),
1537 isolate_snapshot_buffer_(isolate_snapshot_buffer), 1584 isolate_snapshot_buffer_(isolate_snapshot_buffer),
1538 alloc_(alloc), 1585 alloc_(alloc),
1539 vm_isolate_snapshot_size_(0), 1586 vm_isolate_snapshot_size_(0),
1540 isolate_snapshot_size_(0), 1587 isolate_snapshot_size_(0),
1541 forward_list_(NULL), 1588 forward_list_(NULL),
1542 scripts_(Array::Handle(isolate_)), 1589 scripts_(Array::Handle(isolate_)),
1543 symbol_table_(Array::Handle(isolate_)) { 1590 symbol_table_(Array::Handle(isolate_)),
1591 snapshot_code_(snapshot_code) {
1544 ASSERT(isolate_snapshot_buffer_ != NULL); 1592 ASSERT(isolate_snapshot_buffer_ != NULL);
1545 ASSERT(alloc_ != NULL); 1593 ASSERT(alloc_ != NULL);
1546 ASSERT(isolate_ != NULL); 1594 ASSERT(isolate_ != NULL);
1547 ASSERT(ClassFinalizer::AllClassesFinalized()); 1595 ASSERT(ClassFinalizer::AllClassesFinalized());
1548 ObjectStore* object_store = isolate_->object_store(); 1596 ObjectStore* object_store = isolate_->object_store();
1549 ASSERT(object_store != NULL); 1597 ASSERT(object_store != NULL);
1550 Heap* heap = isolate_->heap(); 1598 Heap* heap = isolate_->heap();
1551 ASSERT(heap != NULL); 1599 ASSERT(heap != NULL);
1552 // Ensure the class table is valid. 1600 // Ensure the class table is valid.
1553 #if defined(DEBUG) 1601 #if defined(DEBUG)
(...skipping 30 matching lines...) Expand all
1584 } 1632 }
1585 1633
1586 1634
1587 void FullSnapshotWriter::WriteVmIsolateSnapshot() { 1635 void FullSnapshotWriter::WriteVmIsolateSnapshot() {
1588 ASSERT(vm_isolate_snapshot_buffer_ != NULL); 1636 ASSERT(vm_isolate_snapshot_buffer_ != NULL);
1589 SnapshotWriter writer(Snapshot::kFull, 1637 SnapshotWriter writer(Snapshot::kFull,
1590 vm_isolate_snapshot_buffer_, 1638 vm_isolate_snapshot_buffer_,
1591 alloc_, 1639 alloc_,
1592 kInitialSize, 1640 kInitialSize,
1593 forward_list_, 1641 forward_list_,
1594 true); // Can send any kind of object. 1642 true, /* can_send_any_object */
1643 snapshot_code_);
1595 // Write full snapshot for the VM isolate. 1644 // Write full snapshot for the VM isolate.
1596 // Setup for long jump in case there is an exception while writing 1645 // Setup for long jump in case there is an exception while writing
1597 // the snapshot. 1646 // the snapshot.
1598 LongJumpScope jump; 1647 LongJumpScope jump;
1599 if (setjmp(*jump.Set()) == 0) { 1648 if (setjmp(*jump.Set()) == 0) {
1600 // Reserve space in the output buffer for a snapshot header. 1649 // Reserve space in the output buffer for a snapshot header.
1601 writer.ReserveHeader(); 1650 writer.ReserveHeader();
1602 1651
1603 // Write out the version string. 1652 // Write out the version string.
1604 writer.WriteVersion(); 1653 writer.WriteVersion();
(...skipping 23 matching lines...) Expand all
1628 } 1677 }
1629 } 1678 }
1630 1679
1631 1680
1632 void FullSnapshotWriter::WriteIsolateFullSnapshot() { 1681 void FullSnapshotWriter::WriteIsolateFullSnapshot() {
1633 SnapshotWriter writer(Snapshot::kFull, 1682 SnapshotWriter writer(Snapshot::kFull,
1634 isolate_snapshot_buffer_, 1683 isolate_snapshot_buffer_,
1635 alloc_, 1684 alloc_,
1636 kInitialSize, 1685 kInitialSize,
1637 forward_list_, 1686 forward_list_,
1638 true); 1687 true, /* can_send_any_object */
1688 snapshot_code_);
1639 ObjectStore* object_store = isolate_->object_store(); 1689 ObjectStore* object_store = isolate_->object_store();
1640 ASSERT(object_store != NULL); 1690 ASSERT(object_store != NULL);
1641 1691
1642 // Write full snapshot for a regular isolate. 1692 // Write full snapshot for a regular isolate.
1643 // Setup for long jump in case there is an exception while writing 1693 // Setup for long jump in case there is an exception while writing
1644 // the snapshot. 1694 // the snapshot.
1645 LongJumpScope jump; 1695 LongJumpScope jump;
1646 if (setjmp(*jump.Set()) == 0) { 1696 if (setjmp(*jump.Set()) == 0) {
1647 // Reserve space in the output buffer for a snapshot header. 1697 // Reserve space in the output buffer for a snapshot header.
1648 writer.ReserveHeader(); 1698 writer.ReserveHeader();
(...skipping 22 matching lines...) Expand all
1671 1721
1672 1722
1673 void FullSnapshotWriter::WriteFullSnapshot() { 1723 void FullSnapshotWriter::WriteFullSnapshot() {
1674 if (vm_isolate_snapshot_buffer() != NULL) { 1724 if (vm_isolate_snapshot_buffer() != NULL) {
1675 WriteVmIsolateSnapshot(); 1725 WriteVmIsolateSnapshot();
1676 } 1726 }
1677 WriteIsolateFullSnapshot(); 1727 WriteIsolateFullSnapshot();
1678 } 1728 }
1679 1729
1680 1730
1731 PrecompiledSnapshotWriter::PrecompiledSnapshotWriter(
1732 uint8_t** vm_isolate_snapshot_buffer,
1733 uint8_t** isolate_snapshot_buffer,
1734 ReAlloc alloc)
1735 : FullSnapshotWriter(vm_isolate_snapshot_buffer,
1736 isolate_snapshot_buffer,
1737 alloc,
1738 true /* snapshot_code */) {
1739 }
1740
1741
1742 PrecompiledSnapshotWriter::~PrecompiledSnapshotWriter() {}
1743
1744
1681 uword SnapshotWriter::GetObjectTags(RawObject* raw) { 1745 uword SnapshotWriter::GetObjectTags(RawObject* raw) {
1682 uword tags = raw->ptr()->tags_; 1746 uword tags = raw->ptr()->tags_;
1683 if (SerializedHeaderTag::decode(tags) == kObjectId) { 1747 if (SerializedHeaderTag::decode(tags) == kObjectId) {
1684 intptr_t id = SerializedHeaderData::decode(tags); 1748 intptr_t id = SerializedHeaderData::decode(tags);
1685 return forward_list_->NodeForObjectId(id)->tags(); 1749 return forward_list_->NodeForObjectId(id)->tags();
1686 } else { 1750 } else {
1687 return tags; 1751 return tags;
1688 } 1752 }
1689 } 1753 }
1690 1754
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1801 // Now check if it is an object from the VM isolate (NOTE: premarked objects 1865 // Now check if it is an object from the VM isolate (NOTE: premarked objects
1802 // are considered to be objects in the VM isolate). These objects are shared 1866 // are considered to be objects in the VM isolate). These objects are shared
1803 // by all isolates. 1867 // by all isolates.
1804 if (rawobj->IsVMHeapObject()) { 1868 if (rawobj->IsVMHeapObject()) {
1805 HandleVMIsolateObject(rawobj); 1869 HandleVMIsolateObject(rawobj);
1806 return true; 1870 return true;
1807 } 1871 }
1808 1872
1809 // Check if it is a code object in that case just write a Null object 1873 // Check if it is a code object in that case just write a Null object
1810 // as we do not want code objects in the snapshot. 1874 // as we do not want code objects in the snapshot.
1811 if (cid == kCodeCid) { 1875 if (!snapshot_code() && cid == kCodeCid) {
siva 2015/08/19 19:40:03 maybe if ((cid == kCodeCid) && !snapshot_code()) {
rmacnak 2015/08/19 22:33:54 Done.
1812 WriteVMIsolateObject(kNullObject); 1876 WriteVMIsolateObject(kNullObject);
1813 return true; 1877 return true;
1814 } 1878 }
1815 1879
1816 // Check if classes are not being serialized and it is preinitialized type 1880 // Check if classes are not being serialized and it is preinitialized type
1817 // or a predefined internal VM class in the object store. 1881 // or a predefined internal VM class in the object store.
1818 if (kind_ != Snapshot::kFull) { 1882 if (kind_ != Snapshot::kFull) {
1819 // Check if it is an internal VM class which is in the object store. 1883 // Check if it is an internal VM class which is in the object store.
1820 if (cid == kClassCid) { 1884 if (cid == kClassCid) {
1821 RawClass* raw_class = reinterpret_cast<RawClass*>(rawobj); 1885 RawClass* raw_class = reinterpret_cast<RawClass*>(rawobj);
(...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after
2311 } 2375 }
2312 2376
2313 2377
2314 intptr_t SnapshotWriter::FirstObjectId() { 2378 intptr_t SnapshotWriter::FirstObjectId() {
2315 intptr_t max_vm_isolate_object_id = 2379 intptr_t max_vm_isolate_object_id =
2316 Object::vm_isolate_snapshot_object_table().Length(); 2380 Object::vm_isolate_snapshot_object_table().Length();
2317 return kMaxPredefinedObjectIds + max_vm_isolate_object_id; 2381 return kMaxPredefinedObjectIds + max_vm_isolate_object_id;
2318 } 2382 }
2319 2383
2320 2384
2385 int32_t GetInstructionsId(RawInstructions* instructions) {
Florian Schneider 2015/08/18 11:54:14 Where is this function used? There is already Sna
rmacnak 2015/08/19 22:33:54 Refactoring leftover - deleted.
2386 // TODO(rmacnak): Keep list and write them to another buffer.
2387 return 0;
2388 }
2389
2390
2321 ScriptSnapshotWriter::ScriptSnapshotWriter(uint8_t** buffer, 2391 ScriptSnapshotWriter::ScriptSnapshotWriter(uint8_t** buffer,
2322 ReAlloc alloc) 2392 ReAlloc alloc)
2323 : SnapshotWriter(Snapshot::kScript, 2393 : SnapshotWriter(Snapshot::kScript,
2324 buffer, 2394 buffer,
2325 alloc, 2395 alloc,
2326 kInitialSize, 2396 kInitialSize,
2327 &forward_list_, 2397 &forward_list_,
2328 true), 2398 true, /* can_send_any_object */
2399 false /* snapshot_code */),
2329 forward_list_(kMaxPredefinedObjectIds) { 2400 forward_list_(kMaxPredefinedObjectIds) {
2330 ASSERT(buffer != NULL); 2401 ASSERT(buffer != NULL);
2331 ASSERT(alloc != NULL); 2402 ASSERT(alloc != NULL);
2332 } 2403 }
2333 2404
2334 2405
2335 void ScriptSnapshotWriter::WriteScriptSnapshot(const Library& lib) { 2406 void ScriptSnapshotWriter::WriteScriptSnapshot(const Library& lib) {
2336 ASSERT(kind() == Snapshot::kScript); 2407 ASSERT(kind() == Snapshot::kScript);
2337 ASSERT(isolate() != NULL); 2408 ASSERT(isolate() != NULL);
2338 ASSERT(ClassFinalizer::AllClassesFinalized()); 2409 ASSERT(ClassFinalizer::AllClassesFinalized());
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2372 2443
2373 2444
2374 MessageWriter::MessageWriter(uint8_t** buffer, 2445 MessageWriter::MessageWriter(uint8_t** buffer,
2375 ReAlloc alloc, 2446 ReAlloc alloc,
2376 bool can_send_any_object) 2447 bool can_send_any_object)
2377 : SnapshotWriter(Snapshot::kMessage, 2448 : SnapshotWriter(Snapshot::kMessage,
2378 buffer, 2449 buffer,
2379 alloc, 2450 alloc,
2380 kInitialSize, 2451 kInitialSize,
2381 &forward_list_, 2452 &forward_list_,
2382 can_send_any_object), 2453 can_send_any_object,
2454 false /* snapshot_code */),
2383 forward_list_(kMaxPredefinedObjectIds) { 2455 forward_list_(kMaxPredefinedObjectIds) {
2384 ASSERT(buffer != NULL); 2456 ASSERT(buffer != NULL);
2385 ASSERT(alloc != NULL); 2457 ASSERT(alloc != NULL);
2386 } 2458 }
2387 2459
2388 2460
2389 void MessageWriter::WriteMessage(const Object& obj) { 2461 void MessageWriter::WriteMessage(const Object& obj) {
2390 ASSERT(kind() == Snapshot::kMessage); 2462 ASSERT(kind() == Snapshot::kMessage);
2391 ASSERT(isolate() != NULL); 2463 ASSERT(isolate() != NULL);
2392 2464
2393 // Setup for long jump in case there is an exception while writing 2465 // Setup for long jump in case there is an exception while writing
2394 // the message. 2466 // the message.
2395 LongJumpScope jump; 2467 LongJumpScope jump;
2396 if (setjmp(*jump.Set()) == 0) { 2468 if (setjmp(*jump.Set()) == 0) {
2397 NoSafepointScope no_safepoint; 2469 NoSafepointScope no_safepoint;
2398 WriteObject(obj.raw()); 2470 WriteObject(obj.raw());
2399 UnmarkAll(); 2471 UnmarkAll();
2400 } else { 2472 } else {
2401 ThrowException(exception_type(), exception_msg()); 2473 ThrowException(exception_type(), exception_msg());
2402 } 2474 }
2403 } 2475 }
2404 2476
2405 2477
2406 } // namespace dart 2478 } // namespace dart
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698