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