| 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 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 423 char* p = object->value.as_string; | 423 char* p = object->value.as_string; |
| 424 i = 0; | 424 i = 0; |
| 425 while (i < len) { | 425 while (i < len) { |
| 426 p += Utf8::Encode(Utf16::Next(utf16, &i, len), p); | 426 p += Utf8::Encode(Utf16::Next(utf16, &i, len), p); |
| 427 } | 427 } |
| 428 *p = '\0'; | 428 *p = '\0'; |
| 429 ASSERT(p == (object->value.as_string + utf8_len)); | 429 ASSERT(p == (object->value.as_string + utf8_len)); |
| 430 ::free(utf16); | 430 ::free(utf16); |
| 431 return object; | 431 return object; |
| 432 } | 432 } |
| 433 case kUint8ArrayCid: { | 433 case kTypedDataUint8ArrayCid: |
| 434 case kExternalTypedDataUint8ArrayCid: { |
| 434 intptr_t len = ReadSmiValue(); | 435 intptr_t len = ReadSmiValue(); |
| 435 Dart_CObject* object = AllocateDartCObjectUint8Array(len); | 436 Dart_CObject* object = AllocateDartCObjectUint8Array(len); |
| 436 AddBackRef(object_id, object, kIsDeserialized); | 437 AddBackRef(object_id, object, kIsDeserialized); |
| 437 if (len > 0) { | 438 if (len > 0) { |
| 438 uint8_t* p = object->value.as_byte_array.values; | 439 uint8_t* p = object->value.as_byte_array.values; |
| 439 for (intptr_t i = 0; i < len; i++) { | 440 for (intptr_t i = 0; i < len; i++) { |
| 440 p[i] = Read<uint8_t>(); | 441 p[i] = Read<uint8_t>(); |
| 441 } | 442 } |
| 442 } | 443 } |
| 443 return object; | 444 return object; |
| (...skipping 395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 839 Write<uint16_t>(utf16_str[i]); | 840 Write<uint16_t>(utf16_str[i]); |
| 840 } | 841 } |
| 841 ::free(utf16_str); | 842 ::free(utf16_str); |
| 842 } | 843 } |
| 843 break; | 844 break; |
| 844 } | 845 } |
| 845 case Dart_CObject::kUint8Array: { | 846 case Dart_CObject::kUint8Array: { |
| 846 // Write out the serialization header value for this object. | 847 // Write out the serialization header value for this object. |
| 847 WriteInlinedHeader(object); | 848 WriteInlinedHeader(object); |
| 848 // Write out the class and tags information. | 849 // Write out the class and tags information. |
| 849 WriteIndexedObject(kUint8ArrayCid); | 850 WriteIndexedObject(kTypedDataUint8ArrayCid); |
| 850 WriteIntptrValue(0); | 851 WriteIntptrValue(RawObject::ClassIdTag::update( |
| 852 kTypedDataUint8ArrayCid, 0)); |
| 851 uint8_t* bytes = object->value.as_byte_array.values; | 853 uint8_t* bytes = object->value.as_byte_array.values; |
| 852 intptr_t len = object->value.as_byte_array.length; | 854 intptr_t len = object->value.as_byte_array.length; |
| 853 WriteSmi(len); | 855 WriteSmi(len); |
| 854 for (intptr_t i = 0; i < len; i++) { | 856 for (intptr_t i = 0; i < len; i++) { |
| 855 Write<uint8_t>(bytes[i]); | 857 Write<uint8_t>(bytes[i]); |
| 856 } | 858 } |
| 857 break; | 859 break; |
| 858 } | 860 } |
| 859 case Dart_CObject::kExternalUint8Array: { | 861 case Dart_CObject::kExternalUint8Array: { |
| 860 // TODO(ager): we are writing C pointers into the message in | 862 // TODO(ager): we are writing C pointers into the message in |
| 861 // order to post external arrays through ports. We need to make | 863 // order to post external arrays through ports. We need to make |
| 862 // sure that messages containing pointers can never be posted | 864 // sure that messages containing pointers can never be posted |
| 863 // to other processes. | 865 // to other processes. |
| 864 | 866 |
| 865 // Write out serialization header value for this object. | 867 // Write out serialization header value for this object. |
| 866 WriteInlinedHeader(object); | 868 WriteInlinedHeader(object); |
| 867 // Write out the class and tag information. | 869 // Write out the class and tag information. |
| 868 WriteIndexedObject(kExternalUint8ArrayCid); | 870 WriteIndexedObject(kExternalTypedDataUint8ArrayCid); |
| 869 WriteIntptrValue(0); | 871 WriteIntptrValue(RawObject::ClassIdTag::update( |
| 872 kExternalTypedDataUint8ArrayCid, 0)); |
| 870 int length = object->value.as_external_byte_array.length; | 873 int length = object->value.as_external_byte_array.length; |
| 871 uint8_t* data = object->value.as_external_byte_array.data; | 874 uint8_t* data = object->value.as_external_byte_array.data; |
| 872 void* peer = object->value.as_external_byte_array.peer; | 875 void* peer = object->value.as_external_byte_array.peer; |
| 873 Dart_WeakPersistentHandleFinalizer callback = | 876 Dart_WeakPersistentHandleFinalizer callback = |
| 874 object->value.as_external_byte_array.callback; | 877 object->value.as_external_byte_array.callback; |
| 875 WriteSmi(length); | 878 WriteSmi(length); |
| 876 WriteIntptrValue(reinterpret_cast<intptr_t>(data)); | 879 WriteIntptrValue(reinterpret_cast<intptr_t>(data)); |
| 877 WriteIntptrValue(reinterpret_cast<intptr_t>(peer)); | 880 WriteIntptrValue(reinterpret_cast<intptr_t>(peer)); |
| 878 WriteIntptrValue(reinterpret_cast<intptr_t>(callback)); | 881 WriteIntptrValue(reinterpret_cast<intptr_t>(callback)); |
| 879 break; | 882 break; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 900 if (!success) { | 903 if (!success) { |
| 901 UnmarkAllCObjects(object); | 904 UnmarkAllCObjects(object); |
| 902 return false; | 905 return false; |
| 903 } | 906 } |
| 904 } | 907 } |
| 905 UnmarkAllCObjects(object); | 908 UnmarkAllCObjects(object); |
| 906 return true; | 909 return true; |
| 907 } | 910 } |
| 908 | 911 |
| 909 } // namespace dart | 912 } // namespace dart |
| OLD | NEW |