| 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/dart_api_message.h" | 6 #include "vm/dart_api_message.h" |
| 7 #include "vm/object.h" | 7 #include "vm/object.h" |
| 8 #include "vm/snapshot_ids.h" | 8 #include "vm/snapshot_ids.h" |
| 9 #include "vm/symbols.h" | 9 #include "vm/symbols.h" |
| 10 #include "vm/unicode.h" | 10 #include "vm/unicode.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 return view_class_names[i].type; | 250 return view_class_names[i].type; |
| 251 } | 251 } |
| 252 i++; | 252 i++; |
| 253 } | 253 } |
| 254 return Dart_TypedData_kInvalid; | 254 return Dart_TypedData_kInvalid; |
| 255 } | 255 } |
| 256 | 256 |
| 257 | 257 |
| 258 Dart_CObject* ApiMessageReader::ReadInlinedObject(intptr_t object_id) { | 258 Dart_CObject* ApiMessageReader::ReadInlinedObject(intptr_t object_id) { |
| 259 // Read the class header information and lookup the class. | 259 // Read the class header information and lookup the class. |
| 260 intptr_t class_header = ReadIntptrValue(); | 260 intptr_t class_header = Read<int32_t>(); |
| 261 intptr_t tags = ReadIntptrValue(); | 261 intptr_t tags = Read<int32_t>(); |
| 262 USE(tags); | 262 USE(tags); |
| 263 intptr_t class_id; | 263 intptr_t class_id; |
| 264 | 264 |
| 265 // There is limited support for reading regular dart instances. Only | 265 // There is limited support for reading regular dart instances. Only |
| 266 // typed data views are currently handled. | 266 // typed data views are currently handled. |
| 267 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) { | 267 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) { |
| 268 Dart_CObject_Internal* object = | 268 Dart_CObject_Internal* object = |
| 269 reinterpret_cast<Dart_CObject_Internal*>(GetBackRef(object_id)); | 269 reinterpret_cast<Dart_CObject_Internal*>(GetBackRef(object_id)); |
| 270 if (object == NULL) { | 270 if (object == NULL) { |
| 271 object = | 271 object = |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 ASSERT((value64 <= kIntptrMax) && (value64 >= kIntptrMin)); | 393 ASSERT((value64 <= kIntptrMax) && (value64 >= kIntptrMin)); |
| 394 intptr_t value = static_cast<intptr_t>(value64); | 394 intptr_t value = static_cast<intptr_t>(value64); |
| 395 if (IsVMIsolateObject(value)) { | 395 if (IsVMIsolateObject(value)) { |
| 396 return ReadVMIsolateObject(value); | 396 return ReadVMIsolateObject(value); |
| 397 } | 397 } |
| 398 if (SerializedHeaderTag::decode(value) == kObjectId) { | 398 if (SerializedHeaderTag::decode(value) == kObjectId) { |
| 399 return ReadIndexedObject(SerializedHeaderData::decode(value)); | 399 return ReadIndexedObject(SerializedHeaderData::decode(value)); |
| 400 } | 400 } |
| 401 ASSERT(SerializedHeaderTag::decode(value) == kInlined); | 401 ASSERT(SerializedHeaderTag::decode(value) == kInlined); |
| 402 // Read the class header information and lookup the class. | 402 // Read the class header information and lookup the class. |
| 403 intptr_t class_header = ReadIntptrValue(); | 403 intptr_t class_header = Read<int32_t>(); |
| 404 | 404 |
| 405 // Reading of regular dart instances has limited support in order to | 405 // Reading of regular dart instances has limited support in order to |
| 406 // read typed data views. | 406 // read typed data views. |
| 407 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) { | 407 if (SerializedHeaderData::decode(class_header) == kInstanceObjectId) { |
| 408 intptr_t object_id = SerializedHeaderData::decode(value); | 408 intptr_t object_id = SerializedHeaderData::decode(value); |
| 409 Dart_CObject_Internal* object = | 409 Dart_CObject_Internal* object = |
| 410 AllocateDartCObjectInternal(Dart_CObject_Internal::kUninitialized); | 410 AllocateDartCObjectInternal(Dart_CObject_Internal::kUninitialized); |
| 411 AddBackRef(object_id, object, kIsNotDeserialized); | 411 AddBackRef(object_id, object, kIsNotDeserialized); |
| 412 // Read class of object. | 412 // Read class of object. |
| 413 object->cls = reinterpret_cast<Dart_CObject_Internal*>(ReadObjectImpl()); | 413 object->cls = reinterpret_cast<Dart_CObject_Internal*>(ReadObjectImpl()); |
| 414 ASSERT(object->cls->type == | 414 ASSERT(object->cls->type == |
| 415 static_cast<Dart_CObject_Type>(Dart_CObject_Internal::kClass)); | 415 static_cast<Dart_CObject_Type>(Dart_CObject_Internal::kClass)); |
| 416 return object; | 416 return object; |
| 417 } | 417 } |
| 418 ASSERT((class_header & kSmiTagMask) != 0); | 418 ASSERT((class_header & kSmiTagMask) != 0); |
| 419 intptr_t object_id = SerializedHeaderData::decode(value); | 419 intptr_t object_id = SerializedHeaderData::decode(value); |
| 420 intptr_t class_id = LookupInternalClass(class_header); | 420 intptr_t class_id = LookupInternalClass(class_header); |
| 421 if ((class_id == kArrayCid) || (class_id == kImmutableArrayCid)) { | 421 if ((class_id == kArrayCid) || (class_id == kImmutableArrayCid)) { |
| 422 ASSERT(GetBackRef(object_id) == NULL); | 422 ASSERT(GetBackRef(object_id) == NULL); |
| 423 intptr_t len = ReadSmiValue(); | 423 intptr_t len = ReadSmiValue(); |
| 424 Dart_CObject* value = AllocateDartCObjectArray(len); | 424 Dart_CObject* value = AllocateDartCObjectArray(len); |
| 425 AddBackRef(object_id, value, kIsNotDeserialized); | 425 AddBackRef(object_id, value, kIsNotDeserialized); |
| 426 return value; | 426 return value; |
| 427 } | 427 } |
| 428 | 428 |
| 429 intptr_t tags = ReadIntptrValue(); | 429 intptr_t tags = Read<int32_t>(); |
| 430 USE(tags); | 430 USE(tags); |
| 431 | 431 |
| 432 return ReadInternalVMObject(class_id, object_id); | 432 return ReadInternalVMObject(class_id, object_id); |
| 433 } | 433 } |
| 434 | 434 |
| 435 | 435 |
| 436 Dart_CObject* ApiMessageReader::ReadVMIsolateObject(intptr_t value) { | 436 Dart_CObject* ApiMessageReader::ReadVMIsolateObject(intptr_t value) { |
| 437 intptr_t object_id = GetVMIsolateObjectId(value); | 437 intptr_t object_id = GetVMIsolateObjectId(value); |
| 438 if (object_id == kNullObject) { | 438 if (object_id == kNullObject) { |
| 439 return AllocateDartCObjectNull(); | 439 return AllocateDartCObjectNull(); |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 482 if (type != &dynamic_type_marker) { | 482 if (type != &dynamic_type_marker) { |
| 483 return AllocateDartCObjectUnsupported(); | 483 return AllocateDartCObjectUnsupported(); |
| 484 } | 484 } |
| 485 } | 485 } |
| 486 return value; | 486 return value; |
| 487 } | 487 } |
| 488 case kTypeParameterCid: { | 488 case kTypeParameterCid: { |
| 489 // TODO(sgjesse): Fix this workaround ignoring the type parameter. | 489 // TODO(sgjesse): Fix this workaround ignoring the type parameter. |
| 490 Dart_CObject* value = &dynamic_type_marker; | 490 Dart_CObject* value = &dynamic_type_marker; |
| 491 AddBackRef(object_id, value, kIsDeserialized); | 491 AddBackRef(object_id, value, kIsDeserialized); |
| 492 intptr_t index = ReadIntptrValue(); | 492 intptr_t index = Read<int32_t>(); |
| 493 USE(index); | 493 USE(index); |
| 494 intptr_t token_index = ReadIntptrValue(); | 494 intptr_t token_index = Read<int32_t>(); |
| 495 USE(token_index); | 495 USE(token_index); |
| 496 int8_t type_state = Read<int8_t>(); | 496 int8_t type_state = Read<int8_t>(); |
| 497 USE(type_state); | 497 USE(type_state); |
| 498 Dart_CObject* parameterized_class = ReadObjectImpl(); | 498 Dart_CObject* parameterized_class = ReadObjectImpl(); |
| 499 // The type parameter is finalized, therefore parameterized_class is null. | 499 // The type parameter is finalized, therefore parameterized_class is null. |
| 500 ASSERT(parameterized_class->type == Dart_CObject_kNull); | 500 ASSERT(parameterized_class->type == Dart_CObject_kNull); |
| 501 Dart_CObject* name = ReadObjectImpl(); | 501 Dart_CObject* name = ReadObjectImpl(); |
| 502 ASSERT(name->type == Dart_CObject_kString); | 502 ASSERT(name->type == Dart_CObject_kString); |
| 503 return value; | 503 return value; |
| 504 } | 504 } |
| 505 case kMintCid: { | 505 case kMintCid: { |
| 506 int64_t value64 = Read<int64_t>(); | 506 int64_t value64 = Read<int64_t>(); |
| 507 Dart_CObject* object; | 507 Dart_CObject* object; |
| 508 if ((kMinInt32 <= value64) && (value64 <= kMaxInt32)) { | 508 if ((kMinInt32 <= value64) && (value64 <= kMaxInt32)) { |
| 509 object = AllocateDartCObjectInt32(static_cast<int32_t>(value64)); | 509 object = AllocateDartCObjectInt32(static_cast<int32_t>(value64)); |
| 510 } else { | 510 } else { |
| 511 object = AllocateDartCObjectInt64(value64); | 511 object = AllocateDartCObjectInt64(value64); |
| 512 } | 512 } |
| 513 AddBackRef(object_id, object, kIsDeserialized); | 513 AddBackRef(object_id, object, kIsDeserialized); |
| 514 return object; | 514 return object; |
| 515 } | 515 } |
| 516 case kBigintCid: { | 516 case kBigintCid: { |
| 517 // Read in the hex string representation of the bigint. | 517 // Read in the hex string representation of the bigint. |
| 518 intptr_t len = ReadIntptrValue(); | 518 intptr_t len = Read<int32_t>(); |
| 519 Dart_CObject* object = AllocateDartCObjectBigint(len); | 519 Dart_CObject* object = AllocateDartCObjectBigint(len); |
| 520 AddBackRef(object_id, object, kIsDeserialized); | 520 AddBackRef(object_id, object, kIsDeserialized); |
| 521 char* p = object->value.as_bigint; | 521 char* p = object->value.as_bigint; |
| 522 for (intptr_t i = 0; i < len; i++) { | 522 for (intptr_t i = 0; i < len; i++) { |
| 523 p[i] = Read<uint8_t>(); | 523 p[i] = Read<uint8_t>(); |
| 524 } | 524 } |
| 525 p[len] = '\0'; | 525 p[len] = '\0'; |
| 526 return object; | 526 return object; |
| 527 } | 527 } |
| 528 case kDoubleCid: { | 528 case kDoubleCid: { |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 775 return NULL; | 775 return NULL; |
| 776 } | 776 } |
| 777 | 777 |
| 778 | 778 |
| 779 void ApiMessageWriter::WriteMessage(intptr_t field_count, intptr_t *data) { | 779 void ApiMessageWriter::WriteMessage(intptr_t field_count, intptr_t *data) { |
| 780 // Write out the serialization header value for this object. | 780 // Write out the serialization header value for this object. |
| 781 WriteInlinedObjectHeader(kMaxPredefinedObjectIds); | 781 WriteInlinedObjectHeader(kMaxPredefinedObjectIds); |
| 782 | 782 |
| 783 // Write out the class and tags information. | 783 // Write out the class and tags information. |
| 784 WriteIndexedObject(kArrayCid); | 784 WriteIndexedObject(kArrayCid); |
| 785 WriteIntptrValue(0); | 785 Write<int32_t>(0); |
| 786 | 786 |
| 787 // Write out the length field. | 787 // Write out the length field. |
| 788 Write<RawObject*>(Smi::New(field_count)); | 788 Write<RawObject*>(Smi::New(field_count)); |
| 789 | 789 |
| 790 // Write out the type arguments. | 790 // Write out the type arguments. |
| 791 WriteNullObject(); | 791 WriteNullObject(); |
| 792 | 792 |
| 793 // Write out the individual Smis. | 793 // Write out the individual Smis. |
| 794 for (int i = 0; i < field_count; i++) { | 794 for (int i = 0; i < field_count; i++) { |
| 795 Write<RawObject*>(Integer::New(data[i])); | 795 Write<RawObject*>(Integer::New(data[i])); |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 871 WriteVMIsolateObject(kNullObject); | 871 WriteVMIsolateObject(kNullObject); |
| 872 } | 872 } |
| 873 | 873 |
| 874 | 874 |
| 875 void ApiMessageWriter::WriteMint(Dart_CObject* object, int64_t value) { | 875 void ApiMessageWriter::WriteMint(Dart_CObject* object, int64_t value) { |
| 876 ASSERT(!Smi::IsValid64(value)); | 876 ASSERT(!Smi::IsValid64(value)); |
| 877 // Write out the serialization header value for mint object. | 877 // Write out the serialization header value for mint object. |
| 878 WriteInlinedHeader(object); | 878 WriteInlinedHeader(object); |
| 879 // Write out the class and tags information. | 879 // Write out the class and tags information. |
| 880 WriteIndexedObject(kMintCid); | 880 WriteIndexedObject(kMintCid); |
| 881 WriteIntptrValue(0); | 881 Write<int32_t>(0); |
| 882 // Write the 64-bit value. | 882 // Write the 64-bit value. |
| 883 Write<int64_t>(value); | 883 Write<int64_t>(value); |
| 884 } | 884 } |
| 885 | 885 |
| 886 | 886 |
| 887 void ApiMessageWriter::WriteInt32(Dart_CObject* object) { | 887 void ApiMessageWriter::WriteInt32(Dart_CObject* object) { |
| 888 int64_t value = object->value.as_int32; | 888 int64_t value = object->value.as_int32; |
| 889 if (Smi::IsValid64(value)) { | 889 if (Smi::IsValid64(value)) { |
| 890 WriteSmi(value); | 890 WriteSmi(value); |
| 891 } else { | 891 } else { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 926 const intptr_t array_length = object->value.as_array.length; | 926 const intptr_t array_length = object->value.as_array.length; |
| 927 if (array_length < 0 || | 927 if (array_length < 0 || |
| 928 array_length > Array::kMaxElements) { | 928 array_length > Array::kMaxElements) { |
| 929 return false; | 929 return false; |
| 930 } | 930 } |
| 931 | 931 |
| 932 // Write out the serialization header value for this object. | 932 // Write out the serialization header value for this object. |
| 933 WriteInlinedHeader(object); | 933 WriteInlinedHeader(object); |
| 934 // Write out the class and tags information. | 934 // Write out the class and tags information. |
| 935 WriteIndexedObject(kArrayCid); | 935 WriteIndexedObject(kArrayCid); |
| 936 WriteIntptrValue(0); | 936 Write<int32_t>(0); |
| 937 // Write out the length information. | 937 // Write out the length information. |
| 938 WriteSmi(array_length); | 938 WriteSmi(array_length); |
| 939 // Write out the type arguments. | 939 // Write out the type arguments. |
| 940 WriteNullObject(); | 940 WriteNullObject(); |
| 941 // Write out array elements. | 941 // Write out array elements. |
| 942 for (int i = 0; i < array_length; i++) { | 942 for (int i = 0; i < array_length; i++) { |
| 943 bool success = WriteCObjectRef(object->value.as_array.values[i]); | 943 bool success = WriteCObjectRef(object->value.as_array.values[i]); |
| 944 if (!success) return false; | 944 if (!success) return false; |
| 945 } | 945 } |
| 946 return true; | 946 return true; |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 986 if (array_length < 0 || | 986 if (array_length < 0 || |
| 987 array_length > Array::kMaxElements) { | 987 array_length > Array::kMaxElements) { |
| 988 return false; | 988 return false; |
| 989 } | 989 } |
| 990 | 990 |
| 991 // Write out the serialization header value for this object. | 991 // Write out the serialization header value for this object. |
| 992 intptr_t object_id = GetMarkedCObjectMark(object); | 992 intptr_t object_id = GetMarkedCObjectMark(object); |
| 993 WriteInlinedObjectHeader(kMaxPredefinedObjectIds + object_id); | 993 WriteInlinedObjectHeader(kMaxPredefinedObjectIds + object_id); |
| 994 // Write out the class and tags information. | 994 // Write out the class and tags information. |
| 995 WriteIndexedObject(kArrayCid); | 995 WriteIndexedObject(kArrayCid); |
| 996 WriteIntptrValue(0); | 996 Write<int32_t>(0); |
| 997 // Write out the length information. | 997 // Write out the length information. |
| 998 WriteSmi(array_length); | 998 WriteSmi(array_length); |
| 999 // Write out the type arguments. | 999 // Write out the type arguments. |
| 1000 WriteNullObject(); | 1000 WriteNullObject(); |
| 1001 // Write out array elements. | 1001 // Write out array elements. |
| 1002 for (int i = 0; i < array_length; i++) { | 1002 for (int i = 0; i < array_length; i++) { |
| 1003 bool success = WriteCObjectRef(object->value.as_array.values[i]); | 1003 bool success = WriteCObjectRef(object->value.as_array.values[i]); |
| 1004 if (!success) return false; | 1004 if (!success) return false; |
| 1005 } | 1005 } |
| 1006 return true; | 1006 return true; |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1031 const intptr_t chunk_len = | 1031 const intptr_t chunk_len = |
| 1032 BigintOperations::ComputeChunkLength(hex_string); | 1032 BigintOperations::ComputeChunkLength(hex_string); |
| 1033 if (chunk_len < 0 || | 1033 if (chunk_len < 0 || |
| 1034 chunk_len > Bigint::kMaxElements) { | 1034 chunk_len > Bigint::kMaxElements) { |
| 1035 return false; | 1035 return false; |
| 1036 } | 1036 } |
| 1037 // Write out the serialization header value for this object. | 1037 // Write out the serialization header value for this object. |
| 1038 WriteInlinedHeader(object); | 1038 WriteInlinedHeader(object); |
| 1039 // Write out the class and tags information. | 1039 // Write out the class and tags information. |
| 1040 WriteIndexedObject(kBigintCid); | 1040 WriteIndexedObject(kBigintCid); |
| 1041 WriteIntptrValue(0); | 1041 Write<int32_t>(0); |
| 1042 // Write hex string length and content | 1042 // Write hex string length and content |
| 1043 intptr_t len = strlen(hex_string); | 1043 intptr_t len = strlen(hex_string); |
| 1044 WriteIntptrValue(len); | 1044 Write<int32_t>(len); |
| 1045 for (intptr_t i = 0; i < len; i++) { | 1045 for (intptr_t i = 0; i < len; i++) { |
| 1046 Write<uint8_t>(hex_string[i]); | 1046 Write<uint8_t>(hex_string[i]); |
| 1047 } | 1047 } |
| 1048 break; | 1048 break; |
| 1049 } | 1049 } |
| 1050 case Dart_CObject_kDouble: | 1050 case Dart_CObject_kDouble: |
| 1051 WriteVMIsolateObject(kDoubleObject); | 1051 WriteVMIsolateObject(kDoubleObject); |
| 1052 WriteDouble(object->value.as_double); | 1052 WriteDouble(object->value.as_double); |
| 1053 break; | 1053 break; |
| 1054 case Dart_CObject_kString: { | 1054 case Dart_CObject_kString: { |
| 1055 const uint8_t* utf8_str = | 1055 const uint8_t* utf8_str = |
| 1056 reinterpret_cast<const uint8_t*>(object->value.as_string); | 1056 reinterpret_cast<const uint8_t*>(object->value.as_string); |
| 1057 intptr_t utf8_len = strlen(object->value.as_string); | 1057 intptr_t utf8_len = strlen(object->value.as_string); |
| 1058 if (!Utf8::IsValid(utf8_str, utf8_len)) { | 1058 if (!Utf8::IsValid(utf8_str, utf8_len)) { |
| 1059 return false; | 1059 return false; |
| 1060 } | 1060 } |
| 1061 | 1061 |
| 1062 Utf8::Type type; | 1062 Utf8::Type type; |
| 1063 intptr_t len = Utf8::CodeUnitCount(utf8_str, utf8_len, &type); | 1063 intptr_t len = Utf8::CodeUnitCount(utf8_str, utf8_len, &type); |
| 1064 ASSERT(len > 0); | 1064 ASSERT(len > 0); |
| 1065 if (len > String::kMaxElements) { | 1065 if (len > String::kMaxElements) { |
| 1066 return false; | 1066 return false; |
| 1067 } | 1067 } |
| 1068 | 1068 |
| 1069 // Write out the serialization header value for this object. | 1069 // Write out the serialization header value for this object. |
| 1070 WriteInlinedHeader(object); | 1070 WriteInlinedHeader(object); |
| 1071 // Write out the class and tags information. | 1071 // Write out the class and tags information. |
| 1072 WriteIndexedObject(type == Utf8::kLatin1 ? kOneByteStringCid | 1072 WriteIndexedObject(type == Utf8::kLatin1 ? kOneByteStringCid |
| 1073 : kTwoByteStringCid); | 1073 : kTwoByteStringCid); |
| 1074 WriteIntptrValue(0); | 1074 Write<int32_t>(0); |
| 1075 // Write string length, hash and content | 1075 // Write string length, hash and content |
| 1076 WriteSmi(len); | 1076 WriteSmi(len); |
| 1077 WriteSmi(0); // TODO(sgjesse): Hash - not written. | 1077 WriteSmi(0); // TODO(sgjesse): Hash - not written. |
| 1078 if (type == Utf8::kLatin1) { | 1078 if (type == Utf8::kLatin1) { |
| 1079 uint8_t* latin1_str = | 1079 uint8_t* latin1_str = |
| 1080 reinterpret_cast<uint8_t*>(::malloc(len * sizeof(uint8_t))); | 1080 reinterpret_cast<uint8_t*>(::malloc(len * sizeof(uint8_t))); |
| 1081 bool success = Utf8::DecodeToLatin1(utf8_str, | 1081 bool success = Utf8::DecodeToLatin1(utf8_str, |
| 1082 utf8_len, | 1082 utf8_len, |
| 1083 latin1_str, | 1083 latin1_str, |
| 1084 len); | 1084 len); |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1116 UNIMPLEMENTED(); | 1116 UNIMPLEMENTED(); |
| 1117 } | 1117 } |
| 1118 | 1118 |
| 1119 intptr_t len = object->value.as_typed_data.length; | 1119 intptr_t len = object->value.as_typed_data.length; |
| 1120 if (len < 0 || | 1120 if (len < 0 || |
| 1121 len > TypedData::MaxElements(class_id)) { | 1121 len > TypedData::MaxElements(class_id)) { |
| 1122 return false; | 1122 return false; |
| 1123 } | 1123 } |
| 1124 | 1124 |
| 1125 WriteIndexedObject(class_id); | 1125 WriteIndexedObject(class_id); |
| 1126 WriteIntptrValue(RawObject::ClassIdTag::update(class_id, 0)); | 1126 Write<int32_t>(RawObject::ClassIdTag::update(class_id, 0)); |
| 1127 WriteSmi(len); | 1127 WriteSmi(len); |
| 1128 uint8_t* bytes = object->value.as_typed_data.values; | 1128 uint8_t* bytes = object->value.as_typed_data.values; |
| 1129 for (intptr_t i = 0; i < len; i++) { | 1129 for (intptr_t i = 0; i < len; i++) { |
| 1130 Write<uint8_t>(bytes[i]); | 1130 Write<uint8_t>(bytes[i]); |
| 1131 } | 1131 } |
| 1132 break; | 1132 break; |
| 1133 } | 1133 } |
| 1134 case Dart_CObject_kExternalTypedData: { | 1134 case Dart_CObject_kExternalTypedData: { |
| 1135 // TODO(ager): we are writing C pointers into the message in | 1135 // TODO(ager): we are writing C pointers into the message in |
| 1136 // order to post external arrays through ports. We need to make | 1136 // order to post external arrays through ports. We need to make |
| 1137 // sure that messages containing pointers can never be posted | 1137 // sure that messages containing pointers can never be posted |
| 1138 // to other processes. | 1138 // to other processes. |
| 1139 | 1139 |
| 1140 // Write out serialization header value for this object. | 1140 // Write out serialization header value for this object. |
| 1141 WriteInlinedHeader(object); | 1141 WriteInlinedHeader(object); |
| 1142 // Write out the class and tag information. | 1142 // Write out the class and tag information. |
| 1143 WriteIndexedObject(kExternalTypedDataUint8ArrayCid); | 1143 WriteIndexedObject(kExternalTypedDataUint8ArrayCid); |
| 1144 WriteIntptrValue(RawObject::ClassIdTag::update( | 1144 Write<int32_t>(RawObject::ClassIdTag::update( |
| 1145 kExternalTypedDataUint8ArrayCid, 0)); | 1145 kExternalTypedDataUint8ArrayCid, 0)); |
| 1146 intptr_t length = object->value.as_external_typed_data.length; | 1146 intptr_t length = object->value.as_external_typed_data.length; |
| 1147 if (length < 0 || | 1147 if (length < 0 || |
| 1148 length > ExternalTypedData::MaxElements( | 1148 length > ExternalTypedData::MaxElements( |
| 1149 kExternalTypedDataUint8ArrayCid)) { | 1149 kExternalTypedDataUint8ArrayCid)) { |
| 1150 return false; | 1150 return false; |
| 1151 } | 1151 } |
| 1152 uint8_t* data = object->value.as_external_typed_data.data; | 1152 uint8_t* data = object->value.as_external_typed_data.data; |
| 1153 void* peer = object->value.as_external_typed_data.peer; | 1153 void* peer = object->value.as_external_typed_data.peer; |
| 1154 Dart_WeakPersistentHandleFinalizer callback = | 1154 Dart_WeakPersistentHandleFinalizer callback = |
| (...skipping 26 matching lines...) Expand all Loading... |
| 1181 if (!success) { | 1181 if (!success) { |
| 1182 UnmarkAllCObjects(object); | 1182 UnmarkAllCObjects(object); |
| 1183 return false; | 1183 return false; |
| 1184 } | 1184 } |
| 1185 } | 1185 } |
| 1186 UnmarkAllCObjects(object); | 1186 UnmarkAllCObjects(object); |
| 1187 return true; | 1187 return true; |
| 1188 } | 1188 } |
| 1189 | 1189 |
| 1190 } // namespace dart | 1190 } // namespace dart |
| OLD | NEW |