| OLD | NEW |
| 1 // Copyright 2010 the V8 project authors. All rights reserved. | 1 // Copyright 2010 the V8 project authors. All rights reserved. |
| 2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
| 3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
| 4 // met: | 4 // met: |
| 5 // | 5 // |
| 6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
| 7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
| 8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
| 9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
| 10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 static unsigned ReserveIdRange(int n) { | 168 static unsigned ReserveIdRange(int n) { |
| 169 unsigned tmp = current_id_; | 169 unsigned tmp = current_id_; |
| 170 current_id_ += n; | 170 current_id_ += n; |
| 171 return tmp; | 171 return tmp; |
| 172 } | 172 } |
| 173 | 173 |
| 174 private: | 174 private: |
| 175 static unsigned current_id_; | 175 static unsigned current_id_; |
| 176 static unsigned count_; | 176 static unsigned count_; |
| 177 unsigned id_; | 177 unsigned id_; |
| 178 |
| 179 friend class CaseClause; // Generates AST IDs. |
| 178 }; | 180 }; |
| 179 | 181 |
| 180 | 182 |
| 181 class Statement: public AstNode { | 183 class Statement: public AstNode { |
| 182 public: | 184 public: |
| 183 Statement() : statement_pos_(RelocInfo::kNoPosition) {} | 185 Statement() : statement_pos_(RelocInfo::kNoPosition) {} |
| 184 | 186 |
| 185 virtual Statement* AsStatement() { return this; } | 187 virtual Statement* AsStatement() { return this; } |
| 186 | 188 |
| 187 virtual Assignment* StatementAsSimpleAssignment() { return NULL; } | 189 virtual Assignment* StatementAsSimpleAssignment() { return NULL; } |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 687 Expression* label() const { | 689 Expression* label() const { |
| 688 CHECK(!is_default()); | 690 CHECK(!is_default()); |
| 689 return label_; | 691 return label_; |
| 690 } | 692 } |
| 691 JumpTarget* body_target() { return &body_target_; } | 693 JumpTarget* body_target() { return &body_target_; } |
| 692 ZoneList<Statement*>* statements() const { return statements_; } | 694 ZoneList<Statement*>* statements() const { return statements_; } |
| 693 | 695 |
| 694 int position() { return position_; } | 696 int position() { return position_; } |
| 695 void set_position(int pos) { position_ = pos; } | 697 void set_position(int pos) { position_ = pos; } |
| 696 | 698 |
| 699 int EntryId() { return entry_id_; } |
| 700 |
| 697 // Type feedback information. | 701 // Type feedback information. |
| 698 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 702 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 699 bool IsSmiCompare() { return compare_type_ == SMI_ONLY; } | 703 bool IsSmiCompare() { return compare_type_ == SMI_ONLY; } |
| 700 bool IsObjectCompare() { return compare_type_ == OBJECT_ONLY; } | 704 bool IsObjectCompare() { return compare_type_ == OBJECT_ONLY; } |
| 701 | 705 |
| 702 private: | 706 private: |
| 703 Expression* label_; | 707 Expression* label_; |
| 704 JumpTarget body_target_; | 708 JumpTarget body_target_; |
| 705 ZoneList<Statement*>* statements_; | 709 ZoneList<Statement*>* statements_; |
| 706 int position_; | 710 int position_; |
| 707 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY }; | 711 enum CompareTypeFeedback { NONE, SMI_ONLY, OBJECT_ONLY }; |
| 708 CompareTypeFeedback compare_type_; | 712 CompareTypeFeedback compare_type_; |
| 713 int entry_id_; |
| 709 }; | 714 }; |
| 710 | 715 |
| 711 | 716 |
| 712 class SwitchStatement: public BreakableStatement { | 717 class SwitchStatement: public BreakableStatement { |
| 713 public: | 718 public: |
| 714 explicit inline SwitchStatement(ZoneStringList* labels); | 719 explicit inline SwitchStatement(ZoneStringList* labels); |
| 715 | 720 |
| 716 DECLARE_NODE_TYPE(SwitchStatement) | 721 DECLARE_NODE_TYPE(SwitchStatement) |
| 717 | 722 |
| 718 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 723 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
| (...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1202 enum Type { NORMAL, SYNTHETIC }; | 1207 enum Type { NORMAL, SYNTHETIC }; |
| 1203 Property(Expression* obj, Expression* key, int pos, Type type = NORMAL) | 1208 Property(Expression* obj, Expression* key, int pos, Type type = NORMAL) |
| 1204 : obj_(obj), | 1209 : obj_(obj), |
| 1205 key_(key), | 1210 key_(key), |
| 1206 pos_(pos), | 1211 pos_(pos), |
| 1207 type_(type), | 1212 type_(type), |
| 1208 receiver_types_(NULL), | 1213 receiver_types_(NULL), |
| 1209 is_monomorphic_(false), | 1214 is_monomorphic_(false), |
| 1210 is_array_length_(false), | 1215 is_array_length_(false), |
| 1211 is_string_length_(false), | 1216 is_string_length_(false), |
| 1217 is_string_access_(false), |
| 1212 is_function_prototype_(false), | 1218 is_function_prototype_(false), |
| 1213 is_arguments_access_(false) { } | 1219 is_arguments_access_(false) { } |
| 1214 | 1220 |
| 1215 DECLARE_NODE_TYPE(Property) | 1221 DECLARE_NODE_TYPE(Property) |
| 1216 | 1222 |
| 1217 virtual bool IsValidLeftHandSide() { return true; } | 1223 virtual bool IsValidLeftHandSide() { return true; } |
| 1218 virtual bool IsInlineable() const; | 1224 virtual bool IsInlineable() const; |
| 1219 | 1225 |
| 1220 Expression* obj() const { return obj_; } | 1226 Expression* obj() const { return obj_; } |
| 1221 Expression* key() const { return key_; } | 1227 Expression* key() const { return key_; } |
| 1222 int position() const { return pos_; } | 1228 int position() const { return pos_; } |
| 1223 bool is_synthetic() const { return type_ == SYNTHETIC; } | 1229 bool is_synthetic() const { return type_ == SYNTHETIC; } |
| 1224 | 1230 |
| 1225 bool IsStringLength() const { return is_string_length_; } | 1231 bool IsStringLength() const { return is_string_length_; } |
| 1232 bool IsStringAccess() const { return is_string_access_; } |
| 1226 bool IsFunctionPrototype() const { return is_function_prototype_; } | 1233 bool IsFunctionPrototype() const { return is_function_prototype_; } |
| 1227 | 1234 |
| 1228 // Marks that this is actually an argument rewritten to a keyed property | 1235 // Marks that this is actually an argument rewritten to a keyed property |
| 1229 // accessing the argument through the arguments shadow object. | 1236 // accessing the argument through the arguments shadow object. |
| 1230 void set_is_arguments_access(bool is_arguments_access) { | 1237 void set_is_arguments_access(bool is_arguments_access) { |
| 1231 is_arguments_access_ = is_arguments_access; | 1238 is_arguments_access_ = is_arguments_access; |
| 1232 } | 1239 } |
| 1233 bool is_arguments_access() const { return is_arguments_access_; } | 1240 bool is_arguments_access() const { return is_arguments_access_; } |
| 1234 | 1241 |
| 1242 ExternalArrayType GetExternalArrayType() const { return array_type_; } |
| 1243 void SetExternalArrayType(ExternalArrayType array_type) { |
| 1244 array_type_ = array_type; |
| 1245 } |
| 1246 |
| 1235 // Type feedback information. | 1247 // Type feedback information. |
| 1236 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1248 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1237 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1249 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1238 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } | 1250 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } |
| 1239 virtual bool IsArrayLength() { return is_array_length_; } | 1251 virtual bool IsArrayLength() { return is_array_length_; } |
| 1240 virtual Handle<Map> GetMonomorphicReceiverType() { | 1252 virtual Handle<Map> GetMonomorphicReceiverType() { |
| 1241 return monomorphic_receiver_type_; | 1253 return monomorphic_receiver_type_; |
| 1242 } | 1254 } |
| 1243 | 1255 |
| 1244 // Returns a property singleton property access on 'this'. Used | 1256 // Returns a property singleton property access on 'this'. Used |
| 1245 // during preparsing. | 1257 // during preparsing. |
| 1246 static Property* this_property() { return &this_property_; } | 1258 static Property* this_property() { return &this_property_; } |
| 1247 | 1259 |
| 1248 private: | 1260 private: |
| 1249 Expression* obj_; | 1261 Expression* obj_; |
| 1250 Expression* key_; | 1262 Expression* key_; |
| 1251 int pos_; | 1263 int pos_; |
| 1252 Type type_; | 1264 Type type_; |
| 1253 | 1265 |
| 1254 ZoneMapList* receiver_types_; | 1266 ZoneMapList* receiver_types_; |
| 1255 bool is_monomorphic_ : 1; | 1267 bool is_monomorphic_ : 1; |
| 1256 bool is_array_length_ : 1; | 1268 bool is_array_length_ : 1; |
| 1257 bool is_string_length_ : 1; | 1269 bool is_string_length_ : 1; |
| 1270 bool is_string_access_ : 1; |
| 1258 bool is_function_prototype_ : 1; | 1271 bool is_function_prototype_ : 1; |
| 1259 bool is_arguments_access_ : 1; | 1272 bool is_arguments_access_ : 1; |
| 1260 Handle<Map> monomorphic_receiver_type_; | 1273 Handle<Map> monomorphic_receiver_type_; |
| 1274 ExternalArrayType array_type_; |
| 1261 | 1275 |
| 1262 // Dummy property used during preparsing. | 1276 // Dummy property used during preparsing. |
| 1263 static Property this_property_; | 1277 static Property this_property_; |
| 1264 }; | 1278 }; |
| 1265 | 1279 |
| 1266 | 1280 |
| 1267 class Call: public Expression { | 1281 class Call: public Expression { |
| 1268 public: | 1282 public: |
| 1269 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) | 1283 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
| 1270 : expression_(expression), | 1284 : expression_(expression), |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1614 void mark_block_start() { block_start_ = true; } | 1628 void mark_block_start() { block_start_ = true; } |
| 1615 void mark_block_end() { block_end_ = true; } | 1629 void mark_block_end() { block_end_ = true; } |
| 1616 | 1630 |
| 1617 // Type feedback information. | 1631 // Type feedback information. |
| 1618 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1632 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1619 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1633 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1620 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } | 1634 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } |
| 1621 virtual Handle<Map> GetMonomorphicReceiverType() { | 1635 virtual Handle<Map> GetMonomorphicReceiverType() { |
| 1622 return monomorphic_receiver_type_; | 1636 return monomorphic_receiver_type_; |
| 1623 } | 1637 } |
| 1638 ExternalArrayType GetExternalArrayType() const { return array_type_; } |
| 1639 void SetExternalArrayType(ExternalArrayType array_type) { |
| 1640 array_type_ = array_type; |
| 1641 } |
| 1624 | 1642 |
| 1625 // Bailout support. | 1643 // Bailout support. |
| 1626 int CompoundLoadId() const { return compound_load_id_; } | 1644 int CompoundLoadId() const { return compound_load_id_; } |
| 1627 int AssignmentId() const { return assignment_id_; } | 1645 int AssignmentId() const { return assignment_id_; } |
| 1628 | 1646 |
| 1629 private: | 1647 private: |
| 1630 Token::Value op_; | 1648 Token::Value op_; |
| 1631 Expression* target_; | 1649 Expression* target_; |
| 1632 Expression* value_; | 1650 Expression* value_; |
| 1633 int pos_; | 1651 int pos_; |
| 1634 BinaryOperation* binary_operation_; | 1652 BinaryOperation* binary_operation_; |
| 1635 int compound_load_id_; | 1653 int compound_load_id_; |
| 1636 int assignment_id_; | 1654 int assignment_id_; |
| 1637 | 1655 |
| 1638 bool block_start_; | 1656 bool block_start_; |
| 1639 bool block_end_; | 1657 bool block_end_; |
| 1640 | 1658 |
| 1641 bool is_monomorphic_; | 1659 bool is_monomorphic_; |
| 1642 ZoneMapList* receiver_types_; | 1660 ZoneMapList* receiver_types_; |
| 1643 Handle<Map> monomorphic_receiver_type_; | 1661 Handle<Map> monomorphic_receiver_type_; |
| 1662 ExternalArrayType array_type_; |
| 1644 }; | 1663 }; |
| 1645 | 1664 |
| 1646 | 1665 |
| 1647 class Throw: public Expression { | 1666 class Throw: public Expression { |
| 1648 public: | 1667 public: |
| 1649 Throw(Expression* exception, int pos) | 1668 Throw(Expression* exception, int pos) |
| 1650 : exception_(exception), pos_(pos) {} | 1669 : exception_(exception), pos_(pos) {} |
| 1651 | 1670 |
| 1652 DECLARE_NODE_TYPE(Throw) | 1671 DECLARE_NODE_TYPE(Throw) |
| 1653 | 1672 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1666 Scope* scope, | 1685 Scope* scope, |
| 1667 ZoneList<Statement*>* body, | 1686 ZoneList<Statement*>* body, |
| 1668 int materialized_literal_count, | 1687 int materialized_literal_count, |
| 1669 int expected_property_count, | 1688 int expected_property_count, |
| 1670 bool has_only_simple_this_property_assignments, | 1689 bool has_only_simple_this_property_assignments, |
| 1671 Handle<FixedArray> this_property_assignments, | 1690 Handle<FixedArray> this_property_assignments, |
| 1672 int num_parameters, | 1691 int num_parameters, |
| 1673 int start_position, | 1692 int start_position, |
| 1674 int end_position, | 1693 int end_position, |
| 1675 bool is_expression, | 1694 bool is_expression, |
| 1676 bool contains_loops, | 1695 bool contains_loops) |
| 1677 bool strict_mode) | |
| 1678 : name_(name), | 1696 : name_(name), |
| 1679 scope_(scope), | 1697 scope_(scope), |
| 1680 body_(body), | 1698 body_(body), |
| 1681 materialized_literal_count_(materialized_literal_count), | 1699 materialized_literal_count_(materialized_literal_count), |
| 1682 expected_property_count_(expected_property_count), | 1700 expected_property_count_(expected_property_count), |
| 1683 has_only_simple_this_property_assignments_( | 1701 has_only_simple_this_property_assignments_( |
| 1684 has_only_simple_this_property_assignments), | 1702 has_only_simple_this_property_assignments), |
| 1685 this_property_assignments_(this_property_assignments), | 1703 this_property_assignments_(this_property_assignments), |
| 1686 num_parameters_(num_parameters), | 1704 num_parameters_(num_parameters), |
| 1687 start_position_(start_position), | 1705 start_position_(start_position), |
| 1688 end_position_(end_position), | 1706 end_position_(end_position), |
| 1689 is_expression_(is_expression), | 1707 is_expression_(is_expression), |
| 1690 contains_loops_(contains_loops), | 1708 contains_loops_(contains_loops), |
| 1691 strict_mode_(strict_mode), | |
| 1692 function_token_position_(RelocInfo::kNoPosition), | 1709 function_token_position_(RelocInfo::kNoPosition), |
| 1693 inferred_name_(Heap::empty_string()), | 1710 inferred_name_(Heap::empty_string()), |
| 1694 try_full_codegen_(false), | 1711 try_full_codegen_(false), |
| 1695 pretenure_(false) { } | 1712 pretenure_(false) { } |
| 1696 | 1713 |
| 1697 DECLARE_NODE_TYPE(FunctionLiteral) | 1714 DECLARE_NODE_TYPE(FunctionLiteral) |
| 1698 | 1715 |
| 1699 Handle<String> name() const { return name_; } | 1716 Handle<String> name() const { return name_; } |
| 1700 Scope* scope() const { return scope_; } | 1717 Scope* scope() const { return scope_; } |
| 1701 ZoneList<Statement*>* body() const { return body_; } | 1718 ZoneList<Statement*>* body() const { return body_; } |
| 1702 void set_function_token_position(int pos) { function_token_position_ = pos; } | 1719 void set_function_token_position(int pos) { function_token_position_ = pos; } |
| 1703 int function_token_position() const { return function_token_position_; } | 1720 int function_token_position() const { return function_token_position_; } |
| 1704 int start_position() const { return start_position_; } | 1721 int start_position() const { return start_position_; } |
| 1705 int end_position() const { return end_position_; } | 1722 int end_position() const { return end_position_; } |
| 1706 bool is_expression() const { return is_expression_; } | 1723 bool is_expression() const { return is_expression_; } |
| 1707 bool contains_loops() const { return contains_loops_; } | 1724 bool contains_loops() const { return contains_loops_; } |
| 1708 bool strict_mode() const { return strict_mode_; } | 1725 bool strict_mode() const; |
| 1709 | 1726 |
| 1710 int materialized_literal_count() { return materialized_literal_count_; } | 1727 int materialized_literal_count() { return materialized_literal_count_; } |
| 1711 int expected_property_count() { return expected_property_count_; } | 1728 int expected_property_count() { return expected_property_count_; } |
| 1712 bool has_only_simple_this_property_assignments() { | 1729 bool has_only_simple_this_property_assignments() { |
| 1713 return has_only_simple_this_property_assignments_; | 1730 return has_only_simple_this_property_assignments_; |
| 1714 } | 1731 } |
| 1715 Handle<FixedArray> this_property_assignments() { | 1732 Handle<FixedArray> this_property_assignments() { |
| 1716 return this_property_assignments_; | 1733 return this_property_assignments_; |
| 1717 } | 1734 } |
| 1718 int num_parameters() { return num_parameters_; } | 1735 int num_parameters() { return num_parameters_; } |
| (...skipping 449 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2168 AST_NODE_LIST(DEF_VISIT) | 2185 AST_NODE_LIST(DEF_VISIT) |
| 2169 #undef DEF_VISIT | 2186 #undef DEF_VISIT |
| 2170 | 2187 |
| 2171 private: | 2188 private: |
| 2172 bool stack_overflow_; | 2189 bool stack_overflow_; |
| 2173 }; | 2190 }; |
| 2174 | 2191 |
| 2175 } } // namespace v8::internal | 2192 } } // namespace v8::internal |
| 2176 | 2193 |
| 2177 #endif // V8_AST_H_ | 2194 #endif // V8_AST_H_ |
| OLD | NEW |