OLD | NEW |
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/effect-control-linearizer.h" | 5 #include "src/compiler/effect-control-linearizer.h" |
6 #include "src/compiler/access-builder.h" | 6 #include "src/compiler/access-builder.h" |
7 #include "src/compiler/js-graph.h" | 7 #include "src/compiler/js-graph.h" |
8 #include "src/compiler/linkage.h" | 8 #include "src/compiler/linkage.h" |
9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
10 #include "src/compiler/schedule.h" | 10 #include "src/compiler/schedule.h" |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
53 } // namespace | 53 } // namespace |
54 | 54 |
55 TEST_F(EffectControlLinearizerTest, SimpleLoad) { | 55 TEST_F(EffectControlLinearizerTest, SimpleLoad) { |
56 Schedule schedule(zone()); | 56 Schedule schedule(zone()); |
57 | 57 |
58 // Create the graph. | 58 // Create the graph. |
59 Node* heap_number = NumberConstant(0.5); | 59 Node* heap_number = NumberConstant(0.5); |
60 Node* load = graph()->NewNode( | 60 Node* load = graph()->NewNode( |
61 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number, | 61 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number, |
62 graph()->start(), graph()->start()); | 62 graph()->start(), graph()->start()); |
63 Node* zero = graph()->NewNode(common()->Int32Constant(0)); | 63 Node* ret = graph()->NewNode(common()->Return(), load, graph()->start(), |
64 Node* ret = graph()->NewNode(common()->Return(), zero, load, graph()->start(), | |
65 graph()->start()); | 64 graph()->start()); |
66 | 65 |
67 // Build the basic block structure. | 66 // Build the basic block structure. |
68 BasicBlock* start = schedule.start(); | 67 BasicBlock* start = schedule.start(); |
69 schedule.rpo_order()->push_back(start); | 68 schedule.rpo_order()->push_back(start); |
70 start->set_rpo_number(0); | 69 start->set_rpo_number(0); |
71 | 70 |
72 // Populate the basic blocks with nodes. | 71 // Populate the basic blocks with nodes. |
73 schedule.AddNode(start, graph()->start()); | 72 schedule.AddNode(start, graph()->start()); |
74 schedule.AddNode(start, heap_number); | 73 schedule.AddNode(start, heap_number); |
(...skipping 24 matching lines...) Expand all Loading... |
99 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number, | 98 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number, |
100 graph()->start(), if_true); | 99 graph()->start(), if_true); |
101 | 100 |
102 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); | 101 Node* if_false = graph()->NewNode(common()->IfFalse(), branch); |
103 Node* vfalse = Float64Constant(2); | 102 Node* vfalse = Float64Constant(2); |
104 | 103 |
105 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); | 104 Node* merge = graph()->NewNode(common()->Merge(2), if_true, if_false); |
106 Node* phi = graph()->NewNode( | 105 Node* phi = graph()->NewNode( |
107 common()->Phi(MachineRepresentation::kFloat64, 2), vtrue, vfalse, merge); | 106 common()->Phi(MachineRepresentation::kFloat64, 2), vtrue, vfalse, merge); |
108 | 107 |
109 Node* zero = graph()->NewNode(common()->Int32Constant(0)); | |
110 Node* ret = | 108 Node* ret = |
111 graph()->NewNode(common()->Return(), zero, phi, graph()->start(), merge); | 109 graph()->NewNode(common()->Return(), phi, graph()->start(), merge); |
112 | 110 |
113 // Build the basic block structure. | 111 // Build the basic block structure. |
114 BasicBlock* start = schedule.start(); | 112 BasicBlock* start = schedule.start(); |
115 schedule.rpo_order()->push_back(start); | 113 schedule.rpo_order()->push_back(start); |
116 start->set_rpo_number(0); | 114 start->set_rpo_number(0); |
117 | 115 |
118 BasicBlock* tblock = AddBlockToSchedule(&schedule); | 116 BasicBlock* tblock = AddBlockToSchedule(&schedule); |
119 BasicBlock* fblock = AddBlockToSchedule(&schedule); | 117 BasicBlock* fblock = AddBlockToSchedule(&schedule); |
120 BasicBlock* mblock = AddBlockToSchedule(&schedule); | 118 BasicBlock* mblock = AddBlockToSchedule(&schedule); |
121 | 119 |
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1); | 199 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1); |
202 Node* merge1 = graph()->NewNode(common()->Merge(2), if_true1, if_false1); | 200 Node* merge1 = graph()->NewNode(common()->Merge(2), if_true1, if_false1); |
203 | 201 |
204 // Second floating diamond. | 202 // Second floating diamond. |
205 Node* branch2 = | 203 Node* branch2 = |
206 graph()->NewNode(common()->Branch(), const0, graph()->start()); | 204 graph()->NewNode(common()->Branch(), const0, graph()->start()); |
207 Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2); | 205 Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2); |
208 Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2); | 206 Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2); |
209 Node* merge2 = graph()->NewNode(common()->Merge(2), if_true2, if_false2); | 207 Node* merge2 = graph()->NewNode(common()->Merge(2), if_true2, if_false2); |
210 | 208 |
211 Node* zero = graph()->NewNode(common()->Int32Constant(0)); | 209 Node* ret = |
212 Node* ret = graph()->NewNode(common()->Return(), zero, call, graph()->start(), | 210 graph()->NewNode(common()->Return(), call, graph()->start(), if_success); |
213 if_success); | |
214 | 211 |
215 // Build the basic block structure. | 212 // Build the basic block structure. |
216 BasicBlock* start = schedule.start(); | 213 BasicBlock* start = schedule.start(); |
217 schedule.rpo_order()->push_back(start); | 214 schedule.rpo_order()->push_back(start); |
218 start->set_rpo_number(0); | 215 start->set_rpo_number(0); |
219 | 216 |
220 BasicBlock* t1block = AddBlockToSchedule(&schedule); | 217 BasicBlock* t1block = AddBlockToSchedule(&schedule); |
221 BasicBlock* f1block = AddBlockToSchedule(&schedule); | 218 BasicBlock* f1block = AddBlockToSchedule(&schedule); |
222 BasicBlock* m1block = AddBlockToSchedule(&schedule); | 219 BasicBlock* m1block = AddBlockToSchedule(&schedule); |
223 | 220 |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 NodeProperties::ChangeOp(loop, common()->Loop(2)); | 282 NodeProperties::ChangeOp(loop, common()->Loop(2)); |
286 | 283 |
287 effect_phi->InsertInput(zone(), 1, effect_phi); | 284 effect_phi->InsertInput(zone(), 1, effect_phi); |
288 NodeProperties::ChangeOp(effect_phi, common()->EffectPhi(2)); | 285 NodeProperties::ChangeOp(effect_phi, common()->EffectPhi(2)); |
289 | 286 |
290 Node* heap_number = NumberConstant(0.5); | 287 Node* heap_number = NumberConstant(0.5); |
291 Node* load = graph()->NewNode( | 288 Node* load = graph()->NewNode( |
292 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number, | 289 simplified()->LoadField(AccessBuilder::ForHeapNumberValue()), heap_number, |
293 graph()->start(), loop); | 290 graph()->start(), loop); |
294 | 291 |
295 Node* zero = graph()->NewNode(common()->Int32Constant(0)); | 292 Node* ret = graph()->NewNode(common()->Return(), load, effect_phi, if_true); |
296 Node* ret = | |
297 graph()->NewNode(common()->Return(), zero, load, effect_phi, if_true); | |
298 | 293 |
299 // Build the basic block structure. | 294 // Build the basic block structure. |
300 BasicBlock* start = schedule.start(); | 295 BasicBlock* start = schedule.start(); |
301 schedule.rpo_order()->push_back(start); | 296 schedule.rpo_order()->push_back(start); |
302 start->set_rpo_number(0); | 297 start->set_rpo_number(0); |
303 | 298 |
304 BasicBlock* lblock = AddBlockToSchedule(&schedule); | 299 BasicBlock* lblock = AddBlockToSchedule(&schedule); |
305 BasicBlock* fblock = AddBlockToSchedule(&schedule); | 300 BasicBlock* fblock = AddBlockToSchedule(&schedule); |
306 BasicBlock* rblock = AddBlockToSchedule(&schedule); | 301 BasicBlock* rblock = AddBlockToSchedule(&schedule); |
307 | 302 |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
395 IsIfTrue(CaptureEq(&branch2_capture))), | 390 IsIfTrue(CaptureEq(&branch2_capture))), |
396 IsMerge(IsIfFalse(AllOf(CaptureEq(&branch1_capture), | 391 IsMerge(IsIfFalse(AllOf(CaptureEq(&branch1_capture), |
397 IsBranch(cond1, control1))), | 392 IsBranch(cond1, control1))), |
398 IsIfFalse(AllOf(CaptureEq(&branch2_capture), | 393 IsIfFalse(AllOf(CaptureEq(&branch2_capture), |
399 IsBranch(cond2, control2))))))); | 394 IsBranch(cond2, control2))))))); |
400 } | 395 } |
401 | 396 |
402 } // namespace compiler | 397 } // namespace compiler |
403 } // namespace internal | 398 } // namespace internal |
404 } // namespace v8 | 399 } // namespace v8 |
OLD | NEW |