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

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

Issue 1157023002: [turbofan] Change End to take a variable number of inputs. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 6 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 EXPECT_THAT( 60 EXPECT_THAT(graph()->end(),
61 graph()->end(), 61 IsEnd(graph()->start(),
62 IsEnd(IsMerge(graph()->start(),
63 IsTerminate(graph()->start(), 62 IsTerminate(graph()->start(),
64 AllOf(loop, IsLoop(graph()->start(), loop)))))); 63 AllOf(loop, IsLoop(graph()->start(), loop)))));
65 } 64 }
66 65
67 66
68 TEST_F(ControlReducerTest, NonTerminatingLoopWithEffectPhi) { 67 TEST_F(ControlReducerTest, NonTerminatingLoopWithEffectPhi) {
69 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start()); 68 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
70 loop->AppendInput(graph()->zone(), loop); 69 loop->AppendInput(graph()->zone(), loop);
71 Node* ephi = graph()->NewNode(common()->EffectPhi(2), graph()->start()); 70 Node* ephi = graph()->NewNode(common()->EffectPhi(2), graph()->start());
72 ephi->AppendInput(graph()->zone(), ephi); 71 ephi->AppendInput(graph()->zone(), ephi);
73 ephi->AppendInput(graph()->zone(), loop); 72 ephi->AppendInput(graph()->zone(), loop);
74 ReduceGraph(); 73 ReduceGraph();
75 EXPECT_THAT( 74 EXPECT_THAT(
76 graph()->end(), 75 graph()->end(),
77 IsEnd(IsMerge( 76 IsEnd(graph()->start(),
78 graph()->start(), 77 IsTerminate(AllOf(ephi, IsEffectPhi(graph()->start(), ephi, loop)),
79 IsTerminate(AllOf(ephi, IsEffectPhi(graph()->start(), ephi, loop)), 78 AllOf(loop, IsLoop(graph()->start(), loop)))));
80 AllOf(loop, IsLoop(graph()->start(), loop))))));
81 } 79 }
82 80
83 81
84 TEST_F(ControlReducerTest, NonTerminatingLoopWithTwoEffectPhis) { 82 TEST_F(ControlReducerTest, NonTerminatingLoopWithTwoEffectPhis) {
85 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start()); 83 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
86 loop->AppendInput(graph()->zone(), loop); 84 loop->AppendInput(graph()->zone(), loop);
87 Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), graph()->start()); 85 Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), graph()->start());
88 ephi1->AppendInput(graph()->zone(), ephi1); 86 ephi1->AppendInput(graph()->zone(), ephi1);
89 ephi1->AppendInput(graph()->zone(), loop); 87 ephi1->AppendInput(graph()->zone(), loop);
90 Node* ephi2 = graph()->NewNode(common()->EffectPhi(2), graph()->start()); 88 Node* ephi2 = graph()->NewNode(common()->EffectPhi(2), graph()->start());
91 ephi2->AppendInput(graph()->zone(), ephi2); 89 ephi2->AppendInput(graph()->zone(), ephi2);
92 ephi2->AppendInput(graph()->zone(), loop); 90 ephi2->AppendInput(graph()->zone(), loop);
93 ReduceGraph(); 91 ReduceGraph();
94 EXPECT_THAT( 92 EXPECT_THAT(
95 graph()->end(), 93 graph()->end(),
96 IsEnd(IsMerge( 94 IsEnd(graph()->start(),
97 graph()->start(), 95 IsTerminate(
98 IsTerminate( 96 IsEffectSet(
99 IsEffectSet( 97 AllOf(ephi1, IsEffectPhi(graph()->start(), ephi1, loop)),
100 AllOf(ephi1, IsEffectPhi(graph()->start(), ephi1, loop)), 98 AllOf(ephi2, IsEffectPhi(graph()->start(), ephi2, loop))),
101 AllOf(ephi2, IsEffectPhi(graph()->start(), ephi2, loop))), 99 AllOf(loop, IsLoop(graph()->start(), loop)))));
102 AllOf(loop, IsLoop(graph()->start(), loop))))));
103 } 100 }
104 101
105 102
106 TEST_F(ControlReducerTest, NonTerminatingLoopWithDeadEnd) { 103 TEST_F(ControlReducerTest, NonTerminatingLoopWithDeadEnd) {
107 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start()); 104 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
108 loop->AppendInput(graph()->zone(), loop); 105 loop->AppendInput(graph()->zone(), loop);
109 graph()->end()->ReplaceInput(0, graph()->NewNode(common()->Dead())); 106 graph()->end()->ReplaceInput(0, graph()->NewNode(common()->Dead()));
110 ReduceGraph(); 107 ReduceGraph();
111 EXPECT_THAT(graph()->end(), 108 EXPECT_THAT(graph()->end(),
112 IsEnd(IsTerminate(graph()->start(), 109 IsEnd(IsTerminate(graph()->start(),
(...skipping 200 matching lines...) Expand 10 before | Expand all | Expand 10 after
313 // Phis should be replaced with two selects. 310 // Phis should be replaced with two selects.
314 EXPECT_THAT( 311 EXPECT_THAT(
315 ret, 312 ret,
316 IsReturn(IsInt32Add( 313 IsReturn(IsInt32Add(
317 IsSelect(kType, p0, IsInt32Constant(1), IsInt32Constant(2)), 314 IsSelect(kType, p0, IsInt32Constant(1), IsInt32Constant(2)),
318 IsSelect(kType, p0, IsInt32Constant(2), IsInt32Constant(3))), 315 IsSelect(kType, p0, IsInt32Constant(2), IsInt32Constant(3))),
319 graph()->start(), graph()->start())); 316 graph()->start(), graph()->start()));
320 EXPECT_THAT(graph()->end(), IsEnd(ret)); 317 EXPECT_THAT(graph()->end(), IsEnd(ret));
321 } 318 }
322 319
323
324 } // namespace compiler 320 } // namespace compiler
325 } // namespace internal 321 } // namespace internal
326 } // namespace v8 322 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698