OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 21 matching lines...) Expand all Loading... | |
32 | 32 |
33 #include "assembler.h" | 33 #include "assembler.h" |
34 #include "factory.h" | 34 #include "factory.h" |
35 #include "isolate.h" | 35 #include "isolate.h" |
36 #include "jsregexp.h" | 36 #include "jsregexp.h" |
37 #include "list-inl.h" | 37 #include "list-inl.h" |
38 #include "runtime.h" | 38 #include "runtime.h" |
39 #include "small-pointer-list.h" | 39 #include "small-pointer-list.h" |
40 #include "smart-pointers.h" | 40 #include "smart-pointers.h" |
41 #include "token.h" | 41 #include "token.h" |
42 #include "type-info.h" | |
42 #include "utils.h" | 43 #include "utils.h" |
43 #include "variables.h" | 44 #include "variables.h" |
44 #include "interface.h" | 45 #include "interface.h" |
45 #include "zone-inl.h" | 46 #include "zone-inl.h" |
46 | 47 |
47 namespace v8 { | 48 namespace v8 { |
48 namespace internal { | 49 namespace internal { |
49 | 50 |
50 // The abstract syntax tree is an intermediate, light-weight | 51 // The abstract syntax tree is an intermediate, light-weight |
51 // representation of the parsed JavaScript code suitable for | 52 // representation of the parsed JavaScript code suitable for |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
363 ASSERT(IsMonomorphic()); | 364 ASSERT(IsMonomorphic()); |
364 SmallMapList* types = GetReceiverTypes(); | 365 SmallMapList* types = GetReceiverTypes(); |
365 ASSERT(types != NULL && types->length() == 1); | 366 ASSERT(types != NULL && types->length() == 1); |
366 return types->at(0); | 367 return types->at(0); |
367 } | 368 } |
368 virtual KeyedAccessStoreMode GetStoreMode() { | 369 virtual KeyedAccessStoreMode GetStoreMode() { |
369 UNREACHABLE(); | 370 UNREACHABLE(); |
370 return STANDARD_STORE; | 371 return STANDARD_STORE; |
371 } | 372 } |
372 | 373 |
374 // TODO(rossberg): this should move to its own AST node eventually. | |
375 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); | |
376 byte to_boolean_types() const { return to_boolean_types_; } | |
Sven Panne
2013/05/16 11:58:05
Do we still have problems with #include cycles, so
rossberg
2013/05/17 10:59:50
Yes. But once the type representation has been uni
| |
377 | |
373 BailoutId id() const { return id_; } | 378 BailoutId id() const { return id_; } |
374 TypeFeedbackId test_id() const { return test_id_; } | 379 TypeFeedbackId test_id() const { return test_id_; } |
375 | 380 |
376 protected: | 381 protected: |
377 explicit Expression(Isolate* isolate) | 382 explicit Expression(Isolate* isolate) |
378 : id_(GetNextId(isolate)), | 383 : id_(GetNextId(isolate)), |
379 test_id_(GetNextId(isolate)) {} | 384 test_id_(GetNextId(isolate)) {} |
380 | 385 |
381 private: | 386 private: |
387 byte to_boolean_types_; | |
388 | |
382 const BailoutId id_; | 389 const BailoutId id_; |
383 const TypeFeedbackId test_id_; | 390 const TypeFeedbackId test_id_; |
384 }; | 391 }; |
385 | 392 |
386 | 393 |
387 class BreakableStatement: public Statement { | 394 class BreakableStatement: public Statement { |
388 public: | 395 public: |
389 enum Type { | 396 enum Type { |
390 TARGET_FOR_ANONYMOUS, | 397 TARGET_FOR_ANONYMOUS, |
391 TARGET_FOR_NAMED_ONLY | 398 TARGET_FOR_NAMED_ONLY |
(...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
849 | 856 |
850 | 857 |
851 class ForInStatement: public IterationStatement { | 858 class ForInStatement: public IterationStatement { |
852 public: | 859 public: |
853 DECLARE_NODE_TYPE(ForInStatement) | 860 DECLARE_NODE_TYPE(ForInStatement) |
854 | 861 |
855 void Initialize(Expression* each, Expression* enumerable, Statement* body) { | 862 void Initialize(Expression* each, Expression* enumerable, Statement* body) { |
856 IterationStatement::Initialize(body); | 863 IterationStatement::Initialize(body); |
857 each_ = each; | 864 each_ = each; |
858 enumerable_ = enumerable; | 865 enumerable_ = enumerable; |
866 for_in_type_ = SLOW_FOR_IN; | |
859 } | 867 } |
860 | 868 |
861 Expression* each() const { return each_; } | 869 Expression* each() const { return each_; } |
862 Expression* enumerable() const { return enumerable_; } | 870 Expression* enumerable() const { return enumerable_; } |
863 | 871 |
864 virtual BailoutId ContinueId() const { return EntryId(); } | 872 virtual BailoutId ContinueId() const { return EntryId(); } |
865 virtual BailoutId StackCheckId() const { return body_id_; } | 873 virtual BailoutId StackCheckId() const { return body_id_; } |
866 BailoutId BodyId() const { return body_id_; } | 874 BailoutId BodyId() const { return body_id_; } |
867 BailoutId PrepareId() const { return prepare_id_; } | 875 BailoutId PrepareId() const { return prepare_id_; } |
868 | 876 |
869 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } | 877 TypeFeedbackId ForInFeedbackId() const { return reuse(PrepareId()); } |
878 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | |
879 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | |
880 ForInType for_in_type() const { return for_in_type_; } | |
870 | 881 |
871 protected: | 882 protected: |
872 ForInStatement(Isolate* isolate, ZoneStringList* labels) | 883 ForInStatement(Isolate* isolate, ZoneStringList* labels) |
873 : IterationStatement(isolate, labels), | 884 : IterationStatement(isolate, labels), |
874 each_(NULL), | 885 each_(NULL), |
875 enumerable_(NULL), | 886 enumerable_(NULL), |
876 body_id_(GetNextId(isolate)), | 887 body_id_(GetNextId(isolate)), |
877 prepare_id_(GetNextId(isolate)) { | 888 prepare_id_(GetNextId(isolate)) { |
878 } | 889 } |
879 | 890 |
880 private: | 891 private: |
881 Expression* each_; | 892 Expression* each_; |
882 Expression* enumerable_; | 893 Expression* enumerable_; |
883 const BailoutId body_id_; | 894 const BailoutId body_id_; |
884 const BailoutId prepare_id_; | 895 const BailoutId prepare_id_; |
896 ForInType for_in_type_; | |
Sven Panne
2013/05/16 11:58:05
Can we keep the fields and methods in a common ord
rossberg
2013/05/17 10:59:50
Done here and in a number of other places.
| |
885 }; | 897 }; |
886 | 898 |
887 | 899 |
888 class ExpressionStatement: public Statement { | 900 class ExpressionStatement: public Statement { |
889 public: | 901 public: |
890 DECLARE_NODE_TYPE(ExpressionStatement) | 902 DECLARE_NODE_TYPE(ExpressionStatement) |
891 | 903 |
892 void set_expression(Expression* e) { expression_ = e; } | 904 void set_expression(Expression* e) { expression_ = e; } |
893 Expression* expression() const { return expression_; } | 905 Expression* expression() const { return expression_; } |
894 | 906 |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1013 }; | 1025 }; |
1014 | 1026 |
1015 | 1027 |
1016 class SwitchStatement: public BreakableStatement { | 1028 class SwitchStatement: public BreakableStatement { |
1017 public: | 1029 public: |
1018 DECLARE_NODE_TYPE(SwitchStatement) | 1030 DECLARE_NODE_TYPE(SwitchStatement) |
1019 | 1031 |
1020 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 1032 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
1021 tag_ = tag; | 1033 tag_ = tag; |
1022 cases_ = cases; | 1034 cases_ = cases; |
1035 switch_type_ = UNKNOWN_SWITCH; | |
1023 } | 1036 } |
1024 | 1037 |
1025 Expression* tag() const { return tag_; } | 1038 Expression* tag() const { return tag_; } |
1026 ZoneList<CaseClause*>* cases() const { return cases_; } | 1039 ZoneList<CaseClause*>* cases() const { return cases_; } |
1027 | 1040 |
1041 enum SwitchType { UNKNOWN_SWITCH, SMI_SWITCH, STRING_SWITCH, GENERIC_SWITCH }; | |
1042 SwitchType switch_type() const { return switch_type_; } | |
1043 void set_switch_type(SwitchType switch_type) { switch_type_ = switch_type; } | |
1044 | |
1028 protected: | 1045 protected: |
1029 SwitchStatement(Isolate* isolate, ZoneStringList* labels) | 1046 SwitchStatement(Isolate* isolate, ZoneStringList* labels) |
1030 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS), | 1047 : BreakableStatement(isolate, labels, TARGET_FOR_ANONYMOUS), |
1031 tag_(NULL), | 1048 tag_(NULL), |
1032 cases_(NULL) { } | 1049 cases_(NULL) { } |
1033 | 1050 |
1034 private: | 1051 private: |
1035 Expression* tag_; | 1052 Expression* tag_; |
1036 ZoneList<CaseClause*>* cases_; | 1053 ZoneList<CaseClause*>* cases_; |
1054 SwitchType switch_type_; | |
1037 }; | 1055 }; |
1038 | 1056 |
1039 | 1057 |
1040 // If-statements always have non-null references to their then- and | 1058 // If-statements always have non-null references to their then- and |
1041 // else-parts. When parsing if-statements with no explicit else-part, | 1059 // else-parts. When parsing if-statements with no explicit else-part, |
1042 // the parser implicitly creates an empty statement. Use the | 1060 // the parser implicitly creates an empty statement. Use the |
1043 // HasThenStatement() and HasElseStatement() functions to check if a | 1061 // HasThenStatement() and HasElseStatement() functions to check if a |
1044 // given if-statement has a then- or an else-part containing code. | 1062 // given if-statement has a then- or an else-part containing code. |
1045 class IfStatement: public Statement { | 1063 class IfStatement: public Statement { |
1046 public: | 1064 public: |
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1272 is_simple_(is_simple), | 1290 is_simple_(is_simple), |
1273 depth_(depth) {} | 1291 depth_(depth) {} |
1274 | 1292 |
1275 private: | 1293 private: |
1276 int literal_index_; | 1294 int literal_index_; |
1277 bool is_simple_; | 1295 bool is_simple_; |
1278 int depth_; | 1296 int depth_; |
1279 }; | 1297 }; |
1280 | 1298 |
1281 | 1299 |
1300 // Property is used for passing information | |
1301 // about an object literal's properties from the parser | |
1302 // to the code generator. | |
1303 class ObjectLiteralProperty: public ZoneObject { | |
1304 public: | |
1305 enum Kind { | |
1306 CONSTANT, // Property with constant value (compile time). | |
1307 COMPUTED, // Property with computed value (execution time). | |
1308 MATERIALIZED_LITERAL, // Property value is a materialized literal. | |
1309 GETTER, SETTER, // Property is an accessor function. | |
1310 PROTOTYPE // Property is __proto__. | |
1311 }; | |
1312 | |
1313 ObjectLiteralProperty(Literal* key, Expression* value, Isolate* isolate); | |
1314 | |
1315 Literal* key() { return key_; } | |
1316 Expression* value() { return value_; } | |
1317 Kind kind() { return kind_; } | |
1318 | |
1319 // Type feedback information. | |
1320 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | |
1321 bool IsMonomorphic() { return !receiver_type_.is_null(); } | |
1322 Handle<Map> GetReceiverType() { return receiver_type_; } | |
1323 | |
1324 bool IsCompileTimeValue(); | |
1325 | |
1326 void set_emit_store(bool emit_store); | |
1327 bool emit_store(); | |
1328 | |
1329 protected: | |
1330 template<class> friend class AstNodeFactory; | |
1331 | |
1332 ObjectLiteralProperty(bool is_getter, FunctionLiteral* value); | |
1333 void set_key(Literal* key) { key_ = key; } | |
1334 | |
1335 private: | |
1336 Literal* key_; | |
1337 Expression* value_; | |
1338 Kind kind_; | |
1339 bool emit_store_; | |
1340 Handle<Map> receiver_type_; | |
1341 }; | |
1342 | |
1343 | |
1282 // An object literal has a boilerplate object that is used | 1344 // An object literal has a boilerplate object that is used |
1283 // for minimizing the work when constructing it at runtime. | 1345 // for minimizing the work when constructing it at runtime. |
1284 class ObjectLiteral: public MaterializedLiteral { | 1346 class ObjectLiteral: public MaterializedLiteral { |
1285 public: | 1347 public: |
1286 // Property is used for passing information | 1348 typedef ObjectLiteralProperty Property; |
1287 // about an object literal's properties from the parser | |
1288 // to the code generator. | |
1289 class Property: public ZoneObject { | |
1290 public: | |
1291 enum Kind { | |
1292 CONSTANT, // Property with constant value (compile time). | |
1293 COMPUTED, // Property with computed value (execution time). | |
1294 MATERIALIZED_LITERAL, // Property value is a materialized literal. | |
1295 GETTER, SETTER, // Property is an accessor function. | |
1296 PROTOTYPE // Property is __proto__. | |
1297 }; | |
1298 | |
1299 Property(Literal* key, Expression* value, Isolate* isolate); | |
1300 | |
1301 Literal* key() { return key_; } | |
1302 Expression* value() { return value_; } | |
1303 Kind kind() { return kind_; } | |
1304 | |
1305 // Type feedback information. | |
1306 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | |
1307 bool IsMonomorphic() { return !receiver_type_.is_null(); } | |
1308 Handle<Map> GetReceiverType() { return receiver_type_; } | |
1309 | |
1310 bool IsCompileTimeValue(); | |
1311 | |
1312 void set_emit_store(bool emit_store); | |
1313 bool emit_store(); | |
1314 | |
1315 protected: | |
1316 template<class> friend class AstNodeFactory; | |
1317 | |
1318 Property(bool is_getter, FunctionLiteral* value); | |
1319 void set_key(Literal* key) { key_ = key; } | |
1320 | |
1321 private: | |
1322 Literal* key_; | |
1323 Expression* value_; | |
1324 Kind kind_; | |
1325 bool emit_store_; | |
1326 Handle<Map> receiver_type_; | |
1327 }; | |
1328 | 1349 |
1329 DECLARE_NODE_TYPE(ObjectLiteral) | 1350 DECLARE_NODE_TYPE(ObjectLiteral) |
1330 | 1351 |
1331 Handle<FixedArray> constant_properties() const { | 1352 Handle<FixedArray> constant_properties() const { |
1332 return constant_properties_; | 1353 return constant_properties_; |
1333 } | 1354 } |
1334 ZoneList<Property*>* properties() const { return properties_; } | 1355 ZoneList<Property*>* properties() const { return properties_; } |
1335 bool fast_elements() const { return fast_elements_; } | 1356 bool fast_elements() const { return fast_elements_; } |
1336 bool may_store_doubles() const { return may_store_doubles_; } | 1357 bool may_store_doubles() const { return may_store_doubles_; } |
1337 bool has_function() const { return has_function_; } | 1358 bool has_function() const { return has_function_; } |
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1580 // as the holder! | 1601 // as the holder! |
1581 Handle<JSObject> holder() { return holder_; } | 1602 Handle<JSObject> holder() { return holder_; } |
1582 | 1603 |
1583 Handle<JSGlobalPropertyCell> cell() { return cell_; } | 1604 Handle<JSGlobalPropertyCell> cell() { return cell_; } |
1584 | 1605 |
1585 bool ComputeTarget(Handle<Map> type, Handle<String> name); | 1606 bool ComputeTarget(Handle<Map> type, Handle<String> name); |
1586 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupResult* lookup); | 1607 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupResult* lookup); |
1587 | 1608 |
1588 BailoutId ReturnId() const { return return_id_; } | 1609 BailoutId ReturnId() const { return return_id_; } |
1589 | 1610 |
1611 // TODO(rossberg): this should really move somewhere else (and be merged with | |
1612 // various similar methods in objets.cc), but for now... | |
1613 static Handle<JSObject> GetPrototypeForPrimitiveCheck( | |
1614 CheckType check, Isolate* isolate); | |
1615 | |
1590 #ifdef DEBUG | 1616 #ifdef DEBUG |
1591 // Used to assert that the FullCodeGenerator records the return site. | 1617 // Used to assert that the FullCodeGenerator records the return site. |
1592 bool return_is_recorded_; | 1618 bool return_is_recorded_; |
1593 #endif | 1619 #endif |
1594 | 1620 |
1595 protected: | 1621 protected: |
1596 Call(Isolate* isolate, | 1622 Call(Isolate* isolate, |
1597 Expression* expression, | 1623 Expression* expression, |
1598 ZoneList<Expression*>* arguments, | 1624 ZoneList<Expression*>* arguments, |
1599 int pos) | 1625 int pos) |
(...skipping 26 matching lines...) Expand all Loading... | |
1626 DECLARE_NODE_TYPE(CallNew) | 1652 DECLARE_NODE_TYPE(CallNew) |
1627 | 1653 |
1628 Expression* expression() const { return expression_; } | 1654 Expression* expression() const { return expression_; } |
1629 ZoneList<Expression*>* arguments() const { return arguments_; } | 1655 ZoneList<Expression*>* arguments() const { return arguments_; } |
1630 virtual int position() const { return pos_; } | 1656 virtual int position() const { return pos_; } |
1631 | 1657 |
1632 // Type feedback information. | 1658 // Type feedback information. |
1633 TypeFeedbackId CallNewFeedbackId() const { return reuse(id()); } | 1659 TypeFeedbackId CallNewFeedbackId() const { return reuse(id()); } |
1634 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | 1660 void RecordTypeFeedback(TypeFeedbackOracle* oracle); |
1635 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1661 virtual bool IsMonomorphic() { return is_monomorphic_; } |
1636 Handle<JSFunction> target() { return target_; } | 1662 Handle<JSFunction> target() const { return target_; } |
1663 ElementsKind elements_kind() const { return elements_kind_; } | |
1664 Handle<Smi> allocation_elements_kind() const { return alloc_elements_kind_; } | |
1637 | 1665 |
1638 BailoutId ReturnId() const { return return_id_; } | 1666 BailoutId ReturnId() const { return return_id_; } |
1639 ElementsKind elements_kind() const { return elements_kind_; } | |
1640 | 1667 |
1641 protected: | 1668 protected: |
1642 CallNew(Isolate* isolate, | 1669 CallNew(Isolate* isolate, |
1643 Expression* expression, | 1670 Expression* expression, |
1644 ZoneList<Expression*>* arguments, | 1671 ZoneList<Expression*>* arguments, |
1645 int pos) | 1672 int pos) |
1646 : Expression(isolate), | 1673 : Expression(isolate), |
1647 expression_(expression), | 1674 expression_(expression), |
1648 arguments_(arguments), | 1675 arguments_(arguments), |
1649 pos_(pos), | 1676 pos_(pos), |
1650 is_monomorphic_(false), | 1677 is_monomorphic_(false), |
1651 return_id_(GetNextId(isolate)), | 1678 elements_kind_(GetInitialFastElementsKind()), |
1652 elements_kind_(GetInitialFastElementsKind()) { } | 1679 return_id_(GetNextId(isolate)) { } |
1653 | 1680 |
1654 private: | 1681 private: |
1655 Expression* expression_; | 1682 Expression* expression_; |
1656 ZoneList<Expression*>* arguments_; | 1683 ZoneList<Expression*>* arguments_; |
1657 int pos_; | 1684 int pos_; |
1658 | 1685 |
1659 bool is_monomorphic_; | 1686 bool is_monomorphic_; |
1660 Handle<JSFunction> target_; | 1687 Handle<JSFunction> target_; |
1688 ElementsKind elements_kind_; | |
1689 Handle<Smi> alloc_elements_kind_; | |
1661 | 1690 |
1662 const BailoutId return_id_; | 1691 const BailoutId return_id_; |
1663 ElementsKind elements_kind_; | |
1664 }; | 1692 }; |
1665 | 1693 |
1666 | 1694 |
1667 // The CallRuntime class does not represent any official JavaScript | 1695 // The CallRuntime class does not represent any official JavaScript |
1668 // language construct. Instead it is used to call a C or JS function | 1696 // language construct. Instead it is used to call a C or JS function |
1669 // with a set of arguments. This is used from the builtins that are | 1697 // with a set of arguments. This is used from the builtins that are |
1670 // implemented in JavaScript (see "v8natives.js"). | 1698 // implemented in JavaScript (see "v8natives.js"). |
1671 class CallRuntime: public Expression { | 1699 class CallRuntime: public Expression { |
1672 public: | 1700 public: |
1673 DECLARE_NODE_TYPE(CallRuntime) | 1701 DECLARE_NODE_TYPE(CallRuntime) |
(...skipping 29 matching lines...) Expand all Loading... | |
1703 virtual bool ResultOverwriteAllowed(); | 1731 virtual bool ResultOverwriteAllowed(); |
1704 | 1732 |
1705 Token::Value op() const { return op_; } | 1733 Token::Value op() const { return op_; } |
1706 Expression* expression() const { return expression_; } | 1734 Expression* expression() const { return expression_; } |
1707 virtual int position() const { return pos_; } | 1735 virtual int position() const { return pos_; } |
1708 | 1736 |
1709 BailoutId MaterializeTrueId() { return materialize_true_id_; } | 1737 BailoutId MaterializeTrueId() { return materialize_true_id_; } |
1710 BailoutId MaterializeFalseId() { return materialize_false_id_; } | 1738 BailoutId MaterializeFalseId() { return materialize_false_id_; } |
1711 | 1739 |
1712 TypeFeedbackId UnaryOperationFeedbackId() const { return reuse(id()); } | 1740 TypeFeedbackId UnaryOperationFeedbackId() const { return reuse(id()); } |
1741 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | |
1742 TypeInfo type() const { return type_; } | |
1713 | 1743 |
1714 protected: | 1744 protected: |
1715 UnaryOperation(Isolate* isolate, | 1745 UnaryOperation(Isolate* isolate, |
1716 Token::Value op, | 1746 Token::Value op, |
1717 Expression* expression, | 1747 Expression* expression, |
1718 int pos) | 1748 int pos) |
1719 : Expression(isolate), | 1749 : Expression(isolate), |
1720 op_(op), | 1750 op_(op), |
1721 expression_(expression), | 1751 expression_(expression), |
1722 pos_(pos), | 1752 pos_(pos), |
1723 materialize_true_id_(GetNextId(isolate)), | 1753 materialize_true_id_(GetNextId(isolate)), |
1724 materialize_false_id_(GetNextId(isolate)) { | 1754 materialize_false_id_(GetNextId(isolate)) { |
1725 ASSERT(Token::IsUnaryOp(op)); | 1755 ASSERT(Token::IsUnaryOp(op)); |
1726 } | 1756 } |
1727 | 1757 |
1728 private: | 1758 private: |
1729 Token::Value op_; | 1759 Token::Value op_; |
1730 Expression* expression_; | 1760 Expression* expression_; |
1731 int pos_; | 1761 int pos_; |
1732 | 1762 |
1763 TypeInfo type_; | |
1764 | |
1733 // For unary not (Token::NOT), the AST ids where true and false will | 1765 // For unary not (Token::NOT), the AST ids where true and false will |
1734 // actually be materialized, respectively. | 1766 // actually be materialized, respectively. |
1735 const BailoutId materialize_true_id_; | 1767 const BailoutId materialize_true_id_; |
1736 const BailoutId materialize_false_id_; | 1768 const BailoutId materialize_false_id_; |
1737 }; | 1769 }; |
1738 | 1770 |
1739 | 1771 |
1740 class BinaryOperation: public Expression { | 1772 class BinaryOperation: public Expression { |
1741 public: | 1773 public: |
1742 DECLARE_NODE_TYPE(BinaryOperation) | 1774 DECLARE_NODE_TYPE(BinaryOperation) |
1743 | 1775 |
1744 virtual bool ResultOverwriteAllowed(); | 1776 virtual bool ResultOverwriteAllowed(); |
1745 | 1777 |
1746 Token::Value op() const { return op_; } | 1778 Token::Value op() const { return op_; } |
1747 Expression* left() const { return left_; } | 1779 Expression* left() const { return left_; } |
1748 Expression* right() const { return right_; } | 1780 Expression* right() const { return right_; } |
1749 virtual int position() const { return pos_; } | 1781 virtual int position() const { return pos_; } |
1750 | 1782 |
1751 BailoutId RightId() const { return right_id_; } | 1783 BailoutId RightId() const { return right_id_; } |
1752 | 1784 |
1753 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); } | 1785 TypeFeedbackId BinaryOperationFeedbackId() const { return reuse(id()); } |
1786 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | |
1787 TypeInfo left_type() const { return left_type_; } | |
1788 TypeInfo right_type() const { return right_type_; } | |
1789 TypeInfo result_type() const { return result_type_; } | |
1754 | 1790 |
1755 protected: | 1791 protected: |
1756 BinaryOperation(Isolate* isolate, | 1792 BinaryOperation(Isolate* isolate, |
1757 Token::Value op, | 1793 Token::Value op, |
1758 Expression* left, | 1794 Expression* left, |
1759 Expression* right, | 1795 Expression* right, |
1760 int pos) | 1796 int pos) |
1761 : Expression(isolate), | 1797 : Expression(isolate), |
1762 op_(op), | 1798 op_(op), |
1763 left_(left), | 1799 left_(left), |
1764 right_(right), | 1800 right_(right), |
1765 pos_(pos), | 1801 pos_(pos), |
1766 right_id_(GetNextId(isolate)) { | 1802 right_id_(GetNextId(isolate)) { |
1767 ASSERT(Token::IsBinaryOp(op)); | 1803 ASSERT(Token::IsBinaryOp(op)); |
1768 } | 1804 } |
1769 | 1805 |
1770 private: | 1806 private: |
1771 Token::Value op_; | 1807 Token::Value op_; |
1772 Expression* left_; | 1808 Expression* left_; |
1773 Expression* right_; | 1809 Expression* right_; |
1774 int pos_; | 1810 int pos_; |
1811 | |
1812 TypeInfo left_type_; | |
1813 TypeInfo right_type_; | |
1814 TypeInfo result_type_; | |
1815 | |
1775 // The short-circuit logical operations need an AST ID for their | 1816 // The short-circuit logical operations need an AST ID for their |
1776 // right-hand subexpression. | 1817 // right-hand subexpression. |
1777 const BailoutId right_id_; | 1818 const BailoutId right_id_; |
1778 }; | 1819 }; |
1779 | 1820 |
1780 | 1821 |
1781 class CountOperation: public Expression { | 1822 class CountOperation: public Expression { |
1782 public: | 1823 public: |
1783 DECLARE_NODE_TYPE(CountOperation) | 1824 DECLARE_NODE_TYPE(CountOperation) |
1784 | 1825 |
1785 bool is_prefix() const { return is_prefix_; } | 1826 bool is_prefix() const { return is_prefix_; } |
1786 bool is_postfix() const { return !is_prefix_; } | 1827 bool is_postfix() const { return !is_prefix_; } |
1787 | 1828 |
1788 Token::Value op() const { return op_; } | 1829 Token::Value op() const { return op_; } |
1789 Token::Value binary_op() { | 1830 Token::Value binary_op() { |
1790 return (op() == Token::INC) ? Token::ADD : Token::SUB; | 1831 return (op() == Token::INC) ? Token::ADD : Token::SUB; |
1791 } | 1832 } |
1792 | 1833 |
1793 Expression* expression() const { return expression_; } | 1834 Expression* expression() const { return expression_; } |
1794 virtual int position() const { return pos_; } | 1835 virtual int position() const { return pos_; } |
1795 | 1836 |
1796 virtual void MarkAsStatement() { is_prefix_ = true; } | 1837 virtual void MarkAsStatement() { is_prefix_ = true; } |
1797 | 1838 |
1798 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* znoe); | 1839 void RecordTypeFeedback(TypeFeedbackOracle* oracle, Zone* znoe); |
1799 virtual bool IsMonomorphic() { return is_monomorphic_; } | 1840 virtual bool IsMonomorphic() { return is_monomorphic_; } |
1800 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } | 1841 virtual SmallMapList* GetReceiverTypes() { return &receiver_types_; } |
1801 virtual KeyedAccessStoreMode GetStoreMode() { | 1842 virtual KeyedAccessStoreMode GetStoreMode() { |
1802 return store_mode_; | 1843 return store_mode_; |
1803 } | 1844 } |
1845 TypeInfo type() const { return type_; } | |
1804 | 1846 |
1805 BailoutId AssignmentId() const { return assignment_id_; } | 1847 BailoutId AssignmentId() const { return assignment_id_; } |
1806 | 1848 |
1807 TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; } | 1849 TypeFeedbackId CountBinOpFeedbackId() const { return count_id_; } |
1808 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); } | 1850 TypeFeedbackId CountStoreFeedbackId() const { return reuse(id()); } |
1809 | 1851 |
1810 protected: | 1852 protected: |
1811 CountOperation(Isolate* isolate, | 1853 CountOperation(Isolate* isolate, |
1812 Token::Value op, | 1854 Token::Value op, |
1813 bool is_prefix, | 1855 bool is_prefix, |
1814 Expression* expr, | 1856 Expression* expr, |
1815 int pos) | 1857 int pos) |
1816 : Expression(isolate), | 1858 : Expression(isolate), |
1817 op_(op), | 1859 op_(op), |
1818 is_prefix_(is_prefix), | 1860 is_prefix_(is_prefix), |
1819 is_monomorphic_(false), | 1861 is_monomorphic_(false), |
1820 store_mode_(STANDARD_STORE), | 1862 store_mode_(STANDARD_STORE), |
1821 expression_(expr), | 1863 expression_(expr), |
1822 pos_(pos), | 1864 pos_(pos), |
1823 assignment_id_(GetNextId(isolate)), | 1865 assignment_id_(GetNextId(isolate)), |
1824 count_id_(GetNextId(isolate)) {} | 1866 count_id_(GetNextId(isolate)) {} |
1825 | 1867 |
1826 private: | 1868 private: |
1827 Token::Value op_; | 1869 Token::Value op_; |
1828 bool is_prefix_ : 1; | 1870 bool is_prefix_ : 1; |
1829 bool is_monomorphic_ : 1; | 1871 bool is_monomorphic_ : 1; |
1830 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 1872 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
1831 // must have extra bit. | 1873 // must have extra bit. |
1874 TypeInfo type_; | |
1875 | |
1832 Expression* expression_; | 1876 Expression* expression_; |
1833 int pos_; | 1877 int pos_; |
1834 const BailoutId assignment_id_; | 1878 const BailoutId assignment_id_; |
1835 const TypeFeedbackId count_id_; | 1879 const TypeFeedbackId count_id_; |
1836 SmallMapList receiver_types_; | 1880 SmallMapList receiver_types_; |
1837 }; | 1881 }; |
1838 | 1882 |
1839 | 1883 |
1840 class CompareOperation: public Expression { | 1884 class CompareOperation: public Expression { |
1841 public: | 1885 public: |
1842 DECLARE_NODE_TYPE(CompareOperation) | 1886 DECLARE_NODE_TYPE(CompareOperation) |
1843 | 1887 |
1844 Token::Value op() const { return op_; } | 1888 Token::Value op() const { return op_; } |
1845 Expression* left() const { return left_; } | 1889 Expression* left() const { return left_; } |
1846 Expression* right() const { return right_; } | 1890 Expression* right() const { return right_; } |
1847 virtual int position() const { return pos_; } | 1891 virtual int position() const { return pos_; } |
1848 | 1892 |
1849 // Type feedback information. | 1893 // Type feedback information. |
1850 TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); } | 1894 TypeFeedbackId CompareOperationFeedbackId() const { return reuse(id()); } |
1895 void RecordTypeFeedback(TypeFeedbackOracle* oracle); | |
1896 TypeInfo left_type() const { return left_type_; } | |
1897 TypeInfo right_type() const { return right_type_; } | |
1898 TypeInfo overall_type() const { return overall_type_; } | |
1899 byte compare_nil_types() const { return compare_nil_types_; } | |
1900 Handle<Map> map() const { return map_; } | |
1851 | 1901 |
1852 // Match special cases. | 1902 // Match special cases. |
1853 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); | 1903 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); |
1854 bool IsLiteralCompareUndefined(Expression** expr); | 1904 bool IsLiteralCompareUndefined(Expression** expr); |
1855 bool IsLiteralCompareNull(Expression** expr); | 1905 bool IsLiteralCompareNull(Expression** expr); |
1856 | 1906 |
1857 protected: | 1907 protected: |
1858 CompareOperation(Isolate* isolate, | 1908 CompareOperation(Isolate* isolate, |
1859 Token::Value op, | 1909 Token::Value op, |
1860 Expression* left, | 1910 Expression* left, |
1861 Expression* right, | 1911 Expression* right, |
1862 int pos) | 1912 int pos) |
1863 : Expression(isolate), | 1913 : Expression(isolate), |
1864 op_(op), | 1914 op_(op), |
1865 left_(left), | 1915 left_(left), |
1866 right_(right), | 1916 right_(right), |
1867 pos_(pos) { | 1917 pos_(pos) { |
1868 ASSERT(Token::IsCompareOp(op)); | 1918 ASSERT(Token::IsCompareOp(op)); |
1869 } | 1919 } |
1870 | 1920 |
1871 private: | 1921 private: |
1872 Token::Value op_; | 1922 Token::Value op_; |
1873 Expression* left_; | 1923 Expression* left_; |
1874 Expression* right_; | 1924 Expression* right_; |
1875 int pos_; | 1925 int pos_; |
1926 | |
1927 TypeInfo left_type_; | |
1928 TypeInfo right_type_; | |
1929 TypeInfo overall_type_; | |
1930 byte compare_nil_types_; | |
1931 Handle<Map> map_; | |
1876 }; | 1932 }; |
1877 | 1933 |
1878 | 1934 |
1879 class Conditional: public Expression { | 1935 class Conditional: public Expression { |
1880 public: | 1936 public: |
1881 DECLARE_NODE_TYPE(Conditional) | 1937 DECLARE_NODE_TYPE(Conditional) |
1882 | 1938 |
1883 Expression* condition() const { return condition_; } | 1939 Expression* condition() const { return condition_; } |
1884 Expression* then_expression() const { return then_expression_; } | 1940 Expression* then_expression() const { return then_expression_; } |
1885 Expression* else_expression() const { return else_expression_; } | 1941 Expression* else_expression() const { return else_expression_; } |
(...skipping 1163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3049 private: | 3105 private: |
3050 Isolate* isolate_; | 3106 Isolate* isolate_; |
3051 Zone* zone_; | 3107 Zone* zone_; |
3052 Visitor visitor_; | 3108 Visitor visitor_; |
3053 }; | 3109 }; |
3054 | 3110 |
3055 | 3111 |
3056 } } // namespace v8::internal | 3112 } } // namespace v8::internal |
3057 | 3113 |
3058 #endif // V8_AST_H_ | 3114 #endif // V8_AST_H_ |
OLD | NEW |