Chromium Code Reviews| 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 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 185 | 185 |
| 186 | 186 |
| 187 class AstNode: public ZoneObject { | 187 class AstNode: public ZoneObject { |
| 188 public: | 188 public: |
| 189 #define DECLARE_TYPE_ENUM(type) k##type, | 189 #define DECLARE_TYPE_ENUM(type) k##type, |
| 190 enum NodeType : uint8_t { AST_NODE_LIST(DECLARE_TYPE_ENUM) }; | 190 enum NodeType : uint8_t { AST_NODE_LIST(DECLARE_TYPE_ENUM) }; |
| 191 #undef DECLARE_TYPE_ENUM | 191 #undef DECLARE_TYPE_ENUM |
| 192 | 192 |
| 193 void* operator new(size_t size, Zone* zone) { return zone->New(size); } | 193 void* operator new(size_t size, Zone* zone) { return zone->New(size); } |
| 194 | 194 |
| 195 NodeType node_type() const { return node_type_; } | 195 NodeType node_type() const { return NodeTypeField::decode(bit_field_); } |
| 196 int position() const { return position_; } | 196 int position() const { return position_; } |
| 197 | 197 |
| 198 #ifdef DEBUG | 198 #ifdef DEBUG |
| 199 void Print(Isolate* isolate); | 199 void Print(Isolate* isolate); |
| 200 #endif // DEBUG | 200 #endif // DEBUG |
| 201 | 201 |
| 202 // Type testing & conversion functions overridden by concrete subclasses. | 202 // Type testing & conversion functions overridden by concrete subclasses. |
| 203 #define DECLARE_NODE_FUNCTIONS(type) \ | 203 #define DECLARE_NODE_FUNCTIONS(type) \ |
| 204 V8_INLINE bool Is##type() const; \ | 204 V8_INLINE bool Is##type() const; \ |
| 205 V8_INLINE type* As##type(); \ | 205 V8_INLINE type* As##type(); \ |
| 206 V8_INLINE const type* As##type() const; | 206 V8_INLINE const type* As##type() const; |
| 207 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 207 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 208 #undef DECLARE_NODE_FUNCTIONS | 208 #undef DECLARE_NODE_FUNCTIONS |
| 209 | 209 |
| 210 BreakableStatement* AsBreakableStatement(); | 210 BreakableStatement* AsBreakableStatement(); |
| 211 IterationStatement* AsIterationStatement(); | 211 IterationStatement* AsIterationStatement(); |
| 212 MaterializedLiteral* AsMaterializedLiteral(); | 212 MaterializedLiteral* AsMaterializedLiteral(); |
| 213 | 213 |
| 214 protected: | |
| 215 AstNode(int position, NodeType type) | |
| 216 : position_(position), node_type_(type) {} | |
| 217 | |
| 218 private: | 214 private: |
| 219 // Hidden to prevent accidental usage. It would have to load the | 215 // Hidden to prevent accidental usage. It would have to load the |
| 220 // current zone from the TLS. | 216 // current zone from the TLS. |
| 221 void* operator new(size_t size); | 217 void* operator new(size_t size); |
| 222 | 218 |
| 223 int position_; | 219 int position_; |
| 224 NodeType node_type_; | 220 class NodeTypeField : public BitField<NodeType, 0, 7> {}; |
| 225 // Ends with NodeType which is uint8_t sized. Deriving classes in turn begin | 221 |
| 226 // sub-int32_t-sized fields for optimum packing efficiency. | 222 protected: |
| 223 uint32_t bit_field_; | |
| 224 static const uint8_t kNextBitFieldIndex = NodeTypeField::kNext; | |
| 225 | |
| 226 AstNode(int position, NodeType type) | |
| 227 : position_(position), bit_field_(NodeTypeField::encode(type)) {} | |
| 227 }; | 228 }; |
| 228 | 229 |
| 229 | 230 |
| 230 class Statement : public AstNode { | 231 class Statement : public AstNode { |
| 231 public: | 232 public: |
| 232 bool IsEmpty() { return AsEmptyStatement() != NULL; } | 233 bool IsEmpty() { return AsEmptyStatement() != NULL; } |
| 233 bool IsJump() const; | 234 bool IsJump() const; |
| 234 | 235 |
| 235 protected: | 236 protected: |
| 236 Statement(int position, NodeType type) : AstNode(position, type) {} | 237 Statement(int position, NodeType type) : AstNode(position, type) {} |
| 238 | |
| 239 static const uint8_t kNextBitFieldIndex = AstNode::kNextBitFieldIndex; | |
| 237 }; | 240 }; |
| 238 | 241 |
| 239 | 242 |
| 240 class SmallMapList final { | 243 class SmallMapList final { |
| 241 public: | 244 public: |
| 242 SmallMapList() {} | 245 SmallMapList() {} |
| 243 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} | 246 SmallMapList(int capacity, Zone* zone) : list_(capacity, zone) {} |
| 244 | 247 |
| 245 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); } | 248 void Reserve(int capacity, Zone* zone) { list_.Reserve(capacity, zone); } |
| 246 void Clear() { list_.Clear(); } | 249 void Clear() { list_.Clear(); } |
| (...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 342 SmallMapList* GetReceiverTypes(); | 345 SmallMapList* GetReceiverTypes(); |
| 343 KeyedAccessStoreMode GetStoreMode() const; | 346 KeyedAccessStoreMode GetStoreMode() const; |
| 344 IcCheckType GetKeyType() const; | 347 IcCheckType GetKeyType() const; |
| 345 bool IsMonomorphic() const; | 348 bool IsMonomorphic() const; |
| 346 | 349 |
| 347 void set_base_id(int id) { base_id_ = id; } | 350 void set_base_id(int id) { base_id_ = id; } |
| 348 static int num_ids() { return parent_num_ids() + 2; } | 351 static int num_ids() { return parent_num_ids() + 2; } |
| 349 BailoutId id() const { return BailoutId(local_id(0)); } | 352 BailoutId id() const { return BailoutId(local_id(0)); } |
| 350 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); } | 353 TypeFeedbackId test_id() const { return TypeFeedbackId(local_id(1)); } |
| 351 | 354 |
| 355 private: | |
| 356 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 357 | |
| 358 int base_id_; | |
| 359 class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {}; | |
| 360 | |
| 352 protected: | 361 protected: |
| 353 Expression(int pos, NodeType type) | 362 Expression(int pos, NodeType type) |
| 354 : AstNode(pos, type), | 363 : AstNode(pos, type), base_id_(BailoutId::None().ToInt()) { |
| 355 bit_field_(0), | 364 bit_field_ = ToBooleanTypesField::update(bit_field_, 0); |
|
Toon Verwaest
2016/08/26 14:55:02
Huh? why is this 0-9 rather tahn kNextBitFieldInde
| |
| 356 base_id_(BailoutId::None().ToInt()) {} | 365 } |
| 357 | 366 |
| 358 static int parent_num_ids() { return 0; } | 367 static int parent_num_ids() { return 0; } |
| 359 void set_to_boolean_types(uint16_t types) { | 368 void set_to_boolean_types(uint16_t types) { |
| 360 bit_field_ = ToBooleanTypesField::update(bit_field_, types); | 369 bit_field_ = ToBooleanTypesField::update(bit_field_, types); |
| 361 } | 370 } |
| 362 int base_id() const { | 371 int base_id() const { |
| 363 DCHECK(!BailoutId(base_id_).IsNone()); | 372 DCHECK(!BailoutId(base_id_).IsNone()); |
| 364 return base_id_; | 373 return base_id_; |
| 365 } | 374 } |
| 366 | 375 |
| 367 private: | 376 static const uint8_t kNextBitFieldIndex = ToBooleanTypesField::kNext; |
| 368 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 369 | |
| 370 uint16_t bit_field_; | |
| 371 int base_id_; | |
| 372 class ToBooleanTypesField : public BitField16<uint16_t, 0, 9> {}; | |
| 373 }; | 377 }; |
| 374 | 378 |
| 375 | 379 |
| 376 class BreakableStatement : public Statement { | 380 class BreakableStatement : public Statement { |
| 377 public: | 381 public: |
| 378 enum BreakableType { | 382 enum BreakableType { |
| 379 TARGET_FOR_ANONYMOUS, | 383 TARGET_FOR_ANONYMOUS, |
| 380 TARGET_FOR_NAMED_ONLY | 384 TARGET_FOR_NAMED_ONLY |
| 381 }; | 385 }; |
| 382 | 386 |
| 383 // The labels associated with this statement. May be NULL; | 387 // The labels associated with this statement. May be NULL; |
| 384 // if it is != NULL, guaranteed to contain at least one entry. | 388 // if it is != NULL, guaranteed to contain at least one entry. |
| 385 ZoneList<const AstRawString*>* labels() const { return labels_; } | 389 ZoneList<const AstRawString*>* labels() const { return labels_; } |
| 386 | 390 |
| 387 // Code generation | 391 // Code generation |
| 388 Label* break_target() { return &break_target_; } | 392 Label* break_target() { return &break_target_; } |
| 389 | 393 |
| 390 // Testers. | 394 // Testers. |
| 391 bool is_target_for_anonymous() const { | 395 bool is_target_for_anonymous() const { |
| 392 return breakable_type_ == TARGET_FOR_ANONYMOUS; | 396 return BreakableTypeField::decode(bit_field_) == TARGET_FOR_ANONYMOUS; |
| 393 } | 397 } |
| 394 | 398 |
| 395 void set_base_id(int id) { base_id_ = id; } | 399 void set_base_id(int id) { base_id_ = id; } |
| 396 static int num_ids() { return parent_num_ids() + 2; } | 400 static int num_ids() { return parent_num_ids() + 2; } |
| 397 BailoutId EntryId() const { return BailoutId(local_id(0)); } | 401 BailoutId EntryId() const { return BailoutId(local_id(0)); } |
| 398 BailoutId ExitId() const { return BailoutId(local_id(1)); } | 402 BailoutId ExitId() const { return BailoutId(local_id(1)); } |
| 399 | 403 |
| 404 private: | |
| 405 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 406 | |
| 407 BreakableType breakableType() const { | |
| 408 return BreakableTypeField::decode(bit_field_); | |
| 409 } | |
| 410 | |
| 411 int base_id_; | |
| 412 Label break_target_; | |
| 413 ZoneList<const AstRawString*>* labels_; | |
| 414 | |
| 415 class BreakableTypeField | |
| 416 : public BitField<BreakableType, Statement::kNextBitFieldIndex, 1> {}; | |
| 417 | |
| 400 protected: | 418 protected: |
| 401 BreakableStatement(ZoneList<const AstRawString*>* labels, | 419 BreakableStatement(ZoneList<const AstRawString*>* labels, |
| 402 BreakableType breakable_type, int position, NodeType type) | 420 BreakableType breakable_type, int position, NodeType type) |
| 403 : Statement(position, type), | 421 : Statement(position, type), |
| 404 breakable_type_(breakable_type), | |
| 405 base_id_(BailoutId::None().ToInt()), | 422 base_id_(BailoutId::None().ToInt()), |
| 406 labels_(labels) { | 423 labels_(labels) { |
| 407 DCHECK(labels == NULL || labels->length() > 0); | 424 DCHECK(labels == NULL || labels->length() > 0); |
| 425 bit_field_ |= BreakableTypeField::encode(breakable_type); | |
| 408 } | 426 } |
| 409 static int parent_num_ids() { return 0; } | 427 static int parent_num_ids() { return 0; } |
| 410 | 428 |
| 411 int base_id() const { | 429 int base_id() const { |
| 412 DCHECK(!BailoutId(base_id_).IsNone()); | 430 DCHECK(!BailoutId(base_id_).IsNone()); |
| 413 return base_id_; | 431 return base_id_; |
| 414 } | 432 } |
| 415 | 433 |
| 416 private: | 434 static const uint8_t kNextBitFieldIndex = BreakableTypeField::kNext; |
| 417 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | |
| 418 | |
| 419 BreakableType breakable_type_; | |
| 420 int base_id_; | |
| 421 Label break_target_; | |
| 422 ZoneList<const AstRawString*>* labels_; | |
| 423 }; | 435 }; |
| 424 | 436 |
| 425 | 437 |
| 426 class Block final : public BreakableStatement { | 438 class Block final : public BreakableStatement { |
| 427 public: | 439 public: |
| 428 ZoneList<Statement*>* statements() { return &statements_; } | 440 ZoneList<Statement*>* statements() { return &statements_; } |
| 429 bool ignore_completion_value() const { return ignore_completion_value_; } | 441 bool ignore_completion_value() const { return ignore_completion_value_; } |
| 430 | 442 |
| 431 static int num_ids() { return parent_num_ids() + 1; } | 443 static int num_ids() { return parent_num_ids() + 1; } |
| 432 BailoutId DeclsId() const { return BailoutId(local_id(0)); } | 444 BailoutId DeclsId() const { return BailoutId(local_id(0)); } |
| 433 | 445 |
| 434 bool IsJump() const { | 446 bool IsJump() const { |
| 435 return !statements_.is_empty() && statements_.last()->IsJump() | 447 return !statements_.is_empty() && statements_.last()->IsJump() |
| 436 && labels() == NULL; // Good enough as an approximation... | 448 && labels() == NULL; // Good enough as an approximation... |
| 437 } | 449 } |
| 438 | 450 |
| 439 Scope* scope() const { return scope_; } | 451 Scope* scope() const { return scope_; } |
| 440 void set_scope(Scope* scope) { scope_ = scope; } | 452 void set_scope(Scope* scope) { scope_ = scope; } |
| 441 | 453 |
| 442 private: | 454 private: |
| 443 friend class AstNodeFactory; | 455 friend class AstNodeFactory; |
| 444 | 456 |
| 445 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, | 457 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, |
| 446 bool ignore_completion_value, int pos) | 458 bool ignore_completion_value, int pos) |
| 447 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY, pos, kBlock), | 459 : BreakableStatement(labels, TARGET_FOR_NAMED_ONLY, pos, kBlock), |
| 448 statements_(capacity, zone), | 460 statements_(capacity, zone), |
| 449 ignore_completion_value_(ignore_completion_value), | 461 scope_(NULL) { |
| 450 scope_(NULL) {} | 462 bit_field_ |= IgnoreCompletionField::encode(ignore_completion_value); |
| 463 } | |
| 451 static int parent_num_ids() { return BreakableStatement::num_ids(); } | 464 static int parent_num_ids() { return BreakableStatement::num_ids(); } |
| 452 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 465 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 453 | 466 |
| 454 ZoneList<Statement*> statements_; | 467 ZoneList<Statement*> statements_; |
| 455 bool ignore_completion_value_; | 468 bool ignore_completion_value_; |
| 456 Scope* scope_; | 469 Scope* scope_; |
| 470 | |
| 471 class IgnoreCompletionField | |
| 472 : public BitField<bool, BreakableStatement::kNextBitFieldIndex, 1> {}; | |
| 473 | |
| 474 protected: | |
| 475 static const uint8_t kNextBitFieldIndex = IgnoreCompletionField::kNext; | |
| 457 }; | 476 }; |
| 458 | 477 |
| 459 | 478 |
| 460 class DoExpression final : public Expression { | 479 class DoExpression final : public Expression { |
| 461 public: | 480 public: |
| 462 Block* block() { return block_; } | 481 Block* block() { return block_; } |
| 463 void set_block(Block* b) { block_ = b; } | 482 void set_block(Block* b) { block_ = b; } |
| 464 VariableProxy* result() { return result_; } | 483 VariableProxy* result() { return result_; } |
| 465 void set_result(VariableProxy* v) { result_ = v; } | 484 void set_result(VariableProxy* v) { result_ = v; } |
| 466 FunctionLiteral* represented_function() { return represented_function_; } | 485 FunctionLiteral* represented_function() { return represented_function_; } |
| 467 void set_represented_function(FunctionLiteral* f) { | 486 void set_represented_function(FunctionLiteral* f) { |
| 468 represented_function_ = f; | 487 represented_function_ = f; |
| 469 } | 488 } |
| 470 bool IsAnonymousFunctionDefinition() const; | 489 bool IsAnonymousFunctionDefinition() const; |
| 471 | 490 |
| 491 protected: | |
| 492 static const uint8_t kNextBitFieldIndex = Expression::kNextBitFieldIndex; | |
| 493 | |
| 472 private: | 494 private: |
| 473 friend class AstNodeFactory; | 495 friend class AstNodeFactory; |
| 474 | 496 |
| 475 DoExpression(Block* block, VariableProxy* result, int pos) | 497 DoExpression(Block* block, VariableProxy* result, int pos) |
| 476 : Expression(pos, kDoExpression), | 498 : Expression(pos, kDoExpression), |
| 477 block_(block), | 499 block_(block), |
| 478 result_(result), | 500 result_(result), |
| 479 represented_function_(nullptr) { | 501 represented_function_(nullptr) { |
| 480 DCHECK_NOT_NULL(block_); | 502 DCHECK_NOT_NULL(block_); |
| 481 DCHECK_NOT_NULL(result_); | 503 DCHECK_NOT_NULL(result_); |
| 482 } | 504 } |
| 483 static int parent_num_ids() { return Expression::num_ids(); } | 505 static int parent_num_ids() { return Expression::num_ids(); } |
| 484 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 506 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 485 | 507 |
| 486 Block* block_; | 508 Block* block_; |
| 487 VariableProxy* result_; | 509 VariableProxy* result_; |
| 488 FunctionLiteral* represented_function_; | 510 FunctionLiteral* represented_function_; |
| 489 }; | 511 }; |
| 490 | 512 |
| 491 | 513 |
| 492 class Declaration : public AstNode { | 514 class Declaration : public AstNode { |
| 493 public: | 515 public: |
| 494 VariableProxy* proxy() const { return proxy_; } | 516 VariableProxy* proxy() const { return proxy_; } |
| 495 Scope* scope() const { return scope_; } | 517 Scope* scope() const { return scope_; } |
| 496 | 518 |
| 497 protected: | 519 protected: |
| 498 Declaration(VariableProxy* proxy, Scope* scope, int pos, NodeType type) | 520 Declaration(VariableProxy* proxy, Scope* scope, int pos, NodeType type) |
| 499 : AstNode(pos, type), proxy_(proxy), scope_(scope) {} | 521 : AstNode(pos, type), proxy_(proxy), scope_(scope) {} |
| 500 | 522 |
| 523 static const uint8_t kNextBitFieldIndex = AstNode::kNextBitFieldIndex; | |
| 524 | |
| 501 private: | 525 private: |
| 502 VariableProxy* proxy_; | 526 VariableProxy* proxy_; |
| 503 | 527 |
| 504 // Nested scope from which the declaration originated. | 528 // Nested scope from which the declaration originated. |
| 505 Scope* scope_; | 529 Scope* scope_; |
| 506 }; | 530 }; |
| 507 | 531 |
| 508 | 532 |
| 509 class VariableDeclaration final : public Declaration { | 533 class VariableDeclaration final : public Declaration { |
| 510 private: | 534 private: |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 554 protected: | 578 protected: |
| 555 IterationStatement(ZoneList<const AstRawString*>* labels, int pos, | 579 IterationStatement(ZoneList<const AstRawString*>* labels, int pos, |
| 556 NodeType type) | 580 NodeType type) |
| 557 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS, pos, type), | 581 : BreakableStatement(labels, TARGET_FOR_ANONYMOUS, pos, type), |
| 558 body_(NULL), | 582 body_(NULL), |
| 559 yield_count_(0), | 583 yield_count_(0), |
| 560 first_yield_id_(0) {} | 584 first_yield_id_(0) {} |
| 561 static int parent_num_ids() { return BreakableStatement::num_ids(); } | 585 static int parent_num_ids() { return BreakableStatement::num_ids(); } |
| 562 void Initialize(Statement* body) { body_ = body; } | 586 void Initialize(Statement* body) { body_ = body; } |
| 563 | 587 |
| 588 static const uint8_t kNextBitFieldIndex = | |
| 589 BreakableStatement::kNextBitFieldIndex; | |
| 590 | |
| 564 private: | 591 private: |
| 565 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 592 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 566 | 593 |
| 567 Statement* body_; | 594 Statement* body_; |
| 568 Label continue_target_; | 595 Label continue_target_; |
| 569 int yield_count_; | 596 int yield_count_; |
| 570 int first_yield_id_; | 597 int first_yield_id_; |
| 571 }; | 598 }; |
| 572 | 599 |
| 573 | 600 |
| (...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 708 // Type feedback information. | 735 // Type feedback information. |
| 709 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 736 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 710 FeedbackVectorSlotCache* cache); | 737 FeedbackVectorSlotCache* cache); |
| 711 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; } | 738 FeedbackVectorSlot EachFeedbackSlot() const { return each_slot_; } |
| 712 FeedbackVectorSlot ForInFeedbackSlot() { | 739 FeedbackVectorSlot ForInFeedbackSlot() { |
| 713 DCHECK(!for_in_feedback_slot_.IsInvalid()); | 740 DCHECK(!for_in_feedback_slot_.IsInvalid()); |
| 714 return for_in_feedback_slot_; | 741 return for_in_feedback_slot_; |
| 715 } | 742 } |
| 716 | 743 |
| 717 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 744 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
| 718 ForInType for_in_type() const { return for_in_type_; } | 745 ForInType for_in_type() const { return ForInTypeField::decode(bit_field_); } |
| 719 void set_for_in_type(ForInType type) { for_in_type_ = type; } | 746 void set_for_in_type(ForInType type) { |
| 747 bit_field_ = ForInTypeField::update(bit_field_, type); | |
| 748 } | |
| 720 | 749 |
| 721 static int num_ids() { return parent_num_ids() + 6; } | 750 static int num_ids() { return parent_num_ids() + 6; } |
| 722 BailoutId BodyId() const { return BailoutId(local_id(0)); } | 751 BailoutId BodyId() const { return BailoutId(local_id(0)); } |
| 723 BailoutId EnumId() const { return BailoutId(local_id(1)); } | 752 BailoutId EnumId() const { return BailoutId(local_id(1)); } |
| 724 BailoutId ToObjectId() const { return BailoutId(local_id(2)); } | 753 BailoutId ToObjectId() const { return BailoutId(local_id(2)); } |
| 725 BailoutId PrepareId() const { return BailoutId(local_id(3)); } | 754 BailoutId PrepareId() const { return BailoutId(local_id(3)); } |
| 726 BailoutId FilterId() const { return BailoutId(local_id(4)); } | 755 BailoutId FilterId() const { return BailoutId(local_id(4)); } |
| 727 BailoutId AssignmentId() const { return BailoutId(local_id(5)); } | 756 BailoutId AssignmentId() const { return BailoutId(local_id(5)); } |
| 728 BailoutId ContinueId() const { return EntryId(); } | 757 BailoutId ContinueId() const { return EntryId(); } |
| 729 BailoutId StackCheckId() const { return BodyId(); } | 758 BailoutId StackCheckId() const { return BodyId(); } |
| 730 | 759 |
| 731 private: | 760 private: |
| 732 friend class AstNodeFactory; | 761 friend class AstNodeFactory; |
| 733 | 762 |
| 734 ForInStatement(ZoneList<const AstRawString*>* labels, int pos) | 763 ForInStatement(ZoneList<const AstRawString*>* labels, int pos) |
| 735 : ForEachStatement(labels, pos, kForInStatement), | 764 : ForEachStatement(labels, pos, kForInStatement), |
| 736 each_(nullptr), | 765 each_(nullptr), |
| 737 subject_(nullptr), | 766 subject_(nullptr) { |
| 738 for_in_type_(SLOW_FOR_IN) {} | 767 bit_field_ = ForInTypeField::update(bit_field_, SLOW_FOR_IN); |
| 768 } | |
| 769 | |
| 739 static int parent_num_ids() { return ForEachStatement::num_ids(); } | 770 static int parent_num_ids() { return ForEachStatement::num_ids(); } |
| 740 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 771 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 741 | 772 |
| 742 Expression* each_; | 773 Expression* each_; |
| 743 Expression* subject_; | 774 Expression* subject_; |
| 744 ForInType for_in_type_; | |
| 745 FeedbackVectorSlot each_slot_; | 775 FeedbackVectorSlot each_slot_; |
| 746 FeedbackVectorSlot for_in_feedback_slot_; | 776 FeedbackVectorSlot for_in_feedback_slot_; |
| 777 | |
| 778 class ForInTypeField | |
| 779 : public BitField<ForInType, ForEachStatement::kNextBitFieldIndex, 1> {}; | |
| 780 | |
| 781 protected: | |
| 782 static const uint8_t kNextBitFieldIndex = ForInTypeField::kNext; | |
| 747 }; | 783 }; |
| 748 | 784 |
| 749 | 785 |
| 750 class ForOfStatement final : public ForEachStatement { | 786 class ForOfStatement final : public ForEachStatement { |
| 751 public: | 787 public: |
| 752 void Initialize(Statement* body, Variable* iterator, | 788 void Initialize(Statement* body, Variable* iterator, |
| 753 Expression* assign_iterator, Expression* next_result, | 789 Expression* assign_iterator, Expression* next_result, |
| 754 Expression* result_done, Expression* assign_each) { | 790 Expression* result_done, Expression* assign_each) { |
| 755 ForEachStatement::Initialize(body); | 791 ForEachStatement::Initialize(body); |
| 756 iterator_ = iterator; | 792 iterator_ = iterator; |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1234 class MaterializedLiteral : public Expression { | 1270 class MaterializedLiteral : public Expression { |
| 1235 public: | 1271 public: |
| 1236 int literal_index() { return literal_index_; } | 1272 int literal_index() { return literal_index_; } |
| 1237 | 1273 |
| 1238 int depth() const { | 1274 int depth() const { |
| 1239 // only callable after initialization. | 1275 // only callable after initialization. |
| 1240 DCHECK(depth_ >= 1); | 1276 DCHECK(depth_ >= 1); |
| 1241 return depth_; | 1277 return depth_; |
| 1242 } | 1278 } |
| 1243 | 1279 |
| 1280 private: | |
| 1281 int depth_ : 31; | |
| 1282 int literal_index_; | |
| 1283 | |
| 1284 friend class AstLiteralReindexer; | |
| 1285 | |
| 1286 class IsSimpleField | |
| 1287 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; | |
| 1288 | |
| 1244 protected: | 1289 protected: |
| 1245 MaterializedLiteral(int literal_index, int pos, NodeType type) | 1290 MaterializedLiteral(int literal_index, int pos, NodeType type) |
| 1246 : Expression(pos, type), | 1291 : Expression(pos, type), depth_(0), literal_index_(literal_index) { |
| 1247 is_simple_(false), | 1292 bit_field_ |= IsSimpleField::encode(false); |
| 1248 depth_(0), | 1293 } |
| 1249 literal_index_(literal_index) {} | |
| 1250 | 1294 |
| 1251 // A materialized literal is simple if the values consist of only | 1295 // A materialized literal is simple if the values consist of only |
| 1252 // constants and simple object and array literals. | 1296 // constants and simple object and array literals. |
| 1253 bool is_simple() const { return is_simple_; } | 1297 bool is_simple() const { return IsSimpleField::decode(bit_field_); } |
| 1254 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } | 1298 void set_is_simple(bool is_simple) { |
| 1299 bit_field_ = IsSimpleField::update(bit_field_, is_simple); | |
| 1300 } | |
| 1255 friend class CompileTimeValue; | 1301 friend class CompileTimeValue; |
| 1256 | 1302 |
| 1257 void set_depth(int depth) { | 1303 void set_depth(int depth) { |
| 1258 DCHECK_LE(1, depth); | 1304 DCHECK_LE(1, depth); |
| 1259 depth_ = depth; | 1305 depth_ = depth; |
| 1260 } | 1306 } |
| 1261 | 1307 |
| 1262 // Populate the constant properties/elements fixed array. | 1308 // Populate the constant properties/elements fixed array. |
| 1263 void BuildConstants(Isolate* isolate); | 1309 void BuildConstants(Isolate* isolate); |
| 1264 friend class ArrayLiteral; | 1310 friend class ArrayLiteral; |
| 1265 friend class ObjectLiteral; | 1311 friend class ObjectLiteral; |
| 1266 | 1312 |
| 1267 // If the expression is a literal, return the literal value; | 1313 // If the expression is a literal, return the literal value; |
| 1268 // if the expression is a materialized literal and is simple return a | 1314 // if the expression is a materialized literal and is simple return a |
| 1269 // compile time value as encoded by CompileTimeValue::GetValue(). | 1315 // compile time value as encoded by CompileTimeValue::GetValue(). |
| 1270 // Otherwise, return undefined literal as the placeholder | 1316 // Otherwise, return undefined literal as the placeholder |
| 1271 // in the object literal boilerplate. | 1317 // in the object literal boilerplate. |
| 1272 Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate); | 1318 Handle<Object> GetBoilerplateValue(Expression* expression, Isolate* isolate); |
| 1273 | 1319 |
| 1274 private: | 1320 static const uint8_t kNextBitFieldIndex = IsSimpleField::kNext; |
| 1275 bool is_simple_ : 1; | |
| 1276 int depth_ : 31; | |
| 1277 int literal_index_; | |
| 1278 | |
| 1279 friend class AstLiteralReindexer; | |
| 1280 }; | 1321 }; |
| 1281 | 1322 |
| 1282 | 1323 |
| 1283 // Property is used for passing information | 1324 // Property is used for passing information |
| 1284 // about an object literal's properties from the parser | 1325 // about an object literal's properties from the parser |
| 1285 // to the code generator. | 1326 // to the code generator. |
| 1286 class ObjectLiteralProperty final : public ZoneObject { | 1327 class ObjectLiteralProperty final : public ZoneObject { |
| 1287 public: | 1328 public: |
| 1288 enum Kind : uint8_t { | 1329 enum Kind : uint8_t { |
| 1289 CONSTANT, // Property with constant value (compile time). | 1330 CONSTANT, // Property with constant value (compile time). |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1350 // for minimizing the work when constructing it at runtime. | 1391 // for minimizing the work when constructing it at runtime. |
| 1351 class ObjectLiteral final : public MaterializedLiteral { | 1392 class ObjectLiteral final : public MaterializedLiteral { |
| 1352 public: | 1393 public: |
| 1353 typedef ObjectLiteralProperty Property; | 1394 typedef ObjectLiteralProperty Property; |
| 1354 | 1395 |
| 1355 Handle<FixedArray> constant_properties() const { | 1396 Handle<FixedArray> constant_properties() const { |
| 1356 return constant_properties_; | 1397 return constant_properties_; |
| 1357 } | 1398 } |
| 1358 int properties_count() const { return boilerplate_properties_; } | 1399 int properties_count() const { return boilerplate_properties_; } |
| 1359 ZoneList<Property*>* properties() const { return properties_; } | 1400 ZoneList<Property*>* properties() const { return properties_; } |
| 1360 bool fast_elements() const { return fast_elements_; } | 1401 bool fast_elements() const { return FastElementsField::decode(bit_field_); } |
| 1361 bool may_store_doubles() const { return may_store_doubles_; } | 1402 bool may_store_doubles() const { |
| 1362 bool has_elements() const { return has_elements_; } | 1403 return MayStoreDoublesField::decode(bit_field_); |
| 1404 } | |
| 1405 bool has_elements() const { return HasElementsField::decode(bit_field_); } | |
| 1363 bool has_shallow_properties() const { | 1406 bool has_shallow_properties() const { |
| 1364 return depth() == 1 && !has_elements() && !may_store_doubles(); | 1407 return depth() == 1 && !has_elements() && !may_store_doubles(); |
| 1365 } | 1408 } |
| 1366 | 1409 |
| 1367 // Decide if a property should be in the object boilerplate. | 1410 // Decide if a property should be in the object boilerplate. |
| 1368 static bool IsBoilerplateProperty(Property* property); | 1411 static bool IsBoilerplateProperty(Property* property); |
| 1369 | 1412 |
| 1370 // Populate the constant properties fixed array. | 1413 // Populate the constant properties fixed array. |
| 1371 void BuildConstantProperties(Isolate* isolate); | 1414 void BuildConstantProperties(Isolate* isolate); |
| 1372 | 1415 |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1422 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 1465 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 1423 FeedbackVectorSlotCache* cache); | 1466 FeedbackVectorSlotCache* cache); |
| 1424 | 1467 |
| 1425 private: | 1468 private: |
| 1426 friend class AstNodeFactory; | 1469 friend class AstNodeFactory; |
| 1427 | 1470 |
| 1428 ObjectLiteral(ZoneList<Property*>* properties, int literal_index, | 1471 ObjectLiteral(ZoneList<Property*>* properties, int literal_index, |
| 1429 uint32_t boilerplate_properties, int pos) | 1472 uint32_t boilerplate_properties, int pos) |
| 1430 : MaterializedLiteral(literal_index, pos, kObjectLiteral), | 1473 : MaterializedLiteral(literal_index, pos, kObjectLiteral), |
| 1431 boilerplate_properties_(boilerplate_properties), | 1474 boilerplate_properties_(boilerplate_properties), |
| 1432 fast_elements_(false), | 1475 properties_(properties) { |
| 1433 has_elements_(false), | 1476 bit_field_ |= FastElementsField::encode(false) | |
| 1434 may_store_doubles_(false), | 1477 HasElementsField::encode(false) | |
| 1435 properties_(properties) {} | 1478 MayStoreDoublesField::encode(false); |
| 1479 } | |
| 1436 | 1480 |
| 1437 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } | 1481 static int parent_num_ids() { return MaterializedLiteral::num_ids(); } |
| 1438 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1482 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1439 | 1483 |
| 1440 uint32_t boilerplate_properties_ : 29; | 1484 uint32_t boilerplate_properties_; |
| 1441 bool fast_elements_ : 1; | |
| 1442 bool has_elements_ : 1; | |
| 1443 bool may_store_doubles_ : 1; | |
| 1444 FeedbackVectorSlot slot_; | 1485 FeedbackVectorSlot slot_; |
| 1445 Handle<FixedArray> constant_properties_; | 1486 Handle<FixedArray> constant_properties_; |
| 1446 ZoneList<Property*>* properties_; | 1487 ZoneList<Property*>* properties_; |
| 1488 | |
| 1489 class FastElementsField | |
| 1490 : public BitField<bool, MaterializedLiteral::kNextBitFieldIndex, 1> {}; | |
| 1491 class HasElementsField : public BitField<bool, FastElementsField::kNext, 1> { | |
| 1492 }; | |
| 1493 class MayStoreDoublesField | |
| 1494 : public BitField<bool, HasElementsField::kNext, 1> {}; | |
| 1495 | |
| 1496 protected: | |
| 1497 static const uint8_t kNextBitFieldIndex = MayStoreDoublesField::kNext; | |
| 1447 }; | 1498 }; |
| 1448 | 1499 |
| 1449 | 1500 |
| 1450 // A map from property names to getter/setter pairs allocated in the zone. | 1501 // A map from property names to getter/setter pairs allocated in the zone. |
| 1451 class AccessorTable | 1502 class AccessorTable |
| 1452 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, | 1503 : public base::TemplateHashMap<Literal, ObjectLiteral::Accessors, |
| 1453 ZoneAllocationPolicy> { | 1504 ZoneAllocationPolicy> { |
| 1454 public: | 1505 public: |
| 1455 explicit AccessorTable(Zone* zone) | 1506 explicit AccessorTable(Zone* zone) |
| 1456 : base::TemplateHashMap<Literal, ObjectLiteral::Accessors, | 1507 : base::TemplateHashMap<Literal, ObjectLiteral::Accessors, |
| (...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1628 friend class AstNodeFactory; | 1679 friend class AstNodeFactory; |
| 1629 | 1680 |
| 1630 VariableProxy(Variable* var, int start_position, int end_position); | 1681 VariableProxy(Variable* var, int start_position, int end_position); |
| 1631 VariableProxy(const AstRawString* name, Variable::Kind variable_kind, | 1682 VariableProxy(const AstRawString* name, Variable::Kind variable_kind, |
| 1632 int start_position, int end_position); | 1683 int start_position, int end_position); |
| 1633 explicit VariableProxy(const VariableProxy* copy_from); | 1684 explicit VariableProxy(const VariableProxy* copy_from); |
| 1634 | 1685 |
| 1635 static int parent_num_ids() { return Expression::num_ids(); } | 1686 static int parent_num_ids() { return Expression::num_ids(); } |
| 1636 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1687 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1637 | 1688 |
| 1638 class IsThisField : public BitField8<bool, 0, 1> {}; | 1689 class IsThisField : public BitField<bool, Expression::kNextBitFieldIndex, 1> { |
| 1639 class IsAssignedField : public BitField8<bool, 1, 1> {}; | 1690 }; |
| 1640 class IsResolvedField : public BitField8<bool, 2, 1> {}; | 1691 class IsAssignedField : public BitField<bool, IsThisField::kNext, 1> {}; |
| 1641 class IsNewTargetField : public BitField8<bool, 3, 1> {}; | 1692 class IsResolvedField : public BitField<bool, IsAssignedField::kNext, 1> {}; |
| 1693 class IsNewTargetField : public BitField<bool, IsResolvedField::kNext, 1> {}; | |
| 1642 | 1694 |
| 1643 uint8_t bit_field_; | |
| 1644 // Position is stored in the AstNode superclass, but VariableProxy needs to | 1695 // Position is stored in the AstNode superclass, but VariableProxy needs to |
| 1645 // know its end position too (for error messages). It cannot be inferred from | 1696 // know its end position too (for error messages). It cannot be inferred from |
| 1646 // the variable name length because it can contain escapes. | 1697 // the variable name length because it can contain escapes. |
| 1647 int end_position_; | 1698 int end_position_; |
| 1648 FeedbackVectorSlot variable_feedback_slot_; | 1699 FeedbackVectorSlot variable_feedback_slot_; |
| 1649 union { | 1700 union { |
| 1650 const AstRawString* raw_name_; // if !is_resolved_ | 1701 const AstRawString* raw_name_; // if !is_resolved_ |
| 1651 Variable* var_; // if is_resolved_ | 1702 Variable* var_; // if is_resolved_ |
| 1652 }; | 1703 }; |
| 1653 VariableProxy* next_unresolved_; | 1704 VariableProxy* next_unresolved_; |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1730 bool super_access = property->IsSuperAccess(); | 1781 bool super_access = property->IsSuperAccess(); |
| 1731 return (property->key()->IsPropertyName()) | 1782 return (property->key()->IsPropertyName()) |
| 1732 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) | 1783 ? (super_access ? NAMED_SUPER_PROPERTY : NAMED_PROPERTY) |
| 1733 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); | 1784 : (super_access ? KEYED_SUPER_PROPERTY : KEYED_PROPERTY); |
| 1734 } | 1785 } |
| 1735 | 1786 |
| 1736 private: | 1787 private: |
| 1737 friend class AstNodeFactory; | 1788 friend class AstNodeFactory; |
| 1738 | 1789 |
| 1739 Property(Expression* obj, Expression* key, int pos) | 1790 Property(Expression* obj, Expression* key, int pos) |
| 1740 : Expression(pos, kProperty), | 1791 : Expression(pos, kProperty), obj_(obj), key_(key) { |
| 1741 bit_field_(IsForCallField::encode(false) | | 1792 bit_field_ |= IsForCallField::encode(false) | |
| 1742 IsStringAccessField::encode(false) | | 1793 IsStringAccessField::encode(false) | |
| 1743 InlineCacheStateField::encode(UNINITIALIZED)), | 1794 InlineCacheStateField::encode(UNINITIALIZED); |
| 1744 obj_(obj), | 1795 } |
| 1745 key_(key) {} | |
| 1746 | 1796 |
| 1747 static int parent_num_ids() { return Expression::num_ids(); } | 1797 static int parent_num_ids() { return Expression::num_ids(); } |
| 1748 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1798 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1749 | 1799 |
| 1750 class IsForCallField : public BitField8<bool, 0, 1> {}; | 1800 class IsForCallField |
| 1751 class IsStringAccessField : public BitField8<bool, 1, 1> {}; | 1801 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; |
| 1752 class KeyTypeField : public BitField8<IcCheckType, 2, 1> {}; | 1802 class IsStringAccessField : public BitField<bool, IsForCallField::kNext, 1> { |
| 1753 class InlineCacheStateField : public BitField8<InlineCacheState, 3, 4> {}; | 1803 }; |
| 1804 class KeyTypeField | |
| 1805 : public BitField<IcCheckType, IsStringAccessField::kNext, 1> {}; | |
| 1806 class InlineCacheStateField | |
| 1807 : public BitField<InlineCacheState, KeyTypeField::kNext, 4> {}; | |
| 1754 | 1808 |
| 1755 uint8_t bit_field_; | |
| 1756 FeedbackVectorSlot property_feedback_slot_; | 1809 FeedbackVectorSlot property_feedback_slot_; |
| 1757 Expression* obj_; | 1810 Expression* obj_; |
| 1758 Expression* key_; | 1811 Expression* key_; |
| 1759 SmallMapList receiver_types_; | 1812 SmallMapList receiver_types_; |
| 1760 }; | 1813 }; |
| 1761 | 1814 |
| 1762 | 1815 |
| 1763 class Call final : public Expression { | 1816 class Call final : public Expression { |
| 1764 public: | 1817 public: |
| 1765 Expression* expression() const { return expression_; } | 1818 Expression* expression() const { return expression_; } |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1860 // Used to assert that the FullCodeGenerator records the return site. | 1913 // Used to assert that the FullCodeGenerator records the return site. |
| 1861 bool return_is_recorded_; | 1914 bool return_is_recorded_; |
| 1862 #endif | 1915 #endif |
| 1863 | 1916 |
| 1864 private: | 1917 private: |
| 1865 friend class AstNodeFactory; | 1918 friend class AstNodeFactory; |
| 1866 | 1919 |
| 1867 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos, | 1920 Call(Expression* expression, ZoneList<Expression*>* arguments, int pos, |
| 1868 PossiblyEval possibly_eval) | 1921 PossiblyEval possibly_eval) |
| 1869 : Expression(pos, kCall), | 1922 : Expression(pos, kCall), |
| 1870 bit_field_( | |
| 1871 IsUninitializedField::encode(false) | | |
| 1872 IsPossiblyEvalField::encode(possibly_eval == IS_POSSIBLY_EVAL)), | |
| 1873 expression_(expression), | 1923 expression_(expression), |
| 1874 arguments_(arguments) { | 1924 arguments_(arguments) { |
| 1925 bit_field_ |= | |
| 1926 IsUninitializedField::encode(false) | | |
| 1927 IsPossiblyEvalField::encode(possibly_eval == IS_POSSIBLY_EVAL); | |
| 1928 | |
| 1875 if (expression->IsProperty()) { | 1929 if (expression->IsProperty()) { |
| 1876 expression->AsProperty()->mark_for_call(); | 1930 expression->AsProperty()->mark_for_call(); |
| 1877 } | 1931 } |
| 1878 } | 1932 } |
| 1879 | 1933 |
| 1880 static int parent_num_ids() { return Expression::num_ids(); } | 1934 static int parent_num_ids() { return Expression::num_ids(); } |
| 1881 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 1935 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1882 | 1936 |
| 1883 class IsUninitializedField : public BitField8<bool, 0, 1> {}; | 1937 class IsUninitializedField |
| 1884 class IsTailField : public BitField8<bool, 1, 1> {}; | 1938 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; |
| 1885 class IsPossiblyEvalField : public BitField8<bool, 2, 1> {}; | 1939 class IsTailField : public BitField<bool, IsUninitializedField::kNext, 1> {}; |
| 1940 class IsPossiblyEvalField : public BitField<bool, IsTailField::kNext, 1> {}; | |
| 1886 | 1941 |
| 1887 uint8_t bit_field_; | |
| 1888 FeedbackVectorSlot ic_slot_; | 1942 FeedbackVectorSlot ic_slot_; |
| 1889 FeedbackVectorSlot stub_slot_; | 1943 FeedbackVectorSlot stub_slot_; |
| 1890 Expression* expression_; | 1944 Expression* expression_; |
| 1891 ZoneList<Expression*>* arguments_; | 1945 ZoneList<Expression*>* arguments_; |
| 1892 Handle<JSFunction> target_; | 1946 Handle<JSFunction> target_; |
| 1893 Handle<AllocationSite> allocation_site_; | 1947 Handle<AllocationSite> allocation_site_; |
| 1894 }; | 1948 }; |
| 1895 | 1949 |
| 1896 | 1950 |
| 1897 class CallNew final : public Expression { | 1951 class CallNew final : public Expression { |
| (...skipping 10 matching lines...) Expand all Loading... | |
| 1908 // Construct calls have two slots, one right after the other. | 1962 // Construct calls have two slots, one right after the other. |
| 1909 // The second slot stores the call count for monomorphic calls. | 1963 // The second slot stores the call count for monomorphic calls. |
| 1910 spec->AddGeneralSlot(); | 1964 spec->AddGeneralSlot(); |
| 1911 } | 1965 } |
| 1912 | 1966 |
| 1913 FeedbackVectorSlot CallNewFeedbackSlot() { | 1967 FeedbackVectorSlot CallNewFeedbackSlot() { |
| 1914 DCHECK(!callnew_feedback_slot_.IsInvalid()); | 1968 DCHECK(!callnew_feedback_slot_.IsInvalid()); |
| 1915 return callnew_feedback_slot_; | 1969 return callnew_feedback_slot_; |
| 1916 } | 1970 } |
| 1917 | 1971 |
| 1918 bool IsMonomorphic() const { return is_monomorphic_; } | 1972 bool IsMonomorphic() const { return IsMonomorphicField::decode(bit_field_); } |
| 1919 Handle<JSFunction> target() const { return target_; } | 1973 Handle<JSFunction> target() const { return target_; } |
| 1920 Handle<AllocationSite> allocation_site() const { | 1974 Handle<AllocationSite> allocation_site() const { |
| 1921 return allocation_site_; | 1975 return allocation_site_; |
| 1922 } | 1976 } |
| 1923 | 1977 |
| 1924 static int num_ids() { return parent_num_ids() + 1; } | 1978 static int num_ids() { return parent_num_ids() + 1; } |
| 1925 static int feedback_slots() { return 1; } | 1979 static int feedback_slots() { return 1; } |
| 1926 BailoutId ReturnId() const { return BailoutId(local_id(0)); } | 1980 BailoutId ReturnId() const { return BailoutId(local_id(0)); } |
| 1927 | 1981 |
| 1928 void set_allocation_site(Handle<AllocationSite> site) { | 1982 void set_allocation_site(Handle<AllocationSite> site) { |
| 1929 allocation_site_ = site; | 1983 allocation_site_ = site; |
| 1930 } | 1984 } |
| 1931 void set_is_monomorphic(bool monomorphic) { is_monomorphic_ = monomorphic; } | 1985 void set_is_monomorphic(bool monomorphic) { |
| 1986 bit_field_ = IsMonomorphicField::update(bit_field_, monomorphic); | |
| 1987 } | |
| 1932 void set_target(Handle<JSFunction> target) { target_ = target; } | 1988 void set_target(Handle<JSFunction> target) { target_ = target; } |
| 1933 void SetKnownGlobalTarget(Handle<JSFunction> target) { | 1989 void SetKnownGlobalTarget(Handle<JSFunction> target) { |
| 1934 target_ = target; | 1990 target_ = target; |
| 1935 is_monomorphic_ = true; | 1991 set_is_monomorphic(true); |
| 1936 } | 1992 } |
| 1937 | 1993 |
| 1938 private: | 1994 private: |
| 1939 friend class AstNodeFactory; | 1995 friend class AstNodeFactory; |
| 1940 | 1996 |
| 1941 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) | 1997 CallNew(Expression* expression, ZoneList<Expression*>* arguments, int pos) |
| 1942 : Expression(pos, kCallNew), | 1998 : Expression(pos, kCallNew), |
| 1943 is_monomorphic_(false), | |
| 1944 expression_(expression), | 1999 expression_(expression), |
| 1945 arguments_(arguments) {} | 2000 arguments_(arguments) { |
| 2001 bit_field_ |= IsMonomorphicField::encode(false); | |
| 2002 } | |
| 1946 | 2003 |
| 1947 static int parent_num_ids() { return Expression::num_ids(); } | 2004 static int parent_num_ids() { return Expression::num_ids(); } |
| 1948 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2005 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 1949 | 2006 |
| 1950 bool is_monomorphic_; | |
| 1951 FeedbackVectorSlot callnew_feedback_slot_; | 2007 FeedbackVectorSlot callnew_feedback_slot_; |
| 1952 Expression* expression_; | 2008 Expression* expression_; |
| 1953 ZoneList<Expression*>* arguments_; | 2009 ZoneList<Expression*>* arguments_; |
| 1954 Handle<JSFunction> target_; | 2010 Handle<JSFunction> target_; |
| 1955 Handle<AllocationSite> allocation_site_; | 2011 Handle<AllocationSite> allocation_site_; |
| 2012 | |
| 2013 class IsMonomorphicField | |
| 2014 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; | |
| 1956 }; | 2015 }; |
| 1957 | 2016 |
| 1958 | 2017 |
| 1959 // The CallRuntime class does not represent any official JavaScript | 2018 // The CallRuntime class does not represent any official JavaScript |
| 1960 // language construct. Instead it is used to call a C or JS function | 2019 // language construct. Instead it is used to call a C or JS function |
| 1961 // with a set of arguments. This is used from the builtins that are | 2020 // with a set of arguments. This is used from the builtins that are |
| 1962 // implemented in JavaScript (see "v8natives.js"). | 2021 // implemented in JavaScript (see "v8natives.js"). |
| 1963 class CallRuntime final : public Expression { | 2022 class CallRuntime final : public Expression { |
| 1964 public: | 2023 public: |
| 1965 ZoneList<Expression*>* arguments() const { return arguments_; } | 2024 ZoneList<Expression*>* arguments() const { return arguments_; } |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1999 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2058 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2000 | 2059 |
| 2001 int context_index_; | 2060 int context_index_; |
| 2002 const Runtime::Function* function_; | 2061 const Runtime::Function* function_; |
| 2003 ZoneList<Expression*>* arguments_; | 2062 ZoneList<Expression*>* arguments_; |
| 2004 }; | 2063 }; |
| 2005 | 2064 |
| 2006 | 2065 |
| 2007 class UnaryOperation final : public Expression { | 2066 class UnaryOperation final : public Expression { |
| 2008 public: | 2067 public: |
| 2009 Token::Value op() const { return op_; } | 2068 Token::Value op() const { return OperatorField::decode(bit_field_); } |
| 2010 Expression* expression() const { return expression_; } | 2069 Expression* expression() const { return expression_; } |
| 2011 void set_expression(Expression* e) { expression_ = e; } | 2070 void set_expression(Expression* e) { expression_ = e; } |
| 2012 | 2071 |
| 2013 // For unary not (Token::NOT), the AST ids where true and false will | 2072 // For unary not (Token::NOT), the AST ids where true and false will |
| 2014 // actually be materialized, respectively. | 2073 // actually be materialized, respectively. |
| 2015 static int num_ids() { return parent_num_ids() + 2; } | 2074 static int num_ids() { return parent_num_ids() + 2; } |
| 2016 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); } | 2075 BailoutId MaterializeTrueId() const { return BailoutId(local_id(0)); } |
| 2017 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); } | 2076 BailoutId MaterializeFalseId() const { return BailoutId(local_id(1)); } |
| 2018 | 2077 |
| 2019 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); | 2078 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
| 2020 | 2079 |
| 2021 private: | 2080 private: |
| 2022 friend class AstNodeFactory; | 2081 friend class AstNodeFactory; |
| 2023 | 2082 |
| 2024 UnaryOperation(Token::Value op, Expression* expression, int pos) | 2083 UnaryOperation(Token::Value op, Expression* expression, int pos) |
| 2025 : Expression(pos, kUnaryOperation), op_(op), expression_(expression) { | 2084 : Expression(pos, kUnaryOperation), expression_(expression) { |
| 2085 bit_field_ |= OperatorField::encode(op); | |
| 2026 DCHECK(Token::IsUnaryOp(op)); | 2086 DCHECK(Token::IsUnaryOp(op)); |
| 2027 } | 2087 } |
| 2028 | 2088 |
| 2029 static int parent_num_ids() { return Expression::num_ids(); } | 2089 static int parent_num_ids() { return Expression::num_ids(); } |
| 2030 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2090 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2031 | 2091 |
| 2032 Token::Value op_; | |
| 2033 Expression* expression_; | 2092 Expression* expression_; |
| 2093 | |
| 2094 class OperatorField | |
| 2095 : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {}; | |
| 2034 }; | 2096 }; |
| 2035 | 2097 |
| 2036 | 2098 |
| 2037 class BinaryOperation final : public Expression { | 2099 class BinaryOperation final : public Expression { |
| 2038 public: | 2100 public: |
| 2039 Token::Value op() const { return static_cast<Token::Value>(op_); } | 2101 Token::Value op() const { return OperatorField::decode(bit_field_); } |
| 2040 Expression* left() const { return left_; } | 2102 Expression* left() const { return left_; } |
| 2041 void set_left(Expression* e) { left_ = e; } | 2103 void set_left(Expression* e) { left_ = e; } |
| 2042 Expression* right() const { return right_; } | 2104 Expression* right() const { return right_; } |
| 2043 void set_right(Expression* e) { right_ = e; } | 2105 void set_right(Expression* e) { right_ = e; } |
| 2044 Handle<AllocationSite> allocation_site() const { return allocation_site_; } | 2106 Handle<AllocationSite> allocation_site() const { return allocation_site_; } |
| 2045 void set_allocation_site(Handle<AllocationSite> allocation_site) { | 2107 void set_allocation_site(Handle<AllocationSite> allocation_site) { |
| 2046 allocation_site_ = allocation_site; | 2108 allocation_site_ = allocation_site; |
| 2047 } | 2109 } |
| 2048 | 2110 |
| 2049 void MarkTail() { | 2111 void MarkTail() { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2083 if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust(); | 2145 if (arg.IsJust()) fixed_right_arg_value_ = arg.FromJust(); |
| 2084 } | 2146 } |
| 2085 | 2147 |
| 2086 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); | 2148 void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
| 2087 | 2149 |
| 2088 private: | 2150 private: |
| 2089 friend class AstNodeFactory; | 2151 friend class AstNodeFactory; |
| 2090 | 2152 |
| 2091 BinaryOperation(Token::Value op, Expression* left, Expression* right, int pos) | 2153 BinaryOperation(Token::Value op, Expression* left, Expression* right, int pos) |
| 2092 : Expression(pos, kBinaryOperation), | 2154 : Expression(pos, kBinaryOperation), |
| 2093 op_(static_cast<byte>(op)), | |
| 2094 has_fixed_right_arg_(false), | 2155 has_fixed_right_arg_(false), |
| 2095 fixed_right_arg_value_(0), | 2156 fixed_right_arg_value_(0), |
| 2096 left_(left), | 2157 left_(left), |
| 2097 right_(right) { | 2158 right_(right) { |
| 2159 bit_field_ |= OperatorField::encode(op); | |
| 2098 DCHECK(Token::IsBinaryOp(op)); | 2160 DCHECK(Token::IsBinaryOp(op)); |
| 2099 } | 2161 } |
| 2100 | 2162 |
| 2101 static int parent_num_ids() { return Expression::num_ids(); } | 2163 static int parent_num_ids() { return Expression::num_ids(); } |
| 2102 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2164 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2103 | 2165 |
| 2104 const byte op_; // actually Token::Value | |
| 2105 // TODO(rossberg): the fixed arg should probably be represented as a Constant | 2166 // TODO(rossberg): the fixed arg should probably be represented as a Constant |
| 2106 // type for the RHS. Currenty it's actually a Maybe<int> | 2167 // type for the RHS. Currenty it's actually a Maybe<int> |
| 2107 bool has_fixed_right_arg_; | 2168 bool has_fixed_right_arg_; |
| 2108 int fixed_right_arg_value_; | 2169 int fixed_right_arg_value_; |
| 2109 Expression* left_; | 2170 Expression* left_; |
| 2110 Expression* right_; | 2171 Expression* right_; |
| 2111 Handle<AllocationSite> allocation_site_; | 2172 Handle<AllocationSite> allocation_site_; |
| 2112 FeedbackVectorSlot type_feedback_slot_; | 2173 FeedbackVectorSlot type_feedback_slot_; |
| 2174 | |
| 2175 class OperatorField | |
| 2176 : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {}; | |
| 2113 }; | 2177 }; |
| 2114 | 2178 |
| 2115 | 2179 |
| 2116 class CountOperation final : public Expression { | 2180 class CountOperation final : public Expression { |
| 2117 public: | 2181 public: |
| 2118 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } | 2182 bool is_prefix() const { return IsPrefixField::decode(bit_field_); } |
| 2119 bool is_postfix() const { return !is_prefix(); } | 2183 bool is_postfix() const { return !is_prefix(); } |
| 2120 | 2184 |
| 2121 Token::Value op() const { return TokenField::decode(bit_field_); } | 2185 Token::Value op() const { return TokenField::decode(bit_field_); } |
| 2122 Token::Value binary_op() { | 2186 Token::Value binary_op() { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2157 } | 2221 } |
| 2158 | 2222 |
| 2159 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, | 2223 void AssignFeedbackVectorSlots(Isolate* isolate, FeedbackVectorSpec* spec, |
| 2160 FeedbackVectorSlotCache* cache); | 2224 FeedbackVectorSlotCache* cache); |
| 2161 FeedbackVectorSlot CountSlot() const { return slot_; } | 2225 FeedbackVectorSlot CountSlot() const { return slot_; } |
| 2162 | 2226 |
| 2163 private: | 2227 private: |
| 2164 friend class AstNodeFactory; | 2228 friend class AstNodeFactory; |
| 2165 | 2229 |
| 2166 CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos) | 2230 CountOperation(Token::Value op, bool is_prefix, Expression* expr, int pos) |
| 2167 : Expression(pos, kCountOperation), | 2231 : Expression(pos, kCountOperation), type_(NULL), expression_(expr) { |
| 2168 bit_field_( | 2232 bit_field_ |= |
| 2169 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | | 2233 IsPrefixField::encode(is_prefix) | KeyTypeField::encode(ELEMENT) | |
| 2170 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op)), | 2234 StoreModeField::encode(STANDARD_STORE) | TokenField::encode(op); |
| 2171 type_(NULL), | 2235 } |
| 2172 expression_(expr) {} | |
| 2173 | 2236 |
| 2174 static int parent_num_ids() { return Expression::num_ids(); } | 2237 static int parent_num_ids() { return Expression::num_ids(); } |
| 2175 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2238 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2176 | 2239 |
| 2177 class IsPrefixField : public BitField16<bool, 0, 1> {}; | 2240 class IsPrefixField |
| 2178 class KeyTypeField : public BitField16<IcCheckType, 1, 1> {}; | 2241 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; |
| 2179 class StoreModeField : public BitField16<KeyedAccessStoreMode, 2, 3> {}; | 2242 class KeyTypeField : public BitField<IcCheckType, IsPrefixField::kNext, 1> {}; |
| 2180 class TokenField : public BitField16<Token::Value, 5, 8> {}; | 2243 class StoreModeField |
| 2244 : public BitField<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; | |
| 2245 class TokenField : public BitField<Token::Value, StoreModeField::kNext, 7> {}; | |
| 2181 | 2246 |
| 2182 // Starts with 16-bit field, which should get packed together with | |
| 2183 // Expression's trailing 16-bit field. | |
| 2184 uint16_t bit_field_; | |
| 2185 FeedbackVectorSlot slot_; | 2247 FeedbackVectorSlot slot_; |
| 2186 FeedbackVectorSlot binary_operation_slot_; | 2248 FeedbackVectorSlot binary_operation_slot_; |
| 2187 Type* type_; | 2249 Type* type_; |
| 2188 Expression* expression_; | 2250 Expression* expression_; |
| 2189 SmallMapList receiver_types_; | 2251 SmallMapList receiver_types_; |
| 2190 }; | 2252 }; |
| 2191 | 2253 |
| 2192 | 2254 |
| 2193 class CompareOperation final : public Expression { | 2255 class CompareOperation final : public Expression { |
| 2194 public: | 2256 public: |
| 2195 Token::Value op() const { return op_; } | 2257 Token::Value op() const { return OperatorField::decode(bit_field_); } |
| 2196 Expression* left() const { return left_; } | 2258 Expression* left() const { return left_; } |
| 2197 Expression* right() const { return right_; } | 2259 Expression* right() const { return right_; } |
| 2198 | 2260 |
| 2199 void set_left(Expression* e) { left_ = e; } | 2261 void set_left(Expression* e) { left_ = e; } |
| 2200 void set_right(Expression* e) { right_ = e; } | 2262 void set_right(Expression* e) { right_ = e; } |
| 2201 | 2263 |
| 2202 // Type feedback information. | 2264 // Type feedback information. |
| 2203 static int num_ids() { return parent_num_ids() + 1; } | 2265 static int num_ids() { return parent_num_ids() + 1; } |
| 2204 TypeFeedbackId CompareOperationFeedbackId() const { | 2266 TypeFeedbackId CompareOperationFeedbackId() const { |
| 2205 return TypeFeedbackId(local_id(0)); | 2267 return TypeFeedbackId(local_id(0)); |
| 2206 } | 2268 } |
| 2207 Type* combined_type() const { return combined_type_; } | 2269 Type* combined_type() const { return combined_type_; } |
| 2208 void set_combined_type(Type* type) { combined_type_ = type; } | 2270 void set_combined_type(Type* type) { combined_type_ = type; } |
| 2209 | 2271 |
| 2210 // Match special cases. | 2272 // Match special cases. |
| 2211 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); | 2273 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); |
| 2212 bool IsLiteralCompareUndefined(Expression** expr); | 2274 bool IsLiteralCompareUndefined(Expression** expr); |
| 2213 bool IsLiteralCompareNull(Expression** expr); | 2275 bool IsLiteralCompareNull(Expression** expr); |
| 2214 | 2276 |
| 2215 private: | 2277 private: |
| 2216 friend class AstNodeFactory; | 2278 friend class AstNodeFactory; |
| 2217 | 2279 |
| 2218 CompareOperation(Token::Value op, Expression* left, Expression* right, | 2280 CompareOperation(Token::Value op, Expression* left, Expression* right, |
| 2219 int pos) | 2281 int pos) |
| 2220 : Expression(pos, kCompareOperation), | 2282 : Expression(pos, kCompareOperation), |
| 2221 op_(op), | |
| 2222 left_(left), | 2283 left_(left), |
| 2223 right_(right), | 2284 right_(right), |
| 2224 combined_type_(Type::None()) { | 2285 combined_type_(Type::None()) { |
| 2286 bit_field_ |= OperatorField::encode(op); | |
| 2225 DCHECK(Token::IsCompareOp(op)); | 2287 DCHECK(Token::IsCompareOp(op)); |
| 2226 } | 2288 } |
| 2227 | 2289 |
| 2228 static int parent_num_ids() { return Expression::num_ids(); } | 2290 static int parent_num_ids() { return Expression::num_ids(); } |
| 2229 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2291 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2230 | 2292 |
| 2231 Token::Value op_; | |
| 2232 Expression* left_; | 2293 Expression* left_; |
| 2233 Expression* right_; | 2294 Expression* right_; |
| 2234 | 2295 |
| 2235 Type* combined_type_; | 2296 Type* combined_type_; |
| 2297 | |
| 2298 class OperatorField | |
| 2299 : public BitField<Token::Value, Expression::kNextBitFieldIndex, 7> {}; | |
| 2236 }; | 2300 }; |
| 2237 | 2301 |
| 2238 | 2302 |
| 2239 class Spread final : public Expression { | 2303 class Spread final : public Expression { |
| 2240 public: | 2304 public: |
| 2241 Expression* expression() const { return expression_; } | 2305 Expression* expression() const { return expression_; } |
| 2242 void set_expression(Expression* e) { expression_ = e; } | 2306 void set_expression(Expression* e) { expression_ = e; } |
| 2243 | 2307 |
| 2244 int expression_position() const { return expr_pos_; } | 2308 int expression_position() const { return expr_pos_; } |
| 2245 | 2309 |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2349 FeedbackVectorSlot AssignmentSlot() const { return slot_; } | 2413 FeedbackVectorSlot AssignmentSlot() const { return slot_; } |
| 2350 | 2414 |
| 2351 private: | 2415 private: |
| 2352 friend class AstNodeFactory; | 2416 friend class AstNodeFactory; |
| 2353 | 2417 |
| 2354 Assignment(Token::Value op, Expression* target, Expression* value, int pos); | 2418 Assignment(Token::Value op, Expression* target, Expression* value, int pos); |
| 2355 | 2419 |
| 2356 static int parent_num_ids() { return Expression::num_ids(); } | 2420 static int parent_num_ids() { return Expression::num_ids(); } |
| 2357 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2421 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2358 | 2422 |
| 2359 class IsUninitializedField : public BitField16<bool, 0, 1> {}; | 2423 class IsUninitializedField |
| 2424 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; | |
| 2360 class KeyTypeField | 2425 class KeyTypeField |
| 2361 : public BitField16<IcCheckType, IsUninitializedField::kNext, 1> {}; | 2426 : public BitField<IcCheckType, IsUninitializedField::kNext, 1> {}; |
| 2362 class StoreModeField | 2427 class StoreModeField |
| 2363 : public BitField16<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; | 2428 : public BitField<KeyedAccessStoreMode, KeyTypeField::kNext, 3> {}; |
| 2364 class TokenField : public BitField16<Token::Value, StoreModeField::kNext, 8> { | 2429 class TokenField : public BitField<Token::Value, StoreModeField::kNext, 7> {}; |
| 2365 }; | |
| 2366 | 2430 |
| 2367 // Starts with 16-bit field, which should get packed together with | |
| 2368 // Expression's trailing 16-bit field. | |
| 2369 uint16_t bit_field_; | |
| 2370 FeedbackVectorSlot slot_; | 2431 FeedbackVectorSlot slot_; |
| 2371 Expression* target_; | 2432 Expression* target_; |
| 2372 Expression* value_; | 2433 Expression* value_; |
| 2373 BinaryOperation* binary_operation_; | 2434 BinaryOperation* binary_operation_; |
| 2374 SmallMapList receiver_types_; | 2435 SmallMapList receiver_types_; |
| 2375 }; | 2436 }; |
| 2376 | 2437 |
| 2377 | 2438 |
| 2378 // The RewritableExpression class is a wrapper for AST nodes that wait | 2439 // The RewritableExpression class is a wrapper for AST nodes that wait |
| 2379 // for some potential rewriting. However, even if such nodes are indeed | 2440 // for some potential rewriting. However, even if such nodes are indeed |
| 2380 // rewritten, the RewritableExpression wrapper nodes will survive in the | 2441 // rewritten, the RewritableExpression wrapper nodes will survive in the |
| 2381 // final AST and should be just ignored, i.e., they should be treated as | 2442 // final AST and should be just ignored, i.e., they should be treated as |
| 2382 // equivalent to the wrapped nodes. For this reason and to simplify later | 2443 // equivalent to the wrapped nodes. For this reason and to simplify later |
| 2383 // phases, RewritableExpressions are considered as exceptions of AST nodes | 2444 // phases, RewritableExpressions are considered as exceptions of AST nodes |
| 2384 // in the following sense: | 2445 // in the following sense: |
| 2385 // | 2446 // |
| 2386 // 1. IsRewritableExpression and AsRewritableExpression behave as usual. | 2447 // 1. IsRewritableExpression and AsRewritableExpression behave as usual. |
| 2387 // 2. All other Is* and As* methods are practically delegated to the | 2448 // 2. All other Is* and As* methods are practically delegated to the |
| 2388 // wrapped node, i.e. IsArrayLiteral() will return true iff the | 2449 // wrapped node, i.e. IsArrayLiteral() will return true iff the |
| 2389 // wrapped node is an array literal. | 2450 // wrapped node is an array literal. |
| 2390 // | 2451 // |
| 2391 // Furthermore, an invariant that should be respected is that the wrapped | 2452 // Furthermore, an invariant that should be respected is that the wrapped |
| 2392 // node is not a RewritableExpression. | 2453 // node is not a RewritableExpression. |
| 2393 class RewritableExpression final : public Expression { | 2454 class RewritableExpression final : public Expression { |
| 2394 public: | 2455 public: |
| 2395 Expression* expression() const { return expr_; } | 2456 Expression* expression() const { return expr_; } |
| 2396 bool is_rewritten() const { return is_rewritten_; } | 2457 bool is_rewritten() const { return IsRewrittenField::decode(bit_field_); } |
| 2397 | 2458 |
| 2398 void Rewrite(Expression* new_expression) { | 2459 void Rewrite(Expression* new_expression) { |
| 2399 DCHECK(!is_rewritten()); | 2460 DCHECK(!is_rewritten()); |
| 2400 DCHECK_NOT_NULL(new_expression); | 2461 DCHECK_NOT_NULL(new_expression); |
| 2401 DCHECK(!new_expression->IsRewritableExpression()); | 2462 DCHECK(!new_expression->IsRewritableExpression()); |
| 2402 expr_ = new_expression; | 2463 expr_ = new_expression; |
| 2403 is_rewritten_ = true; | 2464 bit_field_ = IsRewrittenField::update(bit_field_, true); |
| 2404 } | 2465 } |
| 2405 | 2466 |
| 2406 static int num_ids() { return parent_num_ids(); } | 2467 static int num_ids() { return parent_num_ids(); } |
| 2407 | 2468 |
| 2408 private: | 2469 private: |
| 2409 friend class AstNodeFactory; | 2470 friend class AstNodeFactory; |
| 2410 | 2471 |
| 2411 explicit RewritableExpression(Expression* expression) | 2472 explicit RewritableExpression(Expression* expression) |
| 2412 : Expression(expression->position(), kRewritableExpression), | 2473 : Expression(expression->position(), kRewritableExpression), |
| 2413 is_rewritten_(false), | |
| 2414 expr_(expression) { | 2474 expr_(expression) { |
| 2475 bit_field_ |= IsRewrittenField::encode(false); | |
| 2415 DCHECK(!expression->IsRewritableExpression()); | 2476 DCHECK(!expression->IsRewritableExpression()); |
| 2416 } | 2477 } |
| 2417 | 2478 |
| 2418 int local_id(int n) const { return base_id() + parent_num_ids() + n; } | 2479 int local_id(int n) const { return base_id() + parent_num_ids() + n; } |
| 2419 | 2480 |
| 2420 bool is_rewritten_; | |
| 2421 Expression* expr_; | 2481 Expression* expr_; |
| 2482 | |
| 2483 class IsRewrittenField | |
| 2484 : public BitField<bool, Expression::kNextBitFieldIndex, 1> {}; | |
| 2422 }; | 2485 }; |
| 2423 | 2486 |
| 2424 // Our Yield is different from the JS yield in that it "returns" its argument as | 2487 // Our Yield is different from the JS yield in that it "returns" its argument as |
| 2425 // is, without wrapping it in an iterator result object. Such wrapping, if | 2488 // is, without wrapping it in an iterator result object. Such wrapping, if |
| 2426 // desired, must be done beforehand (see the parser). | 2489 // desired, must be done beforehand (see the parser). |
| 2427 class Yield final : public Expression { | 2490 class Yield final : public Expression { |
| 2428 public: | 2491 public: |
| 2429 enum OnException { kOnExceptionThrow, kOnExceptionRethrow }; | 2492 enum OnException { kOnExceptionThrow, kOnExceptionRethrow }; |
| 2430 | 2493 |
| 2431 Expression* generator_object() const { return generator_object_; } | 2494 Expression* generator_object() const { return generator_object_; } |
| 2432 Expression* expression() const { return expression_; } | 2495 Expression* expression() const { return expression_; } |
| 2496 OnException on_exception() const { | |
| 2497 return OnExceptionField::decode(bit_field_); | |
| 2498 } | |
| 2433 bool rethrow_on_exception() const { | 2499 bool rethrow_on_exception() const { |
| 2434 return on_exception_ == kOnExceptionRethrow; | 2500 return on_exception() == kOnExceptionRethrow; |
| 2435 } | 2501 } |
| 2436 int yield_id() const { return yield_id_; } | 2502 int yield_id() const { return yield_id_; } |
| 2437 | 2503 |
| 2438 void set_generator_object(Expression* e) { generator_object_ = e; } | 2504 void set_generator_object(Expression* e) { generator_object_ = e; } |
| 2439 void set_expression(Expression* e) { expression_ = e; } | 2505 void set_expression(Expression* e) { expression_ = e; } |
| 2440 void set_yield_id(int yield_id) { yield_id_ = yield_id; } | 2506 void set_yield_id(int yield_id) { yield_id_ = yield_id; } |
| 2441 | 2507 |
| 2442 private: | 2508 private: |
| 2443 friend class AstNodeFactory; | 2509 friend class AstNodeFactory; |
| 2444 | 2510 |
| 2445 Yield(Expression* generator_object, Expression* expression, int pos, | 2511 Yield(Expression* generator_object, Expression* expression, int pos, |
| 2446 OnException on_exception) | 2512 OnException on_exception) |
| 2447 : Expression(pos, kYield), | 2513 : Expression(pos, kYield), |
| 2448 on_exception_(on_exception), | |
| 2449 yield_id_(-1), | 2514 yield_id_(-1), |
| 2450 generator_object_(generator_object), | 2515 generator_object_(generator_object), |
| 2451 expression_(expression) {} | 2516 expression_(expression) { |
| 2517 bit_field_ |= OnExceptionField::encode(on_exception); | |
| 2518 } | |
| 2452 | 2519 |
| 2453 OnException on_exception_; | |
| 2454 int yield_id_; | 2520 int yield_id_; |
| 2455 Expression* generator_object_; | 2521 Expression* generator_object_; |
| 2456 Expression* expression_; | 2522 Expression* expression_; |
| 2523 | |
| 2524 class OnExceptionField | |
| 2525 : public BitField<OnException, Expression::kNextBitFieldIndex, 1> {}; | |
| 2457 }; | 2526 }; |
| 2458 | 2527 |
| 2459 | 2528 |
| 2460 class Throw final : public Expression { | 2529 class Throw final : public Expression { |
| 2461 public: | 2530 public: |
| 2462 Expression* exception() const { return exception_; } | 2531 Expression* exception() const { return exception_; } |
| 2463 void set_exception(Expression* e) { exception_ = e; } | 2532 void set_exception(Expression* e) { exception_ = e; } |
| 2464 | 2533 |
| 2465 private: | 2534 private: |
| 2466 friend class AstNodeFactory; | 2535 friend class AstNodeFactory; |
| (...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2540 raw_inferred_name_ = NULL; | 2609 raw_inferred_name_ = NULL; |
| 2541 } | 2610 } |
| 2542 | 2611 |
| 2543 void set_raw_inferred_name(const AstString* raw_inferred_name) { | 2612 void set_raw_inferred_name(const AstString* raw_inferred_name) { |
| 2544 DCHECK(raw_inferred_name != NULL); | 2613 DCHECK(raw_inferred_name != NULL); |
| 2545 raw_inferred_name_ = raw_inferred_name; | 2614 raw_inferred_name_ = raw_inferred_name; |
| 2546 DCHECK(inferred_name_.is_null()); | 2615 DCHECK(inferred_name_.is_null()); |
| 2547 inferred_name_ = Handle<String>(); | 2616 inferred_name_ = Handle<String>(); |
| 2548 } | 2617 } |
| 2549 | 2618 |
| 2550 bool pretenure() const { return Pretenure::decode(bitfield_); } | 2619 bool pretenure() const { return Pretenure::decode(bit_field_); } |
| 2551 void set_pretenure() { bitfield_ = Pretenure::update(bitfield_, true); } | 2620 void set_pretenure() { bit_field_ = Pretenure::update(bit_field_, true); } |
| 2552 | 2621 |
| 2553 bool has_duplicate_parameters() const { | 2622 bool has_duplicate_parameters() const { |
| 2554 return HasDuplicateParameters::decode(bitfield_); | 2623 return HasDuplicateParameters::decode(bit_field_); |
| 2555 } | 2624 } |
| 2556 | 2625 |
| 2557 bool is_function() const { return IsFunction::decode(bitfield_); } | 2626 bool is_function() const { return IsFunction::decode(bit_field_); } |
| 2558 | 2627 |
| 2559 // This is used as a heuristic on when to eagerly compile a function | 2628 // This is used as a heuristic on when to eagerly compile a function |
| 2560 // literal. We consider the following constructs as hints that the | 2629 // literal. We consider the following constructs as hints that the |
| 2561 // function will be called immediately: | 2630 // function will be called immediately: |
| 2562 // - (function() { ... })(); | 2631 // - (function() { ... })(); |
| 2563 // - var x = function() { ... }(); | 2632 // - var x = function() { ... }(); |
| 2564 bool should_eager_compile() const { | 2633 bool should_eager_compile() const { |
| 2565 return ShouldEagerCompile::decode(bitfield_); | 2634 return ShouldEagerCompile::decode(bit_field_); |
| 2566 } | 2635 } |
| 2567 void set_should_eager_compile() { | 2636 void set_should_eager_compile() { |
| 2568 bitfield_ = ShouldEagerCompile::update(bitfield_, true); | 2637 bit_field_ = ShouldEagerCompile::update(bit_field_, true); |
| 2569 } | 2638 } |
| 2570 | 2639 |
| 2571 // A hint that we expect this function to be called (exactly) once, | 2640 // A hint that we expect this function to be called (exactly) once, |
| 2572 // i.e. we suspect it's an initialization function. | 2641 // i.e. we suspect it's an initialization function. |
| 2573 bool should_be_used_once_hint() const { | 2642 bool should_be_used_once_hint() const { return should_be_used_once_hint_; } |
| 2574 return ShouldBeUsedOnceHint::decode(bitfield_); | 2643 void set_should_be_used_once_hint() { should_be_used_once_hint_ = true; } |
| 2575 } | |
| 2576 void set_should_be_used_once_hint() { | |
| 2577 bitfield_ = ShouldBeUsedOnceHint::update(bitfield_, true); | |
| 2578 } | |
| 2579 | 2644 |
| 2580 FunctionType function_type() const { | 2645 FunctionType function_type() const { |
| 2581 return FunctionTypeBits::decode(bitfield_); | 2646 return FunctionTypeBits::decode(bit_field_); |
| 2582 } | 2647 } |
| 2583 FunctionKind kind() const { return FunctionKindBits::decode(bitfield_); } | 2648 FunctionKind kind() const { return FunctionKindBits::decode(bit_field_); } |
| 2584 | 2649 |
| 2585 int ast_node_count() { return ast_properties_.node_count(); } | 2650 int ast_node_count() { return ast_properties_.node_count(); } |
| 2586 AstProperties::Flags flags() const { return ast_properties_.flags(); } | 2651 AstProperties::Flags flags() const { return ast_properties_.flags(); } |
| 2587 void set_ast_properties(AstProperties* ast_properties) { | 2652 void set_ast_properties(AstProperties* ast_properties) { |
| 2588 ast_properties_ = *ast_properties; | 2653 ast_properties_ = *ast_properties; |
| 2589 } | 2654 } |
| 2590 const FeedbackVectorSpec* feedback_vector_spec() const { | 2655 const FeedbackVectorSpec* feedback_vector_spec() const { |
| 2591 return ast_properties_.get_spec(); | 2656 return ast_properties_.get_spec(); |
| 2592 } | 2657 } |
| 2593 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } | 2658 bool dont_optimize() { return dont_optimize_reason_ != kNoReason; } |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 2609 FunctionLiteral(Zone* zone, const AstString* name, | 2674 FunctionLiteral(Zone* zone, const AstString* name, |
| 2610 AstValueFactory* ast_value_factory, DeclarationScope* scope, | 2675 AstValueFactory* ast_value_factory, DeclarationScope* scope, |
| 2611 ZoneList<Statement*>* body, int materialized_literal_count, | 2676 ZoneList<Statement*>* body, int materialized_literal_count, |
| 2612 int expected_property_count, int parameter_count, | 2677 int expected_property_count, int parameter_count, |
| 2613 FunctionType function_type, | 2678 FunctionType function_type, |
| 2614 ParameterFlag has_duplicate_parameters, | 2679 ParameterFlag has_duplicate_parameters, |
| 2615 EagerCompileHint eager_compile_hint, FunctionKind kind, | 2680 EagerCompileHint eager_compile_hint, FunctionKind kind, |
| 2616 int position, bool is_function) | 2681 int position, bool is_function) |
| 2617 : Expression(position, kFunctionLiteral), | 2682 : Expression(position, kFunctionLiteral), |
| 2618 dont_optimize_reason_(kNoReason), | 2683 dont_optimize_reason_(kNoReason), |
| 2684 should_be_used_once_hint_(false), | |
| 2619 materialized_literal_count_(materialized_literal_count), | 2685 materialized_literal_count_(materialized_literal_count), |
| 2620 expected_property_count_(expected_property_count), | 2686 expected_property_count_(expected_property_count), |
| 2621 parameter_count_(parameter_count), | 2687 parameter_count_(parameter_count), |
| 2622 function_token_position_(kNoSourcePosition), | 2688 function_token_position_(kNoSourcePosition), |
| 2623 yield_count_(0), | 2689 yield_count_(0), |
| 2624 raw_name_(name), | 2690 raw_name_(name), |
| 2625 scope_(scope), | 2691 scope_(scope), |
| 2626 body_(body), | 2692 body_(body), |
| 2627 raw_inferred_name_(ast_value_factory->empty_string()), | 2693 raw_inferred_name_(ast_value_factory->empty_string()), |
| 2628 ast_properties_(zone) { | 2694 ast_properties_(zone) { |
| 2629 bitfield_ = | 2695 bit_field_ |= |
| 2630 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | | 2696 FunctionTypeBits::encode(function_type) | Pretenure::encode(false) | |
| 2631 HasDuplicateParameters::encode(has_duplicate_parameters == | 2697 HasDuplicateParameters::encode(has_duplicate_parameters == |
| 2632 kHasDuplicateParameters) | | 2698 kHasDuplicateParameters) | |
| 2633 IsFunction::encode(is_function) | | 2699 IsFunction::encode(is_function) | |
| 2634 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | | 2700 ShouldEagerCompile::encode(eager_compile_hint == kShouldEagerCompile) | |
| 2635 FunctionKindBits::encode(kind) | ShouldBeUsedOnceHint::encode(false); | 2701 FunctionKindBits::encode(kind); |
| 2636 DCHECK(IsValidFunctionKind(kind)); | 2702 DCHECK(IsValidFunctionKind(kind)); |
| 2637 } | 2703 } |
| 2638 | 2704 |
| 2639 class FunctionTypeBits : public BitField16<FunctionType, 0, 2> {}; | 2705 class FunctionTypeBits |
| 2640 class Pretenure : public BitField16<bool, 2, 1> {}; | 2706 : public BitField<FunctionType, Expression::kNextBitFieldIndex, 2> {}; |
| 2641 class HasDuplicateParameters : public BitField16<bool, 3, 1> {}; | 2707 class Pretenure : public BitField<bool, FunctionTypeBits::kNext, 1> {}; |
| 2642 class IsFunction : public BitField16<bool, 4, 1> {}; | 2708 class HasDuplicateParameters : public BitField<bool, Pretenure::kNext, 1> {}; |
| 2643 class ShouldEagerCompile : public BitField16<bool, 5, 1> {}; | 2709 class IsFunction : public BitField<bool, HasDuplicateParameters::kNext, 1> {}; |
| 2644 class ShouldBeUsedOnceHint : public BitField16<bool, 6, 1> {}; | 2710 class ShouldEagerCompile : public BitField<bool, IsFunction::kNext, 1> {}; |
| 2645 class FunctionKindBits : public BitField16<FunctionKind, 7, 9> {}; | 2711 class FunctionKindBits |
| 2646 | 2712 : public BitField<FunctionKind, ShouldEagerCompile::kNext, 9> {}; |
| 2647 // Start with 16-bit field, which should get packed together | |
| 2648 // with Expression's trailing 16-bit field. | |
| 2649 uint16_t bitfield_; | |
| 2650 | 2713 |
| 2651 BailoutReason dont_optimize_reason_; | 2714 BailoutReason dont_optimize_reason_; |
|
Toon Verwaest
2016/08/26 14:55:02
We should probably annotate BailoutReason with uin
| |
| 2715 bool should_be_used_once_hint_; | |
|
Toon Verwaest
2016/08/26 14:55:02
bool should_be_used_once_hint_ : 1
| |
| 2652 | 2716 |
| 2653 int materialized_literal_count_; | 2717 int materialized_literal_count_; |
| 2654 int expected_property_count_; | 2718 int expected_property_count_; |
| 2655 int parameter_count_; | 2719 int parameter_count_; |
| 2656 int function_token_position_; | 2720 int function_token_position_; |
| 2657 int yield_count_; | 2721 int yield_count_; |
| 2658 | 2722 |
| 2659 const AstString* raw_name_; | 2723 const AstString* raw_name_; |
| 2660 DeclarationScope* scope_; | 2724 DeclarationScope* scope_; |
| 2661 ZoneList<Statement*>* body_; | 2725 ZoneList<Statement*>* body_; |
| (...skipping 784 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3446 : NULL; \ | 3510 : NULL; \ |
| 3447 } | 3511 } |
| 3448 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) | 3512 AST_NODE_LIST(DECLARE_NODE_FUNCTIONS) |
| 3449 #undef DECLARE_NODE_FUNCTIONS | 3513 #undef DECLARE_NODE_FUNCTIONS |
| 3450 | 3514 |
| 3451 | 3515 |
| 3452 } // namespace internal | 3516 } // namespace internal |
| 3453 } // namespace v8 | 3517 } // namespace v8 |
| 3454 | 3518 |
| 3455 #endif // V8_AST_AST_H_ | 3519 #endif // V8_AST_AST_H_ |
| OLD | NEW |