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 #include "test/cctest/cctest.h" | 6 #include "test/cctest/cctest.h" |
7 | 7 |
8 #include "src/compiler/access-builder.h" | 8 #include "src/compiler/access-builder.h" |
9 #include "src/compiler/common-operator.h" | 9 #include "src/compiler/common-operator.h" |
10 #include "src/compiler/generic-node-inl.h" | 10 #include "src/compiler/generic-node-inl.h" |
(...skipping 1814 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1825 Node* phi3 = graph.NewNode(common.Phi(kMachAnyTagged, 2), phi, phi2, m2); | 1825 Node* phi3 = graph.NewNode(common.Phi(kMachAnyTagged, 2), phi, phi2, m2); |
1826 | 1826 |
1827 Node* ret = graph.NewNode(common.Return(), phi3, start, start); | 1827 Node* ret = graph.NewNode(common.Return(), phi3, start, start); |
1828 Node* end = graph.NewNode(common.End(), ret, start); | 1828 Node* end = graph.NewNode(common.End(), ret, start); |
1829 | 1829 |
1830 graph.SetEnd(end); | 1830 graph.SetEnd(end); |
1831 | 1831 |
1832 ComputeAndVerifySchedule(24, &graph); | 1832 ComputeAndVerifySchedule(24, &graph); |
1833 } | 1833 } |
1834 | 1834 |
| 1835 |
| 1836 TEST(BranchHintTrue) { |
| 1837 HandleAndZoneScope scope; |
| 1838 Graph graph(scope.main_zone()); |
| 1839 CommonOperatorBuilder common(scope.main_zone()); |
| 1840 |
| 1841 Node* start = graph.NewNode(common.Start(1)); |
| 1842 graph.SetStart(start); |
| 1843 |
| 1844 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1845 Node* tv = graph.NewNode(common.Int32Constant(6)); |
| 1846 Node* fv = graph.NewNode(common.Int32Constant(7)); |
| 1847 Node* br = graph.NewNode(common.Branch(BranchHint::kTrue), p0, start); |
| 1848 Node* t = graph.NewNode(common.IfTrue(), br); |
| 1849 Node* f = graph.NewNode(common.IfFalse(), br); |
| 1850 Node* m = graph.NewNode(common.Merge(2), t, f); |
| 1851 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 2), tv, fv, m); |
| 1852 Node* ret = graph.NewNode(common.Return(), phi, start, start); |
| 1853 Node* end = graph.NewNode(common.End(), ret, start); |
| 1854 |
| 1855 graph.SetEnd(end); |
| 1856 |
| 1857 Schedule* schedule = ComputeAndVerifySchedule(13, &graph); |
| 1858 // Make sure the false block is marked as deferred. |
| 1859 CHECK(!schedule->block(t)->deferred()); |
| 1860 CHECK(schedule->block(f)->deferred()); |
| 1861 } |
| 1862 |
| 1863 |
| 1864 TEST(BranchHintFalse) { |
| 1865 HandleAndZoneScope scope; |
| 1866 Graph graph(scope.main_zone()); |
| 1867 CommonOperatorBuilder common(scope.main_zone()); |
| 1868 |
| 1869 Node* start = graph.NewNode(common.Start(1)); |
| 1870 graph.SetStart(start); |
| 1871 |
| 1872 Node* p0 = graph.NewNode(common.Parameter(0), start); |
| 1873 Node* tv = graph.NewNode(common.Int32Constant(6)); |
| 1874 Node* fv = graph.NewNode(common.Int32Constant(7)); |
| 1875 Node* br = graph.NewNode(common.Branch(BranchHint::kFalse), p0, start); |
| 1876 Node* t = graph.NewNode(common.IfTrue(), br); |
| 1877 Node* f = graph.NewNode(common.IfFalse(), br); |
| 1878 Node* m = graph.NewNode(common.Merge(2), t, f); |
| 1879 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 2), tv, fv, m); |
| 1880 Node* ret = graph.NewNode(common.Return(), phi, start, start); |
| 1881 Node* end = graph.NewNode(common.End(), ret, start); |
| 1882 |
| 1883 graph.SetEnd(end); |
| 1884 |
| 1885 Schedule* schedule = ComputeAndVerifySchedule(13, &graph); |
| 1886 // Make sure the true block is marked as deferred. |
| 1887 CHECK(schedule->block(t)->deferred()); |
| 1888 CHECK(!schedule->block(f)->deferred()); |
| 1889 } |
| 1890 |
1835 #endif | 1891 #endif |
OLD | NEW |