| 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 683 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 938 | 958 |
| 939 class ForInStatement FINAL : public ForEachStatement { | 959 class ForInStatement FINAL : public ForEachStatement { |
| 940 public: | 960 public: |
| 941 DECLARE_NODE_TYPE(ForInStatement) | 961 DECLARE_NODE_TYPE(ForInStatement) |
| 942 | 962 |
| 943 Expression* enumerable() const { | 963 Expression* enumerable() const { |
| 944 return subject(); | 964 return subject(); |
| 945 } | 965 } |
| 946 | 966 |
| 947 // Type feedback information. | 967 // Type feedback information. |
| 948 virtual int ComputeFeedbackSlotCount() { return 1; } | 968 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 969 return FeedbackVectorRequirements(1, 0); |
| 970 } |
| 949 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 971 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { |
| 950 for_in_feedback_slot_ = slot; | 972 for_in_feedback_slot_ = slot; |
| 951 } | 973 } |
| 952 | 974 |
| 953 FeedbackVectorSlot ForInFeedbackSlot() { | 975 FeedbackVectorSlot ForInFeedbackSlot() { |
| 954 DCHECK(!for_in_feedback_slot_.IsInvalid()); | 976 DCHECK(!for_in_feedback_slot_.IsInvalid()); |
| 955 return for_in_feedback_slot_; | 977 return for_in_feedback_slot_; |
| 956 } | 978 } |
| 957 | 979 |
| 958 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 980 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
| (...skipping 726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1685 void set_is_assigned() { is_assigned_ = true; } | 1707 void set_is_assigned() { is_assigned_ = true; } |
| 1686 | 1708 |
| 1687 bool is_resolved() const { return is_resolved_; } | 1709 bool is_resolved() const { return is_resolved_; } |
| 1688 void set_is_resolved() { is_resolved_ = true; } | 1710 void set_is_resolved() { is_resolved_ = true; } |
| 1689 | 1711 |
| 1690 Interface* interface() const { return interface_; } | 1712 Interface* interface() const { return interface_; } |
| 1691 | 1713 |
| 1692 // Bind this proxy to the variable var. Interfaces must match. | 1714 // Bind this proxy to the variable var. Interfaces must match. |
| 1693 void BindTo(Variable* var); | 1715 void BindTo(Variable* var); |
| 1694 | 1716 |
| 1695 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 1717 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1696 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 1718 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); |
| 1719 } |
| 1720 virtual void SetFirstICFeedbackSlot(FeedbackVectorICSlot slot) { |
| 1697 variable_feedback_slot_ = slot; | 1721 variable_feedback_slot_ = slot; |
| 1698 } | 1722 } |
| 1699 | 1723 |
| 1700 FeedbackVectorSlot VariableFeedbackSlot() { return variable_feedback_slot_; } | 1724 FeedbackVectorICSlot VariableFeedbackSlot() { |
| 1725 return variable_feedback_slot_; |
| 1726 } |
| 1701 | 1727 |
| 1702 protected: | 1728 protected: |
| 1703 VariableProxy(Zone* zone, Variable* var, int position, IdGen* id_gen); | 1729 VariableProxy(Zone* zone, Variable* var, int position, IdGen* id_gen); |
| 1704 | 1730 |
| 1705 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, | 1731 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, |
| 1706 Interface* interface, int position, IdGen* id_gen); | 1732 Interface* interface, int position, IdGen* id_gen); |
| 1707 | 1733 |
| 1708 bool is_this_ : 1; | 1734 bool is_this_ : 1; |
| 1709 bool is_assigned_ : 1; | 1735 bool is_assigned_ : 1; |
| 1710 bool is_resolved_ : 1; | 1736 bool is_resolved_ : 1; |
| 1711 FeedbackVectorSlot variable_feedback_slot_; | 1737 FeedbackVectorICSlot variable_feedback_slot_; |
| 1712 union { | 1738 union { |
| 1713 const AstRawString* raw_name_; // if !is_resolved_ | 1739 const AstRawString* raw_name_; // if !is_resolved_ |
| 1714 Variable* var_; // if is_resolved_ | 1740 Variable* var_; // if is_resolved_ |
| 1715 }; | 1741 }; |
| 1716 Interface* interface_; | 1742 Interface* interface_; |
| 1717 }; | 1743 }; |
| 1718 | 1744 |
| 1719 | 1745 |
| 1720 class Property FINAL : public Expression { | 1746 class Property FINAL : public Expression { |
| 1721 public: | 1747 public: |
| (...skipping 30 matching lines...) Expand all Loading... |
| 1752 } | 1778 } |
| 1753 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 1779 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
| 1754 void set_is_string_access(bool b) { is_string_access_ = b; } | 1780 void set_is_string_access(bool b) { is_string_access_ = b; } |
| 1755 void mark_for_call() { is_for_call_ = true; } | 1781 void mark_for_call() { is_for_call_ = true; } |
| 1756 bool IsForCall() { return is_for_call_; } | 1782 bool IsForCall() { return is_for_call_; } |
| 1757 | 1783 |
| 1758 bool IsSuperAccess() { | 1784 bool IsSuperAccess() { |
| 1759 return obj()->IsSuperReference(); | 1785 return obj()->IsSuperReference(); |
| 1760 } | 1786 } |
| 1761 | 1787 |
| 1762 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 1788 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1763 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 1789 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); |
| 1790 } |
| 1791 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 1764 property_feedback_slot_ = slot; | 1792 property_feedback_slot_ = slot; |
| 1765 } | 1793 } |
| 1766 | 1794 |
| 1767 FeedbackVectorSlot PropertyFeedbackSlot() const { | 1795 FeedbackVectorICSlot PropertyFeedbackSlot() const { |
| 1768 return property_feedback_slot_; | 1796 return property_feedback_slot_; |
| 1769 } | 1797 } |
| 1770 | 1798 |
| 1771 protected: | 1799 protected: |
| 1772 Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen) | 1800 Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen) |
| 1773 : Expression(zone, pos, num_ids(), id_gen), | 1801 : Expression(zone, pos, num_ids(), id_gen), |
| 1774 is_for_call_(false), | 1802 is_for_call_(false), |
| 1775 is_uninitialized_(false), | 1803 is_uninitialized_(false), |
| 1776 is_string_access_(false), | 1804 is_string_access_(false), |
| 1777 property_feedback_slot_(FeedbackVectorSlot::Invalid()), | 1805 property_feedback_slot_(FeedbackVectorICSlot::Invalid()), |
| 1778 obj_(obj), | 1806 obj_(obj), |
| 1779 key_(key) {} | 1807 key_(key) {} |
| 1780 | 1808 |
| 1781 static int num_ids() { return 2; } | 1809 static int num_ids() { return 2; } |
| 1782 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 1810 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 1783 | 1811 |
| 1784 private: | 1812 private: |
| 1785 bool is_for_call_ : 1; | 1813 bool is_for_call_ : 1; |
| 1786 bool is_uninitialized_ : 1; | 1814 bool is_uninitialized_ : 1; |
| 1787 bool is_string_access_ : 1; | 1815 bool is_string_access_ : 1; |
| 1788 FeedbackVectorSlot property_feedback_slot_; | 1816 FeedbackVectorICSlot property_feedback_slot_; |
| 1789 Expression* obj_; | 1817 Expression* obj_; |
| 1790 Expression* key_; | 1818 Expression* key_; |
| 1791 SmallMapList receiver_types_; | 1819 SmallMapList receiver_types_; |
| 1792 }; | 1820 }; |
| 1793 | 1821 |
| 1794 | 1822 |
| 1795 class Call FINAL : public Expression { | 1823 class Call FINAL : public Expression { |
| 1796 public: | 1824 public: |
| 1797 DECLARE_NODE_TYPE(Call) | 1825 DECLARE_NODE_TYPE(Call) |
| 1798 | 1826 |
| 1799 Expression* expression() const { return expression_; } | 1827 Expression* expression() const { return expression_; } |
| 1800 ZoneList<Expression*>* arguments() const { return arguments_; } | 1828 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1801 | 1829 |
| 1802 // Type feedback information. | 1830 // Type feedback information. |
| 1803 virtual int ComputeFeedbackSlotCount() { return 1; } | 1831 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1804 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 1832 return FeedbackVectorRequirements(0, 1); |
| 1833 } |
| 1834 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 1805 call_feedback_slot_ = slot; | 1835 call_feedback_slot_ = slot; |
| 1806 } | 1836 } |
| 1807 | 1837 |
| 1808 bool HasCallFeedbackSlot() const { return !call_feedback_slot_.IsInvalid(); } | 1838 bool HasCallFeedbackSlot() const { return !call_feedback_slot_.IsInvalid(); } |
| 1809 FeedbackVectorSlot CallFeedbackSlot() const { return call_feedback_slot_; } | 1839 FeedbackVectorICSlot CallFeedbackSlot() const { return call_feedback_slot_; } |
| 1810 | 1840 |
| 1811 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 1841 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| 1812 if (expression()->IsProperty()) { | 1842 if (expression()->IsProperty()) { |
| 1813 return expression()->AsProperty()->GetReceiverTypes(); | 1843 return expression()->AsProperty()->GetReceiverTypes(); |
| 1814 } | 1844 } |
| 1815 return NULL; | 1845 return NULL; |
| 1816 } | 1846 } |
| 1817 | 1847 |
| 1818 virtual bool IsMonomorphic() OVERRIDE { | 1848 virtual bool IsMonomorphic() OVERRIDE { |
| 1819 if (expression()->IsProperty()) { | 1849 if (expression()->IsProperty()) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1861 | 1891 |
| 1862 #ifdef DEBUG | 1892 #ifdef DEBUG |
| 1863 // Used to assert that the FullCodeGenerator records the return site. | 1893 // Used to assert that the FullCodeGenerator records the return site. |
| 1864 bool return_is_recorded_; | 1894 bool return_is_recorded_; |
| 1865 #endif | 1895 #endif |
| 1866 | 1896 |
| 1867 protected: | 1897 protected: |
| 1868 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1898 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
| 1869 int pos, IdGen* id_gen) | 1899 int pos, IdGen* id_gen) |
| 1870 : Expression(zone, pos, num_ids(), id_gen), | 1900 : Expression(zone, pos, num_ids(), id_gen), |
| 1871 call_feedback_slot_(FeedbackVectorSlot::Invalid()), | 1901 call_feedback_slot_(FeedbackVectorICSlot::Invalid()), |
| 1872 expression_(expression), | 1902 expression_(expression), |
| 1873 arguments_(arguments) { | 1903 arguments_(arguments) { |
| 1874 if (expression->IsProperty()) { | 1904 if (expression->IsProperty()) { |
| 1875 expression->AsProperty()->mark_for_call(); | 1905 expression->AsProperty()->mark_for_call(); |
| 1876 } | 1906 } |
| 1877 } | 1907 } |
| 1878 | 1908 |
| 1879 static int num_ids() { return 2; } | 1909 static int num_ids() { return 2; } |
| 1880 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 1910 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 1881 | 1911 |
| 1882 private: | 1912 private: |
| 1883 FeedbackVectorSlot call_feedback_slot_; | 1913 FeedbackVectorICSlot call_feedback_slot_; |
| 1884 Expression* expression_; | 1914 Expression* expression_; |
| 1885 ZoneList<Expression*>* arguments_; | 1915 ZoneList<Expression*>* arguments_; |
| 1886 Handle<JSFunction> target_; | 1916 Handle<JSFunction> target_; |
| 1887 Handle<Cell> cell_; | 1917 Handle<Cell> cell_; |
| 1888 Handle<AllocationSite> allocation_site_; | 1918 Handle<AllocationSite> allocation_site_; |
| 1889 }; | 1919 }; |
| 1890 | 1920 |
| 1891 | 1921 |
| 1892 class CallNew FINAL : public Expression { | 1922 class CallNew FINAL : public Expression { |
| 1893 public: | 1923 public: |
| 1894 DECLARE_NODE_TYPE(CallNew) | 1924 DECLARE_NODE_TYPE(CallNew) |
| 1895 | 1925 |
| 1896 Expression* expression() const { return expression_; } | 1926 Expression* expression() const { return expression_; } |
| 1897 ZoneList<Expression*>* arguments() const { return arguments_; } | 1927 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1898 | 1928 |
| 1899 // Type feedback information. | 1929 // Type feedback information. |
| 1900 virtual int ComputeFeedbackSlotCount() { | 1930 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1901 return FLAG_pretenuring_call_new ? 2 : 1; | 1931 return FeedbackVectorRequirements(FLAG_pretenuring_call_new ? 2 : 1, 0); |
| 1902 } | 1932 } |
| 1903 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 1933 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { |
| 1904 callnew_feedback_slot_ = slot; | 1934 callnew_feedback_slot_ = slot; |
| 1905 } | 1935 } |
| 1906 | 1936 |
| 1907 FeedbackVectorSlot CallNewFeedbackSlot() { return callnew_feedback_slot_; } | 1937 FeedbackVectorSlot CallNewFeedbackSlot() { return callnew_feedback_slot_; } |
| 1908 FeedbackVectorSlot AllocationSiteFeedbackSlot() { | 1938 FeedbackVectorSlot AllocationSiteFeedbackSlot() { |
| 1909 DCHECK(FLAG_pretenuring_call_new); | 1939 DCHECK(FLAG_pretenuring_call_new); |
| 1910 return CallNewFeedbackSlot().next(); | 1940 return CallNewFeedbackSlot().next(); |
| 1911 } | 1941 } |
| (...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1951 public: | 1981 public: |
| 1952 DECLARE_NODE_TYPE(CallRuntime) | 1982 DECLARE_NODE_TYPE(CallRuntime) |
| 1953 | 1983 |
| 1954 Handle<String> name() const { return raw_name_->string(); } | 1984 Handle<String> name() const { return raw_name_->string(); } |
| 1955 const AstRawString* raw_name() const { return raw_name_; } | 1985 const AstRawString* raw_name() const { return raw_name_; } |
| 1956 const Runtime::Function* function() const { return function_; } | 1986 const Runtime::Function* function() const { return function_; } |
| 1957 ZoneList<Expression*>* arguments() const { return arguments_; } | 1987 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1958 bool is_jsruntime() const { return function_ == NULL; } | 1988 bool is_jsruntime() const { return function_ == NULL; } |
| 1959 | 1989 |
| 1960 // Type feedback information. | 1990 // Type feedback information. |
| 1961 virtual int ComputeFeedbackSlotCount() { | 1991 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1962 return (FLAG_vector_ics && is_jsruntime()) ? 1 : 0; | 1992 return FeedbackVectorRequirements( |
| 1993 0, (FLAG_vector_ics && is_jsruntime()) ? 1 : 0); |
| 1963 } | 1994 } |
| 1964 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 1995 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 1965 callruntime_feedback_slot_ = slot; | 1996 callruntime_feedback_slot_ = slot; |
| 1966 } | 1997 } |
| 1967 | 1998 |
| 1968 FeedbackVectorSlot CallRuntimeFeedbackSlot() { | 1999 FeedbackVectorICSlot CallRuntimeFeedbackSlot() { |
| 1969 return callruntime_feedback_slot_; | 2000 return callruntime_feedback_slot_; |
| 1970 } | 2001 } |
| 1971 | 2002 |
| 1972 TypeFeedbackId CallRuntimeFeedbackId() const { | 2003 TypeFeedbackId CallRuntimeFeedbackId() const { |
| 1973 return TypeFeedbackId(base_id() + 0); | 2004 return TypeFeedbackId(base_id() + 0); |
| 1974 } | 2005 } |
| 1975 | 2006 |
| 1976 protected: | 2007 protected: |
| 1977 CallRuntime(Zone* zone, const AstRawString* name, | 2008 CallRuntime(Zone* zone, const AstRawString* name, |
| 1978 const Runtime::Function* function, | 2009 const Runtime::Function* function, |
| 1979 ZoneList<Expression*>* arguments, int pos, IdGen* id_gen) | 2010 ZoneList<Expression*>* arguments, int pos, IdGen* id_gen) |
| 1980 : Expression(zone, pos, num_ids(), id_gen), | 2011 : Expression(zone, pos, num_ids(), id_gen), |
| 1981 raw_name_(name), | 2012 raw_name_(name), |
| 1982 function_(function), | 2013 function_(function), |
| 1983 arguments_(arguments), | 2014 arguments_(arguments), |
| 1984 callruntime_feedback_slot_(FeedbackVectorSlot::Invalid()) {} | 2015 callruntime_feedback_slot_(FeedbackVectorICSlot::Invalid()) {} |
| 1985 | 2016 |
| 1986 static int num_ids() { return 1; } | 2017 static int num_ids() { return 1; } |
| 1987 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 2018 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 1988 | 2019 |
| 1989 private: | 2020 private: |
| 1990 const AstRawString* raw_name_; | 2021 const AstRawString* raw_name_; |
| 1991 const Runtime::Function* function_; | 2022 const Runtime::Function* function_; |
| 1992 ZoneList<Expression*>* arguments_; | 2023 ZoneList<Expression*>* arguments_; |
| 1993 FeedbackVectorSlot callruntime_feedback_slot_; | 2024 FeedbackVectorICSlot callruntime_feedback_slot_; |
| 1994 }; | 2025 }; |
| 1995 | 2026 |
| 1996 | 2027 |
| 1997 class UnaryOperation FINAL : public Expression { | 2028 class UnaryOperation FINAL : public Expression { |
| 1998 public: | 2029 public: |
| 1999 DECLARE_NODE_TYPE(UnaryOperation) | 2030 DECLARE_NODE_TYPE(UnaryOperation) |
| 2000 | 2031 |
| 2001 Token::Value op() const { return op_; } | 2032 Token::Value op() const { return op_; } |
| 2002 Expression* expression() const { return expression_; } | 2033 Expression* expression() const { return expression_; } |
| 2003 | 2034 |
| (...skipping 305 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2309 int index() const { | 2340 int index() const { |
| 2310 DCHECK_EQ(kDelegating, yield_kind()); | 2341 DCHECK_EQ(kDelegating, yield_kind()); |
| 2311 return index_; | 2342 return index_; |
| 2312 } | 2343 } |
| 2313 void set_index(int index) { | 2344 void set_index(int index) { |
| 2314 DCHECK_EQ(kDelegating, yield_kind()); | 2345 DCHECK_EQ(kDelegating, yield_kind()); |
| 2315 index_ = index; | 2346 index_ = index; |
| 2316 } | 2347 } |
| 2317 | 2348 |
| 2318 // Type feedback information. | 2349 // Type feedback information. |
| 2319 virtual int ComputeFeedbackSlotCount() { | 2350 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 2320 return (FLAG_vector_ics && yield_kind() == kDelegating) ? 3 : 0; | 2351 return FeedbackVectorRequirements( |
| 2352 0, (FLAG_vector_ics && yield_kind() == kDelegating) ? 3 : 0); |
| 2321 } | 2353 } |
| 2322 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 2354 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 2323 yield_first_feedback_slot_ = slot; | 2355 yield_first_feedback_slot_ = slot; |
| 2324 } | 2356 } |
| 2325 | 2357 |
| 2326 FeedbackVectorSlot KeyedLoadFeedbackSlot() { | 2358 FeedbackVectorICSlot KeyedLoadFeedbackSlot() { |
| 2327 return yield_first_feedback_slot_; | 2359 return yield_first_feedback_slot_; |
| 2328 } | 2360 } |
| 2329 | 2361 |
| 2330 FeedbackVectorSlot DoneFeedbackSlot() { | 2362 FeedbackVectorICSlot DoneFeedbackSlot() { |
| 2331 return KeyedLoadFeedbackSlot().next(); | 2363 return KeyedLoadFeedbackSlot().next(); |
| 2332 } | 2364 } |
| 2333 | 2365 |
| 2334 FeedbackVectorSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); } | 2366 FeedbackVectorICSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); } |
| 2335 | 2367 |
| 2336 protected: | 2368 protected: |
| 2337 Yield(Zone* zone, Expression* generator_object, Expression* expression, | 2369 Yield(Zone* zone, Expression* generator_object, Expression* expression, |
| 2338 Kind yield_kind, int pos, IdGen* id_gen) | 2370 Kind yield_kind, int pos, IdGen* id_gen) |
| 2339 : Expression(zone, pos, 0, id_gen), | 2371 : Expression(zone, pos, 0, id_gen), |
| 2340 generator_object_(generator_object), | 2372 generator_object_(generator_object), |
| 2341 expression_(expression), | 2373 expression_(expression), |
| 2342 yield_kind_(yield_kind), | 2374 yield_kind_(yield_kind), |
| 2343 index_(-1), | 2375 index_(-1), |
| 2344 yield_first_feedback_slot_(FeedbackVectorSlot::Invalid()) {} | 2376 yield_first_feedback_slot_(FeedbackVectorICSlot::Invalid()) {} |
| 2345 | 2377 |
| 2346 private: | 2378 private: |
| 2347 Expression* generator_object_; | 2379 Expression* generator_object_; |
| 2348 Expression* expression_; | 2380 Expression* expression_; |
| 2349 Kind yield_kind_; | 2381 Kind yield_kind_; |
| 2350 int index_; | 2382 int index_; |
| 2351 FeedbackVectorSlot yield_first_feedback_slot_; | 2383 FeedbackVectorICSlot yield_first_feedback_slot_; |
| 2352 }; | 2384 }; |
| 2353 | 2385 |
| 2354 | 2386 |
| 2355 class Throw FINAL : public Expression { | 2387 class Throw FINAL : public Expression { |
| 2356 public: | 2388 public: |
| 2357 DECLARE_NODE_TYPE(Throw) | 2389 DECLARE_NODE_TYPE(Throw) |
| 2358 | 2390 |
| 2359 Expression* exception() const { return exception_; } | 2391 Expression* exception() const { return exception_; } |
| 2360 | 2392 |
| 2361 protected: | 2393 protected: |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2491 } | 2523 } |
| 2492 | 2524 |
| 2493 int ast_node_count() { return ast_properties_.node_count(); } | 2525 int ast_node_count() { return ast_properties_.node_count(); } |
| 2494 AstProperties::Flags* flags() { return ast_properties_.flags(); } | 2526 AstProperties::Flags* flags() { return ast_properties_.flags(); } |
| 2495 void set_ast_properties(AstProperties* ast_properties) { | 2527 void set_ast_properties(AstProperties* ast_properties) { |
| 2496 ast_properties_ = *ast_properties; | 2528 ast_properties_ = *ast_properties; |
| 2497 } | 2529 } |
| 2498 int slot_count() { | 2530 int slot_count() { |
| 2499 return ast_properties_.feedback_slots(); | 2531 return ast_properties_.feedback_slots(); |
| 2500 } | 2532 } |
| 2533 int ic_slot_count() { return ast_properties_.ic_feedback_slots(); } |
| 2501 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } | 2534 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } |
| 2502 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } | 2535 BailoutReason dont_optimize_reason() { return dont_optimize_reason_; } |
| 2503 void set_dont_optimize_reason(BailoutReason reason) { | 2536 void set_dont_optimize_reason(BailoutReason reason) { |
| 2504 dont_optimize_reason_ = reason; | 2537 dont_optimize_reason_ = reason; |
| 2505 } | 2538 } |
| 2506 | 2539 |
| 2507 protected: | 2540 protected: |
| 2508 FunctionLiteral(Zone* zone, const AstRawString* name, | 2541 FunctionLiteral(Zone* zone, const AstRawString* name, |
| 2509 AstValueFactory* ast_value_factory, Scope* scope, | 2542 AstValueFactory* ast_value_factory, Scope* scope, |
| 2510 ZoneList<Statement*>* body, int materialized_literal_count, | 2543 ZoneList<Statement*>* body, int materialized_literal_count, |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2629 public: | 2662 public: |
| 2630 DECLARE_NODE_TYPE(SuperReference) | 2663 DECLARE_NODE_TYPE(SuperReference) |
| 2631 | 2664 |
| 2632 VariableProxy* this_var() const { return this_var_; } | 2665 VariableProxy* this_var() const { return this_var_; } |
| 2633 | 2666 |
| 2634 TypeFeedbackId HomeObjectFeedbackId() { | 2667 TypeFeedbackId HomeObjectFeedbackId() { |
| 2635 return TypeFeedbackId(base_id() + 0); | 2668 return TypeFeedbackId(base_id() + 0); |
| 2636 } | 2669 } |
| 2637 | 2670 |
| 2638 // Type feedback information. | 2671 // Type feedback information. |
| 2639 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 2672 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 2640 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 2673 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); |
| 2674 } |
| 2675 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 2641 homeobject_feedback_slot_ = slot; | 2676 homeobject_feedback_slot_ = slot; |
| 2642 } | 2677 } |
| 2643 | 2678 |
| 2644 FeedbackVectorSlot HomeObjectFeedbackSlot() { | 2679 FeedbackVectorICSlot HomeObjectFeedbackSlot() { |
| 2645 DCHECK(!FLAG_vector_ics || !homeobject_feedback_slot_.IsInvalid()); | 2680 DCHECK(!FLAG_vector_ics || !homeobject_feedback_slot_.IsInvalid()); |
| 2646 return homeobject_feedback_slot_; | 2681 return homeobject_feedback_slot_; |
| 2647 } | 2682 } |
| 2648 | 2683 |
| 2649 protected: | 2684 protected: |
| 2650 SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen) | 2685 SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen) |
| 2651 : Expression(zone, pos, num_ids(), id_gen), | 2686 : Expression(zone, pos, num_ids(), id_gen), |
| 2652 this_var_(this_var), | 2687 this_var_(this_var), |
| 2653 homeobject_feedback_slot_(FeedbackVectorSlot::Invalid()) { | 2688 homeobject_feedback_slot_(FeedbackVectorICSlot::Invalid()) { |
| 2654 DCHECK(this_var->is_this()); | 2689 DCHECK(this_var->is_this()); |
| 2655 } | 2690 } |
| 2656 | 2691 |
| 2657 static int num_ids() { return 1; } | 2692 static int num_ids() { return 1; } |
| 2658 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 2693 int base_id() const { return Expression::base_id() + Expression::num_ids(); } |
| 2659 | 2694 |
| 2660 private: | 2695 private: |
| 2661 VariableProxy* this_var_; | 2696 VariableProxy* this_var_; |
| 2662 FeedbackVectorSlot homeobject_feedback_slot_; | 2697 FeedbackVectorICSlot homeobject_feedback_slot_; |
| 2663 }; | 2698 }; |
| 2664 | 2699 |
| 2665 | 2700 |
| 2666 #undef DECLARE_NODE_TYPE | 2701 #undef DECLARE_NODE_TYPE |
| 2667 | 2702 |
| 2668 | 2703 |
| 2669 // ---------------------------------------------------------------------------- | 2704 // ---------------------------------------------------------------------------- |
| 2670 // Regular expressions | 2705 // Regular expressions |
| 2671 | 2706 |
| 2672 | 2707 |
| (...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3116 void increase_node_count() { properties_.add_node_count(1); } | 3151 void increase_node_count() { properties_.add_node_count(1); } |
| 3117 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } | 3152 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } |
| 3118 void set_dont_crankshaft_reason(BailoutReason reason) { | 3153 void set_dont_crankshaft_reason(BailoutReason reason) { |
| 3119 dont_crankshaft_reason_ = reason; | 3154 dont_crankshaft_reason_ = reason; |
| 3120 } | 3155 } |
| 3121 void set_dont_turbofan_reason(BailoutReason reason) { | 3156 void set_dont_turbofan_reason(BailoutReason reason) { |
| 3122 dont_turbofan_reason_ = reason; | 3157 dont_turbofan_reason_ = reason; |
| 3123 } | 3158 } |
| 3124 | 3159 |
| 3125 void add_slot_node(AstNode* slot_node) { | 3160 void add_slot_node(AstNode* slot_node) { |
| 3126 int count = slot_node->ComputeFeedbackSlotCount(); | 3161 FeedbackVectorRequirements reqs = slot_node->ComputeFeedbackRequirements(); |
| 3127 if (count > 0) { | 3162 if (reqs.slots() > 0) { |
| 3128 slot_node->SetFirstFeedbackSlot( | 3163 slot_node->SetFirstFeedbackSlot( |
| 3129 FeedbackVectorSlot(properties_.feedback_slots())); | 3164 FeedbackVectorSlot(properties_.feedback_slots())); |
| 3130 properties_.increase_feedback_slots(count); | 3165 properties_.increase_feedback_slots(reqs.slots()); |
| 3166 } |
| 3167 if (reqs.ic_slots() > 0) { |
| 3168 slot_node->SetFirstFeedbackICSlot( |
| 3169 FeedbackVectorICSlot(properties_.ic_feedback_slots())); |
| 3170 properties_.increase_ic_feedback_slots(reqs.ic_slots()); |
| 3131 } | 3171 } |
| 3132 } | 3172 } |
| 3133 | 3173 |
| 3134 AstProperties properties_; | 3174 AstProperties properties_; |
| 3135 BailoutReason dont_crankshaft_reason_; | 3175 BailoutReason dont_crankshaft_reason_; |
| 3136 BailoutReason dont_turbofan_reason_; | 3176 BailoutReason dont_turbofan_reason_; |
| 3137 }; | 3177 }; |
| 3138 | 3178 |
| 3139 | 3179 |
| 3140 class AstNullVisitor BASE_EMBEDDED { | 3180 class AstNullVisitor BASE_EMBEDDED { |
| (...skipping 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3621 Zone* zone_; | 3661 Zone* zone_; |
| 3622 Visitor visitor_; | 3662 Visitor visitor_; |
| 3623 AstValueFactory* ast_value_factory_; | 3663 AstValueFactory* ast_value_factory_; |
| 3624 AstNode::IdGen* id_gen_; | 3664 AstNode::IdGen* id_gen_; |
| 3625 }; | 3665 }; |
| 3626 | 3666 |
| 3627 | 3667 |
| 3628 } } // namespace v8::internal | 3668 } } // namespace v8::internal |
| 3629 | 3669 |
| 3630 #endif // V8_AST_H_ | 3670 #endif // V8_AST_H_ |
| OLD | NEW |