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 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
244 int position_; | 244 int position_; |
245 }; | 245 }; |
246 | 246 |
247 | 247 |
248 class Statement : public AstNode { | 248 class Statement : public AstNode { |
249 public: | 249 public: |
250 explicit Statement(Zone* zone, int position) : AstNode(position) {} | 250 explicit Statement(Zone* zone, int position) : AstNode(position) {} |
251 | 251 |
252 bool IsEmpty() { return AsEmptyStatement() != NULL; } | 252 bool IsEmpty() { return AsEmptyStatement() != NULL; } |
253 virtual bool IsJump() const { return false; } | 253 virtual bool IsJump() const { return false; } |
| 254 virtual void MarkTail() {} |
254 }; | 255 }; |
255 | 256 |
256 | 257 |
257 class SmallMapList final { | 258 class SmallMapList final { |
258 public: | 259 public: |
259 SmallMapList() {} | 260 SmallMapList() {} |
260 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} | 261 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} |
261 | 262 |
262 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); } | 263 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); } |
263 void Clear() { list_.Clear(); } | 264 void Clear() { list_.Clear(); } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
308 // code generation. | 309 // code generation. |
309 kUninitialized, | 310 kUninitialized, |
310 // Evaluated for its side effects. | 311 // Evaluated for its side effects. |
311 kEffect, | 312 kEffect, |
312 // Evaluated for its value (and side effects). | 313 // Evaluated for its value (and side effects). |
313 kValue, | 314 kValue, |
314 // Evaluated for control flow (and side effects). | 315 // Evaluated for control flow (and side effects). |
315 kTest | 316 kTest |
316 }; | 317 }; |
317 | 318 |
| 319 // Mark this expression as being in tail position. |
| 320 virtual void MarkTail() {} |
| 321 |
318 // True iff the expression is a valid reference expression. | 322 // True iff the expression is a valid reference expression. |
319 virtual bool IsValidReferenceExpression() const { return false; } | 323 virtual bool IsValidReferenceExpression() const { return false; } |
320 | 324 |
321 // Helpers for ToBoolean conversion. | 325 // Helpers for ToBoolean conversion. |
322 virtual bool ToBooleanIsTrue() const { return false; } | 326 virtual bool ToBooleanIsTrue() const { return false; } |
323 virtual bool ToBooleanIsFalse() const { return false; } | 327 virtual bool ToBooleanIsFalse() const { return false; } |
324 | 328 |
325 // Symbols that cannot be parsed as array indices are considered property | 329 // Symbols that cannot be parsed as array indices are considered property |
326 // names. We do not treat symbols that can be array indexes as property | 330 // names. We do not treat symbols that can be array indexes as property |
327 // names because [] for string objects is handled only by keyed ICs. | 331 // names because [] for string objects is handled only by keyed ICs. |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 bool ignore_completion_value() const { return ignore_completion_value_; } | 468 bool ignore_completion_value() const { return ignore_completion_value_; } |
465 | 469 |
466 static int num_ids() { return parent_num_ids() + 1; } | 470 static int num_ids() { return parent_num_ids() + 1; } |
467 BailoutId DeclsId() const { return BailoutId(local_id(0)); } | 471 BailoutId DeclsId() const { return BailoutId(local_id(0)); } |
468 | 472 |
469 bool IsJump() const override { | 473 bool IsJump() const override { |
470 return !statements_.is_empty() && statements_.last()->IsJump() | 474 return !statements_.is_empty() && statements_.last()->IsJump() |
471 && labels() == NULL; // Good enough as an approximation... | 475 && labels() == NULL; // Good enough as an approximation... |
472 } | 476 } |
473 | 477 |
| 478 void MarkTail() override { |
| 479 if (!statements_.is_empty()) statements_.last()->MarkTail(); |
| 480 } |
| 481 |
474 Scope* scope() const { return scope_; } | 482 Scope* scope() const { return scope_; } |
475 void set_scope(Scope* scope) { scope_ = scope; } | 483 void set_scope(Scope* scope) { scope_ = scope; } |
476 | 484 |
477 protected: | 485 protected: |
478 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, | 486 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, |
479 bool ignore_completion_value, int pos) | 487 bool ignore_completion_value, int pos) |
480 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos), | 488 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos), |
481 statements_(capacity, zone), | 489 statements_(capacity, zone), |
482 ignore_completion_value_(ignore_completion_value), | 490 ignore_completion_value_(ignore_completion_value), |
483 scope_(NULL) {} | 491 scope_(NULL) {} |
484 static int parent_num_ids() { return BreakableStatement::num_ids(); } | 492 static int parent_num_ids() { return BreakableStatement::num_ids(); } |
485 | 493 |
486 private: | 494 private: |
487 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 495 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
488 | 496 |
489 ZoneList<Statement*> statements_; | 497 ZoneList<Statement*> statements_; |
490 bool ignore_completion_value_; | 498 bool ignore_completion_value_; |
491 Scope* scope_; | 499 Scope* scope_; |
492 }; | 500 }; |
493 | 501 |
494 | 502 |
495 class DoExpression final : public Expression { | 503 class DoExpression final : public Expression { |
496 public: | 504 public: |
497 DECLARE_NODE_TYPE(DoExpression) | 505 DECLARE_NODE_TYPE(DoExpression) |
498 | 506 |
499 Block* block() { return block_; } | 507 Block* block() { return block_; } |
500 VariableProxy* result() { return result_; } | 508 VariableProxy* result() { return result_; } |
501 | 509 |
| 510 void MarkTail() override { block_->MarkTail(); } |
| 511 |
502 protected: | 512 protected: |
503 DoExpression(Zone* zone, Block* block, VariableProxy* result, int pos) | 513 DoExpression(Zone* zone, Block* block, VariableProxy* result, int pos) |
504 : Expression(zone, pos), block_(block), result_(result) { | 514 : Expression(zone, pos), block_(block), result_(result) { |
505 DCHECK_NOT_NULL(block_); | 515 DCHECK_NOT_NULL(block_); |
506 DCHECK_NOT_NULL(result_); | 516 DCHECK_NOT_NULL(result_); |
507 } | 517 } |
508 static int parent_num_ids() { return Expression::num_ids(); } | 518 static int parent_num_ids() { return Expression::num_ids(); } |
509 | 519 |
510 private: | 520 private: |
511 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 521 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
(...skipping 415 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
927 }; | 937 }; |
928 | 938 |
929 | 939 |
930 class ExpressionStatement final : public Statement { | 940 class ExpressionStatement final : public Statement { |
931 public: | 941 public: |
932 DECLARE_NODE_TYPE(ExpressionStatement) | 942 DECLARE_NODE_TYPE(ExpressionStatement) |
933 | 943 |
934 void set_expression(Expression* e) { expression_ = e; } | 944 void set_expression(Expression* e) { expression_ = e; } |
935 Expression* expression() const { return expression_; } | 945 Expression* expression() const { return expression_; } |
936 bool IsJump() const override { return expression_->IsThrow(); } | 946 bool IsJump() const override { return expression_->IsThrow(); } |
| 947 void MarkTail() override { expression_->MarkTail(); } |
937 | 948 |
938 protected: | 949 protected: |
939 ExpressionStatement(Zone* zone, Expression* expression, int pos) | 950 ExpressionStatement(Zone* zone, Expression* expression, int pos) |
940 : Statement(zone, pos), expression_(expression) { } | 951 : Statement(zone, pos), expression_(expression) { } |
941 | 952 |
942 private: | 953 private: |
943 Expression* expression_; | 954 Expression* expression_; |
944 }; | 955 }; |
945 | 956 |
946 | 957 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1005 Scope* scope() { return scope_; } | 1016 Scope* scope() { return scope_; } |
1006 Expression* expression() const { return expression_; } | 1017 Expression* expression() const { return expression_; } |
1007 Statement* statement() const { return statement_; } | 1018 Statement* statement() const { return statement_; } |
1008 void set_statement(Statement* s) { statement_ = s; } | 1019 void set_statement(Statement* s) { statement_ = s; } |
1009 | 1020 |
1010 void set_base_id(int id) { base_id_ = id; } | 1021 void set_base_id(int id) { base_id_ = id; } |
1011 static int num_ids() { return parent_num_ids() + 2; } | 1022 static int num_ids() { return parent_num_ids() + 2; } |
1012 BailoutId ToObjectId() const { return BailoutId(local_id(0)); } | 1023 BailoutId ToObjectId() const { return BailoutId(local_id(0)); } |
1013 BailoutId EntryId() const { return BailoutId(local_id(1)); } | 1024 BailoutId EntryId() const { return BailoutId(local_id(1)); } |
1014 | 1025 |
| 1026 void MarkTail() override { statement_->MarkTail(); } |
| 1027 |
1015 protected: | 1028 protected: |
1016 WithStatement(Zone* zone, Scope* scope, Expression* expression, | 1029 WithStatement(Zone* zone, Scope* scope, Expression* expression, |
1017 Statement* statement, int pos) | 1030 Statement* statement, int pos) |
1018 : Statement(zone, pos), | 1031 : Statement(zone, pos), |
1019 scope_(scope), | 1032 scope_(scope), |
1020 expression_(expression), | 1033 expression_(expression), |
1021 statement_(statement), | 1034 statement_(statement), |
1022 base_id_(BailoutId::None().ToInt()) {} | 1035 base_id_(BailoutId::None().ToInt()) {} |
1023 static int parent_num_ids() { return 0; } | 1036 static int parent_num_ids() { return 0; } |
1024 | 1037 |
(...skipping 21 matching lines...) Expand all Loading... |
1046 CHECK(!is_default()); | 1059 CHECK(!is_default()); |
1047 return label_; | 1060 return label_; |
1048 } | 1061 } |
1049 Label* body_target() { return &body_target_; } | 1062 Label* body_target() { return &body_target_; } |
1050 ZoneList<Statement*>* statements() const { return statements_; } | 1063 ZoneList<Statement*>* statements() const { return statements_; } |
1051 | 1064 |
1052 static int num_ids() { return parent_num_ids() + 2; } | 1065 static int num_ids() { return parent_num_ids() + 2; } |
1053 BailoutId EntryId() const { return BailoutId(local_id(0)); } | 1066 BailoutId EntryId() const { return BailoutId(local_id(0)); } |
1054 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); } | 1067 TypeFeedbackId CompareId() { return TypeFeedbackId(local_id(1)); } |
1055 | 1068 |
| 1069 void MarkTail() override { |
| 1070 if (!statements_->is_empty()) statements_->last()->MarkTail(); |
| 1071 } |
| 1072 |
1056 Type* compare_type() { return compare_type_; } | 1073 Type* compare_type() { return compare_type_; } |
1057 void set_compare_type(Type* type) { compare_type_ = type; } | 1074 void set_compare_type(Type* type) { compare_type_ = type; } |
1058 | 1075 |
1059 protected: | 1076 protected: |
1060 static int parent_num_ids() { return Expression::num_ids(); } | 1077 static int parent_num_ids() { return Expression::num_ids(); } |
1061 | 1078 |
1062 private: | 1079 private: |
1063 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, | 1080 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, |
1064 int pos); | 1081 int pos); |
1065 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1082 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
(...skipping 10 matching lines...) Expand all Loading... |
1076 DECLARE_NODE_TYPE(SwitchStatement) | 1093 DECLARE_NODE_TYPE(SwitchStatement) |
1077 | 1094 |
1078 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 1095 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
1079 tag_ = tag; | 1096 tag_ = tag; |
1080 cases_ = cases; | 1097 cases_ = cases; |
1081 } | 1098 } |
1082 | 1099 |
1083 Expression* tag() const { return tag_; } | 1100 Expression* tag() const { return tag_; } |
1084 ZoneList<CaseClause*>* cases() const { return cases_; } | 1101 ZoneList<CaseClause*>* cases() const { return cases_; } |
1085 | 1102 |
| 1103 void MarkTail() override { |
| 1104 if (!cases_->is_empty()) cases_->last()->MarkTail(); |
| 1105 } |
| 1106 |
1086 protected: | 1107 protected: |
1087 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) | 1108 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
1088 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), | 1109 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
1089 tag_(NULL), | 1110 tag_(NULL), |
1090 cases_(NULL) {} | 1111 cases_(NULL) {} |
1091 | 1112 |
1092 private: | 1113 private: |
1093 Expression* tag_; | 1114 Expression* tag_; |
1094 ZoneList<CaseClause*>* cases_; | 1115 ZoneList<CaseClause*>* cases_; |
1095 }; | 1116 }; |
(...skipping 16 matching lines...) Expand all Loading... |
1112 Statement* else_statement() const { return else_statement_; } | 1133 Statement* else_statement() const { return else_statement_; } |
1113 | 1134 |
1114 void set_then_statement(Statement* s) { then_statement_ = s; } | 1135 void set_then_statement(Statement* s) { then_statement_ = s; } |
1115 void set_else_statement(Statement* s) { else_statement_ = s; } | 1136 void set_else_statement(Statement* s) { else_statement_ = s; } |
1116 | 1137 |
1117 bool IsJump() const override { | 1138 bool IsJump() const override { |
1118 return HasThenStatement() && then_statement()->IsJump() | 1139 return HasThenStatement() && then_statement()->IsJump() |
1119 && HasElseStatement() && else_statement()->IsJump(); | 1140 && HasElseStatement() && else_statement()->IsJump(); |
1120 } | 1141 } |
1121 | 1142 |
| 1143 void MarkTail() override { |
| 1144 then_statement_->MarkTail(); |
| 1145 else_statement_->MarkTail(); |
| 1146 } |
| 1147 |
1122 void set_base_id(int id) { base_id_ = id; } | 1148 void set_base_id(int id) { base_id_ = id; } |
1123 static int num_ids() { return parent_num_ids() + 3; } | 1149 static int num_ids() { return parent_num_ids() + 3; } |
1124 BailoutId IfId() const { return BailoutId(local_id(0)); } | 1150 BailoutId IfId() const { return BailoutId(local_id(0)); } |
1125 BailoutId ThenId() const { return BailoutId(local_id(1)); } | 1151 BailoutId ThenId() const { return BailoutId(local_id(1)); } |
1126 BailoutId ElseId() const { return BailoutId(local_id(2)); } | 1152 BailoutId ElseId() const { return BailoutId(local_id(2)); } |
1127 | 1153 |
1128 protected: | 1154 protected: |
1129 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, | 1155 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, |
1130 Statement* else_statement, int pos) | 1156 Statement* else_statement, int pos) |
1131 : Statement(zone, pos), | 1157 : Statement(zone, pos), |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1181 | 1207 |
1182 class TryCatchStatement final : public TryStatement { | 1208 class TryCatchStatement final : public TryStatement { |
1183 public: | 1209 public: |
1184 DECLARE_NODE_TYPE(TryCatchStatement) | 1210 DECLARE_NODE_TYPE(TryCatchStatement) |
1185 | 1211 |
1186 Scope* scope() { return scope_; } | 1212 Scope* scope() { return scope_; } |
1187 Variable* variable() { return variable_; } | 1213 Variable* variable() { return variable_; } |
1188 Block* catch_block() const { return catch_block_; } | 1214 Block* catch_block() const { return catch_block_; } |
1189 void set_catch_block(Block* b) { catch_block_ = b; } | 1215 void set_catch_block(Block* b) { catch_block_ = b; } |
1190 | 1216 |
| 1217 void MarkTail() override { catch_block_->MarkTail(); } |
| 1218 |
1191 protected: | 1219 protected: |
1192 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope, | 1220 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope, |
1193 Variable* variable, Block* catch_block, int pos) | 1221 Variable* variable, Block* catch_block, int pos) |
1194 : TryStatement(zone, try_block, pos), | 1222 : TryStatement(zone, try_block, pos), |
1195 scope_(scope), | 1223 scope_(scope), |
1196 variable_(variable), | 1224 variable_(variable), |
1197 catch_block_(catch_block) {} | 1225 catch_block_(catch_block) {} |
1198 | 1226 |
1199 private: | 1227 private: |
1200 Scope* scope_; | 1228 Scope* scope_; |
1201 Variable* variable_; | 1229 Variable* variable_; |
1202 Block* catch_block_; | 1230 Block* catch_block_; |
1203 }; | 1231 }; |
1204 | 1232 |
1205 | 1233 |
1206 class TryFinallyStatement final : public TryStatement { | 1234 class TryFinallyStatement final : public TryStatement { |
1207 public: | 1235 public: |
1208 DECLARE_NODE_TYPE(TryFinallyStatement) | 1236 DECLARE_NODE_TYPE(TryFinallyStatement) |
1209 | 1237 |
1210 Block* finally_block() const { return finally_block_; } | 1238 Block* finally_block() const { return finally_block_; } |
1211 void set_finally_block(Block* b) { finally_block_ = b; } | 1239 void set_finally_block(Block* b) { finally_block_ = b; } |
1212 | 1240 |
| 1241 void MarkTail() override { finally_block_->MarkTail(); } |
| 1242 |
1213 protected: | 1243 protected: |
1214 TryFinallyStatement(Zone* zone, Block* try_block, Block* finally_block, | 1244 TryFinallyStatement(Zone* zone, Block* try_block, Block* finally_block, |
1215 int pos) | 1245 int pos) |
1216 : TryStatement(zone, try_block, pos), finally_block_(finally_block) {} | 1246 : TryStatement(zone, try_block, pos), finally_block_(finally_block) {} |
1217 | 1247 |
1218 private: | 1248 private: |
1219 Block* finally_block_; | 1249 Block* finally_block_; |
1220 }; | 1250 }; |
1221 | 1251 |
1222 | 1252 |
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1903 BailoutId LookupId() const { return BailoutId(local_id(2)); } | 1933 BailoutId LookupId() const { return BailoutId(local_id(2)); } |
1904 BailoutId CallId() const { return BailoutId(local_id(3)); } | 1934 BailoutId CallId() const { return BailoutId(local_id(3)); } |
1905 | 1935 |
1906 bool is_uninitialized() const { | 1936 bool is_uninitialized() const { |
1907 return IsUninitializedField::decode(bit_field_); | 1937 return IsUninitializedField::decode(bit_field_); |
1908 } | 1938 } |
1909 void set_is_uninitialized(bool b) { | 1939 void set_is_uninitialized(bool b) { |
1910 bit_field_ = IsUninitializedField::update(bit_field_, b); | 1940 bit_field_ = IsUninitializedField::update(bit_field_, b); |
1911 } | 1941 } |
1912 | 1942 |
| 1943 bool is_tail() const { return IsTailField::decode(bit_field_); } |
| 1944 void MarkTail() override { |
| 1945 bit_field_ = IsTailField::update(bit_field_, true); |
| 1946 } |
| 1947 |
1913 enum CallType { | 1948 enum CallType { |
1914 POSSIBLY_EVAL_CALL, | 1949 POSSIBLY_EVAL_CALL, |
1915 GLOBAL_CALL, | 1950 GLOBAL_CALL, |
1916 LOOKUP_SLOT_CALL, | 1951 LOOKUP_SLOT_CALL, |
1917 NAMED_PROPERTY_CALL, | 1952 NAMED_PROPERTY_CALL, |
1918 KEYED_PROPERTY_CALL, | 1953 KEYED_PROPERTY_CALL, |
1919 NAMED_SUPER_PROPERTY_CALL, | 1954 NAMED_SUPER_PROPERTY_CALL, |
1920 KEYED_SUPER_PROPERTY_CALL, | 1955 KEYED_SUPER_PROPERTY_CALL, |
1921 SUPER_CALL, | 1956 SUPER_CALL, |
1922 OTHER_CALL | 1957 OTHER_CALL |
(...skipping 25 matching lines...) Expand all Loading... |
1948 private: | 1983 private: |
1949 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1984 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1950 | 1985 |
1951 FeedbackVectorSlot ic_slot_; | 1986 FeedbackVectorSlot ic_slot_; |
1952 FeedbackVectorSlot stub_slot_; | 1987 FeedbackVectorSlot stub_slot_; |
1953 Expression* expression_; | 1988 Expression* expression_; |
1954 ZoneList<Expression*>* arguments_; | 1989 ZoneList<Expression*>* arguments_; |
1955 Handle<JSFunction> target_; | 1990 Handle<JSFunction> target_; |
1956 Handle<AllocationSite> allocation_site_; | 1991 Handle<AllocationSite> allocation_site_; |
1957 class IsUninitializedField : public BitField8<bool, 0, 1> {}; | 1992 class IsUninitializedField : public BitField8<bool, 0, 1> {}; |
| 1993 class IsTailField : public BitField8<bool, 1, 1> {}; |
1958 uint8_t bit_field_; | 1994 uint8_t bit_field_; |
1959 }; | 1995 }; |
1960 | 1996 |
1961 | 1997 |
1962 class CallNew final : public Expression { | 1998 class CallNew final : public Expression { |
1963 public: | 1999 public: |
1964 DECLARE_NODE_TYPE(CallNew) | 2000 DECLARE_NODE_TYPE(CallNew) |
1965 | 2001 |
1966 Expression* expression() const { return expression_; } | 2002 Expression* expression() const { return expression_; } |
1967 ZoneList<Expression*>* arguments() const { return arguments_; } | 2003 ZoneList<Expression*>* arguments() const { return arguments_; } |
(...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 DECLARE_NODE_TYPE(BinaryOperation) | 2140 DECLARE_NODE_TYPE(BinaryOperation) |
2105 | 2141 |
2106 Token::Value op() const { return static_cast<Token::Value>(op_); } | 2142 Token::Value op() const { return static_cast<Token::Value>(op_); } |
2107 Expression* left() const { return left_; } | 2143 Expression* left() const { return left_; } |
2108 Expression* right() const { return right_; } | 2144 Expression* right() const { return right_; } |
2109 Handle<AllocationSite> allocation_site() const { return allocation_site_; } | 2145 Handle<AllocationSite> allocation_site() const { return allocation_site_; } |
2110 void set_allocation_site(Handle<AllocationSite> allocation_site) { | 2146 void set_allocation_site(Handle<AllocationSite> allocation_site) { |
2111 allocation_site_ = allocation_site; | 2147 allocation_site_ = allocation_site; |
2112 } | 2148 } |
2113 | 2149 |
| 2150 void MarkTail() override { |
| 2151 switch (op()) { |
| 2152 case Token::COMMA: |
| 2153 case Token::AND: |
| 2154 case Token::OR: |
| 2155 right_->MarkTail(); |
| 2156 default: |
| 2157 break; |
| 2158 } |
| 2159 } |
| 2160 |
2114 // The short-circuit logical operations need an AST ID for their | 2161 // The short-circuit logical operations need an AST ID for their |
2115 // right-hand subexpression. | 2162 // right-hand subexpression. |
2116 static int num_ids() { return parent_num_ids() + 2; } | 2163 static int num_ids() { return parent_num_ids() + 2; } |
2117 BailoutId RightId() const { return BailoutId(local_id(0)); } | 2164 BailoutId RightId() const { return BailoutId(local_id(0)); } |
2118 | 2165 |
2119 TypeFeedbackId BinaryOperationFeedbackId() const { | 2166 TypeFeedbackId BinaryOperationFeedbackId() const { |
2120 return TypeFeedbackId(local_id(1)); | 2167 return TypeFeedbackId(local_id(1)); |
2121 } | 2168 } |
2122 Maybe<int> fixed_right_arg() const { | 2169 Maybe<int> fixed_right_arg() const { |
2123 return has_fixed_right_arg_ ? Just(fixed_right_arg_value_) : Nothing<int>(); | 2170 return has_fixed_right_arg_ ? Just(fixed_right_arg_value_) : Nothing<int>(); |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2295 | 2342 |
2296 | 2343 |
2297 class Conditional final : public Expression { | 2344 class Conditional final : public Expression { |
2298 public: | 2345 public: |
2299 DECLARE_NODE_TYPE(Conditional) | 2346 DECLARE_NODE_TYPE(Conditional) |
2300 | 2347 |
2301 Expression* condition() const { return condition_; } | 2348 Expression* condition() const { return condition_; } |
2302 Expression* then_expression() const { return then_expression_; } | 2349 Expression* then_expression() const { return then_expression_; } |
2303 Expression* else_expression() const { return else_expression_; } | 2350 Expression* else_expression() const { return else_expression_; } |
2304 | 2351 |
| 2352 void MarkTail() override { |
| 2353 then_expression_->MarkTail(); |
| 2354 else_expression_->MarkTail(); |
| 2355 } |
| 2356 |
2305 static int num_ids() { return parent_num_ids() + 2; } | 2357 static int num_ids() { return parent_num_ids() + 2; } |
2306 BailoutId ThenId() const { return BailoutId(local_id(0)); } | 2358 BailoutId ThenId() const { return BailoutId(local_id(0)); } |
2307 BailoutId ElseId() const { return BailoutId(local_id(1)); } | 2359 BailoutId ElseId() const { return BailoutId(local_id(1)); } |
2308 | 2360 |
2309 protected: | 2361 protected: |
2310 Conditional(Zone* zone, Expression* condition, Expression* then_expression, | 2362 Conditional(Zone* zone, Expression* condition, Expression* then_expression, |
2311 Expression* else_expression, int position) | 2363 Expression* else_expression, int position) |
2312 : Expression(zone, position), | 2364 : Expression(zone, position), |
2313 condition_(condition), | 2365 condition_(condition), |
2314 then_expression_(then_expression), | 2366 then_expression_(then_expression), |
(...skipping 1395 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3710 // the parser-level zone. | 3762 // the parser-level zone. |
3711 Zone* parser_zone_; | 3763 Zone* parser_zone_; |
3712 AstValueFactory* ast_value_factory_; | 3764 AstValueFactory* ast_value_factory_; |
3713 }; | 3765 }; |
3714 | 3766 |
3715 | 3767 |
3716 } // namespace internal | 3768 } // namespace internal |
3717 } // namespace v8 | 3769 } // namespace v8 |
3718 | 3770 |
3719 #endif // V8_AST_AST_H_ | 3771 #endif // V8_AST_AST_H_ |
OLD | NEW |