From 44335e189951a863607049a33571932fb6a2a841 Mon Sep 17 00:00:00 2001 From: jeffhao Date: Mon, 18 Jun 2012 13:48:25 -0700 Subject: 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 --- src/compiler/codegen/GenCommon.cc | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'src/compiler/codegen/GenCommon.cc') 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); -- cgit v1.2.3-59-g8ed1b