[MIPS] Fix mips32 trampoline problem.
Reserve argument slots (for $a0-$a3) on the stack in the
InvokeTrampoline() function, for entrypoints that contain direct
reference to native implementation. Called function may use this
space to store $a0-$a3 regs.
This fixes the Settings app crash on mips32, when navigating to:
Settings->Apps->(swipe) On SD card.
Change-Id: If53ce822fd3ef6ef9839c89b556f76fac0792190
diff --git a/compiler/dex/quick/mips/utility_mips.cc b/compiler/dex/quick/mips/utility_mips.cc
index ec6edab..2d26922 100644
--- a/compiler/dex/quick/mips/utility_mips.cc
+++ b/compiler/dex/quick/mips/utility_mips.cc
@@ -17,6 +17,7 @@
#include "codegen_mips.h"
#include "arch/mips/instruction_set_features_mips.h"
+#include "arch/mips/entrypoints_direct_mips.h"
#include "base/logging.h"
#include "dex/quick/mir_to_lir-inl.h"
#include "dex/reg_storage_eq.h"
@@ -708,7 +709,18 @@
}
LIR* MipsMir2Lir::InvokeTrampoline(OpKind op, RegStorage r_tgt, QuickEntrypointEnum trampoline) {
- UNUSED(trampoline); // The address of the trampoline is already loaded into r_tgt.
+ if (IsDirectEntrypoint(trampoline)) {
+ // Reserve argument space on stack (for $a0-$a3) for
+ // entrypoints that directly reference native implementations.
+ // This is not safe in general, as it violates the frame size
+ // of the Quick method, but it is used here only for calling
+ // native functions, outside of the runtime.
+ OpRegImm(kOpSub, rs_rSP, 16);
+ LIR* retVal = OpReg(op, r_tgt);
+ OpRegImm(kOpAdd, rs_rSP, 16);
+ return retVal;
+ }
+
return OpReg(op, r_tgt);
}