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