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