OLD | NEW |
1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #include "src/compiler/access-builder.h" | 7 #include "src/compiler/access-builder.h" |
8 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
9 #include "src/compiler/generic-node-inl.h" | 9 #include "src/compiler/generic-node-inl.h" |
10 #include "src/compiler/generic-node.h" | 10 #include "src/compiler/generic-node.h" |
(...skipping 1792 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1803 graph.SetEnd(end); | 1803 graph.SetEnd(end); |
1804 | 1804 |
1805 ComputeAndVerifySchedule(23, &graph); | 1805 ComputeAndVerifySchedule(23, &graph); |
1806 } | 1806 } |
1807 | 1807 |
1808 | 1808 |
1809 TEST(NestedFloatingDiamondWithLoop) { | 1809 TEST(NestedFloatingDiamondWithLoop) { |
1810 HandleAndZoneScope scope; | 1810 HandleAndZoneScope scope; |
1811 Graph graph(scope.main_zone()); | 1811 Graph graph(scope.main_zone()); |
1812 CommonOperatorBuilder common(scope.main_zone()); | 1812 CommonOperatorBuilder common(scope.main_zone()); |
1813 SimplifiedOperatorBuilder simplified(scope.main_zone()); | |
1814 | 1813 |
1815 Node* start = graph.NewNode(common.Start(2)); | 1814 Node* start = graph.NewNode(common.Start(2)); |
1816 graph.SetStart(start); | 1815 graph.SetStart(start); |
1817 | 1816 |
1818 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1817 Node* p0 = graph.NewNode(common.Parameter(0), start); |
1819 | 1818 |
1820 Node* fv = graph.NewNode(common.Int32Constant(7)); | 1819 Node* fv = graph.NewNode(common.Int32Constant(7)); |
1821 Node* br = graph.NewNode(common.Branch(), p0, graph.start()); | 1820 Node* br = graph.NewNode(common.Branch(), p0, graph.start()); |
1822 Node* t = graph.NewNode(common.IfTrue(), br); | 1821 Node* t = graph.NewNode(common.IfTrue(), br); |
1823 Node* f = graph.NewNode(common.IfFalse(), br); | 1822 Node* f = graph.NewNode(common.IfFalse(), br); |
(...skipping 18 matching lines...) Expand all Loading... |
1842 graph.SetEnd(end); | 1841 graph.SetEnd(end); |
1843 | 1842 |
1844 ComputeAndVerifySchedule(20, &graph); | 1843 ComputeAndVerifySchedule(20, &graph); |
1845 } | 1844 } |
1846 | 1845 |
1847 | 1846 |
1848 TEST(LoopedFloatingDiamond1) { | 1847 TEST(LoopedFloatingDiamond1) { |
1849 HandleAndZoneScope scope; | 1848 HandleAndZoneScope scope; |
1850 Graph graph(scope.main_zone()); | 1849 Graph graph(scope.main_zone()); |
1851 CommonOperatorBuilder common(scope.main_zone()); | 1850 CommonOperatorBuilder common(scope.main_zone()); |
1852 SimplifiedOperatorBuilder simplified(scope.main_zone()); | |
1853 | 1851 |
1854 Node* start = graph.NewNode(common.Start(2)); | 1852 Node* start = graph.NewNode(common.Start(2)); |
1855 graph.SetStart(start); | 1853 graph.SetStart(start); |
1856 | 1854 |
1857 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1855 Node* p0 = graph.NewNode(common.Parameter(0), start); |
1858 | 1856 |
1859 Node* c = graph.NewNode(common.Int32Constant(7)); | 1857 Node* c = graph.NewNode(common.Int32Constant(7)); |
1860 Node* loop = graph.NewNode(common.Loop(2), start, start); | 1858 Node* loop = graph.NewNode(common.Loop(2), start, start); |
1861 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); | 1859 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); |
1862 Node* add = graph.NewNode(&kIntAdd, ind, c); | 1860 Node* add = graph.NewNode(&kIntAdd, ind, c); |
(...skipping 17 matching lines...) Expand all Loading... |
1880 graph.SetEnd(end); | 1878 graph.SetEnd(end); |
1881 | 1879 |
1882 ComputeAndVerifySchedule(20, &graph); | 1880 ComputeAndVerifySchedule(20, &graph); |
1883 } | 1881 } |
1884 | 1882 |
1885 | 1883 |
1886 TEST(LoopedFloatingDiamond2) { | 1884 TEST(LoopedFloatingDiamond2) { |
1887 HandleAndZoneScope scope; | 1885 HandleAndZoneScope scope; |
1888 Graph graph(scope.main_zone()); | 1886 Graph graph(scope.main_zone()); |
1889 CommonOperatorBuilder common(scope.main_zone()); | 1887 CommonOperatorBuilder common(scope.main_zone()); |
1890 SimplifiedOperatorBuilder simplified(scope.main_zone()); | |
1891 | 1888 |
1892 Node* start = graph.NewNode(common.Start(2)); | 1889 Node* start = graph.NewNode(common.Start(2)); |
1893 graph.SetStart(start); | 1890 graph.SetStart(start); |
1894 | 1891 |
1895 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1892 Node* p0 = graph.NewNode(common.Parameter(0), start); |
1896 | 1893 |
1897 Node* c = graph.NewNode(common.Int32Constant(7)); | 1894 Node* c = graph.NewNode(common.Int32Constant(7)); |
1898 Node* loop = graph.NewNode(common.Loop(2), start, start); | 1895 Node* loop = graph.NewNode(common.Loop(2), start, start); |
1899 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); | 1896 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); |
1900 | 1897 |
(...skipping 14 matching lines...) Expand all Loading... |
1915 | 1912 |
1916 Node* ret = graph.NewNode(common.Return(), ind, start, f); | 1913 Node* ret = graph.NewNode(common.Return(), ind, start, f); |
1917 Node* end = graph.NewNode(common.End(), ret, f); | 1914 Node* end = graph.NewNode(common.End(), ret, f); |
1918 | 1915 |
1919 graph.SetEnd(end); | 1916 graph.SetEnd(end); |
1920 | 1917 |
1921 ComputeAndVerifySchedule(20, &graph); | 1918 ComputeAndVerifySchedule(20, &graph); |
1922 } | 1919 } |
1923 | 1920 |
1924 | 1921 |
| 1922 TEST(LoopedFloatingDiamond3) { |
| 1923 HandleAndZoneScope scope; |
| 1924 Graph graph(scope.main_zone()); |
| 1925 CommonOperatorBuilder common(scope.main_zone()); |
| 1926 |
| 1927 Node* start = graph.NewNode(common.Start(2)); |
| 1928 graph.SetStart(start); |
| 1929 |
| 1930 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1931 |
| 1932 Node* c = graph.NewNode(common.Int32Constant(7)); |
| 1933 Node* loop = graph.NewNode(common.Loop(2), start, start); |
| 1934 Node* ind = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); |
| 1935 |
| 1936 Node* br1 = graph.NewNode(common.Branch(), p0, graph.start()); |
| 1937 Node* t1 = graph.NewNode(common.IfTrue(), br1); |
| 1938 Node* f1 = graph.NewNode(common.IfFalse(), br1); |
| 1939 |
| 1940 Node* loop1 = graph.NewNode(common.Loop(2), t1, start); |
| 1941 Node* ind1 = graph.NewNode(common.Phi(kMachAnyTagged, 2), p0, p0, loop); |
| 1942 |
| 1943 Node* add1 = graph.NewNode(&kIntAdd, ind1, c); |
| 1944 Node* br2 = graph.NewNode(common.Branch(), add1, loop1); |
| 1945 Node* t2 = graph.NewNode(common.IfTrue(), br2); |
| 1946 Node* f2 = graph.NewNode(common.IfFalse(), br2); |
| 1947 |
| 1948 loop1->ReplaceInput(1, t2); // close inner loop. |
| 1949 ind1->ReplaceInput(1, ind1); // close inner induction variable. |
| 1950 |
| 1951 Node* m1 = graph.NewNode(common.Merge(2), f1, f2); |
| 1952 Node* phi1 = graph.NewNode(common.Phi(kMachAnyTagged, 2), c, ind1, m1); |
| 1953 |
| 1954 Node* add = graph.NewNode(&kIntAdd, ind, phi1); |
| 1955 |
| 1956 Node* br = graph.NewNode(common.Branch(), add, loop); |
| 1957 Node* t = graph.NewNode(common.IfTrue(), br); |
| 1958 Node* f = graph.NewNode(common.IfFalse(), br); |
| 1959 |
| 1960 loop->ReplaceInput(1, t); // close loop. |
| 1961 ind->ReplaceInput(1, add); // close induction variable. |
| 1962 |
| 1963 Node* ret = graph.NewNode(common.Return(), ind, start, f); |
| 1964 Node* end = graph.NewNode(common.End(), ret, f); |
| 1965 |
| 1966 graph.SetEnd(end); |
| 1967 |
| 1968 ComputeAndVerifySchedule(28, &graph); |
| 1969 } |
| 1970 |
| 1971 |
1925 TEST(PhisPushedDownToDifferentBranches) { | 1972 TEST(PhisPushedDownToDifferentBranches) { |
1926 HandleAndZoneScope scope; | 1973 HandleAndZoneScope scope; |
1927 Graph graph(scope.main_zone()); | 1974 Graph graph(scope.main_zone()); |
1928 CommonOperatorBuilder common(scope.main_zone()); | 1975 CommonOperatorBuilder common(scope.main_zone()); |
1929 SimplifiedOperatorBuilder simplified(scope.main_zone()); | |
1930 | 1976 |
1931 Node* start = graph.NewNode(common.Start(2)); | 1977 Node* start = graph.NewNode(common.Start(2)); |
1932 graph.SetStart(start); | 1978 graph.SetStart(start); |
1933 | 1979 |
1934 Node* p0 = graph.NewNode(common.Parameter(0), start); | 1980 Node* p0 = graph.NewNode(common.Parameter(0), start); |
1935 Node* p1 = graph.NewNode(common.Parameter(1), start); | 1981 Node* p1 = graph.NewNode(common.Parameter(1), start); |
1936 | 1982 |
1937 Node* v1 = graph.NewNode(common.Int32Constant(1)); | 1983 Node* v1 = graph.NewNode(common.Int32Constant(1)); |
1938 Node* v2 = graph.NewNode(common.Int32Constant(2)); | 1984 Node* v2 = graph.NewNode(common.Int32Constant(2)); |
1939 Node* v3 = graph.NewNode(common.Int32Constant(3)); | 1985 Node* v3 = graph.NewNode(common.Int32Constant(3)); |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2036 graph.SetEnd(end); | 2082 graph.SetEnd(end); |
2037 | 2083 |
2038 Schedule* schedule = ComputeAndVerifySchedule(6, &graph); | 2084 Schedule* schedule = ComputeAndVerifySchedule(6, &graph); |
2039 BasicBlock* block = schedule->block(loop); | 2085 BasicBlock* block = schedule->block(loop); |
2040 CHECK_NE(NULL, loop); | 2086 CHECK_NE(NULL, loop); |
2041 CHECK_EQ(block, schedule->block(effect)); | 2087 CHECK_EQ(block, schedule->block(effect)); |
2042 CHECK_GE(block->rpo_number(), 0); | 2088 CHECK_GE(block->rpo_number(), 0); |
2043 } | 2089 } |
2044 | 2090 |
2045 #endif | 2091 #endif |
OLD | NEW |