Index: src/mips/macro-assembler-mips.h |
diff --git a/src/mips/macro-assembler-mips.h b/src/mips/macro-assembler-mips.h |
index 38115bc6d87fd024665e54d55014bb9f3336fe7a..71bff266ebf05c0f5fa07000ea95c87d184e96ce 100644 |
--- a/src/mips/macro-assembler-mips.h |
+++ b/src/mips/macro-assembler-mips.h |
@@ -208,6 +208,12 @@ class MacroAssembler: public Assembler { |
Heap::RootListIndex index, |
BranchDelaySlot bdslot = PROTECT); |
+// Number of instructions needed for calculation of switch table entry address |
+#ifdef _MIPS_ARCH_MIPS32R6 |
+ static const int kSwitchTablePrologueSize = 5; |
+#else |
+ static const int kSwitchTablePrologueSize = 10; |
+#endif |
// GetLabelFunction must be lambda '[](size_t index) -> Label*' or a |
// functor/function with 'Label *func(size_t index)' declaration. |
template <typename Func> |
@@ -1818,13 +1824,13 @@ template <typename Func> |
void MacroAssembler::GenerateSwitchTable(Register index, size_t case_count, |
Func GetLabelFunction) { |
if (kArchVariant >= kMips32r6) { |
- BlockTrampolinePoolFor(case_count + 5); |
+ BlockTrampolinePoolFor(case_count + kSwitchTablePrologueSize); |
addiupc(at, 5); |
Lsa(at, at, index, kPointerSizeLog2); |
lw(at, MemOperand(at)); |
} else { |
Label here; |
- BlockTrampolinePoolFor(case_count + 10); |
+ BlockTrampolinePoolFor(case_count + kSwitchTablePrologueSize); |
push(ra); |
bal(&here); |
sll(at, index, kPointerSizeLog2); // Branch delay slot. |