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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
56 V(Mint) \ | 56 V(Mint) \ |
57 V(Bigint) \ | 57 V(Bigint) \ |
58 V(Double) \ | 58 V(Double) \ |
59 V(Bool) \ | 59 V(Bool) \ |
60 V(Array) \ | 60 V(Array) \ |
61 V(ImmutableArray) \ | 61 V(ImmutableArray) \ |
62 V(GrowableObjectArray) \ | 62 V(GrowableObjectArray) \ |
63 V(ByteArray) \ | 63 V(ByteArray) \ |
64 V(Int8Array) \ | 64 V(Int8Array) \ |
65 V(Uint8Array) \ | 65 V(Uint8Array) \ |
| 66 V(Uint8ClampedArray) \ |
66 V(Int16Array) \ | 67 V(Int16Array) \ |
67 V(Uint16Array) \ | 68 V(Uint16Array) \ |
68 V(Int32Array) \ | 69 V(Int32Array) \ |
69 V(Uint32Array) \ | 70 V(Uint32Array) \ |
70 V(Int64Array) \ | 71 V(Int64Array) \ |
71 V(Uint64Array) \ | 72 V(Uint64Array) \ |
72 V(Float32Array) \ | 73 V(Float32Array) \ |
73 V(Float64Array) \ | 74 V(Float64Array) \ |
74 V(ExternalInt8Array) \ | 75 V(ExternalInt8Array) \ |
75 V(ExternalUint8Array) \ | 76 V(ExternalUint8Array) \ |
| 77 V(ExternalUint8ClampedArray) \ |
76 V(ExternalInt16Array) \ | 78 V(ExternalInt16Array) \ |
77 V(ExternalUint16Array) \ | 79 V(ExternalUint16Array) \ |
78 V(ExternalInt32Array) \ | 80 V(ExternalInt32Array) \ |
79 V(ExternalUint32Array) \ | 81 V(ExternalUint32Array) \ |
80 V(ExternalInt64Array) \ | 82 V(ExternalInt64Array) \ |
81 V(ExternalUint64Array) \ | 83 V(ExternalUint64Array) \ |
82 V(ExternalFloat32Array) \ | 84 V(ExternalFloat32Array) \ |
83 V(ExternalFloat64Array) \ | 85 V(ExternalFloat64Array) \ |
84 V(Stacktrace) \ | 86 V(Stacktrace) \ |
85 V(JSRegExp) \ | 87 V(JSRegExp) \ |
(...skipping 1176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 RAW_HEAP_OBJECT_IMPLEMENTATION(Int8Array); | 1264 RAW_HEAP_OBJECT_IMPLEMENTATION(Int8Array); |
1263 | 1265 |
1264 // Variable length data follows here. | 1266 // Variable length data follows here. |
1265 int8_t data_[0]; | 1267 int8_t data_[0]; |
1266 }; | 1268 }; |
1267 | 1269 |
1268 | 1270 |
1269 class RawUint8Array : public RawByteArray { | 1271 class RawUint8Array : public RawByteArray { |
1270 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint8Array); | 1272 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint8Array); |
1271 | 1273 |
| 1274 protected: |
1272 // Variable length data follows here. | 1275 // Variable length data follows here. |
1273 uint8_t data_[0]; | 1276 uint8_t data_[0]; |
1274 }; | 1277 }; |
1275 | 1278 |
1276 | 1279 |
| 1280 class RawUint8ClampedArray : public RawUint8Array { |
| 1281 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint8ClampedArray); |
| 1282 }; |
| 1283 |
| 1284 |
1277 class RawInt16Array : public RawByteArray { | 1285 class RawInt16Array : public RawByteArray { |
1278 RAW_HEAP_OBJECT_IMPLEMENTATION(Int16Array); | 1286 RAW_HEAP_OBJECT_IMPLEMENTATION(Int16Array); |
1279 | 1287 |
1280 // Variable length data follows here. | 1288 // Variable length data follows here. |
1281 int16_t data_[0]; | 1289 int16_t data_[0]; |
1282 }; | 1290 }; |
1283 | 1291 |
1284 | 1292 |
1285 class RawUint16Array : public RawByteArray { | 1293 class RawUint16Array : public RawByteArray { |
1286 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint16Array); | 1294 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint16Array); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1377 class RawExternalInt8Array : public RawByteArray { | 1385 class RawExternalInt8Array : public RawByteArray { |
1378 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt8Array); | 1386 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt8Array); |
1379 | 1387 |
1380 ExternalByteArrayData<int8_t>* external_data_; | 1388 ExternalByteArrayData<int8_t>* external_data_; |
1381 }; | 1389 }; |
1382 | 1390 |
1383 | 1391 |
1384 class RawExternalUint8Array : public RawByteArray { | 1392 class RawExternalUint8Array : public RawByteArray { |
1385 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint8Array); | 1393 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint8Array); |
1386 | 1394 |
| 1395 protected: |
1387 ExternalByteArrayData<uint8_t>* external_data_; | 1396 ExternalByteArrayData<uint8_t>* external_data_; |
1388 | 1397 |
1389 friend class TokenStream; | 1398 friend class TokenStream; |
1390 friend class RawTokenStream; | 1399 friend class RawTokenStream; |
1391 }; | 1400 }; |
1392 | 1401 |
1393 | 1402 |
| 1403 class RawExternalUint8ClampedArray : public RawExternalUint8Array { |
| 1404 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint8ClampedArray); |
| 1405 }; |
| 1406 |
| 1407 |
1394 class RawExternalInt16Array : public RawByteArray { | 1408 class RawExternalInt16Array : public RawByteArray { |
1395 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt16Array); | 1409 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt16Array); |
1396 | 1410 |
1397 ExternalByteArrayData<int16_t>* external_data_; | 1411 ExternalByteArrayData<int16_t>* external_data_; |
1398 }; | 1412 }; |
1399 | 1413 |
1400 | 1414 |
1401 class RawExternalUint16Array : public RawByteArray { | 1415 class RawExternalUint16Array : public RawByteArray { |
1402 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint16Array); | 1416 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint16Array); |
1403 | 1417 |
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1597 kByteArrayCid == kArrayCid + 3); | 1611 kByteArrayCid == kArrayCid + 3); |
1598 return (index >= kArrayCid && index < kByteArrayCid) || | 1612 return (index >= kArrayCid && index < kByteArrayCid) || |
1599 IsByteArrayClassId(index); | 1613 IsByteArrayClassId(index); |
1600 } | 1614 } |
1601 | 1615 |
1602 | 1616 |
1603 inline bool RawObject::IsByteArrayClassId(intptr_t index) { | 1617 inline bool RawObject::IsByteArrayClassId(intptr_t index) { |
1604 // Make sure this function is updated when new ByteArray types are added. | 1618 // Make sure this function is updated when new ByteArray types are added. |
1605 ASSERT(kInt8ArrayCid == kByteArrayCid + 1 && | 1619 ASSERT(kInt8ArrayCid == kByteArrayCid + 1 && |
1606 kUint8ArrayCid == kByteArrayCid + 2 && | 1620 kUint8ArrayCid == kByteArrayCid + 2 && |
1607 kInt16ArrayCid == kByteArrayCid + 3 && | 1621 kUint8ClampedArrayCid == kByteArrayCid + 3 && |
1608 kUint16ArrayCid == kByteArrayCid + 4 && | 1622 kInt16ArrayCid == kByteArrayCid + 4 && |
1609 kInt32ArrayCid == kByteArrayCid + 5 && | 1623 kUint16ArrayCid == kByteArrayCid + 5 && |
1610 kUint32ArrayCid == kByteArrayCid + 6 && | 1624 kInt32ArrayCid == kByteArrayCid + 6 && |
1611 kInt64ArrayCid == kByteArrayCid + 7 && | 1625 kUint32ArrayCid == kByteArrayCid + 7 && |
1612 kUint64ArrayCid == kByteArrayCid + 8 && | 1626 kInt64ArrayCid == kByteArrayCid + 8 && |
1613 kFloat32ArrayCid == kByteArrayCid + 9 && | 1627 kUint64ArrayCid == kByteArrayCid + 9 && |
1614 kFloat64ArrayCid == kByteArrayCid + 10 && | 1628 kFloat32ArrayCid == kByteArrayCid + 10 && |
1615 kExternalInt8ArrayCid == kByteArrayCid + 11 && | 1629 kFloat64ArrayCid == kByteArrayCid + 11 && |
1616 kExternalUint8ArrayCid == kByteArrayCid + 12 && | 1630 kExternalInt8ArrayCid == kByteArrayCid + 12 && |
1617 kExternalInt16ArrayCid == kByteArrayCid + 13 && | 1631 kExternalUint8ArrayCid == kByteArrayCid + 13 && |
1618 kExternalUint16ArrayCid == kByteArrayCid + 14 && | 1632 kExternalUint8ClampedArrayCid == kByteArrayCid + 14 && |
1619 kExternalInt32ArrayCid == kByteArrayCid + 15 && | 1633 kExternalInt16ArrayCid == kByteArrayCid + 15 && |
1620 kExternalUint32ArrayCid == kByteArrayCid + 16 && | 1634 kExternalUint16ArrayCid == kByteArrayCid + 16 && |
1621 kExternalInt64ArrayCid == kByteArrayCid + 17 && | 1635 kExternalInt32ArrayCid == kByteArrayCid + 17 && |
1622 kExternalUint64ArrayCid == kByteArrayCid + 18 && | 1636 kExternalUint32ArrayCid == kByteArrayCid + 18 && |
1623 kExternalFloat32ArrayCid == kByteArrayCid + 19 && | 1637 kExternalInt64ArrayCid == kByteArrayCid + 19 && |
1624 kExternalFloat64ArrayCid == kByteArrayCid + 20 && | 1638 kExternalUint64ArrayCid == kByteArrayCid + 20 && |
1625 kStacktraceCid == kByteArrayCid + 21); | 1639 kExternalFloat32ArrayCid == kByteArrayCid + 21 && |
| 1640 kExternalFloat64ArrayCid == kByteArrayCid + 22 && |
| 1641 kStacktraceCid == kByteArrayCid + 23); |
1626 return (index >= kByteArrayCid && index <= kExternalFloat64ArrayCid); | 1642 return (index >= kByteArrayCid && index <= kExternalFloat64ArrayCid); |
1627 } | 1643 } |
1628 | 1644 |
1629 inline bool RawObject::IsExternalByteArrayClassId(intptr_t index) { | 1645 inline bool RawObject::IsExternalByteArrayClassId(intptr_t index) { |
1630 // Make sure this function is updated when new ByteArray types are added. | 1646 // Make sure this function is updated when new ByteArray types are added. |
1631 ASSERT(kExternalUint8ArrayCid == kExternalInt8ArrayCid + 1 && | 1647 ASSERT(kExternalUint8ArrayCid == kExternalInt8ArrayCid + 1 && |
1632 kExternalInt16ArrayCid == kExternalInt8ArrayCid + 2 && | 1648 kExternalUint8ClampedArrayCid == kExternalInt8ArrayCid + 2 && |
1633 kExternalUint16ArrayCid == kExternalInt8ArrayCid + 3 && | 1649 kExternalInt16ArrayCid == kExternalInt8ArrayCid + 3 && |
1634 kExternalInt32ArrayCid == kExternalInt8ArrayCid + 4 && | 1650 kExternalUint16ArrayCid == kExternalInt8ArrayCid + 4 && |
1635 kExternalUint32ArrayCid == kExternalInt8ArrayCid + 5 && | 1651 kExternalInt32ArrayCid == kExternalInt8ArrayCid + 5 && |
1636 kExternalInt64ArrayCid == kExternalInt8ArrayCid + 6 && | 1652 kExternalUint32ArrayCid == kExternalInt8ArrayCid + 6 && |
1637 kExternalUint64ArrayCid == kExternalInt8ArrayCid + 7 && | 1653 kExternalInt64ArrayCid == kExternalInt8ArrayCid + 7 && |
1638 kExternalFloat32ArrayCid == kExternalInt8ArrayCid + 8 && | 1654 kExternalUint64ArrayCid == kExternalInt8ArrayCid + 8 && |
1639 kExternalFloat64ArrayCid == kExternalInt8ArrayCid + 9 && | 1655 kExternalFloat32ArrayCid == kExternalInt8ArrayCid + 9 && |
1640 kStacktraceCid == kExternalInt8ArrayCid + 10); | 1656 kExternalFloat64ArrayCid == kExternalInt8ArrayCid + 10 && |
| 1657 kStacktraceCid == kExternalInt8ArrayCid + 11); |
1641 return (index >= kExternalInt8ArrayCid && index <= kExternalFloat64ArrayCid); | 1658 return (index >= kExternalInt8ArrayCid && index <= kExternalFloat64ArrayCid); |
1642 } | 1659 } |
1643 | 1660 |
1644 } // namespace dart | 1661 } // namespace dart |
1645 | 1662 |
1646 #endif // VM_RAW_OBJECT_H_ | 1663 #endif // VM_RAW_OBJECT_H_ |
OLD | NEW |