Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file |
| 2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
| 3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
| 4 | 4 |
| 5 #include "vm/native_entry.h" | 5 #include "vm/native_entry.h" |
| 6 #include "vm/object.h" | 6 #include "vm/object.h" |
| 7 #include "vm/object_store.h" | 7 #include "vm/object_store.h" |
| 8 #include "vm/snapshot.h" | 8 #include "vm/snapshot.h" |
| 9 #include "vm/stub_code.h" | 9 #include "vm/stub_code.h" |
| 10 #include "vm/symbols.h" | 10 #include "vm/symbols.h" |
| (...skipping 634 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 645 func.set_end_token_pos(reader->Read<int32_t>()); | 645 func.set_end_token_pos(reader->Read<int32_t>()); |
| 646 func.set_usage_counter(reader->Read<int32_t>()); | 646 func.set_usage_counter(reader->Read<int32_t>()); |
| 647 func.set_num_fixed_parameters(reader->Read<int16_t>()); | 647 func.set_num_fixed_parameters(reader->Read<int16_t>()); |
| 648 func.set_num_optional_parameters(reader->Read<int16_t>()); | 648 func.set_num_optional_parameters(reader->Read<int16_t>()); |
| 649 func.set_deoptimization_counter(reader->Read<int16_t>()); | 649 func.set_deoptimization_counter(reader->Read<int16_t>()); |
| 650 func.set_kind_tag(reader->Read<uint32_t>()); | 650 func.set_kind_tag(reader->Read<uint32_t>()); |
| 651 func.set_optimized_instruction_count(reader->Read<uint16_t>()); | 651 func.set_optimized_instruction_count(reader->Read<uint16_t>()); |
| 652 func.set_optimized_call_site_count(reader->Read<uint16_t>()); | 652 func.set_optimized_call_site_count(reader->Read<uint16_t>()); |
| 653 | 653 |
| 654 // Set all the object fields. | 654 // Set all the object fields. |
| 655 bool is_optimized = func.usage_counter() != 0; | |
| 656 RawObject** toobj = reader->snapshot_code() ? func.raw()->to() : | |
| 657 (is_optimized ? func.raw()->to_optimized_snapshot() : | |
| 658 func.raw()->to_snapshot()); | |
| 659 READ_OBJECT_FIELDS(func, | 655 READ_OBJECT_FIELDS(func, |
| 660 func.raw()->from(), toobj, | 656 func.raw()->from(), func.raw()->to_snapshot(), |
| 661 kAsReference); | 657 kAsReference); |
| 662 if (!reader->snapshot_code()) { | 658 // Initialize all fields that are not part of the snapshot. |
| 663 // Initialize all fields that are not part of the snapshot. | 659 if (reader->snapshot_code()) { |
| 664 if (!is_optimized) { | 660 func.ClearICDataArray(); |
| 661 func.ClearCode(); | |
| 662 // Read the code object. | |
|
rmacnak
2015/09/29 18:30:03
Read the code object and fixup entry_point_.
siva
2015/09/29 20:24:25
Done.
| |
| 663 (*reader->CodeHandle()) ^= reader->ReadObjectImpl(kAsInlinedObject); | |
| 664 func.SetInstructions(*reader->CodeHandle()); | |
| 665 } else { | |
| 666 bool is_optimized = func.usage_counter() != 0; | |
| 667 if (is_optimized) { | |
| 668 // Read the ic data array as the function is an optimized one. | |
| 669 (*reader->ArrayHandle()) ^= reader->ReadObjectImpl(kAsReference); | |
| 670 func.set_ic_data_array(*reader->ArrayHandle()); | |
| 671 } else { | |
| 665 func.ClearICDataArray(); | 672 func.ClearICDataArray(); |
| 666 } | 673 } |
| 667 func.ClearCode(); | 674 func.ClearCode(); |
| 668 } else { | |
| 669 // Fix entry point. | |
| 670 (*reader->CodeHandle()) = func.CurrentCode(); | |
| 671 uword new_entry = (*reader->CodeHandle()).EntryPoint(); | |
| 672 ASSERT(Dart::vm_isolate()->heap()->CodeContains(new_entry)); | |
| 673 func.StoreNonPointer(&func.raw_ptr()->entry_point_, new_entry); | |
| 674 } | 675 } |
| 675 return func.raw(); | 676 return func.raw(); |
| 676 } else { | 677 } else { |
| 677 return reader->ReadFunctionId(object_id); | 678 return reader->ReadFunctionId(object_id); |
| 678 } | 679 } |
| 679 } | 680 } |
| 680 | 681 |
| 681 | 682 |
| 682 void RawFunction::WriteTo(SnapshotWriter* writer, | 683 void RawFunction::WriteTo(SnapshotWriter* writer, |
| 683 intptr_t object_id, | 684 intptr_t object_id, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 720 writer->Write<int32_t>(0); | 721 writer->Write<int32_t>(0); |
| 721 } | 722 } |
| 722 writer->Write<int16_t>(ptr()->num_fixed_parameters_); | 723 writer->Write<int16_t>(ptr()->num_fixed_parameters_); |
| 723 writer->Write<int16_t>(ptr()->num_optional_parameters_); | 724 writer->Write<int16_t>(ptr()->num_optional_parameters_); |
| 724 writer->Write<int16_t>(ptr()->deoptimization_counter_); | 725 writer->Write<int16_t>(ptr()->deoptimization_counter_); |
| 725 writer->Write<uint32_t>(ptr()->kind_tag_); | 726 writer->Write<uint32_t>(ptr()->kind_tag_); |
| 726 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); | 727 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); |
| 727 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); | 728 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); |
| 728 | 729 |
| 729 // Write out all the object pointer fields. | 730 // Write out all the object pointer fields. |
| 730 RawObject** toobj = | |
| 731 writer->snapshot_code() ? to() : | |
| 732 (is_optimized ? to_optimized_snapshot() : to_snapshot()); | |
| 733 SnapshotWriterVisitor visitor(writer, kAsReference); | 731 SnapshotWriterVisitor visitor(writer, kAsReference); |
| 734 visitor.VisitPointers(from(), toobj); | 732 visitor.VisitPointers(from(), to_snapshot()); |
| 733 if (writer->snapshot_code()) { | |
| 734 ASSERT(ptr()->ic_data_array_ == Array::null()); | |
| 735 ASSERT((ptr()->code_ == ptr()->unoptimized_code_) || | |
| 736 (ptr()->unoptimized_code_ == Code::null())); | |
| 737 // Write out the code object as we are generating a precompiled snapshot. | |
| 738 writer->WriteObjectImpl(ptr()->code_, kAsInlinedObject); | |
| 739 } else if (is_optimized) { | |
| 740 // Write out the ic data array as the function is optimized or | |
| 741 // we are generating a precompiled snapshot. | |
| 742 writer->WriteObjectImpl(ptr()->ic_data_array_, kAsReference); | |
| 743 } | |
| 735 } else { | 744 } else { |
| 736 writer->WriteFunctionId(this, owner_is_class); | 745 writer->WriteFunctionId(this, owner_is_class); |
| 737 } | 746 } |
| 738 } | 747 } |
| 739 | 748 |
| 740 | 749 |
| 741 RawField* Field::ReadFrom(SnapshotReader* reader, | 750 RawField* Field::ReadFrom(SnapshotReader* reader, |
| 742 intptr_t object_id, | 751 intptr_t object_id, |
| 743 intptr_t tags, | 752 intptr_t tags, |
| 744 Snapshot::Kind kind) { | 753 Snapshot::Kind kind) { |
| (...skipping 2538 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3283 // We do not allow objects with native fields in an isolate message. | 3292 // We do not allow objects with native fields in an isolate message. |
| 3284 writer->SetWriteException(Exceptions::kArgument, | 3293 writer->SetWriteException(Exceptions::kArgument, |
| 3285 "Illegal argument in isolate message" | 3294 "Illegal argument in isolate message" |
| 3286 " : (object is a UserTag)"); | 3295 " : (object is a UserTag)"); |
| 3287 } else { | 3296 } else { |
| 3288 UNREACHABLE(); | 3297 UNREACHABLE(); |
| 3289 } | 3298 } |
| 3290 } | 3299 } |
| 3291 | 3300 |
| 3292 } // namespace dart | 3301 } // namespace dart |
| OLD | NEW |