Chromium Code Reviews| 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 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 510 | 510 |
| 511 void Trace(Serializer* s, RawObject* object) { | 511 void Trace(Serializer* s, RawObject* object) { |
| 512 RawFunction* func = Function::RawCast(object); | 512 RawFunction* func = Function::RawCast(object); |
| 513 objects_.Add(func); | 513 objects_.Add(func); |
| 514 | 514 |
| 515 RawObject** from = func->from(); | 515 RawObject** from = func->from(); |
| 516 RawObject** to = func->to_snapshot(); | 516 RawObject** to = func->to_snapshot(); |
| 517 for (RawObject** p = from; p <= to; p++) { | 517 for (RawObject** p = from; p <= to; p++) { |
| 518 s->Push(*p); | 518 s->Push(*p); |
| 519 } | 519 } |
| 520 if (s->kind() == Snapshot::kAppAOT) { | 520 if (s->kind() == Snapshot::kFullAOT) { |
| 521 s->Push(func->ptr()->code_); | 521 s->Push(func->ptr()->code_); |
| 522 } else if (s->kind() == Snapshot::kAppJIT) { | 522 } else if (s->kind() == Snapshot::kFullJIT) { |
| 523 NOT_IN_PRECOMPILED(s->Push(func->ptr()->unoptimized_code_)); | 523 NOT_IN_PRECOMPILED(s->Push(func->ptr()->unoptimized_code_)); |
| 524 s->Push(func->ptr()->code_); | 524 s->Push(func->ptr()->code_); |
| 525 s->Push(func->ptr()->ic_data_array_); | 525 s->Push(func->ptr()->ic_data_array_); |
| 526 } | 526 } |
| 527 } | 527 } |
| 528 | 528 |
| 529 void WriteAlloc(Serializer* s) { | 529 void WriteAlloc(Serializer* s) { |
| 530 s->WriteCid(kFunctionCid); | 530 s->WriteCid(kFunctionCid); |
| 531 intptr_t count = objects_.length(); | 531 intptr_t count = objects_.length(); |
| 532 s->Write<int32_t>(count); | 532 s->Write<int32_t>(count); |
| 533 for (intptr_t i = 0; i < count; i++) { | 533 for (intptr_t i = 0; i < count; i++) { |
| 534 RawFunction* func = objects_[i]; | 534 RawFunction* func = objects_[i]; |
| 535 s->AssignRef(func); | 535 s->AssignRef(func); |
| 536 } | 536 } |
| 537 } | 537 } |
| 538 | 538 |
| 539 void WriteFill(Serializer* s) { | 539 void WriteFill(Serializer* s) { |
| 540 Snapshot::Kind kind = s->kind(); | 540 Snapshot::Kind kind = s->kind(); |
| 541 intptr_t count = objects_.length(); | 541 intptr_t count = objects_.length(); |
| 542 for (intptr_t i = 0; i < count; i++) { | 542 for (intptr_t i = 0; i < count; i++) { |
| 543 RawFunction* func = objects_[i]; | 543 RawFunction* func = objects_[i]; |
| 544 RawObject** from = func->from(); | 544 RawObject** from = func->from(); |
| 545 RawObject** to = func->to_snapshot(); | 545 RawObject** to = func->to_snapshot(); |
| 546 for (RawObject** p = from; p <= to; p++) { | 546 for (RawObject** p = from; p <= to; p++) { |
| 547 s->WriteRef(*p); | 547 s->WriteRef(*p); |
| 548 } | 548 } |
| 549 if (kind == Snapshot::kAppAOT) { | 549 if (kind == Snapshot::kFullAOT) { |
| 550 s->WriteRef(func->ptr()->code_); | 550 s->WriteRef(func->ptr()->code_); |
| 551 } else if (s->kind() == Snapshot::kAppJIT) { | 551 } else if (s->kind() == Snapshot::kFullJIT) { |
| 552 NOT_IN_PRECOMPILED(s->WriteRef(func->ptr()->unoptimized_code_)); | 552 NOT_IN_PRECOMPILED(s->WriteRef(func->ptr()->unoptimized_code_)); |
| 553 s->WriteRef(func->ptr()->code_); | 553 s->WriteRef(func->ptr()->code_); |
| 554 s->WriteRef(func->ptr()->ic_data_array_); | 554 s->WriteRef(func->ptr()->ic_data_array_); |
| 555 } | 555 } |
| 556 | 556 |
| 557 #if !defined(DART_PRECOMPILED_RUNTIME) | 557 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 558 if (kind != Snapshot::kAppAOT) { | 558 if (kind != Snapshot::kFullAOT) { |
| 559 s->WriteTokenPosition(func->ptr()->token_pos_); | 559 s->WriteTokenPosition(func->ptr()->token_pos_); |
| 560 s->WriteTokenPosition(func->ptr()->end_token_pos_); | 560 s->WriteTokenPosition(func->ptr()->end_token_pos_); |
| 561 } | 561 } |
| 562 #endif | 562 #endif |
| 563 s->Write<int16_t>(func->ptr()->num_fixed_parameters_); | 563 s->Write<int16_t>(func->ptr()->num_fixed_parameters_); |
| 564 s->Write<int16_t>(func->ptr()->num_optional_parameters_); | 564 s->Write<int16_t>(func->ptr()->num_optional_parameters_); |
| 565 s->Write<uint32_t>(func->ptr()->kind_tag_); | 565 s->Write<uint32_t>(func->ptr()->kind_tag_); |
| 566 if (kind == Snapshot::kAppAOT) { | 566 if (kind == Snapshot::kFullAOT) { |
| 567 // Omit fields used to support de/reoptimization. | 567 // Omit fields used to support de/reoptimization. |
| 568 } else if (!Snapshot::IncludesCode(kind)) { | 568 } else if (!Snapshot::IncludesCode(kind)) { |
| 569 #if !defined(DART_PRECOMPILED_RUNTIME) | 569 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 570 bool is_optimized = Code::IsOptimized(func->ptr()->code_); | 570 bool is_optimized = Code::IsOptimized(func->ptr()->code_); |
| 571 if (is_optimized) { | 571 if (is_optimized) { |
| 572 s->Write<int32_t>(FLAG_optimization_counter_threshold); | 572 s->Write<int32_t>(FLAG_optimization_counter_threshold); |
| 573 } else { | 573 } else { |
| 574 s->Write<int32_t>(0); | 574 s->Write<int32_t>(0); |
| 575 } | 575 } |
| 576 #endif | 576 #endif |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 609 Function::InstanceSize(), is_vm_object); | 609 Function::InstanceSize(), is_vm_object); |
| 610 RawObject** from = func->from(); | 610 RawObject** from = func->from(); |
| 611 RawObject** to_snapshot = func->to_snapshot(); | 611 RawObject** to_snapshot = func->to_snapshot(); |
| 612 RawObject** to = func->to(); | 612 RawObject** to = func->to(); |
| 613 for (RawObject** p = from; p <= to_snapshot; p++) { | 613 for (RawObject** p = from; p <= to_snapshot; p++) { |
| 614 *p = d->ReadRef(); | 614 *p = d->ReadRef(); |
| 615 } | 615 } |
| 616 for (RawObject** p = to_snapshot + 1; p <= to; p++) { | 616 for (RawObject** p = to_snapshot + 1; p <= to; p++) { |
| 617 *p = Object::null(); | 617 *p = Object::null(); |
| 618 } | 618 } |
| 619 if (kind == Snapshot::kAppAOT) { | 619 if (kind == Snapshot::kFullAOT) { |
| 620 func->ptr()->code_ = reinterpret_cast<RawCode*>(d->ReadRef()); | 620 func->ptr()->code_ = reinterpret_cast<RawCode*>(d->ReadRef()); |
| 621 } else if (kind == Snapshot::kAppJIT) { | 621 } else if (kind == Snapshot::kFullJIT) { |
| 622 NOT_IN_PRECOMPILED(func->ptr()->unoptimized_code_ = | 622 NOT_IN_PRECOMPILED(func->ptr()->unoptimized_code_ = |
| 623 reinterpret_cast<RawCode*>(d->ReadRef())); | 623 reinterpret_cast<RawCode*>(d->ReadRef())); |
| 624 func->ptr()->code_ = reinterpret_cast<RawCode*>(d->ReadRef()); | 624 func->ptr()->code_ = reinterpret_cast<RawCode*>(d->ReadRef()); |
| 625 func->ptr()->ic_data_array_ = reinterpret_cast<RawArray*>(d->ReadRef()); | 625 func->ptr()->ic_data_array_ = reinterpret_cast<RawArray*>(d->ReadRef()); |
| 626 } | 626 } |
| 627 | 627 |
| 628 #if defined(DEBUG) | 628 #if defined(DEBUG) |
| 629 func->ptr()->entry_point_ = 0; | 629 func->ptr()->entry_point_ = 0; |
| 630 #endif | 630 #endif |
| 631 | 631 |
| 632 #if !defined(DART_PRECOMPILED_RUNTIME) | 632 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 633 if (kind != Snapshot::kAppAOT) { | 633 if (kind != Snapshot::kFullAOT) { |
| 634 func->ptr()->token_pos_ = d->ReadTokenPosition(); | 634 func->ptr()->token_pos_ = d->ReadTokenPosition(); |
| 635 func->ptr()->end_token_pos_ = d->ReadTokenPosition(); | 635 func->ptr()->end_token_pos_ = d->ReadTokenPosition(); |
| 636 } | 636 } |
| 637 #endif | 637 #endif |
| 638 func->ptr()->num_fixed_parameters_ = d->Read<int16_t>(); | 638 func->ptr()->num_fixed_parameters_ = d->Read<int16_t>(); |
| 639 func->ptr()->num_optional_parameters_ = d->Read<int16_t>(); | 639 func->ptr()->num_optional_parameters_ = d->Read<int16_t>(); |
| 640 func->ptr()->kind_tag_ = d->Read<uint32_t>(); | 640 func->ptr()->kind_tag_ = d->Read<uint32_t>(); |
| 641 if (kind == Snapshot::kAppAOT) { | 641 if (kind == Snapshot::kFullAOT) { |
| 642 // Omit fields used to support de/reoptimization. | 642 // Omit fields used to support de/reoptimization. |
| 643 } else { | 643 } else { |
| 644 #if !defined(DART_PRECOMPILED_RUNTIME) | 644 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 645 if (Snapshot::IncludesCode(kind)) { | 645 if (Snapshot::IncludesCode(kind)) { |
| 646 func->ptr()->usage_counter_ = 0; | 646 func->ptr()->usage_counter_ = 0; |
| 647 } else { | 647 } else { |
| 648 func->ptr()->usage_counter_ = d->Read<int32_t>(); | 648 func->ptr()->usage_counter_ = d->Read<int32_t>(); |
| 649 } | 649 } |
| 650 func->ptr()->deoptimization_counter_ = 0; | 650 func->ptr()->deoptimization_counter_ = 0; |
| 651 func->ptr()->optimized_instruction_count_ = 0; | 651 func->ptr()->optimized_instruction_count_ = 0; |
| 652 func->ptr()->optimized_call_site_count_ = 0; | 652 func->ptr()->optimized_call_site_count_ = 0; |
| 653 #endif | 653 #endif |
| 654 } | 654 } |
| 655 } | 655 } |
| 656 } | 656 } |
| 657 | 657 |
| 658 void PostLoad(const Array& refs, Snapshot::Kind kind, Zone* zone) { | 658 void PostLoad(const Array& refs, Snapshot::Kind kind, Zone* zone) { |
| 659 NOT_IN_PRODUCT(TimelineDurationScope tds( | 659 NOT_IN_PRODUCT(TimelineDurationScope tds( |
| 660 Thread::Current(), Timeline::GetIsolateStream(), "PostLoadFunction")); | 660 Thread::Current(), Timeline::GetIsolateStream(), "PostLoadFunction")); |
| 661 | 661 |
| 662 if (kind == Snapshot::kAppAOT) { | 662 if (kind == Snapshot::kFullAOT) { |
| 663 Function& func = Function::Handle(zone); | 663 Function& func = Function::Handle(zone); |
| 664 for (intptr_t i = start_index_; i < stop_index_; i++) { | 664 for (intptr_t i = start_index_; i < stop_index_; i++) { |
| 665 func ^= refs.At(i); | 665 func ^= refs.At(i); |
| 666 ASSERT(func.raw()->ptr()->code_->IsCode()); | 666 ASSERT(func.raw()->ptr()->code_->IsCode()); |
| 667 uword entry_point = func.raw()->ptr()->code_->ptr()->entry_point_; | 667 uword entry_point = func.raw()->ptr()->code_->ptr()->entry_point_; |
| 668 ASSERT(entry_point != 0); | 668 ASSERT(entry_point != 0); |
| 669 func.raw()->ptr()->entry_point_ = entry_point; | 669 func.raw()->ptr()->entry_point_ = entry_point; |
| 670 } | 670 } |
| 671 } else if (kind == Snapshot::kAppJIT) { | 671 } else if (kind == Snapshot::kFullJIT) { |
| 672 Function& func = Function::Handle(zone); | 672 Function& func = Function::Handle(zone); |
| 673 Code& code = Code::Handle(zone); | 673 Code& code = Code::Handle(zone); |
| 674 for (intptr_t i = start_index_; i < stop_index_; i++) { | 674 for (intptr_t i = start_index_; i < stop_index_; i++) { |
| 675 func ^= refs.At(i); | 675 func ^= refs.At(i); |
| 676 code ^= func.CurrentCode(); | 676 code ^= func.CurrentCode(); |
| 677 if (func.HasCode() && !code.IsDisabled()) { | 677 if (func.HasCode() && !code.IsDisabled()) { |
| 678 func.SetInstructions(code); | 678 func.SetInstructions(code); |
| 679 func.set_was_compiled(true); | 679 func.set_was_compiled(true); |
| 680 } else { | 680 } else { |
| 681 func.ClearCode(); | 681 func.ClearCode(); |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 698 #if !defined(DART_PRECOMPILED_RUNTIME) | 698 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 699 class ClosureDataSerializationCluster : public SerializationCluster { | 699 class ClosureDataSerializationCluster : public SerializationCluster { |
| 700 public: | 700 public: |
| 701 ClosureDataSerializationCluster() {} | 701 ClosureDataSerializationCluster() {} |
| 702 virtual ~ClosureDataSerializationCluster() {} | 702 virtual ~ClosureDataSerializationCluster() {} |
| 703 | 703 |
| 704 void Trace(Serializer* s, RawObject* object) { | 704 void Trace(Serializer* s, RawObject* object) { |
| 705 RawClosureData* data = ClosureData::RawCast(object); | 705 RawClosureData* data = ClosureData::RawCast(object); |
| 706 objects_.Add(data); | 706 objects_.Add(data); |
| 707 | 707 |
| 708 if (s->kind() != Snapshot::kAppAOT) { | 708 if (s->kind() != Snapshot::kFullAOT) { |
| 709 s->Push(data->ptr()->context_scope_); | 709 s->Push(data->ptr()->context_scope_); |
| 710 } | 710 } |
| 711 s->Push(data->ptr()->parent_function_); | 711 s->Push(data->ptr()->parent_function_); |
| 712 s->Push(data->ptr()->signature_type_); | 712 s->Push(data->ptr()->signature_type_); |
| 713 s->Push(data->ptr()->closure_); | 713 s->Push(data->ptr()->closure_); |
| 714 } | 714 } |
| 715 | 715 |
| 716 void WriteAlloc(Serializer* s) { | 716 void WriteAlloc(Serializer* s) { |
| 717 s->WriteCid(kClosureDataCid); | 717 s->WriteCid(kClosureDataCid); |
| 718 intptr_t count = objects_.length(); | 718 intptr_t count = objects_.length(); |
| 719 s->Write<int32_t>(count); | 719 s->Write<int32_t>(count); |
| 720 for (intptr_t i = 0; i < count; i++) { | 720 for (intptr_t i = 0; i < count; i++) { |
| 721 RawClosureData* data = objects_[i]; | 721 RawClosureData* data = objects_[i]; |
| 722 s->AssignRef(data); | 722 s->AssignRef(data); |
| 723 } | 723 } |
| 724 } | 724 } |
| 725 | 725 |
| 726 void WriteFill(Serializer* s) { | 726 void WriteFill(Serializer* s) { |
| 727 intptr_t count = objects_.length(); | 727 intptr_t count = objects_.length(); |
| 728 for (intptr_t i = 0; i < count; i++) { | 728 for (intptr_t i = 0; i < count; i++) { |
| 729 RawClosureData* data = objects_[i]; | 729 RawClosureData* data = objects_[i]; |
| 730 if (s->kind() != Snapshot::kAppAOT) { | 730 if (s->kind() != Snapshot::kFullAOT) { |
| 731 s->WriteRef(data->ptr()->context_scope_); | 731 s->WriteRef(data->ptr()->context_scope_); |
| 732 } | 732 } |
| 733 s->WriteRef(data->ptr()->parent_function_); | 733 s->WriteRef(data->ptr()->parent_function_); |
| 734 s->WriteRef(data->ptr()->signature_type_); | 734 s->WriteRef(data->ptr()->signature_type_); |
| 735 s->WriteRef(data->ptr()->closure_); | 735 s->WriteRef(data->ptr()->closure_); |
| 736 } | 736 } |
| 737 } | 737 } |
| 738 | 738 |
| 739 private: | 739 private: |
| 740 GrowableArray<RawClosureData*> objects_; | 740 GrowableArray<RawClosureData*> objects_; |
| (...skipping 17 matching lines...) Expand all Loading... | |
| 758 stop_index_ = d->next_index(); | 758 stop_index_ = d->next_index(); |
| 759 } | 759 } |
| 760 | 760 |
| 761 void ReadFill(Deserializer* d) { | 761 void ReadFill(Deserializer* d) { |
| 762 bool is_vm_object = d->isolate() == Dart::vm_isolate(); | 762 bool is_vm_object = d->isolate() == Dart::vm_isolate(); |
| 763 | 763 |
| 764 for (intptr_t id = start_index_; id < stop_index_; id++) { | 764 for (intptr_t id = start_index_; id < stop_index_; id++) { |
| 765 RawClosureData* data = reinterpret_cast<RawClosureData*>(d->Ref(id)); | 765 RawClosureData* data = reinterpret_cast<RawClosureData*>(d->Ref(id)); |
| 766 Deserializer::InitializeHeader(data, kClosureDataCid, | 766 Deserializer::InitializeHeader(data, kClosureDataCid, |
| 767 ClosureData::InstanceSize(), is_vm_object); | 767 ClosureData::InstanceSize(), is_vm_object); |
| 768 if (d->kind() == Snapshot::kAppAOT) { | 768 if (d->kind() == Snapshot::kFullAOT) { |
| 769 data->ptr()->context_scope_ = ContextScope::null(); | 769 data->ptr()->context_scope_ = ContextScope::null(); |
| 770 } else { | 770 } else { |
| 771 data->ptr()->context_scope_ = | 771 data->ptr()->context_scope_ = |
| 772 static_cast<RawContextScope*>(d->ReadRef()); | 772 static_cast<RawContextScope*>(d->ReadRef()); |
| 773 } | 773 } |
| 774 data->ptr()->parent_function_ = static_cast<RawFunction*>(d->ReadRef()); | 774 data->ptr()->parent_function_ = static_cast<RawFunction*>(d->ReadRef()); |
| 775 data->ptr()->signature_type_ = static_cast<RawType*>(d->ReadRef()); | 775 data->ptr()->signature_type_ = static_cast<RawType*>(d->ReadRef()); |
| 776 data->ptr()->closure_ = static_cast<RawInstance*>(d->ReadRef()); | 776 data->ptr()->closure_ = static_cast<RawInstance*>(d->ReadRef()); |
| 777 data->ptr()->hash_ = Object::null(); | 777 data->ptr()->hash_ = Object::null(); |
| 778 } | 778 } |
| (...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 948 RawField* field = Field::RawCast(object); | 948 RawField* field = Field::RawCast(object); |
| 949 objects_.Add(field); | 949 objects_.Add(field); |
| 950 | 950 |
| 951 Snapshot::Kind kind = s->kind(); | 951 Snapshot::Kind kind = s->kind(); |
| 952 | 952 |
| 953 s->Push(field->ptr()->name_); | 953 s->Push(field->ptr()->name_); |
| 954 s->Push(field->ptr()->owner_); | 954 s->Push(field->ptr()->owner_); |
| 955 s->Push(field->ptr()->type_); | 955 s->Push(field->ptr()->type_); |
| 956 // Write out the initial static value or field offset. | 956 // Write out the initial static value or field offset. |
| 957 if (Field::StaticBit::decode(field->ptr()->kind_bits_)) { | 957 if (Field::StaticBit::decode(field->ptr()->kind_bits_)) { |
| 958 if (kind == Snapshot::kAppAOT) { | 958 if (kind == Snapshot::kFullAOT) { |
| 959 // For precompiled static fields, the value was already reset and | 959 // For precompiled static fields, the value was already reset and |
| 960 // initializer_ now contains a Function. | 960 // initializer_ now contains a Function. |
| 961 s->Push(field->ptr()->value_.static_value_); | 961 s->Push(field->ptr()->value_.static_value_); |
| 962 } else if (Field::ConstBit::decode(field->ptr()->kind_bits_)) { | 962 } else if (Field::ConstBit::decode(field->ptr()->kind_bits_)) { |
| 963 // Do not reset const fields. | 963 // Do not reset const fields. |
| 964 s->Push(field->ptr()->value_.static_value_); | 964 s->Push(field->ptr()->value_.static_value_); |
| 965 } else { | 965 } else { |
| 966 // Otherwise, for static fields we write out the initial static value. | 966 // Otherwise, for static fields we write out the initial static value. |
| 967 s->Push(field->ptr()->initializer_.saved_value_); | 967 s->Push(field->ptr()->initializer_.saved_value_); |
| 968 } | 968 } |
| 969 } else { | 969 } else { |
| 970 s->Push(field->ptr()->value_.offset_); | 970 s->Push(field->ptr()->value_.offset_); |
| 971 } | 971 } |
| 972 // Write out the initializer function or saved initial value. | 972 // Write out the initializer function or saved initial value. |
| 973 if (kind == Snapshot::kAppAOT) { | 973 if (kind == Snapshot::kFullAOT) { |
| 974 s->Push(field->ptr()->initializer_.precompiled_); | 974 s->Push(field->ptr()->initializer_.precompiled_); |
| 975 } else { | 975 } else { |
| 976 s->Push(field->ptr()->initializer_.saved_value_); | 976 s->Push(field->ptr()->initializer_.saved_value_); |
| 977 } | 977 } |
| 978 if (kind != Snapshot::kAppAOT) { | 978 if (kind != Snapshot::kFullAOT) { |
| 979 // Write out the guarded list length. | 979 // Write out the guarded list length. |
| 980 s->Push(field->ptr()->guarded_list_length_); | 980 s->Push(field->ptr()->guarded_list_length_); |
| 981 } | 981 } |
| 982 if (kind == Snapshot::kAppJIT) { | 982 if (kind == Snapshot::kFullJIT) { |
| 983 s->Push(field->ptr()->dependent_code_); | 983 s->Push(field->ptr()->dependent_code_); |
| 984 } | 984 } |
| 985 } | 985 } |
| 986 | 986 |
| 987 void WriteAlloc(Serializer* s) { | 987 void WriteAlloc(Serializer* s) { |
| 988 s->WriteCid(kFieldCid); | 988 s->WriteCid(kFieldCid); |
| 989 intptr_t count = objects_.length(); | 989 intptr_t count = objects_.length(); |
| 990 s->Write<int32_t>(count); | 990 s->Write<int32_t>(count); |
| 991 for (intptr_t i = 0; i < count; i++) { | 991 for (intptr_t i = 0; i < count; i++) { |
| 992 RawField* field = objects_[i]; | 992 RawField* field = objects_[i]; |
| 993 s->AssignRef(field); | 993 s->AssignRef(field); |
| 994 } | 994 } |
| 995 } | 995 } |
| 996 | 996 |
| 997 void WriteFill(Serializer* s) { | 997 void WriteFill(Serializer* s) { |
| 998 Snapshot::Kind kind = s->kind(); | 998 Snapshot::Kind kind = s->kind(); |
| 999 intptr_t count = objects_.length(); | 999 intptr_t count = objects_.length(); |
| 1000 for (intptr_t i = 0; i < count; i++) { | 1000 for (intptr_t i = 0; i < count; i++) { |
| 1001 RawField* field = objects_[i]; | 1001 RawField* field = objects_[i]; |
| 1002 | 1002 |
| 1003 s->WriteRef(field->ptr()->name_); | 1003 s->WriteRef(field->ptr()->name_); |
| 1004 s->WriteRef(field->ptr()->owner_); | 1004 s->WriteRef(field->ptr()->owner_); |
| 1005 s->WriteRef(field->ptr()->type_); | 1005 s->WriteRef(field->ptr()->type_); |
| 1006 // Write out the initial static value or field offset. | 1006 // Write out the initial static value or field offset. |
| 1007 if (Field::StaticBit::decode(field->ptr()->kind_bits_)) { | 1007 if (Field::StaticBit::decode(field->ptr()->kind_bits_)) { |
| 1008 if (kind == Snapshot::kAppAOT) { | 1008 if (kind == Snapshot::kFullAOT) { |
| 1009 // For precompiled static fields, the value was already reset and | 1009 // For precompiled static fields, the value was already reset and |
| 1010 // initializer_ now contains a Function. | 1010 // initializer_ now contains a Function. |
| 1011 s->WriteRef(field->ptr()->value_.static_value_); | 1011 s->WriteRef(field->ptr()->value_.static_value_); |
| 1012 } else if (Field::ConstBit::decode(field->ptr()->kind_bits_)) { | 1012 } else if (Field::ConstBit::decode(field->ptr()->kind_bits_)) { |
| 1013 // Do not reset const fields. | 1013 // Do not reset const fields. |
| 1014 s->WriteRef(field->ptr()->value_.static_value_); | 1014 s->WriteRef(field->ptr()->value_.static_value_); |
| 1015 } else { | 1015 } else { |
| 1016 // Otherwise, for static fields we write out the initial static value. | 1016 // Otherwise, for static fields we write out the initial static value. |
| 1017 s->WriteRef(field->ptr()->initializer_.saved_value_); | 1017 s->WriteRef(field->ptr()->initializer_.saved_value_); |
| 1018 } | 1018 } |
| 1019 } else { | 1019 } else { |
| 1020 s->WriteRef(field->ptr()->value_.offset_); | 1020 s->WriteRef(field->ptr()->value_.offset_); |
| 1021 } | 1021 } |
| 1022 // Write out the initializer function or saved initial value. | 1022 // Write out the initializer function or saved initial value. |
| 1023 if (kind == Snapshot::kAppAOT) { | 1023 if (kind == Snapshot::kFullAOT) { |
| 1024 s->WriteRef(field->ptr()->initializer_.precompiled_); | 1024 s->WriteRef(field->ptr()->initializer_.precompiled_); |
| 1025 } else { | 1025 } else { |
| 1026 s->WriteRef(field->ptr()->initializer_.saved_value_); | 1026 s->WriteRef(field->ptr()->initializer_.saved_value_); |
| 1027 } | 1027 } |
| 1028 if (kind != Snapshot::kAppAOT) { | 1028 if (kind != Snapshot::kFullAOT) { |
| 1029 // Write out the guarded list length. | 1029 // Write out the guarded list length. |
| 1030 s->WriteRef(field->ptr()->guarded_list_length_); | 1030 s->WriteRef(field->ptr()->guarded_list_length_); |
| 1031 } | 1031 } |
| 1032 if (kind == Snapshot::kAppJIT) { | 1032 if (kind == Snapshot::kFullJIT) { |
| 1033 s->WriteRef(field->ptr()->dependent_code_); | 1033 s->WriteRef(field->ptr()->dependent_code_); |
| 1034 } | 1034 } |
| 1035 | 1035 |
| 1036 if (kind != Snapshot::kAppAOT) { | 1036 if (kind != Snapshot::kFullAOT) { |
| 1037 s->WriteTokenPosition(field->ptr()->token_pos_); | 1037 s->WriteTokenPosition(field->ptr()->token_pos_); |
| 1038 s->WriteCid(field->ptr()->guarded_cid_); | 1038 s->WriteCid(field->ptr()->guarded_cid_); |
| 1039 s->WriteCid(field->ptr()->is_nullable_); | 1039 s->WriteCid(field->ptr()->is_nullable_); |
| 1040 } | 1040 } |
| 1041 s->Write<uint8_t>(field->ptr()->kind_bits_); | 1041 s->Write<uint8_t>(field->ptr()->kind_bits_); |
| 1042 } | 1042 } |
| 1043 } | 1043 } |
| 1044 | 1044 |
| 1045 private: | 1045 private: |
| 1046 GrowableArray<RawField*> objects_; | 1046 GrowableArray<RawField*> objects_; |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 1074 RawObject** from = field->from(); | 1074 RawObject** from = field->from(); |
| 1075 RawObject** to_snapshot = field->to_snapshot(kind); | 1075 RawObject** to_snapshot = field->to_snapshot(kind); |
| 1076 RawObject** to = field->to(); | 1076 RawObject** to = field->to(); |
| 1077 for (RawObject** p = from; p <= to_snapshot; p++) { | 1077 for (RawObject** p = from; p <= to_snapshot; p++) { |
| 1078 *p = d->ReadRef(); | 1078 *p = d->ReadRef(); |
| 1079 } | 1079 } |
| 1080 for (RawObject** p = to_snapshot + 1; p <= to; p++) { | 1080 for (RawObject** p = to_snapshot + 1; p <= to; p++) { |
| 1081 *p = Object::null(); | 1081 *p = Object::null(); |
| 1082 } | 1082 } |
| 1083 | 1083 |
| 1084 if (kind != Snapshot::kAppAOT) { | 1084 if (kind != Snapshot::kFullAOT) { |
| 1085 field->ptr()->token_pos_ = d->ReadTokenPosition(); | 1085 field->ptr()->token_pos_ = d->ReadTokenPosition(); |
| 1086 field->ptr()->guarded_cid_ = d->ReadCid(); | 1086 field->ptr()->guarded_cid_ = d->ReadCid(); |
| 1087 field->ptr()->is_nullable_ = d->ReadCid(); | 1087 field->ptr()->is_nullable_ = d->ReadCid(); |
| 1088 } | 1088 } |
| 1089 field->ptr()->kind_bits_ = d->Read<uint8_t>(); | 1089 field->ptr()->kind_bits_ = d->Read<uint8_t>(); |
| 1090 } | 1090 } |
| 1091 } | 1091 } |
| 1092 | 1092 |
| 1093 void PostLoad(const Array& refs, Snapshot::Kind kind, Zone* zone) { | 1093 void PostLoad(const Array& refs, Snapshot::Kind kind, Zone* zone) { |
| 1094 NOT_IN_PRODUCT(TimelineDurationScope tds( | 1094 NOT_IN_PRODUCT(TimelineDurationScope tds( |
| (...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1539 }; | 1539 }; |
| 1540 | 1540 |
| 1541 | 1541 |
| 1542 #if !defined(DART_PRECOMPILED_RUNTIME) | 1542 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 1543 class CodeSerializationCluster : public SerializationCluster { | 1543 class CodeSerializationCluster : public SerializationCluster { |
| 1544 public: | 1544 public: |
| 1545 CodeSerializationCluster() {} | 1545 CodeSerializationCluster() {} |
| 1546 virtual ~CodeSerializationCluster() {} | 1546 virtual ~CodeSerializationCluster() {} |
| 1547 | 1547 |
| 1548 void Trace(Serializer* s, RawObject* object) { | 1548 void Trace(Serializer* s, RawObject* object) { |
| 1549 OS::Print("C"); | |
|
zra
2017/05/31 17:10:31
leftover debug print?
rmacnak
2017/05/31 19:53:01
Removed.
| |
| 1549 RawCode* code = Code::RawCast(object); | 1550 RawCode* code = Code::RawCast(object); |
| 1550 objects_.Add(code); | 1551 objects_.Add(code); |
| 1551 | 1552 |
| 1552 s->Push(code->ptr()->object_pool_); | 1553 s->Push(code->ptr()->object_pool_); |
| 1553 s->Push(code->ptr()->owner_); | 1554 s->Push(code->ptr()->owner_); |
| 1554 s->Push(code->ptr()->exception_handlers_); | 1555 s->Push(code->ptr()->exception_handlers_); |
| 1555 s->Push(code->ptr()->pc_descriptors_); | 1556 s->Push(code->ptr()->pc_descriptors_); |
| 1556 #if defined(DART_PRECOMPILED_RUNTIME) || defined(DART_PRECOMPILER) | 1557 #if defined(DART_PRECOMPILED_RUNTIME) || defined(DART_PRECOMPILER) |
| 1557 s->Push(code->ptr()->catch_entry_.catch_entry_state_maps_); | 1558 s->Push(code->ptr()->catch_entry_.catch_entry_state_maps_); |
| 1558 #else | 1559 #else |
| 1559 s->Push(code->ptr()->catch_entry_.variables_); | 1560 s->Push(code->ptr()->catch_entry_.variables_); |
| 1560 #endif | 1561 #endif |
| 1561 s->Push(code->ptr()->stackmaps_); | 1562 s->Push(code->ptr()->stackmaps_); |
| 1562 if (!FLAG_dwarf_stack_traces) { | 1563 if (!FLAG_dwarf_stack_traces) { |
| 1563 s->Push(code->ptr()->inlined_id_to_function_); | 1564 s->Push(code->ptr()->inlined_id_to_function_); |
| 1564 s->Push(code->ptr()->code_source_map_); | 1565 s->Push(code->ptr()->code_source_map_); |
| 1565 } | 1566 } |
| 1566 if (s->kind() != Snapshot::kAppAOT) { | 1567 if (s->kind() != Snapshot::kFullAOT) { |
| 1567 s->Push(code->ptr()->await_token_positions_); | 1568 s->Push(code->ptr()->await_token_positions_); |
| 1568 } | 1569 } |
| 1569 | 1570 |
| 1570 if (s->kind() == Snapshot::kAppJIT) { | 1571 if (s->kind() == Snapshot::kFullJIT) { |
| 1571 s->Push(code->ptr()->deopt_info_array_); | 1572 s->Push(code->ptr()->deopt_info_array_); |
| 1572 s->Push(code->ptr()->static_calls_target_table_); | 1573 s->Push(code->ptr()->static_calls_target_table_); |
| 1573 NOT_IN_PRODUCT(s->Push(code->ptr()->return_address_metadata_)); | 1574 NOT_IN_PRODUCT(s->Push(code->ptr()->return_address_metadata_)); |
| 1574 } | 1575 } |
| 1575 } | 1576 } |
| 1576 | 1577 |
| 1577 void WriteAlloc(Serializer* s) { | 1578 void WriteAlloc(Serializer* s) { |
| 1578 s->WriteCid(kCodeCid); | 1579 s->WriteCid(kCodeCid); |
| 1579 intptr_t count = objects_.length(); | 1580 intptr_t count = objects_.length(); |
| 1580 s->Write<int32_t>(count); | 1581 s->Write<int32_t>(count); |
| 1581 for (intptr_t i = 0; i < count; i++) { | 1582 for (intptr_t i = 0; i < count; i++) { |
| 1582 RawCode* code = objects_[i]; | 1583 RawCode* code = objects_[i]; |
| 1583 s->AssignRef(code); | 1584 s->AssignRef(code); |
| 1584 } | 1585 } |
| 1585 } | 1586 } |
| 1586 | 1587 |
| 1587 void WriteFill(Serializer* s) { | 1588 void WriteFill(Serializer* s) { |
| 1588 Snapshot::Kind kind = s->kind(); | 1589 Snapshot::Kind kind = s->kind(); |
| 1589 intptr_t count = objects_.length(); | 1590 intptr_t count = objects_.length(); |
| 1590 for (intptr_t i = 0; i < count; i++) { | 1591 for (intptr_t i = 0; i < count; i++) { |
| 1591 RawCode* code = objects_[i]; | 1592 RawCode* code = objects_[i]; |
| 1592 | 1593 |
| 1593 intptr_t pointer_offsets_length = | 1594 intptr_t pointer_offsets_length = |
| 1594 Code::PtrOffBits::decode(code->ptr()->state_bits_); | 1595 Code::PtrOffBits::decode(code->ptr()->state_bits_); |
| 1595 if (pointer_offsets_length != 0) { | 1596 if (pointer_offsets_length != 0) { |
| 1596 FATAL("Cannot serialize code with embedded pointers"); | 1597 FATAL("Cannot serialize code with embedded pointers"); |
| 1597 } | 1598 } |
| 1598 if (kind == Snapshot::kAppAOT) { | 1599 if (kind == Snapshot::kFullAOT) { |
| 1599 // No disabled code in precompilation. | 1600 // No disabled code in precompilation. |
| 1600 NOT_IN_PRECOMPILED(ASSERT(code->ptr()->instructions_ == | 1601 NOT_IN_PRECOMPILED(ASSERT(code->ptr()->instructions_ == |
| 1601 code->ptr()->active_instructions_)); | 1602 code->ptr()->active_instructions_)); |
| 1602 } | 1603 } |
| 1603 | 1604 |
| 1604 RawInstructions* instr = code->ptr()->instructions_; | 1605 RawInstructions* instr = code->ptr()->instructions_; |
| 1605 int32_t text_offset = s->GetTextOffset(instr, code); | 1606 int32_t text_offset = s->GetTextOffset(instr, code); |
| 1606 s->Write<int32_t>(text_offset); | 1607 s->Write<int32_t>(text_offset); |
| 1607 if (s->kind() == Snapshot::kAppJIT) { | 1608 if (s->kind() == Snapshot::kFullJIT) { |
| 1608 // TODO(rmacnak): Fix references to disabled code before serializing. | 1609 // TODO(rmacnak): Fix references to disabled code before serializing. |
| 1609 if (code->ptr()->active_instructions_ != code->ptr()->instructions_) { | 1610 if (code->ptr()->active_instructions_ != code->ptr()->instructions_) { |
| 1610 instr = code->ptr()->active_instructions_; | 1611 instr = code->ptr()->active_instructions_; |
| 1611 text_offset = s->GetTextOffset(instr, code); | 1612 text_offset = s->GetTextOffset(instr, code); |
| 1612 } | 1613 } |
| 1613 s->Write<int32_t>(text_offset); | 1614 s->Write<int32_t>(text_offset); |
| 1614 } | 1615 } |
| 1615 | 1616 |
| 1616 s->WriteRef(code->ptr()->object_pool_); | 1617 s->WriteRef(code->ptr()->object_pool_); |
| 1617 s->WriteRef(code->ptr()->owner_); | 1618 s->WriteRef(code->ptr()->owner_); |
| 1618 s->WriteRef(code->ptr()->exception_handlers_); | 1619 s->WriteRef(code->ptr()->exception_handlers_); |
| 1619 s->WriteRef(code->ptr()->pc_descriptors_); | 1620 s->WriteRef(code->ptr()->pc_descriptors_); |
| 1620 #if defined(DART_PRECOMPILED_RUNTIME) || defined(DART_PRECOMPILER) | 1621 #if defined(DART_PRECOMPILED_RUNTIME) || defined(DART_PRECOMPILER) |
| 1621 s->WriteRef(code->ptr()->catch_entry_.catch_entry_state_maps_); | 1622 s->WriteRef(code->ptr()->catch_entry_.catch_entry_state_maps_); |
| 1622 #else | 1623 #else |
| 1623 s->WriteRef(code->ptr()->catch_entry_.variables_); | 1624 s->WriteRef(code->ptr()->catch_entry_.variables_); |
| 1624 #endif | 1625 #endif |
| 1625 s->WriteRef(code->ptr()->stackmaps_); | 1626 s->WriteRef(code->ptr()->stackmaps_); |
| 1626 if (FLAG_dwarf_stack_traces) { | 1627 if (FLAG_dwarf_stack_traces) { |
| 1627 s->WriteRef(Array::null()); | 1628 s->WriteRef(Array::null()); |
| 1628 s->WriteRef(CodeSourceMap::null()); | 1629 s->WriteRef(CodeSourceMap::null()); |
| 1629 } else { | 1630 } else { |
| 1630 s->WriteRef(code->ptr()->inlined_id_to_function_); | 1631 s->WriteRef(code->ptr()->inlined_id_to_function_); |
| 1631 s->WriteRef(code->ptr()->code_source_map_); | 1632 s->WriteRef(code->ptr()->code_source_map_); |
| 1632 } | 1633 } |
| 1633 if (s->kind() != Snapshot::kAppAOT) { | 1634 if (s->kind() != Snapshot::kFullAOT) { |
| 1634 s->WriteRef(code->ptr()->await_token_positions_); | 1635 s->WriteRef(code->ptr()->await_token_positions_); |
| 1635 } | 1636 } |
| 1636 if (s->kind() == Snapshot::kAppJIT) { | 1637 if (s->kind() == Snapshot::kFullJIT) { |
| 1637 s->WriteRef(code->ptr()->deopt_info_array_); | 1638 s->WriteRef(code->ptr()->deopt_info_array_); |
| 1638 s->WriteRef(code->ptr()->static_calls_target_table_); | 1639 s->WriteRef(code->ptr()->static_calls_target_table_); |
| 1639 NOT_IN_PRODUCT(s->WriteRef(code->ptr()->return_address_metadata_)); | 1640 NOT_IN_PRODUCT(s->WriteRef(code->ptr()->return_address_metadata_)); |
| 1640 } | 1641 } |
| 1641 | 1642 |
| 1642 s->Write<int32_t>(code->ptr()->state_bits_); | 1643 s->Write<int32_t>(code->ptr()->state_bits_); |
| 1643 } | 1644 } |
| 1644 } | 1645 } |
| 1645 | 1646 |
| 1646 private: | 1647 private: |
| (...skipping 28 matching lines...) Expand all Loading... | |
| 1675 int32_t text_offset = d->Read<int32_t>(); | 1676 int32_t text_offset = d->Read<int32_t>(); |
| 1676 RawInstructions* instr = d->GetInstructionsAt(text_offset); | 1677 RawInstructions* instr = d->GetInstructionsAt(text_offset); |
| 1677 | 1678 |
| 1678 code->ptr()->entry_point_ = Instructions::UncheckedEntryPoint(instr); | 1679 code->ptr()->entry_point_ = Instructions::UncheckedEntryPoint(instr); |
| 1679 code->ptr()->checked_entry_point_ = | 1680 code->ptr()->checked_entry_point_ = |
| 1680 Instructions::CheckedEntryPoint(instr); | 1681 Instructions::CheckedEntryPoint(instr); |
| 1681 NOT_IN_PRECOMPILED(code->ptr()->active_instructions_ = instr); | 1682 NOT_IN_PRECOMPILED(code->ptr()->active_instructions_ = instr); |
| 1682 code->ptr()->instructions_ = instr; | 1683 code->ptr()->instructions_ = instr; |
| 1683 | 1684 |
| 1684 #if !defined(DART_PRECOMPILED_RUNTIME) | 1685 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 1685 if (d->kind() == Snapshot::kAppJIT) { | 1686 if (d->kind() == Snapshot::kFullJIT) { |
| 1686 int32_t text_offset = d->Read<int32_t>(); | 1687 int32_t text_offset = d->Read<int32_t>(); |
| 1687 RawInstructions* instr = d->GetInstructionsAt(text_offset); | 1688 RawInstructions* instr = d->GetInstructionsAt(text_offset); |
| 1688 code->ptr()->active_instructions_ = instr; | 1689 code->ptr()->active_instructions_ = instr; |
| 1689 code->ptr()->entry_point_ = Instructions::UncheckedEntryPoint(instr); | 1690 code->ptr()->entry_point_ = Instructions::UncheckedEntryPoint(instr); |
| 1690 code->ptr()->checked_entry_point_ = | 1691 code->ptr()->checked_entry_point_ = |
| 1691 Instructions::CheckedEntryPoint(instr); | 1692 Instructions::CheckedEntryPoint(instr); |
| 1692 } | 1693 } |
| 1693 #endif // !DART_PRECOMPILED_RUNTIME | 1694 #endif // !DART_PRECOMPILED_RUNTIME |
| 1694 | 1695 |
| 1695 code->ptr()->object_pool_ = | 1696 code->ptr()->object_pool_ = |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 1709 code->ptr()->stackmaps_ = reinterpret_cast<RawArray*>(d->ReadRef()); | 1710 code->ptr()->stackmaps_ = reinterpret_cast<RawArray*>(d->ReadRef()); |
| 1710 code->ptr()->inlined_id_to_function_ = | 1711 code->ptr()->inlined_id_to_function_ = |
| 1711 reinterpret_cast<RawArray*>(d->ReadRef()); | 1712 reinterpret_cast<RawArray*>(d->ReadRef()); |
| 1712 code->ptr()->code_source_map_ = | 1713 code->ptr()->code_source_map_ = |
| 1713 reinterpret_cast<RawCodeSourceMap*>(d->ReadRef()); | 1714 reinterpret_cast<RawCodeSourceMap*>(d->ReadRef()); |
| 1714 | 1715 |
| 1715 #if !defined(DART_PRECOMPILED_RUNTIME) | 1716 #if !defined(DART_PRECOMPILED_RUNTIME) |
| 1716 code->ptr()->await_token_positions_ = | 1717 code->ptr()->await_token_positions_ = |
| 1717 reinterpret_cast<RawArray*>(d->ReadRef()); | 1718 reinterpret_cast<RawArray*>(d->ReadRef()); |
| 1718 | 1719 |
| 1719 if (d->kind() == Snapshot::kAppJIT) { | 1720 if (d->kind() == Snapshot::kFullJIT) { |
| 1720 code->ptr()->deopt_info_array_ = | 1721 code->ptr()->deopt_info_array_ = |
| 1721 reinterpret_cast<RawArray*>(d->ReadRef()); | 1722 reinterpret_cast<RawArray*>(d->ReadRef()); |
| 1722 code->ptr()->static_calls_target_table_ = | 1723 code->ptr()->static_calls_target_table_ = |
| 1723 reinterpret_cast<RawArray*>(d->ReadRef()); | 1724 reinterpret_cast<RawArray*>(d->ReadRef()); |
| 1724 #if defined(PRODUCT) | 1725 #if defined(PRODUCT) |
| 1725 code->ptr()->return_address_metadata_ = Object::null(); | 1726 code->ptr()->return_address_metadata_ = Object::null(); |
| 1726 #else | 1727 #else |
| 1727 code->ptr()->return_address_metadata_ = d->ReadRef(); | 1728 code->ptr()->return_address_metadata_ = d->ReadRef(); |
| 1728 #endif | 1729 #endif |
| 1729 } else { | 1730 } else { |
| (...skipping 605 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2335 void WriteFill(Serializer* s) { | 2336 void WriteFill(Serializer* s) { |
| 2336 Snapshot::Kind kind = s->kind(); | 2337 Snapshot::Kind kind = s->kind(); |
| 2337 intptr_t count = objects_.length(); | 2338 intptr_t count = objects_.length(); |
| 2338 for (intptr_t i = 0; i < count; i++) { | 2339 for (intptr_t i = 0; i < count; i++) { |
| 2339 RawICData* ic = objects_[i]; | 2340 RawICData* ic = objects_[i]; |
| 2340 RawObject** from = ic->from(); | 2341 RawObject** from = ic->from(); |
| 2341 RawObject** to = ic->to_snapshot(kind); | 2342 RawObject** to = ic->to_snapshot(kind); |
| 2342 for (RawObject** p = from; p <= to; p++) { | 2343 for (RawObject** p = from; p <= to; p++) { |
| 2343 s->WriteRef(*p); | 2344 s->WriteRef(*p); |
| 2344 } | 2345 } |
| 2345 if (kind != Snapshot::kAppAOT) { | 2346 if (kind != Snapshot::kFullAOT) { |
| 2346 NOT_IN_PRECOMPILED(s->Write<int32_t>(ic->ptr()->deopt_id_)); | 2347 NOT_IN_PRECOMPILED(s->Write<int32_t>(ic->ptr()->deopt_id_)); |
| 2347 } | 2348 } |
| 2348 s->Write<uint32_t>(ic->ptr()->state_bits_); | 2349 s->Write<uint32_t>(ic->ptr()->state_bits_); |
| 2349 #if defined(TAG_IC_DATA) | 2350 #if defined(TAG_IC_DATA) |
| 2350 s->Write<int32_t>(ic->ptr()->tag_); | 2351 s->Write<int32_t>(ic->ptr()->tag_); |
| 2351 #endif | 2352 #endif |
| 2352 } | 2353 } |
| 2353 } | 2354 } |
| 2354 | 2355 |
| 2355 private: | 2356 private: |
| (...skipping 2285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4641 if (Snapshot::IncludesCode(kind_)) { | 4642 if (Snapshot::IncludesCode(kind_)) { |
| 4642 return new (Z) RODataSerializationCluster(kTwoByteStringCid); | 4643 return new (Z) RODataSerializationCluster(kTwoByteStringCid); |
| 4643 } else { | 4644 } else { |
| 4644 return new (Z) TwoByteStringSerializationCluster(); | 4645 return new (Z) TwoByteStringSerializationCluster(); |
| 4645 } | 4646 } |
| 4646 } | 4647 } |
| 4647 default: | 4648 default: |
| 4648 break; | 4649 break; |
| 4649 } | 4650 } |
| 4650 | 4651 |
| 4651 FATAL1("No cluster defined for cid %" Pd, cid); | 4652 FATAL2("No cluster defined for cid %" Pd ", kind %s", cid, |
| 4653 Snapshot::KindToCString(kind_)); | |
| 4652 return NULL; | 4654 return NULL; |
| 4653 #endif // !DART_PRECOMPILED_RUNTIME | 4655 #endif // !DART_PRECOMPILED_RUNTIME |
| 4654 } | 4656 } |
| 4655 | 4657 |
| 4656 | 4658 |
| 4657 void Serializer::Push(RawObject* object) { | 4659 void Serializer::Push(RawObject* object) { |
| 4658 if (!object->IsHeapObject()) { | 4660 if (!object->IsHeapObject()) { |
| 4659 RawSmi* smi = Smi::RawCast(object); | 4661 RawSmi* smi = Smi::RawCast(object); |
| 4660 if (smi_ids_.Lookup(smi) == NULL) { | 4662 if (smi_ids_.Lookup(smi) == NULL) { |
| 4661 SmiObjectIdPair pair; | 4663 SmiObjectIdPair pair; |
| (...skipping 770 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5432 isolate()->ValidateClassTable(); | 5434 isolate()->ValidateClassTable(); |
| 5433 #endif | 5435 #endif |
| 5434 // Can't have any mutation happening while we're serializing. | 5436 // Can't have any mutation happening while we're serializing. |
| 5435 ASSERT(isolate()->background_compiler() == NULL); | 5437 ASSERT(isolate()->background_compiler() == NULL); |
| 5436 | 5438 |
| 5437 // TODO(rmacnak): The special case for AOT causes us to always generate the | 5439 // TODO(rmacnak): The special case for AOT causes us to always generate the |
| 5438 // same VM isolate snapshot for every app. AOT snapshots should be cleaned up | 5440 // same VM isolate snapshot for every app. AOT snapshots should be cleaned up |
| 5439 // so the VM isolate snapshot is generated separately and each app is | 5441 // so the VM isolate snapshot is generated separately and each app is |
| 5440 // generated from a VM that has loaded this snapshots, much like app-jit | 5442 // generated from a VM that has loaded this snapshots, much like app-jit |
| 5441 // snapshots. | 5443 // snapshots. |
| 5442 if ((vm_snapshot_data_buffer != NULL) && (kind != Snapshot::kAppAOT)) { | 5444 if ((vm_snapshot_data_buffer != NULL) && (kind != Snapshot::kFullAOT)) { |
| 5443 NOT_IN_PRODUCT(TimelineDurationScope tds( | 5445 NOT_IN_PRODUCT(TimelineDurationScope tds( |
| 5444 thread(), Timeline::GetIsolateStream(), "PrepareNewVMIsolate")); | 5446 thread(), Timeline::GetIsolateStream(), "PrepareNewVMIsolate")); |
| 5445 | 5447 |
| 5446 // Collect all the token stream objects into an array so that we can write | 5448 // Collect all the token stream objects into an array so that we can write |
| 5447 // it out as part of the VM isolate snapshot. We first count the number of | 5449 // it out as part of the VM isolate snapshot. We first count the number of |
| 5448 // token streams, allocate an array and then fill it up with the token | 5450 // token streams, allocate an array and then fill it up with the token |
| 5449 // streams. | 5451 // streams. |
| 5450 SnapshotTokenStreamVisitor token_streams_counter(thread()); | 5452 SnapshotTokenStreamVisitor token_streams_counter(thread()); |
| 5451 heap()->IterateOldObjects(&token_streams_counter); | 5453 heap()->IterateOldObjects(&token_streams_counter); |
| 5452 Dart::vm_isolate()->heap()->IterateOldObjects(&token_streams_counter); | 5454 Dart::vm_isolate()->heap()->IterateOldObjects(&token_streams_counter); |
| (...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5581 | 5583 |
| 5582 FullSnapshotReader::FullSnapshotReader(const Snapshot* snapshot, | 5584 FullSnapshotReader::FullSnapshotReader(const Snapshot* snapshot, |
| 5583 const uint8_t* instructions_buffer, | 5585 const uint8_t* instructions_buffer, |
| 5584 Thread* thread) | 5586 Thread* thread) |
| 5585 : kind_(snapshot->kind()), | 5587 : kind_(snapshot->kind()), |
| 5586 thread_(thread), | 5588 thread_(thread), |
| 5587 buffer_(snapshot->content()), | 5589 buffer_(snapshot->content()), |
| 5588 size_(snapshot->length()), | 5590 size_(snapshot->length()), |
| 5589 instructions_buffer_(instructions_buffer), | 5591 instructions_buffer_(instructions_buffer), |
| 5590 data_buffer_(DataBuffer(snapshot)) { | 5592 data_buffer_(DataBuffer(snapshot)) { |
| 5591 thread->isolate()->set_compilation_allowed(kind_ != Snapshot::kAppAOT); | 5593 thread->isolate()->set_compilation_allowed(kind_ != Snapshot::kFullAOT); |
| 5592 } | 5594 } |
| 5593 | 5595 |
| 5594 | 5596 |
| 5595 RawApiError* FullSnapshotReader::ReadVMSnapshot() { | 5597 RawApiError* FullSnapshotReader::ReadVMSnapshot() { |
| 5596 Deserializer deserializer(thread_, kind_, buffer_, size_, | 5598 Deserializer deserializer(thread_, kind_, buffer_, size_, |
| 5597 instructions_buffer_, data_buffer_); | 5599 instructions_buffer_, data_buffer_); |
| 5598 | 5600 |
| 5599 RawApiError* error = deserializer.VerifyVersionAndFeatures(/*isolate=*/NULL); | 5601 RawApiError* error = deserializer.VerifyVersionAndFeatures(/*isolate=*/NULL); |
| 5600 if (error != ApiError::null()) { | 5602 if (error != ApiError::null()) { |
| 5601 return error; | 5603 return error; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5634 thread_->isolate()->SetupImagePage(data_buffer_, | 5636 thread_->isolate()->SetupImagePage(data_buffer_, |
| 5635 /* is_executable */ false); | 5637 /* is_executable */ false); |
| 5636 } | 5638 } |
| 5637 | 5639 |
| 5638 deserializer.ReadIsolateSnapshot(thread_->isolate()->object_store()); | 5640 deserializer.ReadIsolateSnapshot(thread_->isolate()->object_store()); |
| 5639 | 5641 |
| 5640 return ApiError::null(); | 5642 return ApiError::null(); |
| 5641 } | 5643 } |
| 5642 | 5644 |
| 5643 } // namespace dart | 5645 } // namespace dart |
| OLD | NEW |