| 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/bits.h" | 5 #include "src/base/bits.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 964 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 975 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); | 975 InstructionOperand value_operand = g.UseRegister(node->InputAt(0)); |
| 976 InstructionOperand default_operand = g.Label(default_branch); | 976 InstructionOperand default_operand = g.Label(default_branch); |
| 977 | 977 |
| 978 // Note that {value_range} can be 0 if {min_value} is -2^31 and {max_value} | 978 // Note that {value_range} can be 0 if {min_value} is -2^31 and {max_value} |
| 979 // is 2^31-1, so don't assume that it's non-zero below. | 979 // is 2^31-1, so don't assume that it's non-zero below. |
| 980 size_t value_range = | 980 size_t value_range = |
| 981 1u + bit_cast<uint32_t>(max_value) - bit_cast<uint32_t>(min_value); | 981 1u + bit_cast<uint32_t>(max_value) - bit_cast<uint32_t>(min_value); |
| 982 | 982 |
| 983 // Determine whether to issue an ArchTableSwitch or an ArchLookupSwitch | 983 // Determine whether to issue an ArchTableSwitch or an ArchLookupSwitch |
| 984 // instruction. | 984 // instruction. |
| 985 size_t table_space_cost = 4 + value_range; | 985 size_t table_space_cost = 10 + 2 * value_range; |
| 986 size_t table_time_cost = 3; | 986 size_t table_time_cost = 10; |
| 987 size_t lookup_space_cost = 3 + 2 * case_count; | 987 size_t lookup_space_cost = 2 + 2 * case_count; |
| 988 size_t lookup_time_cost = case_count; | 988 size_t lookup_time_cost = case_count; |
| 989 if (case_count > 0 && | 989 if (case_count > 0 && |
| 990 table_space_cost + 3 * table_time_cost <= | 990 table_space_cost + 3 * table_time_cost <= |
| 991 lookup_space_cost + 3 * lookup_time_cost && | 991 lookup_space_cost + 3 * lookup_time_cost && |
| 992 min_value > std::numeric_limits<int32_t>::min()) { | 992 min_value > std::numeric_limits<int32_t>::min()) { |
| 993 InstructionOperand index_operand = value_operand; | 993 InstructionOperand index_operand = value_operand; |
| 994 if (min_value) { | 994 if (min_value) { |
| 995 index_operand = g.TempRegister(); | 995 index_operand = g.TempRegister(); |
| 996 Emit(kMips64Sub, index_operand, value_operand, | 996 Emit(kMips64Sub, index_operand, value_operand, |
| 997 g.TempImmediate(min_value)); | 997 g.TempImmediate(min_value)); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 MachineOperatorBuilder::Flags | 1134 MachineOperatorBuilder::Flags |
| 1135 InstructionSelector::SupportedMachineOperatorFlags() { | 1135 InstructionSelector::SupportedMachineOperatorFlags() { |
| 1136 return MachineOperatorBuilder::kFloat64Floor | | 1136 return MachineOperatorBuilder::kFloat64Floor | |
| 1137 MachineOperatorBuilder::kFloat64Ceil | | 1137 MachineOperatorBuilder::kFloat64Ceil | |
| 1138 MachineOperatorBuilder::kFloat64RoundTruncate; | 1138 MachineOperatorBuilder::kFloat64RoundTruncate; |
| 1139 } | 1139 } |
| 1140 | 1140 |
| 1141 } // namespace compiler | 1141 } // namespace compiler |
| 1142 } // namespace internal | 1142 } // namespace internal |
| 1143 } // namespace v8 | 1143 } // namespace v8 |
| OLD | NEW |