| 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/bigint_operations.h" | 5 #include "vm/bigint_operations.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/symbols.h" | 10 #include "vm/symbols.h" |
| 10 #include "vm/visitor.h" | 11 #include "vm/visitor.h" |
| 11 | 12 |
| 12 namespace dart { | 13 namespace dart { |
| 13 | 14 |
| 14 #define NEW_OBJECT(type) \ | 15 #define NEW_OBJECT(type) \ |
| 15 ((kind == Snapshot::kFull) ? reader->New##type() : type::New()) | 16 ((kind == Snapshot::kFull) ? reader->New##type() : type::New()) |
| 16 | 17 |
| 17 #define NEW_OBJECT_WITH_LEN(type, len) \ | 18 #define NEW_OBJECT_WITH_LEN(type, len) \ |
| 18 ((kind == Snapshot::kFull) ? reader->New##type(len) : type::New(len)) | 19 ((kind == Snapshot::kFull) ? reader->New##type(len) : type::New(len)) |
| (...skipping 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 702 func.set_optimized_call_site_count(reader->Read<uint16_t>()); | 703 func.set_optimized_call_site_count(reader->Read<uint16_t>()); |
| 703 | 704 |
| 704 // Set all the object fields. | 705 // Set all the object fields. |
| 705 // TODO(5411462): Need to assert No GC can happen here, even though | 706 // TODO(5411462): Need to assert No GC can happen here, even though |
| 706 // allocations may happen. | 707 // allocations may happen. |
| 707 intptr_t num_flds = (func.raw()->to() - func.raw()->from()); | 708 intptr_t num_flds = (func.raw()->to() - func.raw()->from()); |
| 708 for (intptr_t i = 0; i <= num_flds; i++) { | 709 for (intptr_t i = 0; i <= num_flds; i++) { |
| 709 *(func.raw()->from() + i) = reader->ReadObjectRef(); | 710 *(func.raw()->from() + i) = reader->ReadObjectRef(); |
| 710 } | 711 } |
| 711 | 712 |
| 713 // Set up code pointer with the lazy-compile-stub. |
| 714 func.set_code(Code::Handle(StubCode::LazyCompile_entry()->code())); |
| 715 |
| 712 return func.raw(); | 716 return func.raw(); |
| 713 } | 717 } |
| 714 | 718 |
| 715 | 719 |
| 716 void RawFunction::WriteTo(SnapshotWriter* writer, | 720 void RawFunction::WriteTo(SnapshotWriter* writer, |
| 717 intptr_t object_id, | 721 intptr_t object_id, |
| 718 Snapshot::Kind kind) { | 722 Snapshot::Kind kind) { |
| 719 ASSERT(writer != NULL); | 723 ASSERT(writer != NULL); |
| 720 ASSERT(((kind == Snapshot::kScript) && | 724 ASSERT(((kind == Snapshot::kScript) && |
| 721 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || | 725 !RawObject::IsCreatedFromSnapshot(writer->GetObjectTags(this))) || |
| (...skipping 12 matching lines...) Expand all Loading... |
| 734 writer->WriteIntptrValue(ptr()->usage_counter_); | 738 writer->WriteIntptrValue(ptr()->usage_counter_); |
| 735 writer->WriteIntptrValue(ptr()->num_fixed_parameters_); | 739 writer->WriteIntptrValue(ptr()->num_fixed_parameters_); |
| 736 writer->WriteIntptrValue(ptr()->num_optional_parameters_); | 740 writer->WriteIntptrValue(ptr()->num_optional_parameters_); |
| 737 writer->WriteIntptrValue(ptr()->deoptimization_counter_); | 741 writer->WriteIntptrValue(ptr()->deoptimization_counter_); |
| 738 writer->Write<uint16_t>(ptr()->kind_tag_); | 742 writer->Write<uint16_t>(ptr()->kind_tag_); |
| 739 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); | 743 writer->Write<uint16_t>(ptr()->optimized_instruction_count_); |
| 740 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); | 744 writer->Write<uint16_t>(ptr()->optimized_call_site_count_); |
| 741 | 745 |
| 742 // Write out all the object pointer fields. | 746 // Write out all the object pointer fields. |
| 743 SnapshotWriterVisitor visitor(writer); | 747 SnapshotWriterVisitor visitor(writer); |
| 744 visitor.VisitPointers(from(), to()); | 748 visitor.VisitPointers(from(), to_no_code()); |
| 749 |
| 750 // Write null for the code and unoptimized code. |
| 751 writer->WriteVMIsolateObject(kNullObject); |
| 752 writer->WriteVMIsolateObject(kNullObject); |
| 745 } | 753 } |
| 746 | 754 |
| 747 | 755 |
| 748 RawField* Field::ReadFrom(SnapshotReader* reader, | 756 RawField* Field::ReadFrom(SnapshotReader* reader, |
| 749 intptr_t object_id, | 757 intptr_t object_id, |
| 750 intptr_t tags, | 758 intptr_t tags, |
| 751 Snapshot::Kind kind) { | 759 Snapshot::Kind kind) { |
| 752 ASSERT(reader != NULL); | 760 ASSERT(reader != NULL); |
| 753 ASSERT(((kind == Snapshot::kScript) && | 761 ASSERT(((kind == Snapshot::kScript) && |
| 754 !RawObject::IsCreatedFromSnapshot(tags)) || | 762 !RawObject::IsCreatedFromSnapshot(tags)) || |
| (...skipping 1924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2679 // We do not allow objects with native fields in an isolate message. | 2687 // We do not allow objects with native fields in an isolate message. |
| 2680 writer->SetWriteException(Exceptions::kArgument, | 2688 writer->SetWriteException(Exceptions::kArgument, |
| 2681 "Illegal argument in isolate message" | 2689 "Illegal argument in isolate message" |
| 2682 " : (object is a MirrorReference)"); | 2690 " : (object is a MirrorReference)"); |
| 2683 } else { | 2691 } else { |
| 2684 UNREACHABLE(); | 2692 UNREACHABLE(); |
| 2685 } | 2693 } |
| 2686 } | 2694 } |
| 2687 | 2695 |
| 2688 } // namespace dart | 2696 } // namespace dart |
| OLD | NEW |