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