Fix bugs in UnresolvedDirectMethodTrampolineFromCode.
Change-Id: Ife26b464d3dd4d602d8b9269a64a4e2028b7daf6
diff --git a/src/runtime_support.cc b/src/runtime_support.cc
index 55aff57..79fc790 100644
--- a/src/runtime_support.cc
+++ b/src/runtime_support.cc
@@ -344,10 +344,11 @@
cur_arg = cur_arg + (c == 'J' || c == 'D' ? 2 : 1);
}
// Handlerize references in out going arguments
- for(size_t i = 3; i < shorty_len; i++) {
+ for(size_t i = 3; i < (shorty_len - 1); i++) {
char c = shorty[i + 1]; // offset to skip return value
if (c == 'L') {
- Object* obj = reinterpret_cast<Object*>(regs[i + 3]); // skip R0, LR and Method* of caller
+ // Plus 6 to skip args 1 to 3, LR and Method* plus the start offset of 3 to skip the spills
+ Object* obj = reinterpret_cast<Object*>(regs[i + 6]);
AddLocalReference<jobject>(env, obj);
}
cur_arg = cur_arg + (c == 'J' || c == 'D' ? 2 : 1);