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

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 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
« no previous file with comments | « src/hydrogen-bch.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 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.
2000 }; 2100 };
2001 2101
2002 2102
2003 class HArgumentsObject; 2103 class HArgumentsObject;
2004 2104
2005 2105
2006 class HEnterInlined: public HTemplateInstruction<0> { 2106 class HEnterInlined: public HTemplateInstruction<0> {
2007 public: 2107 public:
2008 HEnterInlined(Handle<JSFunction> closure, 2108 static HEnterInlined* New(Zone* zone,
2009 int arguments_count, 2109 HValue* context,
2010 FunctionLiteral* function, 2110 Handle<JSFunction> closure,
2011 InliningKind inlining_kind, 2111 int arguments_count,
2012 Variable* arguments_var, 2112 FunctionLiteral* function,
2013 HArgumentsObject* arguments_object, 2113 InliningKind inlining_kind,
2014 bool undefined_receiver, 2114 Variable* arguments_var,
2015 Zone* zone) 2115 HArgumentsObject* arguments_object,
2016 : closure_(closure), 2116 bool undefined_receiver) {
2017 arguments_count_(arguments_count), 2117 return new(zone) HEnterInlined(closure, arguments_count, function,
2018 arguments_pushed_(false), 2118 inlining_kind, arguments_var,
2019 function_(function), 2119 arguments_object, undefined_receiver, zone);
2020 inlining_kind_(inlining_kind),
2021 arguments_var_(arguments_var),
2022 arguments_object_(arguments_object),
2023 undefined_receiver_(undefined_receiver),
2024 return_targets_(2, zone) {
2025 } 2120 }
2026 2121
2027 void RegisterReturnTarget(HBasicBlock* return_target, Zone* zone); 2122 void RegisterReturnTarget(HBasicBlock* return_target, Zone* zone);
2028 ZoneList<HBasicBlock*>* return_targets() { return &return_targets_; } 2123 ZoneList<HBasicBlock*>* return_targets() { return &return_targets_; }
2029 2124
2030 virtual void PrintDataTo(StringStream* stream); 2125 virtual void PrintDataTo(StringStream* stream);
2031 2126
2032 Handle<JSFunction> closure() const { return closure_; } 2127 Handle<JSFunction> closure() const { return closure_; }
2033 int arguments_count() const { return arguments_count_; } 2128 int arguments_count() const { return arguments_count_; }
2034 bool arguments_pushed() const { return arguments_pushed_; } 2129 bool arguments_pushed() const { return arguments_pushed_; }
2035 void set_arguments_pushed() { arguments_pushed_ = true; } 2130 void set_arguments_pushed() { arguments_pushed_ = true; }
2036 FunctionLiteral* function() const { return function_; } 2131 FunctionLiteral* function() const { return function_; }
2037 InliningKind inlining_kind() const { return inlining_kind_; } 2132 InliningKind inlining_kind() const { return inlining_kind_; }
2038 bool undefined_receiver() const { return undefined_receiver_; } 2133 bool undefined_receiver() const { return undefined_receiver_; }
2039 2134
2040 virtual Representation RequiredInputRepresentation(int index) { 2135 virtual Representation RequiredInputRepresentation(int index) {
2041 return Representation::None(); 2136 return Representation::None();
2042 } 2137 }
2043 2138
2044 Variable* arguments_var() { return arguments_var_; } 2139 Variable* arguments_var() { return arguments_var_; }
2045 HArgumentsObject* arguments_object() { return arguments_object_; } 2140 HArgumentsObject* arguments_object() { return arguments_object_; }
2046 2141
2047 DECLARE_CONCRETE_INSTRUCTION(EnterInlined) 2142 DECLARE_CONCRETE_INSTRUCTION(EnterInlined)
2048 2143
2049 private: 2144 private:
2145 HEnterInlined(Handle<JSFunction> closure,
2146 int arguments_count,
2147 FunctionLiteral* function,
2148 InliningKind inlining_kind,
2149 Variable* arguments_var,
2150 HArgumentsObject* arguments_object,
2151 bool undefined_receiver,
2152 Zone* zone)
2153 : closure_(closure),
2154 arguments_count_(arguments_count),
2155 arguments_pushed_(false),
2156 function_(function),
2157 inlining_kind_(inlining_kind),
2158 arguments_var_(arguments_var),
2159 arguments_object_(arguments_object),
2160 undefined_receiver_(undefined_receiver),
2161 return_targets_(2, zone) {
2162 }
2163
2050 Handle<JSFunction> closure_; 2164 Handle<JSFunction> closure_;
2051 int arguments_count_; 2165 int arguments_count_;
2052 bool arguments_pushed_; 2166 bool arguments_pushed_;
2053 FunctionLiteral* function_; 2167 FunctionLiteral* function_;
2054 InliningKind inlining_kind_; 2168 InliningKind inlining_kind_;
2055 Variable* arguments_var_; 2169 Variable* arguments_var_;
2056 HArgumentsObject* arguments_object_; 2170 HArgumentsObject* arguments_object_;
2057 bool undefined_receiver_; 2171 bool undefined_receiver_;
2058 ZoneList<HBasicBlock*> return_targets_; 2172 ZoneList<HBasicBlock*> return_targets_;
2059 }; 2173 };
2060 2174
2061 2175
2062 class HLeaveInlined: public HTemplateInstruction<0> { 2176 class HLeaveInlined: public HTemplateInstruction<0> {
2063 public: 2177 public:
2064 HLeaveInlined() { } 2178 HLeaveInlined() { }
2065 2179
2066 virtual Representation RequiredInputRepresentation(int index) { 2180 virtual Representation RequiredInputRepresentation(int index) {
2067 return Representation::None(); 2181 return Representation::None();
2068 } 2182 }
2069 2183
2070 DECLARE_CONCRETE_INSTRUCTION(LeaveInlined) 2184 DECLARE_CONCRETE_INSTRUCTION(LeaveInlined)
2071 }; 2185 };
2072 2186
2073 2187
2074 class HPushArgument: public HUnaryOperation { 2188 class HPushArgument: public HUnaryOperation {
2075 public: 2189 public:
2076 explicit HPushArgument(HValue* value) : HUnaryOperation(value) { 2190 DECLARE_INSTRUCTION_FACTORY_P1(HPushArgument, HValue*);
2077 set_representation(Representation::Tagged());
2078 }
2079 2191
2080 virtual Representation RequiredInputRepresentation(int index) { 2192 virtual Representation RequiredInputRepresentation(int index) {
2081 return Representation::Tagged(); 2193 return Representation::Tagged();
2082 } 2194 }
2083 2195
2084 HValue* argument() { return OperandAt(0); } 2196 HValue* argument() { return OperandAt(0); }
2085 2197
2086 DECLARE_CONCRETE_INSTRUCTION(PushArgument) 2198 DECLARE_CONCRETE_INSTRUCTION(PushArgument)
2199
2200 private:
2201 explicit HPushArgument(HValue* value) : HUnaryOperation(value) {
2202 set_representation(Representation::Tagged());
2203 }
2087 }; 2204 };
2088 2205
2089 2206
2090 class HThisFunction: public HTemplateInstruction<0> { 2207 class HThisFunction: public HTemplateInstruction<0> {
2091 public: 2208 public:
2092 HThisFunction() { 2209 HThisFunction() {
2093 set_representation(Representation::Tagged()); 2210 set_representation(Representation::Tagged());
2094 SetFlag(kUseGVN); 2211 SetFlag(kUseGVN);
2095 } 2212 }
2096 2213
2097 virtual Representation RequiredInputRepresentation(int index) { 2214 virtual Representation RequiredInputRepresentation(int index) {
2098 return Representation::None(); 2215 return Representation::None();
2099 } 2216 }
2100 2217
2101 DECLARE_CONCRETE_INSTRUCTION(ThisFunction) 2218 DECLARE_CONCRETE_INSTRUCTION(ThisFunction)
2102 2219
2103 protected: 2220 protected:
2104 virtual bool DataEquals(HValue* other) { return true; } 2221 virtual bool DataEquals(HValue* other) { return true; }
2105 2222
2106 private: 2223 private:
2107 virtual bool IsDeletable() const { return true; } 2224 virtual bool IsDeletable() const { return true; }
2108 }; 2225 };
2109 2226
2110 2227
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 { 2228 class HOuterContext: public HUnaryOperation {
2133 public: 2229 public:
2134 explicit HOuterContext(HValue* inner) : HUnaryOperation(inner) { 2230 DECLARE_INSTRUCTION_FACTORY_P1(HOuterContext, HValue*);
2135 set_representation(Representation::Tagged());
2136 SetFlag(kUseGVN);
2137 }
2138 2231
2139 DECLARE_CONCRETE_INSTRUCTION(OuterContext); 2232 DECLARE_CONCRETE_INSTRUCTION(OuterContext);
2140 2233
2141 virtual Representation RequiredInputRepresentation(int index) { 2234 virtual Representation RequiredInputRepresentation(int index) {
2142 return Representation::Tagged(); 2235 return Representation::Tagged();
2143 } 2236 }
2144 2237
2145 protected: 2238 protected:
2146 virtual bool DataEquals(HValue* other) { return true; } 2239 virtual bool DataEquals(HValue* other) { return true; }
2147 2240
2148 private: 2241 private:
2242 explicit HOuterContext(HValue* inner) : HUnaryOperation(inner) {
2243 set_representation(Representation::Tagged());
2244 SetFlag(kUseGVN);
2245 }
2246
2149 virtual bool IsDeletable() const { return true; } 2247 virtual bool IsDeletable() const { return true; }
2150 }; 2248 };
2151 2249
2152 2250
2153 class HDeclareGlobals: public HUnaryOperation { 2251 class HDeclareGlobals: public HUnaryOperation {
2154 public: 2252 public:
2155 HDeclareGlobals(HValue* context, 2253 HDeclareGlobals(HValue* context,
2156 Handle<FixedArray> pairs, 2254 Handle<FixedArray> pairs,
2157 int flags) 2255 int flags)
2158 : HUnaryOperation(context), 2256 : HUnaryOperation(context),
2159 pairs_(pairs), 2257 pairs_(pairs),
2160 flags_(flags) { 2258 flags_(flags) {
2161 set_representation(Representation::Tagged()); 2259 set_representation(Representation::Tagged());
2162 SetAllSideEffects(); 2260 SetAllSideEffects();
2163 } 2261 }
2164 2262
2263 static HDeclareGlobals* New(Zone* zone,
2264 HValue* context,
2265 Handle<FixedArray> pairs,
2266 int flags) {
2267 return new(zone) HDeclareGlobals(context, pairs, flags);
2268 }
2269
2165 HValue* context() { return OperandAt(0); } 2270 HValue* context() { return OperandAt(0); }
2166 Handle<FixedArray> pairs() const { return pairs_; } 2271 Handle<FixedArray> pairs() const { return pairs_; }
2167 int flags() const { return flags_; } 2272 int flags() const { return flags_; }
2168 2273
2169 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals) 2274 DECLARE_CONCRETE_INSTRUCTION(DeclareGlobals)
2170 2275
2171 virtual Representation RequiredInputRepresentation(int index) { 2276 virtual Representation RequiredInputRepresentation(int index) {
2172 return Representation::Tagged(); 2277 return Representation::Tagged();
2173 } 2278 }
2279
2174 private: 2280 private:
2175 Handle<FixedArray> pairs_; 2281 Handle<FixedArray> pairs_;
2176 int flags_; 2282 int flags_;
2177 }; 2283 };
2178 2284
2179 2285
2180 class HGlobalObject: public HUnaryOperation { 2286 class HGlobalObject: public HUnaryOperation {
2181 public: 2287 public:
2182 explicit HGlobalObject(HValue* context) : HUnaryOperation(context) { 2288 explicit HGlobalObject(HValue* context) : HUnaryOperation(context) {
2183 set_representation(Representation::Tagged()); 2289 set_representation(Representation::Tagged());
2184 SetFlag(kUseGVN); 2290 SetFlag(kUseGVN);
2185 } 2291 }
2186 2292
2293 static HGlobalObject* New(Zone* zone, HValue* context) {
2294 return new(zone) HGlobalObject(context);
2295 }
2296
2187 DECLARE_CONCRETE_INSTRUCTION(GlobalObject) 2297 DECLARE_CONCRETE_INSTRUCTION(GlobalObject)
2188 2298
2189 virtual Representation RequiredInputRepresentation(int index) { 2299 virtual Representation RequiredInputRepresentation(int index) {
2190 return Representation::Tagged(); 2300 return Representation::Tagged();
2191 } 2301 }
2192 2302
2193 protected: 2303 protected:
2194 virtual bool DataEquals(HValue* other) { return true; } 2304 virtual bool DataEquals(HValue* other) { return true; }
2195 2305
2196 private: 2306 private:
2197 virtual bool IsDeletable() const { return true; } 2307 virtual bool IsDeletable() const { return true; }
2198 }; 2308 };
2199 2309
2200 2310
2201 class HGlobalReceiver: public HUnaryOperation { 2311 class HGlobalReceiver: public HUnaryOperation {
2202 public: 2312 public:
2203 explicit HGlobalReceiver(HValue* global_object) 2313 DECLARE_INSTRUCTION_FACTORY_P1(HGlobalReceiver, HValue*);
2204 : HUnaryOperation(global_object) {
2205 set_representation(Representation::Tagged());
2206 SetFlag(kUseGVN);
2207 }
2208 2314
2209 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver) 2315 DECLARE_CONCRETE_INSTRUCTION(GlobalReceiver)
2210 2316
2211 virtual Representation RequiredInputRepresentation(int index) { 2317 virtual Representation RequiredInputRepresentation(int index) {
2212 return Representation::Tagged(); 2318 return Representation::Tagged();
2213 } 2319 }
2214 2320
2215 protected: 2321 protected:
2216 virtual bool DataEquals(HValue* other) { return true; } 2322 virtual bool DataEquals(HValue* other) { return true; }
2217 2323
2218 private: 2324 private:
2325 explicit HGlobalReceiver(HValue* global_object)
2326 : HUnaryOperation(global_object) {
2327 set_representation(Representation::Tagged());
2328 SetFlag(kUseGVN);
2329 }
2330
2219 virtual bool IsDeletable() const { return true; } 2331 virtual bool IsDeletable() const { return true; }
2220 }; 2332 };
2221 2333
2222 2334
2223 template <int V> 2335 template <int V>
2224 class HCall: public HTemplateInstruction<V> { 2336 class HCall: public HTemplateInstruction<V> {
2225 public: 2337 public:
2226 // The argument count includes the receiver. 2338 // The argument count includes the receiver.
2227 explicit HCall<V>(int argument_count) : argument_count_(argument_count) { 2339 explicit HCall<V>(int argument_count) : argument_count_(argument_count) {
2228 this->set_representation(Representation::Tagged()); 2340 this->set_representation(Representation::Tagged());
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
2275 HValue* second() { return OperandAt(1); } 2387 HValue* second() { return OperandAt(1); }
2276 }; 2388 };
2277 2389
2278 2390
2279 class HInvokeFunction: public HBinaryCall { 2391 class HInvokeFunction: public HBinaryCall {
2280 public: 2392 public:
2281 HInvokeFunction(HValue* context, HValue* function, int argument_count) 2393 HInvokeFunction(HValue* context, HValue* function, int argument_count)
2282 : HBinaryCall(context, function, argument_count) { 2394 : HBinaryCall(context, function, argument_count) {
2283 } 2395 }
2284 2396
2397 static HInvokeFunction* New(Zone* zone,
2398 HValue* context,
2399 HValue* function,
2400 int argument_count) {
2401 return new(zone) HInvokeFunction(context, function, argument_count);
2402 }
2403
2285 HInvokeFunction(HValue* context, 2404 HInvokeFunction(HValue* context,
2286 HValue* function, 2405 HValue* function,
2287 Handle<JSFunction> known_function, 2406 Handle<JSFunction> known_function,
2288 int argument_count) 2407 int argument_count)
2289 : HBinaryCall(context, function, argument_count), 2408 : HBinaryCall(context, function, argument_count),
2290 known_function_(known_function) { 2409 known_function_(known_function) {
2291 formal_parameter_count_ = known_function.is_null() 2410 formal_parameter_count_ = known_function.is_null()
2292 ? 0 : known_function->shared()->formal_parameter_count(); 2411 ? 0 : known_function->shared()->formal_parameter_count();
2293 } 2412 }
2294 2413
2414 static HInvokeFunction* New(Zone* zone,
2415 HValue* context,
2416 HValue* function,
2417 Handle<JSFunction> known_function,
2418 int argument_count) {
2419 return new(zone) HInvokeFunction(context, function,
2420 known_function, argument_count);
2421 }
2422
2295 virtual Representation RequiredInputRepresentation(int index) { 2423 virtual Representation RequiredInputRepresentation(int index) {
2296 return Representation::Tagged(); 2424 return Representation::Tagged();
2297 } 2425 }
2298 2426
2299 HValue* context() { return first(); } 2427 HValue* context() { return first(); }
2300 HValue* function() { return second(); } 2428 HValue* function() { return second(); }
2301 Handle<JSFunction> known_function() { return known_function_; } 2429 Handle<JSFunction> known_function() { return known_function_; }
2302 int formal_parameter_count() const { return formal_parameter_count_; } 2430 int formal_parameter_count() const { return formal_parameter_count_; }
2303 2431
2304 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction) 2432 DECLARE_CONCRETE_INSTRUCTION(InvokeFunction)
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
2376 Handle<String> name_; 2504 Handle<String> name_;
2377 }; 2505 };
2378 2506
2379 2507
2380 class HCallFunction: public HBinaryCall { 2508 class HCallFunction: public HBinaryCall {
2381 public: 2509 public:
2382 HCallFunction(HValue* context, HValue* function, int argument_count) 2510 HCallFunction(HValue* context, HValue* function, int argument_count)
2383 : HBinaryCall(context, function, argument_count) { 2511 : HBinaryCall(context, function, argument_count) {
2384 } 2512 }
2385 2513
2514 static HCallFunction* New(Zone* zone,
2515 HValue* context,
2516 HValue* function,
2517 int argument_count) {
2518 return new(zone) HCallFunction(context, function, argument_count);
2519 }
2520
2386 HValue* context() { return first(); } 2521 HValue* context() { return first(); }
2387 HValue* function() { return second(); } 2522 HValue* function() { return second(); }
2388 2523
2389 virtual Representation RequiredInputRepresentation(int index) { 2524 virtual Representation RequiredInputRepresentation(int index) {
2390 return Representation::Tagged(); 2525 return Representation::Tagged();
2391 } 2526 }
2392 2527
2393 DECLARE_CONCRETE_INSTRUCTION(CallFunction) 2528 DECLARE_CONCRETE_INSTRUCTION(CallFunction)
2394 }; 2529 };
2395 2530
2396 2531
2397 class HCallGlobal: public HUnaryCall { 2532 class HCallGlobal: public HUnaryCall {
2398 public: 2533 public:
2399 HCallGlobal(HValue* context, Handle<String> name, int argument_count) 2534 HCallGlobal(HValue* context, Handle<String> name, int argument_count)
2400 : HUnaryCall(context, argument_count), name_(name) { 2535 : HUnaryCall(context, argument_count), name_(name) {
2401 } 2536 }
2402 2537
2538 static HCallGlobal* New(Zone* zone,
2539 HValue* context,
2540 Handle<String> name,
2541 int argument_count) {
2542 return new(zone) HCallGlobal(context, name, argument_count);
2543 }
2544
2403 virtual void PrintDataTo(StringStream* stream); 2545 virtual void PrintDataTo(StringStream* stream);
2404 2546
2405 HValue* context() { return value(); } 2547 HValue* context() { return value(); }
2406 Handle<String> name() const { return name_; } 2548 Handle<String> name() const { return name_; }
2407 2549
2408 virtual Representation RequiredInputRepresentation(int index) { 2550 virtual Representation RequiredInputRepresentation(int index) {
2409 return Representation::Tagged(); 2551 return Representation::Tagged();
2410 } 2552 }
2411 2553
2412 DECLARE_CONCRETE_INSTRUCTION(CallGlobal) 2554 DECLARE_CONCRETE_INSTRUCTION(CallGlobal)
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2476 DECLARE_CONCRETE_INSTRUCTION(CallNewArray) 2618 DECLARE_CONCRETE_INSTRUCTION(CallNewArray)
2477 2619
2478 private: 2620 private:
2479 ElementsKind elements_kind_; 2621 ElementsKind elements_kind_;
2480 Handle<Cell> type_cell_; 2622 Handle<Cell> type_cell_;
2481 }; 2623 };
2482 2624
2483 2625
2484 class HCallRuntime: public HCall<1> { 2626 class HCallRuntime: public HCall<1> {
2485 public: 2627 public:
2486 HCallRuntime(HValue* context, 2628 static HCallRuntime* New(Zone* zone,
2487 Handle<String> name, 2629 HValue* context,
2488 const Runtime::Function* c_function, 2630 Handle<String> name,
2489 int argument_count) 2631 const Runtime::Function* c_function,
2490 : HCall<1>(argument_count), c_function_(c_function), name_(name) { 2632 int argument_count) {
2491 SetOperandAt(0, context); 2633 return new(zone) HCallRuntime(context, name, c_function, argument_count);
2492 } 2634 }
2493 2635
2494 virtual void PrintDataTo(StringStream* stream); 2636 virtual void PrintDataTo(StringStream* stream);
2495 2637
2496 HValue* context() { return OperandAt(0); } 2638 HValue* context() { return OperandAt(0); }
2497 const Runtime::Function* function() const { return c_function_; } 2639 const Runtime::Function* function() const { return c_function_; }
2498 Handle<String> name() const { return name_; } 2640 Handle<String> name() const { return name_; }
2499 2641
2500 virtual Representation RequiredInputRepresentation(int index) { 2642 virtual Representation RequiredInputRepresentation(int index) {
2501 return Representation::Tagged(); 2643 return Representation::Tagged();
2502 } 2644 }
2503 2645
2504 DECLARE_CONCRETE_INSTRUCTION(CallRuntime) 2646 DECLARE_CONCRETE_INSTRUCTION(CallRuntime)
2505 2647
2506 private: 2648 private:
2649 HCallRuntime(HValue* context,
2650 Handle<String> name,
2651 const Runtime::Function* c_function,
2652 int argument_count)
2653 : HCall<1>(argument_count), c_function_(c_function), name_(name) {
2654 SetOperandAt(0, context);
2655 }
2656
2507 const Runtime::Function* c_function_; 2657 const Runtime::Function* c_function_;
2508 Handle<String> name_; 2658 Handle<String> name_;
2509 }; 2659 };
2510 2660
2511 2661
2512 class HMapEnumLength: public HUnaryOperation { 2662 class HMapEnumLength: public HUnaryOperation {
2513 public: 2663 public:
2514 explicit HMapEnumLength(HValue* value) 2664 DECLARE_INSTRUCTION_FACTORY_P1(HMapEnumLength, HValue*);
2515 : HUnaryOperation(value, HType::Smi()) {
2516 set_representation(Representation::Smi());
2517 SetFlag(kUseGVN);
2518 SetGVNFlag(kDependsOnMaps);
2519 }
2520 2665
2521 virtual Representation RequiredInputRepresentation(int index) { 2666 virtual Representation RequiredInputRepresentation(int index) {
2522 return Representation::Tagged(); 2667 return Representation::Tagged();
2523 } 2668 }
2524 2669
2525 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength) 2670 DECLARE_CONCRETE_INSTRUCTION(MapEnumLength)
2526 2671
2527 protected: 2672 protected:
2528 virtual bool DataEquals(HValue* other) { return true; } 2673 virtual bool DataEquals(HValue* other) { return true; }
2529 2674
2530 private: 2675 private:
2676 explicit HMapEnumLength(HValue* value)
2677 : HUnaryOperation(value, HType::Smi()) {
2678 set_representation(Representation::Smi());
2679 SetFlag(kUseGVN);
2680 SetGVNFlag(kDependsOnMaps);
2681 }
2682
2531 virtual bool IsDeletable() const { return true; } 2683 virtual bool IsDeletable() const { return true; }
2532 }; 2684 };
2533 2685
2534 2686
2535 class HElementsKind: public HUnaryOperation { 2687 class HElementsKind: public HUnaryOperation {
2536 public: 2688 public:
2537 explicit HElementsKind(HValue* value) : HUnaryOperation(value) { 2689 explicit HElementsKind(HValue* value) : HUnaryOperation(value) {
2538 set_representation(Representation::Integer32()); 2690 set_representation(Representation::Integer32());
2539 SetFlag(kUseGVN); 2691 SetFlag(kUseGVN);
2540 SetGVNFlag(kDependsOnElementsKind); 2692 SetGVNFlag(kDependsOnElementsKind);
2541 } 2693 }
2542 2694
2543 virtual Representation RequiredInputRepresentation(int index) { 2695 virtual Representation RequiredInputRepresentation(int index) {
2544 return Representation::Tagged(); 2696 return Representation::Tagged();
2545 } 2697 }
2546 2698
2547 DECLARE_CONCRETE_INSTRUCTION(ElementsKind) 2699 DECLARE_CONCRETE_INSTRUCTION(ElementsKind)
2548 2700
2549 protected: 2701 protected:
2550 virtual bool DataEquals(HValue* other) { return true; } 2702 virtual bool DataEquals(HValue* other) { return true; }
2551 2703
2552 private: 2704 private:
2553 virtual bool IsDeletable() const { return true; } 2705 virtual bool IsDeletable() const { return true; }
2554 }; 2706 };
2555 2707
2556 2708
2557 class HBitNot: public HUnaryOperation { 2709 class HBitNot: public HUnaryOperation {
2558 public: 2710 public:
2559 explicit HBitNot(HValue* value) 2711 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 2712
2567 virtual Representation RequiredInputRepresentation(int index) { 2713 virtual Representation RequiredInputRepresentation(int index) {
2568 return Representation::Integer32(); 2714 return Representation::Integer32();
2569 } 2715 }
2570 virtual Representation observed_input_representation(int index) { 2716 virtual Representation observed_input_representation(int index) {
2571 return Representation::Integer32(); 2717 return Representation::Integer32();
2572 } 2718 }
2573 2719
2574 virtual HValue* Canonicalize(); 2720 virtual HValue* Canonicalize();
2575 2721
2576 DECLARE_CONCRETE_INSTRUCTION(BitNot) 2722 DECLARE_CONCRETE_INSTRUCTION(BitNot)
2577 2723
2578 protected: 2724 protected:
2579 virtual bool DataEquals(HValue* other) { return true; } 2725 virtual bool DataEquals(HValue* other) { return true; }
2580 2726
2581 private: 2727 private:
2728 explicit HBitNot(HValue* value)
2729 : HUnaryOperation(value, HType::TaggedNumber()) {
2730 set_representation(Representation::Integer32());
2731 SetFlag(kUseGVN);
2732 SetFlag(kTruncatingToInt32);
2733 SetFlag(kAllowUndefinedAsNaN);
2734 }
2735
2582 virtual bool IsDeletable() const { return true; } 2736 virtual bool IsDeletable() const { return true; }
2583 }; 2737 };
2584 2738
2585 2739
2586 class HUnaryMathOperation: public HTemplateInstruction<2> { 2740 class HUnaryMathOperation: public HTemplateInstruction<2> {
2587 public: 2741 public:
2588 static HInstruction* New(Zone* zone, 2742 static HInstruction* New(Zone* zone,
2589 HValue* context, 2743 HValue* context,
2590 HValue* value, 2744 HValue* value,
2591 BuiltinFunctionId op); 2745 BuiltinFunctionId op);
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after
2676 } 2830 }
2677 2831
2678 virtual bool IsDeletable() const { return true; } 2832 virtual bool IsDeletable() const { return true; }
2679 2833
2680 BuiltinFunctionId op_; 2834 BuiltinFunctionId op_;
2681 }; 2835 };
2682 2836
2683 2837
2684 class HLoadExternalArrayPointer: public HUnaryOperation { 2838 class HLoadExternalArrayPointer: public HUnaryOperation {
2685 public: 2839 public:
2686 explicit HLoadExternalArrayPointer(HValue* value) 2840 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 2841
2696 virtual Representation RequiredInputRepresentation(int index) { 2842 virtual Representation RequiredInputRepresentation(int index) {
2697 return Representation::Tagged(); 2843 return Representation::Tagged();
2698 } 2844 }
2699 2845
2700 virtual HType CalculateInferredType() { 2846 virtual HType CalculateInferredType() {
2701 return HType::None(); 2847 return HType::None();
2702 } 2848 }
2703 2849
2704 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer) 2850 DECLARE_CONCRETE_INSTRUCTION(LoadExternalArrayPointer)
2705 2851
2706 protected: 2852 protected:
2707 virtual bool DataEquals(HValue* other) { return true; } 2853 virtual bool DataEquals(HValue* other) { return true; }
2708 2854
2709 private: 2855 private:
2856 explicit HLoadExternalArrayPointer(HValue* value)
2857 : HUnaryOperation(value) {
2858 set_representation(Representation::External());
2859 // The result of this instruction is idempotent as long as its inputs don't
2860 // change. The external array of a specialized array elements object cannot
2861 // change once set, so it's no necessary to introduce any additional
2862 // dependencies on top of the inputs.
2863 SetFlag(kUseGVN);
2864 }
2865
2710 virtual bool IsDeletable() const { return true; } 2866 virtual bool IsDeletable() const { return true; }
2711 }; 2867 };
2712 2868
2713 2869
2714 class HCheckMaps: public HTemplateInstruction<2> { 2870 class HCheckMaps: public HTemplateInstruction<2> {
2715 public: 2871 public:
2716 static HCheckMaps* New(HValue* value, Handle<Map> map, Zone* zone, 2872 static HCheckMaps* New(Zone* zone, HValue* context, HValue* value,
2717 CompilationInfo* info, HValue *typecheck = NULL); 2873 Handle<Map> map, CompilationInfo* info,
2718 static HCheckMaps* New(HValue* value, SmallMapList* maps, Zone* zone, 2874 HValue *typecheck = NULL);
2875 static HCheckMaps* New(Zone* zone, HValue* context,
2876 HValue* value, SmallMapList* maps,
2719 HValue *typecheck = NULL) { 2877 HValue *typecheck = NULL) {
2720 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck); 2878 HCheckMaps* check_map = new(zone) HCheckMaps(value, zone, typecheck);
2721 for (int i = 0; i < maps->length(); i++) { 2879 for (int i = 0; i < maps->length(); i++) {
2722 check_map->map_set_.Add(maps->at(i), zone); 2880 check_map->map_set_.Add(maps->at(i), zone);
2723 } 2881 }
2724 check_map->map_set_.Sort(); 2882 check_map->map_set_.Sort();
2725 return check_map; 2883 return check_map;
2726 } 2884 }
2727 2885
2728 bool CanOmitMapChecks() { return omit_; } 2886 bool CanOmitMapChecks() { return omit_; }
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
2784 } 2942 }
2785 2943
2786 bool omit_; 2944 bool omit_;
2787 SmallMapList map_set_; 2945 SmallMapList map_set_;
2788 ZoneList<UniqueValueId> map_unique_ids_; 2946 ZoneList<UniqueValueId> map_unique_ids_;
2789 }; 2947 };
2790 2948
2791 2949
2792 class HCheckFunction: public HUnaryOperation { 2950 class HCheckFunction: public HUnaryOperation {
2793 public: 2951 public:
2794 HCheckFunction(HValue* value, Handle<JSFunction> function) 2952 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 2953
2802 virtual Representation RequiredInputRepresentation(int index) { 2954 virtual Representation RequiredInputRepresentation(int index) {
2803 return Representation::Tagged(); 2955 return Representation::Tagged();
2804 } 2956 }
2805 virtual void PrintDataTo(StringStream* stream); 2957 virtual void PrintDataTo(StringStream* stream);
2806 2958
2807 virtual HValue* Canonicalize(); 2959 virtual HValue* Canonicalize();
2808 2960
2809 #ifdef DEBUG 2961 #ifdef DEBUG
2810 virtual void Verify(); 2962 virtual void Verify();
2811 #endif 2963 #endif
2812 2964
2813 virtual void FinalizeUniqueValueId() { 2965 virtual void FinalizeUniqueValueId() {
2814 target_unique_id_ = UniqueValueId(target_); 2966 target_unique_id_ = UniqueValueId(target_);
2815 } 2967 }
2816 2968
2817 Handle<JSFunction> target() const { return target_; } 2969 Handle<JSFunction> target() const { return target_; }
2818 bool target_in_new_space() const { return target_in_new_space_; } 2970 bool target_in_new_space() const { return target_in_new_space_; }
2819 2971
2820 DECLARE_CONCRETE_INSTRUCTION(CheckFunction) 2972 DECLARE_CONCRETE_INSTRUCTION(CheckFunction)
2821 2973
2822 protected: 2974 protected:
2823 virtual bool DataEquals(HValue* other) { 2975 virtual bool DataEquals(HValue* other) {
2824 HCheckFunction* b = HCheckFunction::cast(other); 2976 HCheckFunction* b = HCheckFunction::cast(other);
2825 return target_unique_id_ == b->target_unique_id_; 2977 return target_unique_id_ == b->target_unique_id_;
2826 } 2978 }
2827 2979
2828 private: 2980 private:
2981 HCheckFunction(HValue* value, Handle<JSFunction> function)
2982 : HUnaryOperation(value, value->type()),
2983 target_(function), target_unique_id_() {
2984 set_representation(Representation::Tagged());
2985 SetFlag(kUseGVN);
2986 target_in_new_space_ = Isolate::Current()->heap()->InNewSpace(*function);
2987 }
2988
2829 Handle<JSFunction> target_; 2989 Handle<JSFunction> target_;
2830 UniqueValueId target_unique_id_; 2990 UniqueValueId target_unique_id_;
2831 bool target_in_new_space_; 2991 bool target_in_new_space_;
2832 }; 2992 };
2833 2993
2834 2994
2835 class HCheckInstanceType: public HUnaryOperation { 2995 class HCheckInstanceType: public HUnaryOperation {
2836 public: 2996 public:
2837 static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) { 2997 static HCheckInstanceType* NewIsSpecObject(HValue* value, Zone* zone) {
2838 return new(zone) HCheckInstanceType(value, IS_SPEC_OBJECT); 2998 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()); 3047 set_representation(Representation::Tagged());
2888 SetFlag(kUseGVN); 3048 SetFlag(kUseGVN);
2889 } 3049 }
2890 3050
2891 const Check check_; 3051 const Check check_;
2892 }; 3052 };
2893 3053
2894 3054
2895 class HCheckSmi: public HUnaryOperation { 3055 class HCheckSmi: public HUnaryOperation {
2896 public: 3056 public:
2897 explicit HCheckSmi(HValue* value) : HUnaryOperation(value, HType::Smi()) { 3057 DECLARE_INSTRUCTION_FACTORY_P1(HCheckSmi, HValue*);
2898 set_representation(Representation::Smi());
2899 SetFlag(kUseGVN);
2900 }
2901 3058
2902 virtual Representation RequiredInputRepresentation(int index) { 3059 virtual Representation RequiredInputRepresentation(int index) {
2903 return Representation::Tagged(); 3060 return Representation::Tagged();
2904 } 3061 }
2905 3062
2906 virtual HValue* Canonicalize() { 3063 virtual HValue* Canonicalize() {
2907 HType value_type = value()->type(); 3064 HType value_type = value()->type();
2908 if (value_type.IsSmi()) { 3065 if (value_type.IsSmi()) {
2909 return NULL; 3066 return NULL;
2910 } 3067 }
2911 return this; 3068 return this;
2912 } 3069 }
2913 3070
2914 DECLARE_CONCRETE_INSTRUCTION(CheckSmi) 3071 DECLARE_CONCRETE_INSTRUCTION(CheckSmi)
2915 3072
2916 protected: 3073 protected:
2917 virtual bool DataEquals(HValue* other) { return true; } 3074 virtual bool DataEquals(HValue* other) { return true; }
3075
3076 private:
3077 explicit HCheckSmi(HValue* value) : HUnaryOperation(value, HType::Smi()) {
3078 set_representation(Representation::Smi());
3079 SetFlag(kUseGVN);
3080 }
2918 }; 3081 };
2919 3082
2920 3083
2921 class HIsNumberAndBranch: public HUnaryControlInstruction { 3084 class HIsNumberAndBranch: public HUnaryControlInstruction {
2922 public: 3085 public:
2923 explicit HIsNumberAndBranch(HValue* value) 3086 explicit HIsNumberAndBranch(HValue* value)
2924 : HUnaryControlInstruction(value, NULL, NULL) { 3087 : HUnaryControlInstruction(value, NULL, NULL) {
2925 SetFlag(kFlexibleRepresentation); 3088 SetFlag(kFlexibleRepresentation);
2926 } 3089 }
2927 3090
2928 virtual Representation RequiredInputRepresentation(int index) { 3091 virtual Representation RequiredInputRepresentation(int index) {
2929 return Representation::None(); 3092 return Representation::None();
2930 } 3093 }
2931 3094
2932 DECLARE_CONCRETE_INSTRUCTION(IsNumberAndBranch) 3095 DECLARE_CONCRETE_INSTRUCTION(IsNumberAndBranch)
2933 }; 3096 };
2934 3097
2935 3098
2936 class HCheckHeapObject: public HUnaryOperation { 3099 class HCheckHeapObject: public HUnaryOperation {
2937 public: 3100 public:
2938 explicit HCheckHeapObject(HValue* value) 3101 DECLARE_INSTRUCTION_FACTORY_P1(HCheckHeapObject, HValue*);
2939 : HUnaryOperation(value, HType::NonPrimitive()) {
2940 set_representation(Representation::Tagged());
2941 SetFlag(kUseGVN);
2942 }
2943 3102
2944 virtual Representation RequiredInputRepresentation(int index) { 3103 virtual Representation RequiredInputRepresentation(int index) {
2945 return Representation::Tagged(); 3104 return Representation::Tagged();
2946 } 3105 }
2947 3106
2948 #ifdef DEBUG 3107 #ifdef DEBUG
2949 virtual void Verify(); 3108 virtual void Verify();
2950 #endif 3109 #endif
2951 3110
2952 virtual HValue* Canonicalize() { 3111 virtual HValue* Canonicalize() {
2953 return value()->type().IsHeapObject() ? NULL : this; 3112 return value()->type().IsHeapObject() ? NULL : this;
2954 } 3113 }
2955 3114
2956 DECLARE_CONCRETE_INSTRUCTION(CheckHeapObject) 3115 DECLARE_CONCRETE_INSTRUCTION(CheckHeapObject)
2957 3116
2958 protected: 3117 protected:
2959 virtual bool DataEquals(HValue* other) { return true; } 3118 virtual bool DataEquals(HValue* other) { return true; }
3119
3120 private:
3121 explicit HCheckHeapObject(HValue* value)
3122 : HUnaryOperation(value, HType::NonPrimitive()) {
3123 set_representation(Representation::Tagged());
3124 SetFlag(kUseGVN);
3125 }
2960 }; 3126 };
2961 3127
2962 3128
2963 class HCheckPrototypeMaps: public HTemplateInstruction<0> { 3129 class HCheckPrototypeMaps: public HTemplateInstruction<0> {
2964 public: 3130 public:
2965 HCheckPrototypeMaps(Handle<JSObject> prototype, 3131 static HCheckPrototypeMaps* New(Zone* zone,
2966 Handle<JSObject> holder, 3132 HValue* context,
2967 Zone* zone, 3133 Handle<JSObject> prototype,
2968 CompilationInfo* info) 3134 Handle<JSObject> holder,
2969 : prototypes_(2, zone), 3135 CompilationInfo* info) {
2970 maps_(2, zone), 3136 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 } 3137 }
2995 3138
2996 ZoneList<Handle<JSObject> >* prototypes() { return &prototypes_; } 3139 ZoneList<Handle<JSObject> >* prototypes() { return &prototypes_; }
2997 3140
2998 ZoneList<Handle<Map> >* maps() { return &maps_; } 3141 ZoneList<Handle<Map> >* maps() { return &maps_; }
2999 3142
3000 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps) 3143 DECLARE_CONCRETE_INSTRUCTION(CheckPrototypeMaps)
3001 3144
3002 virtual Representation RequiredInputRepresentation(int index) { 3145 virtual Representation RequiredInputRepresentation(int index) {
3003 return Representation::None(); 3146 return Representation::None();
(...skipping 14 matching lines...) Expand all
3018 bool CanOmitPrototypeChecks() { return can_omit_prototype_maps_; } 3161 bool CanOmitPrototypeChecks() { return can_omit_prototype_maps_; }
3019 3162
3020 protected: 3163 protected:
3021 virtual bool DataEquals(HValue* other) { 3164 virtual bool DataEquals(HValue* other) {
3022 HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other); 3165 HCheckPrototypeMaps* b = HCheckPrototypeMaps::cast(other);
3023 return first_prototype_unique_id_ == b->first_prototype_unique_id_ && 3166 return first_prototype_unique_id_ == b->first_prototype_unique_id_ &&
3024 last_prototype_unique_id_ == b->last_prototype_unique_id_; 3167 last_prototype_unique_id_ == b->last_prototype_unique_id_;
3025 } 3168 }
3026 3169
3027 private: 3170 private:
3171 HCheckPrototypeMaps(Handle<JSObject> prototype,
3172 Handle<JSObject> holder,
3173 Zone* zone,
3174 CompilationInfo* info)
3175 : prototypes_(2, zone),
3176 maps_(2, zone),
3177 first_prototype_unique_id_(),
3178 last_prototype_unique_id_(),
3179 can_omit_prototype_maps_(true) {
3180 SetFlag(kUseGVN);
3181 SetGVNFlag(kDependsOnMaps);
3182 // Keep a list of all objects on the prototype chain up to the holder
3183 // and the expected maps.
3184 while (true) {
3185 prototypes_.Add(prototype, zone);
3186 Handle<Map> map(prototype->map());
3187 maps_.Add(map, zone);
3188 can_omit_prototype_maps_ &= map->CanOmitPrototypeChecks();
3189 if (prototype.is_identical_to(holder)) break;
3190 prototype = Handle<JSObject>(JSObject::cast(prototype->GetPrototype()));
3191 }
3192 if (can_omit_prototype_maps_) {
3193 // Mark in-flight compilation as dependent on those maps.
3194 for (int i = 0; i < maps()->length(); i++) {
3195 Handle<Map> map = maps()->at(i);
3196 map->AddDependentCompilationInfo(DependentCode::kPrototypeCheckGroup,
3197 info);
3198 }
3199 }
3200 }
3201
3028 ZoneList<Handle<JSObject> > prototypes_; 3202 ZoneList<Handle<JSObject> > prototypes_;
3029 ZoneList<Handle<Map> > maps_; 3203 ZoneList<Handle<Map> > maps_;
3030 UniqueValueId first_prototype_unique_id_; 3204 UniqueValueId first_prototype_unique_id_;
3031 UniqueValueId last_prototype_unique_id_; 3205 UniqueValueId last_prototype_unique_id_;
3032 bool can_omit_prototype_maps_; 3206 bool can_omit_prototype_maps_;
3033 }; 3207 };
3034 3208
3035 3209
3036 class InductionVariableData; 3210 class InductionVariableData;
3037 3211
(...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 3593 // 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). 3594 // and this instruction (inserting an idef updates every use).
3421 HPhi* phi_; 3595 HPhi* phi_;
3422 NumericRelation relation_; 3596 NumericRelation relation_;
3423 int operand_index_; 3597 int operand_index_;
3424 }; 3598 };
3425 3599
3426 3600
3427 class HArgumentsObject: public HTemplateInstruction<0> { 3601 class HArgumentsObject: public HTemplateInstruction<0> {
3428 public: 3602 public:
3429 HArgumentsObject(int count, Zone* zone) : values_(count, zone) { 3603 static HArgumentsObject* New(Zone* zone,
3430 set_representation(Representation::Tagged()); 3604 HValue* context,
3431 SetFlag(kIsArguments); 3605 int count) {
3606 return new(zone) HArgumentsObject(count, zone);
3432 } 3607 }
3433 3608
3434 const ZoneList<HValue*>* arguments_values() const { return &values_; } 3609 const ZoneList<HValue*>* arguments_values() const { return &values_; }
3435 int arguments_count() const { return values_.length(); } 3610 int arguments_count() const { return values_.length(); }
3436 3611
3437 void AddArgument(HValue* argument, Zone* zone) { 3612 void AddArgument(HValue* argument, Zone* zone) {
3438 values_.Add(NULL, zone); // Resize list. 3613 values_.Add(NULL, zone); // Resize list.
3439 SetOperandAt(values_.length() - 1, argument); 3614 SetOperandAt(values_.length() - 1, argument);
3440 } 3615 }
3441 3616
3442 virtual int OperandCount() { return values_.length(); } 3617 virtual int OperandCount() { return values_.length(); }
3443 virtual HValue* OperandAt(int index) const { return values_[index]; } 3618 virtual HValue* OperandAt(int index) const { return values_[index]; }
3444 3619
3445 virtual bool HasEscapingOperandAt(int index) { return false; } 3620 virtual bool HasEscapingOperandAt(int index) { return false; }
3446 virtual Representation RequiredInputRepresentation(int index) { 3621 virtual Representation RequiredInputRepresentation(int index) {
3447 return Representation::None(); 3622 return Representation::None();
3448 } 3623 }
3449 3624
3450 DECLARE_CONCRETE_INSTRUCTION(ArgumentsObject) 3625 DECLARE_CONCRETE_INSTRUCTION(ArgumentsObject)
3451 3626
3452 protected: 3627 protected:
3453 virtual void InternalSetOperandAt(int index, HValue* value) { 3628 virtual void InternalSetOperandAt(int index, HValue* value) {
3454 values_[index] = value; 3629 values_[index] = value;
3455 } 3630 }
3456 3631
3457 private: 3632 private:
3633 HArgumentsObject(int count, Zone* zone) : values_(count, zone) {
3634 set_representation(Representation::Tagged());
3635 SetFlag(kIsArguments);
3636 }
3637
3458 virtual bool IsDeletable() const { return true; } 3638 virtual bool IsDeletable() const { return true; }
3459 3639
3460 ZoneList<HValue*> values_; 3640 ZoneList<HValue*> values_;
3461 }; 3641 };
3462 3642
3463 3643
3464 class HConstant: public HTemplateInstruction<0> { 3644 class HConstant: public HTemplateInstruction<0> {
3465 public: 3645 public:
3466 HConstant(Handle<Object> handle, Representation r = Representation::None()); 3646 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, int32_t);
3467 HConstant(int32_t value, 3647 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, double);
3468 Representation r = Representation::None(), 3648 DECLARE_INSTRUCTION_FACTORY_P1(HConstant, Handle<Object>);
3469 bool is_not_in_new_space = true, 3649 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 3650
3485 Handle<Object> handle() { 3651 Handle<Object> handle() {
3486 if (handle_.is_null()) { 3652 if (handle_.is_null()) {
3487 Factory* factory = Isolate::Current()->factory(); 3653 Factory* factory = Isolate::Current()->factory();
3488 // Default arguments to is_not_in_new_space depend on this heap number 3654 // 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. 3655 // to be tenured so that it's guaranteed not be be located in new space.
3490 handle_ = factory->NewNumber(double_value_, TENURED); 3656 handle_ = factory->NewNumber(double_value_, TENURED);
3491 } 3657 }
3492 AllowDeferredHandleDereference smi_check; 3658 AllowDeferredHandleDereference smi_check;
3493 ASSERT(has_int32_value_ || !handle_->IsSmi()); 3659 ASSERT(has_int32_value_ || !handle_->IsSmi());
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
3654 external_reference_value_ == 3820 external_reference_value_ ==
3655 other_constant->external_reference_value_; 3821 other_constant->external_reference_value_;
3656 } else { 3822 } else {
3657 ASSERT(!handle_.is_null()); 3823 ASSERT(!handle_.is_null());
3658 return !other_constant->handle_.is_null() && 3824 return !other_constant->handle_.is_null() &&
3659 unique_id_ == other_constant->unique_id_; 3825 unique_id_ == other_constant->unique_id_;
3660 } 3826 }
3661 } 3827 }
3662 3828
3663 private: 3829 private:
3830 friend class HGraph;
3831 HConstant(Handle<Object> handle, Representation r = Representation::None());
3832 HConstant(int32_t value,
3833 Representation r = Representation::None(),
3834 bool is_not_in_new_space = true,
3835 Handle<Object> optional_handle = Handle<Object>::null());
3836 HConstant(double value,
3837 Representation r = Representation::None(),
3838 bool is_not_in_new_space = true,
3839 Handle<Object> optional_handle = Handle<Object>::null());
3840 HConstant(Handle<Object> handle,
3841 UniqueValueId unique_id,
3842 Representation r,
3843 HType type,
3844 bool is_internalized_string,
3845 bool is_not_in_new_space,
3846 bool is_cell,
3847 bool boolean_value);
3848 explicit HConstant(ExternalReference reference);
3849
3664 void Initialize(Representation r); 3850 void Initialize(Representation r);
3665 3851
3666 virtual bool IsDeletable() const { return true; } 3852 virtual bool IsDeletable() const { return true; }
3667 3853
3668 // If this is a numerical constant, handle_ either points to to the 3854 // If this is a numerical constant, handle_ either points to to the
3669 // HeapObject the constant originated from or is null. If the 3855 // HeapObject the constant originated from or is null. If the
3670 // constant is non-numeric, handle_ always points to a valid 3856 // constant is non-numeric, handle_ always points to a valid
3671 // constant HeapObject. 3857 // constant HeapObject.
3672 Handle<Object> handle_; 3858 Handle<Object> handle_;
3673 UniqueValueId unique_id_; 3859 UniqueValueId unique_id_;
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
3773 private: 3959 private:
3774 bool IgnoreObservedOutputRepresentation(Representation current_rep); 3960 bool IgnoreObservedOutputRepresentation(Representation current_rep);
3775 3961
3776 Representation observed_input_representation_[2]; 3962 Representation observed_input_representation_[2];
3777 Representation observed_output_representation_; 3963 Representation observed_output_representation_;
3778 }; 3964 };
3779 3965
3780 3966
3781 class HWrapReceiver: public HTemplateInstruction<2> { 3967 class HWrapReceiver: public HTemplateInstruction<2> {
3782 public: 3968 public:
3783 HWrapReceiver(HValue* receiver, HValue* function) { 3969 DECLARE_INSTRUCTION_FACTORY_P2(HWrapReceiver, HValue*, HValue*);
3784 set_representation(Representation::Tagged());
3785 SetOperandAt(0, receiver);
3786 SetOperandAt(1, function);
3787 }
3788 3970
3789 virtual Representation RequiredInputRepresentation(int index) { 3971 virtual Representation RequiredInputRepresentation(int index) {
3790 return Representation::Tagged(); 3972 return Representation::Tagged();
3791 } 3973 }
3792 3974
3793 HValue* receiver() { return OperandAt(0); } 3975 HValue* receiver() { return OperandAt(0); }
3794 HValue* function() { return OperandAt(1); } 3976 HValue* function() { return OperandAt(1); }
3795 3977
3796 virtual HValue* Canonicalize(); 3978 virtual HValue* Canonicalize();
3797 3979
3798 virtual void PrintDataTo(StringStream* stream); 3980 virtual void PrintDataTo(StringStream* stream);
3799 3981
3800 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver) 3982 DECLARE_CONCRETE_INSTRUCTION(WrapReceiver)
3983
3984 private:
3985 HWrapReceiver(HValue* receiver, HValue* function) {
3986 set_representation(Representation::Tagged());
3987 SetOperandAt(0, receiver);
3988 SetOperandAt(1, function);
3989 }
3801 }; 3990 };
3802 3991
3803 3992
3804 class HApplyArguments: public HTemplateInstruction<4> { 3993 class HApplyArguments: public HTemplateInstruction<4> {
3805 public: 3994 public:
3806 HApplyArguments(HValue* function, 3995 HApplyArguments(HValue* function,
3807 HValue* receiver, 3996 HValue* receiver,
3808 HValue* length, 3997 HValue* length,
3809 HValue* elements) { 3998 HValue* elements) {
3810 set_representation(Representation::Tagged()); 3999 set_representation(Representation::Tagged());
(...skipping 15 matching lines...) Expand all
3826 HValue* receiver() { return OperandAt(1); } 4015 HValue* receiver() { return OperandAt(1); }
3827 HValue* length() { return OperandAt(2); } 4016 HValue* length() { return OperandAt(2); }
3828 HValue* elements() { return OperandAt(3); } 4017 HValue* elements() { return OperandAt(3); }
3829 4018
3830 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments) 4019 DECLARE_CONCRETE_INSTRUCTION(ApplyArguments)
3831 }; 4020 };
3832 4021
3833 4022
3834 class HArgumentsElements: public HTemplateInstruction<0> { 4023 class HArgumentsElements: public HTemplateInstruction<0> {
3835 public: 4024 public:
3836 explicit HArgumentsElements(bool from_inlined) : from_inlined_(from_inlined) { 4025 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 4026
3843 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements) 4027 DECLARE_CONCRETE_INSTRUCTION(ArgumentsElements)
3844 4028
3845 virtual Representation RequiredInputRepresentation(int index) { 4029 virtual Representation RequiredInputRepresentation(int index) {
3846 return Representation::None(); 4030 return Representation::None();
3847 } 4031 }
3848 4032
3849 bool from_inlined() const { return from_inlined_; } 4033 bool from_inlined() const { return from_inlined_; }
3850 4034
3851 protected: 4035 protected:
3852 virtual bool DataEquals(HValue* other) { return true; } 4036 virtual bool DataEquals(HValue* other) { return true; }
3853 4037
3854 private: 4038 private:
4039 explicit HArgumentsElements(bool from_inlined) : from_inlined_(from_inlined) {
4040 // The value produced by this instruction is a pointer into the stack
4041 // that looks as if it was a smi because of alignment.
4042 set_representation(Representation::Tagged());
4043 SetFlag(kUseGVN);
4044 }
4045
3855 virtual bool IsDeletable() const { return true; } 4046 virtual bool IsDeletable() const { return true; }
3856 4047
3857 bool from_inlined_; 4048 bool from_inlined_;
3858 }; 4049 };
3859 4050
3860 4051
3861 class HArgumentsLength: public HUnaryOperation { 4052 class HArgumentsLength: public HUnaryOperation {
3862 public: 4053 public:
3863 explicit HArgumentsLength(HValue* value) : HUnaryOperation(value) { 4054 DECLARE_INSTRUCTION_FACTORY_P1(HArgumentsLength, HValue*);
3864 set_representation(Representation::Integer32());
3865 SetFlag(kUseGVN);
3866 }
3867 4055
3868 virtual Representation RequiredInputRepresentation(int index) { 4056 virtual Representation RequiredInputRepresentation(int index) {
3869 return Representation::Tagged(); 4057 return Representation::Tagged();
3870 } 4058 }
3871 4059
3872 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength) 4060 DECLARE_CONCRETE_INSTRUCTION(ArgumentsLength)
3873 4061
3874 protected: 4062 protected:
3875 virtual bool DataEquals(HValue* other) { return true; } 4063 virtual bool DataEquals(HValue* other) { return true; }
3876 4064
3877 private: 4065 private:
4066 explicit HArgumentsLength(HValue* value) : HUnaryOperation(value) {
4067 set_representation(Representation::Integer32());
4068 SetFlag(kUseGVN);
4069 }
4070
3878 virtual bool IsDeletable() const { return true; } 4071 virtual bool IsDeletable() const { return true; }
3879 }; 4072 };
3880 4073
3881 4074
3882 class HAccessArgumentsAt: public HTemplateInstruction<3> { 4075 class HAccessArgumentsAt: public HTemplateInstruction<3> {
3883 public: 4076 public:
3884 HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) { 4077 HAccessArgumentsAt(HValue* arguments, HValue* length, HValue* index) {
3885 set_representation(Representation::Tagged()); 4078 set_representation(Representation::Tagged());
3886 SetFlag(kUseGVN); 4079 SetFlag(kUseGVN);
3887 SetOperandAt(0, arguments); 4080 SetOperandAt(0, arguments);
(...skipping 18 matching lines...) Expand all
3906 4099
3907 virtual bool DataEquals(HValue* other) { return true; } 4100 virtual bool DataEquals(HValue* other) { return true; }
3908 }; 4101 };
3909 4102
3910 4103
3911 class HBoundsCheckBaseIndexInformation; 4104 class HBoundsCheckBaseIndexInformation;
3912 4105
3913 4106
3914 class HBoundsCheck: public HTemplateInstruction<2> { 4107 class HBoundsCheck: public HTemplateInstruction<2> {
3915 public: 4108 public:
3916 // Normally HBoundsCheck should be created using the 4109 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 4110
3931 bool skip_check() const { return skip_check_; } 4111 bool skip_check() const { return skip_check_; }
3932 void set_skip_check() { skip_check_ = true; } 4112 void set_skip_check() { skip_check_ = true; }
4113
3933 HValue* base() { return base_; } 4114 HValue* base() { return base_; }
3934 int offset() { return offset_; } 4115 int offset() { return offset_; }
3935 int scale() { return scale_; } 4116 int scale() { return scale_; }
3936 bool index_can_increase() { 4117 bool index_can_increase() {
3937 return (responsibility_direction_ & DIRECTION_LOWER) == 0; 4118 return (responsibility_direction_ & DIRECTION_LOWER) == 0;
3938 } 4119 }
3939 bool index_can_decrease() { 4120 bool index_can_decrease() {
3940 return (responsibility_direction_ & DIRECTION_UPPER) == 0; 4121 return (responsibility_direction_ & DIRECTION_UPPER) == 0;
3941 } 4122 }
3942 4123
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
3992 virtual bool DataEquals(HValue* other) { return true; } 4173 virtual bool DataEquals(HValue* other) { return true; }
3993 virtual void TryGuaranteeRangeChanging(RangeEvaluationContext* context); 4174 virtual void TryGuaranteeRangeChanging(RangeEvaluationContext* context);
3994 bool skip_check_; 4175 bool skip_check_;
3995 HValue* base_; 4176 HValue* base_;
3996 int offset_; 4177 int offset_;
3997 int scale_; 4178 int scale_;
3998 RangeGuaranteeDirection responsibility_direction_; 4179 RangeGuaranteeDirection responsibility_direction_;
3999 bool allow_equality_; 4180 bool allow_equality_;
4000 4181
4001 private: 4182 private:
4183 // Normally HBoundsCheck should be created using the
4184 // HGraphBuilder::AddBoundsCheck() helper.
4185 // However when building stubs, where we know that the arguments are Int32,
4186 // it makes sense to invoke this constructor directly.
4187 HBoundsCheck(HValue* index, HValue* length)
4188 : skip_check_(false),
4189 base_(NULL), offset_(0), scale_(0),
4190 responsibility_direction_(DIRECTION_NONE),
4191 allow_equality_(false) {
4192 SetOperandAt(0, index);
4193 SetOperandAt(1, length);
4194 SetFlag(kFlexibleRepresentation);
4195 SetFlag(kUseGVN);
4196 }
4197
4002 virtual bool IsDeletable() const { 4198 virtual bool IsDeletable() const {
4003 return skip_check() && !FLAG_debug_code; 4199 return skip_check() && !FLAG_debug_code;
4004 } 4200 }
4005 }; 4201 };
4006 4202
4007 4203
4008 class HBoundsCheckBaseIndexInformation: public HTemplateInstruction<2> { 4204 class HBoundsCheckBaseIndexInformation: public HTemplateInstruction<2> {
4009 public: 4205 public:
4010 explicit HBoundsCheckBaseIndexInformation(HBoundsCheck* check) { 4206 explicit HBoundsCheckBaseIndexInformation(HBoundsCheck* check) {
4011 DecompositionResult decomposition; 4207 DecompositionResult decomposition;
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
4088 4284
4089 DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation) 4285 DECLARE_ABSTRACT_INSTRUCTION(BitwiseBinaryOperation)
4090 4286
4091 private: 4287 private:
4092 virtual bool IsDeletable() const { return true; } 4288 virtual bool IsDeletable() const { return true; }
4093 }; 4289 };
4094 4290
4095 4291
4096 class HMathFloorOfDiv: public HBinaryOperation { 4292 class HMathFloorOfDiv: public HBinaryOperation {
4097 public: 4293 public:
4098 HMathFloorOfDiv(HValue* context, HValue* left, HValue* right) 4294 static HMathFloorOfDiv* New(Zone* zone,
4099 : HBinaryOperation(context, left, right) { 4295 HValue* context,
4100 set_representation(Representation::Integer32()); 4296 HValue* left,
4101 SetFlag(kUseGVN); 4297 HValue* right) {
4102 SetFlag(kCanOverflow); 4298 return new(zone) HMathFloorOfDiv(context, left, right);
4103 if (!right->IsConstant()) {
4104 SetFlag(kCanBeDivByZero);
4105 }
4106 SetFlag(kAllowUndefinedAsNaN);
4107 } 4299 }
4108 4300
4109 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited); 4301 virtual HValue* EnsureAndPropagateNotMinusZero(BitVector* visited);
4110 4302
4111 virtual Representation RequiredInputRepresentation(int index) { 4303 virtual Representation RequiredInputRepresentation(int index) {
4112 return Representation::Integer32(); 4304 return Representation::Integer32();
4113 } 4305 }
4114 4306
4115 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv) 4307 DECLARE_CONCRETE_INSTRUCTION(MathFloorOfDiv)
4116 4308
4117 protected: 4309 protected:
4118 virtual bool DataEquals(HValue* other) { return true; } 4310 virtual bool DataEquals(HValue* other) { return true; }
4119 4311
4120 private: 4312 private:
4313 HMathFloorOfDiv(HValue* context, HValue* left, HValue* right)
4314 : HBinaryOperation(context, left, right) {
4315 set_representation(Representation::Integer32());
4316 SetFlag(kUseGVN);
4317 SetFlag(kCanOverflow);
4318 if (!right->IsConstant()) {
4319 SetFlag(kCanBeDivByZero);
4320 }
4321 SetFlag(kAllowUndefinedAsNaN);
4322 }
4323
4121 virtual bool IsDeletable() const { return true; } 4324 virtual bool IsDeletable() const { return true; }
4122 }; 4325 };
4123 4326
4124 4327
4125 class HArithmeticBinaryOperation: public HBinaryOperation { 4328 class HArithmeticBinaryOperation: public HBinaryOperation {
4126 public: 4329 public:
4127 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right) 4330 HArithmeticBinaryOperation(HValue* context, HValue* left, HValue* right)
4128 : HBinaryOperation(context, left, right, HType::TaggedNumber()) { 4331 : HBinaryOperation(context, left, right, HType::TaggedNumber()) {
4129 SetAllSideEffects(); 4332 SetAllSideEffects();
4130 SetFlag(kFlexibleRepresentation); 4333 SetFlag(kFlexibleRepresentation);
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
4212 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch) 4415 DECLARE_CONCRETE_INSTRUCTION(CompareNumericAndBranch)
4213 4416
4214 private: 4417 private:
4215 Representation observed_input_representation_[2]; 4418 Representation observed_input_representation_[2];
4216 Token::Value token_; 4419 Token::Value token_;
4217 }; 4420 };
4218 4421
4219 4422
4220 class HCompareObjectEqAndBranch: public HTemplateControlInstruction<2, 2> { 4423 class HCompareObjectEqAndBranch: public HTemplateControlInstruction<2, 2> {
4221 public: 4424 public:
4222 HCompareObjectEqAndBranch(HValue* left, HValue* right) { 4425 // TODO(danno): make this private when the IfBuilder properly constructs
4426 // control flow instructions.
4427 HCompareObjectEqAndBranch(HValue* left,
4428 HValue* right) {
4223 SetOperandAt(0, left); 4429 SetOperandAt(0, left);
4224 SetOperandAt(1, right); 4430 SetOperandAt(1, right);
4225 } 4431 }
4226 4432
4433 DECLARE_INSTRUCTION_FACTORY_P2(HCompareObjectEqAndBranch, HValue*, HValue*);
4434
4227 HValue* left() { return OperandAt(0); } 4435 HValue* left() { return OperandAt(0); }
4228 HValue* right() { return OperandAt(1); } 4436 HValue* right() { return OperandAt(1); }
4229 4437
4230 virtual void PrintDataTo(StringStream* stream); 4438 virtual void PrintDataTo(StringStream* stream);
4231 4439
4232 virtual Representation RequiredInputRepresentation(int index) { 4440 virtual Representation RequiredInputRepresentation(int index) {
4233 return Representation::Tagged(); 4441 return Representation::Tagged();
4234 } 4442 }
4235 4443
4236 virtual Representation observed_input_representation(int index) { 4444 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) { 4710 virtual Representation RequiredInputRepresentation(int index) {
4503 return Representation::Tagged(); 4711 return Representation::Tagged();
4504 } 4712 }
4505 4713
4506 DECLARE_CONCRETE_INSTRUCTION(InstanceSize) 4714 DECLARE_CONCRETE_INSTRUCTION(InstanceSize)
4507 }; 4715 };
4508 4716
4509 4717
4510 class HPower: public HTemplateInstruction<2> { 4718 class HPower: public HTemplateInstruction<2> {
4511 public: 4719 public:
4512 static HInstruction* New(Zone* zone, HValue* left, HValue* right); 4720 static HInstruction* New(Zone* zone,
4721 HValue* context,
4722 HValue* left,
4723 HValue* right);
4513 4724
4514 HValue* left() { return OperandAt(0); } 4725 HValue* left() { return OperandAt(0); }
4515 HValue* right() const { return OperandAt(1); } 4726 HValue* right() const { return OperandAt(1); }
4516 4727
4517 virtual Representation RequiredInputRepresentation(int index) { 4728 virtual Representation RequiredInputRepresentation(int index) {
4518 return index == 0 4729 return index == 0
4519 ? Representation::Double() 4730 ? Representation::Double()
4520 : Representation::None(); 4731 : Representation::None();
4521 } 4732 }
4522 virtual Representation observed_input_representation(int index) { 4733 virtual Representation observed_input_representation(int index) {
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after
4837 : HArithmeticBinaryOperation(context, left, right), 5048 : HArithmeticBinaryOperation(context, left, right),
4838 operation_(op) { } 5049 operation_(op) { }
4839 5050
4840 Operation operation_; 5051 Operation operation_;
4841 }; 5052 };
4842 5053
4843 5054
4844 class HBitwise: public HBitwiseBinaryOperation { 5055 class HBitwise: public HBitwiseBinaryOperation {
4845 public: 5056 public:
4846 static HInstruction* New(Zone* zone, 5057 static HInstruction* New(Zone* zone,
5058 HValue* context,
4847 Token::Value op, 5059 Token::Value op,
4848 HValue* context,
4849 HValue* left, 5060 HValue* left,
4850 HValue* right); 5061 HValue* right);
4851 5062
4852 Token::Value op() const { return op_; } 5063 Token::Value op() const { return op_; }
4853 5064
4854 virtual bool IsCommutative() const { return true; } 5065 virtual bool IsCommutative() const { return true; }
4855 5066
4856 virtual HValue* Canonicalize(); 5067 virtual HValue* Canonicalize();
4857 5068
4858 virtual void PrintDataTo(StringStream* stream); 5069 virtual void PrintDataTo(StringStream* stream);
4859 5070
4860 DECLARE_CONCRETE_INSTRUCTION(Bitwise) 5071 DECLARE_CONCRETE_INSTRUCTION(Bitwise)
4861 5072
4862 protected: 5073 protected:
4863 virtual bool DataEquals(HValue* other) { 5074 virtual bool DataEquals(HValue* other) {
4864 return op() == HBitwise::cast(other)->op(); 5075 return op() == HBitwise::cast(other)->op();
4865 } 5076 }
4866 5077
4867 virtual Range* InferRange(Zone* zone); 5078 virtual Range* InferRange(Zone* zone);
4868 5079
4869 private: 5080 private:
4870 HBitwise(Token::Value op, HValue* context, HValue* left, HValue* right) 5081 HBitwise(HValue* context,
5082 Token::Value op,
5083 HValue* left,
5084 HValue* right)
4871 : HBitwiseBinaryOperation(context, left, right, HType::TaggedNumber()), 5085 : HBitwiseBinaryOperation(context, left, right, HType::TaggedNumber()),
4872 op_(op) { 5086 op_(op) {
4873 ASSERT(op == Token::BIT_AND || op == Token::BIT_OR || op == Token::BIT_XOR); 5087 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 5088 // BIT_AND with a smi-range positive value will always unset the
4875 // entire sign-extension of the smi-sign. 5089 // entire sign-extension of the smi-sign.
4876 if (op == Token::BIT_AND && 5090 if (op == Token::BIT_AND &&
4877 ((left->IsConstant() && 5091 ((left->IsConstant() &&
4878 left->representation().IsSmi() && 5092 left->representation().IsSmi() &&
4879 HConstant::cast(left)->Integer32Value() >= 0) || 5093 HConstant::cast(left)->Integer32Value() >= 0) ||
4880 (right->IsConstant() && 5094 (right->IsConstant() &&
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
5023 5237
5024 DECLARE_CONCRETE_INSTRUCTION(Ror) 5238 DECLARE_CONCRETE_INSTRUCTION(Ror)
5025 5239
5026 protected: 5240 protected:
5027 virtual bool DataEquals(HValue* other) { return true; } 5241 virtual bool DataEquals(HValue* other) { return true; }
5028 }; 5242 };
5029 5243
5030 5244
5031 class HOsrEntry: public HTemplateInstruction<0> { 5245 class HOsrEntry: public HTemplateInstruction<0> {
5032 public: 5246 public:
5033 explicit HOsrEntry(BailoutId ast_id) : ast_id_(ast_id) { 5247 DECLARE_INSTRUCTION_FACTORY_P1(HOsrEntry, BailoutId);
5034 SetGVNFlag(kChangesOsrEntries);
5035 SetGVNFlag(kChangesNewSpacePromotion);
5036 }
5037 5248
5038 BailoutId ast_id() const { return ast_id_; } 5249 BailoutId ast_id() const { return ast_id_; }
5039 5250
5040 virtual Representation RequiredInputRepresentation(int index) { 5251 virtual Representation RequiredInputRepresentation(int index) {
5041 return Representation::None(); 5252 return Representation::None();
5042 } 5253 }
5043 5254
5044 DECLARE_CONCRETE_INSTRUCTION(OsrEntry) 5255 DECLARE_CONCRETE_INSTRUCTION(OsrEntry)
5045 5256
5046 private: 5257 private:
5258 explicit HOsrEntry(BailoutId ast_id) : ast_id_(ast_id) {
5259 SetGVNFlag(kChangesOsrEntries);
5260 SetGVNFlag(kChangesNewSpacePromotion);
5261 }
5262
5047 BailoutId ast_id_; 5263 BailoutId ast_id_;
5048 }; 5264 };
5049 5265
5050 5266
5051 class HParameter: public HTemplateInstruction<0> { 5267 class HParameter: public HTemplateInstruction<0> {
5052 public: 5268 public:
5053 enum ParameterKind { 5269 enum ParameterKind {
5054 STACK_PARAMETER, 5270 STACK_PARAMETER,
5055 REGISTER_PARAMETER 5271 REGISTER_PARAMETER
5056 }; 5272 };
5057 5273
5274 DECLARE_INSTRUCTION_FACTORY_P1(HParameter, unsigned);
5275 DECLARE_INSTRUCTION_FACTORY_P2(HParameter, unsigned, ParameterKind);
5276 DECLARE_INSTRUCTION_FACTORY_P3(HParameter, unsigned, ParameterKind,
5277 Representation);
5278
5279 unsigned index() const { return index_; }
5280 ParameterKind kind() const { return kind_; }
5281
5282 virtual void PrintDataTo(StringStream* stream);
5283
5284 virtual Representation RequiredInputRepresentation(int index) {
5285 return Representation::None();
5286 }
5287
5288 DECLARE_CONCRETE_INSTRUCTION(Parameter)
5289
5290 private:
5058 explicit HParameter(unsigned index, 5291 explicit HParameter(unsigned index,
5059 ParameterKind kind = STACK_PARAMETER) 5292 ParameterKind kind = STACK_PARAMETER)
5060 : index_(index), 5293 : index_(index),
5061 kind_(kind) { 5294 kind_(kind) {
5062 set_representation(Representation::Tagged()); 5295 set_representation(Representation::Tagged());
5063 } 5296 }
5064 5297
5065 explicit HParameter(unsigned index, 5298 explicit HParameter(unsigned index,
5066 ParameterKind kind, 5299 ParameterKind kind,
5067 Representation r) 5300 Representation r)
5068 : index_(index), 5301 : index_(index),
5069 kind_(kind) { 5302 kind_(kind) {
5070 set_representation(r); 5303 set_representation(r);
5071 } 5304 }
5072 5305
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_; 5306 unsigned index_;
5086 ParameterKind kind_; 5307 ParameterKind kind_;
5087 }; 5308 };
5088 5309
5089 5310
5090 class HCallStub: public HUnaryCall { 5311 class HCallStub: public HUnaryCall {
5091 public: 5312 public:
5092 HCallStub(HValue* context, CodeStub::Major major_key, int argument_count) 5313 HCallStub(HValue* context, CodeStub::Major major_key, int argument_count)
5093 : HUnaryCall(context, argument_count), 5314 : HUnaryCall(context, argument_count),
5094 major_key_(major_key), 5315 major_key_(major_key),
(...skipping 20 matching lines...) Expand all
5115 DECLARE_CONCRETE_INSTRUCTION(CallStub) 5336 DECLARE_CONCRETE_INSTRUCTION(CallStub)
5116 5337
5117 private: 5338 private:
5118 CodeStub::Major major_key_; 5339 CodeStub::Major major_key_;
5119 TranscendentalCache::Type transcendental_type_; 5340 TranscendentalCache::Type transcendental_type_;
5120 }; 5341 };
5121 5342
5122 5343
5123 class HUnknownOSRValue: public HTemplateInstruction<0> { 5344 class HUnknownOSRValue: public HTemplateInstruction<0> {
5124 public: 5345 public:
5125 HUnknownOSRValue() 5346 DECLARE_INSTRUCTION_FACTORY_P0(HUnknownOSRValue)
5126 : incoming_value_(NULL) {
5127 set_representation(Representation::Tagged());
5128 }
5129 5347
5130 virtual Representation RequiredInputRepresentation(int index) { 5348 virtual Representation RequiredInputRepresentation(int index) {
5131 return Representation::None(); 5349 return Representation::None();
5132 } 5350 }
5133 5351
5134 void set_incoming_value(HPhi* value) { 5352 void set_incoming_value(HPhi* value) {
5135 incoming_value_ = value; 5353 incoming_value_ = value;
5136 } 5354 }
5137 5355
5138 HPhi* incoming_value() { 5356 HPhi* incoming_value() {
5139 return incoming_value_; 5357 return incoming_value_;
5140 } 5358 }
5141 5359
5142 virtual Representation KnownOptimalRepresentation() { 5360 virtual Representation KnownOptimalRepresentation() {
5143 if (incoming_value_ == NULL) return Representation::None(); 5361 if (incoming_value_ == NULL) return Representation::None();
5144 return incoming_value_->KnownOptimalRepresentation(); 5362 return incoming_value_->KnownOptimalRepresentation();
5145 } 5363 }
5146 5364
5147 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue) 5365 DECLARE_CONCRETE_INSTRUCTION(UnknownOSRValue)
5148 5366
5149 private: 5367 private:
5368 HUnknownOSRValue()
5369 : incoming_value_(NULL) {
5370 set_representation(Representation::Tagged());
5371 }
5372
5150 HPhi* incoming_value_; 5373 HPhi* incoming_value_;
5151 }; 5374 };
5152 5375
5153 5376
5154 class HLoadGlobalCell: public HTemplateInstruction<0> { 5377 class HLoadGlobalCell: public HTemplateInstruction<0> {
5155 public: 5378 public:
5156 HLoadGlobalCell(Handle<Cell> cell, PropertyDetails details) 5379 HLoadGlobalCell(Handle<Cell> cell, PropertyDetails details)
5157 : cell_(cell), details_(details), unique_id_() { 5380 : cell_(cell), details_(details), unique_id_() {
5158 set_representation(Representation::Tagged()); 5381 set_representation(Representation::Tagged());
5159 SetFlag(kUseGVN); 5382 SetFlag(kUseGVN);
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
5222 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric) 5445 DECLARE_CONCRETE_INSTRUCTION(LoadGlobalGeneric)
5223 5446
5224 private: 5447 private:
5225 Handle<Object> name_; 5448 Handle<Object> name_;
5226 bool for_typeof_; 5449 bool for_typeof_;
5227 }; 5450 };
5228 5451
5229 5452
5230 class HAllocate: public HTemplateInstruction<2> { 5453 class HAllocate: public HTemplateInstruction<2> {
5231 public: 5454 public:
5232 HAllocate(HValue* context, 5455 static HAllocate* New(Zone* zone,
5233 HValue* size, 5456 HValue* context,
5234 HType type, 5457 HValue* size,
5235 bool pretenure, 5458 HType type,
5236 ElementsKind kind = FAST_ELEMENTS) 5459 bool pretenure,
5237 : HTemplateInstruction<2>(type) { 5460 ElementsKind kind = FAST_ELEMENTS) {
5238 SetOperandAt(0, context); 5461 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 } 5462 }
5259 5463
5260 // Maximum instance size for which allocations will be inlined. 5464 // Maximum instance size for which allocations will be inlined.
5261 static const int kMaxInlineSize = 64 * kPointerSize; 5465 static const int kMaxInlineSize = 64 * kPointerSize;
5262 5466
5263 HValue* context() { return OperandAt(0); } 5467 HValue* context() { return OperandAt(0); }
5264 HValue* size() { return OperandAt(1); } 5468 HValue* size() { return OperandAt(1); }
5265 5469
5266 virtual Representation RequiredInputRepresentation(int index) { 5470 virtual Representation RequiredInputRepresentation(int index) {
5267 if (index == 0) { 5471 if (index == 0) {
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
5320 5524
5321 private: 5525 private:
5322 enum Flags { 5526 enum Flags {
5323 ALLOCATE_IN_NEW_SPACE = 1 << 0, 5527 ALLOCATE_IN_NEW_SPACE = 1 << 0,
5324 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1, 5528 ALLOCATE_IN_OLD_DATA_SPACE = 1 << 1,
5325 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2, 5529 ALLOCATE_IN_OLD_POINTER_SPACE = 1 << 2,
5326 ALLOCATE_DOUBLE_ALIGNED = 1 << 3, 5530 ALLOCATE_DOUBLE_ALIGNED = 1 << 3,
5327 PREFILL_WITH_FILLER = 1 << 4 5531 PREFILL_WITH_FILLER = 1 << 4
5328 }; 5532 };
5329 5533
5534 HAllocate(HValue* context,
5535 HValue* size,
5536 HType type,
5537 bool pretenure,
5538 ElementsKind kind)
5539 : HTemplateInstruction<2>(type) {
5540 SetOperandAt(0, context);
5541 SetOperandAt(1, size);
5542 set_representation(Representation::Tagged());
5543 SetFlag(kTrackSideEffectDominators);
5544 SetGVNFlag(kChangesNewSpacePromotion);
5545 SetGVNFlag(kDependsOnNewSpacePromotion);
5546 if (pretenure) {
5547 if (IsFastDoubleElementsKind(kind)) {
5548 flags_ = static_cast<HAllocate::Flags>(ALLOCATE_IN_OLD_DATA_SPACE |
5549 ALLOCATE_DOUBLE_ALIGNED);
5550 } else {
5551 flags_ = ALLOCATE_IN_OLD_POINTER_SPACE;
5552 }
5553 } else {
5554 flags_ = ALLOCATE_IN_NEW_SPACE;
5555 if (IsFastDoubleElementsKind(kind)) {
5556 flags_ = static_cast<HAllocate::Flags>(flags_ |
5557 ALLOCATE_DOUBLE_ALIGNED);
5558 }
5559 }
5560 }
5561
5330 Flags flags_; 5562 Flags flags_;
5331 Handle<Map> known_initial_map_; 5563 Handle<Map> known_initial_map_;
5332 }; 5564 };
5333 5565
5334 5566
5335 class HInnerAllocatedObject: public HTemplateInstruction<1> { 5567 class HInnerAllocatedObject: public HTemplateInstruction<1> {
5336 public: 5568 public:
5337 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged()) 5569 static HInnerAllocatedObject* New(Zone* zone,
5338 : HTemplateInstruction<1>(type), offset_(offset) { 5570 HValue* context,
5339 ASSERT(value->IsAllocate()); 5571 HValue* value,
5340 SetOperandAt(0, value); 5572 int offset,
5341 set_representation(Representation::Tagged()); 5573 HType type = HType::Tagged()) {
5574 return new(zone) HInnerAllocatedObject(value, offset, type);
5342 } 5575 }
5343 5576
5344 HValue* base_object() { return OperandAt(0); } 5577 HValue* base_object() { return OperandAt(0); }
5345 int offset() { return offset_; } 5578 int offset() { return offset_; }
5346 5579
5347 virtual Representation RequiredInputRepresentation(int index) { 5580 virtual Representation RequiredInputRepresentation(int index) {
5348 return Representation::Tagged(); 5581 return Representation::Tagged();
5349 } 5582 }
5350 5583
5351 virtual void PrintDataTo(StringStream* stream); 5584 virtual void PrintDataTo(StringStream* stream);
5352 5585
5353 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject) 5586 DECLARE_CONCRETE_INSTRUCTION(InnerAllocatedObject)
5354 5587
5355 private: 5588 private:
5589 HInnerAllocatedObject(HValue* value, int offset, HType type = HType::Tagged())
5590 : HTemplateInstruction<1>(type), offset_(offset) {
5591 ASSERT(value->IsAllocate());
5592 SetOperandAt(0, value);
5593 set_type(type);
5594 set_representation(Representation::Tagged());
5595 }
5596
5356 int offset_; 5597 int offset_;
5357 }; 5598 };
5358 5599
5359 5600
5360 inline bool StoringValueNeedsWriteBarrier(HValue* value) { 5601 inline bool StoringValueNeedsWriteBarrier(HValue* value) {
5361 return !value->type().IsBoolean() 5602 return !value->type().IsBoolean()
5362 && !value->type().IsSmi() 5603 && !value->type().IsSmi()
5363 && !(value->IsConstant() && HConstant::cast(value)->ImmortalImmovable()); 5604 && !(value->IsConstant() && HConstant::cast(value)->ImmortalImmovable());
5364 } 5605 }
5365 5606
(...skipping 16 matching lines...) Expand all
5382 if (object != new_space_dominator) return true; 5623 if (object != new_space_dominator) return true;
5383 if (object->IsAllocate()) { 5624 if (object->IsAllocate()) {
5384 return !HAllocate::cast(object)->IsNewSpaceAllocation(); 5625 return !HAllocate::cast(object)->IsNewSpaceAllocation();
5385 } 5626 }
5386 return true; 5627 return true;
5387 } 5628 }
5388 5629
5389 5630
5390 class HStoreGlobalCell: public HUnaryOperation { 5631 class HStoreGlobalCell: public HUnaryOperation {
5391 public: 5632 public:
5392 HStoreGlobalCell(HValue* value, 5633 DECLARE_INSTRUCTION_FACTORY_P3(HStoreGlobalCell, HValue*,
5393 Handle<PropertyCell> cell, 5634 Handle<PropertyCell>, PropertyDetails);
5394 PropertyDetails details)
5395 : HUnaryOperation(value),
5396 cell_(cell),
5397 details_(details) {
5398 SetGVNFlag(kChangesGlobalVars);
5399 }
5400 5635
5401 Handle<PropertyCell> cell() const { return cell_; } 5636 Handle<PropertyCell> cell() const { return cell_; }
5402 bool RequiresHoleCheck() { 5637 bool RequiresHoleCheck() {
5403 return !details_.IsDontDelete() || details_.IsReadOnly(); 5638 return !details_.IsDontDelete() || details_.IsReadOnly();
5404 } 5639 }
5405 bool NeedsWriteBarrier() { 5640 bool NeedsWriteBarrier() {
5406 return StoringValueNeedsWriteBarrier(value()); 5641 return StoringValueNeedsWriteBarrier(value());
5407 } 5642 }
5408 5643
5409 virtual Representation RequiredInputRepresentation(int index) { 5644 virtual Representation RequiredInputRepresentation(int index) {
5410 return Representation::Tagged(); 5645 return Representation::Tagged();
5411 } 5646 }
5412 virtual void PrintDataTo(StringStream* stream); 5647 virtual void PrintDataTo(StringStream* stream);
5413 5648
5414 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell) 5649 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalCell)
5415 5650
5416 private: 5651 private:
5652 HStoreGlobalCell(HValue* value,
5653 Handle<PropertyCell> cell,
5654 PropertyDetails details)
5655 : HUnaryOperation(value),
5656 cell_(cell),
5657 details_(details) {
5658 SetGVNFlag(kChangesGlobalVars);
5659 }
5660
5417 Handle<PropertyCell> cell_; 5661 Handle<PropertyCell> cell_;
5418 PropertyDetails details_; 5662 PropertyDetails details_;
5419 }; 5663 };
5420 5664
5421 5665
5422 class HStoreGlobalGeneric: public HTemplateInstruction<3> { 5666 class HStoreGlobalGeneric: public HTemplateInstruction<3> {
5423 public: 5667 public:
5424 HStoreGlobalGeneric(HValue* context, 5668 inline static HStoreGlobalGeneric* New(Zone* zone,
5425 HValue* global_object, 5669 HValue* context,
5426 Handle<Object> name, 5670 HValue* global_object,
5427 HValue* value, 5671 Handle<Object> name,
5428 StrictModeFlag strict_mode_flag) 5672 HValue* value,
5429 : name_(name), 5673 StrictModeFlag strict_mode_flag) {
5430 strict_mode_flag_(strict_mode_flag) { 5674 return new(zone) HStoreGlobalGeneric(context, global_object,
5431 SetOperandAt(0, context); 5675 name, value, strict_mode_flag);
5432 SetOperandAt(1, global_object);
5433 SetOperandAt(2, value);
5434 set_representation(Representation::Tagged());
5435 SetAllSideEffects();
5436 } 5676 }
5437 5677
5438 HValue* context() { return OperandAt(0); } 5678 HValue* context() { return OperandAt(0); }
5439 HValue* global_object() { return OperandAt(1); } 5679 HValue* global_object() { return OperandAt(1); }
5440 Handle<Object> name() const { return name_; } 5680 Handle<Object> name() const { return name_; }
5441 HValue* value() { return OperandAt(2); } 5681 HValue* value() { return OperandAt(2); }
5442 StrictModeFlag strict_mode_flag() { return strict_mode_flag_; } 5682 StrictModeFlag strict_mode_flag() { return strict_mode_flag_; }
5443 5683
5444 virtual void PrintDataTo(StringStream* stream); 5684 virtual void PrintDataTo(StringStream* stream);
5445 5685
5446 virtual Representation RequiredInputRepresentation(int index) { 5686 virtual Representation RequiredInputRepresentation(int index) {
5447 return Representation::Tagged(); 5687 return Representation::Tagged();
5448 } 5688 }
5449 5689
5450 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric) 5690 DECLARE_CONCRETE_INSTRUCTION(StoreGlobalGeneric)
5451 5691
5452 private: 5692 private:
5693 HStoreGlobalGeneric(HValue* context,
5694 HValue* global_object,
5695 Handle<Object> name,
5696 HValue* value,
5697 StrictModeFlag strict_mode_flag)
5698 : name_(name),
5699 strict_mode_flag_(strict_mode_flag) {
5700 SetOperandAt(0, context);
5701 SetOperandAt(1, global_object);
5702 SetOperandAt(2, value);
5703 set_representation(Representation::Tagged());
5704 SetAllSideEffects();
5705 }
5706
5453 Handle<Object> name_; 5707 Handle<Object> name_;
5454 StrictModeFlag strict_mode_flag_; 5708 StrictModeFlag strict_mode_flag_;
5455 }; 5709 };
5456 5710
5457 5711
5458 class HLoadContextSlot: public HUnaryOperation { 5712 class HLoadContextSlot: public HUnaryOperation {
5459 public: 5713 public:
5460 enum Mode { 5714 enum Mode {
5461 // Perform a normal load of the context slot without checking its value. 5715 // Perform a normal load of the context slot without checking its value.
5462 kNoCheck, 5716 kNoCheck,
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
5530 kNoCheck, 5784 kNoCheck,
5531 // Check the previous value of the context slot and deoptimize if it's the 5785 // 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 5786 // hole value. This is used for checking for assignments to uninitialized
5533 // harmony bindings where we deoptimize into full-codegen generated code 5787 // harmony bindings where we deoptimize into full-codegen generated code
5534 // which will subsequently throw a reference error. 5788 // which will subsequently throw a reference error.
5535 kCheckDeoptimize, 5789 kCheckDeoptimize,
5536 // Check the previous value and ignore assignment if it isn't a hole value 5790 // Check the previous value and ignore assignment if it isn't a hole value
5537 kCheckIgnoreAssignment 5791 kCheckIgnoreAssignment
5538 }; 5792 };
5539 5793
5540 HStoreContextSlot(HValue* context, int slot_index, Mode mode, HValue* value) 5794 DECLARE_INSTRUCTION_FACTORY_P4(HStoreContextSlot, HValue*, int,
5541 : slot_index_(slot_index), mode_(mode) { 5795 Mode, HValue*);
5542 SetOperandAt(0, context);
5543 SetOperandAt(1, value);
5544 SetGVNFlag(kChangesContextSlots);
5545 }
5546 5796
5547 HValue* context() { return OperandAt(0); } 5797 HValue* context() { return OperandAt(0); }
5548 HValue* value() { return OperandAt(1); } 5798 HValue* value() { return OperandAt(1); }
5549 int slot_index() const { return slot_index_; } 5799 int slot_index() const { return slot_index_; }
5550 Mode mode() const { return mode_; } 5800 Mode mode() const { return mode_; }
5551 5801
5552 bool NeedsWriteBarrier() { 5802 bool NeedsWriteBarrier() {
5553 return StoringValueNeedsWriteBarrier(value()); 5803 return StoringValueNeedsWriteBarrier(value());
5554 } 5804 }
5555 5805
5556 bool DeoptimizesOnHole() { 5806 bool DeoptimizesOnHole() {
5557 return mode_ == kCheckDeoptimize; 5807 return mode_ == kCheckDeoptimize;
5558 } 5808 }
5559 5809
5560 bool RequiresHoleCheck() { 5810 bool RequiresHoleCheck() {
5561 return mode_ != kNoCheck; 5811 return mode_ != kNoCheck;
5562 } 5812 }
5563 5813
5564 virtual Representation RequiredInputRepresentation(int index) { 5814 virtual Representation RequiredInputRepresentation(int index) {
5565 return Representation::Tagged(); 5815 return Representation::Tagged();
5566 } 5816 }
5567 5817
5568 virtual void PrintDataTo(StringStream* stream); 5818 virtual void PrintDataTo(StringStream* stream);
5569 5819
5570 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot) 5820 DECLARE_CONCRETE_INSTRUCTION(StoreContextSlot)
5571 5821
5572 private: 5822 private:
5823 HStoreContextSlot(HValue* context, int slot_index, Mode mode, HValue* value)
5824 : slot_index_(slot_index), mode_(mode) {
5825 SetOperandAt(0, context);
5826 SetOperandAt(1, value);
5827 SetGVNFlag(kChangesContextSlots);
5828 }
5829
5573 int slot_index_; 5830 int slot_index_;
5574 Mode mode_; 5831 Mode mode_;
5575 }; 5832 };
5576 5833
5577 5834
5578 // Represents an access to a portion of an object, such as the map pointer, 5835 // 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. 5836 // array elements pointer, etc, but not accesses to array elements themselves.
5580 class HObjectAccess { 5837 class HObjectAccess {
5581 public: 5838 public:
5582 inline bool IsInobject() const { 5839 inline bool IsInobject() const {
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after
5734 friend class HStoreNamedField; 5991 friend class HStoreNamedField;
5735 5992
5736 inline Portion portion() const { 5993 inline Portion portion() const {
5737 return PortionField::decode(value_); 5994 return PortionField::decode(value_);
5738 } 5995 }
5739 }; 5996 };
5740 5997
5741 5998
5742 class HLoadNamedField: public HTemplateInstruction<2> { 5999 class HLoadNamedField: public HTemplateInstruction<2> {
5743 public: 6000 public:
5744 HLoadNamedField(HValue* object, 6001 DECLARE_INSTRUCTION_FACTORY_P2(HLoadNamedField, HValue*, HObjectAccess);
5745 HObjectAccess access, 6002 DECLARE_INSTRUCTION_FACTORY_P3(HLoadNamedField, HValue*, HObjectAccess,
5746 HValue* typecheck = NULL) 6003 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 6004
5770 HValue* object() { return OperandAt(0); } 6005 HValue* object() { return OperandAt(0); }
5771 HValue* typecheck() { 6006 HValue* typecheck() {
5772 ASSERT(HasTypeCheck()); 6007 ASSERT(HasTypeCheck());
5773 return OperandAt(1); 6008 return OperandAt(1);
5774 } 6009 }
5775 6010
5776 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); } 6011 bool HasTypeCheck() const { return OperandAt(0) != OperandAt(1); }
5777 HObjectAccess access() const { return access_; } 6012 HObjectAccess access() const { return access_; }
5778 Representation field_representation() const { 6013 Representation field_representation() const {
(...skipping 12 matching lines...) Expand all
5791 6026
5792 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField) 6027 DECLARE_CONCRETE_INSTRUCTION(LoadNamedField)
5793 6028
5794 protected: 6029 protected:
5795 virtual bool DataEquals(HValue* other) { 6030 virtual bool DataEquals(HValue* other) {
5796 HLoadNamedField* b = HLoadNamedField::cast(other); 6031 HLoadNamedField* b = HLoadNamedField::cast(other);
5797 return access_.Equals(b->access_); 6032 return access_.Equals(b->access_);
5798 } 6033 }
5799 6034
5800 private: 6035 private:
6036 HLoadNamedField(HValue* object,
6037 HObjectAccess access,
6038 HValue* typecheck = NULL)
6039 : access_(access) {
6040 ASSERT(object != NULL);
6041 SetOperandAt(0, object);
6042 SetOperandAt(1, typecheck != NULL ? typecheck : object);
6043
6044 Representation representation = access.representation();
6045 if (representation.IsSmi()) {
6046 set_type(HType::Smi());
6047 set_representation(representation);
6048 } else if (representation.IsDouble() ||
6049 representation.IsExternal() ||
6050 representation.IsInteger32()) {
6051 set_representation(representation);
6052 } else if (FLAG_track_heap_object_fields &&
6053 representation.IsHeapObject()) {
6054 set_type(HType::NonPrimitive());
6055 set_representation(Representation::Tagged());
6056 } else {
6057 set_representation(Representation::Tagged());
6058 }
6059 access.SetGVNFlags(this, false);
6060 }
6061
5801 virtual bool IsDeletable() const { return true; } 6062 virtual bool IsDeletable() const { return true; }
5802 6063
5803 HObjectAccess access_; 6064 HObjectAccess access_;
5804 }; 6065 };
5805 6066
5806 6067
5807 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> { 6068 class HLoadNamedFieldPolymorphic: public HTemplateInstruction<2> {
5808 public: 6069 public:
5809 HLoadNamedFieldPolymorphic(HValue* context, 6070 HLoadNamedFieldPolymorphic(HValue* context,
5810 HValue* object, 6071 HValue* object,
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
5909 6170
5910 enum LoadKeyedHoleMode { 6171 enum LoadKeyedHoleMode {
5911 NEVER_RETURN_HOLE, 6172 NEVER_RETURN_HOLE,
5912 ALLOW_RETURN_HOLE 6173 ALLOW_RETURN_HOLE
5913 }; 6174 };
5914 6175
5915 6176
5916 class HLoadKeyed 6177 class HLoadKeyed
5917 : public HTemplateInstruction<3>, public ArrayInstructionInterface { 6178 : public HTemplateInstruction<3>, public ArrayInstructionInterface {
5918 public: 6179 public:
5919 HLoadKeyed(HValue* obj, 6180 DECLARE_INSTRUCTION_FACTORY_P4(HLoadKeyed, HValue*, HValue*, HValue*,
5920 HValue* key, 6181 ElementsKind);
5921 HValue* dependency, 6182 DECLARE_INSTRUCTION_FACTORY_P5(HLoadKeyed, HValue*, HValue*, HValue*,
5922 ElementsKind elements_kind, 6183 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 6184
5969 bool is_external() const { 6185 bool is_external() const {
5970 return IsExternalArrayElementsKind(elements_kind()); 6186 return IsExternalArrayElementsKind(elements_kind());
5971 } 6187 }
5972 HValue* elements() { return OperandAt(0); } 6188 HValue* elements() { return OperandAt(0); }
5973 HValue* key() { return OperandAt(1); } 6189 HValue* key() { return OperandAt(1); }
5974 HValue* dependency() { 6190 HValue* dependency() {
5975 ASSERT(HasDependency()); 6191 ASSERT(HasDependency());
5976 return OperandAt(2); 6192 return OperandAt(2);
5977 } 6193 }
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
6026 virtual bool DataEquals(HValue* other) { 6242 virtual bool DataEquals(HValue* other) {
6027 if (!other->IsLoadKeyed()) return false; 6243 if (!other->IsLoadKeyed()) return false;
6028 HLoadKeyed* other_load = HLoadKeyed::cast(other); 6244 HLoadKeyed* other_load = HLoadKeyed::cast(other);
6029 6245
6030 if (IsDehoisted() && index_offset() != other_load->index_offset()) 6246 if (IsDehoisted() && index_offset() != other_load->index_offset())
6031 return false; 6247 return false;
6032 return elements_kind() == other_load->elements_kind(); 6248 return elements_kind() == other_load->elements_kind();
6033 } 6249 }
6034 6250
6035 private: 6251 private:
6252 HLoadKeyed(HValue* obj,
6253 HValue* key,
6254 HValue* dependency,
6255 ElementsKind elements_kind,
6256 LoadKeyedHoleMode mode = NEVER_RETURN_HOLE)
6257 : bit_field_(0) {
6258 bit_field_ = ElementsKindField::encode(elements_kind) |
6259 HoleModeField::encode(mode);
6260
6261 SetOperandAt(0, obj);
6262 SetOperandAt(1, key);
6263 SetOperandAt(2, dependency != NULL ? dependency : obj);
6264
6265 if (!is_external()) {
6266 // I can detect the case between storing double (holey and fast) and
6267 // smi/object by looking at elements_kind_.
6268 ASSERT(IsFastSmiOrObjectElementsKind(elements_kind) ||
6269 IsFastDoubleElementsKind(elements_kind));
6270
6271 if (IsFastSmiOrObjectElementsKind(elements_kind)) {
6272 if (IsFastSmiElementsKind(elements_kind) &&
6273 (!IsHoleyElementsKind(elements_kind) ||
6274 mode == NEVER_RETURN_HOLE)) {
6275 set_type(HType::Smi());
6276 set_representation(Representation::Smi());
6277 } else {
6278 set_representation(Representation::Tagged());
6279 }
6280
6281 SetGVNFlag(kDependsOnArrayElements);
6282 } else {
6283 set_representation(Representation::Double());
6284 SetGVNFlag(kDependsOnDoubleArrayElements);
6285 }
6286 } else {
6287 if (elements_kind == EXTERNAL_FLOAT_ELEMENTS ||
6288 elements_kind == EXTERNAL_DOUBLE_ELEMENTS) {
6289 set_representation(Representation::Double());
6290 } else {
6291 set_representation(Representation::Integer32());
6292 }
6293
6294 SetGVNFlag(kDependsOnExternalMemory);
6295 // Native code could change the specialized array.
6296 SetGVNFlag(kDependsOnCalls);
6297 }
6298
6299 SetFlag(kUseGVN);
6300 }
6301
6036 virtual bool IsDeletable() const { 6302 virtual bool IsDeletable() const {
6037 return !RequiresHoleCheck(); 6303 return !RequiresHoleCheck();
6038 } 6304 }
6039 6305
6040 // Establish some checks around our packed fields 6306 // Establish some checks around our packed fields
6041 enum LoadKeyedBits { 6307 enum LoadKeyedBits {
6042 kBitsForElementsKind = 5, 6308 kBitsForElementsKind = 5,
6043 kBitsForHoleMode = 1, 6309 kBitsForHoleMode = 1,
6044 kBitsForIndexOffset = 25, 6310 kBitsForIndexOffset = 25,
6045 kBitsForIsDehoisted = 1, 6311 kBitsForIsDehoisted = 1,
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
6091 } 6357 }
6092 6358
6093 virtual HValue* Canonicalize(); 6359 virtual HValue* Canonicalize();
6094 6360
6095 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric) 6361 DECLARE_CONCRETE_INSTRUCTION(LoadKeyedGeneric)
6096 }; 6362 };
6097 6363
6098 6364
6099 class HStoreNamedField: public HTemplateInstruction<2> { 6365 class HStoreNamedField: public HTemplateInstruction<2> {
6100 public: 6366 public:
6101 HStoreNamedField(HValue* obj, 6367 DECLARE_INSTRUCTION_FACTORY_P3(HStoreNamedField, HValue*,
6102 HObjectAccess access, 6368 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 6369
6114 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField) 6370 DECLARE_CONCRETE_INSTRUCTION(StoreNamedField)
6115 6371
6116 virtual bool HasEscapingOperandAt(int index) { return index == 1; } 6372 virtual bool HasEscapingOperandAt(int index) { return index == 1; }
6117 virtual Representation RequiredInputRepresentation(int index) { 6373 virtual Representation RequiredInputRepresentation(int index) {
6118 if (index == 0 && access().IsExternalMemory()) { 6374 if (index == 0 && access().IsExternalMemory()) {
6119 // object must be external in case of external memory access 6375 // object must be external in case of external memory access
6120 return Representation::External(); 6376 return Representation::External();
6121 } else if (index == 1 && 6377 } else if (index == 1 &&
6122 (field_representation().IsDouble() || 6378 (field_representation().IsDouble() ||
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
6172 6428
6173 virtual void FinalizeUniqueValueId() { 6429 virtual void FinalizeUniqueValueId() {
6174 transition_unique_id_ = UniqueValueId(transition_); 6430 transition_unique_id_ = UniqueValueId(transition_);
6175 } 6431 }
6176 6432
6177 Representation field_representation() const { 6433 Representation field_representation() const {
6178 return access_.representation(); 6434 return access_.representation();
6179 } 6435 }
6180 6436
6181 private: 6437 private:
6438 HStoreNamedField(HValue* obj,
6439 HObjectAccess access,
6440 HValue* val)
6441 : access_(access),
6442 transition_(),
6443 transition_unique_id_(),
6444 new_space_dominator_(NULL),
6445 write_barrier_mode_(UPDATE_WRITE_BARRIER) {
6446 SetOperandAt(0, obj);
6447 SetOperandAt(1, val);
6448 access.SetGVNFlags(this, true);
6449 }
6450
6182 HObjectAccess access_; 6451 HObjectAccess access_;
6183 Handle<Map> transition_; 6452 Handle<Map> transition_;
6184 UniqueValueId transition_unique_id_; 6453 UniqueValueId transition_unique_id_;
6185 HValue* new_space_dominator_; 6454 HValue* new_space_dominator_;
6186 WriteBarrierMode write_barrier_mode_; 6455 WriteBarrierMode write_barrier_mode_;
6187 }; 6456 };
6188 6457
6189 6458
6190 class HStoreNamedGeneric: public HTemplateInstruction<3> { 6459 class HStoreNamedGeneric: public HTemplateInstruction<3> {
6191 public: 6460 public:
(...skipping 26 matching lines...) Expand all
6218 6487
6219 private: 6488 private:
6220 Handle<String> name_; 6489 Handle<String> name_;
6221 StrictModeFlag strict_mode_flag_; 6490 StrictModeFlag strict_mode_flag_;
6222 }; 6491 };
6223 6492
6224 6493
6225 class HStoreKeyed 6494 class HStoreKeyed
6226 : public HTemplateInstruction<3>, public ArrayInstructionInterface { 6495 : public HTemplateInstruction<3>, public ArrayInstructionInterface {
6227 public: 6496 public:
6228 HStoreKeyed(HValue* obj, HValue* key, HValue* val, 6497 DECLARE_INSTRUCTION_FACTORY_P4(HStoreKeyed, HValue*, HValue*, HValue*,
6229 ElementsKind elements_kind) 6498 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 6499
6261 virtual bool HasEscapingOperandAt(int index) { return index != 0; } 6500 virtual bool HasEscapingOperandAt(int index) { return index != 0; }
6262 virtual Representation RequiredInputRepresentation(int index) { 6501 virtual Representation RequiredInputRepresentation(int index) {
6263 // kind_fast: tagged[int32] = tagged 6502 // kind_fast: tagged[int32] = tagged
6264 // kind_double: tagged[int32] = double 6503 // kind_double: tagged[int32] = double
6265 // kind_smi : tagged[int32] = smi 6504 // kind_smi : tagged[int32] = smi
6266 // kind_external: external[int32] = (double | int32) 6505 // kind_external: external[int32] = (double | int32)
6267 if (index == 0) { 6506 if (index == 0) {
6268 return is_external() ? Representation::External() 6507 return is_external() ? Representation::External()
6269 : Representation::Tagged(); 6508 : Representation::Tagged();
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
6346 } 6585 }
6347 } 6586 }
6348 6587
6349 bool NeedsCanonicalization(); 6588 bool NeedsCanonicalization();
6350 6589
6351 virtual void PrintDataTo(StringStream* stream); 6590 virtual void PrintDataTo(StringStream* stream);
6352 6591
6353 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed) 6592 DECLARE_CONCRETE_INSTRUCTION(StoreKeyed)
6354 6593
6355 private: 6594 private:
6595 HStoreKeyed(HValue* obj, HValue* key, HValue* val,
6596 ElementsKind elements_kind)
6597 : elements_kind_(elements_kind),
6598 index_offset_(0),
6599 is_dehoisted_(false),
6600 is_uninitialized_(false),
6601 new_space_dominator_(NULL) {
6602 SetOperandAt(0, obj);
6603 SetOperandAt(1, key);
6604 SetOperandAt(2, val);
6605
6606 if (IsFastObjectElementsKind(elements_kind)) {
6607 SetFlag(kTrackSideEffectDominators);
6608 SetGVNFlag(kDependsOnNewSpacePromotion);
6609 }
6610 if (is_external()) {
6611 SetGVNFlag(kChangesExternalMemory);
6612 SetFlag(kAllowUndefinedAsNaN);
6613 } else if (IsFastDoubleElementsKind(elements_kind)) {
6614 SetGVNFlag(kChangesDoubleArrayElements);
6615 } else if (IsFastSmiElementsKind(elements_kind)) {
6616 SetGVNFlag(kChangesArrayElements);
6617 } else {
6618 SetGVNFlag(kChangesArrayElements);
6619 }
6620
6621 // EXTERNAL_{UNSIGNED_,}{BYTE,SHORT,INT}_ELEMENTS are truncating.
6622 if (elements_kind >= EXTERNAL_BYTE_ELEMENTS &&
6623 elements_kind <= EXTERNAL_UNSIGNED_INT_ELEMENTS) {
6624 SetFlag(kTruncatingToInt32);
6625 }
6626 }
6627
6356 ElementsKind elements_kind_; 6628 ElementsKind elements_kind_;
6357 uint32_t index_offset_; 6629 uint32_t index_offset_;
6358 bool is_dehoisted_ : 1; 6630 bool is_dehoisted_ : 1;
6359 bool is_uninitialized_ : 1; 6631 bool is_uninitialized_ : 1;
6360 HValue* new_space_dominator_; 6632 HValue* new_space_dominator_;
6361 }; 6633 };
6362 6634
6363 6635
6364 class HStoreKeyedGeneric: public HTemplateInstruction<4> { 6636 class HStoreKeyedGeneric: public HTemplateInstruction<4> {
6365 public: 6637 public:
(...skipping 25 matching lines...) Expand all
6391 6663
6392 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric) 6664 DECLARE_CONCRETE_INSTRUCTION(StoreKeyedGeneric)
6393 6665
6394 private: 6666 private:
6395 StrictModeFlag strict_mode_flag_; 6667 StrictModeFlag strict_mode_flag_;
6396 }; 6668 };
6397 6669
6398 6670
6399 class HTransitionElementsKind: public HTemplateInstruction<2> { 6671 class HTransitionElementsKind: public HTemplateInstruction<2> {
6400 public: 6672 public:
6401 HTransitionElementsKind(HValue* context, 6673 inline static HTransitionElementsKind* New(Zone* zone,
6402 HValue* object, 6674 HValue* context,
6403 Handle<Map> original_map, 6675 HValue* object,
6404 Handle<Map> transitioned_map) 6676 Handle<Map> original_map,
6405 : original_map_(original_map), 6677 Handle<Map> transitioned_map) {
6406 transitioned_map_(transitioned_map), 6678 return new(zone) HTransitionElementsKind(context, object,
6407 original_map_unique_id_(), 6679 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 } 6680 }
6425 6681
6426 virtual Representation RequiredInputRepresentation(int index) { 6682 virtual Representation RequiredInputRepresentation(int index) {
6427 return Representation::Tagged(); 6683 return Representation::Tagged();
6428 } 6684 }
6429 6685
6430 HValue* object() { return OperandAt(0); } 6686 HValue* object() { return OperandAt(0); }
6431 HValue* context() { return OperandAt(1); } 6687 HValue* context() { return OperandAt(1); }
6432 Handle<Map> original_map() { return original_map_; } 6688 Handle<Map> original_map() { return original_map_; }
6433 Handle<Map> transitioned_map() { return transitioned_map_; } 6689 Handle<Map> transitioned_map() { return transitioned_map_; }
(...skipping 10 matching lines...) Expand all
6444 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind) 6700 DECLARE_CONCRETE_INSTRUCTION(TransitionElementsKind)
6445 6701
6446 protected: 6702 protected:
6447 virtual bool DataEquals(HValue* other) { 6703 virtual bool DataEquals(HValue* other) {
6448 HTransitionElementsKind* instr = HTransitionElementsKind::cast(other); 6704 HTransitionElementsKind* instr = HTransitionElementsKind::cast(other);
6449 return original_map_unique_id_ == instr->original_map_unique_id_ && 6705 return original_map_unique_id_ == instr->original_map_unique_id_ &&
6450 transitioned_map_unique_id_ == instr->transitioned_map_unique_id_; 6706 transitioned_map_unique_id_ == instr->transitioned_map_unique_id_;
6451 } 6707 }
6452 6708
6453 private: 6709 private:
6710 HTransitionElementsKind(HValue* context,
6711 HValue* object,
6712 Handle<Map> original_map,
6713 Handle<Map> transitioned_map)
6714 : original_map_(original_map),
6715 transitioned_map_(transitioned_map),
6716 original_map_unique_id_(),
6717 transitioned_map_unique_id_(),
6718 from_kind_(original_map->elements_kind()),
6719 to_kind_(transitioned_map->elements_kind()) {
6720 SetOperandAt(0, object);
6721 SetOperandAt(1, context);
6722 SetFlag(kUseGVN);
6723 SetGVNFlag(kChangesElementsKind);
6724 if (original_map->has_fast_double_elements()) {
6725 SetGVNFlag(kChangesElementsPointer);
6726 SetGVNFlag(kChangesNewSpacePromotion);
6727 }
6728 if (transitioned_map->has_fast_double_elements()) {
6729 SetGVNFlag(kChangesElementsPointer);
6730 SetGVNFlag(kChangesNewSpacePromotion);
6731 }
6732 set_representation(Representation::Tagged());
6733 }
6734
6454 Handle<Map> original_map_; 6735 Handle<Map> original_map_;
6455 Handle<Map> transitioned_map_; 6736 Handle<Map> transitioned_map_;
6456 UniqueValueId original_map_unique_id_; 6737 UniqueValueId original_map_unique_id_;
6457 UniqueValueId transitioned_map_unique_id_; 6738 UniqueValueId transitioned_map_unique_id_;
6458 ElementsKind from_kind_; 6739 ElementsKind from_kind_;
6459 ElementsKind to_kind_; 6740 ElementsKind to_kind_;
6460 }; 6741 };
6461 6742
6462 6743
6463 class HStringAdd: public HBinaryOperation { 6744 class HStringAdd: public HBinaryOperation {
(...skipping 27 matching lines...) Expand all
6491 // No side-effects except possible allocation. 6772 // No side-effects except possible allocation.
6492 // NOTE: this instruction _does not_ call ToString() on its inputs. 6773 // NOTE: this instruction _does not_ call ToString() on its inputs.
6493 virtual bool IsDeletable() const { return true; } 6774 virtual bool IsDeletable() const { return true; }
6494 6775
6495 const StringAddFlags flags_; 6776 const StringAddFlags flags_;
6496 }; 6777 };
6497 6778
6498 6779
6499 class HStringCharCodeAt: public HTemplateInstruction<3> { 6780 class HStringCharCodeAt: public HTemplateInstruction<3> {
6500 public: 6781 public:
6501 HStringCharCodeAt(HValue* context, HValue* string, HValue* index) { 6782 static HStringCharCodeAt* New(Zone* zone,
6502 SetOperandAt(0, context); 6783 HValue* context,
6503 SetOperandAt(1, string); 6784 HValue* string,
6504 SetOperandAt(2, index); 6785 HValue* index) {
6505 set_representation(Representation::Integer32()); 6786 return new(zone) HStringCharCodeAt(context, string, index);
6506 SetFlag(kUseGVN);
6507 SetGVNFlag(kDependsOnMaps);
6508 SetGVNFlag(kChangesNewSpacePromotion);
6509 } 6787 }
6510 6788
6511 virtual Representation RequiredInputRepresentation(int index) { 6789 virtual Representation RequiredInputRepresentation(int index) {
6512 // The index is supposed to be Integer32. 6790 // The index is supposed to be Integer32.
6513 return index == 2 6791 return index == 2
6514 ? Representation::Integer32() 6792 ? Representation::Integer32()
6515 : Representation::Tagged(); 6793 : Representation::Tagged();
6516 } 6794 }
6517 6795
6518 HValue* context() const { return OperandAt(0); } 6796 HValue* context() const { return OperandAt(0); }
6519 HValue* string() const { return OperandAt(1); } 6797 HValue* string() const { return OperandAt(1); }
6520 HValue* index() const { return OperandAt(2); } 6798 HValue* index() const { return OperandAt(2); }
6521 6799
6522 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt) 6800 DECLARE_CONCRETE_INSTRUCTION(StringCharCodeAt)
6523 6801
6524 protected: 6802 protected:
6525 virtual bool DataEquals(HValue* other) { return true; } 6803 virtual bool DataEquals(HValue* other) { return true; }
6526 6804
6527 virtual Range* InferRange(Zone* zone) { 6805 virtual Range* InferRange(Zone* zone) {
6528 return new(zone) Range(0, String::kMaxUtf16CodeUnit); 6806 return new(zone) Range(0, String::kMaxUtf16CodeUnit);
6529 } 6807 }
6530 6808
6531 private: 6809 private:
6810 HStringCharCodeAt(HValue* context, HValue* string, HValue* index) {
6811 SetOperandAt(0, context);
6812 SetOperandAt(1, string);
6813 SetOperandAt(2, index);
6814 set_representation(Representation::Integer32());
6815 SetFlag(kUseGVN);
6816 SetGVNFlag(kDependsOnMaps);
6817 SetGVNFlag(kChangesNewSpacePromotion);
6818 }
6819
6532 // No side effects: runtime function assumes string + number inputs. 6820 // No side effects: runtime function assumes string + number inputs.
6533 virtual bool IsDeletable() const { return true; } 6821 virtual bool IsDeletable() const { return true; }
6534 }; 6822 };
6535 6823
6536 6824
6537 class HStringCharFromCode: public HTemplateInstruction<2> { 6825 class HStringCharFromCode: public HTemplateInstruction<2> {
6538 public: 6826 public:
6539 static HInstruction* New(Zone* zone, 6827 static HInstruction* New(Zone* zone,
6540 HValue* context, 6828 HValue* context,
6541 HValue* char_code); 6829 HValue* char_code);
(...skipping 22 matching lines...) Expand all
6564 } 6852 }
6565 6853
6566 virtual bool IsDeletable() const { 6854 virtual bool IsDeletable() const {
6567 return !value()->ToNumberCanBeObserved(); 6855 return !value()->ToNumberCanBeObserved();
6568 } 6856 }
6569 }; 6857 };
6570 6858
6571 6859
6572 class HStringLength: public HUnaryOperation { 6860 class HStringLength: public HUnaryOperation {
6573 public: 6861 public:
6574 static HInstruction* New(Zone* zone, HValue* string); 6862 static HInstruction* New(Zone* zone, HValue* context, HValue* string);
6575 6863
6576 virtual Representation RequiredInputRepresentation(int index) { 6864 virtual Representation RequiredInputRepresentation(int index) {
6577 return Representation::Tagged(); 6865 return Representation::Tagged();
6578 } 6866 }
6579 6867
6580 DECLARE_CONCRETE_INSTRUCTION(StringLength) 6868 DECLARE_CONCRETE_INSTRUCTION(StringLength)
6581 6869
6582 protected: 6870 protected:
6583 virtual bool DataEquals(HValue* other) { return true; } 6871 virtual bool DataEquals(HValue* other) { return true; }
6584 6872
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
6722 7010
6723 DECLARE_CONCRETE_INSTRUCTION(Typeof) 7011 DECLARE_CONCRETE_INSTRUCTION(Typeof)
6724 7012
6725 private: 7013 private:
6726 virtual bool IsDeletable() const { return true; } 7014 virtual bool IsDeletable() const { return true; }
6727 }; 7015 };
6728 7016
6729 7017
6730 class HTrapAllocationMemento : public HTemplateInstruction<1> { 7018 class HTrapAllocationMemento : public HTemplateInstruction<1> {
6731 public: 7019 public:
6732 explicit HTrapAllocationMemento(HValue* obj) { 7020 DECLARE_INSTRUCTION_FACTORY_P1(HTrapAllocationMemento, HValue*);
6733 SetOperandAt(0, obj);
6734 }
6735 7021
6736 virtual Representation RequiredInputRepresentation(int index) { 7022 virtual Representation RequiredInputRepresentation(int index) {
6737 return Representation::Tagged(); 7023 return Representation::Tagged();
6738 } 7024 }
6739 7025
6740 HValue* object() { return OperandAt(0); } 7026 HValue* object() { return OperandAt(0); }
6741 7027
6742 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento) 7028 DECLARE_CONCRETE_INSTRUCTION(TrapAllocationMemento)
7029
7030 private:
7031 explicit HTrapAllocationMemento(HValue* obj) {
7032 SetOperandAt(0, obj);
7033 }
6743 }; 7034 };
6744 7035
6745 7036
6746 class HToFastProperties: public HUnaryOperation { 7037 class HToFastProperties: public HUnaryOperation {
6747 public: 7038 public:
7039 DECLARE_INSTRUCTION_FACTORY_P1(HToFastProperties, HValue*);
7040
7041 virtual Representation RequiredInputRepresentation(int index) {
7042 return Representation::Tagged();
7043 }
7044
7045 DECLARE_CONCRETE_INSTRUCTION(ToFastProperties)
7046
7047 private:
6748 explicit HToFastProperties(HValue* value) : HUnaryOperation(value) { 7048 explicit HToFastProperties(HValue* value) : HUnaryOperation(value) {
6749 // This instruction is not marked as having side effects, but 7049 // This instruction is not marked as having side effects, but
6750 // changes the map of the input operand. Use it only when creating 7050 // changes the map of the input operand. Use it only when creating
6751 // object literals via a runtime call. 7051 // object literals via a runtime call.
6752 ASSERT(value->IsCallRuntime()); 7052 ASSERT(value->IsCallRuntime());
6753 #ifdef DEBUG 7053 #ifdef DEBUG
6754 const Runtime::Function* function = HCallRuntime::cast(value)->function(); 7054 const Runtime::Function* function = HCallRuntime::cast(value)->function();
6755 ASSERT(function->function_id == Runtime::kCreateObjectLiteral || 7055 ASSERT(function->function_id == Runtime::kCreateObjectLiteral ||
6756 function->function_id == Runtime::kCreateObjectLiteralShallow); 7056 function->function_id == Runtime::kCreateObjectLiteralShallow);
6757 #endif 7057 #endif
6758 set_representation(Representation::Tagged()); 7058 set_representation(Representation::Tagged());
6759 } 7059 }
6760 7060
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; } 7061 virtual bool IsDeletable() const { return true; }
6769 }; 7062 };
6770 7063
6771 7064
6772 class HValueOf: public HUnaryOperation { 7065 class HValueOf: public HUnaryOperation {
6773 public: 7066 public:
6774 explicit HValueOf(HValue* value) : HUnaryOperation(value) { 7067 explicit HValueOf(HValue* value) : HUnaryOperation(value) {
6775 set_representation(Representation::Tagged()); 7068 set_representation(Representation::Tagged());
6776 } 7069 }
6777 7070
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
6830 7123
6831 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar) 7124 DECLARE_CONCRETE_INSTRUCTION(SeqStringSetChar)
6832 7125
6833 private: 7126 private:
6834 String::Encoding encoding_; 7127 String::Encoding encoding_;
6835 }; 7128 };
6836 7129
6837 7130
6838 class HCheckMapValue: public HTemplateInstruction<2> { 7131 class HCheckMapValue: public HTemplateInstruction<2> {
6839 public: 7132 public:
6840 HCheckMapValue(HValue* value, 7133 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 7134
6850 virtual Representation RequiredInputRepresentation(int index) { 7135 virtual Representation RequiredInputRepresentation(int index) {
6851 return Representation::Tagged(); 7136 return Representation::Tagged();
6852 } 7137 }
6853 7138
6854 virtual void PrintDataTo(StringStream* stream); 7139 virtual void PrintDataTo(StringStream* stream);
6855 7140
6856 virtual HType CalculateInferredType() { 7141 virtual HType CalculateInferredType() {
6857 return HType::Tagged(); 7142 return HType::Tagged();
6858 } 7143 }
6859 7144
6860 HValue* value() { return OperandAt(0); } 7145 HValue* value() { return OperandAt(0); }
6861 HValue* map() { return OperandAt(1); } 7146 HValue* map() { return OperandAt(1); }
6862 7147
6863 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue) 7148 DECLARE_CONCRETE_INSTRUCTION(CheckMapValue)
6864 7149
6865 protected: 7150 protected:
6866 virtual bool DataEquals(HValue* other) { 7151 virtual bool DataEquals(HValue* other) {
6867 return true; 7152 return true;
6868 } 7153 }
7154
7155 private:
7156 HCheckMapValue(HValue* value,
7157 HValue* map) {
7158 SetOperandAt(0, value);
7159 SetOperandAt(1, map);
7160 set_representation(Representation::Tagged());
7161 SetFlag(kUseGVN);
7162 SetGVNFlag(kDependsOnMaps);
7163 SetGVNFlag(kDependsOnElementsKind);
7164 }
6869 }; 7165 };
6870 7166
6871 7167
6872 class HForInPrepareMap : public HTemplateInstruction<2> { 7168 class HForInPrepareMap : public HTemplateInstruction<2> {
6873 public: 7169 public:
6874 HForInPrepareMap(HValue* context, 7170 static HForInPrepareMap* New(Zone* zone,
6875 HValue* object) { 7171 HValue* context,
6876 SetOperandAt(0, context); 7172 HValue* object) {
6877 SetOperandAt(1, object); 7173 return new(zone) HForInPrepareMap(context, object);
6878 set_representation(Representation::Tagged());
6879 SetAllSideEffects();
6880 } 7174 }
6881 7175
6882 virtual Representation RequiredInputRepresentation(int index) { 7176 virtual Representation RequiredInputRepresentation(int index) {
6883 return Representation::Tagged(); 7177 return Representation::Tagged();
6884 } 7178 }
6885 7179
6886 HValue* context() { return OperandAt(0); } 7180 HValue* context() { return OperandAt(0); }
6887 HValue* enumerable() { return OperandAt(1); } 7181 HValue* enumerable() { return OperandAt(1); }
6888 7182
6889 virtual void PrintDataTo(StringStream* stream); 7183 virtual void PrintDataTo(StringStream* stream);
6890 7184
6891 virtual HType CalculateInferredType() { 7185 virtual HType CalculateInferredType() {
6892 return HType::Tagged(); 7186 return HType::Tagged();
6893 } 7187 }
6894 7188
6895 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap); 7189 DECLARE_CONCRETE_INSTRUCTION(ForInPrepareMap);
7190
7191 private:
7192 HForInPrepareMap(HValue* context,
7193 HValue* object) {
7194 SetOperandAt(0, context);
7195 SetOperandAt(1, object);
7196 set_representation(Representation::Tagged());
7197 SetAllSideEffects();
7198 }
6896 }; 7199 };
6897 7200
6898 7201
6899 class HForInCacheArray : public HTemplateInstruction<2> { 7202 class HForInCacheArray : public HTemplateInstruction<2> {
6900 public: 7203 public:
6901 HForInCacheArray(HValue* enumerable, 7204 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 7205
6909 virtual Representation RequiredInputRepresentation(int index) { 7206 virtual Representation RequiredInputRepresentation(int index) {
6910 return Representation::Tagged(); 7207 return Representation::Tagged();
6911 } 7208 }
6912 7209
6913 HValue* enumerable() { return OperandAt(0); } 7210 HValue* enumerable() { return OperandAt(0); }
6914 HValue* map() { return OperandAt(1); } 7211 HValue* map() { return OperandAt(1); }
6915 int idx() { return idx_; } 7212 int idx() { return idx_; }
6916 7213
6917 HForInCacheArray* index_cache() { 7214 HForInCacheArray* index_cache() {
6918 return index_cache_; 7215 return index_cache_;
6919 } 7216 }
6920 7217
6921 void set_index_cache(HForInCacheArray* index_cache) { 7218 void set_index_cache(HForInCacheArray* index_cache) {
6922 index_cache_ = index_cache; 7219 index_cache_ = index_cache;
6923 } 7220 }
6924 7221
6925 virtual void PrintDataTo(StringStream* stream); 7222 virtual void PrintDataTo(StringStream* stream);
6926 7223
6927 virtual HType CalculateInferredType() { 7224 virtual HType CalculateInferredType() {
6928 return HType::Tagged(); 7225 return HType::Tagged();
6929 } 7226 }
6930 7227
6931 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray); 7228 DECLARE_CONCRETE_INSTRUCTION(ForInCacheArray);
6932 7229
6933 private: 7230 private:
7231 HForInCacheArray(HValue* enumerable,
7232 HValue* keys,
7233 int idx) : idx_(idx) {
7234 SetOperandAt(0, enumerable);
7235 SetOperandAt(1, keys);
7236 set_representation(Representation::Tagged());
7237 }
7238
6934 int idx_; 7239 int idx_;
6935 HForInCacheArray* index_cache_; 7240 HForInCacheArray* index_cache_;
6936 }; 7241 };
6937 7242
6938 7243
6939 class HLoadFieldByIndex : public HTemplateInstruction<2> { 7244 class HLoadFieldByIndex : public HTemplateInstruction<2> {
6940 public: 7245 public:
6941 HLoadFieldByIndex(HValue* object, 7246 HLoadFieldByIndex(HValue* object,
6942 HValue* index) { 7247 HValue* index) {
6943 SetOperandAt(0, object); 7248 SetOperandAt(0, object);
(...skipping 20 matching lines...) Expand all
6964 virtual bool IsDeletable() const { return true; } 7269 virtual bool IsDeletable() const { return true; }
6965 }; 7270 };
6966 7271
6967 7272
6968 #undef DECLARE_INSTRUCTION 7273 #undef DECLARE_INSTRUCTION
6969 #undef DECLARE_CONCRETE_INSTRUCTION 7274 #undef DECLARE_CONCRETE_INSTRUCTION
6970 7275
6971 } } // namespace v8::internal 7276 } } // namespace v8::internal
6972 7277
6973 #endif // V8_HYDROGEN_INSTRUCTIONS_H_ 7278 #endif // V8_HYDROGEN_INSTRUCTIONS_H_
OLDNEW
« no previous file with comments | « src/hydrogen-bch.cc ('k') | src/hydrogen-instructions.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698