| 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" | |
| 9 #include "src/compiler/common-operator.h" | 8 #include "src/compiler/common-operator.h" |
| 10 #include "src/compiler/generic-node-inl.h" | 9 #include "src/compiler/generic-node-inl.h" |
| 11 #include "src/compiler/generic-node.h" | 10 #include "src/compiler/generic-node.h" |
| 12 #include "src/compiler/graph.h" | 11 #include "src/compiler/graph.h" |
| 13 #include "src/compiler/graph-visualizer.h" | 12 #include "src/compiler/graph-visualizer.h" |
| 14 #include "src/compiler/js-operator.h" | 13 #include "src/compiler/js-operator.h" |
| 15 #include "src/compiler/machine-operator.h" | 14 #include "src/compiler/machine-operator.h" |
| 16 #include "src/compiler/node.h" | 15 #include "src/compiler/node.h" |
| 17 #include "src/compiler/operator.h" | 16 #include "src/compiler/operator.h" |
| 18 #include "src/compiler/schedule.h" | 17 #include "src/compiler/schedule.h" |
| 19 #include "src/compiler/scheduler.h" | 18 #include "src/compiler/scheduler.h" |
| 20 #include "src/compiler/simplified-operator.h" | |
| 21 #include "src/compiler/verifier.h" | 19 #include "src/compiler/verifier.h" |
| 22 | 20 |
| 23 using namespace v8::internal; | 21 using namespace v8::internal; |
| 24 using namespace v8::internal::compiler; | 22 using namespace v8::internal::compiler; |
| 25 | 23 |
| 26 // TODO(titzer): pull RPO tests out to their own file. | 24 // TODO(titzer): pull RPO tests out to their own file. |
| 27 struct TestLoop { | 25 struct TestLoop { |
| 28 int count; | 26 int count; |
| 29 BasicBlock** nodes; | 27 BasicBlock** nodes; |
| 30 BasicBlock* header() { return nodes[0]; } | 28 BasicBlock* header() { return nodes[0]; } |
| (...skipping 1681 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1712 Node* add = graph.NewNode(machine.Int32Add(), d1, d2); | 1710 Node* add = graph.NewNode(machine.Int32Add(), d1, d2); |
| 1713 Node* d3 = CreateDiamond(&graph, &common, add); | 1711 Node* d3 = CreateDiamond(&graph, &common, add); |
| 1714 Node* ret = graph.NewNode(common.Return(), d3, start, start); | 1712 Node* ret = graph.NewNode(common.Return(), d3, start, start); |
| 1715 Node* end = graph.NewNode(common.End(), ret, start); | 1713 Node* end = graph.NewNode(common.End(), ret, start); |
| 1716 | 1714 |
| 1717 graph.SetEnd(end); | 1715 graph.SetEnd(end); |
| 1718 | 1716 |
| 1719 ComputeAndVerifySchedule(33, &graph); | 1717 ComputeAndVerifySchedule(33, &graph); |
| 1720 } | 1718 } |
| 1721 | 1719 |
| 1722 | |
| 1723 TEST(NestedFloatingDiamonds) { | |
| 1724 HandleAndZoneScope scope; | |
| 1725 Graph graph(scope.main_zone()); | |
| 1726 CommonOperatorBuilder common(scope.main_zone()); | |
| 1727 SimplifiedOperatorBuilder simplified(scope.main_zone()); | |
| 1728 MachineOperatorBuilder machine; | |
| 1729 | |
| 1730 Node* start = graph.NewNode(common.Start(2)); | |
| 1731 graph.SetStart(start); | |
| 1732 | |
| 1733 Node* p0 = graph.NewNode(common.Parameter(0), start); | |
| 1734 | |
| 1735 Node* fv = graph.NewNode(common.Int32Constant(7)); | |
| 1736 Node* br = graph.NewNode(common.Branch(), p0, graph.start()); | |
| 1737 Node* t = graph.NewNode(common.IfTrue(), br); | |
| 1738 Node* f = graph.NewNode(common.IfFalse(), br); | |
| 1739 | |
| 1740 Node* map = graph.NewNode( | |
| 1741 simplified.LoadElement(AccessBuilder::ForFixedArrayElement()), p0, p0, p0, | |
| 1742 start, f); | |
| 1743 Node* br1 = graph.NewNode(common.Branch(), map, graph.start()); | |
| 1744 Node* t1 = graph.NewNode(common.IfTrue(), br1); | |
| 1745 Node* f1 = graph.NewNode(common.IfFalse(), br1); | |
| 1746 Node* m1 = graph.NewNode(common.Merge(2), t1, f1); | |
| 1747 Node* ttrue = graph.NewNode(common.Int32Constant(1)); | |
| 1748 Node* ffalse = graph.NewNode(common.Int32Constant(0)); | |
| 1749 Node* phi1 = graph.NewNode(common.Phi(kMachAnyTagged, 2), ttrue, ffalse, m1); | |
| 1750 | |
| 1751 | |
| 1752 Node* m = graph.NewNode(common.Merge(2), t, f); | |
| 1753 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 2), fv, phi1, m); | |
| 1754 Node* ephi1 = graph.NewNode(common.EffectPhi(2), start, map, m); | |
| 1755 | |
| 1756 Node* ret = graph.NewNode(common.Return(), phi, ephi1, start); | |
| 1757 Node* end = graph.NewNode(common.End(), ret, start); | |
| 1758 | |
| 1759 graph.SetEnd(end); | |
| 1760 | |
| 1761 ComputeAndVerifySchedule(23, &graph); | |
| 1762 } | |
| 1763 | |
| 1764 | |
| 1765 TEST(PhisPushedDownToDifferentBranches) { | |
| 1766 HandleAndZoneScope scope; | |
| 1767 Graph graph(scope.main_zone()); | |
| 1768 CommonOperatorBuilder common(scope.main_zone()); | |
| 1769 SimplifiedOperatorBuilder simplified(scope.main_zone()); | |
| 1770 MachineOperatorBuilder machine; | |
| 1771 | |
| 1772 Node* start = graph.NewNode(common.Start(2)); | |
| 1773 graph.SetStart(start); | |
| 1774 | |
| 1775 Node* p0 = graph.NewNode(common.Parameter(0), start); | |
| 1776 Node* p1 = graph.NewNode(common.Parameter(1), start); | |
| 1777 | |
| 1778 Node* v1 = graph.NewNode(common.Int32Constant(1)); | |
| 1779 Node* v2 = graph.NewNode(common.Int32Constant(2)); | |
| 1780 Node* v3 = graph.NewNode(common.Int32Constant(3)); | |
| 1781 Node* v4 = graph.NewNode(common.Int32Constant(4)); | |
| 1782 Node* br = graph.NewNode(common.Branch(), p0, graph.start()); | |
| 1783 Node* t = graph.NewNode(common.IfTrue(), br); | |
| 1784 Node* f = graph.NewNode(common.IfFalse(), br); | |
| 1785 Node* m = graph.NewNode(common.Merge(2), t, f); | |
| 1786 Node* phi = graph.NewNode(common.Phi(kMachAnyTagged, 2), v1, v2, m); | |
| 1787 Node* phi2 = graph.NewNode(common.Phi(kMachAnyTagged, 2), v3, v4, m); | |
| 1788 | |
| 1789 Node* br2 = graph.NewNode(common.Branch(), p1, graph.start()); | |
| 1790 Node* t2 = graph.NewNode(common.IfTrue(), br2); | |
| 1791 Node* f2 = graph.NewNode(common.IfFalse(), br2); | |
| 1792 Node* m2 = graph.NewNode(common.Merge(2), t2, f2); | |
| 1793 Node* phi3 = graph.NewNode(common.Phi(kMachAnyTagged, 2), phi, phi2, m2); | |
| 1794 | |
| 1795 Node* ret = graph.NewNode(common.Return(), phi3, start, start); | |
| 1796 Node* end = graph.NewNode(common.End(), ret, start); | |
| 1797 | |
| 1798 graph.SetEnd(end); | |
| 1799 | |
| 1800 ComputeAndVerifySchedule(24, &graph); | |
| 1801 } | |
| 1802 | |
| 1803 #endif | 1720 #endif |
| OLD | NEW |