| 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 | 9 |
| 10 namespace v8 { | 10 namespace v8 { |
| (...skipping 1190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1201 opcode = cont->Encode(opcode); | 1201 opcode = cont->Encode(opcode); |
| 1202 inputs[input_count++] = right; | 1202 inputs[input_count++] = right; |
| 1203 | 1203 |
| 1204 if (cont->IsBranch()) { | 1204 if (cont->IsBranch()) { |
| 1205 inputs[input_count++] = g.Label(cont->true_block()); | 1205 inputs[input_count++] = g.Label(cont->true_block()); |
| 1206 inputs[input_count++] = g.Label(cont->false_block()); | 1206 inputs[input_count++] = g.Label(cont->false_block()); |
| 1207 selector->Emit(opcode, 0, nullptr, input_count, inputs); | 1207 selector->Emit(opcode, 0, nullptr, input_count, inputs); |
| 1208 } else if (cont->IsDeoptimize()) { | 1208 } else if (cont->IsDeoptimize()) { |
| 1209 selector->EmitDeoptimize(opcode, 0, nullptr, input_count, inputs, | 1209 selector->EmitDeoptimize(opcode, 0, nullptr, input_count, inputs, |
| 1210 cont->reason(), cont->frame_state()); | 1210 cont->reason(), cont->frame_state()); |
| 1211 } else { | 1211 } else if (cont->IsSet()) { |
| 1212 DCHECK(cont->IsSet()); | |
| 1213 InstructionOperand output = g.DefineAsRegister(cont->result()); | 1212 InstructionOperand output = g.DefineAsRegister(cont->result()); |
| 1214 selector->Emit(opcode, 1, &output, input_count, inputs); | 1213 selector->Emit(opcode, 1, &output, input_count, inputs); |
| 1214 } else { |
| 1215 DCHECK(cont->IsTrap()); |
| 1216 inputs[input_count++] = g.UseImmediate(cont->trap_id()); |
| 1217 selector->Emit(opcode, 0, nullptr, input_count, inputs); |
| 1215 } | 1218 } |
| 1216 } | 1219 } |
| 1217 | 1220 |
| 1218 // Shared routine for multiple compare operations. | 1221 // Shared routine for multiple compare operations. |
| 1219 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 1222 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
| 1220 InstructionOperand left, InstructionOperand right, | 1223 InstructionOperand left, InstructionOperand right, |
| 1221 FlagsContinuation* cont) { | 1224 FlagsContinuation* cont) { |
| 1222 IA32OperandGenerator g(selector); | 1225 IA32OperandGenerator g(selector); |
| 1223 opcode = cont->Encode(opcode); | 1226 opcode = cont->Encode(opcode); |
| 1224 if (cont->IsBranch()) { | 1227 if (cont->IsBranch()) { |
| 1225 selector->Emit(opcode, g.NoOutput(), left, right, | 1228 selector->Emit(opcode, g.NoOutput(), left, right, |
| 1226 g.Label(cont->true_block()), g.Label(cont->false_block())); | 1229 g.Label(cont->true_block()), g.Label(cont->false_block())); |
| 1227 } else if (cont->IsDeoptimize()) { | 1230 } else if (cont->IsDeoptimize()) { |
| 1228 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->reason(), | 1231 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->reason(), |
| 1229 cont->frame_state()); | 1232 cont->frame_state()); |
| 1233 } else if (cont->IsSet()) { |
| 1234 selector->Emit(opcode, g.DefineAsByteRegister(cont->result()), left, right); |
| 1230 } else { | 1235 } else { |
| 1231 DCHECK(cont->IsSet()); | 1236 DCHECK(cont->IsTrap()); |
| 1232 selector->Emit(opcode, g.DefineAsByteRegister(cont->result()), left, right); | 1237 selector->Emit(opcode, g.NoOutput(), left, right, |
| 1238 g.UseImmediate(cont->trap_id())); |
| 1233 } | 1239 } |
| 1234 } | 1240 } |
| 1235 | 1241 |
| 1236 | 1242 |
| 1237 // Shared routine for multiple compare operations. | 1243 // Shared routine for multiple compare operations. |
| 1238 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 1244 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
| 1239 Node* left, Node* right, FlagsContinuation* cont, | 1245 Node* left, Node* right, FlagsContinuation* cont, |
| 1240 bool commutative) { | 1246 bool commutative) { |
| 1241 IA32OperandGenerator g(selector); | 1247 IA32OperandGenerator g(selector); |
| 1242 if (commutative && g.CanBeBetterLeftOperand(right)) { | 1248 if (commutative && g.CanBeBetterLeftOperand(right)) { |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1494 kNotEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); | 1500 kNotEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); |
| 1495 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 1501 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| 1496 } | 1502 } |
| 1497 | 1503 |
| 1498 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { | 1504 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { |
| 1499 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( | 1505 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( |
| 1500 kEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); | 1506 kEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); |
| 1501 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 1507 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| 1502 } | 1508 } |
| 1503 | 1509 |
| 1504 void InstructionSelector::VisitTrapIf(Node* node) { UNREACHABLE(); } | 1510 void InstructionSelector::VisitTrapIf(Node* node) { |
| 1511 FlagsContinuation cont = FlagsContinuation::ForTrap( |
| 1512 kNotEqual, OpParameter<Runtime::FunctionId>(node->op()), |
| 1513 node->InputAt(1)); |
| 1514 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| 1515 } |
| 1505 | 1516 |
| 1506 void InstructionSelector::VisitTrapUnless(Node* node) { UNREACHABLE(); } | 1517 void InstructionSelector::VisitTrapUnless(Node* node) { |
| 1518 FlagsContinuation cont = FlagsContinuation::ForTrap( |
| 1519 kEqual, OpParameter<Runtime::FunctionId>(node->op()), node->InputAt(1)); |
| 1520 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| 1521 } |
| 1507 | 1522 |
| 1508 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { | 1523 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { |
| 1509 IA32OperandGenerator g(this); | 1524 IA32OperandGenerator g(this); |
| 1510 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); | 1525 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); |
| 1511 | 1526 |
| 1512 // Emit either ArchTableSwitch or ArchLookupSwitch. | 1527 // Emit either ArchTableSwitch or ArchLookupSwitch. |
| 1513 size_t table_space_cost = 4 + sw.value_range; | 1528 size_t table_space_cost = 4 + sw.value_range; |
| 1514 size_t table_time_cost = 3; | 1529 size_t table_time_cost = 3; |
| 1515 size_t lookup_space_cost = 3 + 2 * sw.case_count; | 1530 size_t lookup_space_cost = 3 + 2 * sw.case_count; |
| 1516 size_t lookup_time_cost = sw.case_count; | 1531 size_t lookup_time_cost = sw.case_count; |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1751 // static | 1766 // static |
| 1752 MachineOperatorBuilder::AlignmentRequirements | 1767 MachineOperatorBuilder::AlignmentRequirements |
| 1753 InstructionSelector::AlignmentRequirements() { | 1768 InstructionSelector::AlignmentRequirements() { |
| 1754 return MachineOperatorBuilder::AlignmentRequirements:: | 1769 return MachineOperatorBuilder::AlignmentRequirements:: |
| 1755 FullUnalignedAccessSupport(); | 1770 FullUnalignedAccessSupport(); |
| 1756 } | 1771 } |
| 1757 | 1772 |
| 1758 } // namespace compiler | 1773 } // namespace compiler |
| 1759 } // namespace internal | 1774 } // namespace internal |
| 1760 } // namespace v8 | 1775 } // namespace v8 |
| OLD | NEW |