| 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/base/adapters.h" | 5 #include "src/base/adapters.h" |
| 6 #include "src/base/bits.h" | 6 #include "src/base/bits.h" |
| 7 #include "src/compiler/instruction-selector-impl.h" | 7 #include "src/compiler/instruction-selector-impl.h" |
| 8 #include "src/compiler/node-matchers.h" | 8 #include "src/compiler/node-matchers.h" |
| 9 #include "src/compiler/node-properties.h" | 9 #include "src/compiler/node-properties.h" |
| 10 | 10 |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 122 } | 122 } |
| 123 | 123 |
| 124 DCHECK_NE(0u, input_count); | 124 DCHECK_NE(0u, input_count); |
| 125 DCHECK_NE(0u, output_count); | 125 DCHECK_NE(0u, output_count); |
| 126 DCHECK_GE(arraysize(inputs), input_count); | 126 DCHECK_GE(arraysize(inputs), input_count); |
| 127 DCHECK_GE(arraysize(outputs), output_count); | 127 DCHECK_GE(arraysize(outputs), output_count); |
| 128 | 128 |
| 129 opcode = cont->Encode(opcode); | 129 opcode = cont->Encode(opcode); |
| 130 if (cont->IsDeoptimize()) { | 130 if (cont->IsDeoptimize()) { |
| 131 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, | 131 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, |
| 132 cont->frame_state()); | 132 cont->reason(), cont->frame_state()); |
| 133 } else { | 133 } else { |
| 134 selector->Emit(opcode, output_count, outputs, input_count, inputs); | 134 selector->Emit(opcode, output_count, outputs, input_count, inputs); |
| 135 } | 135 } |
| 136 } | 136 } |
| 137 | 137 |
| 138 | 138 |
| 139 static void VisitBinop(InstructionSelector* selector, Node* node, | 139 static void VisitBinop(InstructionSelector* selector, Node* node, |
| 140 InstructionCode opcode) { | 140 InstructionCode opcode) { |
| 141 FlagsContinuation cont; | 141 FlagsContinuation cont; |
| 142 VisitBinop(selector, node, opcode, &cont); | 142 VisitBinop(selector, node, opcode, &cont); |
| (...skipping 1362 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1505 // Shared routine for multiple compare operations. | 1505 // Shared routine for multiple compare operations. |
| 1506 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 1506 static void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
| 1507 InstructionOperand left, InstructionOperand right, | 1507 InstructionOperand left, InstructionOperand right, |
| 1508 FlagsContinuation* cont) { | 1508 FlagsContinuation* cont) { |
| 1509 Mips64OperandGenerator g(selector); | 1509 Mips64OperandGenerator g(selector); |
| 1510 opcode = cont->Encode(opcode); | 1510 opcode = cont->Encode(opcode); |
| 1511 if (cont->IsBranch()) { | 1511 if (cont->IsBranch()) { |
| 1512 selector->Emit(opcode, g.NoOutput(), left, right, | 1512 selector->Emit(opcode, g.NoOutput(), left, right, |
| 1513 g.Label(cont->true_block()), g.Label(cont->false_block())); | 1513 g.Label(cont->true_block()), g.Label(cont->false_block())); |
| 1514 } else if (cont->IsDeoptimize()) { | 1514 } else if (cont->IsDeoptimize()) { |
| 1515 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, | 1515 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->reason(), |
| 1516 cont->frame_state()); | 1516 cont->frame_state()); |
| 1517 } else { | 1517 } else { |
| 1518 DCHECK(cont->IsSet()); | 1518 DCHECK(cont->IsSet()); |
| 1519 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); | 1519 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); |
| 1520 } | 1520 } |
| 1521 } | 1521 } |
| 1522 | 1522 |
| 1523 | 1523 |
| 1524 // Shared routine for multiple float32 compare operations. | 1524 // Shared routine for multiple float32 compare operations. |
| 1525 void VisitFloat32Compare(InstructionSelector* selector, Node* node, | 1525 void VisitFloat32Compare(InstructionSelector* selector, Node* node, |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1630 void EmitWordCompareZero(InstructionSelector* selector, Node* value, | 1630 void EmitWordCompareZero(InstructionSelector* selector, Node* value, |
| 1631 FlagsContinuation* cont) { | 1631 FlagsContinuation* cont) { |
| 1632 Mips64OperandGenerator g(selector); | 1632 Mips64OperandGenerator g(selector); |
| 1633 InstructionCode opcode = cont->Encode(kMips64Cmp); | 1633 InstructionCode opcode = cont->Encode(kMips64Cmp); |
| 1634 InstructionOperand const value_operand = g.UseRegister(value); | 1634 InstructionOperand const value_operand = g.UseRegister(value); |
| 1635 if (cont->IsBranch()) { | 1635 if (cont->IsBranch()) { |
| 1636 selector->Emit(opcode, g.NoOutput(), value_operand, g.TempImmediate(0), | 1636 selector->Emit(opcode, g.NoOutput(), value_operand, g.TempImmediate(0), |
| 1637 g.Label(cont->true_block()), g.Label(cont->false_block())); | 1637 g.Label(cont->true_block()), g.Label(cont->false_block())); |
| 1638 } else if (cont->IsDeoptimize()) { | 1638 } else if (cont->IsDeoptimize()) { |
| 1639 selector->EmitDeoptimize(opcode, g.NoOutput(), value_operand, | 1639 selector->EmitDeoptimize(opcode, g.NoOutput(), value_operand, |
| 1640 g.TempImmediate(0), cont->frame_state()); | 1640 g.TempImmediate(0), cont->reason(), |
| 1641 cont->frame_state()); |
| 1641 } else { | 1642 } else { |
| 1642 selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand, | 1643 selector->Emit(opcode, g.DefineAsRegister(cont->result()), value_operand, |
| 1643 g.TempImmediate(0)); | 1644 g.TempImmediate(0)); |
| 1644 } | 1645 } |
| 1645 } | 1646 } |
| 1646 | 1647 |
| 1647 | 1648 |
| 1648 // Shared routine for word comparisons against zero. | 1649 // Shared routine for word comparisons against zero. |
| 1649 void VisitWordCompareZero(InstructionSelector* selector, Node* user, | 1650 void VisitWordCompareZero(InstructionSelector* selector, Node* user, |
| 1650 Node* value, FlagsContinuation* cont) { | 1651 Node* value, FlagsContinuation* cont) { |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1767 | 1768 |
| 1768 } // namespace | 1769 } // namespace |
| 1769 | 1770 |
| 1770 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, | 1771 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, |
| 1771 BasicBlock* fbranch) { | 1772 BasicBlock* fbranch) { |
| 1772 FlagsContinuation cont(kNotEqual, tbranch, fbranch); | 1773 FlagsContinuation cont(kNotEqual, tbranch, fbranch); |
| 1773 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont); | 1774 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont); |
| 1774 } | 1775 } |
| 1775 | 1776 |
| 1776 void InstructionSelector::VisitDeoptimizeIf(Node* node) { | 1777 void InstructionSelector::VisitDeoptimizeIf(Node* node) { |
| 1777 FlagsContinuation cont = | 1778 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( |
| 1778 FlagsContinuation::ForDeoptimize(kNotEqual, node->InputAt(1)); | 1779 kNotEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); |
| 1779 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 1780 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| 1780 } | 1781 } |
| 1781 | 1782 |
| 1782 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { | 1783 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { |
| 1783 FlagsContinuation cont = | 1784 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( |
| 1784 FlagsContinuation::ForDeoptimize(kEqual, node->InputAt(1)); | 1785 kEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); |
| 1785 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 1786 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| 1786 } | 1787 } |
| 1787 | 1788 |
| 1788 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { | 1789 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { |
| 1789 Mips64OperandGenerator g(this); | 1790 Mips64OperandGenerator g(this); |
| 1790 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); | 1791 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); |
| 1791 | 1792 |
| 1792 // Emit either ArchTableSwitch or ArchLookupSwitch. | 1793 // Emit either ArchTableSwitch or ArchLookupSwitch. |
| 1793 size_t table_space_cost = 10 + 2 * sw.value_range; | 1794 size_t table_space_cost = 10 + 2 * sw.value_range; |
| 1794 size_t table_time_cost = 3; | 1795 size_t table_time_cost = 3; |
| (...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2104 } else { | 2105 } else { |
| 2105 DCHECK(kArchVariant == kMips64r2); | 2106 DCHECK(kArchVariant == kMips64r2); |
| 2106 return MachineOperatorBuilder::AlignmentRequirements:: | 2107 return MachineOperatorBuilder::AlignmentRequirements:: |
| 2107 NoUnalignedAccessSupport(); | 2108 NoUnalignedAccessSupport(); |
| 2108 } | 2109 } |
| 2109 } | 2110 } |
| 2110 | 2111 |
| 2111 } // namespace compiler | 2112 } // namespace compiler |
| 2112 } // namespace internal | 2113 } // namespace internal |
| 2113 } // namespace v8 | 2114 } // namespace v8 |
| OLD | NEW |