| 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/instruction-selector-impl.h" | 5 #include "src/compiler/instruction-selector-impl.h" |
| 6 #include "src/compiler/node-matchers.h" | 6 #include "src/compiler/node-matchers.h" |
| 7 #include "src/compiler/node-properties.h" | 7 #include "src/compiler/node-properties.h" |
| 8 | 8 |
| 9 namespace v8 { | 9 namespace v8 { |
| 10 namespace internal { | 10 namespace internal { |
| (...skipping 416 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 427 &inputs[0], &inputs[1], &opcode)) { | 427 &inputs[0], &inputs[1], &opcode)) { |
| 428 input_count += 2; | 428 input_count += 2; |
| 429 } else if (is_add_sub && can_commute && | 429 } else if (is_add_sub && can_commute && |
| 430 TryMatchAnyExtend(&g, selector, node, right_node, left_node, | 430 TryMatchAnyExtend(&g, selector, node, right_node, left_node, |
| 431 &inputs[0], &inputs[1], &opcode)) { | 431 &inputs[0], &inputs[1], &opcode)) { |
| 432 if (must_commute_cond) cont->Commute(); | 432 if (must_commute_cond) cont->Commute(); |
| 433 input_count += 2; | 433 input_count += 2; |
| 434 } else if (TryMatchAnyShift(selector, node, right_node, &opcode, | 434 } else if (TryMatchAnyShift(selector, node, right_node, &opcode, |
| 435 !is_add_sub)) { | 435 !is_add_sub)) { |
| 436 Matcher m_shift(right_node); | 436 Matcher m_shift(right_node); |
| 437 inputs[input_count++] = cont->IsDeoptimize() | 437 inputs[input_count++] = g.UseRegisterOrImmediateZero(left_node); |
| 438 ? g.UseRegister(left_node) | |
| 439 : g.UseRegisterOrImmediateZero(left_node); | |
| 440 inputs[input_count++] = g.UseRegister(m_shift.left().node()); | 438 inputs[input_count++] = g.UseRegister(m_shift.left().node()); |
| 441 inputs[input_count++] = g.UseImmediate(m_shift.right().node()); | 439 inputs[input_count++] = g.UseImmediate(m_shift.right().node()); |
| 442 } else if (can_commute && TryMatchAnyShift(selector, node, left_node, &opcode, | 440 } else if (can_commute && TryMatchAnyShift(selector, node, left_node, &opcode, |
| 443 !is_add_sub)) { | 441 !is_add_sub)) { |
| 444 if (must_commute_cond) cont->Commute(); | 442 if (must_commute_cond) cont->Commute(); |
| 445 Matcher m_shift(left_node); | 443 Matcher m_shift(left_node); |
| 446 inputs[input_count++] = cont->IsDeoptimize() | 444 inputs[input_count++] = g.UseRegisterOrImmediateZero(right_node); |
| 447 ? g.UseRegister(right_node) | |
| 448 : g.UseRegisterOrImmediateZero(right_node); | |
| 449 inputs[input_count++] = g.UseRegister(m_shift.left().node()); | 445 inputs[input_count++] = g.UseRegister(m_shift.left().node()); |
| 450 inputs[input_count++] = g.UseImmediate(m_shift.right().node()); | 446 inputs[input_count++] = g.UseImmediate(m_shift.right().node()); |
| 451 } else { | 447 } else { |
| 452 inputs[input_count++] = cont->IsDeoptimize() | 448 inputs[input_count++] = g.UseRegisterOrImmediateZero(left_node); |
| 453 ? g.UseRegister(left_node) | |
| 454 : g.UseRegisterOrImmediateZero(left_node); | |
| 455 inputs[input_count++] = g.UseRegister(right_node); | 449 inputs[input_count++] = g.UseRegister(right_node); |
| 456 } | 450 } |
| 457 | 451 |
| 458 if (cont->IsBranch()) { | 452 if (cont->IsBranch()) { |
| 459 inputs[input_count++] = g.Label(cont->true_block()); | 453 inputs[input_count++] = g.Label(cont->true_block()); |
| 460 inputs[input_count++] = g.Label(cont->false_block()); | 454 inputs[input_count++] = g.Label(cont->false_block()); |
| 461 } | 455 } |
| 462 | 456 |
| 463 if (!IsComparisonField::decode(properties)) { | 457 if (!IsComparisonField::decode(properties)) { |
| 464 if (cont->IsDeoptimize()) { | 458 outputs[output_count++] = g.DefineAsRegister(node); |
| 465 // If we can deoptimize as a result of the binop, we need to make sure | |
| 466 // that the deopt inputs are not overwritten by the binop result. One way | |
| 467 // to achieve that is to declare the output register as same-as-first. | |
| 468 outputs[output_count++] = g.DefineSameAsFirst(node); | |
| 469 } else { | |
| 470 outputs[output_count++] = g.DefineAsRegister(node); | |
| 471 } | |
| 472 } | 459 } |
| 473 | 460 |
| 474 if (cont->IsSet()) { | 461 if (cont->IsSet()) { |
| 475 outputs[output_count++] = g.DefineAsRegister(cont->result()); | 462 outputs[output_count++] = g.DefineAsRegister(cont->result()); |
| 476 } | 463 } |
| 477 | 464 |
| 478 DCHECK_NE(0u, input_count); | 465 DCHECK_NE(0u, input_count); |
| 479 DCHECK((output_count != 0) || IsComparisonField::decode(properties)); | 466 DCHECK((output_count != 0) || IsComparisonField::decode(properties)); |
| 480 DCHECK_GE(arraysize(inputs), input_count); | 467 DCHECK_GE(arraysize(inputs), input_count); |
| 481 DCHECK_GE(arraysize(outputs), output_count); | 468 DCHECK_GE(arraysize(outputs), output_count); |
| (...skipping 2315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2797 // static | 2784 // static |
| 2798 MachineOperatorBuilder::AlignmentRequirements | 2785 MachineOperatorBuilder::AlignmentRequirements |
| 2799 InstructionSelector::AlignmentRequirements() { | 2786 InstructionSelector::AlignmentRequirements() { |
| 2800 return MachineOperatorBuilder::AlignmentRequirements:: | 2787 return MachineOperatorBuilder::AlignmentRequirements:: |
| 2801 FullUnalignedAccessSupport(); | 2788 FullUnalignedAccessSupport(); |
| 2802 } | 2789 } |
| 2803 | 2790 |
| 2804 } // namespace compiler | 2791 } // namespace compiler |
| 2805 } // namespace internal | 2792 } // namespace internal |
| 2806 } // namespace v8 | 2793 } // namespace v8 |
| OLD | NEW |