Index: src/compiler/ia32/code-generator-ia32.cc |
diff --git a/src/compiler/ia32/code-generator-ia32.cc b/src/compiler/ia32/code-generator-ia32.cc |
index 54336dc31ee6f8abf1d321b22bfe16d2673cfcf9..f88cd106766c50fa4f3146727e7a7286295841a4 100644 |
--- a/src/compiler/ia32/code-generator-ia32.cc |
+++ b/src/compiler/ia32/code-generator-ia32.cc |
@@ -310,6 +310,9 @@ void CodeGenerator::AssembleArchInstruction(Instruction* instr) { |
case kArchJmp: |
AssembleArchJump(i.InputRpo(0)); |
break; |
+ case kArchSwitch: |
+ AssembleArchSwitch(instr); |
+ break; |
case kArchNop: |
// don't emit code for nops. |
break; |
@@ -758,6 +761,18 @@ void CodeGenerator::AssembleArchJump(BasicBlock::RpoNumber target) { |
} |
+void CodeGenerator::AssembleArchSwitch(Instruction* instr) { |
+ IA32OperandConverter 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(index + 1)); |
+ } |
+ Label* const table = AddJumpTable(labels, label_count); |
+ __ jmp(Operand::JumpTable(i.InputRegister(0), times_4, table)); |
+} |
+ |
+ |
// Assembles boolean materializations after an instruction. |
void CodeGenerator::AssembleArchBoolean(Instruction* instr, |
FlagsCondition condition) { |
@@ -1214,6 +1229,13 @@ void CodeGenerator::AssembleSwap(InstructionOperand* source, |
} |
+void CodeGenerator::AssembleJumpTable(Label** targets, size_t target_count) { |
+ for (size_t index = 0; index < target_count; ++index) { |
+ __ dd(targets[index]); |
+ } |
+} |
+ |
+ |
void CodeGenerator::AddNopForSmiCodeInlining() { __ nop(); } |