| 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 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 98 V(SuperReference) \ | 98 V(SuperReference) \ |
| 99 V(CaseClause) | 99 V(CaseClause) |
| 100 | 100 |
| 101 #define AST_NODE_LIST(V) \ | 101 #define AST_NODE_LIST(V) \ |
| 102 DECLARATION_NODE_LIST(V) \ | 102 DECLARATION_NODE_LIST(V) \ |
| 103 MODULE_NODE_LIST(V) \ | 103 MODULE_NODE_LIST(V) \ |
| 104 STATEMENT_NODE_LIST(V) \ | 104 STATEMENT_NODE_LIST(V) \ |
| 105 EXPRESSION_NODE_LIST(V) | 105 EXPRESSION_NODE_LIST(V) |
| 106 | 106 |
| 107 // Forward declarations | 107 // Forward declarations |
| 108 class AstConstructionVisitor; | 108 class AstNodeFactory; |
| 109 template<class> class AstNodeFactory; | |
| 110 class AstVisitor; | 109 class AstVisitor; |
| 111 class Declaration; | 110 class Declaration; |
| 112 class Module; | 111 class Module; |
| 113 class BreakableStatement; | 112 class BreakableStatement; |
| 114 class Expression; | 113 class Expression; |
| 115 class IterationStatement; | 114 class IterationStatement; |
| 116 class MaterializedLiteral; | 115 class MaterializedLiteral; |
| 117 class Statement; | 116 class Statement; |
| 118 class TargetCollector; | 117 class TargetCollector; |
| 119 class TypeFeedbackOracle; | 118 class TypeFeedbackOracle; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 135 AST_NODE_LIST(DEF_FORWARD_DECLARATION) | 134 AST_NODE_LIST(DEF_FORWARD_DECLARATION) |
| 136 #undef DEF_FORWARD_DECLARATION | 135 #undef DEF_FORWARD_DECLARATION |
| 137 | 136 |
| 138 | 137 |
| 139 // Typedef only introduced to avoid unreadable code. | 138 // Typedef only introduced to avoid unreadable code. |
| 140 // Please do appreciate the required space in "> >". | 139 // Please do appreciate the required space in "> >". |
| 141 typedef ZoneList<Handle<String> > ZoneStringList; | 140 typedef ZoneList<Handle<String> > ZoneStringList; |
| 142 typedef ZoneList<Handle<Object> > ZoneObjectList; | 141 typedef ZoneList<Handle<Object> > ZoneObjectList; |
| 143 | 142 |
| 144 | 143 |
| 145 #define DECLARE_NODE_TYPE(type) \ | 144 #define DECLARE_NODE_TYPE(type) \ |
| 146 virtual void Accept(AstVisitor* v) OVERRIDE; \ | 145 virtual void Accept(AstVisitor* v) OVERRIDE; \ |
| 147 virtual AstNode::NodeType node_type() const FINAL OVERRIDE { \ | 146 virtual AstNode::NodeType node_type() const FINAL OVERRIDE { \ |
| 148 return AstNode::k##type; \ | 147 return AstNode::k##type; \ |
| 149 } \ | 148 } \ |
| 150 template<class> friend class AstNodeFactory; | 149 friend class AstNodeFactory; |
| 151 | 150 |
| 152 | 151 |
| 153 enum AstPropertiesFlag { | 152 enum AstPropertiesFlag { |
| 154 kDontSelfOptimize, | 153 kDontSelfOptimize, |
| 155 kDontSoftInline, | 154 kDontSoftInline, |
| 156 kDontCache | 155 kDontCache |
| 157 }; | 156 }; |
| 158 | 157 |
| 159 | 158 |
| 160 class FeedbackVectorRequirements { | 159 class FeedbackVectorRequirements { |
| (...skipping 1343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1504 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1503 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1505 bool IsMonomorphic() { return !receiver_type_.is_null(); } | 1504 bool IsMonomorphic() { return !receiver_type_.is_null(); } |
| 1506 Handle<Map> GetReceiverType() { return receiver_type_; } | 1505 Handle<Map> GetReceiverType() { return receiver_type_; } |
| 1507 | 1506 |
| 1508 bool IsCompileTimeValue(); | 1507 bool IsCompileTimeValue(); |
| 1509 | 1508 |
| 1510 void set_emit_store(bool emit_store); | 1509 void set_emit_store(bool emit_store); |
| 1511 bool emit_store(); | 1510 bool emit_store(); |
| 1512 | 1511 |
| 1513 protected: | 1512 protected: |
| 1514 template<class> friend class AstNodeFactory; | 1513 friend class AstNodeFactory; |
| 1515 | 1514 |
| 1516 ObjectLiteralProperty(Zone* zone, bool is_getter, FunctionLiteral* value, | 1515 ObjectLiteralProperty(Zone* zone, bool is_getter, FunctionLiteral* value, |
| 1517 bool is_static); | 1516 bool is_static); |
| 1518 void set_key(Literal* key) { key_ = key; } | 1517 void set_key(Literal* key) { key_ = key; } |
| 1519 | 1518 |
| 1520 private: | 1519 private: |
| 1521 Literal* key_; | 1520 Literal* key_; |
| 1522 Expression* value_; | 1521 Expression* value_; |
| 1523 Kind kind_; | 1522 Kind kind_; |
| 1524 bool emit_store_; | 1523 bool emit_store_; |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1701 void BindTo(Variable* var); | 1700 void BindTo(Variable* var); |
| 1702 | 1701 |
| 1703 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { | 1702 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1704 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); | 1703 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); |
| 1705 } | 1704 } |
| 1706 virtual void SetFirstICFeedbackSlot(FeedbackVectorICSlot slot) { | 1705 virtual void SetFirstICFeedbackSlot(FeedbackVectorICSlot slot) { |
| 1707 variable_feedback_slot_ = slot; | 1706 variable_feedback_slot_ = slot; |
| 1708 } | 1707 } |
| 1709 | 1708 |
| 1710 FeedbackVectorICSlot VariableFeedbackSlot() { | 1709 FeedbackVectorICSlot VariableFeedbackSlot() { |
| 1710 DCHECK(!FLAG_vector_ics || !variable_feedback_slot_.IsInvalid()); |
| 1711 return variable_feedback_slot_; | 1711 return variable_feedback_slot_; |
| 1712 } | 1712 } |
| 1713 | 1713 |
| 1714 protected: | 1714 protected: |
| 1715 VariableProxy(Zone* zone, Variable* var, int position); | 1715 VariableProxy(Zone* zone, Variable* var, int position); |
| 1716 | 1716 |
| 1717 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, | 1717 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, |
| 1718 Interface* interface, int position); | 1718 Interface* interface, int position); |
| 1719 | 1719 |
| 1720 bool is_this_ : 1; | 1720 bool is_this_ : 1; |
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1772 } | 1772 } |
| 1773 | 1773 |
| 1774 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { | 1774 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1775 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); | 1775 return FeedbackVectorRequirements(0, FLAG_vector_ics ? 1 : 0); |
| 1776 } | 1776 } |
| 1777 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { | 1777 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 1778 property_feedback_slot_ = slot; | 1778 property_feedback_slot_ = slot; |
| 1779 } | 1779 } |
| 1780 | 1780 |
| 1781 FeedbackVectorICSlot PropertyFeedbackSlot() const { | 1781 FeedbackVectorICSlot PropertyFeedbackSlot() const { |
| 1782 DCHECK(!FLAG_vector_ics || !property_feedback_slot_.IsInvalid()); |
| 1782 return property_feedback_slot_; | 1783 return property_feedback_slot_; |
| 1783 } | 1784 } |
| 1784 | 1785 |
| 1785 protected: | 1786 protected: |
| 1786 Property(Zone* zone, Expression* obj, Expression* key, int pos) | 1787 Property(Zone* zone, Expression* obj, Expression* key, int pos) |
| 1787 : Expression(zone, pos), | 1788 : Expression(zone, pos), |
| 1788 is_for_call_(false), | 1789 is_for_call_(false), |
| 1789 is_uninitialized_(false), | 1790 is_uninitialized_(false), |
| 1790 is_string_access_(false), | 1791 is_string_access_(false), |
| 1791 property_feedback_slot_(FeedbackVectorICSlot::Invalid()), | 1792 property_feedback_slot_(FeedbackVectorICSlot::Invalid()), |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1815 | 1816 |
| 1816 // Type feedback information. | 1817 // Type feedback information. |
| 1817 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { | 1818 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1818 return FeedbackVectorRequirements(0, 1); | 1819 return FeedbackVectorRequirements(0, 1); |
| 1819 } | 1820 } |
| 1820 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { | 1821 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 1821 call_feedback_slot_ = slot; | 1822 call_feedback_slot_ = slot; |
| 1822 } | 1823 } |
| 1823 | 1824 |
| 1824 bool HasCallFeedbackSlot() const { return !call_feedback_slot_.IsInvalid(); } | 1825 bool HasCallFeedbackSlot() const { return !call_feedback_slot_.IsInvalid(); } |
| 1825 FeedbackVectorICSlot CallFeedbackSlot() const { return call_feedback_slot_; } | 1826 FeedbackVectorICSlot CallFeedbackSlot() const { |
| 1827 DCHECK(!call_feedback_slot_.IsInvalid()); |
| 1828 return call_feedback_slot_; |
| 1829 } |
| 1826 | 1830 |
| 1827 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 1831 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
| 1828 if (expression()->IsProperty()) { | 1832 if (expression()->IsProperty()) { |
| 1829 return expression()->AsProperty()->GetReceiverTypes(); | 1833 return expression()->AsProperty()->GetReceiverTypes(); |
| 1830 } | 1834 } |
| 1831 return NULL; | 1835 return NULL; |
| 1832 } | 1836 } |
| 1833 | 1837 |
| 1834 virtual bool IsMonomorphic() OVERRIDE { | 1838 virtual bool IsMonomorphic() OVERRIDE { |
| 1835 if (expression()->IsProperty()) { | 1839 if (expression()->IsProperty()) { |
| (...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1914 ZoneList<Expression*>* arguments() const { return arguments_; } | 1918 ZoneList<Expression*>* arguments() const { return arguments_; } |
| 1915 | 1919 |
| 1916 // Type feedback information. | 1920 // Type feedback information. |
| 1917 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { | 1921 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1918 return FeedbackVectorRequirements(FLAG_pretenuring_call_new ? 2 : 1, 0); | 1922 return FeedbackVectorRequirements(FLAG_pretenuring_call_new ? 2 : 1, 0); |
| 1919 } | 1923 } |
| 1920 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { | 1924 virtual void SetFirstFeedbackSlot(FeedbackVectorSlot slot) { |
| 1921 callnew_feedback_slot_ = slot; | 1925 callnew_feedback_slot_ = slot; |
| 1922 } | 1926 } |
| 1923 | 1927 |
| 1924 FeedbackVectorSlot CallNewFeedbackSlot() { return callnew_feedback_slot_; } | 1928 FeedbackVectorSlot CallNewFeedbackSlot() { |
| 1929 DCHECK(!callnew_feedback_slot_.IsInvalid()); |
| 1930 return callnew_feedback_slot_; |
| 1931 } |
| 1925 FeedbackVectorSlot AllocationSiteFeedbackSlot() { | 1932 FeedbackVectorSlot AllocationSiteFeedbackSlot() { |
| 1926 DCHECK(FLAG_pretenuring_call_new); | 1933 DCHECK(FLAG_pretenuring_call_new); |
| 1927 return CallNewFeedbackSlot().next(); | 1934 return CallNewFeedbackSlot().next(); |
| 1928 } | 1935 } |
| 1929 | 1936 |
| 1930 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1937 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1931 virtual bool IsMonomorphic() OVERRIDE { return is_monomorphic_; } | 1938 virtual bool IsMonomorphic() OVERRIDE { return is_monomorphic_; } |
| 1932 Handle<JSFunction> target() const { return target_; } | 1939 Handle<JSFunction> target() const { return target_; } |
| 1933 Handle<AllocationSite> allocation_site() const { | 1940 Handle<AllocationSite> allocation_site() const { |
| 1934 return allocation_site_; | 1941 return allocation_site_; |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1978 // Type feedback information. | 1985 // Type feedback information. |
| 1979 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { | 1986 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 1980 return FeedbackVectorRequirements( | 1987 return FeedbackVectorRequirements( |
| 1981 0, (FLAG_vector_ics && is_jsruntime()) ? 1 : 0); | 1988 0, (FLAG_vector_ics && is_jsruntime()) ? 1 : 0); |
| 1982 } | 1989 } |
| 1983 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { | 1990 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 1984 callruntime_feedback_slot_ = slot; | 1991 callruntime_feedback_slot_ = slot; |
| 1985 } | 1992 } |
| 1986 | 1993 |
| 1987 FeedbackVectorICSlot CallRuntimeFeedbackSlot() { | 1994 FeedbackVectorICSlot CallRuntimeFeedbackSlot() { |
| 1995 DCHECK(!(FLAG_vector_ics && is_jsruntime()) || |
| 1996 !callruntime_feedback_slot_.IsInvalid()); |
| 1988 return callruntime_feedback_slot_; | 1997 return callruntime_feedback_slot_; |
| 1989 } | 1998 } |
| 1990 | 1999 |
| 1991 static int num_ids() { return parent_num_ids() + 1; } | 2000 static int num_ids() { return parent_num_ids() + 1; } |
| 1992 TypeFeedbackId CallRuntimeFeedbackId() const { | 2001 TypeFeedbackId CallRuntimeFeedbackId() const { |
| 1993 return TypeFeedbackId(local_id(0)); | 2002 return TypeFeedbackId(local_id(0)); |
| 1994 } | 2003 } |
| 1995 | 2004 |
| 1996 protected: | 2005 protected: |
| 1997 CallRuntime(Zone* zone, const AstRawString* name, | 2006 CallRuntime(Zone* zone, const AstRawString* name, |
| (...skipping 280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2278 } | 2287 } |
| 2279 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 2288 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
| 2280 void set_key_type(IcCheckType key_type) { key_type_ = key_type; } | 2289 void set_key_type(IcCheckType key_type) { key_type_ = key_type; } |
| 2281 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } | 2290 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } |
| 2282 | 2291 |
| 2283 protected: | 2292 protected: |
| 2284 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, | 2293 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, |
| 2285 int pos); | 2294 int pos); |
| 2286 static int parent_num_ids() { return Expression::num_ids(); } | 2295 static int parent_num_ids() { return Expression::num_ids(); } |
| 2287 | 2296 |
| 2288 template <class Visitor> | |
| 2289 void Init(AstNodeFactory<Visitor>* factory) { | |
| 2290 DCHECK(Token::IsAssignmentOp(op_)); | |
| 2291 if (is_compound()) { | |
| 2292 binary_operation_ = factory->NewBinaryOperation( | |
| 2293 binary_op(), target_, value_, position() + 1); | |
| 2294 } | |
| 2295 } | |
| 2296 | |
| 2297 private: | 2297 private: |
| 2298 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2298 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2299 | 2299 |
| 2300 bool is_uninitialized_ : 1; | 2300 bool is_uninitialized_ : 1; |
| 2301 IcCheckType key_type_ : 1; | 2301 IcCheckType key_type_ : 1; |
| 2302 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2302 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
| 2303 // must have extra bit. | 2303 // must have extra bit. |
| 2304 Token::Value op_; | 2304 Token::Value op_; |
| 2305 Expression* target_; | 2305 Expression* target_; |
| 2306 Expression* value_; | 2306 Expression* value_; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2339 // Type feedback information. | 2339 // Type feedback information. |
| 2340 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { | 2340 virtual FeedbackVectorRequirements ComputeFeedbackRequirements() { |
| 2341 return FeedbackVectorRequirements( | 2341 return FeedbackVectorRequirements( |
| 2342 0, (FLAG_vector_ics && yield_kind() == kDelegating) ? 3 : 0); | 2342 0, (FLAG_vector_ics && yield_kind() == kDelegating) ? 3 : 0); |
| 2343 } | 2343 } |
| 2344 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { | 2344 virtual void SetFirstFeedbackICSlot(FeedbackVectorICSlot slot) { |
| 2345 yield_first_feedback_slot_ = slot; | 2345 yield_first_feedback_slot_ = slot; |
| 2346 } | 2346 } |
| 2347 | 2347 |
| 2348 FeedbackVectorICSlot KeyedLoadFeedbackSlot() { | 2348 FeedbackVectorICSlot KeyedLoadFeedbackSlot() { |
| 2349 DCHECK(!FLAG_vector_ics || !yield_first_feedback_slot_.IsInvalid()); |
| 2349 return yield_first_feedback_slot_; | 2350 return yield_first_feedback_slot_; |
| 2350 } | 2351 } |
| 2351 | 2352 |
| 2352 FeedbackVectorICSlot DoneFeedbackSlot() { | 2353 FeedbackVectorICSlot DoneFeedbackSlot() { |
| 2353 return KeyedLoadFeedbackSlot().next(); | 2354 return KeyedLoadFeedbackSlot().next(); |
| 2354 } | 2355 } |
| 2355 | 2356 |
| 2356 FeedbackVectorICSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); } | 2357 FeedbackVectorICSlot ValueFeedbackSlot() { return DoneFeedbackSlot().next(); } |
| 2357 | 2358 |
| 2358 protected: | 2359 protected: |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 3104 stack_overflow_ = false; \ | 3105 stack_overflow_ = false; \ |
| 3105 } \ | 3106 } \ |
| 3106 Zone* zone() { return zone_; } \ | 3107 Zone* zone() { return zone_; } \ |
| 3107 Isolate* isolate() { return zone_->isolate(); } \ | 3108 Isolate* isolate() { return zone_->isolate(); } \ |
| 3108 \ | 3109 \ |
| 3109 Zone* zone_; \ | 3110 Zone* zone_; \ |
| 3110 bool stack_overflow_ | 3111 bool stack_overflow_ |
| 3111 | 3112 |
| 3112 | 3113 |
| 3113 // ---------------------------------------------------------------------------- | 3114 // ---------------------------------------------------------------------------- |
| 3114 // Construction time visitor. | |
| 3115 | |
| 3116 class AstConstructionVisitor BASE_EMBEDDED { | |
| 3117 public: | |
| 3118 AstConstructionVisitor() | |
| 3119 : dont_crankshaft_reason_(kNoReason), dont_turbofan_reason_(kNoReason) {} | |
| 3120 | |
| 3121 AstProperties* ast_properties() { return &properties_; } | |
| 3122 BailoutReason dont_optimize_reason() { | |
| 3123 if (dont_turbofan_reason_ != kNoReason) { | |
| 3124 return dont_turbofan_reason_; | |
| 3125 } else { | |
| 3126 return dont_crankshaft_reason_; | |
| 3127 } | |
| 3128 } | |
| 3129 | |
| 3130 private: | |
| 3131 template<class> friend class AstNodeFactory; | |
| 3132 | |
| 3133 // Node visitors. | |
| 3134 #define DEF_VISIT(type) \ | |
| 3135 void Visit##type(type* node); | |
| 3136 AST_NODE_LIST(DEF_VISIT) | |
| 3137 #undef DEF_VISIT | |
| 3138 | |
| 3139 void increase_node_count() { properties_.add_node_count(1); } | |
| 3140 void add_flag(AstPropertiesFlag flag) { properties_.flags()->Add(flag); } | |
| 3141 void set_dont_crankshaft_reason(BailoutReason reason) { | |
| 3142 dont_crankshaft_reason_ = reason; | |
| 3143 } | |
| 3144 void set_dont_turbofan_reason(BailoutReason reason) { | |
| 3145 dont_turbofan_reason_ = reason; | |
| 3146 } | |
| 3147 | |
| 3148 void add_slot_node(AstNode* slot_node) { | |
| 3149 FeedbackVectorRequirements reqs = slot_node->ComputeFeedbackRequirements(); | |
| 3150 if (reqs.slots() > 0) { | |
| 3151 slot_node->SetFirstFeedbackSlot( | |
| 3152 FeedbackVectorSlot(properties_.feedback_slots())); | |
| 3153 properties_.increase_feedback_slots(reqs.slots()); | |
| 3154 } | |
| 3155 if (reqs.ic_slots() > 0) { | |
| 3156 slot_node->SetFirstFeedbackICSlot( | |
| 3157 FeedbackVectorICSlot(properties_.ic_feedback_slots())); | |
| 3158 properties_.increase_ic_feedback_slots(reqs.ic_slots()); | |
| 3159 } | |
| 3160 } | |
| 3161 | |
| 3162 AstProperties properties_; | |
| 3163 BailoutReason dont_crankshaft_reason_; | |
| 3164 BailoutReason dont_turbofan_reason_; | |
| 3165 }; | |
| 3166 | |
| 3167 | |
| 3168 class AstNullVisitor BASE_EMBEDDED { | |
| 3169 public: | |
| 3170 // Node visitors. | |
| 3171 #define DEF_VISIT(type) \ | |
| 3172 void Visit##type(type* node) {} | |
| 3173 AST_NODE_LIST(DEF_VISIT) | |
| 3174 #undef DEF_VISIT | |
| 3175 }; | |
| 3176 | |
| 3177 | |
| 3178 | |
| 3179 // ---------------------------------------------------------------------------- | |
| 3180 // AstNode factory | 3115 // AstNode factory |
| 3181 | 3116 |
| 3182 template<class Visitor> | |
| 3183 class AstNodeFactory FINAL BASE_EMBEDDED { | 3117 class AstNodeFactory FINAL BASE_EMBEDDED { |
| 3184 public: | 3118 public: |
| 3185 explicit AstNodeFactory(AstValueFactory* ast_value_factory) | 3119 explicit AstNodeFactory(AstValueFactory* ast_value_factory) |
| 3186 : zone_(ast_value_factory->zone()), | 3120 : zone_(ast_value_factory->zone()), |
| 3187 ast_value_factory_(ast_value_factory) {} | 3121 ast_value_factory_(ast_value_factory) {} |
| 3188 | 3122 |
| 3189 Visitor* visitor() { return &visitor_; } | |
| 3190 | |
| 3191 #define VISIT_AND_RETURN(NodeType, node) \ | |
| 3192 visitor_.Visit##NodeType((node)); \ | |
| 3193 return node; | |
| 3194 | |
| 3195 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, | 3123 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, |
| 3196 VariableMode mode, | 3124 VariableMode mode, |
| 3197 Scope* scope, | 3125 Scope* scope, |
| 3198 int pos) { | 3126 int pos) { |
| 3199 VariableDeclaration* decl = | 3127 return new (zone_) VariableDeclaration(zone_, proxy, mode, scope, pos); |
| 3200 new(zone_) VariableDeclaration(zone_, proxy, mode, scope, pos); | |
| 3201 VISIT_AND_RETURN(VariableDeclaration, decl) | |
| 3202 } | 3128 } |
| 3203 | 3129 |
| 3204 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, | 3130 FunctionDeclaration* NewFunctionDeclaration(VariableProxy* proxy, |
| 3205 VariableMode mode, | 3131 VariableMode mode, |
| 3206 FunctionLiteral* fun, | 3132 FunctionLiteral* fun, |
| 3207 Scope* scope, | 3133 Scope* scope, |
| 3208 int pos) { | 3134 int pos) { |
| 3209 FunctionDeclaration* decl = | 3135 return new (zone_) FunctionDeclaration(zone_, proxy, mode, fun, scope, pos); |
| 3210 new(zone_) FunctionDeclaration(zone_, proxy, mode, fun, scope, pos); | |
| 3211 VISIT_AND_RETURN(FunctionDeclaration, decl) | |
| 3212 } | 3136 } |
| 3213 | 3137 |
| 3214 ModuleDeclaration* NewModuleDeclaration(VariableProxy* proxy, | 3138 ModuleDeclaration* NewModuleDeclaration(VariableProxy* proxy, |
| 3215 Module* module, | 3139 Module* module, |
| 3216 Scope* scope, | 3140 Scope* scope, |
| 3217 int pos) { | 3141 int pos) { |
| 3218 ModuleDeclaration* decl = | 3142 return new (zone_) ModuleDeclaration(zone_, proxy, module, scope, pos); |
| 3219 new(zone_) ModuleDeclaration(zone_, proxy, module, scope, pos); | |
| 3220 VISIT_AND_RETURN(ModuleDeclaration, decl) | |
| 3221 } | 3143 } |
| 3222 | 3144 |
| 3223 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy, | 3145 ImportDeclaration* NewImportDeclaration(VariableProxy* proxy, |
| 3224 Module* module, | 3146 Module* module, |
| 3225 Scope* scope, | 3147 Scope* scope, |
| 3226 int pos) { | 3148 int pos) { |
| 3227 ImportDeclaration* decl = | 3149 return new (zone_) ImportDeclaration(zone_, proxy, module, scope, pos); |
| 3228 new(zone_) ImportDeclaration(zone_, proxy, module, scope, pos); | |
| 3229 VISIT_AND_RETURN(ImportDeclaration, decl) | |
| 3230 } | 3150 } |
| 3231 | 3151 |
| 3232 ExportDeclaration* NewExportDeclaration(VariableProxy* proxy, | 3152 ExportDeclaration* NewExportDeclaration(VariableProxy* proxy, |
| 3233 Scope* scope, | 3153 Scope* scope, |
| 3234 int pos) { | 3154 int pos) { |
| 3235 ExportDeclaration* decl = | 3155 return new (zone_) ExportDeclaration(zone_, proxy, scope, pos); |
| 3236 new(zone_) ExportDeclaration(zone_, proxy, scope, pos); | |
| 3237 VISIT_AND_RETURN(ExportDeclaration, decl) | |
| 3238 } | 3156 } |
| 3239 | 3157 |
| 3240 ModuleLiteral* NewModuleLiteral(Block* body, Interface* interface, int pos) { | 3158 ModuleLiteral* NewModuleLiteral(Block* body, Interface* interface, int pos) { |
| 3241 ModuleLiteral* module = | 3159 return new (zone_) ModuleLiteral(zone_, body, interface, pos); |
| 3242 new(zone_) ModuleLiteral(zone_, body, interface, pos); | |
| 3243 VISIT_AND_RETURN(ModuleLiteral, module) | |
| 3244 } | 3160 } |
| 3245 | 3161 |
| 3246 ModuleVariable* NewModuleVariable(VariableProxy* proxy, int pos) { | 3162 ModuleVariable* NewModuleVariable(VariableProxy* proxy, int pos) { |
| 3247 ModuleVariable* module = new(zone_) ModuleVariable(zone_, proxy, pos); | 3163 return new (zone_) ModuleVariable(zone_, proxy, pos); |
| 3248 VISIT_AND_RETURN(ModuleVariable, module) | |
| 3249 } | 3164 } |
| 3250 | 3165 |
| 3251 ModulePath* NewModulePath(Module* origin, const AstRawString* name, int pos) { | 3166 ModulePath* NewModulePath(Module* origin, const AstRawString* name, int pos) { |
| 3252 ModulePath* module = new (zone_) ModulePath(zone_, origin, name, pos); | 3167 return new (zone_) ModulePath(zone_, origin, name, pos); |
| 3253 VISIT_AND_RETURN(ModulePath, module) | |
| 3254 } | 3168 } |
| 3255 | 3169 |
| 3256 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) { | 3170 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) { |
| 3257 ModuleUrl* module = new(zone_) ModuleUrl(zone_, url, pos); | 3171 return new (zone_) ModuleUrl(zone_, url, pos); |
| 3258 VISIT_AND_RETURN(ModuleUrl, module) | |
| 3259 } | 3172 } |
| 3260 | 3173 |
| 3261 Block* NewBlock(ZoneList<const AstRawString*>* labels, | 3174 Block* NewBlock(ZoneList<const AstRawString*>* labels, |
| 3262 int capacity, | 3175 int capacity, |
| 3263 bool is_initializer_block, | 3176 bool is_initializer_block, |
| 3264 int pos) { | 3177 int pos) { |
| 3265 Block* block = | 3178 return new (zone_) |
| 3266 new (zone_) Block(zone_, labels, capacity, is_initializer_block, pos); | 3179 Block(zone_, labels, capacity, is_initializer_block, pos); |
| 3267 VISIT_AND_RETURN(Block, block) | |
| 3268 } | 3180 } |
| 3269 | 3181 |
| 3270 #define STATEMENT_WITH_LABELS(NodeType) \ | 3182 #define STATEMENT_WITH_LABELS(NodeType) \ |
| 3271 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ | 3183 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ |
| 3272 NodeType* stmt = new (zone_) NodeType(zone_, labels, pos); \ | 3184 return new (zone_) NodeType(zone_, labels, pos); \ |
| 3273 VISIT_AND_RETURN(NodeType, stmt); \ | |
| 3274 } | 3185 } |
| 3275 STATEMENT_WITH_LABELS(DoWhileStatement) | 3186 STATEMENT_WITH_LABELS(DoWhileStatement) |
| 3276 STATEMENT_WITH_LABELS(WhileStatement) | 3187 STATEMENT_WITH_LABELS(WhileStatement) |
| 3277 STATEMENT_WITH_LABELS(ForStatement) | 3188 STATEMENT_WITH_LABELS(ForStatement) |
| 3278 STATEMENT_WITH_LABELS(SwitchStatement) | 3189 STATEMENT_WITH_LABELS(SwitchStatement) |
| 3279 #undef STATEMENT_WITH_LABELS | 3190 #undef STATEMENT_WITH_LABELS |
| 3280 | 3191 |
| 3281 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, | 3192 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, |
| 3282 ZoneList<const AstRawString*>* labels, | 3193 ZoneList<const AstRawString*>* labels, |
| 3283 int pos) { | 3194 int pos) { |
| 3284 switch (visit_mode) { | 3195 switch (visit_mode) { |
| 3285 case ForEachStatement::ENUMERATE: { | 3196 case ForEachStatement::ENUMERATE: { |
| 3286 ForInStatement* stmt = new (zone_) ForInStatement(zone_, labels, pos); | 3197 return new (zone_) ForInStatement(zone_, labels, pos); |
| 3287 VISIT_AND_RETURN(ForInStatement, stmt); | |
| 3288 } | 3198 } |
| 3289 case ForEachStatement::ITERATE: { | 3199 case ForEachStatement::ITERATE: { |
| 3290 ForOfStatement* stmt = new (zone_) ForOfStatement(zone_, labels, pos); | 3200 return new (zone_) ForOfStatement(zone_, labels, pos); |
| 3291 VISIT_AND_RETURN(ForOfStatement, stmt); | |
| 3292 } | 3201 } |
| 3293 } | 3202 } |
| 3294 UNREACHABLE(); | 3203 UNREACHABLE(); |
| 3295 return NULL; | 3204 return NULL; |
| 3296 } | 3205 } |
| 3297 | 3206 |
| 3298 ModuleStatement* NewModuleStatement( | 3207 ModuleStatement* NewModuleStatement( |
| 3299 VariableProxy* proxy, Block* body, int pos) { | 3208 VariableProxy* proxy, Block* body, int pos) { |
| 3300 ModuleStatement* stmt = new(zone_) ModuleStatement(zone_, proxy, body, pos); | 3209 return new (zone_) ModuleStatement(zone_, proxy, body, pos); |
| 3301 VISIT_AND_RETURN(ModuleStatement, stmt) | |
| 3302 } | 3210 } |
| 3303 | 3211 |
| 3304 ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) { | 3212 ExpressionStatement* NewExpressionStatement(Expression* expression, int pos) { |
| 3305 ExpressionStatement* stmt = | 3213 return new (zone_) ExpressionStatement(zone_, expression, pos); |
| 3306 new(zone_) ExpressionStatement(zone_, expression, pos); | |
| 3307 VISIT_AND_RETURN(ExpressionStatement, stmt) | |
| 3308 } | 3214 } |
| 3309 | 3215 |
| 3310 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) { | 3216 ContinueStatement* NewContinueStatement(IterationStatement* target, int pos) { |
| 3311 ContinueStatement* stmt = new(zone_) ContinueStatement(zone_, target, pos); | 3217 return new (zone_) ContinueStatement(zone_, target, pos); |
| 3312 VISIT_AND_RETURN(ContinueStatement, stmt) | |
| 3313 } | 3218 } |
| 3314 | 3219 |
| 3315 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { | 3220 BreakStatement* NewBreakStatement(BreakableStatement* target, int pos) { |
| 3316 BreakStatement* stmt = new(zone_) BreakStatement(zone_, target, pos); | 3221 return new (zone_) BreakStatement(zone_, target, pos); |
| 3317 VISIT_AND_RETURN(BreakStatement, stmt) | |
| 3318 } | 3222 } |
| 3319 | 3223 |
| 3320 ReturnStatement* NewReturnStatement(Expression* expression, int pos) { | 3224 ReturnStatement* NewReturnStatement(Expression* expression, int pos) { |
| 3321 ReturnStatement* stmt = new(zone_) ReturnStatement(zone_, expression, pos); | 3225 return new (zone_) ReturnStatement(zone_, expression, pos); |
| 3322 VISIT_AND_RETURN(ReturnStatement, stmt) | |
| 3323 } | 3226 } |
| 3324 | 3227 |
| 3325 WithStatement* NewWithStatement(Scope* scope, | 3228 WithStatement* NewWithStatement(Scope* scope, |
| 3326 Expression* expression, | 3229 Expression* expression, |
| 3327 Statement* statement, | 3230 Statement* statement, |
| 3328 int pos) { | 3231 int pos) { |
| 3329 WithStatement* stmt = new(zone_) WithStatement( | 3232 return new (zone_) WithStatement(zone_, scope, expression, statement, pos); |
| 3330 zone_, scope, expression, statement, pos); | |
| 3331 VISIT_AND_RETURN(WithStatement, stmt) | |
| 3332 } | 3233 } |
| 3333 | 3234 |
| 3334 IfStatement* NewIfStatement(Expression* condition, | 3235 IfStatement* NewIfStatement(Expression* condition, |
| 3335 Statement* then_statement, | 3236 Statement* then_statement, |
| 3336 Statement* else_statement, | 3237 Statement* else_statement, |
| 3337 int pos) { | 3238 int pos) { |
| 3338 IfStatement* stmt = new (zone_) | 3239 return new (zone_) |
| 3339 IfStatement(zone_, condition, then_statement, else_statement, pos); | 3240 IfStatement(zone_, condition, then_statement, else_statement, pos); |
| 3340 VISIT_AND_RETURN(IfStatement, stmt) | |
| 3341 } | 3241 } |
| 3342 | 3242 |
| 3343 TryCatchStatement* NewTryCatchStatement(int index, | 3243 TryCatchStatement* NewTryCatchStatement(int index, |
| 3344 Block* try_block, | 3244 Block* try_block, |
| 3345 Scope* scope, | 3245 Scope* scope, |
| 3346 Variable* variable, | 3246 Variable* variable, |
| 3347 Block* catch_block, | 3247 Block* catch_block, |
| 3348 int pos) { | 3248 int pos) { |
| 3349 TryCatchStatement* stmt = new(zone_) TryCatchStatement( | 3249 return new (zone_) TryCatchStatement(zone_, index, try_block, scope, |
| 3350 zone_, index, try_block, scope, variable, catch_block, pos); | 3250 variable, catch_block, pos); |
| 3351 VISIT_AND_RETURN(TryCatchStatement, stmt) | |
| 3352 } | 3251 } |
| 3353 | 3252 |
| 3354 TryFinallyStatement* NewTryFinallyStatement(int index, | 3253 TryFinallyStatement* NewTryFinallyStatement(int index, |
| 3355 Block* try_block, | 3254 Block* try_block, |
| 3356 Block* finally_block, | 3255 Block* finally_block, |
| 3357 int pos) { | 3256 int pos) { |
| 3358 TryFinallyStatement* stmt = new(zone_) TryFinallyStatement( | 3257 return new (zone_) |
| 3359 zone_, index, try_block, finally_block, pos); | 3258 TryFinallyStatement(zone_, index, try_block, finally_block, pos); |
| 3360 VISIT_AND_RETURN(TryFinallyStatement, stmt) | |
| 3361 } | 3259 } |
| 3362 | 3260 |
| 3363 DebuggerStatement* NewDebuggerStatement(int pos) { | 3261 DebuggerStatement* NewDebuggerStatement(int pos) { |
| 3364 DebuggerStatement* stmt = new (zone_) DebuggerStatement(zone_, pos); | 3262 return new (zone_) DebuggerStatement(zone_, pos); |
| 3365 VISIT_AND_RETURN(DebuggerStatement, stmt) | |
| 3366 } | 3263 } |
| 3367 | 3264 |
| 3368 EmptyStatement* NewEmptyStatement(int pos) { | 3265 EmptyStatement* NewEmptyStatement(int pos) { |
| 3369 return new(zone_) EmptyStatement(zone_, pos); | 3266 return new(zone_) EmptyStatement(zone_, pos); |
| 3370 } | 3267 } |
| 3371 | 3268 |
| 3372 CaseClause* NewCaseClause( | 3269 CaseClause* NewCaseClause( |
| 3373 Expression* label, ZoneList<Statement*>* statements, int pos) { | 3270 Expression* label, ZoneList<Statement*>* statements, int pos) { |
| 3374 CaseClause* clause = new (zone_) CaseClause(zone_, label, statements, pos); | 3271 return new (zone_) CaseClause(zone_, label, statements, pos); |
| 3375 VISIT_AND_RETURN(CaseClause, clause) | |
| 3376 } | 3272 } |
| 3377 | 3273 |
| 3378 Literal* NewStringLiteral(const AstRawString* string, int pos) { | 3274 Literal* NewStringLiteral(const AstRawString* string, int pos) { |
| 3379 Literal* lit = | 3275 return new (zone_) |
| 3380 new (zone_) Literal(zone_, ast_value_factory_->NewString(string), pos); | 3276 Literal(zone_, ast_value_factory_->NewString(string), pos); |
| 3381 VISIT_AND_RETURN(Literal, lit) | |
| 3382 } | 3277 } |
| 3383 | 3278 |
| 3384 // A JavaScript symbol (ECMA-262 edition 6). | 3279 // A JavaScript symbol (ECMA-262 edition 6). |
| 3385 Literal* NewSymbolLiteral(const char* name, int pos) { | 3280 Literal* NewSymbolLiteral(const char* name, int pos) { |
| 3386 Literal* lit = | 3281 return new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos); |
| 3387 new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos); | |
| 3388 VISIT_AND_RETURN(Literal, lit) | |
| 3389 } | 3282 } |
| 3390 | 3283 |
| 3391 Literal* NewNumberLiteral(double number, int pos) { | 3284 Literal* NewNumberLiteral(double number, int pos) { |
| 3392 Literal* lit = | 3285 return new (zone_) |
| 3393 new (zone_) Literal(zone_, ast_value_factory_->NewNumber(number), pos); | 3286 Literal(zone_, ast_value_factory_->NewNumber(number), pos); |
| 3394 VISIT_AND_RETURN(Literal, lit) | |
| 3395 } | 3287 } |
| 3396 | 3288 |
| 3397 Literal* NewSmiLiteral(int number, int pos) { | 3289 Literal* NewSmiLiteral(int number, int pos) { |
| 3398 Literal* lit = | 3290 return new (zone_) Literal(zone_, ast_value_factory_->NewSmi(number), pos); |
| 3399 new (zone_) Literal(zone_, ast_value_factory_->NewSmi(number), pos); | |
| 3400 VISIT_AND_RETURN(Literal, lit) | |
| 3401 } | 3291 } |
| 3402 | 3292 |
| 3403 Literal* NewBooleanLiteral(bool b, int pos) { | 3293 Literal* NewBooleanLiteral(bool b, int pos) { |
| 3404 Literal* lit = | 3294 return new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos); |
| 3405 new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos); | |
| 3406 VISIT_AND_RETURN(Literal, lit) | |
| 3407 } | 3295 } |
| 3408 | 3296 |
| 3409 Literal* NewStringListLiteral(ZoneList<const AstRawString*>* strings, | 3297 Literal* NewStringListLiteral(ZoneList<const AstRawString*>* strings, |
| 3410 int pos) { | 3298 int pos) { |
| 3411 Literal* lit = new (zone_) | 3299 return new (zone_) |
| 3412 Literal(zone_, ast_value_factory_->NewStringList(strings), pos); | 3300 Literal(zone_, ast_value_factory_->NewStringList(strings), pos); |
| 3413 VISIT_AND_RETURN(Literal, lit) | |
| 3414 } | 3301 } |
| 3415 | 3302 |
| 3416 Literal* NewNullLiteral(int pos) { | 3303 Literal* NewNullLiteral(int pos) { |
| 3417 Literal* lit = | 3304 return new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos); |
| 3418 new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos); | |
| 3419 VISIT_AND_RETURN(Literal, lit) | |
| 3420 } | 3305 } |
| 3421 | 3306 |
| 3422 Literal* NewUndefinedLiteral(int pos) { | 3307 Literal* NewUndefinedLiteral(int pos) { |
| 3423 Literal* lit = | 3308 return new (zone_) Literal(zone_, ast_value_factory_->NewUndefined(), pos); |
| 3424 new (zone_) Literal(zone_, ast_value_factory_->NewUndefined(), pos); | |
| 3425 VISIT_AND_RETURN(Literal, lit) | |
| 3426 } | 3309 } |
| 3427 | 3310 |
| 3428 Literal* NewTheHoleLiteral(int pos) { | 3311 Literal* NewTheHoleLiteral(int pos) { |
| 3429 Literal* lit = | 3312 return new (zone_) Literal(zone_, ast_value_factory_->NewTheHole(), pos); |
| 3430 new (zone_) Literal(zone_, ast_value_factory_->NewTheHole(), pos); | |
| 3431 VISIT_AND_RETURN(Literal, lit) | |
| 3432 } | 3313 } |
| 3433 | 3314 |
| 3434 ObjectLiteral* NewObjectLiteral( | 3315 ObjectLiteral* NewObjectLiteral( |
| 3435 ZoneList<ObjectLiteral::Property*>* properties, | 3316 ZoneList<ObjectLiteral::Property*>* properties, |
| 3436 int literal_index, | 3317 int literal_index, |
| 3437 int boilerplate_properties, | 3318 int boilerplate_properties, |
| 3438 bool has_function, | 3319 bool has_function, |
| 3439 int pos) { | 3320 int pos) { |
| 3440 ObjectLiteral* lit = | 3321 return new (zone_) ObjectLiteral(zone_, properties, literal_index, |
| 3441 new (zone_) ObjectLiteral(zone_, properties, literal_index, | 3322 boilerplate_properties, has_function, pos); |
| 3442 boilerplate_properties, has_function, pos); | |
| 3443 VISIT_AND_RETURN(ObjectLiteral, lit) | |
| 3444 } | 3323 } |
| 3445 | 3324 |
| 3446 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key, | 3325 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key, |
| 3447 Expression* value, | 3326 Expression* value, |
| 3448 bool is_static) { | 3327 bool is_static) { |
| 3449 return new (zone_) ObjectLiteral::Property(zone_, ast_value_factory_, key, | 3328 return new (zone_) ObjectLiteral::Property(zone_, ast_value_factory_, key, |
| 3450 value, is_static); | 3329 value, is_static); |
| 3451 } | 3330 } |
| 3452 | 3331 |
| 3453 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, | 3332 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, |
| 3454 FunctionLiteral* value, | 3333 FunctionLiteral* value, |
| 3455 int pos, bool is_static) { | 3334 int pos, bool is_static) { |
| 3456 ObjectLiteral::Property* prop = | 3335 ObjectLiteral::Property* prop = |
| 3457 new (zone_) ObjectLiteral::Property(zone_, is_getter, value, is_static); | 3336 new (zone_) ObjectLiteral::Property(zone_, is_getter, value, is_static); |
| 3458 prop->set_key(NewStringLiteral(value->raw_name(), pos)); | 3337 prop->set_key(NewStringLiteral(value->raw_name(), pos)); |
| 3459 return prop; // Not an AST node, will not be visited. | 3338 return prop; |
| 3460 } | 3339 } |
| 3461 | 3340 |
| 3462 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, | 3341 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, |
| 3463 const AstRawString* flags, | 3342 const AstRawString* flags, |
| 3464 int literal_index, | 3343 int literal_index, |
| 3465 int pos) { | 3344 int pos) { |
| 3466 RegExpLiteral* lit = | 3345 return new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos); |
| 3467 new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos); | |
| 3468 VISIT_AND_RETURN(RegExpLiteral, lit); | |
| 3469 } | 3346 } |
| 3470 | 3347 |
| 3471 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, | 3348 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, |
| 3472 int literal_index, | 3349 int literal_index, |
| 3473 int pos) { | 3350 int pos) { |
| 3474 ArrayLiteral* lit = | 3351 return new (zone_) ArrayLiteral(zone_, values, literal_index, pos); |
| 3475 new (zone_) ArrayLiteral(zone_, values, literal_index, pos); | |
| 3476 VISIT_AND_RETURN(ArrayLiteral, lit) | |
| 3477 } | 3352 } |
| 3478 | 3353 |
| 3479 VariableProxy* NewVariableProxy(Variable* var, | 3354 VariableProxy* NewVariableProxy(Variable* var, |
| 3480 int pos = RelocInfo::kNoPosition) { | 3355 int pos = RelocInfo::kNoPosition) { |
| 3481 VariableProxy* proxy = new (zone_) VariableProxy(zone_, var, pos); | 3356 return new (zone_) VariableProxy(zone_, var, pos); |
| 3482 VISIT_AND_RETURN(VariableProxy, proxy) | |
| 3483 } | 3357 } |
| 3484 | 3358 |
| 3485 VariableProxy* NewVariableProxy(const AstRawString* name, | 3359 VariableProxy* NewVariableProxy(const AstRawString* name, |
| 3486 bool is_this, | 3360 bool is_this, |
| 3487 Interface* interface = Interface::NewValue(), | 3361 Interface* interface = Interface::NewValue(), |
| 3488 int position = RelocInfo::kNoPosition) { | 3362 int position = RelocInfo::kNoPosition) { |
| 3489 VariableProxy* proxy = | 3363 return new (zone_) VariableProxy(zone_, name, is_this, interface, position); |
| 3490 new (zone_) VariableProxy(zone_, name, is_this, interface, position); | |
| 3491 VISIT_AND_RETURN(VariableProxy, proxy) | |
| 3492 } | 3364 } |
| 3493 | 3365 |
| 3494 Property* NewProperty(Expression* obj, Expression* key, int pos) { | 3366 Property* NewProperty(Expression* obj, Expression* key, int pos) { |
| 3495 Property* prop = new (zone_) Property(zone_, obj, key, pos); | 3367 return new (zone_) Property(zone_, obj, key, pos); |
| 3496 VISIT_AND_RETURN(Property, prop) | |
| 3497 } | 3368 } |
| 3498 | 3369 |
| 3499 Call* NewCall(Expression* expression, | 3370 Call* NewCall(Expression* expression, |
| 3500 ZoneList<Expression*>* arguments, | 3371 ZoneList<Expression*>* arguments, |
| 3501 int pos) { | 3372 int pos) { |
| 3502 Call* call = new (zone_) Call(zone_, expression, arguments, pos); | 3373 return new (zone_) Call(zone_, expression, arguments, pos); |
| 3503 VISIT_AND_RETURN(Call, call) | |
| 3504 } | 3374 } |
| 3505 | 3375 |
| 3506 CallNew* NewCallNew(Expression* expression, | 3376 CallNew* NewCallNew(Expression* expression, |
| 3507 ZoneList<Expression*>* arguments, | 3377 ZoneList<Expression*>* arguments, |
| 3508 int pos) { | 3378 int pos) { |
| 3509 CallNew* call = new (zone_) CallNew(zone_, expression, arguments, pos); | 3379 return new (zone_) CallNew(zone_, expression, arguments, pos); |
| 3510 VISIT_AND_RETURN(CallNew, call) | |
| 3511 } | 3380 } |
| 3512 | 3381 |
| 3513 CallRuntime* NewCallRuntime(const AstRawString* name, | 3382 CallRuntime* NewCallRuntime(const AstRawString* name, |
| 3514 const Runtime::Function* function, | 3383 const Runtime::Function* function, |
| 3515 ZoneList<Expression*>* arguments, | 3384 ZoneList<Expression*>* arguments, |
| 3516 int pos) { | 3385 int pos) { |
| 3517 CallRuntime* call = | 3386 return new (zone_) CallRuntime(zone_, name, function, arguments, pos); |
| 3518 new (zone_) CallRuntime(zone_, name, function, arguments, pos); | |
| 3519 VISIT_AND_RETURN(CallRuntime, call) | |
| 3520 } | 3387 } |
| 3521 | 3388 |
| 3522 UnaryOperation* NewUnaryOperation(Token::Value op, | 3389 UnaryOperation* NewUnaryOperation(Token::Value op, |
| 3523 Expression* expression, | 3390 Expression* expression, |
| 3524 int pos) { | 3391 int pos) { |
| 3525 UnaryOperation* node = | 3392 return new (zone_) UnaryOperation(zone_, op, expression, pos); |
| 3526 new (zone_) UnaryOperation(zone_, op, expression, pos); | |
| 3527 VISIT_AND_RETURN(UnaryOperation, node) | |
| 3528 } | 3393 } |
| 3529 | 3394 |
| 3530 BinaryOperation* NewBinaryOperation(Token::Value op, | 3395 BinaryOperation* NewBinaryOperation(Token::Value op, |
| 3531 Expression* left, | 3396 Expression* left, |
| 3532 Expression* right, | 3397 Expression* right, |
| 3533 int pos) { | 3398 int pos) { |
| 3534 BinaryOperation* node = | 3399 return new (zone_) BinaryOperation(zone_, op, left, right, pos); |
| 3535 new (zone_) BinaryOperation(zone_, op, left, right, pos); | |
| 3536 VISIT_AND_RETURN(BinaryOperation, node) | |
| 3537 } | 3400 } |
| 3538 | 3401 |
| 3539 CountOperation* NewCountOperation(Token::Value op, | 3402 CountOperation* NewCountOperation(Token::Value op, |
| 3540 bool is_prefix, | 3403 bool is_prefix, |
| 3541 Expression* expr, | 3404 Expression* expr, |
| 3542 int pos) { | 3405 int pos) { |
| 3543 CountOperation* node = | 3406 return new (zone_) CountOperation(zone_, op, is_prefix, expr, pos); |
| 3544 new (zone_) CountOperation(zone_, op, is_prefix, expr, pos); | |
| 3545 VISIT_AND_RETURN(CountOperation, node) | |
| 3546 } | 3407 } |
| 3547 | 3408 |
| 3548 CompareOperation* NewCompareOperation(Token::Value op, | 3409 CompareOperation* NewCompareOperation(Token::Value op, |
| 3549 Expression* left, | 3410 Expression* left, |
| 3550 Expression* right, | 3411 Expression* right, |
| 3551 int pos) { | 3412 int pos) { |
| 3552 CompareOperation* node = | 3413 return new (zone_) CompareOperation(zone_, op, left, right, pos); |
| 3553 new (zone_) CompareOperation(zone_, op, left, right, pos); | |
| 3554 VISIT_AND_RETURN(CompareOperation, node) | |
| 3555 } | 3414 } |
| 3556 | 3415 |
| 3557 Conditional* NewConditional(Expression* condition, | 3416 Conditional* NewConditional(Expression* condition, |
| 3558 Expression* then_expression, | 3417 Expression* then_expression, |
| 3559 Expression* else_expression, | 3418 Expression* else_expression, |
| 3560 int position) { | 3419 int position) { |
| 3561 Conditional* cond = new (zone_) Conditional( | 3420 return new (zone_) Conditional(zone_, condition, then_expression, |
| 3562 zone_, condition, then_expression, else_expression, position); | 3421 else_expression, position); |
| 3563 VISIT_AND_RETURN(Conditional, cond) | |
| 3564 } | 3422 } |
| 3565 | 3423 |
| 3566 Assignment* NewAssignment(Token::Value op, | 3424 Assignment* NewAssignment(Token::Value op, |
| 3567 Expression* target, | 3425 Expression* target, |
| 3568 Expression* value, | 3426 Expression* value, |
| 3569 int pos) { | 3427 int pos) { |
| 3428 DCHECK(Token::IsAssignmentOp(op)); |
| 3570 Assignment* assign = new (zone_) Assignment(zone_, op, target, value, pos); | 3429 Assignment* assign = new (zone_) Assignment(zone_, op, target, value, pos); |
| 3571 assign->Init(this); | 3430 if (assign->is_compound()) { |
| 3572 VISIT_AND_RETURN(Assignment, assign) | 3431 assign->binary_operation_ = |
| 3432 NewBinaryOperation(assign->binary_op(), target, value, pos + 1); |
| 3433 } |
| 3434 return assign; |
| 3573 } | 3435 } |
| 3574 | 3436 |
| 3575 Yield* NewYield(Expression *generator_object, | 3437 Yield* NewYield(Expression *generator_object, |
| 3576 Expression* expression, | 3438 Expression* expression, |
| 3577 Yield::Kind yield_kind, | 3439 Yield::Kind yield_kind, |
| 3578 int pos) { | 3440 int pos) { |
| 3579 if (!expression) expression = NewUndefinedLiteral(pos); | 3441 if (!expression) expression = NewUndefinedLiteral(pos); |
| 3580 Yield* yield = | 3442 return new (zone_) |
| 3581 new (zone_) Yield(zone_, generator_object, expression, yield_kind, pos); | 3443 Yield(zone_, generator_object, expression, yield_kind, pos); |
| 3582 VISIT_AND_RETURN(Yield, yield) | |
| 3583 } | 3444 } |
| 3584 | 3445 |
| 3585 Throw* NewThrow(Expression* exception, int pos) { | 3446 Throw* NewThrow(Expression* exception, int pos) { |
| 3586 Throw* t = new (zone_) Throw(zone_, exception, pos); | 3447 return new (zone_) Throw(zone_, exception, pos); |
| 3587 VISIT_AND_RETURN(Throw, t) | |
| 3588 } | 3448 } |
| 3589 | 3449 |
| 3590 FunctionLiteral* NewFunctionLiteral( | 3450 FunctionLiteral* NewFunctionLiteral( |
| 3591 const AstRawString* name, AstValueFactory* ast_value_factory, | 3451 const AstRawString* name, AstValueFactory* ast_value_factory, |
| 3592 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, | 3452 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, |
| 3593 int expected_property_count, int handler_count, int parameter_count, | 3453 int expected_property_count, int handler_count, int parameter_count, |
| 3594 FunctionLiteral::ParameterFlag has_duplicate_parameters, | 3454 FunctionLiteral::ParameterFlag has_duplicate_parameters, |
| 3595 FunctionLiteral::FunctionType function_type, | 3455 FunctionLiteral::FunctionType function_type, |
| 3596 FunctionLiteral::IsFunctionFlag is_function, | 3456 FunctionLiteral::IsFunctionFlag is_function, |
| 3597 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind, | 3457 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind, |
| 3598 int position) { | 3458 int position) { |
| 3599 FunctionLiteral* lit = new (zone_) FunctionLiteral( | 3459 return new (zone_) FunctionLiteral( |
| 3600 zone_, name, ast_value_factory, scope, body, materialized_literal_count, | 3460 zone_, name, ast_value_factory, scope, body, materialized_literal_count, |
| 3601 expected_property_count, handler_count, parameter_count, function_type, | 3461 expected_property_count, handler_count, parameter_count, function_type, |
| 3602 has_duplicate_parameters, is_function, is_parenthesized, kind, | 3462 has_duplicate_parameters, is_function, is_parenthesized, kind, |
| 3603 position); | 3463 position); |
| 3604 // Top-level literal doesn't count for the AST's properties. | |
| 3605 if (is_function == FunctionLiteral::kIsFunction) { | |
| 3606 visitor_.VisitFunctionLiteral(lit); | |
| 3607 } | |
| 3608 return lit; | |
| 3609 } | 3464 } |
| 3610 | 3465 |
| 3611 ClassLiteral* NewClassLiteral(const AstRawString* name, Expression* extends, | 3466 ClassLiteral* NewClassLiteral(const AstRawString* name, Expression* extends, |
| 3612 Expression* constructor, | 3467 Expression* constructor, |
| 3613 ZoneList<ObjectLiteral::Property*>* properties, | 3468 ZoneList<ObjectLiteral::Property*>* properties, |
| 3614 int start_position, int end_position) { | 3469 int start_position, int end_position) { |
| 3615 ClassLiteral* lit = | 3470 return new (zone_) ClassLiteral(zone_, name, extends, constructor, |
| 3616 new (zone_) ClassLiteral(zone_, name, extends, constructor, properties, | 3471 properties, start_position, end_position); |
| 3617 start_position, end_position); | |
| 3618 VISIT_AND_RETURN(ClassLiteral, lit) | |
| 3619 } | 3472 } |
| 3620 | 3473 |
| 3621 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, | 3474 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, |
| 3622 v8::Extension* extension, | 3475 v8::Extension* extension, |
| 3623 int pos) { | 3476 int pos) { |
| 3624 NativeFunctionLiteral* lit = | 3477 return new (zone_) NativeFunctionLiteral(zone_, name, extension, pos); |
| 3625 new (zone_) NativeFunctionLiteral(zone_, name, extension, pos); | |
| 3626 VISIT_AND_RETURN(NativeFunctionLiteral, lit) | |
| 3627 } | 3478 } |
| 3628 | 3479 |
| 3629 ThisFunction* NewThisFunction(int pos) { | 3480 ThisFunction* NewThisFunction(int pos) { |
| 3630 ThisFunction* fun = new (zone_) ThisFunction(zone_, pos); | 3481 return new (zone_) ThisFunction(zone_, pos); |
| 3631 VISIT_AND_RETURN(ThisFunction, fun) | |
| 3632 } | 3482 } |
| 3633 | 3483 |
| 3634 SuperReference* NewSuperReference(VariableProxy* this_var, int pos) { | 3484 SuperReference* NewSuperReference(VariableProxy* this_var, int pos) { |
| 3635 SuperReference* super = new (zone_) SuperReference(zone_, this_var, pos); | 3485 return new (zone_) SuperReference(zone_, this_var, pos); |
| 3636 VISIT_AND_RETURN(SuperReference, super); | |
| 3637 } | 3486 } |
| 3638 | 3487 |
| 3639 #undef VISIT_AND_RETURN | |
| 3640 | |
| 3641 private: | 3488 private: |
| 3642 Zone* zone_; | 3489 Zone* zone_; |
| 3643 Visitor visitor_; | |
| 3644 AstValueFactory* ast_value_factory_; | 3490 AstValueFactory* ast_value_factory_; |
| 3645 }; | 3491 }; |
| 3646 | 3492 |
| 3647 | 3493 |
| 3648 } } // namespace v8::internal | 3494 } } // namespace v8::internal |
| 3649 | 3495 |
| 3650 #endif // V8_AST_H_ | 3496 #endif // V8_AST_H_ |
| OLD | NEW |