Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(5)

Side by Side Diff: test/unittests/compiler/scheduler-unittest.cc

Issue 877033002: [turbofan] Some cleanup for scheduler unittests. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 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/v8.h"
6
7 #include "src/compiler/access-builder.h" 5 #include "src/compiler/access-builder.h"
8 #include "src/compiler/common-operator.h" 6 #include "src/compiler/common-operator.h"
9 #include "src/compiler/graph.h" 7 #include "src/compiler/graph.h"
10 #include "src/compiler/graph-visualizer.h" 8 #include "src/compiler/graph-visualizer.h"
11 #include "src/compiler/js-operator.h" 9 #include "src/compiler/js-operator.h"
12 #include "src/compiler/node.h" 10 #include "src/compiler/node.h"
13 #include "src/compiler/opcodes.h" 11 #include "src/compiler/opcodes.h"
14 #include "src/compiler/operator.h" 12 #include "src/compiler/operator.h"
15 #include "src/compiler/schedule.h" 13 #include "src/compiler/schedule.h"
16 #include "src/compiler/scheduler.h" 14 #include "src/compiler/scheduler.h"
17 #include "src/compiler/simplified-operator.h" 15 #include "src/compiler/simplified-operator.h"
18 #include "src/compiler/verifier.h" 16 #include "src/compiler/verifier.h"
17 #include "test/unittests/compiler/compiler-test-utils.h"
19 #include "test/unittests/test-utils.h" 18 #include "test/unittests/test-utils.h"
20 19
21 using namespace v8::internal; 20 namespace v8 {
22 using namespace v8::internal::compiler; 21 namespace internal {
22 namespace compiler {
23 23
24 namespace { 24 class SchedulerTest : public TestWithZone {
25
26 class SchedulerTest : public virtual TestWithZone {
27 public: 25 public:
28 SchedulerTest() 26 SchedulerTest()
29 : TestWithZone(), 27 : graph_(zone()), common_(zone()), simplified_(zone()), js_(zone()) {}
30 graph_(zone()),
31 common_(zone()),
32 simplified_(zone()),
33 js_(zone()) {}
34 28
35 static Schedule* ComputeAndVerifySchedule(int expected, Graph* graph) { 29 static Schedule* ComputeAndVerifySchedule(int expected, Graph* graph) {
36 if (FLAG_trace_turbo) { 30 if (FLAG_trace_turbo) {
37 OFStream os(stdout); 31 OFStream os(stdout);
38 os << AsDOT(*graph); 32 os << AsDOT(*graph);
39 } 33 }
40 34
41 Schedule* schedule = Scheduler::ComputeSchedule(graph->zone(), graph); 35 Schedule* schedule = Scheduler::ComputeSchedule(graph->zone(), graph);
42 36
43 if (FLAG_trace_turbo_scheduler) { 37 if (FLAG_trace_turbo_scheduler) {
(...skipping 19 matching lines...) Expand all
63 SimplifiedOperatorBuilder* simplified() { return &simplified_; } 57 SimplifiedOperatorBuilder* simplified() { return &simplified_; }
64 JSOperatorBuilder* js() { return &js_; } 58 JSOperatorBuilder* js() { return &js_; }
65 59
66 private: 60 private:
67 Graph graph_; 61 Graph graph_;
68 CommonOperatorBuilder common_; 62 CommonOperatorBuilder common_;
69 SimplifiedOperatorBuilder simplified_; 63 SimplifiedOperatorBuilder simplified_;
70 JSOperatorBuilder js_; 64 JSOperatorBuilder js_;
71 }; 65 };
72 66
73 class SchedulerRPOTest : public virtual SchedulerTest { 67
68 class SchedulerRPOTest : public SchedulerTest {
74 public: 69 public:
75 SchedulerRPOTest() {} 70 SchedulerRPOTest() {}
76 71
77 // TODO(titzer): pull RPO tests out to their own file. 72 // TODO(titzer): pull RPO tests out to their own file.
78 static void CheckRPONumbers(BasicBlockVector* order, size_t expected, 73 static void CheckRPONumbers(BasicBlockVector* order, size_t expected,
79 bool loops_allowed) { 74 bool loops_allowed) {
80 CHECK(expected == order->size()); 75 CHECK(expected == order->size());
81 for (int i = 0; i < static_cast<int>(order->size()); i++) { 76 for (int i = 0; i < static_cast<int>(order->size()); i++) {
82 CHECK(order->at(i)->rpo_number() == i); 77 CHECK(order->at(i)->rpo_number() == i);
83 if (!loops_allowed) { 78 if (!loops_allowed) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 loop->nodes[i] = schedule->NewBasicBlock(); 121 loop->nodes[i] = schedule->NewBasicBlock();
127 if (i > 0) { 122 if (i > 0) {
128 schedule->AddSuccessorForTesting(loop->nodes[i - 1], loop->nodes[i]); 123 schedule->AddSuccessorForTesting(loop->nodes[i - 1], loop->nodes[i]);
129 } 124 }
130 } 125 }
131 schedule->AddSuccessorForTesting(loop->nodes[count - 1], loop->nodes[0]); 126 schedule->AddSuccessorForTesting(loop->nodes[count - 1], loop->nodes[0]);
132 return loop; 127 return loop;
133 } 128 }
134 }; 129 };
135 130
136 class SchedulerTestWithIsolate : public virtual SchedulerTest, 131
137 public virtual TestWithIsolate { 132 class SchedulerTestWithIsolate : public SchedulerTest, public TestWithIsolate {
138 public: 133 public:
139 SchedulerTestWithIsolate() {} 134 SchedulerTestWithIsolate() {}
140 135
141 Unique<HeapObject> GetUniqueUndefined() { 136 Unique<HeapObject> GetUniqueUndefined() {
142 Handle<HeapObject> object = 137 Handle<HeapObject> object =
143 Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate()); 138 Handle<HeapObject>(isolate()->heap()->undefined_value(), isolate());
144 return Unique<HeapObject>::CreateUninitialized(object); 139 return Unique<HeapObject>::CreateUninitialized(object);
145 } 140 }
146 }; 141 };
147 142
148 Operator kIntAdd(IrOpcode::kInt32Add, Operator::kPure, "Int32Add", 2, 0, 0, 1, 143 namespace {
149 0, 0); 144
145 const Operator kIntAdd(IrOpcode::kInt32Add, Operator::kPure, "Int32Add", 2, 0,
146 0, 1, 0, 0);
150 147
151 } // namespace 148 } // namespace
152 149
153 150
154 TEST_F(SchedulerTest, BuildScheduleEmpty) { 151 TEST_F(SchedulerTest, BuildScheduleEmpty) {
155 graph()->SetStart(graph()->NewNode(common()->Start(0))); 152 graph()->SetStart(graph()->NewNode(common()->Start(0)));
156 graph()->SetEnd(graph()->NewNode(common()->End(), graph()->start())); 153 graph()->SetEnd(graph()->NewNode(common()->End(), graph()->start()));
157 USE(Scheduler::ComputeSchedule(zone(), graph())); 154 USE(Scheduler::ComputeSchedule(zone(), graph()));
158 } 155 }
159 156
(...skipping 1425 matching lines...) Expand 10 before | Expand all | Expand 10 after
1585 graph()->SetStart(n0); 1582 graph()->SetStart(n0);
1586 graph()->SetEnd(n22); 1583 graph()->SetEnd(n22);
1587 1584
1588 Schedule* schedule = ComputeAndVerifySchedule(19, graph()); 1585 Schedule* schedule = ComputeAndVerifySchedule(19, graph());
1589 // Make sure the integer-only add gets hoisted to a different block that the 1586 // Make sure the integer-only add gets hoisted to a different block that the
1590 // JSAdd. 1587 // JSAdd.
1591 CHECK(schedule->block(n19) != schedule->block(n20)); 1588 CHECK(schedule->block(n19) != schedule->block(n20));
1592 } 1589 }
1593 1590
1594 1591
1595 #if V8_TURBOFAN_TARGET 1592 namespace {
1596 1593
1597 static Node* CreateDiamond(Graph* graph, CommonOperatorBuilder* common, 1594 Node* CreateDiamond(Graph* graph, CommonOperatorBuilder* common, Node* cond) {
1598 Node* cond) {
1599 Node* tv = graph->NewNode(common->Int32Constant(6)); 1595 Node* tv = graph->NewNode(common->Int32Constant(6));
1600 Node* fv = graph->NewNode(common->Int32Constant(7)); 1596 Node* fv = graph->NewNode(common->Int32Constant(7));
1601 Node* br = graph->NewNode(common->Branch(), cond, graph->start()); 1597 Node* br = graph->NewNode(common->Branch(), cond, graph->start());
1602 Node* t = graph->NewNode(common->IfTrue(), br); 1598 Node* t = graph->NewNode(common->IfTrue(), br);
1603 Node* f = graph->NewNode(common->IfFalse(), br); 1599 Node* f = graph->NewNode(common->IfFalse(), br);
1604 Node* m = graph->NewNode(common->Merge(2), t, f); 1600 Node* m = graph->NewNode(common->Merge(2), t, f);
1605 Node* phi = graph->NewNode(common->Phi(kMachAnyTagged, 2), tv, fv, m); 1601 Node* phi = graph->NewNode(common->Phi(kMachAnyTagged, 2), tv, fv, m);
1606 return phi; 1602 return phi;
1607 } 1603 }
1608 1604
1605 } // namespace
1609 1606
1610 TEST_F(SchedulerTest, FloatingDiamond1) { 1607
1608 TARGET_TEST_F(SchedulerTest, FloatingDiamond1) {
1611 Node* start = graph()->NewNode(common()->Start(1)); 1609 Node* start = graph()->NewNode(common()->Start(1));
1612 graph()->SetStart(start); 1610 graph()->SetStart(start);
1613 1611
1614 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 1612 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
1615 Node* d1 = CreateDiamond(graph(), common(), p0); 1613 Node* d1 = CreateDiamond(graph(), common(), p0);
1616 Node* ret = graph()->NewNode(common()->Return(), d1, start, start); 1614 Node* ret = graph()->NewNode(common()->Return(), d1, start, start);
1617 Node* end = graph()->NewNode(common()->End(), ret, start); 1615 Node* end = graph()->NewNode(common()->End(), ret, start);
1618 1616
1619 graph()->SetEnd(end); 1617 graph()->SetEnd(end);
1620 1618
1621 ComputeAndVerifySchedule(13, graph()); 1619 ComputeAndVerifySchedule(13, graph());
1622 } 1620 }
1623 1621
1624 1622
1625 TEST_F(SchedulerTest, FloatingDiamond2) { 1623 TARGET_TEST_F(SchedulerTest, FloatingDiamond2) {
1626 Node* start = graph()->NewNode(common()->Start(2)); 1624 Node* start = graph()->NewNode(common()->Start(2));
1627 graph()->SetStart(start); 1625 graph()->SetStart(start);
1628 1626
1629 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 1627 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
1630 Node* p1 = graph()->NewNode(common()->Parameter(1), start); 1628 Node* p1 = graph()->NewNode(common()->Parameter(1), start);
1631 Node* d1 = CreateDiamond(graph(), common(), p0); 1629 Node* d1 = CreateDiamond(graph(), common(), p0);
1632 Node* d2 = CreateDiamond(graph(), common(), p1); 1630 Node* d2 = CreateDiamond(graph(), common(), p1);
1633 Node* add = graph()->NewNode(&kIntAdd, d1, d2); 1631 Node* add = graph()->NewNode(&kIntAdd, d1, d2);
1634 Node* ret = graph()->NewNode(common()->Return(), add, start, start); 1632 Node* ret = graph()->NewNode(common()->Return(), add, start, start);
1635 Node* end = graph()->NewNode(common()->End(), ret, start); 1633 Node* end = graph()->NewNode(common()->End(), ret, start);
1636 1634
1637 graph()->SetEnd(end); 1635 graph()->SetEnd(end);
1638 1636
1639 ComputeAndVerifySchedule(24, graph()); 1637 ComputeAndVerifySchedule(24, graph());
1640 } 1638 }
1641 1639
1642 1640
1643 TEST_F(SchedulerTest, FloatingDiamond3) { 1641 TARGET_TEST_F(SchedulerTest, FloatingDiamond3) {
1644 Node* start = graph()->NewNode(common()->Start(2)); 1642 Node* start = graph()->NewNode(common()->Start(2));
1645 graph()->SetStart(start); 1643 graph()->SetStart(start);
1646 1644
1647 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 1645 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
1648 Node* p1 = graph()->NewNode(common()->Parameter(1), start); 1646 Node* p1 = graph()->NewNode(common()->Parameter(1), start);
1649 Node* d1 = CreateDiamond(graph(), common(), p0); 1647 Node* d1 = CreateDiamond(graph(), common(), p0);
1650 Node* d2 = CreateDiamond(graph(), common(), p1); 1648 Node* d2 = CreateDiamond(graph(), common(), p1);
1651 Node* add = graph()->NewNode(&kIntAdd, d1, d2); 1649 Node* add = graph()->NewNode(&kIntAdd, d1, d2);
1652 Node* d3 = CreateDiamond(graph(), common(), add); 1650 Node* d3 = CreateDiamond(graph(), common(), add);
1653 Node* ret = graph()->NewNode(common()->Return(), d3, start, start); 1651 Node* ret = graph()->NewNode(common()->Return(), d3, start, start);
1654 Node* end = graph()->NewNode(common()->End(), ret, start); 1652 Node* end = graph()->NewNode(common()->End(), ret, start);
1655 1653
1656 graph()->SetEnd(end); 1654 graph()->SetEnd(end);
1657 1655
1658 ComputeAndVerifySchedule(33, graph()); 1656 ComputeAndVerifySchedule(33, graph());
1659 } 1657 }
1660 1658
1661 1659
1662 TEST_F(SchedulerTest, NestedFloatingDiamonds) { 1660 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamonds) {
1663 Node* start = graph()->NewNode(common()->Start(2)); 1661 Node* start = graph()->NewNode(common()->Start(2));
1664 graph()->SetStart(start); 1662 graph()->SetStart(start);
1665 1663
1666 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 1664 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
1667 1665
1668 Node* fv = graph()->NewNode(common()->Int32Constant(7)); 1666 Node* fv = graph()->NewNode(common()->Int32Constant(7));
1669 Node* br = graph()->NewNode(common()->Branch(), p0, graph()->start()); 1667 Node* br = graph()->NewNode(common()->Branch(), p0, graph()->start());
1670 Node* t = graph()->NewNode(common()->IfTrue(), br); 1668 Node* t = graph()->NewNode(common()->IfTrue(), br);
1671 Node* f = graph()->NewNode(common()->IfFalse(), br); 1669 Node* f = graph()->NewNode(common()->IfFalse(), br);
1672 1670
(...skipping 16 matching lines...) Expand all
1689 1687
1690 Node* ret = graph()->NewNode(common()->Return(), phi, ephi1, start); 1688 Node* ret = graph()->NewNode(common()->Return(), phi, ephi1, start);
1691 Node* end = graph()->NewNode(common()->End(), ret, start); 1689 Node* end = graph()->NewNode(common()->End(), ret, start);
1692 1690
1693 graph()->SetEnd(end); 1691 graph()->SetEnd(end);
1694 1692
1695 ComputeAndVerifySchedule(23, graph()); 1693 ComputeAndVerifySchedule(23, graph());
1696 } 1694 }
1697 1695
1698 1696
1699 TEST_F(SchedulerTest, NestedFloatingDiamondWithChain) { 1697 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithChain) {
1700 Node* start = graph()->NewNode(common()->Start(2)); 1698 Node* start = graph()->NewNode(common()->Start(2));
1701 graph()->SetStart(start); 1699 graph()->SetStart(start);
1702 1700
1703 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 1701 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
1704 Node* p1 = graph()->NewNode(common()->Parameter(1), start); 1702 Node* p1 = graph()->NewNode(common()->Parameter(1), start);
1705 Node* c = graph()->NewNode(common()->Int32Constant(7)); 1703 Node* c = graph()->NewNode(common()->Int32Constant(7));
1706 1704
1707 Node* brA1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); 1705 Node* brA1 = graph()->NewNode(common()->Branch(), p0, graph()->start());
1708 Node* tA1 = graph()->NewNode(common()->IfTrue(), brA1); 1706 Node* tA1 = graph()->NewNode(common()->IfTrue(), brA1);
1709 Node* fA1 = graph()->NewNode(common()->IfFalse(), brA1); 1707 Node* fA1 = graph()->NewNode(common()->IfFalse(), brA1);
(...skipping 23 matching lines...) Expand all
1733 Node* add = graph()->NewNode(&kIntAdd, phiA2, phiB2); 1731 Node* add = graph()->NewNode(&kIntAdd, phiA2, phiB2);
1734 Node* ret = graph()->NewNode(common()->Return(), add, start, start); 1732 Node* ret = graph()->NewNode(common()->Return(), add, start, start);
1735 Node* end = graph()->NewNode(common()->End(), ret, start); 1733 Node* end = graph()->NewNode(common()->End(), ret, start);
1736 1734
1737 graph()->SetEnd(end); 1735 graph()->SetEnd(end);
1738 1736
1739 ComputeAndVerifySchedule(35, graph()); 1737 ComputeAndVerifySchedule(35, graph());
1740 } 1738 }
1741 1739
1742 1740
1743 TEST_F(SchedulerTest, NestedFloatingDiamondWithLoop) { 1741 TARGET_TEST_F(SchedulerTest, NestedFloatingDiamondWithLoop) {
1744 Node* start = graph()->NewNode(common()->Start(2)); 1742 Node* start = graph()->NewNode(common()->Start(2));
1745 graph()->SetStart(start); 1743 graph()->SetStart(start);
1746 1744
1747 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 1745 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
1748 1746
1749 Node* fv = graph()->NewNode(common()->Int32Constant(7)); 1747 Node* fv = graph()->NewNode(common()->Int32Constant(7));
1750 Node* br = graph()->NewNode(common()->Branch(), p0, graph()->start()); 1748 Node* br = graph()->NewNode(common()->Branch(), p0, graph()->start());
1751 Node* t = graph()->NewNode(common()->IfTrue(), br); 1749 Node* t = graph()->NewNode(common()->IfTrue(), br);
1752 Node* f = graph()->NewNode(common()->IfFalse(), br); 1750 Node* f = graph()->NewNode(common()->IfFalse(), br);
1753 1751
(...skipping 13 matching lines...) Expand all
1767 1765
1768 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); 1766 Node* ret = graph()->NewNode(common()->Return(), phi, start, start);
1769 Node* end = graph()->NewNode(common()->End(), ret, start); 1767 Node* end = graph()->NewNode(common()->End(), ret, start);
1770 1768
1771 graph()->SetEnd(end); 1769 graph()->SetEnd(end);
1772 1770
1773 ComputeAndVerifySchedule(20, graph()); 1771 ComputeAndVerifySchedule(20, graph());
1774 } 1772 }
1775 1773
1776 1774
1777 TEST_F(SchedulerTest, LoopedFloatingDiamond1) { 1775 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond1) {
1778 Node* start = graph()->NewNode(common()->Start(2)); 1776 Node* start = graph()->NewNode(common()->Start(2));
1779 graph()->SetStart(start); 1777 graph()->SetStart(start);
1780 1778
1781 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 1779 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
1782 1780
1783 Node* c = graph()->NewNode(common()->Int32Constant(7)); 1781 Node* c = graph()->NewNode(common()->Int32Constant(7));
1784 Node* loop = graph()->NewNode(common()->Loop(2), start, start); 1782 Node* loop = graph()->NewNode(common()->Loop(2), start, start);
1785 Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); 1783 Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop);
1786 Node* add = graph()->NewNode(&kIntAdd, ind, c); 1784 Node* add = graph()->NewNode(&kIntAdd, ind, c);
1787 1785
(...skipping 12 matching lines...) Expand all
1800 1798
1801 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); 1799 Node* ret = graph()->NewNode(common()->Return(), ind, start, f);
1802 Node* end = graph()->NewNode(common()->End(), ret, f); 1800 Node* end = graph()->NewNode(common()->End(), ret, f);
1803 1801
1804 graph()->SetEnd(end); 1802 graph()->SetEnd(end);
1805 1803
1806 ComputeAndVerifySchedule(20, graph()); 1804 ComputeAndVerifySchedule(20, graph());
1807 } 1805 }
1808 1806
1809 1807
1810 TEST_F(SchedulerTest, LoopedFloatingDiamond2) { 1808 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond2) {
1811 Node* start = graph()->NewNode(common()->Start(2)); 1809 Node* start = graph()->NewNode(common()->Start(2));
1812 graph()->SetStart(start); 1810 graph()->SetStart(start);
1813 1811
1814 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 1812 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
1815 1813
1816 Node* c = graph()->NewNode(common()->Int32Constant(7)); 1814 Node* c = graph()->NewNode(common()->Int32Constant(7));
1817 Node* loop = graph()->NewNode(common()->Loop(2), start, start); 1815 Node* loop = graph()->NewNode(common()->Loop(2), start, start);
1818 Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); 1816 Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop);
1819 1817
1820 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); 1818 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start());
(...skipping 13 matching lines...) Expand all
1834 1832
1835 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); 1833 Node* ret = graph()->NewNode(common()->Return(), ind, start, f);
1836 Node* end = graph()->NewNode(common()->End(), ret, f); 1834 Node* end = graph()->NewNode(common()->End(), ret, f);
1837 1835
1838 graph()->SetEnd(end); 1836 graph()->SetEnd(end);
1839 1837
1840 ComputeAndVerifySchedule(20, graph()); 1838 ComputeAndVerifySchedule(20, graph());
1841 } 1839 }
1842 1840
1843 1841
1844 TEST_F(SchedulerTest, LoopedFloatingDiamond3) { 1842 TARGET_TEST_F(SchedulerTest, LoopedFloatingDiamond3) {
1845 Node* start = graph()->NewNode(common()->Start(2)); 1843 Node* start = graph()->NewNode(common()->Start(2));
1846 graph()->SetStart(start); 1844 graph()->SetStart(start);
1847 1845
1848 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 1846 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
1849 1847
1850 Node* c = graph()->NewNode(common()->Int32Constant(7)); 1848 Node* c = graph()->NewNode(common()->Int32Constant(7));
1851 Node* loop = graph()->NewNode(common()->Loop(2), start, start); 1849 Node* loop = graph()->NewNode(common()->Loop(2), start, start);
1852 Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop); 1850 Node* ind = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), p0, p0, loop);
1853 1851
1854 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); 1852 Node* br1 = graph()->NewNode(common()->Branch(), p0, graph()->start());
(...skipping 25 matching lines...) Expand all
1880 1878
1881 Node* ret = graph()->NewNode(common()->Return(), ind, start, f); 1879 Node* ret = graph()->NewNode(common()->Return(), ind, start, f);
1882 Node* end = graph()->NewNode(common()->End(), ret, f); 1880 Node* end = graph()->NewNode(common()->End(), ret, f);
1883 1881
1884 graph()->SetEnd(end); 1882 graph()->SetEnd(end);
1885 1883
1886 ComputeAndVerifySchedule(28, graph()); 1884 ComputeAndVerifySchedule(28, graph());
1887 } 1885 }
1888 1886
1889 1887
1890 TEST_F(SchedulerTest, PhisPushedDownToDifferentBranches) { 1888 TARGET_TEST_F(SchedulerTest, PhisPushedDownToDifferentBranches) {
1891 Node* start = graph()->NewNode(common()->Start(2)); 1889 Node* start = graph()->NewNode(common()->Start(2));
1892 graph()->SetStart(start); 1890 graph()->SetStart(start);
1893 1891
1894 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 1892 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
1895 Node* p1 = graph()->NewNode(common()->Parameter(1), start); 1893 Node* p1 = graph()->NewNode(common()->Parameter(1), start);
1896 1894
1897 Node* v1 = graph()->NewNode(common()->Int32Constant(1)); 1895 Node* v1 = graph()->NewNode(common()->Int32Constant(1));
1898 Node* v2 = graph()->NewNode(common()->Int32Constant(2)); 1896 Node* v2 = graph()->NewNode(common()->Int32Constant(2));
1899 Node* v3 = graph()->NewNode(common()->Int32Constant(3)); 1897 Node* v3 = graph()->NewNode(common()->Int32Constant(3));
1900 Node* v4 = graph()->NewNode(common()->Int32Constant(4)); 1898 Node* v4 = graph()->NewNode(common()->Int32Constant(4));
(...skipping 13 matching lines...) Expand all
1914 1912
1915 Node* ret = graph()->NewNode(common()->Return(), phi3, start, start); 1913 Node* ret = graph()->NewNode(common()->Return(), phi3, start, start);
1916 Node* end = graph()->NewNode(common()->End(), ret, start); 1914 Node* end = graph()->NewNode(common()->End(), ret, start);
1917 1915
1918 graph()->SetEnd(end); 1916 graph()->SetEnd(end);
1919 1917
1920 ComputeAndVerifySchedule(24, graph()); 1918 ComputeAndVerifySchedule(24, graph());
1921 } 1919 }
1922 1920
1923 1921
1924 TEST_F(SchedulerTest, BranchHintTrue) { 1922 TARGET_TEST_F(SchedulerTest, BranchHintTrue) {
1925 Node* start = graph()->NewNode(common()->Start(1)); 1923 Node* start = graph()->NewNode(common()->Start(1));
1926 graph()->SetStart(start); 1924 graph()->SetStart(start);
1927 1925
1928 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 1926 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
1929 Node* tv = graph()->NewNode(common()->Int32Constant(6)); 1927 Node* tv = graph()->NewNode(common()->Int32Constant(6));
1930 Node* fv = graph()->NewNode(common()->Int32Constant(7)); 1928 Node* fv = graph()->NewNode(common()->Int32Constant(7));
1931 Node* br = graph()->NewNode(common()->Branch(BranchHint::kTrue), p0, start); 1929 Node* br = graph()->NewNode(common()->Branch(BranchHint::kTrue), p0, start);
1932 Node* t = graph()->NewNode(common()->IfTrue(), br); 1930 Node* t = graph()->NewNode(common()->IfTrue(), br);
1933 Node* f = graph()->NewNode(common()->IfFalse(), br); 1931 Node* f = graph()->NewNode(common()->IfFalse(), br);
1934 Node* m = graph()->NewNode(common()->Merge(2), t, f); 1932 Node* m = graph()->NewNode(common()->Merge(2), t, f);
1935 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), tv, fv, m); 1933 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), tv, fv, m);
1936 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); 1934 Node* ret = graph()->NewNode(common()->Return(), phi, start, start);
1937 Node* end = graph()->NewNode(common()->End(), ret, start); 1935 Node* end = graph()->NewNode(common()->End(), ret, start);
1938 1936
1939 graph()->SetEnd(end); 1937 graph()->SetEnd(end);
1940 1938
1941 Schedule* schedule = ComputeAndVerifySchedule(13, graph()); 1939 Schedule* schedule = ComputeAndVerifySchedule(13, graph());
1942 // Make sure the false block is marked as deferred. 1940 // Make sure the false block is marked as deferred.
1943 CHECK(!schedule->block(t)->deferred()); 1941 CHECK(!schedule->block(t)->deferred());
1944 CHECK(schedule->block(f)->deferred()); 1942 CHECK(schedule->block(f)->deferred());
1945 } 1943 }
1946 1944
1947 1945
1948 TEST_F(SchedulerTest, BranchHintFalse) { 1946 TARGET_TEST_F(SchedulerTest, BranchHintFalse) {
1949 Node* start = graph()->NewNode(common()->Start(1)); 1947 Node* start = graph()->NewNode(common()->Start(1));
1950 graph()->SetStart(start); 1948 graph()->SetStart(start);
1951 1949
1952 Node* p0 = graph()->NewNode(common()->Parameter(0), start); 1950 Node* p0 = graph()->NewNode(common()->Parameter(0), start);
1953 Node* tv = graph()->NewNode(common()->Int32Constant(6)); 1951 Node* tv = graph()->NewNode(common()->Int32Constant(6));
1954 Node* fv = graph()->NewNode(common()->Int32Constant(7)); 1952 Node* fv = graph()->NewNode(common()->Int32Constant(7));
1955 Node* br = graph()->NewNode(common()->Branch(BranchHint::kFalse), p0, start); 1953 Node* br = graph()->NewNode(common()->Branch(BranchHint::kFalse), p0, start);
1956 Node* t = graph()->NewNode(common()->IfTrue(), br); 1954 Node* t = graph()->NewNode(common()->IfTrue(), br);
1957 Node* f = graph()->NewNode(common()->IfFalse(), br); 1955 Node* f = graph()->NewNode(common()->IfFalse(), br);
1958 Node* m = graph()->NewNode(common()->Merge(2), t, f); 1956 Node* m = graph()->NewNode(common()->Merge(2), t, f);
1959 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), tv, fv, m); 1957 Node* phi = graph()->NewNode(common()->Phi(kMachAnyTagged, 2), tv, fv, m);
1960 Node* ret = graph()->NewNode(common()->Return(), phi, start, start); 1958 Node* ret = graph()->NewNode(common()->Return(), phi, start, start);
1961 Node* end = graph()->NewNode(common()->End(), ret, start); 1959 Node* end = graph()->NewNode(common()->End(), ret, start);
1962 1960
1963 graph()->SetEnd(end); 1961 graph()->SetEnd(end);
1964 1962
1965 Schedule* schedule = ComputeAndVerifySchedule(13, graph()); 1963 Schedule* schedule = ComputeAndVerifySchedule(13, graph());
1966 // Make sure the true block is marked as deferred. 1964 // Make sure the true block is marked as deferred.
1967 CHECK(schedule->block(t)->deferred()); 1965 CHECK(schedule->block(t)->deferred());
1968 CHECK(!schedule->block(f)->deferred()); 1966 CHECK(!schedule->block(f)->deferred());
1969 } 1967 }
1970 1968
1971 1969
1972 TEST_F(SchedulerTest, ScheduleTerminate) { 1970 TARGET_TEST_F(SchedulerTest, ScheduleTerminate) {
1973 Node* start = graph()->NewNode(common()->Start(1)); 1971 Node* start = graph()->NewNode(common()->Start(1));
1974 graph()->SetStart(start); 1972 graph()->SetStart(start);
1975 1973
1976 Node* loop = graph()->NewNode(common()->Loop(2), start, start); 1974 Node* loop = graph()->NewNode(common()->Loop(2), start, start);
1977 loop->ReplaceInput(1, loop); // self loop, NTL. 1975 loop->ReplaceInput(1, loop); // self loop, NTL.
1978 1976
1979 Node* effect = graph()->NewNode(common()->EffectPhi(1), start, loop); 1977 Node* effect = graph()->NewNode(common()->EffectPhi(1), start, loop);
1980 effect->ReplaceInput(0, effect); 1978 effect->ReplaceInput(0, effect);
1981 1979
1982 Node* terminate = graph()->NewNode(common()->Terminate(1), effect, loop); 1980 Node* terminate = graph()->NewNode(common()->Terminate(1), effect, loop);
1983 Node* end = graph()->NewNode(common()->End(), terminate); 1981 Node* end = graph()->NewNode(common()->End(), terminate);
1984 1982
1985 graph()->SetEnd(end); 1983 graph()->SetEnd(end);
1986 1984
1987 Schedule* schedule = ComputeAndVerifySchedule(6, graph()); 1985 Schedule* schedule = ComputeAndVerifySchedule(6, graph());
1988 BasicBlock* block = schedule->block(loop); 1986 BasicBlock* block = schedule->block(loop);
1989 CHECK_NE(NULL, loop); 1987 CHECK_NE(NULL, loop);
1990 CHECK_EQ(block, schedule->block(effect)); 1988 CHECK_EQ(block, schedule->block(effect));
1991 CHECK_GE(block->rpo_number(), 0); 1989 CHECK_GE(block->rpo_number(), 0);
1992 } 1990 }
1993 1991
1994 #endif 1992 } // namespace compiler
1993 } // namespace internal
1994 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698