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/access-builder.h" | 5 #include "src/compiler/access-builder.h" |
6 #include "src/compiler/common-operator.h" | 6 #include "src/compiler/common-operator.h" |
7 #include "src/compiler/graph.h" | 7 #include "src/compiler/graph.h" |
8 #include "src/compiler/graph-visualizer.h" | 8 #include "src/compiler/graph-visualizer.h" |
9 #include "src/compiler/js-operator.h" | 9 #include "src/compiler/js-operator.h" |
10 #include "src/compiler/node.h" | 10 #include "src/compiler/node.h" |
(...skipping 640 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
651 | 651 |
652 namespace { | 652 namespace { |
653 | 653 |
654 Node* CreateDiamond(Graph* graph, CommonOperatorBuilder* common, Node* cond) { | 654 Node* CreateDiamond(Graph* graph, CommonOperatorBuilder* common, Node* cond) { |
655 Node* tv = graph->NewNode(common->Int32Constant(6)); | 655 Node* tv = graph->NewNode(common->Int32Constant(6)); |
656 Node* fv = graph->NewNode(common->Int32Constant(7)); | 656 Node* fv = graph->NewNode(common->Int32Constant(7)); |
657 Node* br = graph->NewNode(common->Branch(), cond, graph->start()); | 657 Node* br = graph->NewNode(common->Branch(), cond, graph->start()); |
658 Node* t = graph->NewNode(common->IfTrue(), br); | 658 Node* t = graph->NewNode(common->IfTrue(), br); |
659 Node* f = graph->NewNode(common->IfFalse(), br); | 659 Node* f = graph->NewNode(common->IfFalse(), br); |
660 Node* m = graph->NewNode(common->Merge(2), t, f); | 660 Node* m = graph->NewNode(common->Merge(2), t, f); |
661 Node* phi = graph->NewNode(common->Phi(kMachAnyTagged, 2), tv, fv, m); | 661 Node* phi = |
| 662 graph->NewNode(common->Phi(MachineRepresentation::kTagged, 2), tv, fv, m); |
662 return phi; | 663 return phi; |
663 } | 664 } |
664 | 665 |
665 } // namespace | 666 } // namespace |
666 | 667 |
667 | 668 |
668 TARGET_TEST_F(SchedulerTest, FloatingDiamond1) { | 669 TARGET_TEST_F(SchedulerTest, FloatingDiamond1) { |
669 Node* start = graph()->NewNode(common()->Start(1)); | 670 Node* start = graph()->NewNode(common()->Start(1)); |
670 graph()->SetStart(start); | 671 graph()->SetStart(start); |
671 | 672 |
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
730 | 731 |
731 Node* map = graph()->NewNode( | 732 Node* map = graph()->NewNode( |
732 simplified()->LoadElement(AccessBuilder::ForFixedArrayElement()), p0, p0, | 733 simplified()->LoadElement(AccessBuilder::ForFixedArrayElement()), p0, p0, |
733 start, f); | 734 start, f); |
734 Node* br1 = graph()->NewNode(common()->Branch(), map, graph()->start()); | 735 Node* br1 = graph()->NewNode(common()->Branch(), map, graph()->start()); |
735 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); | 736 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); |
736 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); | 737 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); |
737 Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1); | 738 Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1); |
738 Node* ttrue = graph()->NewNode(common()->Int32Constant(1)); | 739 Node* ttrue = graph()->NewNode(common()->Int32Constant(1)); |
739 Node* ffalse = graph()->NewNode(common()->Int32Constant(0)); | 740 Node* ffalse = graph()->NewNode(common()->Int32Constant(0)); |
740 Node* phi1 = | 741 Node* phi1 = graph()->NewNode( |
741 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), ttrue, ffalse, m1); | 742 common()->Phi(MachineRepresentation::kTagged, 2), ttrue, ffalse, m1); |
742 | 743 |
743 | 744 |
744 Node* m = graph()->NewNode(common()->Merge(2), t, f); | 745 Node* m = graph()->NewNode(common()->Merge(2), t, f); |
745 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fv, phi1, m); | 746 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| 747 fv, phi1, m); |
746 Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), start, map, m); | 748 Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), start, map, m); |
747 | 749 |
748 Node* ret = graph()->NewNode(common()->Return(), phi, ephi1, start); | 750 Node* ret = graph()->NewNode(common()->Return(), phi, ephi1, start); |
749 Node* end = graph()->NewNode(common()->End(1), ret); | 751 Node* end = graph()->NewNode(common()->End(1), ret); |
750 | 752 |
751 graph()->SetEnd(end); | 753 graph()->SetEnd(end); |
752 | 754 |
753 ComputeAndVerifySchedule(23); | 755 ComputeAndVerifySchedule(23); |
754 } | 756 } |
755 | 757 |
756 | 758 |
757 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithChain) { | 759 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithChain) { |
758 Node* start = graph()->NewNode(common()->Start(2)); | 760 Node* start = graph()->NewNode(common()->Start(2)); |
759 graph()->SetStart(start); | 761 graph()->SetStart(start); |
760 | 762 |
761 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 763 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
762 Node* p1 = graph()->NewNode(common()->Parameter(1), start); | 764 Node* p1 = graph()->NewNode(common()->Parameter(1), start); |
763 Node* c = graph()->NewNode(common()->Int32Constant(7)); | 765 Node* c = graph()->NewNode(common()->Int32Constant(7)); |
764 | 766 |
765 Node* brA1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); | 767 Node* brA1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); |
766 Node* tA1 = graph()->NewNode(common()->IfTrue(), brA1); | 768 Node* tA1 = graph()->NewNode(common()->IfTrue(), brA1); |
767 Node* fA1 = graph()->NewNode(common()->IfFalse(), brA1); | 769 Node* fA1 = graph()->NewNode(common()->IfFalse(), brA1); |
768 Node* mA1 = graph()->NewNode(common()->Merge(2), tA1, fA1); | 770 Node* mA1 = graph()->NewNode(common()->Merge(2), tA1, fA1); |
769 Node* phiA1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p1, mA1); | 771 Node* phiA1 = graph()->NewNode( |
| 772 common()->Phi(MachineRepresentation::kTagged, 2), p0, p1, mA1); |
770 | 773 |
771 Node* brB1 = graph()->NewNode(common()->Branch(), p1, graph()->start()); | 774 Node* brB1 = graph()->NewNode(common()->Branch(), p1, graph()->start()); |
772 Node* tB1 = graph()->NewNode(common()->IfTrue(), brB1); | 775 Node* tB1 = graph()->NewNode(common()->IfTrue(), brB1); |
773 Node* fB1 = graph()->NewNode(common()->IfFalse(), brB1); | 776 Node* fB1 = graph()->NewNode(common()->IfFalse(), brB1); |
774 Node* mB1 = graph()->NewNode(common()->Merge(2), tB1, fB1); | 777 Node* mB1 = graph()->NewNode(common()->Merge(2), tB1, fB1); |
775 Node* phiB1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p1, mB1); | 778 Node* phiB1 = graph()->NewNode( |
| 779 common()->Phi(MachineRepresentation::kTagged, 2), p0, p1, mB1); |
776 | 780 |
777 Node* brA2 = graph()->NewNode(common()->Branch(), phiB1, mA1); | 781 Node* brA2 = graph()->NewNode(common()->Branch(), phiB1, mA1); |
778 Node* tA2 = graph()->NewNode(common()->IfTrue(), brA2); | 782 Node* tA2 = graph()->NewNode(common()->IfTrue(), brA2); |
779 Node* fA2 = graph()->NewNode(common()->IfFalse(), brA2); | 783 Node* fA2 = graph()->NewNode(common()->IfFalse(), brA2); |
780 Node* mA2 = graph()->NewNode(common()->Merge(2), tA2, fA2); | 784 Node* mA2 = graph()->NewNode(common()->Merge(2), tA2, fA2); |
781 Node* phiA2 = | 785 Node* phiA2 = graph()->NewNode( |
782 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), phiB1, c, mA2); | 786 common()->Phi(MachineRepresentation::kTagged, 2), phiB1, c, mA2); |
783 | 787 |
784 Node* brB2 = graph()->NewNode(common()->Branch(), phiA1, mB1); | 788 Node* brB2 = graph()->NewNode(common()->Branch(), phiA1, mB1); |
785 Node* tB2 = graph()->NewNode(common()->IfTrue(), brB2); | 789 Node* tB2 = graph()->NewNode(common()->IfTrue(), brB2); |
786 Node* fB2 = graph()->NewNode(common()->IfFalse(), brB2); | 790 Node* fB2 = graph()->NewNode(common()->IfFalse(), brB2); |
787 Node* mB2 = graph()->NewNode(common()->Merge(2), tB2, fB2); | 791 Node* mB2 = graph()->NewNode(common()->Merge(2), tB2, fB2); |
788 Node* phiB2 = | 792 Node* phiB2 = graph()->NewNode( |
789 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), phiA1, c, mB2); | 793 common()->Phi(MachineRepresentation::kTagged, 2), phiA1, c, mB2); |
790 | 794 |
791 Node* add = graph()->NewNode(&kIntAdd, phiA2, phiB2); | 795 Node* add = graph()->NewNode(&kIntAdd, phiA2, phiB2); |
792 Node* ret = graph()->NewNode(common()->Return(), add, start, start); | 796 Node* ret = graph()->NewNode(common()->Return(), add, start, start); |
793 Node* end = graph()->NewNode(common()->End(1), ret); | 797 Node* end = graph()->NewNode(common()->End(1), ret); |
794 | 798 |
795 graph()->SetEnd(end); | 799 graph()->SetEnd(end); |
796 | 800 |
797 ComputeAndVerifySchedule(36); | 801 ComputeAndVerifySchedule(36); |
798 } | 802 } |
799 | 803 |
800 | 804 |
801 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithLoop) { | 805 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithLoop) { |
802 Node* start = graph()->NewNode(common()->Start(2)); | 806 Node* start = graph()->NewNode(common()->Start(2)); |
803 graph()->SetStart(start); | 807 graph()->SetStart(start); |
804 | 808 |
805 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 809 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
806 | 810 |
807 Node* fv = graph()->NewNode(common()->Int32Constant(7)); | 811 Node* fv = graph()->NewNode(common()->Int32Constant(7)); |
808 Node* br = graph()->NewNode(common()->Branch(), p0, graph()->start()); | 812 Node* br = graph()->NewNode(common()->Branch(), p0, graph()->start()); |
809 Node* t = graph()->NewNode(common()->IfTrue(), br); | 813 Node* t = graph()->NewNode(common()->IfTrue(), br); |
810 Node* f = graph()->NewNode(common()->IfFalse(), br); | 814 Node* f = graph()->NewNode(common()->IfFalse(), br); |
811 | 815 |
812 Node* loop = graph()->NewNode(common()->Loop(2), f, start); | 816 Node* loop = graph()->NewNode(common()->Loop(2), f, start); |
813 Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); | 817 Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| 818 p0, p0, loop); |
814 | 819 |
815 Node* add = graph()->NewNode(&kIntAdd, ind, fv); | 820 Node* add = graph()->NewNode(&kIntAdd, ind, fv); |
816 Node* br1 = graph()->NewNode(common()->Branch(), add, loop); | 821 Node* br1 = graph()->NewNode(common()->Branch(), add, loop); |
817 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); | 822 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); |
818 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); | 823 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); |
819 | 824 |
820 loop->ReplaceInput(1, t1); // close loop. | 825 loop->ReplaceInput(1, t1); // close loop. |
821 ind->ReplaceInput(1, ind); // close induction variable. | 826 ind->ReplaceInput(1, ind); // close induction variable. |
822 | 827 |
823 Node* m = graph()->NewNode(common()->Merge(2), t, f1); | 828 Node* m = graph()->NewNode(common()->Merge(2), t, f1); |
824 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fv, ind, m); | 829 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| 830 fv, ind, m); |
825 | 831 |
826 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); | 832 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); |
827 Node* end = graph()->NewNode(common()->End(1), ret); | 833 Node* end = graph()->NewNode(common()->End(1), ret); |
828 | 834 |
829 graph()->SetEnd(end); | 835 graph()->SetEnd(end); |
830 | 836 |
831 ComputeAndVerifySchedule(20); | 837 ComputeAndVerifySchedule(20); |
832 } | 838 } |
833 | 839 |
834 | 840 |
835 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond1) { | 841 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond1) { |
836 Node* start = graph()->NewNode(common()->Start(2)); | 842 Node* start = graph()->NewNode(common()->Start(2)); |
837 graph()->SetStart(start); | 843 graph()->SetStart(start); |
838 | 844 |
839 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 845 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
840 | 846 |
841 Node* c = graph()->NewNode(common()->Int32Constant(7)); | 847 Node* c = graph()->NewNode(common()->Int32Constant(7)); |
842 Node* loop = graph()->NewNode(common()->Loop(2), start, start); | 848 Node* loop = graph()->NewNode(common()->Loop(2), start, start); |
843 Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); | 849 Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| 850 p0, p0, loop); |
844 Node* add = graph()->NewNode(&kIntAdd, ind, c); | 851 Node* add = graph()->NewNode(&kIntAdd, ind, c); |
845 | 852 |
846 Node* br = graph()->NewNode(common()->Branch(), add, loop); | 853 Node* br = graph()->NewNode(common()->Branch(), add, loop); |
847 Node* t = graph()->NewNode(common()->IfTrue(), br); | 854 Node* t = graph()->NewNode(common()->IfTrue(), br); |
848 Node* f = graph()->NewNode(common()->IfFalse(), br); | 855 Node* f = graph()->NewNode(common()->IfFalse(), br); |
849 | 856 |
850 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); | 857 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); |
851 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); | 858 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); |
852 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); | 859 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); |
853 Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1); | 860 Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1); |
854 Node* phi1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), add, p0, m1); | 861 Node* phi1 = graph()->NewNode( |
| 862 common()->Phi(MachineRepresentation::kTagged, 2), add, p0, m1); |
855 | 863 |
856 loop->ReplaceInput(1, t); // close loop. | 864 loop->ReplaceInput(1, t); // close loop. |
857 ind->ReplaceInput(1, phi1); // close induction variable. | 865 ind->ReplaceInput(1, phi1); // close induction variable. |
858 | 866 |
859 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); | 867 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); |
860 Node* end = graph()->NewNode(common()->End(2), ret, f); | 868 Node* end = graph()->NewNode(common()->End(2), ret, f); |
861 | 869 |
862 graph()->SetEnd(end); | 870 graph()->SetEnd(end); |
863 | 871 |
864 ComputeAndVerifySchedule(20); | 872 ComputeAndVerifySchedule(20); |
865 } | 873 } |
866 | 874 |
867 | 875 |
868 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond2) { | 876 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond2) { |
869 Node* start = graph()->NewNode(common()->Start(2)); | 877 Node* start = graph()->NewNode(common()->Start(2)); |
870 graph()->SetStart(start); | 878 graph()->SetStart(start); |
871 | 879 |
872 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 880 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
873 | 881 |
874 Node* c = graph()->NewNode(common()->Int32Constant(7)); | 882 Node* c = graph()->NewNode(common()->Int32Constant(7)); |
875 Node* loop = graph()->NewNode(common()->Loop(2), start, start); | 883 Node* loop = graph()->NewNode(common()->Loop(2), start, start); |
876 Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); | 884 Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| 885 p0, p0, loop); |
877 | 886 |
878 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); | 887 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); |
879 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); | 888 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); |
880 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); | 889 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); |
881 Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1); | 890 Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1); |
882 Node* phi1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), c, ind, m1); | 891 Node* phi1 = graph()->NewNode( |
| 892 common()->Phi(MachineRepresentation::kTagged, 2), c, ind, m1); |
883 | 893 |
884 Node* add = graph()->NewNode(&kIntAdd, ind, phi1); | 894 Node* add = graph()->NewNode(&kIntAdd, ind, phi1); |
885 | 895 |
886 Node* br = graph()->NewNode(common()->Branch(), add, loop); | 896 Node* br = graph()->NewNode(common()->Branch(), add, loop); |
887 Node* t = graph()->NewNode(common()->IfTrue(), br); | 897 Node* t = graph()->NewNode(common()->IfTrue(), br); |
888 Node* f = graph()->NewNode(common()->IfFalse(), br); | 898 Node* f = graph()->NewNode(common()->IfFalse(), br); |
889 | 899 |
890 loop->ReplaceInput(1, t); // close loop. | 900 loop->ReplaceInput(1, t); // close loop. |
891 ind->ReplaceInput(1, add); // close induction variable. | 901 ind->ReplaceInput(1, add); // close induction variable. |
892 | 902 |
893 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); | 903 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); |
894 Node* end = graph()->NewNode(common()->End(2), ret, f); | 904 Node* end = graph()->NewNode(common()->End(2), ret, f); |
895 | 905 |
896 graph()->SetEnd(end); | 906 graph()->SetEnd(end); |
897 | 907 |
898 ComputeAndVerifySchedule(20); | 908 ComputeAndVerifySchedule(20); |
899 } | 909 } |
900 | 910 |
901 | 911 |
902 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond3) { | 912 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond3) { |
903 Node* start = graph()->NewNode(common()->Start(2)); | 913 Node* start = graph()->NewNode(common()->Start(2)); |
904 graph()->SetStart(start); | 914 graph()->SetStart(start); |
905 | 915 |
906 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 916 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
907 | 917 |
908 Node* c = graph()->NewNode(common()->Int32Constant(7)); | 918 Node* c = graph()->NewNode(common()->Int32Constant(7)); |
909 Node* loop = graph()->NewNode(common()->Loop(2), start, start); | 919 Node* loop = graph()->NewNode(common()->Loop(2), start, start); |
910 Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); | 920 Node* ind = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| 921 p0, p0, loop); |
911 | 922 |
912 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); | 923 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); |
913 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); | 924 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); |
914 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); | 925 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); |
915 | 926 |
916 Node* loop1 = graph()->NewNode(common()->Loop(2), t1, start); | 927 Node* loop1 = graph()->NewNode(common()->Loop(2), t1, start); |
917 Node* ind1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); | 928 Node* ind1 = graph()->NewNode( |
| 929 common()->Phi(MachineRepresentation::kTagged, 2), p0, p0, loop); |
918 | 930 |
919 Node* add1 = graph()->NewNode(&kIntAdd, ind1, c); | 931 Node* add1 = graph()->NewNode(&kIntAdd, ind1, c); |
920 Node* br2 = graph()->NewNode(common()->Branch(), add1, loop1); | 932 Node* br2 = graph()->NewNode(common()->Branch(), add1, loop1); |
921 Node* t2 = graph()->NewNode(common()->IfTrue(), br2); | 933 Node* t2 = graph()->NewNode(common()->IfTrue(), br2); |
922 Node* f2 = graph()->NewNode(common()->IfFalse(), br2); | 934 Node* f2 = graph()->NewNode(common()->IfFalse(), br2); |
923 | 935 |
924 loop1->ReplaceInput(1, t2); // close inner loop. | 936 loop1->ReplaceInput(1, t2); // close inner loop. |
925 ind1->ReplaceInput(1, ind1); // close inner induction variable. | 937 ind1->ReplaceInput(1, ind1); // close inner induction variable. |
926 | 938 |
927 Node* m1 = graph()->NewNode(common()->Merge(2), f1, f2); | 939 Node* m1 = graph()->NewNode(common()->Merge(2), f1, f2); |
928 Node* phi1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), c, ind1, m1); | 940 Node* phi1 = graph()->NewNode( |
| 941 common()->Phi(MachineRepresentation::kTagged, 2), c, ind1, m1); |
929 | 942 |
930 Node* add = graph()->NewNode(&kIntAdd, ind, phi1); | 943 Node* add = graph()->NewNode(&kIntAdd, ind, phi1); |
931 | 944 |
932 Node* br = graph()->NewNode(common()->Branch(), add, loop); | 945 Node* br = graph()->NewNode(common()->Branch(), add, loop); |
933 Node* t = graph()->NewNode(common()->IfTrue(), br); | 946 Node* t = graph()->NewNode(common()->IfTrue(), br); |
934 Node* f = graph()->NewNode(common()->IfFalse(), br); | 947 Node* f = graph()->NewNode(common()->IfFalse(), br); |
935 | 948 |
936 loop->ReplaceInput(1, t); // close loop. | 949 loop->ReplaceInput(1, t); // close loop. |
937 ind->ReplaceInput(1, add); // close induction variable. | 950 ind->ReplaceInput(1, add); // close induction variable. |
938 | 951 |
(...skipping 14 matching lines...) Expand all Loading... |
953 Node* p1 = graph()->NewNode(common()->Parameter(1), start); | 966 Node* p1 = graph()->NewNode(common()->Parameter(1), start); |
954 | 967 |
955 Node* v1 = graph()->NewNode(common()->Int32Constant(1)); | 968 Node* v1 = graph()->NewNode(common()->Int32Constant(1)); |
956 Node* v2 = graph()->NewNode(common()->Int32Constant(2)); | 969 Node* v2 = graph()->NewNode(common()->Int32Constant(2)); |
957 Node* v3 = graph()->NewNode(common()->Int32Constant(3)); | 970 Node* v3 = graph()->NewNode(common()->Int32Constant(3)); |
958 Node* v4 = graph()->NewNode(common()->Int32Constant(4)); | 971 Node* v4 = graph()->NewNode(common()->Int32Constant(4)); |
959 Node* br = graph()->NewNode(common()->Branch(), p0, graph()->start()); | 972 Node* br = graph()->NewNode(common()->Branch(), p0, graph()->start()); |
960 Node* t = graph()->NewNode(common()->IfTrue(), br); | 973 Node* t = graph()->NewNode(common()->IfTrue(), br); |
961 Node* f = graph()->NewNode(common()->IfFalse(), br); | 974 Node* f = graph()->NewNode(common()->IfFalse(), br); |
962 Node* m = graph()->NewNode(common()->Merge(2), t, f); | 975 Node* m = graph()->NewNode(common()->Merge(2), t, f); |
963 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), v1, v2, m); | 976 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
964 Node* phi2 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), v3, v4, m); | 977 v1, v2, m); |
| 978 Node* phi2 = graph()->NewNode( |
| 979 common()->Phi(MachineRepresentation::kTagged, 2), v3, v4, m); |
965 | 980 |
966 Node* br2 = graph()->NewNode(common()->Branch(), p1, graph()->start()); | 981 Node* br2 = graph()->NewNode(common()->Branch(), p1, graph()->start()); |
967 Node* t2 = graph()->NewNode(common()->IfTrue(), br2); | 982 Node* t2 = graph()->NewNode(common()->IfTrue(), br2); |
968 Node* f2 = graph()->NewNode(common()->IfFalse(), br2); | 983 Node* f2 = graph()->NewNode(common()->IfFalse(), br2); |
969 Node* m2 = graph()->NewNode(common()->Merge(2), t2, f2); | 984 Node* m2 = graph()->NewNode(common()->Merge(2), t2, f2); |
970 Node* phi3 = | 985 Node* phi3 = graph()->NewNode( |
971 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), phi, phi2, m2); | 986 common()->Phi(MachineRepresentation::kTagged, 2), phi, phi2, m2); |
972 | 987 |
973 Node* ret = graph()->NewNode(common()->Return(), phi3, start, start); | 988 Node* ret = graph()->NewNode(common()->Return(), phi3, start, start); |
974 Node* end = graph()->NewNode(common()->End(1), ret); | 989 Node* end = graph()->NewNode(common()->End(1), ret); |
975 | 990 |
976 graph()->SetEnd(end); | 991 graph()->SetEnd(end); |
977 | 992 |
978 ComputeAndVerifySchedule(24); | 993 ComputeAndVerifySchedule(24); |
979 } | 994 } |
980 | 995 |
981 | 996 |
982 TARGET_TEST_F(SchedulerTest, BranchHintTrue) { | 997 TARGET_TEST_F(SchedulerTest, BranchHintTrue) { |
983 Node* start = graph()->NewNode(common()->Start(1)); | 998 Node* start = graph()->NewNode(common()->Start(1)); |
984 graph()->SetStart(start); | 999 graph()->SetStart(start); |
985 | 1000 |
986 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 1001 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
987 Node* tv = graph()->NewNode(common()->Int32Constant(6)); | 1002 Node* tv = graph()->NewNode(common()->Int32Constant(6)); |
988 Node* fv = graph()->NewNode(common()->Int32Constant(7)); | 1003 Node* fv = graph()->NewNode(common()->Int32Constant(7)); |
989 Node* br = graph()->NewNode(common()->Branch(BranchHint::kTrue), p0, start); | 1004 Node* br = graph()->NewNode(common()->Branch(BranchHint::kTrue), p0, start); |
990 Node* t = graph()->NewNode(common()->IfTrue(), br); | 1005 Node* t = graph()->NewNode(common()->IfTrue(), br); |
991 Node* f = graph()->NewNode(common()->IfFalse(), br); | 1006 Node* f = graph()->NewNode(common()->IfFalse(), br); |
992 Node* m = graph()->NewNode(common()->Merge(2), t, f); | 1007 Node* m = graph()->NewNode(common()->Merge(2), t, f); |
993 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), tv, fv, m); | 1008 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| 1009 tv, fv, m); |
994 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); | 1010 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); |
995 Node* end = graph()->NewNode(common()->End(1), ret); | 1011 Node* end = graph()->NewNode(common()->End(1), ret); |
996 | 1012 |
997 graph()->SetEnd(end); | 1013 graph()->SetEnd(end); |
998 | 1014 |
999 Schedule* schedule = ComputeAndVerifySchedule(13); | 1015 Schedule* schedule = ComputeAndVerifySchedule(13); |
1000 // Make sure the false block is marked as deferred. | 1016 // Make sure the false block is marked as deferred. |
1001 EXPECT_FALSE(schedule->block(t)->deferred()); | 1017 EXPECT_FALSE(schedule->block(t)->deferred()); |
1002 EXPECT_TRUE(schedule->block(f)->deferred()); | 1018 EXPECT_TRUE(schedule->block(f)->deferred()); |
1003 } | 1019 } |
1004 | 1020 |
1005 | 1021 |
1006 TARGET_TEST_F(SchedulerTest, BranchHintFalse) { | 1022 TARGET_TEST_F(SchedulerTest, BranchHintFalse) { |
1007 Node* start = graph()->NewNode(common()->Start(1)); | 1023 Node* start = graph()->NewNode(common()->Start(1)); |
1008 graph()->SetStart(start); | 1024 graph()->SetStart(start); |
1009 | 1025 |
1010 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 1026 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
1011 Node* tv = graph()->NewNode(common()->Int32Constant(6)); | 1027 Node* tv = graph()->NewNode(common()->Int32Constant(6)); |
1012 Node* fv = graph()->NewNode(common()->Int32Constant(7)); | 1028 Node* fv = graph()->NewNode(common()->Int32Constant(7)); |
1013 Node* br = graph()->NewNode(common()->Branch(BranchHint::kFalse), p0, start); | 1029 Node* br = graph()->NewNode(common()->Branch(BranchHint::kFalse), p0, start); |
1014 Node* t = graph()->NewNode(common()->IfTrue(), br); | 1030 Node* t = graph()->NewNode(common()->IfTrue(), br); |
1015 Node* f = graph()->NewNode(common()->IfFalse(), br); | 1031 Node* f = graph()->NewNode(common()->IfFalse(), br); |
1016 Node* m = graph()->NewNode(common()->Merge(2), t, f); | 1032 Node* m = graph()->NewNode(common()->Merge(2), t, f); |
1017 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), tv, fv, m); | 1033 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| 1034 tv, fv, m); |
1018 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); | 1035 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); |
1019 Node* end = graph()->NewNode(common()->End(1), ret); | 1036 Node* end = graph()->NewNode(common()->End(1), ret); |
1020 | 1037 |
1021 graph()->SetEnd(end); | 1038 graph()->SetEnd(end); |
1022 | 1039 |
1023 Schedule* schedule = ComputeAndVerifySchedule(13); | 1040 Schedule* schedule = ComputeAndVerifySchedule(13); |
1024 // Make sure the true block is marked as deferred. | 1041 // Make sure the true block is marked as deferred. |
1025 EXPECT_TRUE(schedule->block(t)->deferred()); | 1042 EXPECT_TRUE(schedule->block(t)->deferred()); |
1026 EXPECT_FALSE(schedule->block(f)->deferred()); | 1043 EXPECT_FALSE(schedule->block(f)->deferred()); |
1027 } | 1044 } |
1028 | 1045 |
1029 | 1046 |
1030 TARGET_TEST_F(SchedulerTest, CallException) { | 1047 TARGET_TEST_F(SchedulerTest, CallException) { |
1031 Node* start = graph()->NewNode(common()->Start(1)); | 1048 Node* start = graph()->NewNode(common()->Start(1)); |
1032 graph()->SetStart(start); | 1049 graph()->SetStart(start); |
1033 | 1050 |
1034 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 1051 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
1035 Node* c1 = graph()->NewNode(&kMockCall, start); | 1052 Node* c1 = graph()->NewNode(&kMockCall, start); |
1036 Node* ok1 = graph()->NewNode(common()->IfSuccess(), c1); | 1053 Node* ok1 = graph()->NewNode(common()->IfSuccess(), c1); |
1037 Node* ex1 = graph()->NewNode( | 1054 Node* ex1 = graph()->NewNode( |
1038 common()->IfException(IfExceptionHint::kLocallyUncaught), c1, c1); | 1055 common()->IfException(IfExceptionHint::kLocallyUncaught), c1, c1); |
1039 Node* c2 = graph()->NewNode(&kMockCall, ok1); | 1056 Node* c2 = graph()->NewNode(&kMockCall, ok1); |
1040 Node* ok2 = graph()->NewNode(common()->IfSuccess(), c2); | 1057 Node* ok2 = graph()->NewNode(common()->IfSuccess(), c2); |
1041 Node* ex2 = graph()->NewNode( | 1058 Node* ex2 = graph()->NewNode( |
1042 common()->IfException(IfExceptionHint::kLocallyUncaught), c2, c2); | 1059 common()->IfException(IfExceptionHint::kLocallyUncaught), c2, c2); |
1043 Node* hdl = graph()->NewNode(common()->Merge(2), ex1, ex2); | 1060 Node* hdl = graph()->NewNode(common()->Merge(2), ex1, ex2); |
1044 Node* m = graph()->NewNode(common()->Merge(2), ok2, hdl); | 1061 Node* m = graph()->NewNode(common()->Merge(2), ok2, hdl); |
1045 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), c2, p0, m); | 1062 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kTagged, 2), |
| 1063 c2, p0, m); |
1046 Node* ret = graph()->NewNode(common()->Return(), phi, start, m); | 1064 Node* ret = graph()->NewNode(common()->Return(), phi, start, m); |
1047 Node* end = graph()->NewNode(common()->End(1), ret); | 1065 Node* end = graph()->NewNode(common()->End(1), ret); |
1048 | 1066 |
1049 graph()->SetEnd(end); | 1067 graph()->SetEnd(end); |
1050 | 1068 |
1051 Schedule* schedule = ComputeAndVerifySchedule(17); | 1069 Schedule* schedule = ComputeAndVerifySchedule(17); |
1052 // Make sure the exception blocks as well as the handler are deferred. | 1070 // Make sure the exception blocks as well as the handler are deferred. |
1053 EXPECT_TRUE(schedule->block(ex1)->deferred()); | 1071 EXPECT_TRUE(schedule->block(ex1)->deferred()); |
1054 EXPECT_TRUE(schedule->block(ex2)->deferred()); | 1072 EXPECT_TRUE(schedule->block(ex2)->deferred()); |
1055 EXPECT_TRUE(schedule->block(hdl)->deferred()); | 1073 EXPECT_TRUE(schedule->block(hdl)->deferred()); |
(...skipping 21 matching lines...) Expand all Loading... |
1077 | 1095 |
1078 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 1096 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
1079 Node* sw = graph()->NewNode(common()->Switch(3), p0, start); | 1097 Node* sw = graph()->NewNode(common()->Switch(3), p0, start); |
1080 Node* c0 = graph()->NewNode(common()->IfValue(0), sw); | 1098 Node* c0 = graph()->NewNode(common()->IfValue(0), sw); |
1081 Node* v0 = graph()->NewNode(common()->Int32Constant(11)); | 1099 Node* v0 = graph()->NewNode(common()->Int32Constant(11)); |
1082 Node* c1 = graph()->NewNode(common()->IfValue(1), sw); | 1100 Node* c1 = graph()->NewNode(common()->IfValue(1), sw); |
1083 Node* v1 = graph()->NewNode(common()->Int32Constant(22)); | 1101 Node* v1 = graph()->NewNode(common()->Int32Constant(22)); |
1084 Node* d = graph()->NewNode(common()->IfDefault(), sw); | 1102 Node* d = graph()->NewNode(common()->IfDefault(), sw); |
1085 Node* vd = graph()->NewNode(common()->Int32Constant(33)); | 1103 Node* vd = graph()->NewNode(common()->Int32Constant(33)); |
1086 Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d); | 1104 Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d); |
1087 Node* phi = graph()->NewNode(common()->Phi(kMachInt32, 3), v0, v1, vd, m); | 1105 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 3), |
| 1106 v0, v1, vd, m); |
1088 Node* ret = graph()->NewNode(common()->Return(), phi, start, m); | 1107 Node* ret = graph()->NewNode(common()->Return(), phi, start, m); |
1089 Node* end = graph()->NewNode(common()->End(1), ret); | 1108 Node* end = graph()->NewNode(common()->End(1), ret); |
1090 | 1109 |
1091 graph()->SetEnd(end); | 1110 graph()->SetEnd(end); |
1092 | 1111 |
1093 ComputeAndVerifySchedule(16); | 1112 ComputeAndVerifySchedule(16); |
1094 } | 1113 } |
1095 | 1114 |
1096 | 1115 |
1097 TARGET_TEST_F(SchedulerTest, FloatingSwitch) { | 1116 TARGET_TEST_F(SchedulerTest, FloatingSwitch) { |
1098 Node* start = graph()->NewNode(common()->Start(1)); | 1117 Node* start = graph()->NewNode(common()->Start(1)); |
1099 graph()->SetStart(start); | 1118 graph()->SetStart(start); |
1100 | 1119 |
1101 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 1120 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
1102 Node* sw = graph()->NewNode(common()->Switch(3), p0, start); | 1121 Node* sw = graph()->NewNode(common()->Switch(3), p0, start); |
1103 Node* c0 = graph()->NewNode(common()->IfValue(0), sw); | 1122 Node* c0 = graph()->NewNode(common()->IfValue(0), sw); |
1104 Node* v0 = graph()->NewNode(common()->Int32Constant(11)); | 1123 Node* v0 = graph()->NewNode(common()->Int32Constant(11)); |
1105 Node* c1 = graph()->NewNode(common()->IfValue(1), sw); | 1124 Node* c1 = graph()->NewNode(common()->IfValue(1), sw); |
1106 Node* v1 = graph()->NewNode(common()->Int32Constant(22)); | 1125 Node* v1 = graph()->NewNode(common()->Int32Constant(22)); |
1107 Node* d = graph()->NewNode(common()->IfDefault(), sw); | 1126 Node* d = graph()->NewNode(common()->IfDefault(), sw); |
1108 Node* vd = graph()->NewNode(common()->Int32Constant(33)); | 1127 Node* vd = graph()->NewNode(common()->Int32Constant(33)); |
1109 Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d); | 1128 Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d); |
1110 Node* phi = graph()->NewNode(common()->Phi(kMachInt32, 3), v0, v1, vd, m); | 1129 Node* phi = graph()->NewNode(common()->Phi(MachineRepresentation::kWord32, 3), |
| 1130 v0, v1, vd, m); |
1111 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); | 1131 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); |
1112 Node* end = graph()->NewNode(common()->End(1), ret); | 1132 Node* end = graph()->NewNode(common()->End(1), ret); |
1113 | 1133 |
1114 graph()->SetEnd(end); | 1134 graph()->SetEnd(end); |
1115 | 1135 |
1116 ComputeAndVerifySchedule(16); | 1136 ComputeAndVerifySchedule(16); |
1117 } | 1137 } |
1118 | 1138 |
1119 | 1139 |
1120 TARGET_TEST_F(SchedulerTest, Terminate) { | 1140 TARGET_TEST_F(SchedulerTest, Terminate) { |
(...skipping 12 matching lines...) Expand all Loading... |
1133 | 1153 |
1134 Schedule* schedule = ComputeAndVerifySchedule(6); | 1154 Schedule* schedule = ComputeAndVerifySchedule(6); |
1135 BasicBlock* block = schedule->block(loop); | 1155 BasicBlock* block = schedule->block(loop); |
1136 EXPECT_EQ(block, schedule->block(effect)); | 1156 EXPECT_EQ(block, schedule->block(effect)); |
1137 EXPECT_GE(block->rpo_number(), 0); | 1157 EXPECT_GE(block->rpo_number(), 0); |
1138 } | 1158 } |
1139 | 1159 |
1140 } // namespace compiler | 1160 } // namespace compiler |
1141 } // namespace internal | 1161 } // namespace internal |
1142 } // namespace v8 | 1162 } // namespace v8 |
OLD | NEW |