| 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 #ifndef VM_RAW_OBJECT_H_ | 5 #ifndef VM_RAW_OBJECT_H_ |
| 6 #define VM_RAW_OBJECT_H_ | 6 #define VM_RAW_OBJECT_H_ |
| 7 | 7 |
| 8 #include "platform/assert.h" | 8 #include "platform/assert.h" |
| 9 #include "vm/globals.h" | 9 #include "vm/globals.h" |
| 10 #include "vm/snapshot.h" | 10 #include "vm/snapshot.h" |
| (...skipping 877 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 888 // Variable length data follows here. | 888 // Variable length data follows here. |
| 889 uint32_t data_[0]; | 889 uint32_t data_[0]; |
| 890 | 890 |
| 891 friend class SnapshotReader; | 891 friend class SnapshotReader; |
| 892 }; | 892 }; |
| 893 | 893 |
| 894 | 894 |
| 895 template<typename T> | 895 template<typename T> |
| 896 class ExternalStringData { | 896 class ExternalStringData { |
| 897 public: | 897 public: |
| 898 typedef void Callback(void* peer); | 898 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) : |
| 899 ExternalStringData(const T* data, void* peer, Callback* callback) : | |
| 900 data_(data), peer_(peer), callback_(callback) { | 899 data_(data), peer_(peer), callback_(callback) { |
| 901 } | 900 } |
| 901 |
| 902 ~ExternalStringData() { |
| 903 if (callback_ != NULL) (*callback_)(peer_); |
| 904 } |
| 905 |
| 906 const T* data() { |
| 907 return data_; |
| 908 } |
| 909 void* peer() { |
| 910 return peer_; |
| 911 } |
| 912 |
| 913 private: |
| 902 const T* data_; | 914 const T* data_; |
| 903 void* peer_; | 915 void* peer_; |
| 904 Callback* callback_; | 916 Dart_PeerFinalizer callback_; |
| 905 }; | 917 }; |
| 906 | 918 |
| 907 | 919 |
| 908 class RawExternalOneByteString : public RawString { | 920 class RawExternalOneByteString : public RawString { |
| 909 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalOneByteString); | 921 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalOneByteString); |
| 910 | 922 |
| 911 ExternalStringData<uint8_t>* external_data_; | 923 ExternalStringData<uint8_t>* external_data_; |
| 912 }; | 924 }; |
| 913 | 925 |
| 914 | 926 |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 976 RAW_HEAP_OBJECT_IMPLEMENTATION(InternalByteArray); | 988 RAW_HEAP_OBJECT_IMPLEMENTATION(InternalByteArray); |
| 977 | 989 |
| 978 // Variable length data follows here. | 990 // Variable length data follows here. |
| 979 uint8_t* data() { | 991 uint8_t* data() { |
| 980 uword address_of_length = reinterpret_cast<uword>(&length_); | 992 uword address_of_length = reinterpret_cast<uword>(&length_); |
| 981 return reinterpret_cast<uint8_t*>(address_of_length + kWordSize); | 993 return reinterpret_cast<uint8_t*>(address_of_length + kWordSize); |
| 982 } | 994 } |
| 983 }; | 995 }; |
| 984 | 996 |
| 985 | 997 |
| 998 class ExternalByteArrayData { |
| 999 public: |
| 1000 ExternalByteArrayData(uint8_t* data, |
| 1001 void* peer, |
| 1002 Dart_PeerFinalizer callback) : |
| 1003 data_(data), peer_(peer), callback_(callback) { |
| 1004 } |
| 1005 |
| 1006 ~ExternalByteArrayData() { |
| 1007 if (callback_ != NULL) (*callback_)(peer_); |
| 1008 } |
| 1009 |
| 1010 uint8_t* data() { |
| 1011 return data_; |
| 1012 } |
| 1013 void* peer() { |
| 1014 return peer_; |
| 1015 } |
| 1016 |
| 1017 private: |
| 1018 uint8_t* data_; |
| 1019 void* peer_; |
| 1020 Dart_PeerFinalizer callback_; |
| 1021 }; |
| 1022 |
| 1023 |
| 986 class RawExternalByteArray : public RawByteArray { | 1024 class RawExternalByteArray : public RawByteArray { |
| 987 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalByteArray); | 1025 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalByteArray); |
| 988 | 1026 |
| 989 uint8_t* data_; | 1027 ExternalByteArrayData* external_data_; |
| 990 }; | 1028 }; |
| 991 | 1029 |
| 992 | 1030 |
| 993 class RawClosure : public RawInstance { | 1031 class RawClosure : public RawInstance { |
| 994 RAW_HEAP_OBJECT_IMPLEMENTATION(Closure); | 1032 RAW_HEAP_OBJECT_IMPLEMENTATION(Closure); |
| 995 | 1033 |
| 996 RawObject** from() { | 1034 RawObject** from() { |
| 997 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); | 1035 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); |
| 998 } | 1036 } |
| 999 RawAbstractTypeArguments* type_arguments_; | 1037 RawAbstractTypeArguments* type_arguments_; |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1041 intptr_t type_; // Uninitialized, simple or complex. | 1079 intptr_t type_; // Uninitialized, simple or complex. |
| 1042 intptr_t flags_; // Represents global/local, case insensitive, multiline. | 1080 intptr_t flags_; // Represents global/local, case insensitive, multiline. |
| 1043 | 1081 |
| 1044 // Variable length data follows here. | 1082 // Variable length data follows here. |
| 1045 uint8_t data_[0]; | 1083 uint8_t data_[0]; |
| 1046 }; | 1084 }; |
| 1047 | 1085 |
| 1048 } // namespace dart | 1086 } // namespace dart |
| 1049 | 1087 |
| 1050 #endif // VM_RAW_OBJECT_H_ | 1088 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |