| OLD | NEW |
| 1 // Copyright 2014 the V8 project authors. All rights reserved. | 1 // Copyright 2014 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/change-lowering.h" | 5 #include "src/compiler/change-lowering.h" |
| 6 | 6 |
| 7 #include "src/code-factory.h" | 7 #include "src/code-factory.h" |
| 8 #include "src/compiler/js-graph.h" | 8 #include "src/compiler/js-graph.h" |
| 9 #include "src/compiler/linkage.h" | 9 #include "src/compiler/linkage.h" |
| 10 #include "src/compiler/machine-operator.h" | 10 #include "src/compiler/machine-operator.h" |
| (...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 250 const Operator* phi_op = common()->Phi(kMachFloat64, 2); | 250 const Operator* phi_op = common()->Phi(kMachFloat64, 2); |
| 251 | 251 |
| 252 Node* check1 = TestNotSmi(object); | 252 Node* check1 = TestNotSmi(object); |
| 253 Node* branch1 = | 253 Node* branch1 = |
| 254 graph()->NewNode(common()->Branch(BranchHint::kFalse), check1, control); | 254 graph()->NewNode(common()->Branch(BranchHint::kFalse), check1, control); |
| 255 | 255 |
| 256 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1); | 256 Node* if_true1 = graph()->NewNode(common()->IfTrue(), branch1); |
| 257 Node* vtrue1 = graph()->NewNode(value->op(), object, context, frame_state, | 257 Node* vtrue1 = graph()->NewNode(value->op(), object, context, frame_state, |
| 258 effect, if_true1); | 258 effect, if_true1); |
| 259 Node* etrue1 = vtrue1; | 259 Node* etrue1 = vtrue1; |
| 260 { | |
| 261 Node* check2 = TestNotSmi(vtrue1); | |
| 262 Node* branch2 = graph()->NewNode(common()->Branch(), check2, if_true1); | |
| 263 | 260 |
| 264 Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2); | 261 Node* check2 = TestNotSmi(vtrue1); |
| 265 Node* vtrue2 = LoadHeapNumberValue(vtrue1, if_true2); | 262 Node* branch2 = graph()->NewNode(common()->Branch(), check2, if_true1); |
| 266 | 263 |
| 267 Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2); | 264 Node* if_true2 = graph()->NewNode(common()->IfTrue(), branch2); |
| 268 Node* vfalse2 = ChangeSmiToFloat64(vtrue1); | 265 Node* vtrue2 = LoadHeapNumberValue(vtrue1, if_true2); |
| 269 | 266 |
| 270 if_true1 = graph()->NewNode(merge_op, if_true2, if_false2); | 267 Node* if_false2 = graph()->NewNode(common()->IfFalse(), branch2); |
| 271 vtrue1 = graph()->NewNode(phi_op, vtrue2, vfalse2, if_true1); | 268 Node* vfalse2 = ChangeSmiToFloat64(vtrue1); |
| 272 } | 269 |
| 270 if_true1 = graph()->NewNode(merge_op, if_true2, if_false2); |
| 271 vtrue1 = graph()->NewNode(phi_op, vtrue2, vfalse2, if_true1); |
| 273 | 272 |
| 274 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1); | 273 Node* if_false1 = graph()->NewNode(common()->IfFalse(), branch1); |
| 275 Node* vfalse1 = ChangeSmiToFloat64(object); | 274 Node* vfalse1 = ChangeSmiToFloat64(object); |
| 276 Node* efalse1 = effect; | 275 Node* efalse1 = effect; |
| 277 | 276 |
| 278 Node* merge1 = graph()->NewNode(merge_op, if_true1, if_false1); | 277 Node* merge1 = graph()->NewNode(merge_op, if_true1, if_false1); |
| 279 Node* ephi1 = graph()->NewNode(ephi_op, etrue1, efalse1, merge1); | 278 Node* ephi1 = graph()->NewNode(ephi_op, etrue1, efalse1, merge1); |
| 280 Node* phi1 = graph()->NewNode(phi_op, vtrue1, vfalse1, merge1); | 279 Node* phi1 = graph()->NewNode(phi_op, vtrue1, vfalse1, merge1); |
| 281 | 280 |
| 282 NodeProperties::ReplaceWithValue(value, phi1, ephi1, merge1); | 281 // Wire the new diamond into the graph, {JSToNumber} can still throw. |
| 282 NodeProperties::ReplaceUses(value, phi1, ephi1, etrue1, etrue1); |
| 283 |
| 284 // TODO(mstarzinger): This iteration cuts out the IfSuccess projection from |
| 285 // the node and places it inside the diamond. Come up with a helper method! |
| 286 for (Node* use : etrue1->uses()) { |
| 287 if (use->opcode() == IrOpcode::kIfSuccess) { |
| 288 use->ReplaceUses(merge1); |
| 289 NodeProperties::ReplaceControlInput(branch2, use); |
| 290 } |
| 291 } |
| 292 |
| 283 return Replace(phi1); | 293 return Replace(phi1); |
| 284 } | 294 } |
| 285 | 295 |
| 286 Node* check = TestNotSmi(value); | 296 Node* check = TestNotSmi(value); |
| 287 Node* branch = | 297 Node* branch = |
| 288 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); | 298 graph()->NewNode(common()->Branch(BranchHint::kFalse), check, control); |
| 289 | 299 |
| 290 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); | 300 Node* if_true = graph()->NewNode(common()->IfTrue(), branch); |
| 291 Node* vtrue = LoadHeapNumberValue(value, if_true); | 301 Node* vtrue = LoadHeapNumberValue(value, if_true); |
| 292 | 302 |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 } | 347 } |
| 338 | 348 |
| 339 | 349 |
| 340 MachineOperatorBuilder* ChangeLowering::machine() const { | 350 MachineOperatorBuilder* ChangeLowering::machine() const { |
| 341 return jsgraph()->machine(); | 351 return jsgraph()->machine(); |
| 342 } | 352 } |
| 343 | 353 |
| 344 } // namespace compiler | 354 } // namespace compiler |
| 345 } // namespace internal | 355 } // namespace internal |
| 346 } // namespace v8 | 356 } // namespace v8 |
| OLD | NEW |