Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(98)

Side by Side Diff: src/ast/ast.h

Issue 1565153002: Add a generic mechanism for expression rewriting (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « BUILD.gn ('k') | src/ast/ast-expression-rewriter.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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
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
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
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
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
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 172 matching lines...) Expand 10 before | Expand all | Expand 10 after
993 BreakableStatement* target_; 1005 BreakableStatement* target_;
994 }; 1006 };
995 1007
996 1008
997 class ReturnStatement final : public JumpStatement { 1009 class ReturnStatement final : public JumpStatement {
998 public: 1010 public:
999 DECLARE_NODE_TYPE(ReturnStatement) 1011 DECLARE_NODE_TYPE(ReturnStatement)
1000 1012
1001 Expression* expression() const { return expression_; } 1013 Expression* expression() const { return expression_; }
1002 1014
1015 void set_expression(Expression* e) { expression_ = e; }
1016
1003 protected: 1017 protected:
1004 explicit ReturnStatement(Zone* zone, Expression* expression, int pos) 1018 explicit ReturnStatement(Zone* zone, Expression* expression, int pos)
1005 : JumpStatement(zone, pos), expression_(expression) { } 1019 : JumpStatement(zone, pos), expression_(expression) { }
1006 1020
1007 private: 1021 private:
1008 Expression* expression_; 1022 Expression* expression_;
1009 }; 1023 };
1010 1024
1011 1025
1012 class WithStatement final : public Statement { 1026 class WithStatement final : public Statement {
1013 public: 1027 public:
1014 DECLARE_NODE_TYPE(WithStatement) 1028 DECLARE_NODE_TYPE(WithStatement)
1015 1029
1016 Scope* scope() { return scope_; } 1030 Scope* scope() { return scope_; }
1017 Expression* expression() const { return expression_; } 1031 Expression* expression() const { return expression_; }
1032 void set_expression(Expression* e) { expression_ = e; }
1018 Statement* statement() const { return statement_; } 1033 Statement* statement() const { return statement_; }
1019 void set_statement(Statement* s) { statement_ = s; } 1034 void set_statement(Statement* s) { statement_ = s; }
1020 1035
1021 void set_base_id(int id) { base_id_ = id; } 1036 void set_base_id(int id) { base_id_ = id; }
1022 static int num_ids() { return parent_num_ids() + 2; } 1037 static int num_ids() { return parent_num_ids() + 2; }
1023 BailoutId ToObjectId() const { return BailoutId(local_id(0)); } 1038 BailoutId ToObjectId() const { return BailoutId(local_id(0)); }
1024 BailoutId EntryId() const { return BailoutId(local_id(1)); } 1039 BailoutId EntryId() const { return BailoutId(local_id(1)); }
1025 1040
1026 void MarkTail() override { statement_->MarkTail(); } 1041 void MarkTail() override { statement_->MarkTail(); }
1027 1042
(...skipping 24 matching lines...) Expand all
1052 1067
1053 class CaseClause final : public Expression { 1068 class CaseClause final : public Expression {
1054 public: 1069 public:
1055 DECLARE_NODE_TYPE(CaseClause) 1070 DECLARE_NODE_TYPE(CaseClause)
1056 1071
1057 bool is_default() const { return label_ == NULL; } 1072 bool is_default() const { return label_ == NULL; }
1058 Expression* label() const { 1073 Expression* label() const {
1059 CHECK(!is_default()); 1074 CHECK(!is_default());
1060 return label_; 1075 return label_;
1061 } 1076 }
1077 void set_label(Expression* e) { label_ = e; }
1062 Label* body_target() { return &body_target_; } 1078 Label* body_target() { return &body_target_; }
1063 ZoneList<Statement*>* statements() const { return statements_; } 1079 ZoneList<Statement*>* statements() const { return statements_; }
1064 1080
1065 static int num_ids() { return parent_num_ids() + 2; } 1081 static int num_ids() { return parent_num_ids() + 2; }
1066 BailoutId EntryId() const { return BailoutId(local_id(0)); } 1082 BailoutId EntryId() const { return BailoutId(local_id(0)); }
1067 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); } 1083 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); }
1068 1084
1069 void MarkTail() override { 1085 void MarkTail() override {
1070 if (!statements_->is_empty()) statements_->last()->MarkTail(); 1086 if (!statements_->is_empty()) statements_->last()->MarkTail();
1071 } 1087 }
(...skipping 21 matching lines...) Expand all
1093 DECLARE_NODE_TYPE(SwitchStatement) 1109 DECLARE_NODE_TYPE(SwitchStatement)
1094 1110
1095 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { 1111 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) {
1096 tag_ = tag; 1112 tag_ = tag;
1097 cases_ = cases; 1113 cases_ = cases;
1098 } 1114 }
1099 1115
1100 Expression* tag() const { return tag_; } 1116 Expression* tag() const { return tag_; }
1101 ZoneList<CaseClause*>* cases() const { return cases_; } 1117 ZoneList<CaseClause*>* cases() const { return cases_; }
1102 1118
1119 void set_tag(Expression* t) { tag_ = t; }
1120
1103 void MarkTail() override { 1121 void MarkTail() override {
1104 if (!cases_->is_empty()) cases_->last()->MarkTail(); 1122 if (!cases_->is_empty()) cases_->last()->MarkTail();
1105 } 1123 }
1106 1124
1107 protected: 1125 protected:
1108 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) 1126 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos)
1109 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), 1127 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos),
1110 tag_(NULL), 1128 tag_(NULL),
1111 cases_(NULL) {} 1129 cases_(NULL) {}
1112 1130
(...skipping 12 matching lines...) Expand all
1125 public: 1143 public:
1126 DECLARE_NODE_TYPE(IfStatement) 1144 DECLARE_NODE_TYPE(IfStatement)
1127 1145
1128 bool HasThenStatement() const { return !then_statement()->IsEmpty(); } 1146 bool HasThenStatement() const { return !then_statement()->IsEmpty(); }
1129 bool HasElseStatement() const { return !else_statement()->IsEmpty(); } 1147 bool HasElseStatement() const { return !else_statement()->IsEmpty(); }
1130 1148
1131 Expression* condition() const { return condition_; } 1149 Expression* condition() const { return condition_; }
1132 Statement* then_statement() const { return then_statement_; } 1150 Statement* then_statement() const { return then_statement_; }
1133 Statement* else_statement() const { return else_statement_; } 1151 Statement* else_statement() const { return else_statement_; }
1134 1152
1153 void set_condition(Expression* e) { condition_ = e; }
1135 void set_then_statement(Statement* s) { then_statement_ = s; } 1154 void set_then_statement(Statement* s) { then_statement_ = s; }
1136 void set_else_statement(Statement* s) { else_statement_ = s; } 1155 void set_else_statement(Statement* s) { else_statement_ = s; }
1137 1156
1138 bool IsJump() const override { 1157 bool IsJump() const override {
1139 return HasThenStatement() && then_statement()->IsJump() 1158 return HasThenStatement() && then_statement()->IsJump()
1140 && HasElseStatement() && else_statement()->IsJump(); 1159 && HasElseStatement() && else_statement()->IsJump();
1141 } 1160 }
1142 1161
1143 void MarkTail() override { 1162 void MarkTail() override {
1144 then_statement_->MarkTail(); 1163 then_statement_->MarkTail();
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
1419 COMPUTED, // Property with computed value (execution time). 1438 COMPUTED, // Property with computed value (execution time).
1420 MATERIALIZED_LITERAL, // Property value is a materialized literal. 1439 MATERIALIZED_LITERAL, // Property value is a materialized literal.
1421 GETTER, SETTER, // Property is an accessor function. 1440 GETTER, SETTER, // Property is an accessor function.
1422 PROTOTYPE // Property is __proto__. 1441 PROTOTYPE // Property is __proto__.
1423 }; 1442 };
1424 1443
1425 Expression* key() { return key_; } 1444 Expression* key() { return key_; }
1426 Expression* value() { return value_; } 1445 Expression* value() { return value_; }
1427 Kind kind() { return kind_; } 1446 Kind kind() { return kind_; }
1428 1447
1448 void set_key(Expression* e) { key_ = e; }
1449 void set_value(Expression* e) { value_ = e; }
1450
1429 // Type feedback information. 1451 // Type feedback information.
1430 bool IsMonomorphic() { return !receiver_type_.is_null(); } 1452 bool IsMonomorphic() { return !receiver_type_.is_null(); }
1431 Handle<Map> GetReceiverType() { return receiver_type_; } 1453 Handle<Map> GetReceiverType() { return receiver_type_; }
1432 1454
1433 bool IsCompileTimeValue(); 1455 bool IsCompileTimeValue();
1434 1456
1435 void set_emit_store(bool emit_store); 1457 void set_emit_store(bool emit_store);
1436 bool emit_store(); 1458 bool emit_store();
1437 1459
1438 bool is_static() const { return is_static_; } 1460 bool is_static() const { return is_static_; }
(...skipping 353 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 1814
1793 class Property final : public Expression { 1815 class Property final : public Expression {
1794 public: 1816 public:
1795 DECLARE_NODE_TYPE(Property) 1817 DECLARE_NODE_TYPE(Property)
1796 1818
1797 bool IsValidReferenceExpression() const override { return true; } 1819 bool IsValidReferenceExpression() const override { return true; }
1798 1820
1799 Expression* obj() const { return obj_; } 1821 Expression* obj() const { return obj_; }
1800 Expression* key() const { return key_; } 1822 Expression* key() const { return key_; }
1801 1823
1824 void set_obj(Expression* e) { obj_ = e; }
1825 void set_key(Expression* e) { key_ = e; }
1826
1802 static int num_ids() { return parent_num_ids() + 1; } 1827 static int num_ids() { return parent_num_ids() + 1; }
1803 BailoutId LoadId() const { return BailoutId(local_id(0)); } 1828 BailoutId LoadId() const { return BailoutId(local_id(0)); }
1804 1829
1805 bool IsStringAccess() const { 1830 bool IsStringAccess() const {
1806 return IsStringAccessField::decode(bit_field_); 1831 return IsStringAccessField::decode(bit_field_);
1807 } 1832 }
1808 1833
1809 // Type feedback information. 1834 // Type feedback information.
1810 bool IsMonomorphic() override { return receiver_types_.length() == 1; } 1835 bool IsMonomorphic() override { return receiver_types_.length() == 1; }
1811 SmallMapList* GetReceiverTypes() override { return &receiver_types_; } 1836 SmallMapList* GetReceiverTypes() override { return &receiver_types_; }
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
1883 }; 1908 };
1884 1909
1885 1910
1886 class Call final : public Expression { 1911 class Call final : public Expression {
1887 public: 1912 public:
1888 DECLARE_NODE_TYPE(Call) 1913 DECLARE_NODE_TYPE(Call)
1889 1914
1890 Expression* expression() const { return expression_; } 1915 Expression* expression() const { return expression_; }
1891 ZoneList<Expression*>* arguments() const { return arguments_; } 1916 ZoneList<Expression*>* arguments() const { return arguments_; }
1892 1917
1918 void set_expression(Expression* e) { expression_ = e; }
1919
1893 // Type feedback information. 1920 // Type feedback information.
1894 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 1921 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
1895 FeedbackVectorSlotCache* cache) override; 1922 FeedbackVectorSlotCache* cache) override;
1896 1923
1897 FeedbackVectorSlot CallFeedbackSlot() const { return stub_slot_; } 1924 FeedbackVectorSlot CallFeedbackSlot() const { return stub_slot_; }
1898 1925
1899 FeedbackVectorSlot CallFeedbackICSlot() const { return ic_slot_; } 1926 FeedbackVectorSlot CallFeedbackICSlot() const { return ic_slot_; }
1900 1927
1901 SmallMapList* GetReceiverTypes() override { 1928 SmallMapList* GetReceiverTypes() override {
1902 if (expression()->IsProperty()) { 1929 if (expression()->IsProperty()) {
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 }; 2029 };
2003 2030
2004 2031
2005 class CallNew final : public Expression { 2032 class CallNew final : public Expression {
2006 public: 2033 public:
2007 DECLARE_NODE_TYPE(CallNew) 2034 DECLARE_NODE_TYPE(CallNew)
2008 2035
2009 Expression* expression() const { return expression_; } 2036 Expression* expression() const { return expression_; }
2010 ZoneList<Expression*>* arguments() const { return arguments_; } 2037 ZoneList<Expression*>* arguments() const { return arguments_; }
2011 2038
2039 void set_expression(Expression* e) { expression_ = e; }
2040
2012 // Type feedback information. 2041 // Type feedback information.
2013 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 2042 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2014 FeedbackVectorSlotCache* cache) override { 2043 FeedbackVectorSlotCache* cache) override {
2015 callnew_feedback_slot_ = spec->AddGeneralSlot(); 2044 callnew_feedback_slot_ = spec->AddGeneralSlot();
2016 } 2045 }
2017 2046
2018 FeedbackVectorSlot CallNewFeedbackSlot() { 2047 FeedbackVectorSlot CallNewFeedbackSlot() {
2019 DCHECK(!callnew_feedback_slot_.IsInvalid()); 2048 DCHECK(!callnew_feedback_slot_.IsInvalid());
2020 return callnew_feedback_slot_; 2049 return callnew_feedback_slot_;
2021 } 2050 }
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
2111 ZoneList<Expression*>* arguments_; 2140 ZoneList<Expression*>* arguments_;
2112 }; 2141 };
2113 2142
2114 2143
2115 class UnaryOperation final : public Expression { 2144 class UnaryOperation final : public Expression {
2116 public: 2145 public:
2117 DECLARE_NODE_TYPE(UnaryOperation) 2146 DECLARE_NODE_TYPE(UnaryOperation)
2118 2147
2119 Token::Value op() const { return op_; } 2148 Token::Value op() const { return op_; }
2120 Expression* expression() const { return expression_; } 2149 Expression* expression() const { return expression_; }
2150 void set_expression(Expression* e) { expression_ = e; }
2121 2151
2122 // For unary not (Token::NOT), the AST ids where true and false will 2152 // For unary not (Token::NOT), the AST ids where true and false will
2123 // actually be materialized, respectively. 2153 // actually be materialized, respectively.
2124 static int num_ids() { return parent_num_ids() + 2; } 2154 static int num_ids() { return parent_num_ids() + 2; }
2125 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); } 2155 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); }
2126 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); } 2156 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); }
2127 2157
2128 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) override; 2158 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle) override;
2129 2159
2130 protected: 2160 protected:
(...skipping 10 matching lines...) Expand all
2141 Expression* expression_; 2171 Expression* expression_;
2142 }; 2172 };
2143 2173
2144 2174
2145 class BinaryOperation final : public Expression { 2175 class BinaryOperation final : public Expression {
2146 public: 2176 public:
2147 DECLARE_NODE_TYPE(BinaryOperation) 2177 DECLARE_NODE_TYPE(BinaryOperation)
2148 2178
2149 Token::Value op() const { return static_cast<Token::Value>(op_); } 2179 Token::Value op() const { return static_cast<Token::Value>(op_); }
2150 Expression* left() const { return left_; } 2180 Expression* left() const { return left_; }
2181 void set_left(Expression* e) { left_ = e; }
2151 Expression* right() const { return right_; } 2182 Expression* right() const { return right_; }
2183 void set_right(Expression* e) { right_ = e; }
2152 Handle<AllocationSite> allocation_site() const { return allocation_site_; } 2184 Handle<AllocationSite> allocation_site() const { return allocation_site_; }
2153 void set_allocation_site(Handle<AllocationSite> allocation_site) { 2185 void set_allocation_site(Handle<AllocationSite> allocation_site) {
2154 allocation_site_ = allocation_site; 2186 allocation_site_ = allocation_site;
2155 } 2187 }
2156 2188
2157 void MarkTail() override { 2189 void MarkTail() override {
2158 switch (op()) { 2190 switch (op()) {
2159 case Token::COMMA: 2191 case Token::COMMA:
2160 case Token::AND: 2192 case Token::AND:
2161 case Token::OR: 2193 case Token::OR:
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
2216 2248
2217 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } 2249 bool is_prefix() const { return IsPrefixField::decode(bit_field_); }
2218 bool is_postfix() const { return !is_prefix(); } 2250 bool is_postfix() const { return !is_prefix(); }
2219 2251
2220 Token::Value op() const { return TokenField::decode(bit_field_); } 2252 Token::Value op() const { return TokenField::decode(bit_field_); }
2221 Token::Value binary_op() { 2253 Token::Value binary_op() {
2222 return (op() == Token::INC) ? Token::ADD : Token::SUB; 2254 return (op() == Token::INC) ? Token::ADD : Token::SUB;
2223 } 2255 }
2224 2256
2225 Expression* expression() const { return expression_; } 2257 Expression* expression() const { return expression_; }
2258 void set_expression(Expression* e) { expression_ = e; }
2226 2259
2227 bool IsMonomorphic() override { return receiver_types_.length() == 1; } 2260 bool IsMonomorphic() override { return receiver_types_.length() == 1; }
2228 SmallMapList* GetReceiverTypes() override { return &receiver_types_; } 2261 SmallMapList* GetReceiverTypes() override { return &receiver_types_; }
2229 IcCheckType GetKeyType() const override { 2262 IcCheckType GetKeyType() const override {
2230 return KeyTypeField::decode(bit_field_); 2263 return KeyTypeField::decode(bit_field_);
2231 } 2264 }
2232 KeyedAccessStoreMode GetStoreMode() const override { 2265 KeyedAccessStoreMode GetStoreMode() const override {
2233 return StoreModeField::decode(bit_field_); 2266 return StoreModeField::decode(bit_field_);
2234 } 2267 }
2235 Type* type() const { return type_; } 2268 Type* type() const { return type_; }
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
2285 2318
2286 2319
2287 class CompareOperation final : public Expression { 2320 class CompareOperation final : public Expression {
2288 public: 2321 public:
2289 DECLARE_NODE_TYPE(CompareOperation) 2322 DECLARE_NODE_TYPE(CompareOperation)
2290 2323
2291 Token::Value op() const { return op_; } 2324 Token::Value op() const { return op_; }
2292 Expression* left() const { return left_; } 2325 Expression* left() const { return left_; }
2293 Expression* right() const { return right_; } 2326 Expression* right() const { return right_; }
2294 2327
2328 void set_left(Expression* e) { left_ = e; }
2329 void set_right(Expression* e) { right_ = e; }
2330
2295 // Type feedback information. 2331 // Type feedback information.
2296 static int num_ids() { return parent_num_ids() + 1; } 2332 static int num_ids() { return parent_num_ids() + 1; }
2297 TypeFeedbackId CompareOperationFeedbackId() const { 2333 TypeFeedbackId CompareOperationFeedbackId() const {
2298 return TypeFeedbackId(local_id(0)); 2334 return TypeFeedbackId(local_id(0));
2299 } 2335 }
2300 Type* combined_type() const { return combined_type_; } 2336 Type* combined_type() const { return combined_type_; }
2301 void set_combined_type(Type* type) { combined_type_ = type; } 2337 void set_combined_type(Type* type) { combined_type_ = type; }
2302 2338
2303 // Match special cases. 2339 // Match special cases.
2304 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); 2340 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check);
(...skipping 21 matching lines...) Expand all
2326 2362
2327 Type* combined_type_; 2363 Type* combined_type_;
2328 }; 2364 };
2329 2365
2330 2366
2331 class Spread final : public Expression { 2367 class Spread final : public Expression {
2332 public: 2368 public:
2333 DECLARE_NODE_TYPE(Spread) 2369 DECLARE_NODE_TYPE(Spread)
2334 2370
2335 Expression* expression() const { return expression_; } 2371 Expression* expression() const { return expression_; }
2372 void set_expression(Expression* e) { expression_ = e; }
2336 2373
2337 static int num_ids() { return parent_num_ids(); } 2374 static int num_ids() { return parent_num_ids(); }
2338 2375
2339 protected: 2376 protected:
2340 Spread(Zone* zone, Expression* expression, int pos) 2377 Spread(Zone* zone, Expression* expression, int pos)
2341 : Expression(zone, pos), expression_(expression) {} 2378 : Expression(zone, pos), expression_(expression) {}
2342 static int parent_num_ids() { return Expression::num_ids(); } 2379 static int parent_num_ids() { return Expression::num_ids(); }
2343 2380
2344 private: 2381 private:
2345 int local_id(int n) const { return base_id() + parent_num_ids() + n; } 2382 int local_id(int n) const { return base_id() + parent_num_ids() + n; }
2346 2383
2347 Expression* expression_; 2384 Expression* expression_;
2348 }; 2385 };
2349 2386
2350 2387
2351 class Conditional final : public Expression { 2388 class Conditional final : public Expression {
2352 public: 2389 public:
2353 DECLARE_NODE_TYPE(Conditional) 2390 DECLARE_NODE_TYPE(Conditional)
2354 2391
2355 Expression* condition() const { return condition_; } 2392 Expression* condition() const { return condition_; }
2356 Expression* then_expression() const { return then_expression_; } 2393 Expression* then_expression() const { return then_expression_; }
2357 Expression* else_expression() const { return else_expression_; } 2394 Expression* else_expression() const { return else_expression_; }
2358 2395
2396 void set_condition(Expression* e) { condition_ = e; }
2397 void set_then_expression(Expression* e) { then_expression_ = e; }
2398 void set_else_expression(Expression* e) { else_expression_ = e; }
2399
2359 void MarkTail() override { 2400 void MarkTail() override {
2360 then_expression_->MarkTail(); 2401 then_expression_->MarkTail();
2361 else_expression_->MarkTail(); 2402 else_expression_->MarkTail();
2362 } 2403 }
2363 2404
2364 static int num_ids() { return parent_num_ids() + 2; } 2405 static int num_ids() { return parent_num_ids() + 2; }
2365 BailoutId ThenId() const { return BailoutId(local_id(0)); } 2406 BailoutId ThenId() const { return BailoutId(local_id(0)); }
2366 BailoutId ElseId() const { return BailoutId(local_id(1)); } 2407 BailoutId ElseId() const { return BailoutId(local_id(1)); }
2367 2408
2368 protected: 2409 protected:
(...skipping 19 matching lines...) Expand all
2388 DECLARE_NODE_TYPE(Assignment) 2429 DECLARE_NODE_TYPE(Assignment)
2389 2430
2390 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } 2431 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; }
2391 2432
2392 Token::Value binary_op() const; 2433 Token::Value binary_op() const;
2393 2434
2394 Token::Value op() const { return TokenField::decode(bit_field_); } 2435 Token::Value op() const { return TokenField::decode(bit_field_); }
2395 Expression* target() const { return target_; } 2436 Expression* target() const { return target_; }
2396 Expression* value() const { return value_; } 2437 Expression* value() const { return value_; }
2397 2438
2439 void set_target(Expression* e) { target_ = e; }
2440 void set_value(Expression* e) { value_ = e; }
2441
2398 BinaryOperation* binary_operation() const { return binary_operation_; } 2442 BinaryOperation* binary_operation() const { return binary_operation_; }
2399 2443
2400 // This check relies on the definition order of token in token.h. 2444 // This check relies on the definition order of token in token.h.
2401 bool is_compound() const { return op() > Token::ASSIGN; } 2445 bool is_compound() const { return op() > Token::ASSIGN; }
2402 2446
2403 static int num_ids() { return parent_num_ids() + 2; } 2447 static int num_ids() { return parent_num_ids() + 2; }
2404 BailoutId AssignmentId() const { return BailoutId(local_id(0)); } 2448 BailoutId AssignmentId() const { return BailoutId(local_id(0)); }
2405 2449
2406 // Type feedback information. 2450 // Type feedback information.
2407 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); } 2451 TypeFeedbackId AssignmentFeedbackId() { return TypeFeedbackId(local_id(1)); }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
2460 }; 2504 };
2461 2505
2462 2506
2463 class RewritableAssignmentExpression : public Expression { 2507 class RewritableAssignmentExpression : public Expression {
2464 public: 2508 public:
2465 DECLARE_NODE_TYPE(RewritableAssignmentExpression) 2509 DECLARE_NODE_TYPE(RewritableAssignmentExpression)
2466 2510
2467 Expression* expression() { return expr_; } 2511 Expression* expression() { return expr_; }
2468 bool is_rewritten() const { return is_rewritten_; } 2512 bool is_rewritten() const { return is_rewritten_; }
2469 2513
2514 void set_expression(Expression* e) { expr_ = e; }
2515
2470 void Rewrite(Expression* new_expression) { 2516 void Rewrite(Expression* new_expression) {
2471 DCHECK(!is_rewritten()); 2517 DCHECK(!is_rewritten());
2472 DCHECK_NOT_NULL(new_expression); 2518 DCHECK_NOT_NULL(new_expression);
2473 expr_ = new_expression; 2519 expr_ = new_expression;
2474 is_rewritten_ = true; 2520 is_rewritten_ = true;
2475 } 2521 }
2476 2522
2477 static int num_ids() { return parent_num_ids(); } 2523 static int num_ids() { return parent_num_ids(); }
2478 2524
2479 protected: 2525 protected:
(...skipping 18 matching lines...) Expand all
2498 kInitial, // The initial yield that returns the unboxed generator object. 2544 kInitial, // The initial yield that returns the unboxed generator object.
2499 kSuspend, // A normal yield: { value: EXPRESSION, done: false } 2545 kSuspend, // A normal yield: { value: EXPRESSION, done: false }
2500 kDelegating, // A yield*. 2546 kDelegating, // A yield*.
2501 kFinal // A return: { value: EXPRESSION, done: true } 2547 kFinal // A return: { value: EXPRESSION, done: true }
2502 }; 2548 };
2503 2549
2504 Expression* generator_object() const { return generator_object_; } 2550 Expression* generator_object() const { return generator_object_; }
2505 Expression* expression() const { return expression_; } 2551 Expression* expression() const { return expression_; }
2506 Kind yield_kind() const { return yield_kind_; } 2552 Kind yield_kind() const { return yield_kind_; }
2507 2553
2554 void set_generator_object(Expression* e) { generator_object_ = e; }
2555 void set_expression(Expression* e) { expression_ = e; }
2556
2508 // Type feedback information. 2557 // Type feedback information.
2509 bool HasFeedbackSlots() const { return yield_kind() == kDelegating; } 2558 bool HasFeedbackSlots() const { return yield_kind() == kDelegating; }
2510 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, 2559 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec,
2511 FeedbackVectorSlotCache* cache) override { 2560 FeedbackVectorSlotCache* cache) override {
2512 if (HasFeedbackSlots()) { 2561 if (HasFeedbackSlots()) {
2513 yield_first_feedback_slot_ = spec->AddKeyedLoadICSlot(); 2562 yield_first_feedback_slot_ = spec->AddKeyedLoadICSlot();
2514 keyed_load_feedback_slot_ = spec->AddLoadICSlot(); 2563 keyed_load_feedback_slot_ = spec->AddLoadICSlot();
2515 done_feedback_slot_ = spec->AddLoadICSlot(); 2564 done_feedback_slot_ = spec->AddLoadICSlot();
2516 } 2565 }
2517 } 2566 }
(...skipping 23 matching lines...) Expand all
2541 FeedbackVectorSlot keyed_load_feedback_slot_; 2590 FeedbackVectorSlot keyed_load_feedback_slot_;
2542 FeedbackVectorSlot done_feedback_slot_; 2591 FeedbackVectorSlot done_feedback_slot_;
2543 }; 2592 };
2544 2593
2545 2594
2546 class Throw final : public Expression { 2595 class Throw final : public Expression {
2547 public: 2596 public:
2548 DECLARE_NODE_TYPE(Throw) 2597 DECLARE_NODE_TYPE(Throw)
2549 2598
2550 Expression* exception() const { return exception_; } 2599 Expression* exception() const { return exception_; }
2600 void set_exception(Expression* e) { exception_ = e; }
2551 2601
2552 protected: 2602 protected:
2553 Throw(Zone* zone, Expression* exception, int pos) 2603 Throw(Zone* zone, Expression* exception, int pos)
2554 : Expression(zone, pos), exception_(exception) {} 2604 : Expression(zone, pos), exception_(exception) {}
2555 2605
2556 private: 2606 private:
2557 Expression* exception_; 2607 Expression* exception_;
2558 }; 2608 };
2559 2609
2560 2610
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
2760 Handle<String> name() const { return raw_name_->string(); } 2810 Handle<String> name() const { return raw_name_->string(); }
2761 const AstRawString* raw_name() const { return raw_name_; } 2811 const AstRawString* raw_name() const { return raw_name_; }
2762 void set_raw_name(const AstRawString* name) { 2812 void set_raw_name(const AstRawString* name) {
2763 DCHECK_NULL(raw_name_); 2813 DCHECK_NULL(raw_name_);
2764 raw_name_ = name; 2814 raw_name_ = name;
2765 } 2815 }
2766 2816
2767 Scope* scope() const { return scope_; } 2817 Scope* scope() const { return scope_; }
2768 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; } 2818 VariableProxy* class_variable_proxy() const { return class_variable_proxy_; }
2769 Expression* extends() const { return extends_; } 2819 Expression* extends() const { return extends_; }
2820 void set_extends(Expression* e) { extends_ = e; }
2770 FunctionLiteral* constructor() const { return constructor_; } 2821 FunctionLiteral* constructor() const { return constructor_; }
2822 void set_constructor(FunctionLiteral* f) { constructor_ = f; }
2771 ZoneList<Property*>* properties() const { return properties_; } 2823 ZoneList<Property*>* properties() const { return properties_; }
2772 int start_position() const { return position(); } 2824 int start_position() const { return position(); }
2773 int end_position() const { return end_position_; } 2825 int end_position() const { return end_position_; }
2774 2826
2775 BailoutId EntryId() const { return BailoutId(local_id(0)); } 2827 BailoutId EntryId() const { return BailoutId(local_id(0)); }
2776 BailoutId DeclsId() const { return BailoutId(local_id(1)); } 2828 BailoutId DeclsId() const { return BailoutId(local_id(1)); }
2777 BailoutId ExitId() { return BailoutId(local_id(2)); } 2829 BailoutId ExitId() { return BailoutId(local_id(2)); }
2778 BailoutId CreateLiteralId() const { return BailoutId(local_id(3)); } 2830 BailoutId CreateLiteralId() const { return BailoutId(local_id(3)); }
2779 2831
2780 // Return an AST id for a property that is used in simulate instructions. 2832 // 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
2851 protected: 2903 protected:
2852 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {} 2904 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {}
2853 }; 2905 };
2854 2906
2855 2907
2856 class SuperPropertyReference final : public Expression { 2908 class SuperPropertyReference final : public Expression {
2857 public: 2909 public:
2858 DECLARE_NODE_TYPE(SuperPropertyReference) 2910 DECLARE_NODE_TYPE(SuperPropertyReference)
2859 2911
2860 VariableProxy* this_var() const { return this_var_; } 2912 VariableProxy* this_var() const { return this_var_; }
2913 void set_this_var(VariableProxy* v) { this_var_ = v; }
2861 Expression* home_object() const { return home_object_; } 2914 Expression* home_object() const { return home_object_; }
2915 void set_home_object(Expression* e) { home_object_ = e; }
2862 2916
2863 protected: 2917 protected:
2864 SuperPropertyReference(Zone* zone, VariableProxy* this_var, 2918 SuperPropertyReference(Zone* zone, VariableProxy* this_var,
2865 Expression* home_object, int pos) 2919 Expression* home_object, int pos)
2866 : Expression(zone, pos), this_var_(this_var), home_object_(home_object) { 2920 : Expression(zone, pos), this_var_(this_var), home_object_(home_object) {
2867 DCHECK(this_var->is_this()); 2921 DCHECK(this_var->is_this());
2868 DCHECK(home_object->IsProperty()); 2922 DCHECK(home_object->IsProperty());
2869 } 2923 }
2870 2924
2871 private: 2925 private:
2872 VariableProxy* this_var_; 2926 VariableProxy* this_var_;
2873 Expression* home_object_; 2927 Expression* home_object_;
2874 }; 2928 };
2875 2929
2876 2930
2877 class SuperCallReference final : public Expression { 2931 class SuperCallReference final : public Expression {
2878 public: 2932 public:
2879 DECLARE_NODE_TYPE(SuperCallReference) 2933 DECLARE_NODE_TYPE(SuperCallReference)
2880 2934
2881 VariableProxy* this_var() const { return this_var_; } 2935 VariableProxy* this_var() const { return this_var_; }
2936 void set_this_var(VariableProxy* v) { this_var_ = v; }
2882 VariableProxy* new_target_var() const { return new_target_var_; } 2937 VariableProxy* new_target_var() const { return new_target_var_; }
2938 void set_new_target_var(VariableProxy* v) { new_target_var_ = v; }
2883 VariableProxy* this_function_var() const { return this_function_var_; } 2939 VariableProxy* this_function_var() const { return this_function_var_; }
2940 void set_this_function_var(VariableProxy* v) { this_function_var_ = v; }
2884 2941
2885 protected: 2942 protected:
2886 SuperCallReference(Zone* zone, VariableProxy* this_var, 2943 SuperCallReference(Zone* zone, VariableProxy* this_var,
2887 VariableProxy* new_target_var, 2944 VariableProxy* new_target_var,
2888 VariableProxy* this_function_var, int pos) 2945 VariableProxy* this_function_var, int pos)
2889 : Expression(zone, pos), 2946 : Expression(zone, pos),
2890 this_var_(this_var), 2947 this_var_(this_var),
2891 new_target_var_(new_target_var), 2948 new_target_var_(new_target_var),
2892 this_function_var_(this_function_var) { 2949 this_function_var_(this_function_var) {
2893 DCHECK(this_var->is_this()); 2950 DCHECK(this_var->is_this());
(...skipping 423 matching lines...) Expand 10 before | Expand all | Expand 10 after
3317 } \ 3374 } \
3318 \ 3375 \
3319 void InitializeAstVisitor(uintptr_t stack_limit) { \ 3376 void InitializeAstVisitor(uintptr_t stack_limit) { \
3320 stack_limit_ = stack_limit; \ 3377 stack_limit_ = stack_limit; \
3321 stack_overflow_ = false; \ 3378 stack_overflow_ = false; \
3322 } \ 3379 } \
3323 \ 3380 \
3324 uintptr_t stack_limit_; \ 3381 uintptr_t stack_limit_; \
3325 bool stack_overflow_ 3382 bool stack_overflow_
3326 3383
3384 #define DEFINE_AST_REWRITER_SUBCLASS_MEMBERS() \
3385 public: \
3386 AstNode* Rewrite(AstNode* node) { \
3387 DCHECK_NULL(replacement_); \
3388 Visit(node); \
3389 if (HasStackOverflow()) return nullptr; \
3390 if (replacement_ == nullptr) return node; \
3391 AstNode* result = replacement_; \
3392 replacement_ = nullptr; \
3393 return result; \
3394 } \
3395 \
3396 private: \
3397 void InitializeAstRewriter(Isolate* isolate) { \
3398 InitializeAstVisitor(isolate); \
3399 replacement_ = nullptr; \
3400 } \
3401 \
3402 void InitializeAstRewriter(uintptr_t stack_limit) { \
3403 InitializeAstVisitor(stack_limit); \
3404 replacement_ = nullptr; \
3405 } \
3406 \
3407 DEFINE_AST_VISITOR_SUBCLASS_MEMBERS(); \
3408 \
3409 protected: \
3410 AstNode* replacement_
3411
3412 // Macro for rewriting things; `GET` is the expression to be rewritten;
3413 // `SET` is a command that should do the rewriting, i.e. something
3414 // sensible with the variable called `replacement`.
3415 #define AST_REWRITE(Type, GET, SET) \
rossberg 2016/01/08 10:36:57 Can this macro be simplified to just AST_REWRITE(T
rossberg 2016/01/08 10:36:57 Is there a strong reason to put this here instead
nickie 2016/01/08 13:22:09 Most of its uses are of the form: AST_REWRITE
nickie 2016/01/08 13:22:09 I think that the macro will be useful in classes d
3416 do { \
3417 DCHECK(!HasStackOverflow()); \
3418 DCHECK_NULL(replacement_); \
3419 Visit(GET); \
3420 if (HasStackOverflow()) return; \
3421 if (replacement_ == nullptr) break; \
3422 Type* replacement = reinterpret_cast<Type*>(replacement_); \
3423 do { \
3424 SET; \
3425 } while (false); \
3426 replacement_ = nullptr; \
3427 } while (false)
3428
3327 3429
3328 // ---------------------------------------------------------------------------- 3430 // ----------------------------------------------------------------------------
3329 // AstNode factory 3431 // AstNode factory
3330 3432
3331 class AstNodeFactory final BASE_EMBEDDED { 3433 class AstNodeFactory final BASE_EMBEDDED {
3332 public: 3434 public:
3333 explicit AstNodeFactory(AstValueFactory* ast_value_factory) 3435 explicit AstNodeFactory(AstValueFactory* ast_value_factory)
3334 : local_zone_(ast_value_factory->zone()), 3436 : local_zone_(ast_value_factory->zone()),
3335 parser_zone_(ast_value_factory->zone()), 3437 parser_zone_(ast_value_factory->zone()),
3336 ast_value_factory_(ast_value_factory) {} 3438 ast_value_factory_(ast_value_factory) {}
(...skipping 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
3769 // the parser-level zone. 3871 // the parser-level zone.
3770 Zone* parser_zone_; 3872 Zone* parser_zone_;
3771 AstValueFactory* ast_value_factory_; 3873 AstValueFactory* ast_value_factory_;
3772 }; 3874 };
3773 3875
3774 3876
3775 } // namespace internal 3877 } // namespace internal
3776 } // namespace v8 3878 } // namespace v8
3777 3879
3778 #endif // V8_AST_AST_H_ 3880 #endif // V8_AST_AST_H_
OLDNEW
« no previous file with comments | « BUILD.gn ('k') | src/ast/ast-expression-rewriter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698