OLD | NEW |
---|---|
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_AST_AST_H_ | 5 #ifndef V8_AST_AST_H_ |
6 #define V8_AST_AST_H_ | 6 #define V8_AST_AST_H_ |
7 | 7 |
8 #include "src/assembler.h" | 8 #include "src/assembler.h" |
9 #include "src/ast/ast-value-factory.h" | 9 #include "src/ast/ast-value-factory.h" |
10 #include "src/ast/modules.h" | 10 #include "src/ast/modules.h" |
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
498 bool ignore_completion_value_; | 498 bool ignore_completion_value_; |
499 Scope* scope_; | 499 Scope* scope_; |
500 }; | 500 }; |
501 | 501 |
502 | 502 |
503 class DoExpression final : public Expression { | 503 class DoExpression final : public Expression { |
504 public: | 504 public: |
505 DECLARE_NODE_TYPE(DoExpression) | 505 DECLARE_NODE_TYPE(DoExpression) |
506 | 506 |
507 Block* block() { return block_; } | 507 Block* block() { return block_; } |
508 void set_block(Block* b) { block_ = b; } | |
508 VariableProxy* result() { return result_; } | 509 VariableProxy* result() { return result_; } |
510 void set_result(VariableProxy* v) { result_ = v; } | |
509 | 511 |
510 void MarkTail() override { block_->MarkTail(); } | 512 void MarkTail() override { block_->MarkTail(); } |
511 | 513 |
512 protected: | 514 protected: |
513 DoExpression(Zone* zone, Block* block, VariableProxy* result, int pos) | 515 DoExpression(Zone* zone, Block* block, VariableProxy* result, int pos) |
514 : Expression(zone, pos), block_(block), result_(result) { | 516 : Expression(zone, pos), block_(block), result_(result) { |
515 DCHECK_NOT_NULL(block_); | 517 DCHECK_NOT_NULL(block_); |
516 DCHECK_NOT_NULL(result_); | 518 DCHECK_NOT_NULL(result_); |
517 } | 519 } |
518 static int parent_num_ids() { return Expression::num_ids(); } | 520 static int parent_num_ids() { return Expression::num_ids(); } |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
576 bool is_class_declaration_; | 578 bool is_class_declaration_; |
577 int declaration_group_start_; | 579 int declaration_group_start_; |
578 }; | 580 }; |
579 | 581 |
580 | 582 |
581 class FunctionDeclaration final : public Declaration { | 583 class FunctionDeclaration final : public Declaration { |
582 public: | 584 public: |
583 DECLARE_NODE_TYPE(FunctionDeclaration) | 585 DECLARE_NODE_TYPE(FunctionDeclaration) |
584 | 586 |
585 FunctionLiteral* fun() const { return fun_; } | 587 FunctionLiteral* fun() const { return fun_; } |
588 void set_fun(FunctionLiteral* f) { fun_ = f; } | |
586 InitializationFlag initialization() const override { | 589 InitializationFlag initialization() const override { |
587 return kCreatedInitialized; | 590 return kCreatedInitialized; |
588 } | 591 } |
589 bool IsInlineable() const override; | 592 bool IsInlineable() const override; |
590 | 593 |
591 protected: | 594 protected: |
592 FunctionDeclaration(Zone* zone, | 595 FunctionDeclaration(Zone* zone, |
593 VariableProxy* proxy, | 596 VariableProxy* proxy, |
594 VariableMode mode, | 597 VariableMode mode, |
595 FunctionLiteral* fun, | 598 FunctionLiteral* fun, |
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
699 class DoWhileStatement final : public IterationStatement { | 702 class DoWhileStatement final : public IterationStatement { |
700 public: | 703 public: |
701 DECLARE_NODE_TYPE(DoWhileStatement) | 704 DECLARE_NODE_TYPE(DoWhileStatement) |
702 | 705 |
703 void Initialize(Expression* cond, Statement* body) { | 706 void Initialize(Expression* cond, Statement* body) { |
704 IterationStatement::Initialize(body); | 707 IterationStatement::Initialize(body); |
705 cond_ = cond; | 708 cond_ = cond; |
706 } | 709 } |
707 | 710 |
708 Expression* cond() const { return cond_; } | 711 Expression* cond() const { return cond_; } |
712 void set_cond(Expression* e) { cond_ = e; } | |
709 | 713 |
710 static int num_ids() { return parent_num_ids() + 2; } | 714 static int num_ids() { return parent_num_ids() + 2; } |
711 BailoutId ContinueId() const override { return BailoutId(local_id(0)); } | 715 BailoutId ContinueId() const override { return BailoutId(local_id(0)); } |
712 BailoutId StackCheckId() const override { return BackEdgeId(); } | 716 BailoutId StackCheckId() const override { return BackEdgeId(); } |
713 BailoutId BackEdgeId() const { return BailoutId(local_id(1)); } | 717 BailoutId BackEdgeId() const { return BailoutId(local_id(1)); } |
714 | 718 |
715 protected: | 719 protected: |
716 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 720 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
717 : IterationStatement(zone, labels, pos), cond_(NULL) {} | 721 : IterationStatement(zone, labels, pos), cond_(NULL) {} |
718 static int parent_num_ids() { return IterationStatement::num_ids(); } | 722 static int parent_num_ids() { return IterationStatement::num_ids(); } |
719 | 723 |
720 private: | 724 private: |
721 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 725 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
722 | 726 |
723 Expression* cond_; | 727 Expression* cond_; |
724 }; | 728 }; |
725 | 729 |
726 | 730 |
727 class WhileStatement final : public IterationStatement { | 731 class WhileStatement final : public IterationStatement { |
728 public: | 732 public: |
729 DECLARE_NODE_TYPE(WhileStatement) | 733 DECLARE_NODE_TYPE(WhileStatement) |
730 | 734 |
731 void Initialize(Expression* cond, Statement* body) { | 735 void Initialize(Expression* cond, Statement* body) { |
732 IterationStatement::Initialize(body); | 736 IterationStatement::Initialize(body); |
733 cond_ = cond; | 737 cond_ = cond; |
734 } | 738 } |
735 | 739 |
736 Expression* cond() const { return cond_; } | 740 Expression* cond() const { return cond_; } |
741 void set_cond(Expression* e) { cond_ = e; } | |
737 | 742 |
738 static int num_ids() { return parent_num_ids() + 1; } | 743 static int num_ids() { return parent_num_ids() + 1; } |
739 BailoutId ContinueId() const override { return EntryId(); } | 744 BailoutId ContinueId() const override { return EntryId(); } |
740 BailoutId StackCheckId() const override { return BodyId(); } | 745 BailoutId StackCheckId() const override { return BodyId(); } |
741 BailoutId BodyId() const { return BailoutId(local_id(0)); } | 746 BailoutId BodyId() const { return BailoutId(local_id(0)); } |
742 | 747 |
743 protected: | 748 protected: |
744 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 749 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
745 : IterationStatement(zone, labels, pos), cond_(NULL) {} | 750 : IterationStatement(zone, labels, pos), cond_(NULL) {} |
746 static int parent_num_ids() { return IterationStatement::num_ids(); } | 751 static int parent_num_ids() { return IterationStatement::num_ids(); } |
(...skipping 16 matching lines...) Expand all Loading... | |
763 IterationStatement::Initialize(body); | 768 IterationStatement::Initialize(body); |
764 init_ = init; | 769 init_ = init; |
765 cond_ = cond; | 770 cond_ = cond; |
766 next_ = next; | 771 next_ = next; |
767 } | 772 } |
768 | 773 |
769 Statement* init() const { return init_; } | 774 Statement* init() const { return init_; } |
770 Expression* cond() const { return cond_; } | 775 Expression* cond() const { return cond_; } |
771 Statement* next() const { return next_; } | 776 Statement* next() const { return next_; } |
772 | 777 |
778 void set_init(Statement* s) { init_ = s; } | |
779 void set_cond(Expression* e) { cond_ = e; } | |
780 void set_next(Statement* s) { next_ = s; } | |
781 | |
773 static int num_ids() { return parent_num_ids() + 2; } | 782 static int num_ids() { return parent_num_ids() + 2; } |
774 BailoutId ContinueId() const override { return BailoutId(local_id(0)); } | 783 BailoutId ContinueId() const override { return BailoutId(local_id(0)); } |
775 BailoutId StackCheckId() const override { return BodyId(); } | 784 BailoutId StackCheckId() const override { return BodyId(); } |
776 BailoutId BodyId() const { return BailoutId(local_id(1)); } | 785 BailoutId BodyId() const { return BailoutId(local_id(1)); } |
777 | 786 |
778 protected: | 787 protected: |
779 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 788 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
780 : IterationStatement(zone, labels, pos), | 789 : IterationStatement(zone, labels, pos), |
781 init_(NULL), | 790 init_(NULL), |
782 cond_(NULL), | 791 cond_(NULL), |
(...skipping 18 matching lines...) Expand all Loading... | |
801 | 810 |
802 void Initialize(Expression* each, Expression* subject, Statement* body) { | 811 void Initialize(Expression* each, Expression* subject, Statement* body) { |
803 IterationStatement::Initialize(body); | 812 IterationStatement::Initialize(body); |
804 each_ = each; | 813 each_ = each; |
805 subject_ = subject; | 814 subject_ = subject; |
806 } | 815 } |
807 | 816 |
808 Expression* each() const { return each_; } | 817 Expression* each() const { return each_; } |
809 Expression* subject() const { return subject_; } | 818 Expression* subject() const { return subject_; } |
810 | 819 |
820 void set_each(Expression* e) { each_ = e; } | |
821 void set_subject(Expression* e) { subject_ = e; } | |
822 | |
811 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 823 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
812 FeedbackVectorSlotCache* cache) override; | 824 FeedbackVectorSlotCache* cache) override; |
813 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; } | 825 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; } |
814 | 826 |
815 protected: | 827 protected: |
816 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 828 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
817 : IterationStatement(zone, labels, pos), each_(NULL), subject_(NULL) {} | 829 : IterationStatement(zone, labels, pos), each_(NULL), subject_(NULL) {} |
818 | 830 |
819 private: | 831 private: |
820 Expression* each_; | 832 Expression* each_; |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
905 // result.done | 917 // result.done |
906 Expression* result_done() const { | 918 Expression* result_done() const { |
907 return result_done_; | 919 return result_done_; |
908 } | 920 } |
909 | 921 |
910 // each = result.value | 922 // each = result.value |
911 Expression* assign_each() const { | 923 Expression* assign_each() const { |
912 return assign_each_; | 924 return assign_each_; |
913 } | 925 } |
914 | 926 |
927 void set_assign_iterator(Expression* e) { assign_iterator_ = e; } | |
928 void set_next_result(Expression* e) { next_result_ = e; } | |
929 void set_result_done(Expression* e) { result_done_ = e; } | |
930 void set_assign_each(Expression* e) { assign_each_ = e; } | |
nickie
2016/01/11 10:24:18
Small fix #1: these four lines had inadvertently b
| |
931 | |
915 BailoutId ContinueId() const override { return EntryId(); } | 932 BailoutId ContinueId() const override { return EntryId(); } |
916 BailoutId StackCheckId() const override { return BackEdgeId(); } | 933 BailoutId StackCheckId() const override { return BackEdgeId(); } |
917 | 934 |
918 static int num_ids() { return parent_num_ids() + 1; } | 935 static int num_ids() { return parent_num_ids() + 1; } |
919 BailoutId BackEdgeId() const { return BailoutId(local_id(0)); } | 936 BailoutId BackEdgeId() const { return BailoutId(local_id(0)); } |
920 | 937 |
921 protected: | 938 protected: |
922 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 939 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
923 : ForEachStatement(zone, labels, pos), | 940 : ForEachStatement(zone, labels, pos), |
924 assign_iterator_(NULL), | 941 assign_iterator_(NULL), |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
993 BreakableStatement* target_; | 1010 BreakableStatement* target_; |
994 }; | 1011 }; |
995 | 1012 |
996 | 1013 |
997 class ReturnStatement final : public JumpStatement { | 1014 class ReturnStatement final : public JumpStatement { |
998 public: | 1015 public: |
999 DECLARE_NODE_TYPE(ReturnStatement) | 1016 DECLARE_NODE_TYPE(ReturnStatement) |
1000 | 1017 |
1001 Expression* expression() const { return expression_; } | 1018 Expression* expression() const { return expression_; } |
1002 | 1019 |
1020 void set_expression(Expression* e) { expression_ = e; } | |
1021 | |
1003 protected: | 1022 protected: |
1004 explicit ReturnStatement(Zone* zone, Expression* expression, int pos) | 1023 explicit ReturnStatement(Zone* zone, Expression* expression, int pos) |
1005 : JumpStatement(zone, pos), expression_(expression) { } | 1024 : JumpStatement(zone, pos), expression_(expression) { } |
1006 | 1025 |
1007 private: | 1026 private: |
1008 Expression* expression_; | 1027 Expression* expression_; |
1009 }; | 1028 }; |
1010 | 1029 |
1011 | 1030 |
1012 class WithStatement final : public Statement { | 1031 class WithStatement final : public Statement { |
1013 public: | 1032 public: |
1014 DECLARE_NODE_TYPE(WithStatement) | 1033 DECLARE_NODE_TYPE(WithStatement) |
1015 | 1034 |
1016 Scope* scope() { return scope_; } | 1035 Scope* scope() { return scope_; } |
1017 Expression* expression() const { return expression_; } | 1036 Expression* expression() const { return expression_; } |
1037 void set_expression(Expression* e) { expression_ = e; } | |
1018 Statement* statement() const { return statement_; } | 1038 Statement* statement() const { return statement_; } |
1019 void set_statement(Statement* s) { statement_ = s; } | 1039 void set_statement(Statement* s) { statement_ = s; } |
1020 | 1040 |
1021 void set_base_id(int id) { base_id_ = id; } | 1041 void set_base_id(int id) { base_id_ = id; } |
1022 static int num_ids() { return parent_num_ids() + 2; } | 1042 static int num_ids() { return parent_num_ids() + 2; } |
1023 BailoutId ToObjectId() const { return BailoutId(local_id(0)); } | 1043 BailoutId ToObjectId() const { return BailoutId(local_id(0)); } |
1024 BailoutId EntryId() const { return BailoutId(local_id(1)); } | 1044 BailoutId EntryId() const { return BailoutId(local_id(1)); } |
1025 | 1045 |
1026 void MarkTail() override { statement_->MarkTail(); } | 1046 void MarkTail() override { statement_->MarkTail(); } |
1027 | 1047 |
(...skipping 24 matching lines...) Expand all Loading... | |
1052 | 1072 |
1053 class CaseClause final : public Expression { | 1073 class CaseClause final : public Expression { |
1054 public: | 1074 public: |
1055 DECLARE_NODE_TYPE(CaseClause) | 1075 DECLARE_NODE_TYPE(CaseClause) |
1056 | 1076 |
1057 bool is_default() const { return label_ == NULL; } | 1077 bool is_default() const { return label_ == NULL; } |
1058 Expression* label() const { | 1078 Expression* label() const { |
1059 CHECK(!is_default()); | 1079 CHECK(!is_default()); |
1060 return label_; | 1080 return label_; |
1061 } | 1081 } |
1082 void set_label(Expression* e) { label_ = e; } | |
1062 Label* body_target() { return &body_target_; } | 1083 Label* body_target() { return &body_target_; } |
1063 ZoneList<Statement*>* statements() const { return statements_; } | 1084 ZoneList<Statement*>* statements() const { return statements_; } |
1064 | 1085 |
1065 static int num_ids() { return parent_num_ids() + 2; } | 1086 static int num_ids() { return parent_num_ids() + 2; } |
1066 BailoutId EntryId() const { return BailoutId(local_id(0)); } | 1087 BailoutId EntryId() const { return BailoutId(local_id(0)); } |
1067 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); } | 1088 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); } |
1068 | 1089 |
1069 void MarkTail() override { | 1090 void MarkTail() override { |
1070 if (!statements_->is_empty()) statements_->last()->MarkTail(); | 1091 if (!statements_->is_empty()) statements_->last()->MarkTail(); |
1071 } | 1092 } |
(...skipping 21 matching lines...) Expand all Loading... | |
1093 DECLARE_NODE_TYPE(SwitchStatement) | 1114 DECLARE_NODE_TYPE(SwitchStatement) |
1094 | 1115 |
1095 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 1116 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
1096 tag_ = tag; | 1117 tag_ = tag; |
1097 cases_ = cases; | 1118 cases_ = cases; |
1098 } | 1119 } |
1099 | 1120 |
1100 Expression* tag() const { return tag_; } | 1121 Expression* tag() const { return tag_; } |
1101 ZoneList<CaseClause*>* cases() const { return cases_; } | 1122 ZoneList<CaseClause*>* cases() const { return cases_; } |
1102 | 1123 |
1124 void set_tag(Expression* t) { tag_ = t; } | |
1125 | |
1103 void MarkTail() override { | 1126 void MarkTail() override { |
1104 if (!cases_->is_empty()) cases_->last()->MarkTail(); | 1127 if (!cases_->is_empty()) cases_->last()->MarkTail(); |
1105 } | 1128 } |
1106 | 1129 |
1107 protected: | 1130 protected: |
1108 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 1131 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
1109 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), | 1132 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
1110 tag_(NULL), | 1133 tag_(NULL), |
1111 cases_(NULL) {} | 1134 cases_(NULL) {} |
1112 | 1135 |
(...skipping 12 matching lines...) Expand all Loading... | |
1125 public: | 1148 public: |
1126 DECLARE_NODE_TYPE(IfStatement) | 1149 DECLARE_NODE_TYPE(IfStatement) |
1127 | 1150 |
1128 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } | 1151 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } |
1129 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } | 1152 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } |
1130 | 1153 |
1131 Expression* condition() const { return condition_; } | 1154 Expression* condition() const { return condition_; } |
1132 Statement* then_statement() const { return then_statement_; } | 1155 Statement* then_statement() const { return then_statement_; } |
1133 Statement* else_statement() const { return else_statement_; } | 1156 Statement* else_statement() const { return else_statement_; } |
1134 | 1157 |
1158 void set_condition(Expression* e) { condition_ = e; } | |
1135 void set_then_statement(Statement* s) { then_statement_ = s; } | 1159 void set_then_statement(Statement* s) { then_statement_ = s; } |
1136 void set_else_statement(Statement* s) { else_statement_ = s; } | 1160 void set_else_statement(Statement* s) { else_statement_ = s; } |
1137 | 1161 |
1138 bool IsJump() const override { | 1162 bool IsJump() const override { |
1139 return HasThenStatement() && then_statement()->IsJump() | 1163 return HasThenStatement() && then_statement()->IsJump() |
1140 && HasElseStatement() && else_statement()->IsJump(); | 1164 && HasElseStatement() && else_statement()->IsJump(); |
1141 } | 1165 } |
1142 | 1166 |
1143 void MarkTail() override { | 1167 void MarkTail() override { |
1144 then_statement_->MarkTail(); | 1168 then_statement_->MarkTail(); |
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1419 COMPUTED, // Property with computed value (execution time). | 1443 COMPUTED, // Property with computed value (execution time). |
1420 MATERIALIZED_LITERAL, // Property value is a materialized literal. | 1444 MATERIALIZED_LITERAL, // Property value is a materialized literal. |
1421 GETTER, SETTER, // Property is an accessor function. | 1445 GETTER, SETTER, // Property is an accessor function. |
1422 PROTOTYPE // Property is __proto__. | 1446 PROTOTYPE // Property is __proto__. |
1423 }; | 1447 }; |
1424 | 1448 |
1425 Expression* key() { return key_; } | 1449 Expression* key() { return key_; } |
1426 Expression* value() { return value_; } | 1450 Expression* value() { return value_; } |
1427 Kind kind() { return kind_; } | 1451 Kind kind() { return kind_; } |
1428 | 1452 |
1453 void set_key(Expression* e) { key_ = e; } | |
1454 void set_value(Expression* e) { value_ = e; } | |
1455 | |
1429 // Type feedback information. | 1456 // Type feedback information. |
1430 bool IsMonomorphic() { return !receiver_type_.is_null(); } | 1457 bool IsMonomorphic() { return !receiver_type_.is_null(); } |
1431 Handle<Map> GetReceiverType() { return receiver_type_; } | 1458 Handle<Map> GetReceiverType() { return receiver_type_; } |
1432 | 1459 |
1433 bool IsCompileTimeValue(); | 1460 bool IsCompileTimeValue(); |
1434 | 1461 |
1435 void set_emit_store(bool emit_store); | 1462 void set_emit_store(bool emit_store); |
1436 bool emit_store(); | 1463 bool emit_store(); |
1437 | 1464 |
1438 bool is_static() const { return is_static_; } | 1465 bool is_static() const { return is_static_; } |
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1792 | 1819 |
1793 class Property final : public Expression { | 1820 class Property final : public Expression { |
1794 public: | 1821 public: |
1795 DECLARE_NODE_TYPE(Property) | 1822 DECLARE_NODE_TYPE(Property) |
1796 | 1823 |
1797 bool IsValidReferenceExpression() const override { return true; } | 1824 bool IsValidReferenceExpression() const override { return true; } |
1798 | 1825 |
1799 Expression* obj() const { return obj_; } | 1826 Expression* obj() const { return obj_; } |
1800 Expression* key() const { return key_; } | 1827 Expression* key() const { return key_; } |
1801 | 1828 |
1829 void set_obj(Expression* e) { obj_ = e; } | |
1830 void set_key(Expression* e) { key_ = e; } | |
1831 | |
1802 static int num_ids() { return parent_num_ids() + 1; } | 1832 static int num_ids() { return parent_num_ids() + 1; } |
1803 BailoutId LoadId() const { return BailoutId(local_id(0)); } | 1833 BailoutId LoadId() const { return BailoutId(local_id(0)); } |
1804 | 1834 |
1805 bool IsStringAccess() const { | 1835 bool IsStringAccess() const { |
1806 return IsStringAccessField::decode(bit_field_); | 1836 return IsStringAccessField::decode(bit_field_); |
1807 } | 1837 } |
1808 | 1838 |
1809 // Type feedback information. | 1839 // Type feedback information. |
1810 bool IsMonomorphic() override { return receiver_types_.length() == 1; } | 1840 bool IsMonomorphic() override { return receiver_types_.length() == 1; } |
1811 SmallMapList* GetReceiverTypes() override { return &receiver_types_; } | 1841 SmallMapList* GetReceiverTypes() override { return &receiver_types_; } |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1883 }; | 1913 }; |
1884 | 1914 |
1885 | 1915 |
1886 class Call final : public Expression { | 1916 class Call final : public Expression { |
1887 public: | 1917 public: |
1888 DECLARE_NODE_TYPE(Call) | 1918 DECLARE_NODE_TYPE(Call) |
1889 | 1919 |
1890 Expression* expression() const { return expression_; } | 1920 Expression* expression() const { return expression_; } |
1891 ZoneList<Expression*>* arguments() const { return arguments_; } | 1921 ZoneList<Expression*>* arguments() const { return arguments_; } |
1892 | 1922 |
1923 void set_expression(Expression* e) { expression_ = e; } | |
1924 | |
1893 // Type feedback information. | 1925 // Type feedback information. |
1894 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1926 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
1895 FeedbackVectorSlotCache* cache) override; | 1927 FeedbackVectorSlotCache* cache) override; |
1896 | 1928 |
1897 FeedbackVectorSlot CallFeedbackSlot() const { return stub_slot_; } | 1929 FeedbackVectorSlot CallFeedbackSlot() const { return stub_slot_; } |
1898 | 1930 |
1899 FeedbackVectorSlot CallFeedbackICSlot() const { return ic_slot_; } | 1931 FeedbackVectorSlot CallFeedbackICSlot() const { return ic_slot_; } |
1900 | 1932 |
1901 SmallMapList* GetReceiverTypes() override { | 1933 SmallMapList* GetReceiverTypes() override { |
1902 if (expression()->IsProperty()) { | 1934 if (expression()->IsProperty()) { |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2002 }; | 2034 }; |
2003 | 2035 |
2004 | 2036 |
2005 class CallNew final : public Expression { | 2037 class CallNew final : public Expression { |
2006 public: | 2038 public: |
2007 DECLARE_NODE_TYPE(CallNew) | 2039 DECLARE_NODE_TYPE(CallNew) |
2008 | 2040 |
2009 Expression* expression() const { return expression_; } | 2041 Expression* expression() const { return expression_; } |
2010 ZoneList<Expression*>* arguments() const { return arguments_; } | 2042 ZoneList<Expression*>* arguments() const { return arguments_; } |
2011 | 2043 |
2044 void set_expression(Expression* e) { expression_ = e; } | |
2045 | |
2012 // Type feedback information. | 2046 // Type feedback information. |
2013 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2047 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
2014 FeedbackVectorSlotCache* cache) override { | 2048 FeedbackVectorSlotCache* cache) override { |
2015 callnew_feedback_slot_ = spec->AddGeneralSlot(); | 2049 callnew_feedback_slot_ = spec->AddGeneralSlot(); |
2016 } | 2050 } |
2017 | 2051 |
2018 FeedbackVectorSlot CallNewFeedbackSlot() { | 2052 FeedbackVectorSlot CallNewFeedbackSlot() { |
2019 DCHECK(!callnew_feedback_slot_.IsInvalid()); | 2053 DCHECK(!callnew_feedback_slot_.IsInvalid()); |
2020 return callnew_feedback_slot_; | 2054 return callnew_feedback_slot_; |
2021 } | 2055 } |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2111 ZoneList<Expression*>* arguments_; | 2145 ZoneList<Expression*>* arguments_; |
2112 }; | 2146 }; |
2113 | 2147 |
2114 | 2148 |
2115 class UnaryOperation final : public Expression { | 2149 class UnaryOperation final : public Expression { |
2116 public: | 2150 public: |
2117 DECLARE_NODE_TYPE(UnaryOperation) | 2151 DECLARE_NODE_TYPE(UnaryOperation) |
2118 | 2152 |
2119 Token::Value op() const { return op_; } | 2153 Token::Value op() const { return op_; } |
2120 Expression* expression() const { return expression_; } | 2154 Expression* expression() const { return expression_; } |
2155 void set_expression(Expression* e) { expression_ = e; } | |
2121 | 2156 |
2122 // For unary not (Token::NOT), the AST ids where true and false will | 2157 // For unary not (Token::NOT), the AST ids where true and false will |
2123 // actually be materialized, respectively. | 2158 // actually be materialized, respectively. |
2124 static int num_ids() { return parent_num_ids() + 2; } | 2159 static int num_ids() { return parent_num_ids() + 2; } |
2125 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); } | 2160 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); } |
2126 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); } | 2161 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); } |
2127 | 2162 |
2128 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) override; | 2163 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) override; |
2129 | 2164 |
2130 protected: | 2165 protected: |
(...skipping 10 matching lines...) Expand all Loading... | |
2141 Expression* expression_; | 2176 Expression* expression_; |
2142 }; | 2177 }; |
2143 | 2178 |
2144 | 2179 |
2145 class BinaryOperation final : public Expression { | 2180 class BinaryOperation final : public Expression { |
2146 public: | 2181 public: |
2147 DECLARE_NODE_TYPE(BinaryOperation) | 2182 DECLARE_NODE_TYPE(BinaryOperation) |
2148 | 2183 |
2149 Token::Value op() const { return static_cast<Token::Value>(op_); } | 2184 Token::Value op() const { return static_cast<Token::Value>(op_); } |
2150 Expression* left() const { return left_; } | 2185 Expression* left() const { return left_; } |
2186 void set_left(Expression* e) { left_ = e; } | |
2151 Expression* right() const { return right_; } | 2187 Expression* right() const { return right_; } |
2188 void set_right(Expression* e) { right_ = e; } | |
2152 Handle<AllocationSite> allocation_site() const { return allocation_site_; } | 2189 Handle<AllocationSite> allocation_site() const { return allocation_site_; } |
2153 void set_allocation_site(Handle<AllocationSite> allocation_site) { | 2190 void set_allocation_site(Handle<AllocationSite> allocation_site) { |
2154 allocation_site_ = allocation_site; | 2191 allocation_site_ = allocation_site; |
2155 } | 2192 } |
2156 | 2193 |
2157 void MarkTail() override { | 2194 void MarkTail() override { |
2158 switch (op()) { | 2195 switch (op()) { |
2159 case Token::COMMA: | 2196 case Token::COMMA: |
2160 case Token::AND: | 2197 case Token::AND: |
2161 case Token::OR: | 2198 case Token::OR: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2216 | 2253 |
2217 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } | 2254 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } |
2218 bool is_postfix() const { return !is_prefix(); } | 2255 bool is_postfix() const { return !is_prefix(); } |
2219 | 2256 |
2220 Token::Value op() const { return TokenField::decode(bit_field_); } | 2257 Token::Value op() const { return TokenField::decode(bit_field_); } |
2221 Token::Value binary_op() { | 2258 Token::Value binary_op() { |
2222 return (op() == Token::INC) ? Token::ADD : Token::SUB; | 2259 return (op() == Token::INC) ? Token::ADD : Token::SUB; |
2223 } | 2260 } |
2224 | 2261 |
2225 Expression* expression() const { return expression_; } | 2262 Expression* expression() const { return expression_; } |
2263 void set_expression(Expression* e) { expression_ = e; } | |
2226 | 2264 |
2227 bool IsMonomorphic() override { return receiver_types_.length() == 1; } | 2265 bool IsMonomorphic() override { return receiver_types_.length() == 1; } |
2228 SmallMapList* GetReceiverTypes() override { return &receiver_types_; } | 2266 SmallMapList* GetReceiverTypes() override { return &receiver_types_; } |
2229 IcCheckType GetKeyType() const override { | 2267 IcCheckType GetKeyType() const override { |
2230 return KeyTypeField::decode(bit_field_); | 2268 return KeyTypeField::decode(bit_field_); |
2231 } | 2269 } |
2232 KeyedAccessStoreMode GetStoreMode() const override { | 2270 KeyedAccessStoreMode GetStoreMode() const override { |
2233 return StoreModeField::decode(bit_field_); | 2271 return StoreModeField::decode(bit_field_); |
2234 } | 2272 } |
2235 Type* type() const { return type_; } | 2273 Type* type() const { return type_; } |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2285 | 2323 |
2286 | 2324 |
2287 class CompareOperation final : public Expression { | 2325 class CompareOperation final : public Expression { |
2288 public: | 2326 public: |
2289 DECLARE_NODE_TYPE(CompareOperation) | 2327 DECLARE_NODE_TYPE(CompareOperation) |
2290 | 2328 |
2291 Token::Value op() const { return op_; } | 2329 Token::Value op() const { return op_; } |
2292 Expression* left() const { return left_; } | 2330 Expression* left() const { return left_; } |
2293 Expression* right() const { return right_; } | 2331 Expression* right() const { return right_; } |
2294 | 2332 |
2333 void set_left(Expression* e) { left_ = e; } | |
2334 void set_right(Expression* e) { right_ = e; } | |
2335 | |
2295 // Type feedback information. | 2336 // Type feedback information. |
2296 static int num_ids() { return parent_num_ids() + 1; } | 2337 static int num_ids() { return parent_num_ids() + 1; } |
2297 TypeFeedbackId CompareOperationFeedbackId() const { | 2338 TypeFeedbackId CompareOperationFeedbackId() const { |
2298 return TypeFeedbackId(local_id(0)); | 2339 return TypeFeedbackId(local_id(0)); |
2299 } | 2340 } |
2300 Type* combined_type() const { return combined_type_; } | 2341 Type* combined_type() const { return combined_type_; } |
2301 void set_combined_type(Type* type) { combined_type_ = type; } | 2342 void set_combined_type(Type* type) { combined_type_ = type; } |
2302 | 2343 |
2303 // Match special cases. | 2344 // Match special cases. |
2304 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); | 2345 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); |
(...skipping 21 matching lines...) Expand all Loading... | |
2326 | 2367 |
2327 Type* combined_type_; | 2368 Type* combined_type_; |
2328 }; | 2369 }; |
2329 | 2370 |
2330 | 2371 |
2331 class Spread final : public Expression { | 2372 class Spread final : public Expression { |
2332 public: | 2373 public: |
2333 DECLARE_NODE_TYPE(Spread) | 2374 DECLARE_NODE_TYPE(Spread) |
2334 | 2375 |
2335 Expression* expression() const { return expression_; } | 2376 Expression* expression() const { return expression_; } |
2377 void set_expression(Expression* e) { expression_ = e; } | |
2336 | 2378 |
2337 static int num_ids() { return parent_num_ids(); } | 2379 static int num_ids() { return parent_num_ids(); } |
2338 | 2380 |
2339 protected: | 2381 protected: |
2340 Spread(Zone* zone, Expression* expression, int pos) | 2382 Spread(Zone* zone, Expression* expression, int pos) |
2341 : Expression(zone, pos), expression_(expression) {} | 2383 : Expression(zone, pos), expression_(expression) {} |
2342 static int parent_num_ids() { return Expression::num_ids(); } | 2384 static int parent_num_ids() { return Expression::num_ids(); } |
2343 | 2385 |
2344 private: | 2386 private: |
2345 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2387 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2346 | 2388 |
2347 Expression* expression_; | 2389 Expression* expression_; |
2348 }; | 2390 }; |
2349 | 2391 |
2350 | 2392 |
2351 class Conditional final : public Expression { | 2393 class Conditional final : public Expression { |
2352 public: | 2394 public: |
2353 DECLARE_NODE_TYPE(Conditional) | 2395 DECLARE_NODE_TYPE(Conditional) |
2354 | 2396 |
2355 Expression* condition() const { return condition_; } | 2397 Expression* condition() const { return condition_; } |
2356 Expression* then_expression() const { return then_expression_; } | 2398 Expression* then_expression() const { return then_expression_; } |
2357 Expression* else_expression() const { return else_expression_; } | 2399 Expression* else_expression() const { return else_expression_; } |
2358 | 2400 |
2401 void set_condition(Expression* e) { condition_ = e; } | |
2402 void set_then_expression(Expression* e) { then_expression_ = e; } | |
2403 void set_else_expression(Expression* e) { else_expression_ = e; } | |
2404 | |
2359 void MarkTail() override { | 2405 void MarkTail() override { |
2360 then_expression_->MarkTail(); | 2406 then_expression_->MarkTail(); |
2361 else_expression_->MarkTail(); | 2407 else_expression_->MarkTail(); |
2362 } | 2408 } |
2363 | 2409 |
2364 static int num_ids() { return parent_num_ids() + 2; } | 2410 static int num_ids() { return parent_num_ids() + 2; } |
2365 BailoutId ThenId() const { return BailoutId(local_id(0)); } | 2411 BailoutId ThenId() const { return BailoutId(local_id(0)); } |
2366 BailoutId ElseId() const { return BailoutId(local_id(1)); } | 2412 BailoutId ElseId() const { return BailoutId(local_id(1)); } |
2367 | 2413 |
2368 protected: | 2414 protected: |
(...skipping 19 matching lines...) Expand all Loading... | |
2388 DECLARE_NODE_TYPE(Assignment) | 2434 DECLARE_NODE_TYPE(Assignment) |
2389 | 2435 |
2390 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } | 2436 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } |
2391 | 2437 |
2392 Token::Value binary_op() const; | 2438 Token::Value binary_op() const; |
2393 | 2439 |
2394 Token::Value op() const { return TokenField::decode(bit_field_); } | 2440 Token::Value op() const { return TokenField::decode(bit_field_); } |
2395 Expression* target() const { return target_; } | 2441 Expression* target() const { return target_; } |
2396 Expression* value() const { return value_; } | 2442 Expression* value() const { return value_; } |
2397 | 2443 |
2444 void set_target(Expression* e) { target_ = e; } | |
2445 void set_value(Expression* e) { value_ = e; } | |
2446 | |
2398 BinaryOperation* binary_operation() const { return binary_operation_; } | 2447 BinaryOperation* binary_operation() const { return binary_operation_; } |
2399 | 2448 |
2400 // This check relies on the definition order of token in token.h. | 2449 // This check relies on the definition order of token in token.h. |
2401 bool is_compound() const { return op() > Token::ASSIGN; } | 2450 bool is_compound() const { return op() > Token::ASSIGN; } |
2402 | 2451 |
2403 static int num_ids() { return parent_num_ids() + 2; } | 2452 static int num_ids() { return parent_num_ids() + 2; } |
2404 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } | 2453 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } |
2405 | 2454 |
2406 // Type feedback information. | 2455 // Type feedback information. |
2407 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); } | 2456 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); } |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2460 }; | 2509 }; |
2461 | 2510 |
2462 | 2511 |
2463 class RewritableAssignmentExpression : public Expression { | 2512 class RewritableAssignmentExpression : public Expression { |
2464 public: | 2513 public: |
2465 DECLARE_NODE_TYPE(RewritableAssignmentExpression) | 2514 DECLARE_NODE_TYPE(RewritableAssignmentExpression) |
2466 | 2515 |
2467 Expression* expression() { return expr_; } | 2516 Expression* expression() { return expr_; } |
2468 bool is_rewritten() const { return is_rewritten_; } | 2517 bool is_rewritten() const { return is_rewritten_; } |
2469 | 2518 |
2519 void set_expression(Expression* e) { expr_ = e; } | |
2520 | |
2470 void Rewrite(Expression* new_expression) { | 2521 void Rewrite(Expression* new_expression) { |
2471 DCHECK(!is_rewritten()); | 2522 DCHECK(!is_rewritten()); |
2472 DCHECK_NOT_NULL(new_expression); | 2523 DCHECK_NOT_NULL(new_expression); |
2473 expr_ = new_expression; | 2524 expr_ = new_expression; |
2474 is_rewritten_ = true; | 2525 is_rewritten_ = true; |
2475 } | 2526 } |
2476 | 2527 |
2477 static int num_ids() { return parent_num_ids(); } | 2528 static int num_ids() { return parent_num_ids(); } |
2478 | 2529 |
2479 protected: | 2530 protected: |
(...skipping 18 matching lines...) Expand all Loading... | |
2498 kInitial, // The initial yield that returns the unboxed generator object. | 2549 kInitial, // The initial yield that returns the unboxed generator object. |
2499 kSuspend, // A normal yield: { value: EXPRESSION, done: false } | 2550 kSuspend, // A normal yield: { value: EXPRESSION, done: false } |
2500 kDelegating, // A yield*. | 2551 kDelegating, // A yield*. |
2501 kFinal // A return: { value: EXPRESSION, done: true } | 2552 kFinal // A return: { value: EXPRESSION, done: true } |
2502 }; | 2553 }; |
2503 | 2554 |
2504 Expression* generator_object() const { return generator_object_; } | 2555 Expression* generator_object() const { return generator_object_; } |
2505 Expression* expression() const { return expression_; } | 2556 Expression* expression() const { return expression_; } |
2506 Kind yield_kind() const { return yield_kind_; } | 2557 Kind yield_kind() const { return yield_kind_; } |
2507 | 2558 |
2559 void set_generator_object(Expression* e) { generator_object_ = e; } | |
2560 void set_expression(Expression* e) { expression_ = e; } | |
2561 | |
2508 // Type feedback information. | 2562 // Type feedback information. |
2509 bool HasFeedbackSlots() const { return yield_kind() == kDelegating; } | 2563 bool HasFeedbackSlots() const { return yield_kind() == kDelegating; } |
2510 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2564 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
2511 FeedbackVectorSlotCache* cache) override { | 2565 FeedbackVectorSlotCache* cache) override { |
2512 if (HasFeedbackSlots()) { | 2566 if (HasFeedbackSlots()) { |
2513 yield_first_feedback_slot_ = spec->AddKeyedLoadICSlot(); | 2567 yield_first_feedback_slot_ = spec->AddKeyedLoadICSlot(); |
2514 keyed_load_feedback_slot_ = spec->AddLoadICSlot(); | 2568 keyed_load_feedback_slot_ = spec->AddLoadICSlot(); |
2515 done_feedback_slot_ = spec->AddLoadICSlot(); | 2569 done_feedback_slot_ = spec->AddLoadICSlot(); |
2516 } | 2570 } |
2517 } | 2571 } |
(...skipping 23 matching lines...) Expand all Loading... | |
2541 FeedbackVectorSlot keyed_load_feedback_slot_; | 2595 FeedbackVectorSlot keyed_load_feedback_slot_; |
2542 FeedbackVectorSlot done_feedback_slot_; | 2596 FeedbackVectorSlot done_feedback_slot_; |
2543 }; | 2597 }; |
2544 | 2598 |
2545 | 2599 |
2546 class Throw final : public Expression { | 2600 class Throw final : public Expression { |
2547 public: | 2601 public: |
2548 DECLARE_NODE_TYPE(Throw) | 2602 DECLARE_NODE_TYPE(Throw) |
2549 | 2603 |
2550 Expression* exception() const { return exception_; } | 2604 Expression* exception() const { return exception_; } |
2605 void set_exception(Expression* e) { exception_ = e; } | |
2551 | 2606 |
2552 protected: | 2607 protected: |
2553 Throw(Zone* zone, Expression* exception, int pos) | 2608 Throw(Zone* zone, Expression* exception, int pos) |
2554 : Expression(zone, pos), exception_(exception) {} | 2609 : Expression(zone, pos), exception_(exception) {} |
2555 | 2610 |
2556 private: | 2611 private: |
2557 Expression* exception_; | 2612 Expression* exception_; |
2558 }; | 2613 }; |
2559 | 2614 |
2560 | 2615 |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2760 Handle<String> name() const { return raw_name_->string(); } | 2815 Handle<String> name() const { return raw_name_->string(); } |
2761 const AstRawString* raw_name() const { return raw_name_; } | 2816 const AstRawString* raw_name() const { return raw_name_; } |
2762 void set_raw_name(const AstRawString* name) { | 2817 void set_raw_name(const AstRawString* name) { |
2763 DCHECK_NULL(raw_name_); | 2818 DCHECK_NULL(raw_name_); |
2764 raw_name_ = name; | 2819 raw_name_ = name; |
2765 } | 2820 } |
2766 | 2821 |
2767 Scope* scope() const { return scope_; } | 2822 Scope* scope() const { return scope_; } |
2768 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; } | 2823 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; } |
2769 Expression* extends() const { return extends_; } | 2824 Expression* extends() const { return extends_; } |
2825 void set_extends(Expression* e) { extends_ = e; } | |
2770 FunctionLiteral* constructor() const { return constructor_; } | 2826 FunctionLiteral* constructor() const { return constructor_; } |
2827 void set_constructor(FunctionLiteral* f) { constructor_ = f; } | |
2771 ZoneList<Property*>* properties() const { return properties_; } | 2828 ZoneList<Property*>* properties() const { return properties_; } |
2772 int start_position() const { return position(); } | 2829 int start_position() const { return position(); } |
2773 int end_position() const { return end_position_; } | 2830 int end_position() const { return end_position_; } |
2774 | 2831 |
2775 BailoutId EntryId() const { return BailoutId(local_id(0)); } | 2832 BailoutId EntryId() const { return BailoutId(local_id(0)); } |
2776 BailoutId DeclsId() const { return BailoutId(local_id(1)); } | 2833 BailoutId DeclsId() const { return BailoutId(local_id(1)); } |
2777 BailoutId ExitId() { return BailoutId(local_id(2)); } | 2834 BailoutId ExitId() { return BailoutId(local_id(2)); } |
2778 BailoutId CreateLiteralId() const { return BailoutId(local_id(3)); } | 2835 BailoutId CreateLiteralId() const { return BailoutId(local_id(3)); } |
2779 | 2836 |
2780 // Return an AST id for a property that is used in simulate instructions. | 2837 // Return an AST id for a property that is used in simulate instructions. |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2851 protected: | 2908 protected: |
2852 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {} | 2909 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {} |
2853 }; | 2910 }; |
2854 | 2911 |
2855 | 2912 |
2856 class SuperPropertyReference final : public Expression { | 2913 class SuperPropertyReference final : public Expression { |
2857 public: | 2914 public: |
2858 DECLARE_NODE_TYPE(SuperPropertyReference) | 2915 DECLARE_NODE_TYPE(SuperPropertyReference) |
2859 | 2916 |
2860 VariableProxy* this_var() const { return this_var_; } | 2917 VariableProxy* this_var() const { return this_var_; } |
2918 void set_this_var(VariableProxy* v) { this_var_ = v; } | |
2861 Expression* home_object() const { return home_object_; } | 2919 Expression* home_object() const { return home_object_; } |
2920 void set_home_object(Expression* e) { home_object_ = e; } | |
2862 | 2921 |
2863 protected: | 2922 protected: |
2864 SuperPropertyReference(Zone* zone, VariableProxy* this_var, | 2923 SuperPropertyReference(Zone* zone, VariableProxy* this_var, |
2865 Expression* home_object, int pos) | 2924 Expression* home_object, int pos) |
2866 : Expression(zone, pos), this_var_(this_var), home_object_(home_object) { | 2925 : Expression(zone, pos), this_var_(this_var), home_object_(home_object) { |
2867 DCHECK(this_var->is_this()); | 2926 DCHECK(this_var->is_this()); |
2868 DCHECK(home_object->IsProperty()); | 2927 DCHECK(home_object->IsProperty()); |
2869 } | 2928 } |
2870 | 2929 |
2871 private: | 2930 private: |
2872 VariableProxy* this_var_; | 2931 VariableProxy* this_var_; |
2873 Expression* home_object_; | 2932 Expression* home_object_; |
2874 }; | 2933 }; |
2875 | 2934 |
2876 | 2935 |
2877 class SuperCallReference final : public Expression { | 2936 class SuperCallReference final : public Expression { |
2878 public: | 2937 public: |
2879 DECLARE_NODE_TYPE(SuperCallReference) | 2938 DECLARE_NODE_TYPE(SuperCallReference) |
2880 | 2939 |
2881 VariableProxy* this_var() const { return this_var_; } | 2940 VariableProxy* this_var() const { return this_var_; } |
2941 void set_this_var(VariableProxy* v) { this_var_ = v; } | |
2882 VariableProxy* new_target_var() const { return new_target_var_; } | 2942 VariableProxy* new_target_var() const { return new_target_var_; } |
2943 void set_new_target_var(VariableProxy* v) { new_target_var_ = v; } | |
2883 VariableProxy* this_function_var() const { return this_function_var_; } | 2944 VariableProxy* this_function_var() const { return this_function_var_; } |
2945 void set_this_function_var(VariableProxy* v) { this_function_var_ = v; } | |
2884 | 2946 |
2885 protected: | 2947 protected: |
2886 SuperCallReference(Zone* zone, VariableProxy* this_var, | 2948 SuperCallReference(Zone* zone, VariableProxy* this_var, |
2887 VariableProxy* new_target_var, | 2949 VariableProxy* new_target_var, |
2888 VariableProxy* this_function_var, int pos) | 2950 VariableProxy* this_function_var, int pos) |
2889 : Expression(zone, pos), | 2951 : Expression(zone, pos), |
2890 this_var_(this_var), | 2952 this_var_(this_var), |
2891 new_target_var_(new_target_var), | 2953 new_target_var_(new_target_var), |
2892 this_function_var_(this_function_var) { | 2954 this_function_var_(this_function_var) { |
2893 DCHECK(this_var->is_this()); | 2955 DCHECK(this_var->is_this()); |
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3317 } \ | 3379 } \ |
3318 \ | 3380 \ |
3319 void InitializeAstVisitor(uintptr_t stack_limit) { \ | 3381 void InitializeAstVisitor(uintptr_t stack_limit) { \ |
3320 stack_limit_ = stack_limit; \ | 3382 stack_limit_ = stack_limit; \ |
3321 stack_overflow_ = false; \ | 3383 stack_overflow_ = false; \ |
3322 } \ | 3384 } \ |
3323 \ | 3385 \ |
3324 uintptr_t stack_limit_; \ | 3386 uintptr_t stack_limit_; \ |
3325 bool stack_overflow_ | 3387 bool stack_overflow_ |
3326 | 3388 |
3389 #define DEFINE_AST_REWRITER_SUBCLASS_MEMBERS() \ | |
3390 public: \ | |
3391 AstNode* Rewrite(AstNode* node) { \ | |
3392 DCHECK_NULL(replacement_); \ | |
3393 DCHECK_NOT_NULL(node); \ | |
3394 Visit(node); \ | |
3395 if (HasStackOverflow()) return node; \ | |
nickie
2016/01/11 10:24:18
Small fix #2: in case of failure, a non-null node
| |
3396 if (replacement_ == nullptr) return node; \ | |
3397 AstNode* result = replacement_; \ | |
3398 replacement_ = nullptr; \ | |
3399 return result; \ | |
3400 } \ | |
3401 \ | |
3402 private: \ | |
3403 void InitializeAstRewriter(Isolate* isolate) { \ | |
3404 InitializeAstVisitor(isolate); \ | |
3405 replacement_ = nullptr; \ | |
3406 } \ | |
3407 \ | |
3408 void InitializeAstRewriter(uintptr_t stack_limit) { \ | |
3409 InitializeAstVisitor(stack_limit); \ | |
3410 replacement_ = nullptr; \ | |
3411 } \ | |
3412 \ | |
3413 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); \ | |
3414 \ | |
3415 protected: \ | |
3416 AstNode* replacement_ | |
3417 | |
3418 // Generic macro for rewriting things; `GET` is the expression to be | |
3419 // rewritten; `SET` is a command that should do the rewriting, i.e. | |
3420 // something sensible with the variable called `replacement`. | |
3421 #define AST_REWRITE(Type, GET, SET) \ | |
3422 do { \ | |
3423 DCHECK(!HasStackOverflow()); \ | |
3424 DCHECK_NULL(replacement_); \ | |
3425 Visit(GET); \ | |
3426 if (HasStackOverflow()) return; \ | |
3427 if (replacement_ == nullptr) break; \ | |
3428 Type* replacement = reinterpret_cast<Type*>(replacement_); \ | |
3429 do { \ | |
3430 SET; \ | |
3431 } while (false); \ | |
3432 replacement_ = nullptr; \ | |
3433 } while (false) | |
3434 | |
3435 // Macro for rewriting object properties; it assumes that `object` has | |
3436 // `property` with a public getter and setter. | |
3437 #define AST_REWRITE_PROPERTY(Type, object, property) \ | |
3438 do { \ | |
3439 auto _obj = (object); \ | |
3440 AST_REWRITE(Type, _obj->property(), _obj->set_##property(replacement)); \ | |
3441 } while (false) | |
3442 | |
3443 // Macro for rewriting list elements; it assumes that `list` has methods | |
3444 // `at` and `Set`. | |
3445 #define AST_REWRITE_LIST_ELEMENT(Type, list, index) \ | |
3446 do { \ | |
3447 auto _list = (list); \ | |
3448 auto _index = (index); \ | |
3449 AST_REWRITE(Type, _list->at(_index), _list->Set(_index, replacement)); \ | |
3450 } while (false) | |
3451 | |
3327 | 3452 |
3328 // ---------------------------------------------------------------------------- | 3453 // ---------------------------------------------------------------------------- |
3329 // AstNode factory | 3454 // AstNode factory |
3330 | 3455 |
3331 class AstNodeFactory final BASE_EMBEDDED { | 3456 class AstNodeFactory final BASE_EMBEDDED { |
3332 public: | 3457 public: |
3333 explicit AstNodeFactory(AstValueFactory* ast_value_factory) | 3458 explicit AstNodeFactory(AstValueFactory* ast_value_factory) |
3334 : local_zone_(ast_value_factory->zone()), | 3459 : local_zone_(ast_value_factory->zone()), |
3335 parser_zone_(ast_value_factory->zone()), | 3460 parser_zone_(ast_value_factory->zone()), |
3336 ast_value_factory_(ast_value_factory) {} | 3461 ast_value_factory_(ast_value_factory) {} |
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3769 // the parser-level zone. | 3894 // the parser-level zone. |
3770 Zone* parser_zone_; | 3895 Zone* parser_zone_; |
3771 AstValueFactory* ast_value_factory_; | 3896 AstValueFactory* ast_value_factory_; |
3772 }; | 3897 }; |
3773 | 3898 |
3774 | 3899 |
3775 } // namespace internal | 3900 } // namespace internal |
3776 } // namespace v8 | 3901 } // namespace v8 |
3777 | 3902 |
3778 #endif // V8_AST_AST_H_ | 3903 #endif // V8_AST_AST_H_ |
OLD | NEW |