| 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 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 47 } | 47 } |
| 48 | 48 |
| 49 | 49 |
| 50 static bool IsSplitClassId(intptr_t class_id) { | 50 static bool IsSplitClassId(intptr_t class_id) { |
| 51 // Return whether this class is serialized in two steps: first a reference, | 51 // Return whether this class is serialized in two steps: first a reference, |
| 52 // with sufficient information to allocate a correctly sized object, and then | 52 // with sufficient information to allocate a correctly sized object, and then |
| 53 // later inline with complete contents. | 53 // later inline with complete contents. |
| 54 return class_id >= kNumPredefinedCids || | 54 return class_id >= kNumPredefinedCids || |
| 55 class_id == kArrayCid || | 55 class_id == kArrayCid || |
| 56 class_id == kImmutableArrayCid || | 56 class_id == kImmutableArrayCid || |
| 57 RawObject::IsTypedDataViewClassId(class_id); | 57 RawObject::IsImplicitFieldClassId(class_id); |
| 58 } | 58 } |
| 59 | 59 |
| 60 | 60 |
| 61 static intptr_t ClassIdFromObjectId(intptr_t object_id) { | 61 static intptr_t ClassIdFromObjectId(intptr_t object_id) { |
| 62 ASSERT(object_id > kClassIdsOffset); | 62 ASSERT(object_id > kClassIdsOffset); |
| 63 intptr_t class_id = (object_id - kClassIdsOffset); | 63 intptr_t class_id = (object_id - kClassIdsOffset); |
| 64 return class_id; | 64 return class_id; |
| 65 } | 65 } |
| 66 | 66 |
| 67 | 67 |
| 68 static intptr_t ObjectIdFromClassId(intptr_t class_id) { | 68 static intptr_t ObjectIdFromClassId(intptr_t class_id) { |
| 69 ASSERT((class_id > kIllegalCid) && (class_id < kNumPredefinedCids)); | 69 ASSERT((class_id > kIllegalCid) && (class_id < kNumPredefinedCids)); |
| 70 ASSERT(!RawObject::IsTypedDataViewClassId(class_id)); | 70 ASSERT(!(RawObject::IsImplicitFieldClassId(class_id))); |
| 71 return (class_id + kClassIdsOffset); | 71 return (class_id + kClassIdsOffset); |
| 72 } | 72 } |
| 73 | 73 |
| 74 | 74 |
| 75 static RawType* GetType(ObjectStore* object_store, intptr_t index) { | 75 static RawType* GetType(ObjectStore* object_store, intptr_t index) { |
| 76 switch (index) { | 76 switch (index) { |
| 77 case kObjectType: return object_store->object_type(); | 77 case kObjectType: return object_store->object_type(); |
| 78 case kNullType: return object_store->null_type(); | 78 case kNullType: return object_store->null_type(); |
| 79 case kFunctionType: return object_store->function_type(); | 79 case kFunctionType: return object_store->function_type(); |
| 80 case kNumberType: return object_store->number_type(); | 80 case kNumberType: return object_store->number_type(); |
| (...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1100 WriteInlinedObjectHeader(kOmittedObjectId); | 1100 WriteInlinedObjectHeader(kOmittedObjectId); |
| 1101 | 1101 |
| 1102 // Write out the class information. | 1102 // Write out the class information. |
| 1103 WriteIndexedObject(kImmutableArrayCid); | 1103 WriteIndexedObject(kImmutableArrayCid); |
| 1104 | 1104 |
| 1105 // Write out the length field. | 1105 // Write out the length field. |
| 1106 Write<RawObject*>(rawarray->ptr()->length_); | 1106 Write<RawObject*>(rawarray->ptr()->length_); |
| 1107 | 1107 |
| 1108 return; | 1108 return; |
| 1109 } | 1109 } |
| 1110 if (RawObject::IsTypedDataViewClassId(class_id)) { | 1110 if (RawObject::IsImplicitFieldClassId(class_id)) { |
| 1111 WriteInstanceRef(raw, cls); | 1111 WriteInstanceRef(raw, cls); |
| 1112 return; | 1112 return; |
| 1113 } | 1113 } |
| 1114 // Object is being referenced, add it to the forward ref list and mark | 1114 // Object is being referenced, add it to the forward ref list and mark |
| 1115 // it so that future references to this object in the snapshot will use | 1115 // it so that future references to this object in the snapshot will use |
| 1116 // this object id. Mark it as not having been serialized yet so that we | 1116 // this object id. Mark it as not having been serialized yet so that we |
| 1117 // will serialize the object when we go through the forward list. | 1117 // will serialize the object when we go through the forward list. |
| 1118 forward_list_.MarkAndAddObject(raw, kIsSerialized); | 1118 forward_list_.MarkAndAddObject(raw, kIsSerialized); |
| 1119 switch (class_id) { | 1119 switch (class_id) { |
| 1120 #define SNAPSHOT_WRITE(clazz) \ | 1120 #define SNAPSHOT_WRITE(clazz) \ |
| (...skipping 513 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 NoGCScope no_gc; | 1634 NoGCScope no_gc; |
| 1635 WriteObject(obj.raw()); | 1635 WriteObject(obj.raw()); |
| 1636 UnmarkAll(); | 1636 UnmarkAll(); |
| 1637 } else { | 1637 } else { |
| 1638 ThrowException(exception_type(), exception_msg()); | 1638 ThrowException(exception_type(), exception_msg()); |
| 1639 } | 1639 } |
| 1640 } | 1640 } |
| 1641 | 1641 |
| 1642 | 1642 |
| 1643 } // namespace dart | 1643 } // namespace dart |
| OLD | NEW |