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/ast/ast-value-factory.h" | 8 #include "src/ast/ast-value-factory.h" |
9 #include "src/ast/modules.h" | 9 #include "src/ast/modules.h" |
10 #include "src/ast/variables.h" | 10 #include "src/ast/variables.h" |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
223 | 223 |
224 private: | 224 private: |
225 // Hidden to prevent accidental usage. It would have to load the | 225 // Hidden to prevent accidental usage. It would have to load the |
226 // current zone from the TLS. | 226 // current zone from the TLS. |
227 void* operator new(size_t size); | 227 void* operator new(size_t size); |
228 | 228 |
229 friend class CaseClause; // Generates AST IDs. | 229 friend class CaseClause; // Generates AST IDs. |
230 | 230 |
231 int position_; | 231 int position_; |
232 NodeType node_type_; | 232 NodeType node_type_; |
233 // Ends with NodeType which is uint8_t sized. Deriving classes in turn begin | |
234 // sub-int32_t-sized fields for optimum packing efficiency. | |
233 }; | 235 }; |
234 | 236 |
235 | 237 |
236 class Statement : public AstNode { | 238 class Statement : public AstNode { |
237 public: | 239 public: |
238 bool IsEmpty() { return AsEmptyStatement() != NULL; } | 240 bool IsEmpty() { return AsEmptyStatement() != NULL; } |
239 bool IsJump() const; | 241 bool IsJump() const; |
240 | 242 |
241 protected: | 243 protected: |
242 Statement(Zone* zone, int position, NodeType type) | 244 Statement(Zone* zone, int position, NodeType type) |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
351 IcCheckType GetKeyType() const; | 353 IcCheckType GetKeyType() const; |
352 bool IsMonomorphic() const; | 354 bool IsMonomorphic() const; |
353 | 355 |
354 void set_base_id(int id) { base_id_ = id; } | 356 void set_base_id(int id) { base_id_ = id; } |
355 static int num_ids() { return parent_num_ids() + 2; } | 357 static int num_ids() { return parent_num_ids() + 2; } |
356 BailoutId id() const { return BailoutId(local_id(0)); } | 358 BailoutId id() const { return BailoutId(local_id(0)); } |
357 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); } | 359 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); } |
358 | 360 |
359 protected: | 361 protected: |
360 Expression(Zone* zone, int pos, NodeType type) | 362 Expression(Zone* zone, int pos, NodeType type) |
361 : AstNode(pos, type), | 363 : AstNode(pos, type), base_id_(BailoutId::None().ToInt()) {} |
362 base_id_(BailoutId::None().ToInt()), | |
363 bit_field_(0) {} | |
364 static int parent_num_ids() { return 0; } | 364 static int parent_num_ids() { return 0; } |
365 void set_to_boolean_types(uint16_t types) { | 365 void set_to_boolean_types(uint16_t types) { |
366 bit_field_ = ToBooleanTypesField::update(bit_field_, types); | 366 bit_field_ = ToBooleanTypesField::update(bit_field_, types); |
367 } | 367 } |
368 | 368 |
369 int base_id() const { | 369 int base_id() const { |
370 DCHECK(!BailoutId(base_id_).IsNone()); | 370 DCHECK(!BailoutId(base_id_).IsNone()); |
371 return base_id_; | 371 return base_id_; |
372 } | 372 } |
373 | 373 |
374 private: | 374 private: |
375 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 375 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
376 | 376 |
377 uint16_t bit_field_ = 0; | |
Michael Starzinger
2016/07/18 08:20:52
nit: Why use implicit initialization here and expl
| |
377 int base_id_; | 378 int base_id_; |
378 class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {}; | 379 class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {}; |
379 uint16_t bit_field_; | |
380 // Ends with 16-bit field; deriving classes in turn begin with | |
381 // 16-bit fields for optimum packing efficiency. | |
382 }; | 380 }; |
383 | 381 |
384 | 382 |
385 class BreakableStatement : public Statement { | 383 class BreakableStatement : public Statement { |
386 public: | 384 public: |
387 enum BreakableType { | 385 enum BreakableType { |
388 TARGET_FOR_ANONYMOUS, | 386 TARGET_FOR_ANONYMOUS, |
389 TARGET_FOR_NAMED_ONLY | 387 TARGET_FOR_NAMED_ONLY |
390 }; | 388 }; |
391 | 389 |
(...skipping 11 matching lines...) Expand all Loading... | |
403 | 401 |
404 void set_base_id(int id) { base_id_ = id; } | 402 void set_base_id(int id) { base_id_ = id; } |
405 static int num_ids() { return parent_num_ids() + 2; } | 403 static int num_ids() { return parent_num_ids() + 2; } |
406 BailoutId EntryId() const { return BailoutId(local_id(0)); } | 404 BailoutId EntryId() const { return BailoutId(local_id(0)); } |
407 BailoutId ExitId() const { return BailoutId(local_id(1)); } | 405 BailoutId ExitId() const { return BailoutId(local_id(1)); } |
408 | 406 |
409 protected: | 407 protected: |
410 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, | 408 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, |
411 BreakableType breakable_type, int position, NodeType type) | 409 BreakableType breakable_type, int position, NodeType type) |
412 : Statement(zone, position, type), | 410 : Statement(zone, position, type), |
413 labels_(labels), | |
414 breakable_type_(breakable_type), | 411 breakable_type_(breakable_type), |
415 base_id_(BailoutId::None().ToInt()) { | 412 base_id_(BailoutId::None().ToInt()), |
413 labels_(labels) { | |
416 DCHECK(labels == NULL || labels->length() > 0); | 414 DCHECK(labels == NULL || labels->length() > 0); |
417 } | 415 } |
418 static int parent_num_ids() { return 0; } | 416 static int parent_num_ids() { return 0; } |
419 | 417 |
420 int base_id() const { | 418 int base_id() const { |
421 DCHECK(!BailoutId(base_id_).IsNone()); | 419 DCHECK(!BailoutId(base_id_).IsNone()); |
422 return base_id_; | 420 return base_id_; |
423 } | 421 } |
424 | 422 |
425 private: | 423 private: |
426 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 424 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
427 | 425 |
426 BreakableType breakable_type_; | |
427 int base_id_; | |
428 Label break_target_; | |
428 ZoneList<const AstRawString*>* labels_; | 429 ZoneList<const AstRawString*>* labels_; |
429 BreakableType breakable_type_; | |
430 Label break_target_; | |
431 int base_id_; | |
432 }; | 430 }; |
433 | 431 |
434 | 432 |
435 class Block final : public BreakableStatement { | 433 class Block final : public BreakableStatement { |
436 public: | 434 public: |
437 DECLARE_NODE_TYPE(Block) | 435 DECLARE_NODE_TYPE(Block) |
438 | 436 |
439 ZoneList<Statement*>* statements() { return &statements_; } | 437 ZoneList<Statement*>* statements() { return &statements_; } |
440 bool ignore_completion_value() const { return ignore_completion_value_; } | 438 bool ignore_completion_value() const { return ignore_completion_value_; } |
441 | 439 |
(...skipping 534 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
976 | 974 |
977 void set_base_id(int id) { base_id_ = id; } | 975 void set_base_id(int id) { base_id_ = id; } |
978 static int num_ids() { return parent_num_ids() + 2; } | 976 static int num_ids() { return parent_num_ids() + 2; } |
979 BailoutId ToObjectId() const { return BailoutId(local_id(0)); } | 977 BailoutId ToObjectId() const { return BailoutId(local_id(0)); } |
980 BailoutId EntryId() const { return BailoutId(local_id(1)); } | 978 BailoutId EntryId() const { return BailoutId(local_id(1)); } |
981 | 979 |
982 protected: | 980 protected: |
983 WithStatement(Zone* zone, Scope* scope, Expression* expression, | 981 WithStatement(Zone* zone, Scope* scope, Expression* expression, |
984 Statement* statement, int pos) | 982 Statement* statement, int pos) |
985 : Statement(zone, pos, kWithStatement), | 983 : Statement(zone, pos, kWithStatement), |
984 base_id_(BailoutId::None().ToInt()), | |
986 scope_(scope), | 985 scope_(scope), |
987 expression_(expression), | 986 expression_(expression), |
988 statement_(statement), | 987 statement_(statement) {} |
989 base_id_(BailoutId::None().ToInt()) {} | |
990 static int parent_num_ids() { return 0; } | 988 static int parent_num_ids() { return 0; } |
991 | 989 |
992 int base_id() const { | 990 int base_id() const { |
993 DCHECK(!BailoutId(base_id_).IsNone()); | 991 DCHECK(!BailoutId(base_id_).IsNone()); |
994 return base_id_; | 992 return base_id_; |
995 } | 993 } |
996 | 994 |
997 private: | 995 private: |
998 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 996 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
999 | 997 |
998 int base_id_; | |
1000 Scope* scope_; | 999 Scope* scope_; |
1001 Expression* expression_; | 1000 Expression* expression_; |
1002 Statement* statement_; | 1001 Statement* statement_; |
1003 int base_id_; | |
1004 }; | 1002 }; |
1005 | 1003 |
1006 | 1004 |
1007 class CaseClause final : public Expression { | 1005 class CaseClause final : public Expression { |
1008 public: | 1006 public: |
1009 DECLARE_NODE_TYPE(CaseClause) | 1007 DECLARE_NODE_TYPE(CaseClause) |
1010 | 1008 |
1011 bool is_default() const { return label_ == NULL; } | 1009 bool is_default() const { return label_ == NULL; } |
1012 Expression* label() const { | 1010 Expression* label() const { |
1013 CHECK(!is_default()); | 1011 CHECK(!is_default()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1094 void set_base_id(int id) { base_id_ = id; } | 1092 void set_base_id(int id) { base_id_ = id; } |
1095 static int num_ids() { return parent_num_ids() + 3; } | 1093 static int num_ids() { return parent_num_ids() + 3; } |
1096 BailoutId IfId() const { return BailoutId(local_id(0)); } | 1094 BailoutId IfId() const { return BailoutId(local_id(0)); } |
1097 BailoutId ThenId() const { return BailoutId(local_id(1)); } | 1095 BailoutId ThenId() const { return BailoutId(local_id(1)); } |
1098 BailoutId ElseId() const { return BailoutId(local_id(2)); } | 1096 BailoutId ElseId() const { return BailoutId(local_id(2)); } |
1099 | 1097 |
1100 protected: | 1098 protected: |
1101 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, | 1099 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, |
1102 Statement* else_statement, int pos) | 1100 Statement* else_statement, int pos) |
1103 : Statement(zone, pos, kIfStatement), | 1101 : Statement(zone, pos, kIfStatement), |
1102 base_id_(BailoutId::None().ToInt()), | |
1104 condition_(condition), | 1103 condition_(condition), |
1105 then_statement_(then_statement), | 1104 then_statement_(then_statement), |
1106 else_statement_(else_statement), | 1105 else_statement_(else_statement) {} |
1107 base_id_(BailoutId::None().ToInt()) {} | |
1108 static int parent_num_ids() { return 0; } | 1106 static int parent_num_ids() { return 0; } |
1109 | 1107 |
1110 int base_id() const { | 1108 int base_id() const { |
1111 DCHECK(!BailoutId(base_id_).IsNone()); | 1109 DCHECK(!BailoutId(base_id_).IsNone()); |
1112 return base_id_; | 1110 return base_id_; |
1113 } | 1111 } |
1114 | 1112 |
1115 private: | 1113 private: |
1116 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1114 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1117 | 1115 |
1116 int base_id_; | |
1118 Expression* condition_; | 1117 Expression* condition_; |
1119 Statement* then_statement_; | 1118 Statement* then_statement_; |
1120 Statement* else_statement_; | 1119 Statement* else_statement_; |
1121 int base_id_; | |
1122 }; | 1120 }; |
1123 | 1121 |
1124 | 1122 |
1125 class TryStatement : public Statement { | 1123 class TryStatement : public Statement { |
1126 public: | 1124 public: |
1127 Block* try_block() const { return try_block_; } | 1125 Block* try_block() const { return try_block_; } |
1128 void set_try_block(Block* b) { try_block_ = b; } | 1126 void set_try_block(Block* b) { try_block_ = b; } |
1129 | 1127 |
1130 // Prediction of whether exceptions thrown into the handler for this try block | 1128 // Prediction of whether exceptions thrown into the handler for this try block |
1131 // will be caught. | 1129 // will be caught. |
1132 // | 1130 // |
1133 // This is set in ast-numbering and later compiled into the code's handler | 1131 // This is set in ast-numbering and later compiled into the code's handler |
1134 // table. The runtime uses this information to implement a feature that | 1132 // table. The runtime uses this information to implement a feature that |
1135 // notifies the debugger when an uncaught exception is thrown, _before_ the | 1133 // notifies the debugger when an uncaught exception is thrown, _before_ the |
1136 // exception propagates to the top. | 1134 // exception propagates to the top. |
1137 // | 1135 // |
1138 // Since it's generally undecidable whether an exception will be caught, our | 1136 // Since it's generally undecidable whether an exception will be caught, our |
1139 // prediction is only an approximation. | 1137 // prediction is only an approximation. |
1140 bool catch_predicted() const { return catch_predicted_; } | 1138 bool catch_predicted() const { return catch_predicted_; } |
1141 void set_catch_predicted(bool b) { catch_predicted_ = b; } | 1139 void set_catch_predicted(bool b) { catch_predicted_ = b; } |
1142 | 1140 |
1143 protected: | 1141 protected: |
1144 TryStatement(Zone* zone, Block* try_block, int pos, NodeType type) | 1142 TryStatement(Zone* zone, Block* try_block, int pos, NodeType type) |
1145 : Statement(zone, pos, type), | 1143 : Statement(zone, pos, type), |
1146 try_block_(try_block), | 1144 catch_predicted_(false), |
1147 catch_predicted_(false) {} | 1145 try_block_(try_block) {} |
1148 | 1146 |
1149 private: | 1147 private: |
1148 bool catch_predicted_; | |
1150 Block* try_block_; | 1149 Block* try_block_; |
1151 bool catch_predicted_; | |
1152 }; | 1150 }; |
1153 | 1151 |
1154 | 1152 |
1155 class TryCatchStatement final : public TryStatement { | 1153 class TryCatchStatement final : public TryStatement { |
1156 public: | 1154 public: |
1157 DECLARE_NODE_TYPE(TryCatchStatement) | 1155 DECLARE_NODE_TYPE(TryCatchStatement) |
1158 | 1156 |
1159 Scope* scope() { return scope_; } | 1157 Scope* scope() { return scope_; } |
1160 Variable* variable() { return variable_; } | 1158 Variable* variable() { return variable_; } |
1161 Block* catch_block() const { return catch_block_; } | 1159 Block* catch_block() const { return catch_block_; } |
1162 void set_catch_block(Block* b) { catch_block_ = b; } | 1160 void set_catch_block(Block* b) { catch_block_ = b; } |
1163 | 1161 |
1164 // The clear_pending_message flag indicates whether or not to clear the | 1162 // The clear_pending_message flag indicates whether or not to clear the |
1165 // isolate's pending exception message before executing the catch_block. In | 1163 // isolate's pending exception message before executing the catch_block. In |
1166 // the normal use case, this flag is always on because the message object | 1164 // the normal use case, this flag is always on because the message object |
1167 // is not needed anymore when entering the catch block and should not be kept | 1165 // is not needed anymore when entering the catch block and should not be kept |
1168 // alive. | 1166 // alive. |
1169 // The use case where the flag is off is when the catch block is guaranteed to | 1167 // The use case where the flag is off is when the catch block is guaranteed to |
1170 // rethrow the caught exception (using %ReThrow), which reuses the pending | 1168 // rethrow the caught exception (using %ReThrow), which reuses the pending |
1171 // message instead of generating a new one. | 1169 // message instead of generating a new one. |
1172 // (When the catch block doesn't rethrow but is guaranteed to perform an | 1170 // (When the catch block doesn't rethrow but is guaranteed to perform an |
1173 // ordinary throw, not clearing the old message is safe but not very useful.) | 1171 // ordinary throw, not clearing the old message is safe but not very useful.) |
1174 bool clear_pending_message() { return clear_pending_message_; } | 1172 bool clear_pending_message() { return clear_pending_message_; } |
1175 | 1173 |
1176 protected: | 1174 protected: |
1177 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope, | 1175 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope, |
1178 Variable* variable, Block* catch_block, | 1176 Variable* variable, Block* catch_block, |
1179 bool clear_pending_message, int pos) | 1177 bool clear_pending_message, int pos) |
1180 : TryStatement(zone, try_block, pos, kTryCatchStatement), | 1178 : TryStatement(zone, try_block, pos, kTryCatchStatement), |
1179 clear_pending_message_(clear_pending_message), | |
1181 scope_(scope), | 1180 scope_(scope), |
1182 variable_(variable), | 1181 variable_(variable), |
1183 catch_block_(catch_block), | 1182 catch_block_(catch_block) {} |
1184 clear_pending_message_(clear_pending_message) {} | |
1185 | 1183 |
1186 private: | 1184 private: |
1185 bool clear_pending_message_; | |
1187 Scope* scope_; | 1186 Scope* scope_; |
1188 Variable* variable_; | 1187 Variable* variable_; |
1189 Block* catch_block_; | 1188 Block* catch_block_; |
1190 bool clear_pending_message_; | |
1191 }; | 1189 }; |
1192 | 1190 |
1193 | 1191 |
1194 class TryFinallyStatement final : public TryStatement { | 1192 class TryFinallyStatement final : public TryStatement { |
1195 public: | 1193 public: |
1196 DECLARE_NODE_TYPE(TryFinallyStatement) | 1194 DECLARE_NODE_TYPE(TryFinallyStatement) |
1197 | 1195 |
1198 Block* finally_block() const { return finally_block_; } | 1196 Block* finally_block() const { return finally_block_; } |
1199 void set_finally_block(Block* b) { finally_block_ = b; } | 1197 void set_finally_block(Block* b) { finally_block_ = b; } |
1200 | 1198 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1320 | 1318 |
1321 int depth() const { | 1319 int depth() const { |
1322 // only callable after initialization. | 1320 // only callable after initialization. |
1323 DCHECK(depth_ >= 1); | 1321 DCHECK(depth_ >= 1); |
1324 return depth_; | 1322 return depth_; |
1325 } | 1323 } |
1326 | 1324 |
1327 protected: | 1325 protected: |
1328 MaterializedLiteral(Zone* zone, int literal_index, int pos, NodeType type) | 1326 MaterializedLiteral(Zone* zone, int literal_index, int pos, NodeType type) |
1329 : Expression(zone, pos, type), | 1327 : Expression(zone, pos, type), |
1330 literal_index_(literal_index), | |
1331 is_simple_(false), | 1328 is_simple_(false), |
1332 depth_(0) {} | 1329 depth_(0), |
1330 literal_index_(literal_index) {} | |
1333 | 1331 |
1334 // A materialized literal is simple if the values consist of only | 1332 // A materialized literal is simple if the values consist of only |
1335 // constants and simple object and array literals. | 1333 // constants and simple object and array literals. |
1336 bool is_simple() const { return is_simple_; } | 1334 bool is_simple() const { return is_simple_; } |
1337 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } | 1335 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } |
1338 friend class CompileTimeValue; | 1336 friend class CompileTimeValue; |
1339 | 1337 |
1340 void set_depth(int depth) { | 1338 void set_depth(int depth) { |
1341 DCHECK(depth >= 1); | 1339 DCHECK_LE(1, depth); |
1342 depth_ = depth; | 1340 depth_ = depth; |
1343 } | 1341 } |
1344 | 1342 |
1345 // Populate the constant properties/elements fixed array. | 1343 // Populate the constant properties/elements fixed array. |
1346 void BuildConstants(Isolate* isolate); | 1344 void BuildConstants(Isolate* isolate); |
1347 friend class ArrayLiteral; | 1345 friend class ArrayLiteral; |
1348 friend class ObjectLiteral; | 1346 friend class ObjectLiteral; |
1349 | 1347 |
1350 // If the expression is a literal, return the literal value; | 1348 // If the expression is a literal, return the literal value; |
1351 // if the expression is a materialized literal and is simple return a | 1349 // if the expression is a materialized literal and is simple return a |
1352 // compile time value as encoded by CompileTimeValue::GetValue(). | 1350 // compile time value as encoded by CompileTimeValue::GetValue(). |
1353 // Otherwise, return undefined literal as the placeholder | 1351 // Otherwise, return undefined literal as the placeholder |
1354 // in the object literal boilerplate. | 1352 // in the object literal boilerplate. |
1355 Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate); | 1353 Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate); |
1356 | 1354 |
1357 private: | 1355 private: |
1356 bool is_simple_ : 1; | |
1357 int depth_ : 31; | |
1358 int literal_index_; | 1358 int literal_index_; |
1359 bool is_simple_; | |
1360 int depth_; | |
1361 | 1359 |
1362 friend class AstLiteralReindexer; | 1360 friend class AstLiteralReindexer; |
1363 }; | 1361 }; |
1364 | 1362 |
1365 | 1363 |
1366 // Property is used for passing information | 1364 // Property is used for passing information |
1367 // about an object literal's properties from the parser | 1365 // about an object literal's properties from the parser |
1368 // to the code generator. | 1366 // to the code generator. |
1369 class ObjectLiteralProperty final : public ZoneObject { | 1367 class ObjectLiteralProperty final : public ZoneObject { |
1370 public: | 1368 public: |
1371 enum Kind { | 1369 enum Kind : uint8_t { |
1372 CONSTANT, // Property with constant value (compile time). | 1370 CONSTANT, // Property with constant value (compile time). |
1373 COMPUTED, // Property with computed value (execution time). | 1371 COMPUTED, // Property with computed value (execution time). |
1374 MATERIALIZED_LITERAL, // Property value is a materialized literal. | 1372 MATERIALIZED_LITERAL, // Property value is a materialized literal. |
1375 GETTER, SETTER, // Property is an accessor function. | 1373 GETTER, |
1376 PROTOTYPE // Property is __proto__. | 1374 SETTER, // Property is an accessor function. |
1375 PROTOTYPE // Property is __proto__. | |
1377 }; | 1376 }; |
1378 | 1377 |
1379 Expression* key() { return key_; } | 1378 Expression* key() { return key_; } |
1380 Expression* value() { return value_; } | 1379 Expression* value() { return value_; } |
1381 Kind kind() { return kind_; } | 1380 Kind kind() { return kind_; } |
1382 | 1381 |
1383 void set_key(Expression* e) { key_ = e; } | 1382 void set_key(Expression* e) { key_ = e; } |
1384 void set_value(Expression* e) { value_ = e; } | 1383 void set_value(Expression* e) { value_ = e; } |
1385 | 1384 |
1386 // Type feedback information. | 1385 // Type feedback information. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1501 return parent_num_ids() + 1 + 2 * properties()->length(); | 1500 return parent_num_ids() + 1 + 2 * properties()->length(); |
1502 } | 1501 } |
1503 | 1502 |
1504 // Object literals need one feedback slot for each non-trivial value, as well | 1503 // Object literals need one feedback slot for each non-trivial value, as well |
1505 // as some slots for home objects. | 1504 // as some slots for home objects. |
1506 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1505 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
1507 FeedbackVectorSlotCache* cache); | 1506 FeedbackVectorSlotCache* cache); |
1508 | 1507 |
1509 protected: | 1508 protected: |
1510 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, | 1509 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, |
1511 int boilerplate_properties, int pos) | 1510 uint32_t boilerplate_properties, int pos) |
1512 : MaterializedLiteral(zone, literal_index, pos, kObjectLiteral), | 1511 : MaterializedLiteral(zone, literal_index, pos, kObjectLiteral), |
1513 properties_(properties), | |
1514 boilerplate_properties_(boilerplate_properties), | 1512 boilerplate_properties_(boilerplate_properties), |
1515 fast_elements_(false), | 1513 fast_elements_(false), |
1516 has_elements_(false), | 1514 has_elements_(false), |
1517 may_store_doubles_(false) {} | 1515 may_store_doubles_(false), |
1516 properties_(properties) {} | |
1518 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } | 1517 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } |
1519 | 1518 |
1520 private: | 1519 private: |
1521 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1520 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1521 uint32_t boilerplate_properties_ : 29; | |
1522 bool fast_elements_ : 1; | |
1523 bool has_elements_ : 1; | |
1524 bool may_store_doubles_ : 1; | |
1525 FeedbackVectorSlot slot_; | |
1522 Handle<FixedArray> constant_properties_; | 1526 Handle<FixedArray> constant_properties_; |
1523 ZoneList<Property*>* properties_; | 1527 ZoneList<Property*>* properties_; |
1524 int boilerplate_properties_; | |
1525 bool fast_elements_; | |
1526 bool has_elements_; | |
1527 bool may_store_doubles_; | |
1528 FeedbackVectorSlot slot_; | |
1529 }; | 1528 }; |
1530 | 1529 |
1531 | 1530 |
1532 // A map from property names to getter/setter pairs allocated in the zone. | 1531 // A map from property names to getter/setter pairs allocated in the zone. |
1533 class AccessorTable | 1532 class AccessorTable |
1534 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, | 1533 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, |
1535 ZoneAllocationPolicy> { | 1534 ZoneAllocationPolicy> { |
1536 public: | 1535 public: |
1537 explicit AccessorTable(Zone* zone) | 1536 explicit AccessorTable(Zone* zone) |
1538 : base::TemplateHashMap<Literal, ObjectLiteral::Accessors, | 1537 : base::TemplateHashMap<Literal, ObjectLiteral::Accessors, |
(...skipping 17 matching lines...) Expand all Loading... | |
1556 public: | 1555 public: |
1557 DECLARE_NODE_TYPE(RegExpLiteral) | 1556 DECLARE_NODE_TYPE(RegExpLiteral) |
1558 | 1557 |
1559 Handle<String> pattern() const { return pattern_->string(); } | 1558 Handle<String> pattern() const { return pattern_->string(); } |
1560 int flags() const { return flags_; } | 1559 int flags() const { return flags_; } |
1561 | 1560 |
1562 protected: | 1561 protected: |
1563 RegExpLiteral(Zone* zone, const AstRawString* pattern, int flags, | 1562 RegExpLiteral(Zone* zone, const AstRawString* pattern, int flags, |
1564 int literal_index, int pos) | 1563 int literal_index, int pos) |
1565 : MaterializedLiteral(zone, literal_index, pos, kRegExpLiteral), | 1564 : MaterializedLiteral(zone, literal_index, pos, kRegExpLiteral), |
1566 pattern_(pattern), | 1565 flags_(flags), |
1567 flags_(flags) { | 1566 pattern_(pattern) { |
1568 set_depth(1); | 1567 set_depth(1); |
1569 } | 1568 } |
1570 | 1569 |
1571 private: | 1570 private: |
1571 int const flags_; | |
1572 const AstRawString* const pattern_; | 1572 const AstRawString* const pattern_; |
1573 int const flags_; | |
1574 }; | 1573 }; |
1575 | 1574 |
1576 | 1575 |
1577 // An array literal has a literals object that is used | 1576 // An array literal has a literals object that is used |
1578 // for minimizing the work when constructing it at runtime. | 1577 // for minimizing the work when constructing it at runtime. |
1579 class ArrayLiteral final : public MaterializedLiteral { | 1578 class ArrayLiteral final : public MaterializedLiteral { |
1580 public: | 1579 public: |
1581 DECLARE_NODE_TYPE(ArrayLiteral) | 1580 DECLARE_NODE_TYPE(ArrayLiteral) |
1582 | 1581 |
1583 Handle<FixedArray> constant_elements() const { return constant_elements_; } | 1582 Handle<FixedArray> constant_elements() const { return constant_elements_; } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1630 }; | 1629 }; |
1631 | 1630 |
1632 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1631 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
1633 FeedbackVectorSlotCache* cache); | 1632 FeedbackVectorSlotCache* cache); |
1634 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } | 1633 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } |
1635 | 1634 |
1636 protected: | 1635 protected: |
1637 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, | 1636 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, |
1638 int first_spread_index, int literal_index, int pos) | 1637 int first_spread_index, int literal_index, int pos) |
1639 : MaterializedLiteral(zone, literal_index, pos, kArrayLiteral), | 1638 : MaterializedLiteral(zone, literal_index, pos, kArrayLiteral), |
1640 values_(values), | 1639 first_spread_index_(first_spread_index), |
1641 first_spread_index_(first_spread_index) {} | 1640 values_(values) {} |
1642 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } | 1641 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } |
1643 | 1642 |
1644 private: | 1643 private: |
1645 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1644 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1646 | 1645 |
1646 int first_spread_index_; | |
1647 FeedbackVectorSlot literal_slot_; | |
1647 Handle<FixedArray> constant_elements_; | 1648 Handle<FixedArray> constant_elements_; |
1648 ZoneList<Expression*>* values_; | 1649 ZoneList<Expression*>* values_; |
1649 int first_spread_index_; | |
1650 FeedbackVectorSlot literal_slot_; | |
1651 }; | 1650 }; |
1652 | 1651 |
1653 | 1652 |
1654 class VariableProxy final : public Expression { | 1653 class VariableProxy final : public Expression { |
1655 public: | 1654 public: |
1656 DECLARE_NODE_TYPE(VariableProxy) | 1655 DECLARE_NODE_TYPE(VariableProxy) |
1657 | 1656 |
1658 bool IsValidReferenceExpression() const { | 1657 bool IsValidReferenceExpression() const { |
1659 return !is_this() && !is_new_target(); | 1658 return !is_this() && !is_new_target(); |
1660 } | 1659 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1721 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1720 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1722 | 1721 |
1723 class IsThisField : public BitField8<bool, 0, 1> {}; | 1722 class IsThisField : public BitField8<bool, 0, 1> {}; |
1724 class IsAssignedField : public BitField8<bool, 1, 1> {}; | 1723 class IsAssignedField : public BitField8<bool, 1, 1> {}; |
1725 class IsResolvedField : public BitField8<bool, 2, 1> {}; | 1724 class IsResolvedField : public BitField8<bool, 2, 1> {}; |
1726 class IsNewTargetField : public BitField8<bool, 3, 1> {}; | 1725 class IsNewTargetField : public BitField8<bool, 3, 1> {}; |
1727 | 1726 |
1728 // Start with 16-bit (or smaller) field, which should get packed together | 1727 // Start with 16-bit (or smaller) field, which should get packed together |
1729 // with Expression's trailing 16-bit field. | 1728 // with Expression's trailing 16-bit field. |
1730 uint8_t bit_field_; | 1729 uint8_t bit_field_; |
1730 // Position is stored in the AstNode superclass, but VariableProxy needs to | |
1731 // know its end position too (for error messages). It cannot be inferred from | |
1732 // the variable name length because it can contain escapes. | |
1733 int end_position_; | |
1731 FeedbackVectorSlot variable_feedback_slot_; | 1734 FeedbackVectorSlot variable_feedback_slot_; |
1732 union { | 1735 union { |
1733 const AstRawString* raw_name_; // if !is_resolved_ | 1736 const AstRawString* raw_name_; // if !is_resolved_ |
1734 Variable* var_; // if is_resolved_ | 1737 Variable* var_; // if is_resolved_ |
1735 }; | 1738 }; |
1736 // Position is stored in the AstNode superclass, but VariableProxy needs to | |
1737 // know its end position too (for error messages). It cannot be inferred from | |
1738 // the variable name length because it can contain escapes. | |
1739 int end_position_; | |
1740 }; | 1739 }; |
1741 | 1740 |
1742 | 1741 |
1743 // Left-hand side can only be a property, a global or a (parameter or local) | 1742 // Left-hand side can only be a property, a global or a (parameter or local) |
1744 // slot. | 1743 // slot. |
1745 enum LhsKind { | 1744 enum LhsKind { |
1746 VARIABLE, | 1745 VARIABLE, |
1747 NAMED_PROPERTY, | 1746 NAMED_PROPERTY, |
1748 KEYED_PROPERTY, | 1747 KEYED_PROPERTY, |
1749 NAMED_SUPER_PROPERTY, | 1748 NAMED_SUPER_PROPERTY, |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1936 | 1935 |
1937 #ifdef DEBUG | 1936 #ifdef DEBUG |
1938 // Used to assert that the FullCodeGenerator records the return site. | 1937 // Used to assert that the FullCodeGenerator records the return site. |
1939 bool return_is_recorded_; | 1938 bool return_is_recorded_; |
1940 #endif | 1939 #endif |
1941 | 1940 |
1942 protected: | 1941 protected: |
1943 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1942 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
1944 int pos) | 1943 int pos) |
1945 : Expression(zone, pos, kCall), | 1944 : Expression(zone, pos, kCall), |
1945 bit_field_(IsUninitializedField::encode(false)), | |
1946 expression_(expression), | 1946 expression_(expression), |
1947 arguments_(arguments), | 1947 arguments_(arguments) { |
1948 bit_field_(IsUninitializedField::encode(false)) { | |
1949 if (expression->IsProperty()) { | 1948 if (expression->IsProperty()) { |
1950 expression->AsProperty()->mark_for_call(); | 1949 expression->AsProperty()->mark_for_call(); |
1951 } | 1950 } |
1952 } | 1951 } |
1953 static int parent_num_ids() { return Expression::num_ids(); } | 1952 static int parent_num_ids() { return Expression::num_ids(); } |
1954 | 1953 |
1955 private: | 1954 private: |
1956 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1955 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1957 | 1956 |
1957 class IsUninitializedField : public BitField8<bool, 0, 1> {}; | |
1958 class IsTailField : public BitField8<bool, 1, 1> {}; | |
1959 uint8_t bit_field_; | |
1958 FeedbackVectorSlot ic_slot_; | 1960 FeedbackVectorSlot ic_slot_; |
1959 FeedbackVectorSlot stub_slot_; | 1961 FeedbackVectorSlot stub_slot_; |
1960 Expression* expression_; | 1962 Expression* expression_; |
1961 ZoneList<Expression*>* arguments_; | 1963 ZoneList<Expression*>* arguments_; |
1962 Handle<JSFunction> target_; | 1964 Handle<JSFunction> target_; |
1963 Handle<AllocationSite> allocation_site_; | 1965 Handle<AllocationSite> allocation_site_; |
1964 class IsUninitializedField : public BitField8<bool, 0, 1> {}; | |
1965 class IsTailField : public BitField8<bool, 1, 1> {}; | |
1966 uint8_t bit_field_; | |
1967 }; | 1966 }; |
1968 | 1967 |
1969 | 1968 |
1970 class CallNew final : public Expression { | 1969 class CallNew final : public Expression { |
1971 public: | 1970 public: |
1972 DECLARE_NODE_TYPE(CallNew) | 1971 DECLARE_NODE_TYPE(CallNew) |
1973 | 1972 |
1974 Expression* expression() const { return expression_; } | 1973 Expression* expression() const { return expression_; } |
1975 ZoneList<Expression*>* arguments() const { return arguments_; } | 1974 ZoneList<Expression*>* arguments() const { return arguments_; } |
1976 | 1975 |
(...skipping 30 matching lines...) Expand all Loading... | |
2007 void set_target(Handle<JSFunction> target) { target_ = target; } | 2006 void set_target(Handle<JSFunction> target) { target_ = target; } |
2008 void SetKnownGlobalTarget(Handle<JSFunction> target) { | 2007 void SetKnownGlobalTarget(Handle<JSFunction> target) { |
2009 target_ = target; | 2008 target_ = target; |
2010 is_monomorphic_ = true; | 2009 is_monomorphic_ = true; |
2011 } | 2010 } |
2012 | 2011 |
2013 protected: | 2012 protected: |
2014 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 2013 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
2015 int pos) | 2014 int pos) |
2016 : Expression(zone, pos, kCallNew), | 2015 : Expression(zone, pos, kCallNew), |
2016 is_monomorphic_(false), | |
2017 expression_(expression), | 2017 expression_(expression), |
2018 arguments_(arguments), | 2018 arguments_(arguments) {} |
2019 is_monomorphic_(false) {} | |
2020 | 2019 |
2021 static int parent_num_ids() { return Expression::num_ids(); } | 2020 static int parent_num_ids() { return Expression::num_ids(); } |
2022 | 2021 |
2023 private: | 2022 private: |
2024 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2023 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2025 | 2024 |
2025 bool is_monomorphic_; | |
2026 FeedbackVectorSlot callnew_feedback_slot_; | |
2026 Expression* expression_; | 2027 Expression* expression_; |
2027 ZoneList<Expression*>* arguments_; | 2028 ZoneList<Expression*>* arguments_; |
2028 bool is_monomorphic_; | |
2029 Handle<JSFunction> target_; | 2029 Handle<JSFunction> target_; |
2030 Handle<AllocationSite> allocation_site_; | 2030 Handle<AllocationSite> allocation_site_; |
2031 FeedbackVectorSlot callnew_feedback_slot_; | |
2032 }; | 2031 }; |
2033 | 2032 |
2034 | 2033 |
2035 // The CallRuntime class does not represent any official JavaScript | 2034 // The CallRuntime class does not represent any official JavaScript |
2036 // language construct. Instead it is used to call a C or JS function | 2035 // language construct. Instead it is used to call a C or JS function |
2037 // with a set of arguments. This is used from the builtins that are | 2036 // with a set of arguments. This is used from the builtins that are |
2038 // implemented in JavaScript (see "v8natives.js"). | 2037 // implemented in JavaScript (see "v8natives.js"). |
2039 class CallRuntime final : public Expression { | 2038 class CallRuntime final : public Expression { |
2040 public: | 2039 public: |
2041 DECLARE_NODE_TYPE(CallRuntime) | 2040 DECLARE_NODE_TYPE(CallRuntime) |
(...skipping 20 matching lines...) Expand all Loading... | |
2062 protected: | 2061 protected: |
2063 CallRuntime(Zone* zone, const Runtime::Function* function, | 2062 CallRuntime(Zone* zone, const Runtime::Function* function, |
2064 ZoneList<Expression*>* arguments, int pos) | 2063 ZoneList<Expression*>* arguments, int pos) |
2065 : Expression(zone, pos, kCallRuntime), | 2064 : Expression(zone, pos, kCallRuntime), |
2066 function_(function), | 2065 function_(function), |
2067 arguments_(arguments) {} | 2066 arguments_(arguments) {} |
2068 | 2067 |
2069 CallRuntime(Zone* zone, int context_index, ZoneList<Expression*>* arguments, | 2068 CallRuntime(Zone* zone, int context_index, ZoneList<Expression*>* arguments, |
2070 int pos) | 2069 int pos) |
2071 : Expression(zone, pos, kCallRuntime), | 2070 : Expression(zone, pos, kCallRuntime), |
2071 context_index_(context_index), | |
2072 function_(NULL), | 2072 function_(NULL), |
2073 context_index_(context_index), | |
2074 arguments_(arguments) {} | 2073 arguments_(arguments) {} |
2075 | 2074 |
2076 static int parent_num_ids() { return Expression::num_ids(); } | 2075 static int parent_num_ids() { return Expression::num_ids(); } |
2077 | 2076 |
2078 private: | 2077 private: |
2079 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2078 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2080 | 2079 |
2080 int context_index_; | |
2081 const Runtime::Function* function_; | 2081 const Runtime::Function* function_; |
2082 int context_index_; | |
2083 ZoneList<Expression*>* arguments_; | 2082 ZoneList<Expression*>* arguments_; |
2084 }; | 2083 }; |
2085 | 2084 |
2086 | 2085 |
2087 class UnaryOperation final : public Expression { | 2086 class UnaryOperation final : public Expression { |
2088 public: | 2087 public: |
2089 DECLARE_NODE_TYPE(UnaryOperation) | 2088 DECLARE_NODE_TYPE(UnaryOperation) |
2090 | 2089 |
2091 Token::Value op() const { return op_; } | 2090 Token::Value op() const { return op_; } |
2092 Expression* expression() const { return expression_; } | 2091 Expression* expression() const { return expression_; } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2246 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2245 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2247 | 2246 |
2248 class IsPrefixField : public BitField16<bool, 0, 1> {}; | 2247 class IsPrefixField : public BitField16<bool, 0, 1> {}; |
2249 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; | 2248 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; |
2250 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; | 2249 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; |
2251 class TokenField : public BitField16<Token::Value, 5, 8> {}; | 2250 class TokenField : public BitField16<Token::Value, 5, 8> {}; |
2252 | 2251 |
2253 // Starts with 16-bit field, which should get packed together with | 2252 // Starts with 16-bit field, which should get packed together with |
2254 // Expression's trailing 16-bit field. | 2253 // Expression's trailing 16-bit field. |
2255 uint16_t bit_field_; | 2254 uint16_t bit_field_; |
2255 FeedbackVectorSlot slot_; | |
2256 Type* type_; | 2256 Type* type_; |
2257 Expression* expression_; | 2257 Expression* expression_; |
2258 SmallMapList receiver_types_; | 2258 SmallMapList receiver_types_; |
2259 FeedbackVectorSlot slot_; | |
2260 }; | 2259 }; |
2261 | 2260 |
2262 | 2261 |
2263 class CompareOperation final : public Expression { | 2262 class CompareOperation final : public Expression { |
2264 public: | 2263 public: |
2265 DECLARE_NODE_TYPE(CompareOperation) | 2264 DECLARE_NODE_TYPE(CompareOperation) |
2266 | 2265 |
2267 Token::Value op() const { return op_; } | 2266 Token::Value op() const { return op_; } |
2268 Expression* left() const { return left_; } | 2267 Expression* left() const { return left_; } |
2269 Expression* right() const { return right_; } | 2268 Expression* right() const { return right_; } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2314 Expression* expression() const { return expression_; } | 2313 Expression* expression() const { return expression_; } |
2315 void set_expression(Expression* e) { expression_ = e; } | 2314 void set_expression(Expression* e) { expression_ = e; } |
2316 | 2315 |
2317 int expression_position() const { return expr_pos_; } | 2316 int expression_position() const { return expr_pos_; } |
2318 | 2317 |
2319 static int num_ids() { return parent_num_ids(); } | 2318 static int num_ids() { return parent_num_ids(); } |
2320 | 2319 |
2321 protected: | 2320 protected: |
2322 Spread(Zone* zone, Expression* expression, int pos, int expr_pos) | 2321 Spread(Zone* zone, Expression* expression, int pos, int expr_pos) |
2323 : Expression(zone, pos, kSpread), | 2322 : Expression(zone, pos, kSpread), |
2324 expression_(expression), | 2323 expr_pos_(expr_pos), |
2325 expr_pos_(expr_pos) {} | 2324 expression_(expression) {} |
2326 static int parent_num_ids() { return Expression::num_ids(); } | 2325 static int parent_num_ids() { return Expression::num_ids(); } |
2327 | 2326 |
2328 private: | 2327 private: |
2329 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2328 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2330 | 2329 |
2330 int expr_pos_; | |
2331 Expression* expression_; | 2331 Expression* expression_; |
2332 int expr_pos_; | |
2333 }; | 2332 }; |
2334 | 2333 |
2335 | 2334 |
2336 class Conditional final : public Expression { | 2335 class Conditional final : public Expression { |
2337 public: | 2336 public: |
2338 DECLARE_NODE_TYPE(Conditional) | 2337 DECLARE_NODE_TYPE(Conditional) |
2339 | 2338 |
2340 Expression* condition() const { return condition_; } | 2339 Expression* condition() const { return condition_; } |
2341 Expression* then_expression() const { return then_expression_; } | 2340 Expression* then_expression() const { return then_expression_; } |
2342 Expression* else_expression() const { return else_expression_; } | 2341 Expression* else_expression() const { return else_expression_; } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2435 class KeyTypeField | 2434 class KeyTypeField |
2436 : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {}; | 2435 : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {}; |
2437 class StoreModeField | 2436 class StoreModeField |
2438 : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; | 2437 : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; |
2439 class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> { | 2438 class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> { |
2440 }; | 2439 }; |
2441 | 2440 |
2442 // Starts with 16-bit field, which should get packed together with | 2441 // Starts with 16-bit field, which should get packed together with |
2443 // Expression's trailing 16-bit field. | 2442 // Expression's trailing 16-bit field. |
2444 uint16_t bit_field_; | 2443 uint16_t bit_field_; |
2444 FeedbackVectorSlot slot_; | |
2445 Expression* target_; | 2445 Expression* target_; |
2446 Expression* value_; | 2446 Expression* value_; |
2447 BinaryOperation* binary_operation_; | 2447 BinaryOperation* binary_operation_; |
2448 SmallMapList receiver_types_; | 2448 SmallMapList receiver_types_; |
2449 FeedbackVectorSlot slot_; | |
2450 }; | 2449 }; |
2451 | 2450 |
2452 | 2451 |
2453 // The RewritableExpression class is a wrapper for AST nodes that wait | 2452 // The RewritableExpression class is a wrapper for AST nodes that wait |
2454 // for some potential rewriting. However, even if such nodes are indeed | 2453 // for some potential rewriting. However, even if such nodes are indeed |
2455 // rewritten, the RewritableExpression wrapper nodes will survive in the | 2454 // rewritten, the RewritableExpression wrapper nodes will survive in the |
2456 // final AST and should be just ignored, i.e., they should be treated as | 2455 // final AST and should be just ignored, i.e., they should be treated as |
2457 // equivalent to the wrapped nodes. For this reason and to simplify later | 2456 // equivalent to the wrapped nodes. For this reason and to simplify later |
2458 // phases, RewritableExpressions are considered as exceptions of AST nodes | 2457 // phases, RewritableExpressions are considered as exceptions of AST nodes |
2459 // in the following sense: | 2458 // in the following sense: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2514 int yield_id() const { return yield_id_; } | 2513 int yield_id() const { return yield_id_; } |
2515 | 2514 |
2516 void set_generator_object(Expression* e) { generator_object_ = e; } | 2515 void set_generator_object(Expression* e) { generator_object_ = e; } |
2517 void set_expression(Expression* e) { expression_ = e; } | 2516 void set_expression(Expression* e) { expression_ = e; } |
2518 void set_yield_id(int yield_id) { yield_id_ = yield_id; } | 2517 void set_yield_id(int yield_id) { yield_id_ = yield_id; } |
2519 | 2518 |
2520 protected: | 2519 protected: |
2521 Yield(Zone* zone, Expression* generator_object, Expression* expression, | 2520 Yield(Zone* zone, Expression* generator_object, Expression* expression, |
2522 int pos, OnException on_exception) | 2521 int pos, OnException on_exception) |
2523 : Expression(zone, pos, kYield), | 2522 : Expression(zone, pos, kYield), |
2523 on_exception_(on_exception), | |
2524 yield_id_(-1), | |
2524 generator_object_(generator_object), | 2525 generator_object_(generator_object), |
2525 expression_(expression), | 2526 expression_(expression) {} |
2526 on_exception_(on_exception), | |
2527 yield_id_(-1) {} | |
2528 | 2527 |
2529 private: | 2528 private: |
2529 OnException on_exception_; | |
2530 int yield_id_; | |
2530 Expression* generator_object_; | 2531 Expression* generator_object_; |
2531 Expression* expression_; | 2532 Expression* expression_; |
2532 OnException on_exception_; | |
2533 int yield_id_; | |
2534 }; | 2533 }; |
2535 | 2534 |
2536 | 2535 |
2537 class Throw final : public Expression { | 2536 class Throw final : public Expression { |
2538 public: | 2537 public: |
2539 DECLARE_NODE_TYPE(Throw) | 2538 DECLARE_NODE_TYPE(Throw) |
2540 | 2539 |
2541 Expression* exception() const { return exception_; } | 2540 Expression* exception() const { return exception_; } |
2542 void set_exception(Expression* e) { exception_ = e; } | 2541 void set_exception(Expression* e) { exception_ = e; } |
2543 | 2542 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2686 protected: | 2685 protected: |
2687 FunctionLiteral(Zone* zone, const AstString* name, | 2686 FunctionLiteral(Zone* zone, const AstString* name, |
2688 AstValueFactory* ast_value_factory, Scope* scope, | 2687 AstValueFactory* ast_value_factory, Scope* scope, |
2689 ZoneList<Statement*>* body, int materialized_literal_count, | 2688 ZoneList<Statement*>* body, int materialized_literal_count, |
2690 int expected_property_count, int parameter_count, | 2689 int expected_property_count, int parameter_count, |
2691 FunctionType function_type, | 2690 FunctionType function_type, |
2692 ParameterFlag has_duplicate_parameters, | 2691 ParameterFlag has_duplicate_parameters, |
2693 EagerCompileHint eager_compile_hint, FunctionKind kind, | 2692 EagerCompileHint eager_compile_hint, FunctionKind kind, |
2694 int position, bool is_function) | 2693 int position, bool is_function) |
2695 : Expression(zone, position, kFunctionLiteral), | 2694 : Expression(zone, position, kFunctionLiteral), |
2696 raw_name_(name), | |
2697 scope_(scope), | |
2698 body_(body), | |
2699 raw_inferred_name_(ast_value_factory->empty_string()), | |
2700 ast_properties_(zone), | |
2701 dont_optimize_reason_(kNoReason), | 2695 dont_optimize_reason_(kNoReason), |
2702 materialized_literal_count_(materialized_literal_count), | 2696 materialized_literal_count_(materialized_literal_count), |
2703 expected_property_count_(expected_property_count), | 2697 expected_property_count_(expected_property_count), |
2704 parameter_count_(parameter_count), | 2698 parameter_count_(parameter_count), |
2705 function_token_position_(kNoSourcePosition), | 2699 function_token_position_(kNoSourcePosition), |
2706 yield_count_(0) { | 2700 yield_count_(0), |
2701 raw_name_(name), | |
2702 scope_(scope), | |
2703 body_(body), | |
2704 raw_inferred_name_(ast_value_factory->empty_string()), | |
2705 ast_properties_(zone) { | |
2707 bitfield_ = | 2706 bitfield_ = |
2708 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | | 2707 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | |
2709 HasDuplicateParameters::encode(has_duplicate_parameters == | 2708 HasDuplicateParameters::encode(has_duplicate_parameters == |
2710 kHasDuplicateParameters) | | 2709 kHasDuplicateParameters) | |
2711 IsFunction::encode(is_function) | | 2710 IsFunction::encode(is_function) | |
2712 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | | 2711 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | |
2713 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); | 2712 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); |
2714 DCHECK(IsValidFunctionKind(kind)); | 2713 DCHECK(IsValidFunctionKind(kind)); |
2715 } | 2714 } |
2716 | 2715 |
2717 private: | 2716 private: |
2718 class FunctionTypeBits : public BitField16<FunctionType, 0, 2> {}; | 2717 class FunctionTypeBits : public BitField16<FunctionType, 0, 2> {}; |
2719 class Pretenure : public BitField16<bool, 2, 1> {}; | 2718 class Pretenure : public BitField16<bool, 2, 1> {}; |
2720 class HasDuplicateParameters : public BitField16<bool, 3, 1> {}; | 2719 class HasDuplicateParameters : public BitField16<bool, 3, 1> {}; |
2721 class IsFunction : public BitField16<bool, 4, 1> {}; | 2720 class IsFunction : public BitField16<bool, 4, 1> {}; |
2722 class ShouldEagerCompile : public BitField16<bool, 5, 1> {}; | 2721 class ShouldEagerCompile : public BitField16<bool, 5, 1> {}; |
2723 class ShouldBeUsedOnceHint : public BitField16<bool, 6, 1> {}; | 2722 class ShouldBeUsedOnceHint : public BitField16<bool, 6, 1> {}; |
2724 class FunctionKindBits : public BitField16<FunctionKind, 7, 9> {}; | 2723 class FunctionKindBits : public BitField16<FunctionKind, 7, 9> {}; |
2725 | 2724 |
2726 // Start with 16-bit field, which should get packed together | 2725 // Start with 16-bit field, which should get packed together |
2727 // with Expression's trailing 16-bit field. | 2726 // with Expression's trailing 16-bit field. |
2728 uint16_t bitfield_; | 2727 uint16_t bitfield_; |
2729 | 2728 |
2730 const AstString* raw_name_; | |
2731 Scope* scope_; | |
2732 ZoneList<Statement*>* body_; | |
2733 const AstString* raw_inferred_name_; | |
2734 Handle<String> inferred_name_; | |
2735 AstProperties ast_properties_; | |
2736 BailoutReason dont_optimize_reason_; | 2729 BailoutReason dont_optimize_reason_; |
2737 | 2730 |
2738 int materialized_literal_count_; | 2731 int materialized_literal_count_; |
2739 int expected_property_count_; | 2732 int expected_property_count_; |
2740 int parameter_count_; | 2733 int parameter_count_; |
2741 int function_token_position_; | 2734 int function_token_position_; |
2742 int yield_count_; | 2735 int yield_count_; |
2736 | |
2737 const AstString* raw_name_; | |
2738 Scope* scope_; | |
2739 ZoneList<Statement*>* body_; | |
2740 const AstString* raw_inferred_name_; | |
2741 Handle<String> inferred_name_; | |
2742 AstProperties ast_properties_; | |
2743 }; | 2743 }; |
2744 | 2744 |
2745 | 2745 |
2746 class ClassLiteral final : public Expression { | 2746 class ClassLiteral final : public Expression { |
2747 public: | 2747 public: |
2748 typedef ObjectLiteralProperty Property; | 2748 typedef ObjectLiteralProperty Property; |
2749 | 2749 |
2750 DECLARE_NODE_TYPE(ClassLiteral) | 2750 DECLARE_NODE_TYPE(ClassLiteral) |
2751 | 2751 |
2752 Scope* scope() const { return scope_; } | 2752 Scope* scope() const { return scope_; } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2788 bool IsAnonymousFunctionDefinition() const { | 2788 bool IsAnonymousFunctionDefinition() const { |
2789 return constructor()->raw_name()->length() == 0; | 2789 return constructor()->raw_name()->length() == 0; |
2790 } | 2790 } |
2791 | 2791 |
2792 protected: | 2792 protected: |
2793 ClassLiteral(Zone* zone, Scope* scope, VariableProxy* class_variable_proxy, | 2793 ClassLiteral(Zone* zone, Scope* scope, VariableProxy* class_variable_proxy, |
2794 Expression* extends, FunctionLiteral* constructor, | 2794 Expression* extends, FunctionLiteral* constructor, |
2795 ZoneList<Property*>* properties, int start_position, | 2795 ZoneList<Property*>* properties, int start_position, |
2796 int end_position) | 2796 int end_position) |
2797 : Expression(zone, start_position, kClassLiteral), | 2797 : Expression(zone, start_position, kClassLiteral), |
2798 end_position_(end_position), | |
2798 scope_(scope), | 2799 scope_(scope), |
2799 class_variable_proxy_(class_variable_proxy), | 2800 class_variable_proxy_(class_variable_proxy), |
2800 extends_(extends), | 2801 extends_(extends), |
2801 constructor_(constructor), | 2802 constructor_(constructor), |
2802 properties_(properties), | 2803 properties_(properties) {} |
2803 end_position_(end_position) {} | |
2804 | 2804 |
2805 static int parent_num_ids() { return Expression::num_ids(); } | 2805 static int parent_num_ids() { return Expression::num_ids(); } |
2806 | 2806 |
2807 private: | 2807 private: |
2808 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2808 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2809 | 2809 |
2810 int end_position_; | |
2811 FeedbackVectorSlot prototype_slot_; | |
2812 FeedbackVectorSlot proxy_slot_; | |
2810 Scope* scope_; | 2813 Scope* scope_; |
2811 VariableProxy* class_variable_proxy_; | 2814 VariableProxy* class_variable_proxy_; |
2812 Expression* extends_; | 2815 Expression* extends_; |
2813 FunctionLiteral* constructor_; | 2816 FunctionLiteral* constructor_; |
2814 ZoneList<Property*>* properties_; | 2817 ZoneList<Property*>* properties_; |
2815 int end_position_; | |
2816 FeedbackVectorSlot prototype_slot_; | |
2817 FeedbackVectorSlot proxy_slot_; | |
2818 }; | 2818 }; |
2819 | 2819 |
2820 | 2820 |
2821 class NativeFunctionLiteral final : public Expression { | 2821 class NativeFunctionLiteral final : public Expression { |
2822 public: | 2822 public: |
2823 DECLARE_NODE_TYPE(NativeFunctionLiteral) | 2823 DECLARE_NODE_TYPE(NativeFunctionLiteral) |
2824 | 2824 |
2825 Handle<String> name() const { return name_->string(); } | 2825 Handle<String> name() const { return name_->string(); } |
2826 v8::Extension* extension() const { return extension_; } | 2826 v8::Extension* extension() const { return extension_; } |
2827 | 2827 |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3278 return new (local_zone_) | 3278 return new (local_zone_) |
3279 Literal(local_zone_, ast_value_factory_->NewUndefined(), pos); | 3279 Literal(local_zone_, ast_value_factory_->NewUndefined(), pos); |
3280 } | 3280 } |
3281 | 3281 |
3282 Literal* NewTheHoleLiteral(int pos) { | 3282 Literal* NewTheHoleLiteral(int pos) { |
3283 return new (local_zone_) | 3283 return new (local_zone_) |
3284 Literal(local_zone_, ast_value_factory_->NewTheHole(), pos); | 3284 Literal(local_zone_, ast_value_factory_->NewTheHole(), pos); |
3285 } | 3285 } |
3286 | 3286 |
3287 ObjectLiteral* NewObjectLiteral( | 3287 ObjectLiteral* NewObjectLiteral( |
3288 ZoneList<ObjectLiteral::Property*>* properties, | 3288 ZoneList<ObjectLiteral::Property*>* properties, int literal_index, |
3289 int literal_index, | 3289 uint32_t boilerplate_properties, int pos) { |
3290 int boilerplate_properties, | |
3291 int pos) { | |
3292 return new (local_zone_) ObjectLiteral( | 3290 return new (local_zone_) ObjectLiteral( |
3293 local_zone_, properties, literal_index, boilerplate_properties, pos); | 3291 local_zone_, properties, literal_index, boilerplate_properties, pos); |
3294 } | 3292 } |
3295 | 3293 |
3296 ObjectLiteral::Property* NewObjectLiteralProperty( | 3294 ObjectLiteral::Property* NewObjectLiteralProperty( |
3297 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, | 3295 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, |
3298 bool is_static, bool is_computed_name) { | 3296 bool is_static, bool is_computed_name) { |
3299 return new (local_zone_) | 3297 return new (local_zone_) |
3300 ObjectLiteral::Property(key, value, kind, is_static, is_computed_name); | 3298 ObjectLiteral::Property(key, value, kind, is_static, is_computed_name); |
3301 } | 3299 } |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3593 : NULL; \ | 3591 : NULL; \ |
3594 } | 3592 } |
3595 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3593 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3596 #undef DECLARE_NODE_FUNCTIONS | 3594 #undef DECLARE_NODE_FUNCTIONS |
3597 | 3595 |
3598 | 3596 |
3599 } // namespace internal | 3597 } // namespace internal |
3600 } // namespace v8 | 3598 } // namespace v8 |
3601 | 3599 |
3602 #endif // V8_AST_AST_H_ | 3600 #endif // V8_AST_AST_H_ |
OLD | NEW |