| 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/object_store.h" | 7 #include "vm/object_store.h" |
| 8 | 8 |
| 9 namespace dart { | 9 namespace dart { |
| 10 | 10 |
| (...skipping 697 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 708 // Write out the class and tags information. | 708 // Write out the class and tags information. |
| 709 WriteObjectHeader(ObjectStore::kUint8ArrayClass, 0); | 709 WriteObjectHeader(ObjectStore::kUint8ArrayClass, 0); |
| 710 uint8_t* bytes = object->value.as_byte_array.values; | 710 uint8_t* bytes = object->value.as_byte_array.values; |
| 711 intptr_t len = object->value.as_byte_array.length; | 711 intptr_t len = object->value.as_byte_array.length; |
| 712 WriteSmi(len); | 712 WriteSmi(len); |
| 713 for (intptr_t i = 0; i < len; i++) { | 713 for (intptr_t i = 0; i < len; i++) { |
| 714 Write<uint8_t>(bytes[i]); | 714 Write<uint8_t>(bytes[i]); |
| 715 } | 715 } |
| 716 break; | 716 break; |
| 717 } | 717 } |
| 718 case Dart_CObject::kExternalUint8Array: { |
| 719 // TODO(ager): we are writing C pointers into the message in |
| 720 // order to post external arrays through ports. We need to make |
| 721 // sure that messages containing pointers can never be posted |
| 722 // to other processes. |
| 723 |
| 724 // Write out serialization header value for this object. |
| 725 WriteInlinedHeader(object); |
| 726 // Write out the class and tag information. |
| 727 WriteObjectHeader(ObjectStore::kExternalUint8ArrayClass, 0); |
| 728 int length = object->value.as_external_byte_array.length; |
| 729 uint8_t* data = object->value.as_external_byte_array.data; |
| 730 void* peer = object->value.as_external_byte_array.peer; |
| 731 Dart_PeerFinalizer callback = |
| 732 object->value.as_external_byte_array.callback; |
| 733 WriteSmi(length); |
| 734 WriteIntptrValue(reinterpret_cast<intptr_t>(data)); |
| 735 WriteIntptrValue(reinterpret_cast<intptr_t>(peer)); |
| 736 WriteIntptrValue(reinterpret_cast<intptr_t>(callback)); |
| 737 break; |
| 738 } |
| 718 default: | 739 default: |
| 719 UNREACHABLE(); | 740 UNREACHABLE(); |
| 720 } | 741 } |
| 721 } | 742 } |
| 722 | 743 |
| 723 | 744 |
| 724 void ApiMessageWriter::WriteCMessage(Dart_CObject* object) { | 745 void ApiMessageWriter::WriteCMessage(Dart_CObject* object) { |
| 725 WriteCObject(object); | 746 WriteCObject(object); |
| 726 // Write out all objects that were added to the forward list and have | 747 // Write out all objects that were added to the forward list and have |
| 727 // not been serialized yet. These would typically be fields of arrays. | 748 // not been serialized yet. These would typically be fields of arrays. |
| 728 // NOTE: The forward list might grow as we process the list. | 749 // NOTE: The forward list might grow as we process the list. |
| 729 for (intptr_t i = 0; i < forward_id_; i++) { | 750 for (intptr_t i = 0; i < forward_id_; i++) { |
| 730 WriteForwardedCObject(forward_list_[i]); | 751 WriteForwardedCObject(forward_list_[i]); |
| 731 } | 752 } |
| 732 UnmarkAllCObjects(object); | 753 UnmarkAllCObjects(object); |
| 733 FinalizeBuffer(); | 754 FinalizeBuffer(); |
| 734 } | 755 } |
| 735 | 756 |
| 736 } // namespace dart | 757 } // namespace dart |
| OLD | NEW |