Index: src/compiler/arm/code-generator-arm.cc |
diff --git a/src/compiler/arm/code-generator-arm.cc b/src/compiler/arm/code-generator-arm.cc |
index 52f0765e04306087edd13639bc8960e9f8320d01..1ff7ea3acc65e05cf0ca29420b308efcb93d6e23 100644 |
--- a/src/compiler/arm/code-generator-arm.cc |
+++ b/src/compiler/arm/code-generator-arm.cc |
@@ -336,8 +336,12 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
AssembleArchJump(i.InputRpo(0)); |
DCHECK_EQ(LeaveCC, i.OutputSBit()); |
break; |
- case kArchSwitch: |
- AssembleArchSwitch(instr); |
+ case kArchLookupSwitch: |
+ AssembleArchLookupSwitch(instr); |
+ DCHECK_EQ(LeaveCC, i.OutputSBit()); |
+ break; |
+ case kArchTableSwitch: |
+ AssembleArchTableSwitch(instr); |
DCHECK_EQ(LeaveCC, i.OutputSBit()); |
break; |
case kArchNop: |
@@ -741,18 +745,6 @@ void CodeGenerator::AssembleArchJump(BasicBlock::RpoNumber target) { |
} |
-void CodeGenerator::AssembleArchSwitch(Instruction* instr) { |
- ArmOperandConverter i(this, instr); |
- int const kNumLabels = static_cast<int>(instr->InputCount() - 1); |
- __ BlockConstPoolFor(kNumLabels + 2); |
- __ ldr(pc, MemOperand(pc, i.InputRegister(0), LSL, 2)); |
- __ nop(); |
- for (int index = 0; index < kNumLabels; ++index) { |
- __ dd(GetLabel(i.InputRpo(index + 1))); |
- } |
-} |
- |
- |
// Assembles boolean materializations after an instruction. |
void CodeGenerator::AssembleArchBoolean(Instruction* instr, |
FlagsCondition condition) { |
@@ -768,6 +760,31 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr, |
} |
+void CodeGenerator::AssembleArchLookupSwitch(Instruction* instr) { |
+ ArmOperandConverter i(this, instr); |
+ Register input = i.InputRegister(0); |
+ for (size_t index = 2; index < instr->InputCount(); index += 2) { |
+ __ cmp(input, Operand(i.InputInt32(index + 0))); |
+ __ b(eq, GetLabel(i.InputRpo(index + 1))); |
+ } |
+ AssembleArchJump(i.InputRpo(1)); |
+} |
+ |
+ |
+void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) { |
+ ArmOperandConverter i(this, instr); |
+ Register input = i.InputRegister(0); |
+ size_t const case_count = instr->InputCount() - 2; |
+ __ cmp(input, Operand(case_count)); |
+ __ BlockConstPoolFor(case_count + 2); |
+ __ ldr(pc, MemOperand(pc, input, LSL, 2), lo); |
+ __ b(GetLabel(i.InputRpo(1))); |
+ for (size_t index = 0; index < case_count; ++index) { |
+ __ dd(GetLabel(i.InputRpo(index + 2))); |
+ } |
+} |
+ |
+ |
void CodeGenerator::AssembleDeoptimizerCall(int deoptimization_id) { |
Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( |
isolate(), deoptimization_id, Deoptimizer::LAZY); |