Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(86)

Side by Side Diff: runtime/vm/raw_object.h

Issue 13139002: Remove support for 'dart:scalarlist' in the Dart VM. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
56 V(Number) \ 56 V(Number) \
57 V(Integer) \ 57 V(Integer) \
58 V(Smi) \ 58 V(Smi) \
59 V(Mint) \ 59 V(Mint) \
60 V(Bigint) \ 60 V(Bigint) \
61 V(Double) \ 61 V(Double) \
62 V(Bool) \ 62 V(Bool) \
63 V(Array) \ 63 V(Array) \
64 V(ImmutableArray) \ 64 V(ImmutableArray) \
65 V(GrowableObjectArray) \ 65 V(GrowableObjectArray) \
66 V(ByteArray) \
67 V(Int8Array) \
68 V(Uint8Array) \
69 V(Uint8ClampedArray) \
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(ExternalUint8ClampedArray) \
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(TypedData) \ 66 V(TypedData) \
90 V(ExternalTypedData) \ 67 V(ExternalTypedData) \
91 V(Stacktrace) \ 68 V(Stacktrace) \
92 V(JSRegExp) \ 69 V(JSRegExp) \
93 V(WeakProperty) \ 70 V(WeakProperty) \
94 V(DartFunction) \ 71 V(DartFunction) \
95 V(Float32x4) \ 72 V(Float32x4) \
96 V(Uint32x4) \ 73 V(Uint32x4) \
97 74
98 75
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 364
388 // Class Id predicates. 365 // Class Id predicates.
389 static bool IsErrorClassId(intptr_t index); 366 static bool IsErrorClassId(intptr_t index);
390 static bool IsNumberClassId(intptr_t index); 367 static bool IsNumberClassId(intptr_t index);
391 static bool IsIntegerClassId(intptr_t index); 368 static bool IsIntegerClassId(intptr_t index);
392 static bool IsStringClassId(intptr_t index); 369 static bool IsStringClassId(intptr_t index);
393 static bool IsOneByteStringClassId(intptr_t index); 370 static bool IsOneByteStringClassId(intptr_t index);
394 static bool IsTwoByteStringClassId(intptr_t index); 371 static bool IsTwoByteStringClassId(intptr_t index);
395 static bool IsExternalStringClassId(intptr_t index); 372 static bool IsExternalStringClassId(intptr_t index);
396 static bool IsBuiltinListClassId(intptr_t index); 373 static bool IsBuiltinListClassId(intptr_t index);
397 static bool IsByteArrayClassId(intptr_t index);
398 static bool IsExternalByteArrayClassId(intptr_t index);
399 static bool IsTypedDataClassId(intptr_t index); 374 static bool IsTypedDataClassId(intptr_t index);
400 static bool IsTypedDataViewClassId(intptr_t index); 375 static bool IsTypedDataViewClassId(intptr_t index);
401 static bool IsExternalTypedDataClassId(intptr_t index); 376 static bool IsExternalTypedDataClassId(intptr_t index);
402 377
403 static intptr_t NumberOfTypedDataClasses(); 378 static intptr_t NumberOfTypedDataClasses();
404 379
405 private: 380 private:
406 uword tags_; // Various object tags (bits). 381 uword tags_; // Various object tags (bits).
407 382
408 class FreeBit : public BitField<bool, kFreeBit, 1> {}; 383 class FreeBit : public BitField<bool, kFreeBit, 1> {};
(...skipping 1003 matching lines...) Expand 10 before | Expand all | Expand 10 after
1412 public: 1387 public:
1413 uint32_t x() const { return value_[0]; } 1388 uint32_t x() const { return value_[0]; }
1414 uint32_t y() const { return value_[1]; } 1389 uint32_t y() const { return value_[1]; }
1415 uint32_t z() const { return value_[2]; } 1390 uint32_t z() const { return value_[2]; }
1416 uint32_t w() const { return value_[3]; } 1391 uint32_t w() const { return value_[3]; }
1417 }; 1392 };
1418 1393
1419 1394
1420 // Define an aliases for intptr_t. 1395 // Define an aliases for intptr_t.
1421 #if defined(ARCH_IS_32_BIT) 1396 #if defined(ARCH_IS_32_BIT)
1422 #define RawIntPtrArray RawInt32Array 1397 #define kIntPtrCid kTypedDataInt32ArrayCid
1423 #define IntPtrArray Int32Array 1398 #define SetIntPtr SetInt32
1424 #elif defined(ARCH_IS_64_BIT) 1399 #elif defined(ARCH_IS_64_BIT)
1425 #define RawIntPtrArray RawInt64Array 1400 #define kIntPtrCid kTypedDataInt64ArrayCid
1426 #define IntPtrArray Int64Array 1401 #define SetIntPtr SetInt64
1427 #else 1402 #else
1428 #error Architecture is not 32-bit or 64-bit. 1403 #error Architecture is not 32-bit or 64-bit.
1429 #endif // ARCH_IS_32_BIT 1404 #endif // ARCH_IS_32_BIT
1430 1405
1431 1406
1432 class RawTypedData : public RawInstance { 1407 class RawTypedData : public RawInstance {
1433 RAW_HEAP_OBJECT_IMPLEMENTATION(TypedData); 1408 RAW_HEAP_OBJECT_IMPLEMENTATION(TypedData);
1434 1409
1435 protected: 1410 protected:
1436 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } 1411 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
1437 RawSmi* length_; 1412 RawSmi* length_;
1438 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } 1413 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
1439 1414
1440 // Variable length data follows here. 1415 // Variable length data follows here.
1441 uint8_t data_[0]; 1416 uint8_t data_[0];
1442 1417
1443 friend class Object; 1418 friend class Object;
1419 friend class Instance;
1444 }; 1420 };
1445 1421
1446 1422
1447 class RawExternalTypedData : public RawInstance { 1423 class RawExternalTypedData : public RawInstance {
1448 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData); 1424 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTypedData);
1449 1425
1450 protected: 1426 protected:
1451 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); } 1427 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
1452 RawSmi* length_; 1428 RawSmi* length_;
1453 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); } 1429 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
1454 1430
1455 uint8_t* data_; 1431 uint8_t* data_;
1456 void* peer_; 1432 void* peer_;
1457 1433
1458 friend class TokenStream; 1434 friend class TokenStream;
1459 friend class RawTokenStream; 1435 friend class RawTokenStream;
1460 }; 1436 };
1461 1437
1462 1438
1463 class RawByteArray : public RawInstance {
1464 RAW_HEAP_OBJECT_IMPLEMENTATION(ByteArray);
1465
1466 protected:
1467 RawObject** from() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
1468 RawSmi* length_;
1469 RawObject** to() { return reinterpret_cast<RawObject**>(&ptr()->length_); }
1470 };
1471
1472
1473 class RawInt8Array : public RawByteArray {
1474 RAW_HEAP_OBJECT_IMPLEMENTATION(Int8Array);
1475
1476 // Variable length data follows here.
1477 int8_t data_[0];
1478 };
1479
1480
1481 class RawUint8Array : public RawByteArray {
1482 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint8Array);
1483
1484 // Variable length data follows here.
1485 uint8_t data_[0];
1486 };
1487
1488
1489 class RawUint8ClampedArray : public RawByteArray {
1490 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint8ClampedArray);
1491
1492 // Variable length data follows here.
1493 uint8_t data_[0];
1494 };
1495
1496
1497 class RawInt16Array : public RawByteArray {
1498 RAW_HEAP_OBJECT_IMPLEMENTATION(Int16Array);
1499
1500 // Variable length data follows here.
1501 int16_t data_[0];
1502 };
1503
1504
1505 class RawUint16Array : public RawByteArray {
1506 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint16Array);
1507
1508 // Variable length data follows here.
1509 uint16_t data_[0];
1510 };
1511
1512
1513 class RawInt32Array : public RawByteArray {
1514 RAW_HEAP_OBJECT_IMPLEMENTATION(Int32Array);
1515
1516 // Variable length data follows here.
1517 int32_t data_[0];
1518
1519 friend class Instance;
1520 };
1521
1522
1523 class RawUint32Array : public RawByteArray {
1524 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint32Array);
1525
1526 // Variable length data follows here.
1527 uint32_t data_[0];
1528 };
1529
1530
1531 class RawInt64Array : public RawByteArray {
1532 RAW_HEAP_OBJECT_IMPLEMENTATION(Int64Array);
1533
1534 // Variable length data follows here.
1535 int64_t data_[0];
1536
1537 friend class Instance;
1538 };
1539
1540
1541 class RawUint64Array : public RawByteArray {
1542 RAW_HEAP_OBJECT_IMPLEMENTATION(Uint64Array);
1543
1544 // Variable length data follows here.
1545 uint64_t data_[0];
1546 };
1547
1548
1549 class RawFloat32Array : public RawByteArray {
1550 RAW_HEAP_OBJECT_IMPLEMENTATION(Float32Array);
1551
1552 // Variable length data follows here.
1553 float data_[0];
1554 };
1555
1556
1557 class RawFloat64Array : public RawByteArray {
1558 RAW_HEAP_OBJECT_IMPLEMENTATION(Float64Array);
1559
1560 // Variable length data follows here.
1561 double data_[0];
1562 };
1563
1564
1565 class RawExternalInt8Array : public RawByteArray {
1566 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt8Array);
1567
1568 int8_t* data_;
1569 void* peer_;
1570 };
1571
1572
1573 class RawExternalUint8Array : public RawByteArray {
1574 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint8Array);
1575
1576 uint8_t* data_;
1577 void* peer_;
1578
1579 friend class RawExternalUint8ClampedArray;
1580 };
1581
1582
1583 class RawExternalUint8ClampedArray : public RawExternalUint8Array {
1584 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint8ClampedArray);
1585 };
1586
1587
1588 class RawExternalInt16Array : public RawByteArray {
1589 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt16Array);
1590
1591 int16_t* data_;
1592 void* peer_;
1593 };
1594
1595
1596 class RawExternalUint16Array : public RawByteArray {
1597 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint16Array);
1598
1599 uint16_t* data_;
1600 void* peer_;
1601 };
1602
1603
1604 class RawExternalInt32Array : public RawByteArray {
1605 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt32Array);
1606
1607 int32_t* data_;
1608 void* peer_;
1609 };
1610
1611
1612 class RawExternalUint32Array : public RawByteArray {
1613 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint32Array);
1614
1615 uint32_t* data_;
1616 void* peer_;
1617 };
1618
1619
1620 class RawExternalInt64Array : public RawByteArray {
1621 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalInt64Array);
1622
1623 int64_t* data_;
1624 void* peer_;
1625 };
1626
1627
1628 class RawExternalUint64Array : public RawByteArray {
1629 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalUint64Array);
1630
1631 uint64_t* data_;
1632 void* peer_;
1633 };
1634
1635
1636 class RawExternalFloat32Array : public RawByteArray {
1637 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalFloat32Array);
1638
1639 float* data_;
1640 void* peer_;
1641 };
1642
1643
1644 class RawExternalFloat64Array : public RawByteArray {
1645 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalFloat64Array);
1646
1647 double* data_;
1648 void* peer_;
1649 };
1650
1651
1652 class RawDartFunction : public RawInstance { 1439 class RawDartFunction : public RawInstance {
1653 RAW_HEAP_OBJECT_IMPLEMENTATION(DartFunction); 1440 RAW_HEAP_OBJECT_IMPLEMENTATION(DartFunction);
1654 }; 1441 };
1655 1442
1656 1443
1657 // VM type for capturing stacktraces when exceptions are thrown, 1444 // VM type for capturing stacktraces when exceptions are thrown,
1658 // Currently we don't have any interface that this object is supposed 1445 // Currently we don't have any interface that this object is supposed
1659 // to implement so we just support the 'toString' method which 1446 // to implement so we just support the 'toString' method which
1660 // converts the stack trace into a string. 1447 // converts the stack trace into a string.
1661 class RawStacktrace : public RawInstance { 1448 class RawStacktrace : public RawInstance {
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 kExternalTwoByteStringCid == kStringCid + 4); 1579 kExternalTwoByteStringCid == kStringCid + 4);
1793 return (index == kExternalOneByteStringCid || 1580 return (index == kExternalOneByteStringCid ||
1794 index == kExternalTwoByteStringCid); 1581 index == kExternalTwoByteStringCid);
1795 } 1582 }
1796 1583
1797 1584
1798 inline bool RawObject::IsBuiltinListClassId(intptr_t index) { 1585 inline bool RawObject::IsBuiltinListClassId(intptr_t index) {
1799 // Make sure this function is updated when new builtin List types are added. 1586 // Make sure this function is updated when new builtin List types are added.
1800 ASSERT(kImmutableArrayCid == kArrayCid + 1 && 1587 ASSERT(kImmutableArrayCid == kArrayCid + 1 &&
1801 kGrowableObjectArrayCid == kArrayCid + 2 && 1588 kGrowableObjectArrayCid == kArrayCid + 2 &&
1802 kByteArrayCid == kArrayCid + 3); 1589 kTypedDataCid == kArrayCid + 3);
1803 return (index >= kArrayCid && index < kByteArrayCid) || 1590 return ((index >= kArrayCid && index < kTypedDataCid) ||
1804 IsByteArrayClassId(index); 1591 IsTypedDataClassId(index) ||
1805 } 1592 IsTypedDataViewClassId(index) ||
1806 1593 IsExternalTypedDataClassId(index));
1807
1808 inline bool RawObject::IsByteArrayClassId(intptr_t index) {
1809 // Make sure this function is updated when new ByteArray types are added.
1810 ASSERT(kInt8ArrayCid == kByteArrayCid + 1 &&
1811 kUint8ArrayCid == kByteArrayCid + 2 &&
1812 kUint8ClampedArrayCid == kByteArrayCid + 3 &&
1813 kInt16ArrayCid == kByteArrayCid + 4 &&
1814 kUint16ArrayCid == kByteArrayCid + 5 &&
1815 kInt32ArrayCid == kByteArrayCid + 6 &&
1816 kUint32ArrayCid == kByteArrayCid + 7 &&
1817 kInt64ArrayCid == kByteArrayCid + 8 &&
1818 kUint64ArrayCid == kByteArrayCid + 9 &&
1819 kFloat32ArrayCid == kByteArrayCid + 10 &&
1820 kFloat64ArrayCid == kByteArrayCid + 11 &&
1821 kExternalInt8ArrayCid == kByteArrayCid + 12 &&
1822 kExternalUint8ArrayCid == kByteArrayCid + 13 &&
1823 kExternalUint8ClampedArrayCid == kByteArrayCid + 14 &&
1824 kExternalInt16ArrayCid == kByteArrayCid + 15 &&
1825 kExternalUint16ArrayCid == kByteArrayCid + 16 &&
1826 kExternalInt32ArrayCid == kByteArrayCid + 17 &&
1827 kExternalUint32ArrayCid == kByteArrayCid + 18 &&
1828 kExternalInt64ArrayCid == kByteArrayCid + 19 &&
1829 kExternalUint64ArrayCid == kByteArrayCid + 20 &&
1830 kExternalFloat32ArrayCid == kByteArrayCid + 21 &&
1831 kExternalFloat64ArrayCid == kByteArrayCid + 22 &&
1832 kTypedDataCid == kByteArrayCid + 23);
1833 return (index >= kByteArrayCid && index <= kExternalFloat64ArrayCid);
1834 }
1835
1836
1837 inline bool RawObject::IsExternalByteArrayClassId(intptr_t index) {
1838 // Make sure this function is updated when new ByteArray types are added.
1839 ASSERT(kExternalUint8ArrayCid == kExternalInt8ArrayCid + 1 &&
1840 kExternalUint8ClampedArrayCid == kExternalInt8ArrayCid + 2 &&
1841 kExternalInt16ArrayCid == kExternalInt8ArrayCid + 3 &&
1842 kExternalUint16ArrayCid == kExternalInt8ArrayCid + 4 &&
1843 kExternalInt32ArrayCid == kExternalInt8ArrayCid + 5 &&
1844 kExternalUint32ArrayCid == kExternalInt8ArrayCid + 6 &&
1845 kExternalInt64ArrayCid == kExternalInt8ArrayCid + 7 &&
1846 kExternalUint64ArrayCid == kExternalInt8ArrayCid + 8 &&
1847 kExternalFloat32ArrayCid == kExternalInt8ArrayCid + 9 &&
1848 kExternalFloat64ArrayCid == kExternalInt8ArrayCid + 10 &&
1849 kTypedDataCid == kExternalInt8ArrayCid + 11);
1850 return (index >= kExternalInt8ArrayCid && index <= kExternalFloat64ArrayCid);
1851 } 1594 }
1852 1595
1853 1596
1854 inline bool RawObject::IsTypedDataClassId(intptr_t index) { 1597 inline bool RawObject::IsTypedDataClassId(intptr_t index) {
1855 // Make sure this is updated when new TypedData types are added. 1598 // Make sure this is updated when new TypedData types are added.
1856 ASSERT(kTypedDataUint8ArrayCid == kTypedDataInt8ArrayCid + 1 && 1599 ASSERT(kTypedDataUint8ArrayCid == kTypedDataInt8ArrayCid + 1 &&
1857 kTypedDataUint8ClampedArrayCid == kTypedDataInt8ArrayCid + 2 && 1600 kTypedDataUint8ClampedArrayCid == kTypedDataInt8ArrayCid + 2 &&
1858 kTypedDataInt16ArrayCid == kTypedDataInt8ArrayCid + 3 && 1601 kTypedDataInt16ArrayCid == kTypedDataInt8ArrayCid + 3 &&
1859 kTypedDataUint16ArrayCid == kTypedDataInt8ArrayCid + 4 && 1602 kTypedDataUint16ArrayCid == kTypedDataInt8ArrayCid + 4 &&
1860 kTypedDataInt32ArrayCid == kTypedDataInt8ArrayCid + 5 && 1603 kTypedDataInt32ArrayCid == kTypedDataInt8ArrayCid + 5 &&
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 // Make sure this is updated when new TypedData types are added. 1667 // Make sure this is updated when new TypedData types are added.
1925 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 12); 1668 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 12);
1926 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 13); 1669 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 13);
1927 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 12); 1670 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 12);
1928 return (kNullCid - kTypedDataInt8ArrayCid); 1671 return (kNullCid - kTypedDataInt8ArrayCid);
1929 } 1672 }
1930 1673
1931 } // namespace dart 1674 } // namespace dart
1932 1675
1933 #endif // VM_RAW_OBJECT_H_ 1676 #endif // VM_RAW_OBJECT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698