Index: src/compiler/mips/code-generator-mips.cc |
diff --git a/src/compiler/mips/code-generator-mips.cc b/src/compiler/mips/code-generator-mips.cc |
index 8f03f7bbb2b350e682751d47a9519910dd7c4ad0..856a69def9c5548015b7f4a24fdc2bcf8175f0b0 100644 |
--- a/src/compiler/mips/code-generator-mips.cc |
+++ b/src/compiler/mips/code-generator-mips.cc |
@@ -428,8 +428,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. |
@@ -805,28 +808,6 @@ void CodeGenerator::AssembleArchJump(BasicBlock::RpoNumber target) { |
} |
-void CodeGenerator::AssembleArchSwitch(Instruction* instr) { |
- MipsOperandConverter i(this, instr); |
- int const kNumLabels = static_cast<int>(instr->InputCount() - 1); |
- v8::internal::Assembler::BlockTrampolinePoolScope block_trampoline_pool( |
- masm()); |
- Label here; |
- |
- __ bal(&here); |
- __ nop(); // Branch delay slot nop. |
- __ bind(&here); |
- __ sll(at, i.InputRegister(0), 2); |
- __ addu(at, at, ra); |
- __ lw(at, MemOperand(at, 5 * v8::internal::Assembler::kInstrSize)); |
- __ jr(at); |
- __ nop(); // Branch delay slot 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) { |
@@ -904,6 +885,37 @@ void CodeGenerator::AssembleArchBoolean(Instruction* instr, |
} |
+void CodeGenerator::AssembleArchLookupSwitch(Instruction* instr) { |
+ MipsOperandConverter i(this, instr); |
+ Register input = i.InputRegister(0); |
+ for (size_t index = 2; index < instr->InputCount(); index += 2) { |
+ __ Branch(GetLabel(i.InputRpo(index + 1)), eq, input, |
+ Operand(i.InputInt32(index + 0))); |
+ } |
+ AssembleArchJump(i.InputRpo(1)); |
+} |
+ |
+ |
+void CodeGenerator::AssembleArchTableSwitch(Instruction* instr) { |
+ MipsOperandConverter i(this, instr); |
+ Register input = i.InputRegister(0); |
+ size_t const case_count = instr->InputCount() - 2; |
+ Label here; |
+ __ Branch(GetLabel(i.InputRpo(1)), hs, input, Operand(case_count)); |
+ __ bal(&here); |
paul.l...
2015/02/17 19:33:59
We need a BlockTrampolinePoolFor() call before thi
|
+ __ nop(); // Branch delay slot nop. |
+ __ bind(&here); |
+ __ sll(at, input, 2); |
+ __ addu(at, at, ra); |
+ __ lw(at, MemOperand(at, 5 * v8::internal::Assembler::kInstrSize)); |
+ __ jr(at); |
+ __ nop(); // Branch delay slot nop. |
+ 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); |