| 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 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 203 // code generation. | 203 // code generation. |
| 204 kUninitialized, | 204 kUninitialized, |
| 205 // Evaluated for its side effects. | 205 // Evaluated for its side effects. |
| 206 kEffect, | 206 kEffect, |
| 207 // Evaluated for its value (and side effects). | 207 // Evaluated for its value (and side effects). |
| 208 kValue, | 208 kValue, |
| 209 // Evaluated for control flow (and side effects). | 209 // Evaluated for control flow (and side effects). |
| 210 kTest | 210 kTest |
| 211 }; | 211 }; |
| 212 | 212 |
| 213 Expression() : id_(GetNextId()) {} | 213 Expression() : id_(GetNextId()), test_id_(GetNextId()) {} |
| 214 | 214 |
| 215 virtual int position() const { | 215 virtual int position() const { |
| 216 UNREACHABLE(); | 216 UNREACHABLE(); |
| 217 return 0; | 217 return 0; |
| 218 } | 218 } |
| 219 | 219 |
| 220 virtual Expression* AsExpression() { return this; } | 220 virtual Expression* AsExpression() { return this; } |
| 221 | 221 |
| 222 virtual bool IsTrivial() { return false; } | 222 virtual bool IsTrivial() { return false; } |
| 223 virtual bool IsValidLeftHandSide() { return false; } | 223 virtual bool IsValidLeftHandSide() { return false; } |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 virtual ZoneMapList* GetReceiverTypes() { | 255 virtual ZoneMapList* GetReceiverTypes() { |
| 256 UNREACHABLE(); | 256 UNREACHABLE(); |
| 257 return NULL; | 257 return NULL; |
| 258 } | 258 } |
| 259 virtual Handle<Map> GetMonomorphicReceiverType() { | 259 virtual Handle<Map> GetMonomorphicReceiverType() { |
| 260 UNREACHABLE(); | 260 UNREACHABLE(); |
| 261 return Handle<Map>(); | 261 return Handle<Map>(); |
| 262 } | 262 } |
| 263 | 263 |
| 264 unsigned id() const { return id_; } | 264 unsigned id() const { return id_; } |
| 265 unsigned test_id() const { return test_id_; } |
| 265 | 266 |
| 266 private: | 267 private: |
| 267 unsigned id_; | 268 unsigned id_; |
| 269 unsigned test_id_; |
| 268 }; | 270 }; |
| 269 | 271 |
| 270 | 272 |
| 271 /** | 273 /** |
| 272 * A sentinel used during pre parsing that represents some expression | 274 * A sentinel used during pre parsing that represents some expression |
| 273 * that is a valid left hand side without having to actually build | 275 * that is a valid left hand side without having to actually build |
| 274 * the expression. | 276 * the expression. |
| 275 */ | 277 */ |
| 276 class ValidLeftHandSideSentinel: public Expression { | 278 class ValidLeftHandSideSentinel: public Expression { |
| 277 public: | 279 public: |
| (...skipping 745 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1023 }; | 1025 }; |
| 1024 | 1026 |
| 1025 | 1027 |
| 1026 class VariableProxy: public Expression { | 1028 class VariableProxy: public Expression { |
| 1027 public: | 1029 public: |
| 1028 explicit VariableProxy(Variable* var); | 1030 explicit VariableProxy(Variable* var); |
| 1029 | 1031 |
| 1030 DECLARE_NODE_TYPE(VariableProxy) | 1032 DECLARE_NODE_TYPE(VariableProxy) |
| 1031 | 1033 |
| 1032 // Type testing & conversion | 1034 // Type testing & conversion |
| 1033 Variable* AsVariable() { return (this == NULL) ? NULL : var_; } | 1035 virtual Property* AsProperty() { |
| 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 } |
| 1034 | 1045 |
| 1035 virtual bool IsValidLeftHandSide() { | 1046 virtual bool IsValidLeftHandSide() { |
| 1036 return var_ == NULL ? true : var_->IsValidLeftHandSide(); | 1047 return var_ == NULL ? true : var_->IsValidLeftHandSide(); |
| 1037 } | 1048 } |
| 1038 | 1049 |
| 1039 virtual bool IsTrivial() { | 1050 virtual bool IsTrivial() { |
| 1040 // Reading from a mutable variable is a side effect, but the | 1051 // Reading from a mutable variable is a side effect, but the |
| 1041 // variable for 'this' is immutable. | 1052 // variable for 'this' is immutable. |
| 1042 return is_this_ || is_trivial_; | 1053 return is_this_ || is_trivial_; |
| 1043 } | 1054 } |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1152 Property(Expression* obj, Expression* key, int pos, Type type = NORMAL) | 1163 Property(Expression* obj, Expression* key, int pos, Type type = NORMAL) |
| 1153 : obj_(obj), | 1164 : obj_(obj), |
| 1154 key_(key), | 1165 key_(key), |
| 1155 pos_(pos), | 1166 pos_(pos), |
| 1156 type_(type), | 1167 type_(type), |
| 1157 receiver_types_(NULL), | 1168 receiver_types_(NULL), |
| 1158 is_monomorphic_(false), | 1169 is_monomorphic_(false), |
| 1159 is_array_length_(false), | 1170 is_array_length_(false), |
| 1160 is_string_length_(false), | 1171 is_string_length_(false), |
| 1161 is_string_access_(false), | 1172 is_string_access_(false), |
| 1162 is_function_prototype_(false) { } | 1173 is_function_prototype_(false), |
| 1174 is_arguments_access_(false) { } |
| 1163 | 1175 |
| 1164 DECLARE_NODE_TYPE(Property) | 1176 DECLARE_NODE_TYPE(Property) |
| 1165 | 1177 |
| 1166 virtual bool IsValidLeftHandSide() { return true; } | 1178 virtual bool IsValidLeftHandSide() { return true; } |
| 1167 virtual bool IsInlineable() const; | 1179 virtual bool IsInlineable() const; |
| 1168 | 1180 |
| 1169 Expression* obj() const { return obj_; } | 1181 Expression* obj() const { return obj_; } |
| 1170 Expression* key() const { return key_; } | 1182 Expression* key() const { return key_; } |
| 1171 virtual int position() const { return pos_; } | 1183 virtual int position() const { return pos_; } |
| 1172 bool is_synthetic() const { return type_ == SYNTHETIC; } | 1184 bool is_synthetic() const { return type_ == SYNTHETIC; } |
| 1173 | 1185 |
| 1174 bool IsStringLength() const { return is_string_length_; } | 1186 bool IsStringLength() const { return is_string_length_; } |
| 1175 bool IsStringAccess() const { return is_string_access_; } | 1187 bool IsStringAccess() const { return is_string_access_; } |
| 1176 bool IsFunctionPrototype() const { return is_function_prototype_; } | 1188 bool IsFunctionPrototype() const { return is_function_prototype_; } |
| 1177 | 1189 |
| 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 |
| 1178 // Type feedback information. | 1197 // Type feedback information. |
| 1179 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1198 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
| 1180 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1199 virtual bool IsMonomorphic() { return is_monomorphic_; } |
| 1181 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } | 1200 virtual ZoneMapList* GetReceiverTypes() { return receiver_types_; } |
| 1182 virtual bool IsArrayLength() { return is_array_length_; } | 1201 virtual bool IsArrayLength() { return is_array_length_; } |
| 1183 virtual Handle<Map> GetMonomorphicReceiverType() { | 1202 virtual Handle<Map> GetMonomorphicReceiverType() { |
| 1184 return monomorphic_receiver_type_; | 1203 return monomorphic_receiver_type_; |
| 1185 } | 1204 } |
| 1186 | 1205 |
| 1187 private: | 1206 private: |
| 1188 Expression* obj_; | 1207 Expression* obj_; |
| 1189 Expression* key_; | 1208 Expression* key_; |
| 1190 int pos_; | 1209 int pos_; |
| 1191 Type type_; | 1210 Type type_; |
| 1192 | 1211 |
| 1193 ZoneMapList* receiver_types_; | 1212 ZoneMapList* receiver_types_; |
| 1194 bool is_monomorphic_ : 1; | 1213 bool is_monomorphic_ : 1; |
| 1195 bool is_array_length_ : 1; | 1214 bool is_array_length_ : 1; |
| 1196 bool is_string_length_ : 1; | 1215 bool is_string_length_ : 1; |
| 1197 bool is_string_access_ : 1; | 1216 bool is_string_access_ : 1; |
| 1198 bool is_function_prototype_ : 1; | 1217 bool is_function_prototype_ : 1; |
| 1218 bool is_arguments_access_ : 1; |
| 1199 Handle<Map> monomorphic_receiver_type_; | 1219 Handle<Map> monomorphic_receiver_type_; |
| 1200 }; | 1220 }; |
| 1201 | 1221 |
| 1202 | 1222 |
| 1203 class Call: public Expression { | 1223 class Call: public Expression { |
| 1204 public: | 1224 public: |
| 1205 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) | 1225 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
| 1206 : expression_(expression), | 1226 : expression_(expression), |
| 1207 arguments_(arguments), | 1227 arguments_(arguments), |
| 1208 pos_(pos), | 1228 pos_(pos), |
| (...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1621 FunctionLiteral(Handle<String> name, | 1641 FunctionLiteral(Handle<String> name, |
| 1622 Scope* scope, | 1642 Scope* scope, |
| 1623 ZoneList<Statement*>* body, | 1643 ZoneList<Statement*>* body, |
| 1624 int materialized_literal_count, | 1644 int materialized_literal_count, |
| 1625 int expected_property_count, | 1645 int expected_property_count, |
| 1626 bool has_only_simple_this_property_assignments, | 1646 bool has_only_simple_this_property_assignments, |
| 1627 Handle<FixedArray> this_property_assignments, | 1647 Handle<FixedArray> this_property_assignments, |
| 1628 int num_parameters, | 1648 int num_parameters, |
| 1629 int start_position, | 1649 int start_position, |
| 1630 int end_position, | 1650 int end_position, |
| 1631 bool is_expression, | 1651 bool is_expression) |
| 1632 bool has_duplicate_parameters) | |
| 1633 : name_(name), | 1652 : name_(name), |
| 1634 scope_(scope), | 1653 scope_(scope), |
| 1635 body_(body), | 1654 body_(body), |
| 1636 materialized_literal_count_(materialized_literal_count), | 1655 materialized_literal_count_(materialized_literal_count), |
| 1637 expected_property_count_(expected_property_count), | 1656 expected_property_count_(expected_property_count), |
| 1638 has_only_simple_this_property_assignments_( | 1657 has_only_simple_this_property_assignments_( |
| 1639 has_only_simple_this_property_assignments), | 1658 has_only_simple_this_property_assignments), |
| 1640 this_property_assignments_(this_property_assignments), | 1659 this_property_assignments_(this_property_assignments), |
| 1641 num_parameters_(num_parameters), | 1660 num_parameters_(num_parameters), |
| 1642 start_position_(start_position), | 1661 start_position_(start_position), |
| 1643 end_position_(end_position), | 1662 end_position_(end_position), |
| 1663 is_expression_(is_expression), |
| 1644 function_token_position_(RelocInfo::kNoPosition), | 1664 function_token_position_(RelocInfo::kNoPosition), |
| 1645 inferred_name_(HEAP->empty_string()), | 1665 inferred_name_(HEAP->empty_string()), |
| 1646 is_expression_(is_expression), | 1666 pretenure_(false) { } |
| 1647 pretenure_(false), | |
| 1648 has_duplicate_parameters_(has_duplicate_parameters) { | |
| 1649 } | |
| 1650 | 1667 |
| 1651 DECLARE_NODE_TYPE(FunctionLiteral) | 1668 DECLARE_NODE_TYPE(FunctionLiteral) |
| 1652 | 1669 |
| 1653 Handle<String> name() const { return name_; } | 1670 Handle<String> name() const { return name_; } |
| 1654 Scope* scope() const { return scope_; } | 1671 Scope* scope() const { return scope_; } |
| 1655 ZoneList<Statement*>* body() const { return body_; } | 1672 ZoneList<Statement*>* body() const { return body_; } |
| 1656 void set_function_token_position(int pos) { function_token_position_ = pos; } | 1673 void set_function_token_position(int pos) { function_token_position_ = pos; } |
| 1657 int function_token_position() const { return function_token_position_; } | 1674 int function_token_position() const { return function_token_position_; } |
| 1658 int start_position() const { return start_position_; } | 1675 int start_position() const { return start_position_; } |
| 1659 int end_position() const { return end_position_; } | 1676 int end_position() const { return end_position_; } |
| (...skipping 19 matching lines...) Expand all Loading... |
| 1679 | 1696 |
| 1680 Handle<String> inferred_name() const { return inferred_name_; } | 1697 Handle<String> inferred_name() const { return inferred_name_; } |
| 1681 void set_inferred_name(Handle<String> inferred_name) { | 1698 void set_inferred_name(Handle<String> inferred_name) { |
| 1682 inferred_name_ = inferred_name; | 1699 inferred_name_ = inferred_name; |
| 1683 } | 1700 } |
| 1684 | 1701 |
| 1685 bool pretenure() { return pretenure_; } | 1702 bool pretenure() { return pretenure_; } |
| 1686 void set_pretenure(bool value) { pretenure_ = value; } | 1703 void set_pretenure(bool value) { pretenure_ = value; } |
| 1687 virtual bool IsInlineable() const; | 1704 virtual bool IsInlineable() const; |
| 1688 | 1705 |
| 1689 bool has_duplicate_parameters() { return has_duplicate_parameters_; } | |
| 1690 | |
| 1691 private: | 1706 private: |
| 1692 Handle<String> name_; | 1707 Handle<String> name_; |
| 1693 Scope* scope_; | 1708 Scope* scope_; |
| 1694 ZoneList<Statement*>* body_; | 1709 ZoneList<Statement*>* body_; |
| 1695 int materialized_literal_count_; | 1710 int materialized_literal_count_; |
| 1696 int expected_property_count_; | 1711 int expected_property_count_; |
| 1697 bool has_only_simple_this_property_assignments_; | 1712 bool has_only_simple_this_property_assignments_; |
| 1698 Handle<FixedArray> this_property_assignments_; | 1713 Handle<FixedArray> this_property_assignments_; |
| 1699 int num_parameters_; | 1714 int num_parameters_; |
| 1700 int start_position_; | 1715 int start_position_; |
| 1701 int end_position_; | 1716 int end_position_; |
| 1717 bool is_expression_; |
| 1702 int function_token_position_; | 1718 int function_token_position_; |
| 1703 Handle<String> inferred_name_; | 1719 Handle<String> inferred_name_; |
| 1704 bool is_expression_; | |
| 1705 bool pretenure_; | 1720 bool pretenure_; |
| 1706 bool has_duplicate_parameters_; | |
| 1707 }; | 1721 }; |
| 1708 | 1722 |
| 1709 | 1723 |
| 1710 class SharedFunctionInfoLiteral: public Expression { | 1724 class SharedFunctionInfoLiteral: public Expression { |
| 1711 public: | 1725 public: |
| 1712 explicit SharedFunctionInfoLiteral( | 1726 explicit SharedFunctionInfoLiteral( |
| 1713 Handle<SharedFunctionInfo> shared_function_info) | 1727 Handle<SharedFunctionInfo> shared_function_info) |
| 1714 : shared_function_info_(shared_function_info) { } | 1728 : shared_function_info_(shared_function_info) { } |
| 1715 | 1729 |
| 1716 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) | 1730 DECLARE_NODE_TYPE(SharedFunctionInfoLiteral) |
| (...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2153 | 2167 |
| 2154 private: | 2168 private: |
| 2155 Isolate* isolate_; | 2169 Isolate* isolate_; |
| 2156 bool stack_overflow_; | 2170 bool stack_overflow_; |
| 2157 }; | 2171 }; |
| 2158 | 2172 |
| 2159 | 2173 |
| 2160 } } // namespace v8::internal | 2174 } } // namespace v8::internal |
| 2161 | 2175 |
| 2162 #endif // V8_AST_H_ | 2176 #endif // V8_AST_H_ |
| OLD | NEW |