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

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

Issue 1160863003: [turbofan] Remove the JSGraph dependency from the ControlFlowOptimizer. (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
« no previous file with comments | « src/compiler/pipeline.cc ('k') | test/unittests/compiler/graph-unittest.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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-flow-optimizer.h" 5 #include "src/compiler/control-flow-optimizer.h"
6 #include "src/compiler/js-graph.h"
7 #include "src/compiler/js-operator.h" 6 #include "src/compiler/js-operator.h"
8 #include "src/compiler/machine-operator.h" 7 #include "src/compiler/machine-operator.h"
9 #include "test/unittests/compiler/graph-unittest.h" 8 #include "test/unittests/compiler/graph-unittest.h"
10 #include "test/unittests/compiler/node-test-utils.h" 9 #include "test/unittests/compiler/node-test-utils.h"
11 #include "testing/gmock-support.h" 10 #include "testing/gmock-support.h"
12 11
13 using testing::AllOf; 12 using testing::AllOf;
14 using testing::Capture; 13 using testing::Capture;
15 using testing::CaptureEq; 14 using testing::CaptureEq;
16 15
17 namespace v8 { 16 namespace v8 {
18 namespace internal { 17 namespace internal {
19 namespace compiler { 18 namespace compiler {
20 19
21 class ControlFlowOptimizerTest : public GraphTest { 20 class ControlFlowOptimizerTest : public GraphTest {
22 public: 21 public:
23 explicit ControlFlowOptimizerTest(int num_parameters = 3) 22 explicit ControlFlowOptimizerTest(int num_parameters = 3)
24 : GraphTest(num_parameters), 23 : GraphTest(num_parameters), machine_(zone()), javascript_(zone()) {}
25 machine_(zone()),
26 javascript_(zone()),
27 jsgraph_(isolate(), graph(), common(), javascript(), machine()) {}
28 ~ControlFlowOptimizerTest() override {} 24 ~ControlFlowOptimizerTest() override {}
29 25
30 protected: 26 protected:
31 void Optimize() { 27 void Optimize() {
32 ControlFlowOptimizer optimizer(jsgraph(), zone()); 28 ControlFlowOptimizer optimizer(graph(), common(), machine(), zone());
33 optimizer.Optimize(); 29 optimizer.Optimize();
34 } 30 }
35 31
36 Node* EmptyFrameState() { return jsgraph()->EmptyFrameState(); }
37
38 JSGraph* jsgraph() { return &jsgraph_; }
39 JSOperatorBuilder* javascript() { return &javascript_; } 32 JSOperatorBuilder* javascript() { return &javascript_; }
40 MachineOperatorBuilder* machine() { return &machine_; } 33 MachineOperatorBuilder* machine() { return &machine_; }
41 34
42 private: 35 private:
43 MachineOperatorBuilder machine_; 36 MachineOperatorBuilder machine_;
44 JSOperatorBuilder javascript_; 37 JSOperatorBuilder javascript_;
45 JSGraph jsgraph_;
46 }; 38 };
47 39
48 40
49 TEST_F(ControlFlowOptimizerTest, BuildSwitch1) { 41 TEST_F(ControlFlowOptimizerTest, BuildSwitch1) {
50 Node* index = Parameter(0); 42 Node* index = Parameter(0);
51 Node* branch0 = graph()->NewNode( 43 Node* branch0 = graph()->NewNode(
52 common()->Branch(), 44 common()->Branch(),
53 graph()->NewNode(machine()->Word32Equal(), index, Int32Constant(0)), 45 graph()->NewNode(machine()->Word32Equal(), index, Int32Constant(0)),
54 start()); 46 start());
55 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0); 47 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
(...skipping 14 matching lines...) Expand all
70 IsIfValue(1, CaptureEq(&switch_capture)), 62 IsIfValue(1, CaptureEq(&switch_capture)),
71 IsIfDefault(AllOf(CaptureEq(&switch_capture), 63 IsIfDefault(AllOf(CaptureEq(&switch_capture),
72 IsSwitch(index, start())))))); 64 IsSwitch(index, start()))))));
73 } 65 }
74 66
75 67
76 TEST_F(ControlFlowOptimizerTest, BuildSwitch2) { 68 TEST_F(ControlFlowOptimizerTest, BuildSwitch2) {
77 Node* input = Parameter(0); 69 Node* input = Parameter(0);
78 Node* context = Parameter(1); 70 Node* context = Parameter(1);
79 Node* index = graph()->NewNode(javascript()->ToNumber(), input, context, 71 Node* index = graph()->NewNode(javascript()->ToNumber(), input, context,
80 EmptyFrameState(), start(), start()); 72 start(), start(), start());
81 Node* if_success = graph()->NewNode(common()->IfSuccess(), index); 73 Node* if_success = graph()->NewNode(common()->IfSuccess(), index);
82 Node* branch0 = graph()->NewNode( 74 Node* branch0 = graph()->NewNode(
83 common()->Branch(), 75 common()->Branch(),
84 graph()->NewNode(machine()->Word32Equal(), index, Int32Constant(0)), 76 graph()->NewNode(machine()->Word32Equal(), index, Int32Constant(0)),
85 if_success); 77 if_success);
86 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0); 78 Node* if_true0 = graph()->NewNode(common()->IfTrue(), branch0);
87 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0); 79 Node* if_false0 = graph()->NewNode(common()->IfFalse(), branch0);
88 Node* branch1 = graph()->NewNode( 80 Node* branch1 = graph()->NewNode(
89 common()->Branch(), 81 common()->Branch(),
90 graph()->NewNode(machine()->Word32Equal(), index, Int32Constant(1)), 82 graph()->NewNode(machine()->Word32Equal(), index, Int32Constant(1)),
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
128 IsIfTrue(CaptureEq(&branch2_capture))), 120 IsIfTrue(CaptureEq(&branch2_capture))),
129 IsMerge(IsIfFalse(AllOf(CaptureEq(&branch1_capture), 121 IsMerge(IsIfFalse(AllOf(CaptureEq(&branch1_capture),
130 IsBranch(cond1, control1))), 122 IsBranch(cond1, control1))),
131 IsIfFalse(AllOf(CaptureEq(&branch2_capture), 123 IsIfFalse(AllOf(CaptureEq(&branch2_capture),
132 IsBranch(cond2, control2))))))); 124 IsBranch(cond2, control2)))))));
133 } 125 }
134 126
135 } // namespace compiler 127 } // namespace compiler
136 } // namespace internal 128 } // namespace internal
137 } // namespace v8 129 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/pipeline.cc ('k') | test/unittests/compiler/graph-unittest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698