| OLD | NEW |
| 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 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 | 508 |
| 509 void Trace(Serializer* s, RawObject* object) { | 509 void Trace(Serializer* s, RawObject* object) { |
| 510 RawFunction* func = Function::RawCast(object); | 510 RawFunction* func = Function::RawCast(object); |
| 511 objects_.Add(func); | 511 objects_.Add(func); |
| 512 | 512 |
| 513 RawObject** from = func->from(); | 513 RawObject** from = func->from(); |
| 514 RawObject** to = func->to_snapshot(); | 514 RawObject** to = func->to_snapshot(); |
| 515 for (RawObject** p = from; p <= to; p++) { | 515 for (RawObject** p = from; p <= to; p++) { |
| 516 s->Push(*p); | 516 s->Push(*p); |
| 517 } | 517 } |
| 518 if (s->kind() == Snapshot::kAppNoJIT) { | 518 if (s->kind() == Snapshot::kAppAOT) { |
| 519 s->Push(func->ptr()->code_); | 519 s->Push(func->ptr()->code_); |
| 520 } else if (s->kind() == Snapshot::kAppWithJIT) { | 520 } else if (s->kind() == Snapshot::kAppJIT) { |
| 521 NOT_IN_PRECOMPILED(s->Push(func->ptr()->unoptimized_code_)); | 521 NOT_IN_PRECOMPILED(s->Push(func->ptr()->unoptimized_code_)); |
| 522 s->Push(func->ptr()->code_); | 522 s->Push(func->ptr()->code_); |
| 523 s->Push(func->ptr()->ic_data_array_); | 523 s->Push(func->ptr()->ic_data_array_); |
| 524 } | 524 } |
| 525 } | 525 } |
| 526 | 526 |
| 527 void WriteAlloc(Serializer* s) { | 527 void WriteAlloc(Serializer* s) { |
| 528 s->WriteCid(kFunctionCid); | 528 s->WriteCid(kFunctionCid); |
| 529 intptr_t count = objects_.length(); | 529 intptr_t count = objects_.length(); |
| 530 s->Write<int32_t>(count); | 530 s->Write<int32_t>(count); |
| 531 for (intptr_t i = 0; i < count; i++) { | 531 for (intptr_t i = 0; i < count; i++) { |
| 532 RawFunction* func = objects_[i]; | 532 RawFunction* func = objects_[i]; |
| 533 s->AssignRef(func); | 533 s->AssignRef(func); |
| 534 } | 534 } |
| 535 } | 535 } |
| 536 | 536 |
| 537 void WriteFill(Serializer* s) { | 537 void WriteFill(Serializer* s) { |
| 538 Snapshot::Kind kind = s->kind(); | 538 Snapshot::Kind kind = s->kind(); |
| 539 intptr_t count = objects_.length(); | 539 intptr_t count = objects_.length(); |
| 540 for (intptr_t i = 0; i < count; i++) { | 540 for (intptr_t i = 0; i < count; i++) { |
| 541 RawFunction* func = objects_[i]; | 541 RawFunction* func = objects_[i]; |
| 542 RawObject** from = func->from(); | 542 RawObject** from = func->from(); |
| 543 RawObject** to = func->to_snapshot(); | 543 RawObject** to = func->to_snapshot(); |
| 544 for (RawObject** p = from; p <= to; p++) { | 544 for (RawObject** p = from; p <= to; p++) { |
| 545 s->WriteRef(*p); | 545 s->WriteRef(*p); |
| 546 } | 546 } |
| 547 if (kind == Snapshot::kAppNoJIT) { | 547 if (kind == Snapshot::kAppAOT) { |
| 548 s->WriteRef(func->ptr()->code_); | 548 s->WriteRef(func->ptr()->code_); |
| 549 } else if (s->kind() == Snapshot::kAppWithJIT) { | 549 } else if (s->kind() == Snapshot::kAppJIT) { |
| 550 NOT_IN_PRECOMPILED(s->WriteRef(func->ptr()->unoptimized_code_)); | 550 NOT_IN_PRECOMPILED(s->WriteRef(func->ptr()->unoptimized_code_)); |
| 551 s->WriteRef(func->ptr()->code_); | 551 s->WriteRef(func->ptr()->code_); |
| 552 s->WriteRef(func->ptr()->ic_data_array_); | 552 s->WriteRef(func->ptr()->ic_data_array_); |
| 553 } | 553 } |
| 554 | 554 |
| 555 #if !defined(DART_PRECOMPILED_RUNTIME) | 555 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 556 if (kind != Snapshot::kAppNoJIT) { | 556 if (kind != Snapshot::kAppAOT) { |
| 557 s->WriteTokenPosition(func->ptr()->token_pos_); | 557 s->WriteTokenPosition(func->ptr()->token_pos_); |
| 558 s->WriteTokenPosition(func->ptr()->end_token_pos_); | 558 s->WriteTokenPosition(func->ptr()->end_token_pos_); |
| 559 } | 559 } |
| 560 #endif | 560 #endif |
| 561 s->Write<int16_t>(func->ptr()->num_fixed_parameters_); | 561 s->Write<int16_t>(func->ptr()->num_fixed_parameters_); |
| 562 s->Write<int16_t>(func->ptr()->num_optional_parameters_); | 562 s->Write<int16_t>(func->ptr()->num_optional_parameters_); |
| 563 s->Write<uint32_t>(func->ptr()->kind_tag_); | 563 s->Write<uint32_t>(func->ptr()->kind_tag_); |
| 564 if (kind == Snapshot::kAppNoJIT) { | 564 if (kind == Snapshot::kAppAOT) { |
| 565 // Omit fields used to support de/reoptimization. | 565 // Omit fields used to support de/reoptimization. |
| 566 } else if (!Snapshot::IncludesCode(kind)) { | 566 } else if (!Snapshot::IncludesCode(kind)) { |
| 567 #if !defined(DART_PRECOMPILED_RUNTIME) | 567 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 568 bool is_optimized = Code::IsOptimized(func->ptr()->code_); | 568 bool is_optimized = Code::IsOptimized(func->ptr()->code_); |
| 569 if (is_optimized) { | 569 if (is_optimized) { |
| 570 s->Write<int32_t>(FLAG_optimization_counter_threshold); | 570 s->Write<int32_t>(FLAG_optimization_counter_threshold); |
| 571 } else { | 571 } else { |
| 572 s->Write<int32_t>(0); | 572 s->Write<int32_t>(0); |
| 573 } | 573 } |
| 574 #endif | 574 #endif |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 607 Function::InstanceSize(), is_vm_object); | 607 Function::InstanceSize(), is_vm_object); |
| 608 RawObject** from = func->from(); | 608 RawObject** from = func->from(); |
| 609 RawObject** to_snapshot = func->to_snapshot(); | 609 RawObject** to_snapshot = func->to_snapshot(); |
| 610 RawObject** to = func->to(); | 610 RawObject** to = func->to(); |
| 611 for (RawObject** p = from; p <= to_snapshot; p++) { | 611 for (RawObject** p = from; p <= to_snapshot; p++) { |
| 612 *p = d->ReadRef(); | 612 *p = d->ReadRef(); |
| 613 } | 613 } |
| 614 for (RawObject** p = to_snapshot + 1; p <= to; p++) { | 614 for (RawObject** p = to_snapshot + 1; p <= to; p++) { |
| 615 *p = Object::null(); | 615 *p = Object::null(); |
| 616 } | 616 } |
| 617 if (kind == Snapshot::kAppNoJIT) { | 617 if (kind == Snapshot::kAppAOT) { |
| 618 func->ptr()->code_ = reinterpret_cast<RawCode*>(d->ReadRef()); | 618 func->ptr()->code_ = reinterpret_cast<RawCode*>(d->ReadRef()); |
| 619 } else if (kind == Snapshot::kAppWithJIT) { | 619 } else if (kind == Snapshot::kAppJIT) { |
| 620 NOT_IN_PRECOMPILED(func->ptr()->unoptimized_code_ = | 620 NOT_IN_PRECOMPILED(func->ptr()->unoptimized_code_ = |
| 621 reinterpret_cast<RawCode*>(d->ReadRef())); | 621 reinterpret_cast<RawCode*>(d->ReadRef())); |
| 622 func->ptr()->code_ = reinterpret_cast<RawCode*>(d->ReadRef()); | 622 func->ptr()->code_ = reinterpret_cast<RawCode*>(d->ReadRef()); |
| 623 func->ptr()->ic_data_array_ = reinterpret_cast<RawArray*>(d->ReadRef()); | 623 func->ptr()->ic_data_array_ = reinterpret_cast<RawArray*>(d->ReadRef()); |
| 624 } | 624 } |
| 625 | 625 |
| 626 #if defined(DEBUG) | 626 #if defined(DEBUG) |
| 627 func->ptr()->entry_point_ = 0; | 627 func->ptr()->entry_point_ = 0; |
| 628 #endif | 628 #endif |
| 629 | 629 |
| 630 #if !defined(DART_PRECOMPILED_RUNTIME) | 630 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 631 if (kind != Snapshot::kAppNoJIT) { | 631 if (kind != Snapshot::kAppAOT) { |
| 632 func->ptr()->token_pos_ = d->ReadTokenPosition(); | 632 func->ptr()->token_pos_ = d->ReadTokenPosition(); |
| 633 func->ptr()->end_token_pos_ = d->ReadTokenPosition(); | 633 func->ptr()->end_token_pos_ = d->ReadTokenPosition(); |
| 634 } | 634 } |
| 635 #endif | 635 #endif |
| 636 func->ptr()->num_fixed_parameters_ = d->Read<int16_t>(); | 636 func->ptr()->num_fixed_parameters_ = d->Read<int16_t>(); |
| 637 func->ptr()->num_optional_parameters_ = d->Read<int16_t>(); | 637 func->ptr()->num_optional_parameters_ = d->Read<int16_t>(); |
| 638 func->ptr()->kind_tag_ = d->Read<uint32_t>(); | 638 func->ptr()->kind_tag_ = d->Read<uint32_t>(); |
| 639 if (kind == Snapshot::kAppNoJIT) { | 639 if (kind == Snapshot::kAppAOT) { |
| 640 // Omit fields used to support de/reoptimization. | 640 // Omit fields used to support de/reoptimization. |
| 641 } else { | 641 } else { |
| 642 #if !defined(DART_PRECOMPILED_RUNTIME) | 642 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 643 if (Snapshot::IncludesCode(kind)) { | 643 if (Snapshot::IncludesCode(kind)) { |
| 644 func->ptr()->usage_counter_ = 0; | 644 func->ptr()->usage_counter_ = 0; |
| 645 } else { | 645 } else { |
| 646 func->ptr()->usage_counter_ = d->Read<int32_t>(); | 646 func->ptr()->usage_counter_ = d->Read<int32_t>(); |
| 647 } | 647 } |
| 648 func->ptr()->deoptimization_counter_ = 0; | 648 func->ptr()->deoptimization_counter_ = 0; |
| 649 func->ptr()->optimized_instruction_count_ = 0; | 649 func->ptr()->optimized_instruction_count_ = 0; |
| 650 func->ptr()->optimized_call_site_count_ = 0; | 650 func->ptr()->optimized_call_site_count_ = 0; |
| 651 #endif | 651 #endif |
| 652 } | 652 } |
| 653 } | 653 } |
| 654 } | 654 } |
| 655 | 655 |
| 656 void PostLoad(const Array& refs, Snapshot::Kind kind, Zone* zone) { | 656 void PostLoad(const Array& refs, Snapshot::Kind kind, Zone* zone) { |
| 657 NOT_IN_PRODUCT(TimelineDurationScope tds( | 657 NOT_IN_PRODUCT(TimelineDurationScope tds( |
| 658 Thread::Current(), Timeline::GetIsolateStream(), "PostLoadFunction")); | 658 Thread::Current(), Timeline::GetIsolateStream(), "PostLoadFunction")); |
| 659 | 659 |
| 660 if (kind == Snapshot::kAppNoJIT) { | 660 if (kind == Snapshot::kAppAOT) { |
| 661 Function& func = Function::Handle(zone); | 661 Function& func = Function::Handle(zone); |
| 662 for (intptr_t i = start_index_; i < stop_index_; i++) { | 662 for (intptr_t i = start_index_; i < stop_index_; i++) { |
| 663 func ^= refs.At(i); | 663 func ^= refs.At(i); |
| 664 ASSERT(func.raw()->ptr()->code_->IsCode()); | 664 ASSERT(func.raw()->ptr()->code_->IsCode()); |
| 665 uword entry_point = func.raw()->ptr()->code_->ptr()->entry_point_; | 665 uword entry_point = func.raw()->ptr()->code_->ptr()->entry_point_; |
| 666 ASSERT(entry_point != 0); | 666 ASSERT(entry_point != 0); |
| 667 func.raw()->ptr()->entry_point_ = entry_point; | 667 func.raw()->ptr()->entry_point_ = entry_point; |
| 668 } | 668 } |
| 669 } else if (kind == Snapshot::kAppWithJIT) { | 669 } else if (kind == Snapshot::kAppJIT) { |
| 670 Function& func = Function::Handle(zone); | 670 Function& func = Function::Handle(zone); |
| 671 Code& code = Code::Handle(zone); | 671 Code& code = Code::Handle(zone); |
| 672 for (intptr_t i = start_index_; i < stop_index_; i++) { | 672 for (intptr_t i = start_index_; i < stop_index_; i++) { |
| 673 func ^= refs.At(i); | 673 func ^= refs.At(i); |
| 674 code ^= func.CurrentCode(); | 674 code ^= func.CurrentCode(); |
| 675 if (func.HasCode() && !code.IsDisabled()) { | 675 if (func.HasCode() && !code.IsDisabled()) { |
| 676 func.SetInstructions(code); | 676 func.SetInstructions(code); |
| 677 func.set_was_compiled(true); | 677 func.set_was_compiled(true); |
| 678 } else { | 678 } else { |
| 679 func.ClearCode(); | 679 func.ClearCode(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 696 #if !defined(DART_PRECOMPILED_RUNTIME) | 696 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 697 class ClosureDataSerializationCluster : public SerializationCluster { | 697 class ClosureDataSerializationCluster : public SerializationCluster { |
| 698 public: | 698 public: |
| 699 ClosureDataSerializationCluster() {} | 699 ClosureDataSerializationCluster() {} |
| 700 virtual ~ClosureDataSerializationCluster() {} | 700 virtual ~ClosureDataSerializationCluster() {} |
| 701 | 701 |
| 702 void Trace(Serializer* s, RawObject* object) { | 702 void Trace(Serializer* s, RawObject* object) { |
| 703 RawClosureData* data = ClosureData::RawCast(object); | 703 RawClosureData* data = ClosureData::RawCast(object); |
| 704 objects_.Add(data); | 704 objects_.Add(data); |
| 705 | 705 |
| 706 if (s->kind() != Snapshot::kAppNoJIT) { | 706 if (s->kind() != Snapshot::kAppAOT) { |
| 707 s->Push(data->ptr()->context_scope_); | 707 s->Push(data->ptr()->context_scope_); |
| 708 } | 708 } |
| 709 s->Push(data->ptr()->parent_function_); | 709 s->Push(data->ptr()->parent_function_); |
| 710 s->Push(data->ptr()->signature_type_); | 710 s->Push(data->ptr()->signature_type_); |
| 711 s->Push(data->ptr()->closure_); | 711 s->Push(data->ptr()->closure_); |
| 712 } | 712 } |
| 713 | 713 |
| 714 void WriteAlloc(Serializer* s) { | 714 void WriteAlloc(Serializer* s) { |
| 715 s->WriteCid(kClosureDataCid); | 715 s->WriteCid(kClosureDataCid); |
| 716 intptr_t count = objects_.length(); | 716 intptr_t count = objects_.length(); |
| 717 s->Write<int32_t>(count); | 717 s->Write<int32_t>(count); |
| 718 for (intptr_t i = 0; i < count; i++) { | 718 for (intptr_t i = 0; i < count; i++) { |
| 719 RawClosureData* data = objects_[i]; | 719 RawClosureData* data = objects_[i]; |
| 720 s->AssignRef(data); | 720 s->AssignRef(data); |
| 721 } | 721 } |
| 722 } | 722 } |
| 723 | 723 |
| 724 void WriteFill(Serializer* s) { | 724 void WriteFill(Serializer* s) { |
| 725 intptr_t count = objects_.length(); | 725 intptr_t count = objects_.length(); |
| 726 for (intptr_t i = 0; i < count; i++) { | 726 for (intptr_t i = 0; i < count; i++) { |
| 727 RawClosureData* data = objects_[i]; | 727 RawClosureData* data = objects_[i]; |
| 728 if (s->kind() != Snapshot::kAppNoJIT) { | 728 if (s->kind() != Snapshot::kAppAOT) { |
| 729 s->WriteRef(data->ptr()->context_scope_); | 729 s->WriteRef(data->ptr()->context_scope_); |
| 730 } | 730 } |
| 731 s->WriteRef(data->ptr()->parent_function_); | 731 s->WriteRef(data->ptr()->parent_function_); |
| 732 s->WriteRef(data->ptr()->signature_type_); | 732 s->WriteRef(data->ptr()->signature_type_); |
| 733 s->WriteRef(data->ptr()->closure_); | 733 s->WriteRef(data->ptr()->closure_); |
| 734 } | 734 } |
| 735 } | 735 } |
| 736 | 736 |
| 737 private: | 737 private: |
| 738 GrowableArray<RawClosureData*> objects_; | 738 GrowableArray<RawClosureData*> objects_; |
| (...skipping 17 matching lines...) Expand all Loading... |
| 756 stop_index_ = d->next_index(); | 756 stop_index_ = d->next_index(); |
| 757 } | 757 } |
| 758 | 758 |
| 759 void ReadFill(Deserializer* d) { | 759 void ReadFill(Deserializer* d) { |
| 760 bool is_vm_object = d->isolate() == Dart::vm_isolate(); | 760 bool is_vm_object = d->isolate() == Dart::vm_isolate(); |
| 761 | 761 |
| 762 for (intptr_t id = start_index_; id < stop_index_; id++) { | 762 for (intptr_t id = start_index_; id < stop_index_; id++) { |
| 763 RawClosureData* data = reinterpret_cast<RawClosureData*>(d->Ref(id)); | 763 RawClosureData* data = reinterpret_cast<RawClosureData*>(d->Ref(id)); |
| 764 Deserializer::InitializeHeader(data, kClosureDataCid, | 764 Deserializer::InitializeHeader(data, kClosureDataCid, |
| 765 ClosureData::InstanceSize(), is_vm_object); | 765 ClosureData::InstanceSize(), is_vm_object); |
| 766 if (d->kind() == Snapshot::kAppNoJIT) { | 766 if (d->kind() == Snapshot::kAppAOT) { |
| 767 data->ptr()->context_scope_ = ContextScope::null(); | 767 data->ptr()->context_scope_ = ContextScope::null(); |
| 768 } else { | 768 } else { |
| 769 data->ptr()->context_scope_ = | 769 data->ptr()->context_scope_ = |
| 770 static_cast<RawContextScope*>(d->ReadRef()); | 770 static_cast<RawContextScope*>(d->ReadRef()); |
| 771 } | 771 } |
| 772 data->ptr()->parent_function_ = static_cast<RawFunction*>(d->ReadRef()); | 772 data->ptr()->parent_function_ = static_cast<RawFunction*>(d->ReadRef()); |
| 773 data->ptr()->signature_type_ = static_cast<RawType*>(d->ReadRef()); | 773 data->ptr()->signature_type_ = static_cast<RawType*>(d->ReadRef()); |
| 774 data->ptr()->closure_ = static_cast<RawInstance*>(d->ReadRef()); | 774 data->ptr()->closure_ = static_cast<RawInstance*>(d->ReadRef()); |
| 775 } | 775 } |
| 776 } | 776 } |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 867 RawField* field = Field::RawCast(object); | 867 RawField* field = Field::RawCast(object); |
| 868 objects_.Add(field); | 868 objects_.Add(field); |
| 869 | 869 |
| 870 Snapshot::Kind kind = s->kind(); | 870 Snapshot::Kind kind = s->kind(); |
| 871 | 871 |
| 872 s->Push(field->ptr()->name_); | 872 s->Push(field->ptr()->name_); |
| 873 s->Push(field->ptr()->owner_); | 873 s->Push(field->ptr()->owner_); |
| 874 s->Push(field->ptr()->type_); | 874 s->Push(field->ptr()->type_); |
| 875 // Write out the initial static value or field offset. | 875 // Write out the initial static value or field offset. |
| 876 if (Field::StaticBit::decode(field->ptr()->kind_bits_)) { | 876 if (Field::StaticBit::decode(field->ptr()->kind_bits_)) { |
| 877 if (kind == Snapshot::kAppNoJIT) { | 877 if (kind == Snapshot::kAppAOT) { |
| 878 // For precompiled static fields, the value was already reset and | 878 // For precompiled static fields, the value was already reset and |
| 879 // initializer_ now contains a Function. | 879 // initializer_ now contains a Function. |
| 880 s->Push(field->ptr()->value_.static_value_); | 880 s->Push(field->ptr()->value_.static_value_); |
| 881 } else if (Field::ConstBit::decode(field->ptr()->kind_bits_)) { | 881 } else if (Field::ConstBit::decode(field->ptr()->kind_bits_)) { |
| 882 // Do not reset const fields. | 882 // Do not reset const fields. |
| 883 s->Push(field->ptr()->value_.static_value_); | 883 s->Push(field->ptr()->value_.static_value_); |
| 884 } else { | 884 } else { |
| 885 // Otherwise, for static fields we write out the initial static value. | 885 // Otherwise, for static fields we write out the initial static value. |
| 886 s->Push(field->ptr()->initializer_.saved_value_); | 886 s->Push(field->ptr()->initializer_.saved_value_); |
| 887 } | 887 } |
| 888 } else { | 888 } else { |
| 889 s->Push(field->ptr()->value_.offset_); | 889 s->Push(field->ptr()->value_.offset_); |
| 890 } | 890 } |
| 891 // Write out the initializer function or saved initial value. | 891 // Write out the initializer function or saved initial value. |
| 892 if (kind == Snapshot::kAppNoJIT) { | 892 if (kind == Snapshot::kAppAOT) { |
| 893 s->Push(field->ptr()->initializer_.precompiled_); | 893 s->Push(field->ptr()->initializer_.precompiled_); |
| 894 } else { | 894 } else { |
| 895 s->Push(field->ptr()->initializer_.saved_value_); | 895 s->Push(field->ptr()->initializer_.saved_value_); |
| 896 } | 896 } |
| 897 if (kind != Snapshot::kAppNoJIT) { | 897 if (kind != Snapshot::kAppAOT) { |
| 898 // Write out the guarded list length. | 898 // Write out the guarded list length. |
| 899 s->Push(field->ptr()->guarded_list_length_); | 899 s->Push(field->ptr()->guarded_list_length_); |
| 900 } | 900 } |
| 901 if (kind == Snapshot::kAppWithJIT) { | 901 if (kind == Snapshot::kAppJIT) { |
| 902 s->Push(field->ptr()->dependent_code_); | 902 s->Push(field->ptr()->dependent_code_); |
| 903 } | 903 } |
| 904 } | 904 } |
| 905 | 905 |
| 906 void WriteAlloc(Serializer* s) { | 906 void WriteAlloc(Serializer* s) { |
| 907 s->WriteCid(kFieldCid); | 907 s->WriteCid(kFieldCid); |
| 908 intptr_t count = objects_.length(); | 908 intptr_t count = objects_.length(); |
| 909 s->Write<int32_t>(count); | 909 s->Write<int32_t>(count); |
| 910 for (intptr_t i = 0; i < count; i++) { | 910 for (intptr_t i = 0; i < count; i++) { |
| 911 RawField* field = objects_[i]; | 911 RawField* field = objects_[i]; |
| 912 s->AssignRef(field); | 912 s->AssignRef(field); |
| 913 } | 913 } |
| 914 } | 914 } |
| 915 | 915 |
| 916 void WriteFill(Serializer* s) { | 916 void WriteFill(Serializer* s) { |
| 917 Snapshot::Kind kind = s->kind(); | 917 Snapshot::Kind kind = s->kind(); |
| 918 intptr_t count = objects_.length(); | 918 intptr_t count = objects_.length(); |
| 919 for (intptr_t i = 0; i < count; i++) { | 919 for (intptr_t i = 0; i < count; i++) { |
| 920 RawField* field = objects_[i]; | 920 RawField* field = objects_[i]; |
| 921 | 921 |
| 922 s->WriteRef(field->ptr()->name_); | 922 s->WriteRef(field->ptr()->name_); |
| 923 s->WriteRef(field->ptr()->owner_); | 923 s->WriteRef(field->ptr()->owner_); |
| 924 s->WriteRef(field->ptr()->type_); | 924 s->WriteRef(field->ptr()->type_); |
| 925 // Write out the initial static value or field offset. | 925 // Write out the initial static value or field offset. |
| 926 if (Field::StaticBit::decode(field->ptr()->kind_bits_)) { | 926 if (Field::StaticBit::decode(field->ptr()->kind_bits_)) { |
| 927 if (kind == Snapshot::kAppNoJIT) { | 927 if (kind == Snapshot::kAppAOT) { |
| 928 // For precompiled static fields, the value was already reset and | 928 // For precompiled static fields, the value was already reset and |
| 929 // initializer_ now contains a Function. | 929 // initializer_ now contains a Function. |
| 930 s->WriteRef(field->ptr()->value_.static_value_); | 930 s->WriteRef(field->ptr()->value_.static_value_); |
| 931 } else if (Field::ConstBit::decode(field->ptr()->kind_bits_)) { | 931 } else if (Field::ConstBit::decode(field->ptr()->kind_bits_)) { |
| 932 // Do not reset const fields. | 932 // Do not reset const fields. |
| 933 s->WriteRef(field->ptr()->value_.static_value_); | 933 s->WriteRef(field->ptr()->value_.static_value_); |
| 934 } else { | 934 } else { |
| 935 // Otherwise, for static fields we write out the initial static value. | 935 // Otherwise, for static fields we write out the initial static value. |
| 936 s->WriteRef(field->ptr()->initializer_.saved_value_); | 936 s->WriteRef(field->ptr()->initializer_.saved_value_); |
| 937 } | 937 } |
| 938 } else { | 938 } else { |
| 939 s->WriteRef(field->ptr()->value_.offset_); | 939 s->WriteRef(field->ptr()->value_.offset_); |
| 940 } | 940 } |
| 941 // Write out the initializer function or saved initial value. | 941 // Write out the initializer function or saved initial value. |
| 942 if (kind == Snapshot::kAppNoJIT) { | 942 if (kind == Snapshot::kAppAOT) { |
| 943 s->WriteRef(field->ptr()->initializer_.precompiled_); | 943 s->WriteRef(field->ptr()->initializer_.precompiled_); |
| 944 } else { | 944 } else { |
| 945 s->WriteRef(field->ptr()->initializer_.saved_value_); | 945 s->WriteRef(field->ptr()->initializer_.saved_value_); |
| 946 } | 946 } |
| 947 if (kind != Snapshot::kAppNoJIT) { | 947 if (kind != Snapshot::kAppAOT) { |
| 948 // Write out the guarded list length. | 948 // Write out the guarded list length. |
| 949 s->WriteRef(field->ptr()->guarded_list_length_); | 949 s->WriteRef(field->ptr()->guarded_list_length_); |
| 950 } | 950 } |
| 951 if (kind == Snapshot::kAppWithJIT) { | 951 if (kind == Snapshot::kAppJIT) { |
| 952 s->WriteRef(field->ptr()->dependent_code_); | 952 s->WriteRef(field->ptr()->dependent_code_); |
| 953 } | 953 } |
| 954 | 954 |
| 955 if (kind != Snapshot::kAppNoJIT) { | 955 if (kind != Snapshot::kAppAOT) { |
| 956 s->WriteTokenPosition(field->ptr()->token_pos_); | 956 s->WriteTokenPosition(field->ptr()->token_pos_); |
| 957 s->WriteCid(field->ptr()->guarded_cid_); | 957 s->WriteCid(field->ptr()->guarded_cid_); |
| 958 s->WriteCid(field->ptr()->is_nullable_); | 958 s->WriteCid(field->ptr()->is_nullable_); |
| 959 } | 959 } |
| 960 s->Write<uint8_t>(field->ptr()->kind_bits_); | 960 s->Write<uint8_t>(field->ptr()->kind_bits_); |
| 961 } | 961 } |
| 962 } | 962 } |
| 963 | 963 |
| 964 private: | 964 private: |
| 965 GrowableArray<RawField*> objects_; | 965 GrowableArray<RawField*> objects_; |
| (...skipping 27 matching lines...) Expand all Loading... |
| 993 RawObject** from = field->from(); | 993 RawObject** from = field->from(); |
| 994 RawObject** to_snapshot = field->to_snapshot(kind); | 994 RawObject** to_snapshot = field->to_snapshot(kind); |
| 995 RawObject** to = field->to(); | 995 RawObject** to = field->to(); |
| 996 for (RawObject** p = from; p <= to_snapshot; p++) { | 996 for (RawObject** p = from; p <= to_snapshot; p++) { |
| 997 *p = d->ReadRef(); | 997 *p = d->ReadRef(); |
| 998 } | 998 } |
| 999 for (RawObject** p = to_snapshot + 1; p <= to; p++) { | 999 for (RawObject** p = to_snapshot + 1; p <= to; p++) { |
| 1000 *p = Object::null(); | 1000 *p = Object::null(); |
| 1001 } | 1001 } |
| 1002 | 1002 |
| 1003 if (kind != Snapshot::kAppNoJIT) { | 1003 if (kind != Snapshot::kAppAOT) { |
| 1004 field->ptr()->token_pos_ = d->ReadTokenPosition(); | 1004 field->ptr()->token_pos_ = d->ReadTokenPosition(); |
| 1005 field->ptr()->guarded_cid_ = d->ReadCid(); | 1005 field->ptr()->guarded_cid_ = d->ReadCid(); |
| 1006 field->ptr()->is_nullable_ = d->ReadCid(); | 1006 field->ptr()->is_nullable_ = d->ReadCid(); |
| 1007 } | 1007 } |
| 1008 field->ptr()->kind_bits_ = d->Read<uint8_t>(); | 1008 field->ptr()->kind_bits_ = d->Read<uint8_t>(); |
| 1009 } | 1009 } |
| 1010 } | 1010 } |
| 1011 | 1011 |
| 1012 void PostLoad(const Array& refs, Snapshot::Kind kind, Zone* zone) { | 1012 void PostLoad(const Array& refs, Snapshot::Kind kind, Zone* zone) { |
| 1013 NOT_IN_PRODUCT(TimelineDurationScope tds( | 1013 NOT_IN_PRODUCT(TimelineDurationScope tds( |
| (...skipping 468 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1482 void Trace(Serializer* s, RawObject* object) { | 1482 void Trace(Serializer* s, RawObject* object) { |
| 1483 RawCode* code = Code::RawCast(object); | 1483 RawCode* code = Code::RawCast(object); |
| 1484 objects_.Add(code); | 1484 objects_.Add(code); |
| 1485 | 1485 |
| 1486 s->Push(code->ptr()->object_pool_); | 1486 s->Push(code->ptr()->object_pool_); |
| 1487 s->Push(code->ptr()->owner_); | 1487 s->Push(code->ptr()->owner_); |
| 1488 s->Push(code->ptr()->exception_handlers_); | 1488 s->Push(code->ptr()->exception_handlers_); |
| 1489 s->Push(code->ptr()->pc_descriptors_); | 1489 s->Push(code->ptr()->pc_descriptors_); |
| 1490 s->Push(code->ptr()->stackmaps_); | 1490 s->Push(code->ptr()->stackmaps_); |
| 1491 | 1491 |
| 1492 if (s->kind() == Snapshot::kAppWithJIT) { | 1492 if (s->kind() == Snapshot::kAppJIT) { |
| 1493 s->Push(code->ptr()->deopt_info_array_); | 1493 s->Push(code->ptr()->deopt_info_array_); |
| 1494 s->Push(code->ptr()->static_calls_target_table_); | 1494 s->Push(code->ptr()->static_calls_target_table_); |
| 1495 NOT_IN_PRODUCT(s->Push(code->ptr()->inlined_metadata_)); | 1495 NOT_IN_PRODUCT(s->Push(code->ptr()->inlined_metadata_)); |
| 1496 NOT_IN_PRODUCT(s->Push(code->ptr()->return_address_metadata_)); | 1496 NOT_IN_PRODUCT(s->Push(code->ptr()->return_address_metadata_)); |
| 1497 } | 1497 } |
| 1498 } | 1498 } |
| 1499 | 1499 |
| 1500 void WriteAlloc(Serializer* s) { | 1500 void WriteAlloc(Serializer* s) { |
| 1501 s->WriteCid(kCodeCid); | 1501 s->WriteCid(kCodeCid); |
| 1502 intptr_t count = objects_.length(); | 1502 intptr_t count = objects_.length(); |
| 1503 s->Write<int32_t>(count); | 1503 s->Write<int32_t>(count); |
| 1504 for (intptr_t i = 0; i < count; i++) { | 1504 for (intptr_t i = 0; i < count; i++) { |
| 1505 RawCode* code = objects_[i]; | 1505 RawCode* code = objects_[i]; |
| 1506 s->AssignRef(code); | 1506 s->AssignRef(code); |
| 1507 } | 1507 } |
| 1508 } | 1508 } |
| 1509 | 1509 |
| 1510 void WriteFill(Serializer* s) { | 1510 void WriteFill(Serializer* s) { |
| 1511 Snapshot::Kind kind = s->kind(); | 1511 Snapshot::Kind kind = s->kind(); |
| 1512 intptr_t count = objects_.length(); | 1512 intptr_t count = objects_.length(); |
| 1513 for (intptr_t i = 0; i < count; i++) { | 1513 for (intptr_t i = 0; i < count; i++) { |
| 1514 RawCode* code = objects_[i]; | 1514 RawCode* code = objects_[i]; |
| 1515 | 1515 |
| 1516 intptr_t pointer_offsets_length = | 1516 intptr_t pointer_offsets_length = |
| 1517 Code::PtrOffBits::decode(code->ptr()->state_bits_); | 1517 Code::PtrOffBits::decode(code->ptr()->state_bits_); |
| 1518 if (pointer_offsets_length != 0) { | 1518 if (pointer_offsets_length != 0) { |
| 1519 FATAL("Cannot serialize code with embedded pointers"); | 1519 FATAL("Cannot serialize code with embedded pointers"); |
| 1520 } | 1520 } |
| 1521 if (kind == Snapshot::kAppNoJIT) { | 1521 if (kind == Snapshot::kAppAOT) { |
| 1522 // No disabled code in precompilation. | 1522 // No disabled code in precompilation. |
| 1523 NOT_IN_PRECOMPILED(ASSERT(code->ptr()->instructions_ == | 1523 NOT_IN_PRECOMPILED(ASSERT(code->ptr()->instructions_ == |
| 1524 code->ptr()->active_instructions_)); | 1524 code->ptr()->active_instructions_)); |
| 1525 } | 1525 } |
| 1526 | 1526 |
| 1527 RawInstructions* instr = code->ptr()->instructions_; | 1527 RawInstructions* instr = code->ptr()->instructions_; |
| 1528 int32_t text_offset = s->GetTextOffset(instr, code); | 1528 int32_t text_offset = s->GetTextOffset(instr, code); |
| 1529 s->Write<int32_t>(text_offset); | 1529 s->Write<int32_t>(text_offset); |
| 1530 if (s->kind() == Snapshot::kAppWithJIT) { | 1530 if (s->kind() == Snapshot::kAppJIT) { |
| 1531 // TODO(rmacnak): Fix references to disabled code before serializing. | 1531 // TODO(rmacnak): Fix references to disabled code before serializing. |
| 1532 if (code->ptr()->active_instructions_ != code->ptr()->instructions_) { | 1532 if (code->ptr()->active_instructions_ != code->ptr()->instructions_) { |
| 1533 instr = code->ptr()->active_instructions_; | 1533 instr = code->ptr()->active_instructions_; |
| 1534 text_offset = s->GetTextOffset(instr, code); | 1534 text_offset = s->GetTextOffset(instr, code); |
| 1535 } | 1535 } |
| 1536 s->Write<int32_t>(text_offset); | 1536 s->Write<int32_t>(text_offset); |
| 1537 } | 1537 } |
| 1538 | 1538 |
| 1539 s->WriteRef(code->ptr()->object_pool_); | 1539 s->WriteRef(code->ptr()->object_pool_); |
| 1540 s->WriteRef(code->ptr()->owner_); | 1540 s->WriteRef(code->ptr()->owner_); |
| 1541 s->WriteRef(code->ptr()->exception_handlers_); | 1541 s->WriteRef(code->ptr()->exception_handlers_); |
| 1542 s->WriteRef(code->ptr()->pc_descriptors_); | 1542 s->WriteRef(code->ptr()->pc_descriptors_); |
| 1543 s->WriteRef(code->ptr()->stackmaps_); | 1543 s->WriteRef(code->ptr()->stackmaps_); |
| 1544 | 1544 |
| 1545 if (s->kind() == Snapshot::kAppWithJIT) { | 1545 if (s->kind() == Snapshot::kAppJIT) { |
| 1546 s->WriteRef(code->ptr()->deopt_info_array_); | 1546 s->WriteRef(code->ptr()->deopt_info_array_); |
| 1547 s->WriteRef(code->ptr()->static_calls_target_table_); | 1547 s->WriteRef(code->ptr()->static_calls_target_table_); |
| 1548 NOT_IN_PRODUCT(s->WriteRef(code->ptr()->inlined_metadata_)); | 1548 NOT_IN_PRODUCT(s->WriteRef(code->ptr()->inlined_metadata_)); |
| 1549 NOT_IN_PRODUCT(s->WriteRef(code->ptr()->return_address_metadata_)); | 1549 NOT_IN_PRODUCT(s->WriteRef(code->ptr()->return_address_metadata_)); |
| 1550 } | 1550 } |
| 1551 | 1551 |
| 1552 s->Write<int32_t>(code->ptr()->state_bits_); | 1552 s->Write<int32_t>(code->ptr()->state_bits_); |
| 1553 } | 1553 } |
| 1554 } | 1554 } |
| 1555 | 1555 |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1586 RawInstructions* instr = reinterpret_cast<RawInstructions*>( | 1586 RawInstructions* instr = reinterpret_cast<RawInstructions*>( |
| 1587 d->GetInstructionsAt(text_offset) + kHeapObjectTag); | 1587 d->GetInstructionsAt(text_offset) + kHeapObjectTag); |
| 1588 | 1588 |
| 1589 code->ptr()->entry_point_ = Instructions::UncheckedEntryPoint(instr); | 1589 code->ptr()->entry_point_ = Instructions::UncheckedEntryPoint(instr); |
| 1590 code->ptr()->checked_entry_point_ = | 1590 code->ptr()->checked_entry_point_ = |
| 1591 Instructions::CheckedEntryPoint(instr); | 1591 Instructions::CheckedEntryPoint(instr); |
| 1592 NOT_IN_PRECOMPILED(code->ptr()->active_instructions_ = instr); | 1592 NOT_IN_PRECOMPILED(code->ptr()->active_instructions_ = instr); |
| 1593 code->ptr()->instructions_ = instr; | 1593 code->ptr()->instructions_ = instr; |
| 1594 | 1594 |
| 1595 #if !defined(DART_PRECOMPILED_RUNTIME) | 1595 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 1596 if (d->kind() == Snapshot::kAppWithJIT) { | 1596 if (d->kind() == Snapshot::kAppJIT) { |
| 1597 int32_t text_offset = d->Read<int32_t>(); | 1597 int32_t text_offset = d->Read<int32_t>(); |
| 1598 RawInstructions* instr = reinterpret_cast<RawInstructions*>( | 1598 RawInstructions* instr = reinterpret_cast<RawInstructions*>( |
| 1599 d->GetInstructionsAt(text_offset) + kHeapObjectTag); | 1599 d->GetInstructionsAt(text_offset) + kHeapObjectTag); |
| 1600 code->ptr()->active_instructions_ = instr; | 1600 code->ptr()->active_instructions_ = instr; |
| 1601 code->ptr()->entry_point_ = Instructions::UncheckedEntryPoint(instr); | 1601 code->ptr()->entry_point_ = Instructions::UncheckedEntryPoint(instr); |
| 1602 code->ptr()->checked_entry_point_ = | 1602 code->ptr()->checked_entry_point_ = |
| 1603 Instructions::CheckedEntryPoint(instr); | 1603 Instructions::CheckedEntryPoint(instr); |
| 1604 } | 1604 } |
| 1605 #endif // !DART_PRECOMPILED_RUNTIME | 1605 #endif // !DART_PRECOMPILED_RUNTIME |
| 1606 | 1606 |
| 1607 code->ptr()->object_pool_ = | 1607 code->ptr()->object_pool_ = |
| 1608 reinterpret_cast<RawObjectPool*>(d->ReadRef()); | 1608 reinterpret_cast<RawObjectPool*>(d->ReadRef()); |
| 1609 code->ptr()->owner_ = d->ReadRef(); | 1609 code->ptr()->owner_ = d->ReadRef(); |
| 1610 code->ptr()->exception_handlers_ = | 1610 code->ptr()->exception_handlers_ = |
| 1611 reinterpret_cast<RawExceptionHandlers*>(d->ReadRef()); | 1611 reinterpret_cast<RawExceptionHandlers*>(d->ReadRef()); |
| 1612 code->ptr()->pc_descriptors_ = | 1612 code->ptr()->pc_descriptors_ = |
| 1613 reinterpret_cast<RawPcDescriptors*>(d->ReadRef()); | 1613 reinterpret_cast<RawPcDescriptors*>(d->ReadRef()); |
| 1614 code->ptr()->stackmaps_ = reinterpret_cast<RawArray*>(d->ReadRef()); | 1614 code->ptr()->stackmaps_ = reinterpret_cast<RawArray*>(d->ReadRef()); |
| 1615 | 1615 |
| 1616 #if !defined(DART_PRECOMPILED_RUNTIME) | 1616 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 1617 if (d->kind() == Snapshot::kAppWithJIT) { | 1617 if (d->kind() == Snapshot::kAppJIT) { |
| 1618 code->ptr()->deopt_info_array_ = | 1618 code->ptr()->deopt_info_array_ = |
| 1619 reinterpret_cast<RawArray*>(d->ReadRef()); | 1619 reinterpret_cast<RawArray*>(d->ReadRef()); |
| 1620 code->ptr()->static_calls_target_table_ = | 1620 code->ptr()->static_calls_target_table_ = |
| 1621 reinterpret_cast<RawArray*>(d->ReadRef()); | 1621 reinterpret_cast<RawArray*>(d->ReadRef()); |
| 1622 #if defined(PRODUCT) | 1622 #if defined(PRODUCT) |
| 1623 code->ptr()->inlined_metadata_ = Array::null(); | 1623 code->ptr()->inlined_metadata_ = Array::null(); |
| 1624 code->ptr()->return_address_metadata_ = Object::null(); | 1624 code->ptr()->return_address_metadata_ = Object::null(); |
| 1625 #else | 1625 #else |
| 1626 code->ptr()->inlined_metadata_ = | 1626 code->ptr()->inlined_metadata_ = |
| 1627 reinterpret_cast<RawArray*>(d->ReadRef()); | 1627 reinterpret_cast<RawArray*>(d->ReadRef()); |
| (...skipping 610 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2238 void WriteFill(Serializer* s) { | 2238 void WriteFill(Serializer* s) { |
| 2239 Snapshot::Kind kind = s->kind(); | 2239 Snapshot::Kind kind = s->kind(); |
| 2240 intptr_t count = objects_.length(); | 2240 intptr_t count = objects_.length(); |
| 2241 for (intptr_t i = 0; i < count; i++) { | 2241 for (intptr_t i = 0; i < count; i++) { |
| 2242 RawICData* ic = objects_[i]; | 2242 RawICData* ic = objects_[i]; |
| 2243 RawObject** from = ic->from(); | 2243 RawObject** from = ic->from(); |
| 2244 RawObject** to = ic->to_snapshot(kind); | 2244 RawObject** to = ic->to_snapshot(kind); |
| 2245 for (RawObject** p = from; p <= to; p++) { | 2245 for (RawObject** p = from; p <= to; p++) { |
| 2246 s->WriteRef(*p); | 2246 s->WriteRef(*p); |
| 2247 } | 2247 } |
| 2248 if (kind != Snapshot::kAppNoJIT) { | 2248 if (kind != Snapshot::kAppAOT) { |
| 2249 NOT_IN_PRECOMPILED(s->Write<int32_t>(ic->ptr()->deopt_id_)); | 2249 NOT_IN_PRECOMPILED(s->Write<int32_t>(ic->ptr()->deopt_id_)); |
| 2250 } | 2250 } |
| 2251 s->Write<uint32_t>(ic->ptr()->state_bits_); | 2251 s->Write<uint32_t>(ic->ptr()->state_bits_); |
| 2252 #if defined(TAG_IC_DATA) | 2252 #if defined(TAG_IC_DATA) |
| 2253 s->Write<int32_t>(ic->ptr()->tag_); | 2253 s->Write<int32_t>(ic->ptr()->tag_); |
| 2254 #endif | 2254 #endif |
| 2255 } | 2255 } |
| 2256 } | 2256 } |
| 2257 | 2257 |
| 2258 private: | 2258 private: |
| (...skipping 3102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5361 | 5361 |
| 5362 deserializer.ReadVMSnapshot(); | 5362 deserializer.ReadVMSnapshot(); |
| 5363 | 5363 |
| 5364 Dart::set_instructions_snapshot_buffer(instructions_buffer_); | 5364 Dart::set_instructions_snapshot_buffer(instructions_buffer_); |
| 5365 Dart::set_data_snapshot_buffer(data_buffer_); | 5365 Dart::set_data_snapshot_buffer(data_buffer_); |
| 5366 | 5366 |
| 5367 return ApiError::null(); | 5367 return ApiError::null(); |
| 5368 } | 5368 } |
| 5369 | 5369 |
| 5370 } // namespace dart | 5370 } // namespace dart |
| OLD | NEW |