| OLD | NEW |
| 1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef V8_AST_H_ | 5 #ifndef V8_AST_H_ |
| 6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
| 7 | 7 |
| 8 #include "src/v8.h" | 8 #include "src/v8.h" |
| 9 | 9 |
| 10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 template<class> friend class AstNodeFactory; | 150 template<class> friend class AstNodeFactory; |
| 151 | 151 |
| 152 | 152 |
| 153 enum AstPropertiesFlag { | 153 enum AstPropertiesFlag { |
| 154 kDontSelfOptimize, | 154 kDontSelfOptimize, |
| 155 kDontSoftInline, | 155 kDontSoftInline, |
| 156 kDontCache | 156 kDontCache |
| 157 }; | 157 }; |
| 158 | 158 |
| 159 | 159 |
| 160 class FeedbackVectorRequirements { |
| 161 public: |
| 162 FeedbackVectorRequirements(int slots, int ic_slots) |
| 163 : slots_(slots), ic_slots_(ic_slots) {} |
| 164 |
| 165 int slots() const { return slots_; } |
| 166 int ic_slots() const { return ic_slots_; } |
| 167 |
| 168 private: |
| 169 int slots_; |
| 170 int ic_slots_; |
| 171 }; |
| 172 |
| 173 |
| 160 class AstProperties FINAL BASE_EMBEDDED { | 174 class AstProperties FINAL BASE_EMBEDDED { |
| 161 public: | 175 public: |
| 162 class Flags : public EnumSet<AstPropertiesFlag, int> {}; | 176 class Flags : public EnumSet<AstPropertiesFlag, int> {}; |
| 163 | 177 |
| 164 AstProperties() : node_count_(0), feedback_slots_(0) {} | 178 AstProperties() : node_count_(0), feedback_slots_(0), ic_feedback_slots_(0) {} |
| 165 | 179 |
| 166 Flags* flags() { return &flags_; } | 180 Flags* flags() { return &flags_; } |
| 167 int node_count() { return node_count_; } | 181 int node_count() { return node_count_; } |
| 168 void add_node_count(int count) { node_count_ += count; } | 182 void add_node_count(int count) { node_count_ += count; } |
| 169 | 183 |
| 170 int feedback_slots() const { return feedback_slots_; } | 184 int feedback_slots() const { return feedback_slots_; } |
| 171 void increase_feedback_slots(int count) { | 185 void increase_feedback_slots(int count) { |
| 172 feedback_slots_ += count; | 186 feedback_slots_ += count; |
| 173 } | 187 } |
| 174 | 188 |
| 189 int ic_feedback_slots() const { return ic_feedback_slots_; } |
| 190 void increase_ic_feedback_slots(int count) { ic_feedback_slots_ += count; } |
| 191 |
| 175 private: | 192 private: |
| 176 Flags flags_; | 193 Flags flags_; |
| 177 int node_count_; | 194 int node_count_; |
| 178 int feedback_slots_; | 195 int feedback_slots_; |
| 196 int ic_feedback_slots_; |
| 179 }; | 197 }; |
| 180 | 198 |
| 181 | 199 |
| 182 class AstNode: public ZoneObject { | 200 class AstNode: public ZoneObject { |
| 183 public: | 201 public: |
| 184 // For generating IDs for AstNodes. | 202 // For generating IDs for AstNodes. |
| 185 class IdGen { | 203 class IdGen { |
| 186 public: | 204 public: |
| 187 IdGen() : id_(BailoutId::FirstUsable().ToInt()) {} | 205 IdGen() : id_(BailoutId::FirstUsable().ToInt()) {} |
| 188 | 206 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 230 | 248 |
| 231 virtual TargetCollector* AsTargetCollector() { return NULL; } | 249 virtual TargetCollector* AsTargetCollector() { return NULL; } |
| 232 virtual BreakableStatement* AsBreakableStatement() { return NULL; } | 250 virtual BreakableStatement* AsBreakableStatement() { return NULL; } |
| 233 virtual IterationStatement* AsIterationStatement() { return NULL; } | 251 virtual IterationStatement* AsIterationStatement() { return NULL; } |
| 234 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } | 252 virtual MaterializedLiteral* AsMaterializedLiteral() { return NULL; } |
| 235 | 253 |
| 236 // The interface for feedback slots, with default no-op implementations for | 254 // The interface for feedback slots, with default no-op implementations for |
| 237 // node types which don't actually have this. Note that this is conceptually | 255 // node types which don't actually have this. Note that this is conceptually |
| 238 // not really nice, but multiple inheritance would introduce yet another | 256 // not really nice, but multiple inheritance would introduce yet another |
| 239 // vtable entry per node, something we don't want for space reasons. | 257 // vtable entry per node, something we don't want for space reasons. |
| 240 virtual int ComputeFeedbackSlotCount() { | 258 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 241 UNREACHABLE(); | 259 return FeedbackVectorRequirements(0, 0); |
| 242 return 0; | |
| 243 } | 260 } |
| 244 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { UNREACHABLE(); } | 261 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { UNREACHABLE(); } |
| 262 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 263 UNREACHABLE(); |
| 264 } |
| 245 | 265 |
| 246 private: | 266 private: |
| 247 // Hidden to prevent accidental usage. It would have to load the | 267 // Hidden to prevent accidental usage. It would have to load the |
| 248 // current zone from the TLS. | 268 // current zone from the TLS. |
| 249 void* operator new(size_t size); | 269 void* operator new(size_t size); |
| 250 | 270 |
| 251 friend class CaseClause; // Generates AST IDs. | 271 friend class CaseClause; // Generates AST IDs. |
| 252 | 272 |
| 253 int position_; | 273 int position_; |
| 254 }; | 274 }; |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 940 | 960 |
| 941 class ForInStatement FINAL : public ForEachStatement { | 961 class ForInStatement FINAL : public ForEachStatement { |
| 942 public: | 962 public: |
| 943 DECLARE_NODE_TYPE(ForInStatement) | 963 DECLARE_NODE_TYPE(ForInStatement) |
| 944 | 964 |
| 945 Expression* enumerable() const { | 965 Expression* enumerable() const { |
| 946 return subject(); | 966 return subject(); |
| 947 } | 967 } |
| 948 | 968 |
| 949 // Type feedback information. | 969 // Type feedback information. |
| 950 virtual int ComputeFeedbackSlotCount() { return 1; } | 970 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 971 return FeedbackVectorRequirements(1, 0); |
| 972 } |
| 951 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 973 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { |
| 952 for_in_feedback_slot_ = slot; | 974 for_in_feedback_slot_ = slot; |
| 953 } | 975 } |
| 954 | 976 |
| 955 FeedbackVectorSlot ForInFeedbackSlot() { | 977 FeedbackVectorSlot ForInFeedbackSlot() { |
| 956 DCHECK(!for_in_feedback_slot_.IsInvalid()); | 978 DCHECK(!for_in_feedback_slot_.IsInvalid()); |
| 957 return for_in_feedback_slot_; | 979 return for_in_feedback_slot_; |
| 958 } | 980 } |
| 959 | 981 |
| 960 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 982 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1687 void set_is_assigned() { is_assigned_ = true; } | 1709 void set_is_assigned() { is_assigned_ = true; } |
| 1688 | 1710 |
| 1689 bool is_resolved() const { return is_resolved_; } | 1711 bool is_resolved() const { return is_resolved_; } |
| 1690 void set_is_resolved() { is_resolved_ = true; } | 1712 void set_is_resolved() { is_resolved_ = true; } |
| 1691 | 1713 |
| 1692 Interface* interface() const { return interface_; } | 1714 Interface* interface() const { return interface_; } |
| 1693 | 1715 |
| 1694 // Bind this proxy to the variable var. Interfaces must match. | 1716 // Bind this proxy to the variable var. Interfaces must match. |
| 1695 void BindTo(Variable* var); | 1717 void BindTo(Variable* var); |
| 1696 | 1718 |
| 1697 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 1719 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1698 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 1720 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); |
| 1721 } |
| 1722 virtual void SetFirstICFeedbackSlot(FeedbackVectorICSlot slot) { |
| 1699 variable_feedback_slot_ = slot; | 1723 variable_feedback_slot_ = slot; |
| 1700 } | 1724 } |
| 1701 | 1725 |
| 1702 FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; } | 1726 FeedbackVectorICSlot VariableFeedbackSlot() { |
| 1727 return variable_feedback_slot_; |
| 1728 } |
| 1703 | 1729 |
| 1704 protected: | 1730 protected: |
| 1705 VariableProxy(Zone* zone, Variable* var, int position, IdGen* id_gen); | 1731 VariableProxy(Zone* zone, Variable* var, int position, IdGen* id_gen); |
| 1706 | 1732 |
| 1707 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, | 1733 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, |
| 1708 Interface* interface, int position, IdGen* id_gen); | 1734 Interface* interface, int position, IdGen* id_gen); |
| 1709 | 1735 |
| 1710 union { | 1736 union { |
| 1711 const AstRawString* raw_name_; // if !is_resolved_ | 1737 const AstRawString* raw_name_; // if !is_resolved_ |
| 1712 Variable* var_; // if is_resolved_ | 1738 Variable* var_; // if is_resolved_ |
| 1713 }; | 1739 }; |
| 1714 Interface* interface_; | 1740 Interface* interface_; |
| 1715 FeedbackVectorSlot variable_feedback_slot_; | 1741 FeedbackVectorICSlot variable_feedback_slot_; |
| 1716 bool is_this_ : 1; | 1742 bool is_this_ : 1; |
| 1717 bool is_assigned_ : 1; | 1743 bool is_assigned_ : 1; |
| 1718 bool is_resolved_ : 1; | 1744 bool is_resolved_ : 1; |
| 1719 }; | 1745 }; |
| 1720 | 1746 |
| 1721 | 1747 |
| 1722 class Property FINAL : public Expression { | 1748 class Property FINAL : public Expression { |
| 1723 public: | 1749 public: |
| 1724 DECLARE_NODE_TYPE(Property) | 1750 DECLARE_NODE_TYPE(Property) |
| 1725 | 1751 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 1750 } | 1776 } |
| 1751 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 1777 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
| 1752 void set_is_string_access(bool b) { is_string_access_ = b; } | 1778 void set_is_string_access(bool b) { is_string_access_ = b; } |
| 1753 void mark_for_call() { is_for_call_ = true; } | 1779 void mark_for_call() { is_for_call_ = true; } |
| 1754 bool IsForCall() { return is_for_call_; } | 1780 bool IsForCall() { return is_for_call_; } |
| 1755 | 1781 |
| 1756 bool IsSuperAccess() { | 1782 bool IsSuperAccess() { |
| 1757 return obj()->IsSuperReference(); | 1783 return obj()->IsSuperReference(); |
| 1758 } | 1784 } |
| 1759 | 1785 |
| 1760 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 1786 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1761 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 1787 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); |
| 1788 } |
| 1789 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 1762 property_feedback_slot_ = slot; | 1790 property_feedback_slot_ = slot; |
| 1763 } | 1791 } |
| 1764 | 1792 |
| 1765 FeedbackVectorSlot PropertyFeedbackSlot() const { | 1793 FeedbackVectorICSlot PropertyFeedbackSlot() const { |
| 1766 return property_feedback_slot_; | 1794 return property_feedback_slot_; |
| 1767 } | 1795 } |
| 1768 | 1796 |
| 1769 protected: | 1797 protected: |
| 1770 Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen) | 1798 Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen) |
| 1771 : Expression(zone, pos, num_ids(), id_gen), | 1799 : Expression(zone, pos, num_ids(), id_gen), |
| 1772 obj_(obj), | 1800 obj_(obj), |
| 1773 key_(key), | 1801 key_(key), |
| 1774 property_feedback_slot_(FeedbackVectorSlot::Invalid()), | 1802 property_feedback_slot_(FeedbackVectorICSlot::Invalid()), |
| 1775 is_for_call_(false), | 1803 is_for_call_(false), |
| 1776 is_uninitialized_(false), | 1804 is_uninitialized_(false), |
| 1777 is_string_access_(false) {} | 1805 is_string_access_(false) {} |
| 1778 | 1806 |
| 1779 static int num_ids() { return 2; } | 1807 static int num_ids() { return 2; } |
| 1780 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 1808 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 1781 | 1809 |
| 1782 private: | 1810 private: |
| 1783 Expression* obj_; | 1811 Expression* obj_; |
| 1784 Expression* key_; | 1812 Expression* key_; |
| 1785 FeedbackVectorSlot property_feedback_slot_; | 1813 FeedbackVectorICSlot property_feedback_slot_; |
| 1786 | 1814 |
| 1787 SmallMapList receiver_types_; | 1815 SmallMapList receiver_types_; |
| 1788 bool is_for_call_ : 1; | 1816 bool is_for_call_ : 1; |
| 1789 bool is_uninitialized_ : 1; | 1817 bool is_uninitialized_ : 1; |
| 1790 bool is_string_access_ : 1; | 1818 bool is_string_access_ : 1; |
| 1791 }; | 1819 }; |
| 1792 | 1820 |
| 1793 | 1821 |
| 1794 class Call FINAL : public Expression { | 1822 class Call FINAL : public Expression { |
| 1795 public: | 1823 public: |
| 1796 DECLARE_NODE_TYPE(Call) | 1824 DECLARE_NODE_TYPE(Call) |
| 1797 | 1825 |
| 1798 Expression* expression() const { return expression_; } | 1826 Expression* expression() const { return expression_; } |
| 1799 ZoneList<Expression*>* arguments() const { return arguments_; } | 1827 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1800 | 1828 |
| 1801 // Type feedback information. | 1829 // Type feedback information. |
| 1802 virtual int ComputeFeedbackSlotCount() { return 1; } | 1830 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1803 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 1831 return FeedbackVectorRequirements(0, 1); |
| 1832 } |
| 1833 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 1804 call_feedback_slot_ = slot; | 1834 call_feedback_slot_ = slot; |
| 1805 } | 1835 } |
| 1806 | 1836 |
| 1807 bool HasCallFeedbackSlot() const { return !call_feedback_slot_.IsInvalid(); } | 1837 bool HasCallFeedbackSlot() const { return !call_feedback_slot_.IsInvalid(); } |
| 1808 FeedbackVectorSlot CallFeedbackSlot() const { return call_feedback_slot_; } | 1838 FeedbackVectorICSlot CallFeedbackSlot() const { return call_feedback_slot_; } |
| 1809 | 1839 |
| 1810 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 1840 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| 1811 if (expression()->IsProperty()) { | 1841 if (expression()->IsProperty()) { |
| 1812 return expression()->AsProperty()->GetReceiverTypes(); | 1842 return expression()->AsProperty()->GetReceiverTypes(); |
| 1813 } | 1843 } |
| 1814 return NULL; | 1844 return NULL; |
| 1815 } | 1845 } |
| 1816 | 1846 |
| 1817 virtual bool IsMonomorphic() OVERRIDE { | 1847 virtual bool IsMonomorphic() OVERRIDE { |
| 1818 if (expression()->IsProperty()) { | 1848 if (expression()->IsProperty()) { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 // Used to assert that the FullCodeGenerator records the return site. | 1891 // Used to assert that the FullCodeGenerator records the return site. |
| 1862 bool return_is_recorded_; | 1892 bool return_is_recorded_; |
| 1863 #endif | 1893 #endif |
| 1864 | 1894 |
| 1865 protected: | 1895 protected: |
| 1866 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1896 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
| 1867 int pos, IdGen* id_gen) | 1897 int pos, IdGen* id_gen) |
| 1868 : Expression(zone, pos, num_ids(), id_gen), | 1898 : Expression(zone, pos, num_ids(), id_gen), |
| 1869 expression_(expression), | 1899 expression_(expression), |
| 1870 arguments_(arguments), | 1900 arguments_(arguments), |
| 1871 call_feedback_slot_(FeedbackVectorSlot::Invalid()) { | 1901 call_feedback_slot_(FeedbackVectorICSlot::Invalid()) { |
| 1872 if (expression->IsProperty()) { | 1902 if (expression->IsProperty()) { |
| 1873 expression->AsProperty()->mark_for_call(); | 1903 expression->AsProperty()->mark_for_call(); |
| 1874 } | 1904 } |
| 1875 } | 1905 } |
| 1876 | 1906 |
| 1877 static int num_ids() { return 2; } | 1907 static int num_ids() { return 2; } |
| 1878 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 1908 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 1879 | 1909 |
| 1880 private: | 1910 private: |
| 1881 Expression* expression_; | 1911 Expression* expression_; |
| 1882 ZoneList<Expression*>* arguments_; | 1912 ZoneList<Expression*>* arguments_; |
| 1883 Handle<JSFunction> target_; | 1913 Handle<JSFunction> target_; |
| 1884 Handle<Cell> cell_; | 1914 Handle<Cell> cell_; |
| 1885 Handle<AllocationSite> allocation_site_; | 1915 Handle<AllocationSite> allocation_site_; |
| 1886 FeedbackVectorSlot call_feedback_slot_; | 1916 FeedbackVectorICSlot call_feedback_slot_; |
| 1887 }; | 1917 }; |
| 1888 | 1918 |
| 1889 | 1919 |
| 1890 class CallNew FINAL : public Expression { | 1920 class CallNew FINAL : public Expression { |
| 1891 public: | 1921 public: |
| 1892 DECLARE_NODE_TYPE(CallNew) | 1922 DECLARE_NODE_TYPE(CallNew) |
| 1893 | 1923 |
| 1894 Expression* expression() const { return expression_; } | 1924 Expression* expression() const { return expression_; } |
| 1895 ZoneList<Expression*>* arguments() const { return arguments_; } | 1925 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1896 | 1926 |
| 1897 // Type feedback information. | 1927 // Type feedback information. |
| 1898 virtual int ComputeFeedbackSlotCount() { | 1928 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1899 return FLAG_pretenuring_call_new ? 2 : 1; | 1929 return FeedbackVectorRequirements(FLAG_pretenuring_call_new ? 2 : 1, 0); |
| 1900 } | 1930 } |
| 1901 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 1931 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { |
| 1902 callnew_feedback_slot_ = slot; | 1932 callnew_feedback_slot_ = slot; |
| 1903 } | 1933 } |
| 1904 | 1934 |
| 1905 FeedbackVectorSlot CallNewFeedbackSlot() { return callnew_feedback_slot_; } | 1935 FeedbackVectorSlot CallNewFeedbackSlot() { return callnew_feedback_slot_; } |
| 1906 FeedbackVectorSlot AllocationSiteFeedbackSlot() { | 1936 FeedbackVectorSlot AllocationSiteFeedbackSlot() { |
| 1907 DCHECK(FLAG_pretenuring_call_new); | 1937 DCHECK(FLAG_pretenuring_call_new); |
| 1908 return CallNewFeedbackSlot().next(); | 1938 return CallNewFeedbackSlot().next(); |
| 1909 } | 1939 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1949 public: | 1979 public: |
| 1950 DECLARE_NODE_TYPE(CallRuntime) | 1980 DECLARE_NODE_TYPE(CallRuntime) |
| 1951 | 1981 |
| 1952 Handle<String> name() const { return raw_name_->string(); } | 1982 Handle<String> name() const { return raw_name_->string(); } |
| 1953 const AstRawString* raw_name() const { return raw_name_; } | 1983 const AstRawString* raw_name() const { return raw_name_; } |
| 1954 const Runtime::Function* function() const { return function_; } | 1984 const Runtime::Function* function() const { return function_; } |
| 1955 ZoneList<Expression*>* arguments() const { return arguments_; } | 1985 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1956 bool is_jsruntime() const { return function_ == NULL; } | 1986 bool is_jsruntime() const { return function_ == NULL; } |
| 1957 | 1987 |
| 1958 // Type feedback information. | 1988 // Type feedback information. |
| 1959 virtual int ComputeFeedbackSlotCount() { | 1989 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1960 return (FLAG_vector_ics && is_jsruntime()) ? 1 : 0; | 1990 return FeedbackVectorRequirements( |
| 1991 0, (FLAG_vector_ics && is_jsruntime()) ? 1 : 0); |
| 1961 } | 1992 } |
| 1962 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 1993 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 1963 callruntime_feedback_slot_ = slot; | 1994 callruntime_feedback_slot_ = slot; |
| 1964 } | 1995 } |
| 1965 | 1996 |
| 1966 FeedbackVectorSlot CallRuntimeFeedbackSlot() { | 1997 FeedbackVectorICSlot CallRuntimeFeedbackSlot() { |
| 1967 return callruntime_feedback_slot_; | 1998 return callruntime_feedback_slot_; |
| 1968 } | 1999 } |
| 1969 | 2000 |
| 1970 TypeFeedbackId CallRuntimeFeedbackId() const { | 2001 TypeFeedbackId CallRuntimeFeedbackId() const { |
| 1971 return TypeFeedbackId(base_id() + 0); | 2002 return TypeFeedbackId(base_id() + 0); |
| 1972 } | 2003 } |
| 1973 | 2004 |
| 1974 protected: | 2005 protected: |
| 1975 CallRuntime(Zone* zone, const AstRawString* name, | 2006 CallRuntime(Zone* zone, const AstRawString* name, |
| 1976 const Runtime::Function* function, | 2007 const Runtime::Function* function, |
| 1977 ZoneList<Expression*>* arguments, int pos, IdGen* id_gen) | 2008 ZoneList<Expression*>* arguments, int pos, IdGen* id_gen) |
| 1978 : Expression(zone, pos, num_ids(), id_gen), | 2009 : Expression(zone, pos, num_ids(), id_gen), |
| 1979 raw_name_(name), | 2010 raw_name_(name), |
| 1980 function_(function), | 2011 function_(function), |
| 1981 arguments_(arguments), | 2012 arguments_(arguments), |
| 1982 callruntime_feedback_slot_(FeedbackVectorSlot::Invalid()) {} | 2013 callruntime_feedback_slot_(FeedbackVectorICSlot::Invalid()) {} |
| 1983 | 2014 |
| 1984 static int num_ids() { return 1; } | 2015 static int num_ids() { return 1; } |
| 1985 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 2016 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 1986 | 2017 |
| 1987 private: | 2018 private: |
| 1988 const AstRawString* raw_name_; | 2019 const AstRawString* raw_name_; |
| 1989 const Runtime::Function* function_; | 2020 const Runtime::Function* function_; |
| 1990 ZoneList<Expression*>* arguments_; | 2021 ZoneList<Expression*>* arguments_; |
| 1991 FeedbackVectorSlot callruntime_feedback_slot_; | 2022 FeedbackVectorICSlot callruntime_feedback_slot_; |
| 1992 }; | 2023 }; |
| 1993 | 2024 |
| 1994 | 2025 |
| 1995 class UnaryOperation FINAL : public Expression { | 2026 class UnaryOperation FINAL : public Expression { |
| 1996 public: | 2027 public: |
| 1997 DECLARE_NODE_TYPE(UnaryOperation) | 2028 DECLARE_NODE_TYPE(UnaryOperation) |
| 1998 | 2029 |
| 1999 Token::Value op() const { return op_; } | 2030 Token::Value op() const { return op_; } |
| 2000 Expression* expression() const { return expression_; } | 2031 Expression* expression() const { return expression_; } |
| 2001 | 2032 |
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2294 int index() const { | 2325 int index() const { |
| 2295 DCHECK_EQ(kDelegating, yield_kind()); | 2326 DCHECK_EQ(kDelegating, yield_kind()); |
| 2296 return index_; | 2327 return index_; |
| 2297 } | 2328 } |
| 2298 void set_index(int index) { | 2329 void set_index(int index) { |
| 2299 DCHECK_EQ(kDelegating, yield_kind()); | 2330 DCHECK_EQ(kDelegating, yield_kind()); |
| 2300 index_ = index; | 2331 index_ = index; |
| 2301 } | 2332 } |
| 2302 | 2333 |
| 2303 // Type feedback information. | 2334 // Type feedback information. |
| 2304 virtual int ComputeFeedbackSlotCount() { | 2335 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 2305 return (FLAG_vector_ics && yield_kind() == kDelegating) ? 3 : 0; | 2336 return FeedbackVectorRequirements( |
| 2337 0, (FLAG_vector_ics && yield_kind() == kDelegating) ? 3 : 0); |
| 2306 } | 2338 } |
| 2307 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 2339 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 2308 yield_first_feedback_slot_ = slot; | 2340 yield_first_feedback_slot_ = slot; |
| 2309 } | 2341 } |
| 2310 | 2342 |
| 2311 FeedbackVectorSlot KeyedLoadFeedbackSlot() { | 2343 FeedbackVectorICSlot KeyedLoadFeedbackSlot() { |
| 2312 return yield_first_feedback_slot_; | 2344 return yield_first_feedback_slot_; |
| 2313 } | 2345 } |
| 2314 | 2346 |
| 2315 FeedbackVectorSlot DoneFeedbackSlot() { | 2347 FeedbackVectorICSlot DoneFeedbackSlot() { |
| 2316 return KeyedLoadFeedbackSlot().next(); | 2348 return KeyedLoadFeedbackSlot().next(); |
| 2317 } | 2349 } |
| 2318 | 2350 |
| 2319 FeedbackVectorSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); } | 2351 FeedbackVectorICSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); } |
| 2320 | 2352 |
| 2321 protected: | 2353 protected: |
| 2322 Yield(Zone* zone, Expression* generator_object, Expression* expression, | 2354 Yield(Zone* zone, Expression* generator_object, Expression* expression, |
| 2323 Kind yield_kind, int pos, IdGen* id_gen) | 2355 Kind yield_kind, int pos, IdGen* id_gen) |
| 2324 : Expression(zone, pos, 0, id_gen), | 2356 : Expression(zone, pos, 0, id_gen), |
| 2325 generator_object_(generator_object), | 2357 generator_object_(generator_object), |
| 2326 expression_(expression), | 2358 expression_(expression), |
| 2327 yield_kind_(yield_kind), | 2359 yield_kind_(yield_kind), |
| 2328 index_(-1), | 2360 index_(-1), |
| 2329 yield_first_feedback_slot_(FeedbackVectorSlot::Invalid()) {} | 2361 yield_first_feedback_slot_(FeedbackVectorICSlot::Invalid()) {} |
| 2330 | 2362 |
| 2331 private: | 2363 private: |
| 2332 Expression* generator_object_; | 2364 Expression* generator_object_; |
| 2333 Expression* expression_; | 2365 Expression* expression_; |
| 2334 Kind yield_kind_; | 2366 Kind yield_kind_; |
| 2335 int index_; | 2367 int index_; |
| 2336 FeedbackVectorSlot yield_first_feedback_slot_; | 2368 FeedbackVectorICSlot yield_first_feedback_slot_; |
| 2337 }; | 2369 }; |
| 2338 | 2370 |
| 2339 | 2371 |
| 2340 class Throw FINAL : public Expression { | 2372 class Throw FINAL : public Expression { |
| 2341 public: | 2373 public: |
| 2342 DECLARE_NODE_TYPE(Throw) | 2374 DECLARE_NODE_TYPE(Throw) |
| 2343 | 2375 |
| 2344 Expression* exception() const { return exception_; } | 2376 Expression* exception() const { return exception_; } |
| 2345 | 2377 |
| 2346 protected: | 2378 protected: |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2476 } | 2508 } |
| 2477 | 2509 |
| 2478 int ast_node_count() { return ast_properties_.node_count(); } | 2510 int ast_node_count() { return ast_properties_.node_count(); } |
| 2479 AstProperties::Flags* flags() { return ast_properties_.flags(); } | 2511 AstProperties::Flags* flags() { return ast_properties_.flags(); } |
| 2480 void set_ast_properties(AstProperties* ast_properties) { | 2512 void set_ast_properties(AstProperties* ast_properties) { |
| 2481 ast_properties_ = *ast_properties; | 2513 ast_properties_ = *ast_properties; |
| 2482 } | 2514 } |
| 2483 int slot_count() { | 2515 int slot_count() { |
| 2484 return ast_properties_.feedback_slots(); | 2516 return ast_properties_.feedback_slots(); |
| 2485 } | 2517 } |
| 2518 int ic_slot_count() { return ast_properties_.ic_feedback_slots(); } |
| 2486 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } | 2519 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } |
| 2487 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | 2520 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } |
| 2488 void set_dont_optimize_reason(BailoutReason reason) { | 2521 void set_dont_optimize_reason(BailoutReason reason) { |
| 2489 dont_optimize_reason_ = reason; | 2522 dont_optimize_reason_ = reason; |
| 2490 } | 2523 } |
| 2491 | 2524 |
| 2492 protected: | 2525 protected: |
| 2493 FunctionLiteral(Zone* zone, const AstRawString* name, | 2526 FunctionLiteral(Zone* zone, const AstRawString* name, |
| 2494 AstValueFactory* ast_value_factory, Scope* scope, | 2527 AstValueFactory* ast_value_factory, Scope* scope, |
| 2495 ZoneList<Statement*>* body, int materialized_literal_count, | 2528 ZoneList<Statement*>* body, int materialized_literal_count, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2614 public: | 2647 public: |
| 2615 DECLARE_NODE_TYPE(SuperReference) | 2648 DECLARE_NODE_TYPE(SuperReference) |
| 2616 | 2649 |
| 2617 VariableProxy* this_var() const { return this_var_; } | 2650 VariableProxy* this_var() const { return this_var_; } |
| 2618 | 2651 |
| 2619 TypeFeedbackId HomeObjectFeedbackId() { | 2652 TypeFeedbackId HomeObjectFeedbackId() { |
| 2620 return TypeFeedbackId(base_id() + 0); | 2653 return TypeFeedbackId(base_id() + 0); |
| 2621 } | 2654 } |
| 2622 | 2655 |
| 2623 // Type feedback information. | 2656 // Type feedback information. |
| 2624 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 2657 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 2625 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 2658 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); |
| 2659 } |
| 2660 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 2626 homeobject_feedback_slot_ = slot; | 2661 homeobject_feedback_slot_ = slot; |
| 2627 } | 2662 } |
| 2628 | 2663 |
| 2629 FeedbackVectorSlot HomeObjectFeedbackSlot() { | 2664 FeedbackVectorICSlot HomeObjectFeedbackSlot() { |
| 2630 DCHECK(!FLAG_vector_ics || !homeobject_feedback_slot_.IsInvalid()); | 2665 DCHECK(!FLAG_vector_ics || !homeobject_feedback_slot_.IsInvalid()); |
| 2631 return homeobject_feedback_slot_; | 2666 return homeobject_feedback_slot_; |
| 2632 } | 2667 } |
| 2633 | 2668 |
| 2634 protected: | 2669 protected: |
| 2635 SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen) | 2670 SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen) |
| 2636 : Expression(zone, pos, num_ids(), id_gen), | 2671 : Expression(zone, pos, num_ids(), id_gen), |
| 2637 this_var_(this_var), | 2672 this_var_(this_var), |
| 2638 homeobject_feedback_slot_(FeedbackVectorSlot::Invalid()) { | 2673 homeobject_feedback_slot_(FeedbackVectorICSlot::Invalid()) { |
| 2639 DCHECK(this_var->is_this()); | 2674 DCHECK(this_var->is_this()); |
| 2640 } | 2675 } |
| 2641 | 2676 |
| 2642 static int num_ids() { return 1; } | 2677 static int num_ids() { return 1; } |
| 2643 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 2678 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 2644 | 2679 |
| 2645 private: | 2680 private: |
| 2646 VariableProxy* this_var_; | 2681 VariableProxy* this_var_; |
| 2647 FeedbackVectorSlot homeobject_feedback_slot_; | 2682 FeedbackVectorICSlot homeobject_feedback_slot_; |
| 2648 }; | 2683 }; |
| 2649 | 2684 |
| 2650 | 2685 |
| 2651 #undef DECLARE_NODE_TYPE | 2686 #undef DECLARE_NODE_TYPE |
| 2652 | 2687 |
| 2653 | 2688 |
| 2654 // ---------------------------------------------------------------------------- | 2689 // ---------------------------------------------------------------------------- |
| 2655 // Regular expressions | 2690 // Regular expressions |
| 2656 | 2691 |
| 2657 | 2692 |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3101 void increase_node_count() { properties_.add_node_count(1); } | 3136 void increase_node_count() { properties_.add_node_count(1); } |
| 3102 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } | 3137 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } |
| 3103 void set_dont_crankshaft_reason(BailoutReason reason) { | 3138 void set_dont_crankshaft_reason(BailoutReason reason) { |
| 3104 dont_crankshaft_reason_ = reason; | 3139 dont_crankshaft_reason_ = reason; |
| 3105 } | 3140 } |
| 3106 void set_dont_turbofan_reason(BailoutReason reason) { | 3141 void set_dont_turbofan_reason(BailoutReason reason) { |
| 3107 dont_turbofan_reason_ = reason; | 3142 dont_turbofan_reason_ = reason; |
| 3108 } | 3143 } |
| 3109 | 3144 |
| 3110 void add_slot_node(AstNode* slot_node) { | 3145 void add_slot_node(AstNode* slot_node) { |
| 3111 int count = slot_node->ComputeFeedbackSlotCount(); | 3146 FeedbackVectorRequirements reqs = slot_node->ComputeFeedbackRequirements(); |
| 3112 if (count > 0) { | 3147 if (reqs.slots() > 0) { |
| 3113 slot_node->SetFirstFeedbackSlot( | 3148 slot_node->SetFirstFeedbackSlot( |
| 3114 FeedbackVectorSlot(properties_.feedback_slots())); | 3149 FeedbackVectorSlot(properties_.feedback_slots())); |
| 3115 properties_.increase_feedback_slots(count); | 3150 properties_.increase_feedback_slots(reqs.slots()); |
| 3151 } |
| 3152 if (reqs.ic_slots() > 0) { |
| 3153 slot_node->SetFirstFeedbackICSlot( |
| 3154 FeedbackVectorICSlot(properties_.ic_feedback_slots())); |
| 3155 properties_.increase_ic_feedback_slots(reqs.ic_slots()); |
| 3116 } | 3156 } |
| 3117 } | 3157 } |
| 3118 | 3158 |
| 3119 AstProperties properties_; | 3159 AstProperties properties_; |
| 3120 BailoutReason dont_crankshaft_reason_; | 3160 BailoutReason dont_crankshaft_reason_; |
| 3121 BailoutReason dont_turbofan_reason_; | 3161 BailoutReason dont_turbofan_reason_; |
| 3122 }; | 3162 }; |
| 3123 | 3163 |
| 3124 | 3164 |
| 3125 class AstNullVisitor BASE_EMBEDDED { | 3165 class AstNullVisitor BASE_EMBEDDED { |
| (...skipping 489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3615 Zone* zone_; | 3655 Zone* zone_; |
| 3616 Visitor visitor_; | 3656 Visitor visitor_; |
| 3617 AstValueFactory* ast_value_factory_; | 3657 AstValueFactory* ast_value_factory_; |
| 3618 AstNode::IdGen* id_gen_; | 3658 AstNode::IdGen* id_gen_; |
| 3619 }; | 3659 }; |
| 3620 | 3660 |
| 3621 | 3661 |
| 3622 } } // namespace v8::internal | 3662 } } // namespace v8::internal |
| 3623 | 3663 |
| 3624 #endif // V8_AST_H_ | 3664 #endif // V8_AST_H_ |
| OLD | NEW |