| 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/snapshot.h" | 5 #include "vm/snapshot.h" |
| 6 | 6 |
| 7 #include "platform/assert.h" | 7 #include "platform/assert.h" |
| 8 #include "vm/bigint_operations.h" | 8 #include "vm/bigint_operations.h" |
| 9 #include "vm/bootstrap.h" | 9 #include "vm/bootstrap.h" |
| 10 #include "vm/exceptions.h" | 10 #include "vm/exceptions.h" |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 if (object_id == kNullObject) { | 654 if (object_id == kNullObject) { |
| 655 // This is a singleton null object, return it. | 655 // This is a singleton null object, return it. |
| 656 return Object::null(); | 656 return Object::null(); |
| 657 } | 657 } |
| 658 if (object_id == kSentinelObject) { | 658 if (object_id == kSentinelObject) { |
| 659 return Object::sentinel().raw(); | 659 return Object::sentinel().raw(); |
| 660 } | 660 } |
| 661 if (object_id == kEmptyArrayObject) { | 661 if (object_id == kEmptyArrayObject) { |
| 662 return Object::empty_array().raw(); | 662 return Object::empty_array().raw(); |
| 663 } | 663 } |
| 664 if (object_id == kTrueValue) { |
| 665 return Bool::True().raw(); |
| 666 } |
| 667 if (object_id == kFalseValue) { |
| 668 return Bool::False().raw(); |
| 669 } |
| 664 intptr_t class_id = ClassIdFromObjectId(object_id); | 670 intptr_t class_id = ClassIdFromObjectId(object_id); |
| 665 if (IsSingletonClassId(class_id)) { | 671 if (IsSingletonClassId(class_id)) { |
| 666 return isolate()->class_table()->At(class_id); // get singleton class. | 672 return isolate()->class_table()->At(class_id); // get singleton class. |
| 667 } else { | 673 } else { |
| 668 ASSERT(Symbols::IsVMSymbolId(object_id)); | 674 ASSERT(Symbols::IsVMSymbolId(object_id)); |
| 669 return Symbols::GetVMSymbol(object_id); // return VM symbol. | 675 return Symbols::GetVMSymbol(object_id); // return VM symbol. |
| 670 } | 676 } |
| 671 UNREACHABLE(); | 677 UNREACHABLE(); |
| 672 return Object::null(); | 678 return Object::null(); |
| 673 } | 679 } |
| 674 | 680 |
| 675 | 681 |
| 676 RawObject* SnapshotReader::ReadIndexedObject(intptr_t object_id) { | 682 RawObject* SnapshotReader::ReadIndexedObject(intptr_t object_id) { |
| 677 if (object_id == kTrueValue) { | |
| 678 return object_store()->true_value(); | |
| 679 } | |
| 680 if (object_id == kFalseValue) { | |
| 681 return object_store()->false_value(); | |
| 682 } | |
| 683 intptr_t class_id = ClassIdFromObjectId(object_id); | 683 intptr_t class_id = ClassIdFromObjectId(object_id); |
| 684 if (IsObjectStoreClassId(class_id)) { | 684 if (IsObjectStoreClassId(class_id)) { |
| 685 return isolate()->class_table()->At(class_id); // get singleton class. | 685 return isolate()->class_table()->At(class_id); // get singleton class. |
| 686 } | 686 } |
| 687 if (kind_ != Snapshot::kFull) { | 687 if (kind_ != Snapshot::kFull) { |
| 688 if (IsObjectStoreTypeId(object_id)) { | 688 if (IsObjectStoreTypeId(object_id)) { |
| 689 return GetType(object_store(), object_id); // return type obj. | 689 return GetType(object_store(), object_id); // return type obj. |
| 690 } | 690 } |
| 691 } | 691 } |
| 692 Object* object = GetBackRef(object_id); | 692 Object* object = GetBackRef(object_id); |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 805 WriteVMIsolateObject(kSentinelObject); | 805 WriteVMIsolateObject(kSentinelObject); |
| 806 return; | 806 return; |
| 807 } | 807 } |
| 808 | 808 |
| 809 // Check if it is a singleton empty array object. | 809 // Check if it is a singleton empty array object. |
| 810 if (rawobj == Object::empty_array().raw()) { | 810 if (rawobj == Object::empty_array().raw()) { |
| 811 WriteVMIsolateObject(kEmptyArrayObject); | 811 WriteVMIsolateObject(kEmptyArrayObject); |
| 812 return; | 812 return; |
| 813 } | 813 } |
| 814 | 814 |
| 815 // Check if it is a singleton boolean true object. |
| 816 if (rawobj == Bool::True().raw()) { |
| 817 WriteVMIsolateObject(kTrueValue); |
| 818 return; |
| 819 } |
| 820 |
| 821 // Check if it is a singleton boolean false object. |
| 822 if (rawobj == Bool::False().raw()) { |
| 823 WriteVMIsolateObject(kFalseValue); |
| 824 return; |
| 825 } |
| 826 |
| 815 // Check if it is a singleton class object which is shared by | 827 // Check if it is a singleton class object which is shared by |
| 816 // all isolates. | 828 // all isolates. |
| 817 intptr_t id = rawobj->GetClassId(); | 829 intptr_t id = rawobj->GetClassId(); |
| 818 if (id == kClassCid) { | 830 if (id == kClassCid) { |
| 819 RawClass* raw_class = reinterpret_cast<RawClass*>(rawobj); | 831 RawClass* raw_class = reinterpret_cast<RawClass*>(rawobj); |
| 820 intptr_t class_id = raw_class->ptr()->id_; | 832 intptr_t class_id = raw_class->ptr()->id_; |
| 821 if (IsSingletonClassId(class_id)) { | 833 if (IsSingletonClassId(class_id)) { |
| 822 intptr_t object_id = ObjectIdFromClassId(class_id); | 834 intptr_t object_id = ObjectIdFromClassId(class_id); |
| 823 WriteVMIsolateObject(object_id); | 835 WriteVMIsolateObject(object_id); |
| 824 return; | 836 return; |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 } | 1044 } |
| 1033 | 1045 |
| 1034 // Now check if it is an object from the VM isolate (NOTE: premarked objects | 1046 // Now check if it is an object from the VM isolate (NOTE: premarked objects |
| 1035 // are considered to be objects in the VM isolate). These objects are shared | 1047 // are considered to be objects in the VM isolate). These objects are shared |
| 1036 // by all isolates. | 1048 // by all isolates. |
| 1037 if (rawobj->IsMarked()) { | 1049 if (rawobj->IsMarked()) { |
| 1038 HandleVMIsolateObject(rawobj); | 1050 HandleVMIsolateObject(rawobj); |
| 1039 return true; | 1051 return true; |
| 1040 } | 1052 } |
| 1041 | 1053 |
| 1042 // Check if it is a singleton boolean true value. | |
| 1043 if (rawobj == object_store()->true_value()) { | |
| 1044 WriteIndexedObject(kTrueValue); | |
| 1045 return true; | |
| 1046 } | |
| 1047 | |
| 1048 // Check if it is a singleton boolean false value. | |
| 1049 if (rawobj == object_store()->false_value()) { | |
| 1050 WriteIndexedObject(kFalseValue); | |
| 1051 return true; | |
| 1052 } | |
| 1053 | |
| 1054 // Check if the object is a Mint and could potentially be a Smi | 1054 // Check if the object is a Mint and could potentially be a Smi |
| 1055 // on other architectures (64 bit), if so write it out as int64_t value. | 1055 // on other architectures (64 bit), if so write it out as int64_t value. |
| 1056 if (rawobj->GetClassId() == kMintCid) { | 1056 if (rawobj->GetClassId() == kMintCid) { |
| 1057 int64_t value = reinterpret_cast<RawMint*>(rawobj)->ptr()->value_; | 1057 int64_t value = reinterpret_cast<RawMint*>(rawobj)->ptr()->value_; |
| 1058 const intptr_t kSmi64Bits = 62; | 1058 const intptr_t kSmi64Bits = 62; |
| 1059 const int64_t kSmi64Max = (static_cast<int64_t>(1) << kSmi64Bits) - 1; | 1059 const int64_t kSmi64Max = (static_cast<int64_t>(1) << kSmi64Bits) - 1; |
| 1060 const int64_t kSmi64Min = -(static_cast<int64_t>(1) << kSmi64Bits); | 1060 const int64_t kSmi64Min = -(static_cast<int64_t>(1) << kSmi64Bits); |
| 1061 if (value <= kSmi64Max && value >= kSmi64Min) { | 1061 if (value <= kSmi64Max && value >= kSmi64Min) { |
| 1062 Write<int64_t>((value << kSmiTagShift) | kSmiTag); | 1062 Write<int64_t>((value << kSmiTagShift) | kSmiTag); |
| 1063 return true; | 1063 return true; |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 UnmarkAll(); | 1315 UnmarkAll(); |
| 1316 isolate->set_long_jump_base(base); | 1316 isolate->set_long_jump_base(base); |
| 1317 } else { | 1317 } else { |
| 1318 isolate->set_long_jump_base(base); | 1318 isolate->set_long_jump_base(base); |
| 1319 ThrowException(exception_type(), exception_msg()); | 1319 ThrowException(exception_type(), exception_msg()); |
| 1320 } | 1320 } |
| 1321 } | 1321 } |
| 1322 | 1322 |
| 1323 | 1323 |
| 1324 } // namespace dart | 1324 } // namespace dart |
| OLD | NEW |