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 1693 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1704 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { | 1704 void InstructionSelector::VisitDeoptimizeUnless(Node* node) { |
1705 FlagsContinuation cont = | 1705 FlagsContinuation cont = |
1706 FlagsContinuation::ForDeoptimize(kEqual, node->InputAt(1)); | 1706 FlagsContinuation::ForDeoptimize(kEqual, node->InputAt(1)); |
1707 VisitWordCompareZero(this, node, node->InputAt(0), &cont); | 1707 VisitWordCompareZero(this, node, node->InputAt(0), &cont); |
1708 } | 1708 } |
1709 | 1709 |
1710 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { | 1710 void InstructionSelector::VisitSwitch(Node* node, const SwitchInfo& sw) { |
1711 Mips64OperandGenerator g(this); | 1711 Mips64OperandGenerator g(this); |
1712 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); | 1712 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); |
1713 | 1713 |
1714 // TODO(mips): TableSwitch is broken, as it messes with ra without saving it | 1714 // Emit either ArchTableSwitch or ArchLookupSwitch. |
1715 // properly (which breaks with frame elision, i.e. inside stubs). | 1715 size_t table_space_cost = 10 + 2 * sw.value_range; |
1716 if (false) { | 1716 size_t table_time_cost = 3; |
1717 // Emit either ArchTableSwitch or ArchLookupSwitch. | 1717 size_t lookup_space_cost = 2 + 2 * sw.case_count; |
1718 size_t table_space_cost = 10 + 2 * sw.value_range; | 1718 size_t lookup_time_cost = sw.case_count; |
1719 size_t table_time_cost = 3; | 1719 if (sw.case_count > 0 && |
1720 size_t lookup_space_cost = 2 + 2 * sw.case_count; | 1720 table_space_cost + 3 * table_time_cost <= |
1721 size_t lookup_time_cost = sw.case_count; | 1721 lookup_space_cost + 3 * lookup_time_cost && |
1722 if (sw.case_count > 0 && | 1722 sw.min_value > std::numeric_limits<int32_t>::min()) { |
1723 table_space_cost + 3 * table_time_cost <= | 1723 InstructionOperand index_operand = value_operand; |
1724 lookup_space_cost + 3 * lookup_time_cost && | 1724 if (sw.min_value) { |
1725 sw.min_value > std::numeric_limits<int32_t>::min()) { | 1725 index_operand = g.TempRegister(); |
1726 InstructionOperand index_operand = value_operand; | 1726 Emit(kMips64Sub, index_operand, value_operand, |
1727 if (sw.min_value) { | 1727 g.TempImmediate(sw.min_value)); |
1728 index_operand = g.TempRegister(); | |
1729 Emit(kMips64Sub, index_operand, value_operand, | |
1730 g.TempImmediate(sw.min_value)); | |
1731 } | |
1732 // Generate a table lookup. | |
1733 return EmitTableSwitch(sw, index_operand); | |
1734 } | 1728 } |
| 1729 // Generate a table lookup. |
| 1730 return EmitTableSwitch(sw, index_operand); |
1735 } | 1731 } |
1736 | 1732 |
1737 // Generate a sequence of conditional jumps. | 1733 // Generate a sequence of conditional jumps. |
1738 return EmitLookupSwitch(sw, value_operand); | 1734 return EmitLookupSwitch(sw, value_operand); |
1739 } | 1735 } |
1740 | 1736 |
1741 | 1737 |
1742 void InstructionSelector::VisitWord32Equal(Node* const node) { | 1738 void InstructionSelector::VisitWord32Equal(Node* const node) { |
1743 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); | 1739 FlagsContinuation cont = FlagsContinuation::ForSet(kEqual, node); |
1744 Int32BinopMatcher m(node); | 1740 Int32BinopMatcher m(node); |
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1939 MachineOperatorBuilder::kFloat32RoundUp | | 1935 MachineOperatorBuilder::kFloat32RoundUp | |
1940 MachineOperatorBuilder::kFloat64RoundTruncate | | 1936 MachineOperatorBuilder::kFloat64RoundTruncate | |
1941 MachineOperatorBuilder::kFloat32RoundTruncate | | 1937 MachineOperatorBuilder::kFloat32RoundTruncate | |
1942 MachineOperatorBuilder::kFloat64RoundTiesEven | | 1938 MachineOperatorBuilder::kFloat64RoundTiesEven | |
1943 MachineOperatorBuilder::kFloat32RoundTiesEven; | 1939 MachineOperatorBuilder::kFloat32RoundTiesEven; |
1944 } | 1940 } |
1945 | 1941 |
1946 } // namespace compiler | 1942 } // namespace compiler |
1947 } // namespace internal | 1943 } // namespace internal |
1948 } // namespace v8 | 1944 } // namespace v8 |
OLD | NEW |