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

Side by Side Diff: src/hydrogen-instructions.h

Issue 21356002: Improve instruction creating/adding shorthand in HGraphBuilder (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Review feedback and merge with ToT Created 7 years, 4 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 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1301 int flags_; 1301 int flags_;
1302 GVNFlagSet gvn_flags_; 1302 GVNFlagSet gvn_flags_;
1303 1303
1304 private: 1304 private:
1305 virtual bool IsDeletable() const { return false; } 1305 virtual bool IsDeletable() const { return false; }
1306 1306
1307 DISALLOW_COPY_AND_ASSIGN(HValue); 1307 DISALLOW_COPY_AND_ASSIGN(HValue);
1308 }; 1308 };
1309 1309
1310 1310
1311 #define DECLARE_INSTRUCTION_FACTORY_P0(I) \
1312 static I* New(Zone* zone, HValue* context) { \
1313 return new(zone) I(); \
1314 }
1315
1316 #define DECLARE_INSTRUCTION_FACTORY_P1(I, P1) \
1317 static I* New(Zone* zone, HValue* context, P1 p1) { \
1318 return new(zone) I(p1); \
1319 }
1320
1321 #define DECLARE_INSTRUCTION_FACTORY_P2(I, P1, P2) \
1322 static I* New(Zone* zone, HValue* context, P1 p1, P2 p2) { \
1323 return new(zone) I(p1, p2); \
1324 }
1325
1326 #define DECLARE_INSTRUCTION_FACTORY_P3(I, P1, P2, P3) \
1327 static I* New(Zone* zone, HValue* context, P1 p1, P2 p2, P3 p3) { \
1328 return new(zone) I(p1, p2, p3); \
1329 }
1330
1331 #define DECLARE_INSTRUCTION_FACTORY_P4(I, P1, P2, P3, P4) \
1332 static I* New(Zone* zone, \
1333 HValue* context, \
1334 P1 p1, \
1335 P2 p2, \
1336 P3 p3, \
1337 P4 p4) { \
1338 return new(zone) I(p1, p2, p3, p4); \
1339 }
1340
1341 #define DECLARE_INSTRUCTION_FACTORY_P5(I, P1, P2, P3, P4, P5) \
1342 static I* New(Zone* zone, \
1343 HValue* context, \
1344 P1 p1, \
1345 P2 p2, \
1346 P3 p3, \
1347 P4 p4, \
1348 P5 p5) { \
1349 return new(zone) I(p1, p2, p3, p4, p5); \
1350 }
1351
1352
1311 class HInstruction: public HValue { 1353 class HInstruction: public HValue {
1312 public: 1354 public:
1313 HInstruction* next() const { return next_; } 1355 HInstruction* next() const { return next_; }
1314 HInstruction* previous() const { return previous_; } 1356 HInstruction* previous() const { return previous_; }
1315 1357
1316 virtual void PrintTo(StringStream* stream); 1358 virtual void PrintTo(StringStream* stream);
1317 virtual void PrintDataTo(StringStream* stream); 1359 virtual void PrintDataTo(StringStream* stream);
1318 1360
1319 bool IsLinked() const { return block() != NULL; } 1361 bool IsLinked() const { return block() != NULL; }
1320 void Unlink(); 1362 void Unlink();
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
1513 SetOperandAt(0, constrained_value); 1555 SetOperandAt(0, constrained_value);
1514 SetOperandAt(1, related_value); 1556 SetOperandAt(1, related_value);
1515 } 1557 }
1516 1558
1517 NumericRelation relation_; 1559 NumericRelation relation_;
1518 }; 1560 };
1519 1561
1520 1562
1521 class HDeoptimize: public HTemplateInstruction<0> { 1563 class HDeoptimize: public HTemplateInstruction<0> {
1522 public: 1564 public:
1523 explicit HDeoptimize(Deoptimizer::BailoutType type) : type_(type) {} 1565 DECLARE_INSTRUCTION_FACTORY_P1(HDeoptimize, Deoptimizer::BailoutType);
1524 1566
1525 virtual Representation RequiredInputRepresentation(int index) { 1567 virtual Representation RequiredInputRepresentation(int index) {
1526 return Representation::None(); 1568 return Representation::None();
1527 } 1569 }
1528 1570
1529 Deoptimizer::BailoutType type() { return type_; } 1571 Deoptimizer::BailoutType type() { return type_; }
1530 1572
1531 DECLARE_CONCRETE_INSTRUCTION(Deoptimize) 1573 DECLARE_CONCRETE_INSTRUCTION(Deoptimize)
1532 1574
1533 private: 1575 private:
1576 explicit HDeoptimize(Deoptimizer::BailoutType type) : type_(type) {}
1577
1534 Deoptimizer::BailoutType type_; 1578 Deoptimizer::BailoutType type_;
1535 }; 1579 };
1536 1580
1537 1581
1538 // Inserts an int3/stop break instruction for debugging purposes. 1582 // Inserts an int3/stop break instruction for debugging purposes.
1539 class HDebugBreak: public HTemplateInstruction<0> { 1583 class HDebugBreak: public HTemplateInstruction<0> {
1540 public: 1584 public:
1541 virtual Representation RequiredInputRepresentation(int index) { 1585 virtual Representation RequiredInputRepresentation(int index) {
1542 return Representation::None(); 1586 return Representation::None();
1543 } 1587 }
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after
1624 return Representation::Tagged(); 1668 return Representation::Tagged();
1625 } 1669 }
1626 1670
1627 DECLARE_CONCRETE_INSTRUCTION(CompareMap) 1671 DECLARE_CONCRETE_INSTRUCTION(CompareMap)
1628 1672
1629 private: 1673 private:
1630 Handle<Map> map_; 1674 Handle<Map> map_;
1631 }; 1675 };
1632 1676
1633 1677
1678 class HContext: public HTemplateInstruction<0> {
1679 public:
1680 static HContext* New(Zone* zone) {
1681 return new(zone) HContext();
1682 }
1683
1684 virtual Representation RequiredInputRepresentation(int index) {
1685 return Representation::None();
1686 }
1687
1688 DECLARE_CONCRETE_INSTRUCTION(Context)
1689
1690 protected:
1691 virtual bool DataEquals(HValue* other) { return true; }
1692
1693 private:
1694 HContext() {
1695 set_representation(Representation::Tagged());
1696 SetFlag(kUseGVN);
1697 }
1698
1699 virtual bool IsDeletable() const { return true; }
1700 };
1701
1702
1634 class HReturn: public HTemplateControlInstruction<0, 3> { 1703 class HReturn: public HTemplateControlInstruction<0, 3> {
1635 public: 1704 public:
1636 HReturn(HValue* value, HValue* context, HValue* parameter_count) { 1705 static HInstruction* New(Zone* zone,
1637 SetOperandAt(0, value); 1706 HValue* context,
1638 SetOperandAt(1, context); 1707 HValue* value,
1639 SetOperandAt(2, parameter_count); 1708 HValue* parameter_count) {
1709 return new(zone) HReturn(value, context, parameter_count);
1710 }
1711
1712 static HInstruction* New(Zone* zone,
1713 HValue* context,
1714 HValue* value) {
1715 return new(zone) HReturn(value, context, 0);
1640 } 1716 }
1641 1717
1642 virtual Representation RequiredInputRepresentation(int index) { 1718 virtual Representation RequiredInputRepresentation(int index) {
1643 return Representation::Tagged(); 1719 return Representation::Tagged();
1644 } 1720 }
1645 1721
1646 virtual void PrintDataTo(StringStream* stream); 1722 virtual void PrintDataTo(StringStream* stream);
1647 1723
1648 HValue* value() { return OperandAt(0); } 1724 HValue* value() { return OperandAt(0); }
1649 HValue* context() { return OperandAt(1); } 1725 HValue* context() { return OperandAt(1); }
1650 HValue* parameter_count() { return OperandAt(2); } 1726 HValue* parameter_count() { return OperandAt(2); }
1651 1727
1652 DECLARE_CONCRETE_INSTRUCTION(Return) 1728 DECLARE_CONCRETE_INSTRUCTION(Return)
1729
1730 private:
1731 HReturn(HValue* value, HValue* context, HValue* parameter_count) {
1732 SetOperandAt(0, value);
1733 SetOperandAt(1, context);
1734 SetOperandAt(2, parameter_count);
1735 }
1653 }; 1736 };
1654 1737
1655 1738
1656 class HAbnormalExit: public HTemplateControlInstruction<0, 0> { 1739 class HAbnormalExit: public HTemplateControlInstruction<0, 0> {
1657 public: 1740 public:
1658 virtual Representation RequiredInputRepresentation(int index) { 1741 virtual Representation RequiredInputRepresentation(int index) {
1659 return Representation::None(); 1742 return Representation::None();
1660 } 1743 }
1661 1744
1662 DECLARE_CONCRETE_INSTRUCTION(AbnormalExit) 1745 DECLARE_CONCRETE_INSTRUCTION(AbnormalExit)
(...skipping 11 matching lines...) Expand all
1674 return reinterpret_cast<HUnaryOperation*>(value); 1757 return reinterpret_cast<HUnaryOperation*>(value);
1675 } 1758 }
1676 1759
1677 HValue* value() const { return OperandAt(0); } 1760 HValue* value() const { return OperandAt(0); }
1678 virtual void PrintDataTo(StringStream* stream); 1761 virtual void PrintDataTo(StringStream* stream);
1679 }; 1762 };
1680 1763
1681 1764
1682 class HThrow: public HTemplateInstruction<2> { 1765 class HThrow: public HTemplateInstruction<2> {
1683 public: 1766 public:
1684 HThrow(HValue* context, HValue* value) { 1767 static HThrow* New(Zone* zone,
1685 SetOperandAt(0, context); 1768 HValue* context,
1686 SetOperandAt(1, value); 1769 HValue* value) {
1687 SetAllSideEffects(); 1770 return new(zone) HThrow(context, value);
1688 } 1771 }
1689 1772
1690 virtual Representation RequiredInputRepresentation(int index) { 1773 virtual Representation RequiredInputRepresentation(int index) {
1691 return Representation::Tagged(); 1774 return Representation::Tagged();
1692 } 1775 }
1693 1776
1694 HValue* context() { return OperandAt(0); } 1777 HValue* context() { return OperandAt(0); }
1695 HValue* value() { return OperandAt(1); } 1778 HValue* value() { return OperandAt(1); }
1696 1779
1697 DECLARE_CONCRETE_INSTRUCTION(Throw) 1780 DECLARE_CONCRETE_INSTRUCTION(Throw)
1781
1782 private:
1783 HThrow(HValue* context, HValue* value) {
1784 SetOperandAt(0, context);
1785 SetOperandAt(1, value);
1786 SetAllSideEffects();
1787 }
1698 }; 1788 };
1699 1789
1700 1790
1701 class HUseConst: public HUnaryOperation { 1791 class HUseConst: public HUnaryOperation {
1702 public: 1792 public:
1703 explicit HUseConst(HValue* old_value) : HUnaryOperation(old_value) { } 1793 DECLARE_INSTRUCTION_FACTORY_P1(HUseConst, HValue*);
1704 1794
1705 virtual Representation RequiredInputRepresentation(int index) { 1795 virtual Representation RequiredInputRepresentation(int index) {
1706 return Representation::None(); 1796 return Representation::None();
1707 } 1797 }
1708 1798
1709 DECLARE_CONCRETE_INSTRUCTION(UseConst) 1799 DECLARE_CONCRETE_INSTRUCTION(UseConst)
1800
1801 private:
1802 explicit HUseConst(HValue* old_value) : HUnaryOperation(old_value) { }
1710 }; 1803 };
1711 1804
1712 1805
1713 class HForceRepresentation: public HTemplateInstruction<1> { 1806 class HForceRepresentation: public HTemplateInstruction<1> {
1714 public: 1807 public:
1715 HForceRepresentation(HValue* value, Representation required_representation) { 1808 DECLARE_INSTRUCTION_FACTORY_P2(HForceRepresentation, HValue*, Representation);
1716 SetOperandAt(0, value);
1717 set_representation(required_representation);
1718 }
1719 1809
1720 HValue* value() { return OperandAt(0); } 1810 HValue* value() { return OperandAt(0); }
1721 1811
1722 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 1812 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
1723 1813
1724 virtual Representation RequiredInputRepresentation(int index) { 1814 virtual Representation RequiredInputRepresentation(int index) {
1725 return representation(); // Same as the output representation. 1815 return representation(); // Same as the output representation.
1726 } 1816 }
1727 1817
1728 virtual void PrintDataTo(StringStream* stream); 1818 virtual void PrintDataTo(StringStream* stream);
1729 1819
1730 DECLARE_CONCRETE_INSTRUCTION(ForceRepresentation) 1820 DECLARE_CONCRETE_INSTRUCTION(ForceRepresentation)
1821
1822 private:
1823 HForceRepresentation(HValue* value, Representation required_representation) {
1824 SetOperandAt(0, value);
1825 set_representation(required_representation);
1826 }
1731 }; 1827 };
1732 1828
1733 1829
1734 class HChange: public HUnaryOperation { 1830 class HChange: public HUnaryOperation {
1735 public: 1831 public:
1736 HChange(HValue* value, 1832 HChange(HValue* value,
1737 Representation to, 1833 Representation to,
1738 bool is_truncating_to_smi, 1834 bool is_truncating_to_smi,
1739 bool is_truncating_to_int32, 1835 bool is_truncating_to_int32,
1740 bool allow_undefined_as_nan) 1836 bool allow_undefined_as_nan)
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
1782 1878
1783 private: 1879 private:
1784 virtual bool IsDeletable() const { 1880 virtual bool IsDeletable() const {
1785 return !from().IsTagged() || value()->type().IsSmi(); 1881 return !from().IsTagged() || value()->type().IsSmi();
1786 } 1882 }
1787 }; 1883 };
1788 1884
1789 1885
1790 class HClampToUint8: public HUnaryOperation { 1886 class HClampToUint8: public HUnaryOperation {
1791 public: 1887 public:
1792 explicit HClampToUint8(HValue* value) 1888 DECLARE_INSTRUCTION_FACTORY_P1(HClampToUint8, HValue*);
1793 : HUnaryOperation(value) {
1794 set_representation(Representation::Integer32());
1795 SetFlag(kAllowUndefinedAsNaN);
1796 SetFlag(kUseGVN);
1797 }
1798 1889
1799 virtual Representation RequiredInputRepresentation(int index) { 1890 virtual Representation RequiredInputRepresentation(int index) {
1800 return Representation::None(); 1891 return Representation::None();
1801 } 1892 }
1802 1893
1803 DECLARE_CONCRETE_INSTRUCTION(ClampToUint8) 1894 DECLARE_CONCRETE_INSTRUCTION(ClampToUint8)
1804 1895
1805 protected: 1896 protected:
1806 virtual bool DataEquals(HValue* other) { return true; } 1897 virtual bool DataEquals(HValue* other) { return true; }
1807 1898
1808 private: 1899 private:
1900 explicit HClampToUint8(HValue* value)
1901 : HUnaryOperation(value) {
1902 set_representation(Representation::Integer32());
1903 SetFlag(kAllowUndefinedAsNaN);
1904 SetFlag(kUseGVN);
1905 }
1906
1809 virtual bool IsDeletable() const { return true; } 1907 virtual bool IsDeletable() const { return true; }
1810 }; 1908 };
1811 1909
1812 1910
1813 enum RemovableSimulate { 1911 enum RemovableSimulate {
1814 REMOVABLE_SIMULATE, 1912 REMOVABLE_SIMULATE,
1815 FIXED_SIMULATE 1913 FIXED_SIMULATE
1816 }; 1914 };
1817 1915
1818 1916
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after
1955 }; 2053 };
1956 2054
1957 2055
1958 class HStackCheck: public HTemplateInstruction<1> { 2056 class HStackCheck: public HTemplateInstruction<1> {
1959 public: 2057 public:
1960 enum Type { 2058 enum Type {
1961 kFunctionEntry, 2059 kFunctionEntry,
1962 kBackwardsBranch 2060 kBackwardsBranch
1963 }; 2061 };
1964 2062
1965 HStackCheck(HValue* context, Type type) : type_(type) { 2063 DECLARE_INSTRUCTION_FACTORY_P2(HStackCheck, HValue*, Type);
1966 SetOperandAt(0, context);
1967 SetGVNFlag(kChangesNewSpacePromotion);
1968 }
1969 2064
1970 HValue* context() { return OperandAt(0); } 2065 HValue* context() { return OperandAt(0); }
1971 2066
1972 virtual Representation RequiredInputRepresentation(int index) { 2067 virtual Representation RequiredInputRepresentation(int index) {
1973 return Representation::Tagged(); 2068 return Representation::Tagged();
1974 } 2069 }
1975 2070
1976 void Eliminate() { 2071 void Eliminate() {
1977 // The stack check eliminator might try to eliminate the same stack 2072 // The stack check eliminator might try to eliminate the same stack
1978 // check instruction multiple times. 2073 // check instruction multiple times.
1979 if (IsLinked()) { 2074 if (IsLinked()) {
1980 DeleteAndReplaceWith(NULL); 2075 DeleteAndReplaceWith(NULL);
1981 } 2076 }
1982 } 2077 }
1983 2078
1984 bool is_function_entry() { return type_ == kFunctionEntry; } 2079 bool is_function_entry() { return type_ == kFunctionEntry; }
1985 bool is_backwards_branch() { return type_ == kBackwardsBranch; } 2080 bool is_backwards_branch() { return type_ == kBackwardsBranch; }
1986 2081
1987 DECLARE_CONCRETE_INSTRUCTION(StackCheck) 2082 DECLARE_CONCRETE_INSTRUCTION(StackCheck)
1988 2083
1989 private: 2084 private:
2085 HStackCheck(HValue* context, Type type) : type_(type) {
2086 SetOperandAt(0, context);
2087 SetGVNFlag(kChangesNewSpacePromotion);
2088 }
2089
1990 Type type_; 2090 Type type_;
1991 }; 2091 };
1992 2092
1993 2093
1994 enum InliningKind { 2094 enum InliningKind {
1995 NORMAL_RETURN, // Normal function/method call and return. 2095 NORMAL_RETURN, // Normal function/method call and return.
1996 DROP_EXTRA_ON_RETURN, // Drop an extra value from the environment on return. 2096 DROP_EXTRA_ON_RETURN, // Drop an extra value from the environment on return.
1997 CONSTRUCT_CALL_RETURN, // Either use allocated receiver or return value. 2097 CONSTRUCT_CALL_RETURN, // Either use allocated receiver or return value.
1998 GETTER_CALL_RETURN, // Returning from a getter, need to restore context. 2098 GETTER_CALL_RETURN, // Returning from a getter, need to restore context.
1999 SETTER_CALL_RETURN // Use the RHS of the assignment as the return value. 2099 SETTER_CALL_RETURN // Use the RHS of the assignment as the return value.
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
2066 virtual Representation RequiredInputRepresentation(int index) { 2166 virtual Representation RequiredInputRepresentation(int index) {
2067 return Representation::None(); 2167 return Representation::None();
2068 } 2168 }
2069 2169
2070 DECLARE_CONCRETE_INSTRUCTION(LeaveInlined) 2170 DECLARE_CONCRETE_INSTRUCTION(LeaveInlined)
2071 }; 2171 };
2072 2172
2073 2173
2074 class HPushArgument: public HUnaryOperation { 2174 class HPushArgument: public HUnaryOperation {
2075 public: 2175 public:
2076 explicit HPushArgument(HValue* value) : HUnaryOperation(value) { 2176 DECLARE_INSTRUCTION_FACTORY_P1(HPushArgument, HValue*);
2077 set_representation(Representation::Tagged());
2078 }
2079 2177
2080 virtual Representation RequiredInputRepresentation(int index) { 2178 virtual Representation RequiredInputRepresentation(int index) {
2081 return Representation::Tagged(); 2179 return Representation::Tagged();
2082 } 2180 }
2083 2181
2084 HValue* argument() { return OperandAt(0); } 2182 HValue* argument() { return OperandAt(0); }
2085 2183
2086 DECLARE_CONCRETE_INSTRUCTION(PushArgument) 2184 DECLARE_CONCRETE_INSTRUCTION(PushArgument)
2185
2186 private:
2187 explicit HPushArgument(HValue* value) : HUnaryOperation(value) {
2188 set_representation(Representation::Tagged());
2189 }
2087 }; 2190 };
2088 2191
2089 2192
2090 class HThisFunction: public HTemplateInstruction<0> { 2193 class HThisFunction: public HTemplateInstruction<0> {
2091 public: 2194 public:
2092 HThisFunction() { 2195 HThisFunction() {
2093 set_representation(Representation::Tagged()); 2196 set_representation(Representation::Tagged());
2094 SetFlag(kUseGVN); 2197 SetFlag(kUseGVN);
2095 } 2198 }
2096 2199
2097 virtual Representation RequiredInputRepresentation(int index) { 2200 virtual Representation RequiredInputRepresentation(int index) {
2098 return Representation::None(); 2201 return Representation::None();
2099 } 2202 }
2100 2203
2101 DECLARE_CONCRETE_INSTRUCTION(ThisFunction) 2204 DECLARE_CONCRETE_INSTRUCTION(ThisFunction)
2102 2205
2103 protected: 2206 protected:
2104 virtual bool DataEquals(HValue* other) { return true; } 2207 virtual bool DataEquals(HValue* other) { return true; }
2105 2208
2106 private: 2209 private:
2107 virtual bool IsDeletable() const { return true; } 2210 virtual bool IsDeletable() const { return true; }
2108 }; 2211 };
2109 2212
2110 2213
2111 class HContext: public HTemplateInstruction<0> {
2112 public:
2113 HContext() {
2114 set_representation(Representation::Tagged());
2115 SetFlag(kUseGVN);
2116 }
2117
2118 virtual Representation RequiredInputRepresentation(int index) {
2119 return Representation::None();
2120 }
2121
2122 DECLARE_CONCRETE_INSTRUCTION(Context)
2123
2124 protected:
2125 virtual bool DataEquals(HValue* other) { return true; }
2126
2127 private:
2128 virtual bool IsDeletable() const { return true; }
2129 };
2130
2131
2132 class HOuterContext: public HUnaryOperation { 2214 class HOuterContext: public HUnaryOperation {
2133 public: 2215 public:
2134 explicit HOuterContext(HValue* inner) : HUnaryOperation(inner) { 2216 DECLARE_INSTRUCTION_FACTORY_P1(HOuterContext, HValue*);
2135 set_representation(Representation::Tagged());
2136 SetFlag(kUseGVN);
2137 }
2138 2217
2139 DECLARE_CONCRETE_INSTRUCTION(OuterContext); 2218 DECLARE_CONCRETE_INSTRUCTION(OuterContext);
2140 2219
2141 virtual Representation RequiredInputRepresentation(int index) { 2220 virtual Representation RequiredInputRepresentation(int index) {
2142 return Representation::Tagged(); 2221 return Representation::Tagged();
2143 } 2222 }
2144 2223
2145 protected: 2224 protected:
2146 virtual bool DataEquals(HValue* other) { return true; } 2225 virtual bool DataEquals(HValue* other) { return true; }
2147 2226
2148 private: 2227 private:
2228 explicit HOuterContext(HValue* inner) : HUnaryOperation(inner) {
2229 set_representation(Representation::Tagged());
2230 SetFlag(kUseGVN);
2231 }
2232
2149 virtual bool IsDeletable() const { return true; } 2233 virtual bool IsDeletable() const { return true; }
2150 }; 2234 };
2151 2235
2152 2236
2153 class HDeclareGlobals: public HUnaryOperation { 2237 class HDeclareGlobals: public HUnaryOperation {
2154 public: 2238 public:
2155 HDeclareGlobals(HValue* context, 2239 HDeclareGlobals(HValue* context,
2156 Handle<FixedArray> pairs, 2240 Handle<FixedArray> pairs,
2157 int flags) 2241 int flags)
2158 : HUnaryOperation(context), 2242 : HUnaryOperation(context),
2159 pairs_(pairs), 2243 pairs_(pairs),
2160 flags_(flags) { 2244 flags_(flags) {
2161 set_representation(Representation::Tagged()); 2245 set_representation(Representation::Tagged());
2162 SetAllSideEffects(); 2246 SetAllSideEffects();
2163 } 2247 }
2164 2248
2249 static HDeclareGlobals* New(Zone* zone,
2250 HValue* context,
2251 Handle<FixedArray> pairs,
2252 int flags) {
2253 return new(zone) HDeclareGlobals(context, pairs, flags);
2254 }
2255
2165 HValue* context() { return OperandAt(0); } 2256 HValue* context() { return OperandAt(0); }
2166 Handle<FixedArray> pairs() const { return pairs_; } 2257 Handle<FixedArray> pairs() const { return pairs_; }
2167 int flags() const { return flags_; } 2258 int flags() const { return flags_; }
2168 2259
2169 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals) 2260 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals)
2170 2261
2171 virtual Representation RequiredInputRepresentation(int index) { 2262 virtual Representation RequiredInputRepresentation(int index) {
2172 return Representation::Tagged(); 2263 return Representation::Tagged();
2173 } 2264 }
2265
2174 private: 2266 private:
2175 Handle<FixedArray> pairs_; 2267 Handle<FixedArray> pairs_;
2176 int flags_; 2268 int flags_;
2177 }; 2269 };
2178 2270
2179 2271
2180 class HGlobalObject: public HUnaryOperation { 2272 class HGlobalObject: public HUnaryOperation {
2181 public: 2273 public:
2182 explicit HGlobalObject(HValue* context) : HUnaryOperation(context) { 2274 explicit HGlobalObject(HValue* context) : HUnaryOperation(context) {
2183 set_representation(Representation::Tagged()); 2275 set_representation(Representation::Tagged());
2184 SetFlag(kUseGVN); 2276 SetFlag(kUseGVN);
2185 } 2277 }
2186 2278
2279 static HGlobalObject* New(Zone* zone, HValue* context) {
2280 return new(zone) HGlobalObject(context);
2281 }
2282
2187 DECLARE_CONCRETE_INSTRUCTION(GlobalObject) 2283 DECLARE_CONCRETE_INSTRUCTION(GlobalObject)
2188 2284
2189 virtual Representation RequiredInputRepresentation(int index) { 2285 virtual Representation RequiredInputRepresentation(int index) {
2190 return Representation::Tagged(); 2286 return Representation::Tagged();
2191 } 2287 }
2192 2288
2193 protected: 2289 protected:
2194 virtual bool DataEquals(HValue* other) { return true; } 2290 virtual bool DataEquals(HValue* other) { return true; }
2195 2291
2196 private: 2292 private:
2197 virtual bool IsDeletable() const { return true; } 2293 virtual bool IsDeletable() const { return true; }
2198 }; 2294 };
2199 2295
2200 2296
2201 class HGlobalReceiver: public HUnaryOperation { 2297 class HGlobalReceiver: public HUnaryOperation {
2202 public: 2298 public:
2203 explicit HGlobalReceiver(HValue* global_object) 2299 DECLARE_INSTRUCTION_FACTORY_P1(HGlobalReceiver, HValue*);
2204 : HUnaryOperation(global_object) {
2205 set_representation(Representation::Tagged());
2206 SetFlag(kUseGVN);
2207 }
2208 2300
2209 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver) 2301 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver)
2210 2302
2211 virtual Representation RequiredInputRepresentation(int index) { 2303 virtual Representation RequiredInputRepresentation(int index) {
2212 return Representation::Tagged(); 2304 return Representation::Tagged();
2213 } 2305 }
2214 2306
2215 protected: 2307 protected:
2216 virtual bool DataEquals(HValue* other) { return true; } 2308 virtual bool DataEquals(HValue* other) { return true; }
2217 2309
2218 private: 2310 private:
2311 explicit HGlobalReceiver(HValue* global_object)
2312 : HUnaryOperation(global_object) {
2313 set_representation(Representation::Tagged());
2314 SetFlag(kUseGVN);
2315 }
2316
2219 virtual bool IsDeletable() const { return true; } 2317 virtual bool IsDeletable() const { return true; }
2220 }; 2318 };
2221 2319
2222 2320
2223 template <int V> 2321 template <int V>
2224 class HCall: public HTemplateInstruction<V> { 2322 class HCall: public HTemplateInstruction<V> {
2225 public: 2323 public:
2226 // The argument count includes the receiver. 2324 // The argument count includes the receiver.
2227 explicit HCall<V>(int argument_count) : argument_count_(argument_count) { 2325 explicit HCall<V>(int argument_count) : argument_count_(argument_count) {
2228 this->set_representation(Representation::Tagged()); 2326 this->set_representation(Representation::Tagged());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 HValue* second() { return OperandAt(1); } 2373 HValue* second() { return OperandAt(1); }
2276 }; 2374 };
2277 2375
2278 2376
2279 class HInvokeFunction: public HBinaryCall { 2377 class HInvokeFunction: public HBinaryCall {
2280 public: 2378 public:
2281 HInvokeFunction(HValue* context, HValue* function, int argument_count) 2379 HInvokeFunction(HValue* context, HValue* function, int argument_count)
2282 : HBinaryCall(context, function, argument_count) { 2380 : HBinaryCall(context, function, argument_count) {
2283 } 2381 }
2284 2382
2383 static HInvokeFunction* New(Zone* zone,
2384 HValue* context,
2385 HValue* function,
2386 int argument_count) {
2387 return new(zone) HInvokeFunction(context, function, argument_count);
2388 }
2389
2285 HInvokeFunction(HValue* context, 2390 HInvokeFunction(HValue* context,
2286 HValue* function, 2391 HValue* function,
2287 Handle<JSFunction> known_function, 2392 Handle<JSFunction> known_function,
2288 int argument_count) 2393 int argument_count)
2289 : HBinaryCall(context, function, argument_count), 2394 : HBinaryCall(context, function, argument_count),
2290 known_function_(known_function) { 2395 known_function_(known_function) {
2291 formal_parameter_count_ = known_function.is_null() 2396 formal_parameter_count_ = known_function.is_null()
2292 ? 0 : known_function->shared()->formal_parameter_count(); 2397 ? 0 : known_function->shared()->formal_parameter_count();
2293 } 2398 }
2294 2399
2400 static HInvokeFunction* New(Zone* zone,
2401 HValue* context,
2402 HValue* function,
2403 Handle<JSFunction> known_function,
2404 int argument_count) {
2405 return new(zone) HInvokeFunction(context, function,
2406 known_function, argument_count);
2407 }
2408
2295 virtual Representation RequiredInputRepresentation(int index) { 2409 virtual Representation RequiredInputRepresentation(int index) {
2296 return Representation::Tagged(); 2410 return Representation::Tagged();
2297 } 2411 }
2298 2412
2299 HValue* context() { return first(); } 2413 HValue* context() { return first(); }
2300 HValue* function() { return second(); } 2414 HValue* function() { return second(); }
2301 Handle<JSFunction> known_function() { return known_function_; } 2415 Handle<JSFunction> known_function() { return known_function_; }
2302 int formal_parameter_count() const { return formal_parameter_count_; } 2416 int formal_parameter_count() const { return formal_parameter_count_; }
2303 2417
2304 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction) 2418 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 Handle<String> name_; 2490 Handle<String> name_;
2377 }; 2491 };
2378 2492
2379 2493
2380 class HCallFunction: public HBinaryCall { 2494 class HCallFunction: public HBinaryCall {
2381 public: 2495 public:
2382 HCallFunction(HValue* context, HValue* function, int argument_count) 2496 HCallFunction(HValue* context, HValue* function, int argument_count)
2383 : HBinaryCall(context, function, argument_count) { 2497 : HBinaryCall(context, function, argument_count) {
2384 } 2498 }
2385 2499
2500 static HCallFunction* New(Zone* zone,
2501 HValue* context,
2502 HValue* function,
2503 int argument_count) {
2504 return new(zone) HCallFunction(context, function, argument_count);
2505 }
2506
2386 HValue* context() { return first(); } 2507 HValue* context() { return first(); }
2387 HValue* function() { return second(); } 2508 HValue* function() { return second(); }
2388 2509
2389 virtual Representation RequiredInputRepresentation(int index) { 2510 virtual Representation RequiredInputRepresentation(int index) {
2390 return Representation::Tagged(); 2511 return Representation::Tagged();
2391 } 2512 }
2392 2513
2393 DECLARE_CONCRETE_INSTRUCTION(CallFunction) 2514 DECLARE_CONCRETE_INSTRUCTION(CallFunction)
2394 }; 2515 };
2395 2516
2396 2517
2397 class HCallGlobal: public HUnaryCall { 2518 class HCallGlobal: public HUnaryCall {
2398 public: 2519 public:
2399 HCallGlobal(HValue* context, Handle<String> name, int argument_count) 2520 HCallGlobal(HValue* context, Handle<String> name, int argument_count)
2400 : HUnaryCall(context, argument_count), name_(name) { 2521 : HUnaryCall(context, argument_count), name_(name) {
2401 } 2522 }
2402 2523
2524 static HCallGlobal* New(Zone* zone,
2525 HValue* context,
2526 Handle<String> name,
2527 int argument_count) {
2528 return new(zone) HCallGlobal(context, name, argument_count);
2529 }
2530
2403 virtual void PrintDataTo(StringStream* stream); 2531 virtual void PrintDataTo(StringStream* stream);
2404 2532
2405 HValue* context() { return value(); } 2533 HValue* context() { return value(); }
2406 Handle<String> name() const { return name_; } 2534 Handle<String> name() const { return name_; }
2407 2535
2408 virtual Representation RequiredInputRepresentation(int index) { 2536 virtual Representation RequiredInputRepresentation(int index) {
2409 return Representation::Tagged(); 2537 return Representation::Tagged();
2410 } 2538 }
2411 2539
2412 DECLARE_CONCRETE_INSTRUCTION(CallGlobal) 2540 DECLARE_CONCRETE_INSTRUCTION(CallGlobal)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 DECLARE_CONCRETE_INSTRUCTION(CallNewArray) 2604 DECLARE_CONCRETE_INSTRUCTION(CallNewArray)
2477 2605
2478 private: 2606 private:
2479 ElementsKind elements_kind_; 2607 ElementsKind elements_kind_;
2480 Handle<Cell> type_cell_; 2608 Handle<Cell> type_cell_;
2481 }; 2609 };
2482 2610
2483 2611
2484 class HCallRuntime: public HCall<1> { 2612 class HCallRuntime: public HCall<1> {
2485 public: 2613 public:
2486 HCallRuntime(HValue* context, 2614 static HCallRuntime* New(Zone* zone,
2487 Handle<String> name, 2615 HValue* context,
2488 const Runtime::Function* c_function, 2616 Handle<String> name,
2489 int argument_count) 2617 const Runtime::Function* c_function,
2490 : HCall<1>(argument_count), c_function_(c_function), name_(name) { 2618 int argument_count) {
2491 SetOperandAt(0, context); 2619 return new(zone) HCallRuntime(context, name, c_function, argument_count);
2492 } 2620 }
2493 2621
2494 virtual void PrintDataTo(StringStream* stream); 2622 virtual void PrintDataTo(StringStream* stream);
2495 2623
2496 HValue* context() { return OperandAt(0); } 2624 HValue* context() { return OperandAt(0); }
2497 const Runtime::Function* function() const { return c_function_; } 2625 const Runtime::Function* function() const { return c_function_; }
2498 Handle<String> name() const { return name_; } 2626 Handle<String> name() const { return name_; }
2499 2627
2500 virtual Representation RequiredInputRepresentation(int index) { 2628 virtual Representation RequiredInputRepresentation(int index) {
2501 return Representation::Tagged(); 2629 return Representation::Tagged();
2502 } 2630 }
2503 2631
2504 DECLARE_CONCRETE_INSTRUCTION(CallRuntime) 2632 DECLARE_CONCRETE_INSTRUCTION(CallRuntime)
2505 2633
2506 private: 2634 private:
2635 HCallRuntime(HValue* context,
2636 Handle<String> name,
2637 const Runtime::Function* c_function,
2638 int argument_count)
2639 : HCall<1>(argument_count), c_function_(c_function), name_(name) {
2640 SetOperandAt(0, context);
2641 }
2642
2507 const Runtime::Function* c_function_; 2643 const Runtime::Function* c_function_;
2508 Handle<String> name_; 2644 Handle<String> name_;
2509 }; 2645 };
2510 2646
2511 2647
2512 class HMapEnumLength: public HUnaryOperation { 2648 class HMapEnumLength: public HUnaryOperation {
2513 public: 2649 public:
2514 explicit HMapEnumLength(HValue* value) 2650 DECLARE_INSTRUCTION_FACTORY_P1(HMapEnumLength, HValue*);
2515 : HUnaryOperation(value, HType::Smi()) {
2516 set_representation(Representation::Smi());
2517 SetFlag(kUseGVN);
2518 SetGVNFlag(kDependsOnMaps);
2519 }
2520 2651
2521 virtual Representation RequiredInputRepresentation(int index) { 2652 virtual Representation RequiredInputRepresentation(int index) {
2522 return Representation::Tagged(); 2653 return Representation::Tagged();
2523 } 2654 }
2524 2655
2525 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength) 2656 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength)
2526 2657
2527 protected: 2658 protected:
2528 virtual bool DataEquals(HValue* other) { return true; } 2659 virtual bool DataEquals(HValue* other) { return true; }
2529 2660
2530 private: 2661 private:
2662 explicit HMapEnumLength(HValue* value)
2663 : HUnaryOperation(value, HType::Smi()) {
2664 set_representation(Representation::Smi());
2665 SetFlag(kUseGVN);
2666 SetGVNFlag(kDependsOnMaps);
2667 }
2668
2531 virtual bool IsDeletable() const { return true; } 2669 virtual bool IsDeletable() const { return true; }
2532 }; 2670 };
2533 2671
2534 2672
2535 class HElementsKind: public HUnaryOperation { 2673 class HElementsKind: public HUnaryOperation {
2536 public: 2674 public:
2537 explicit HElementsKind(HValue* value) : HUnaryOperation(value) { 2675 explicit HElementsKind(HValue* value) : HUnaryOperation(value) {
2538 set_representation(Representation::Integer32()); 2676 set_representation(Representation::Integer32());
2539 SetFlag(kUseGVN); 2677 SetFlag(kUseGVN);
2540 SetGVNFlag(kDependsOnElementsKind); 2678 SetGVNFlag(kDependsOnElementsKind);
2541 } 2679 }
2542 2680
2543 virtual Representation RequiredInputRepresentation(int index) { 2681 virtual Representation RequiredInputRepresentation(int index) {
2544 return Representation::Tagged(); 2682 return Representation::Tagged();
2545 } 2683 }
2546 2684
2547 DECLARE_CONCRETE_INSTRUCTION(ElementsKind) 2685 DECLARE_CONCRETE_INSTRUCTION(ElementsKind)
2548 2686
2549 protected: 2687 protected:
2550 virtual bool DataEquals(HValue* other) { return true; } 2688 virtual bool DataEquals(HValue* other) { return true; }
2551 2689
2552 private: 2690 private:
2553 virtual bool IsDeletable() const { return true; } 2691 virtual bool IsDeletable() const { return true; }
2554 }; 2692 };
2555 2693
2556 2694
2557 class HBitNot: public HUnaryOperation { 2695 class HBitNot: public HUnaryOperation {
2558 public: 2696 public:
2559 explicit HBitNot(HValue* value) 2697 DECLARE_INSTRUCTION_FACTORY_P1(HBitNot, HValue*);
2560 : HUnaryOperation(value, HType::TaggedNumber()) {
2561 set_representation(Representation::Integer32());
2562 SetFlag(kUseGVN);
2563 SetFlag(kTruncatingToInt32);
2564 SetFlag(kAllowUndefinedAsNaN);
2565 }
2566 2698
2567 virtual Representation RequiredInputRepresentation(int index) { 2699 virtual Representation RequiredInputRepresentation(int index) {
2568 return Representation::Integer32(); 2700 return Representation::Integer32();
2569 } 2701 }
2570 virtual Representation observed_input_representation(int index) { 2702 virtual Representation observed_input_representation(int index) {
2571 return Representation::Integer32(); 2703 return Representation::Integer32();
2572 } 2704 }
2573 2705
2574 virtual HValue* Canonicalize(); 2706 virtual HValue* Canonicalize();
2575 2707
2576 DECLARE_CONCRETE_INSTRUCTION(BitNot) 2708 DECLARE_CONCRETE_INSTRUCTION(BitNot)
2577 2709
2578 protected: 2710 protected:
2579 virtual bool DataEquals(HValue* other) { return true; } 2711 virtual bool DataEquals(HValue* other) { return true; }
2580 2712
2581 private: 2713 private:
2714 explicit HBitNot(HValue* value)
2715 : HUnaryOperation(value, HType::TaggedNumber()) {
2716 set_representation(Representation::Integer32());
2717 SetFlag(kUseGVN);
2718 SetFlag(kTruncatingToInt32);
2719 SetFlag(kAllowUndefinedAsNaN);
2720 }
2721
2582 virtual bool IsDeletable() const { return true; } 2722 virtual bool IsDeletable() const { return true; }
2583 }; 2723 };
2584 2724
2585 2725
2586 class HUnaryMathOperation: public HTemplateInstruction<2> { 2726 class HUnaryMathOperation: public HTemplateInstruction<2> {
2587 public: 2727 public:
2588 static HInstruction* New(Zone* zone, 2728 static HInstruction* New(Zone* zone,
2589 HValue* context, 2729 HValue* context,
2590 HValue* value, 2730 HValue* value,
2591 BuiltinFunctionId op); 2731 BuiltinFunctionId op);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2676 } 2816 }
2677 2817
2678 virtual bool IsDeletable() const { return true; } 2818 virtual bool IsDeletable() const { return true; }
2679 2819
2680 BuiltinFunctionId op_; 2820 BuiltinFunctionId op_;
2681 }; 2821 };
2682 2822
2683 2823
2684 class HLoadExternalArrayPointer: public HUnaryOperation { 2824 class HLoadExternalArrayPointer: public HUnaryOperation {
2685 public: 2825 public:
2686 explicit HLoadExternalArrayPointer(HValue* value) 2826 DECLARE_INSTRUCTION_FACTORY_P1(HLoadExternalArrayPointer, HValue*);
2687 : HUnaryOperation(value) {
2688 set_representation(Representation::External());
2689 // The result of this instruction is idempotent as long as its inputs don't
2690 // change. The external array of a specialized array elements object cannot
2691 // change once set, so it's no necessary to introduce any additional
2692 // dependencies on top of the inputs.
2693 SetFlag(kUseGVN);
2694 }
2695 2827
2696 virtual Representation RequiredInputRepresentation(int index) { 2828 virtual Representation RequiredInputRepresentation(int index) {
2697 return Representation::Tagged(); 2829 return Representation::Tagged();
2698 } 2830 }
2699 2831
2700 virtual HType CalculateInferredType() { 2832 virtual HType CalculateInferredType() {
2701 return HType::None(); 2833 return HType::None();
2702 } 2834 }
2703 2835
2704 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer) 2836 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer)
2705 2837
2706 protected: 2838 protected:
2707 virtual bool DataEquals(HValue* other) { return true; } 2839 virtual bool DataEquals(HValue* other) { return true; }
2708 2840
2709 private: 2841 private:
2842 explicit HLoadExternalArrayPointer(HValue* value)
2843 : HUnaryOperation(value) {
2844 set_representation(Representation::External());
2845 // The result of this instruction is idempotent as long as its inputs don't
2846 // change. The external array of a specialized array elements object cannot
2847 // change once set, so it's no necessary to introduce any additional
2848 // dependencies on top of the inputs.
2849 SetFlag(kUseGVN);
2850 }
2851
2710 virtual bool IsDeletable() const { return true; } 2852 virtual bool IsDeletable() const { return true; }
2711 }; 2853 };
2712 2854
2713 2855
2714 class HCheckMaps: public HTemplateInstruction<2> { 2856 class HCheckMaps: public HTemplateInstruction<2> {
2715 public: 2857 public:
2716 static HCheckMaps* New(HValue* value, Handle<Map> map, Zone* zone, 2858 static HCheckMaps* New(Zone* zone, HValue* context, HValue* value,
2717 CompilationInfo* info, HValue *typecheck = NULL); 2859 Handle<Map> map, CompilationInfo* info,
2718 static HCheckMaps* New(HValue* value, SmallMapList* maps, Zone* zone, 2860 HValue *typecheck = NULL);
2861 static HCheckMaps* New(Zone* zone, HValue* context,
2862 HValue* value, SmallMapList* maps,
2719 HValue *typecheck = NULL) { 2863 HValue *typecheck = NULL) {
2720 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); 2864 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck);
2721 for (int i = 0; i < maps->length(); i++) { 2865 for (int i = 0; i < maps->length(); i++) {
2722 check_map->map_set_.Add(maps->at(i), zone); 2866 check_map->map_set_.Add(maps->at(i), zone);
2723 } 2867 }
2724 check_map->map_set_.Sort(); 2868 check_map->map_set_.Sort();
2725 return check_map; 2869 return check_map;
2726 } 2870 }
2727 2871
2728 bool CanOmitMapChecks() { return omit_; } 2872 bool CanOmitMapChecks() { return omit_; }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2784 } 2928 }
2785 2929
2786 bool omit_; 2930 bool omit_;
2787 SmallMapList map_set_; 2931 SmallMapList map_set_;
2788 ZoneList<UniqueValueId> map_unique_ids_; 2932 ZoneList<UniqueValueId> map_unique_ids_;
2789 }; 2933 };
2790 2934
2791 2935
2792 class HCheckFunction: public HUnaryOperation { 2936 class HCheckFunction: public HUnaryOperation {
2793 public: 2937 public:
2794 HCheckFunction(HValue* value, Handle<JSFunction> function) 2938 DECLARE_INSTRUCTION_FACTORY_P2(HCheckFunction, HValue*, Handle<JSFunction>);
2795 : HUnaryOperation(value, value->type()),
2796 target_(function), target_unique_id_() {
2797 set_representation(Representation::Tagged());
2798 SetFlag(kUseGVN);
2799 target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function);
2800 }
2801 2939
2802 virtual Representation RequiredInputRepresentation(int index) { 2940 virtual Representation RequiredInputRepresentation(int index) {
2803 return Representation::Tagged(); 2941 return Representation::Tagged();
2804 } 2942 }
2805 virtual void PrintDataTo(StringStream* stream); 2943 virtual void PrintDataTo(StringStream* stream);
2806 2944
2807 virtual HValue* Canonicalize(); 2945 virtual HValue* Canonicalize();
2808 2946
2809 #ifdef DEBUG 2947 #ifdef DEBUG
2810 virtual void Verify(); 2948 virtual void Verify();
2811 #endif 2949 #endif
2812 2950
2813 virtual void FinalizeUniqueValueId() { 2951 virtual void FinalizeUniqueValueId() {
2814 target_unique_id_ = UniqueValueId(target_); 2952 target_unique_id_ = UniqueValueId(target_);
2815 } 2953 }
2816 2954
2817 Handle<JSFunction> target() const { return target_; } 2955 Handle<JSFunction> target() const { return target_; }
2818 bool target_in_new_space() const { return target_in_new_space_; } 2956 bool target_in_new_space() const { return target_in_new_space_; }
2819 2957
2820 DECLARE_CONCRETE_INSTRUCTION(CheckFunction) 2958 DECLARE_CONCRETE_INSTRUCTION(CheckFunction)
2821 2959
2822 protected: 2960 protected:
2823 virtual bool DataEquals(HValue* other) { 2961 virtual bool DataEquals(HValue* other) {
2824 HCheckFunction* b = HCheckFunction::cast(other); 2962 HCheckFunction* b = HCheckFunction::cast(other);
2825 return target_unique_id_ == b->target_unique_id_; 2963 return target_unique_id_ == b->target_unique_id_;
2826 } 2964 }
2827 2965
2828 private: 2966 private:
2967 HCheckFunction(HValue* value, Handle<JSFunction> function)
2968 : HUnaryOperation(value, value->type()),
2969 target_(function), target_unique_id_() {
2970 set_representation(Representation::Tagged());
2971 SetFlag(kUseGVN);
2972 target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function);
2973 }
2974
2829 Handle<JSFunction> target_; 2975 Handle<JSFunction> target_;
2830 UniqueValueId target_unique_id_; 2976 UniqueValueId target_unique_id_;
2831 bool target_in_new_space_; 2977 bool target_in_new_space_;
2832 }; 2978 };
2833 2979
2834 2980
2835 class HCheckInstanceType: public HUnaryOperation { 2981 class HCheckInstanceType: public HUnaryOperation {
2836 public: 2982 public:
2837 static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) { 2983 static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) {
2838 return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT); 2984 return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
2887 set_representation(Representation::Tagged()); 3033 set_representation(Representation::Tagged());
2888 SetFlag(kUseGVN); 3034 SetFlag(kUseGVN);
2889 } 3035 }
2890 3036
2891 const Check check_; 3037 const Check check_;
2892 }; 3038 };
2893 3039
2894 3040
2895 class HCheckSmi: public HUnaryOperation { 3041 class HCheckSmi: public HUnaryOperation {
2896 public: 3042 public:
2897 explicit HCheckSmi(HValue* value) : HUnaryOperation(value, HType::Smi()) { 3043 DECLARE_INSTRUCTION_FACTORY_P1(HCheckSmi, HValue*);
2898 set_representation(Representation::Smi());
2899 SetFlag(kUseGVN);
2900 }
2901 3044
2902 virtual Representation RequiredInputRepresentation(int index) { 3045 virtual Representation RequiredInputRepresentation(int index) {
2903 return Representation::Tagged(); 3046 return Representation::Tagged();
2904 } 3047 }
2905 3048
2906 virtual HValue* Canonicalize() { 3049 virtual HValue* Canonicalize() {
2907 HType value_type = value()->type(); 3050 HType value_type = value()->type();
2908 if (value_type.IsSmi()) { 3051 if (value_type.IsSmi()) {
2909 return NULL; 3052 return NULL;
2910 } 3053 }
2911 return this; 3054 return this;
2912 } 3055 }
2913 3056
2914 DECLARE_CONCRETE_INSTRUCTION(CheckSmi) 3057 DECLARE_CONCRETE_INSTRUCTION(CheckSmi)
2915 3058
2916 protected: 3059 protected:
2917 virtual bool DataEquals(HValue* other) { return true; } 3060 virtual bool DataEquals(HValue* other) { return true; }
3061
3062 private:
3063 explicit HCheckSmi(HValue* value) : HUnaryOperation(value, HType::Smi()) {
3064 set_representation(Representation::Smi());
3065 SetFlag(kUseGVN);
3066 }
2918 }; 3067 };
2919 3068
2920 3069
2921 class HIsNumberAndBranch: public HUnaryControlInstruction { 3070 class HIsNumberAndBranch: public HUnaryControlInstruction {
2922 public: 3071 public:
2923 explicit HIsNumberAndBranch(HValue* value) 3072 explicit HIsNumberAndBranch(HValue* value)
2924 : HUnaryControlInstruction(value, NULL, NULL) { 3073 : HUnaryControlInstruction(value, NULL, NULL) {
2925 SetFlag(kFlexibleRepresentation); 3074 SetFlag(kFlexibleRepresentation);
2926 } 3075 }
2927 3076
2928 virtual Representation RequiredInputRepresentation(int index) { 3077 virtual Representation RequiredInputRepresentation(int index) {
2929 return Representation::None(); 3078 return Representation::None();
2930 } 3079 }
2931 3080
2932 DECLARE_CONCRETE_INSTRUCTION(IsNumberAndBranch) 3081 DECLARE_CONCRETE_INSTRUCTION(IsNumberAndBranch)
2933 }; 3082 };
2934 3083
2935 3084
2936 class HCheckHeapObject: public HUnaryOperation { 3085 class HCheckHeapObject: public HUnaryOperation {
2937 public: 3086 public:
2938 explicit HCheckHeapObject(HValue* value) 3087 DECLARE_INSTRUCTION_FACTORY_P1(HCheckHeapObject, HValue*);
2939 : HUnaryOperation(value, HType::NonPrimitive()) {
2940 set_representation(Representation::Tagged());
2941 SetFlag(kUseGVN);
2942 }
2943 3088
2944 virtual Representation RequiredInputRepresentation(int index) { 3089 virtual Representation RequiredInputRepresentation(int index) {
2945 return Representation::Tagged(); 3090 return Representation::Tagged();
2946 } 3091 }
2947 3092
2948 #ifdef DEBUG 3093 #ifdef DEBUG
2949 virtual void Verify(); 3094 virtual void Verify();
2950 #endif 3095 #endif
2951 3096
2952 virtual HValue* Canonicalize() { 3097 virtual HValue* Canonicalize() {
2953 return value()->type().IsHeapObject() ? NULL : this; 3098 return value()->type().IsHeapObject() ? NULL : this;
2954 } 3099 }
2955 3100
2956 DECLARE_CONCRETE_INSTRUCTION(CheckHeapObject) 3101 DECLARE_CONCRETE_INSTRUCTION(CheckHeapObject)
2957 3102
2958 protected: 3103 protected:
2959 virtual bool DataEquals(HValue* other) { return true; } 3104 virtual bool DataEquals(HValue* other) { return true; }
3105
3106 private:
3107 explicit HCheckHeapObject(HValue* value)
3108 : HUnaryOperation(value, HType::NonPrimitive()) {
3109 set_representation(Representation::Tagged());
3110 SetFlag(kUseGVN);
3111 }
2960 }; 3112 };
2961 3113
2962 3114
2963 class HCheckPrototypeMaps: public HTemplateInstruction<0> { 3115 class HCheckPrototypeMaps: public HTemplateInstruction<0> {
2964 public: 3116 public:
2965 HCheckPrototypeMaps(Handle<JSObject> prototype, 3117 static HCheckPrototypeMaps* New(Zone* zone,
2966 Handle<JSObject> holder, 3118 HValue* context,
2967 Zone* zone, 3119 Handle<JSObject> prototype,
2968 CompilationInfo* info) 3120 Handle<JSObject> holder,
2969 : prototypes_(2, zone), 3121 CompilationInfo* info) {
2970 maps_(2, zone), 3122 return new(zone) HCheckPrototypeMaps(prototype, holder, zone, info);
2971 first_prototype_unique_id_(),
2972 last_prototype_unique_id_(),
2973 can_omit_prototype_maps_(true) {
2974 SetFlag(kUseGVN);
2975 SetGVNFlag(kDependsOnMaps);
2976 // Keep a list of all objects on the prototype chain up to the holder
2977 // and the expected maps.
2978 while (true) {
2979 prototypes_.Add(prototype, zone);
2980 Handle<Map> map(prototype->map());
2981 maps_.Add(map, zone);
2982 can_omit_prototype_maps_ &= map->CanOmitPrototypeChecks();
2983 if (prototype.is_identical_to(holder)) break;
2984 prototype = Handle<JSObject>(JSObject::cast(prototype->GetPrototype()));
2985 }
2986 if (can_omit_prototype_maps_) {
2987 // Mark in-flight compilation as dependent on those maps.
2988 for (int i = 0; i < maps()->length(); i++) {
2989 Handle<Map> map = maps()->at(i);
2990 map->AddDependentCompilationInfo(DependentCode::kPrototypeCheckGroup,
2991 info);
2992 }
2993 }
2994 } 3123 }
2995 3124
2996 ZoneList<Handle<JSObject> >* prototypes() { return &prototypes_; } 3125 ZoneList<Handle<JSObject> >* prototypes() { return &prototypes_; }
2997 3126
2998 ZoneList<Handle<Map> >* maps() { return &maps_; } 3127 ZoneList<Handle<Map> >* maps() { return &maps_; }
2999 3128
3000 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps) 3129 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps)
3001 3130
3002 virtual Representation RequiredInputRepresentation(int index) { 3131 virtual Representation RequiredInputRepresentation(int index) {
3003 return Representation::None(); 3132 return Representation::None();
(...skipping 14 matching lines...) Expand all
3018 bool CanOmitPrototypeChecks() { return can_omit_prototype_maps_; } 3147 bool CanOmitPrototypeChecks() { return can_omit_prototype_maps_; }
3019 3148
3020 protected: 3149 protected:
3021 virtual bool DataEquals(HValue* other) { 3150 virtual bool DataEquals(HValue* other) {
3022 HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other); 3151 HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other);
3023 return first_prototype_unique_id_ == b->first_prototype_unique_id_ && 3152 return first_prototype_unique_id_ == b->first_prototype_unique_id_ &&
3024 last_prototype_unique_id_ == b->last_prototype_unique_id_; 3153 last_prototype_unique_id_ == b->last_prototype_unique_id_;
3025 } 3154 }
3026 3155
3027 private: 3156 private:
3157 HCheckPrototypeMaps(Handle<JSObject> prototype,
3158 Handle<JSObject> holder,
3159 Zone* zone,
3160 CompilationInfo* info)
3161 : prototypes_(2, zone),
3162 maps_(2, zone),
3163 first_prototype_unique_id_(),
3164 last_prototype_unique_id_(),
3165 can_omit_prototype_maps_(true) {
3166 SetFlag(kUseGVN);
3167 SetGVNFlag(kDependsOnMaps);
3168 // Keep a list of all objects on the prototype chain up to the holder
3169 // and the expected maps.
3170 while (true) {
3171 prototypes_.Add(prototype, zone);
3172 Handle<Map> map(prototype->map());
3173 maps_.Add(map, zone);
3174 can_omit_prototype_maps_ &= map->CanOmitPrototypeChecks();
3175 if (prototype.is_identical_to(holder)) break;
3176 prototype = Handle<JSObject>(JSObject::cast(prototype->GetPrototype()));
3177 }
3178 if (can_omit_prototype_maps_) {
3179 // Mark in-flight compilation as dependent on those maps.
3180 for (int i = 0; i < maps()->length(); i++) {
3181 Handle<Map> map = maps()->at(i);
3182 map->AddDependentCompilationInfo(DependentCode::kPrototypeCheckGroup,
3183 info);
3184 }
3185 }
3186 }
3187
3028 ZoneList<Handle<JSObject> > prototypes_; 3188 ZoneList<Handle<JSObject> > prototypes_;
3029 ZoneList<Handle<Map> > maps_; 3189 ZoneList<Handle<Map> > maps_;
3030 UniqueValueId first_prototype_unique_id_; 3190 UniqueValueId first_prototype_unique_id_;
3031 UniqueValueId last_prototype_unique_id_; 3191 UniqueValueId last_prototype_unique_id_;
3032 bool can_omit_prototype_maps_; 3192 bool can_omit_prototype_maps_;
3033 }; 3193 };
3034 3194
3035 3195
3036 class InductionVariableData; 3196 class InductionVariableData;
3037 3197
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after
3419 // the operand can change if a new idef of the phi is added between the phi 3579 // the operand can change if a new idef of the phi is added between the phi
3420 // and this instruction (inserting an idef updates every use). 3580 // and this instruction (inserting an idef updates every use).
3421 HPhi* phi_; 3581 HPhi* phi_;
3422 NumericRelation relation_; 3582 NumericRelation relation_;
3423 int operand_index_; 3583 int operand_index_;
3424 }; 3584 };
3425 3585
3426 3586
3427 class HArgumentsObject: public HTemplateInstruction<0> { 3587 class HArgumentsObject: public HTemplateInstruction<0> {
3428 public: 3588 public:
3429 HArgumentsObject(int count, Zone* zone) : values_(count, zone) { 3589 static HArgumentsObject* New(Zone* zone,
3430 set_representation(Representation::Tagged()); 3590 HValue* context,
3431 SetFlag(kIsArguments); 3591 int count) {
3592 return new(zone) HArgumentsObject(count, zone);
3432 } 3593 }
3433 3594
3434 const ZoneList<HValue*>* arguments_values() const { return &values_; } 3595 const ZoneList<HValue*>* arguments_values() const { return &values_; }
3435 int arguments_count() const { return values_.length(); } 3596 int arguments_count() const { return values_.length(); }
3436 3597
3437 void AddArgument(HValue* argument, Zone* zone) { 3598 void AddArgument(HValue* argument, Zone* zone) {
3438 values_.Add(NULL, zone); // Resize list. 3599 values_.Add(NULL, zone); // Resize list.
3439 SetOperandAt(values_.length() - 1, argument); 3600 SetOperandAt(values_.length() - 1, argument);
3440 } 3601 }
3441 3602
3442 virtual int OperandCount() { return values_.length(); } 3603 virtual int OperandCount() { return values_.length(); }
3443 virtual HValue* OperandAt(int index) const { return values_[index]; } 3604 virtual HValue* OperandAt(int index) const { return values_[index]; }
3444 3605
3445 virtual bool HasEscapingOperandAt(int index) { return false; } 3606 virtual bool HasEscapingOperandAt(int index) { return false; }
3446 virtual Representation RequiredInputRepresentation(int index) { 3607 virtual Representation RequiredInputRepresentation(int index) {
3447 return Representation::None(); 3608 return Representation::None();
3448 } 3609 }
3449 3610
3450 DECLARE_CONCRETE_INSTRUCTION(ArgumentsObject) 3611 DECLARE_CONCRETE_INSTRUCTION(ArgumentsObject)
3451 3612
3452 protected: 3613 protected:
3453 virtual void InternalSetOperandAt(int index, HValue* value) { 3614 virtual void InternalSetOperandAt(int index, HValue* value) {
3454 values_[index] = value; 3615 values_[index] = value;
3455 } 3616 }
3456 3617
3457 private: 3618 private:
3619 HArgumentsObject(int count, Zone* zone) : values_(count, zone) {
3620 set_representation(Representation::Tagged());
3621 SetFlag(kIsArguments);
3622 }
3623
3458 virtual bool IsDeletable() const { return true; } 3624 virtual bool IsDeletable() const { return true; }
3459 3625
3460 ZoneList<HValue*> values_; 3626 ZoneList<HValue*> values_;
3461 }; 3627 };
3462 3628
3463 3629
3464 class HConstant: public HTemplateInstruction<0> { 3630 class HConstant: public HTemplateInstruction<0> {
3465 public: 3631 public:
3466 HConstant(Handle<Object> handle, Representation r = Representation::None()); 3632 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, int32_t);
3467 HConstant(int32_t value, 3633 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, double);
3468 Representation r = Representation::None(), 3634 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Handle<Object>);
3469 bool is_not_in_new_space = true, 3635 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, ExternalReference);
3470 Handle<Object> optional_handle = Handle<Object>::null());
3471 HConstant(double value,
3472 Representation r = Representation::None(),
3473 bool is_not_in_new_space = true,
3474 Handle<Object> optional_handle = Handle<Object>::null());
3475 HConstant(Handle<Object> handle,
3476 UniqueValueId unique_id,
3477 Representation r,
3478 HType type,
3479 bool is_internalized_string,
3480 bool is_not_in_new_space,
3481 bool is_cell,
3482 bool boolean_value);
3483 explicit HConstant(ExternalReference reference);
3484 3636
3485 Handle<Object> handle() { 3637 Handle<Object> handle() {
3486 if (handle_.is_null()) { 3638 if (handle_.is_null()) {
3487 Factory* factory = Isolate::Current()->factory(); 3639 Factory* factory = Isolate::Current()->factory();
3488 // Default arguments to is_not_in_new_space depend on this heap number 3640 // Default arguments to is_not_in_new_space depend on this heap number
3489 // to be tenured so that it's guaranteed not be be located in new space. 3641 // to be tenured so that it's guaranteed not be be located in new space.
3490 handle_ = factory->NewNumber(double_value_, TENURED); 3642 handle_ = factory->NewNumber(double_value_, TENURED);
3491 } 3643 }
3492 AllowDeferredHandleDereference smi_check; 3644 AllowDeferredHandleDereference smi_check;
3493 ASSERT(has_int32_value_ || !handle_->IsSmi()); 3645 ASSERT(has_int32_value_ || !handle_->IsSmi());
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
3654 external_reference_value_ == 3806 external_reference_value_ ==
3655 other_constant->external_reference_value_; 3807 other_constant->external_reference_value_;
3656 } else { 3808 } else {
3657 ASSERT(!handle_.is_null()); 3809 ASSERT(!handle_.is_null());
3658 return !other_constant->handle_.is_null() && 3810 return !other_constant->handle_.is_null() &&
3659 unique_id_ == other_constant->unique_id_; 3811 unique_id_ == other_constant->unique_id_;
3660 } 3812 }
3661 } 3813 }
3662 3814
3663 private: 3815 private:
3816 friend class HGraph;
3817 HConstant(Handle<Object> handle, Representation r = Representation::None());
3818 HConstant(int32_t value,
3819 Representation r = Representation::None(),
3820 bool is_not_in_new_space = true,
3821 Handle<Object> optional_handle = Handle<Object>::null());
3822 HConstant(double value,
3823 Representation r = Representation::None(),
3824 bool is_not_in_new_space = true,
3825 Handle<Object> optional_handle = Handle<Object>::null());
3826 HConstant(Handle<Object> handle,
3827 UniqueValueId unique_id,
3828 Representation r,
3829 HType type,
3830 bool is_internalized_string,
3831 bool is_not_in_new_space,
3832 bool is_cell,
3833 bool boolean_value);
3834 explicit HConstant(ExternalReference reference);
3835
3664 void Initialize(Representation r); 3836 void Initialize(Representation r);
3665 3837
3666 virtual bool IsDeletable() const { return true; } 3838 virtual bool IsDeletable() const { return true; }
3667 3839
3668 // If this is a numerical constant, handle_ either points to to the 3840 // If this is a numerical constant, handle_ either points to to the
3669 // HeapObject the constant originated from or is null. If the 3841 // HeapObject the constant originated from or is null. If the
3670 // constant is non-numeric, handle_ always points to a valid 3842 // constant is non-numeric, handle_ always points to a valid
3671 // constant HeapObject. 3843 // constant HeapObject.
3672 Handle<Object> handle_; 3844 Handle<Object> handle_;
3673 UniqueValueId unique_id_; 3845 UniqueValueId unique_id_;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3773 private: 3945 private:
3774 bool IgnoreObservedOutputRepresentation(Representation current_rep); 3946 bool IgnoreObservedOutputRepresentation(Representation current_rep);
3775 3947
3776 Representation observed_input_representation_[2]; 3948 Representation observed_input_representation_[2];
3777 Representation observed_output_representation_; 3949 Representation observed_output_representation_;
3778 }; 3950 };
3779 3951
3780 3952
3781 class HWrapReceiver: public HTemplateInstruction<2> { 3953 class HWrapReceiver: public HTemplateInstruction<2> {
3782 public: 3954 public:
3783 HWrapReceiver(HValue* receiver, HValue* function) { 3955 DECLARE_INSTRUCTION_FACTORY_P2(HWrapReceiver, HValue*, HValue*);
3784 set_representation(Representation::Tagged());
3785 SetOperandAt(0, receiver);
3786 SetOperandAt(1, function);
3787 }
3788 3956
3789 virtual Representation RequiredInputRepresentation(int index) { 3957 virtual Representation RequiredInputRepresentation(int index) {
3790 return Representation::Tagged(); 3958 return Representation::Tagged();
3791 } 3959 }
3792 3960
3793 HValue* receiver() { return OperandAt(0); } 3961 HValue* receiver() { return OperandAt(0); }
3794 HValue* function() { return OperandAt(1); } 3962 HValue* function() { return OperandAt(1); }
3795 3963
3796 virtual HValue* Canonicalize(); 3964 virtual HValue* Canonicalize();
3797 3965
3798 virtual void PrintDataTo(StringStream* stream); 3966 virtual void PrintDataTo(StringStream* stream);
3799 3967
3800 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver) 3968 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver)
3969
3970 private:
3971 HWrapReceiver(HValue* receiver, HValue* function) {
3972 set_representation(Representation::Tagged());
3973 SetOperandAt(0, receiver);
3974 SetOperandAt(1, function);
3975 }
3801 }; 3976 };
3802 3977
3803 3978
3804 class HApplyArguments: public HTemplateInstruction<4> { 3979 class HApplyArguments: public HTemplateInstruction<4> {
3805 public: 3980 public:
3806 HApplyArguments(HValue* function, 3981 HApplyArguments(HValue* function,
3807 HValue* receiver, 3982 HValue* receiver,
3808 HValue* length, 3983 HValue* length,
3809 HValue* elements) { 3984 HValue* elements) {
3810 set_representation(Representation::Tagged()); 3985 set_representation(Representation::Tagged());
(...skipping 15 matching lines...) Expand all
3826 HValue* receiver() { return OperandAt(1); } 4001 HValue* receiver() { return OperandAt(1); }
3827 HValue* length() { return OperandAt(2); } 4002 HValue* length() { return OperandAt(2); }
3828 HValue* elements() { return OperandAt(3); } 4003 HValue* elements() { return OperandAt(3); }
3829 4004
3830 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments) 4005 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments)
3831 }; 4006 };
3832 4007
3833 4008
3834 class HArgumentsElements: public HTemplateInstruction<0> { 4009 class HArgumentsElements: public HTemplateInstruction<0> {
3835 public: 4010 public:
3836 explicit HArgumentsElements(bool from_inlined) : from_inlined_(from_inlined) { 4011 DECLARE_INSTRUCTION_FACTORY_P1(HArgumentsElements, bool);
3837 // The value produced by this instruction is a pointer into the stack
3838 // that looks as if it was a smi because of alignment.
3839 set_representation(Representation::Tagged());
3840 SetFlag(kUseGVN);
3841 }
3842 4012
3843 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements) 4013 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements)
3844 4014
3845 virtual Representation RequiredInputRepresentation(int index) { 4015 virtual Representation RequiredInputRepresentation(int index) {
3846 return Representation::None(); 4016 return Representation::None();
3847 } 4017 }
3848 4018
3849 bool from_inlined() const { return from_inlined_; } 4019 bool from_inlined() const { return from_inlined_; }
3850 4020
3851 protected: 4021 protected:
3852 virtual bool DataEquals(HValue* other) { return true; } 4022 virtual bool DataEquals(HValue* other) { return true; }
3853 4023
3854 private: 4024 private:
4025 explicit HArgumentsElements(bool from_inlined) : from_inlined_(from_inlined) {
4026 // The value produced by this instruction is a pointer into the stack
4027 // that looks as if it was a smi because of alignment.
4028 set_representation(Representation::Tagged());
4029 SetFlag(kUseGVN);
4030 }
4031
3855 virtual bool IsDeletable() const { return true; } 4032 virtual bool IsDeletable() const { return true; }
3856 4033
3857 bool from_inlined_; 4034 bool from_inlined_;
3858 }; 4035 };
3859 4036
3860 4037
3861 class HArgumentsLength: public HUnaryOperation { 4038 class HArgumentsLength: public HUnaryOperation {
3862 public: 4039 public:
3863 explicit HArgumentsLength(HValue* value) : HUnaryOperation(value) { 4040 DECLARE_INSTRUCTION_FACTORY_P1(HArgumentsLength, HValue*);
3864 set_representation(Representation::Integer32());
3865 SetFlag(kUseGVN);
3866 }
3867 4041
3868 virtual Representation RequiredInputRepresentation(int index) { 4042 virtual Representation RequiredInputRepresentation(int index) {
3869 return Representation::Tagged(); 4043 return Representation::Tagged();
3870 } 4044 }
3871 4045
3872 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength) 4046 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength)
3873 4047
3874 protected: 4048 protected:
3875 virtual bool DataEquals(HValue* other) { return true; } 4049 virtual bool DataEquals(HValue* other) { return true; }
3876 4050
3877 private: 4051 private:
4052 explicit HArgumentsLength(HValue* value) : HUnaryOperation(value) {
4053 set_representation(Representation::Integer32());
4054 SetFlag(kUseGVN);
4055 }
4056
3878 virtual bool IsDeletable() const { return true; } 4057 virtual bool IsDeletable() const { return true; }
3879 }; 4058 };
3880 4059
3881 4060
3882 class HAccessArgumentsAt: public HTemplateInstruction<3> { 4061 class HAccessArgumentsAt: public HTemplateInstruction<3> {
3883 public: 4062 public:
3884 HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) { 4063 HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) {
3885 set_representation(Representation::Tagged()); 4064 set_representation(Representation::Tagged());
3886 SetFlag(kUseGVN); 4065 SetFlag(kUseGVN);
3887 SetOperandAt(0, arguments); 4066 SetOperandAt(0, arguments);
(...skipping 18 matching lines...) Expand all
3906 4085
3907 virtual bool DataEquals(HValue* other) { return true; } 4086 virtual bool DataEquals(HValue* other) { return true; }
3908 }; 4087 };
3909 4088
3910 4089
3911 class HBoundsCheckBaseIndexInformation; 4090 class HBoundsCheckBaseIndexInformation;
3912 4091
3913 4092
3914 class HBoundsCheck: public HTemplateInstruction<2> { 4093 class HBoundsCheck: public HTemplateInstruction<2> {
3915 public: 4094 public:
3916 // Normally HBoundsCheck should be created using the 4095 DECLARE_INSTRUCTION_FACTORY_P2(HBoundsCheck, HValue*, HValue*);
3917 // HGraphBuilder::AddBoundsCheck() helper.
3918 // However when building stubs, where we know that the arguments are Int32,
3919 // it makes sense to invoke this constructor directly.
3920 HBoundsCheck(HValue* index, HValue* length)
3921 : skip_check_(false),
3922 base_(NULL), offset_(0), scale_(0),
3923 responsibility_direction_(DIRECTION_NONE),
3924 allow_equality_(false) {
3925 SetOperandAt(0, index);
3926 SetOperandAt(1, length);
3927 SetFlag(kFlexibleRepresentation);
3928 SetFlag(kUseGVN);
3929 }
3930 4096
3931 bool skip_check() const { return skip_check_; } 4097 bool skip_check() const { return skip_check_; }
3932 void set_skip_check() { skip_check_ = true; } 4098 void set_skip_check() { skip_check_ = true; }
4099
3933 HValue* base() { return base_; } 4100 HValue* base() { return base_; }
3934 int offset() { return offset_; } 4101 int offset() { return offset_; }
3935 int scale() { return scale_; } 4102 int scale() { return scale_; }
3936 bool index_can_increase() { 4103 bool index_can_increase() {
3937 return (responsibility_direction_ & DIRECTION_LOWER) == 0; 4104 return (responsibility_direction_ & DIRECTION_LOWER) == 0;
3938 } 4105 }
3939 bool index_can_decrease() { 4106 bool index_can_decrease() {
3940 return (responsibility_direction_ & DIRECTION_UPPER) == 0; 4107 return (responsibility_direction_ & DIRECTION_UPPER) == 0;
3941 } 4108 }
3942 4109
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3992 virtual bool DataEquals(HValue* other) { return true; } 4159 virtual bool DataEquals(HValue* other) { return true; }
3993 virtual void TryGuaranteeRangeChanging(RangeEvaluationContext* context); 4160 virtual void TryGuaranteeRangeChanging(RangeEvaluationContext* context);
3994 bool skip_check_; 4161 bool skip_check_;
3995 HValue* base_; 4162 HValue* base_;
3996 int offset_; 4163 int offset_;
3997 int scale_; 4164 int scale_;
3998 RangeGuaranteeDirection responsibility_direction_; 4165 RangeGuaranteeDirection responsibility_direction_;
3999 bool allow_equality_; 4166 bool allow_equality_;
4000 4167
4001 private: 4168 private:
4169 // Normally HBoundsCheck should be created using the
4170 // HGraphBuilder::AddBoundsCheck() helper.
4171 // However when building stubs, where we know that the arguments are Int32,
4172 // it makes sense to invoke this constructor directly.
4173 HBoundsCheck(HValue* index, HValue* length)
4174 : skip_check_(false),
4175 base_(NULL), offset_(0), scale_(0),
4176 responsibility_direction_(DIRECTION_NONE),
4177 allow_equality_(false) {
4178 SetOperandAt(0, index);
4179 SetOperandAt(1, length);
4180 SetFlag(kFlexibleRepresentation);
4181 SetFlag(kUseGVN);
4182 }
4183
4002 virtual bool IsDeletable() const { 4184 virtual bool IsDeletable() const {
4003 return skip_check() && !FLAG_debug_code; 4185 return skip_check() && !FLAG_debug_code;
4004 } 4186 }
4005 }; 4187 };
4006 4188
4007 4189
4008 class HBoundsCheckBaseIndexInformation: public HTemplateInstruction<2> { 4190 class HBoundsCheckBaseIndexInformation: public HTemplateInstruction<2> {
4009 public: 4191 public:
4010 explicit HBoundsCheckBaseIndexInformation(HBoundsCheck* check) { 4192 explicit HBoundsCheckBaseIndexInformation(HBoundsCheck* check) {
4011 DecompositionResult decomposition; 4193 DecompositionResult decomposition;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
4088 4270
4089 DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation) 4271 DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation)
4090 4272
4091 private: 4273 private:
4092 virtual bool IsDeletable() const { return true; } 4274 virtual bool IsDeletable() const { return true; }
4093 }; 4275 };
4094 4276
4095 4277
4096 class HMathFloorOfDiv: public HBinaryOperation { 4278 class HMathFloorOfDiv: public HBinaryOperation {
4097 public: 4279 public:
4098 HMathFloorOfDiv(HValue* context, HValue* left, HValue* right) 4280 static HMathFloorOfDiv* New(Zone* zone,
4099 : HBinaryOperation(context, left, right) { 4281 HValue* context,
4100 set_representation(Representation::Integer32()); 4282 HValue* left,
4101 SetFlag(kUseGVN); 4283 HValue* right) {
4102 SetFlag(kCanOverflow); 4284 return new(zone) HMathFloorOfDiv(context, left, right);
4103 if (!right->IsConstant()) {
4104 SetFlag(kCanBeDivByZero);
4105 }
4106 SetFlag(kAllowUndefinedAsNaN);
4107 } 4285 }
4108 4286
4109 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 4287 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
4110 4288
4111 virtual Representation RequiredInputRepresentation(int index) { 4289 virtual Representation RequiredInputRepresentation(int index) {
4112 return Representation::Integer32(); 4290 return Representation::Integer32();
4113 } 4291 }
4114 4292
4115 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv) 4293 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv)
4116 4294
4117 protected: 4295 protected:
4118 virtual bool DataEquals(HValue* other) { return true; } 4296 virtual bool DataEquals(HValue* other) { return true; }
4119 4297
4120 private: 4298 private:
4299 HMathFloorOfDiv(HValue* context, HValue* left, HValue* right)
4300 : HBinaryOperation(context, left, right) {
4301 set_representation(Representation::Integer32());
4302 SetFlag(kUseGVN);
4303 SetFlag(kCanOverflow);
4304 if (!right->IsConstant()) {
4305 SetFlag(kCanBeDivByZero);
4306 }
4307 SetFlag(kAllowUndefinedAsNaN);
4308 }
4309
4121 virtual bool IsDeletable() const { return true; } 4310 virtual bool IsDeletable() const { return true; }
4122 }; 4311 };
4123 4312
4124 4313
4125 class HArithmeticBinaryOperation: public HBinaryOperation { 4314 class HArithmeticBinaryOperation: public HBinaryOperation {
4126 public: 4315 public:
4127 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) 4316 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right)
4128 : HBinaryOperation(context, left, right, HType::TaggedNumber()) { 4317 : HBinaryOperation(context, left, right, HType::TaggedNumber()) {
4129 SetAllSideEffects(); 4318 SetAllSideEffects();
4130 SetFlag(kFlexibleRepresentation); 4319 SetFlag(kFlexibleRepresentation);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
4212 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch) 4401 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch)
4213 4402
4214 private: 4403 private:
4215 Representation observed_input_representation_[2]; 4404 Representation observed_input_representation_[2];
4216 Token::Value token_; 4405 Token::Value token_;
4217 }; 4406 };
4218 4407
4219 4408
4220 class HCompareObjectEqAndBranch: public HTemplateControlInstruction<2, 2> { 4409 class HCompareObjectEqAndBranch: public HTemplateControlInstruction<2, 2> {
4221 public: 4410 public:
4222 HCompareObjectEqAndBranch(HValue* left, HValue* right) { 4411 // TODO(danno): make this private when the IfBuilder properly constructs
4412 // control flow instructions.
4413 HCompareObjectEqAndBranch(HValue* left,
4414 HValue* right) {
4223 SetOperandAt(0, left); 4415 SetOperandAt(0, left);
4224 SetOperandAt(1, right); 4416 SetOperandAt(1, right);
4225 } 4417 }
4226 4418
4419 DECLARE_INSTRUCTION_FACTORY_P2(HCompareObjectEqAndBranch, HValue*, HValue*);
4420
4227 HValue* left() { return OperandAt(0); } 4421 HValue* left() { return OperandAt(0); }
4228 HValue* right() { return OperandAt(1); } 4422 HValue* right() { return OperandAt(1); }
4229 4423
4230 virtual void PrintDataTo(StringStream* stream); 4424 virtual void PrintDataTo(StringStream* stream);
4231 4425
4232 virtual Representation RequiredInputRepresentation(int index) { 4426 virtual Representation RequiredInputRepresentation(int index) {
4233 return Representation::Tagged(); 4427 return Representation::Tagged();
4234 } 4428 }
4235 4429
4236 virtual Representation observed_input_representation(int index) { 4430 virtual Representation observed_input_representation(int index) {
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after
4502 virtual Representation RequiredInputRepresentation(int index) { 4696 virtual Representation RequiredInputRepresentation(int index) {
4503 return Representation::Tagged(); 4697 return Representation::Tagged();
4504 } 4698 }
4505 4699
4506 DECLARE_CONCRETE_INSTRUCTION(InstanceSize) 4700 DECLARE_CONCRETE_INSTRUCTION(InstanceSize)
4507 }; 4701 };
4508 4702
4509 4703
4510 class HPower: public HTemplateInstruction<2> { 4704 class HPower: public HTemplateInstruction<2> {
4511 public: 4705 public:
4512 static HInstruction* New(Zone* zone, HValue* left, HValue* right); 4706 static HInstruction* New(Zone* zone,
4707 HValue* context,
4708 HValue* left,
4709 HValue* right);
4513 4710
4514 HValue* left() { return OperandAt(0); } 4711 HValue* left() { return OperandAt(0); }
4515 HValue* right() const { return OperandAt(1); } 4712 HValue* right() const { return OperandAt(1); }
4516 4713
4517 virtual Representation RequiredInputRepresentation(int index) { 4714 virtual Representation RequiredInputRepresentation(int index) {
4518 return index == 0 4715 return index == 0
4519 ? Representation::Double() 4716 ? Representation::Double()
4520 : Representation::None(); 4717 : Representation::None();
4521 } 4718 }
4522 virtual Representation observed_input_representation(int index) { 4719 virtual Representation observed_input_representation(int index) {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
4837 : HArithmeticBinaryOperation(context, left, right), 5034 : HArithmeticBinaryOperation(context, left, right),
4838 operation_(op) { } 5035 operation_(op) { }
4839 5036
4840 Operation operation_; 5037 Operation operation_;
4841 }; 5038 };
4842 5039
4843 5040
4844 class HBitwise: public HBitwiseBinaryOperation { 5041 class HBitwise: public HBitwiseBinaryOperation {
4845 public: 5042 public:
4846 static HInstruction* New(Zone* zone, 5043 static HInstruction* New(Zone* zone,
5044 HValue* context,
4847 Token::Value op, 5045 Token::Value op,
4848 HValue* context,
4849 HValue* left, 5046 HValue* left,
4850 HValue* right); 5047 HValue* right);
4851 5048
4852 Token::Value op() const { return op_; } 5049 Token::Value op() const { return op_; }
4853 5050
4854 virtual bool IsCommutative() const { return true; } 5051 virtual bool IsCommutative() const { return true; }
4855 5052
4856 virtual HValue* Canonicalize(); 5053 virtual HValue* Canonicalize();
4857 5054
4858 virtual void PrintDataTo(StringStream* stream); 5055 virtual void PrintDataTo(StringStream* stream);
4859 5056
4860 DECLARE_CONCRETE_INSTRUCTION(Bitwise) 5057 DECLARE_CONCRETE_INSTRUCTION(Bitwise)
4861 5058
4862 protected: 5059 protected:
4863 virtual bool DataEquals(HValue* other) { 5060 virtual bool DataEquals(HValue* other) {
4864 return op() == HBitwise::cast(other)->op(); 5061 return op() == HBitwise::cast(other)->op();
4865 } 5062 }
4866 5063
4867 virtual Range* InferRange(Zone* zone); 5064 virtual Range* InferRange(Zone* zone);
4868 5065
4869 private: 5066 private:
4870 HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right) 5067 HBitwise(HValue* context,
5068 Token::Value op,
5069 HValue* left,
5070 HValue* right)
4871 : HBitwiseBinaryOperation(context, left, right, HType::TaggedNumber()), 5071 : HBitwiseBinaryOperation(context, left, right, HType::TaggedNumber()),
4872 op_(op) { 5072 op_(op) {
4873 ASSERT(op == Token::BIT_AND || op == Token::BIT_OR || op == Token::BIT_XOR); 5073 ASSERT(op == Token::BIT_AND || op == Token::BIT_OR || op == Token::BIT_XOR);
4874 // BIT_AND with a smi-range positive value will always unset the 5074 // BIT_AND with a smi-range positive value will always unset the
4875 // entire sign-extension of the smi-sign. 5075 // entire sign-extension of the smi-sign.
4876 if (op == Token::BIT_AND && 5076 if (op == Token::BIT_AND &&
4877 ((left->IsConstant() && 5077 ((left->IsConstant() &&
4878 left->representation().IsSmi() && 5078 left->representation().IsSmi() &&
4879 HConstant::cast(left)->Integer32Value() >= 0) || 5079 HConstant::cast(left)->Integer32Value() >= 0) ||
4880 (right->IsConstant() && 5080 (right->IsConstant() &&
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
5023 5223
5024 DECLARE_CONCRETE_INSTRUCTION(Ror) 5224 DECLARE_CONCRETE_INSTRUCTION(Ror)
5025 5225
5026 protected: 5226 protected:
5027 virtual bool DataEquals(HValue* other) { return true; } 5227 virtual bool DataEquals(HValue* other) { return true; }
5028 }; 5228 };
5029 5229
5030 5230
5031 class HOsrEntry: public HTemplateInstruction<0> { 5231 class HOsrEntry: public HTemplateInstruction<0> {
5032 public: 5232 public:
5033 explicit HOsrEntry(BailoutId ast_id) : ast_id_(ast_id) { 5233 DECLARE_INSTRUCTION_FACTORY_P1(HOsrEntry, BailoutId);
5034 SetGVNFlag(kChangesOsrEntries);
5035 SetGVNFlag(kChangesNewSpacePromotion);
5036 }
5037 5234
5038 BailoutId ast_id() const { return ast_id_; } 5235 BailoutId ast_id() const { return ast_id_; }
5039 5236
5040 virtual Representation RequiredInputRepresentation(int index) { 5237 virtual Representation RequiredInputRepresentation(int index) {
5041 return Representation::None(); 5238 return Representation::None();
5042 } 5239 }
5043 5240
5044 DECLARE_CONCRETE_INSTRUCTION(OsrEntry) 5241 DECLARE_CONCRETE_INSTRUCTION(OsrEntry)
5045 5242
5046 private: 5243 private:
5244 explicit HOsrEntry(BailoutId ast_id) : ast_id_(ast_id) {
5245 SetGVNFlag(kChangesOsrEntries);
5246 SetGVNFlag(kChangesNewSpacePromotion);
5247 }
5248
5047 BailoutId ast_id_; 5249 BailoutId ast_id_;
5048 }; 5250 };
5049 5251
5050 5252
5051 class HParameter: public HTemplateInstruction<0> { 5253 class HParameter: public HTemplateInstruction<0> {
5052 public: 5254 public:
5053 enum ParameterKind { 5255 enum ParameterKind {
5054 STACK_PARAMETER, 5256 STACK_PARAMETER,
5055 REGISTER_PARAMETER 5257 REGISTER_PARAMETER
5056 }; 5258 };
5057 5259
5260 DECLARE_INSTRUCTION_FACTORY_P1(HParameter, unsigned);
5261 DECLARE_INSTRUCTION_FACTORY_P2(HParameter, unsigned, ParameterKind);
5262 DECLARE_INSTRUCTION_FACTORY_P3(HParameter, unsigned, ParameterKind,
5263 Representation);
5264
5265 unsigned index() const { return index_; }
5266 ParameterKind kind() const { return kind_; }
5267
5268 virtual void PrintDataTo(StringStream* stream);
5269
5270 virtual Representation RequiredInputRepresentation(int index) {
5271 return Representation::None();
5272 }
5273
5274 DECLARE_CONCRETE_INSTRUCTION(Parameter)
5275
5276 private:
5058 explicit HParameter(unsigned index, 5277 explicit HParameter(unsigned index,
5059 ParameterKind kind = STACK_PARAMETER) 5278 ParameterKind kind = STACK_PARAMETER)
5060 : index_(index), 5279 : index_(index),
5061 kind_(kind) { 5280 kind_(kind) {
5062 set_representation(Representation::Tagged()); 5281 set_representation(Representation::Tagged());
5063 } 5282 }
5064 5283
5065 explicit HParameter(unsigned index, 5284 explicit HParameter(unsigned index,
5066 ParameterKind kind, 5285 ParameterKind kind,
5067 Representation r) 5286 Representation r)
5068 : index_(index), 5287 : index_(index),
5069 kind_(kind) { 5288 kind_(kind) {
5070 set_representation(r); 5289 set_representation(r);
5071 } 5290 }
5072 5291
5073 unsigned index() const { return index_; }
5074 ParameterKind kind() const { return kind_; }
5075
5076 virtual void PrintDataTo(StringStream* stream);
5077
5078 virtual Representation RequiredInputRepresentation(int index) {
5079 return Representation::None();
5080 }
5081
5082 DECLARE_CONCRETE_INSTRUCTION(Parameter)
5083
5084 private:
5085 unsigned index_; 5292 unsigned index_;
5086 ParameterKind kind_; 5293 ParameterKind kind_;
5087 }; 5294 };
5088 5295
5089 5296
5090 class HCallStub: public HUnaryCall { 5297 class HCallStub: public HUnaryCall {
5091 public: 5298 public:
5092 HCallStub(HValue* context, CodeStub::Major major_key, int argument_count) 5299 HCallStub(HValue* context, CodeStub::Major major_key, int argument_count)
5093 : HUnaryCall(context, argument_count), 5300 : HUnaryCall(context, argument_count),
5094 major_key_(major_key), 5301 major_key_(major_key),
(...skipping 20 matching lines...) Expand all
5115 DECLARE_CONCRETE_INSTRUCTION(CallStub) 5322 DECLARE_CONCRETE_INSTRUCTION(CallStub)
5116 5323
5117 private: 5324 private:
5118 CodeStub::Major major_key_; 5325 CodeStub::Major major_key_;
5119 TranscendentalCache::Type transcendental_type_; 5326 TranscendentalCache::Type transcendental_type_;
5120 }; 5327 };
5121 5328
5122 5329
5123 class HUnknownOSRValue: public HTemplateInstruction<0> { 5330 class HUnknownOSRValue: public HTemplateInstruction<0> {
5124 public: 5331 public:
5125 HUnknownOSRValue() 5332 DECLARE_INSTRUCTION_FACTORY_P0(HUnknownOSRValue)
5126 : incoming_value_(NULL) {
5127 set_representation(Representation::Tagged());
5128 }
5129 5333
5130 virtual Representation RequiredInputRepresentation(int index) { 5334 virtual Representation RequiredInputRepresentation(int index) {
5131 return Representation::None(); 5335 return Representation::None();
5132 } 5336 }
5133 5337
5134 void set_incoming_value(HPhi* value) { 5338 void set_incoming_value(HPhi* value) {
5135 incoming_value_ = value; 5339 incoming_value_ = value;
5136 } 5340 }
5137 5341
5138 HPhi* incoming_value() { 5342 HPhi* incoming_value() {
5139 return incoming_value_; 5343 return incoming_value_;
5140 } 5344 }
5141 5345
5142 virtual Representation KnownOptimalRepresentation() { 5346 virtual Representation KnownOptimalRepresentation() {
5143 if (incoming_value_ == NULL) return Representation::None(); 5347 if (incoming_value_ == NULL) return Representation::None();
5144 return incoming_value_->KnownOptimalRepresentation(); 5348 return incoming_value_->KnownOptimalRepresentation();
5145 } 5349 }
5146 5350
5147 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue) 5351 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue)
5148 5352
5149 private: 5353 private:
5354 HUnknownOSRValue()
5355 : incoming_value_(NULL) {
5356 set_representation(Representation::Tagged());
5357 }
5358
5150 HPhi* incoming_value_; 5359 HPhi* incoming_value_;
5151 }; 5360 };
5152 5361
5153 5362
5154 class HLoadGlobalCell: public HTemplateInstruction<0> { 5363 class HLoadGlobalCell: public HTemplateInstruction<0> {
5155 public: 5364 public:
5156 HLoadGlobalCell(Handle<Cell> cell, PropertyDetails details) 5365 HLoadGlobalCell(Handle<Cell> cell, PropertyDetails details)
5157 : cell_(cell), details_(details), unique_id_() { 5366 : cell_(cell), details_(details), unique_id_() {
5158 set_representation(Representation::Tagged()); 5367 set_representation(Representation::Tagged());
5159 SetFlag(kUseGVN); 5368 SetFlag(kUseGVN);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
5222 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) 5431 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric)
5223 5432
5224 private: 5433 private:
5225 Handle<Object> name_; 5434 Handle<Object> name_;
5226 bool for_typeof_; 5435 bool for_typeof_;
5227 }; 5436 };
5228 5437
5229 5438
5230 class HAllocate: public HTemplateInstruction<2> { 5439 class HAllocate: public HTemplateInstruction<2> {
5231 public: 5440 public:
5232 HAllocate(HValue* context, 5441 static HAllocate* New(Zone* zone,
5233 HValue* size, 5442 HValue* context,
5234 HType type, 5443 HValue* size,
5235 bool pretenure, 5444 HType type,
5236 ElementsKind kind = FAST_ELEMENTS) 5445 bool pretenure,
5237 : HTemplateInstruction<2>(type) { 5446 ElementsKind kind = FAST_ELEMENTS) {
5238 SetOperandAt(0, context); 5447 return new(zone) HAllocate(context, size, type, pretenure, kind);
5239 SetOperandAt(1, size);
5240 set_representation(Representation::Tagged());
5241 SetFlag(kTrackSideEffectDominators);
5242 SetGVNFlag(kChangesNewSpacePromotion);
5243 SetGVNFlag(kDependsOnNewSpacePromotion);
5244 if (pretenure) {
5245 if (IsFastDoubleElementsKind(kind)) {
5246 flags_ = static_cast<HAllocate::Flags>(ALLOCATE_IN_OLD_DATA_SPACE |
5247 ALLOCATE_DOUBLE_ALIGNED);
5248 } else {
5249 flags_ = ALLOCATE_IN_OLD_POINTER_SPACE;
5250 }
5251 } else {
5252 flags_ = ALLOCATE_IN_NEW_SPACE;
5253 if (IsFastDoubleElementsKind(kind)) {
5254 flags_ = static_cast<HAllocate::Flags>(flags_ |
5255 ALLOCATE_DOUBLE_ALIGNED);
5256 }
5257 }
5258 } 5448 }
5259 5449
5260 // Maximum instance size for which allocations will be inlined. 5450 // Maximum instance size for which allocations will be inlined.
5261 static const int kMaxInlineSize = 64 * kPointerSize; 5451 static const int kMaxInlineSize = 64 * kPointerSize;
5262 5452
5263 HValue* context() { return OperandAt(0); } 5453 HValue* context() { return OperandAt(0); }
5264 HValue* size() { return OperandAt(1); } 5454 HValue* size() { return OperandAt(1); }
5265 5455
5266 virtual Representation RequiredInputRepresentation(int index) { 5456 virtual Representation RequiredInputRepresentation(int index) {
5267 if (index == 0) { 5457 if (index == 0) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5320 5510
5321 private: 5511 private:
5322 enum Flags { 5512 enum Flags {
5323 ALLOCATE_IN_NEW_SPACE = 1 << 0, 5513 ALLOCATE_IN_NEW_SPACE = 1 << 0,
5324 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, 5514 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1,
5325 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, 5515 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2,
5326 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, 5516 ALLOCATE_DOUBLE_ALIGNED = 1 << 3,
5327 PREFILL_WITH_FILLER = 1 << 4 5517 PREFILL_WITH_FILLER = 1 << 4
5328 }; 5518 };
5329 5519
5520 HAllocate(HValue* context,
5521 HValue* size,
5522 HType type,
5523 bool pretenure,
5524 ElementsKind kind)
5525 : HTemplateInstruction<2>(type) {
5526 SetOperandAt(0, context);
5527 SetOperandAt(1, size);
5528 set_representation(Representation::Tagged());
5529 SetFlag(kTrackSideEffectDominators);
5530 SetGVNFlag(kChangesNewSpacePromotion);
5531 SetGVNFlag(kDependsOnNewSpacePromotion);
5532 if (pretenure) {
5533 if (IsFastDoubleElementsKind(kind)) {
5534 flags_ = static_cast<HAllocate::Flags>(ALLOCATE_IN_OLD_DATA_SPACE |
5535 ALLOCATE_DOUBLE_ALIGNED);
5536 } else {
5537 flags_ = ALLOCATE_IN_OLD_POINTER_SPACE;
5538 }
5539 } else {
5540 flags_ = ALLOCATE_IN_NEW_SPACE;
5541 if (IsFastDoubleElementsKind(kind)) {
5542 flags_ = static_cast<HAllocate::Flags>(flags_ |
5543 ALLOCATE_DOUBLE_ALIGNED);
5544 }
5545 }
5546 }
5547
5330 Flags flags_; 5548 Flags flags_;
5331 Handle<Map> known_initial_map_; 5549 Handle<Map> known_initial_map_;
5332 }; 5550 };
5333 5551
5334 5552
5335 class HInnerAllocatedObject: public HTemplateInstruction<1> { 5553 class HInnerAllocatedObject: public HTemplateInstruction<1> {
5336 public: 5554 public:
5337 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) 5555 static HInnerAllocatedObject* New(Zone* zone,
5338 : HTemplateInstruction<1>(type), offset_(offset) { 5556 HValue* context,
5339 ASSERT(value->IsAllocate()); 5557 HValue* value,
5340 SetOperandAt(0, value); 5558 int offset,
5341 set_representation(Representation::Tagged()); 5559 HType type = HType::Tagged()) {
5560 return new(zone) HInnerAllocatedObject(value, offset, type);
5342 } 5561 }
5343 5562
5344 HValue* base_object() { return OperandAt(0); } 5563 HValue* base_object() { return OperandAt(0); }
5345 int offset() { return offset_; } 5564 int offset() { return offset_; }
5346 5565
5347 virtual Representation RequiredInputRepresentation(int index) { 5566 virtual Representation RequiredInputRepresentation(int index) {
5348 return Representation::Tagged(); 5567 return Representation::Tagged();
5349 } 5568 }
5350 5569
5351 virtual void PrintDataTo(StringStream* stream); 5570 virtual void PrintDataTo(StringStream* stream);
5352 5571
5353 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject) 5572 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject)
5354 5573
5355 private: 5574 private:
5575 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged())
5576 : HTemplateInstruction<1>(type), offset_(offset) {
5577 ASSERT(value->IsAllocate());
5578 SetOperandAt(0, value);
5579 set_type(type);
5580 set_representation(Representation::Tagged());
5581 }
5582
5356 int offset_; 5583 int offset_;
5357 }; 5584 };
5358 5585
5359 5586
5360 inline bool StoringValueNeedsWriteBarrier(HValue* value) { 5587 inline bool StoringValueNeedsWriteBarrier(HValue* value) {
5361 return !value->type().IsBoolean() 5588 return !value->type().IsBoolean()
5362 && !value->type().IsSmi() 5589 && !value->type().IsSmi()
5363 && !(value->IsConstant() && HConstant::cast(value)->ImmortalImmovable()); 5590 && !(value->IsConstant() && HConstant::cast(value)->ImmortalImmovable());
5364 } 5591 }
5365 5592
(...skipping 16 matching lines...) Expand all
5382 if (object != new_space_dominator) return true; 5609 if (object != new_space_dominator) return true;
5383 if (object->IsAllocate()) { 5610 if (object->IsAllocate()) {
5384 return !HAllocate::cast(object)->IsNewSpaceAllocation(); 5611 return !HAllocate::cast(object)->IsNewSpaceAllocation();
5385 } 5612 }
5386 return true; 5613 return true;
5387 } 5614 }
5388 5615
5389 5616
5390 class HStoreGlobalCell: public HUnaryOperation { 5617 class HStoreGlobalCell: public HUnaryOperation {
5391 public: 5618 public:
5392 HStoreGlobalCell(HValue* value, 5619 DECLARE_INSTRUCTION_FACTORY_P3(HStoreGlobalCell, HValue*,
5393 Handle<PropertyCell> cell, 5620 Handle<PropertyCell>, PropertyDetails);
5394 PropertyDetails details)
5395 : HUnaryOperation(value),
5396 cell_(cell),
5397 details_(details) {
5398 SetGVNFlag(kChangesGlobalVars);
5399 }
5400 5621
5401 Handle<PropertyCell> cell() const { return cell_; } 5622 Handle<PropertyCell> cell() const { return cell_; }
5402 bool RequiresHoleCheck() { 5623 bool RequiresHoleCheck() {
5403 return !details_.IsDontDelete() || details_.IsReadOnly(); 5624 return !details_.IsDontDelete() || details_.IsReadOnly();
5404 } 5625 }
5405 bool NeedsWriteBarrier() { 5626 bool NeedsWriteBarrier() {
5406 return StoringValueNeedsWriteBarrier(value()); 5627 return StoringValueNeedsWriteBarrier(value());
5407 } 5628 }
5408 5629
5409 virtual Representation RequiredInputRepresentation(int index) { 5630 virtual Representation RequiredInputRepresentation(int index) {
5410 return Representation::Tagged(); 5631 return Representation::Tagged();
5411 } 5632 }
5412 virtual void PrintDataTo(StringStream* stream); 5633 virtual void PrintDataTo(StringStream* stream);
5413 5634
5414 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell) 5635 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell)
5415 5636
5416 private: 5637 private:
5638 HStoreGlobalCell(HValue* value,
5639 Handle<PropertyCell> cell,
5640 PropertyDetails details)
5641 : HUnaryOperation(value),
5642 cell_(cell),
5643 details_(details) {
5644 SetGVNFlag(kChangesGlobalVars);
5645 }
5646
5417 Handle<PropertyCell> cell_; 5647 Handle<PropertyCell> cell_;
5418 PropertyDetails details_; 5648 PropertyDetails details_;
5419 }; 5649 };
5420 5650
5421 5651
5422 class HStoreGlobalGeneric: public HTemplateInstruction<3> { 5652 class HStoreGlobalGeneric: public HTemplateInstruction<3> {
5423 public: 5653 public:
5424 HStoreGlobalGeneric(HValue* context, 5654 inline static HStoreGlobalGeneric* New(Zone* zone,
5425 HValue* global_object, 5655 HValue* context,
5426 Handle<Object> name, 5656 HValue* global_object,
5427 HValue* value, 5657 Handle<Object> name,
5428 StrictModeFlag strict_mode_flag) 5658 HValue* value,
5429 : name_(name), 5659 StrictModeFlag strict_mode_flag) {
5430 strict_mode_flag_(strict_mode_flag) { 5660 return new(zone) HStoreGlobalGeneric(context, global_object,
5431 SetOperandAt(0, context); 5661 name, value, strict_mode_flag);
5432 SetOperandAt(1, global_object);
5433 SetOperandAt(2, value);
5434 set_representation(Representation::Tagged());
5435 SetAllSideEffects();
5436 } 5662 }
5437 5663
5438 HValue* context() { return OperandAt(0); } 5664 HValue* context() { return OperandAt(0); }
5439 HValue* global_object() { return OperandAt(1); } 5665 HValue* global_object() { return OperandAt(1); }
5440 Handle<Object> name() const { return name_; } 5666 Handle<Object> name() const { return name_; }
5441 HValue* value() { return OperandAt(2); } 5667 HValue* value() { return OperandAt(2); }
5442 StrictModeFlag strict_mode_flag() { return strict_mode_flag_; } 5668 StrictModeFlag strict_mode_flag() { return strict_mode_flag_; }
5443 5669
5444 virtual void PrintDataTo(StringStream* stream); 5670 virtual void PrintDataTo(StringStream* stream);
5445 5671
5446 virtual Representation RequiredInputRepresentation(int index) { 5672 virtual Representation RequiredInputRepresentation(int index) {
5447 return Representation::Tagged(); 5673 return Representation::Tagged();
5448 } 5674 }
5449 5675
5450 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric) 5676 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric)
5451 5677
5452 private: 5678 private:
5679 HStoreGlobalGeneric(HValue* context,
5680 HValue* global_object,
5681 Handle<Object> name,
5682 HValue* value,
5683 StrictModeFlag strict_mode_flag)
5684 : name_(name),
5685 strict_mode_flag_(strict_mode_flag) {
5686 SetOperandAt(0, context);
5687 SetOperandAt(1, global_object);
5688 SetOperandAt(2, value);
5689 set_representation(Representation::Tagged());
5690 SetAllSideEffects();
5691 }
5692
5453 Handle<Object> name_; 5693 Handle<Object> name_;
5454 StrictModeFlag strict_mode_flag_; 5694 StrictModeFlag strict_mode_flag_;
5455 }; 5695 };
5456 5696
5457 5697
5458 class HLoadContextSlot: public HUnaryOperation { 5698 class HLoadContextSlot: public HUnaryOperation {
5459 public: 5699 public:
5460 enum Mode { 5700 enum Mode {
5461 // Perform a normal load of the context slot without checking its value. 5701 // Perform a normal load of the context slot without checking its value.
5462 kNoCheck, 5702 kNoCheck,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
5530 kNoCheck, 5770 kNoCheck,
5531 // Check the previous value of the context slot and deoptimize if it's the 5771 // Check the previous value of the context slot and deoptimize if it's the
5532 // hole value. This is used for checking for assignments to uninitialized 5772 // hole value. This is used for checking for assignments to uninitialized
5533 // harmony bindings where we deoptimize into full-codegen generated code 5773 // harmony bindings where we deoptimize into full-codegen generated code
5534 // which will subsequently throw a reference error. 5774 // which will subsequently throw a reference error.
5535 kCheckDeoptimize, 5775 kCheckDeoptimize,
5536 // Check the previous value and ignore assignment if it isn't a hole value 5776 // Check the previous value and ignore assignment if it isn't a hole value
5537 kCheckIgnoreAssignment 5777 kCheckIgnoreAssignment
5538 }; 5778 };
5539 5779
5540 HStoreContextSlot(HValue* context, int slot_index, Mode mode, HValue* value) 5780 DECLARE_INSTRUCTION_FACTORY_P4(HStoreContextSlot, HValue*, int,
5541 : slot_index_(slot_index), mode_(mode) { 5781 Mode, HValue*);
5542 SetOperandAt(0, context);
5543 SetOperandAt(1, value);
5544 SetGVNFlag(kChangesContextSlots);
5545 }
5546 5782
5547 HValue* context() { return OperandAt(0); } 5783 HValue* context() { return OperandAt(0); }
5548 HValue* value() { return OperandAt(1); } 5784 HValue* value() { return OperandAt(1); }
5549 int slot_index() const { return slot_index_; } 5785 int slot_index() const { return slot_index_; }
5550 Mode mode() const { return mode_; } 5786 Mode mode() const { return mode_; }
5551 5787
5552 bool NeedsWriteBarrier() { 5788 bool NeedsWriteBarrier() {
5553 return StoringValueNeedsWriteBarrier(value()); 5789 return StoringValueNeedsWriteBarrier(value());
5554 } 5790 }
5555 5791
5556 bool DeoptimizesOnHole() { 5792 bool DeoptimizesOnHole() {
5557 return mode_ == kCheckDeoptimize; 5793 return mode_ == kCheckDeoptimize;
5558 } 5794 }
5559 5795
5560 bool RequiresHoleCheck() { 5796 bool RequiresHoleCheck() {
5561 return mode_ != kNoCheck; 5797 return mode_ != kNoCheck;
5562 } 5798 }
5563 5799
5564 virtual Representation RequiredInputRepresentation(int index) { 5800 virtual Representation RequiredInputRepresentation(int index) {
5565 return Representation::Tagged(); 5801 return Representation::Tagged();
5566 } 5802 }
5567 5803
5568 virtual void PrintDataTo(StringStream* stream); 5804 virtual void PrintDataTo(StringStream* stream);
5569 5805
5570 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) 5806 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot)
5571 5807
5572 private: 5808 private:
5809 HStoreContextSlot(HValue* context, int slot_index, Mode mode, HValue* value)
5810 : slot_index_(slot_index), mode_(mode) {
5811 SetOperandAt(0, context);
5812 SetOperandAt(1, value);
5813 SetGVNFlag(kChangesContextSlots);
5814 }
5815
5573 int slot_index_; 5816 int slot_index_;
5574 Mode mode_; 5817 Mode mode_;
5575 }; 5818 };
5576 5819
5577 5820
5578 // Represents an access to a portion of an object, such as the map pointer, 5821 // Represents an access to a portion of an object, such as the map pointer,
5579 // array elements pointer, etc, but not accesses to array elements themselves. 5822 // array elements pointer, etc, but not accesses to array elements themselves.
5580 class HObjectAccess { 5823 class HObjectAccess {
5581 public: 5824 public:
5582 inline bool IsInobject() const { 5825 inline bool IsInobject() const {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
5734 friend class HStoreNamedField; 5977 friend class HStoreNamedField;
5735 5978
5736 inline Portion portion() const { 5979 inline Portion portion() const {
5737 return PortionField::decode(value_); 5980 return PortionField::decode(value_);
5738 } 5981 }
5739 }; 5982 };
5740 5983
5741 5984
5742 class HLoadNamedField: public HTemplateInstruction<2> { 5985 class HLoadNamedField: public HTemplateInstruction<2> {
5743 public: 5986 public:
5744 HLoadNamedField(HValue* object, 5987 DECLARE_INSTRUCTION_FACTORY_P2(HLoadNamedField, HValue*, HObjectAccess);
5745 HObjectAccess access, 5988 DECLARE_INSTRUCTION_FACTORY_P3(HLoadNamedField, HValue*, HObjectAccess,
5746 HValue* typecheck = NULL) 5989 HValue*);
5747 : access_(access) {
5748 ASSERT(object != NULL);
5749 SetOperandAt(0, object);
5750 SetOperandAt(1, typecheck != NULL ? typecheck : object);
5751
5752 Representation representation = access.representation();
5753 if (representation.IsSmi()) {
5754 set_type(HType::Smi());
5755 set_representation(representation);
5756 } else if (representation.IsDouble() ||
5757 representation.IsExternal() ||
5758 representation.IsInteger32()) {
5759 set_representation(representation);
5760 } else if (FLAG_track_heap_object_fields &&
5761 representation.IsHeapObject()) {
5762 set_type(HType::NonPrimitive());
5763 set_representation(Representation::Tagged());
5764 } else {
5765 set_representation(Representation::Tagged());
5766 }
5767 access.SetGVNFlags(this, false);
5768 }
5769 5990
5770 HValue* object() { return OperandAt(0); } 5991 HValue* object() { return OperandAt(0); }
5771 HValue* typecheck() { 5992 HValue* typecheck() {
5772 ASSERT(HasTypeCheck()); 5993 ASSERT(HasTypeCheck());
5773 return OperandAt(1); 5994 return OperandAt(1);
5774 } 5995 }
5775 5996
5776 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); } 5997 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); }
5777 HObjectAccess access() const { return access_; } 5998 HObjectAccess access() const { return access_; }
5778 Representation field_representation() const { 5999 Representation field_representation() const {
(...skipping 12 matching lines...) Expand all
5791 6012
5792 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) 6013 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField)
5793 6014
5794 protected: 6015 protected:
5795 virtual bool DataEquals(HValue* other) { 6016 virtual bool DataEquals(HValue* other) {
5796 HLoadNamedField* b = HLoadNamedField::cast(other); 6017 HLoadNamedField* b = HLoadNamedField::cast(other);
5797 return access_.Equals(b->access_); 6018 return access_.Equals(b->access_);
5798 } 6019 }
5799 6020
5800 private: 6021 private:
6022 HLoadNamedField(HValue* object,
6023 HObjectAccess access,
6024 HValue* typecheck = NULL)
6025 : access_(access) {
6026 ASSERT(object != NULL);
6027 SetOperandAt(0, object);
6028 SetOperandAt(1, typecheck != NULL ? typecheck : object);
6029
6030 Representation representation = access.representation();
6031 if (representation.IsSmi()) {
6032 set_type(HType::Smi());
6033 set_representation(representation);
6034 } else if (representation.IsDouble() ||
6035 representation.IsExternal() ||
6036 representation.IsInteger32()) {
6037 set_representation(representation);
6038 } else if (FLAG_track_heap_object_fields &&
6039 representation.IsHeapObject()) {
6040 set_type(HType::NonPrimitive());
6041 set_representation(Representation::Tagged());
6042 } else {
6043 set_representation(Representation::Tagged());
6044 }
6045 access.SetGVNFlags(this, false);
6046 }
6047
5801 virtual bool IsDeletable() const { return true; } 6048 virtual bool IsDeletable() const { return true; }
5802 6049
5803 HObjectAccess access_; 6050 HObjectAccess access_;
5804 }; 6051 };
5805 6052
5806 6053
5807 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { 6054 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> {
5808 public: 6055 public:
5809 HLoadNamedFieldPolymorphic(HValue* context, 6056 HLoadNamedFieldPolymorphic(HValue* context,
5810 HValue* object, 6057 HValue* object,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
5909 6156
5910 enum LoadKeyedHoleMode { 6157 enum LoadKeyedHoleMode {
5911 NEVER_RETURN_HOLE, 6158 NEVER_RETURN_HOLE,
5912 ALLOW_RETURN_HOLE 6159 ALLOW_RETURN_HOLE
5913 }; 6160 };
5914 6161
5915 6162
5916 class HLoadKeyed 6163 class HLoadKeyed
5917 : public HTemplateInstruction<3>, public ArrayInstructionInterface { 6164 : public HTemplateInstruction<3>, public ArrayInstructionInterface {
5918 public: 6165 public:
5919 HLoadKeyed(HValue* obj, 6166 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*,
5920 HValue* key, 6167 ElementsKind);
5921 HValue* dependency, 6168 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*,
5922 ElementsKind elements_kind, 6169 ElementsKind, LoadKeyedHoleMode);
5923 LoadKeyedHoleMode mode = NEVER_RETURN_HOLE)
5924 : bit_field_(0) {
5925 bit_field_ = ElementsKindField::encode(elements_kind) |
5926 HoleModeField::encode(mode);
5927
5928 SetOperandAt(0, obj);
5929 SetOperandAt(1, key);
5930 SetOperandAt(2, dependency != NULL ? dependency : obj);
5931
5932 if (!is_external()) {
5933 // I can detect the case between storing double (holey and fast) and
5934 // smi/object by looking at elements_kind_.
5935 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) ||
5936 IsFastDoubleElementsKind(elements_kind));
5937
5938 if (IsFastSmiOrObjectElementsKind(elements_kind)) {
5939 if (IsFastSmiElementsKind(elements_kind) &&
5940 (!IsHoleyElementsKind(elements_kind) ||
5941 mode == NEVER_RETURN_HOLE)) {
5942 set_type(HType::Smi());
5943 set_representation(Representation::Smi());
5944 } else {
5945 set_representation(Representation::Tagged());
5946 }
5947
5948 SetGVNFlag(kDependsOnArrayElements);
5949 } else {
5950 set_representation(Representation::Double());
5951 SetGVNFlag(kDependsOnDoubleArrayElements);
5952 }
5953 } else {
5954 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS ||
5955 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) {
5956 set_representation(Representation::Double());
5957 } else {
5958 set_representation(Representation::Integer32());
5959 }
5960
5961 SetGVNFlag(kDependsOnExternalMemory);
5962 // Native code could change the specialized array.
5963 SetGVNFlag(kDependsOnCalls);
5964 }
5965
5966 SetFlag(kUseGVN);
5967 }
5968 6170
5969 bool is_external() const { 6171 bool is_external() const {
5970 return IsExternalArrayElementsKind(elements_kind()); 6172 return IsExternalArrayElementsKind(elements_kind());
5971 } 6173 }
5972 HValue* elements() { return OperandAt(0); } 6174 HValue* elements() { return OperandAt(0); }
5973 HValue* key() { return OperandAt(1); } 6175 HValue* key() { return OperandAt(1); }
5974 HValue* dependency() { 6176 HValue* dependency() {
5975 ASSERT(HasDependency()); 6177 ASSERT(HasDependency());
5976 return OperandAt(2); 6178 return OperandAt(2);
5977 } 6179 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
6026 virtual bool DataEquals(HValue* other) { 6228 virtual bool DataEquals(HValue* other) {
6027 if (!other->IsLoadKeyed()) return false; 6229 if (!other->IsLoadKeyed()) return false;
6028 HLoadKeyed* other_load = HLoadKeyed::cast(other); 6230 HLoadKeyed* other_load = HLoadKeyed::cast(other);
6029 6231
6030 if (IsDehoisted() && index_offset() != other_load->index_offset()) 6232 if (IsDehoisted() && index_offset() != other_load->index_offset())
6031 return false; 6233 return false;
6032 return elements_kind() == other_load->elements_kind(); 6234 return elements_kind() == other_load->elements_kind();
6033 } 6235 }
6034 6236
6035 private: 6237 private:
6238 HLoadKeyed(HValue* obj,
6239 HValue* key,
6240 HValue* dependency,
6241 ElementsKind elements_kind,
6242 LoadKeyedHoleMode mode = NEVER_RETURN_HOLE)
6243 : bit_field_(0) {
6244 bit_field_ = ElementsKindField::encode(elements_kind) |
6245 HoleModeField::encode(mode);
6246
6247 SetOperandAt(0, obj);
6248 SetOperandAt(1, key);
6249 SetOperandAt(2, dependency != NULL ? dependency : obj);
6250
6251 if (!is_external()) {
6252 // I can detect the case between storing double (holey and fast) and
6253 // smi/object by looking at elements_kind_.
6254 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) ||
6255 IsFastDoubleElementsKind(elements_kind));
6256
6257 if (IsFastSmiOrObjectElementsKind(elements_kind)) {
6258 if (IsFastSmiElementsKind(elements_kind) &&
6259 (!IsHoleyElementsKind(elements_kind) ||
6260 mode == NEVER_RETURN_HOLE)) {
6261 set_type(HType::Smi());
6262 set_representation(Representation::Smi());
6263 } else {
6264 set_representation(Representation::Tagged());
6265 }
6266
6267 SetGVNFlag(kDependsOnArrayElements);
6268 } else {
6269 set_representation(Representation::Double());
6270 SetGVNFlag(kDependsOnDoubleArrayElements);
6271 }
6272 } else {
6273 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS ||
6274 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) {
6275 set_representation(Representation::Double());
6276 } else {
6277 set_representation(Representation::Integer32());
6278 }
6279
6280 SetGVNFlag(kDependsOnExternalMemory);
6281 // Native code could change the specialized array.
6282 SetGVNFlag(kDependsOnCalls);
6283 }
6284
6285 SetFlag(kUseGVN);
6286 }
6287
6036 virtual bool IsDeletable() const { 6288 virtual bool IsDeletable() const {
6037 return !RequiresHoleCheck(); 6289 return !RequiresHoleCheck();
6038 } 6290 }
6039 6291
6040 // Establish some checks around our packed fields 6292 // Establish some checks around our packed fields
6041 enum LoadKeyedBits { 6293 enum LoadKeyedBits {
6042 kBitsForElementsKind = 5, 6294 kBitsForElementsKind = 5,
6043 kBitsForHoleMode = 1, 6295 kBitsForHoleMode = 1,
6044 kBitsForIndexOffset = 25, 6296 kBitsForIndexOffset = 25,
6045 kBitsForIsDehoisted = 1, 6297 kBitsForIsDehoisted = 1,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
6091 } 6343 }
6092 6344
6093 virtual HValue* Canonicalize(); 6345 virtual HValue* Canonicalize();
6094 6346
6095 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) 6347 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric)
6096 }; 6348 };
6097 6349
6098 6350
6099 class HStoreNamedField: public HTemplateInstruction<2> { 6351 class HStoreNamedField: public HTemplateInstruction<2> {
6100 public: 6352 public:
6101 HStoreNamedField(HValue* obj, 6353 DECLARE_INSTRUCTION_FACTORY_P3(HStoreNamedField, HValue*,
6102 HObjectAccess access, 6354 HObjectAccess, HValue*);
6103 HValue* val)
6104 : access_(access),
6105 transition_(),
6106 transition_unique_id_(),
6107 new_space_dominator_(NULL),
6108 write_barrier_mode_(UPDATE_WRITE_BARRIER) {
6109 SetOperandAt(0, obj);
6110 SetOperandAt(1, val);
6111 access.SetGVNFlags(this, true);
6112 }
6113 6355
6114 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) 6356 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField)
6115 6357
6116 virtual bool HasEscapingOperandAt(int index) { return index == 1; } 6358 virtual bool HasEscapingOperandAt(int index) { return index == 1; }
6117 virtual Representation RequiredInputRepresentation(int index) { 6359 virtual Representation RequiredInputRepresentation(int index) {
6118 if (index == 0 && access().IsExternalMemory()) { 6360 if (index == 0 && access().IsExternalMemory()) {
6119 // object must be external in case of external memory access 6361 // object must be external in case of external memory access
6120 return Representation::External(); 6362 return Representation::External();
6121 } else if (index == 1 && 6363 } else if (index == 1 &&
6122 (field_representation().IsDouble() || 6364 (field_representation().IsDouble() ||
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
6172 6414
6173 virtual void FinalizeUniqueValueId() { 6415 virtual void FinalizeUniqueValueId() {
6174 transition_unique_id_ = UniqueValueId(transition_); 6416 transition_unique_id_ = UniqueValueId(transition_);
6175 } 6417 }
6176 6418
6177 Representation field_representation() const { 6419 Representation field_representation() const {
6178 return access_.representation(); 6420 return access_.representation();
6179 } 6421 }
6180 6422
6181 private: 6423 private:
6424 HStoreNamedField(HValue* obj,
6425 HObjectAccess access,
6426 HValue* val)
6427 : access_(access),
6428 transition_(),
6429 transition_unique_id_(),
6430 new_space_dominator_(NULL),
6431 write_barrier_mode_(UPDATE_WRITE_BARRIER) {
6432 SetOperandAt(0, obj);
6433 SetOperandAt(1, val);
6434 access.SetGVNFlags(this, true);
6435 }
6436
6182 HObjectAccess access_; 6437 HObjectAccess access_;
6183 Handle<Map> transition_; 6438 Handle<Map> transition_;
6184 UniqueValueId transition_unique_id_; 6439 UniqueValueId transition_unique_id_;
6185 HValue* new_space_dominator_; 6440 HValue* new_space_dominator_;
6186 WriteBarrierMode write_barrier_mode_; 6441 WriteBarrierMode write_barrier_mode_;
6187 }; 6442 };
6188 6443
6189 6444
6190 class HStoreNamedGeneric: public HTemplateInstruction<3> { 6445 class HStoreNamedGeneric: public HTemplateInstruction<3> {
6191 public: 6446 public:
(...skipping 26 matching lines...) Expand all
6218 6473
6219 private: 6474 private:
6220 Handle<String> name_; 6475 Handle<String> name_;
6221 StrictModeFlag strict_mode_flag_; 6476 StrictModeFlag strict_mode_flag_;
6222 }; 6477 };
6223 6478
6224 6479
6225 class HStoreKeyed 6480 class HStoreKeyed
6226 : public HTemplateInstruction<3>, public ArrayInstructionInterface { 6481 : public HTemplateInstruction<3>, public ArrayInstructionInterface {
6227 public: 6482 public:
6228 HStoreKeyed(HValue* obj, HValue* key, HValue* val, 6483 DECLARE_INSTRUCTION_FACTORY_P4(HStoreKeyed, HValue*, HValue*, HValue*,
6229 ElementsKind elements_kind) 6484 ElementsKind);
6230 : elements_kind_(elements_kind),
6231 index_offset_(0),
6232 is_dehoisted_(false),
6233 is_uninitialized_(false),
6234 new_space_dominator_(NULL) {
6235 SetOperandAt(0, obj);
6236 SetOperandAt(1, key);
6237 SetOperandAt(2, val);
6238
6239 if (IsFastObjectElementsKind(elements_kind)) {
6240 SetFlag(kTrackSideEffectDominators);
6241 SetGVNFlag(kDependsOnNewSpacePromotion);
6242 }
6243 if (is_external()) {
6244 SetGVNFlag(kChangesExternalMemory);
6245 SetFlag(kAllowUndefinedAsNaN);
6246 } else if (IsFastDoubleElementsKind(elements_kind)) {
6247 SetGVNFlag(kChangesDoubleArrayElements);
6248 } else if (IsFastSmiElementsKind(elements_kind)) {
6249 SetGVNFlag(kChangesArrayElements);
6250 } else {
6251 SetGVNFlag(kChangesArrayElements);
6252 }
6253
6254 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating.
6255 if (elements_kind >= EXTERNAL_BYTE_ELEMENTS &&
6256 elements_kind <= EXTERNAL_UNSIGNED_INT_ELEMENTS) {
6257 SetFlag(kTruncatingToInt32);
6258 }
6259 }
6260 6485
6261 virtual bool HasEscapingOperandAt(int index) { return index != 0; } 6486 virtual bool HasEscapingOperandAt(int index) { return index != 0; }
6262 virtual Representation RequiredInputRepresentation(int index) { 6487 virtual Representation RequiredInputRepresentation(int index) {
6263 // kind_fast: tagged[int32] = tagged 6488 // kind_fast: tagged[int32] = tagged
6264 // kind_double: tagged[int32] = double 6489 // kind_double: tagged[int32] = double
6265 // kind_smi : tagged[int32] = smi 6490 // kind_smi : tagged[int32] = smi
6266 // kind_external: external[int32] = (double | int32) 6491 // kind_external: external[int32] = (double | int32)
6267 if (index == 0) { 6492 if (index == 0) {
6268 return is_external() ? Representation::External() 6493 return is_external() ? Representation::External()
6269 : Representation::Tagged(); 6494 : Representation::Tagged();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
6346 } 6571 }
6347 } 6572 }
6348 6573
6349 bool NeedsCanonicalization(); 6574 bool NeedsCanonicalization();
6350 6575
6351 virtual void PrintDataTo(StringStream* stream); 6576 virtual void PrintDataTo(StringStream* stream);
6352 6577
6353 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed) 6578 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed)
6354 6579
6355 private: 6580 private:
6581 HStoreKeyed(HValue* obj, HValue* key, HValue* val,
6582 ElementsKind elements_kind)
6583 : elements_kind_(elements_kind),
6584 index_offset_(0),
6585 is_dehoisted_(false),
6586 is_uninitialized_(false),
6587 new_space_dominator_(NULL) {
6588 SetOperandAt(0, obj);
6589 SetOperandAt(1, key);
6590 SetOperandAt(2, val);
6591
6592 if (IsFastObjectElementsKind(elements_kind)) {
6593 SetFlag(kTrackSideEffectDominators);
6594 SetGVNFlag(kDependsOnNewSpacePromotion);
6595 }
6596 if (is_external()) {
6597 SetGVNFlag(kChangesExternalMemory);
6598 SetFlag(kAllowUndefinedAsNaN);
6599 } else if (IsFastDoubleElementsKind(elements_kind)) {
6600 SetGVNFlag(kChangesDoubleArrayElements);
6601 } else if (IsFastSmiElementsKind(elements_kind)) {
6602 SetGVNFlag(kChangesArrayElements);
6603 } else {
6604 SetGVNFlag(kChangesArrayElements);
6605 }
6606
6607 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating.
6608 if (elements_kind >= EXTERNAL_BYTE_ELEMENTS &&
6609 elements_kind <= EXTERNAL_UNSIGNED_INT_ELEMENTS) {
6610 SetFlag(kTruncatingToInt32);
6611 }
6612 }
6613
6356 ElementsKind elements_kind_; 6614 ElementsKind elements_kind_;
6357 uint32_t index_offset_; 6615 uint32_t index_offset_;
6358 bool is_dehoisted_ : 1; 6616 bool is_dehoisted_ : 1;
6359 bool is_uninitialized_ : 1; 6617 bool is_uninitialized_ : 1;
6360 HValue* new_space_dominator_; 6618 HValue* new_space_dominator_;
6361 }; 6619 };
6362 6620
6363 6621
6364 class HStoreKeyedGeneric: public HTemplateInstruction<4> { 6622 class HStoreKeyedGeneric: public HTemplateInstruction<4> {
6365 public: 6623 public:
(...skipping 25 matching lines...) Expand all
6391 6649
6392 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric) 6650 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric)
6393 6651
6394 private: 6652 private:
6395 StrictModeFlag strict_mode_flag_; 6653 StrictModeFlag strict_mode_flag_;
6396 }; 6654 };
6397 6655
6398 6656
6399 class HTransitionElementsKind: public HTemplateInstruction<2> { 6657 class HTransitionElementsKind: public HTemplateInstruction<2> {
6400 public: 6658 public:
6401 HTransitionElementsKind(HValue* context, 6659 inline static HTransitionElementsKind* New(Zone* zone,
6402 HValue* object, 6660 HValue* context,
6403 Handle<Map> original_map, 6661 HValue* object,
6404 Handle<Map> transitioned_map) 6662 Handle<Map> original_map,
6405 : original_map_(original_map), 6663 Handle<Map> transitioned_map) {
6406 transitioned_map_(transitioned_map), 6664 return new(zone) HTransitionElementsKind(context, object,
6407 original_map_unique_id_(), 6665 original_map, transitioned_map);
6408 transitioned_map_unique_id_(),
6409 from_kind_(original_map->elements_kind()),
6410 to_kind_(transitioned_map->elements_kind()) {
6411 SetOperandAt(0, object);
6412 SetOperandAt(1, context);
6413 SetFlag(kUseGVN);
6414 SetGVNFlag(kChangesElementsKind);
6415 if (original_map->has_fast_double_elements()) {
6416 SetGVNFlag(kChangesElementsPointer);
6417 SetGVNFlag(kChangesNewSpacePromotion);
6418 }
6419 if (transitioned_map->has_fast_double_elements()) {
6420 SetGVNFlag(kChangesElementsPointer);
6421 SetGVNFlag(kChangesNewSpacePromotion);
6422 }
6423 set_representation(Representation::Tagged());
6424 } 6666 }
6425 6667
6426 virtual Representation RequiredInputRepresentation(int index) { 6668 virtual Representation RequiredInputRepresentation(int index) {
6427 return Representation::Tagged(); 6669 return Representation::Tagged();
6428 } 6670 }
6429 6671
6430 HValue* object() { return OperandAt(0); } 6672 HValue* object() { return OperandAt(0); }
6431 HValue* context() { return OperandAt(1); } 6673 HValue* context() { return OperandAt(1); }
6432 Handle<Map> original_map() { return original_map_; } 6674 Handle<Map> original_map() { return original_map_; }
6433 Handle<Map> transitioned_map() { return transitioned_map_; } 6675 Handle<Map> transitioned_map() { return transitioned_map_; }
(...skipping 10 matching lines...) Expand all
6444 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind) 6686 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind)
6445 6687
6446 protected: 6688 protected:
6447 virtual bool DataEquals(HValue* other) { 6689 virtual bool DataEquals(HValue* other) {
6448 HTransitionElementsKind* instr = HTransitionElementsKind::cast(other); 6690 HTransitionElementsKind* instr = HTransitionElementsKind::cast(other);
6449 return original_map_unique_id_ == instr->original_map_unique_id_ && 6691 return original_map_unique_id_ == instr->original_map_unique_id_ &&
6450 transitioned_map_unique_id_ == instr->transitioned_map_unique_id_; 6692 transitioned_map_unique_id_ == instr->transitioned_map_unique_id_;
6451 } 6693 }
6452 6694
6453 private: 6695 private:
6696 HTransitionElementsKind(HValue* context,
6697 HValue* object,
6698 Handle<Map> original_map,
6699 Handle<Map> transitioned_map)
6700 : original_map_(original_map),
6701 transitioned_map_(transitioned_map),
6702 original_map_unique_id_(),
6703 transitioned_map_unique_id_(),
6704 from_kind_(original_map->elements_kind()),
6705 to_kind_(transitioned_map->elements_kind()) {
6706 SetOperandAt(0, object);
6707 SetOperandAt(1, context);
6708 SetFlag(kUseGVN);
6709 SetGVNFlag(kChangesElementsKind);
6710 if (original_map->has_fast_double_elements()) {
6711 SetGVNFlag(kChangesElementsPointer);
6712 SetGVNFlag(kChangesNewSpacePromotion);
6713 }
6714 if (transitioned_map->has_fast_double_elements()) {
6715 SetGVNFlag(kChangesElementsPointer);
6716 SetGVNFlag(kChangesNewSpacePromotion);
6717 }
6718 set_representation(Representation::Tagged());
6719 }
6720
6454 Handle<Map> original_map_; 6721 Handle<Map> original_map_;
6455 Handle<Map> transitioned_map_; 6722 Handle<Map> transitioned_map_;
6456 UniqueValueId original_map_unique_id_; 6723 UniqueValueId original_map_unique_id_;
6457 UniqueValueId transitioned_map_unique_id_; 6724 UniqueValueId transitioned_map_unique_id_;
6458 ElementsKind from_kind_; 6725 ElementsKind from_kind_;
6459 ElementsKind to_kind_; 6726 ElementsKind to_kind_;
6460 }; 6727 };
6461 6728
6462 6729
6463 class HStringAdd: public HBinaryOperation { 6730 class HStringAdd: public HBinaryOperation {
(...skipping 27 matching lines...) Expand all
6491 // No side-effects except possible allocation. 6758 // No side-effects except possible allocation.
6492 // NOTE: this instruction _does not_ call ToString() on its inputs. 6759 // NOTE: this instruction _does not_ call ToString() on its inputs.
6493 virtual bool IsDeletable() const { return true; } 6760 virtual bool IsDeletable() const { return true; }
6494 6761
6495 const StringAddFlags flags_; 6762 const StringAddFlags flags_;
6496 }; 6763 };
6497 6764
6498 6765
6499 class HStringCharCodeAt: public HTemplateInstruction<3> { 6766 class HStringCharCodeAt: public HTemplateInstruction<3> {
6500 public: 6767 public:
6501 HStringCharCodeAt(HValue* context, HValue* string, HValue* index) { 6768 static HStringCharCodeAt* New(Zone* zone,
6502 SetOperandAt(0, context); 6769 HValue* context,
6503 SetOperandAt(1, string); 6770 HValue* string,
6504 SetOperandAt(2, index); 6771 HValue* index) {
6505 set_representation(Representation::Integer32()); 6772 return new(zone) HStringCharCodeAt(context, string, index);
6506 SetFlag(kUseGVN);
6507 SetGVNFlag(kDependsOnMaps);
6508 SetGVNFlag(kChangesNewSpacePromotion);
6509 } 6773 }
6510 6774
6511 virtual Representation RequiredInputRepresentation(int index) { 6775 virtual Representation RequiredInputRepresentation(int index) {
6512 // The index is supposed to be Integer32. 6776 // The index is supposed to be Integer32.
6513 return index == 2 6777 return index == 2
6514 ? Representation::Integer32() 6778 ? Representation::Integer32()
6515 : Representation::Tagged(); 6779 : Representation::Tagged();
6516 } 6780 }
6517 6781
6518 HValue* context() const { return OperandAt(0); } 6782 HValue* context() const { return OperandAt(0); }
6519 HValue* string() const { return OperandAt(1); } 6783 HValue* string() const { return OperandAt(1); }
6520 HValue* index() const { return OperandAt(2); } 6784 HValue* index() const { return OperandAt(2); }
6521 6785
6522 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt) 6786 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt)
6523 6787
6524 protected: 6788 protected:
6525 virtual bool DataEquals(HValue* other) { return true; } 6789 virtual bool DataEquals(HValue* other) { return true; }
6526 6790
6527 virtual Range* InferRange(Zone* zone) { 6791 virtual Range* InferRange(Zone* zone) {
6528 return new(zone) Range(0, String::kMaxUtf16CodeUnit); 6792 return new(zone) Range(0, String::kMaxUtf16CodeUnit);
6529 } 6793 }
6530 6794
6531 private: 6795 private:
6796 HStringCharCodeAt(HValue* context, HValue* string, HValue* index) {
6797 SetOperandAt(0, context);
6798 SetOperandAt(1, string);
6799 SetOperandAt(2, index);
6800 set_representation(Representation::Integer32());
6801 SetFlag(kUseGVN);
6802 SetGVNFlag(kDependsOnMaps);
6803 SetGVNFlag(kChangesNewSpacePromotion);
6804 }
6805
6532 // No side effects: runtime function assumes string + number inputs. 6806 // No side effects: runtime function assumes string + number inputs.
6533 virtual bool IsDeletable() const { return true; } 6807 virtual bool IsDeletable() const { return true; }
6534 }; 6808 };
6535 6809
6536 6810
6537 class HStringCharFromCode: public HTemplateInstruction<2> { 6811 class HStringCharFromCode: public HTemplateInstruction<2> {
6538 public: 6812 public:
6539 static HInstruction* New(Zone* zone, 6813 static HInstruction* New(Zone* zone,
6540 HValue* context, 6814 HValue* context,
6541 HValue* char_code); 6815 HValue* char_code);
(...skipping 22 matching lines...) Expand all
6564 } 6838 }
6565 6839
6566 virtual bool IsDeletable() const { 6840 virtual bool IsDeletable() const {
6567 return !value()->ToNumberCanBeObserved(); 6841 return !value()->ToNumberCanBeObserved();
6568 } 6842 }
6569 }; 6843 };
6570 6844
6571 6845
6572 class HStringLength: public HUnaryOperation { 6846 class HStringLength: public HUnaryOperation {
6573 public: 6847 public:
6574 static HInstruction* New(Zone* zone, HValue* string); 6848 static HInstruction* New(Zone* zone, HValue* context, HValue* string);
6575 6849
6576 virtual Representation RequiredInputRepresentation(int index) { 6850 virtual Representation RequiredInputRepresentation(int index) {
6577 return Representation::Tagged(); 6851 return Representation::Tagged();
6578 } 6852 }
6579 6853
6580 DECLARE_CONCRETE_INSTRUCTION(StringLength) 6854 DECLARE_CONCRETE_INSTRUCTION(StringLength)
6581 6855
6582 protected: 6856 protected:
6583 virtual bool DataEquals(HValue* other) { return true; } 6857 virtual bool DataEquals(HValue* other) { return true; }
6584 6858
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
6722 6996
6723 DECLARE_CONCRETE_INSTRUCTION(Typeof) 6997 DECLARE_CONCRETE_INSTRUCTION(Typeof)
6724 6998
6725 private: 6999 private:
6726 virtual bool IsDeletable() const { return true; } 7000 virtual bool IsDeletable() const { return true; }
6727 }; 7001 };
6728 7002
6729 7003
6730 class HTrapAllocationMemento : public HTemplateInstruction<1> { 7004 class HTrapAllocationMemento : public HTemplateInstruction<1> {
6731 public: 7005 public:
6732 explicit HTrapAllocationMemento(HValue* obj) { 7006 DECLARE_INSTRUCTION_FACTORY_P1(HTrapAllocationMemento, HValue*);
6733 SetOperandAt(0, obj);
6734 }
6735 7007
6736 virtual Representation RequiredInputRepresentation(int index) { 7008 virtual Representation RequiredInputRepresentation(int index) {
6737 return Representation::Tagged(); 7009 return Representation::Tagged();
6738 } 7010 }
6739 7011
6740 HValue* object() { return OperandAt(0); } 7012 HValue* object() { return OperandAt(0); }
6741 7013
6742 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento) 7014 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento)
7015
7016 private:
7017 explicit HTrapAllocationMemento(HValue* obj) {
7018 SetOperandAt(0, obj);
7019 }
6743 }; 7020 };
6744 7021
6745 7022
6746 class HToFastProperties: public HUnaryOperation { 7023 class HToFastProperties: public HUnaryOperation {
6747 public: 7024 public:
7025 DECLARE_INSTRUCTION_FACTORY_P1(HToFastProperties, HValue*);
7026
7027 virtual Representation RequiredInputRepresentation(int index) {
7028 return Representation::Tagged();
7029 }
7030
7031 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties)
7032
7033 private:
6748 explicit HToFastProperties(HValue* value) : HUnaryOperation(value) { 7034 explicit HToFastProperties(HValue* value) : HUnaryOperation(value) {
6749 // This instruction is not marked as having side effects, but 7035 // This instruction is not marked as having side effects, but
6750 // changes the map of the input operand. Use it only when creating 7036 // changes the map of the input operand. Use it only when creating
6751 // object literals via a runtime call. 7037 // object literals via a runtime call.
6752 ASSERT(value->IsCallRuntime()); 7038 ASSERT(value->IsCallRuntime());
6753 #ifdef DEBUG 7039 #ifdef DEBUG
6754 const Runtime::Function* function = HCallRuntime::cast(value)->function(); 7040 const Runtime::Function* function = HCallRuntime::cast(value)->function();
6755 ASSERT(function->function_id == Runtime::kCreateObjectLiteral || 7041 ASSERT(function->function_id == Runtime::kCreateObjectLiteral ||
6756 function->function_id == Runtime::kCreateObjectLiteralShallow); 7042 function->function_id == Runtime::kCreateObjectLiteralShallow);
6757 #endif 7043 #endif
6758 set_representation(Representation::Tagged()); 7044 set_representation(Representation::Tagged());
6759 } 7045 }
6760 7046
6761 virtual Representation RequiredInputRepresentation(int index) {
6762 return Representation::Tagged();
6763 }
6764
6765 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties)
6766
6767 private:
6768 virtual bool IsDeletable() const { return true; } 7047 virtual bool IsDeletable() const { return true; }
6769 }; 7048 };
6770 7049
6771 7050
6772 class HValueOf: public HUnaryOperation { 7051 class HValueOf: public HUnaryOperation {
6773 public: 7052 public:
6774 explicit HValueOf(HValue* value) : HUnaryOperation(value) { 7053 explicit HValueOf(HValue* value) : HUnaryOperation(value) {
6775 set_representation(Representation::Tagged()); 7054 set_representation(Representation::Tagged());
6776 } 7055 }
6777 7056
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
6830 7109
6831 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar) 7110 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar)
6832 7111
6833 private: 7112 private:
6834 String::Encoding encoding_; 7113 String::Encoding encoding_;
6835 }; 7114 };
6836 7115
6837 7116
6838 class HCheckMapValue: public HTemplateInstruction<2> { 7117 class HCheckMapValue: public HTemplateInstruction<2> {
6839 public: 7118 public:
6840 HCheckMapValue(HValue* value, 7119 DECLARE_INSTRUCTION_FACTORY_P2(HCheckMapValue, HValue*, HValue*);
6841 HValue* map) {
6842 SetOperandAt(0, value);
6843 SetOperandAt(1, map);
6844 set_representation(Representation::Tagged());
6845 SetFlag(kUseGVN);
6846 SetGVNFlag(kDependsOnMaps);
6847 SetGVNFlag(kDependsOnElementsKind);
6848 }
6849 7120
6850 virtual Representation RequiredInputRepresentation(int index) { 7121 virtual Representation RequiredInputRepresentation(int index) {
6851 return Representation::Tagged(); 7122 return Representation::Tagged();
6852 } 7123 }
6853 7124
6854 virtual void PrintDataTo(StringStream* stream); 7125 virtual void PrintDataTo(StringStream* stream);
6855 7126
6856 virtual HType CalculateInferredType() { 7127 virtual HType CalculateInferredType() {
6857 return HType::Tagged(); 7128 return HType::Tagged();
6858 } 7129 }
6859 7130
6860 HValue* value() { return OperandAt(0); } 7131 HValue* value() { return OperandAt(0); }
6861 HValue* map() { return OperandAt(1); } 7132 HValue* map() { return OperandAt(1); }
6862 7133
6863 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue) 7134 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue)
6864 7135
6865 protected: 7136 protected:
6866 virtual bool DataEquals(HValue* other) { 7137 virtual bool DataEquals(HValue* other) {
6867 return true; 7138 return true;
6868 } 7139 }
7140
7141 private:
7142 HCheckMapValue(HValue* value,
7143 HValue* map) {
7144 SetOperandAt(0, value);
7145 SetOperandAt(1, map);
7146 set_representation(Representation::Tagged());
7147 SetFlag(kUseGVN);
7148 SetGVNFlag(kDependsOnMaps);
7149 SetGVNFlag(kDependsOnElementsKind);
7150 }
6869 }; 7151 };
6870 7152
6871 7153
6872 class HForInPrepareMap : public HTemplateInstruction<2> { 7154 class HForInPrepareMap : public HTemplateInstruction<2> {
6873 public: 7155 public:
6874 HForInPrepareMap(HValue* context, 7156 static HForInPrepareMap* New(Zone* zone,
6875 HValue* object) { 7157 HValue* context,
6876 SetOperandAt(0, context); 7158 HValue* object) {
6877 SetOperandAt(1, object); 7159 return new(zone) HForInPrepareMap(context, object);
6878 set_representation(Representation::Tagged());
6879 SetAllSideEffects();
6880 } 7160 }
6881 7161
6882 virtual Representation RequiredInputRepresentation(int index) { 7162 virtual Representation RequiredInputRepresentation(int index) {
6883 return Representation::Tagged(); 7163 return Representation::Tagged();
6884 } 7164 }
6885 7165
6886 HValue* context() { return OperandAt(0); } 7166 HValue* context() { return OperandAt(0); }
6887 HValue* enumerable() { return OperandAt(1); } 7167 HValue* enumerable() { return OperandAt(1); }
6888 7168
6889 virtual void PrintDataTo(StringStream* stream); 7169 virtual void PrintDataTo(StringStream* stream);
6890 7170
6891 virtual HType CalculateInferredType() { 7171 virtual HType CalculateInferredType() {
6892 return HType::Tagged(); 7172 return HType::Tagged();
6893 } 7173 }
6894 7174
6895 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap); 7175 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap);
7176
7177 private:
7178 HForInPrepareMap(HValue* context,
7179 HValue* object) {
7180 SetOperandAt(0, context);
7181 SetOperandAt(1, object);
7182 set_representation(Representation::Tagged());
7183 SetAllSideEffects();
7184 }
6896 }; 7185 };
6897 7186
6898 7187
6899 class HForInCacheArray : public HTemplateInstruction<2> { 7188 class HForInCacheArray : public HTemplateInstruction<2> {
6900 public: 7189 public:
6901 HForInCacheArray(HValue* enumerable, 7190 DECLARE_INSTRUCTION_FACTORY_P3(HForInCacheArray, HValue*, HValue*, int);
6902 HValue* keys,
6903 int idx) : idx_(idx) {
6904 SetOperandAt(0, enumerable);
6905 SetOperandAt(1, keys);
6906 set_representation(Representation::Tagged());
6907 }
6908 7191
6909 virtual Representation RequiredInputRepresentation(int index) { 7192 virtual Representation RequiredInputRepresentation(int index) {
6910 return Representation::Tagged(); 7193 return Representation::Tagged();
6911 } 7194 }
6912 7195
6913 HValue* enumerable() { return OperandAt(0); } 7196 HValue* enumerable() { return OperandAt(0); }
6914 HValue* map() { return OperandAt(1); } 7197 HValue* map() { return OperandAt(1); }
6915 int idx() { return idx_; } 7198 int idx() { return idx_; }
6916 7199
6917 HForInCacheArray* index_cache() { 7200 HForInCacheArray* index_cache() {
6918 return index_cache_; 7201 return index_cache_;
6919 } 7202 }
6920 7203
6921 void set_index_cache(HForInCacheArray* index_cache) { 7204 void set_index_cache(HForInCacheArray* index_cache) {
6922 index_cache_ = index_cache; 7205 index_cache_ = index_cache;
6923 } 7206 }
6924 7207
6925 virtual void PrintDataTo(StringStream* stream); 7208 virtual void PrintDataTo(StringStream* stream);
6926 7209
6927 virtual HType CalculateInferredType() { 7210 virtual HType CalculateInferredType() {
6928 return HType::Tagged(); 7211 return HType::Tagged();
6929 } 7212 }
6930 7213
6931 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray); 7214 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray);
6932 7215
6933 private: 7216 private:
7217 HForInCacheArray(HValue* enumerable,
7218 HValue* keys,
7219 int idx) : idx_(idx) {
7220 SetOperandAt(0, enumerable);
7221 SetOperandAt(1, keys);
7222 set_representation(Representation::Tagged());
7223 }
7224
6934 int idx_; 7225 int idx_;
6935 HForInCacheArray* index_cache_; 7226 HForInCacheArray* index_cache_;
6936 }; 7227 };
6937 7228
6938 7229
6939 class HLoadFieldByIndex : public HTemplateInstruction<2> { 7230 class HLoadFieldByIndex : public HTemplateInstruction<2> {
6940 public: 7231 public:
6941 HLoadFieldByIndex(HValue* object, 7232 HLoadFieldByIndex(HValue* object,
6942 HValue* index) { 7233 HValue* index) {
6943 SetOperandAt(0, object); 7234 SetOperandAt(0, object);
(...skipping 20 matching lines...) Expand all
6964 virtual bool IsDeletable() const { return true; } 7255 virtual bool IsDeletable() const { return true; }
6965 }; 7256 };
6966 7257
6967 7258
6968 #undef DECLARE_INSTRUCTION 7259 #undef DECLARE_INSTRUCTION
6969 #undef DECLARE_CONCRETE_INSTRUCTION 7260 #undef DECLARE_CONCRETE_INSTRUCTION
6970 7261
6971 } } // namespace v8::internal 7262 } } // namespace v8::internal
6972 7263
6973 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7264 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« src/hydrogen.cc ('K') | « src/hydrogen-bch.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698