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 696ca010caa4a068fafa5131261485546ee71cee..77dc85902292a79c76745c2c20ad9f458e413a83 100644 |
--- a/test/cctest/test-macro-assembler-mips.cc |
+++ b/test/cctest/test-macro-assembler-mips.cc |
@@ -185,7 +185,7 @@ TEST(jump_tables4) { |
CcTest::InitializeVM(); |
Isolate* isolate = CcTest::i_isolate(); |
HandleScope scope(isolate); |
- MacroAssembler assembler(isolate, NULL, 0, |
+ MacroAssembler assembler(isolate, nullptr, 0, |
v8::internal::CodeObjectRequired::kYes); |
MacroAssembler* masm = &assembler; |
@@ -193,11 +193,9 @@ TEST(jump_tables4) { |
int values[kNumCases]; |
isolate->random_number_generator()->NextBytes(values, sizeof(values)); |
Label labels[kNumCases]; |
- Label near_start, end; |
- |
- __ addiu(sp, sp, -4); |
- __ sw(ra, MemOperand(sp)); |
+ Label near_start, end, done; |
+ __ Push(ra); |
__ mov(v0, zero_reg); |
__ Branch(&end); |
@@ -209,35 +207,17 @@ TEST(jump_tables4) { |
__ addiu(v0, v0, 1); |
} |
- Label done; |
- { |
- __ BlockTrampolinePoolFor(kNumCases + 6); |
- PredictableCodeSizeScope predictable( |
- masm, (kNumCases + 6) * Assembler::kInstrSize); |
- Label here; |
- |
- __ bal(&here); |
- __ sll(at, a0, 2); // In delay slot. |
- __ bind(&here); |
- __ addu(at, at, ra); |
- __ lw(at, MemOperand(at, 4 * Assembler::kInstrSize)); |
- __ jr(at); |
- __ nop(); // Branch delay slot nop. |
- for (int i = 0; i < kNumCases; ++i) { |
- __ dd(&labels[i]); |
- } |
- } |
+ __ GenerateSwitchTable(a0, kNumCases, |
+ [&labels](size_t i) { return labels + i; }); |
for (int i = 0; i < kNumCases; ++i) { |
__ bind(&labels[i]); |
- __ lui(v0, (values[i] >> 16) & 0xffff); |
- __ ori(v0, v0, values[i] & 0xffff); |
+ __ li(v0, values[i]); |
__ Branch(&done); |
} |
__ bind(&done); |
- __ lw(ra, MemOperand(sp)); |
- __ addiu(sp, sp, 4); |
+ __ Pop(ra); |
__ jr(ra); |
__ nop(); |
@@ -279,23 +259,21 @@ TEST(jump_tables5) { |
Label labels[kNumCases]; |
Label done; |
- __ addiu(sp, sp, -4); |
- __ sw(ra, MemOperand(sp)); |
+ __ Push(ra); |
{ |
- __ BlockTrampolinePoolFor(kNumCases * 2 + 7 + 1); |
+ __ BlockTrampolinePoolFor(kNumCases + 6 + 1); |
PredictableCodeSizeScope predictable( |
- masm, kNumCases * kPointerSize + ((7 + 1) * Assembler::kInstrSize)); |
- Label here; |
- |
- __ bal(&here); |
- __ sll(at, a0, 2); // In delay slot. |
- __ bind(&here); |
- __ addu(at, at, ra); |
- __ lw(at, MemOperand(at, 6 * Assembler::kInstrSize)); |
+ masm, kNumCases * kPointerSize + ((6 + 1) * Assembler::kInstrSize)); |
+ |
+ __ addiupc(at, 6 + 1); |
+ __ lsa(at, at, a0, 2); |
+ __ lw(at, MemOperand(at)); |
__ jalr(at); |
__ nop(); // Branch delay slot nop. |
__ bc(&done); |
+ // A nop instruction must be generated by the forbidden slot guard |
+ // (Assembler::dd(Label*)). |
for (int i = 0; i < kNumCases; ++i) { |
__ dd(&labels[i]); |
} |
@@ -303,15 +281,13 @@ TEST(jump_tables5) { |
for (int i = 0; i < kNumCases; ++i) { |
__ bind(&labels[i]); |
- __ lui(v0, (values[i] >> 16) & 0xffff); |
- __ ori(v0, v0, values[i] & 0xffff); |
+ __ li(v0, values[i]); |
__ jr(ra); |
__ nop(); |
} |
__ bind(&done); |
- __ lw(ra, MemOperand(sp)); |
- __ addiu(sp, sp, 4); |
+ __ Pop(ra); |
__ jr(ra); |
__ nop(); |