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 1607 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1618 values_(values), | 1618 values_(values), |
1619 first_element_id_(ReserveIdRange(zone, values->length())) {} | 1619 first_element_id_(ReserveIdRange(zone, values->length())) {} |
1620 | 1620 |
1621 private: | 1621 private: |
1622 Handle<FixedArray> constant_elements_; | 1622 Handle<FixedArray> constant_elements_; |
1623 ZoneList<Expression*>* values_; | 1623 ZoneList<Expression*>* values_; |
1624 const BailoutId first_element_id_; | 1624 const BailoutId first_element_id_; |
1625 }; | 1625 }; |
1626 | 1626 |
1627 | 1627 |
1628 class VariableProxy V8_FINAL : public Expression { | 1628 class VariableProxy V8_FINAL : public Expression, public FeedbackSlotInterface { |
1629 public: | 1629 public: |
1630 DECLARE_NODE_TYPE(VariableProxy) | 1630 DECLARE_NODE_TYPE(VariableProxy) |
1631 | 1631 |
1632 virtual bool IsValidReferenceExpression() const V8_OVERRIDE { | 1632 virtual bool IsValidReferenceExpression() const V8_OVERRIDE { |
1633 return var_ == NULL ? true : var_->IsValidReference(); | 1633 return var_ == NULL ? true : var_->IsValidReference(); |
1634 } | 1634 } |
1635 | 1635 |
1636 bool IsArguments() const { return var_ != NULL && var_->is_arguments(); } | 1636 bool IsArguments() const { return var_ != NULL && var_->is_arguments(); } |
1637 | 1637 |
1638 Handle<String> name() const { return name_->string(); } | 1638 Handle<String> name() const { return name_->string(); } |
1639 const AstRawString* raw_name() const { return name_; } | 1639 const AstRawString* raw_name() const { return name_; } |
1640 Variable* var() const { return var_; } | 1640 Variable* var() const { return var_; } |
1641 bool is_this() const { return is_this_; } | 1641 bool is_this() const { return is_this_; } |
1642 Interface* interface() const { return interface_; } | 1642 Interface* interface() const { return interface_; } |
1643 | 1643 |
1644 bool is_assigned() const { return is_assigned_; } | 1644 bool is_assigned() const { return is_assigned_; } |
1645 void set_is_assigned() { is_assigned_ = true; } | 1645 void set_is_assigned() { is_assigned_ = true; } |
1646 | 1646 |
1647 // Bind this proxy to the variable var. Interfaces must match. | 1647 // Bind this proxy to the variable var. Interfaces must match. |
1648 void BindTo(Variable* var); | 1648 void BindTo(Variable* var); |
1649 | 1649 |
| 1650 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } |
| 1651 virtual void SetFirstFeedbackSlot(int slot) { |
| 1652 variable_feedback_slot_ = slot; |
| 1653 } |
| 1654 |
| 1655 int VariableFeedbackSlot() { return variable_feedback_slot_; } |
| 1656 |
1650 protected: | 1657 protected: |
1651 VariableProxy(Zone* zone, Variable* var, int position); | 1658 VariableProxy(Zone* zone, Variable* var, int position); |
1652 | 1659 |
1653 VariableProxy(Zone* zone, | 1660 VariableProxy(Zone* zone, |
1654 const AstRawString* name, | 1661 const AstRawString* name, |
1655 bool is_this, | 1662 bool is_this, |
1656 Interface* interface, | 1663 Interface* interface, |
1657 int position); | 1664 int position); |
1658 | 1665 |
1659 const AstRawString* name_; | 1666 const AstRawString* name_; |
1660 Variable* var_; // resolved variable, or NULL | 1667 Variable* var_; // resolved variable, or NULL |
1661 bool is_this_; | 1668 bool is_this_; |
1662 bool is_assigned_; | 1669 bool is_assigned_; |
1663 Interface* interface_; | 1670 Interface* interface_; |
| 1671 int variable_feedback_slot_; |
1664 }; | 1672 }; |
1665 | 1673 |
1666 | 1674 |
1667 class Property V8_FINAL : public Expression { | 1675 class Property V8_FINAL : public Expression, public FeedbackSlotInterface { |
1668 public: | 1676 public: |
1669 DECLARE_NODE_TYPE(Property) | 1677 DECLARE_NODE_TYPE(Property) |
1670 | 1678 |
1671 virtual bool IsValidReferenceExpression() const V8_OVERRIDE { return true; } | 1679 virtual bool IsValidReferenceExpression() const V8_OVERRIDE { return true; } |
1672 | 1680 |
1673 Expression* obj() const { return obj_; } | 1681 Expression* obj() const { return obj_; } |
1674 Expression* key() const { return key_; } | 1682 Expression* key() const { return key_; } |
1675 | 1683 |
1676 BailoutId LoadId() const { return load_id_; } | 1684 BailoutId LoadId() const { return load_id_; } |
1677 | 1685 |
(...skipping 15 matching lines...) Expand all Loading... |
1693 return is_uninitialized_; | 1701 return is_uninitialized_; |
1694 } | 1702 } |
1695 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 1703 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
1696 void set_is_string_access(bool b) { is_string_access_ = b; } | 1704 void set_is_string_access(bool b) { is_string_access_ = b; } |
1697 void set_is_function_prototype(bool b) { is_function_prototype_ = b; } | 1705 void set_is_function_prototype(bool b) { is_function_prototype_ = b; } |
1698 void mark_for_call() { is_for_call_ = true; } | 1706 void mark_for_call() { is_for_call_ = true; } |
1699 bool IsForCall() { return is_for_call_; } | 1707 bool IsForCall() { return is_for_call_; } |
1700 | 1708 |
1701 TypeFeedbackId PropertyFeedbackId() { return reuse(id()); } | 1709 TypeFeedbackId PropertyFeedbackId() { return reuse(id()); } |
1702 | 1710 |
| 1711 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } |
| 1712 virtual void SetFirstFeedbackSlot(int slot) { |
| 1713 property_feedback_slot_ = slot; |
| 1714 } |
| 1715 |
| 1716 int PropertyFeedbackSlot() const { return property_feedback_slot_; } |
| 1717 |
1703 protected: | 1718 protected: |
1704 Property(Zone* zone, | 1719 Property(Zone* zone, |
1705 Expression* obj, | 1720 Expression* obj, |
1706 Expression* key, | 1721 Expression* key, |
1707 int pos) | 1722 int pos) |
1708 : Expression(zone, pos), | 1723 : Expression(zone, pos), |
1709 obj_(obj), | 1724 obj_(obj), |
1710 key_(key), | 1725 key_(key), |
1711 load_id_(GetNextId(zone)), | 1726 load_id_(GetNextId(zone)), |
| 1727 property_feedback_slot_(kInvalidFeedbackSlot), |
1712 is_for_call_(false), | 1728 is_for_call_(false), |
1713 is_uninitialized_(false), | 1729 is_uninitialized_(false), |
1714 is_string_access_(false), | 1730 is_string_access_(false), |
1715 is_function_prototype_(false) { } | 1731 is_function_prototype_(false) { } |
1716 | 1732 |
1717 private: | 1733 private: |
1718 Expression* obj_; | 1734 Expression* obj_; |
1719 Expression* key_; | 1735 Expression* key_; |
1720 const BailoutId load_id_; | 1736 const BailoutId load_id_; |
| 1737 int property_feedback_slot_; |
1721 | 1738 |
1722 SmallMapList receiver_types_; | 1739 SmallMapList receiver_types_; |
1723 bool is_for_call_ : 1; | 1740 bool is_for_call_ : 1; |
1724 bool is_uninitialized_ : 1; | 1741 bool is_uninitialized_ : 1; |
1725 bool is_string_access_ : 1; | 1742 bool is_string_access_ : 1; |
1726 bool is_function_prototype_ : 1; | 1743 bool is_function_prototype_ : 1; |
1727 }; | 1744 }; |
1728 | 1745 |
1729 | 1746 |
1730 class Call V8_FINAL : public Expression, public FeedbackSlotInterface { | 1747 class Call V8_FINAL : public Expression, public FeedbackSlotInterface { |
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1888 int callnew_feedback_slot_; | 1905 int callnew_feedback_slot_; |
1889 | 1906 |
1890 const BailoutId return_id_; | 1907 const BailoutId return_id_; |
1891 }; | 1908 }; |
1892 | 1909 |
1893 | 1910 |
1894 // The CallRuntime class does not represent any official JavaScript | 1911 // The CallRuntime class does not represent any official JavaScript |
1895 // language construct. Instead it is used to call a C or JS function | 1912 // language construct. Instead it is used to call a C or JS function |
1896 // with a set of arguments. This is used from the builtins that are | 1913 // with a set of arguments. This is used from the builtins that are |
1897 // implemented in JavaScript (see "v8natives.js"). | 1914 // implemented in JavaScript (see "v8natives.js"). |
1898 class CallRuntime V8_FINAL : public Expression { | 1915 class CallRuntime V8_FINAL : public Expression, public FeedbackSlotInterface { |
1899 public: | 1916 public: |
1900 DECLARE_NODE_TYPE(CallRuntime) | 1917 DECLARE_NODE_TYPE(CallRuntime) |
1901 | 1918 |
1902 Handle<String> name() const { return raw_name_->string(); } | 1919 Handle<String> name() const { return raw_name_->string(); } |
1903 const AstRawString* raw_name() const { return raw_name_; } | 1920 const AstRawString* raw_name() const { return raw_name_; } |
1904 const Runtime::Function* function() const { return function_; } | 1921 const Runtime::Function* function() const { return function_; } |
1905 ZoneList<Expression*>* arguments() const { return arguments_; } | 1922 ZoneList<Expression*>* arguments() const { return arguments_; } |
1906 bool is_jsruntime() const { return function_ == NULL; } | 1923 bool is_jsruntime() const { return function_ == NULL; } |
1907 | 1924 |
| 1925 // Type feedback information. |
| 1926 virtual int ComputeFeedbackSlotCount() { |
| 1927 return (FLAG_vector_ics && is_jsruntime()) ? 1 : 0; |
| 1928 } |
| 1929 virtual void SetFirstFeedbackSlot(int slot) { |
| 1930 callruntime_feedback_slot_ = slot; |
| 1931 } |
| 1932 |
| 1933 int CallRuntimeFeedbackSlot() { |
| 1934 ASSERT(!is_jsruntime() || |
| 1935 callruntime_feedback_slot_ != kInvalidFeedbackSlot); |
| 1936 return callruntime_feedback_slot_; |
| 1937 } |
| 1938 |
1908 TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); } | 1939 TypeFeedbackId CallRuntimeFeedbackId() const { return reuse(id()); } |
1909 | 1940 |
1910 protected: | 1941 protected: |
1911 CallRuntime(Zone* zone, | 1942 CallRuntime(Zone* zone, |
1912 const AstRawString* name, | 1943 const AstRawString* name, |
1913 const Runtime::Function* function, | 1944 const Runtime::Function* function, |
1914 ZoneList<Expression*>* arguments, | 1945 ZoneList<Expression*>* arguments, |
1915 int pos) | 1946 int pos) |
1916 : Expression(zone, pos), | 1947 : Expression(zone, pos), |
1917 raw_name_(name), | 1948 raw_name_(name), |
1918 function_(function), | 1949 function_(function), |
1919 arguments_(arguments) { } | 1950 arguments_(arguments) { } |
1920 | 1951 |
1921 private: | 1952 private: |
1922 const AstRawString* raw_name_; | 1953 const AstRawString* raw_name_; |
1923 const Runtime::Function* function_; | 1954 const Runtime::Function* function_; |
1924 ZoneList<Expression*>* arguments_; | 1955 ZoneList<Expression*>* arguments_; |
| 1956 int callruntime_feedback_slot_; |
1925 }; | 1957 }; |
1926 | 1958 |
1927 | 1959 |
1928 class UnaryOperation V8_FINAL : public Expression { | 1960 class UnaryOperation V8_FINAL : public Expression { |
1929 public: | 1961 public: |
1930 DECLARE_NODE_TYPE(UnaryOperation) | 1962 DECLARE_NODE_TYPE(UnaryOperation) |
1931 | 1963 |
1932 Token::Value op() const { return op_; } | 1964 Token::Value op() const { return op_; } |
1933 Expression* expression() const { return expression_; } | 1965 Expression* expression() const { return expression_; } |
1934 | 1966 |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2208 BinaryOperation* binary_operation_; | 2240 BinaryOperation* binary_operation_; |
2209 const BailoutId assignment_id_; | 2241 const BailoutId assignment_id_; |
2210 | 2242 |
2211 bool is_uninitialized_ : 1; | 2243 bool is_uninitialized_ : 1; |
2212 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2244 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
2213 // must have extra bit. | 2245 // must have extra bit. |
2214 SmallMapList receiver_types_; | 2246 SmallMapList receiver_types_; |
2215 }; | 2247 }; |
2216 | 2248 |
2217 | 2249 |
2218 class Yield V8_FINAL : public Expression { | 2250 class Yield V8_FINAL : public Expression, public FeedbackSlotInterface { |
2219 public: | 2251 public: |
2220 DECLARE_NODE_TYPE(Yield) | 2252 DECLARE_NODE_TYPE(Yield) |
2221 | 2253 |
2222 enum Kind { | 2254 enum Kind { |
2223 INITIAL, // The initial yield that returns the unboxed generator object. | 2255 INITIAL, // The initial yield that returns the unboxed generator object. |
2224 SUSPEND, // A normal yield: { value: EXPRESSION, done: false } | 2256 SUSPEND, // A normal yield: { value: EXPRESSION, done: false } |
2225 DELEGATING, // A yield*. | 2257 DELEGATING, // A yield*. |
2226 FINAL // A return: { value: EXPRESSION, done: true } | 2258 FINAL // A return: { value: EXPRESSION, done: true } |
2227 }; | 2259 }; |
2228 | 2260 |
2229 Expression* generator_object() const { return generator_object_; } | 2261 Expression* generator_object() const { return generator_object_; } |
2230 Expression* expression() const { return expression_; } | 2262 Expression* expression() const { return expression_; } |
2231 Kind yield_kind() const { return yield_kind_; } | 2263 Kind yield_kind() const { return yield_kind_; } |
2232 | 2264 |
2233 // Delegating yield surrounds the "yield" in a "try/catch". This index | 2265 // Delegating yield surrounds the "yield" in a "try/catch". This index |
2234 // locates the catch handler in the handler table, and is equivalent to | 2266 // locates the catch handler in the handler table, and is equivalent to |
2235 // TryCatchStatement::index(). | 2267 // TryCatchStatement::index(). |
2236 int index() const { | 2268 int index() const { |
2237 ASSERT(yield_kind() == DELEGATING); | 2269 ASSERT(yield_kind() == DELEGATING); |
2238 return index_; | 2270 return index_; |
2239 } | 2271 } |
2240 void set_index(int index) { | 2272 void set_index(int index) { |
2241 ASSERT(yield_kind() == DELEGATING); | 2273 ASSERT(yield_kind() == DELEGATING); |
2242 index_ = index; | 2274 index_ = index; |
2243 } | 2275 } |
2244 | 2276 |
| 2277 // Type feedback information. |
| 2278 virtual int ComputeFeedbackSlotCount() { |
| 2279 return (FLAG_vector_ics && yield_kind() == DELEGATING) ? 3 : 0; |
| 2280 } |
| 2281 virtual void SetFirstFeedbackSlot(int slot) { |
| 2282 yield_first_feedback_slot_ = slot; |
| 2283 } |
| 2284 |
| 2285 int KeyedLoadFeedbackSlot() { |
| 2286 ASSERT(yield_first_feedback_slot_ != kInvalidFeedbackSlot); |
| 2287 return yield_first_feedback_slot_; |
| 2288 } |
| 2289 |
| 2290 int DoneFeedbackSlot() { |
| 2291 ASSERT(yield_first_feedback_slot_ != kInvalidFeedbackSlot); |
| 2292 return yield_first_feedback_slot_ + 1; |
| 2293 } |
| 2294 |
| 2295 int ValueFeedbackSlot() { |
| 2296 ASSERT(yield_first_feedback_slot_ != kInvalidFeedbackSlot); |
| 2297 return yield_first_feedback_slot_ + 2; |
| 2298 } |
| 2299 |
2245 protected: | 2300 protected: |
2246 Yield(Zone* zone, | 2301 Yield(Zone* zone, |
2247 Expression* generator_object, | 2302 Expression* generator_object, |
2248 Expression* expression, | 2303 Expression* expression, |
2249 Kind yield_kind, | 2304 Kind yield_kind, |
2250 int pos) | 2305 int pos) |
2251 : Expression(zone, pos), | 2306 : Expression(zone, pos), |
2252 generator_object_(generator_object), | 2307 generator_object_(generator_object), |
2253 expression_(expression), | 2308 expression_(expression), |
2254 yield_kind_(yield_kind), | 2309 yield_kind_(yield_kind), |
2255 index_(-1) { } | 2310 index_(-1), |
| 2311 yield_first_feedback_slot_(kInvalidFeedbackSlot) { } |
2256 | 2312 |
2257 private: | 2313 private: |
2258 Expression* generator_object_; | 2314 Expression* generator_object_; |
2259 Expression* expression_; | 2315 Expression* expression_; |
2260 Kind yield_kind_; | 2316 Kind yield_kind_; |
2261 int index_; | 2317 int index_; |
| 2318 int yield_first_feedback_slot_; |
2262 }; | 2319 }; |
2263 | 2320 |
2264 | 2321 |
2265 class Throw V8_FINAL : public Expression { | 2322 class Throw V8_FINAL : public Expression { |
2266 public: | 2323 public: |
2267 DECLARE_NODE_TYPE(Throw) | 2324 DECLARE_NODE_TYPE(Throw) |
2268 | 2325 |
2269 Expression* exception() const { return exception_; } | 2326 Expression* exception() const { return exception_; } |
2270 | 2327 |
2271 protected: | 2328 protected: |
(...skipping 1149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3421 private: | 3478 private: |
3422 Zone* zone_; | 3479 Zone* zone_; |
3423 Visitor visitor_; | 3480 Visitor visitor_; |
3424 AstValueFactory* ast_value_factory_; | 3481 AstValueFactory* ast_value_factory_; |
3425 }; | 3482 }; |
3426 | 3483 |
3427 | 3484 |
3428 } } // namespace v8::internal | 3485 } } // namespace v8::internal |
3429 | 3486 |
3430 #endif // V8_AST_H_ | 3487 #endif // V8_AST_H_ |
OLD | NEW |