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_H_ | 5 #ifndef V8_AST_H_ |
6 #define V8_AST_H_ | 6 #define V8_AST_H_ |
7 | 7 |
8 #include "src/v8.h" | 8 #include "src/v8.h" |
9 | 9 |
10 #include "src/assembler.h" | 10 #include "src/assembler.h" |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
378 return STANDARD_STORE; | 378 return STANDARD_STORE; |
379 } | 379 } |
380 | 380 |
381 // TODO(rossberg): this should move to its own AST node eventually. | 381 // TODO(rossberg): this should move to its own AST node eventually. |
382 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); | 382 virtual void RecordToBooleanTypeFeedback(TypeFeedbackOracle* oracle); |
383 byte to_boolean_types() const { return to_boolean_types_; } | 383 byte to_boolean_types() const { return to_boolean_types_; } |
384 | 384 |
385 BailoutId id() const { return BailoutId(base_id() + 0); } | 385 BailoutId id() const { return BailoutId(base_id() + 0); } |
386 TypeFeedbackId test_id() const { return TypeFeedbackId(base_id() + 1); } | 386 TypeFeedbackId test_id() const { return TypeFeedbackId(base_id() + 1); } |
387 | 387 |
388 void AllocateBailoutIdRange(IdGen* id_gen) { | |
389 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
390 } | |
391 | |
388 protected: | 392 protected: |
389 Expression(Zone* zone, int pos, int num_ids_needed_by_subclass, IdGen* id_gen) | 393 Expression(Zone* zone, int pos) |
390 : AstNode(pos), | 394 : AstNode(pos), |
391 is_parenthesized_(false), | 395 is_parenthesized_(false), |
392 is_multi_parenthesized_(false), | 396 is_multi_parenthesized_(false), |
393 bounds_(Bounds::Unbounded(zone)), | 397 bounds_(Bounds::Unbounded(zone)), |
394 base_id_( | 398 base_id_(BailoutId::None().ToInt()) {} |
395 id_gen->ReserveIdRange(num_ids_needed_by_subclass + num_ids())) {} | |
396 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } | 399 void set_to_boolean_types(byte types) { to_boolean_types_ = types; } |
397 | 400 |
398 static int num_ids() { return 2; } | 401 void InitializeBaseBailoutId(int count, IdGen* id_gen) { |
399 int base_id() const { return base_id_; } | 402 DCHECK(BailoutId(base_id_).IsNone()); |
403 base_id_ = id_gen->ReserveIdRange(count); | |
404 } | |
405 | |
406 int base_id() const { | |
407 DCHECK(!BailoutId(base_id_).IsNone()); | |
408 return base_id_; | |
409 } | |
410 | |
411 int leaf_base_id() const { return base_id() + 2; } | |
Sven Panne
2014/10/14 06:56:26
I don't understand what leaf_base_id() should do.
| |
412 | |
413 static const int kBailoutIdCount = 2; | |
400 | 414 |
401 private: | 415 private: |
402 byte to_boolean_types_; | 416 byte to_boolean_types_; |
403 bool is_parenthesized_ : 1; | 417 bool is_parenthesized_ : 1; |
404 bool is_multi_parenthesized_ : 1; | 418 bool is_multi_parenthesized_ : 1; |
405 Bounds bounds_; | 419 Bounds bounds_; |
406 const int base_id_; | 420 int base_id_; |
407 }; | 421 }; |
408 | 422 |
409 | 423 |
410 class BreakableStatement : public Statement { | 424 class BreakableStatement : public Statement { |
411 public: | 425 public: |
412 enum BreakableType { | 426 enum BreakableType { |
413 TARGET_FOR_ANONYMOUS, | 427 TARGET_FOR_ANONYMOUS, |
414 TARGET_FOR_NAMED_ONLY | 428 TARGET_FOR_NAMED_ONLY |
415 }; | 429 }; |
416 | 430 |
(...skipping 10 matching lines...) Expand all Loading... | |
427 Label* break_target() { return &break_target_; } | 441 Label* break_target() { return &break_target_; } |
428 | 442 |
429 // Testers. | 443 // Testers. |
430 bool is_target_for_anonymous() const { | 444 bool is_target_for_anonymous() const { |
431 return breakable_type_ == TARGET_FOR_ANONYMOUS; | 445 return breakable_type_ == TARGET_FOR_ANONYMOUS; |
432 } | 446 } |
433 | 447 |
434 BailoutId EntryId() const { return BailoutId(base_id() + 0); } | 448 BailoutId EntryId() const { return BailoutId(base_id() + 0); } |
435 BailoutId ExitId() const { return BailoutId(base_id() + 1); } | 449 BailoutId ExitId() const { return BailoutId(base_id() + 1); } |
436 | 450 |
451 void AllocateBailoutIdRange(IdGen* id_gen) { | |
452 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
453 } | |
454 | |
437 protected: | 455 protected: |
438 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, | 456 BreakableStatement(Zone* zone, ZoneList<const AstRawString*>* labels, |
439 BreakableType breakable_type, int position, | 457 BreakableType breakable_type, int position) |
440 int num_ids_needed_by_subclass, IdGen* id_gen) | |
441 : Statement(zone, position), | 458 : Statement(zone, position), |
442 labels_(labels), | 459 labels_(labels), |
443 breakable_type_(breakable_type), | 460 breakable_type_(breakable_type), |
444 base_id_( | 461 base_id_(BailoutId::None().ToInt()) { |
445 id_gen->ReserveIdRange(num_ids_needed_by_subclass + num_ids())) { | |
446 DCHECK(labels == NULL || labels->length() > 0); | 462 DCHECK(labels == NULL || labels->length() > 0); |
447 } | 463 } |
448 | 464 |
449 static int num_ids() { return 2; } | 465 void InitializeBaseBailoutId(int count, IdGen* id_gen) { |
450 int base_id() const { return base_id_; } | 466 DCHECK(BailoutId(base_id_).IsNone()); |
467 base_id_ = id_gen->ReserveIdRange(count); | |
468 } | |
469 | |
470 int base_id() const { | |
471 DCHECK(!BailoutId(base_id_).IsNone()); | |
472 return base_id_; | |
473 } | |
474 | |
475 int leaf_base_id() const { return base_id() + 2; } | |
476 | |
477 static const int kBailoutIdCount = 2; | |
451 | 478 |
452 private: | 479 private: |
453 ZoneList<const AstRawString*>* labels_; | 480 ZoneList<const AstRawString*>* labels_; |
454 BreakableType breakable_type_; | 481 BreakableType breakable_type_; |
455 Label break_target_; | 482 Label break_target_; |
456 const int base_id_; | 483 int base_id_; |
457 }; | 484 }; |
458 | 485 |
459 | 486 |
460 class Block FINAL : public BreakableStatement { | 487 class Block FINAL : public BreakableStatement { |
461 public: | 488 public: |
462 DECLARE_NODE_TYPE(Block) | 489 DECLARE_NODE_TYPE(Block) |
463 | 490 |
464 void AddStatement(Statement* statement, Zone* zone) { | 491 void AddStatement(Statement* statement, Zone* zone) { |
465 statements_.Add(statement, zone); | 492 statements_.Add(statement, zone); |
466 } | 493 } |
467 | 494 |
468 ZoneList<Statement*>* statements() { return &statements_; } | 495 ZoneList<Statement*>* statements() { return &statements_; } |
469 bool is_initializer_block() const { return is_initializer_block_; } | 496 bool is_initializer_block() const { return is_initializer_block_; } |
470 | 497 |
471 BailoutId DeclsId() const { return BailoutId(base_id() + 0); } | 498 BailoutId DeclsId() const { return BailoutId(base_id() + 0); } |
472 | 499 |
473 virtual bool IsJump() const OVERRIDE { | 500 virtual bool IsJump() const OVERRIDE { |
474 return !statements_.is_empty() && statements_.last()->IsJump() | 501 return !statements_.is_empty() && statements_.last()->IsJump() |
475 && labels() == NULL; // Good enough as an approximation... | 502 && labels() == NULL; // Good enough as an approximation... |
476 } | 503 } |
477 | 504 |
478 Scope* scope() const { return scope_; } | 505 Scope* scope() const { return scope_; } |
479 void set_scope(Scope* scope) { scope_ = scope; } | 506 void set_scope(Scope* scope) { scope_ = scope; } |
480 | 507 |
508 void AllocateBailoutIdRange(IdGen* id_gen) { | |
509 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
510 } | |
511 | |
481 protected: | 512 protected: |
482 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, | 513 Block(Zone* zone, ZoneList<const AstRawString*>* labels, int capacity, |
483 bool is_initializer_block, int pos, IdGen* id_gen) | 514 bool is_initializer_block, int pos) |
484 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos, num_ids(), | 515 : BreakableStatement(zone, labels, TARGET_FOR_NAMED_ONLY, pos), |
485 id_gen), | |
486 statements_(capacity, zone), | 516 statements_(capacity, zone), |
487 is_initializer_block_(is_initializer_block), | 517 is_initializer_block_(is_initializer_block), |
488 scope_(NULL) {} | 518 scope_(NULL) {} |
489 | 519 |
490 static int num_ids() { return 1; } | 520 int base_id() const { return leaf_base_id(); } |
491 int base_id() const { | 521 static const int kBailoutIdCount = BreakableStatement::kBailoutIdCount + 1; |
492 return BreakableStatement::base_id() + BreakableStatement::num_ids(); | |
493 } | |
494 | 522 |
495 private: | 523 private: |
496 ZoneList<Statement*> statements_; | 524 ZoneList<Statement*> statements_; |
497 bool is_initializer_block_; | 525 bool is_initializer_block_; |
498 Scope* scope_; | 526 Scope* scope_; |
499 }; | 527 }; |
500 | 528 |
501 | 529 |
502 class Declaration : public AstNode { | 530 class Declaration : public AstNode { |
503 public: | 531 public: |
504 VariableProxy* proxy() const { return proxy_; } | 532 VariableProxy* proxy() const { return proxy_; } |
505 VariableMode mode() const { return mode_; } | 533 VariableMode mode() const { return mode_; } |
506 Scope* scope() const { return scope_; } | 534 Scope* scope() const { return scope_; } |
507 virtual InitializationFlag initialization() const = 0; | 535 virtual InitializationFlag initialization() const = 0; |
508 virtual bool IsInlineable() const; | 536 virtual bool IsInlineable() const; |
537 void AllocateBailoutIdRange(IdGen* id_gen) {} | |
509 | 538 |
510 protected: | 539 protected: |
511 Declaration(Zone* zone, | 540 Declaration(Zone* zone, |
512 VariableProxy* proxy, | 541 VariableProxy* proxy, |
513 VariableMode mode, | 542 VariableMode mode, |
514 Scope* scope, | 543 Scope* scope, |
515 int pos) | 544 int pos) |
516 : AstNode(pos), | 545 : AstNode(pos), |
517 proxy_(proxy), | 546 proxy_(proxy), |
518 mode_(mode), | 547 mode_(mode), |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
637 ExportDeclaration(Zone* zone, VariableProxy* proxy, Scope* scope, int pos) | 666 ExportDeclaration(Zone* zone, VariableProxy* proxy, Scope* scope, int pos) |
638 : Declaration(zone, proxy, LET, scope, pos) {} | 667 : Declaration(zone, proxy, LET, scope, pos) {} |
639 }; | 668 }; |
640 | 669 |
641 | 670 |
642 class Module : public AstNode { | 671 class Module : public AstNode { |
643 public: | 672 public: |
644 Interface* interface() const { return interface_; } | 673 Interface* interface() const { return interface_; } |
645 Block* body() const { return body_; } | 674 Block* body() const { return body_; } |
646 | 675 |
676 void AllocateBailoutIdRange(IdGen* id_gen) {} | |
677 | |
647 protected: | 678 protected: |
648 Module(Zone* zone, int pos) | 679 Module(Zone* zone, int pos) |
649 : AstNode(pos), | 680 : AstNode(pos), |
650 interface_(Interface::NewModule(zone)), | 681 interface_(Interface::NewModule(zone)), |
651 body_(NULL) {} | 682 body_(NULL) {} |
652 Module(Zone* zone, Interface* interface, int pos, Block* body = NULL) | 683 Module(Zone* zone, Interface* interface, int pos, Block* body = NULL) |
653 : AstNode(pos), | 684 : AstNode(pos), |
654 interface_(interface), | 685 interface_(interface), |
655 body_(body) {} | 686 body_(body) {} |
656 | 687 |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
717 }; | 748 }; |
718 | 749 |
719 | 750 |
720 class ModuleStatement FINAL : public Statement { | 751 class ModuleStatement FINAL : public Statement { |
721 public: | 752 public: |
722 DECLARE_NODE_TYPE(ModuleStatement) | 753 DECLARE_NODE_TYPE(ModuleStatement) |
723 | 754 |
724 VariableProxy* proxy() const { return proxy_; } | 755 VariableProxy* proxy() const { return proxy_; } |
725 Block* body() const { return body_; } | 756 Block* body() const { return body_; } |
726 | 757 |
758 void AllocateBailoutIdRange(IdGen* id_gen) {} | |
759 | |
727 protected: | 760 protected: |
728 ModuleStatement(Zone* zone, VariableProxy* proxy, Block* body, int pos) | 761 ModuleStatement(Zone* zone, VariableProxy* proxy, Block* body, int pos) |
729 : Statement(zone, pos), | 762 : Statement(zone, pos), |
730 proxy_(proxy), | 763 proxy_(proxy), |
731 body_(body) { | 764 body_(body) { |
732 } | 765 } |
733 | 766 |
734 private: | 767 private: |
735 VariableProxy* proxy_; | 768 VariableProxy* proxy_; |
736 Block* body_; | 769 Block* body_; |
737 }; | 770 }; |
738 | 771 |
739 | 772 |
740 class IterationStatement : public BreakableStatement { | 773 class IterationStatement : public BreakableStatement { |
741 public: | 774 public: |
742 // Type testing & conversion. | 775 // Type testing & conversion. |
743 virtual IterationStatement* AsIterationStatement() FINAL OVERRIDE { | 776 virtual IterationStatement* AsIterationStatement() FINAL OVERRIDE { |
744 return this; | 777 return this; |
745 } | 778 } |
746 | 779 |
747 Statement* body() const { return body_; } | 780 Statement* body() const { return body_; } |
748 | 781 |
749 BailoutId OsrEntryId() const { return BailoutId(base_id() + 0); } | 782 BailoutId OsrEntryId() const { return BailoutId(base_id() + 0); } |
750 virtual BailoutId ContinueId() const = 0; | 783 virtual BailoutId ContinueId() const = 0; |
751 virtual BailoutId StackCheckId() const = 0; | 784 virtual BailoutId StackCheckId() const = 0; |
752 | 785 |
753 // Code generation | 786 // Code generation |
754 Label* continue_target() { return &continue_target_; } | 787 Label* continue_target() { return &continue_target_; } |
755 | 788 |
789 void AllocateBailoutIdRange(IdGen* id_gen) { | |
790 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
791 } | |
792 | |
756 protected: | 793 protected: |
757 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 794 IterationStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
758 int num_ids_needed_by_subclass, IdGen* id_gen) | 795 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
759 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, | |
760 num_ids_needed_by_subclass + num_ids(), id_gen), | |
761 body_(NULL) {} | 796 body_(NULL) {} |
762 | 797 |
763 void Initialize(Statement* body) { | 798 void Initialize(Statement* body) { |
764 body_ = body; | 799 body_ = body; |
765 } | 800 } |
766 | 801 |
767 static int num_ids() { return 1; } | 802 int base_id() const { return BreakableStatement::leaf_base_id(); } |
768 int base_id() const { | 803 int leaf_base_id() const { return base_id() + 1; } |
769 return BreakableStatement::base_id() + BreakableStatement::num_ids(); | 804 static const int kBailoutIdCount = BreakableStatement::kBailoutIdCount + 1; |
770 } | |
771 | 805 |
772 private: | 806 private: |
773 Statement* body_; | 807 Statement* body_; |
774 Label continue_target_; | 808 Label continue_target_; |
775 }; | 809 }; |
776 | 810 |
777 | 811 |
778 class DoWhileStatement FINAL : public IterationStatement { | 812 class DoWhileStatement FINAL : public IterationStatement { |
779 public: | 813 public: |
780 DECLARE_NODE_TYPE(DoWhileStatement) | 814 DECLARE_NODE_TYPE(DoWhileStatement) |
781 | 815 |
782 void Initialize(Expression* cond, Statement* body) { | 816 void Initialize(Expression* cond, Statement* body) { |
783 IterationStatement::Initialize(body); | 817 IterationStatement::Initialize(body); |
784 cond_ = cond; | 818 cond_ = cond; |
785 } | 819 } |
786 | 820 |
787 Expression* cond() const { return cond_; } | 821 Expression* cond() const { return cond_; } |
788 | 822 |
789 virtual BailoutId ContinueId() const OVERRIDE { | 823 virtual BailoutId ContinueId() const OVERRIDE { |
790 return BailoutId(base_id() + 0); | 824 return BailoutId(base_id() + 0); |
791 } | 825 } |
792 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } | 826 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } |
793 BailoutId BackEdgeId() const { return BailoutId(base_id() + 1); } | 827 BailoutId BackEdgeId() const { return BailoutId(base_id() + 1); } |
794 | 828 |
829 void AllocateBailoutIdRange(IdGen* id_gen) { | |
830 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
831 } | |
832 | |
795 protected: | 833 protected: |
796 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 834 DoWhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
797 IdGen* id_gen) | 835 : IterationStatement(zone, labels, pos), cond_(NULL) {} |
798 : IterationStatement(zone, labels, pos, num_ids(), id_gen), cond_(NULL) {} | |
799 | 836 |
800 static int num_ids() { return 2; } | 837 int base_id() const { return leaf_base_id(); } |
801 int base_id() const { | 838 static const int kBailoutIdCount = IterationStatement::kBailoutIdCount + 2; |
802 return IterationStatement::base_id() + IterationStatement::num_ids(); | |
803 } | |
804 | 839 |
805 private: | 840 private: |
806 Expression* cond_; | 841 Expression* cond_; |
807 }; | 842 }; |
808 | 843 |
809 | 844 |
810 class WhileStatement FINAL : public IterationStatement { | 845 class WhileStatement FINAL : public IterationStatement { |
811 public: | 846 public: |
812 DECLARE_NODE_TYPE(WhileStatement) | 847 DECLARE_NODE_TYPE(WhileStatement) |
813 | 848 |
814 void Initialize(Expression* cond, Statement* body) { | 849 void Initialize(Expression* cond, Statement* body) { |
815 IterationStatement::Initialize(body); | 850 IterationStatement::Initialize(body); |
816 cond_ = cond; | 851 cond_ = cond; |
817 } | 852 } |
818 | 853 |
819 Expression* cond() const { return cond_; } | 854 Expression* cond() const { return cond_; } |
820 bool may_have_function_literal() const { | 855 bool may_have_function_literal() const { |
821 return may_have_function_literal_; | 856 return may_have_function_literal_; |
822 } | 857 } |
823 void set_may_have_function_literal(bool value) { | 858 void set_may_have_function_literal(bool value) { |
824 may_have_function_literal_ = value; | 859 may_have_function_literal_ = value; |
825 } | 860 } |
826 | 861 |
827 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } | 862 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } |
828 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } | 863 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } |
829 BailoutId BodyId() const { return BailoutId(base_id() + 0); } | 864 BailoutId BodyId() const { return BailoutId(base_id() + 0); } |
830 | 865 |
866 void AllocateBailoutIdRange(IdGen* id_gen) { | |
867 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
868 } | |
869 | |
831 protected: | 870 protected: |
832 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 871 WhileStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
833 IdGen* id_gen) | 872 : IterationStatement(zone, labels, pos), |
834 : IterationStatement(zone, labels, pos, num_ids(), id_gen), | |
835 cond_(NULL), | 873 cond_(NULL), |
836 may_have_function_literal_(true) {} | 874 may_have_function_literal_(true) {} |
837 | 875 |
838 static int num_ids() { return 1; } | 876 int base_id() const { return leaf_base_id(); } |
839 int base_id() const { | 877 static const int kBailoutIdCount = IterationStatement::kBailoutIdCount + 1; |
840 return IterationStatement::base_id() + IterationStatement::num_ids(); | |
841 } | |
842 | 878 |
843 private: | 879 private: |
844 Expression* cond_; | 880 Expression* cond_; |
845 | 881 |
846 // True if there is a function literal subexpression in the condition. | 882 // True if there is a function literal subexpression in the condition. |
847 bool may_have_function_literal_; | 883 bool may_have_function_literal_; |
848 }; | 884 }; |
849 | 885 |
850 | 886 |
851 class ForStatement FINAL : public IterationStatement { | 887 class ForStatement FINAL : public IterationStatement { |
(...skipping 20 matching lines...) Expand all Loading... | |
872 void set_may_have_function_literal(bool value) { | 908 void set_may_have_function_literal(bool value) { |
873 may_have_function_literal_ = value; | 909 may_have_function_literal_ = value; |
874 } | 910 } |
875 | 911 |
876 virtual BailoutId ContinueId() const OVERRIDE { | 912 virtual BailoutId ContinueId() const OVERRIDE { |
877 return BailoutId(base_id() + 0); | 913 return BailoutId(base_id() + 0); |
878 } | 914 } |
879 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } | 915 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } |
880 BailoutId BodyId() const { return BailoutId(base_id() + 1); } | 916 BailoutId BodyId() const { return BailoutId(base_id() + 1); } |
881 | 917 |
918 void AllocateBailoutIdRange(IdGen* id_gen) { | |
919 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
920 } | |
921 | |
882 bool is_fast_smi_loop() { return loop_variable_ != NULL; } | 922 bool is_fast_smi_loop() { return loop_variable_ != NULL; } |
883 Variable* loop_variable() { return loop_variable_; } | 923 Variable* loop_variable() { return loop_variable_; } |
884 void set_loop_variable(Variable* var) { loop_variable_ = var; } | 924 void set_loop_variable(Variable* var) { loop_variable_ = var; } |
885 | 925 |
886 protected: | 926 protected: |
887 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 927 ForStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
888 IdGen* id_gen) | 928 : IterationStatement(zone, labels, pos), |
889 : IterationStatement(zone, labels, pos, num_ids(), id_gen), | |
890 init_(NULL), | 929 init_(NULL), |
891 cond_(NULL), | 930 cond_(NULL), |
892 next_(NULL), | 931 next_(NULL), |
893 may_have_function_literal_(true), | 932 may_have_function_literal_(true), |
894 loop_variable_(NULL) {} | 933 loop_variable_(NULL) {} |
895 | 934 |
896 static int num_ids() { return 2; } | 935 int base_id() const { return leaf_base_id(); } |
897 int base_id() const { | 936 static const int kBailoutIdCount = IterationStatement::kBailoutIdCount + 2; |
898 return IterationStatement::base_id() + IterationStatement::num_ids(); | |
899 } | |
900 | 937 |
901 private: | 938 private: |
902 Statement* init_; | 939 Statement* init_; |
903 Expression* cond_; | 940 Expression* cond_; |
904 Statement* next_; | 941 Statement* next_; |
905 | 942 |
906 // True if there is a function literal subexpression in the condition. | 943 // True if there is a function literal subexpression in the condition. |
907 bool may_have_function_literal_; | 944 bool may_have_function_literal_; |
908 Variable* loop_variable_; | 945 Variable* loop_variable_; |
909 }; | 946 }; |
910 | 947 |
911 | 948 |
912 class ForEachStatement : public IterationStatement { | 949 class ForEachStatement : public IterationStatement { |
913 public: | 950 public: |
914 enum VisitMode { | 951 enum VisitMode { |
915 ENUMERATE, // for (each in subject) body; | 952 ENUMERATE, // for (each in subject) body; |
916 ITERATE // for (each of subject) body; | 953 ITERATE // for (each of subject) body; |
917 }; | 954 }; |
918 | 955 |
919 void Initialize(Expression* each, Expression* subject, Statement* body) { | 956 void Initialize(Expression* each, Expression* subject, Statement* body) { |
920 IterationStatement::Initialize(body); | 957 IterationStatement::Initialize(body); |
921 each_ = each; | 958 each_ = each; |
922 subject_ = subject; | 959 subject_ = subject; |
923 } | 960 } |
924 | 961 |
925 Expression* each() const { return each_; } | 962 Expression* each() const { return each_; } |
926 Expression* subject() const { return subject_; } | 963 Expression* subject() const { return subject_; } |
927 | 964 |
928 protected: | 965 protected: |
929 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 966 ForEachStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
930 int num_ids_needed_by_subclass, IdGen* id_gen) | 967 : IterationStatement(zone, labels, pos), each_(NULL), subject_(NULL) {} |
931 : IterationStatement(zone, labels, pos, num_ids_needed_by_subclass, | |
932 id_gen), | |
933 each_(NULL), | |
934 subject_(NULL) {} | |
935 | 968 |
936 private: | 969 private: |
937 Expression* each_; | 970 Expression* each_; |
938 Expression* subject_; | 971 Expression* subject_; |
939 }; | 972 }; |
940 | 973 |
941 | 974 |
942 class ForInStatement FINAL : public ForEachStatement { | 975 class ForInStatement FINAL : public ForEachStatement { |
943 public: | 976 public: |
944 DECLARE_NODE_TYPE(ForInStatement) | 977 DECLARE_NODE_TYPE(ForInStatement) |
(...skipping 13 matching lines...) Expand all Loading... | |
958 | 991 |
959 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; | 992 enum ForInType { FAST_FOR_IN, SLOW_FOR_IN }; |
960 ForInType for_in_type() const { return for_in_type_; } | 993 ForInType for_in_type() const { return for_in_type_; } |
961 void set_for_in_type(ForInType type) { for_in_type_ = type; } | 994 void set_for_in_type(ForInType type) { for_in_type_ = type; } |
962 | 995 |
963 BailoutId BodyId() const { return BailoutId(base_id() + 0); } | 996 BailoutId BodyId() const { return BailoutId(base_id() + 0); } |
964 BailoutId PrepareId() const { return BailoutId(base_id() + 1); } | 997 BailoutId PrepareId() const { return BailoutId(base_id() + 1); } |
965 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } | 998 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } |
966 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } | 999 virtual BailoutId StackCheckId() const OVERRIDE { return BodyId(); } |
967 | 1000 |
1001 void AllocateBailoutIdRange(IdGen* id_gen) { | |
1002 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
1003 } | |
1004 | |
968 protected: | 1005 protected: |
969 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 1006 ForInStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
970 IdGen* id_gen) | 1007 : ForEachStatement(zone, labels, pos), |
971 : ForEachStatement(zone, labels, pos, num_ids(), id_gen), | |
972 for_in_type_(SLOW_FOR_IN), | 1008 for_in_type_(SLOW_FOR_IN), |
973 for_in_feedback_slot_(kInvalidFeedbackSlot) {} | 1009 for_in_feedback_slot_(kInvalidFeedbackSlot) {} |
974 | 1010 |
975 static int num_ids() { return 2; } | 1011 int base_id() const { return leaf_base_id(); } |
976 int base_id() const { | 1012 static const int kBailoutIdCount = ForEachStatement::kBailoutIdCount + 2; |
977 return ForEachStatement::base_id() + ForEachStatement::num_ids(); | |
978 } | |
979 | 1013 |
980 private: | 1014 private: |
981 ForInType for_in_type_; | 1015 ForInType for_in_type_; |
982 int for_in_feedback_slot_; | 1016 int for_in_feedback_slot_; |
983 }; | 1017 }; |
984 | 1018 |
985 | 1019 |
986 class ForOfStatement FINAL : public ForEachStatement { | 1020 class ForOfStatement FINAL : public ForEachStatement { |
987 public: | 1021 public: |
988 DECLARE_NODE_TYPE(ForOfStatement) | 1022 DECLARE_NODE_TYPE(ForOfStatement) |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1023 // each = result.value | 1057 // each = result.value |
1024 Expression* assign_each() const { | 1058 Expression* assign_each() const { |
1025 return assign_each_; | 1059 return assign_each_; |
1026 } | 1060 } |
1027 | 1061 |
1028 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } | 1062 virtual BailoutId ContinueId() const OVERRIDE { return EntryId(); } |
1029 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } | 1063 virtual BailoutId StackCheckId() const OVERRIDE { return BackEdgeId(); } |
1030 | 1064 |
1031 BailoutId BackEdgeId() const { return BailoutId(base_id() + 0); } | 1065 BailoutId BackEdgeId() const { return BailoutId(base_id() + 0); } |
1032 | 1066 |
1067 void AllocateBailoutIdRange(IdGen* id_gen) { | |
1068 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
1069 } | |
1070 | |
1033 protected: | 1071 protected: |
1034 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 1072 ForOfStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
1035 IdGen* id_gen) | 1073 : ForEachStatement(zone, labels, pos), |
1036 : ForEachStatement(zone, labels, pos, num_ids(), id_gen), | |
1037 assign_iterator_(NULL), | 1074 assign_iterator_(NULL), |
1038 next_result_(NULL), | 1075 next_result_(NULL), |
1039 result_done_(NULL), | 1076 result_done_(NULL), |
1040 assign_each_(NULL) {} | 1077 assign_each_(NULL) {} |
1041 | 1078 |
1042 static int num_ids() { return 1; } | 1079 int base_id() const { return leaf_base_id(); } |
1043 int base_id() const { | 1080 static const int kBailoutIdCount = ForEachStatement::kBailoutIdCount + 1; |
1044 return ForEachStatement::base_id() + ForEachStatement::num_ids(); | |
1045 } | |
1046 | 1081 |
1047 private: | 1082 private: |
1048 Expression* assign_iterator_; | 1083 Expression* assign_iterator_; |
1049 Expression* next_result_; | 1084 Expression* next_result_; |
1050 Expression* result_done_; | 1085 Expression* result_done_; |
1051 Expression* assign_each_; | 1086 Expression* assign_each_; |
1052 }; | 1087 }; |
1053 | 1088 |
1054 | 1089 |
1055 class ExpressionStatement FINAL : public Statement { | 1090 class ExpressionStatement FINAL : public Statement { |
1056 public: | 1091 public: |
1057 DECLARE_NODE_TYPE(ExpressionStatement) | 1092 DECLARE_NODE_TYPE(ExpressionStatement) |
1058 | 1093 |
1059 void set_expression(Expression* e) { expression_ = e; } | 1094 void set_expression(Expression* e) { expression_ = e; } |
1060 Expression* expression() const { return expression_; } | 1095 Expression* expression() const { return expression_; } |
1061 virtual bool IsJump() const OVERRIDE { return expression_->IsThrow(); } | 1096 virtual bool IsJump() const OVERRIDE { return expression_->IsThrow(); } |
1062 | 1097 |
1098 void AllocateBailoutIdRange(IdGen* id_gen) {} | |
1099 | |
1063 protected: | 1100 protected: |
1064 ExpressionStatement(Zone* zone, Expression* expression, int pos) | 1101 ExpressionStatement(Zone* zone, Expression* expression, int pos) |
1065 : Statement(zone, pos), expression_(expression) { } | 1102 : Statement(zone, pos), expression_(expression) { } |
1066 | 1103 |
1067 private: | 1104 private: |
1068 Expression* expression_; | 1105 Expression* expression_; |
1069 }; | 1106 }; |
1070 | 1107 |
1071 | 1108 |
1072 class JumpStatement : public Statement { | 1109 class JumpStatement : public Statement { |
1073 public: | 1110 public: |
1074 virtual bool IsJump() const FINAL OVERRIDE { return true; } | 1111 virtual bool IsJump() const FINAL OVERRIDE { return true; } |
1075 | 1112 |
1113 void AllocateBailoutIdRange(IdGen* id_gen) {} | |
1114 | |
1076 protected: | 1115 protected: |
1077 explicit JumpStatement(Zone* zone, int pos) : Statement(zone, pos) {} | 1116 explicit JumpStatement(Zone* zone, int pos) : Statement(zone, pos) {} |
1078 }; | 1117 }; |
1079 | 1118 |
1080 | 1119 |
1081 class ContinueStatement FINAL : public JumpStatement { | 1120 class ContinueStatement FINAL : public JumpStatement { |
1082 public: | 1121 public: |
1083 DECLARE_NODE_TYPE(ContinueStatement) | 1122 DECLARE_NODE_TYPE(ContinueStatement) |
1084 | 1123 |
1085 IterationStatement* target() const { return target_; } | 1124 IterationStatement* target() const { return target_; } |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1124 | 1163 |
1125 | 1164 |
1126 class WithStatement FINAL : public Statement { | 1165 class WithStatement FINAL : public Statement { |
1127 public: | 1166 public: |
1128 DECLARE_NODE_TYPE(WithStatement) | 1167 DECLARE_NODE_TYPE(WithStatement) |
1129 | 1168 |
1130 Scope* scope() { return scope_; } | 1169 Scope* scope() { return scope_; } |
1131 Expression* expression() const { return expression_; } | 1170 Expression* expression() const { return expression_; } |
1132 Statement* statement() const { return statement_; } | 1171 Statement* statement() const { return statement_; } |
1133 | 1172 |
1173 void AllocateBailoutIdRange(IdGen* id_gen) {} | |
1174 | |
1134 protected: | 1175 protected: |
1135 WithStatement( | 1176 WithStatement( |
1136 Zone* zone, Scope* scope, | 1177 Zone* zone, Scope* scope, |
1137 Expression* expression, Statement* statement, int pos) | 1178 Expression* expression, Statement* statement, int pos) |
1138 : Statement(zone, pos), | 1179 : Statement(zone, pos), |
1139 scope_(scope), | 1180 scope_(scope), |
1140 expression_(expression), | 1181 expression_(expression), |
1141 statement_(statement) { } | 1182 statement_(statement) { } |
1142 | 1183 |
1143 private: | 1184 private: |
(...skipping 11 matching lines...) Expand all Loading... | |
1155 Expression* label() const { | 1196 Expression* label() const { |
1156 CHECK(!is_default()); | 1197 CHECK(!is_default()); |
1157 return label_; | 1198 return label_; |
1158 } | 1199 } |
1159 Label* body_target() { return &body_target_; } | 1200 Label* body_target() { return &body_target_; } |
1160 ZoneList<Statement*>* statements() const { return statements_; } | 1201 ZoneList<Statement*>* statements() const { return statements_; } |
1161 | 1202 |
1162 BailoutId EntryId() const { return BailoutId(base_id() + 0); } | 1203 BailoutId EntryId() const { return BailoutId(base_id() + 0); } |
1163 TypeFeedbackId CompareId() { return TypeFeedbackId(base_id() + 1); } | 1204 TypeFeedbackId CompareId() { return TypeFeedbackId(base_id() + 1); } |
1164 | 1205 |
1206 void AllocateBailoutIdRange(IdGen* id_gen) { | |
1207 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
1208 } | |
1209 | |
1165 Type* compare_type() { return compare_type_; } | 1210 Type* compare_type() { return compare_type_; } |
1166 void set_compare_type(Type* type) { compare_type_ = type; } | 1211 void set_compare_type(Type* type) { compare_type_ = type; } |
1167 | 1212 |
1168 private: | 1213 private: |
1169 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, | 1214 CaseClause(Zone* zone, Expression* label, ZoneList<Statement*>* statements, |
1170 int pos, IdGen* id_gen); | 1215 int pos); |
1171 | 1216 |
1172 static int num_ids() { return 2; } | 1217 int base_id() const { return leaf_base_id(); } |
1173 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 1218 static const int kBailoutIdCount = Expression::kBailoutIdCount + 2; |
1174 | 1219 |
1175 Expression* label_; | 1220 Expression* label_; |
1176 Label body_target_; | 1221 Label body_target_; |
1177 ZoneList<Statement*>* statements_; | 1222 ZoneList<Statement*>* statements_; |
1178 Type* compare_type_; | 1223 Type* compare_type_; |
1179 }; | 1224 }; |
1180 | 1225 |
1181 | 1226 |
1182 class SwitchStatement FINAL : public BreakableStatement { | 1227 class SwitchStatement FINAL : public BreakableStatement { |
1183 public: | 1228 public: |
1184 DECLARE_NODE_TYPE(SwitchStatement) | 1229 DECLARE_NODE_TYPE(SwitchStatement) |
1185 | 1230 |
1186 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { | 1231 void Initialize(Expression* tag, ZoneList<CaseClause*>* cases) { |
1187 tag_ = tag; | 1232 tag_ = tag; |
1188 cases_ = cases; | 1233 cases_ = cases; |
1189 } | 1234 } |
1190 | 1235 |
1191 Expression* tag() const { return tag_; } | 1236 Expression* tag() const { return tag_; } |
1192 ZoneList<CaseClause*>* cases() const { return cases_; } | 1237 ZoneList<CaseClause*>* cases() const { return cases_; } |
1193 | 1238 |
1194 protected: | 1239 protected: |
1195 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos, | 1240 SwitchStatement(Zone* zone, ZoneList<const AstRawString*>* labels, int pos) |
1196 IdGen* id_gen) | 1241 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos), |
1197 : BreakableStatement(zone, labels, TARGET_FOR_ANONYMOUS, pos, 0, id_gen), | |
1198 tag_(NULL), | 1242 tag_(NULL), |
1199 cases_(NULL) {} | 1243 cases_(NULL) {} |
1200 | 1244 |
1201 private: | 1245 private: |
1202 Expression* tag_; | 1246 Expression* tag_; |
1203 ZoneList<CaseClause*>* cases_; | 1247 ZoneList<CaseClause*>* cases_; |
1204 }; | 1248 }; |
1205 | 1249 |
1206 | 1250 |
1207 // If-statements always have non-null references to their then- and | 1251 // If-statements always have non-null references to their then- and |
(...skipping 14 matching lines...) Expand all Loading... | |
1222 | 1266 |
1223 virtual bool IsJump() const OVERRIDE { | 1267 virtual bool IsJump() const OVERRIDE { |
1224 return HasThenStatement() && then_statement()->IsJump() | 1268 return HasThenStatement() && then_statement()->IsJump() |
1225 && HasElseStatement() && else_statement()->IsJump(); | 1269 && HasElseStatement() && else_statement()->IsJump(); |
1226 } | 1270 } |
1227 | 1271 |
1228 BailoutId IfId() const { return BailoutId(base_id() + 0); } | 1272 BailoutId IfId() const { return BailoutId(base_id() + 0); } |
1229 BailoutId ThenId() const { return BailoutId(base_id() + 1); } | 1273 BailoutId ThenId() const { return BailoutId(base_id() + 1); } |
1230 BailoutId ElseId() const { return BailoutId(base_id() + 2); } | 1274 BailoutId ElseId() const { return BailoutId(base_id() + 2); } |
1231 | 1275 |
1276 void AllocateBailoutIdRange(IdGen* id_gen) { | |
1277 DCHECK(BailoutId(base_id_).IsNone()); | |
1278 base_id_ = id_gen->ReserveIdRange(kBailoutIdCount); | |
1279 } | |
1280 | |
1232 protected: | 1281 protected: |
1233 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, | 1282 IfStatement(Zone* zone, Expression* condition, Statement* then_statement, |
1234 Statement* else_statement, int pos, IdGen* id_gen) | 1283 Statement* else_statement, int pos) |
1235 : Statement(zone, pos), | 1284 : Statement(zone, pos), |
1236 condition_(condition), | 1285 condition_(condition), |
1237 then_statement_(then_statement), | 1286 then_statement_(then_statement), |
1238 else_statement_(else_statement), | 1287 else_statement_(else_statement), |
1239 base_id_(id_gen->ReserveIdRange(num_ids())) {} | 1288 base_id_(BailoutId::None().ToInt()) {} |
1240 | 1289 |
1241 static int num_ids() { return 3; } | 1290 int base_id() const { |
1242 int base_id() const { return base_id_; } | 1291 DCHECK(!BailoutId(base_id_).IsNone()); |
1292 return base_id_; | |
1293 } | |
1294 | |
1295 static const int kBailoutIdCount = 3; | |
1243 | 1296 |
1244 private: | 1297 private: |
1245 Expression* condition_; | 1298 Expression* condition_; |
1246 Statement* then_statement_; | 1299 Statement* then_statement_; |
1247 Statement* else_statement_; | 1300 Statement* else_statement_; |
1248 const int base_id_; | 1301 int base_id_; |
1249 }; | 1302 }; |
1250 | 1303 |
1251 | 1304 |
1252 // NOTE: TargetCollectors are represented as nodes to fit in the target | 1305 // NOTE: TargetCollectors are represented as nodes to fit in the target |
1253 // stack in the compiler; this should probably be reworked. | 1306 // stack in the compiler; this should probably be reworked. |
1254 class TargetCollector FINAL : public AstNode { | 1307 class TargetCollector FINAL : public AstNode { |
1255 public: | 1308 public: |
1256 explicit TargetCollector(Zone* zone) | 1309 explicit TargetCollector(Zone* zone) |
1257 : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { } | 1310 : AstNode(RelocInfo::kNoPosition), targets_(0, zone) { } |
1258 | 1311 |
(...skipping 17 matching lines...) Expand all Loading... | |
1276 class TryStatement : public Statement { | 1329 class TryStatement : public Statement { |
1277 public: | 1330 public: |
1278 void set_escaping_targets(ZoneList<Label*>* targets) { | 1331 void set_escaping_targets(ZoneList<Label*>* targets) { |
1279 escaping_targets_ = targets; | 1332 escaping_targets_ = targets; |
1280 } | 1333 } |
1281 | 1334 |
1282 int index() const { return index_; } | 1335 int index() const { return index_; } |
1283 Block* try_block() const { return try_block_; } | 1336 Block* try_block() const { return try_block_; } |
1284 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } | 1337 ZoneList<Label*>* escaping_targets() const { return escaping_targets_; } |
1285 | 1338 |
1339 void AllocateBailoutIdRange(IdGen* id_gen) {} | |
1340 | |
1286 protected: | 1341 protected: |
1287 TryStatement(Zone* zone, int index, Block* try_block, int pos) | 1342 TryStatement(Zone* zone, int index, Block* try_block, int pos) |
1288 : Statement(zone, pos), | 1343 : Statement(zone, pos), |
1289 index_(index), | 1344 index_(index), |
1290 try_block_(try_block), | 1345 try_block_(try_block), |
1291 escaping_targets_(NULL) { } | 1346 escaping_targets_(NULL) { } |
1292 | 1347 |
1293 private: | 1348 private: |
1294 // Unique (per-function) index of this handler. This is not an AST ID. | 1349 // Unique (per-function) index of this handler. This is not an AST ID. |
1295 int index_; | 1350 int index_; |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1344 Block* finally_block_; | 1399 Block* finally_block_; |
1345 }; | 1400 }; |
1346 | 1401 |
1347 | 1402 |
1348 class DebuggerStatement FINAL : public Statement { | 1403 class DebuggerStatement FINAL : public Statement { |
1349 public: | 1404 public: |
1350 DECLARE_NODE_TYPE(DebuggerStatement) | 1405 DECLARE_NODE_TYPE(DebuggerStatement) |
1351 | 1406 |
1352 BailoutId DebugBreakId() const { return BailoutId(base_id() + 0); } | 1407 BailoutId DebugBreakId() const { return BailoutId(base_id() + 0); } |
1353 | 1408 |
1409 void AllocateBailoutIdRange(IdGen* id_gen) { | |
1410 DCHECK(BailoutId(base_id_).IsNone()); | |
1411 base_id_ = id_gen->ReserveIdRange(kBailoutIdCount); | |
1412 } | |
1413 | |
1354 protected: | 1414 protected: |
1355 explicit DebuggerStatement(Zone* zone, int pos, IdGen* id_gen) | 1415 explicit DebuggerStatement(Zone* zone, int pos) |
1356 : Statement(zone, pos), base_id_(id_gen->ReserveIdRange(num_ids())) {} | 1416 : Statement(zone, pos), base_id_(BailoutId::None().ToInt()) {} |
1357 | 1417 |
1358 static int num_ids() { return 1; } | 1418 int base_id() const { |
1359 int base_id() const { return base_id_; } | 1419 DCHECK(!BailoutId(base_id_).IsNone()); |
1420 return base_id_; | |
1421 } | |
1422 static const int kBailoutIdCount = 1; | |
1360 | 1423 |
1361 private: | 1424 private: |
1362 const int base_id_; | 1425 int base_id_; |
1363 }; | 1426 }; |
1364 | 1427 |
1365 | 1428 |
1366 class EmptyStatement FINAL : public Statement { | 1429 class EmptyStatement FINAL : public Statement { |
1367 public: | 1430 public: |
1368 DECLARE_NODE_TYPE(EmptyStatement) | 1431 DECLARE_NODE_TYPE(EmptyStatement) |
1369 | 1432 |
1433 void AllocateBailoutIdRange(IdGen* id_gen) {} | |
1434 | |
1370 protected: | 1435 protected: |
1371 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {} | 1436 explicit EmptyStatement(Zone* zone, int pos): Statement(zone, pos) {} |
1372 }; | 1437 }; |
1373 | 1438 |
1374 | 1439 |
1375 class Literal FINAL : public Expression { | 1440 class Literal FINAL : public Expression { |
1376 public: | 1441 public: |
1377 DECLARE_NODE_TYPE(Literal) | 1442 DECLARE_NODE_TYPE(Literal) |
1378 | 1443 |
1379 virtual bool IsPropertyName() const OVERRIDE { | 1444 virtual bool IsPropertyName() const OVERRIDE { |
(...skipping 22 matching lines...) Expand all Loading... | |
1402 | 1467 |
1403 // Support for using Literal as a HashMap key. NOTE: Currently, this works | 1468 // Support for using Literal as a HashMap key. NOTE: Currently, this works |
1404 // only for string and number literals! | 1469 // only for string and number literals! |
1405 uint32_t Hash(); | 1470 uint32_t Hash(); |
1406 static bool Match(void* literal1, void* literal2); | 1471 static bool Match(void* literal1, void* literal2); |
1407 | 1472 |
1408 TypeFeedbackId LiteralFeedbackId() const { | 1473 TypeFeedbackId LiteralFeedbackId() const { |
1409 return TypeFeedbackId(base_id() + 0); | 1474 return TypeFeedbackId(base_id() + 0); |
1410 } | 1475 } |
1411 | 1476 |
1477 void AllocateBailoutIdRange(IdGen* id_gen) { | |
1478 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
1479 } | |
1480 | |
1412 protected: | 1481 protected: |
1413 Literal(Zone* zone, const AstValue* value, int position, IdGen* id_gen) | 1482 Literal(Zone* zone, const AstValue* value, int position) |
1414 : Expression(zone, position, num_ids(), id_gen), value_(value) {} | 1483 : Expression(zone, position), value_(value) {} |
1415 | 1484 |
1416 static int num_ids() { return 1; } | 1485 int base_id() const { return leaf_base_id(); } |
1417 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 1486 static const int kBailoutIdCount = Expression::kBailoutIdCount + 1; |
1418 | 1487 |
1419 private: | 1488 private: |
1420 const AstValue* value_; | 1489 const AstValue* value_; |
1421 }; | 1490 }; |
1422 | 1491 |
1423 | 1492 |
1424 // Base class for literals that needs space in the corresponding JSFunction. | 1493 // Base class for literals that needs space in the corresponding JSFunction. |
1425 class MaterializedLiteral : public Expression { | 1494 class MaterializedLiteral : public Expression { |
1426 public: | 1495 public: |
1427 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } | 1496 virtual MaterializedLiteral* AsMaterializedLiteral() { return this; } |
1428 | 1497 |
1429 int literal_index() { return literal_index_; } | 1498 int literal_index() { return literal_index_; } |
1430 | 1499 |
1431 int depth() const { | 1500 int depth() const { |
1432 // only callable after initialization. | 1501 // only callable after initialization. |
1433 DCHECK(depth_ >= 1); | 1502 DCHECK(depth_ >= 1); |
1434 return depth_; | 1503 return depth_; |
1435 } | 1504 } |
1436 | 1505 |
1437 protected: | 1506 protected: |
1438 MaterializedLiteral(Zone* zone, int literal_index, int pos, | 1507 MaterializedLiteral(Zone* zone, int literal_index, int pos) |
1439 int num_ids_needed_by_subclass, IdGen* id_gen) | 1508 : Expression(zone, pos), |
1440 : Expression(zone, pos, num_ids_needed_by_subclass, id_gen), | |
1441 literal_index_(literal_index), | 1509 literal_index_(literal_index), |
1442 is_simple_(false), | 1510 is_simple_(false), |
1443 depth_(0) {} | 1511 depth_(0) {} |
1444 | 1512 |
1445 // A materialized literal is simple if the values consist of only | 1513 // A materialized literal is simple if the values consist of only |
1446 // constants and simple object and array literals. | 1514 // constants and simple object and array literals. |
1447 bool is_simple() const { return is_simple_; } | 1515 bool is_simple() const { return is_simple_; } |
1448 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } | 1516 void set_is_simple(bool is_simple) { is_simple_ = is_simple; } |
1449 friend class CompileTimeValue; | 1517 friend class CompileTimeValue; |
1450 | 1518 |
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1560 }; | 1628 }; |
1561 | 1629 |
1562 struct Accessors: public ZoneObject { | 1630 struct Accessors: public ZoneObject { |
1563 Accessors() : getter(NULL), setter(NULL) { } | 1631 Accessors() : getter(NULL), setter(NULL) { } |
1564 Expression* getter; | 1632 Expression* getter; |
1565 Expression* setter; | 1633 Expression* setter; |
1566 }; | 1634 }; |
1567 | 1635 |
1568 protected: | 1636 protected: |
1569 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, | 1637 ObjectLiteral(Zone* zone, ZoneList<Property*>* properties, int literal_index, |
1570 int boilerplate_properties, bool has_function, int pos, | 1638 int boilerplate_properties, bool has_function, int pos) |
1571 IdGen* id_gen) | 1639 : MaterializedLiteral(zone, literal_index, pos), |
1572 : MaterializedLiteral(zone, literal_index, pos, 0, id_gen), | |
1573 properties_(properties), | 1640 properties_(properties), |
1574 boilerplate_properties_(boilerplate_properties), | 1641 boilerplate_properties_(boilerplate_properties), |
1575 fast_elements_(false), | 1642 fast_elements_(false), |
1576 may_store_doubles_(false), | 1643 may_store_doubles_(false), |
1577 has_function_(has_function) {} | 1644 has_function_(has_function) {} |
1578 | 1645 |
1579 private: | 1646 private: |
1580 Handle<FixedArray> constant_properties_; | 1647 Handle<FixedArray> constant_properties_; |
1581 ZoneList<Property*>* properties_; | 1648 ZoneList<Property*>* properties_; |
1582 int boilerplate_properties_; | 1649 int boilerplate_properties_; |
1583 bool fast_elements_; | 1650 bool fast_elements_; |
1584 bool may_store_doubles_; | 1651 bool may_store_doubles_; |
1585 bool has_function_; | 1652 bool has_function_; |
1586 }; | 1653 }; |
1587 | 1654 |
1588 | 1655 |
1589 // Node for capturing a regexp literal. | 1656 // Node for capturing a regexp literal. |
1590 class RegExpLiteral FINAL : public MaterializedLiteral { | 1657 class RegExpLiteral FINAL : public MaterializedLiteral { |
1591 public: | 1658 public: |
1592 DECLARE_NODE_TYPE(RegExpLiteral) | 1659 DECLARE_NODE_TYPE(RegExpLiteral) |
1593 | 1660 |
1594 Handle<String> pattern() const { return pattern_->string(); } | 1661 Handle<String> pattern() const { return pattern_->string(); } |
1595 Handle<String> flags() const { return flags_->string(); } | 1662 Handle<String> flags() const { return flags_->string(); } |
1596 | 1663 |
1597 protected: | 1664 protected: |
1598 RegExpLiteral(Zone* zone, const AstRawString* pattern, | 1665 RegExpLiteral(Zone* zone, const AstRawString* pattern, |
1599 const AstRawString* flags, int literal_index, int pos, | 1666 const AstRawString* flags, int literal_index, int pos) |
1600 IdGen* id_gen) | 1667 : MaterializedLiteral(zone, literal_index, pos), |
1601 : MaterializedLiteral(zone, literal_index, pos, 0, id_gen), | |
1602 pattern_(pattern), | 1668 pattern_(pattern), |
1603 flags_(flags) { | 1669 flags_(flags) { |
1604 set_depth(1); | 1670 set_depth(1); |
1605 } | 1671 } |
1606 | 1672 |
1607 private: | 1673 private: |
1608 const AstRawString* pattern_; | 1674 const AstRawString* pattern_; |
1609 const AstRawString* flags_; | 1675 const AstRawString* flags_; |
1610 }; | 1676 }; |
1611 | 1677 |
(...skipping 19 matching lines...) Expand all Loading... | |
1631 flags |= ArrayLiteral::kDisableMementos; | 1697 flags |= ArrayLiteral::kDisableMementos; |
1632 return flags; | 1698 return flags; |
1633 } | 1699 } |
1634 | 1700 |
1635 enum Flags { | 1701 enum Flags { |
1636 kNoFlags = 0, | 1702 kNoFlags = 0, |
1637 kShallowElements = 1, | 1703 kShallowElements = 1, |
1638 kDisableMementos = 1 << 1 | 1704 kDisableMementos = 1 << 1 |
1639 }; | 1705 }; |
1640 | 1706 |
1707 | |
1708 void AllocateBailoutIdRange(IdGen* id_gen) { | |
1709 int count = MaterializedLiteral::kBailoutIdCount + values()->length(); | |
1710 InitializeBaseBailoutId(count, id_gen); | |
1711 } | |
1712 | |
1641 protected: | 1713 protected: |
1642 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, int literal_index, | 1714 ArrayLiteral(Zone* zone, ZoneList<Expression*>* values, int literal_index, |
1643 int pos, IdGen* id_gen) | 1715 int pos) |
1644 : MaterializedLiteral(zone, literal_index, pos, num_ids(values), id_gen), | 1716 : MaterializedLiteral(zone, literal_index, pos), values_(values) {} |
1645 values_(values) {} | |
1646 | 1717 |
1647 static int num_ids(ZoneList<Expression*>* values) { return values->length(); } | 1718 int base_id() const { return leaf_base_id(); } |
1648 int base_id() const { | |
1649 return MaterializedLiteral::base_id() + MaterializedLiteral::num_ids(); | |
1650 } | |
1651 | 1719 |
1652 private: | 1720 private: |
1653 Handle<FixedArray> constant_elements_; | 1721 Handle<FixedArray> constant_elements_; |
1654 ZoneList<Expression*>* values_; | 1722 ZoneList<Expression*>* values_; |
1655 }; | 1723 }; |
1656 | 1724 |
1657 | 1725 |
1658 class VariableProxy FINAL : public Expression { | 1726 class VariableProxy FINAL : public Expression { |
1659 public: | 1727 public: |
1660 DECLARE_NODE_TYPE(VariableProxy) | 1728 DECLARE_NODE_TYPE(VariableProxy) |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1694 void BindTo(Variable* var); | 1762 void BindTo(Variable* var); |
1695 | 1763 |
1696 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 1764 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } |
1697 virtual void SetFirstFeedbackSlot(int slot) { | 1765 virtual void SetFirstFeedbackSlot(int slot) { |
1698 variable_feedback_slot_ = slot; | 1766 variable_feedback_slot_ = slot; |
1699 } | 1767 } |
1700 | 1768 |
1701 int VariableFeedbackSlot() { return variable_feedback_slot_; } | 1769 int VariableFeedbackSlot() { return variable_feedback_slot_; } |
1702 | 1770 |
1703 protected: | 1771 protected: |
1704 VariableProxy(Zone* zone, Variable* var, int position, IdGen* id_gen); | 1772 VariableProxy(Zone* zone, Variable* var, int position); |
1705 | 1773 |
1706 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, | 1774 VariableProxy(Zone* zone, const AstRawString* name, bool is_this, |
1707 Interface* interface, int position, IdGen* id_gen); | 1775 Interface* interface, int position); |
1708 | 1776 |
1709 union { | 1777 union { |
1710 const AstRawString* raw_name_; // if !is_resolved_ | 1778 const AstRawString* raw_name_; // if !is_resolved_ |
1711 Variable* var_; // if is_resolved_ | 1779 Variable* var_; // if is_resolved_ |
1712 }; | 1780 }; |
1713 Interface* interface_; | 1781 Interface* interface_; |
1714 int variable_feedback_slot_; | 1782 int variable_feedback_slot_; |
1715 bool is_this_ : 1; | 1783 bool is_this_ : 1; |
1716 bool is_assigned_ : 1; | 1784 bool is_assigned_ : 1; |
1717 bool is_resolved_ : 1; | 1785 bool is_resolved_ : 1; |
1718 }; | 1786 }; |
1719 | 1787 |
1720 | 1788 |
1721 class Property FINAL : public Expression { | 1789 class Property FINAL : public Expression { |
1722 public: | 1790 public: |
1723 DECLARE_NODE_TYPE(Property) | 1791 DECLARE_NODE_TYPE(Property) |
1724 | 1792 |
1725 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; } | 1793 virtual bool IsValidReferenceExpression() const OVERRIDE { return true; } |
1726 | 1794 |
1727 Expression* obj() const { return obj_; } | 1795 Expression* obj() const { return obj_; } |
1728 Expression* key() const { return key_; } | 1796 Expression* key() const { return key_; } |
1729 | 1797 |
1730 BailoutId LoadId() const { return BailoutId(base_id() + 0); } | 1798 BailoutId LoadId() const { return BailoutId(base_id() + 0); } |
1731 TypeFeedbackId PropertyFeedbackId() { return TypeFeedbackId(base_id() + 1); } | 1799 TypeFeedbackId PropertyFeedbackId() { return TypeFeedbackId(base_id() + 1); } |
1732 | 1800 |
1801 void AllocateBailoutIdRange(IdGen* id_gen) { | |
1802 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
1803 } | |
1733 | 1804 |
1734 bool IsStringAccess() const { return is_string_access_; } | 1805 bool IsStringAccess() const { return is_string_access_; } |
1735 | 1806 |
1736 // Type feedback information. | 1807 // Type feedback information. |
1737 virtual bool IsMonomorphic() OVERRIDE { | 1808 virtual bool IsMonomorphic() OVERRIDE { |
1738 return receiver_types_.length() == 1; | 1809 return receiver_types_.length() == 1; |
1739 } | 1810 } |
1740 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 1811 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
1741 return &receiver_types_; | 1812 return &receiver_types_; |
1742 } | 1813 } |
(...skipping 14 matching lines...) Expand all Loading... | |
1757 } | 1828 } |
1758 | 1829 |
1759 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 1830 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } |
1760 virtual void SetFirstFeedbackSlot(int slot) { | 1831 virtual void SetFirstFeedbackSlot(int slot) { |
1761 property_feedback_slot_ = slot; | 1832 property_feedback_slot_ = slot; |
1762 } | 1833 } |
1763 | 1834 |
1764 int PropertyFeedbackSlot() const { return property_feedback_slot_; } | 1835 int PropertyFeedbackSlot() const { return property_feedback_slot_; } |
1765 | 1836 |
1766 protected: | 1837 protected: |
1767 Property(Zone* zone, Expression* obj, Expression* key, int pos, IdGen* id_gen) | 1838 Property(Zone* zone, Expression* obj, Expression* key, int pos) |
1768 : Expression(zone, pos, num_ids(), id_gen), | 1839 : Expression(zone, pos), |
1769 obj_(obj), | 1840 obj_(obj), |
1770 key_(key), | 1841 key_(key), |
1771 property_feedback_slot_(kInvalidFeedbackSlot), | 1842 property_feedback_slot_(kInvalidFeedbackSlot), |
1772 is_for_call_(false), | 1843 is_for_call_(false), |
1773 is_uninitialized_(false), | 1844 is_uninitialized_(false), |
1774 is_string_access_(false) {} | 1845 is_string_access_(false) {} |
1775 | 1846 |
1776 static int num_ids() { return 2; } | 1847 int base_id() const { return leaf_base_id(); } |
1777 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 1848 static const int kBailoutIdCount = Expression::kBailoutIdCount + 2; |
1778 | 1849 |
1779 private: | 1850 private: |
1780 Expression* obj_; | 1851 Expression* obj_; |
1781 Expression* key_; | 1852 Expression* key_; |
1782 int property_feedback_slot_; | 1853 int property_feedback_slot_; |
1783 | 1854 |
1784 SmallMapList receiver_types_; | 1855 SmallMapList receiver_types_; |
1785 bool is_for_call_ : 1; | 1856 bool is_for_call_ : 1; |
1786 bool is_uninitialized_ : 1; | 1857 bool is_uninitialized_ : 1; |
1787 bool is_string_access_ : 1; | 1858 bool is_string_access_ : 1; |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1837 | 1908 |
1838 void set_target(Handle<JSFunction> target) { target_ = target; } | 1909 void set_target(Handle<JSFunction> target) { target_ = target; } |
1839 void set_allocation_site(Handle<AllocationSite> site) { | 1910 void set_allocation_site(Handle<AllocationSite> site) { |
1840 allocation_site_ = site; | 1911 allocation_site_ = site; |
1841 } | 1912 } |
1842 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it); | 1913 bool ComputeGlobalTarget(Handle<GlobalObject> global, LookupIterator* it); |
1843 | 1914 |
1844 BailoutId ReturnId() const { return BailoutId(base_id() + 0); } | 1915 BailoutId ReturnId() const { return BailoutId(base_id() + 0); } |
1845 BailoutId EvalOrLookupId() const { return BailoutId(base_id() + 1); } | 1916 BailoutId EvalOrLookupId() const { return BailoutId(base_id() + 1); } |
1846 | 1917 |
1918 void AllocateBailoutIdRange(IdGen* id_gen) { | |
1919 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
1920 } | |
1921 | |
1847 enum CallType { | 1922 enum CallType { |
1848 POSSIBLY_EVAL_CALL, | 1923 POSSIBLY_EVAL_CALL, |
1849 GLOBAL_CALL, | 1924 GLOBAL_CALL, |
1850 LOOKUP_SLOT_CALL, | 1925 LOOKUP_SLOT_CALL, |
1851 PROPERTY_CALL, | 1926 PROPERTY_CALL, |
1852 OTHER_CALL | 1927 OTHER_CALL |
1853 }; | 1928 }; |
1854 | 1929 |
1855 // Helpers to determine how to handle the call. | 1930 // Helpers to determine how to handle the call. |
1856 CallType GetCallType(Isolate* isolate) const; | 1931 CallType GetCallType(Isolate* isolate) const; |
1857 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; | 1932 bool IsUsingCallFeedbackSlot(Isolate* isolate) const; |
1858 | 1933 |
1859 #ifdef DEBUG | 1934 #ifdef DEBUG |
1860 // Used to assert that the FullCodeGenerator records the return site. | 1935 // Used to assert that the FullCodeGenerator records the return site. |
1861 bool return_is_recorded_; | 1936 bool return_is_recorded_; |
1862 #endif | 1937 #endif |
1863 | 1938 |
1864 protected: | 1939 protected: |
1865 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 1940 Call(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
1866 int pos, IdGen* id_gen) | 1941 int pos) |
1867 : Expression(zone, pos, num_ids(), id_gen), | 1942 : Expression(zone, pos), |
1868 expression_(expression), | 1943 expression_(expression), |
1869 arguments_(arguments), | 1944 arguments_(arguments), |
1870 call_feedback_slot_(kInvalidFeedbackSlot) { | 1945 call_feedback_slot_(kInvalidFeedbackSlot) { |
1871 if (expression->IsProperty()) { | 1946 if (expression->IsProperty()) { |
1872 expression->AsProperty()->mark_for_call(); | 1947 expression->AsProperty()->mark_for_call(); |
1873 } | 1948 } |
1874 } | 1949 } |
1875 | 1950 |
1876 static int num_ids() { return 2; } | 1951 int base_id() const { return leaf_base_id(); } |
1877 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 1952 static const int kBailoutIdCount = Expression::kBailoutIdCount + 2; |
1878 | 1953 |
1879 private: | 1954 private: |
1880 Expression* expression_; | 1955 Expression* expression_; |
1881 ZoneList<Expression*>* arguments_; | 1956 ZoneList<Expression*>* arguments_; |
1882 Handle<JSFunction> target_; | 1957 Handle<JSFunction> target_; |
1883 Handle<Cell> cell_; | 1958 Handle<Cell> cell_; |
1884 Handle<AllocationSite> allocation_site_; | 1959 Handle<AllocationSite> allocation_site_; |
1885 int call_feedback_slot_; | 1960 int call_feedback_slot_; |
1886 }; | 1961 }; |
1887 | 1962 |
(...skipping 27 matching lines...) Expand all Loading... | |
1915 virtual bool IsMonomorphic() OVERRIDE { return is_monomorphic_; } | 1990 virtual bool IsMonomorphic() OVERRIDE { return is_monomorphic_; } |
1916 Handle<JSFunction> target() const { return target_; } | 1991 Handle<JSFunction> target() const { return target_; } |
1917 Handle<AllocationSite> allocation_site() const { | 1992 Handle<AllocationSite> allocation_site() const { |
1918 return allocation_site_; | 1993 return allocation_site_; |
1919 } | 1994 } |
1920 | 1995 |
1921 static int feedback_slots() { return 1; } | 1996 static int feedback_slots() { return 1; } |
1922 | 1997 |
1923 BailoutId ReturnId() const { return BailoutId(base_id() + 0); } | 1998 BailoutId ReturnId() const { return BailoutId(base_id() + 0); } |
1924 | 1999 |
2000 void AllocateBailoutIdRange(IdGen* id_gen) { | |
2001 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
2002 } | |
2003 | |
1925 protected: | 2004 protected: |
1926 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, | 2005 CallNew(Zone* zone, Expression* expression, ZoneList<Expression*>* arguments, |
1927 int pos, IdGen* id_gen) | 2006 int pos) |
1928 : Expression(zone, pos, num_ids(), id_gen), | 2007 : Expression(zone, pos), |
1929 expression_(expression), | 2008 expression_(expression), |
1930 arguments_(arguments), | 2009 arguments_(arguments), |
1931 is_monomorphic_(false), | 2010 is_monomorphic_(false), |
1932 callnew_feedback_slot_(kInvalidFeedbackSlot) {} | 2011 callnew_feedback_slot_(kInvalidFeedbackSlot) {} |
1933 | 2012 |
1934 static int num_ids() { return 1; } | 2013 int base_id() const { return leaf_base_id(); } |
1935 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 2014 static const int kBailoutIdCount = Expression::kBailoutIdCount + 1; |
1936 | 2015 |
1937 private: | 2016 private: |
1938 Expression* expression_; | 2017 Expression* expression_; |
1939 ZoneList<Expression*>* arguments_; | 2018 ZoneList<Expression*>* arguments_; |
1940 bool is_monomorphic_; | 2019 bool is_monomorphic_; |
1941 Handle<JSFunction> target_; | 2020 Handle<JSFunction> target_; |
1942 Handle<AllocationSite> allocation_site_; | 2021 Handle<AllocationSite> allocation_site_; |
1943 int callnew_feedback_slot_; | 2022 int callnew_feedback_slot_; |
1944 }; | 2023 }; |
1945 | 2024 |
(...skipping 23 matching lines...) Expand all Loading... | |
1969 int CallRuntimeFeedbackSlot() { | 2048 int CallRuntimeFeedbackSlot() { |
1970 DCHECK(!is_jsruntime() || | 2049 DCHECK(!is_jsruntime() || |
1971 callruntime_feedback_slot_ != kInvalidFeedbackSlot); | 2050 callruntime_feedback_slot_ != kInvalidFeedbackSlot); |
1972 return callruntime_feedback_slot_; | 2051 return callruntime_feedback_slot_; |
1973 } | 2052 } |
1974 | 2053 |
1975 TypeFeedbackId CallRuntimeFeedbackId() const { | 2054 TypeFeedbackId CallRuntimeFeedbackId() const { |
1976 return TypeFeedbackId(base_id() + 0); | 2055 return TypeFeedbackId(base_id() + 0); |
1977 } | 2056 } |
1978 | 2057 |
2058 void AllocateBailoutIdRange(IdGen* id_gen) { | |
2059 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
2060 } | |
2061 | |
1979 protected: | 2062 protected: |
1980 CallRuntime(Zone* zone, const AstRawString* name, | 2063 CallRuntime(Zone* zone, const AstRawString* name, |
1981 const Runtime::Function* function, | 2064 const Runtime::Function* function, |
1982 ZoneList<Expression*>* arguments, int pos, IdGen* id_gen) | 2065 ZoneList<Expression*>* arguments, int pos) |
1983 : Expression(zone, pos, num_ids(), id_gen), | 2066 : Expression(zone, pos), |
1984 raw_name_(name), | 2067 raw_name_(name), |
1985 function_(function), | 2068 function_(function), |
1986 arguments_(arguments) {} | 2069 arguments_(arguments) {} |
1987 | 2070 |
1988 static int num_ids() { return 1; } | 2071 int base_id() const { return leaf_base_id(); } |
1989 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 2072 static const int kBailoutIdCount = Expression::kBailoutIdCount + 1; |
1990 | 2073 |
1991 private: | 2074 private: |
1992 const AstRawString* raw_name_; | 2075 const AstRawString* raw_name_; |
1993 const Runtime::Function* function_; | 2076 const Runtime::Function* function_; |
1994 ZoneList<Expression*>* arguments_; | 2077 ZoneList<Expression*>* arguments_; |
1995 int callruntime_feedback_slot_; | 2078 int callruntime_feedback_slot_; |
1996 }; | 2079 }; |
1997 | 2080 |
1998 | 2081 |
1999 class UnaryOperation FINAL : public Expression { | 2082 class UnaryOperation FINAL : public Expression { |
2000 public: | 2083 public: |
2001 DECLARE_NODE_TYPE(UnaryOperation) | 2084 DECLARE_NODE_TYPE(UnaryOperation) |
2002 | 2085 |
2003 Token::Value op() const { return op_; } | 2086 Token::Value op() const { return op_; } |
2004 Expression* expression() const { return expression_; } | 2087 Expression* expression() const { return expression_; } |
2005 | 2088 |
2006 // For unary not (Token::NOT), the AST ids where true and false will | 2089 // For unary not (Token::NOT), the AST ids where true and false will |
2007 // actually be materialized, respectively. | 2090 // actually be materialized, respectively. |
2008 BailoutId MaterializeTrueId() const { return BailoutId(base_id() + 0); } | 2091 BailoutId MaterializeTrueId() const { return BailoutId(base_id() + 0); } |
2009 BailoutId MaterializeFalseId() const { return BailoutId(base_id() + 1); } | 2092 BailoutId MaterializeFalseId() const { return BailoutId(base_id() + 1); } |
2010 | 2093 |
2094 void AllocateBailoutIdRange(IdGen* id_gen) { | |
2095 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
2096 } | |
2097 | |
2011 virtual void RecordToBooleanTypeFeedback( | 2098 virtual void RecordToBooleanTypeFeedback( |
2012 TypeFeedbackOracle* oracle) OVERRIDE; | 2099 TypeFeedbackOracle* oracle) OVERRIDE; |
2013 | 2100 |
2014 protected: | 2101 protected: |
2015 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos, | 2102 UnaryOperation(Zone* zone, Token::Value op, Expression* expression, int pos) |
2016 IdGen* id_gen) | 2103 : Expression(zone, pos), op_(op), expression_(expression) { |
2017 : Expression(zone, pos, num_ids(), id_gen), | |
2018 op_(op), | |
2019 expression_(expression) { | |
2020 DCHECK(Token::IsUnaryOp(op)); | 2104 DCHECK(Token::IsUnaryOp(op)); |
2021 } | 2105 } |
2022 | 2106 |
2023 static int num_ids() { return 2; } | 2107 int base_id() const { return leaf_base_id(); } |
2024 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 2108 static const int kBailoutIdCount = Expression::kBailoutIdCount + 2; |
2025 | 2109 |
2026 private: | 2110 private: |
2027 Token::Value op_; | 2111 Token::Value op_; |
2028 Expression* expression_; | 2112 Expression* expression_; |
2029 }; | 2113 }; |
2030 | 2114 |
2031 | 2115 |
2032 class BinaryOperation FINAL : public Expression { | 2116 class BinaryOperation FINAL : public Expression { |
2033 public: | 2117 public: |
2034 DECLARE_NODE_TYPE(BinaryOperation) | 2118 DECLARE_NODE_TYPE(BinaryOperation) |
2035 | 2119 |
2036 virtual bool ResultOverwriteAllowed() const OVERRIDE; | 2120 virtual bool ResultOverwriteAllowed() const OVERRIDE; |
2037 | 2121 |
2038 Token::Value op() const { return op_; } | 2122 Token::Value op() const { return op_; } |
2039 Expression* left() const { return left_; } | 2123 Expression* left() const { return left_; } |
2040 Expression* right() const { return right_; } | 2124 Expression* right() const { return right_; } |
2041 Handle<AllocationSite> allocation_site() const { return allocation_site_; } | 2125 Handle<AllocationSite> allocation_site() const { return allocation_site_; } |
2042 void set_allocation_site(Handle<AllocationSite> allocation_site) { | 2126 void set_allocation_site(Handle<AllocationSite> allocation_site) { |
2043 allocation_site_ = allocation_site; | 2127 allocation_site_ = allocation_site; |
2044 } | 2128 } |
2045 | 2129 |
2046 // The short-circuit logical operations need an AST ID for their | 2130 // The short-circuit logical operations need an AST ID for their |
2047 // right-hand subexpression. | 2131 // right-hand subexpression. |
2048 BailoutId RightId() const { return BailoutId(base_id() + 0); } | 2132 BailoutId RightId() const { return BailoutId(base_id() + 0); } |
2049 | 2133 |
2050 TypeFeedbackId BinaryOperationFeedbackId() const { | 2134 TypeFeedbackId BinaryOperationFeedbackId() const { |
2051 return TypeFeedbackId(base_id() + 1); | 2135 return TypeFeedbackId(base_id() + 1); |
2052 } | 2136 } |
2137 void AllocateBailoutIdRange(IdGen* id_gen) { | |
2138 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
2139 } | |
2140 | |
2053 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } | 2141 Maybe<int> fixed_right_arg() const { return fixed_right_arg_; } |
2054 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; } | 2142 void set_fixed_right_arg(Maybe<int> arg) { fixed_right_arg_ = arg; } |
2055 | 2143 |
2056 virtual void RecordToBooleanTypeFeedback( | 2144 virtual void RecordToBooleanTypeFeedback( |
2057 TypeFeedbackOracle* oracle) OVERRIDE; | 2145 TypeFeedbackOracle* oracle) OVERRIDE; |
2058 | 2146 |
2059 protected: | 2147 protected: |
2060 BinaryOperation(Zone* zone, Token::Value op, Expression* left, | 2148 BinaryOperation(Zone* zone, Token::Value op, Expression* left, |
2061 Expression* right, int pos, IdGen* id_gen) | 2149 Expression* right, int pos) |
2062 : Expression(zone, pos, num_ids(), id_gen), | 2150 : Expression(zone, pos), op_(op), left_(left), right_(right) { |
2063 op_(op), | |
2064 left_(left), | |
2065 right_(right) { | |
2066 DCHECK(Token::IsBinaryOp(op)); | 2151 DCHECK(Token::IsBinaryOp(op)); |
2067 } | 2152 } |
2068 | 2153 |
2069 static int num_ids() { return 2; } | 2154 int base_id() const { return leaf_base_id(); } |
2070 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 2155 static const int kBailoutIdCount = Expression::kBailoutIdCount + 2; |
2071 | 2156 |
2072 private: | 2157 private: |
2073 Token::Value op_; | 2158 Token::Value op_; |
2074 Expression* left_; | 2159 Expression* left_; |
2075 Expression* right_; | 2160 Expression* right_; |
2076 Handle<AllocationSite> allocation_site_; | 2161 Handle<AllocationSite> allocation_site_; |
2077 | 2162 |
2078 // TODO(rossberg): the fixed arg should probably be represented as a Constant | 2163 // TODO(rossberg): the fixed arg should probably be represented as a Constant |
2079 // type for the RHS. | 2164 // type for the RHS. |
2080 Maybe<int> fixed_right_arg_; | 2165 Maybe<int> fixed_right_arg_; |
(...skipping 28 matching lines...) Expand all Loading... | |
2109 void set_type(Type* type) { type_ = type; } | 2194 void set_type(Type* type) { type_ = type; } |
2110 | 2195 |
2111 BailoutId AssignmentId() const { return BailoutId(base_id() + 0); } | 2196 BailoutId AssignmentId() const { return BailoutId(base_id() + 0); } |
2112 TypeFeedbackId CountBinOpFeedbackId() const { | 2197 TypeFeedbackId CountBinOpFeedbackId() const { |
2113 return TypeFeedbackId(base_id() + 1); | 2198 return TypeFeedbackId(base_id() + 1); |
2114 } | 2199 } |
2115 TypeFeedbackId CountStoreFeedbackId() const { | 2200 TypeFeedbackId CountStoreFeedbackId() const { |
2116 return TypeFeedbackId(base_id() + 2); | 2201 return TypeFeedbackId(base_id() + 2); |
2117 } | 2202 } |
2118 | 2203 |
2204 void AllocateBailoutIdRange(IdGen* id_gen) { | |
2205 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
2206 } | |
2207 | |
2119 protected: | 2208 protected: |
2120 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, | 2209 CountOperation(Zone* zone, Token::Value op, bool is_prefix, Expression* expr, |
2121 int pos, IdGen* id_gen) | 2210 int pos) |
2122 : Expression(zone, pos, num_ids(), id_gen), | 2211 : Expression(zone, pos), |
2123 op_(op), | 2212 op_(op), |
2124 is_prefix_(is_prefix), | 2213 is_prefix_(is_prefix), |
2125 store_mode_(STANDARD_STORE), | 2214 store_mode_(STANDARD_STORE), |
2126 expression_(expr) {} | 2215 expression_(expr) {} |
2127 | 2216 |
2128 static int num_ids() { return 3; } | 2217 int base_id() const { return leaf_base_id(); } |
2129 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 2218 static const int kBailoutIdCount = Expression::kBailoutIdCount + 3; |
2130 | 2219 |
2131 private: | 2220 private: |
2132 Token::Value op_; | 2221 Token::Value op_; |
2133 bool is_prefix_ : 1; | 2222 bool is_prefix_ : 1; |
2134 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, | 2223 KeyedAccessStoreMode store_mode_ : 5; // Windows treats as signed, |
2135 // must have extra bit. | 2224 // must have extra bit. |
2136 Type* type_; | 2225 Type* type_; |
2137 Expression* expression_; | 2226 Expression* expression_; |
2138 SmallMapList receiver_types_; | 2227 SmallMapList receiver_types_; |
2139 }; | 2228 }; |
2140 | 2229 |
2141 | 2230 |
2142 class CompareOperation FINAL : public Expression { | 2231 class CompareOperation FINAL : public Expression { |
2143 public: | 2232 public: |
2144 DECLARE_NODE_TYPE(CompareOperation) | 2233 DECLARE_NODE_TYPE(CompareOperation) |
2145 | 2234 |
2146 Token::Value op() const { return op_; } | 2235 Token::Value op() const { return op_; } |
2147 Expression* left() const { return left_; } | 2236 Expression* left() const { return left_; } |
2148 Expression* right() const { return right_; } | 2237 Expression* right() const { return right_; } |
2149 | 2238 |
2150 // Type feedback information. | 2239 // Type feedback information. |
2151 TypeFeedbackId CompareOperationFeedbackId() const { | 2240 TypeFeedbackId CompareOperationFeedbackId() const { |
2152 return TypeFeedbackId(base_id() + 0); | 2241 return TypeFeedbackId(base_id() + 0); |
2153 } | 2242 } |
2243 void AllocateBailoutIdRange(IdGen* id_gen) { | |
2244 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
2245 } | |
2154 Type* combined_type() const { return combined_type_; } | 2246 Type* combined_type() const { return combined_type_; } |
2155 void set_combined_type(Type* type) { combined_type_ = type; } | 2247 void set_combined_type(Type* type) { combined_type_ = type; } |
2156 | 2248 |
2157 // Match special cases. | 2249 // Match special cases. |
2158 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); | 2250 bool IsLiteralCompareTypeof(Expression** expr, Handle<String>* check); |
2159 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate); | 2251 bool IsLiteralCompareUndefined(Expression** expr, Isolate* isolate); |
2160 bool IsLiteralCompareNull(Expression** expr); | 2252 bool IsLiteralCompareNull(Expression** expr); |
2161 | 2253 |
2162 protected: | 2254 protected: |
2163 CompareOperation(Zone* zone, Token::Value op, Expression* left, | 2255 CompareOperation(Zone* zone, Token::Value op, Expression* left, |
2164 Expression* right, int pos, IdGen* id_gen) | 2256 Expression* right, int pos) |
2165 : Expression(zone, pos, num_ids(), id_gen), | 2257 : Expression(zone, pos), |
2166 op_(op), | 2258 op_(op), |
2167 left_(left), | 2259 left_(left), |
2168 right_(right), | 2260 right_(right), |
2169 combined_type_(Type::None(zone)) { | 2261 combined_type_(Type::None(zone)) { |
2170 DCHECK(Token::IsCompareOp(op)); | 2262 DCHECK(Token::IsCompareOp(op)); |
2171 } | 2263 } |
2172 | 2264 |
2173 static int num_ids() { return 1; } | 2265 int base_id() const { return leaf_base_id(); } |
2174 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 2266 static const int kBailoutIdCount = Expression::kBailoutIdCount + 1; |
2175 | 2267 |
2176 private: | 2268 private: |
2177 Token::Value op_; | 2269 Token::Value op_; |
2178 Expression* left_; | 2270 Expression* left_; |
2179 Expression* right_; | 2271 Expression* right_; |
2180 | 2272 |
2181 Type* combined_type_; | 2273 Type* combined_type_; |
2182 }; | 2274 }; |
2183 | 2275 |
2184 | 2276 |
2185 class Conditional FINAL : public Expression { | 2277 class Conditional FINAL : public Expression { |
2186 public: | 2278 public: |
2187 DECLARE_NODE_TYPE(Conditional) | 2279 DECLARE_NODE_TYPE(Conditional) |
2188 | 2280 |
2189 Expression* condition() const { return condition_; } | 2281 Expression* condition() const { return condition_; } |
2190 Expression* then_expression() const { return then_expression_; } | 2282 Expression* then_expression() const { return then_expression_; } |
2191 Expression* else_expression() const { return else_expression_; } | 2283 Expression* else_expression() const { return else_expression_; } |
2192 | 2284 |
2193 BailoutId ThenId() const { return BailoutId(base_id() + 0); } | 2285 BailoutId ThenId() const { return BailoutId(base_id() + 0); } |
2194 BailoutId ElseId() const { return BailoutId(base_id() + 1); } | 2286 BailoutId ElseId() const { return BailoutId(base_id() + 1); } |
2195 | 2287 |
2288 void AllocateBailoutIdRange(IdGen* id_gen) { | |
2289 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
2290 } | |
2291 | |
2196 protected: | 2292 protected: |
2197 Conditional(Zone* zone, Expression* condition, Expression* then_expression, | 2293 Conditional(Zone* zone, Expression* condition, Expression* then_expression, |
2198 Expression* else_expression, int position, IdGen* id_gen) | 2294 Expression* else_expression, int position) |
2199 : Expression(zone, position, num_ids(), id_gen), | 2295 : Expression(zone, position), |
2200 condition_(condition), | 2296 condition_(condition), |
2201 then_expression_(then_expression), | 2297 then_expression_(then_expression), |
2202 else_expression_(else_expression) {} | 2298 else_expression_(else_expression) {} |
2203 | 2299 |
2204 static int num_ids() { return 2; } | 2300 int base_id() const { return leaf_base_id(); } |
2205 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 2301 static const int kBailoutIdCount = Expression::kBailoutIdCount + 2; |
2206 | 2302 |
2207 private: | 2303 private: |
2208 Expression* condition_; | 2304 Expression* condition_; |
2209 Expression* then_expression_; | 2305 Expression* then_expression_; |
2210 Expression* else_expression_; | 2306 Expression* else_expression_; |
2211 }; | 2307 }; |
2212 | 2308 |
2213 | 2309 |
2214 class Assignment FINAL : public Expression { | 2310 class Assignment FINAL : public Expression { |
2215 public: | 2311 public: |
2216 DECLARE_NODE_TYPE(Assignment) | 2312 DECLARE_NODE_TYPE(Assignment) |
2217 | 2313 |
2218 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } | 2314 Assignment* AsSimpleAssignment() { return !is_compound() ? this : NULL; } |
2219 | 2315 |
2220 Token::Value binary_op() const; | 2316 Token::Value binary_op() const; |
2221 | 2317 |
2222 Token::Value op() const { return op_; } | 2318 Token::Value op() const { return op_; } |
2223 Expression* target() const { return target_; } | 2319 Expression* target() const { return target_; } |
2224 Expression* value() const { return value_; } | 2320 Expression* value() const { return value_; } |
2225 BinaryOperation* binary_operation() const { return binary_operation_; } | 2321 BinaryOperation* binary_operation() const { return binary_operation_; } |
2226 | 2322 |
2227 // This check relies on the definition order of token in token.h. | 2323 // This check relies on the definition order of token in token.h. |
2228 bool is_compound() const { return op() > Token::ASSIGN; } | 2324 bool is_compound() const { return op() > Token::ASSIGN; } |
2229 | 2325 |
2230 BailoutId AssignmentId() const { return BailoutId(base_id() + 0); } | 2326 BailoutId AssignmentId() const { return BailoutId(base_id() + 0); } |
2231 | 2327 |
2328 void AllocateBailoutIdRange(IdGen* id_gen) { | |
2329 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
2330 } | |
2331 | |
2232 // Type feedback information. | 2332 // Type feedback information. |
2233 TypeFeedbackId AssignmentFeedbackId() { | 2333 TypeFeedbackId AssignmentFeedbackId() { |
2234 return TypeFeedbackId(base_id() + 1); | 2334 return TypeFeedbackId(base_id() + 1); |
2235 } | 2335 } |
2236 virtual bool IsMonomorphic() OVERRIDE { | 2336 virtual bool IsMonomorphic() OVERRIDE { |
2237 return receiver_types_.length() == 1; | 2337 return receiver_types_.length() == 1; |
2238 } | 2338 } |
2239 bool IsUninitialized() { return is_uninitialized_; } | 2339 bool IsUninitialized() { return is_uninitialized_; } |
2240 bool HasNoTypeInformation() { | 2340 bool HasNoTypeInformation() { |
2241 return is_uninitialized_; | 2341 return is_uninitialized_; |
2242 } | 2342 } |
2243 virtual SmallMapList* GetReceiverTypes() OVERRIDE { | 2343 virtual SmallMapList* GetReceiverTypes() OVERRIDE { |
2244 return &receiver_types_; | 2344 return &receiver_types_; |
2245 } | 2345 } |
2246 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { | 2346 virtual KeyedAccessStoreMode GetStoreMode() OVERRIDE { |
2247 return store_mode_; | 2347 return store_mode_; |
2248 } | 2348 } |
2249 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } | 2349 void set_is_uninitialized(bool b) { is_uninitialized_ = b; } |
2250 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } | 2350 void set_store_mode(KeyedAccessStoreMode mode) { store_mode_ = mode; } |
2251 | 2351 |
2252 protected: | 2352 protected: |
2253 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, | 2353 Assignment(Zone* zone, Token::Value op, Expression* target, Expression* value, |
2254 int pos, IdGen* id_gen); | 2354 int pos); |
2255 | 2355 |
2256 static int num_ids() { return 2; } | 2356 int base_id() const { return leaf_base_id(); } |
2257 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 2357 static const int kBailoutIdCount = Expression::kBailoutIdCount + 2; |
2258 | 2358 |
2259 template<class Visitor> | 2359 template<class Visitor> |
2260 void Init(Zone* zone, AstNodeFactory<Visitor>* factory) { | 2360 void Init(Zone* zone, AstNodeFactory<Visitor>* factory) { |
2261 DCHECK(Token::IsAssignmentOp(op_)); | 2361 DCHECK(Token::IsAssignmentOp(op_)); |
2262 if (is_compound()) { | 2362 if (is_compound()) { |
2263 binary_operation_ = factory->NewBinaryOperation( | 2363 binary_operation_ = factory->NewBinaryOperation( |
2264 binary_op(), target_, value_, position() + 1); | 2364 binary_op(), target_, value_, position() + 1); |
2265 } | 2365 } |
2266 } | 2366 } |
2267 | 2367 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2322 return yield_first_feedback_slot_ + 1; | 2422 return yield_first_feedback_slot_ + 1; |
2323 } | 2423 } |
2324 | 2424 |
2325 int ValueFeedbackSlot() { | 2425 int ValueFeedbackSlot() { |
2326 DCHECK(yield_first_feedback_slot_ != kInvalidFeedbackSlot); | 2426 DCHECK(yield_first_feedback_slot_ != kInvalidFeedbackSlot); |
2327 return yield_first_feedback_slot_ + 2; | 2427 return yield_first_feedback_slot_ + 2; |
2328 } | 2428 } |
2329 | 2429 |
2330 protected: | 2430 protected: |
2331 Yield(Zone* zone, Expression* generator_object, Expression* expression, | 2431 Yield(Zone* zone, Expression* generator_object, Expression* expression, |
2332 Kind yield_kind, int pos, IdGen* id_gen) | 2432 Kind yield_kind, int pos) |
2333 : Expression(zone, pos, 0, id_gen), | 2433 : Expression(zone, pos), |
2334 generator_object_(generator_object), | 2434 generator_object_(generator_object), |
2335 expression_(expression), | 2435 expression_(expression), |
2336 yield_kind_(yield_kind), | 2436 yield_kind_(yield_kind), |
2337 index_(-1), | 2437 index_(-1), |
2338 yield_first_feedback_slot_(kInvalidFeedbackSlot) {} | 2438 yield_first_feedback_slot_(kInvalidFeedbackSlot) {} |
2339 | 2439 |
2340 private: | 2440 private: |
2341 Expression* generator_object_; | 2441 Expression* generator_object_; |
2342 Expression* expression_; | 2442 Expression* expression_; |
2343 Kind yield_kind_; | 2443 Kind yield_kind_; |
2344 int index_; | 2444 int index_; |
2345 int yield_first_feedback_slot_; | 2445 int yield_first_feedback_slot_; |
2346 }; | 2446 }; |
2347 | 2447 |
2348 | 2448 |
2349 class Throw FINAL : public Expression { | 2449 class Throw FINAL : public Expression { |
2350 public: | 2450 public: |
2351 DECLARE_NODE_TYPE(Throw) | 2451 DECLARE_NODE_TYPE(Throw) |
2352 | 2452 |
2353 Expression* exception() const { return exception_; } | 2453 Expression* exception() const { return exception_; } |
2354 | 2454 |
2355 protected: | 2455 protected: |
2356 Throw(Zone* zone, Expression* exception, int pos, IdGen* id_gen) | 2456 Throw(Zone* zone, Expression* exception, int pos) |
2357 : Expression(zone, pos, 0, id_gen), exception_(exception) {} | 2457 : Expression(zone, pos), exception_(exception) {} |
2358 | 2458 |
2359 private: | 2459 private: |
2360 Expression* exception_; | 2460 Expression* exception_; |
2361 }; | 2461 }; |
2362 | 2462 |
2363 | 2463 |
2364 class FunctionLiteral FINAL : public Expression { | 2464 class FunctionLiteral FINAL : public Expression { |
2365 public: | 2465 public: |
2366 enum FunctionType { | 2466 enum FunctionType { |
2367 ANONYMOUS_EXPRESSION, | 2467 ANONYMOUS_EXPRESSION, |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2500 | 2600 |
2501 protected: | 2601 protected: |
2502 FunctionLiteral(Zone* zone, const AstRawString* name, | 2602 FunctionLiteral(Zone* zone, const AstRawString* name, |
2503 AstValueFactory* ast_value_factory, Scope* scope, | 2603 AstValueFactory* ast_value_factory, Scope* scope, |
2504 ZoneList<Statement*>* body, int materialized_literal_count, | 2604 ZoneList<Statement*>* body, int materialized_literal_count, |
2505 int expected_property_count, int handler_count, | 2605 int expected_property_count, int handler_count, |
2506 int parameter_count, FunctionType function_type, | 2606 int parameter_count, FunctionType function_type, |
2507 ParameterFlag has_duplicate_parameters, | 2607 ParameterFlag has_duplicate_parameters, |
2508 IsFunctionFlag is_function, | 2608 IsFunctionFlag is_function, |
2509 IsParenthesizedFlag is_parenthesized, FunctionKind kind, | 2609 IsParenthesizedFlag is_parenthesized, FunctionKind kind, |
2510 int position, IdGen* id_gen) | 2610 int position) |
2511 : Expression(zone, position, 0, id_gen), | 2611 : Expression(zone, position), |
2512 raw_name_(name), | 2612 raw_name_(name), |
2513 scope_(scope), | 2613 scope_(scope), |
2514 body_(body), | 2614 body_(body), |
2515 raw_inferred_name_(ast_value_factory->empty_string()), | 2615 raw_inferred_name_(ast_value_factory->empty_string()), |
2516 dont_optimize_reason_(kNoReason), | 2616 dont_optimize_reason_(kNoReason), |
2517 materialized_literal_count_(materialized_literal_count), | 2617 materialized_literal_count_(materialized_literal_count), |
2518 expected_property_count_(expected_property_count), | 2618 expected_property_count_(expected_property_count), |
2519 handler_count_(handler_count), | 2619 handler_count_(handler_count), |
2520 parameter_count_(parameter_count), | 2620 parameter_count_(parameter_count), |
2521 function_token_position_(RelocInfo::kNoPosition) { | 2621 function_token_position_(RelocInfo::kNoPosition) { |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2567 const AstRawString* raw_name() const { return raw_name_; } | 2667 const AstRawString* raw_name() const { return raw_name_; } |
2568 Expression* extends() const { return extends_; } | 2668 Expression* extends() const { return extends_; } |
2569 Expression* constructor() const { return constructor_; } | 2669 Expression* constructor() const { return constructor_; } |
2570 ZoneList<Property*>* properties() const { return properties_; } | 2670 ZoneList<Property*>* properties() const { return properties_; } |
2571 int start_position() const { return position(); } | 2671 int start_position() const { return position(); } |
2572 int end_position() const { return end_position_; } | 2672 int end_position() const { return end_position_; } |
2573 | 2673 |
2574 protected: | 2674 protected: |
2575 ClassLiteral(Zone* zone, const AstRawString* name, Expression* extends, | 2675 ClassLiteral(Zone* zone, const AstRawString* name, Expression* extends, |
2576 Expression* constructor, ZoneList<Property*>* properties, | 2676 Expression* constructor, ZoneList<Property*>* properties, |
2577 int start_position, int end_position, IdGen* id_gen) | 2677 int start_position, int end_position) |
2578 : Expression(zone, start_position, 0, id_gen), | 2678 : Expression(zone, start_position), |
2579 raw_name_(name), | 2679 raw_name_(name), |
2580 extends_(extends), | 2680 extends_(extends), |
2581 constructor_(constructor), | 2681 constructor_(constructor), |
2582 properties_(properties), | 2682 properties_(properties), |
2583 end_position_(end_position) {} | 2683 end_position_(end_position) {} |
2584 | 2684 |
2585 private: | 2685 private: |
2586 const AstRawString* raw_name_; | 2686 const AstRawString* raw_name_; |
2587 Expression* extends_; | 2687 Expression* extends_; |
2588 Expression* constructor_; | 2688 Expression* constructor_; |
2589 ZoneList<Property*>* properties_; | 2689 ZoneList<Property*>* properties_; |
2590 int end_position_; | 2690 int end_position_; |
2591 }; | 2691 }; |
2592 | 2692 |
2593 | 2693 |
2594 class NativeFunctionLiteral FINAL : public Expression { | 2694 class NativeFunctionLiteral FINAL : public Expression { |
2595 public: | 2695 public: |
2596 DECLARE_NODE_TYPE(NativeFunctionLiteral) | 2696 DECLARE_NODE_TYPE(NativeFunctionLiteral) |
2597 | 2697 |
2598 Handle<String> name() const { return name_->string(); } | 2698 Handle<String> name() const { return name_->string(); } |
2599 v8::Extension* extension() const { return extension_; } | 2699 v8::Extension* extension() const { return extension_; } |
2600 | 2700 |
2601 protected: | 2701 protected: |
2602 NativeFunctionLiteral(Zone* zone, const AstRawString* name, | 2702 NativeFunctionLiteral(Zone* zone, const AstRawString* name, |
2603 v8::Extension* extension, int pos, IdGen* id_gen) | 2703 v8::Extension* extension, int pos) |
2604 : Expression(zone, pos, 0, id_gen), name_(name), extension_(extension) {} | 2704 : Expression(zone, pos), name_(name), extension_(extension) {} |
2605 | 2705 |
2606 private: | 2706 private: |
2607 const AstRawString* name_; | 2707 const AstRawString* name_; |
2608 v8::Extension* extension_; | 2708 v8::Extension* extension_; |
2609 }; | 2709 }; |
2610 | 2710 |
2611 | 2711 |
2612 class ThisFunction FINAL : public Expression { | 2712 class ThisFunction FINAL : public Expression { |
2613 public: | 2713 public: |
2614 DECLARE_NODE_TYPE(ThisFunction) | 2714 DECLARE_NODE_TYPE(ThisFunction) |
2615 | 2715 |
2616 protected: | 2716 protected: |
2617 ThisFunction(Zone* zone, int pos, IdGen* id_gen) | 2717 ThisFunction(Zone* zone, int pos) : Expression(zone, pos) {} |
2618 : Expression(zone, pos, 0, id_gen) {} | |
2619 }; | 2718 }; |
2620 | 2719 |
2621 | 2720 |
2622 class SuperReference FINAL : public Expression { | 2721 class SuperReference FINAL : public Expression { |
2623 public: | 2722 public: |
2624 DECLARE_NODE_TYPE(SuperReference) | 2723 DECLARE_NODE_TYPE(SuperReference) |
2625 | 2724 |
2626 VariableProxy* this_var() const { return this_var_; } | 2725 VariableProxy* this_var() const { return this_var_; } |
2627 | 2726 |
2628 TypeFeedbackId HomeObjectFeedbackId() { | 2727 TypeFeedbackId HomeObjectFeedbackId() { |
2629 return TypeFeedbackId(base_id() + 0); | 2728 return TypeFeedbackId(base_id() + 0); |
2630 } | 2729 } |
2631 | 2730 |
2731 void AllocateBailoutIdRange(IdGen* id_gen) { | |
2732 InitializeBaseBailoutId(kBailoutIdCount, id_gen); | |
2733 } | |
2734 | |
2632 // Type feedback information. | 2735 // Type feedback information. |
2633 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } | 2736 virtual int ComputeFeedbackSlotCount() { return FLAG_vector_ics ? 1 : 0; } |
2634 virtual void SetFirstFeedbackSlot(int slot) { | 2737 virtual void SetFirstFeedbackSlot(int slot) { |
2635 homeobject_feedback_slot_ = slot; | 2738 homeobject_feedback_slot_ = slot; |
2636 } | 2739 } |
2637 | 2740 |
2638 int HomeObjectFeedbackSlot() { | 2741 int HomeObjectFeedbackSlot() { |
2639 DCHECK(!FLAG_vector_ics || | 2742 DCHECK(!FLAG_vector_ics || |
2640 homeobject_feedback_slot_ != kInvalidFeedbackSlot); | 2743 homeobject_feedback_slot_ != kInvalidFeedbackSlot); |
2641 return homeobject_feedback_slot_; | 2744 return homeobject_feedback_slot_; |
2642 } | 2745 } |
2643 | 2746 |
2644 protected: | 2747 protected: |
2645 SuperReference(Zone* zone, VariableProxy* this_var, int pos, IdGen* id_gen) | 2748 SuperReference(Zone* zone, VariableProxy* this_var, int pos) |
2646 : Expression(zone, pos, num_ids(), id_gen), | 2749 : Expression(zone, pos), |
2647 this_var_(this_var), | 2750 this_var_(this_var), |
2648 homeobject_feedback_slot_(kInvalidFeedbackSlot) { | 2751 homeobject_feedback_slot_(kInvalidFeedbackSlot) { |
2649 DCHECK(this_var->is_this()); | 2752 DCHECK(this_var->is_this()); |
2650 } | 2753 } |
2651 | 2754 |
2652 static int num_ids() { return 1; } | 2755 int base_id() const { return leaf_base_id(); } |
2653 int base_id() const { return Expression::base_id() + Expression::num_ids(); } | 2756 static const int kBailoutIdCount = Expression::kBailoutIdCount + 1; |
2654 | 2757 |
2655 private: | 2758 private: |
2656 VariableProxy* this_var_; | 2759 VariableProxy* this_var_; |
2657 int homeobject_feedback_slot_; | 2760 int homeobject_feedback_slot_; |
2658 }; | 2761 }; |
2659 | 2762 |
2660 | 2763 |
2661 #undef DECLARE_NODE_TYPE | 2764 #undef DECLARE_NODE_TYPE |
2662 | 2765 |
2663 | 2766 |
(...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3141 }; | 3244 }; |
3142 | 3245 |
3143 | 3246 |
3144 | 3247 |
3145 // ---------------------------------------------------------------------------- | 3248 // ---------------------------------------------------------------------------- |
3146 // AstNode factory | 3249 // AstNode factory |
3147 | 3250 |
3148 template<class Visitor> | 3251 template<class Visitor> |
3149 class AstNodeFactory FINAL BASE_EMBEDDED { | 3252 class AstNodeFactory FINAL BASE_EMBEDDED { |
3150 public: | 3253 public: |
3151 AstNodeFactory(Zone* zone, AstValueFactory* ast_value_factory, | 3254 AstNodeFactory(Zone* zone, AstValueFactory* ast_value_factory) |
3152 AstNode::IdGen* id_gen) | 3255 : zone_(zone), ast_value_factory_(ast_value_factory) {} |
3153 : zone_(zone), ast_value_factory_(ast_value_factory), id_gen_(id_gen) {} | |
3154 | 3256 |
3155 Visitor* visitor() { return &visitor_; } | 3257 Visitor* visitor() { return &visitor_; } |
3156 | 3258 |
3157 #define VISIT_AND_RETURN(NodeType, node) \ | 3259 #define VISIT_AND_RETURN(NodeType, node) \ |
3158 visitor_.Visit##NodeType((node)); \ | 3260 visitor_.Visit##NodeType((node)); \ |
3159 return node; | 3261 return node; |
3160 | 3262 |
3161 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, | 3263 VariableDeclaration* NewVariableDeclaration(VariableProxy* proxy, |
3162 VariableMode mode, | 3264 VariableMode mode, |
3163 Scope* scope, | 3265 Scope* scope, |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3221 | 3323 |
3222 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) { | 3324 ModuleUrl* NewModuleUrl(Handle<String> url, int pos) { |
3223 ModuleUrl* module = new(zone_) ModuleUrl(zone_, url, pos); | 3325 ModuleUrl* module = new(zone_) ModuleUrl(zone_, url, pos); |
3224 VISIT_AND_RETURN(ModuleUrl, module) | 3326 VISIT_AND_RETURN(ModuleUrl, module) |
3225 } | 3327 } |
3226 | 3328 |
3227 Block* NewBlock(ZoneList<const AstRawString*>* labels, | 3329 Block* NewBlock(ZoneList<const AstRawString*>* labels, |
3228 int capacity, | 3330 int capacity, |
3229 bool is_initializer_block, | 3331 bool is_initializer_block, |
3230 int pos) { | 3332 int pos) { |
3231 Block* block = new (zone_) | 3333 Block* block = |
3232 Block(zone_, labels, capacity, is_initializer_block, pos, id_gen_); | 3334 new (zone_) Block(zone_, labels, capacity, is_initializer_block, pos); |
3233 VISIT_AND_RETURN(Block, block) | 3335 VISIT_AND_RETURN(Block, block) |
3234 } | 3336 } |
3235 | 3337 |
3236 #define STATEMENT_WITH_LABELS(NodeType) \ | 3338 #define STATEMENT_WITH_LABELS(NodeType) \ |
3237 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ | 3339 NodeType* New##NodeType(ZoneList<const AstRawString*>* labels, int pos) { \ |
3238 NodeType* stmt = new (zone_) NodeType(zone_, labels, pos, id_gen_); \ | 3340 NodeType* stmt = new (zone_) NodeType(zone_, labels, pos); \ |
3239 VISIT_AND_RETURN(NodeType, stmt); \ | 3341 VISIT_AND_RETURN(NodeType, stmt); \ |
3240 } | 3342 } |
3241 STATEMENT_WITH_LABELS(DoWhileStatement) | 3343 STATEMENT_WITH_LABELS(DoWhileStatement) |
3242 STATEMENT_WITH_LABELS(WhileStatement) | 3344 STATEMENT_WITH_LABELS(WhileStatement) |
3243 STATEMENT_WITH_LABELS(ForStatement) | 3345 STATEMENT_WITH_LABELS(ForStatement) |
3244 STATEMENT_WITH_LABELS(SwitchStatement) | 3346 STATEMENT_WITH_LABELS(SwitchStatement) |
3245 #undef STATEMENT_WITH_LABELS | 3347 #undef STATEMENT_WITH_LABELS |
3246 | 3348 |
3247 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, | 3349 ForEachStatement* NewForEachStatement(ForEachStatement::VisitMode visit_mode, |
3248 ZoneList<const AstRawString*>* labels, | 3350 ZoneList<const AstRawString*>* labels, |
3249 int pos) { | 3351 int pos) { |
3250 switch (visit_mode) { | 3352 switch (visit_mode) { |
3251 case ForEachStatement::ENUMERATE: { | 3353 case ForEachStatement::ENUMERATE: { |
3252 ForInStatement* stmt = | 3354 ForInStatement* stmt = new (zone_) ForInStatement(zone_, labels, pos); |
3253 new (zone_) ForInStatement(zone_, labels, pos, id_gen_); | |
3254 VISIT_AND_RETURN(ForInStatement, stmt); | 3355 VISIT_AND_RETURN(ForInStatement, stmt); |
3255 } | 3356 } |
3256 case ForEachStatement::ITERATE: { | 3357 case ForEachStatement::ITERATE: { |
3257 ForOfStatement* stmt = | 3358 ForOfStatement* stmt = new (zone_) ForOfStatement(zone_, labels, pos); |
3258 new (zone_) ForOfStatement(zone_, labels, pos, id_gen_); | |
3259 VISIT_AND_RETURN(ForOfStatement, stmt); | 3359 VISIT_AND_RETURN(ForOfStatement, stmt); |
3260 } | 3360 } |
3261 } | 3361 } |
3262 UNREACHABLE(); | 3362 UNREACHABLE(); |
3263 return NULL; | 3363 return NULL; |
3264 } | 3364 } |
3265 | 3365 |
3266 ModuleStatement* NewModuleStatement( | 3366 ModuleStatement* NewModuleStatement( |
3267 VariableProxy* proxy, Block* body, int pos) { | 3367 VariableProxy* proxy, Block* body, int pos) { |
3268 ModuleStatement* stmt = new(zone_) ModuleStatement(zone_, proxy, body, pos); | 3368 ModuleStatement* stmt = new(zone_) ModuleStatement(zone_, proxy, body, pos); |
(...skipping 27 matching lines...) Expand all Loading... | |
3296 int pos) { | 3396 int pos) { |
3297 WithStatement* stmt = new(zone_) WithStatement( | 3397 WithStatement* stmt = new(zone_) WithStatement( |
3298 zone_, scope, expression, statement, pos); | 3398 zone_, scope, expression, statement, pos); |
3299 VISIT_AND_RETURN(WithStatement, stmt) | 3399 VISIT_AND_RETURN(WithStatement, stmt) |
3300 } | 3400 } |
3301 | 3401 |
3302 IfStatement* NewIfStatement(Expression* condition, | 3402 IfStatement* NewIfStatement(Expression* condition, |
3303 Statement* then_statement, | 3403 Statement* then_statement, |
3304 Statement* else_statement, | 3404 Statement* else_statement, |
3305 int pos) { | 3405 int pos) { |
3306 IfStatement* stmt = new (zone_) IfStatement( | 3406 IfStatement* stmt = new (zone_) |
3307 zone_, condition, then_statement, else_statement, pos, id_gen_); | 3407 IfStatement(zone_, condition, then_statement, else_statement, pos); |
3308 VISIT_AND_RETURN(IfStatement, stmt) | 3408 VISIT_AND_RETURN(IfStatement, stmt) |
3309 } | 3409 } |
3310 | 3410 |
3311 TryCatchStatement* NewTryCatchStatement(int index, | 3411 TryCatchStatement* NewTryCatchStatement(int index, |
3312 Block* try_block, | 3412 Block* try_block, |
3313 Scope* scope, | 3413 Scope* scope, |
3314 Variable* variable, | 3414 Variable* variable, |
3315 Block* catch_block, | 3415 Block* catch_block, |
3316 int pos) { | 3416 int pos) { |
3317 TryCatchStatement* stmt = new(zone_) TryCatchStatement( | 3417 TryCatchStatement* stmt = new(zone_) TryCatchStatement( |
3318 zone_, index, try_block, scope, variable, catch_block, pos); | 3418 zone_, index, try_block, scope, variable, catch_block, pos); |
3319 VISIT_AND_RETURN(TryCatchStatement, stmt) | 3419 VISIT_AND_RETURN(TryCatchStatement, stmt) |
3320 } | 3420 } |
3321 | 3421 |
3322 TryFinallyStatement* NewTryFinallyStatement(int index, | 3422 TryFinallyStatement* NewTryFinallyStatement(int index, |
3323 Block* try_block, | 3423 Block* try_block, |
3324 Block* finally_block, | 3424 Block* finally_block, |
3325 int pos) { | 3425 int pos) { |
3326 TryFinallyStatement* stmt = new(zone_) TryFinallyStatement( | 3426 TryFinallyStatement* stmt = new(zone_) TryFinallyStatement( |
3327 zone_, index, try_block, finally_block, pos); | 3427 zone_, index, try_block, finally_block, pos); |
3328 VISIT_AND_RETURN(TryFinallyStatement, stmt) | 3428 VISIT_AND_RETURN(TryFinallyStatement, stmt) |
3329 } | 3429 } |
3330 | 3430 |
3331 DebuggerStatement* NewDebuggerStatement(int pos) { | 3431 DebuggerStatement* NewDebuggerStatement(int pos) { |
3332 DebuggerStatement* stmt = | 3432 DebuggerStatement* stmt = new (zone_) DebuggerStatement(zone_, pos); |
3333 new (zone_) DebuggerStatement(zone_, pos, id_gen_); | |
3334 VISIT_AND_RETURN(DebuggerStatement, stmt) | 3433 VISIT_AND_RETURN(DebuggerStatement, stmt) |
3335 } | 3434 } |
3336 | 3435 |
3337 EmptyStatement* NewEmptyStatement(int pos) { | 3436 EmptyStatement* NewEmptyStatement(int pos) { |
3338 return new(zone_) EmptyStatement(zone_, pos); | 3437 return new(zone_) EmptyStatement(zone_, pos); |
3339 } | 3438 } |
3340 | 3439 |
3341 CaseClause* NewCaseClause( | 3440 CaseClause* NewCaseClause( |
3342 Expression* label, ZoneList<Statement*>* statements, int pos) { | 3441 Expression* label, ZoneList<Statement*>* statements, int pos) { |
3343 CaseClause* clause = | 3442 CaseClause* clause = new (zone_) CaseClause(zone_, label, statements, pos); |
3344 new (zone_) CaseClause(zone_, label, statements, pos, id_gen_); | |
3345 VISIT_AND_RETURN(CaseClause, clause) | 3443 VISIT_AND_RETURN(CaseClause, clause) |
3346 } | 3444 } |
3347 | 3445 |
3348 Literal* NewStringLiteral(const AstRawString* string, int pos) { | 3446 Literal* NewStringLiteral(const AstRawString* string, int pos) { |
3349 Literal* lit = new (zone_) | 3447 Literal* lit = |
3350 Literal(zone_, ast_value_factory_->NewString(string), pos, id_gen_); | 3448 new (zone_) Literal(zone_, ast_value_factory_->NewString(string), pos); |
3351 VISIT_AND_RETURN(Literal, lit) | 3449 VISIT_AND_RETURN(Literal, lit) |
3352 } | 3450 } |
3353 | 3451 |
3354 // A JavaScript symbol (ECMA-262 edition 6). | 3452 // A JavaScript symbol (ECMA-262 edition 6). |
3355 Literal* NewSymbolLiteral(const char* name, int pos) { | 3453 Literal* NewSymbolLiteral(const char* name, int pos) { |
3356 Literal* lit = new (zone_) | 3454 Literal* lit = |
3357 Literal(zone_, ast_value_factory_->NewSymbol(name), pos, id_gen_); | 3455 new (zone_) Literal(zone_, ast_value_factory_->NewSymbol(name), pos); |
3358 VISIT_AND_RETURN(Literal, lit) | 3456 VISIT_AND_RETURN(Literal, lit) |
3359 } | 3457 } |
3360 | 3458 |
3361 Literal* NewNumberLiteral(double number, int pos) { | 3459 Literal* NewNumberLiteral(double number, int pos) { |
3362 Literal* lit = new (zone_) | 3460 Literal* lit = |
3363 Literal(zone_, ast_value_factory_->NewNumber(number), pos, id_gen_); | 3461 new (zone_) Literal(zone_, ast_value_factory_->NewNumber(number), pos); |
3364 VISIT_AND_RETURN(Literal, lit) | 3462 VISIT_AND_RETURN(Literal, lit) |
3365 } | 3463 } |
3366 | 3464 |
3367 Literal* NewSmiLiteral(int number, int pos) { | 3465 Literal* NewSmiLiteral(int number, int pos) { |
3368 Literal* lit = new (zone_) | 3466 Literal* lit = |
3369 Literal(zone_, ast_value_factory_->NewSmi(number), pos, id_gen_); | 3467 new (zone_) Literal(zone_, ast_value_factory_->NewSmi(number), pos); |
3370 VISIT_AND_RETURN(Literal, lit) | 3468 VISIT_AND_RETURN(Literal, lit) |
3371 } | 3469 } |
3372 | 3470 |
3373 Literal* NewBooleanLiteral(bool b, int pos) { | 3471 Literal* NewBooleanLiteral(bool b, int pos) { |
3374 Literal* lit = new (zone_) | 3472 Literal* lit = |
3375 Literal(zone_, ast_value_factory_->NewBoolean(b), pos, id_gen_); | 3473 new (zone_) Literal(zone_, ast_value_factory_->NewBoolean(b), pos); |
3376 VISIT_AND_RETURN(Literal, lit) | 3474 VISIT_AND_RETURN(Literal, lit) |
3377 } | 3475 } |
3378 | 3476 |
3379 Literal* NewStringListLiteral(ZoneList<const AstRawString*>* strings, | 3477 Literal* NewStringListLiteral(ZoneList<const AstRawString*>* strings, |
3380 int pos) { | 3478 int pos) { |
3381 Literal* lit = new (zone_) Literal( | 3479 Literal* lit = new (zone_) |
3382 zone_, ast_value_factory_->NewStringList(strings), pos, id_gen_); | 3480 Literal(zone_, ast_value_factory_->NewStringList(strings), pos); |
3383 VISIT_AND_RETURN(Literal, lit) | 3481 VISIT_AND_RETURN(Literal, lit) |
3384 } | 3482 } |
3385 | 3483 |
3386 Literal* NewNullLiteral(int pos) { | 3484 Literal* NewNullLiteral(int pos) { |
3387 Literal* lit = | 3485 Literal* lit = |
3388 new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos, id_gen_); | 3486 new (zone_) Literal(zone_, ast_value_factory_->NewNull(), pos); |
3389 VISIT_AND_RETURN(Literal, lit) | 3487 VISIT_AND_RETURN(Literal, lit) |
3390 } | 3488 } |
3391 | 3489 |
3392 Literal* NewUndefinedLiteral(int pos) { | 3490 Literal* NewUndefinedLiteral(int pos) { |
3393 Literal* lit = new (zone_) | 3491 Literal* lit = |
3394 Literal(zone_, ast_value_factory_->NewUndefined(), pos, id_gen_); | 3492 new (zone_) Literal(zone_, ast_value_factory_->NewUndefined(), pos); |
3395 VISIT_AND_RETURN(Literal, lit) | 3493 VISIT_AND_RETURN(Literal, lit) |
3396 } | 3494 } |
3397 | 3495 |
3398 Literal* NewTheHoleLiteral(int pos) { | 3496 Literal* NewTheHoleLiteral(int pos) { |
3399 Literal* lit = new (zone_) | 3497 Literal* lit = |
3400 Literal(zone_, ast_value_factory_->NewTheHole(), pos, id_gen_); | 3498 new (zone_) Literal(zone_, ast_value_factory_->NewTheHole(), pos); |
3401 VISIT_AND_RETURN(Literal, lit) | 3499 VISIT_AND_RETURN(Literal, lit) |
3402 } | 3500 } |
3403 | 3501 |
3404 ObjectLiteral* NewObjectLiteral( | 3502 ObjectLiteral* NewObjectLiteral( |
3405 ZoneList<ObjectLiteral::Property*>* properties, | 3503 ZoneList<ObjectLiteral::Property*>* properties, |
3406 int literal_index, | 3504 int literal_index, |
3407 int boilerplate_properties, | 3505 int boilerplate_properties, |
3408 bool has_function, | 3506 bool has_function, |
3409 int pos) { | 3507 int pos) { |
3410 ObjectLiteral* lit = new (zone_) | 3508 ObjectLiteral* lit = |
3411 ObjectLiteral(zone_, properties, literal_index, boilerplate_properties, | 3509 new (zone_) ObjectLiteral(zone_, properties, literal_index, |
3412 has_function, pos, id_gen_); | 3510 boilerplate_properties, has_function, pos); |
3413 VISIT_AND_RETURN(ObjectLiteral, lit) | 3511 VISIT_AND_RETURN(ObjectLiteral, lit) |
3414 } | 3512 } |
3415 | 3513 |
3416 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key, | 3514 ObjectLiteral::Property* NewObjectLiteralProperty(Literal* key, |
3417 Expression* value, | 3515 Expression* value, |
3418 bool is_static) { | 3516 bool is_static) { |
3419 return new (zone_) ObjectLiteral::Property(zone_, ast_value_factory_, key, | 3517 return new (zone_) ObjectLiteral::Property(zone_, ast_value_factory_, key, |
3420 value, is_static); | 3518 value, is_static); |
3421 } | 3519 } |
3422 | 3520 |
3423 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, | 3521 ObjectLiteral::Property* NewObjectLiteralProperty(bool is_getter, |
3424 FunctionLiteral* value, | 3522 FunctionLiteral* value, |
3425 int pos, bool is_static) { | 3523 int pos, bool is_static) { |
3426 ObjectLiteral::Property* prop = | 3524 ObjectLiteral::Property* prop = |
3427 new (zone_) ObjectLiteral::Property(zone_, is_getter, value, is_static); | 3525 new (zone_) ObjectLiteral::Property(zone_, is_getter, value, is_static); |
3428 prop->set_key(NewStringLiteral(value->raw_name(), pos)); | 3526 prop->set_key(NewStringLiteral(value->raw_name(), pos)); |
3429 return prop; // Not an AST node, will not be visited. | 3527 return prop; // Not an AST node, will not be visited. |
3430 } | 3528 } |
3431 | 3529 |
3432 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, | 3530 RegExpLiteral* NewRegExpLiteral(const AstRawString* pattern, |
3433 const AstRawString* flags, | 3531 const AstRawString* flags, |
3434 int literal_index, | 3532 int literal_index, |
3435 int pos) { | 3533 int pos) { |
3436 RegExpLiteral* lit = new (zone_) | 3534 RegExpLiteral* lit = |
3437 RegExpLiteral(zone_, pattern, flags, literal_index, pos, id_gen_); | 3535 new (zone_) RegExpLiteral(zone_, pattern, flags, literal_index, pos); |
3438 VISIT_AND_RETURN(RegExpLiteral, lit); | 3536 VISIT_AND_RETURN(RegExpLiteral, lit); |
3439 } | 3537 } |
3440 | 3538 |
3441 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, | 3539 ArrayLiteral* NewArrayLiteral(ZoneList<Expression*>* values, |
3442 int literal_index, | 3540 int literal_index, |
3443 int pos) { | 3541 int pos) { |
3444 ArrayLiteral* lit = | 3542 ArrayLiteral* lit = |
3445 new (zone_) ArrayLiteral(zone_, values, literal_index, pos, id_gen_); | 3543 new (zone_) ArrayLiteral(zone_, values, literal_index, pos); |
3446 VISIT_AND_RETURN(ArrayLiteral, lit) | 3544 VISIT_AND_RETURN(ArrayLiteral, lit) |
3447 } | 3545 } |
3448 | 3546 |
3449 VariableProxy* NewVariableProxy(Variable* var, | 3547 VariableProxy* NewVariableProxy(Variable* var, |
3450 int pos = RelocInfo::kNoPosition) { | 3548 int pos = RelocInfo::kNoPosition) { |
3451 VariableProxy* proxy = new (zone_) VariableProxy(zone_, var, pos, id_gen_); | 3549 VariableProxy* proxy = new (zone_) VariableProxy(zone_, var, pos); |
3452 VISIT_AND_RETURN(VariableProxy, proxy) | 3550 VISIT_AND_RETURN(VariableProxy, proxy) |
3453 } | 3551 } |
3454 | 3552 |
3455 VariableProxy* NewVariableProxy(const AstRawString* name, | 3553 VariableProxy* NewVariableProxy(const AstRawString* name, |
3456 bool is_this, | 3554 bool is_this, |
3457 Interface* interface = Interface::NewValue(), | 3555 Interface* interface = Interface::NewValue(), |
3458 int position = RelocInfo::kNoPosition) { | 3556 int position = RelocInfo::kNoPosition) { |
3459 VariableProxy* proxy = new (zone_) | 3557 VariableProxy* proxy = |
3460 VariableProxy(zone_, name, is_this, interface, position, id_gen_); | 3558 new (zone_) VariableProxy(zone_, name, is_this, interface, position); |
3461 VISIT_AND_RETURN(VariableProxy, proxy) | 3559 VISIT_AND_RETURN(VariableProxy, proxy) |
3462 } | 3560 } |
3463 | 3561 |
3464 Property* NewProperty(Expression* obj, Expression* key, int pos) { | 3562 Property* NewProperty(Expression* obj, Expression* key, int pos) { |
3465 Property* prop = new (zone_) Property(zone_, obj, key, pos, id_gen_); | 3563 Property* prop = new (zone_) Property(zone_, obj, key, pos); |
3466 VISIT_AND_RETURN(Property, prop) | 3564 VISIT_AND_RETURN(Property, prop) |
3467 } | 3565 } |
3468 | 3566 |
3469 Call* NewCall(Expression* expression, | 3567 Call* NewCall(Expression* expression, |
3470 ZoneList<Expression*>* arguments, | 3568 ZoneList<Expression*>* arguments, |
3471 int pos) { | 3569 int pos) { |
3472 SuperReference* super_ref = expression->AsSuperReference(); | 3570 SuperReference* super_ref = expression->AsSuperReference(); |
3473 Call* call; | 3571 Call* call; |
3474 if (super_ref != NULL) { | 3572 if (super_ref != NULL) { |
3475 Literal* constructor = | 3573 Literal* constructor = |
3476 NewStringLiteral(ast_value_factory_->constructor_string(), pos); | 3574 NewStringLiteral(ast_value_factory_->constructor_string(), pos); |
3477 Property* superConstructor = NewProperty(super_ref, constructor, pos); | 3575 Property* superConstructor = NewProperty(super_ref, constructor, pos); |
3478 call = new (zone_) Call(zone_, superConstructor, arguments, pos, id_gen_); | 3576 call = new (zone_) Call(zone_, superConstructor, arguments, pos); |
3479 } else { | 3577 } else { |
3480 call = new (zone_) Call(zone_, expression, arguments, pos, id_gen_); | 3578 call = new (zone_) Call(zone_, expression, arguments, pos); |
3481 } | 3579 } |
3482 VISIT_AND_RETURN(Call, call) | 3580 VISIT_AND_RETURN(Call, call) |
3483 } | 3581 } |
3484 | 3582 |
3485 CallNew* NewCallNew(Expression* expression, | 3583 CallNew* NewCallNew(Expression* expression, |
3486 ZoneList<Expression*>* arguments, | 3584 ZoneList<Expression*>* arguments, |
3487 int pos) { | 3585 int pos) { |
3488 CallNew* call = | 3586 CallNew* call = new (zone_) CallNew(zone_, expression, arguments, pos); |
3489 new (zone_) CallNew(zone_, expression, arguments, pos, id_gen_); | |
3490 VISIT_AND_RETURN(CallNew, call) | 3587 VISIT_AND_RETURN(CallNew, call) |
3491 } | 3588 } |
3492 | 3589 |
3493 CallRuntime* NewCallRuntime(const AstRawString* name, | 3590 CallRuntime* NewCallRuntime(const AstRawString* name, |
3494 const Runtime::Function* function, | 3591 const Runtime::Function* function, |
3495 ZoneList<Expression*>* arguments, | 3592 ZoneList<Expression*>* arguments, |
3496 int pos) { | 3593 int pos) { |
3497 CallRuntime* call = | 3594 CallRuntime* call = |
3498 new (zone_) CallRuntime(zone_, name, function, arguments, pos, id_gen_); | 3595 new (zone_) CallRuntime(zone_, name, function, arguments, pos); |
3499 VISIT_AND_RETURN(CallRuntime, call) | 3596 VISIT_AND_RETURN(CallRuntime, call) |
3500 } | 3597 } |
3501 | 3598 |
3502 UnaryOperation* NewUnaryOperation(Token::Value op, | 3599 UnaryOperation* NewUnaryOperation(Token::Value op, |
3503 Expression* expression, | 3600 Expression* expression, |
3504 int pos) { | 3601 int pos) { |
3505 UnaryOperation* node = | 3602 UnaryOperation* node = |
3506 new (zone_) UnaryOperation(zone_, op, expression, pos, id_gen_); | 3603 new (zone_) UnaryOperation(zone_, op, expression, pos); |
3507 VISIT_AND_RETURN(UnaryOperation, node) | 3604 VISIT_AND_RETURN(UnaryOperation, node) |
3508 } | 3605 } |
3509 | 3606 |
3510 BinaryOperation* NewBinaryOperation(Token::Value op, | 3607 BinaryOperation* NewBinaryOperation(Token::Value op, |
3511 Expression* left, | 3608 Expression* left, |
3512 Expression* right, | 3609 Expression* right, |
3513 int pos) { | 3610 int pos) { |
3514 BinaryOperation* node = | 3611 BinaryOperation* node = |
3515 new (zone_) BinaryOperation(zone_, op, left, right, pos, id_gen_); | 3612 new (zone_) BinaryOperation(zone_, op, left, right, pos); |
3516 VISIT_AND_RETURN(BinaryOperation, node) | 3613 VISIT_AND_RETURN(BinaryOperation, node) |
3517 } | 3614 } |
3518 | 3615 |
3519 CountOperation* NewCountOperation(Token::Value op, | 3616 CountOperation* NewCountOperation(Token::Value op, |
3520 bool is_prefix, | 3617 bool is_prefix, |
3521 Expression* expr, | 3618 Expression* expr, |
3522 int pos) { | 3619 int pos) { |
3523 CountOperation* node = | 3620 CountOperation* node = |
3524 new (zone_) CountOperation(zone_, op, is_prefix, expr, pos, id_gen_); | 3621 new (zone_) CountOperation(zone_, op, is_prefix, expr, pos); |
3525 VISIT_AND_RETURN(CountOperation, node) | 3622 VISIT_AND_RETURN(CountOperation, node) |
3526 } | 3623 } |
3527 | 3624 |
3528 CompareOperation* NewCompareOperation(Token::Value op, | 3625 CompareOperation* NewCompareOperation(Token::Value op, |
3529 Expression* left, | 3626 Expression* left, |
3530 Expression* right, | 3627 Expression* right, |
3531 int pos) { | 3628 int pos) { |
3532 CompareOperation* node = | 3629 CompareOperation* node = |
3533 new (zone_) CompareOperation(zone_, op, left, right, pos, id_gen_); | 3630 new (zone_) CompareOperation(zone_, op, left, right, pos); |
3534 VISIT_AND_RETURN(CompareOperation, node) | 3631 VISIT_AND_RETURN(CompareOperation, node) |
3535 } | 3632 } |
3536 | 3633 |
3537 Conditional* NewConditional(Expression* condition, | 3634 Conditional* NewConditional(Expression* condition, |
3538 Expression* then_expression, | 3635 Expression* then_expression, |
3539 Expression* else_expression, | 3636 Expression* else_expression, |
3540 int position) { | 3637 int position) { |
3541 Conditional* cond = new (zone_) Conditional( | 3638 Conditional* cond = new (zone_) Conditional( |
3542 zone_, condition, then_expression, else_expression, position, id_gen_); | 3639 zone_, condition, then_expression, else_expression, position); |
3543 VISIT_AND_RETURN(Conditional, cond) | 3640 VISIT_AND_RETURN(Conditional, cond) |
3544 } | 3641 } |
3545 | 3642 |
3546 Assignment* NewAssignment(Token::Value op, | 3643 Assignment* NewAssignment(Token::Value op, |
3547 Expression* target, | 3644 Expression* target, |
3548 Expression* value, | 3645 Expression* value, |
3549 int pos) { | 3646 int pos) { |
3550 Assignment* assign = | 3647 Assignment* assign = new (zone_) Assignment(zone_, op, target, value, pos); |
3551 new (zone_) Assignment(zone_, op, target, value, pos, id_gen_); | |
3552 assign->Init(zone_, this); | 3648 assign->Init(zone_, this); |
3553 VISIT_AND_RETURN(Assignment, assign) | 3649 VISIT_AND_RETURN(Assignment, assign) |
3554 } | 3650 } |
3555 | 3651 |
3556 Yield* NewYield(Expression *generator_object, | 3652 Yield* NewYield(Expression *generator_object, |
3557 Expression* expression, | 3653 Expression* expression, |
3558 Yield::Kind yield_kind, | 3654 Yield::Kind yield_kind, |
3559 int pos) { | 3655 int pos) { |
3560 if (!expression) expression = NewUndefinedLiteral(pos); | 3656 if (!expression) expression = NewUndefinedLiteral(pos); |
3561 Yield* yield = new (zone_) | 3657 Yield* yield = |
3562 Yield(zone_, generator_object, expression, yield_kind, pos, id_gen_); | 3658 new (zone_) Yield(zone_, generator_object, expression, yield_kind, pos); |
3563 VISIT_AND_RETURN(Yield, yield) | 3659 VISIT_AND_RETURN(Yield, yield) |
3564 } | 3660 } |
3565 | 3661 |
3566 Throw* NewThrow(Expression* exception, int pos) { | 3662 Throw* NewThrow(Expression* exception, int pos) { |
3567 Throw* t = new (zone_) Throw(zone_, exception, pos, id_gen_); | 3663 Throw* t = new (zone_) Throw(zone_, exception, pos); |
3568 VISIT_AND_RETURN(Throw, t) | 3664 VISIT_AND_RETURN(Throw, t) |
3569 } | 3665 } |
3570 | 3666 |
3571 FunctionLiteral* NewFunctionLiteral( | 3667 FunctionLiteral* NewFunctionLiteral( |
3572 const AstRawString* name, AstValueFactory* ast_value_factory, | 3668 const AstRawString* name, AstValueFactory* ast_value_factory, |
3573 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, | 3669 Scope* scope, ZoneList<Statement*>* body, int materialized_literal_count, |
3574 int expected_property_count, int handler_count, int parameter_count, | 3670 int expected_property_count, int handler_count, int parameter_count, |
3575 FunctionLiteral::ParameterFlag has_duplicate_parameters, | 3671 FunctionLiteral::ParameterFlag has_duplicate_parameters, |
3576 FunctionLiteral::FunctionType function_type, | 3672 FunctionLiteral::FunctionType function_type, |
3577 FunctionLiteral::IsFunctionFlag is_function, | 3673 FunctionLiteral::IsFunctionFlag is_function, |
3578 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind, | 3674 FunctionLiteral::IsParenthesizedFlag is_parenthesized, FunctionKind kind, |
3579 int position) { | 3675 int position) { |
3580 FunctionLiteral* lit = new (zone_) FunctionLiteral( | 3676 FunctionLiteral* lit = new (zone_) FunctionLiteral( |
3581 zone_, name, ast_value_factory, scope, body, materialized_literal_count, | 3677 zone_, name, ast_value_factory, scope, body, materialized_literal_count, |
3582 expected_property_count, handler_count, parameter_count, function_type, | 3678 expected_property_count, handler_count, parameter_count, function_type, |
3583 has_duplicate_parameters, is_function, is_parenthesized, kind, position, | 3679 has_duplicate_parameters, is_function, is_parenthesized, kind, |
3584 id_gen_); | 3680 position); |
3585 // Top-level literal doesn't count for the AST's properties. | 3681 // Top-level literal doesn't count for the AST's properties. |
3586 if (is_function == FunctionLiteral::kIsFunction) { | 3682 if (is_function == FunctionLiteral::kIsFunction) { |
3587 visitor_.VisitFunctionLiteral(lit); | 3683 visitor_.VisitFunctionLiteral(lit); |
3588 } | 3684 } |
3589 return lit; | 3685 return lit; |
3590 } | 3686 } |
3591 | 3687 |
3592 ClassLiteral* NewClassLiteral(const AstRawString* name, Expression* extends, | 3688 ClassLiteral* NewClassLiteral(const AstRawString* name, Expression* extends, |
3593 Expression* constructor, | 3689 Expression* constructor, |
3594 ZoneList<ObjectLiteral::Property*>* properties, | 3690 ZoneList<ObjectLiteral::Property*>* properties, |
3595 int start_position, int end_position) { | 3691 int start_position, int end_position) { |
3596 ClassLiteral* lit = | 3692 ClassLiteral* lit = |
3597 new (zone_) ClassLiteral(zone_, name, extends, constructor, properties, | 3693 new (zone_) ClassLiteral(zone_, name, extends, constructor, properties, |
3598 start_position, end_position, id_gen_); | 3694 start_position, end_position); |
3599 VISIT_AND_RETURN(ClassLiteral, lit) | 3695 VISIT_AND_RETURN(ClassLiteral, lit) |
3600 } | 3696 } |
3601 | 3697 |
3602 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, | 3698 NativeFunctionLiteral* NewNativeFunctionLiteral(const AstRawString* name, |
3603 v8::Extension* extension, | 3699 v8::Extension* extension, |
3604 int pos) { | 3700 int pos) { |
3605 NativeFunctionLiteral* lit = | 3701 NativeFunctionLiteral* lit = |
3606 new (zone_) NativeFunctionLiteral(zone_, name, extension, pos, id_gen_); | 3702 new (zone_) NativeFunctionLiteral(zone_, name, extension, pos); |
3607 VISIT_AND_RETURN(NativeFunctionLiteral, lit) | 3703 VISIT_AND_RETURN(NativeFunctionLiteral, lit) |
3608 } | 3704 } |
3609 | 3705 |
3610 ThisFunction* NewThisFunction(int pos) { | 3706 ThisFunction* NewThisFunction(int pos) { |
3611 ThisFunction* fun = new (zone_) ThisFunction(zone_, pos, id_gen_); | 3707 ThisFunction* fun = new (zone_) ThisFunction(zone_, pos); |
3612 VISIT_AND_RETURN(ThisFunction, fun) | 3708 VISIT_AND_RETURN(ThisFunction, fun) |
3613 } | 3709 } |
3614 | 3710 |
3615 SuperReference* NewSuperReference(VariableProxy* this_var, int pos) { | 3711 SuperReference* NewSuperReference(VariableProxy* this_var, int pos) { |
3616 SuperReference* super = | 3712 SuperReference* super = new (zone_) SuperReference(zone_, this_var, pos); |
3617 new (zone_) SuperReference(zone_, this_var, pos, id_gen_); | |
3618 VISIT_AND_RETURN(SuperReference, super); | 3713 VISIT_AND_RETURN(SuperReference, super); |
3619 } | 3714 } |
3620 | 3715 |
3621 #undef VISIT_AND_RETURN | 3716 #undef VISIT_AND_RETURN |
3622 | 3717 |
3623 private: | 3718 private: |
3624 Zone* zone_; | 3719 Zone* zone_; |
3625 Visitor visitor_; | 3720 Visitor visitor_; |
3626 AstValueFactory* ast_value_factory_; | 3721 AstValueFactory* ast_value_factory_; |
3627 AstNode::IdGen* id_gen_; | |
3628 }; | 3722 }; |
3629 | 3723 |
3630 | 3724 |
3631 } } // namespace v8::internal | 3725 } } // namespace v8::internal |
3632 | 3726 |
3633 #endif // V8_AST_H_ | 3727 #endif // V8_AST_H_ |
OLD | NEW |