| 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 <algorithm> | 5 #include <algorithm> |
| 6 | 6 |
| 7 #include "src/base/adapters.h" | 7 #include "src/base/adapters.h" |
| 8 #include "src/compiler/instruction-selector-impl.h" | 8 #include "src/compiler/instruction-selector-impl.h" |
| 9 #include "src/compiler/node-matchers.h" | 9 #include "src/compiler/node-matchers.h" |
| 10 #include "src/compiler/node-properties.h" | 10 #include "src/compiler/node-properties.h" |
| (...skipping 422 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 433 } | 433 } |
| 434 | 434 |
| 435 DCHECK_NE(0u, input_count); | 435 DCHECK_NE(0u, input_count); |
| 436 DCHECK_NE(0u, output_count); | 436 DCHECK_NE(0u, output_count); |
| 437 DCHECK_GE(arraysize(inputs), input_count); | 437 DCHECK_GE(arraysize(inputs), input_count); |
| 438 DCHECK_GE(arraysize(outputs), output_count); | 438 DCHECK_GE(arraysize(outputs), output_count); |
| 439 | 439 |
| 440 opcode = cont->Encode(opcode); | 440 opcode = cont->Encode(opcode); |
| 441 if (cont->IsDeoptimize()) { | 441 if (cont->IsDeoptimize()) { |
| 442 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, | 442 selector->EmitDeoptimize(opcode, output_count, outputs, input_count, inputs, |
| 443 cont->frame_state()); | 443 cont->reason(), cont->frame_state()); |
| 444 } else { | 444 } else { |
| 445 selector->Emit(opcode, output_count, outputs, input_count, inputs); | 445 selector->Emit(opcode, output_count, outputs, input_count, inputs); |
| 446 } | 446 } |
| 447 } | 447 } |
| 448 | 448 |
| 449 | 449 |
| 450 // Shared routine for multiple binary operations. | 450 // Shared routine for multiple binary operations. |
| 451 static void VisitBinop(InstructionSelector* selector, Node* node, | 451 static void VisitBinop(InstructionSelector* selector, Node* node, |
| 452 InstructionCode opcode) { | 452 InstructionCode opcode) { |
| 453 FlagsContinuation cont; | 453 FlagsContinuation cont; |
| (...skipping 1045 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1499 opcode |= AddressingModeField::encode(addressing_mode); | 1499 opcode |= AddressingModeField::encode(addressing_mode); |
| 1500 opcode = cont->Encode(opcode); | 1500 opcode = cont->Encode(opcode); |
| 1501 inputs[input_count++] = right; | 1501 inputs[input_count++] = right; |
| 1502 | 1502 |
| 1503 if (cont->IsBranch()) { | 1503 if (cont->IsBranch()) { |
| 1504 inputs[input_count++] = g.Label(cont->true_block()); | 1504 inputs[input_count++] = g.Label(cont->true_block()); |
| 1505 inputs[input_count++] = g.Label(cont->false_block()); | 1505 inputs[input_count++] = g.Label(cont->false_block()); |
| 1506 selector->Emit(opcode, 0, nullptr, input_count, inputs); | 1506 selector->Emit(opcode, 0, nullptr, input_count, inputs); |
| 1507 } else if (cont->IsDeoptimize()) { | 1507 } else if (cont->IsDeoptimize()) { |
| 1508 selector->EmitDeoptimize(opcode, 0, nullptr, input_count, inputs, | 1508 selector->EmitDeoptimize(opcode, 0, nullptr, input_count, inputs, |
| 1509 cont->frame_state()); | 1509 cont->reason(), cont->frame_state()); |
| 1510 } else { | 1510 } else { |
| 1511 DCHECK(cont->IsSet()); | 1511 DCHECK(cont->IsSet()); |
| 1512 InstructionOperand output = g.DefineAsRegister(cont->result()); | 1512 InstructionOperand output = g.DefineAsRegister(cont->result()); |
| 1513 selector->Emit(opcode, 1, &output, input_count, inputs); | 1513 selector->Emit(opcode, 1, &output, input_count, inputs); |
| 1514 } | 1514 } |
| 1515 } | 1515 } |
| 1516 | 1516 |
| 1517 // Shared routine for multiple compare operations. | 1517 // Shared routine for multiple compare operations. |
| 1518 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 1518 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
| 1519 InstructionOperand left, InstructionOperand right, | 1519 InstructionOperand left, InstructionOperand right, |
| 1520 FlagsContinuation* cont) { | 1520 FlagsContinuation* cont) { |
| 1521 X64OperandGenerator g(selector); | 1521 X64OperandGenerator g(selector); |
| 1522 opcode = cont->Encode(opcode); | 1522 opcode = cont->Encode(opcode); |
| 1523 if (cont->IsBranch()) { | 1523 if (cont->IsBranch()) { |
| 1524 selector->Emit(opcode, g.NoOutput(), left, right, | 1524 selector->Emit(opcode, g.NoOutput(), left, right, |
| 1525 g.Label(cont->true_block()), g.Label(cont->false_block())); | 1525 g.Label(cont->true_block()), g.Label(cont->false_block())); |
| 1526 } else if (cont->IsDeoptimize()) { | 1526 } else if (cont->IsDeoptimize()) { |
| 1527 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, | 1527 selector->EmitDeoptimize(opcode, g.NoOutput(), left, right, cont->reason(), |
| 1528 cont->frame_state()); | 1528 cont->frame_state()); |
| 1529 } else { | 1529 } else { |
| 1530 DCHECK(cont->IsSet()); | 1530 DCHECK(cont->IsSet()); |
| 1531 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); | 1531 selector->Emit(opcode, g.DefineAsRegister(cont->result()), left, right); |
| 1532 } | 1532 } |
| 1533 } | 1533 } |
| 1534 | 1534 |
| 1535 | 1535 |
| 1536 // Shared routine for multiple compare operations. | 1536 // Shared routine for multiple compare operations. |
| 1537 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, | 1537 void VisitCompare(InstructionSelector* selector, InstructionCode opcode, |
| (...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1634 ExternalReference js_stack_limit = | 1634 ExternalReference js_stack_limit = |
| 1635 ExternalReference::address_of_stack_limit(selector->isolate()); | 1635 ExternalReference::address_of_stack_limit(selector->isolate()); |
| 1636 if (mleft.object().Is(js_stack_limit) && mleft.index().Is(0)) { | 1636 if (mleft.object().Is(js_stack_limit) && mleft.index().Is(0)) { |
| 1637 // Compare(Load(js_stack_limit), LoadStackPointer) | 1637 // Compare(Load(js_stack_limit), LoadStackPointer) |
| 1638 if (!node->op()->HasProperty(Operator::kCommutative)) cont->Commute(); | 1638 if (!node->op()->HasProperty(Operator::kCommutative)) cont->Commute(); |
| 1639 InstructionCode opcode = cont->Encode(kX64StackCheck); | 1639 InstructionCode opcode = cont->Encode(kX64StackCheck); |
| 1640 if (cont->IsBranch()) { | 1640 if (cont->IsBranch()) { |
| 1641 selector->Emit(opcode, g.NoOutput(), g.Label(cont->true_block()), | 1641 selector->Emit(opcode, g.NoOutput(), g.Label(cont->true_block()), |
| 1642 g.Label(cont->false_block())); | 1642 g.Label(cont->false_block())); |
| 1643 } else if (cont->IsDeoptimize()) { | 1643 } else if (cont->IsDeoptimize()) { |
| 1644 selector->EmitDeoptimize(opcode, 0, nullptr, 0, nullptr, | 1644 selector->EmitDeoptimize(opcode, 0, nullptr, 0, nullptr, cont->reason(), |
| 1645 cont->frame_state()); | 1645 cont->frame_state()); |
| 1646 } else { | 1646 } else { |
| 1647 DCHECK(cont->IsSet()); | 1647 DCHECK(cont->IsSet()); |
| 1648 selector->Emit(opcode, g.DefineAsRegister(cont->result())); | 1648 selector->Emit(opcode, g.DefineAsRegister(cont->result())); |
| 1649 } | 1649 } |
| 1650 return; | 1650 return; |
| 1651 } | 1651 } |
| 1652 } | 1652 } |
| 1653 VisitWordCompare(selector, node, kX64Cmp, cont); | 1653 VisitWordCompare(selector, node, kX64Cmp, cont); |
| 1654 } | 1654 } |
| (...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1818 | 1818 |
| 1819 } // namespace | 1819 } // namespace |
| 1820 | 1820 |
| 1821 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, | 1821 void InstructionSelector::VisitBranch(Node* branch, BasicBlock* tbranch, |
| 1822 BasicBlock* fbranch) { | 1822 BasicBlock* fbranch) { |
| 1823 FlagsContinuation cont(kNotEqual, tbranch, fbranch); | 1823 FlagsContinuation cont(kNotEqual, tbranch, fbranch); |
| 1824 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont); | 1824 VisitWordCompareZero(this, branch, branch->InputAt(0), &cont); |
| 1825 } | 1825 } |
| 1826 | 1826 |
| 1827 void InstructionSelector::VisitDeoptimizeIf(Node* node) { | 1827 void InstructionSelector::VisitDeoptimizeIf(Node* node) { |
| 1828 FlagsContinuation cont = | 1828 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( |
| 1829 FlagsContinuation::ForDeoptimize(kNotEqual, node->InputAt(1)); | 1829 kNotEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); |
| 1830 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 1830 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| 1831 } | 1831 } |
| 1832 | 1832 |
| 1833 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { | 1833 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { |
| 1834 FlagsContinuation cont = | 1834 FlagsContinuation cont = FlagsContinuation::ForDeoptimize( |
| 1835 FlagsContinuation::ForDeoptimize(kEqual, node->InputAt(1)); | 1835 kEqual, DeoptimizeReasonOf(node->op()), node->InputAt(1)); |
| 1836 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 1836 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
| 1837 } | 1837 } |
| 1838 | 1838 |
| 1839 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { | 1839 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { |
| 1840 X64OperandGenerator g(this); | 1840 X64OperandGenerator g(this); |
| 1841 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); | 1841 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); |
| 1842 | 1842 |
| 1843 // Emit either ArchTableSwitch or ArchLookupSwitch. | 1843 // Emit either ArchTableSwitch or ArchLookupSwitch. |
| 1844 size_t table_space_cost = 4 + sw.value_range; | 1844 size_t table_space_cost = 4 + sw.value_range; |
| 1845 size_t table_time_cost = 3; | 1845 size_t table_time_cost = 3; |
| (...skipping 310 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2156 // static | 2156 // static |
| 2157 MachineOperatorBuilder::AlignmentRequirements | 2157 MachineOperatorBuilder::AlignmentRequirements |
| 2158 InstructionSelector::AlignmentRequirements() { | 2158 InstructionSelector::AlignmentRequirements() { |
| 2159 return MachineOperatorBuilder::AlignmentRequirements:: | 2159 return MachineOperatorBuilder::AlignmentRequirements:: |
| 2160 FullUnalignedAccessSupport(); | 2160 FullUnalignedAccessSupport(); |
| 2161 } | 2161 } |
| 2162 | 2162 |
| 2163 } // namespace compiler | 2163 } // namespace compiler |
| 2164 } // namespace internal | 2164 } // namespace internal |
| 2165 } // namespace v8 | 2165 } // namespace v8 |
| OLD | NEW |