MIPS32: Properly handle doubles in GetRegisterIfAccessible
There was a problem with floating point registers and exception
handler. In optimizing compiler fpu registers are treated as 64-bit.
This is problematic since logic in GetRegisterIfAccessible doesn't
support 64-bit floating point registers.
This fixes tests:
510-checker-try-catch
534-checker-bce-deoptimization
Test: mma test-art-target on CI20 (mips32r2) and emulator (mips32r6)
Change-Id: I0f49c1c30f97077b82ad08fcc3cdb86a4877af23
diff --git a/runtime/stack.cc b/runtime/stack.cc
index 4678ac6..3b5360c 100644
--- a/runtime/stack.cc
+++ b/runtime/stack.cc
@@ -325,6 +325,14 @@
reg = (kind == kDoubleHiVReg) ? (2 * reg + 1) : (2 * reg);
}
+ // MIPS32 float registers are used as 64-bit (for MIPS32r2 it is pair
+ // F(2n)-F(2n+1), and for MIPS32r6 it is 64-bit register F(2n)). When
+ // accessing upper 32-bits from double, reg + 1 should be used.
+ if ((kRuntimeISA == InstructionSet::kMips) && (kind == kDoubleHiVReg)) {
+ DCHECK_ALIGNED(reg, 2);
+ reg++;
+ }
+
if (!IsAccessibleRegister(reg, is_float)) {
return false;
}