OLD | NEW |
1 // Copyright 2011 the V8 project authors. All rights reserved. | 1 // Copyright 2011 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 1014 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1025 }; | 1025 }; |
1026 | 1026 |
1027 | 1027 |
1028 class VariableProxy: public Expression { | 1028 class VariableProxy: public Expression { |
1029 public: | 1029 public: |
1030 explicit VariableProxy(Variable* var); | 1030 explicit VariableProxy(Variable* var); |
1031 | 1031 |
1032 DECLARE_NODE_TYPE(VariableProxy) | 1032 DECLARE_NODE_TYPE(VariableProxy) |
1033 | 1033 |
1034 // Type testing & conversion | 1034 // Type testing & conversion |
1035 virtual Property* AsProperty() { | 1035 Variable* AsVariable() { return (this == NULL) ? NULL : var_; } |
1036 return var_ == NULL ? NULL : var_->AsProperty(); | |
1037 } | |
1038 | |
1039 Variable* AsVariable() { | |
1040 if (this == NULL || var_ == NULL) return NULL; | |
1041 Expression* rewrite = var_->rewrite(); | |
1042 if (rewrite == NULL || rewrite->AsSlot() != NULL) return var_; | |
1043 return NULL; | |
1044 } | |
1045 | 1036 |
1046 virtual bool IsValidLeftHandSide() { | 1037 virtual bool IsValidLeftHandSide() { |
1047 return var_ == NULL ? true : var_->IsValidLeftHandSide(); | 1038 return var_ == NULL ? true : var_->IsValidLeftHandSide(); |
1048 } | 1039 } |
1049 | 1040 |
1050 virtual bool IsTrivial() { | 1041 virtual bool IsTrivial() { |
1051 // Reading from a mutable variable is a side effect, but the | 1042 // Reading from a mutable variable is a side effect, but the |
1052 // variable for 'this' is immutable. | 1043 // variable for 'this' is immutable. |
1053 return is_this_ || is_trivial_; | 1044 return is_this_ || is_trivial_; |
1054 } | 1045 } |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1163 Property(Expression* obj, Expression* key, int pos, Type type = NORMAL) | 1154 Property(Expression* obj, Expression* key, int pos, Type type = NORMAL) |
1164 : obj_(obj), | 1155 : obj_(obj), |
1165 key_(key), | 1156 key_(key), |
1166 pos_(pos), | 1157 pos_(pos), |
1167 type_(type), | 1158 type_(type), |
1168 receiver_types_(NULL), | 1159 receiver_types_(NULL), |
1169 is_monomorphic_(false), | 1160 is_monomorphic_(false), |
1170 is_array_length_(false), | 1161 is_array_length_(false), |
1171 is_string_length_(false), | 1162 is_string_length_(false), |
1172 is_string_access_(false), | 1163 is_string_access_(false), |
1173 is_function_prototype_(false), | 1164 is_function_prototype_(false) { } |
1174 is_arguments_access_(false) { } | |
1175 | 1165 |
1176 DECLARE_NODE_TYPE(Property) | 1166 DECLARE_NODE_TYPE(Property) |
1177 | 1167 |
1178 virtual bool IsValidLeftHandSide() { return true; } | 1168 virtual bool IsValidLeftHandSide() { return true; } |
1179 virtual bool IsInlineable() const; | 1169 virtual bool IsInlineable() const; |
1180 | 1170 |
1181 Expression* obj() const { return obj_; } | 1171 Expression* obj() const { return obj_; } |
1182 Expression* key() const { return key_; } | 1172 Expression* key() const { return key_; } |
1183 virtual int position() const { return pos_; } | 1173 virtual int position() const { return pos_; } |
1184 bool is_synthetic() const { return type_ == SYNTHETIC; } | 1174 bool is_synthetic() const { return type_ == SYNTHETIC; } |
1185 | 1175 |
1186 bool IsStringLength() const { return is_string_length_; } | 1176 bool IsStringLength() const { return is_string_length_; } |
1187 bool IsStringAccess() const { return is_string_access_; } | 1177 bool IsStringAccess() const { return is_string_access_; } |
1188 bool IsFunctionPrototype() const { return is_function_prototype_; } | 1178 bool IsFunctionPrototype() const { return is_function_prototype_; } |
1189 | 1179 |
1190 // Marks that this is actually an argument rewritten to a keyed property | |
1191 // accessing the argument through the arguments shadow object. | |
1192 void set_is_arguments_access(bool is_arguments_access) { | |
1193 is_arguments_access_ = is_arguments_access; | |
1194 } | |
1195 bool is_arguments_access() const { return is_arguments_access_; } | |
1196 | |
1197 // Type feedback information. | 1180 // Type feedback information. |
1198 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1181 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
1199 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1182 virtual bool IsMonomorphic() { return is_monomorphic_; } |
1200 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } | 1183 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } |
1201 virtual bool IsArrayLength() { return is_array_length_; } | 1184 virtual bool IsArrayLength() { return is_array_length_; } |
1202 virtual Handle<Map> GetMonomorphicReceiverType() { | 1185 virtual Handle<Map> GetMonomorphicReceiverType() { |
1203 return monomorphic_receiver_type_; | 1186 return monomorphic_receiver_type_; |
1204 } | 1187 } |
1205 | 1188 |
1206 private: | 1189 private: |
1207 Expression* obj_; | 1190 Expression* obj_; |
1208 Expression* key_; | 1191 Expression* key_; |
1209 int pos_; | 1192 int pos_; |
1210 Type type_; | 1193 Type type_; |
1211 | 1194 |
1212 ZoneMapList* receiver_types_; | 1195 ZoneMapList* receiver_types_; |
1213 bool is_monomorphic_ : 1; | 1196 bool is_monomorphic_ : 1; |
1214 bool is_array_length_ : 1; | 1197 bool is_array_length_ : 1; |
1215 bool is_string_length_ : 1; | 1198 bool is_string_length_ : 1; |
1216 bool is_string_access_ : 1; | 1199 bool is_string_access_ : 1; |
1217 bool is_function_prototype_ : 1; | 1200 bool is_function_prototype_ : 1; |
1218 bool is_arguments_access_ : 1; | |
1219 Handle<Map> monomorphic_receiver_type_; | 1201 Handle<Map> monomorphic_receiver_type_; |
1220 }; | 1202 }; |
1221 | 1203 |
1222 | 1204 |
1223 class Call: public Expression { | 1205 class Call: public Expression { |
1224 public: | 1206 public: |
1225 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) | 1207 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
1226 : expression_(expression), | 1208 : expression_(expression), |
1227 arguments_(arguments), | 1209 arguments_(arguments), |
1228 pos_(pos), | 1210 pos_(pos), |
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1641 FunctionLiteral(Handle<String> name, | 1623 FunctionLiteral(Handle<String> name, |
1642 Scope* scope, | 1624 Scope* scope, |
1643 ZoneList<Statement*>* body, | 1625 ZoneList<Statement*>* body, |
1644 int materialized_literal_count, | 1626 int materialized_literal_count, |
1645 int expected_property_count, | 1627 int expected_property_count, |
1646 bool has_only_simple_this_property_assignments, | 1628 bool has_only_simple_this_property_assignments, |
1647 Handle<FixedArray> this_property_assignments, | 1629 Handle<FixedArray> this_property_assignments, |
1648 int num_parameters, | 1630 int num_parameters, |
1649 int start_position, | 1631 int start_position, |
1650 int end_position, | 1632 int end_position, |
1651 bool is_expression) | 1633 bool is_expression, |
| 1634 bool has_duplicate_parameters) |
1652 : name_(name), | 1635 : name_(name), |
1653 scope_(scope), | 1636 scope_(scope), |
1654 body_(body), | 1637 body_(body), |
1655 materialized_literal_count_(materialized_literal_count), | 1638 materialized_literal_count_(materialized_literal_count), |
1656 expected_property_count_(expected_property_count), | 1639 expected_property_count_(expected_property_count), |
1657 has_only_simple_this_property_assignments_( | 1640 has_only_simple_this_property_assignments_( |
1658 has_only_simple_this_property_assignments), | 1641 has_only_simple_this_property_assignments), |
1659 this_property_assignments_(this_property_assignments), | 1642 this_property_assignments_(this_property_assignments), |
1660 num_parameters_(num_parameters), | 1643 num_parameters_(num_parameters), |
1661 start_position_(start_position), | 1644 start_position_(start_position), |
1662 end_position_(end_position), | 1645 end_position_(end_position), |
1663 is_expression_(is_expression), | |
1664 function_token_position_(RelocInfo::kNoPosition), | 1646 function_token_position_(RelocInfo::kNoPosition), |
1665 inferred_name_(HEAP->empty_string()), | 1647 inferred_name_(HEAP->empty_string()), |
1666 pretenure_(false) { } | 1648 is_expression_(is_expression), |
| 1649 pretenure_(false), |
| 1650 has_duplicate_parameters_(has_duplicate_parameters) { |
| 1651 } |
1667 | 1652 |
1668 DECLARE_NODE_TYPE(FunctionLiteral) | 1653 DECLARE_NODE_TYPE(FunctionLiteral) |
1669 | 1654 |
1670 Handle<String> name() const { return name_; } | 1655 Handle<String> name() const { return name_; } |
1671 Scope* scope() const { return scope_; } | 1656 Scope* scope() const { return scope_; } |
1672 ZoneList<Statement*>* body() const { return body_; } | 1657 ZoneList<Statement*>* body() const { return body_; } |
1673 void set_function_token_position(int pos) { function_token_position_ = pos; } | 1658 void set_function_token_position(int pos) { function_token_position_ = pos; } |
1674 int function_token_position() const { return function_token_position_; } | 1659 int function_token_position() const { return function_token_position_; } |
1675 int start_position() const { return start_position_; } | 1660 int start_position() const { return start_position_; } |
1676 int end_position() const { return end_position_; } | 1661 int end_position() const { return end_position_; } |
(...skipping 19 matching lines...) Expand all Loading... |
1696 | 1681 |
1697 Handle<String> inferred_name() const { return inferred_name_; } | 1682 Handle<String> inferred_name() const { return inferred_name_; } |
1698 void set_inferred_name(Handle<String> inferred_name) { | 1683 void set_inferred_name(Handle<String> inferred_name) { |
1699 inferred_name_ = inferred_name; | 1684 inferred_name_ = inferred_name; |
1700 } | 1685 } |
1701 | 1686 |
1702 bool pretenure() { return pretenure_; } | 1687 bool pretenure() { return pretenure_; } |
1703 void set_pretenure(bool value) { pretenure_ = value; } | 1688 void set_pretenure(bool value) { pretenure_ = value; } |
1704 virtual bool IsInlineable() const; | 1689 virtual bool IsInlineable() const; |
1705 | 1690 |
| 1691 bool has_duplicate_parameters() { return has_duplicate_parameters_; } |
| 1692 |
1706 private: | 1693 private: |
1707 Handle<String> name_; | 1694 Handle<String> name_; |
1708 Scope* scope_; | 1695 Scope* scope_; |
1709 ZoneList<Statement*>* body_; | 1696 ZoneList<Statement*>* body_; |
1710 int materialized_literal_count_; | 1697 int materialized_literal_count_; |
1711 int expected_property_count_; | 1698 int expected_property_count_; |
1712 bool has_only_simple_this_property_assignments_; | 1699 bool has_only_simple_this_property_assignments_; |
1713 Handle<FixedArray> this_property_assignments_; | 1700 Handle<FixedArray> this_property_assignments_; |
1714 int num_parameters_; | 1701 int num_parameters_; |
1715 int start_position_; | 1702 int start_position_; |
1716 int end_position_; | 1703 int end_position_; |
1717 bool is_expression_; | |
1718 int function_token_position_; | 1704 int function_token_position_; |
1719 Handle<String> inferred_name_; | 1705 Handle<String> inferred_name_; |
| 1706 bool is_expression_; |
1720 bool pretenure_; | 1707 bool pretenure_; |
| 1708 bool has_duplicate_parameters_; |
1721 }; | 1709 }; |
1722 | 1710 |
1723 | 1711 |
1724 class SharedFunctionInfoLiteral: public Expression { | 1712 class SharedFunctionInfoLiteral: public Expression { |
1725 public: | 1713 public: |
1726 explicit SharedFunctionInfoLiteral( | 1714 explicit SharedFunctionInfoLiteral( |
1727 Handle<SharedFunctionInfo> shared_function_info) | 1715 Handle<SharedFunctionInfo> shared_function_info) |
1728 : shared_function_info_(shared_function_info) { } | 1716 : shared_function_info_(shared_function_info) { } |
1729 | 1717 |
1730 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) | 1718 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2167 | 2155 |
2168 private: | 2156 private: |
2169 Isolate* isolate_; | 2157 Isolate* isolate_; |
2170 bool stack_overflow_; | 2158 bool stack_overflow_; |
2171 }; | 2159 }; |
2172 | 2160 |
2173 | 2161 |
2174 } } // namespace v8::internal | 2162 } } // namespace v8::internal |
2175 | 2163 |
2176 #endif // V8_AST_H_ | 2164 #endif // V8_AST_H_ |
OLD | NEW |