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

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

Issue 1123213002: [turbofan] Connect non-terminating loops via Terminate. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 7 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
OLDNEW
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/control-reducer.h" 5 #include "src/compiler/control-reducer.h"
6 #include "src/compiler/diamond.h" 6 #include "src/compiler/diamond.h"
7 #include "src/compiler/graph-visualizer.h" 7 #include "src/compiler/graph-visualizer.h"
8 #include "src/compiler/js-graph.h" 8 #include "src/compiler/js-graph.h"
9 #include "src/compiler/js-operator.h" 9 #include "src/compiler/js-operator.h"
10 #include "src/compiler/machine-operator.h" 10 #include "src/compiler/machine-operator.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 } 50 }
51 51
52 JSGraph* jsgraph() { return &jsgraph_; } 52 JSGraph* jsgraph() { return &jsgraph_; }
53 }; 53 };
54 54
55 55
56 TEST_F(ControlReducerTest, NonTerminatingLoop) { 56 TEST_F(ControlReducerTest, NonTerminatingLoop) {
57 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start()); 57 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
58 loop->AppendInput(graph()->zone(), loop); 58 loop->AppendInput(graph()->zone(), loop);
59 ReduceGraph(); 59 ReduceGraph();
60 Capture<Node*> branch;
61 EXPECT_THAT( 60 EXPECT_THAT(
62 graph()->end(), 61 graph()->end(),
63 IsEnd(IsMerge( 62 IsEnd(IsMerge(graph()->start(),
64 graph()->start(), 63 IsTerminate(graph()->start(),
65 IsReturn(IsUndefinedConstant(), graph()->start(), 64 AllOf(loop, IsLoop(graph()->start(), loop))))));
66 IsIfFalse(
67 AllOf(CaptureEq(&branch),
68 IsBranch(IsAlways(),
69 AllOf(loop, IsLoop(graph()->start(),
70 IsIfTrue(CaptureEq(
71 &branch)))))))))));
72 } 65 }
73 66
74 67
75 TEST_F(ControlReducerTest, NonTerminatingLoopWithEffectPhi) { 68 TEST_F(ControlReducerTest, NonTerminatingLoopWithEffectPhi) {
76 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start()); 69 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
77 loop->AppendInput(graph()->zone(), loop); 70 loop->AppendInput(graph()->zone(), loop);
78 Node* ephi = graph()->NewNode(common()->EffectPhi(2), graph()->start()); 71 Node* ephi = graph()->NewNode(common()->EffectPhi(2), graph()->start());
79 ephi->AppendInput(graph()->zone(), ephi); 72 ephi->AppendInput(graph()->zone(), ephi);
80 ephi->AppendInput(graph()->zone(), loop); 73 ephi->AppendInput(graph()->zone(), loop);
81 ReduceGraph(); 74 ReduceGraph();
82 Capture<Node*> branch;
83 EXPECT_THAT( 75 EXPECT_THAT(
84 graph()->end(), 76 graph()->end(),
85 IsEnd(IsMerge( 77 IsEnd(IsMerge(
86 graph()->start(), 78 graph()->start(),
87 IsReturn(IsUndefinedConstant(), 79 IsTerminate(AllOf(ephi, IsEffectPhi(graph()->start(), ephi, loop)),
88 AllOf(ephi, IsEffectPhi(graph()->start(), ephi, loop)), 80 AllOf(loop, IsLoop(graph()->start(), loop))))));
89 IsIfFalse(
90 AllOf(CaptureEq(&branch),
91 IsBranch(IsAlways(),
92 AllOf(loop, IsLoop(graph()->start(),
93 IsIfTrue(CaptureEq(
94 &branch)))))))))));
95 } 81 }
96 82
97 83
98 TEST_F(ControlReducerTest, NonTerminatingLoopWithTwoEffectPhis) { 84 TEST_F(ControlReducerTest, NonTerminatingLoopWithTwoEffectPhis) {
99 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start()); 85 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
100 loop->AppendInput(graph()->zone(), loop); 86 loop->AppendInput(graph()->zone(), loop);
101 Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), graph()->start()); 87 Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), graph()->start());
102 ephi1->AppendInput(graph()->zone(), ephi1); 88 ephi1->AppendInput(graph()->zone(), ephi1);
103 ephi1->AppendInput(graph()->zone(), loop); 89 ephi1->AppendInput(graph()->zone(), loop);
104 Node* ephi2 = graph()->NewNode(common()->EffectPhi(2), graph()->start()); 90 Node* ephi2 = graph()->NewNode(common()->EffectPhi(2), graph()->start());
105 ephi2->AppendInput(graph()->zone(), ephi2); 91 ephi2->AppendInput(graph()->zone(), ephi2);
106 ephi2->AppendInput(graph()->zone(), loop); 92 ephi2->AppendInput(graph()->zone(), loop);
107 ReduceGraph(); 93 ReduceGraph();
108 Capture<Node*> branch;
109 EXPECT_THAT( 94 EXPECT_THAT(
110 graph()->end(), 95 graph()->end(),
111 IsEnd(IsMerge( 96 IsEnd(IsMerge(
112 graph()->start(), 97 graph()->start(),
113 IsReturn( 98 IsTerminate(
114 IsUndefinedConstant(),
115 IsEffectSet( 99 IsEffectSet(
116 AllOf(ephi1, IsEffectPhi(graph()->start(), ephi1, loop)), 100 AllOf(ephi1, IsEffectPhi(graph()->start(), ephi1, loop)),
117 AllOf(ephi2, IsEffectPhi(graph()->start(), ephi2, loop))), 101 AllOf(ephi2, IsEffectPhi(graph()->start(), ephi2, loop))),
118 IsIfFalse(AllOf( 102 AllOf(loop, IsLoop(graph()->start(), loop))))));
119 CaptureEq(&branch),
120 IsBranch(
121 IsAlways(),
122 AllOf(loop, IsLoop(graph()->start(),
123 IsIfTrue(CaptureEq(&branch)))))))))));
124 } 103 }
125 104
126 105
127 TEST_F(ControlReducerTest, NonTerminatingLoopWithDeadEnd) { 106 TEST_F(ControlReducerTest, NonTerminatingLoopWithDeadEnd) {
128 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start()); 107 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
129 loop->AppendInput(graph()->zone(), loop); 108 loop->AppendInput(graph()->zone(), loop);
130 graph()->end()->ReplaceInput(0, graph()->NewNode(common()->Dead())); 109 graph()->end()->ReplaceInput(0, graph()->NewNode(common()->Dead()));
131 ReduceGraph(); 110 ReduceGraph();
132 Capture<Node*> branch; 111 EXPECT_THAT(graph()->end(),
133 EXPECT_THAT( 112 IsEnd(IsTerminate(graph()->start(),
134 graph()->end(), 113 AllOf(loop, IsLoop(graph()->start(), loop)))));
135 IsEnd(IsReturn(
136 IsUndefinedConstant(), graph()->start(),
137 IsIfFalse(AllOf(
138 CaptureEq(&branch),
139 IsBranch(IsAlways(),
140 AllOf(loop, IsLoop(graph()->start(),
141 IsIfTrue(CaptureEq(&branch))))))))));
142 } 114 }
143 115
144 116
145 TEST_F(ControlReducerTest, PhiAsInputToBranch_true) { 117 TEST_F(ControlReducerTest, PhiAsInputToBranch_true) {
146 Node* p0 = Parameter(0); 118 Node* p0 = Parameter(0);
147 Node* branch1 = graph()->NewNode(common()->Branch(), p0, graph()->start()); 119 Node* branch1 = graph()->NewNode(common()->Branch(), p0, graph()->start());
148 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1); 120 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1);
149 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1); 121 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1);
150 Node* merge1 = graph()->NewNode(common()->Merge(2), if_true1, if_false1); 122 Node* merge1 = graph()->NewNode(common()->Merge(2), if_true1, if_false1);
151 Node* phi1 = graph()->NewNode(common()->Phi(kMachInt32, 2), 123 Node* phi1 = graph()->NewNode(common()->Phi(kMachInt32, 2),
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
345 IsSelect(kType, p0, IsInt32Constant(1), IsInt32Constant(2)), 317 IsSelect(kType, p0, IsInt32Constant(1), IsInt32Constant(2)),
346 IsSelect(kType, p0, IsInt32Constant(2), IsInt32Constant(3))), 318 IsSelect(kType, p0, IsInt32Constant(2), IsInt32Constant(3))),
347 graph()->start(), graph()->start())); 319 graph()->start(), graph()->start()));
348 EXPECT_THAT(graph()->end(), IsEnd(ret)); 320 EXPECT_THAT(graph()->end(), IsEnd(ret));
349 } 321 }
350 322
351 323
352 } // namespace compiler 324 } // namespace compiler
353 } // namespace internal 325 } // namespace internal
354 } // namespace v8 326 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/common-operator-unittest.cc ('k') | test/unittests/compiler/node-test-utils.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698