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

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

Issue 875263004: [turbofan] Ensure that NTLs are always properly connected to the end. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "src/compiler/control-reducer.h"
6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/js-operator.h"
8 #include "src/compiler/machine-operator.h"
9 #include "src/compiler/node.h"
10 #include "test/unittests/compiler/graph-unittest.h"
11 #include "test/unittests/compiler/node-test-utils.h"
12 #include "testing/gmock-support.h"
13
14 using testing::_;
15 using testing::AllOf;
16 using testing::Capture;
17 using testing::CaptureEq;
18
19 namespace v8 {
20 namespace internal {
21 namespace compiler {
22
23 class ControlReducerTest : public GraphTest {
24 protected:
25 void ReduceGraph() {
26 JSOperatorBuilder javascript(zone());
27 MachineOperatorBuilder machine(zone());
28 JSGraph jsgraph(isolate(), graph(), common(), &javascript, &machine);
29 ControlReducer::ReduceGraph(zone(), &jsgraph, common());
30 }
31 };
32
33
34 TEST_F(ControlReducerTest, NonTerminatingLoop) {
35 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
36 loop->AppendInput(graph()->zone(), loop);
37 ReduceGraph();
38 Capture<Node*> branch;
39 EXPECT_THAT(
40 graph()->end(),
41 IsEnd(IsMerge(
42 graph()->start(),
43 IsReturn(IsUndefinedConstant(), graph()->start(),
44 IsIfFalse(
45 AllOf(CaptureEq(&branch),
46 IsBranch(IsAlways(),
47 AllOf(loop, IsLoop(graph()->start(),
48 IsIfTrue(CaptureEq(
49 &branch)))))))))));
50 }
51
52
53 TEST_F(ControlReducerTest, NonTerminatingLoopWithEffectPhi) {
54 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
55 loop->AppendInput(graph()->zone(), loop);
56 Node* ephi = graph()->NewNode(common()->EffectPhi(2), graph()->start());
57 ephi->AppendInput(graph()->zone(), ephi);
58 ephi->AppendInput(graph()->zone(), loop);
59 ReduceGraph();
60 Capture<Node*> branch;
61 EXPECT_THAT(
62 graph()->end(),
63 IsEnd(IsMerge(
64 graph()->start(),
65 IsReturn(IsUndefinedConstant(),
66 AllOf(ephi, IsEffectPhi(graph()->start(), ephi, loop)),
67 IsIfFalse(
68 AllOf(CaptureEq(&branch),
69 IsBranch(IsAlways(),
70 AllOf(loop, IsLoop(graph()->start(),
71 IsIfTrue(CaptureEq(
72 &branch)))))))))));
73 }
74
75
76 TEST_F(ControlReducerTest, NonTerminatingLoopWithTwoEffectPhis) {
77 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
78 loop->AppendInput(graph()->zone(), loop);
79 Node* ephi1 = graph()->NewNode(common()->EffectPhi(2), graph()->start());
80 ephi1->AppendInput(graph()->zone(), ephi1);
81 ephi1->AppendInput(graph()->zone(), loop);
82 Node* ephi2 = graph()->NewNode(common()->EffectPhi(2), graph()->start());
83 ephi2->AppendInput(graph()->zone(), ephi2);
84 ephi2->AppendInput(graph()->zone(), loop);
85 ReduceGraph();
86 Capture<Node*> branch;
87 EXPECT_THAT(
88 graph()->end(),
89 IsEnd(IsMerge(
90 graph()->start(),
91 IsReturn(
92 IsUndefinedConstant(),
93 IsEffectSet(
94 AllOf(ephi1, IsEffectPhi(graph()->start(), ephi1, loop)),
95 AllOf(ephi2, IsEffectPhi(graph()->start(), ephi2, loop))),
96 IsIfFalse(AllOf(
97 CaptureEq(&branch),
98 IsBranch(
99 IsAlways(),
100 AllOf(loop, IsLoop(graph()->start(),
101 IsIfTrue(CaptureEq(&branch)))))))))));
102 }
103
104
105 TEST_F(ControlReducerTest, NonTerminatingLoopWithDeadEnd) {
106 Node* loop = graph()->NewNode(common()->Loop(2), graph()->start());
107 loop->AppendInput(graph()->zone(), loop);
108 graph()->end()->ReplaceInput(0, graph()->NewNode(common()->Dead()));
109 ReduceGraph();
110 Capture<Node*> branch;
111 EXPECT_THAT(
112 graph()->end(),
113 IsEnd(IsReturn(
114 IsUndefinedConstant(), graph()->start(),
115 IsIfFalse(AllOf(
116 CaptureEq(&branch),
117 IsBranch(IsAlways(),
118 AllOf(loop, IsLoop(graph()->start(),
119 IsIfTrue(CaptureEq(&branch))))))))));
120 }
121
122 } // namespace compiler
123 } // namespace internal
124 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/common-operator-unittest.cc ('k') | test/unittests/compiler/graph-unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698