summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author jeffhao <jeffhao@google.com> 2012-06-18 13:48:25 -0700
committer jeffhao <jeffhao@google.com> 2012-06-18 14:38:46 -0700
commit44335e189951a863607049a33571932fb6a2a841 (patch)
tree0d8bfb84cd0830523cc7ec5fd0eabed0770ae6de
parent83c26f9c7ee42b0037d2679f6f37dd28a3f13af7 (diff)
Fix arguments to throw of ArrayIndexOutOfBounds exception.
The handler expects the array length in the second arg, but x86 was passing the array pointer. Change-Id: I0439b93f70569f3e1aa5ef34b9dfa75062935170
-rw-r--r--src/compiler/codegen/GenCommon.cc15
1 files changed, 8 insertions, 7 deletions
diff --git a/src/compiler/codegen/GenCommon.cc b/src/compiler/codegen/GenCommon.cc
index a1c7645095..40c0f22fa9 100644
--- a/src/compiler/codegen/GenCommon.cc
+++ b/src/compiler/codegen/GenCommon.cc
@@ -898,19 +898,20 @@ void handleThrowLaunchpads(CompilationUnit *cUnit)
funcOffset = ENTRYPOINT_OFFSET(pThrowNullPointerFromCode);
break;
case kThrowArrayBounds:
+#if defined (TARGET_X86)
+ // x86 leaves the array pointer in v2, so load the array length that the handler expects
+ opRegMem(cUnit, kOpMov, v2, v2, Array::LengthOffset().Int32Value());
+#endif
+ // Move v1 (array index) to rARG0 and v2 (array length) to rARG1
if (v2 != rARG0) {
opRegCopy(cUnit, rARG0, v1);
opRegCopy(cUnit, rARG1, v2);
} else {
if (v1 == rARG1) {
-#if defined(TARGET_ARM)
- int rTmp = r12;
-#else
- int rTmp = oatAllocTemp(cUnit);
-#endif
- opRegCopy(cUnit, rTmp, v1);
+ // Swap v1 and v2, using rARG2 as a temp
+ opRegCopy(cUnit, rARG2, v1);
opRegCopy(cUnit, rARG1, v2);
- opRegCopy(cUnit, rARG0, rTmp);
+ opRegCopy(cUnit, rARG0, rARG2);
} else {
opRegCopy(cUnit, rARG1, v2);
opRegCopy(cUnit, rARG0, v1);