| 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 613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 624 CheckLoop(order, loop1, 4); | 624 CheckLoop(order, loop1, 4); |
| 625 } | 625 } |
| 626 | 626 |
| 627 | 627 |
| 628 // ----------------------------------------------------------------------------- | 628 // ----------------------------------------------------------------------------- |
| 629 // Graph end-to-end scheduling. | 629 // Graph end-to-end scheduling. |
| 630 | 630 |
| 631 | 631 |
| 632 TEST_F(SchedulerTest, BuildScheduleEmpty) { | 632 TEST_F(SchedulerTest, BuildScheduleEmpty) { |
| 633 graph()->SetStart(graph()->NewNode(common()->Start(0))); | 633 graph()->SetStart(graph()->NewNode(common()->Start(0))); |
| 634 graph()->SetEnd(graph()->NewNode(common()->End(), graph()->start())); | 634 graph()->SetEnd(graph()->NewNode(common()->End(1), graph()->start())); |
| 635 USE(Scheduler::ComputeSchedule(zone(), graph(), Scheduler::kNoFlags)); | 635 USE(Scheduler::ComputeSchedule(zone(), graph(), Scheduler::kNoFlags)); |
| 636 } | 636 } |
| 637 | 637 |
| 638 | 638 |
| 639 TEST_F(SchedulerTest, BuildScheduleOneParameter) { | 639 TEST_F(SchedulerTest, BuildScheduleOneParameter) { |
| 640 graph()->SetStart(graph()->NewNode(common()->Start(0))); | 640 graph()->SetStart(graph()->NewNode(common()->Start(0))); |
| 641 | 641 |
| 642 Node* p1 = graph()->NewNode(common()->Parameter(0), graph()->start()); | 642 Node* p1 = graph()->NewNode(common()->Parameter(0), graph()->start()); |
| 643 Node* ret = graph()->NewNode(common()->Return(), p1, graph()->start(), | 643 Node* ret = graph()->NewNode(common()->Return(), p1, graph()->start(), |
| 644 graph()->start()); | 644 graph()->start()); |
| 645 | 645 |
| 646 graph()->SetEnd(graph()->NewNode(common()->End(), ret)); | 646 graph()->SetEnd(graph()->NewNode(common()->End(1), ret)); |
| 647 | 647 |
| 648 USE(Scheduler::ComputeSchedule(zone(), graph(), Scheduler::kNoFlags)); | 648 USE(Scheduler::ComputeSchedule(zone(), graph(), Scheduler::kNoFlags)); |
| 649 } | 649 } |
| 650 | 650 |
| 651 | 651 |
| 652 TEST_F(SchedulerTest, BuildScheduleIfSplit) { | 652 TEST_F(SchedulerTest, BuildScheduleIfSplit) { |
| 653 graph()->SetStart(graph()->NewNode(common()->Start(5))); | 653 graph()->SetStart(graph()->NewNode(common()->Start(5))); |
| 654 | 654 |
| 655 Node* p1 = graph()->NewNode(common()->Parameter(0), graph()->start()); | 655 Node* p1 = graph()->NewNode(common()->Parameter(0), graph()->start()); |
| 656 Node* p2 = graph()->NewNode(common()->Parameter(1), graph()->start()); | 656 Node* p2 = graph()->NewNode(common()->Parameter(1), graph()->start()); |
| 657 Node* p3 = graph()->NewNode(common()->Parameter(2), graph()->start()); | 657 Node* p3 = graph()->NewNode(common()->Parameter(2), graph()->start()); |
| 658 Node* p4 = graph()->NewNode(common()->Parameter(3), graph()->start()); | 658 Node* p4 = graph()->NewNode(common()->Parameter(3), graph()->start()); |
| 659 Node* p5 = graph()->NewNode(common()->Parameter(4), graph()->start()); | 659 Node* p5 = graph()->NewNode(common()->Parameter(4), graph()->start()); |
| 660 Node* cmp = | 660 Node* cmp = |
| 661 graph()->NewNode(js()->LessThanOrEqual(LanguageMode::SLOPPY), p1, p2, p3, | 661 graph()->NewNode(js()->LessThanOrEqual(LanguageMode::SLOPPY), p1, p2, p3, |
| 662 p4, p5, graph()->start(), graph()->start()); | 662 p4, p5, graph()->start(), graph()->start()); |
| 663 Node* branch = graph()->NewNode(common()->Branch(), cmp, graph()->start()); | 663 Node* branch = graph()->NewNode(common()->Branch(), cmp, graph()->start()); |
| 664 Node* true_branch = graph()->NewNode(common()->IfTrue(), branch); | 664 Node* true_branch = graph()->NewNode(common()->IfTrue(), branch); |
| 665 Node* false_branch = graph()->NewNode(common()->IfFalse(), branch); | 665 Node* false_branch = graph()->NewNode(common()->IfFalse(), branch); |
| 666 | 666 |
| 667 Node* ret1 = | 667 Node* ret1 = |
| 668 graph()->NewNode(common()->Return(), p4, graph()->start(), true_branch); | 668 graph()->NewNode(common()->Return(), p4, graph()->start(), true_branch); |
| 669 Node* ret2 = | 669 Node* ret2 = |
| 670 graph()->NewNode(common()->Return(), p5, graph()->start(), false_branch); | 670 graph()->NewNode(common()->Return(), p5, graph()->start(), false_branch); |
| 671 Node* merge = graph()->NewNode(common()->Merge(2), ret1, ret2); | 671 graph()->SetEnd(graph()->NewNode(common()->End(2), ret1, ret2)); |
| 672 graph()->SetEnd(graph()->NewNode(common()->End(), merge)); | |
| 673 | 672 |
| 674 ComputeAndVerifySchedule(13); | 673 ComputeAndVerifySchedule(13); |
| 675 } | 674 } |
| 676 | 675 |
| 677 | 676 |
| 678 namespace { | 677 namespace { |
| 679 | 678 |
| 680 Node* CreateDiamond(Graph* graph, CommonOperatorBuilder* common, Node* cond) { | 679 Node* CreateDiamond(Graph* graph, CommonOperatorBuilder* common, Node* cond) { |
| 681 Node* tv = graph->NewNode(common->Int32Constant(6)); | 680 Node* tv = graph->NewNode(common->Int32Constant(6)); |
| 682 Node* fv = graph->NewNode(common->Int32Constant(7)); | 681 Node* fv = graph->NewNode(common->Int32Constant(7)); |
| 683 Node* br = graph->NewNode(common->Branch(), cond, graph->start()); | 682 Node* br = graph->NewNode(common->Branch(), cond, graph->start()); |
| 684 Node* t = graph->NewNode(common->IfTrue(), br); | 683 Node* t = graph->NewNode(common->IfTrue(), br); |
| 685 Node* f = graph->NewNode(common->IfFalse(), br); | 684 Node* f = graph->NewNode(common->IfFalse(), br); |
| 686 Node* m = graph->NewNode(common->Merge(2), t, f); | 685 Node* m = graph->NewNode(common->Merge(2), t, f); |
| 687 Node* phi = graph->NewNode(common->Phi(kMachAnyTagged, 2), tv, fv, m); | 686 Node* phi = graph->NewNode(common->Phi(kMachAnyTagged, 2), tv, fv, m); |
| 688 return phi; | 687 return phi; |
| 689 } | 688 } |
| 690 | 689 |
| 691 } // namespace | 690 } // namespace |
| 692 | 691 |
| 693 | 692 |
| 694 TARGET_TEST_F(SchedulerTest, FloatingDiamond1) { | 693 TARGET_TEST_F(SchedulerTest, FloatingDiamond1) { |
| 695 Node* start = graph()->NewNode(common()->Start(1)); | 694 Node* start = graph()->NewNode(common()->Start(1)); |
| 696 graph()->SetStart(start); | 695 graph()->SetStart(start); |
| 697 | 696 |
| 698 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 697 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
| 699 Node* d1 = CreateDiamond(graph(), common(), p0); | 698 Node* d1 = CreateDiamond(graph(), common(), p0); |
| 700 Node* ret = graph()->NewNode(common()->Return(), d1, start, start); | 699 Node* ret = graph()->NewNode(common()->Return(), d1, start, start); |
| 701 Node* end = graph()->NewNode(common()->End(), ret, start); | 700 Node* end = graph()->NewNode(common()->End(1), ret); |
| 702 | 701 |
| 703 graph()->SetEnd(end); | 702 graph()->SetEnd(end); |
| 704 | 703 |
| 705 ComputeAndVerifySchedule(13); | 704 ComputeAndVerifySchedule(13); |
| 706 } | 705 } |
| 707 | 706 |
| 708 | 707 |
| 709 TARGET_TEST_F(SchedulerTest, FloatingDiamond2) { | 708 TARGET_TEST_F(SchedulerTest, FloatingDiamond2) { |
| 710 Node* start = graph()->NewNode(common()->Start(2)); | 709 Node* start = graph()->NewNode(common()->Start(2)); |
| 711 graph()->SetStart(start); | 710 graph()->SetStart(start); |
| 712 | 711 |
| 713 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 712 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
| 714 Node* p1 = graph()->NewNode(common()->Parameter(1), start); | 713 Node* p1 = graph()->NewNode(common()->Parameter(1), start); |
| 715 Node* d1 = CreateDiamond(graph(), common(), p0); | 714 Node* d1 = CreateDiamond(graph(), common(), p0); |
| 716 Node* d2 = CreateDiamond(graph(), common(), p1); | 715 Node* d2 = CreateDiamond(graph(), common(), p1); |
| 717 Node* add = graph()->NewNode(&kIntAdd, d1, d2); | 716 Node* add = graph()->NewNode(&kIntAdd, d1, d2); |
| 718 Node* ret = graph()->NewNode(common()->Return(), add, start, start); | 717 Node* ret = graph()->NewNode(common()->Return(), add, start, start); |
| 719 Node* end = graph()->NewNode(common()->End(), ret, start); | 718 Node* end = graph()->NewNode(common()->End(1), ret); |
| 720 | 719 |
| 721 graph()->SetEnd(end); | 720 graph()->SetEnd(end); |
| 722 | 721 |
| 723 ComputeAndVerifySchedule(24); | 722 ComputeAndVerifySchedule(24); |
| 724 } | 723 } |
| 725 | 724 |
| 726 | 725 |
| 727 TARGET_TEST_F(SchedulerTest, FloatingDiamond3) { | 726 TARGET_TEST_F(SchedulerTest, FloatingDiamond3) { |
| 728 Node* start = graph()->NewNode(common()->Start(2)); | 727 Node* start = graph()->NewNode(common()->Start(2)); |
| 729 graph()->SetStart(start); | 728 graph()->SetStart(start); |
| 730 | 729 |
| 731 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 730 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
| 732 Node* p1 = graph()->NewNode(common()->Parameter(1), start); | 731 Node* p1 = graph()->NewNode(common()->Parameter(1), start); |
| 733 Node* d1 = CreateDiamond(graph(), common(), p0); | 732 Node* d1 = CreateDiamond(graph(), common(), p0); |
| 734 Node* d2 = CreateDiamond(graph(), common(), p1); | 733 Node* d2 = CreateDiamond(graph(), common(), p1); |
| 735 Node* add = graph()->NewNode(&kIntAdd, d1, d2); | 734 Node* add = graph()->NewNode(&kIntAdd, d1, d2); |
| 736 Node* d3 = CreateDiamond(graph(), common(), add); | 735 Node* d3 = CreateDiamond(graph(), common(), add); |
| 737 Node* ret = graph()->NewNode(common()->Return(), d3, start, start); | 736 Node* ret = graph()->NewNode(common()->Return(), d3, start, start); |
| 738 Node* end = graph()->NewNode(common()->End(), ret, start); | 737 Node* end = graph()->NewNode(common()->End(1), ret); |
| 739 | 738 |
| 740 graph()->SetEnd(end); | 739 graph()->SetEnd(end); |
| 741 | 740 |
| 742 ComputeAndVerifySchedule(33); | 741 ComputeAndVerifySchedule(33); |
| 743 } | 742 } |
| 744 | 743 |
| 745 | 744 |
| 746 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamonds) { | 745 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamonds) { |
| 747 Node* start = graph()->NewNode(common()->Start(2)); | 746 Node* start = graph()->NewNode(common()->Start(2)); |
| 748 graph()->SetStart(start); | 747 graph()->SetStart(start); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 765 Node* ffalse = graph()->NewNode(common()->Int32Constant(0)); | 764 Node* ffalse = graph()->NewNode(common()->Int32Constant(0)); |
| 766 Node* phi1 = | 765 Node* phi1 = |
| 767 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), ttrue, ffalse, m1); | 766 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), ttrue, ffalse, m1); |
| 768 | 767 |
| 769 | 768 |
| 770 Node* m = graph()->NewNode(common()->Merge(2), t, f); | 769 Node* m = graph()->NewNode(common()->Merge(2), t, f); |
| 771 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fv, phi1, m); | 770 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fv, phi1, m); |
| 772 Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), start, map, m); | 771 Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), start, map, m); |
| 773 | 772 |
| 774 Node* ret = graph()->NewNode(common()->Return(), phi, ephi1, start); | 773 Node* ret = graph()->NewNode(common()->Return(), phi, ephi1, start); |
| 775 Node* end = graph()->NewNode(common()->End(), ret, start); | 774 Node* end = graph()->NewNode(common()->End(1), ret); |
| 776 | 775 |
| 777 graph()->SetEnd(end); | 776 graph()->SetEnd(end); |
| 778 | 777 |
| 779 ComputeAndVerifySchedule(23); | 778 ComputeAndVerifySchedule(23); |
| 780 } | 779 } |
| 781 | 780 |
| 782 | 781 |
| 783 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithChain) { | 782 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithChain) { |
| 784 Node* start = graph()->NewNode(common()->Start(2)); | 783 Node* start = graph()->NewNode(common()->Start(2)); |
| 785 graph()->SetStart(start); | 784 graph()->SetStart(start); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 809 | 808 |
| 810 Node* brB2 = graph()->NewNode(common()->Branch(), phiA1, mB1); | 809 Node* brB2 = graph()->NewNode(common()->Branch(), phiA1, mB1); |
| 811 Node* tB2 = graph()->NewNode(common()->IfTrue(), brB2); | 810 Node* tB2 = graph()->NewNode(common()->IfTrue(), brB2); |
| 812 Node* fB2 = graph()->NewNode(common()->IfFalse(), brB2); | 811 Node* fB2 = graph()->NewNode(common()->IfFalse(), brB2); |
| 813 Node* mB2 = graph()->NewNode(common()->Merge(2), tB2, fB2); | 812 Node* mB2 = graph()->NewNode(common()->Merge(2), tB2, fB2); |
| 814 Node* phiB2 = | 813 Node* phiB2 = |
| 815 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), phiA1, c, mB2); | 814 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), phiA1, c, mB2); |
| 816 | 815 |
| 817 Node* add = graph()->NewNode(&kIntAdd, phiA2, phiB2); | 816 Node* add = graph()->NewNode(&kIntAdd, phiA2, phiB2); |
| 818 Node* ret = graph()->NewNode(common()->Return(), add, start, start); | 817 Node* ret = graph()->NewNode(common()->Return(), add, start, start); |
| 819 Node* end = graph()->NewNode(common()->End(), ret, start); | 818 Node* end = graph()->NewNode(common()->End(1), ret); |
| 820 | 819 |
| 821 graph()->SetEnd(end); | 820 graph()->SetEnd(end); |
| 822 | 821 |
| 823 ComputeAndVerifySchedule(36); | 822 ComputeAndVerifySchedule(36); |
| 824 } | 823 } |
| 825 | 824 |
| 826 | 825 |
| 827 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithLoop) { | 826 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithLoop) { |
| 828 Node* start = graph()->NewNode(common()->Start(2)); | 827 Node* start = graph()->NewNode(common()->Start(2)); |
| 829 graph()->SetStart(start); | 828 graph()->SetStart(start); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 843 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); | 842 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); |
| 844 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); | 843 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); |
| 845 | 844 |
| 846 loop->ReplaceInput(1, t1); // close loop. | 845 loop->ReplaceInput(1, t1); // close loop. |
| 847 ind->ReplaceInput(1, ind); // close induction variable. | 846 ind->ReplaceInput(1, ind); // close induction variable. |
| 848 | 847 |
| 849 Node* m = graph()->NewNode(common()->Merge(2), t, f1); | 848 Node* m = graph()->NewNode(common()->Merge(2), t, f1); |
| 850 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fv, ind, m); | 849 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), fv, ind, m); |
| 851 | 850 |
| 852 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); | 851 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); |
| 853 Node* end = graph()->NewNode(common()->End(), ret, start); | 852 Node* end = graph()->NewNode(common()->End(1), ret); |
| 854 | 853 |
| 855 graph()->SetEnd(end); | 854 graph()->SetEnd(end); |
| 856 | 855 |
| 857 ComputeAndVerifySchedule(20); | 856 ComputeAndVerifySchedule(20); |
| 858 } | 857 } |
| 859 | 858 |
| 860 | 859 |
| 861 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond1) { | 860 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond1) { |
| 862 Node* start = graph()->NewNode(common()->Start(2)); | 861 Node* start = graph()->NewNode(common()->Start(2)); |
| 863 graph()->SetStart(start); | 862 graph()->SetStart(start); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 876 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); | 875 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); |
| 877 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); | 876 Node* t1 = graph()->NewNode(common()->IfTrue(), br1); |
| 878 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); | 877 Node* f1 = graph()->NewNode(common()->IfFalse(), br1); |
| 879 Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1); | 878 Node* m1 = graph()->NewNode(common()->Merge(2), t1, f1); |
| 880 Node* phi1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), add, p0, m1); | 879 Node* phi1 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), add, p0, m1); |
| 881 | 880 |
| 882 loop->ReplaceInput(1, t); // close loop. | 881 loop->ReplaceInput(1, t); // close loop. |
| 883 ind->ReplaceInput(1, phi1); // close induction variable. | 882 ind->ReplaceInput(1, phi1); // close induction variable. |
| 884 | 883 |
| 885 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); | 884 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); |
| 886 Node* end = graph()->NewNode(common()->End(), ret, f); | 885 Node* end = graph()->NewNode(common()->End(2), ret, f); |
| 887 | 886 |
| 888 graph()->SetEnd(end); | 887 graph()->SetEnd(end); |
| 889 | 888 |
| 890 ComputeAndVerifySchedule(20); | 889 ComputeAndVerifySchedule(20); |
| 891 } | 890 } |
| 892 | 891 |
| 893 | 892 |
| 894 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond2) { | 893 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond2) { |
| 895 Node* start = graph()->NewNode(common()->Start(2)); | 894 Node* start = graph()->NewNode(common()->Start(2)); |
| 896 graph()->SetStart(start); | 895 graph()->SetStart(start); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 910 Node* add = graph()->NewNode(&kIntAdd, ind, phi1); | 909 Node* add = graph()->NewNode(&kIntAdd, ind, phi1); |
| 911 | 910 |
| 912 Node* br = graph()->NewNode(common()->Branch(), add, loop); | 911 Node* br = graph()->NewNode(common()->Branch(), add, loop); |
| 913 Node* t = graph()->NewNode(common()->IfTrue(), br); | 912 Node* t = graph()->NewNode(common()->IfTrue(), br); |
| 914 Node* f = graph()->NewNode(common()->IfFalse(), br); | 913 Node* f = graph()->NewNode(common()->IfFalse(), br); |
| 915 | 914 |
| 916 loop->ReplaceInput(1, t); // close loop. | 915 loop->ReplaceInput(1, t); // close loop. |
| 917 ind->ReplaceInput(1, add); // close induction variable. | 916 ind->ReplaceInput(1, add); // close induction variable. |
| 918 | 917 |
| 919 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); | 918 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); |
| 920 Node* end = graph()->NewNode(common()->End(), ret, f); | 919 Node* end = graph()->NewNode(common()->End(2), ret, f); |
| 921 | 920 |
| 922 graph()->SetEnd(end); | 921 graph()->SetEnd(end); |
| 923 | 922 |
| 924 ComputeAndVerifySchedule(20); | 923 ComputeAndVerifySchedule(20); |
| 925 } | 924 } |
| 926 | 925 |
| 927 | 926 |
| 928 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond3) { | 927 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond3) { |
| 929 Node* start = graph()->NewNode(common()->Start(2)); | 928 Node* start = graph()->NewNode(common()->Start(2)); |
| 930 graph()->SetStart(start); | 929 graph()->SetStart(start); |
| (...skipping 25 matching lines...) Expand all Loading... |
| 956 Node* add = graph()->NewNode(&kIntAdd, ind, phi1); | 955 Node* add = graph()->NewNode(&kIntAdd, ind, phi1); |
| 957 | 956 |
| 958 Node* br = graph()->NewNode(common()->Branch(), add, loop); | 957 Node* br = graph()->NewNode(common()->Branch(), add, loop); |
| 959 Node* t = graph()->NewNode(common()->IfTrue(), br); | 958 Node* t = graph()->NewNode(common()->IfTrue(), br); |
| 960 Node* f = graph()->NewNode(common()->IfFalse(), br); | 959 Node* f = graph()->NewNode(common()->IfFalse(), br); |
| 961 | 960 |
| 962 loop->ReplaceInput(1, t); // close loop. | 961 loop->ReplaceInput(1, t); // close loop. |
| 963 ind->ReplaceInput(1, add); // close induction variable. | 962 ind->ReplaceInput(1, add); // close induction variable. |
| 964 | 963 |
| 965 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); | 964 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); |
| 966 Node* end = graph()->NewNode(common()->End(), ret, f); | 965 Node* end = graph()->NewNode(common()->End(2), ret, f); |
| 967 | 966 |
| 968 graph()->SetEnd(end); | 967 graph()->SetEnd(end); |
| 969 | 968 |
| 970 ComputeAndVerifySchedule(28); | 969 ComputeAndVerifySchedule(28); |
| 971 } | 970 } |
| 972 | 971 |
| 973 | 972 |
| 974 TARGET_TEST_F(SchedulerTest, PhisPushedDownToDifferentBranches) { | 973 TARGET_TEST_F(SchedulerTest, PhisPushedDownToDifferentBranches) { |
| 975 Node* start = graph()->NewNode(common()->Start(2)); | 974 Node* start = graph()->NewNode(common()->Start(2)); |
| 976 graph()->SetStart(start); | 975 graph()->SetStart(start); |
| (...skipping 13 matching lines...) Expand all Loading... |
| 990 Node* phi2 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), v3, v4, m); | 989 Node* phi2 = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), v3, v4, m); |
| 991 | 990 |
| 992 Node* br2 = graph()->NewNode(common()->Branch(), p1, graph()->start()); | 991 Node* br2 = graph()->NewNode(common()->Branch(), p1, graph()->start()); |
| 993 Node* t2 = graph()->NewNode(common()->IfTrue(), br2); | 992 Node* t2 = graph()->NewNode(common()->IfTrue(), br2); |
| 994 Node* f2 = graph()->NewNode(common()->IfFalse(), br2); | 993 Node* f2 = graph()->NewNode(common()->IfFalse(), br2); |
| 995 Node* m2 = graph()->NewNode(common()->Merge(2), t2, f2); | 994 Node* m2 = graph()->NewNode(common()->Merge(2), t2, f2); |
| 996 Node* phi3 = | 995 Node* phi3 = |
| 997 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), phi, phi2, m2); | 996 graph()->NewNode(common()->Phi(kMachAnyTagged, 2), phi, phi2, m2); |
| 998 | 997 |
| 999 Node* ret = graph()->NewNode(common()->Return(), phi3, start, start); | 998 Node* ret = graph()->NewNode(common()->Return(), phi3, start, start); |
| 1000 Node* end = graph()->NewNode(common()->End(), ret, start); | 999 Node* end = graph()->NewNode(common()->End(1), ret); |
| 1001 | 1000 |
| 1002 graph()->SetEnd(end); | 1001 graph()->SetEnd(end); |
| 1003 | 1002 |
| 1004 ComputeAndVerifySchedule(24); | 1003 ComputeAndVerifySchedule(24); |
| 1005 } | 1004 } |
| 1006 | 1005 |
| 1007 | 1006 |
| 1008 TARGET_TEST_F(SchedulerTest, BranchHintTrue) { | 1007 TARGET_TEST_F(SchedulerTest, BranchHintTrue) { |
| 1009 Node* start = graph()->NewNode(common()->Start(1)); | 1008 Node* start = graph()->NewNode(common()->Start(1)); |
| 1010 graph()->SetStart(start); | 1009 graph()->SetStart(start); |
| 1011 | 1010 |
| 1012 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 1011 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
| 1013 Node* tv = graph()->NewNode(common()->Int32Constant(6)); | 1012 Node* tv = graph()->NewNode(common()->Int32Constant(6)); |
| 1014 Node* fv = graph()->NewNode(common()->Int32Constant(7)); | 1013 Node* fv = graph()->NewNode(common()->Int32Constant(7)); |
| 1015 Node* br = graph()->NewNode(common()->Branch(BranchHint::kTrue), p0, start); | 1014 Node* br = graph()->NewNode(common()->Branch(BranchHint::kTrue), p0, start); |
| 1016 Node* t = graph()->NewNode(common()->IfTrue(), br); | 1015 Node* t = graph()->NewNode(common()->IfTrue(), br); |
| 1017 Node* f = graph()->NewNode(common()->IfFalse(), br); | 1016 Node* f = graph()->NewNode(common()->IfFalse(), br); |
| 1018 Node* m = graph()->NewNode(common()->Merge(2), t, f); | 1017 Node* m = graph()->NewNode(common()->Merge(2), t, f); |
| 1019 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), tv, fv, m); | 1018 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), tv, fv, m); |
| 1020 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); | 1019 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); |
| 1021 Node* end = graph()->NewNode(common()->End(), ret, start); | 1020 Node* end = graph()->NewNode(common()->End(1), ret); |
| 1022 | 1021 |
| 1023 graph()->SetEnd(end); | 1022 graph()->SetEnd(end); |
| 1024 | 1023 |
| 1025 Schedule* schedule = ComputeAndVerifySchedule(13); | 1024 Schedule* schedule = ComputeAndVerifySchedule(13); |
| 1026 // Make sure the false block is marked as deferred. | 1025 // Make sure the false block is marked as deferred. |
| 1027 EXPECT_FALSE(schedule->block(t)->deferred()); | 1026 EXPECT_FALSE(schedule->block(t)->deferred()); |
| 1028 EXPECT_TRUE(schedule->block(f)->deferred()); | 1027 EXPECT_TRUE(schedule->block(f)->deferred()); |
| 1029 } | 1028 } |
| 1030 | 1029 |
| 1031 | 1030 |
| 1032 TARGET_TEST_F(SchedulerTest, BranchHintFalse) { | 1031 TARGET_TEST_F(SchedulerTest, BranchHintFalse) { |
| 1033 Node* start = graph()->NewNode(common()->Start(1)); | 1032 Node* start = graph()->NewNode(common()->Start(1)); |
| 1034 graph()->SetStart(start); | 1033 graph()->SetStart(start); |
| 1035 | 1034 |
| 1036 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 1035 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
| 1037 Node* tv = graph()->NewNode(common()->Int32Constant(6)); | 1036 Node* tv = graph()->NewNode(common()->Int32Constant(6)); |
| 1038 Node* fv = graph()->NewNode(common()->Int32Constant(7)); | 1037 Node* fv = graph()->NewNode(common()->Int32Constant(7)); |
| 1039 Node* br = graph()->NewNode(common()->Branch(BranchHint::kFalse), p0, start); | 1038 Node* br = graph()->NewNode(common()->Branch(BranchHint::kFalse), p0, start); |
| 1040 Node* t = graph()->NewNode(common()->IfTrue(), br); | 1039 Node* t = graph()->NewNode(common()->IfTrue(), br); |
| 1041 Node* f = graph()->NewNode(common()->IfFalse(), br); | 1040 Node* f = graph()->NewNode(common()->IfFalse(), br); |
| 1042 Node* m = graph()->NewNode(common()->Merge(2), t, f); | 1041 Node* m = graph()->NewNode(common()->Merge(2), t, f); |
| 1043 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), tv, fv, m); | 1042 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), tv, fv, m); |
| 1044 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); | 1043 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); |
| 1045 Node* end = graph()->NewNode(common()->End(), ret, start); | 1044 Node* end = graph()->NewNode(common()->End(1), ret); |
| 1046 | 1045 |
| 1047 graph()->SetEnd(end); | 1046 graph()->SetEnd(end); |
| 1048 | 1047 |
| 1049 Schedule* schedule = ComputeAndVerifySchedule(13); | 1048 Schedule* schedule = ComputeAndVerifySchedule(13); |
| 1050 // Make sure the true block is marked as deferred. | 1049 // Make sure the true block is marked as deferred. |
| 1051 EXPECT_TRUE(schedule->block(t)->deferred()); | 1050 EXPECT_TRUE(schedule->block(t)->deferred()); |
| 1052 EXPECT_FALSE(schedule->block(f)->deferred()); | 1051 EXPECT_FALSE(schedule->block(f)->deferred()); |
| 1053 } | 1052 } |
| 1054 | 1053 |
| 1055 | 1054 |
| 1056 TARGET_TEST_F(SchedulerTest, CallException) { | 1055 TARGET_TEST_F(SchedulerTest, CallException) { |
| 1057 Node* start = graph()->NewNode(common()->Start(1)); | 1056 Node* start = graph()->NewNode(common()->Start(1)); |
| 1058 graph()->SetStart(start); | 1057 graph()->SetStart(start); |
| 1059 | 1058 |
| 1060 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 1059 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
| 1061 Node* c1 = graph()->NewNode(&kMockCall, start); | 1060 Node* c1 = graph()->NewNode(&kMockCall, start); |
| 1062 Node* ok1 = graph()->NewNode(common()->IfSuccess(), c1); | 1061 Node* ok1 = graph()->NewNode(common()->IfSuccess(), c1); |
| 1063 Node* ex1 = graph()->NewNode(common()->IfException(), c1); | 1062 Node* ex1 = graph()->NewNode(common()->IfException(), c1); |
| 1064 Node* c2 = graph()->NewNode(&kMockCall, ok1); | 1063 Node* c2 = graph()->NewNode(&kMockCall, ok1); |
| 1065 Node* ok2 = graph()->NewNode(common()->IfSuccess(), c2); | 1064 Node* ok2 = graph()->NewNode(common()->IfSuccess(), c2); |
| 1066 Node* ex2 = graph()->NewNode(common()->IfException(), c2); | 1065 Node* ex2 = graph()->NewNode(common()->IfException(), c2); |
| 1067 Node* hdl = graph()->NewNode(common()->Merge(2), ex1, ex2); | 1066 Node* hdl = graph()->NewNode(common()->Merge(2), ex1, ex2); |
| 1068 Node* m = graph()->NewNode(common()->Merge(2), ok2, hdl); | 1067 Node* m = graph()->NewNode(common()->Merge(2), ok2, hdl); |
| 1069 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), c2, p0, m); | 1068 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), c2, p0, m); |
| 1070 Node* ret = graph()->NewNode(common()->Return(), phi, start, m); | 1069 Node* ret = graph()->NewNode(common()->Return(), phi, start, m); |
| 1071 Node* end = graph()->NewNode(common()->End(), ret); | 1070 Node* end = graph()->NewNode(common()->End(1), ret); |
| 1072 | 1071 |
| 1073 graph()->SetEnd(end); | 1072 graph()->SetEnd(end); |
| 1074 | 1073 |
| 1075 Schedule* schedule = ComputeAndVerifySchedule(17); | 1074 Schedule* schedule = ComputeAndVerifySchedule(17); |
| 1076 // Make sure the exception blocks as well as the handler are deferred. | 1075 // Make sure the exception blocks as well as the handler are deferred. |
| 1077 EXPECT_TRUE(schedule->block(ex1)->deferred()); | 1076 EXPECT_TRUE(schedule->block(ex1)->deferred()); |
| 1078 EXPECT_TRUE(schedule->block(ex2)->deferred()); | 1077 EXPECT_TRUE(schedule->block(ex2)->deferred()); |
| 1079 EXPECT_TRUE(schedule->block(hdl)->deferred()); | 1078 EXPECT_TRUE(schedule->block(hdl)->deferred()); |
| 1080 EXPECT_FALSE(schedule->block(m)->deferred()); | 1079 EXPECT_FALSE(schedule->block(m)->deferred()); |
| 1081 } | 1080 } |
| 1082 | 1081 |
| 1083 | 1082 |
| 1084 TARGET_TEST_F(SchedulerTest, TailCall) { | 1083 TARGET_TEST_F(SchedulerTest, TailCall) { |
| 1085 Node* start = graph()->NewNode(common()->Start(1)); | 1084 Node* start = graph()->NewNode(common()->Start(1)); |
| 1086 graph()->SetStart(start); | 1085 graph()->SetStart(start); |
| 1087 | 1086 |
| 1088 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 1087 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
| 1089 Node* call = graph()->NewNode(&kMockTailCall, p0, start, start); | 1088 Node* call = graph()->NewNode(&kMockTailCall, p0, start, start); |
| 1090 Node* end = graph()->NewNode(common()->End(), call); | 1089 Node* end = graph()->NewNode(common()->End(1), call); |
| 1091 | 1090 |
| 1092 graph()->SetEnd(end); | 1091 graph()->SetEnd(end); |
| 1093 | 1092 |
| 1094 ComputeAndVerifySchedule(4); | 1093 ComputeAndVerifySchedule(4); |
| 1095 } | 1094 } |
| 1096 | 1095 |
| 1097 | 1096 |
| 1098 TARGET_TEST_F(SchedulerTest, Switch) { | 1097 TARGET_TEST_F(SchedulerTest, Switch) { |
| 1099 Node* start = graph()->NewNode(common()->Start(1)); | 1098 Node* start = graph()->NewNode(common()->Start(1)); |
| 1100 graph()->SetStart(start); | 1099 graph()->SetStart(start); |
| 1101 | 1100 |
| 1102 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 1101 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
| 1103 Node* sw = graph()->NewNode(common()->Switch(3), p0, start); | 1102 Node* sw = graph()->NewNode(common()->Switch(3), p0, start); |
| 1104 Node* c0 = graph()->NewNode(common()->IfValue(0), sw); | 1103 Node* c0 = graph()->NewNode(common()->IfValue(0), sw); |
| 1105 Node* v0 = graph()->NewNode(common()->Int32Constant(11)); | 1104 Node* v0 = graph()->NewNode(common()->Int32Constant(11)); |
| 1106 Node* c1 = graph()->NewNode(common()->IfValue(1), sw); | 1105 Node* c1 = graph()->NewNode(common()->IfValue(1), sw); |
| 1107 Node* v1 = graph()->NewNode(common()->Int32Constant(22)); | 1106 Node* v1 = graph()->NewNode(common()->Int32Constant(22)); |
| 1108 Node* d = graph()->NewNode(common()->IfDefault(), sw); | 1107 Node* d = graph()->NewNode(common()->IfDefault(), sw); |
| 1109 Node* vd = graph()->NewNode(common()->Int32Constant(33)); | 1108 Node* vd = graph()->NewNode(common()->Int32Constant(33)); |
| 1110 Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d); | 1109 Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d); |
| 1111 Node* phi = graph()->NewNode(common()->Phi(kMachInt32, 3), v0, v1, vd, m); | 1110 Node* phi = graph()->NewNode(common()->Phi(kMachInt32, 3), v0, v1, vd, m); |
| 1112 Node* ret = graph()->NewNode(common()->Return(), phi, start, m); | 1111 Node* ret = graph()->NewNode(common()->Return(), phi, start, m); |
| 1113 Node* end = graph()->NewNode(common()->End(), ret); | 1112 Node* end = graph()->NewNode(common()->End(1), ret); |
| 1114 | 1113 |
| 1115 graph()->SetEnd(end); | 1114 graph()->SetEnd(end); |
| 1116 | 1115 |
| 1117 ComputeAndVerifySchedule(16); | 1116 ComputeAndVerifySchedule(16); |
| 1118 } | 1117 } |
| 1119 | 1118 |
| 1120 | 1119 |
| 1121 TARGET_TEST_F(SchedulerTest, FloatingSwitch) { | 1120 TARGET_TEST_F(SchedulerTest, FloatingSwitch) { |
| 1122 Node* start = graph()->NewNode(common()->Start(1)); | 1121 Node* start = graph()->NewNode(common()->Start(1)); |
| 1123 graph()->SetStart(start); | 1122 graph()->SetStart(start); |
| 1124 | 1123 |
| 1125 Node* p0 = graph()->NewNode(common()->Parameter(0), start); | 1124 Node* p0 = graph()->NewNode(common()->Parameter(0), start); |
| 1126 Node* sw = graph()->NewNode(common()->Switch(3), p0, start); | 1125 Node* sw = graph()->NewNode(common()->Switch(3), p0, start); |
| 1127 Node* c0 = graph()->NewNode(common()->IfValue(0), sw); | 1126 Node* c0 = graph()->NewNode(common()->IfValue(0), sw); |
| 1128 Node* v0 = graph()->NewNode(common()->Int32Constant(11)); | 1127 Node* v0 = graph()->NewNode(common()->Int32Constant(11)); |
| 1129 Node* c1 = graph()->NewNode(common()->IfValue(1), sw); | 1128 Node* c1 = graph()->NewNode(common()->IfValue(1), sw); |
| 1130 Node* v1 = graph()->NewNode(common()->Int32Constant(22)); | 1129 Node* v1 = graph()->NewNode(common()->Int32Constant(22)); |
| 1131 Node* d = graph()->NewNode(common()->IfDefault(), sw); | 1130 Node* d = graph()->NewNode(common()->IfDefault(), sw); |
| 1132 Node* vd = graph()->NewNode(common()->Int32Constant(33)); | 1131 Node* vd = graph()->NewNode(common()->Int32Constant(33)); |
| 1133 Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d); | 1132 Node* m = graph()->NewNode(common()->Merge(3), c0, c1, d); |
| 1134 Node* phi = graph()->NewNode(common()->Phi(kMachInt32, 3), v0, v1, vd, m); | 1133 Node* phi = graph()->NewNode(common()->Phi(kMachInt32, 3), v0, v1, vd, m); |
| 1135 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); | 1134 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); |
| 1136 Node* end = graph()->NewNode(common()->End(), ret); | 1135 Node* end = graph()->NewNode(common()->End(1), ret); |
| 1137 | 1136 |
| 1138 graph()->SetEnd(end); | 1137 graph()->SetEnd(end); |
| 1139 | 1138 |
| 1140 ComputeAndVerifySchedule(16); | 1139 ComputeAndVerifySchedule(16); |
| 1141 } | 1140 } |
| 1142 | 1141 |
| 1143 | 1142 |
| 1144 TARGET_TEST_F(SchedulerTest, Terminate) { | 1143 TARGET_TEST_F(SchedulerTest, Terminate) { |
| 1145 Node* start = graph()->NewNode(common()->Start(1)); | 1144 Node* start = graph()->NewNode(common()->Start(1)); |
| 1146 graph()->SetStart(start); | 1145 graph()->SetStart(start); |
| 1147 | 1146 |
| 1148 Node* loop = graph()->NewNode(common()->Loop(2), start, start); | 1147 Node* loop = graph()->NewNode(common()->Loop(2), start, start); |
| 1149 loop->ReplaceInput(1, loop); // self loop, NTL. | 1148 loop->ReplaceInput(1, loop); // self loop, NTL. |
| 1150 | 1149 |
| 1151 Node* effect = graph()->NewNode(common()->EffectPhi(1), start, loop); | 1150 Node* effect = graph()->NewNode(common()->EffectPhi(1), start, loop); |
| 1152 | 1151 |
| 1153 Node* terminate = graph()->NewNode(common()->Terminate(), effect, loop); | 1152 Node* terminate = graph()->NewNode(common()->Terminate(), effect, loop); |
| 1154 effect->ReplaceInput(1, terminate); | 1153 effect->ReplaceInput(1, terminate); |
| 1155 | 1154 |
| 1156 Node* end = graph()->NewNode(common()->End(), terminate); | 1155 Node* end = graph()->NewNode(common()->End(1), terminate); |
| 1157 | 1156 |
| 1158 graph()->SetEnd(end); | 1157 graph()->SetEnd(end); |
| 1159 | 1158 |
| 1160 Schedule* schedule = ComputeAndVerifySchedule(6); | 1159 Schedule* schedule = ComputeAndVerifySchedule(6); |
| 1161 BasicBlock* block = schedule->block(loop); | 1160 BasicBlock* block = schedule->block(loop); |
| 1162 EXPECT_EQ(block, schedule->block(effect)); | 1161 EXPECT_EQ(block, schedule->block(effect)); |
| 1163 EXPECT_GE(block->rpo_number(), 0); | 1162 EXPECT_GE(block->rpo_number(), 0); |
| 1164 } | 1163 } |
| 1165 | 1164 |
| 1166 } // namespace compiler | 1165 } // namespace compiler |
| 1167 } // namespace internal | 1166 } // namespace internal |
| 1168 } // namespace v8 | 1167 } // namespace v8 |
| OLD | NEW |