OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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 #include "src/compiler/bytecode-graph-builder.h" | 5 #include "src/compiler/bytecode-graph-builder.h" |
6 | 6 |
7 #include "src/compiler/bytecode-branch-analysis.h" | 7 #include "src/compiler/bytecode-branch-analysis.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/operator-properties.h" | 9 #include "src/compiler/operator-properties.h" |
10 #include "src/interpreter/bytecodes.h" | 10 #include "src/interpreter/bytecodes.h" |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 Node* parameters_state_values_; | 96 Node* parameters_state_values_; |
97 Node* registers_state_values_; | 97 Node* registers_state_values_; |
98 Node* accumulator_state_values_; | 98 Node* accumulator_state_values_; |
99 int register_base_; | 99 int register_base_; |
100 int accumulator_base_; | 100 int accumulator_base_; |
101 }; | 101 }; |
102 | 102 |
103 // Helper for generating frame states for before and after a bytecode. | 103 // Helper for generating frame states for before and after a bytecode. |
104 class BytecodeGraphBuilder::FrameStateBeforeAndAfter { | 104 class BytecodeGraphBuilder::FrameStateBeforeAndAfter { |
105 public: | 105 public: |
106 FrameStateBeforeAndAfter(BytecodeGraphBuilder* builder, | 106 explicit FrameStateBeforeAndAfter(BytecodeGraphBuilder* builder) |
107 const interpreter::BytecodeArrayIterator& iterator) | |
108 : builder_(builder), | 107 : builder_(builder), |
109 id_after_(BailoutId::None()), | 108 id_after_(BailoutId::None()), |
110 added_to_node_(false), | 109 added_to_node_(false), |
111 output_poke_offset_(0), | 110 output_poke_offset_(0), |
112 output_poke_count_(0) { | 111 output_poke_count_(0) { |
113 BailoutId id_before(iterator.current_offset()); | 112 BailoutId id_before(builder->bytecode_iterator().current_offset()); |
114 frame_state_before_ = builder_->environment()->Checkpoint( | 113 frame_state_before_ = builder_->environment()->Checkpoint( |
115 id_before, OutputFrameStateCombine::Ignore()); | 114 id_before, OutputFrameStateCombine::Ignore()); |
116 id_after_ = BailoutId(id_before.ToInt() + iterator.current_bytecode_size()); | 115 id_after_ = BailoutId(id_before.ToInt() + |
| 116 builder->bytecode_iterator().current_bytecode_size()); |
117 } | 117 } |
118 | 118 |
119 ~FrameStateBeforeAndAfter() { | 119 ~FrameStateBeforeAndAfter() { |
120 DCHECK(added_to_node_); | 120 DCHECK(added_to_node_); |
121 DCHECK(builder_->environment()->StateValuesAreUpToDate(output_poke_offset_, | 121 DCHECK(builder_->environment()->StateValuesAreUpToDate(output_poke_offset_, |
122 output_poke_count_)); | 122 output_poke_count_)); |
123 } | 123 } |
124 | 124 |
125 private: | 125 private: |
126 friend class Environment; | 126 friend class Environment; |
(...skipping 490 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 while (!iterator.done()) { | 617 while (!iterator.done()) { |
618 int current_offset = iterator.current_offset(); | 618 int current_offset = iterator.current_offset(); |
619 if (analysis.is_reachable(current_offset)) { | 619 if (analysis.is_reachable(current_offset)) { |
620 EnterAndExitExceptionHandlers(current_offset); | 620 EnterAndExitExceptionHandlers(current_offset); |
621 MergeEnvironmentsOfForwardBranches(current_offset); | 621 MergeEnvironmentsOfForwardBranches(current_offset); |
622 BuildLoopHeaderForBackwardBranches(current_offset); | 622 BuildLoopHeaderForBackwardBranches(current_offset); |
623 | 623 |
624 switch (iterator.current_bytecode()) { | 624 switch (iterator.current_bytecode()) { |
625 #define BYTECODE_CASE(name, ...) \ | 625 #define BYTECODE_CASE(name, ...) \ |
626 case interpreter::Bytecode::k##name: \ | 626 case interpreter::Bytecode::k##name: \ |
627 Visit##name(iterator); \ | 627 Visit##name(); \ |
628 break; | 628 break; |
629 BYTECODE_LIST(BYTECODE_CASE) | 629 BYTECODE_LIST(BYTECODE_CASE) |
630 #undef BYTECODE_CODE | 630 #undef BYTECODE_CODE |
631 } | 631 } |
632 } | 632 } |
633 iterator.Advance(); | 633 iterator.Advance(); |
634 } | 634 } |
635 set_branch_analysis(nullptr); | 635 set_branch_analysis(nullptr); |
636 set_bytecode_iterator(nullptr); | 636 set_bytecode_iterator(nullptr); |
637 DCHECK(exception_handlers_.empty()); | 637 DCHECK(exception_handlers_.empty()); |
638 } | 638 } |
639 | 639 |
640 | 640 void BytecodeGraphBuilder::VisitLdaZero() { |
641 void BytecodeGraphBuilder::VisitLdaZero( | |
642 const interpreter::BytecodeArrayIterator& iterator) { | |
643 Node* node = jsgraph()->ZeroConstant(); | 641 Node* node = jsgraph()->ZeroConstant(); |
644 environment()->BindAccumulator(node); | 642 environment()->BindAccumulator(node); |
645 } | 643 } |
646 | 644 |
647 | 645 void BytecodeGraphBuilder::VisitLdaSmi8() { |
648 void BytecodeGraphBuilder::VisitLdaSmi8( | 646 Node* node = jsgraph()->Constant(bytecode_iterator().GetImmediateOperand(0)); |
649 const interpreter::BytecodeArrayIterator& iterator) { | |
650 Node* node = jsgraph()->Constant(iterator.GetImmediateOperand(0)); | |
651 environment()->BindAccumulator(node); | 647 environment()->BindAccumulator(node); |
652 } | 648 } |
653 | 649 |
654 | 650 void BytecodeGraphBuilder::VisitLdaConstantWide() { |
655 void BytecodeGraphBuilder::VisitLdaConstantWide( | 651 Node* node = |
656 const interpreter::BytecodeArrayIterator& iterator) { | 652 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); |
657 Node* node = jsgraph()->Constant(iterator.GetConstantForIndexOperand(0)); | |
658 environment()->BindAccumulator(node); | 653 environment()->BindAccumulator(node); |
659 } | 654 } |
660 | 655 |
661 | 656 void BytecodeGraphBuilder::VisitLdaConstant() { |
662 void BytecodeGraphBuilder::VisitLdaConstant( | 657 Node* node = |
663 const interpreter::BytecodeArrayIterator& iterator) { | 658 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); |
664 Node* node = jsgraph()->Constant(iterator.GetConstantForIndexOperand(0)); | |
665 environment()->BindAccumulator(node); | 659 environment()->BindAccumulator(node); |
666 } | 660 } |
667 | 661 |
668 | 662 void BytecodeGraphBuilder::VisitLdaUndefined() { |
669 void BytecodeGraphBuilder::VisitLdaUndefined( | |
670 const interpreter::BytecodeArrayIterator& iterator) { | |
671 Node* node = jsgraph()->UndefinedConstant(); | 663 Node* node = jsgraph()->UndefinedConstant(); |
672 environment()->BindAccumulator(node); | 664 environment()->BindAccumulator(node); |
673 } | 665 } |
674 | 666 |
675 | 667 void BytecodeGraphBuilder::VisitLdaNull() { |
676 void BytecodeGraphBuilder::VisitLdaNull( | |
677 const interpreter::BytecodeArrayIterator& iterator) { | |
678 Node* node = jsgraph()->NullConstant(); | 668 Node* node = jsgraph()->NullConstant(); |
679 environment()->BindAccumulator(node); | 669 environment()->BindAccumulator(node); |
680 } | 670 } |
681 | 671 |
682 | 672 void BytecodeGraphBuilder::VisitLdaTheHole() { |
683 void BytecodeGraphBuilder::VisitLdaTheHole( | |
684 const interpreter::BytecodeArrayIterator& iterator) { | |
685 Node* node = jsgraph()->TheHoleConstant(); | 673 Node* node = jsgraph()->TheHoleConstant(); |
686 environment()->BindAccumulator(node); | 674 environment()->BindAccumulator(node); |
687 } | 675 } |
688 | 676 |
689 | 677 void BytecodeGraphBuilder::VisitLdaTrue() { |
690 void BytecodeGraphBuilder::VisitLdaTrue( | |
691 const interpreter::BytecodeArrayIterator& iterator) { | |
692 Node* node = jsgraph()->TrueConstant(); | 678 Node* node = jsgraph()->TrueConstant(); |
693 environment()->BindAccumulator(node); | 679 environment()->BindAccumulator(node); |
694 } | 680 } |
695 | 681 |
696 | 682 void BytecodeGraphBuilder::VisitLdaFalse() { |
697 void BytecodeGraphBuilder::VisitLdaFalse( | |
698 const interpreter::BytecodeArrayIterator& iterator) { | |
699 Node* node = jsgraph()->FalseConstant(); | 683 Node* node = jsgraph()->FalseConstant(); |
700 environment()->BindAccumulator(node); | 684 environment()->BindAccumulator(node); |
701 } | 685 } |
702 | 686 |
703 | 687 void BytecodeGraphBuilder::VisitLdar() { |
704 void BytecodeGraphBuilder::VisitLdar( | 688 Node* value = |
705 const interpreter::BytecodeArrayIterator& iterator) { | 689 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
706 Node* value = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | |
707 environment()->BindAccumulator(value); | 690 environment()->BindAccumulator(value); |
708 } | 691 } |
709 | 692 |
710 | 693 void BytecodeGraphBuilder::VisitStar() { |
711 void BytecodeGraphBuilder::VisitStar( | |
712 const interpreter::BytecodeArrayIterator& iterator) { | |
713 Node* value = environment()->LookupAccumulator(); | 694 Node* value = environment()->LookupAccumulator(); |
714 environment()->BindRegister(iterator.GetRegisterOperand(0), value); | 695 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), value); |
715 } | 696 } |
716 | 697 |
717 | 698 void BytecodeGraphBuilder::VisitMov() { |
718 void BytecodeGraphBuilder::VisitMov( | 699 Node* value = |
719 const interpreter::BytecodeArrayIterator& iterator) { | 700 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
720 Node* value = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | 701 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(1), value); |
721 environment()->BindRegister(iterator.GetRegisterOperand(1), value); | |
722 } | 702 } |
723 | 703 |
724 | 704 void BytecodeGraphBuilder::VisitMovWide() { VisitMov(); } |
725 void BytecodeGraphBuilder::VisitMovWide( | |
726 const interpreter::BytecodeArrayIterator& iterator) { | |
727 VisitMov(iterator); | |
728 } | |
729 | |
730 | 705 |
731 void BytecodeGraphBuilder::BuildLoadGlobal( | 706 void BytecodeGraphBuilder::BuildLoadGlobal( |
732 const interpreter::BytecodeArrayIterator& iterator, | |
733 TypeofMode typeof_mode) { | 707 TypeofMode typeof_mode) { |
734 FrameStateBeforeAndAfter states(this, iterator); | 708 FrameStateBeforeAndAfter states(this); |
735 Handle<Name> name = | 709 Handle<Name> name = |
736 Handle<Name>::cast(iterator.GetConstantForIndexOperand(0)); | 710 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
737 VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(1)); | 711 VectorSlotPair feedback = |
| 712 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); |
738 | 713 |
739 const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode); | 714 const Operator* op = javascript()->LoadGlobal(name, feedback, typeof_mode); |
740 Node* node = NewNode(op, BuildLoadFeedbackVector()); | 715 Node* node = NewNode(op, BuildLoadFeedbackVector()); |
741 environment()->BindAccumulator(node, &states); | 716 environment()->BindAccumulator(node, &states); |
742 } | 717 } |
743 | 718 |
744 | 719 void BytecodeGraphBuilder::VisitLdaGlobalSloppy() { |
745 void BytecodeGraphBuilder::VisitLdaGlobalSloppy( | |
746 const interpreter::BytecodeArrayIterator& iterator) { | |
747 DCHECK(is_sloppy(language_mode())); | 720 DCHECK(is_sloppy(language_mode())); |
748 BuildLoadGlobal(iterator, TypeofMode::NOT_INSIDE_TYPEOF); | 721 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); |
749 } | 722 } |
750 | 723 |
751 | 724 void BytecodeGraphBuilder::VisitLdaGlobalStrict() { |
752 void BytecodeGraphBuilder::VisitLdaGlobalStrict( | |
753 const interpreter::BytecodeArrayIterator& iterator) { | |
754 DCHECK(is_strict(language_mode())); | 725 DCHECK(is_strict(language_mode())); |
755 BuildLoadGlobal(iterator, TypeofMode::NOT_INSIDE_TYPEOF); | 726 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); |
756 } | 727 } |
757 | 728 |
758 | 729 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofSloppy() { |
759 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofSloppy( | |
760 const interpreter::BytecodeArrayIterator& iterator) { | |
761 DCHECK(is_sloppy(language_mode())); | 730 DCHECK(is_sloppy(language_mode())); |
762 BuildLoadGlobal(iterator, TypeofMode::INSIDE_TYPEOF); | 731 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); |
763 } | 732 } |
764 | 733 |
765 | 734 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofStrict() { |
766 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofStrict( | |
767 const interpreter::BytecodeArrayIterator& iterator) { | |
768 DCHECK(is_strict(language_mode())); | 735 DCHECK(is_strict(language_mode())); |
769 BuildLoadGlobal(iterator, TypeofMode::INSIDE_TYPEOF); | 736 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); |
770 } | 737 } |
771 | 738 |
772 | 739 void BytecodeGraphBuilder::VisitLdaGlobalSloppyWide() { |
773 void BytecodeGraphBuilder::VisitLdaGlobalSloppyWide( | |
774 const interpreter::BytecodeArrayIterator& iterator) { | |
775 DCHECK(is_sloppy(language_mode())); | 740 DCHECK(is_sloppy(language_mode())); |
776 BuildLoadGlobal(iterator, TypeofMode::NOT_INSIDE_TYPEOF); | 741 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); |
777 } | 742 } |
778 | 743 |
779 | 744 void BytecodeGraphBuilder::VisitLdaGlobalStrictWide() { |
780 void BytecodeGraphBuilder::VisitLdaGlobalStrictWide( | |
781 const interpreter::BytecodeArrayIterator& iterator) { | |
782 DCHECK(is_strict(language_mode())); | 745 DCHECK(is_strict(language_mode())); |
783 BuildLoadGlobal(iterator, TypeofMode::NOT_INSIDE_TYPEOF); | 746 BuildLoadGlobal(TypeofMode::NOT_INSIDE_TYPEOF); |
784 } | 747 } |
785 | 748 |
786 | 749 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofSloppyWide() { |
787 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofSloppyWide( | |
788 const interpreter::BytecodeArrayIterator& iterator) { | |
789 DCHECK(is_sloppy(language_mode())); | 750 DCHECK(is_sloppy(language_mode())); |
790 BuildLoadGlobal(iterator, TypeofMode::INSIDE_TYPEOF); | 751 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); |
791 } | 752 } |
792 | 753 |
793 | 754 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofStrictWide() { |
794 void BytecodeGraphBuilder::VisitLdaGlobalInsideTypeofStrictWide( | |
795 const interpreter::BytecodeArrayIterator& iterator) { | |
796 DCHECK(is_strict(language_mode())); | 755 DCHECK(is_strict(language_mode())); |
797 BuildLoadGlobal(iterator, TypeofMode::INSIDE_TYPEOF); | 756 BuildLoadGlobal(TypeofMode::INSIDE_TYPEOF); |
798 } | 757 } |
799 | 758 |
800 | 759 void BytecodeGraphBuilder::BuildStoreGlobal() { |
801 void BytecodeGraphBuilder::BuildStoreGlobal( | 760 FrameStateBeforeAndAfter states(this); |
802 const interpreter::BytecodeArrayIterator& iterator) { | |
803 FrameStateBeforeAndAfter states(this, iterator); | |
804 Handle<Name> name = | 761 Handle<Name> name = |
805 Handle<Name>::cast(iterator.GetConstantForIndexOperand(0)); | 762 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
806 VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(1)); | 763 VectorSlotPair feedback = |
| 764 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); |
807 Node* value = environment()->LookupAccumulator(); | 765 Node* value = environment()->LookupAccumulator(); |
808 | 766 |
809 const Operator* op = | 767 const Operator* op = |
810 javascript()->StoreGlobal(language_mode(), name, feedback); | 768 javascript()->StoreGlobal(language_mode(), name, feedback); |
811 Node* node = NewNode(op, value, BuildLoadFeedbackVector()); | 769 Node* node = NewNode(op, value, BuildLoadFeedbackVector()); |
812 environment()->RecordAfterState(node, &states); | 770 environment()->RecordAfterState(node, &states); |
813 } | 771 } |
814 | 772 |
815 | 773 void BytecodeGraphBuilder::VisitStaGlobalSloppy() { |
816 void BytecodeGraphBuilder::VisitStaGlobalSloppy( | |
817 const interpreter::BytecodeArrayIterator& iterator) { | |
818 DCHECK(is_sloppy(language_mode())); | 774 DCHECK(is_sloppy(language_mode())); |
819 BuildStoreGlobal(iterator); | 775 BuildStoreGlobal(); |
820 } | 776 } |
821 | 777 |
822 | 778 void BytecodeGraphBuilder::VisitStaGlobalStrict() { |
823 void BytecodeGraphBuilder::VisitStaGlobalStrict( | |
824 const interpreter::BytecodeArrayIterator& iterator) { | |
825 DCHECK(is_strict(language_mode())); | 779 DCHECK(is_strict(language_mode())); |
826 BuildStoreGlobal(iterator); | 780 BuildStoreGlobal(); |
827 } | 781 } |
828 | 782 |
829 void BytecodeGraphBuilder::VisitStaGlobalSloppyWide( | 783 void BytecodeGraphBuilder::VisitStaGlobalSloppyWide() { |
830 const interpreter::BytecodeArrayIterator& iterator) { | |
831 DCHECK(is_sloppy(language_mode())); | 784 DCHECK(is_sloppy(language_mode())); |
832 BuildStoreGlobal(iterator); | 785 BuildStoreGlobal(); |
833 } | 786 } |
834 | 787 |
835 | 788 void BytecodeGraphBuilder::VisitStaGlobalStrictWide() { |
836 void BytecodeGraphBuilder::VisitStaGlobalStrictWide( | |
837 const interpreter::BytecodeArrayIterator& iterator) { | |
838 DCHECK(is_strict(language_mode())); | 789 DCHECK(is_strict(language_mode())); |
839 BuildStoreGlobal(iterator); | 790 BuildStoreGlobal(); |
840 } | 791 } |
841 | 792 |
842 | 793 void BytecodeGraphBuilder::VisitLdaContextSlot() { |
843 void BytecodeGraphBuilder::VisitLdaContextSlot( | |
844 const interpreter::BytecodeArrayIterator& iterator) { | |
845 // TODO(mythria): LoadContextSlots are unrolled by the required depth when | 794 // TODO(mythria): LoadContextSlots are unrolled by the required depth when |
846 // generating bytecode. Hence the value of depth is always 0. Update this | 795 // generating bytecode. Hence the value of depth is always 0. Update this |
847 // code, when the implementation changes. | 796 // code, when the implementation changes. |
848 // TODO(mythria): immutable flag is also set to false. This information is not | 797 // TODO(mythria): immutable flag is also set to false. This information is not |
849 // available in bytecode array. update this code when the implementation | 798 // available in bytecode array. update this code when the implementation |
850 // changes. | 799 // changes. |
851 const Operator* op = | 800 const Operator* op = javascript()->LoadContext( |
852 javascript()->LoadContext(0, iterator.GetIndexOperand(1), false); | 801 0, bytecode_iterator().GetIndexOperand(1), false); |
853 Node* context = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | 802 Node* context = |
| 803 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
854 Node* node = NewNode(op, context); | 804 Node* node = NewNode(op, context); |
855 environment()->BindAccumulator(node); | 805 environment()->BindAccumulator(node); |
856 } | 806 } |
857 | 807 |
| 808 void BytecodeGraphBuilder::VisitLdaContextSlotWide() { VisitLdaContextSlot(); } |
858 | 809 |
859 void BytecodeGraphBuilder::VisitLdaContextSlotWide( | 810 void BytecodeGraphBuilder::VisitStaContextSlot() { |
860 const interpreter::BytecodeArrayIterator& iterator) { | |
861 VisitLdaContextSlot(iterator); | |
862 } | |
863 | |
864 | |
865 void BytecodeGraphBuilder::VisitStaContextSlot( | |
866 const interpreter::BytecodeArrayIterator& iterator) { | |
867 // TODO(mythria): LoadContextSlots are unrolled by the required depth when | 811 // TODO(mythria): LoadContextSlots are unrolled by the required depth when |
868 // generating bytecode. Hence the value of depth is always 0. Update this | 812 // generating bytecode. Hence the value of depth is always 0. Update this |
869 // code, when the implementation changes. | 813 // code, when the implementation changes. |
870 const Operator* op = | 814 const Operator* op = |
871 javascript()->StoreContext(0, iterator.GetIndexOperand(1)); | 815 javascript()->StoreContext(0, bytecode_iterator().GetIndexOperand(1)); |
872 Node* context = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | 816 Node* context = |
| 817 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
873 Node* value = environment()->LookupAccumulator(); | 818 Node* value = environment()->LookupAccumulator(); |
874 NewNode(op, context, value); | 819 NewNode(op, context, value); |
875 } | 820 } |
876 | 821 |
| 822 void BytecodeGraphBuilder::VisitStaContextSlotWide() { VisitStaContextSlot(); } |
877 | 823 |
878 void BytecodeGraphBuilder::VisitStaContextSlotWide( | 824 void BytecodeGraphBuilder::BuildLdaLookupSlot(TypeofMode typeof_mode) { |
879 const interpreter::BytecodeArrayIterator& iterator) { | 825 FrameStateBeforeAndAfter states(this); |
880 VisitStaContextSlot(iterator); | |
881 } | |
882 | |
883 | |
884 void BytecodeGraphBuilder::BuildLdaLookupSlot( | |
885 TypeofMode typeof_mode, | |
886 const interpreter::BytecodeArrayIterator& iterator) { | |
887 FrameStateBeforeAndAfter states(this, iterator); | |
888 Handle<String> name = | 826 Handle<String> name = |
889 Handle<String>::cast(iterator.GetConstantForIndexOperand(0)); | 827 Handle<String>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
890 const Operator* op = javascript()->LoadDynamic(name, typeof_mode); | 828 const Operator* op = javascript()->LoadDynamic(name, typeof_mode); |
891 Node* value = | 829 Node* value = |
892 NewNode(op, BuildLoadFeedbackVector(), environment()->Context()); | 830 NewNode(op, BuildLoadFeedbackVector(), environment()->Context()); |
893 environment()->BindAccumulator(value, &states); | 831 environment()->BindAccumulator(value, &states); |
894 } | 832 } |
895 | 833 |
896 | 834 void BytecodeGraphBuilder::VisitLdaLookupSlot() { |
897 void BytecodeGraphBuilder::VisitLdaLookupSlot( | 835 BuildLdaLookupSlot(TypeofMode::NOT_INSIDE_TYPEOF); |
898 const interpreter::BytecodeArrayIterator& iterator) { | |
899 BuildLdaLookupSlot(TypeofMode::NOT_INSIDE_TYPEOF, iterator); | |
900 } | 836 } |
901 | 837 |
902 | 838 void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeof() { |
903 void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeof( | 839 BuildLdaLookupSlot(TypeofMode::INSIDE_TYPEOF); |
904 const interpreter::BytecodeArrayIterator& iterator) { | |
905 BuildLdaLookupSlot(TypeofMode::INSIDE_TYPEOF, iterator); | |
906 } | 840 } |
907 | 841 |
908 | 842 void BytecodeGraphBuilder::BuildStaLookupSlot(LanguageMode language_mode) { |
909 void BytecodeGraphBuilder::BuildStaLookupSlot( | 843 FrameStateBeforeAndAfter states(this); |
910 LanguageMode language_mode, | |
911 const interpreter::BytecodeArrayIterator& iterator) { | |
912 FrameStateBeforeAndAfter states(this, iterator); | |
913 Node* value = environment()->LookupAccumulator(); | 844 Node* value = environment()->LookupAccumulator(); |
914 Node* name = jsgraph()->Constant(iterator.GetConstantForIndexOperand(0)); | 845 Node* name = |
| 846 jsgraph()->Constant(bytecode_iterator().GetConstantForIndexOperand(0)); |
915 Node* language = jsgraph()->Constant(language_mode); | 847 Node* language = jsgraph()->Constant(language_mode); |
916 const Operator* op = javascript()->CallRuntime(Runtime::kStoreLookupSlot); | 848 const Operator* op = javascript()->CallRuntime(Runtime::kStoreLookupSlot); |
917 Node* store = NewNode(op, value, environment()->Context(), name, language); | 849 Node* store = NewNode(op, value, environment()->Context(), name, language); |
918 environment()->BindAccumulator(store, &states); | 850 environment()->BindAccumulator(store, &states); |
919 } | 851 } |
920 | 852 |
| 853 void BytecodeGraphBuilder::VisitLdaLookupSlotWide() { VisitLdaLookupSlot(); } |
921 | 854 |
922 void BytecodeGraphBuilder::VisitLdaLookupSlotWide( | 855 void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeofWide() { |
923 const interpreter::BytecodeArrayIterator& iterator) { | 856 VisitLdaLookupSlotInsideTypeof(); |
924 VisitLdaLookupSlot(iterator); | |
925 } | 857 } |
926 | 858 |
927 | 859 void BytecodeGraphBuilder::VisitStaLookupSlotSloppy() { |
928 void BytecodeGraphBuilder::VisitLdaLookupSlotInsideTypeofWide( | 860 BuildStaLookupSlot(LanguageMode::SLOPPY); |
929 const interpreter::BytecodeArrayIterator& iterator) { | |
930 VisitLdaLookupSlotInsideTypeof(iterator); | |
931 } | 861 } |
932 | 862 |
933 | 863 void BytecodeGraphBuilder::VisitStaLookupSlotStrict() { |
934 void BytecodeGraphBuilder::VisitStaLookupSlotSloppy( | 864 BuildStaLookupSlot(LanguageMode::STRICT); |
935 const interpreter::BytecodeArrayIterator& iterator) { | |
936 BuildStaLookupSlot(LanguageMode::SLOPPY, iterator); | |
937 } | 865 } |
938 | 866 |
939 | 867 void BytecodeGraphBuilder::VisitStaLookupSlotSloppyWide() { |
940 void BytecodeGraphBuilder::VisitStaLookupSlotStrict( | 868 VisitStaLookupSlotSloppy(); |
941 const interpreter::BytecodeArrayIterator& iterator) { | |
942 BuildStaLookupSlot(LanguageMode::STRICT, iterator); | |
943 } | 869 } |
944 | 870 |
945 | 871 void BytecodeGraphBuilder::VisitStaLookupSlotStrictWide() { |
946 void BytecodeGraphBuilder::VisitStaLookupSlotSloppyWide( | 872 VisitStaLookupSlotStrict(); |
947 const interpreter::BytecodeArrayIterator& iterator) { | |
948 VisitStaLookupSlotSloppy(iterator); | |
949 } | 873 } |
950 | 874 |
951 | 875 void BytecodeGraphBuilder::BuildNamedLoad() { |
952 void BytecodeGraphBuilder::VisitStaLookupSlotStrictWide( | 876 FrameStateBeforeAndAfter states(this); |
953 const interpreter::BytecodeArrayIterator& iterator) { | 877 Node* object = |
954 VisitStaLookupSlotStrict(iterator); | 878 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
955 } | |
956 | |
957 | |
958 void BytecodeGraphBuilder::BuildNamedLoad( | |
959 const interpreter::BytecodeArrayIterator& iterator) { | |
960 FrameStateBeforeAndAfter states(this, iterator); | |
961 Node* object = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | |
962 Handle<Name> name = | 879 Handle<Name> name = |
963 Handle<Name>::cast(iterator.GetConstantForIndexOperand(1)); | 880 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); |
964 VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(2)); | 881 VectorSlotPair feedback = |
| 882 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); |
965 | 883 |
966 const Operator* op = javascript()->LoadNamed(language_mode(), name, feedback); | 884 const Operator* op = javascript()->LoadNamed(language_mode(), name, feedback); |
967 Node* node = NewNode(op, object, BuildLoadFeedbackVector()); | 885 Node* node = NewNode(op, object, BuildLoadFeedbackVector()); |
968 environment()->BindAccumulator(node, &states); | 886 environment()->BindAccumulator(node, &states); |
969 } | 887 } |
970 | 888 |
971 | 889 void BytecodeGraphBuilder::VisitLoadICSloppy() { |
972 void BytecodeGraphBuilder::VisitLoadICSloppy( | |
973 const interpreter::BytecodeArrayIterator& iterator) { | |
974 DCHECK(is_sloppy(language_mode())); | 890 DCHECK(is_sloppy(language_mode())); |
975 BuildNamedLoad(iterator); | 891 BuildNamedLoad(); |
976 } | 892 } |
977 | 893 |
978 | 894 void BytecodeGraphBuilder::VisitLoadICStrict() { |
979 void BytecodeGraphBuilder::VisitLoadICStrict( | |
980 const interpreter::BytecodeArrayIterator& iterator) { | |
981 DCHECK(is_strict(language_mode())); | 895 DCHECK(is_strict(language_mode())); |
982 BuildNamedLoad(iterator); | 896 BuildNamedLoad(); |
983 } | 897 } |
984 | 898 |
985 | 899 void BytecodeGraphBuilder::VisitLoadICSloppyWide() { |
986 void BytecodeGraphBuilder::VisitLoadICSloppyWide( | |
987 const interpreter::BytecodeArrayIterator& iterator) { | |
988 DCHECK(is_sloppy(language_mode())); | 900 DCHECK(is_sloppy(language_mode())); |
989 BuildNamedLoad(iterator); | 901 BuildNamedLoad(); |
990 } | 902 } |
991 | 903 |
992 | 904 void BytecodeGraphBuilder::VisitLoadICStrictWide() { |
993 void BytecodeGraphBuilder::VisitLoadICStrictWide( | |
994 const interpreter::BytecodeArrayIterator& iterator) { | |
995 DCHECK(is_strict(language_mode())); | 905 DCHECK(is_strict(language_mode())); |
996 BuildNamedLoad(iterator); | 906 BuildNamedLoad(); |
997 } | 907 } |
998 | 908 |
999 | 909 void BytecodeGraphBuilder::BuildKeyedLoad() { |
1000 void BytecodeGraphBuilder::BuildKeyedLoad( | 910 FrameStateBeforeAndAfter states(this); |
1001 const interpreter::BytecodeArrayIterator& iterator) { | |
1002 FrameStateBeforeAndAfter states(this, iterator); | |
1003 Node* key = environment()->LookupAccumulator(); | 911 Node* key = environment()->LookupAccumulator(); |
1004 Node* object = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | 912 Node* object = |
1005 VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(1)); | 913 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
| 914 VectorSlotPair feedback = |
| 915 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(1)); |
1006 | 916 |
1007 const Operator* op = javascript()->LoadProperty(language_mode(), feedback); | 917 const Operator* op = javascript()->LoadProperty(language_mode(), feedback); |
1008 Node* node = NewNode(op, object, key, BuildLoadFeedbackVector()); | 918 Node* node = NewNode(op, object, key, BuildLoadFeedbackVector()); |
1009 environment()->BindAccumulator(node, &states); | 919 environment()->BindAccumulator(node, &states); |
1010 } | 920 } |
1011 | 921 |
1012 | 922 void BytecodeGraphBuilder::VisitKeyedLoadICSloppy() { |
1013 void BytecodeGraphBuilder::VisitKeyedLoadICSloppy( | |
1014 const interpreter::BytecodeArrayIterator& iterator) { | |
1015 DCHECK(is_sloppy(language_mode())); | 923 DCHECK(is_sloppy(language_mode())); |
1016 BuildKeyedLoad(iterator); | 924 BuildKeyedLoad(); |
1017 } | 925 } |
1018 | 926 |
1019 | 927 void BytecodeGraphBuilder::VisitKeyedLoadICStrict() { |
1020 void BytecodeGraphBuilder::VisitKeyedLoadICStrict( | |
1021 const interpreter::BytecodeArrayIterator& iterator) { | |
1022 DCHECK(is_strict(language_mode())); | 928 DCHECK(is_strict(language_mode())); |
1023 BuildKeyedLoad(iterator); | 929 BuildKeyedLoad(); |
1024 } | 930 } |
1025 | 931 |
1026 | 932 void BytecodeGraphBuilder::VisitKeyedLoadICSloppyWide() { |
1027 void BytecodeGraphBuilder::VisitKeyedLoadICSloppyWide( | |
1028 const interpreter::BytecodeArrayIterator& iterator) { | |
1029 DCHECK(is_sloppy(language_mode())); | 933 DCHECK(is_sloppy(language_mode())); |
1030 BuildKeyedLoad(iterator); | 934 BuildKeyedLoad(); |
1031 } | 935 } |
1032 | 936 |
1033 | 937 void BytecodeGraphBuilder::VisitKeyedLoadICStrictWide() { |
1034 void BytecodeGraphBuilder::VisitKeyedLoadICStrictWide( | |
1035 const interpreter::BytecodeArrayIterator& iterator) { | |
1036 DCHECK(is_strict(language_mode())); | 938 DCHECK(is_strict(language_mode())); |
1037 BuildKeyedLoad(iterator); | 939 BuildKeyedLoad(); |
1038 } | 940 } |
1039 | 941 |
1040 | 942 void BytecodeGraphBuilder::BuildNamedStore() { |
1041 void BytecodeGraphBuilder::BuildNamedStore( | 943 FrameStateBeforeAndAfter states(this); |
1042 const interpreter::BytecodeArrayIterator& iterator) { | |
1043 FrameStateBeforeAndAfter states(this, iterator); | |
1044 Node* value = environment()->LookupAccumulator(); | 944 Node* value = environment()->LookupAccumulator(); |
1045 Node* object = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | 945 Node* object = |
| 946 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1046 Handle<Name> name = | 947 Handle<Name> name = |
1047 Handle<Name>::cast(iterator.GetConstantForIndexOperand(1)); | 948 Handle<Name>::cast(bytecode_iterator().GetConstantForIndexOperand(1)); |
1048 VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(2)); | 949 VectorSlotPair feedback = |
| 950 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); |
1049 | 951 |
1050 const Operator* op = | 952 const Operator* op = |
1051 javascript()->StoreNamed(language_mode(), name, feedback); | 953 javascript()->StoreNamed(language_mode(), name, feedback); |
1052 Node* node = NewNode(op, object, value, BuildLoadFeedbackVector()); | 954 Node* node = NewNode(op, object, value, BuildLoadFeedbackVector()); |
1053 environment()->RecordAfterState(node, &states); | 955 environment()->RecordAfterState(node, &states); |
1054 } | 956 } |
1055 | 957 |
1056 | 958 void BytecodeGraphBuilder::VisitStoreICSloppy() { |
1057 void BytecodeGraphBuilder::VisitStoreICSloppy( | |
1058 const interpreter::BytecodeArrayIterator& iterator) { | |
1059 DCHECK(is_sloppy(language_mode())); | 959 DCHECK(is_sloppy(language_mode())); |
1060 BuildNamedStore(iterator); | 960 BuildNamedStore(); |
1061 } | 961 } |
1062 | 962 |
1063 | 963 void BytecodeGraphBuilder::VisitStoreICStrict() { |
1064 void BytecodeGraphBuilder::VisitStoreICStrict( | |
1065 const interpreter::BytecodeArrayIterator& iterator) { | |
1066 DCHECK(is_strict(language_mode())); | 964 DCHECK(is_strict(language_mode())); |
1067 BuildNamedStore(iterator); | 965 BuildNamedStore(); |
1068 } | 966 } |
1069 | 967 |
1070 | 968 void BytecodeGraphBuilder::VisitStoreICSloppyWide() { |
1071 void BytecodeGraphBuilder::VisitStoreICSloppyWide( | |
1072 const interpreter::BytecodeArrayIterator& iterator) { | |
1073 DCHECK(is_sloppy(language_mode())); | 969 DCHECK(is_sloppy(language_mode())); |
1074 BuildNamedStore(iterator); | 970 BuildNamedStore(); |
1075 } | 971 } |
1076 | 972 |
1077 | 973 void BytecodeGraphBuilder::VisitStoreICStrictWide() { |
1078 void BytecodeGraphBuilder::VisitStoreICStrictWide( | |
1079 const interpreter::BytecodeArrayIterator& iterator) { | |
1080 DCHECK(is_strict(language_mode())); | 974 DCHECK(is_strict(language_mode())); |
1081 BuildNamedStore(iterator); | 975 BuildNamedStore(); |
1082 } | 976 } |
1083 | 977 |
1084 | 978 void BytecodeGraphBuilder::BuildKeyedStore() { |
1085 void BytecodeGraphBuilder::BuildKeyedStore( | 979 FrameStateBeforeAndAfter states(this); |
1086 const interpreter::BytecodeArrayIterator& iterator) { | |
1087 FrameStateBeforeAndAfter states(this, iterator); | |
1088 Node* value = environment()->LookupAccumulator(); | 980 Node* value = environment()->LookupAccumulator(); |
1089 Node* object = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | 981 Node* object = |
1090 Node* key = environment()->LookupRegister(iterator.GetRegisterOperand(1)); | 982 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1091 VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(2)); | 983 Node* key = |
| 984 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1)); |
| 985 VectorSlotPair feedback = |
| 986 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(2)); |
1092 | 987 |
1093 const Operator* op = javascript()->StoreProperty(language_mode(), feedback); | 988 const Operator* op = javascript()->StoreProperty(language_mode(), feedback); |
1094 Node* node = NewNode(op, object, key, value, BuildLoadFeedbackVector()); | 989 Node* node = NewNode(op, object, key, value, BuildLoadFeedbackVector()); |
1095 environment()->RecordAfterState(node, &states); | 990 environment()->RecordAfterState(node, &states); |
1096 } | 991 } |
1097 | 992 |
1098 | 993 void BytecodeGraphBuilder::VisitKeyedStoreICSloppy() { |
1099 void BytecodeGraphBuilder::VisitKeyedStoreICSloppy( | |
1100 const interpreter::BytecodeArrayIterator& iterator) { | |
1101 DCHECK(is_sloppy(language_mode())); | 994 DCHECK(is_sloppy(language_mode())); |
1102 BuildKeyedStore(iterator); | 995 BuildKeyedStore(); |
1103 } | 996 } |
1104 | 997 |
1105 | 998 void BytecodeGraphBuilder::VisitKeyedStoreICStrict() { |
1106 void BytecodeGraphBuilder::VisitKeyedStoreICStrict( | |
1107 const interpreter::BytecodeArrayIterator& iterator) { | |
1108 DCHECK(is_strict(language_mode())); | 999 DCHECK(is_strict(language_mode())); |
1109 BuildKeyedStore(iterator); | 1000 BuildKeyedStore(); |
1110 } | 1001 } |
1111 | 1002 |
1112 | 1003 void BytecodeGraphBuilder::VisitKeyedStoreICSloppyWide() { |
1113 void BytecodeGraphBuilder::VisitKeyedStoreICSloppyWide( | |
1114 const interpreter::BytecodeArrayIterator& iterator) { | |
1115 DCHECK(is_sloppy(language_mode())); | 1004 DCHECK(is_sloppy(language_mode())); |
1116 BuildKeyedStore(iterator); | 1005 BuildKeyedStore(); |
1117 } | 1006 } |
1118 | 1007 |
1119 | 1008 void BytecodeGraphBuilder::VisitKeyedStoreICStrictWide() { |
1120 void BytecodeGraphBuilder::VisitKeyedStoreICStrictWide( | |
1121 const interpreter::BytecodeArrayIterator& iterator) { | |
1122 DCHECK(is_strict(language_mode())); | 1009 DCHECK(is_strict(language_mode())); |
1123 BuildKeyedStore(iterator); | 1010 BuildKeyedStore(); |
1124 } | 1011 } |
1125 | 1012 |
1126 | 1013 void BytecodeGraphBuilder::VisitPushContext() { |
1127 void BytecodeGraphBuilder::VisitPushContext( | |
1128 const interpreter::BytecodeArrayIterator& iterator) { | |
1129 Node* new_context = environment()->LookupAccumulator(); | 1014 Node* new_context = environment()->LookupAccumulator(); |
1130 environment()->BindRegister(iterator.GetRegisterOperand(0), | 1015 environment()->BindRegister(bytecode_iterator().GetRegisterOperand(0), |
1131 environment()->Context()); | 1016 environment()->Context()); |
1132 environment()->SetContext(new_context); | 1017 environment()->SetContext(new_context); |
1133 } | 1018 } |
1134 | 1019 |
1135 | 1020 void BytecodeGraphBuilder::VisitPopContext() { |
1136 void BytecodeGraphBuilder::VisitPopContext( | 1021 Node* context = |
1137 const interpreter::BytecodeArrayIterator& iterator) { | 1022 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1138 Node* context = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | |
1139 environment()->SetContext(context); | 1023 environment()->SetContext(context); |
1140 } | 1024 } |
1141 | 1025 |
1142 | 1026 void BytecodeGraphBuilder::VisitCreateClosure() { |
1143 void BytecodeGraphBuilder::VisitCreateClosure( | 1027 Handle<SharedFunctionInfo> shared_info = Handle<SharedFunctionInfo>::cast( |
1144 const interpreter::BytecodeArrayIterator& iterator) { | 1028 bytecode_iterator().GetConstantForIndexOperand(0)); |
1145 Handle<SharedFunctionInfo> shared_info = | |
1146 Handle<SharedFunctionInfo>::cast(iterator.GetConstantForIndexOperand(0)); | |
1147 PretenureFlag tenured = | 1029 PretenureFlag tenured = |
1148 iterator.GetImmediateOperand(1) ? TENURED : NOT_TENURED; | 1030 bytecode_iterator().GetImmediateOperand(1) ? TENURED : NOT_TENURED; |
1149 const Operator* op = javascript()->CreateClosure(shared_info, tenured); | 1031 const Operator* op = javascript()->CreateClosure(shared_info, tenured); |
1150 Node* closure = NewNode(op); | 1032 Node* closure = NewNode(op); |
1151 environment()->BindAccumulator(closure); | 1033 environment()->BindAccumulator(closure); |
1152 } | 1034 } |
1153 | 1035 |
1154 | 1036 void BytecodeGraphBuilder::VisitCreateClosureWide() { VisitCreateClosure(); } |
1155 void BytecodeGraphBuilder::VisitCreateClosureWide( | |
1156 const interpreter::BytecodeArrayIterator& iterator) { | |
1157 VisitCreateClosure(iterator); | |
1158 } | |
1159 | |
1160 | 1037 |
1161 void BytecodeGraphBuilder::BuildCreateArguments( | 1038 void BytecodeGraphBuilder::BuildCreateArguments( |
1162 CreateArgumentsParameters::Type type, | 1039 CreateArgumentsParameters::Type type) { |
1163 const interpreter::BytecodeArrayIterator& iterator) { | 1040 FrameStateBeforeAndAfter states(this); |
1164 FrameStateBeforeAndAfter states(this, iterator); | |
1165 const Operator* op = javascript()->CreateArguments(type, 0); | 1041 const Operator* op = javascript()->CreateArguments(type, 0); |
1166 Node* object = NewNode(op, GetFunctionClosure()); | 1042 Node* object = NewNode(op, GetFunctionClosure()); |
1167 environment()->BindAccumulator(object, &states); | 1043 environment()->BindAccumulator(object, &states); |
1168 } | 1044 } |
1169 | 1045 |
1170 | 1046 void BytecodeGraphBuilder::VisitCreateMappedArguments() { |
1171 void BytecodeGraphBuilder::VisitCreateMappedArguments( | 1047 BuildCreateArguments(CreateArgumentsParameters::kMappedArguments); |
1172 const interpreter::BytecodeArrayIterator& iterator) { | |
1173 BuildCreateArguments(CreateArgumentsParameters::kMappedArguments, iterator); | |
1174 } | 1048 } |
1175 | 1049 |
1176 | 1050 void BytecodeGraphBuilder::VisitCreateUnmappedArguments() { |
1177 void BytecodeGraphBuilder::VisitCreateUnmappedArguments( | 1051 BuildCreateArguments(CreateArgumentsParameters::kUnmappedArguments); |
1178 const interpreter::BytecodeArrayIterator& iterator) { | |
1179 BuildCreateArguments(CreateArgumentsParameters::kUnmappedArguments, iterator); | |
1180 } | 1052 } |
1181 | 1053 |
1182 | 1054 void BytecodeGraphBuilder::BuildCreateLiteral(const Operator* op) { |
1183 void BytecodeGraphBuilder::BuildCreateLiteral( | 1055 FrameStateBeforeAndAfter states(this); |
1184 const Operator* op, const interpreter::BytecodeArrayIterator& iterator) { | |
1185 FrameStateBeforeAndAfter states(this, iterator); | |
1186 Node* literal = NewNode(op, GetFunctionClosure()); | 1056 Node* literal = NewNode(op, GetFunctionClosure()); |
1187 environment()->BindAccumulator(literal, &states); | 1057 environment()->BindAccumulator(literal, &states); |
1188 } | 1058 } |
1189 | 1059 |
1190 | 1060 void BytecodeGraphBuilder::BuildCreateRegExpLiteral() { |
1191 void BytecodeGraphBuilder::BuildCreateRegExpLiteral( | |
1192 const interpreter::BytecodeArrayIterator& iterator) { | |
1193 Handle<String> constant_pattern = | 1061 Handle<String> constant_pattern = |
1194 Handle<String>::cast(iterator.GetConstantForIndexOperand(0)); | 1062 Handle<String>::cast(bytecode_iterator().GetConstantForIndexOperand(0)); |
1195 int literal_index = iterator.GetIndexOperand(1); | 1063 int literal_index = bytecode_iterator().GetIndexOperand(1); |
1196 int literal_flags = iterator.GetImmediateOperand(2); | 1064 int literal_flags = bytecode_iterator().GetImmediateOperand(2); |
1197 const Operator* op = javascript()->CreateLiteralRegExp( | 1065 const Operator* op = javascript()->CreateLiteralRegExp( |
1198 constant_pattern, literal_flags, literal_index); | 1066 constant_pattern, literal_flags, literal_index); |
1199 BuildCreateLiteral(op, iterator); | 1067 BuildCreateLiteral(op); |
| 1068 } |
| 1069 |
| 1070 void BytecodeGraphBuilder::VisitCreateRegExpLiteral() { |
| 1071 BuildCreateRegExpLiteral(); |
| 1072 } |
| 1073 |
| 1074 void BytecodeGraphBuilder::VisitCreateRegExpLiteralWide() { |
| 1075 BuildCreateRegExpLiteral(); |
| 1076 } |
| 1077 |
| 1078 void BytecodeGraphBuilder::BuildCreateArrayLiteral() { |
| 1079 Handle<FixedArray> constant_elements = Handle<FixedArray>::cast( |
| 1080 bytecode_iterator().GetConstantForIndexOperand(0)); |
| 1081 int literal_index = bytecode_iterator().GetIndexOperand(1); |
| 1082 int literal_flags = bytecode_iterator().GetImmediateOperand(2); |
| 1083 const Operator* op = javascript()->CreateLiteralArray( |
| 1084 constant_elements, literal_flags, literal_index); |
| 1085 BuildCreateLiteral(op); |
| 1086 } |
| 1087 |
| 1088 void BytecodeGraphBuilder::VisitCreateArrayLiteral() { |
| 1089 BuildCreateArrayLiteral(); |
| 1090 } |
| 1091 |
| 1092 void BytecodeGraphBuilder::VisitCreateArrayLiteralWide() { |
| 1093 BuildCreateArrayLiteral(); |
| 1094 } |
| 1095 |
| 1096 void BytecodeGraphBuilder::BuildCreateObjectLiteral() { |
| 1097 Handle<FixedArray> constant_properties = Handle<FixedArray>::cast( |
| 1098 bytecode_iterator().GetConstantForIndexOperand(0)); |
| 1099 int literal_index = bytecode_iterator().GetIndexOperand(1); |
| 1100 int literal_flags = bytecode_iterator().GetImmediateOperand(2); |
| 1101 const Operator* op = javascript()->CreateLiteralObject( |
| 1102 constant_properties, literal_flags, literal_index); |
| 1103 BuildCreateLiteral(op); |
| 1104 } |
| 1105 |
| 1106 void BytecodeGraphBuilder::VisitCreateObjectLiteral() { |
| 1107 BuildCreateObjectLiteral(); |
| 1108 } |
| 1109 |
| 1110 void BytecodeGraphBuilder::VisitCreateObjectLiteralWide() { |
| 1111 BuildCreateObjectLiteral(); |
1200 } | 1112 } |
1201 | 1113 |
1202 | 1114 |
1203 void BytecodeGraphBuilder::VisitCreateRegExpLiteral( | |
1204 const interpreter::BytecodeArrayIterator& iterator) { | |
1205 BuildCreateRegExpLiteral(iterator); | |
1206 } | |
1207 | |
1208 | |
1209 void BytecodeGraphBuilder::VisitCreateRegExpLiteralWide( | |
1210 const interpreter::BytecodeArrayIterator& iterator) { | |
1211 BuildCreateRegExpLiteral(iterator); | |
1212 } | |
1213 | |
1214 | |
1215 void BytecodeGraphBuilder::BuildCreateArrayLiteral( | |
1216 const interpreter::BytecodeArrayIterator& iterator) { | |
1217 Handle<FixedArray> constant_elements = | |
1218 Handle<FixedArray>::cast(iterator.GetConstantForIndexOperand(0)); | |
1219 int literal_index = iterator.GetIndexOperand(1); | |
1220 int literal_flags = iterator.GetImmediateOperand(2); | |
1221 const Operator* op = javascript()->CreateLiteralArray( | |
1222 constant_elements, literal_flags, literal_index); | |
1223 BuildCreateLiteral(op, iterator); | |
1224 } | |
1225 | |
1226 | |
1227 void BytecodeGraphBuilder::VisitCreateArrayLiteral( | |
1228 const interpreter::BytecodeArrayIterator& iterator) { | |
1229 BuildCreateArrayLiteral(iterator); | |
1230 } | |
1231 | |
1232 | |
1233 void BytecodeGraphBuilder::VisitCreateArrayLiteralWide( | |
1234 const interpreter::BytecodeArrayIterator& iterator) { | |
1235 BuildCreateArrayLiteral(iterator); | |
1236 } | |
1237 | |
1238 | |
1239 void BytecodeGraphBuilder::BuildCreateObjectLiteral( | |
1240 const interpreter::BytecodeArrayIterator& iterator) { | |
1241 Handle<FixedArray> constant_properties = | |
1242 Handle<FixedArray>::cast(iterator.GetConstantForIndexOperand(0)); | |
1243 int literal_index = iterator.GetIndexOperand(1); | |
1244 int literal_flags = iterator.GetImmediateOperand(2); | |
1245 const Operator* op = javascript()->CreateLiteralObject( | |
1246 constant_properties, literal_flags, literal_index); | |
1247 BuildCreateLiteral(op, iterator); | |
1248 } | |
1249 | |
1250 | |
1251 void BytecodeGraphBuilder::VisitCreateObjectLiteral( | |
1252 const interpreter::BytecodeArrayIterator& iterator) { | |
1253 BuildCreateObjectLiteral(iterator); | |
1254 } | |
1255 | |
1256 | |
1257 void BytecodeGraphBuilder::VisitCreateObjectLiteralWide( | |
1258 const interpreter::BytecodeArrayIterator& iterator) { | |
1259 BuildCreateObjectLiteral(iterator); | |
1260 } | |
1261 | |
1262 | |
1263 Node* BytecodeGraphBuilder::ProcessCallArguments(const Operator* call_op, | 1115 Node* BytecodeGraphBuilder::ProcessCallArguments(const Operator* call_op, |
1264 Node* callee, | 1116 Node* callee, |
1265 interpreter::Register receiver, | 1117 interpreter::Register receiver, |
1266 size_t arity) { | 1118 size_t arity) { |
1267 Node** all = info()->zone()->NewArray<Node*>(static_cast<int>(arity)); | 1119 Node** all = info()->zone()->NewArray<Node*>(static_cast<int>(arity)); |
1268 all[0] = callee; | 1120 all[0] = callee; |
1269 all[1] = environment()->LookupRegister(receiver); | 1121 all[1] = environment()->LookupRegister(receiver); |
1270 int receiver_index = receiver.index(); | 1122 int receiver_index = receiver.index(); |
1271 for (int i = 2; i < static_cast<int>(arity); ++i) { | 1123 for (int i = 2; i < static_cast<int>(arity); ++i) { |
1272 all[i] = environment()->LookupRegister( | 1124 all[i] = environment()->LookupRegister( |
1273 interpreter::Register(receiver_index + i - 1)); | 1125 interpreter::Register(receiver_index + i - 1)); |
1274 } | 1126 } |
1275 Node* value = MakeNode(call_op, static_cast<int>(arity), all, false); | 1127 Node* value = MakeNode(call_op, static_cast<int>(arity), all, false); |
1276 return value; | 1128 return value; |
1277 } | 1129 } |
1278 | 1130 |
1279 | 1131 void BytecodeGraphBuilder::BuildCall() { |
1280 void BytecodeGraphBuilder::BuildCall( | 1132 FrameStateBeforeAndAfter states(this); |
1281 const interpreter::BytecodeArrayIterator& iterator) { | |
1282 FrameStateBeforeAndAfter states(this, iterator); | |
1283 // TODO(rmcilroy): Set receiver_hint correctly based on whether the receiver | 1133 // TODO(rmcilroy): Set receiver_hint correctly based on whether the receiver |
1284 // register has been loaded with null / undefined explicitly or we are sure it | 1134 // register has been loaded with null / undefined explicitly or we are sure it |
1285 // is not null / undefined. | 1135 // is not null / undefined. |
1286 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; | 1136 ConvertReceiverMode receiver_hint = ConvertReceiverMode::kAny; |
1287 Node* callee = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | 1137 Node* callee = |
1288 interpreter::Register receiver = iterator.GetRegisterOperand(1); | 1138 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1289 size_t arg_count = iterator.GetCountOperand(2); | 1139 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
1290 VectorSlotPair feedback = CreateVectorSlotPair(iterator.GetIndexOperand(3)); | 1140 size_t arg_count = bytecode_iterator().GetCountOperand(2); |
| 1141 VectorSlotPair feedback = |
| 1142 CreateVectorSlotPair(bytecode_iterator().GetIndexOperand(3)); |
1291 | 1143 |
1292 // TODO(ishell): provide correct tail_call_mode value to CallFunction. | 1144 // TODO(ishell): provide correct tail_call_mode value to CallFunction. |
1293 const Operator* call = javascript()->CallFunction( | 1145 const Operator* call = javascript()->CallFunction( |
1294 arg_count + 2, language_mode(), feedback, receiver_hint); | 1146 arg_count + 2, language_mode(), feedback, receiver_hint); |
1295 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 2); | 1147 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 2); |
1296 environment()->BindAccumulator(value, &states); | 1148 environment()->BindAccumulator(value, &states); |
1297 } | 1149 } |
1298 | 1150 |
| 1151 void BytecodeGraphBuilder::VisitCall() { BuildCall(); } |
1299 | 1152 |
1300 void BytecodeGraphBuilder::VisitCall( | 1153 void BytecodeGraphBuilder::VisitCallWide() { BuildCall(); } |
1301 const interpreter::BytecodeArrayIterator& iterator) { | |
1302 BuildCall(iterator); | |
1303 } | |
1304 | 1154 |
1305 | 1155 void BytecodeGraphBuilder::BuildCallJSRuntime() { |
1306 void BytecodeGraphBuilder::VisitCallWide( | 1156 FrameStateBeforeAndAfter states(this); |
1307 const interpreter::BytecodeArrayIterator& iterator) { | 1157 Node* callee = |
1308 BuildCall(iterator); | 1158 BuildLoadNativeContextField(bytecode_iterator().GetIndexOperand(0)); |
1309 } | 1159 interpreter::Register receiver = bytecode_iterator().GetRegisterOperand(1); |
1310 | 1160 size_t arg_count = bytecode_iterator().GetCountOperand(2); |
1311 | |
1312 void BytecodeGraphBuilder::BuildCallJSRuntime( | |
1313 const interpreter::BytecodeArrayIterator& iterator) { | |
1314 FrameStateBeforeAndAfter states(this, iterator); | |
1315 Node* callee = BuildLoadNativeContextField(iterator.GetIndexOperand(0)); | |
1316 interpreter::Register receiver = iterator.GetRegisterOperand(1); | |
1317 size_t arg_count = iterator.GetCountOperand(2); | |
1318 | 1161 |
1319 // Create node to perform the JS runtime call. | 1162 // Create node to perform the JS runtime call. |
1320 const Operator* call = | 1163 const Operator* call = |
1321 javascript()->CallFunction(arg_count + 2, language_mode()); | 1164 javascript()->CallFunction(arg_count + 2, language_mode()); |
1322 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 2); | 1165 Node* value = ProcessCallArguments(call, callee, receiver, arg_count + 2); |
1323 environment()->BindAccumulator(value, &states); | 1166 environment()->BindAccumulator(value, &states); |
1324 } | 1167 } |
1325 | 1168 |
| 1169 void BytecodeGraphBuilder::VisitCallJSRuntime() { BuildCallJSRuntime(); } |
1326 | 1170 |
1327 void BytecodeGraphBuilder::VisitCallJSRuntime( | 1171 void BytecodeGraphBuilder::VisitCallJSRuntimeWide() { BuildCallJSRuntime(); } |
1328 const interpreter::BytecodeArrayIterator& iterator) { | |
1329 BuildCallJSRuntime(iterator); | |
1330 } | |
1331 | |
1332 | |
1333 void BytecodeGraphBuilder::VisitCallJSRuntimeWide( | |
1334 const interpreter::BytecodeArrayIterator& iterator) { | |
1335 BuildCallJSRuntime(iterator); | |
1336 } | |
1337 | |
1338 | 1172 |
1339 Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments( | 1173 Node* BytecodeGraphBuilder::ProcessCallRuntimeArguments( |
1340 const Operator* call_runtime_op, interpreter::Register first_arg, | 1174 const Operator* call_runtime_op, interpreter::Register first_arg, |
1341 size_t arity) { | 1175 size_t arity) { |
1342 Node** all = info()->zone()->NewArray<Node*>(arity); | 1176 Node** all = info()->zone()->NewArray<Node*>(arity); |
1343 int first_arg_index = first_arg.index(); | 1177 int first_arg_index = first_arg.index(); |
1344 for (int i = 0; i < static_cast<int>(arity); ++i) { | 1178 for (int i = 0; i < static_cast<int>(arity); ++i) { |
1345 all[i] = environment()->LookupRegister( | 1179 all[i] = environment()->LookupRegister( |
1346 interpreter::Register(first_arg_index + i)); | 1180 interpreter::Register(first_arg_index + i)); |
1347 } | 1181 } |
1348 Node* value = MakeNode(call_runtime_op, static_cast<int>(arity), all, false); | 1182 Node* value = MakeNode(call_runtime_op, static_cast<int>(arity), all, false); |
1349 return value; | 1183 return value; |
1350 } | 1184 } |
1351 | 1185 |
1352 | 1186 void BytecodeGraphBuilder::BuildCallRuntime() { |
1353 void BytecodeGraphBuilder::BuildCallRuntime( | 1187 FrameStateBeforeAndAfter states(this); |
1354 const interpreter::BytecodeArrayIterator& iterator) { | |
1355 FrameStateBeforeAndAfter states(this, iterator); | |
1356 Runtime::FunctionId functionId = | 1188 Runtime::FunctionId functionId = |
1357 static_cast<Runtime::FunctionId>(iterator.GetIndexOperand(0)); | 1189 static_cast<Runtime::FunctionId>(bytecode_iterator().GetIndexOperand(0)); |
1358 interpreter::Register first_arg = iterator.GetRegisterOperand(1); | 1190 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
1359 size_t arg_count = iterator.GetCountOperand(2); | 1191 size_t arg_count = bytecode_iterator().GetCountOperand(2); |
1360 | 1192 |
1361 // Create node to perform the runtime call. | 1193 // Create node to perform the runtime call. |
1362 const Operator* call = javascript()->CallRuntime(functionId, arg_count); | 1194 const Operator* call = javascript()->CallRuntime(functionId, arg_count); |
1363 Node* value = ProcessCallRuntimeArguments(call, first_arg, arg_count); | 1195 Node* value = ProcessCallRuntimeArguments(call, first_arg, arg_count); |
1364 environment()->BindAccumulator(value, &states); | 1196 environment()->BindAccumulator(value, &states); |
1365 } | 1197 } |
1366 | 1198 |
| 1199 void BytecodeGraphBuilder::VisitCallRuntime() { BuildCallRuntime(); } |
1367 | 1200 |
1368 void BytecodeGraphBuilder::VisitCallRuntime( | 1201 void BytecodeGraphBuilder::VisitCallRuntimeWide() { BuildCallRuntime(); } |
1369 const interpreter::BytecodeArrayIterator& iterator) { | |
1370 BuildCallRuntime(iterator); | |
1371 } | |
1372 | 1202 |
1373 | 1203 void BytecodeGraphBuilder::BuildCallRuntimeForPair() { |
1374 void BytecodeGraphBuilder::VisitCallRuntimeWide( | 1204 FrameStateBeforeAndAfter states(this); |
1375 const interpreter::BytecodeArrayIterator& iterator) { | |
1376 BuildCallRuntime(iterator); | |
1377 } | |
1378 | |
1379 | |
1380 void BytecodeGraphBuilder::BuildCallRuntimeForPair( | |
1381 const interpreter::BytecodeArrayIterator& iterator) { | |
1382 FrameStateBeforeAndAfter states(this, iterator); | |
1383 Runtime::FunctionId functionId = | 1205 Runtime::FunctionId functionId = |
1384 static_cast<Runtime::FunctionId>(iterator.GetIndexOperand(0)); | 1206 static_cast<Runtime::FunctionId>(bytecode_iterator().GetIndexOperand(0)); |
1385 interpreter::Register first_arg = iterator.GetRegisterOperand(1); | 1207 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
1386 size_t arg_count = iterator.GetCountOperand(2); | 1208 size_t arg_count = bytecode_iterator().GetCountOperand(2); |
1387 interpreter::Register first_return = iterator.GetRegisterOperand(3); | 1209 interpreter::Register first_return = |
| 1210 bytecode_iterator().GetRegisterOperand(3); |
1388 | 1211 |
1389 // Create node to perform the runtime call. | 1212 // Create node to perform the runtime call. |
1390 const Operator* call = javascript()->CallRuntime(functionId, arg_count); | 1213 const Operator* call = javascript()->CallRuntime(functionId, arg_count); |
1391 Node* return_pair = ProcessCallRuntimeArguments(call, first_arg, arg_count); | 1214 Node* return_pair = ProcessCallRuntimeArguments(call, first_arg, arg_count); |
1392 environment()->BindRegistersToProjections(first_return, return_pair, &states); | 1215 environment()->BindRegistersToProjections(first_return, return_pair, &states); |
1393 } | 1216 } |
1394 | 1217 |
| 1218 void BytecodeGraphBuilder::VisitCallRuntimeForPair() { |
| 1219 BuildCallRuntimeForPair(); |
| 1220 } |
1395 | 1221 |
1396 void BytecodeGraphBuilder::VisitCallRuntimeForPair( | 1222 void BytecodeGraphBuilder::VisitCallRuntimeForPairWide() { |
1397 const interpreter::BytecodeArrayIterator& iterator) { | 1223 BuildCallRuntimeForPair(); |
1398 BuildCallRuntimeForPair(iterator); | |
1399 } | 1224 } |
1400 | 1225 |
1401 | 1226 |
1402 void BytecodeGraphBuilder::VisitCallRuntimeForPairWide( | |
1403 const interpreter::BytecodeArrayIterator& iterator) { | |
1404 BuildCallRuntimeForPair(iterator); | |
1405 } | |
1406 | |
1407 | |
1408 Node* BytecodeGraphBuilder::ProcessCallNewArguments( | 1227 Node* BytecodeGraphBuilder::ProcessCallNewArguments( |
1409 const Operator* call_new_op, interpreter::Register callee, | 1228 const Operator* call_new_op, interpreter::Register callee, |
1410 interpreter::Register first_arg, size_t arity) { | 1229 interpreter::Register first_arg, size_t arity) { |
1411 Node** all = info()->zone()->NewArray<Node*>(arity); | 1230 Node** all = info()->zone()->NewArray<Node*>(arity); |
1412 all[0] = environment()->LookupRegister(callee); | 1231 all[0] = environment()->LookupRegister(callee); |
1413 int first_arg_index = first_arg.index(); | 1232 int first_arg_index = first_arg.index(); |
1414 for (int i = 1; i < static_cast<int>(arity) - 1; ++i) { | 1233 for (int i = 1; i < static_cast<int>(arity) - 1; ++i) { |
1415 all[i] = environment()->LookupRegister( | 1234 all[i] = environment()->LookupRegister( |
1416 interpreter::Register(first_arg_index + i - 1)); | 1235 interpreter::Register(first_arg_index + i - 1)); |
1417 } | 1236 } |
1418 // Original constructor is the same as the callee. | 1237 // Original constructor is the same as the callee. |
1419 all[arity - 1] = environment()->LookupRegister(callee); | 1238 all[arity - 1] = environment()->LookupRegister(callee); |
1420 Node* value = MakeNode(call_new_op, static_cast<int>(arity), all, false); | 1239 Node* value = MakeNode(call_new_op, static_cast<int>(arity), all, false); |
1421 return value; | 1240 return value; |
1422 } | 1241 } |
1423 | 1242 |
1424 | 1243 void BytecodeGraphBuilder::BuildCallConstruct() { |
1425 void BytecodeGraphBuilder::BuildCallConstruct( | 1244 FrameStateBeforeAndAfter states(this); |
1426 const interpreter::BytecodeArrayIterator& iterator) { | 1245 interpreter::Register callee = bytecode_iterator().GetRegisterOperand(0); |
1427 FrameStateBeforeAndAfter states(this, iterator); | 1246 interpreter::Register first_arg = bytecode_iterator().GetRegisterOperand(1); |
1428 interpreter::Register callee = iterator.GetRegisterOperand(0); | 1247 size_t arg_count = bytecode_iterator().GetCountOperand(2); |
1429 interpreter::Register first_arg = iterator.GetRegisterOperand(1); | |
1430 size_t arg_count = iterator.GetCountOperand(2); | |
1431 | 1248 |
1432 // TODO(turbofan): Pass the feedback here. | 1249 // TODO(turbofan): Pass the feedback here. |
1433 const Operator* call = javascript()->CallConstruct( | 1250 const Operator* call = javascript()->CallConstruct( |
1434 static_cast<int>(arg_count) + 2, VectorSlotPair()); | 1251 static_cast<int>(arg_count) + 2, VectorSlotPair()); |
1435 Node* value = ProcessCallNewArguments(call, callee, first_arg, arg_count + 2); | 1252 Node* value = ProcessCallNewArguments(call, callee, first_arg, arg_count + 2); |
1436 environment()->BindAccumulator(value, &states); | 1253 environment()->BindAccumulator(value, &states); |
1437 } | 1254 } |
1438 | 1255 |
| 1256 void BytecodeGraphBuilder::VisitNew() { BuildCallConstruct(); } |
1439 | 1257 |
1440 void BytecodeGraphBuilder::VisitNew( | 1258 void BytecodeGraphBuilder::VisitNewWide() { BuildCallConstruct(); } |
1441 const interpreter::BytecodeArrayIterator& iterator) { | |
1442 BuildCallConstruct(iterator); | |
1443 } | |
1444 | 1259 |
1445 | 1260 void BytecodeGraphBuilder::VisitThrow() { |
1446 void BytecodeGraphBuilder::VisitNewWide( | 1261 FrameStateBeforeAndAfter states(this); |
1447 const interpreter::BytecodeArrayIterator& iterator) { | |
1448 BuildCallConstruct(iterator); | |
1449 } | |
1450 | |
1451 | |
1452 void BytecodeGraphBuilder::VisitThrow( | |
1453 const interpreter::BytecodeArrayIterator& iterator) { | |
1454 FrameStateBeforeAndAfter states(this, iterator); | |
1455 Node* value = environment()->LookupAccumulator(); | 1262 Node* value = environment()->LookupAccumulator(); |
1456 Node* call = NewNode(javascript()->CallRuntime(Runtime::kThrow), value); | 1263 Node* call = NewNode(javascript()->CallRuntime(Runtime::kThrow), value); |
1457 environment()->RecordAfterState(call, &states); | 1264 environment()->RecordAfterState(call, &states); |
1458 Node* control = NewNode(common()->Throw(), value); | 1265 Node* control = NewNode(common()->Throw(), value); |
1459 UpdateControlDependencyToLeaveFunction(control); | 1266 UpdateControlDependencyToLeaveFunction(control); |
1460 } | 1267 } |
1461 | 1268 |
1462 | 1269 void BytecodeGraphBuilder::VisitReThrow() { |
1463 void BytecodeGraphBuilder::VisitReThrow( | 1270 FrameStateBeforeAndAfter states(this); |
1464 const interpreter::BytecodeArrayIterator& iterator) { | |
1465 FrameStateBeforeAndAfter states(this, iterator); | |
1466 Node* value = environment()->LookupAccumulator(); | 1271 Node* value = environment()->LookupAccumulator(); |
1467 Node* call = NewNode(javascript()->CallRuntime(Runtime::kReThrow), value); | 1272 Node* call = NewNode(javascript()->CallRuntime(Runtime::kReThrow), value); |
1468 environment()->RecordAfterState(call, &states); | 1273 environment()->RecordAfterState(call, &states); |
1469 Node* control = NewNode(common()->Throw(), value); | 1274 Node* control = NewNode(common()->Throw(), value); |
1470 UpdateControlDependencyToLeaveFunction(control); | 1275 UpdateControlDependencyToLeaveFunction(control); |
1471 } | 1276 } |
1472 | 1277 |
1473 | 1278 void BytecodeGraphBuilder::BuildBinaryOp(const Operator* js_op) { |
1474 void BytecodeGraphBuilder::BuildBinaryOp( | 1279 FrameStateBeforeAndAfter states(this); |
1475 const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) { | 1280 Node* left = |
1476 FrameStateBeforeAndAfter states(this, iterator); | 1281 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1477 Node* left = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | |
1478 Node* right = environment()->LookupAccumulator(); | 1282 Node* right = environment()->LookupAccumulator(); |
1479 Node* node = NewNode(js_op, left, right); | 1283 Node* node = NewNode(js_op, left, right); |
1480 environment()->BindAccumulator(node, &states); | 1284 environment()->BindAccumulator(node, &states); |
1481 } | 1285 } |
1482 | 1286 |
1483 | 1287 void BytecodeGraphBuilder::VisitAdd() { |
1484 void BytecodeGraphBuilder::VisitAdd( | |
1485 const interpreter::BytecodeArrayIterator& iterator) { | |
1486 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1288 BinaryOperationHints hints = BinaryOperationHints::Any(); |
1487 BuildBinaryOp(javascript()->Add(language_mode(), hints), iterator); | 1289 BuildBinaryOp(javascript()->Add(language_mode(), hints)); |
1488 } | 1290 } |
1489 | 1291 |
1490 | 1292 void BytecodeGraphBuilder::VisitSub() { |
1491 void BytecodeGraphBuilder::VisitSub( | |
1492 const interpreter::BytecodeArrayIterator& iterator) { | |
1493 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1293 BinaryOperationHints hints = BinaryOperationHints::Any(); |
1494 BuildBinaryOp(javascript()->Subtract(language_mode(), hints), iterator); | 1294 BuildBinaryOp(javascript()->Subtract(language_mode(), hints)); |
1495 } | 1295 } |
1496 | 1296 |
1497 | 1297 void BytecodeGraphBuilder::VisitMul() { |
1498 void BytecodeGraphBuilder::VisitMul( | |
1499 const interpreter::BytecodeArrayIterator& iterator) { | |
1500 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1298 BinaryOperationHints hints = BinaryOperationHints::Any(); |
1501 BuildBinaryOp(javascript()->Multiply(language_mode(), hints), iterator); | 1299 BuildBinaryOp(javascript()->Multiply(language_mode(), hints)); |
1502 } | 1300 } |
1503 | 1301 |
1504 | 1302 void BytecodeGraphBuilder::VisitDiv() { |
1505 void BytecodeGraphBuilder::VisitDiv( | |
1506 const interpreter::BytecodeArrayIterator& iterator) { | |
1507 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1303 BinaryOperationHints hints = BinaryOperationHints::Any(); |
1508 BuildBinaryOp(javascript()->Divide(language_mode(), hints), iterator); | 1304 BuildBinaryOp(javascript()->Divide(language_mode(), hints)); |
1509 } | 1305 } |
1510 | 1306 |
1511 | 1307 void BytecodeGraphBuilder::VisitMod() { |
1512 void BytecodeGraphBuilder::VisitMod( | |
1513 const interpreter::BytecodeArrayIterator& iterator) { | |
1514 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1308 BinaryOperationHints hints = BinaryOperationHints::Any(); |
1515 BuildBinaryOp(javascript()->Modulus(language_mode(), hints), iterator); | 1309 BuildBinaryOp(javascript()->Modulus(language_mode(), hints)); |
1516 } | 1310 } |
1517 | 1311 |
1518 | 1312 void BytecodeGraphBuilder::VisitBitwiseOr() { |
1519 void BytecodeGraphBuilder::VisitBitwiseOr( | |
1520 const interpreter::BytecodeArrayIterator& iterator) { | |
1521 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1313 BinaryOperationHints hints = BinaryOperationHints::Any(); |
1522 BuildBinaryOp(javascript()->BitwiseOr(language_mode(), hints), iterator); | 1314 BuildBinaryOp(javascript()->BitwiseOr(language_mode(), hints)); |
1523 } | 1315 } |
1524 | 1316 |
1525 | 1317 void BytecodeGraphBuilder::VisitBitwiseXor() { |
1526 void BytecodeGraphBuilder::VisitBitwiseXor( | |
1527 const interpreter::BytecodeArrayIterator& iterator) { | |
1528 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1318 BinaryOperationHints hints = BinaryOperationHints::Any(); |
1529 BuildBinaryOp(javascript()->BitwiseXor(language_mode(), hints), iterator); | 1319 BuildBinaryOp(javascript()->BitwiseXor(language_mode(), hints)); |
1530 } | 1320 } |
1531 | 1321 |
1532 | 1322 void BytecodeGraphBuilder::VisitBitwiseAnd() { |
1533 void BytecodeGraphBuilder::VisitBitwiseAnd( | |
1534 const interpreter::BytecodeArrayIterator& iterator) { | |
1535 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1323 BinaryOperationHints hints = BinaryOperationHints::Any(); |
1536 BuildBinaryOp(javascript()->BitwiseAnd(language_mode(), hints), iterator); | 1324 BuildBinaryOp(javascript()->BitwiseAnd(language_mode(), hints)); |
1537 } | 1325 } |
1538 | 1326 |
1539 | 1327 void BytecodeGraphBuilder::VisitShiftLeft() { |
1540 void BytecodeGraphBuilder::VisitShiftLeft( | |
1541 const interpreter::BytecodeArrayIterator& iterator) { | |
1542 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1328 BinaryOperationHints hints = BinaryOperationHints::Any(); |
1543 BuildBinaryOp(javascript()->ShiftLeft(language_mode(), hints), iterator); | 1329 BuildBinaryOp(javascript()->ShiftLeft(language_mode(), hints)); |
1544 } | 1330 } |
1545 | 1331 |
1546 | 1332 void BytecodeGraphBuilder::VisitShiftRight() { |
1547 void BytecodeGraphBuilder::VisitShiftRight( | |
1548 const interpreter::BytecodeArrayIterator& iterator) { | |
1549 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1333 BinaryOperationHints hints = BinaryOperationHints::Any(); |
1550 BuildBinaryOp(javascript()->ShiftRight(language_mode(), hints), iterator); | 1334 BuildBinaryOp(javascript()->ShiftRight(language_mode(), hints)); |
1551 } | 1335 } |
1552 | 1336 |
1553 | 1337 void BytecodeGraphBuilder::VisitShiftRightLogical() { |
1554 void BytecodeGraphBuilder::VisitShiftRightLogical( | |
1555 const interpreter::BytecodeArrayIterator& iterator) { | |
1556 BinaryOperationHints hints = BinaryOperationHints::Any(); | 1338 BinaryOperationHints hints = BinaryOperationHints::Any(); |
1557 BuildBinaryOp(javascript()->ShiftRightLogical(language_mode(), hints), | 1339 BuildBinaryOp(javascript()->ShiftRightLogical(language_mode(), hints)); |
1558 iterator); | |
1559 } | 1340 } |
1560 | 1341 |
1561 | 1342 void BytecodeGraphBuilder::VisitInc() { |
1562 void BytecodeGraphBuilder::VisitInc( | 1343 FrameStateBeforeAndAfter states(this); |
1563 const interpreter::BytecodeArrayIterator& iterator) { | |
1564 FrameStateBeforeAndAfter states(this, iterator); | |
1565 const Operator* js_op = | 1344 const Operator* js_op = |
1566 javascript()->Add(language_mode(), BinaryOperationHints::Any()); | 1345 javascript()->Add(language_mode(), BinaryOperationHints::Any()); |
1567 Node* node = NewNode(js_op, environment()->LookupAccumulator(), | 1346 Node* node = NewNode(js_op, environment()->LookupAccumulator(), |
1568 jsgraph()->OneConstant()); | 1347 jsgraph()->OneConstant()); |
1569 environment()->BindAccumulator(node, &states); | 1348 environment()->BindAccumulator(node, &states); |
1570 } | 1349 } |
1571 | 1350 |
1572 | 1351 void BytecodeGraphBuilder::VisitDec() { |
1573 void BytecodeGraphBuilder::VisitDec( | 1352 FrameStateBeforeAndAfter states(this); |
1574 const interpreter::BytecodeArrayIterator& iterator) { | |
1575 FrameStateBeforeAndAfter states(this, iterator); | |
1576 const Operator* js_op = | 1353 const Operator* js_op = |
1577 javascript()->Subtract(language_mode(), BinaryOperationHints::Any()); | 1354 javascript()->Subtract(language_mode(), BinaryOperationHints::Any()); |
1578 Node* node = NewNode(js_op, environment()->LookupAccumulator(), | 1355 Node* node = NewNode(js_op, environment()->LookupAccumulator(), |
1579 jsgraph()->OneConstant()); | 1356 jsgraph()->OneConstant()); |
1580 environment()->BindAccumulator(node, &states); | 1357 environment()->BindAccumulator(node, &states); |
1581 } | 1358 } |
1582 | 1359 |
1583 | 1360 void BytecodeGraphBuilder::VisitLogicalNot() { |
1584 void BytecodeGraphBuilder::VisitLogicalNot( | |
1585 const interpreter::BytecodeArrayIterator& iterator) { | |
1586 Node* value = NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), | 1361 Node* value = NewNode(javascript()->ToBoolean(ToBooleanHint::kAny), |
1587 environment()->LookupAccumulator()); | 1362 environment()->LookupAccumulator()); |
1588 Node* node = NewNode(common()->Select(MachineRepresentation::kTagged), value, | 1363 Node* node = NewNode(common()->Select(MachineRepresentation::kTagged), value, |
1589 jsgraph()->FalseConstant(), jsgraph()->TrueConstant()); | 1364 jsgraph()->FalseConstant(), jsgraph()->TrueConstant()); |
1590 environment()->BindAccumulator(node); | 1365 environment()->BindAccumulator(node); |
1591 } | 1366 } |
1592 | 1367 |
1593 | 1368 void BytecodeGraphBuilder::VisitTypeOf() { |
1594 void BytecodeGraphBuilder::VisitTypeOf( | |
1595 const interpreter::BytecodeArrayIterator& iterator) { | |
1596 Node* node = | 1369 Node* node = |
1597 NewNode(javascript()->TypeOf(), environment()->LookupAccumulator()); | 1370 NewNode(javascript()->TypeOf(), environment()->LookupAccumulator()); |
1598 environment()->BindAccumulator(node); | 1371 environment()->BindAccumulator(node); |
1599 } | 1372 } |
1600 | 1373 |
1601 | 1374 void BytecodeGraphBuilder::BuildDelete() { |
1602 void BytecodeGraphBuilder::BuildDelete( | 1375 FrameStateBeforeAndAfter states(this); |
1603 const interpreter::BytecodeArrayIterator& iterator) { | |
1604 FrameStateBeforeAndAfter states(this, iterator); | |
1605 Node* key = environment()->LookupAccumulator(); | 1376 Node* key = environment()->LookupAccumulator(); |
1606 Node* object = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | 1377 Node* object = |
| 1378 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1607 Node* node = | 1379 Node* node = |
1608 NewNode(javascript()->DeleteProperty(language_mode()), object, key); | 1380 NewNode(javascript()->DeleteProperty(language_mode()), object, key); |
1609 environment()->BindAccumulator(node, &states); | 1381 environment()->BindAccumulator(node, &states); |
1610 } | 1382 } |
1611 | 1383 |
1612 | 1384 void BytecodeGraphBuilder::VisitDeletePropertyStrict() { |
1613 void BytecodeGraphBuilder::VisitDeletePropertyStrict( | |
1614 const interpreter::BytecodeArrayIterator& iterator) { | |
1615 DCHECK(is_strict(language_mode())); | 1385 DCHECK(is_strict(language_mode())); |
1616 BuildDelete(iterator); | 1386 BuildDelete(); |
1617 } | 1387 } |
1618 | 1388 |
1619 | 1389 void BytecodeGraphBuilder::VisitDeletePropertySloppy() { |
1620 void BytecodeGraphBuilder::VisitDeletePropertySloppy( | |
1621 const interpreter::BytecodeArrayIterator& iterator) { | |
1622 DCHECK(is_sloppy(language_mode())); | 1390 DCHECK(is_sloppy(language_mode())); |
1623 BuildDelete(iterator); | 1391 BuildDelete(); |
1624 } | 1392 } |
1625 | 1393 |
1626 | 1394 void BytecodeGraphBuilder::VisitDeleteLookupSlot() { |
1627 void BytecodeGraphBuilder::VisitDeleteLookupSlot( | 1395 FrameStateBeforeAndAfter states(this); |
1628 const interpreter::BytecodeArrayIterator& iterator) { | |
1629 FrameStateBeforeAndAfter states(this, iterator); | |
1630 Node* name = environment()->LookupAccumulator(); | 1396 Node* name = environment()->LookupAccumulator(); |
1631 const Operator* op = javascript()->CallRuntime(Runtime::kDeleteLookupSlot); | 1397 const Operator* op = javascript()->CallRuntime(Runtime::kDeleteLookupSlot); |
1632 Node* result = NewNode(op, environment()->Context(), name); | 1398 Node* result = NewNode(op, environment()->Context(), name); |
1633 environment()->BindAccumulator(result, &states); | 1399 environment()->BindAccumulator(result, &states); |
1634 } | 1400 } |
1635 | 1401 |
1636 | 1402 void BytecodeGraphBuilder::BuildCompareOp(const Operator* js_op) { |
1637 void BytecodeGraphBuilder::BuildCompareOp( | 1403 FrameStateBeforeAndAfter states(this); |
1638 const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) { | 1404 Node* left = |
1639 FrameStateBeforeAndAfter states(this, iterator); | 1405 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1640 Node* left = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | |
1641 Node* right = environment()->LookupAccumulator(); | 1406 Node* right = environment()->LookupAccumulator(); |
1642 Node* node = NewNode(js_op, left, right); | 1407 Node* node = NewNode(js_op, left, right); |
1643 environment()->BindAccumulator(node, &states); | 1408 environment()->BindAccumulator(node, &states); |
1644 } | 1409 } |
1645 | 1410 |
1646 | 1411 void BytecodeGraphBuilder::VisitTestEqual() { |
1647 void BytecodeGraphBuilder::VisitTestEqual( | 1412 BuildCompareOp(javascript()->Equal()); |
1648 const interpreter::BytecodeArrayIterator& iterator) { | 1413 } |
1649 BuildCompareOp(javascript()->Equal(), iterator); | 1414 |
1650 } | 1415 void BytecodeGraphBuilder::VisitTestNotEqual() { |
1651 | 1416 BuildCompareOp(javascript()->NotEqual()); |
1652 | 1417 } |
1653 void BytecodeGraphBuilder::VisitTestNotEqual( | 1418 |
1654 const interpreter::BytecodeArrayIterator& iterator) { | 1419 void BytecodeGraphBuilder::VisitTestEqualStrict() { |
1655 BuildCompareOp(javascript()->NotEqual(), iterator); | 1420 BuildCompareOp(javascript()->StrictEqual()); |
1656 } | 1421 } |
1657 | 1422 |
1658 | 1423 void BytecodeGraphBuilder::VisitTestNotEqualStrict() { |
1659 void BytecodeGraphBuilder::VisitTestEqualStrict( | 1424 BuildCompareOp(javascript()->StrictNotEqual()); |
1660 const interpreter::BytecodeArrayIterator& iterator) { | 1425 } |
1661 BuildCompareOp(javascript()->StrictEqual(), iterator); | 1426 |
1662 } | 1427 void BytecodeGraphBuilder::VisitTestLessThan() { |
1663 | 1428 BuildCompareOp(javascript()->LessThan(language_mode())); |
1664 | 1429 } |
1665 void BytecodeGraphBuilder::VisitTestNotEqualStrict( | 1430 |
1666 const interpreter::BytecodeArrayIterator& iterator) { | 1431 void BytecodeGraphBuilder::VisitTestGreaterThan() { |
1667 BuildCompareOp(javascript()->StrictNotEqual(), iterator); | 1432 BuildCompareOp(javascript()->GreaterThan(language_mode())); |
1668 } | 1433 } |
1669 | 1434 |
1670 | 1435 void BytecodeGraphBuilder::VisitTestLessThanOrEqual() { |
1671 void BytecodeGraphBuilder::VisitTestLessThan( | 1436 BuildCompareOp(javascript()->LessThanOrEqual(language_mode())); |
1672 const interpreter::BytecodeArrayIterator& iterator) { | 1437 } |
1673 BuildCompareOp(javascript()->LessThan(language_mode()), iterator); | 1438 |
1674 } | 1439 void BytecodeGraphBuilder::VisitTestGreaterThanOrEqual() { |
1675 | 1440 BuildCompareOp(javascript()->GreaterThanOrEqual(language_mode())); |
1676 | 1441 } |
1677 void BytecodeGraphBuilder::VisitTestGreaterThan( | 1442 |
1678 const interpreter::BytecodeArrayIterator& iterator) { | 1443 void BytecodeGraphBuilder::VisitTestIn() { |
1679 BuildCompareOp(javascript()->GreaterThan(language_mode()), iterator); | 1444 BuildCompareOp(javascript()->HasProperty()); |
1680 } | 1445 } |
1681 | 1446 |
1682 | 1447 void BytecodeGraphBuilder::VisitTestInstanceOf() { |
1683 void BytecodeGraphBuilder::VisitTestLessThanOrEqual( | 1448 BuildCompareOp(javascript()->InstanceOf()); |
1684 const interpreter::BytecodeArrayIterator& iterator) { | 1449 } |
1685 BuildCompareOp(javascript()->LessThanOrEqual(language_mode()), iterator); | 1450 |
1686 } | 1451 void BytecodeGraphBuilder::BuildCastOperator(const Operator* js_op) { |
1687 | 1452 FrameStateBeforeAndAfter states(this); |
1688 | |
1689 void BytecodeGraphBuilder::VisitTestGreaterThanOrEqual( | |
1690 const interpreter::BytecodeArrayIterator& iterator) { | |
1691 BuildCompareOp(javascript()->GreaterThanOrEqual(language_mode()), iterator); | |
1692 } | |
1693 | |
1694 | |
1695 void BytecodeGraphBuilder::VisitTestIn( | |
1696 const interpreter::BytecodeArrayIterator& iterator) { | |
1697 BuildCompareOp(javascript()->HasProperty(), iterator); | |
1698 } | |
1699 | |
1700 | |
1701 void BytecodeGraphBuilder::VisitTestInstanceOf( | |
1702 const interpreter::BytecodeArrayIterator& iterator) { | |
1703 BuildCompareOp(javascript()->InstanceOf(), iterator); | |
1704 } | |
1705 | |
1706 | |
1707 void BytecodeGraphBuilder::BuildCastOperator( | |
1708 const Operator* js_op, const interpreter::BytecodeArrayIterator& iterator) { | |
1709 FrameStateBeforeAndAfter states(this, iterator); | |
1710 Node* node = NewNode(js_op, environment()->LookupAccumulator()); | 1453 Node* node = NewNode(js_op, environment()->LookupAccumulator()); |
1711 environment()->BindAccumulator(node, &states); | 1454 environment()->BindAccumulator(node, &states); |
1712 } | 1455 } |
1713 | 1456 |
1714 | 1457 void BytecodeGraphBuilder::VisitToName() { |
1715 void BytecodeGraphBuilder::VisitToName( | 1458 BuildCastOperator(javascript()->ToName()); |
1716 const interpreter::BytecodeArrayIterator& iterator) { | 1459 } |
1717 BuildCastOperator(javascript()->ToName(), iterator); | 1460 |
1718 } | 1461 void BytecodeGraphBuilder::VisitToObject() { |
1719 | 1462 BuildCastOperator(javascript()->ToObject()); |
1720 | 1463 } |
1721 void BytecodeGraphBuilder::VisitToObject( | 1464 |
1722 const interpreter::BytecodeArrayIterator& iterator) { | 1465 void BytecodeGraphBuilder::VisitToNumber() { |
1723 BuildCastOperator(javascript()->ToObject(), iterator); | 1466 BuildCastOperator(javascript()->ToNumber()); |
1724 } | 1467 } |
1725 | 1468 |
1726 | 1469 void BytecodeGraphBuilder::VisitJump() { BuildJump(); } |
1727 void BytecodeGraphBuilder::VisitToNumber( | 1470 |
1728 const interpreter::BytecodeArrayIterator& iterator) { | 1471 void BytecodeGraphBuilder::VisitJumpConstant() { BuildJump(); } |
1729 BuildCastOperator(javascript()->ToNumber(), iterator); | 1472 |
1730 } | 1473 void BytecodeGraphBuilder::VisitJumpConstantWide() { BuildJump(); } |
1731 | 1474 |
1732 | 1475 void BytecodeGraphBuilder::VisitJumpIfTrue() { |
1733 void BytecodeGraphBuilder::VisitJump( | |
1734 const interpreter::BytecodeArrayIterator& iterator) { | |
1735 BuildJump(); | |
1736 } | |
1737 | |
1738 | |
1739 void BytecodeGraphBuilder::VisitJumpConstant( | |
1740 const interpreter::BytecodeArrayIterator& iterator) { | |
1741 BuildJump(); | |
1742 } | |
1743 | |
1744 | |
1745 void BytecodeGraphBuilder::VisitJumpConstantWide( | |
1746 const interpreter::BytecodeArrayIterator& iterator) { | |
1747 BuildJump(); | |
1748 } | |
1749 | |
1750 | |
1751 void BytecodeGraphBuilder::VisitJumpIfTrue( | |
1752 const interpreter::BytecodeArrayIterator& iterator) { | |
1753 BuildJumpIfEqual(jsgraph()->TrueConstant()); | 1476 BuildJumpIfEqual(jsgraph()->TrueConstant()); |
1754 } | 1477 } |
1755 | 1478 |
1756 | 1479 void BytecodeGraphBuilder::VisitJumpIfTrueConstant() { |
1757 void BytecodeGraphBuilder::VisitJumpIfTrueConstant( | |
1758 const interpreter::BytecodeArrayIterator& iterator) { | |
1759 BuildJumpIfEqual(jsgraph()->TrueConstant()); | 1480 BuildJumpIfEqual(jsgraph()->TrueConstant()); |
1760 } | 1481 } |
1761 | 1482 |
1762 | 1483 void BytecodeGraphBuilder::VisitJumpIfTrueConstantWide() { |
1763 void BytecodeGraphBuilder::VisitJumpIfTrueConstantWide( | |
1764 const interpreter::BytecodeArrayIterator& iterator) { | |
1765 BuildJumpIfEqual(jsgraph()->TrueConstant()); | 1484 BuildJumpIfEqual(jsgraph()->TrueConstant()); |
1766 } | 1485 } |
1767 | 1486 |
1768 | 1487 void BytecodeGraphBuilder::VisitJumpIfFalse() { |
1769 void BytecodeGraphBuilder::VisitJumpIfFalse( | |
1770 const interpreter::BytecodeArrayIterator& iterator) { | |
1771 BuildJumpIfEqual(jsgraph()->FalseConstant()); | 1488 BuildJumpIfEqual(jsgraph()->FalseConstant()); |
1772 } | 1489 } |
1773 | 1490 |
1774 | 1491 void BytecodeGraphBuilder::VisitJumpIfFalseConstant() { |
1775 void BytecodeGraphBuilder::VisitJumpIfFalseConstant( | |
1776 const interpreter::BytecodeArrayIterator& iterator) { | |
1777 BuildJumpIfEqual(jsgraph()->FalseConstant()); | 1492 BuildJumpIfEqual(jsgraph()->FalseConstant()); |
1778 } | 1493 } |
1779 | 1494 |
1780 | 1495 void BytecodeGraphBuilder::VisitJumpIfFalseConstantWide() { |
1781 void BytecodeGraphBuilder::VisitJumpIfFalseConstantWide( | |
1782 const interpreter::BytecodeArrayIterator& iterator) { | |
1783 BuildJumpIfEqual(jsgraph()->FalseConstant()); | 1496 BuildJumpIfEqual(jsgraph()->FalseConstant()); |
1784 } | 1497 } |
1785 | 1498 |
1786 | 1499 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrue() { |
1787 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrue( | |
1788 const interpreter::BytecodeArrayIterator& iterator) { | |
1789 BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); | 1500 BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); |
1790 } | 1501 } |
1791 | 1502 |
1792 | 1503 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstant() { |
1793 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstant( | |
1794 const interpreter::BytecodeArrayIterator& iterator) { | |
1795 BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); | 1504 BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); |
1796 } | 1505 } |
1797 | 1506 |
1798 | 1507 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstantWide() { |
1799 void BytecodeGraphBuilder::VisitJumpIfToBooleanTrueConstantWide( | |
1800 const interpreter::BytecodeArrayIterator& iterator) { | |
1801 BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); | 1508 BuildJumpIfToBooleanEqual(jsgraph()->TrueConstant()); |
1802 } | 1509 } |
1803 | 1510 |
1804 | 1511 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalse() { |
1805 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalse( | |
1806 const interpreter::BytecodeArrayIterator& iterator) { | |
1807 BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); | 1512 BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); |
1808 } | 1513 } |
1809 | 1514 |
1810 | 1515 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstant() { |
1811 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstant( | |
1812 const interpreter::BytecodeArrayIterator& iterator) { | |
1813 BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); | 1516 BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); |
1814 } | 1517 } |
1815 | 1518 |
1816 | 1519 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstantWide() { |
1817 void BytecodeGraphBuilder::VisitJumpIfToBooleanFalseConstantWide( | |
1818 const interpreter::BytecodeArrayIterator& iterator) { | |
1819 BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); | 1520 BuildJumpIfToBooleanEqual(jsgraph()->FalseConstant()); |
1820 } | 1521 } |
1821 | 1522 |
1822 | 1523 void BytecodeGraphBuilder::VisitJumpIfNull() { |
1823 void BytecodeGraphBuilder::VisitJumpIfNull( | |
1824 const interpreter::BytecodeArrayIterator& iterator) { | |
1825 BuildJumpIfEqual(jsgraph()->NullConstant()); | 1524 BuildJumpIfEqual(jsgraph()->NullConstant()); |
1826 } | 1525 } |
1827 | 1526 |
1828 | 1527 void BytecodeGraphBuilder::VisitJumpIfNullConstant() { |
1829 void BytecodeGraphBuilder::VisitJumpIfNullConstant( | |
1830 const interpreter::BytecodeArrayIterator& iterator) { | |
1831 BuildJumpIfEqual(jsgraph()->NullConstant()); | 1528 BuildJumpIfEqual(jsgraph()->NullConstant()); |
1832 } | 1529 } |
1833 | 1530 |
1834 | 1531 void BytecodeGraphBuilder::VisitJumpIfNullConstantWide() { |
1835 void BytecodeGraphBuilder::VisitJumpIfNullConstantWide( | |
1836 const interpreter::BytecodeArrayIterator& iterator) { | |
1837 BuildJumpIfEqual(jsgraph()->NullConstant()); | 1532 BuildJumpIfEqual(jsgraph()->NullConstant()); |
1838 } | 1533 } |
1839 | 1534 |
1840 | 1535 void BytecodeGraphBuilder::VisitJumpIfUndefined() { |
1841 void BytecodeGraphBuilder::VisitJumpIfUndefined( | |
1842 const interpreter::BytecodeArrayIterator& iterator) { | |
1843 BuildJumpIfEqual(jsgraph()->UndefinedConstant()); | 1536 BuildJumpIfEqual(jsgraph()->UndefinedConstant()); |
1844 } | 1537 } |
1845 | 1538 |
1846 | 1539 void BytecodeGraphBuilder::VisitJumpIfUndefinedConstant() { |
1847 void BytecodeGraphBuilder::VisitJumpIfUndefinedConstant( | |
1848 const interpreter::BytecodeArrayIterator& iterator) { | |
1849 BuildJumpIfEqual(jsgraph()->UndefinedConstant()); | 1540 BuildJumpIfEqual(jsgraph()->UndefinedConstant()); |
1850 } | 1541 } |
1851 | 1542 |
1852 | 1543 void BytecodeGraphBuilder::VisitJumpIfUndefinedConstantWide() { |
1853 void BytecodeGraphBuilder::VisitJumpIfUndefinedConstantWide( | |
1854 const interpreter::BytecodeArrayIterator& iterator) { | |
1855 BuildJumpIfEqual(jsgraph()->UndefinedConstant()); | 1544 BuildJumpIfEqual(jsgraph()->UndefinedConstant()); |
1856 } | 1545 } |
1857 | 1546 |
1858 | 1547 void BytecodeGraphBuilder::VisitReturn() { |
1859 void BytecodeGraphBuilder::VisitReturn( | |
1860 const interpreter::BytecodeArrayIterator& iterator) { | |
1861 Node* control = | 1548 Node* control = |
1862 NewNode(common()->Return(), environment()->LookupAccumulator()); | 1549 NewNode(common()->Return(), environment()->LookupAccumulator()); |
1863 UpdateControlDependencyToLeaveFunction(control); | 1550 UpdateControlDependencyToLeaveFunction(control); |
1864 set_environment(nullptr); | 1551 set_environment(nullptr); |
1865 } | 1552 } |
1866 | 1553 |
1867 | 1554 void BytecodeGraphBuilder::BuildForInPrepare() { |
1868 void BytecodeGraphBuilder::BuildForInPrepare( | 1555 FrameStateBeforeAndAfter states(this); |
1869 const interpreter::BytecodeArrayIterator& iterator) { | |
1870 FrameStateBeforeAndAfter states(this, iterator); | |
1871 Node* receiver = environment()->LookupAccumulator(); | 1556 Node* receiver = environment()->LookupAccumulator(); |
1872 Node* prepare = NewNode(javascript()->ForInPrepare(), receiver); | 1557 Node* prepare = NewNode(javascript()->ForInPrepare(), receiver); |
1873 environment()->BindRegistersToProjections(iterator.GetRegisterOperand(0), | 1558 environment()->BindRegistersToProjections( |
1874 prepare, &states); | 1559 bytecode_iterator().GetRegisterOperand(0), prepare, &states); |
1875 } | 1560 } |
1876 | 1561 |
1877 | 1562 void BytecodeGraphBuilder::VisitForInPrepare() { BuildForInPrepare(); } |
1878 void BytecodeGraphBuilder::VisitForInPrepare( | 1563 |
1879 const interpreter::BytecodeArrayIterator& iterator) { | 1564 void BytecodeGraphBuilder::VisitForInPrepareWide() { BuildForInPrepare(); } |
1880 BuildForInPrepare(iterator); | 1565 |
1881 } | 1566 void BytecodeGraphBuilder::VisitForInDone() { |
1882 | 1567 FrameStateBeforeAndAfter states(this); |
1883 | 1568 Node* index = |
1884 void BytecodeGraphBuilder::VisitForInPrepareWide( | 1569 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1885 const interpreter::BytecodeArrayIterator& iterator) { | |
1886 BuildForInPrepare(iterator); | |
1887 } | |
1888 | |
1889 | |
1890 void BytecodeGraphBuilder::VisitForInDone( | |
1891 const interpreter::BytecodeArrayIterator& iterator) { | |
1892 FrameStateBeforeAndAfter states(this, iterator); | |
1893 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | |
1894 Node* cache_length = | 1570 Node* cache_length = |
1895 environment()->LookupRegister(iterator.GetRegisterOperand(1)); | 1571 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1)); |
1896 Node* exit_cond = NewNode(javascript()->ForInDone(), index, cache_length); | 1572 Node* exit_cond = NewNode(javascript()->ForInDone(), index, cache_length); |
1897 environment()->BindAccumulator(exit_cond, &states); | 1573 environment()->BindAccumulator(exit_cond, &states); |
1898 } | 1574 } |
1899 | 1575 |
1900 | 1576 void BytecodeGraphBuilder::BuildForInNext() { |
1901 void BytecodeGraphBuilder::BuildForInNext( | 1577 FrameStateBeforeAndAfter states(this); |
1902 const interpreter::BytecodeArrayIterator& iterator) { | |
1903 FrameStateBeforeAndAfter states(this, iterator); | |
1904 Node* receiver = | 1578 Node* receiver = |
1905 environment()->LookupRegister(iterator.GetRegisterOperand(0)); | 1579 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1906 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(1)); | 1580 Node* index = |
1907 int catch_reg_pair_index = iterator.GetRegisterOperand(2).index(); | 1581 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(1)); |
| 1582 int catch_reg_pair_index = bytecode_iterator().GetRegisterOperand(2).index(); |
1908 Node* cache_type = environment()->LookupRegister( | 1583 Node* cache_type = environment()->LookupRegister( |
1909 interpreter::Register(catch_reg_pair_index)); | 1584 interpreter::Register(catch_reg_pair_index)); |
1910 Node* cache_array = environment()->LookupRegister( | 1585 Node* cache_array = environment()->LookupRegister( |
1911 interpreter::Register(catch_reg_pair_index + 1)); | 1586 interpreter::Register(catch_reg_pair_index + 1)); |
1912 | 1587 |
1913 Node* value = NewNode(javascript()->ForInNext(), receiver, cache_array, | 1588 Node* value = NewNode(javascript()->ForInNext(), receiver, cache_array, |
1914 cache_type, index); | 1589 cache_type, index); |
1915 environment()->BindAccumulator(value, &states); | 1590 environment()->BindAccumulator(value, &states); |
1916 } | 1591 } |
1917 | 1592 |
| 1593 void BytecodeGraphBuilder::VisitForInNext() { BuildForInNext(); } |
1918 | 1594 |
1919 void BytecodeGraphBuilder::VisitForInNext( | 1595 void BytecodeGraphBuilder::VisitForInNextWide() { BuildForInNext(); } |
1920 const interpreter::BytecodeArrayIterator& iterator) { | |
1921 BuildForInNext(iterator); | |
1922 } | |
1923 | 1596 |
1924 | 1597 void BytecodeGraphBuilder::VisitForInStep() { |
1925 void BytecodeGraphBuilder::VisitForInNextWide( | 1598 FrameStateBeforeAndAfter states(this); |
1926 const interpreter::BytecodeArrayIterator& iterator) { | 1599 Node* index = |
1927 BuildForInNext(iterator); | 1600 environment()->LookupRegister(bytecode_iterator().GetRegisterOperand(0)); |
1928 } | |
1929 | |
1930 | |
1931 void BytecodeGraphBuilder::VisitForInStep( | |
1932 const interpreter::BytecodeArrayIterator& iterator) { | |
1933 FrameStateBeforeAndAfter states(this, iterator); | |
1934 Node* index = environment()->LookupRegister(iterator.GetRegisterOperand(0)); | |
1935 index = NewNode(javascript()->ForInStep(), index); | 1601 index = NewNode(javascript()->ForInStep(), index); |
1936 environment()->BindAccumulator(index, &states); | 1602 environment()->BindAccumulator(index, &states); |
1937 } | 1603 } |
1938 | 1604 |
1939 | 1605 |
1940 void BytecodeGraphBuilder::MergeEnvironmentsOfBackwardBranches( | 1606 void BytecodeGraphBuilder::MergeEnvironmentsOfBackwardBranches( |
1941 int source_offset, int target_offset) { | 1607 int source_offset, int target_offset) { |
1942 DCHECK_GE(source_offset, target_offset); | 1608 DCHECK_GE(source_offset, target_offset); |
1943 const ZoneVector<int>* branch_sites = | 1609 const ZoneVector<int>* branch_sites = |
1944 branch_analysis()->BackwardBranchesTargetting(target_offset); | 1610 branch_analysis()->BackwardBranchesTargetting(target_offset); |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1997 NewMerge(); | 1663 NewMerge(); |
1998 merge_environments_[source_offset] = environment(); | 1664 merge_environments_[source_offset] = environment(); |
1999 if (source_offset >= target_offset) { | 1665 if (source_offset >= target_offset) { |
2000 MergeEnvironmentsOfBackwardBranches(source_offset, target_offset); | 1666 MergeEnvironmentsOfBackwardBranches(source_offset, target_offset); |
2001 } | 1667 } |
2002 set_environment(nullptr); | 1668 set_environment(nullptr); |
2003 } | 1669 } |
2004 | 1670 |
2005 | 1671 |
2006 void BytecodeGraphBuilder::BuildJump() { | 1672 void BytecodeGraphBuilder::BuildJump() { |
2007 int source_offset = bytecode_iterator()->current_offset(); | 1673 int source_offset = bytecode_iterator().current_offset(); |
2008 int target_offset = bytecode_iterator()->GetJumpTargetOffset(); | 1674 int target_offset = bytecode_iterator().GetJumpTargetOffset(); |
2009 BuildJump(source_offset, target_offset); | 1675 BuildJump(source_offset, target_offset); |
2010 } | 1676 } |
2011 | 1677 |
2012 | 1678 |
2013 void BytecodeGraphBuilder::BuildConditionalJump(Node* condition) { | 1679 void BytecodeGraphBuilder::BuildConditionalJump(Node* condition) { |
2014 int source_offset = bytecode_iterator()->current_offset(); | 1680 int source_offset = bytecode_iterator().current_offset(); |
2015 NewBranch(condition); | 1681 NewBranch(condition); |
2016 Environment* if_false_environment = environment()->CopyForConditional(); | 1682 Environment* if_false_environment = environment()->CopyForConditional(); |
2017 NewIfTrue(); | 1683 NewIfTrue(); |
2018 BuildJump(source_offset, bytecode_iterator()->GetJumpTargetOffset()); | 1684 BuildJump(source_offset, bytecode_iterator().GetJumpTargetOffset()); |
2019 set_environment(if_false_environment); | 1685 set_environment(if_false_environment); |
2020 NewIfFalse(); | 1686 NewIfFalse(); |
2021 } | 1687 } |
2022 | 1688 |
2023 | 1689 |
2024 void BytecodeGraphBuilder::BuildJumpIfEqual(Node* comperand) { | 1690 void BytecodeGraphBuilder::BuildJumpIfEqual(Node* comperand) { |
2025 Node* accumulator = environment()->LookupAccumulator(); | 1691 Node* accumulator = environment()->LookupAccumulator(); |
2026 Node* condition = | 1692 Node* condition = |
2027 NewNode(javascript()->StrictEqual(), accumulator, comperand); | 1693 NewNode(javascript()->StrictEqual(), accumulator, comperand); |
2028 BuildConditionalJump(condition); | 1694 BuildConditionalJump(condition); |
(...skipping 95 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2124 // Update the current control dependency for control-producing nodes. | 1790 // Update the current control dependency for control-producing nodes. |
2125 if (NodeProperties::IsControl(result)) { | 1791 if (NodeProperties::IsControl(result)) { |
2126 environment()->UpdateControlDependency(result); | 1792 environment()->UpdateControlDependency(result); |
2127 } | 1793 } |
2128 // Update the current effect dependency for effect-producing nodes. | 1794 // Update the current effect dependency for effect-producing nodes. |
2129 if (result->op()->EffectOutputCount() > 0) { | 1795 if (result->op()->EffectOutputCount() > 0) { |
2130 environment()->UpdateEffectDependency(result); | 1796 environment()->UpdateEffectDependency(result); |
2131 } | 1797 } |
2132 // Add implicit exception continuation for throwing nodes. | 1798 // Add implicit exception continuation for throwing nodes. |
2133 if (!result->op()->HasProperty(Operator::kNoThrow) && inside_handler) { | 1799 if (!result->op()->HasProperty(Operator::kNoThrow) && inside_handler) { |
2134 int throw_offset = bytecode_iterator()->current_offset(); | 1800 int throw_offset = bytecode_iterator().current_offset(); |
2135 int handler_offset = exception_handlers_.top().handler_offset_; | 1801 int handler_offset = exception_handlers_.top().handler_offset_; |
2136 // TODO(mstarzinger): Thread through correct prediction! | 1802 // TODO(mstarzinger): Thread through correct prediction! |
2137 IfExceptionHint hint = IfExceptionHint::kLocallyCaught; | 1803 IfExceptionHint hint = IfExceptionHint::kLocallyCaught; |
2138 // TODO(mstarzinger): For now we mutate the branch analysis result and | 1804 // TODO(mstarzinger): For now we mutate the branch analysis result and |
2139 // add the artificial control flow from throw-site to handler-entry. | 1805 // add the artificial control flow from throw-site to handler-entry. |
2140 // This can be simplified by pushing environment forward along the | 1806 // This can be simplified by pushing environment forward along the |
2141 // direction of the data-flow. | 1807 // direction of the data-flow. |
2142 branch_analysis_->AddExceptionalBranch(throw_offset, handler_offset); | 1808 branch_analysis_->AddExceptionalBranch(throw_offset, handler_offset); |
2143 Environment* success_env = environment()->CopyForConditional(); | 1809 Environment* success_env = environment()->CopyForConditional(); |
2144 const Operator* op = common()->IfException(hint); | 1810 const Operator* op = common()->IfException(hint); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2241 | 1907 |
2242 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { | 1908 void BytecodeGraphBuilder::UpdateControlDependencyToLeaveFunction(Node* exit) { |
2243 if (environment()->IsMarkedAsUnreachable()) return; | 1909 if (environment()->IsMarkedAsUnreachable()) return; |
2244 environment()->MarkAsUnreachable(); | 1910 environment()->MarkAsUnreachable(); |
2245 exit_controls_.push_back(exit); | 1911 exit_controls_.push_back(exit); |
2246 } | 1912 } |
2247 | 1913 |
2248 } // namespace compiler | 1914 } // namespace compiler |
2249 } // namespace internal | 1915 } // namespace internal |
2250 } // namespace v8 | 1916 } // namespace v8 |
OLD | NEW |