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 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
222 | 222 |
223 private: | 223 private: |
224 // Hidden to prevent accidental usage. It would have to load the | 224 // Hidden to prevent accidental usage. It would have to load the |
225 // current zone from the TLS. | 225 // current zone from the TLS. |
226 void* operator new(size_t size); | 226 void* operator new(size_t size); |
227 | 227 |
228 friend class CaseClause; // Generates AST IDs. | 228 friend class CaseClause; // Generates AST IDs. |
229 | 229 |
230 int position_; | 230 int position_; |
231 NodeType node_type_; | 231 NodeType node_type_; |
| 232 // Ends with NodeType which is uint8_t sized. Deriving classes in turn begin |
| 233 // sub-int32_t-sized fields for optimum packing efficiency. |
232 }; | 234 }; |
233 | 235 |
234 | 236 |
235 class Statement : public AstNode { | 237 class Statement : public AstNode { |
236 public: | 238 public: |
237 bool IsEmpty() { return AsEmptyStatement() != NULL; } | 239 bool IsEmpty() { return AsEmptyStatement() != NULL; } |
238 bool IsJump() const; | 240 bool IsJump() const; |
239 | 241 |
240 protected: | 242 protected: |
241 Statement(Zone* zone, int position, NodeType type) | 243 Statement(Zone* zone, int position, NodeType type) |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
351 bool IsMonomorphic() const; | 353 bool IsMonomorphic() const; |
352 | 354 |
353 void set_base_id(int id) { base_id_ = id; } | 355 void set_base_id(int id) { base_id_ = id; } |
354 static int num_ids() { return parent_num_ids() + 2; } | 356 static int num_ids() { return parent_num_ids() + 2; } |
355 BailoutId id() const { return BailoutId(local_id(0)); } | 357 BailoutId id() const { return BailoutId(local_id(0)); } |
356 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); } | 358 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); } |
357 | 359 |
358 protected: | 360 protected: |
359 Expression(Zone* zone, int pos, NodeType type) | 361 Expression(Zone* zone, int pos, NodeType type) |
360 : AstNode(pos, type), | 362 : AstNode(pos, type), |
361 base_id_(BailoutId::None().ToInt()), | 363 bit_field_(0), |
362 bit_field_(0) {} | 364 base_id_(BailoutId::None().ToInt()) {} |
363 static int parent_num_ids() { return 0; } | 365 static int parent_num_ids() { return 0; } |
364 void set_to_boolean_types(uint16_t types) { | 366 void set_to_boolean_types(uint16_t types) { |
365 bit_field_ = ToBooleanTypesField::update(bit_field_, types); | 367 bit_field_ = ToBooleanTypesField::update(bit_field_, types); |
366 } | 368 } |
367 | 369 |
368 int base_id() const { | 370 int base_id() const { |
369 DCHECK(!BailoutId(base_id_).IsNone()); | 371 DCHECK(!BailoutId(base_id_).IsNone()); |
370 return base_id_; | 372 return base_id_; |
371 } | 373 } |
372 | 374 |
373 private: | 375 private: |
374 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 376 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
375 | 377 |
| 378 uint16_t bit_field_; |
376 int base_id_; | 379 int base_id_; |
377 class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {}; | 380 class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {}; |
378 uint16_t bit_field_; | |
379 // Ends with 16-bit field; deriving classes in turn begin with | |
380 // 16-bit fields for optimum packing efficiency. | |
381 }; | 381 }; |
382 | 382 |
383 | 383 |
384 class BreakableStatement : public Statement { | 384 class BreakableStatement : public Statement { |
385 public: | 385 public: |
386 enum BreakableType { | 386 enum BreakableType { |
387 TARGET_FOR_ANONYMOUS, | 387 TARGET_FOR_ANONYMOUS, |
388 TARGET_FOR_NAMED_ONLY | 388 TARGET_FOR_NAMED_ONLY |
389 }; | 389 }; |
390 | 390 |
(...skipping 11 matching lines...) Expand all Loading... |
402 | 402 |
403 void set_base_id(int id) { base_id_ = id; } | 403 void set_base_id(int id) { base_id_ = id; } |
404 static int num_ids() { return parent_num_ids() + 2; } | 404 static int num_ids() { return parent_num_ids() + 2; } |
405 BailoutId EntryId() const { return BailoutId(local_id(0)); } | 405 BailoutId EntryId() const { return BailoutId(local_id(0)); } |
406 BailoutId ExitId() const { return BailoutId(local_id(1)); } | 406 BailoutId ExitId() const { return BailoutId(local_id(1)); } |
407 | 407 |
408 protected: | 408 protected: |
409 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, | 409 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, |
410 BreakableType breakable_type, int position, NodeType type) | 410 BreakableType breakable_type, int position, NodeType type) |
411 : Statement(zone, position, type), | 411 : Statement(zone, position, type), |
412 labels_(labels), | |
413 breakable_type_(breakable_type), | 412 breakable_type_(breakable_type), |
414 base_id_(BailoutId::None().ToInt()) { | 413 base_id_(BailoutId::None().ToInt()), |
| 414 labels_(labels) { |
415 DCHECK(labels == NULL || labels->length() > 0); | 415 DCHECK(labels == NULL || labels->length() > 0); |
416 } | 416 } |
417 static int parent_num_ids() { return 0; } | 417 static int parent_num_ids() { return 0; } |
418 | 418 |
419 int base_id() const { | 419 int base_id() const { |
420 DCHECK(!BailoutId(base_id_).IsNone()); | 420 DCHECK(!BailoutId(base_id_).IsNone()); |
421 return base_id_; | 421 return base_id_; |
422 } | 422 } |
423 | 423 |
424 private: | 424 private: |
425 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 425 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
426 | 426 |
| 427 BreakableType breakable_type_; |
| 428 int base_id_; |
| 429 Label break_target_; |
427 ZoneList<const AstRawString*>* labels_; | 430 ZoneList<const AstRawString*>* labels_; |
428 BreakableType breakable_type_; | |
429 Label break_target_; | |
430 int base_id_; | |
431 }; | 431 }; |
432 | 432 |
433 | 433 |
434 class Block final : public BreakableStatement { | 434 class Block final : public BreakableStatement { |
435 public: | 435 public: |
436 DECLARE_NODE_TYPE(Block) | 436 DECLARE_NODE_TYPE(Block) |
437 | 437 |
438 ZoneList<Statement*>* statements() { return &statements_; } | 438 ZoneList<Statement*>* statements() { return &statements_; } |
439 bool ignore_completion_value() const { return ignore_completion_value_; } | 439 bool ignore_completion_value() const { return ignore_completion_value_; } |
440 | 440 |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
931 | 931 |
932 void set_base_id(int id) { base_id_ = id; } | 932 void set_base_id(int id) { base_id_ = id; } |
933 static int num_ids() { return parent_num_ids() + 2; } | 933 static int num_ids() { return parent_num_ids() + 2; } |
934 BailoutId ToObjectId() const { return BailoutId(local_id(0)); } | 934 BailoutId ToObjectId() const { return BailoutId(local_id(0)); } |
935 BailoutId EntryId() const { return BailoutId(local_id(1)); } | 935 BailoutId EntryId() const { return BailoutId(local_id(1)); } |
936 | 936 |
937 protected: | 937 protected: |
938 WithStatement(Zone* zone, Scope* scope, Expression* expression, | 938 WithStatement(Zone* zone, Scope* scope, Expression* expression, |
939 Statement* statement, int pos) | 939 Statement* statement, int pos) |
940 : Statement(zone, pos, kWithStatement), | 940 : Statement(zone, pos, kWithStatement), |
| 941 base_id_(BailoutId::None().ToInt()), |
941 scope_(scope), | 942 scope_(scope), |
942 expression_(expression), | 943 expression_(expression), |
943 statement_(statement), | 944 statement_(statement) {} |
944 base_id_(BailoutId::None().ToInt()) {} | |
945 static int parent_num_ids() { return 0; } | 945 static int parent_num_ids() { return 0; } |
946 | 946 |
947 int base_id() const { | 947 int base_id() const { |
948 DCHECK(!BailoutId(base_id_).IsNone()); | 948 DCHECK(!BailoutId(base_id_).IsNone()); |
949 return base_id_; | 949 return base_id_; |
950 } | 950 } |
951 | 951 |
952 private: | 952 private: |
953 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 953 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
954 | 954 |
| 955 int base_id_; |
955 Scope* scope_; | 956 Scope* scope_; |
956 Expression* expression_; | 957 Expression* expression_; |
957 Statement* statement_; | 958 Statement* statement_; |
958 int base_id_; | |
959 }; | 959 }; |
960 | 960 |
961 | 961 |
962 class CaseClause final : public Expression { | 962 class CaseClause final : public Expression { |
963 public: | 963 public: |
964 DECLARE_NODE_TYPE(CaseClause) | 964 DECLARE_NODE_TYPE(CaseClause) |
965 | 965 |
966 bool is_default() const { return label_ == NULL; } | 966 bool is_default() const { return label_ == NULL; } |
967 Expression* label() const { | 967 Expression* label() const { |
968 CHECK(!is_default()); | 968 CHECK(!is_default()); |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1049 void set_base_id(int id) { base_id_ = id; } | 1049 void set_base_id(int id) { base_id_ = id; } |
1050 static int num_ids() { return parent_num_ids() + 3; } | 1050 static int num_ids() { return parent_num_ids() + 3; } |
1051 BailoutId IfId() const { return BailoutId(local_id(0)); } | 1051 BailoutId IfId() const { return BailoutId(local_id(0)); } |
1052 BailoutId ThenId() const { return BailoutId(local_id(1)); } | 1052 BailoutId ThenId() const { return BailoutId(local_id(1)); } |
1053 BailoutId ElseId() const { return BailoutId(local_id(2)); } | 1053 BailoutId ElseId() const { return BailoutId(local_id(2)); } |
1054 | 1054 |
1055 protected: | 1055 protected: |
1056 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, | 1056 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, |
1057 Statement* else_statement, int pos) | 1057 Statement* else_statement, int pos) |
1058 : Statement(zone, pos, kIfStatement), | 1058 : Statement(zone, pos, kIfStatement), |
| 1059 base_id_(BailoutId::None().ToInt()), |
1059 condition_(condition), | 1060 condition_(condition), |
1060 then_statement_(then_statement), | 1061 then_statement_(then_statement), |
1061 else_statement_(else_statement), | 1062 else_statement_(else_statement) {} |
1062 base_id_(BailoutId::None().ToInt()) {} | |
1063 static int parent_num_ids() { return 0; } | 1063 static int parent_num_ids() { return 0; } |
1064 | 1064 |
1065 int base_id() const { | 1065 int base_id() const { |
1066 DCHECK(!BailoutId(base_id_).IsNone()); | 1066 DCHECK(!BailoutId(base_id_).IsNone()); |
1067 return base_id_; | 1067 return base_id_; |
1068 } | 1068 } |
1069 | 1069 |
1070 private: | 1070 private: |
1071 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1071 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1072 | 1072 |
| 1073 int base_id_; |
1073 Expression* condition_; | 1074 Expression* condition_; |
1074 Statement* then_statement_; | 1075 Statement* then_statement_; |
1075 Statement* else_statement_; | 1076 Statement* else_statement_; |
1076 int base_id_; | |
1077 }; | 1077 }; |
1078 | 1078 |
1079 | 1079 |
1080 class TryStatement : public Statement { | 1080 class TryStatement : public Statement { |
1081 public: | 1081 public: |
1082 Block* try_block() const { return try_block_; } | 1082 Block* try_block() const { return try_block_; } |
1083 void set_try_block(Block* b) { try_block_ = b; } | 1083 void set_try_block(Block* b) { try_block_ = b; } |
1084 | 1084 |
1085 // Prediction of whether exceptions thrown into the handler for this try block | 1085 // Prediction of whether exceptions thrown into the handler for this try block |
1086 // will be caught. | 1086 // will be caught. |
1087 // | 1087 // |
1088 // This is set in ast-numbering and later compiled into the code's handler | 1088 // This is set in ast-numbering and later compiled into the code's handler |
1089 // table. The runtime uses this information to implement a feature that | 1089 // table. The runtime uses this information to implement a feature that |
1090 // notifies the debugger when an uncaught exception is thrown, _before_ the | 1090 // notifies the debugger when an uncaught exception is thrown, _before_ the |
1091 // exception propagates to the top. | 1091 // exception propagates to the top. |
1092 // | 1092 // |
1093 // Since it's generally undecidable whether an exception will be caught, our | 1093 // Since it's generally undecidable whether an exception will be caught, our |
1094 // prediction is only an approximation. | 1094 // prediction is only an approximation. |
1095 bool catch_predicted() const { return catch_predicted_; } | 1095 bool catch_predicted() const { return catch_predicted_; } |
1096 void set_catch_predicted(bool b) { catch_predicted_ = b; } | 1096 void set_catch_predicted(bool b) { catch_predicted_ = b; } |
1097 | 1097 |
1098 protected: | 1098 protected: |
1099 TryStatement(Zone* zone, Block* try_block, int pos, NodeType type) | 1099 TryStatement(Zone* zone, Block* try_block, int pos, NodeType type) |
1100 : Statement(zone, pos, type), | 1100 : Statement(zone, pos, type), |
1101 try_block_(try_block), | 1101 catch_predicted_(false), |
1102 catch_predicted_(false) {} | 1102 try_block_(try_block) {} |
1103 | 1103 |
1104 private: | 1104 private: |
| 1105 bool catch_predicted_; |
1105 Block* try_block_; | 1106 Block* try_block_; |
1106 bool catch_predicted_; | |
1107 }; | 1107 }; |
1108 | 1108 |
1109 | 1109 |
1110 class TryCatchStatement final : public TryStatement { | 1110 class TryCatchStatement final : public TryStatement { |
1111 public: | 1111 public: |
1112 DECLARE_NODE_TYPE(TryCatchStatement) | 1112 DECLARE_NODE_TYPE(TryCatchStatement) |
1113 | 1113 |
1114 Scope* scope() { return scope_; } | 1114 Scope* scope() { return scope_; } |
1115 Variable* variable() { return variable_; } | 1115 Variable* variable() { return variable_; } |
1116 Block* catch_block() const { return catch_block_; } | 1116 Block* catch_block() const { return catch_block_; } |
1117 void set_catch_block(Block* b) { catch_block_ = b; } | 1117 void set_catch_block(Block* b) { catch_block_ = b; } |
1118 | 1118 |
1119 // The clear_pending_message flag indicates whether or not to clear the | 1119 // The clear_pending_message flag indicates whether or not to clear the |
1120 // isolate's pending exception message before executing the catch_block. In | 1120 // isolate's pending exception message before executing the catch_block. In |
1121 // the normal use case, this flag is always on because the message object | 1121 // the normal use case, this flag is always on because the message object |
1122 // is not needed anymore when entering the catch block and should not be kept | 1122 // is not needed anymore when entering the catch block and should not be kept |
1123 // alive. | 1123 // alive. |
1124 // The use case where the flag is off is when the catch block is guaranteed to | 1124 // The use case where the flag is off is when the catch block is guaranteed to |
1125 // rethrow the caught exception (using %ReThrow), which reuses the pending | 1125 // rethrow the caught exception (using %ReThrow), which reuses the pending |
1126 // message instead of generating a new one. | 1126 // message instead of generating a new one. |
1127 // (When the catch block doesn't rethrow but is guaranteed to perform an | 1127 // (When the catch block doesn't rethrow but is guaranteed to perform an |
1128 // ordinary throw, not clearing the old message is safe but not very useful.) | 1128 // ordinary throw, not clearing the old message is safe but not very useful.) |
1129 bool clear_pending_message() { return clear_pending_message_; } | 1129 bool clear_pending_message() { return clear_pending_message_; } |
1130 | 1130 |
1131 protected: | 1131 protected: |
1132 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope, | 1132 TryCatchStatement(Zone* zone, Block* try_block, Scope* scope, |
1133 Variable* variable, Block* catch_block, | 1133 Variable* variable, Block* catch_block, |
1134 bool clear_pending_message, int pos) | 1134 bool clear_pending_message, int pos) |
1135 : TryStatement(zone, try_block, pos, kTryCatchStatement), | 1135 : TryStatement(zone, try_block, pos, kTryCatchStatement), |
| 1136 clear_pending_message_(clear_pending_message), |
1136 scope_(scope), | 1137 scope_(scope), |
1137 variable_(variable), | 1138 variable_(variable), |
1138 catch_block_(catch_block), | 1139 catch_block_(catch_block) {} |
1139 clear_pending_message_(clear_pending_message) {} | |
1140 | 1140 |
1141 private: | 1141 private: |
| 1142 bool clear_pending_message_; |
1142 Scope* scope_; | 1143 Scope* scope_; |
1143 Variable* variable_; | 1144 Variable* variable_; |
1144 Block* catch_block_; | 1145 Block* catch_block_; |
1145 bool clear_pending_message_; | |
1146 }; | 1146 }; |
1147 | 1147 |
1148 | 1148 |
1149 class TryFinallyStatement final : public TryStatement { | 1149 class TryFinallyStatement final : public TryStatement { |
1150 public: | 1150 public: |
1151 DECLARE_NODE_TYPE(TryFinallyStatement) | 1151 DECLARE_NODE_TYPE(TryFinallyStatement) |
1152 | 1152 |
1153 Block* finally_block() const { return finally_block_; } | 1153 Block* finally_block() const { return finally_block_; } |
1154 void set_finally_block(Block* b) { finally_block_ = b; } | 1154 void set_finally_block(Block* b) { finally_block_ = b; } |
1155 | 1155 |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1275 | 1275 |
1276 int depth() const { | 1276 int depth() const { |
1277 // only callable after initialization. | 1277 // only callable after initialization. |
1278 DCHECK(depth_ >= 1); | 1278 DCHECK(depth_ >= 1); |
1279 return depth_; | 1279 return depth_; |
1280 } | 1280 } |
1281 | 1281 |
1282 protected: | 1282 protected: |
1283 MaterializedLiteral(Zone* zone, int literal_index, int pos, NodeType type) | 1283 MaterializedLiteral(Zone* zone, int literal_index, int pos, NodeType type) |
1284 : Expression(zone, pos, type), | 1284 : Expression(zone, pos, type), |
1285 literal_index_(literal_index), | |
1286 is_simple_(false), | 1285 is_simple_(false), |
1287 depth_(0) {} | 1286 depth_(0), |
| 1287 literal_index_(literal_index) {} |
1288 | 1288 |
1289 // A materialized literal is simple if the values consist of only | 1289 // A materialized literal is simple if the values consist of only |
1290 // constants and simple object and array literals. | 1290 // constants and simple object and array literals. |
1291 bool is_simple() const { return is_simple_; } | 1291 bool is_simple() const { return is_simple_; } |
1292 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } | 1292 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } |
1293 friend class CompileTimeValue; | 1293 friend class CompileTimeValue; |
1294 | 1294 |
1295 void set_depth(int depth) { | 1295 void set_depth(int depth) { |
1296 DCHECK(depth >= 1); | 1296 DCHECK_LE(1, depth); |
1297 depth_ = depth; | 1297 depth_ = depth; |
1298 } | 1298 } |
1299 | 1299 |
1300 // Populate the constant properties/elements fixed array. | 1300 // Populate the constant properties/elements fixed array. |
1301 void BuildConstants(Isolate* isolate); | 1301 void BuildConstants(Isolate* isolate); |
1302 friend class ArrayLiteral; | 1302 friend class ArrayLiteral; |
1303 friend class ObjectLiteral; | 1303 friend class ObjectLiteral; |
1304 | 1304 |
1305 // If the expression is a literal, return the literal value; | 1305 // If the expression is a literal, return the literal value; |
1306 // if the expression is a materialized literal and is simple return a | 1306 // if the expression is a materialized literal and is simple return a |
1307 // compile time value as encoded by CompileTimeValue::GetValue(). | 1307 // compile time value as encoded by CompileTimeValue::GetValue(). |
1308 // Otherwise, return undefined literal as the placeholder | 1308 // Otherwise, return undefined literal as the placeholder |
1309 // in the object literal boilerplate. | 1309 // in the object literal boilerplate. |
1310 Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate); | 1310 Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate); |
1311 | 1311 |
1312 private: | 1312 private: |
| 1313 bool is_simple_ : 1; |
| 1314 int depth_ : 31; |
1313 int literal_index_; | 1315 int literal_index_; |
1314 bool is_simple_; | |
1315 int depth_; | |
1316 | 1316 |
1317 friend class AstLiteralReindexer; | 1317 friend class AstLiteralReindexer; |
1318 }; | 1318 }; |
1319 | 1319 |
1320 | 1320 |
1321 // Property is used for passing information | 1321 // Property is used for passing information |
1322 // about an object literal's properties from the parser | 1322 // about an object literal's properties from the parser |
1323 // to the code generator. | 1323 // to the code generator. |
1324 class ObjectLiteralProperty final : public ZoneObject { | 1324 class ObjectLiteralProperty final : public ZoneObject { |
1325 public: | 1325 public: |
1326 enum Kind { | 1326 enum Kind : uint8_t { |
1327 CONSTANT, // Property with constant value (compile time). | 1327 CONSTANT, // Property with constant value (compile time). |
1328 COMPUTED, // Property with computed value (execution time). | 1328 COMPUTED, // Property with computed value (execution time). |
1329 MATERIALIZED_LITERAL, // Property value is a materialized literal. | 1329 MATERIALIZED_LITERAL, // Property value is a materialized literal. |
1330 GETTER, SETTER, // Property is an accessor function. | 1330 GETTER, |
1331 PROTOTYPE // Property is __proto__. | 1331 SETTER, // Property is an accessor function. |
| 1332 PROTOTYPE // Property is __proto__. |
1332 }; | 1333 }; |
1333 | 1334 |
1334 Expression* key() { return key_; } | 1335 Expression* key() { return key_; } |
1335 Expression* value() { return value_; } | 1336 Expression* value() { return value_; } |
1336 Kind kind() { return kind_; } | 1337 Kind kind() { return kind_; } |
1337 | 1338 |
1338 void set_key(Expression* e) { key_ = e; } | 1339 void set_key(Expression* e) { key_ = e; } |
1339 void set_value(Expression* e) { value_ = e; } | 1340 void set_value(Expression* e) { value_ = e; } |
1340 | 1341 |
1341 // Type feedback information. | 1342 // Type feedback information. |
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1456 return parent_num_ids() + 1 + 2 * properties()->length(); | 1457 return parent_num_ids() + 1 + 2 * properties()->length(); |
1457 } | 1458 } |
1458 | 1459 |
1459 // Object literals need one feedback slot for each non-trivial value, as well | 1460 // Object literals need one feedback slot for each non-trivial value, as well |
1460 // as some slots for home objects. | 1461 // as some slots for home objects. |
1461 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1462 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
1462 FeedbackVectorSlotCache* cache); | 1463 FeedbackVectorSlotCache* cache); |
1463 | 1464 |
1464 protected: | 1465 protected: |
1465 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, | 1466 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, |
1466 int boilerplate_properties, int pos) | 1467 uint32_t boilerplate_properties, int pos) |
1467 : MaterializedLiteral(zone, literal_index, pos, kObjectLiteral), | 1468 : MaterializedLiteral(zone, literal_index, pos, kObjectLiteral), |
1468 properties_(properties), | |
1469 boilerplate_properties_(boilerplate_properties), | 1469 boilerplate_properties_(boilerplate_properties), |
1470 fast_elements_(false), | 1470 fast_elements_(false), |
1471 has_elements_(false), | 1471 has_elements_(false), |
1472 may_store_doubles_(false) {} | 1472 may_store_doubles_(false), |
| 1473 properties_(properties) {} |
1473 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } | 1474 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } |
1474 | 1475 |
1475 private: | 1476 private: |
1476 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1477 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1478 uint32_t boilerplate_properties_ : 29; |
| 1479 bool fast_elements_ : 1; |
| 1480 bool has_elements_ : 1; |
| 1481 bool may_store_doubles_ : 1; |
| 1482 FeedbackVectorSlot slot_; |
1477 Handle<FixedArray> constant_properties_; | 1483 Handle<FixedArray> constant_properties_; |
1478 ZoneList<Property*>* properties_; | 1484 ZoneList<Property*>* properties_; |
1479 int boilerplate_properties_; | |
1480 bool fast_elements_; | |
1481 bool has_elements_; | |
1482 bool may_store_doubles_; | |
1483 FeedbackVectorSlot slot_; | |
1484 }; | 1485 }; |
1485 | 1486 |
1486 | 1487 |
1487 // A map from property names to getter/setter pairs allocated in the zone. | 1488 // A map from property names to getter/setter pairs allocated in the zone. |
1488 class AccessorTable | 1489 class AccessorTable |
1489 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, | 1490 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, |
1490 ZoneAllocationPolicy> { | 1491 ZoneAllocationPolicy> { |
1491 public: | 1492 public: |
1492 explicit AccessorTable(Zone* zone) | 1493 explicit AccessorTable(Zone* zone) |
1493 : base::TemplateHashMap<Literal, ObjectLiteral::Accessors, | 1494 : base::TemplateHashMap<Literal, ObjectLiteral::Accessors, |
(...skipping 17 matching lines...) Expand all Loading... |
1511 public: | 1512 public: |
1512 DECLARE_NODE_TYPE(RegExpLiteral) | 1513 DECLARE_NODE_TYPE(RegExpLiteral) |
1513 | 1514 |
1514 Handle<String> pattern() const { return pattern_->string(); } | 1515 Handle<String> pattern() const { return pattern_->string(); } |
1515 int flags() const { return flags_; } | 1516 int flags() const { return flags_; } |
1516 | 1517 |
1517 protected: | 1518 protected: |
1518 RegExpLiteral(Zone* zone, const AstRawString* pattern, int flags, | 1519 RegExpLiteral(Zone* zone, const AstRawString* pattern, int flags, |
1519 int literal_index, int pos) | 1520 int literal_index, int pos) |
1520 : MaterializedLiteral(zone, literal_index, pos, kRegExpLiteral), | 1521 : MaterializedLiteral(zone, literal_index, pos, kRegExpLiteral), |
1521 pattern_(pattern), | 1522 flags_(flags), |
1522 flags_(flags) { | 1523 pattern_(pattern) { |
1523 set_depth(1); | 1524 set_depth(1); |
1524 } | 1525 } |
1525 | 1526 |
1526 private: | 1527 private: |
| 1528 int const flags_; |
1527 const AstRawString* const pattern_; | 1529 const AstRawString* const pattern_; |
1528 int const flags_; | |
1529 }; | 1530 }; |
1530 | 1531 |
1531 | 1532 |
1532 // An array literal has a literals object that is used | 1533 // An array literal has a literals object that is used |
1533 // for minimizing the work when constructing it at runtime. | 1534 // for minimizing the work when constructing it at runtime. |
1534 class ArrayLiteral final : public MaterializedLiteral { | 1535 class ArrayLiteral final : public MaterializedLiteral { |
1535 public: | 1536 public: |
1536 DECLARE_NODE_TYPE(ArrayLiteral) | 1537 DECLARE_NODE_TYPE(ArrayLiteral) |
1537 | 1538 |
1538 Handle<FixedArray> constant_elements() const { return constant_elements_; } | 1539 Handle<FixedArray> constant_elements() const { return constant_elements_; } |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1585 }; | 1586 }; |
1586 | 1587 |
1587 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1588 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
1588 FeedbackVectorSlotCache* cache); | 1589 FeedbackVectorSlotCache* cache); |
1589 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } | 1590 FeedbackVectorSlot LiteralFeedbackSlot() const { return literal_slot_; } |
1590 | 1591 |
1591 protected: | 1592 protected: |
1592 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, | 1593 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, |
1593 int first_spread_index, int literal_index, int pos) | 1594 int first_spread_index, int literal_index, int pos) |
1594 : MaterializedLiteral(zone, literal_index, pos, kArrayLiteral), | 1595 : MaterializedLiteral(zone, literal_index, pos, kArrayLiteral), |
1595 values_(values), | 1596 first_spread_index_(first_spread_index), |
1596 first_spread_index_(first_spread_index) {} | 1597 values_(values) {} |
1597 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } | 1598 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } |
1598 | 1599 |
1599 private: | 1600 private: |
1600 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1601 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1601 | 1602 |
| 1603 int first_spread_index_; |
| 1604 FeedbackVectorSlot literal_slot_; |
1602 Handle<FixedArray> constant_elements_; | 1605 Handle<FixedArray> constant_elements_; |
1603 ZoneList<Expression*>* values_; | 1606 ZoneList<Expression*>* values_; |
1604 int first_spread_index_; | |
1605 FeedbackVectorSlot literal_slot_; | |
1606 }; | 1607 }; |
1607 | 1608 |
1608 | 1609 |
1609 class VariableProxy final : public Expression { | 1610 class VariableProxy final : public Expression { |
1610 public: | 1611 public: |
1611 DECLARE_NODE_TYPE(VariableProxy) | 1612 DECLARE_NODE_TYPE(VariableProxy) |
1612 | 1613 |
1613 bool IsValidReferenceExpression() const { | 1614 bool IsValidReferenceExpression() const { |
1614 return !is_this() && !is_new_target(); | 1615 return !is_this() && !is_new_target(); |
1615 } | 1616 } |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1676 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1677 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1677 | 1678 |
1678 class IsThisField : public BitField8<bool, 0, 1> {}; | 1679 class IsThisField : public BitField8<bool, 0, 1> {}; |
1679 class IsAssignedField : public BitField8<bool, 1, 1> {}; | 1680 class IsAssignedField : public BitField8<bool, 1, 1> {}; |
1680 class IsResolvedField : public BitField8<bool, 2, 1> {}; | 1681 class IsResolvedField : public BitField8<bool, 2, 1> {}; |
1681 class IsNewTargetField : public BitField8<bool, 3, 1> {}; | 1682 class IsNewTargetField : public BitField8<bool, 3, 1> {}; |
1682 | 1683 |
1683 // Start with 16-bit (or smaller) field, which should get packed together | 1684 // Start with 16-bit (or smaller) field, which should get packed together |
1684 // with Expression's trailing 16-bit field. | 1685 // with Expression's trailing 16-bit field. |
1685 uint8_t bit_field_; | 1686 uint8_t bit_field_; |
| 1687 // Position is stored in the AstNode superclass, but VariableProxy needs to |
| 1688 // know its end position too (for error messages). It cannot be inferred from |
| 1689 // the variable name length because it can contain escapes. |
| 1690 int end_position_; |
1686 FeedbackVectorSlot variable_feedback_slot_; | 1691 FeedbackVectorSlot variable_feedback_slot_; |
1687 union { | 1692 union { |
1688 const AstRawString* raw_name_; // if !is_resolved_ | 1693 const AstRawString* raw_name_; // if !is_resolved_ |
1689 Variable* var_; // if is_resolved_ | 1694 Variable* var_; // if is_resolved_ |
1690 }; | 1695 }; |
1691 // Position is stored in the AstNode superclass, but VariableProxy needs to | |
1692 // know its end position too (for error messages). It cannot be inferred from | |
1693 // the variable name length because it can contain escapes. | |
1694 int end_position_; | |
1695 }; | 1696 }; |
1696 | 1697 |
1697 | 1698 |
1698 // Left-hand side can only be a property, a global or a (parameter or local) | 1699 // Left-hand side can only be a property, a global or a (parameter or local) |
1699 // slot. | 1700 // slot. |
1700 enum LhsKind { | 1701 enum LhsKind { |
1701 VARIABLE, | 1702 VARIABLE, |
1702 NAMED_PROPERTY, | 1703 NAMED_PROPERTY, |
1703 KEYED_PROPERTY, | 1704 KEYED_PROPERTY, |
1704 NAMED_SUPER_PROPERTY, | 1705 NAMED_SUPER_PROPERTY, |
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1891 | 1892 |
1892 #ifdef DEBUG | 1893 #ifdef DEBUG |
1893 // Used to assert that the FullCodeGenerator records the return site. | 1894 // Used to assert that the FullCodeGenerator records the return site. |
1894 bool return_is_recorded_; | 1895 bool return_is_recorded_; |
1895 #endif | 1896 #endif |
1896 | 1897 |
1897 protected: | 1898 protected: |
1898 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1899 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
1899 int pos) | 1900 int pos) |
1900 : Expression(zone, pos, kCall), | 1901 : Expression(zone, pos, kCall), |
| 1902 bit_field_(IsUninitializedField::encode(false)), |
1901 expression_(expression), | 1903 expression_(expression), |
1902 arguments_(arguments), | 1904 arguments_(arguments) { |
1903 bit_field_(IsUninitializedField::encode(false)) { | |
1904 if (expression->IsProperty()) { | 1905 if (expression->IsProperty()) { |
1905 expression->AsProperty()->mark_for_call(); | 1906 expression->AsProperty()->mark_for_call(); |
1906 } | 1907 } |
1907 } | 1908 } |
1908 static int parent_num_ids() { return Expression::num_ids(); } | 1909 static int parent_num_ids() { return Expression::num_ids(); } |
1909 | 1910 |
1910 private: | 1911 private: |
1911 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1912 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1912 | 1913 |
| 1914 class IsUninitializedField : public BitField8<bool, 0, 1> {}; |
| 1915 class IsTailField : public BitField8<bool, 1, 1> {}; |
| 1916 uint8_t bit_field_; |
1913 FeedbackVectorSlot ic_slot_; | 1917 FeedbackVectorSlot ic_slot_; |
1914 FeedbackVectorSlot stub_slot_; | 1918 FeedbackVectorSlot stub_slot_; |
1915 Expression* expression_; | 1919 Expression* expression_; |
1916 ZoneList<Expression*>* arguments_; | 1920 ZoneList<Expression*>* arguments_; |
1917 Handle<JSFunction> target_; | 1921 Handle<JSFunction> target_; |
1918 Handle<AllocationSite> allocation_site_; | 1922 Handle<AllocationSite> allocation_site_; |
1919 class IsUninitializedField : public BitField8<bool, 0, 1> {}; | |
1920 class IsTailField : public BitField8<bool, 1, 1> {}; | |
1921 uint8_t bit_field_; | |
1922 }; | 1923 }; |
1923 | 1924 |
1924 | 1925 |
1925 class CallNew final : public Expression { | 1926 class CallNew final : public Expression { |
1926 public: | 1927 public: |
1927 DECLARE_NODE_TYPE(CallNew) | 1928 DECLARE_NODE_TYPE(CallNew) |
1928 | 1929 |
1929 Expression* expression() const { return expression_; } | 1930 Expression* expression() const { return expression_; } |
1930 ZoneList<Expression*>* arguments() const { return arguments_; } | 1931 ZoneList<Expression*>* arguments() const { return arguments_; } |
1931 | 1932 |
(...skipping 30 matching lines...) Expand all Loading... |
1962 void set_target(Handle<JSFunction> target) { target_ = target; } | 1963 void set_target(Handle<JSFunction> target) { target_ = target; } |
1963 void SetKnownGlobalTarget(Handle<JSFunction> target) { | 1964 void SetKnownGlobalTarget(Handle<JSFunction> target) { |
1964 target_ = target; | 1965 target_ = target; |
1965 is_monomorphic_ = true; | 1966 is_monomorphic_ = true; |
1966 } | 1967 } |
1967 | 1968 |
1968 protected: | 1969 protected: |
1969 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1970 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
1970 int pos) | 1971 int pos) |
1971 : Expression(zone, pos, kCallNew), | 1972 : Expression(zone, pos, kCallNew), |
| 1973 is_monomorphic_(false), |
1972 expression_(expression), | 1974 expression_(expression), |
1973 arguments_(arguments), | 1975 arguments_(arguments) {} |
1974 is_monomorphic_(false) {} | |
1975 | 1976 |
1976 static int parent_num_ids() { return Expression::num_ids(); } | 1977 static int parent_num_ids() { return Expression::num_ids(); } |
1977 | 1978 |
1978 private: | 1979 private: |
1979 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1980 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
1980 | 1981 |
| 1982 bool is_monomorphic_; |
| 1983 FeedbackVectorSlot callnew_feedback_slot_; |
1981 Expression* expression_; | 1984 Expression* expression_; |
1982 ZoneList<Expression*>* arguments_; | 1985 ZoneList<Expression*>* arguments_; |
1983 bool is_monomorphic_; | |
1984 Handle<JSFunction> target_; | 1986 Handle<JSFunction> target_; |
1985 Handle<AllocationSite> allocation_site_; | 1987 Handle<AllocationSite> allocation_site_; |
1986 FeedbackVectorSlot callnew_feedback_slot_; | |
1987 }; | 1988 }; |
1988 | 1989 |
1989 | 1990 |
1990 // The CallRuntime class does not represent any official JavaScript | 1991 // The CallRuntime class does not represent any official JavaScript |
1991 // language construct. Instead it is used to call a C or JS function | 1992 // language construct. Instead it is used to call a C or JS function |
1992 // with a set of arguments. This is used from the builtins that are | 1993 // with a set of arguments. This is used from the builtins that are |
1993 // implemented in JavaScript (see "v8natives.js"). | 1994 // implemented in JavaScript (see "v8natives.js"). |
1994 class CallRuntime final : public Expression { | 1995 class CallRuntime final : public Expression { |
1995 public: | 1996 public: |
1996 DECLARE_NODE_TYPE(CallRuntime) | 1997 DECLARE_NODE_TYPE(CallRuntime) |
(...skipping 20 matching lines...) Expand all Loading... |
2017 protected: | 2018 protected: |
2018 CallRuntime(Zone* zone, const Runtime::Function* function, | 2019 CallRuntime(Zone* zone, const Runtime::Function* function, |
2019 ZoneList<Expression*>* arguments, int pos) | 2020 ZoneList<Expression*>* arguments, int pos) |
2020 : Expression(zone, pos, kCallRuntime), | 2021 : Expression(zone, pos, kCallRuntime), |
2021 function_(function), | 2022 function_(function), |
2022 arguments_(arguments) {} | 2023 arguments_(arguments) {} |
2023 | 2024 |
2024 CallRuntime(Zone* zone, int context_index, ZoneList<Expression*>* arguments, | 2025 CallRuntime(Zone* zone, int context_index, ZoneList<Expression*>* arguments, |
2025 int pos) | 2026 int pos) |
2026 : Expression(zone, pos, kCallRuntime), | 2027 : Expression(zone, pos, kCallRuntime), |
| 2028 context_index_(context_index), |
2027 function_(NULL), | 2029 function_(NULL), |
2028 context_index_(context_index), | |
2029 arguments_(arguments) {} | 2030 arguments_(arguments) {} |
2030 | 2031 |
2031 static int parent_num_ids() { return Expression::num_ids(); } | 2032 static int parent_num_ids() { return Expression::num_ids(); } |
2032 | 2033 |
2033 private: | 2034 private: |
2034 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2035 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2035 | 2036 |
| 2037 int context_index_; |
2036 const Runtime::Function* function_; | 2038 const Runtime::Function* function_; |
2037 int context_index_; | |
2038 ZoneList<Expression*>* arguments_; | 2039 ZoneList<Expression*>* arguments_; |
2039 }; | 2040 }; |
2040 | 2041 |
2041 | 2042 |
2042 class UnaryOperation final : public Expression { | 2043 class UnaryOperation final : public Expression { |
2043 public: | 2044 public: |
2044 DECLARE_NODE_TYPE(UnaryOperation) | 2045 DECLARE_NODE_TYPE(UnaryOperation) |
2045 | 2046 |
2046 Token::Value op() const { return op_; } | 2047 Token::Value op() const { return op_; } |
2047 Expression* expression() const { return expression_; } | 2048 Expression* expression() const { return expression_; } |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2201 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2202 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2202 | 2203 |
2203 class IsPrefixField : public BitField16<bool, 0, 1> {}; | 2204 class IsPrefixField : public BitField16<bool, 0, 1> {}; |
2204 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; | 2205 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; |
2205 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; | 2206 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; |
2206 class TokenField : public BitField16<Token::Value, 5, 8> {}; | 2207 class TokenField : public BitField16<Token::Value, 5, 8> {}; |
2207 | 2208 |
2208 // Starts with 16-bit field, which should get packed together with | 2209 // Starts with 16-bit field, which should get packed together with |
2209 // Expression's trailing 16-bit field. | 2210 // Expression's trailing 16-bit field. |
2210 uint16_t bit_field_; | 2211 uint16_t bit_field_; |
| 2212 FeedbackVectorSlot slot_; |
2211 Type* type_; | 2213 Type* type_; |
2212 Expression* expression_; | 2214 Expression* expression_; |
2213 SmallMapList receiver_types_; | 2215 SmallMapList receiver_types_; |
2214 FeedbackVectorSlot slot_; | |
2215 }; | 2216 }; |
2216 | 2217 |
2217 | 2218 |
2218 class CompareOperation final : public Expression { | 2219 class CompareOperation final : public Expression { |
2219 public: | 2220 public: |
2220 DECLARE_NODE_TYPE(CompareOperation) | 2221 DECLARE_NODE_TYPE(CompareOperation) |
2221 | 2222 |
2222 Token::Value op() const { return op_; } | 2223 Token::Value op() const { return op_; } |
2223 Expression* left() const { return left_; } | 2224 Expression* left() const { return left_; } |
2224 Expression* right() const { return right_; } | 2225 Expression* right() const { return right_; } |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2269 Expression* expression() const { return expression_; } | 2270 Expression* expression() const { return expression_; } |
2270 void set_expression(Expression* e) { expression_ = e; } | 2271 void set_expression(Expression* e) { expression_ = e; } |
2271 | 2272 |
2272 int expression_position() const { return expr_pos_; } | 2273 int expression_position() const { return expr_pos_; } |
2273 | 2274 |
2274 static int num_ids() { return parent_num_ids(); } | 2275 static int num_ids() { return parent_num_ids(); } |
2275 | 2276 |
2276 protected: | 2277 protected: |
2277 Spread(Zone* zone, Expression* expression, int pos, int expr_pos) | 2278 Spread(Zone* zone, Expression* expression, int pos, int expr_pos) |
2278 : Expression(zone, pos, kSpread), | 2279 : Expression(zone, pos, kSpread), |
2279 expression_(expression), | 2280 expr_pos_(expr_pos), |
2280 expr_pos_(expr_pos) {} | 2281 expression_(expression) {} |
2281 static int parent_num_ids() { return Expression::num_ids(); } | 2282 static int parent_num_ids() { return Expression::num_ids(); } |
2282 | 2283 |
2283 private: | 2284 private: |
2284 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2285 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2285 | 2286 |
| 2287 int expr_pos_; |
2286 Expression* expression_; | 2288 Expression* expression_; |
2287 int expr_pos_; | |
2288 }; | 2289 }; |
2289 | 2290 |
2290 | 2291 |
2291 class Conditional final : public Expression { | 2292 class Conditional final : public Expression { |
2292 public: | 2293 public: |
2293 DECLARE_NODE_TYPE(Conditional) | 2294 DECLARE_NODE_TYPE(Conditional) |
2294 | 2295 |
2295 Expression* condition() const { return condition_; } | 2296 Expression* condition() const { return condition_; } |
2296 Expression* then_expression() const { return then_expression_; } | 2297 Expression* then_expression() const { return then_expression_; } |
2297 Expression* else_expression() const { return else_expression_; } | 2298 Expression* else_expression() const { return else_expression_; } |
(...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2390 class KeyTypeField | 2391 class KeyTypeField |
2391 : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {}; | 2392 : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {}; |
2392 class StoreModeField | 2393 class StoreModeField |
2393 : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; | 2394 : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; |
2394 class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> { | 2395 class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> { |
2395 }; | 2396 }; |
2396 | 2397 |
2397 // Starts with 16-bit field, which should get packed together with | 2398 // Starts with 16-bit field, which should get packed together with |
2398 // Expression's trailing 16-bit field. | 2399 // Expression's trailing 16-bit field. |
2399 uint16_t bit_field_; | 2400 uint16_t bit_field_; |
| 2401 FeedbackVectorSlot slot_; |
2400 Expression* target_; | 2402 Expression* target_; |
2401 Expression* value_; | 2403 Expression* value_; |
2402 BinaryOperation* binary_operation_; | 2404 BinaryOperation* binary_operation_; |
2403 SmallMapList receiver_types_; | 2405 SmallMapList receiver_types_; |
2404 FeedbackVectorSlot slot_; | |
2405 }; | 2406 }; |
2406 | 2407 |
2407 | 2408 |
2408 // The RewritableExpression class is a wrapper for AST nodes that wait | 2409 // The RewritableExpression class is a wrapper for AST nodes that wait |
2409 // for some potential rewriting. However, even if such nodes are indeed | 2410 // for some potential rewriting. However, even if such nodes are indeed |
2410 // rewritten, the RewritableExpression wrapper nodes will survive in the | 2411 // rewritten, the RewritableExpression wrapper nodes will survive in the |
2411 // final AST and should be just ignored, i.e., they should be treated as | 2412 // final AST and should be just ignored, i.e., they should be treated as |
2412 // equivalent to the wrapped nodes. For this reason and to simplify later | 2413 // equivalent to the wrapped nodes. For this reason and to simplify later |
2413 // phases, RewritableExpressions are considered as exceptions of AST nodes | 2414 // phases, RewritableExpressions are considered as exceptions of AST nodes |
2414 // in the following sense: | 2415 // in the following sense: |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2469 int yield_id() const { return yield_id_; } | 2470 int yield_id() const { return yield_id_; } |
2470 | 2471 |
2471 void set_generator_object(Expression* e) { generator_object_ = e; } | 2472 void set_generator_object(Expression* e) { generator_object_ = e; } |
2472 void set_expression(Expression* e) { expression_ = e; } | 2473 void set_expression(Expression* e) { expression_ = e; } |
2473 void set_yield_id(int yield_id) { yield_id_ = yield_id; } | 2474 void set_yield_id(int yield_id) { yield_id_ = yield_id; } |
2474 | 2475 |
2475 protected: | 2476 protected: |
2476 Yield(Zone* zone, Expression* generator_object, Expression* expression, | 2477 Yield(Zone* zone, Expression* generator_object, Expression* expression, |
2477 int pos, OnException on_exception) | 2478 int pos, OnException on_exception) |
2478 : Expression(zone, pos, kYield), | 2479 : Expression(zone, pos, kYield), |
| 2480 on_exception_(on_exception), |
| 2481 yield_id_(-1), |
2479 generator_object_(generator_object), | 2482 generator_object_(generator_object), |
2480 expression_(expression), | 2483 expression_(expression) {} |
2481 on_exception_(on_exception), | |
2482 yield_id_(-1) {} | |
2483 | 2484 |
2484 private: | 2485 private: |
| 2486 OnException on_exception_; |
| 2487 int yield_id_; |
2485 Expression* generator_object_; | 2488 Expression* generator_object_; |
2486 Expression* expression_; | 2489 Expression* expression_; |
2487 OnException on_exception_; | |
2488 int yield_id_; | |
2489 }; | 2490 }; |
2490 | 2491 |
2491 | 2492 |
2492 class Throw final : public Expression { | 2493 class Throw final : public Expression { |
2493 public: | 2494 public: |
2494 DECLARE_NODE_TYPE(Throw) | 2495 DECLARE_NODE_TYPE(Throw) |
2495 | 2496 |
2496 Expression* exception() const { return exception_; } | 2497 Expression* exception() const { return exception_; } |
2497 void set_exception(Expression* e) { exception_ = e; } | 2498 void set_exception(Expression* e) { exception_ = e; } |
2498 | 2499 |
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2641 protected: | 2642 protected: |
2642 FunctionLiteral(Zone* zone, const AstString* name, | 2643 FunctionLiteral(Zone* zone, const AstString* name, |
2643 AstValueFactory* ast_value_factory, Scope* scope, | 2644 AstValueFactory* ast_value_factory, Scope* scope, |
2644 ZoneList<Statement*>* body, int materialized_literal_count, | 2645 ZoneList<Statement*>* body, int materialized_literal_count, |
2645 int expected_property_count, int parameter_count, | 2646 int expected_property_count, int parameter_count, |
2646 FunctionType function_type, | 2647 FunctionType function_type, |
2647 ParameterFlag has_duplicate_parameters, | 2648 ParameterFlag has_duplicate_parameters, |
2648 EagerCompileHint eager_compile_hint, FunctionKind kind, | 2649 EagerCompileHint eager_compile_hint, FunctionKind kind, |
2649 int position, bool is_function) | 2650 int position, bool is_function) |
2650 : Expression(zone, position, kFunctionLiteral), | 2651 : Expression(zone, position, kFunctionLiteral), |
2651 raw_name_(name), | |
2652 scope_(scope), | |
2653 body_(body), | |
2654 raw_inferred_name_(ast_value_factory->empty_string()), | |
2655 ast_properties_(zone), | |
2656 dont_optimize_reason_(kNoReason), | 2652 dont_optimize_reason_(kNoReason), |
2657 materialized_literal_count_(materialized_literal_count), | 2653 materialized_literal_count_(materialized_literal_count), |
2658 expected_property_count_(expected_property_count), | 2654 expected_property_count_(expected_property_count), |
2659 parameter_count_(parameter_count), | 2655 parameter_count_(parameter_count), |
2660 function_token_position_(kNoSourcePosition), | 2656 function_token_position_(kNoSourcePosition), |
2661 yield_count_(0) { | 2657 yield_count_(0), |
| 2658 raw_name_(name), |
| 2659 scope_(scope), |
| 2660 body_(body), |
| 2661 raw_inferred_name_(ast_value_factory->empty_string()), |
| 2662 ast_properties_(zone) { |
2662 bitfield_ = | 2663 bitfield_ = |
2663 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | | 2664 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | |
2664 HasDuplicateParameters::encode(has_duplicate_parameters == | 2665 HasDuplicateParameters::encode(has_duplicate_parameters == |
2665 kHasDuplicateParameters) | | 2666 kHasDuplicateParameters) | |
2666 IsFunction::encode(is_function) | | 2667 IsFunction::encode(is_function) | |
2667 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | | 2668 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | |
2668 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); | 2669 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); |
2669 DCHECK(IsValidFunctionKind(kind)); | 2670 DCHECK(IsValidFunctionKind(kind)); |
2670 } | 2671 } |
2671 | 2672 |
2672 private: | 2673 private: |
2673 class FunctionTypeBits : public BitField16<FunctionType, 0, 2> {}; | 2674 class FunctionTypeBits : public BitField16<FunctionType, 0, 2> {}; |
2674 class Pretenure : public BitField16<bool, 2, 1> {}; | 2675 class Pretenure : public BitField16<bool, 2, 1> {}; |
2675 class HasDuplicateParameters : public BitField16<bool, 3, 1> {}; | 2676 class HasDuplicateParameters : public BitField16<bool, 3, 1> {}; |
2676 class IsFunction : public BitField16<bool, 4, 1> {}; | 2677 class IsFunction : public BitField16<bool, 4, 1> {}; |
2677 class ShouldEagerCompile : public BitField16<bool, 5, 1> {}; | 2678 class ShouldEagerCompile : public BitField16<bool, 5, 1> {}; |
2678 class ShouldBeUsedOnceHint : public BitField16<bool, 6, 1> {}; | 2679 class ShouldBeUsedOnceHint : public BitField16<bool, 6, 1> {}; |
2679 class FunctionKindBits : public BitField16<FunctionKind, 7, 9> {}; | 2680 class FunctionKindBits : public BitField16<FunctionKind, 7, 9> {}; |
2680 | 2681 |
2681 // Start with 16-bit field, which should get packed together | 2682 // Start with 16-bit field, which should get packed together |
2682 // with Expression's trailing 16-bit field. | 2683 // with Expression's trailing 16-bit field. |
2683 uint16_t bitfield_; | 2684 uint16_t bitfield_; |
2684 | 2685 |
2685 const AstString* raw_name_; | |
2686 Scope* scope_; | |
2687 ZoneList<Statement*>* body_; | |
2688 const AstString* raw_inferred_name_; | |
2689 Handle<String> inferred_name_; | |
2690 AstProperties ast_properties_; | |
2691 BailoutReason dont_optimize_reason_; | 2686 BailoutReason dont_optimize_reason_; |
2692 | 2687 |
2693 int materialized_literal_count_; | 2688 int materialized_literal_count_; |
2694 int expected_property_count_; | 2689 int expected_property_count_; |
2695 int parameter_count_; | 2690 int parameter_count_; |
2696 int function_token_position_; | 2691 int function_token_position_; |
2697 int yield_count_; | 2692 int yield_count_; |
| 2693 |
| 2694 const AstString* raw_name_; |
| 2695 Scope* scope_; |
| 2696 ZoneList<Statement*>* body_; |
| 2697 const AstString* raw_inferred_name_; |
| 2698 Handle<String> inferred_name_; |
| 2699 AstProperties ast_properties_; |
2698 }; | 2700 }; |
2699 | 2701 |
2700 | 2702 |
2701 class ClassLiteral final : public Expression { | 2703 class ClassLiteral final : public Expression { |
2702 public: | 2704 public: |
2703 typedef ObjectLiteralProperty Property; | 2705 typedef ObjectLiteralProperty Property; |
2704 | 2706 |
2705 DECLARE_NODE_TYPE(ClassLiteral) | 2707 DECLARE_NODE_TYPE(ClassLiteral) |
2706 | 2708 |
2707 Scope* scope() const { return scope_; } | 2709 Scope* scope() const { return scope_; } |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2743 bool IsAnonymousFunctionDefinition() const { | 2745 bool IsAnonymousFunctionDefinition() const { |
2744 return constructor()->raw_name()->length() == 0; | 2746 return constructor()->raw_name()->length() == 0; |
2745 } | 2747 } |
2746 | 2748 |
2747 protected: | 2749 protected: |
2748 ClassLiteral(Zone* zone, Scope* scope, VariableProxy* class_variable_proxy, | 2750 ClassLiteral(Zone* zone, Scope* scope, VariableProxy* class_variable_proxy, |
2749 Expression* extends, FunctionLiteral* constructor, | 2751 Expression* extends, FunctionLiteral* constructor, |
2750 ZoneList<Property*>* properties, int start_position, | 2752 ZoneList<Property*>* properties, int start_position, |
2751 int end_position) | 2753 int end_position) |
2752 : Expression(zone, start_position, kClassLiteral), | 2754 : Expression(zone, start_position, kClassLiteral), |
| 2755 end_position_(end_position), |
2753 scope_(scope), | 2756 scope_(scope), |
2754 class_variable_proxy_(class_variable_proxy), | 2757 class_variable_proxy_(class_variable_proxy), |
2755 extends_(extends), | 2758 extends_(extends), |
2756 constructor_(constructor), | 2759 constructor_(constructor), |
2757 properties_(properties), | 2760 properties_(properties) {} |
2758 end_position_(end_position) {} | |
2759 | 2761 |
2760 static int parent_num_ids() { return Expression::num_ids(); } | 2762 static int parent_num_ids() { return Expression::num_ids(); } |
2761 | 2763 |
2762 private: | 2764 private: |
2763 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2765 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
2764 | 2766 |
| 2767 int end_position_; |
| 2768 FeedbackVectorSlot prototype_slot_; |
| 2769 FeedbackVectorSlot proxy_slot_; |
2765 Scope* scope_; | 2770 Scope* scope_; |
2766 VariableProxy* class_variable_proxy_; | 2771 VariableProxy* class_variable_proxy_; |
2767 Expression* extends_; | 2772 Expression* extends_; |
2768 FunctionLiteral* constructor_; | 2773 FunctionLiteral* constructor_; |
2769 ZoneList<Property*>* properties_; | 2774 ZoneList<Property*>* properties_; |
2770 int end_position_; | |
2771 FeedbackVectorSlot prototype_slot_; | |
2772 FeedbackVectorSlot proxy_slot_; | |
2773 }; | 2775 }; |
2774 | 2776 |
2775 | 2777 |
2776 class NativeFunctionLiteral final : public Expression { | 2778 class NativeFunctionLiteral final : public Expression { |
2777 public: | 2779 public: |
2778 DECLARE_NODE_TYPE(NativeFunctionLiteral) | 2780 DECLARE_NODE_TYPE(NativeFunctionLiteral) |
2779 | 2781 |
2780 Handle<String> name() const { return name_->string(); } | 2782 Handle<String> name() const { return name_->string(); } |
2781 v8::Extension* extension() const { return extension_; } | 2783 v8::Extension* extension() const { return extension_; } |
2782 | 2784 |
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3225 return new (local_zone_) | 3227 return new (local_zone_) |
3226 Literal(local_zone_, ast_value_factory_->NewUndefined(), pos); | 3228 Literal(local_zone_, ast_value_factory_->NewUndefined(), pos); |
3227 } | 3229 } |
3228 | 3230 |
3229 Literal* NewTheHoleLiteral(int pos) { | 3231 Literal* NewTheHoleLiteral(int pos) { |
3230 return new (local_zone_) | 3232 return new (local_zone_) |
3231 Literal(local_zone_, ast_value_factory_->NewTheHole(), pos); | 3233 Literal(local_zone_, ast_value_factory_->NewTheHole(), pos); |
3232 } | 3234 } |
3233 | 3235 |
3234 ObjectLiteral* NewObjectLiteral( | 3236 ObjectLiteral* NewObjectLiteral( |
3235 ZoneList<ObjectLiteral::Property*>* properties, | 3237 ZoneList<ObjectLiteral::Property*>* properties, int literal_index, |
3236 int literal_index, | 3238 uint32_t boilerplate_properties, int pos) { |
3237 int boilerplate_properties, | |
3238 int pos) { | |
3239 return new (local_zone_) ObjectLiteral( | 3239 return new (local_zone_) ObjectLiteral( |
3240 local_zone_, properties, literal_index, boilerplate_properties, pos); | 3240 local_zone_, properties, literal_index, boilerplate_properties, pos); |
3241 } | 3241 } |
3242 | 3242 |
3243 ObjectLiteral::Property* NewObjectLiteralProperty( | 3243 ObjectLiteral::Property* NewObjectLiteralProperty( |
3244 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, | 3244 Expression* key, Expression* value, ObjectLiteralProperty::Kind kind, |
3245 bool is_static, bool is_computed_name) { | 3245 bool is_static, bool is_computed_name) { |
3246 return new (local_zone_) | 3246 return new (local_zone_) |
3247 ObjectLiteral::Property(key, value, kind, is_static, is_computed_name); | 3247 ObjectLiteral::Property(key, value, kind, is_static, is_computed_name); |
3248 } | 3248 } |
(...skipping 291 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3540 : NULL; \ | 3540 : NULL; \ |
3541 } | 3541 } |
3542 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3542 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
3543 #undef DECLARE_NODE_FUNCTIONS | 3543 #undef DECLARE_NODE_FUNCTIONS |
3544 | 3544 |
3545 | 3545 |
3546 } // namespace internal | 3546 } // namespace internal |
3547 } // namespace v8 | 3547 } // namespace v8 |
3548 | 3548 |
3549 #endif // V8_AST_AST_H_ | 3549 #endif // V8_AST_AST_H_ |
OLD | NEW |