Chromium Code Reviews| Index: test/cctest/test-macro-assembler-mips.cc |
| diff --git a/test/cctest/test-macro-assembler-mips.cc b/test/cctest/test-macro-assembler-mips.cc |
| index 727b9322c96d2b6e4f0298e7d963fa9e9f82b5d3..a1de8b4e9f3c8d2b022366159cce90b86a2d27b7 100644 |
| --- a/test/cctest/test-macro-assembler-mips.cc |
| +++ b/test/cctest/test-macro-assembler-mips.cc |
| @@ -296,16 +296,24 @@ TEST(jump_tables6) { |
| v8::internal::CodeObjectRequired::kYes); |
| MacroAssembler* masm = &assembler; |
| - const int kNumCases = 40; |
| - const int kFillInstr = 32551; |
| + const int kSwitchTableCases = 40; |
| + const int kInstrSize = 4; |
|
ivica.bogosavljevic
2016/12/06 09:25:35
this constant is already defined, please reuse it
dusan.simicic
2016/12/06 14:19:39
Done.
|
| const int kMaxBranchOffset = (1 << (18 - 1)) - 1; |
| - const int kTrampolineSlotsSize = 4 * Instruction::kInstrSize; |
| +#ifdef _MIPS_ARCH_MIPS32R6 |
| + const int kSwitchTablePrologueSize = 5; |
|
ivica.bogosavljevic
2016/12/06 09:25:35
Create a constant and use it both here and in Gene
dusan.simicic
2016/12/06 14:19:40
Done.
|
| + const int kTrampolineSlotsSize = 2 * kInstrSize; |
| +#else |
| + const int kSwitchTablePrologueSize = 10; |
| + const int kTrampolineSlotsSize = 4 * kInstrSize; |
|
ivica.bogosavljevic
2016/12/06 09:25:35
Generally this looks good, but these hardcoded num
dusan.simicic
2016/12/06 14:19:39
kTrampolineSlotsSize constant redefined as public
|
| +#endif |
| const int kMaxOffsetForTrampolineStart = |
| kMaxBranchOffset - 16 * kTrampolineSlotsSize; |
| + const int kFillInstr = (kMaxOffsetForTrampolineStart / kInstrSize) - |
| + (kSwitchTablePrologueSize + kSwitchTableCases) - 20; |
| - int values[kNumCases]; |
| + int values[kSwitchTableCases]; |
| isolate->random_number_generator()->NextBytes(values, sizeof(values)); |
| - Label labels[kNumCases]; |
| + Label labels[kSwitchTableCases]; |
| Label near_start, end, done; |
| __ Push(ra); |
| @@ -315,7 +323,7 @@ TEST(jump_tables6) { |
| int gen_insn = 0; |
| __ Branch(&end); |
| - gen_insn += 2; |
| + gen_insn += IsMipsArchVariant(kMips32r6) ? 1 : 2; |
|
ivica.bogosavljevic
2016/12/06 09:25:35
this count actually should be something like:
gen_
dusan.simicic
2016/12/06 14:19:39
Done.
|
| __ bind(&near_start); |
| // Generate slightly less than 32K instructions, which will soon require |
| @@ -325,23 +333,23 @@ TEST(jump_tables6) { |
| } |
| gen_insn += kFillInstr; |
| - __ GenerateSwitchTable(a0, kNumCases, |
| + __ GenerateSwitchTable(a0, kSwitchTableCases, |
| [&labels](size_t i) { return labels + i; }); |
| - gen_insn += (10 + kNumCases); |
| + gen_insn += (kSwitchTablePrologueSize + kSwitchTableCases); |
| - for (int i = 0; i < kNumCases; ++i) { |
| + for (int i = 0; i < kSwitchTableCases; ++i) { |
| __ bind(&labels[i]); |
| __ li(v0, values[i]); |
| __ Branch(&done); |
| } |
| - gen_insn += (4 * kNumCases); |
| + gen_insn += ((IsMipsArchVariant(kMips32r6) ? 3 : 4) * kSwitchTableCases); |
| // If offset from here to first branch instr is greater than max allowed |
| // offset for trampoline ... |
| CHECK_LT(kMaxOffsetForTrampolineStart, masm->pc_offset() - offs1); |
| // ... number of generated instructions must be greater then "gen_insn", |
| // as we are expecting trampoline generation |
| - CHECK_LT(gen_insn, (masm->pc_offset() - offs1) / Instruction::kInstrSize); |
| + CHECK_LT(gen_insn, (masm->pc_offset() - offs1) / kInstrSize); |
| __ bind(&done); |
| __ Pop(ra); |
| @@ -359,7 +367,7 @@ TEST(jump_tables6) { |
| code->Print(std::cout); |
| #endif |
| F1 f = FUNCTION_CAST<F1>(code->entry()); |
| - for (int i = 0; i < kNumCases; ++i) { |
| + for (int i = 0; i < kSwitchTableCases; ++i) { |
| int res = |
| reinterpret_cast<int>(CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0)); |
| ::printf("f(%d) = %d\n", i, res); |