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/class_finalizer.h" | 10 #include "vm/class_finalizer.h" |
(...skipping 962 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
973 WriteInlinedObjectHeader(object_id); | 973 WriteInlinedObjectHeader(object_id); |
974 | 974 |
975 // Write out the class information. | 975 // Write out the class information. |
976 WriteIndexedObject(kImmutableArrayCid); | 976 WriteIndexedObject(kImmutableArrayCid); |
977 | 977 |
978 // Write out the length field. | 978 // Write out the length field. |
979 Write<RawObject*>(rawarray->ptr()->length_); | 979 Write<RawObject*>(rawarray->ptr()->length_); |
980 | 980 |
981 return; | 981 return; |
982 } | 982 } |
983 if (RawObject::IsTypedDataViewClassId(class_id)) { | |
984 WriteInstanceRef(raw, cls); | |
985 return; | |
986 } | |
983 // Object is being referenced, add it to the forward ref list and mark | 987 // Object is being referenced, add it to the forward ref list and mark |
984 // it so that future references to this object in the snapshot will use | 988 // it so that future references to this object in the snapshot will use |
985 // this object id. Mark it as not having been serialized yet so that we | 989 // this object id. Mark it as not having been serialized yet so that we |
986 // will serialize the object when we go through the forward list. | 990 // will serialize the object when we go through the forward list. |
987 intptr_t object_id = MarkObject(raw, kIsSerialized); | 991 intptr_t object_id = MarkObject(raw, kIsSerialized); |
988 switch (class_id) { | 992 switch (class_id) { |
989 #define SNAPSHOT_WRITE(clazz) \ | 993 #define SNAPSHOT_WRITE(clazz) \ |
990 case clazz::kClassId: { \ | 994 case clazz::kClassId: { \ |
991 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(raw); \ | 995 Raw##clazz* raw_obj = reinterpret_cast<Raw##clazz*>(raw); \ |
992 raw_obj->WriteTo(this, object_id, kind_); \ | 996 raw_obj->WriteTo(this, object_id, kind_); \ |
(...skipping 19 matching lines...) Expand all Loading... | |
1012 reinterpret_cast<RawExternalTypedData*>(raw); | 1016 reinterpret_cast<RawExternalTypedData*>(raw); |
1013 raw_obj->WriteTo(this, object_id, kind_); | 1017 raw_obj->WriteTo(this, object_id, kind_); |
1014 return; | 1018 return; |
1015 } | 1019 } |
1016 #undef SNAPSHOT_WRITE | 1020 #undef SNAPSHOT_WRITE |
1017 #define SNAPSHOT_WRITE(clazz) \ | 1021 #define SNAPSHOT_WRITE(clazz) \ |
1018 case kTypedData##clazz##ViewCid: \ | 1022 case kTypedData##clazz##ViewCid: \ |
1019 | 1023 |
1020 CLASS_LIST_TYPED_DATA(SNAPSHOT_WRITE) | 1024 CLASS_LIST_TYPED_DATA(SNAPSHOT_WRITE) |
1021 case kByteDataViewCid: { | 1025 case kByteDataViewCid: { |
1022 WriteInstanceRef(raw, cls); | 1026 // Handled above. |
1027 UNREACHABLE(); | |
1023 return; | 1028 return; |
1024 } | 1029 } |
1025 #undef SNAPSHOT_WRITE | 1030 #undef SNAPSHOT_WRITE |
siva
2013/04/09 21:15:12
Do we need this set of case statements for typedat
Søren Gjesse
2013/04/10 13:25:20
Yes, of cause. Done.
| |
1026 default: break; | 1031 default: break; |
1027 } | 1032 } |
1028 UNREACHABLE(); | 1033 UNREACHABLE(); |
1029 } | 1034 } |
1030 | 1035 |
1031 | 1036 |
1032 void FullSnapshotWriter::WriteFullSnapshot() { | 1037 void FullSnapshotWriter::WriteFullSnapshot() { |
1033 Isolate* isolate = Isolate::Current(); | 1038 Isolate* isolate = Isolate::Current(); |
1034 ASSERT(isolate != NULL); | 1039 ASSERT(isolate != NULL); |
1035 ObjectStore* object_store = isolate->object_store(); | 1040 ObjectStore* object_store = isolate->object_store(); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1081 | 1086 |
1082 | 1087 |
1083 intptr_t SnapshotWriter::MarkObject(RawObject* raw, SerializeState state) { | 1088 intptr_t SnapshotWriter::MarkObject(RawObject* raw, SerializeState state) { |
1084 NoGCScope no_gc; | 1089 NoGCScope no_gc; |
1085 intptr_t object_id = forward_list_.length() + kMaxPredefinedObjectIds; | 1090 intptr_t object_id = forward_list_.length() + kMaxPredefinedObjectIds; |
1086 ASSERT(object_id <= kMaxObjectId); | 1091 ASSERT(object_id <= kMaxObjectId); |
1087 uword value = 0; | 1092 uword value = 0; |
1088 value = SerializedHeaderTag::update(kObjectId, value); | 1093 value = SerializedHeaderTag::update(kObjectId, value); |
1089 value = SerializedHeaderData::update(object_id, value); | 1094 value = SerializedHeaderData::update(object_id, value); |
1090 uword tags = raw->ptr()->tags_; | 1095 uword tags = raw->ptr()->tags_; |
1096 ASSERT(SerializedHeaderTag::decode(tags) != kObjectId); | |
1091 raw->ptr()->tags_ = value; | 1097 raw->ptr()->tags_ = value; |
1092 ForwardObjectNode* node = new ForwardObjectNode(raw, tags, state); | 1098 ForwardObjectNode* node = new ForwardObjectNode(raw, tags, state); |
1093 ASSERT(node != NULL); | 1099 ASSERT(node != NULL); |
1094 forward_list_.Add(node); | 1100 forward_list_.Add(node); |
1095 return object_id; | 1101 return object_id; |
1096 } | 1102 } |
1097 | 1103 |
1098 | 1104 |
1099 void SnapshotWriter::UnmarkAll() { | 1105 void SnapshotWriter::UnmarkAll() { |
1100 NoGCScope no_gc; | 1106 NoGCScope no_gc; |
(...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1466 UnmarkAll(); | 1472 UnmarkAll(); |
1467 isolate->set_long_jump_base(base); | 1473 isolate->set_long_jump_base(base); |
1468 } else { | 1474 } else { |
1469 isolate->set_long_jump_base(base); | 1475 isolate->set_long_jump_base(base); |
1470 ThrowException(exception_type(), exception_msg()); | 1476 ThrowException(exception_type(), exception_msg()); |
1471 } | 1477 } |
1472 } | 1478 } |
1473 | 1479 |
1474 | 1480 |
1475 } // namespace dart | 1481 } // namespace dart |
OLD | NEW |