Commit 0830ac7c authored by balazs.kilvady's avatar balazs.kilvady Committed by Commit bot

MIPS: Fix 'MIPS: Fix dd() implementations for compact branches.'

Port 5091e8f2

TEST=cctest/test-assembler-mips64/jump_tables1,cctest/test-assembler-mips64/jump_tables2,cctest/test-assembler-mips64/jump_tables3,cctest/test-macro-assembler-mips/jump_tables5
BUG=

Review URL: https://codereview.chromium.org/1582533005

Cr-Commit-Position: refs/heads/master@{#33266}
parent 322ffda3
...@@ -3226,17 +3226,16 @@ TEST(jump_tables1) { ...@@ -3226,17 +3226,16 @@ TEST(jump_tables1) {
Label done; Label done;
{ {
__ BlockTrampolinePoolFor(kNumCases * 2 + 7); __ BlockTrampolinePoolFor(kNumCases * 2 + 6);
PredictableCodeSizeScope predictable( PredictableCodeSizeScope predictable(
&assm, (kNumCases * 2 + 7) * Assembler::kInstrSize); &assm, (kNumCases * 2 + 6) * Assembler::kInstrSize);
Label here; Label here;
__ bal(&here); __ bal(&here);
__ nop(); __ dsll(at, a0, 3); // In delay slot.
__ bind(&here); __ bind(&here);
__ dsll(at, a0, 3);
__ daddu(at, at, ra); __ daddu(at, at, ra);
__ ld(at, MemOperand(at, 5 * Assembler::kInstrSize)); __ ld(at, MemOperand(at, 4 * Assembler::kInstrSize));
__ jr(at); __ jr(at);
__ nop(); __ nop();
for (int i = 0; i < kNumCases; ++i) { for (int i = 0; i < kNumCases; ++i) {
...@@ -3305,17 +3304,16 @@ TEST(jump_tables2) { ...@@ -3305,17 +3304,16 @@ TEST(jump_tables2) {
__ Align(8); __ Align(8);
__ bind(&dispatch); __ bind(&dispatch);
{ {
__ BlockTrampolinePoolFor(kNumCases * 2 + 7); __ BlockTrampolinePoolFor(kNumCases * 2 + 6);
PredictableCodeSizeScope predictable( PredictableCodeSizeScope predictable(
&assm, (kNumCases * 2 + 7) * Assembler::kInstrSize); &assm, (kNumCases * 2 + 6) * Assembler::kInstrSize);
Label here; Label here;
__ bal(&here); __ bal(&here);
__ nop(); __ dsll(at, a0, 3); // In delay slot.
__ bind(&here); __ bind(&here);
__ dsll(at, a0, 3);
__ daddu(at, at, ra); __ daddu(at, at, ra);
__ ld(at, MemOperand(at, 5 * Assembler::kInstrSize)); __ ld(at, MemOperand(at, 4 * Assembler::kInstrSize));
__ jr(at); __ jr(at);
__ nop(); __ nop();
for (int i = 0; i < kNumCases; ++i) { for (int i = 0; i < kNumCases; ++i) {
...@@ -3386,17 +3384,16 @@ TEST(jump_tables3) { ...@@ -3386,17 +3384,16 @@ TEST(jump_tables3) {
__ Align(8); __ Align(8);
__ bind(&dispatch); __ bind(&dispatch);
{ {
__ BlockTrampolinePoolFor(kNumCases * 2 + 7); __ BlockTrampolinePoolFor(kNumCases * 2 + 6);
PredictableCodeSizeScope predictable( PredictableCodeSizeScope predictable(
&assm, (kNumCases * 2 + 7) * Assembler::kInstrSize); &assm, (kNumCases * 2 + 6) * Assembler::kInstrSize);
Label here; Label here;
__ bal(&here); __ bal(&here);
__ nop(); __ dsll(at, a0, 3); // In delay slot.
__ bind(&here); __ bind(&here);
__ dsll(at, a0, 3);
__ daddu(at, at, ra); __ daddu(at, at, ra);
__ ld(at, MemOperand(at, 5 * Assembler::kInstrSize)); __ ld(at, MemOperand(at, 4 * Assembler::kInstrSize));
__ jr(at); __ jr(at);
__ nop(); __ nop();
for (int i = 0; i < kNumCases; ++i) { for (int i = 0; i < kNumCases; ++i) {
......
...@@ -289,7 +289,7 @@ TEST(jump_tables5) { ...@@ -289,7 +289,7 @@ TEST(jump_tables5) {
Label here; Label here;
__ bal(&here); __ bal(&here);
__ sll(at, a0, 3); // In delay slot. __ sll(at, a0, 2); // In delay slot.
__ bind(&here); __ bind(&here);
__ addu(at, at, ra); __ addu(at, at, ra);
__ lw(at, MemOperand(at, 6 * Assembler::kInstrSize)); __ lw(at, MemOperand(at, 6 * Assembler::kInstrSize));
...@@ -324,9 +324,9 @@ TEST(jump_tables5) { ...@@ -324,9 +324,9 @@ TEST(jump_tables5) {
#endif #endif
F1 f = FUNCTION_CAST<F1>(code->entry()); F1 f = FUNCTION_CAST<F1>(code->entry());
for (int i = 0; i < kNumCases; ++i) { for (int i = 0; i < kNumCases; ++i) {
int64_t res = reinterpret_cast<int64_t>( int32_t res = reinterpret_cast<int32_t>(
CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0)); CALL_GENERATED_CODE(isolate, f, i, 0, 0, 0, 0));
::printf("f(%d) = %" PRId64 "\n", i, res); ::printf("f(%d) = %d\n", i, res);
CHECK_EQ(values[i], res); CHECK_EQ(values[i], res);
} }
} }
......
...@@ -341,6 +341,9 @@ TEST(jump_tables5) { ...@@ -341,6 +341,9 @@ TEST(jump_tables5) {
__ jalr(at); __ jalr(at);
__ nop(); // Branch delay slot nop. __ nop(); // Branch delay slot nop.
__ bc(&done); __ bc(&done);
// A nop instruction must be generated by the forbidden slot guard
// (Assembler::dd(Label*)) so the first label goes to an 8 bytes aligned
// location.
for (int i = 0; i < kNumCases; ++i) { for (int i = 0; i < kNumCases; ++i) {
__ dd(&labels[i]); __ dd(&labels[i]);
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment