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(InternalByteArray) \ | 69 V(Int8Array) \ |
70 V(ExternalByteArray) \ | 70 V(Uint8Array) \ |
| 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) \ |
71 V(Closure) \ | 89 V(Closure) \ |
72 V(Stacktrace) \ | 90 V(Stacktrace) \ |
73 V(JSRegExp) \ | 91 V(JSRegExp) \ |
74 | 92 |
75 #define CLASS_LIST(V) \ | 93 #define CLASS_LIST(V) \ |
76 V(Object) \ | 94 V(Object) \ |
77 CLASS_LIST_NO_OBJECT(V) | 95 CLASS_LIST_NO_OBJECT(V) |
78 | 96 |
79 | 97 |
80 // Forward declarations. | 98 // Forward declarations. |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1106 class RawByteArray : public RawInstance { | 1124 class RawByteArray : public RawInstance { |
1107 RAW_HEAP_OBJECT_IMPLEMENTATION(ByteArray); | 1125 RAW_HEAP_OBJECT_IMPLEMENTATION(ByteArray); |
1108 | 1126 |
1109 protected: | 1127 protected: |
1110 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1128 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
1111 RawSmi* length_; | 1129 RawSmi* length_; |
1112 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } | 1130 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } |
1113 }; | 1131 }; |
1114 | 1132 |
1115 | 1133 |
1116 class RawInternalByteArray : public RawByteArray { | 1134 class RawInt8Array: public RawByteArray { |
1117 RAW_HEAP_OBJECT_IMPLEMENTATION(InternalByteArray); | 1135 RAW_HEAP_OBJECT_IMPLEMENTATION(Int8Array); |
1118 | 1136 |
1119 // Variable length data follows here. | 1137 // Variable length data follows here. |
1120 uint8_t* data() { | 1138 int8_t data_[0]; |
1121 uword address_of_length = reinterpret_cast<uword>(&length_); | |
1122 return reinterpret_cast<uint8_t*>(address_of_length + kWordSize); | |
1123 } | |
1124 }; | 1139 }; |
1125 | 1140 |
1126 | 1141 |
| 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> |
1127 class ExternalByteArrayData { | 1215 class ExternalByteArrayData { |
1128 public: | 1216 public: |
1129 ExternalByteArrayData(uint8_t* data, | 1217 ExternalByteArrayData(T* data, |
1130 void* peer, | 1218 void* peer, |
1131 Dart_PeerFinalizer callback) : | 1219 Dart_PeerFinalizer callback) : |
1132 data_(data), peer_(peer), callback_(callback) { | 1220 data_(data), peer_(peer), callback_(callback) { |
1133 } | 1221 } |
1134 ~ExternalByteArrayData() { | 1222 ~ExternalByteArrayData() { |
1135 if (callback_ != NULL) (*callback_)(peer_); | 1223 if (callback_ != NULL) (*callback_)(peer_); |
1136 } | 1224 } |
1137 | 1225 |
1138 uint8_t* data() { | 1226 T* data() { |
1139 return data_; | 1227 return data_; |
1140 } | 1228 } |
1141 void* peer() { | 1229 void* peer() { |
1142 return peer_; | 1230 return peer_; |
1143 } | 1231 } |
1144 | 1232 |
1145 private: | 1233 private: |
1146 uint8_t* data_; | 1234 T* data_; |
1147 void* peer_; | 1235 void* peer_; |
1148 Dart_PeerFinalizer callback_; | 1236 Dart_PeerFinalizer callback_; |
1149 }; | 1237 }; |
1150 | 1238 |
1151 | 1239 |
1152 class RawExternalByteArray : public RawByteArray { | 1240 class RawExternalInt8Array: public RawByteArray { |
1153 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalByteArray); | 1241 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt8Array); |
1154 | 1242 |
1155 ExternalByteArrayData* external_data_; | 1243 ExternalByteArrayData<int8_t>* external_data_; |
1156 }; | 1244 }; |
1157 | 1245 |
1158 | 1246 |
| 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 |
1159 class RawClosure : public RawInstance { | 1310 class RawClosure : public RawInstance { |
1160 RAW_HEAP_OBJECT_IMPLEMENTATION(Closure); | 1311 RAW_HEAP_OBJECT_IMPLEMENTATION(Closure); |
1161 | 1312 |
1162 RawObject** from() { | 1313 RawObject** from() { |
1163 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); | 1314 return reinterpret_cast<RawObject**>(&ptr()->type_arguments_); |
1164 } | 1315 } |
1165 RawAbstractTypeArguments* type_arguments_; | 1316 RawAbstractTypeArguments* type_arguments_; |
1166 RawFunction* function_; | 1317 RawFunction* function_; |
1167 RawContext* context_; | 1318 RawContext* context_; |
1168 // TODO(iposva): Remove this temporary hack. | 1319 // TODO(iposva): Remove this temporary hack. |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1207 intptr_t type_; // Uninitialized, simple or complex. | 1358 intptr_t type_; // Uninitialized, simple or complex. |
1208 intptr_t flags_; // Represents global/local, case insensitive, multiline. | 1359 intptr_t flags_; // Represents global/local, case insensitive, multiline. |
1209 | 1360 |
1210 // Variable length data follows here. | 1361 // Variable length data follows here. |
1211 uint8_t data_[0]; | 1362 uint8_t data_[0]; |
1212 }; | 1363 }; |
1213 | 1364 |
1214 } // namespace dart | 1365 } // namespace dart |
1215 | 1366 |
1216 #endif // VM_RAW_OBJECT_H_ | 1367 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |