| 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/dart_api_message.h" | 5 #include "vm/dart_api_message.h" |
| 6 #include "vm/object.h" | 6 #include "vm/object.h" |
| 7 #include "vm/snapshot_ids.h" | 7 #include "vm/snapshot_ids.h" |
| 8 #include "vm/symbols.h" | 8 #include "vm/symbols.h" |
| 9 #include "vm/unicode.h" | 9 #include "vm/unicode.h" |
| 10 | 10 |
| (...skipping 463 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 474 } | 474 } |
| 475 ASSERT(SerializedHeaderTag::decode(value) == kInlined); | 475 ASSERT(SerializedHeaderTag::decode(value) == kInlined); |
| 476 // Read the class header information and lookup the class. | 476 // Read the class header information and lookup the class. |
| 477 intptr_t class_header = Read<int32_t>(); | 477 intptr_t class_header = Read<int32_t>(); |
| 478 | 478 |
| 479 intptr_t object_id = SerializedHeaderData::decode(value); | 479 intptr_t object_id = SerializedHeaderData::decode(value); |
| 480 if (object_id == kOmittedObjectId) { | 480 if (object_id == kOmittedObjectId) { |
| 481 object_id = NextAvailableObjectId(); | 481 object_id = NextAvailableObjectId(); |
| 482 } | 482 } |
| 483 | 483 |
| 484 intptr_t tags = ReadTags(); |
| 485 USE(tags); |
| 486 |
| 484 // Reading of regular dart instances has limited support in order to | 487 // Reading of regular dart instances has limited support in order to |
| 485 // read typed data views. | 488 // read typed data views. |
| 486 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) { | 489 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) { |
| 487 Dart_CObject_Internal* object = | 490 Dart_CObject_Internal* object = |
| 488 AllocateDartCObjectInternal(Dart_CObject_Internal::kUninitialized); | 491 AllocateDartCObjectInternal(Dart_CObject_Internal::kUninitialized); |
| 489 AddBackRef(object_id, object, kIsNotDeserialized); | 492 AddBackRef(object_id, object, kIsNotDeserialized); |
| 490 // Read class of object. | 493 // Read class of object. |
| 491 object->cls = reinterpret_cast<Dart_CObject_Internal*>(ReadObjectImpl()); | 494 object->cls = reinterpret_cast<Dart_CObject_Internal*>(ReadObjectImpl()); |
| 492 ASSERT(object->cls->type == | 495 ASSERT(object->cls->type == |
| 493 static_cast<Dart_CObject_Type>(Dart_CObject_Internal::kClass)); | 496 static_cast<Dart_CObject_Type>(Dart_CObject_Internal::kClass)); |
| 494 return object; | 497 return object; |
| 495 } | 498 } |
| 496 ASSERT((class_header & kSmiTagMask) != 0); | 499 ASSERT((class_header & kSmiTagMask) != 0); |
| 497 intptr_t class_id = LookupInternalClass(class_header); | 500 intptr_t class_id = LookupInternalClass(class_header); |
| 498 if ((class_id == kArrayCid) || (class_id == kImmutableArrayCid)) { | 501 if ((class_id == kArrayCid) || (class_id == kImmutableArrayCid)) { |
| 499 ASSERT(GetBackRef(object_id) == NULL); | 502 ASSERT(GetBackRef(object_id) == NULL); |
| 500 intptr_t len = ReadSmiValue(); | 503 intptr_t len = ReadSmiValue(); |
| 501 Dart_CObject* value = AllocateDartCObjectArray(len); | 504 Dart_CObject* value = AllocateDartCObjectArray(len); |
| 502 AddBackRef(object_id, value, kIsNotDeserialized); | 505 AddBackRef(object_id, value, kIsNotDeserialized); |
| 503 return value; | 506 return value; |
| 504 } | 507 } |
| 505 | |
| 506 intptr_t tags = ReadTags(); | |
| 507 USE(tags); | |
| 508 | |
| 509 return ReadInternalVMObject(class_id, object_id); | 508 return ReadInternalVMObject(class_id, object_id); |
| 510 } | 509 } |
| 511 | 510 |
| 512 | 511 |
| 513 Dart_CObject* ApiMessageReader::ReadVMIsolateObject(intptr_t value) { | 512 Dart_CObject* ApiMessageReader::ReadVMIsolateObject(intptr_t value) { |
| 514 intptr_t object_id = GetVMIsolateObjectId(value); | 513 intptr_t object_id = GetVMIsolateObjectId(value); |
| 515 if (object_id == kNullObject) { | 514 if (object_id == kNullObject) { |
| 516 return AllocateDartCObjectNull(); | 515 return AllocateDartCObjectNull(); |
| 517 } | 516 } |
| 518 if (object_id == kTrueValue) { | 517 if (object_id == kTrueValue) { |
| (...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1053 if (type == Dart_CObject_kArray) { | 1052 if (type == Dart_CObject_kArray) { |
| 1054 const intptr_t array_length = object->value.as_array.length; | 1053 const intptr_t array_length = object->value.as_array.length; |
| 1055 if (array_length < 0 || | 1054 if (array_length < 0 || |
| 1056 array_length > Array::kMaxElements) { | 1055 array_length > Array::kMaxElements) { |
| 1057 return false; | 1056 return false; |
| 1058 } | 1057 } |
| 1059 // Write out the serialization header value for this object. | 1058 // Write out the serialization header value for this object. |
| 1060 WriteInlinedHeader(object); | 1059 WriteInlinedHeader(object); |
| 1061 // Write out the class information. | 1060 // Write out the class information. |
| 1062 WriteIndexedObject(kArrayCid); | 1061 WriteIndexedObject(kArrayCid); |
| 1062 WriteTags(0); |
| 1063 // Write out the length information. | 1063 // Write out the length information. |
| 1064 WriteSmi(array_length); | 1064 WriteSmi(array_length); |
| 1065 // Add object to forward list so that this object is serialized later. | 1065 // Add object to forward list so that this object is serialized later. |
| 1066 AddToForwardList(object); | 1066 AddToForwardList(object); |
| 1067 return true; | 1067 return true; |
| 1068 } | 1068 } |
| 1069 return WriteCObjectInlined(object, type); | 1069 return WriteCObjectInlined(object, type); |
| 1070 } | 1070 } |
| 1071 | 1071 |
| 1072 | 1072 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1290 if (!success) { | 1290 if (!success) { |
| 1291 UnmarkAllCObjects(object); | 1291 UnmarkAllCObjects(object); |
| 1292 return false; | 1292 return false; |
| 1293 } | 1293 } |
| 1294 } | 1294 } |
| 1295 UnmarkAllCObjects(object); | 1295 UnmarkAllCObjects(object); |
| 1296 return true; | 1296 return true; |
| 1297 } | 1297 } |
| 1298 | 1298 |
| 1299 } // namespace dart | 1299 } // namespace dart |
| OLD | NEW |