| 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/token.h" | 10 #include "vm/token.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 V(TwoByteString) \ | 58 V(TwoByteString) \ |
| 59 V(FourByteString) \ | 59 V(FourByteString) \ |
| 60 V(ExternalOneByteString) \ | 60 V(ExternalOneByteString) \ |
| 61 V(ExternalTwoByteString) \ | 61 V(ExternalTwoByteString) \ |
| 62 V(ExternalFourByteString) \ | 62 V(ExternalFourByteString) \ |
| 63 V(Bool) \ | 63 V(Bool) \ |
| 64 V(Array) \ | 64 V(Array) \ |
| 65 V(ImmutableArray) \ | 65 V(ImmutableArray) \ |
| 66 V(GrowableObjectArray) \ | 66 V(GrowableObjectArray) \ |
| 67 V(ByteArray) \ | 67 V(ByteArray) \ |
| 68 V(InternalByteArray) \ | 68 V(Int8Array) \ |
| 69 V(ExternalByteArray) \ | 69 V(Uint8Array) \ |
| 70 V(Int16Array) \ |
| 71 V(Uint16Array) \ |
| 72 V(Int32Array) \ |
| 73 V(Uint32Array) \ |
| 74 V(Int64Array) \ |
| 75 V(Uint64Array) \ |
| 76 V(Float32Array) \ |
| 77 V(Float64Array) \ |
| 78 V(ExternalInt8Array) \ |
| 79 V(ExternalUint8Array) \ |
| 80 V(ExternalInt16Array) \ |
| 81 V(ExternalUint16Array) \ |
| 82 V(ExternalInt32Array) \ |
| 83 V(ExternalUint32Array) \ |
| 84 V(ExternalInt64Array) \ |
| 85 V(ExternalUint64Array) \ |
| 86 V(ExternalFloat32Array) \ |
| 87 V(ExternalFloat64Array) \ |
| 70 V(Closure) \ | 88 V(Closure) \ |
| 71 V(Stacktrace) \ | 89 V(Stacktrace) \ |
| 72 V(JSRegExp) \ | 90 V(JSRegExp) \ |
| 73 | 91 |
| 74 #define CLASS_LIST(V) \ | 92 #define CLASS_LIST(V) \ |
| 75 V(Object) \ | 93 V(Object) \ |
| 76 CLASS_LIST_NO_OBJECT(V) | 94 CLASS_LIST_NO_OBJECT(V) |
| 77 | 95 |
| 78 | 96 |
| 79 // Forward declarations. | 97 // Forward declarations. |
| (...skipping 1006 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1086 class RawByteArray : public RawInstance { | 1104 class RawByteArray : public RawInstance { |
| 1087 RAW_HEAP_OBJECT_IMPLEMENTATION(ByteArray); | 1105 RAW_HEAP_OBJECT_IMPLEMENTATION(ByteArray); |
| 1088 | 1106 |
| 1089 protected: | 1107 protected: |
| 1090 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1108 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 1091 RawSmi* length_; | 1109 RawSmi* length_; |
| 1092 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1110 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
| 1093 }; | 1111 }; |
| 1094 | 1112 |
| 1095 | 1113 |
| 1096 class RawInternalByteArray : public RawByteArray { | 1114 class RawInt8Array: public RawByteArray { |
| 1097 RAW_HEAP_OBJECT_IMPLEMENTATION(InternalByteArray); | 1115 RAW_HEAP_OBJECT_IMPLEMENTATION(Int8Array); |
| 1098 | 1116 |
| 1099 // Variable length data follows here. | 1117 // Variable length data follows here. |
| 1100 uint8_t* data() { | 1118 int8_t data_[0]; |
| 1101 uword address_of_length = reinterpret_cast<uword>(&length_); | |
| 1102 return reinterpret_cast<uint8_t*>(address_of_length + kWordSize); | |
| 1103 } | |
| 1104 }; | 1119 }; |
| 1105 | 1120 |
| 1106 | 1121 |
| 1122 class RawUint8Array: public RawByteArray { |
| 1123 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint8Array); |
| 1124 |
| 1125 // Variable length data follows here. |
| 1126 uint8_t data_[0]; |
| 1127 }; |
| 1128 |
| 1129 |
| 1130 class RawInt16Array: public RawByteArray { |
| 1131 RAW_HEAP_OBJECT_IMPLEMENTATION(Int16Array); |
| 1132 |
| 1133 // Variable length data follows here. |
| 1134 int16_t data_[0]; |
| 1135 }; |
| 1136 |
| 1137 |
| 1138 class RawUint16Array: public RawByteArray { |
| 1139 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint16Array); |
| 1140 |
| 1141 // Variable length data follows here. |
| 1142 uint16_t data_[0]; |
| 1143 }; |
| 1144 |
| 1145 |
| 1146 class RawInt32Array: public RawByteArray { |
| 1147 RAW_HEAP_OBJECT_IMPLEMENTATION(Int32Array); |
| 1148 |
| 1149 // Variable length data follows here. |
| 1150 int32_t data_[0]; |
| 1151 }; |
| 1152 |
| 1153 |
| 1154 class RawUint32Array: public RawByteArray { |
| 1155 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint32Array); |
| 1156 |
| 1157 // Variable length data follows here. |
| 1158 uint32_t data_[0]; |
| 1159 }; |
| 1160 |
| 1161 |
| 1162 class RawInt64Array: public RawByteArray { |
| 1163 RAW_HEAP_OBJECT_IMPLEMENTATION(Int64Array); |
| 1164 |
| 1165 // Variable length data follows here. |
| 1166 int64_t data_[0]; |
| 1167 }; |
| 1168 |
| 1169 |
| 1170 class RawUint64Array: public RawByteArray { |
| 1171 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint64Array); |
| 1172 |
| 1173 // Variable length data follows here. |
| 1174 uint64_t data_[0]; |
| 1175 }; |
| 1176 |
| 1177 |
| 1178 class RawFloat32Array: public RawByteArray { |
| 1179 RAW_HEAP_OBJECT_IMPLEMENTATION(Float32Array); |
| 1180 |
| 1181 // Variable length data follows here. |
| 1182 float data_[0]; |
| 1183 }; |
| 1184 |
| 1185 |
| 1186 class RawFloat64Array: public RawByteArray { |
| 1187 RAW_HEAP_OBJECT_IMPLEMENTATION(Float64Array); |
| 1188 |
| 1189 // Variable length data follows here. |
| 1190 double data_[0]; |
| 1191 }; |
| 1192 |
| 1193 |
| 1194 template<typename T> |
| 1107 class ExternalByteArrayData { | 1195 class ExternalByteArrayData { |
| 1108 public: | 1196 public: |
| 1109 ExternalByteArrayData(uint8_t* data, | 1197 ExternalByteArrayData(T* data, |
| 1110 void* peer, | 1198 void* peer, |
| 1111 Dart_PeerFinalizer callback) : | 1199 Dart_PeerFinalizer callback) : |
| 1112 data_(data), peer_(peer), callback_(callback) { | 1200 data_(data), peer_(peer), callback_(callback) { |
| 1113 } | 1201 } |
| 1114 ~ExternalByteArrayData() { | 1202 ~ExternalByteArrayData() { |
| 1115 if (callback_ != NULL) (*callback_)(peer_); | 1203 if (callback_ != NULL) (*callback_)(peer_); |
| 1116 } | 1204 } |
| 1117 | 1205 |
| 1118 uint8_t* data() { | 1206 T* data() { |
| 1119 return data_; | 1207 return data_; |
| 1120 } | 1208 } |
| 1121 void* peer() { | 1209 void* peer() { |
| 1122 return peer_; | 1210 return peer_; |
| 1123 } | 1211 } |
| 1124 | 1212 |
| 1125 private: | 1213 private: |
| 1126 uint8_t* data_; | 1214 T* data_; |
| 1127 void* peer_; | 1215 void* peer_; |
| 1128 Dart_PeerFinalizer callback_; | 1216 Dart_PeerFinalizer callback_; |
| 1129 }; | 1217 }; |
| 1130 | 1218 |
| 1131 | 1219 |
| 1132 class RawExternalByteArray : public RawByteArray { | 1220 class RawExternalInt8Array: public RawByteArray { |
| 1133 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalByteArray); | 1221 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt8Array); |
| 1134 | 1222 |
| 1135 ExternalByteArrayData* external_data_; | 1223 ExternalByteArrayData<int8_t>* external_data_; |
| 1136 }; | 1224 }; |
| 1137 | 1225 |
| 1138 | 1226 |
| 1227 class RawExternalUint8Array: public RawByteArray { |
| 1228 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint8Array); |
| 1229 |
| 1230 ExternalByteArrayData<uint8_t>* external_data_; |
| 1231 }; |
| 1232 |
| 1233 |
| 1234 class RawExternalInt16Array: public RawByteArray { |
| 1235 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt16Array); |
| 1236 |
| 1237 ExternalByteArrayData<int16_t>* external_data_; |
| 1238 }; |
| 1239 |
| 1240 |
| 1241 class RawExternalUint16Array: public RawByteArray { |
| 1242 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint16Array); |
| 1243 |
| 1244 ExternalByteArrayData<uint16_t>* external_data_; |
| 1245 }; |
| 1246 |
| 1247 |
| 1248 class RawExternalInt32Array: public RawByteArray { |
| 1249 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt32Array); |
| 1250 |
| 1251 ExternalByteArrayData<int32_t>* external_data_; |
| 1252 }; |
| 1253 |
| 1254 |
| 1255 class RawExternalUint32Array: public RawByteArray { |
| 1256 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint32Array); |
| 1257 |
| 1258 ExternalByteArrayData<uint32_t>* external_data_; |
| 1259 }; |
| 1260 |
| 1261 |
| 1262 class RawExternalInt64Array: public RawByteArray { |
| 1263 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt64Array); |
| 1264 |
| 1265 ExternalByteArrayData<int64_t>* external_data_; |
| 1266 }; |
| 1267 |
| 1268 |
| 1269 class RawExternalUint64Array: public RawByteArray { |
| 1270 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint64Array); |
| 1271 |
| 1272 ExternalByteArrayData<uint64_t>* external_data_; |
| 1273 }; |
| 1274 |
| 1275 |
| 1276 class RawExternalFloat32Array: public RawByteArray { |
| 1277 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalFloat32Array); |
| 1278 |
| 1279 ExternalByteArrayData<float>* external_data_; |
| 1280 }; |
| 1281 |
| 1282 |
| 1283 class RawExternalFloat64Array: public RawByteArray { |
| 1284 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalFloat64Array); |
| 1285 |
| 1286 ExternalByteArrayData<double>* external_data_; |
| 1287 }; |
| 1288 |
| 1289 |
| 1139 class RawClosure : public RawInstance { | 1290 class RawClosure : public RawInstance { |
| 1140 RAW_HEAP_OBJECT_IMPLEMENTATION(Closure); | 1291 RAW_HEAP_OBJECT_IMPLEMENTATION(Closure); |
| 1141 | 1292 |
| 1142 RawObject** from() { | 1293 RawObject** from() { |
| 1143 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); | 1294 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); |
| 1144 } | 1295 } |
| 1145 RawAbstractTypeArguments* type_arguments_; | 1296 RawAbstractTypeArguments* type_arguments_; |
| 1146 RawFunction* function_; | 1297 RawFunction* function_; |
| 1147 RawContext* context_; | 1298 RawContext* context_; |
| 1148 // TODO(iposva): Remove this temporary hack. | 1299 // TODO(iposva): Remove this temporary hack. |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1187 intptr_t type_; // Uninitialized, simple or complex. | 1338 intptr_t type_; // Uninitialized, simple or complex. |
| 1188 intptr_t flags_; // Represents global/local, case insensitive, multiline. | 1339 intptr_t flags_; // Represents global/local, case insensitive, multiline. |
| 1189 | 1340 |
| 1190 // Variable length data follows here. | 1341 // Variable length data follows here. |
| 1191 uint8_t data_[0]; | 1342 uint8_t data_[0]; |
| 1192 }; | 1343 }; |
| 1193 | 1344 |
| 1194 } // namespace dart | 1345 } // namespace dart |
| 1195 | 1346 |
| 1196 #endif // VM_RAW_OBJECT_H_ | 1347 #endif // VM_RAW_OBJECT_H_ |
| OLD | NEW |