Index: src/compiler/x64/code-generator-x64.cc |
diff --git a/src/compiler/x64/code-generator-x64.cc b/src/compiler/x64/code-generator-x64.cc |
index e52326eac15d64825ca09233f7a6987f42ab2438..adf8966906cdba104476f3a29694f85b570661ee 100644 |
--- a/src/compiler/x64/code-generator-x64.cc |
+++ b/src/compiler/x64/code-generator-x64.cc |
@@ -532,8 +532,11 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
case kArchJmp: |
AssembleArchJump(i.InputRpo(0)); |
break; |
- case kArchSwitch: |
- AssembleArchSwitch(instr); |
+ case kArchLookupSwitch: |
+ AssembleArchLookupSwitch(instr); |
+ break; |
+ case kArchTableSwitch: |
+ AssembleArchTableSwitch(instr); |
break; |
case kArchNop: |
// don't emit code for nops. |
@@ -1070,19 +1073,6 @@ void CodeGenerator::AssembleArchJump(BasicBlock::RpoNumber target) { |
} |
-void CodeGenerator::AssembleArchSwitch(Instruction* instr) { |
- X64OperandConverter i(this, instr); |
- size_t const label_count = instr->InputCount() - 1; |
- Label** labels = zone()->NewArray<Label*>(label_count); |
- for (size_t index = 0; index < label_count; ++index) { |
- labels[index] = GetLabel(i.InputRpo(static_cast<int>(index + 1))); |
- } |
- Label* const table = AddJumpTable(labels, label_count); |
- __ leaq(kScratchRegister, Operand(table)); |
- __ jmp(Operand(kScratchRegister, i.InputRegister(0), times_8, 0)); |
-} |
- |
- |
// Assembles boolean materializations after this instruction. |
void CodeGenerator::AssembleArchBoolean(Instruction* instr, |
FlagsCondition condition) { |
@@ -1150,6 +1140,33 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr, |
} |
+void CodeGenerator::AssembleArchLookupSwitch(Instruction* instr) { |
+ X64OperandConverter i(this, instr); |
+ Register input = i.InputRegister(0); |
+ for (size_t index = 2; index < instr->InputCount(); index += 2) { |
+ __ cmpl(input, Immediate(i.InputInt32(static_cast<int>(index + 0)))); |
+ __ j(equal, GetLabel(i.InputRpo(static_cast<int>(index + 1)))); |
+ } |
+ AssembleArchJump(i.InputRpo(1)); |
+} |
+ |
+ |
+void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) { |
+ X64OperandConverter i(this, instr); |
+ Register input = i.InputRegister(0); |
+ int32_t const case_count = static_cast<int32_t>(instr->InputCount() - 2); |
+ Label** cases = zone()->NewArray<Label*>(case_count); |
+ for (int32_t index = 0; index < case_count; ++index) { |
+ cases[index] = GetLabel(i.InputRpo(index + 2)); |
+ } |
+ Label* const table = AddJumpTable(cases, case_count); |
+ __ cmpl(input, Immediate(case_count)); |
+ __ j(above_equal, GetLabel(i.InputRpo(1))); |
+ __ leaq(kScratchRegister, Operand(table)); |
+ __ jmp(Operand(kScratchRegister, input, times_8, 0)); |
+} |
+ |
+ |
void CodeGenerator::AssembleDeoptimizerCall(int deoptimization_id) { |
Address deopt_entry = Deoptimizer::GetDeoptimizationEntry( |
isolate(), deoptimization_id, Deoptimizer::LAZY); |