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

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

Issue 2397853003: Include optimized code in JIT app snapshots. (Closed)
Patch Set: reorder Created 4 years, 2 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
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2016, 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/clustered_snapshot.h" 5 #include "vm/clustered_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 504 matching lines...) Expand 10 before | Expand all | Expand 10 after
515 515
516 RawObject** from = func->from(); 516 RawObject** from = func->from();
517 RawObject** to = func->to_snapshot(); 517 RawObject** to = func->to_snapshot();
518 for (RawObject** p = from; p <= to; p++) { 518 for (RawObject** p = from; p <= to; p++) {
519 s->Push(*p); 519 s->Push(*p);
520 } 520 }
521 if (s->kind() == Snapshot::kAppNoJIT) { 521 if (s->kind() == Snapshot::kAppNoJIT) {
522 s->Push(func->ptr()->code_); 522 s->Push(func->ptr()->code_);
523 } else if (s->kind() == Snapshot::kAppWithJIT) { 523 } else if (s->kind() == Snapshot::kAppWithJIT) {
524 NOT_IN_PRECOMPILED(s->Push(func->ptr()->unoptimized_code_)); 524 NOT_IN_PRECOMPILED(s->Push(func->ptr()->unoptimized_code_));
525 s->Push(func->ptr()->code_);
525 s->Push(func->ptr()->ic_data_array_); 526 s->Push(func->ptr()->ic_data_array_);
526 } 527 }
527 } 528 }
528 529
529 void WriteAlloc(Serializer* s) { 530 void WriteAlloc(Serializer* s) {
530 s->WriteCid(kFunctionCid); 531 s->WriteCid(kFunctionCid);
531 intptr_t count = objects_.length(); 532 intptr_t count = objects_.length();
532 s->Write<int32_t>(count); 533 s->Write<int32_t>(count);
533 for (intptr_t i = 0; i < count; i++) { 534 for (intptr_t i = 0; i < count; i++) {
534 RawFunction* func = objects_[i]; 535 RawFunction* func = objects_[i];
535 s->AssignRef(func); 536 s->AssignRef(func);
536 } 537 }
537 } 538 }
538 539
539 void WriteFill(Serializer* s) { 540 void WriteFill(Serializer* s) {
540 Snapshot::Kind kind = s->kind(); 541 Snapshot::Kind kind = s->kind();
541 intptr_t count = objects_.length(); 542 intptr_t count = objects_.length();
542 for (intptr_t i = 0; i < count; i++) { 543 for (intptr_t i = 0; i < count; i++) {
543 RawFunction* func = objects_[i]; 544 RawFunction* func = objects_[i];
544 RawObject** from = func->from(); 545 RawObject** from = func->from();
545 RawObject** to = func->to_snapshot(); 546 RawObject** to = func->to_snapshot();
546 for (RawObject** p = from; p <= to; p++) { 547 for (RawObject** p = from; p <= to; p++) {
547 s->WriteRef(*p); 548 s->WriteRef(*p);
548 } 549 }
549 if (kind == Snapshot::kAppNoJIT) { 550 if (kind == Snapshot::kAppNoJIT) {
550 s->WriteRef(func->ptr()->code_); 551 s->WriteRef(func->ptr()->code_);
551 } else if (s->kind() == Snapshot::kAppWithJIT) { 552 } else if (s->kind() == Snapshot::kAppWithJIT) {
552 NOT_IN_PRECOMPILED(s->WriteRef(func->ptr()->unoptimized_code_)); 553 NOT_IN_PRECOMPILED(s->WriteRef(func->ptr()->unoptimized_code_));
554 s->WriteRef(func->ptr()->code_);
553 s->WriteRef(func->ptr()->ic_data_array_); 555 s->WriteRef(func->ptr()->ic_data_array_);
554 } 556 }
555 557
556 #if !defined(DART_PRECOMPILED_RUNTIME) 558 #if !defined(DART_PRECOMPILED_RUNTIME)
557 if (kind != Snapshot::kAppNoJIT) { 559 if (kind != Snapshot::kAppNoJIT) {
558 s->WriteTokenPosition(func->ptr()->token_pos_); 560 s->WriteTokenPosition(func->ptr()->token_pos_);
559 s->WriteTokenPosition(func->ptr()->end_token_pos_); 561 s->WriteTokenPosition(func->ptr()->end_token_pos_);
560 } 562 }
561 #endif 563 #endif
562 s->Write<int16_t>(func->ptr()->num_fixed_parameters_); 564 s->Write<int16_t>(func->ptr()->num_fixed_parameters_);
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
617 *p = d->ReadRef(); 619 *p = d->ReadRef();
618 } 620 }
619 for (RawObject** p = to_snapshot + 1; p <= to; p++) { 621 for (RawObject** p = to_snapshot + 1; p <= to; p++) {
620 *p = Object::null(); 622 *p = Object::null();
621 } 623 }
622 if (kind == Snapshot::kAppNoJIT) { 624 if (kind == Snapshot::kAppNoJIT) {
623 func->ptr()->code_ = reinterpret_cast<RawCode*>(d->ReadRef()); 625 func->ptr()->code_ = reinterpret_cast<RawCode*>(d->ReadRef());
624 } else if (kind == Snapshot::kAppWithJIT) { 626 } else if (kind == Snapshot::kAppWithJIT) {
625 NOT_IN_PRECOMPILED(func->ptr()->unoptimized_code_ = 627 NOT_IN_PRECOMPILED(func->ptr()->unoptimized_code_ =
626 reinterpret_cast<RawCode*>(d->ReadRef())); 628 reinterpret_cast<RawCode*>(d->ReadRef()));
629 func->ptr()->code_ = reinterpret_cast<RawCode*>(d->ReadRef());
627 func->ptr()->ic_data_array_ = reinterpret_cast<RawArray*>(d->ReadRef()); 630 func->ptr()->ic_data_array_ = reinterpret_cast<RawArray*>(d->ReadRef());
628 } 631 }
629 632
630 #if defined(DEBUG) 633 #if defined(DEBUG)
631 func->ptr()->entry_point_ = 0; 634 func->ptr()->entry_point_ = 0;
632 #endif 635 #endif
633 636
634 #if !defined(DART_PRECOMPILED_RUNTIME) 637 #if !defined(DART_PRECOMPILED_RUNTIME)
635 if (kind != Snapshot::kAppNoJIT) { 638 if (kind != Snapshot::kAppNoJIT) {
636 func->ptr()->token_pos_ = d->ReadTokenPosition(); 639 func->ptr()->token_pos_ = d->ReadTokenPosition();
(...skipping 27 matching lines...) Expand all
664 ASSERT(func.raw()->ptr()->code_->IsCode()); 667 ASSERT(func.raw()->ptr()->code_->IsCode());
665 uword entry_point = func.raw()->ptr()->code_->ptr()->entry_point_; 668 uword entry_point = func.raw()->ptr()->code_->ptr()->entry_point_;
666 ASSERT(entry_point != 0); 669 ASSERT(entry_point != 0);
667 func.raw()->ptr()->entry_point_ = entry_point; 670 func.raw()->ptr()->entry_point_ = entry_point;
668 } 671 }
669 } else if (kind == Snapshot::kAppWithJIT) { 672 } else if (kind == Snapshot::kAppWithJIT) {
670 Function& func = Function::Handle(zone); 673 Function& func = Function::Handle(zone);
671 Code& code = Code::Handle(zone); 674 Code& code = Code::Handle(zone);
672 for (intptr_t i = start_index_; i < stop_index_; i++) { 675 for (intptr_t i = start_index_; i < stop_index_; i++) {
673 func ^= refs.At(i); 676 func ^= refs.At(i);
674 code ^= func.unoptimized_code(); 677 code ^= func.CurrentCode();
675 if (!code.IsNull()) { 678 if (func.HasCode() && !code.IsDisabled()) {
676 func.SetInstructions(code); 679 func.SetInstructions(code);
677 func.set_was_compiled(true); 680 func.set_was_compiled(true);
678 } else { 681 } else {
679 func.ClearCode(); 682 func.ClearCode();
680 func.set_was_compiled(false); 683 func.set_was_compiled(false);
681 } 684 }
682 } 685 }
683 } else { 686 } else {
684 Function& func = Function::Handle(zone); 687 Function& func = Function::Handle(zone);
685 for (intptr_t i = start_index_; i < stop_index_; i++) { 688 for (intptr_t i = start_index_; i < stop_index_; i++) {
(...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after
892 // Write out the initializer function or saved initial value. 895 // Write out the initializer function or saved initial value.
893 if (kind == Snapshot::kAppNoJIT) { 896 if (kind == Snapshot::kAppNoJIT) {
894 s->Push(field->ptr()->initializer_.precompiled_); 897 s->Push(field->ptr()->initializer_.precompiled_);
895 } else { 898 } else {
896 s->Push(field->ptr()->initializer_.saved_value_); 899 s->Push(field->ptr()->initializer_.saved_value_);
897 } 900 }
898 if (kind != Snapshot::kAppNoJIT) { 901 if (kind != Snapshot::kAppNoJIT) {
899 // Write out the guarded list length. 902 // Write out the guarded list length.
900 s->Push(field->ptr()->guarded_list_length_); 903 s->Push(field->ptr()->guarded_list_length_);
901 } 904 }
905 if (kind == Snapshot::kAppWithJIT) {
906 s->Push(field->ptr()->dependent_code_);
907 }
902 } 908 }
903 909
904 void WriteAlloc(Serializer* s) { 910 void WriteAlloc(Serializer* s) {
905 s->WriteCid(kFieldCid); 911 s->WriteCid(kFieldCid);
906 intptr_t count = objects_.length(); 912 intptr_t count = objects_.length();
907 s->Write<int32_t>(count); 913 s->Write<int32_t>(count);
908 for (intptr_t i = 0; i < count; i++) { 914 for (intptr_t i = 0; i < count; i++) {
909 RawField* field = objects_[i]; 915 RawField* field = objects_[i];
910 s->AssignRef(field); 916 s->AssignRef(field);
911 } 917 }
(...skipping 27 matching lines...) Expand all
939 // Write out the initializer function or saved initial value. 945 // Write out the initializer function or saved initial value.
940 if (kind == Snapshot::kAppNoJIT) { 946 if (kind == Snapshot::kAppNoJIT) {
941 s->WriteRef(field->ptr()->initializer_.precompiled_); 947 s->WriteRef(field->ptr()->initializer_.precompiled_);
942 } else { 948 } else {
943 s->WriteRef(field->ptr()->initializer_.saved_value_); 949 s->WriteRef(field->ptr()->initializer_.saved_value_);
944 } 950 }
945 if (kind != Snapshot::kAppNoJIT) { 951 if (kind != Snapshot::kAppNoJIT) {
946 // Write out the guarded list length. 952 // Write out the guarded list length.
947 s->WriteRef(field->ptr()->guarded_list_length_); 953 s->WriteRef(field->ptr()->guarded_list_length_);
948 } 954 }
955 if (kind == Snapshot::kAppWithJIT) {
956 s->WriteRef(field->ptr()->dependent_code_);
957 }
949 958
950 if (kind != Snapshot::kAppNoJIT) { 959 if (kind != Snapshot::kAppNoJIT) {
951 s->WriteTokenPosition(field->ptr()->token_pos_); 960 s->WriteTokenPosition(field->ptr()->token_pos_);
952 s->WriteCid(field->ptr()->guarded_cid_); 961 s->WriteCid(field->ptr()->guarded_cid_);
953 s->WriteCid(field->ptr()->is_nullable_); 962 s->WriteCid(field->ptr()->is_nullable_);
954 } 963 }
955 s->Write<uint8_t>(field->ptr()->kind_bits_); 964 s->Write<uint8_t>(field->ptr()->kind_bits_);
956 } 965 }
957 } 966 }
958 967
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
1477 1486
1478 void Trace(Serializer* s, RawObject* object) { 1487 void Trace(Serializer* s, RawObject* object) {
1479 RawCode* code = Code::RawCast(object); 1488 RawCode* code = Code::RawCast(object);
1480 objects_.Add(code); 1489 objects_.Add(code);
1481 1490
1482 s->Push(code->ptr()->object_pool_); 1491 s->Push(code->ptr()->object_pool_);
1483 s->Push(code->ptr()->owner_); 1492 s->Push(code->ptr()->owner_);
1484 s->Push(code->ptr()->exception_handlers_); 1493 s->Push(code->ptr()->exception_handlers_);
1485 s->Push(code->ptr()->pc_descriptors_); 1494 s->Push(code->ptr()->pc_descriptors_);
1486 s->Push(code->ptr()->stackmaps_); 1495 s->Push(code->ptr()->stackmaps_);
1496
1497 if (s->kind() == Snapshot::kAppWithJIT) {
1498 s->Push(code->ptr()->deopt_info_array_);
1499 s->Push(code->ptr()->static_calls_target_table_);
1500 NOT_IN_PRODUCT(s->Push(code->ptr()->inlined_metadata_));
1501 NOT_IN_PRODUCT(s->Push(code->ptr()->return_address_metadata_));
1502 }
1487 } 1503 }
1488 1504
1489 void WriteAlloc(Serializer* s) { 1505 void WriteAlloc(Serializer* s) {
1490 s->WriteCid(kCodeCid); 1506 s->WriteCid(kCodeCid);
1491 intptr_t count = objects_.length(); 1507 intptr_t count = objects_.length();
1492 s->Write<int32_t>(count); 1508 s->Write<int32_t>(count);
1493 for (intptr_t i = 0; i < count; i++) { 1509 for (intptr_t i = 0; i < count; i++) {
1494 RawCode* code = objects_[i]; 1510 RawCode* code = objects_[i];
1495 s->AssignRef(code); 1511 s->AssignRef(code);
1496 } 1512 }
1497 } 1513 }
1498 1514
1499 void WriteFill(Serializer* s) { 1515 void WriteFill(Serializer* s) {
1500 Snapshot::Kind kind = s->kind(); 1516 Snapshot::Kind kind = s->kind();
1501 intptr_t count = objects_.length(); 1517 intptr_t count = objects_.length();
1502 for (intptr_t i = 0; i < count; i++) { 1518 for (intptr_t i = 0; i < count; i++) {
1503 RawCode* code = objects_[i]; 1519 RawCode* code = objects_[i];
1504 1520
1505 intptr_t pointer_offsets_length = 1521 intptr_t pointer_offsets_length =
1506 Code::PtrOffBits::decode(code->ptr()->state_bits_); 1522 Code::PtrOffBits::decode(code->ptr()->state_bits_);
1507 if (pointer_offsets_length != 0) { 1523 if (pointer_offsets_length != 0) {
1508 FATAL("Cannot serialize code with embedded pointers"); 1524 FATAL("Cannot serialize code with embedded pointers");
1509 } 1525 }
1510 if (kind == Snapshot::kAppNoJIT) { 1526 if (kind == Snapshot::kAppNoJIT) {
1511 // No disabled code in precompilation. 1527 // No disabled code in precompilation.
1512 NOT_IN_PRECOMPILED(ASSERT( 1528 NOT_IN_PRECOMPILED(ASSERT(
1513 code->ptr()->instructions_ == code->ptr()->active_instructions_)); 1529 code->ptr()->instructions_ == code->ptr()->active_instructions_));
1514 } else {
1515 ASSERT(kind == Snapshot::kAppWithJIT);
1516 // We never include optimized code in JIT precompilation. Deoptimization
1517 // requires code patching and we cannot patch code that is shared
1518 // between isolates and should not mutate memory allocated by the
1519 // embedder.
1520 bool is_optimized = Code::PtrOffBits::decode(code->ptr()->state_bits_);
1521 if (is_optimized) {
1522 FATAL("Cannot include optimized code in a JIT snapshot");
1523 }
1524 } 1530 }
1525 1531
1526 RawInstructions* instr = code->ptr()->instructions_; 1532 RawInstructions* instr = code->ptr()->instructions_;
1527 int32_t text_offset = s->GetTextOffset(instr, code); 1533 int32_t text_offset = s->GetTextOffset(instr, code);
1528 s->Write<int32_t>(text_offset); 1534 s->Write<int32_t>(text_offset);
1535 if (s->kind() == Snapshot::kAppWithJIT) {
1536 // TODO(rmacnak): Fix references to disabled code before serializing.
1537 if (code->ptr()->active_instructions_ != code->ptr()->instructions_) {
1538 instr = code->ptr()->active_instructions_;
1539 text_offset = s->GetTextOffset(instr, code);
1540 }
1541 s->Write<int32_t>(text_offset);
1542 }
1529 1543
1530 s->WriteRef(code->ptr()->object_pool_); 1544 s->WriteRef(code->ptr()->object_pool_);
1531 s->WriteRef(code->ptr()->owner_); 1545 s->WriteRef(code->ptr()->owner_);
1532 s->WriteRef(code->ptr()->exception_handlers_); 1546 s->WriteRef(code->ptr()->exception_handlers_);
1533 s->WriteRef(code->ptr()->pc_descriptors_); 1547 s->WriteRef(code->ptr()->pc_descriptors_);
1534 s->WriteRef(code->ptr()->stackmaps_); 1548 s->WriteRef(code->ptr()->stackmaps_);
1535 1549
1550 if (s->kind() == Snapshot::kAppWithJIT) {
1551 s->WriteRef(code->ptr()->deopt_info_array_);
1552 s->WriteRef(code->ptr()->static_calls_target_table_);
1553 NOT_IN_PRODUCT(s->WriteRef(code->ptr()->inlined_metadata_));
1554 NOT_IN_PRODUCT(s->WriteRef(code->ptr()->return_address_metadata_));
1555 }
1556
1536 s->Write<int32_t>(code->ptr()->state_bits_); 1557 s->Write<int32_t>(code->ptr()->state_bits_);
1537 } 1558 }
1538 } 1559 }
1539 1560
1540 private: 1561 private:
1541 GrowableArray<RawCode*> objects_; 1562 GrowableArray<RawCode*> objects_;
1542 }; 1563 };
1543 #endif // !DART_PRECOMPILED_RUNTIME 1564 #endif // !DART_PRECOMPILED_RUNTIME
1544 1565
1545 1566
(...skipping 22 matching lines...) Expand all
1568 1589
1569 int32_t text_offset = d->Read<int32_t>(); 1590 int32_t text_offset = d->Read<int32_t>();
1570 RawInstructions* instr = reinterpret_cast<RawInstructions*>( 1591 RawInstructions* instr = reinterpret_cast<RawInstructions*>(
1571 d->GetInstructionsAt(text_offset) + kHeapObjectTag); 1592 d->GetInstructionsAt(text_offset) + kHeapObjectTag);
1572 1593
1573 code->ptr()->entry_point_ = Instructions::UncheckedEntryPoint(instr); 1594 code->ptr()->entry_point_ = Instructions::UncheckedEntryPoint(instr);
1574 code->ptr()->checked_entry_point_ = 1595 code->ptr()->checked_entry_point_ =
1575 Instructions::CheckedEntryPoint(instr); 1596 Instructions::CheckedEntryPoint(instr);
1576 NOT_IN_PRECOMPILED(code->ptr()->active_instructions_ = instr); 1597 NOT_IN_PRECOMPILED(code->ptr()->active_instructions_ = instr);
1577 code->ptr()->instructions_ = instr; 1598 code->ptr()->instructions_ = instr;
1599
1600 #if !defined(DART_PRECOMPILED_RUNTIME)
1601 if (d->kind() == Snapshot::kAppWithJIT) {
1602 int32_t text_offset = d->Read<int32_t>();
1603 RawInstructions* instr = reinterpret_cast<RawInstructions*>(
1604 d->GetInstructionsAt(text_offset) + kHeapObjectTag);
1605 code->ptr()->active_instructions_ = instr;
1606 code->ptr()->entry_point_ = Instructions::UncheckedEntryPoint(instr);
1607 code->ptr()->checked_entry_point_ =
1608 Instructions::CheckedEntryPoint(instr);
1609 }
1610 #endif // !DART_PRECOMPILED_RUNTIME
1611
1578 code->ptr()->object_pool_ = 1612 code->ptr()->object_pool_ =
1579 reinterpret_cast<RawObjectPool*>(d->ReadRef()); 1613 reinterpret_cast<RawObjectPool*>(d->ReadRef());
1580 code->ptr()->owner_ = d->ReadRef(); 1614 code->ptr()->owner_ = d->ReadRef();
1581 code->ptr()->exception_handlers_ = 1615 code->ptr()->exception_handlers_ =
1582 reinterpret_cast<RawExceptionHandlers*>(d->ReadRef()); 1616 reinterpret_cast<RawExceptionHandlers*>(d->ReadRef());
1583 code->ptr()->pc_descriptors_ = 1617 code->ptr()->pc_descriptors_ =
1584 reinterpret_cast<RawPcDescriptors*>(d->ReadRef()); 1618 reinterpret_cast<RawPcDescriptors*>(d->ReadRef());
1585 code->ptr()->stackmaps_ = 1619 code->ptr()->stackmaps_ =
1586 reinterpret_cast<RawArray*>(d->ReadRef()); 1620 reinterpret_cast<RawArray*>(d->ReadRef());
1587 1621
1588 #if !defined(DART_PRECOMPILED_RUNTIME) 1622 #if !defined(DART_PRECOMPILED_RUNTIME)
1589 code->ptr()->deopt_info_array_ = Array::null(); 1623 if (d->kind() == Snapshot::kAppWithJIT) {
1590 code->ptr()->static_calls_target_table_ = Array::null(); 1624 code->ptr()->deopt_info_array_ =
1625 reinterpret_cast<RawArray*>(d->ReadRef());
1626 code->ptr()->static_calls_target_table_ =
1627 reinterpret_cast<RawArray*>(d->ReadRef());
1628 #if defined(PRODUCT)
1629 code->ptr()->inlined_metadata_ = Array::null();
1630 code->ptr()->return_address_metadata_ = Object::null();
1631 #else
1632 code->ptr()->inlined_metadata_ =
1633 reinterpret_cast<RawArray*>(d->ReadRef());
1634 code->ptr()->return_address_metadata_ = d->ReadRef();
1635 #endif
1636 } else {
1637 code->ptr()->deopt_info_array_ = Array::null();
1638 code->ptr()->static_calls_target_table_ = Array::null();
1639 code->ptr()->inlined_metadata_ = Array::null();
1640 code->ptr()->return_address_metadata_ = Object::null();
1641 }
1642
1591 code->ptr()->var_descriptors_ = LocalVarDescriptors::null(); 1643 code->ptr()->var_descriptors_ = LocalVarDescriptors::null();
1592 code->ptr()->inlined_metadata_ = Array::null();
1593 code->ptr()->code_source_map_ = CodeSourceMap::null(); 1644 code->ptr()->code_source_map_ = CodeSourceMap::null();
1594 code->ptr()->comments_ = Array::null(); 1645 code->ptr()->comments_ = Array::null();
1595 code->ptr()->return_address_metadata_ = Object::null();
1596 1646
1597 code->ptr()->compile_timestamp_ = 0; 1647 code->ptr()->compile_timestamp_ = 0;
1598 #endif 1648 #endif // !DART_PRECOMPILED_RUNTIME
1649
1599 code->ptr()->state_bits_ = d->Read<int32_t>(); 1650 code->ptr()->state_bits_ = d->Read<int32_t>();
1600 } 1651 }
1601 } 1652 }
1602 }; 1653 };
1603 1654
1604 1655
1605 #if !defined(DART_PRECOMPILED_RUNTIME) 1656 #if !defined(DART_PRECOMPILED_RUNTIME)
1606 class ObjectPoolSerializationCluster : public SerializationCluster { 1657 class ObjectPoolSerializationCluster : public SerializationCluster {
1607 public: 1658 public:
1608 ObjectPoolSerializationCluster() { } 1659 ObjectPoolSerializationCluster() { }
(...skipping 2280 matching lines...) Expand 10 before | Expand all | Expand 10 after
3889 } 3940 }
3890 3941
3891 regexp->ptr()->num_registers_ = d->Read<int32_t>(); 3942 regexp->ptr()->num_registers_ = d->Read<int32_t>();
3892 regexp->ptr()->type_flags_ = d->Read<int8_t>(); 3943 regexp->ptr()->type_flags_ = d->Read<int8_t>();
3893 } 3944 }
3894 } 3945 }
3895 }; 3946 };
3896 3947
3897 3948
3898 #if !defined(DART_PRECOMPILED_RUNTIME) 3949 #if !defined(DART_PRECOMPILED_RUNTIME)
3950 class WeakPropertySerializationCluster : public SerializationCluster {
3951 public:
3952 WeakPropertySerializationCluster() { }
3953 virtual ~WeakPropertySerializationCluster() { }
3954
3955 void Trace(Serializer* s, RawObject* object) {
3956 RawWeakProperty* property = WeakProperty::RawCast(object);
3957 objects_.Add(property);
3958
3959 RawObject** from = property->from();
3960 RawObject** to = property->to();
3961 for (RawObject** p = from; p <= to; p++) {
3962 s->Push(*p);
3963 }
3964 }
3965
3966 void WriteAlloc(Serializer* s) {
3967 s->WriteCid(kWeakPropertyCid);
3968 intptr_t count = objects_.length();
3969 s->Write<int32_t>(count);
3970 for (intptr_t i = 0; i < count; i++) {
3971 RawWeakProperty* property = objects_[i];
3972 s->AssignRef(property);
3973 }
3974 }
3975
3976 void WriteFill(Serializer* s) {
3977 intptr_t count = objects_.length();
3978 for (intptr_t i = 0; i < count; i++) {
3979 RawWeakProperty* property = objects_[i];
3980 RawObject** from = property->from();
3981 RawObject** to = property->to();
3982 for (RawObject** p = from; p <= to; p++) {
3983 s->WriteRef(*p);
3984 }
3985 }
3986 }
3987
3988 private:
3989 GrowableArray<RawWeakProperty*> objects_;
3990 };
3991 #endif // !DART_PRECOMPILED_RUNTIME
3992
3993
3994 class WeakPropertyDeserializationCluster : public DeserializationCluster {
3995 public:
3996 WeakPropertyDeserializationCluster() { }
3997 virtual ~WeakPropertyDeserializationCluster() { }
3998
3999 void ReadAlloc(Deserializer* d) {
4000 start_index_ = d->next_index();
4001 PageSpace* old_space = d->heap()->old_space();
4002 intptr_t count = d->Read<int32_t>();
4003 for (intptr_t i = 0; i < count; i++) {
4004 d->AssignRef(AllocateUninitialized(old_space,
4005 WeakProperty::InstanceSize()));
4006 }
4007 stop_index_ = d->next_index();
4008 }
4009
4010 void ReadFill(Deserializer* d) {
4011 bool is_vm_object = d->isolate() == Dart::vm_isolate();
4012
4013 for (intptr_t id = start_index_; id < stop_index_; id++) {
4014 RawWeakProperty* property =
4015 reinterpret_cast<RawWeakProperty*>(d->Ref(id));
4016 Deserializer::InitializeHeader(property, kWeakPropertyCid,
4017 WeakProperty::InstanceSize(),
4018 is_vm_object);
4019 RawObject** from = property->from();
4020 RawObject** to = property->to();
4021 for (RawObject** p = from; p <= to; p++) {
4022 *p = d->ReadRef();
4023 }
4024 }
4025 }
4026 };
4027
4028
4029 #if !defined(DART_PRECOMPILED_RUNTIME)
3899 class LinkedHashMapSerializationCluster : public SerializationCluster { 4030 class LinkedHashMapSerializationCluster : public SerializationCluster {
3900 public: 4031 public:
3901 LinkedHashMapSerializationCluster() { } 4032 LinkedHashMapSerializationCluster() { }
3902 virtual ~LinkedHashMapSerializationCluster() { } 4033 virtual ~LinkedHashMapSerializationCluster() { }
3903 4034
3904 void Trace(Serializer* s, RawObject* object) { 4035 void Trace(Serializer* s, RawObject* object) {
3905 RawLinkedHashMap* map = LinkedHashMap::RawCast(object); 4036 RawLinkedHashMap* map = LinkedHashMap::RawCast(object);
3906 objects_.Add(map); 4037 objects_.Add(map);
3907 4038
3908 s->Push(map->ptr()->type_arguments_); 4039 s->Push(map->ptr()->type_arguments_);
(...skipping 455 matching lines...) Expand 10 before | Expand all | Expand 10 after
4364 case kTypeParameterCid: return new (Z) TypeParameterSerializationCluster(); 4495 case kTypeParameterCid: return new (Z) TypeParameterSerializationCluster();
4365 case kBoundedTypeCid: return new (Z) BoundedTypeSerializationCluster(); 4496 case kBoundedTypeCid: return new (Z) BoundedTypeSerializationCluster();
4366 case kClosureCid: return new (Z) ClosureSerializationCluster(); 4497 case kClosureCid: return new (Z) ClosureSerializationCluster();
4367 case kMintCid: return new (Z) MintSerializationCluster(); 4498 case kMintCid: return new (Z) MintSerializationCluster();
4368 case kBigintCid: return new (Z) BigintSerializationCluster(); 4499 case kBigintCid: return new (Z) BigintSerializationCluster();
4369 case kDoubleCid: return new (Z) DoubleSerializationCluster(); 4500 case kDoubleCid: return new (Z) DoubleSerializationCluster();
4370 case kGrowableObjectArrayCid: 4501 case kGrowableObjectArrayCid:
4371 return new (Z) GrowableObjectArraySerializationCluster(); 4502 return new (Z) GrowableObjectArraySerializationCluster();
4372 case kStacktraceCid: return new (Z) StacktraceSerializationCluster(); 4503 case kStacktraceCid: return new (Z) StacktraceSerializationCluster();
4373 case kRegExpCid: return new (Z) RegExpSerializationCluster(); 4504 case kRegExpCid: return new (Z) RegExpSerializationCluster();
4505 case kWeakPropertyCid: return new (Z) WeakPropertySerializationCluster();
4374 case kLinkedHashMapCid: return new (Z) LinkedHashMapSerializationCluster(); 4506 case kLinkedHashMapCid: return new (Z) LinkedHashMapSerializationCluster();
4375 case kArrayCid: 4507 case kArrayCid:
4376 return new (Z) ArraySerializationCluster(kArrayCid); 4508 return new (Z) ArraySerializationCluster(kArrayCid);
4377 case kImmutableArrayCid: 4509 case kImmutableArrayCid:
4378 return new (Z) ArraySerializationCluster(kImmutableArrayCid); 4510 return new (Z) ArraySerializationCluster(kImmutableArrayCid);
4379 case kOneByteStringCid: { 4511 case kOneByteStringCid: {
4380 if (Snapshot::IncludesCode(kind_)) { 4512 if (Snapshot::IncludesCode(kind_)) {
4381 return new (Z) RODataSerializationCluster(kOneByteStringCid); 4513 return new (Z) RODataSerializationCluster(kOneByteStringCid);
4382 } else { 4514 } else {
4383 return new (Z) OneByteStringSerializationCluster(); 4515 return new (Z) OneByteStringSerializationCluster();
(...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after
4689 return new (Z) TypeParameterDeserializationCluster(); 4821 return new (Z) TypeParameterDeserializationCluster();
4690 case kBoundedTypeCid: return new (Z) BoundedTypeDeserializationCluster(); 4822 case kBoundedTypeCid: return new (Z) BoundedTypeDeserializationCluster();
4691 case kClosureCid: return new (Z) ClosureDeserializationCluster(); 4823 case kClosureCid: return new (Z) ClosureDeserializationCluster();
4692 case kMintCid: return new (Z) MintDeserializationCluster(); 4824 case kMintCid: return new (Z) MintDeserializationCluster();
4693 case kBigintCid: return new (Z) BigintDeserializationCluster(); 4825 case kBigintCid: return new (Z) BigintDeserializationCluster();
4694 case kDoubleCid: return new (Z) DoubleDeserializationCluster(); 4826 case kDoubleCid: return new (Z) DoubleDeserializationCluster();
4695 case kGrowableObjectArrayCid: 4827 case kGrowableObjectArrayCid:
4696 return new (Z) GrowableObjectArrayDeserializationCluster(); 4828 return new (Z) GrowableObjectArrayDeserializationCluster();
4697 case kStacktraceCid: return new (Z) StacktraceDeserializationCluster(); 4829 case kStacktraceCid: return new (Z) StacktraceDeserializationCluster();
4698 case kRegExpCid: return new (Z) RegExpDeserializationCluster(); 4830 case kRegExpCid: return new (Z) RegExpDeserializationCluster();
4831 case kWeakPropertyCid: return new (Z) WeakPropertyDeserializationCluster();
4699 case kLinkedHashMapCid: 4832 case kLinkedHashMapCid:
4700 return new (Z) LinkedHashMapDeserializationCluster(); 4833 return new (Z) LinkedHashMapDeserializationCluster();
4701 case kArrayCid: 4834 case kArrayCid:
4702 return new (Z) ArrayDeserializationCluster(kArrayCid); 4835 return new (Z) ArrayDeserializationCluster(kArrayCid);
4703 case kImmutableArrayCid: 4836 case kImmutableArrayCid:
4704 return new (Z) ArrayDeserializationCluster(kImmutableArrayCid); 4837 return new (Z) ArrayDeserializationCluster(kImmutableArrayCid);
4705 case kOneByteStringCid: { 4838 case kOneByteStringCid: {
4706 if (Snapshot::IncludesCode(kind_)) { 4839 if (Snapshot::IncludesCode(kind_)) {
4707 return new (Z) RODataDeserializationCluster(); 4840 return new (Z) RODataDeserializationCluster();
4708 } else { 4841 } else {
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
5206 5339
5207 deserializer.ReadVMSnapshot(); 5340 deserializer.ReadVMSnapshot();
5208 5341
5209 Dart::set_instructions_snapshot_buffer(instructions_buffer_); 5342 Dart::set_instructions_snapshot_buffer(instructions_buffer_);
5210 Dart::set_data_snapshot_buffer(data_buffer_); 5343 Dart::set_data_snapshot_buffer(data_buffer_);
5211 5344
5212 return ApiError::null(); 5345 return ApiError::null();
5213 } 5346 }
5214 5347
5215 } // namespace dart 5348 } // namespace dart
OLDNEW
« no previous file with comments | « runtime/bin/main.cc ('k') | runtime/vm/raw_object.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698