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

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

Issue 298963006: Change COMPILE_ASSERT to take only one argument and use it in more places. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 6 years, 6 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
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/ring_buffer.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1624 matching lines...) Expand 10 before | Expand all | Expand 10 after
1635 friend class Object; 1635 friend class Object;
1636 1636
1637 public: 1637 public:
1638 uword tag() const { return tag_; } 1638 uword tag() const { return tag_; }
1639 }; 1639 };
1640 1640
1641 // Class Id predicates. 1641 // Class Id predicates.
1642 1642
1643 inline bool RawObject::IsErrorClassId(intptr_t index) { 1643 inline bool RawObject::IsErrorClassId(intptr_t index) {
1644 // Make sure this function is updated when new Error types are added. 1644 // Make sure this function is updated when new Error types are added.
1645 ASSERT(kApiErrorCid == kErrorCid + 1 && 1645 COMPILE_ASSERT(kApiErrorCid == kErrorCid + 1 &&
1646 kLanguageErrorCid == kErrorCid + 2 && 1646 kLanguageErrorCid == kErrorCid + 2 &&
1647 kUnhandledExceptionCid == kErrorCid + 3 && 1647 kUnhandledExceptionCid == kErrorCid + 3 &&
1648 kUnwindErrorCid == kErrorCid + 4 && 1648 kUnwindErrorCid == kErrorCid + 4 &&
1649 kInstanceCid == kErrorCid + 5); 1649 kInstanceCid == kErrorCid + 5);
1650 return (index >= kErrorCid && index < kInstanceCid); 1650 return (index >= kErrorCid && index < kInstanceCid);
1651 } 1651 }
1652 1652
1653 1653
1654 inline bool RawObject::IsNumberClassId(intptr_t index) { 1654 inline bool RawObject::IsNumberClassId(intptr_t index) {
1655 // Make sure this function is updated when new Number types are added. 1655 // Make sure this function is updated when new Number types are added.
1656 ASSERT(kIntegerCid == kNumberCid + 1 && 1656 COMPILE_ASSERT(kIntegerCid == kNumberCid + 1 &&
1657 kSmiCid == kNumberCid + 2 && 1657 kSmiCid == kNumberCid + 2 &&
1658 kMintCid == kNumberCid + 3 && 1658 kMintCid == kNumberCid + 3 &&
1659 kBigintCid == kNumberCid + 4 && 1659 kBigintCid == kNumberCid + 4 &&
1660 kDoubleCid == kNumberCid + 5); 1660 kDoubleCid == kNumberCid + 5);
1661 return (index >= kNumberCid && index < kBoolCid); 1661 return (index >= kNumberCid && index < kBoolCid);
1662 } 1662 }
1663 1663
1664 1664
1665 inline bool RawObject::IsIntegerClassId(intptr_t index) { 1665 inline bool RawObject::IsIntegerClassId(intptr_t index) {
1666 // Make sure this function is updated when new Integer types are added. 1666 // Make sure this function is updated when new Integer types are added.
1667 ASSERT(kSmiCid == kIntegerCid + 1 && 1667 COMPILE_ASSERT(kSmiCid == kIntegerCid + 1 &&
1668 kMintCid == kIntegerCid + 2 && 1668 kMintCid == kIntegerCid + 2 &&
1669 kBigintCid == kIntegerCid + 3 && 1669 kBigintCid == kIntegerCid + 3 &&
1670 kDoubleCid == kIntegerCid + 4); 1670 kDoubleCid == kIntegerCid + 4);
1671 return (index >= kIntegerCid && index < kDoubleCid); 1671 return (index >= kIntegerCid && index < kDoubleCid);
1672 } 1672 }
1673 1673
1674 1674
1675 inline bool RawObject::IsStringClassId(intptr_t index) { 1675 inline bool RawObject::IsStringClassId(intptr_t index) {
1676 // Make sure this function is updated when new StringCid types are added. 1676 // Make sure this function is updated when new StringCid types are added.
1677 ASSERT(kOneByteStringCid == kStringCid + 1 && 1677 COMPILE_ASSERT(kOneByteStringCid == kStringCid + 1 &&
1678 kTwoByteStringCid == kStringCid + 2 && 1678 kTwoByteStringCid == kStringCid + 2 &&
1679 kExternalOneByteStringCid == kStringCid + 3 && 1679 kExternalOneByteStringCid == kStringCid + 3 &&
1680 kExternalTwoByteStringCid == kStringCid + 4); 1680 kExternalTwoByteStringCid == kStringCid + 4);
1681 return (index >= kStringCid && index <= kExternalTwoByteStringCid); 1681 return (index >= kStringCid && index <= kExternalTwoByteStringCid);
1682 } 1682 }
1683 1683
1684 1684
1685 inline bool RawObject::IsOneByteStringClassId(intptr_t index) { 1685 inline bool RawObject::IsOneByteStringClassId(intptr_t index) {
1686 // Make sure this function is updated when new StringCid types are added. 1686 // Make sure this function is updated when new StringCid types are added.
1687 ASSERT(kOneByteStringCid == kStringCid + 1 && 1687 COMPILE_ASSERT(kOneByteStringCid == kStringCid + 1 &&
1688 kTwoByteStringCid == kStringCid + 2 && 1688 kTwoByteStringCid == kStringCid + 2 &&
1689 kExternalOneByteStringCid == kStringCid + 3 && 1689 kExternalOneByteStringCid == kStringCid + 3 &&
1690 kExternalTwoByteStringCid == kStringCid + 4); 1690 kExternalTwoByteStringCid == kStringCid + 4);
1691 return (index == kOneByteStringCid || index == kExternalOneByteStringCid); 1691 return (index == kOneByteStringCid || index == kExternalOneByteStringCid);
1692 } 1692 }
1693 1693
1694 1694
1695 inline bool RawObject::IsTwoByteStringClassId(intptr_t index) { 1695 inline bool RawObject::IsTwoByteStringClassId(intptr_t index) {
1696 // Make sure this function is updated when new StringCid types are added. 1696 // Make sure this function is updated when new StringCid types are added.
1697 ASSERT(kOneByteStringCid == kStringCid + 1 && 1697 COMPILE_ASSERT(kOneByteStringCid == kStringCid + 1 &&
1698 kTwoByteStringCid == kStringCid + 2 && 1698 kTwoByteStringCid == kStringCid + 2 &&
1699 kExternalOneByteStringCid == kStringCid + 3 && 1699 kExternalOneByteStringCid == kStringCid + 3 &&
1700 kExternalTwoByteStringCid == kStringCid + 4); 1700 kExternalTwoByteStringCid == kStringCid + 4);
1701 return (index == kOneByteStringCid || 1701 return (index == kOneByteStringCid ||
1702 index == kTwoByteStringCid || 1702 index == kTwoByteStringCid ||
1703 index == kExternalOneByteStringCid || 1703 index == kExternalOneByteStringCid ||
1704 index == kExternalTwoByteStringCid); 1704 index == kExternalTwoByteStringCid);
1705 } 1705 }
1706 1706
1707 1707
1708 inline bool RawObject::IsExternalStringClassId(intptr_t index) { 1708 inline bool RawObject::IsExternalStringClassId(intptr_t index) {
1709 // Make sure this function is updated when new StringCid types are added. 1709 // Make sure this function is updated when new StringCid types are added.
1710 ASSERT(kOneByteStringCid == kStringCid + 1 && 1710 COMPILE_ASSERT(kOneByteStringCid == kStringCid + 1 &&
1711 kTwoByteStringCid == kStringCid + 2 && 1711 kTwoByteStringCid == kStringCid + 2 &&
1712 kExternalOneByteStringCid == kStringCid + 3 && 1712 kExternalOneByteStringCid == kStringCid + 3 &&
1713 kExternalTwoByteStringCid == kStringCid + 4); 1713 kExternalTwoByteStringCid == kStringCid + 4);
1714 return (index == kExternalOneByteStringCid || 1714 return (index == kExternalOneByteStringCid ||
1715 index == kExternalTwoByteStringCid); 1715 index == kExternalTwoByteStringCid);
1716 } 1716 }
1717 1717
1718 1718
1719 inline bool RawObject::IsBuiltinListClassId(intptr_t index) { 1719 inline bool RawObject::IsBuiltinListClassId(intptr_t index) {
1720 // Make sure this function is updated when new builtin List types are added. 1720 // Make sure this function is updated when new builtin List types are added.
1721 ASSERT(kImmutableArrayCid == kArrayCid + 1); 1721 COMPILE_ASSERT(kImmutableArrayCid == kArrayCid + 1);
1722 return ((index >= kArrayCid && index <= kImmutableArrayCid) || 1722 return ((index >= kArrayCid && index <= kImmutableArrayCid) ||
1723 (index == kGrowableObjectArrayCid) || 1723 (index == kGrowableObjectArrayCid) ||
1724 IsTypedDataClassId(index) || 1724 IsTypedDataClassId(index) ||
1725 IsTypedDataViewClassId(index) || 1725 IsTypedDataViewClassId(index) ||
1726 IsExternalTypedDataClassId(index)); 1726 IsExternalTypedDataClassId(index));
1727 } 1727 }
1728 1728
1729 1729
1730 inline bool RawObject::IsTypedDataClassId(intptr_t index) { 1730 inline bool RawObject::IsTypedDataClassId(intptr_t index) {
1731 // Make sure this is updated when new TypedData types are added. 1731 // Make sure this is updated when new TypedData types are added.
1732 ASSERT(kTypedDataUint8ArrayCid == kTypedDataInt8ArrayCid + 1 && 1732 COMPILE_ASSERT(kTypedDataUint8ArrayCid == kTypedDataInt8ArrayCid + 1 &&
1733 kTypedDataUint8ClampedArrayCid == kTypedDataInt8ArrayCid + 2 && 1733 kTypedDataUint8ClampedArrayCid == kTypedDataInt8ArrayCid + 2 &&
1734 kTypedDataInt16ArrayCid == kTypedDataInt8ArrayCid + 3 && 1734 kTypedDataInt16ArrayCid == kTypedDataInt8ArrayCid + 3 &&
1735 kTypedDataUint16ArrayCid == kTypedDataInt8ArrayCid + 4 && 1735 kTypedDataUint16ArrayCid == kTypedDataInt8ArrayCid + 4 &&
1736 kTypedDataInt32ArrayCid == kTypedDataInt8ArrayCid + 5 && 1736 kTypedDataInt32ArrayCid == kTypedDataInt8ArrayCid + 5 &&
1737 kTypedDataUint32ArrayCid == kTypedDataInt8ArrayCid + 6 && 1737 kTypedDataUint32ArrayCid == kTypedDataInt8ArrayCid + 6 &&
1738 kTypedDataInt64ArrayCid == kTypedDataInt8ArrayCid + 7 && 1738 kTypedDataInt64ArrayCid == kTypedDataInt8ArrayCid + 7 &&
1739 kTypedDataUint64ArrayCid == kTypedDataInt8ArrayCid + 8 && 1739 kTypedDataUint64ArrayCid == kTypedDataInt8ArrayCid + 8 &&
1740 kTypedDataFloat32ArrayCid == kTypedDataInt8ArrayCid + 9 && 1740 kTypedDataFloat32ArrayCid == kTypedDataInt8ArrayCid + 9 &&
1741 kTypedDataFloat64ArrayCid == kTypedDataInt8ArrayCid + 10 && 1741 kTypedDataFloat64ArrayCid == kTypedDataInt8ArrayCid + 10 &&
1742 kTypedDataFloat32x4ArrayCid == kTypedDataInt8ArrayCid + 11 && 1742 kTypedDataFloat32x4ArrayCid == kTypedDataInt8ArrayCid + 11 &&
1743 kTypedDataInt32x4ArrayCid == kTypedDataInt8ArrayCid + 12 && 1743 kTypedDataInt32x4ArrayCid == kTypedDataInt8ArrayCid + 12 &&
1744 kTypedDataFloat64x2ArrayCid == kTypedDataInt8ArrayCid + 13 && 1744 kTypedDataFloat64x2ArrayCid == kTypedDataInt8ArrayCid + 13 &&
1745 kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); 1745 kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14);
1746 return (index >= kTypedDataInt8ArrayCid && 1746 return (index >= kTypedDataInt8ArrayCid &&
1747 index <= kTypedDataFloat64x2ArrayCid); 1747 index <= kTypedDataFloat64x2ArrayCid);
1748 } 1748 }
1749 1749
1750 1750
1751 inline bool RawObject::IsTypedDataViewClassId(intptr_t index) { 1751 inline bool RawObject::IsTypedDataViewClassId(intptr_t index) {
1752 // Make sure this is updated when new TypedData types are added. 1752 // Make sure this is updated when new TypedData types are added.
1753 ASSERT(kTypedDataUint8ArrayViewCid == kTypedDataInt8ArrayViewCid + 1 && 1753 COMPILE_ASSERT(
1754 kTypedDataUint8ClampedArrayViewCid == kTypedDataInt8ArrayViewCid + 2 && 1754 kTypedDataUint8ArrayViewCid == kTypedDataInt8ArrayViewCid + 1 &&
1755 kTypedDataInt16ArrayViewCid == kTypedDataInt8ArrayViewCid + 3 && 1755 kTypedDataUint8ClampedArrayViewCid == kTypedDataInt8ArrayViewCid + 2 &&
1756 kTypedDataUint16ArrayViewCid == kTypedDataInt8ArrayViewCid + 4 && 1756 kTypedDataInt16ArrayViewCid == kTypedDataInt8ArrayViewCid + 3 &&
1757 kTypedDataInt32ArrayViewCid == kTypedDataInt8ArrayViewCid + 5 && 1757 kTypedDataUint16ArrayViewCid == kTypedDataInt8ArrayViewCid + 4 &&
1758 kTypedDataUint32ArrayViewCid == kTypedDataInt8ArrayViewCid + 6 && 1758 kTypedDataInt32ArrayViewCid == kTypedDataInt8ArrayViewCid + 5 &&
1759 kTypedDataInt64ArrayViewCid == kTypedDataInt8ArrayViewCid + 7 && 1759 kTypedDataUint32ArrayViewCid == kTypedDataInt8ArrayViewCid + 6 &&
1760 kTypedDataUint64ArrayViewCid == kTypedDataInt8ArrayViewCid + 8 && 1760 kTypedDataInt64ArrayViewCid == kTypedDataInt8ArrayViewCid + 7 &&
1761 kTypedDataFloat32ArrayViewCid == kTypedDataInt8ArrayViewCid + 9 && 1761 kTypedDataUint64ArrayViewCid == kTypedDataInt8ArrayViewCid + 8 &&
1762 kTypedDataFloat64ArrayViewCid == kTypedDataInt8ArrayViewCid + 10 && 1762 kTypedDataFloat32ArrayViewCid == kTypedDataInt8ArrayViewCid + 9 &&
1763 kTypedDataFloat32x4ArrayViewCid == kTypedDataInt8ArrayViewCid + 11 && 1763 kTypedDataFloat64ArrayViewCid == kTypedDataInt8ArrayViewCid + 10 &&
1764 kTypedDataInt32x4ArrayViewCid == kTypedDataInt8ArrayViewCid + 12 && 1764 kTypedDataFloat32x4ArrayViewCid == kTypedDataInt8ArrayViewCid + 11 &&
1765 kTypedDataFloat64x2ArrayViewCid == kTypedDataInt8ArrayViewCid + 13 && 1765 kTypedDataInt32x4ArrayViewCid == kTypedDataInt8ArrayViewCid + 12 &&
1766 kByteDataViewCid == kTypedDataInt8ArrayViewCid + 14 && 1766 kTypedDataFloat64x2ArrayViewCid == kTypedDataInt8ArrayViewCid + 13 &&
1767 kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 15); 1767 kByteDataViewCid == kTypedDataInt8ArrayViewCid + 14 &&
1768 kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 15);
1768 return (index >= kTypedDataInt8ArrayViewCid && 1769 return (index >= kTypedDataInt8ArrayViewCid &&
1769 index <= kByteDataViewCid); 1770 index <= kByteDataViewCid);
1770 } 1771 }
1771 1772
1772 1773
1773 inline bool RawObject::IsExternalTypedDataClassId(intptr_t index) { 1774 inline bool RawObject::IsExternalTypedDataClassId(intptr_t index) {
1774 // Make sure this is updated when new ExternalTypedData types are added. 1775 // Make sure this is updated when new ExternalTypedData types are added.
1775 ASSERT((kExternalTypedDataUint8ArrayCid == 1776 COMPILE_ASSERT(
1776 kExternalTypedDataInt8ArrayCid + 1) && 1777 (kExternalTypedDataUint8ArrayCid ==
1777 (kExternalTypedDataUint8ClampedArrayCid == 1778 kExternalTypedDataInt8ArrayCid + 1) &&
1778 kExternalTypedDataInt8ArrayCid + 2) && 1779 (kExternalTypedDataUint8ClampedArrayCid ==
1779 (kExternalTypedDataInt16ArrayCid == 1780 kExternalTypedDataInt8ArrayCid + 2) &&
1780 kExternalTypedDataInt8ArrayCid + 3) && 1781 (kExternalTypedDataInt16ArrayCid ==
1781 (kExternalTypedDataUint16ArrayCid == 1782 kExternalTypedDataInt8ArrayCid + 3) &&
1782 kExternalTypedDataInt8ArrayCid + 4) && 1783 (kExternalTypedDataUint16ArrayCid ==
1783 (kExternalTypedDataInt32ArrayCid == 1784 kExternalTypedDataInt8ArrayCid + 4) &&
1784 kExternalTypedDataInt8ArrayCid + 5) && 1785 (kExternalTypedDataInt32ArrayCid ==
1785 (kExternalTypedDataUint32ArrayCid == 1786 kExternalTypedDataInt8ArrayCid + 5) &&
1786 kExternalTypedDataInt8ArrayCid + 6) && 1787 (kExternalTypedDataUint32ArrayCid ==
1787 (kExternalTypedDataInt64ArrayCid == 1788 kExternalTypedDataInt8ArrayCid + 6) &&
1788 kExternalTypedDataInt8ArrayCid + 7) && 1789 (kExternalTypedDataInt64ArrayCid ==
1789 (kExternalTypedDataUint64ArrayCid == 1790 kExternalTypedDataInt8ArrayCid + 7) &&
1790 kExternalTypedDataInt8ArrayCid + 8) && 1791 (kExternalTypedDataUint64ArrayCid ==
1791 (kExternalTypedDataFloat32ArrayCid == 1792 kExternalTypedDataInt8ArrayCid + 8) &&
1792 kExternalTypedDataInt8ArrayCid + 9) && 1793 (kExternalTypedDataFloat32ArrayCid ==
1793 (kExternalTypedDataFloat64ArrayCid == 1794 kExternalTypedDataInt8ArrayCid + 9) &&
1794 kExternalTypedDataInt8ArrayCid + 10) && 1795 (kExternalTypedDataFloat64ArrayCid ==
1795 (kExternalTypedDataFloat32x4ArrayCid == 1796 kExternalTypedDataInt8ArrayCid + 10) &&
1796 kExternalTypedDataInt8ArrayCid + 11) && 1797 (kExternalTypedDataFloat32x4ArrayCid ==
1797 (kExternalTypedDataInt32x4ArrayCid == 1798 kExternalTypedDataInt8ArrayCid + 11) &&
1798 kExternalTypedDataInt8ArrayCid + 12) && 1799 (kExternalTypedDataInt32x4ArrayCid ==
1799 (kExternalTypedDataFloat64x2ArrayCid == 1800 kExternalTypedDataInt8ArrayCid + 12) &&
1800 kExternalTypedDataInt8ArrayCid + 13) && 1801 (kExternalTypedDataFloat64x2ArrayCid ==
1801 (kNullCid == kExternalTypedDataInt8ArrayCid + 14)); 1802 kExternalTypedDataInt8ArrayCid + 13) &&
1803 (kNullCid == kExternalTypedDataInt8ArrayCid + 14));
1802 return (index >= kExternalTypedDataInt8ArrayCid && 1804 return (index >= kExternalTypedDataInt8ArrayCid &&
1803 index <= kExternalTypedDataFloat64x2ArrayCid); 1805 index <= kExternalTypedDataFloat64x2ArrayCid);
1804 } 1806 }
1805 1807
1806 1808
1807 inline bool RawObject::IsInternalVMdefinedClassId(intptr_t index) { 1809 inline bool RawObject::IsInternalVMdefinedClassId(intptr_t index) {
1808 return ((index < kNumPredefinedCids) && 1810 return ((index < kNumPredefinedCids) &&
1809 !RawObject::IsTypedDataViewClassId(index)); 1811 !RawObject::IsTypedDataViewClassId(index));
1810 } 1812 }
1811 1813
(...skipping 16 matching lines...) Expand all
1828 (index == kCodeCid) || 1830 (index == kCodeCid) ||
1829 (index == kContextScopeCid) || 1831 (index == kContextScopeCid) ||
1830 (index == kInstanceCid) || 1832 (index == kInstanceCid) ||
1831 (index == kBigintCid) || 1833 (index == kBigintCid) ||
1832 (index == kJSRegExpCid); 1834 (index == kJSRegExpCid);
1833 } 1835 }
1834 1836
1835 1837
1836 inline intptr_t RawObject::NumberOfTypedDataClasses() { 1838 inline intptr_t RawObject::NumberOfTypedDataClasses() {
1837 // Make sure this is updated when new TypedData types are added. 1839 // Make sure this is updated when new TypedData types are added.
1838 ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14); 1840 COMPILE_ASSERT(kTypedDataInt8ArrayViewCid == kTypedDataInt8ArrayCid + 14);
1839 ASSERT(kExternalTypedDataInt8ArrayCid == kTypedDataInt8ArrayViewCid + 15); 1841 COMPILE_ASSERT(kExternalTypedDataInt8ArrayCid ==
1840 ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14); 1842 kTypedDataInt8ArrayViewCid + 15);
1843 COMPILE_ASSERT(kNullCid == kExternalTypedDataInt8ArrayCid + 14);
1841 return (kNullCid - kTypedDataInt8ArrayCid); 1844 return (kNullCid - kTypedDataInt8ArrayCid);
1842 } 1845 }
1843 1846
1844 } // namespace dart 1847 } // namespace dart
1845 1848
1846 #endif // VM_RAW_OBJECT_H_ 1849 #endif // VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/object.cc ('k') | runtime/vm/ring_buffer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698