| 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/compiler/instruction-selector-impl.h" | 6 #include "src/compiler/instruction-selector-impl.h" |
| 7 #include "src/compiler/node-matchers.h" | 7 #include "src/compiler/node-matchers.h" |
| 8 #include "src/compiler/node-properties.h" | 8 #include "src/compiler/node-properties.h" |
| 9 #include "src/ppc/frames-ppc.h" | 9 #include "src/ppc/frames-ppc.h" |
| 10 | 10 |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 148 | 148 |
| 149 DCHECK_NE(0u, input_count); | 149 DCHECK_NE(0u, input_count); |
| 150 DCHECK_NE(0u, output_count); | 150 DCHECK_NE(0u, output_count); |
| 151 DCHECK_GE(arraysize(inputs), input_count); | 151 DCHECK_GE(arraysize(inputs), input_count); |
| 152 DCHECK_GE(arraysize(outputs), output_count); | 152 DCHECK_GE(arraysize(outputs), output_count); |
| 153 | 153 |
| 154 opcode = cont->Encode(opcode); | 154 opcode = cont->Encode(opcode); |
| 155 if (cont->IsDeoptimize()) { | 155 if (cont->IsDeoptimize()) { |
| 156 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, | 156 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, |
| 157 cont->reason(), cont->frame_state()); | 157 cont->reason(), cont->frame_state()); |
| 158 } else if (cont->IsTrap()) { |
| 159 inputs[input_count++] = g.UseImmediate(cont->trap_id()); |
| 160 selector->Emit(opcode, output_count, outputs, input_count, inputs); |
| 158 } else { | 161 } else { |
| 159 selector->Emit(opcode, output_count, outputs, input_count, inputs); | 162 selector->Emit(opcode, output_count, outputs, input_count, inputs); |
| 160 } | 163 } |
| 161 } | 164 } |
| 162 | 165 |
| 163 | 166 |
| 164 // Shared routine for multiple binary operations. | 167 // Shared routine for multiple binary operations. |
| 165 template <typename Matcher> | 168 template <typename Matcher> |
| 166 void VisitBinop(InstructionSelector* selector, Node* node, | 169 void VisitBinop(InstructionSelector* selector, Node* node, |
| 167 InstructionCode opcode, ImmediateMode operand_mode) { | 170 InstructionCode opcode, ImmediateMode operand_mode) { |
| (...skipping 1360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1528 InstructionOperand left, InstructionOperand right, | 1531 InstructionOperand left, InstructionOperand right, |
| 1529 FlagsContinuation* cont) { | 1532 FlagsContinuation* cont) { |
| 1530 PPCOperandGenerator g(selector); | 1533 PPCOperandGenerator g(selector); |
| 1531 opcode = cont->Encode(opcode); | 1534 opcode = cont->Encode(opcode); |
| 1532 if (cont->IsBranch()) { | 1535 if (cont->IsBranch()) { |
| 1533 selector->Emit(opcode, g.NoOutput(), left, right, | 1536 selector->Emit(opcode, g.NoOutput(), left, right, |
| 1534 g.Label(cont->true_block()), g.Label(cont->false_block())); | 1537 g.Label(cont->true_block()), g.Label(cont->false_block())); |
| 1535 } else if (cont->IsDeoptimize()) { | 1538 } else if (cont->IsDeoptimize()) { |
| 1536 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->reason(), | 1539 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->reason(), |
| 1537 cont->frame_state()); | 1540 cont->frame_state()); |
| 1541 } else if (cont->IsSet()) { |
| 1542 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); |
| 1538 } else { | 1543 } else { |
| 1539 DCHECK(cont->IsSet()); | 1544 DCHECK(cont->IsTrap()); |
| 1540 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); | 1545 selector->Emit(opcode, g.NoOutput(), left, right, |
| 1546 g.UseImmediate(cont->trap_id())); |
| 1541 } | 1547 } |
| 1542 } | 1548 } |
| 1543 | 1549 |
| 1544 | 1550 |
| 1545 // Shared routine for multiple word compare operations. | 1551 // Shared routine for multiple word compare operations. |
| 1546 void VisitWordCompare(InstructionSelector* selector, Node* node, | 1552 void VisitWordCompare(InstructionSelector* selector, Node* node, |
| 1547 InstructionCode opcode, FlagsContinuation* cont, | 1553 InstructionCode opcode, FlagsContinuation* cont, |
| 1548 bool commutative, ImmediateMode immediate_mode) { | 1554 bool commutative, ImmediateMode immediate_mode) { |
| 1549 PPCOperandGenerator g(selector); | 1555 PPCOperandGenerator g(selector); |
| 1550 Node* left = node->InputAt(0); | 1556 Node* left = node->InputAt(0); |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1781 VisitWord32CompareZero(this, node, node->InputAt(0), &cont); | 1787 VisitWord32CompareZero(this, node, node->InputAt(0), &cont); |
| 1782 } | 1788 } |
| 1783 | 1789 |
| 1784 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { | 1790 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { |
| 1785 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( | 1791 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( |
| 1786 kEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); | 1792 kEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); |
| 1787 VisitWord32CompareZero(this, node, node->InputAt(0), &cont); | 1793 VisitWord32CompareZero(this, node, node->InputAt(0), &cont); |
| 1788 } | 1794 } |
| 1789 | 1795 |
| 1790 void InstructionSelector::VisitTrapIf(Node* node, Runtime::FunctionId func_id) { | 1796 void InstructionSelector::VisitTrapIf(Node* node, Runtime::FunctionId func_id) { |
| 1791 UNREACHABLE(); | 1797 FlagsContinuation cont = |
| 1798 FlagsContinuation::ForTrap(kNotEqual, func_id, node->InputAt(1)); |
| 1799 VisitWord32CompareZero(this, node, node->InputAt(0), &cont); |
| 1792 } | 1800 } |
| 1793 | 1801 |
| 1794 void InstructionSelector::VisitTrapUnless(Node* node, | 1802 void InstructionSelector::VisitTrapUnless(Node* node, |
| 1795 Runtime::FunctionId func_id) { | 1803 Runtime::FunctionId func_id) { |
| 1796 UNREACHABLE(); | 1804 FlagsContinuation cont = |
| 1805 FlagsContinuation::ForTrap(kEqual, func_id, node->InputAt(1)); |
| 1806 VisitWord32CompareZero(this, node, node->InputAt(0), &cont); |
| 1797 } | 1807 } |
| 1798 | 1808 |
| 1799 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { | 1809 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { |
| 1800 PPCOperandGenerator g(this); | 1810 PPCOperandGenerator g(this); |
| 1801 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); | 1811 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); |
| 1802 | 1812 |
| 1803 // Emit either ArchTableSwitch or ArchLookupSwitch. | 1813 // Emit either ArchTableSwitch or ArchLookupSwitch. |
| 1804 size_t table_space_cost = 4 + sw.value_range; | 1814 size_t table_space_cost = 4 + sw.value_range; |
| 1805 size_t table_time_cost = 3; | 1815 size_t table_time_cost = 3; |
| 1806 size_t lookup_space_cost = 3 + 2 * sw.case_count; | 1816 size_t lookup_space_cost = 3 + 2 * sw.case_count; |
| (...skipping 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2107 // static | 2117 // static |
| 2108 MachineOperatorBuilder::AlignmentRequirements | 2118 MachineOperatorBuilder::AlignmentRequirements |
| 2109 InstructionSelector::AlignmentRequirements() { | 2119 InstructionSelector::AlignmentRequirements() { |
| 2110 return MachineOperatorBuilder::AlignmentRequirements:: | 2120 return MachineOperatorBuilder::AlignmentRequirements:: |
| 2111 FullUnalignedAccessSupport(); | 2121 FullUnalignedAccessSupport(); |
| 2112 } | 2122 } |
| 2113 | 2123 |
| 2114 } // namespace compiler | 2124 } // namespace compiler |
| 2115 } // namespace internal | 2125 } // namespace internal |
| 2116 } // namespace v8 | 2126 } // namespace v8 |
| OLD | NEW |