dvmThrowException(gDvm.exArithmeticException, msg);
}
-void dvmThrowArrayIndexOutOfBoundsException(int index, int length)
+void dvmThrowArrayIndexOutOfBoundsException(int length, int index)
{
dvmThrowExceptionFmt(gDvm.exArrayIndexOutOfBoundsException,
"length=%d; index=%d", length, index);
void dvmThrowStringIndexOutOfBoundsExceptionWithRegion(jsize stringLength,
jsize requestStart, jsize requestLength) {
dvmThrowExceptionFmt(gDvm.exStringIndexOutOfBoundsException,
- "length=%d; regionStart=%d regionLength=%d",
+ "length=%d; regionStart=%d; regionLength=%d",
stringLength, requestStart, requestLength);
}
/*
* Throw an ArrayIndexOutOfBoundsException in the current thread,
- * using the given index and array length in the detail message.
+ * using the given array length and index in the detail message.
*/
-void dvmThrowArrayIndexOutOfBoundsException(int index, int length);
+void dvmThrowArrayIndexOutOfBoundsException(int length, int index);
/*
* Throw an ArrayStoreException in the current thread, using the given classes'
static bool checkArrayElementBounds(ArrayObject* arrayObj, jsize index) {
assert(arrayObj != NULL);
if (index < 0 || index >= (int) arrayObj->length) {
- dvmThrowArrayIndexOutOfBoundsException(index, arrayObj->length);
+ dvmThrowArrayIndexOutOfBoundsException(arrayObj->length, index);
return false;
}
return true;
size = arrayData[2] | (((u4)arrayData[3]) << 16);
if (size > arrayObj->length) {
- dvmThrowArrayIndexOutOfBoundsException(size, arrayObj->length);
+ dvmThrowArrayIndexOutOfBoundsException(arrayObj->length, size);
return false;
}
copySwappedArrayData(arrayObj->contents, &arrayData[4], size, width);
/*
* Invalid array index. Note that our calling convention is strange; we use r1
* and r3 because those just happen to be the registers all our callers are
- * using. We shuffle them here before calling the C function.
+ * using. We move r3 before calling the C function, but r1 happens to match.
* r1: index
* r3: size
*/
common_errArrayIndex:
EXPORT_PC()
- mov r0, r1
- mov r1, r3
+ mov r0, r3
bl dvmThrowArrayIndexOutOfBoundsException
b common_exceptionThrown
GOTO_exceptionThrown();
if (GET_REGISTER(vsrc2) >= arrayObj->length) {
dvmThrowArrayIndexOutOfBoundsException(
- GET_REGISTER(vsrc2), arrayObj->length);
+ arrayObj->length, GET_REGISTER(vsrc2));
GOTO_exceptionThrown();
}
obj = (Object*) GET_REGISTER(vdst);
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
SET_REGISTER##_regsize(vdst, \
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
ILOGV("+ APUT[%d]=0x%08x", GET_REGISTER(vsrc2), GET_REGISTER(vdst));\
/*
* Invalid array index. Note that our calling convention is strange; we use r1
* and r3 because those just happen to be the registers all our callers are
- * using. We shuffle them here before calling the C function.
+ * using. We move r3 before calling the C function, but r1 happens to match.
* r1: index
* r3: size
*/
common_errArrayIndex:
EXPORT_PC()
- mov r0, r1
- mov r1, r3
+ mov r0, r3
bl dvmThrowArrayIndexOutOfBoundsException
b common_exceptionThrown
/*
* Invalid array index. Note that our calling convention is strange; we use r1
* and r3 because those just happen to be the registers all our callers are
- * using. We shuffle them here before calling the C function.
+ * using. We move r3 before calling the C function, but r1 happens to match.
* r1: index
* r3: size
*/
common_errArrayIndex:
EXPORT_PC()
- mov r0, r1
- mov r1, r3
+ mov r0, r3
bl dvmThrowArrayIndexOutOfBoundsException
b common_exceptionThrown
/*
* Invalid array index. Note that our calling convention is strange; we use r1
* and r3 because those just happen to be the registers all our callers are
- * using. We shuffle them here before calling the C function.
+ * using. We move r3 before calling the C function, but r1 happens to match.
* r1: index
* r3: size
*/
common_errArrayIndex:
EXPORT_PC()
- mov r0, r1
- mov r1, r3
+ mov r0, r3
bl dvmThrowArrayIndexOutOfBoundsException
b common_exceptionThrown
/*
* Invalid array index. Note that our calling convention is strange; we use r1
* and r3 because those just happen to be the registers all our callers are
- * using. We shuffle them here before calling the C function.
+ * using. We move r3 before calling the C function, but r1 happens to match.
* r1: index
* r3: size
*/
common_errArrayIndex:
EXPORT_PC()
- mov r0, r1
- mov r1, r3
+ mov r0, r3
bl dvmThrowArrayIndexOutOfBoundsException
b common_exceptionThrown
common_errArrayIndex:
EXPORT_PC
movl offArrayObject_length(%eax), %eax
- movl %ecx,OUT_ARG0(%esp)
- movl %eax,OUT_ARG1(%esp)
- call dvmThrowArrayIndexOutOfBoundsException # args (index, length)
+ movl %eax,OUT_ARG0(%esp)
+ movl %ecx,OUT_ARG1(%esp)
+ call dvmThrowArrayIndexOutOfBoundsException # args (length, index)
jmp common_exceptionThrown
/*
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
SET_REGISTER##_regsize(vdst, \
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
ILOGV("+ APUT[%d]=0x%08x", GET_REGISTER(vsrc2), GET_REGISTER(vdst));\
GOTO_exceptionThrown();
if (GET_REGISTER(vsrc2) >= arrayObj->length) {
dvmThrowArrayIndexOutOfBoundsException(
- GET_REGISTER(vsrc2), arrayObj->length);
+ arrayObj->length, GET_REGISTER(vsrc2));
GOTO_exceptionThrown();
}
obj = (Object*) GET_REGISTER(vdst);
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
SET_REGISTER##_regsize(vdst, \
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
ILOGV("+ APUT[%d]=0x%08x", GET_REGISTER(vsrc2), GET_REGISTER(vdst));\
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
SET_REGISTER##_regsize(vdst, \
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
ILOGV("+ APUT[%d]=0x%08x", GET_REGISTER(vsrc2), GET_REGISTER(vdst));\
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
SET_REGISTER##_regsize(vdst, \
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
ILOGV("+ APUT[%d]=0x%08x", GET_REGISTER(vsrc2), GET_REGISTER(vdst));\
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
SET_REGISTER##_regsize(vdst, \
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
ILOGV("+ APUT[%d]=0x%08x", GET_REGISTER(vsrc2), GET_REGISTER(vdst));\
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
SET_REGISTER##_regsize(vdst, \
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
ILOGV("+ APUT[%d]=0x%08x", GET_REGISTER(vsrc2), GET_REGISTER(vdst));\
GOTO_exceptionThrown();
if (GET_REGISTER(vsrc2) >= arrayObj->length) {
dvmThrowArrayIndexOutOfBoundsException(
- GET_REGISTER(vsrc2), arrayObj->length);
+ arrayObj->length, GET_REGISTER(vsrc2));
GOTO_exceptionThrown();
}
obj = (Object*) GET_REGISTER(vdst);
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
SET_REGISTER##_regsize(vdst, \
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
ILOGV("+ APUT[%d]=0x%08x", GET_REGISTER(vsrc2), GET_REGISTER(vdst));\
GOTO_exceptionThrown();
if (GET_REGISTER(vsrc2) >= arrayObj->length) {
dvmThrowArrayIndexOutOfBoundsException(
- GET_REGISTER(vsrc2), arrayObj->length);
+ arrayObj->length, GET_REGISTER(vsrc2));
GOTO_exceptionThrown();
}
obj = (Object*) GET_REGISTER(vdst);
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
SET_REGISTER##_regsize(vdst, \
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
ILOGV("+ APUT[%d]=0x%08x", GET_REGISTER(vsrc2), GET_REGISTER(vdst));\
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
SET_REGISTER##_regsize(vdst, \
GOTO_exceptionThrown(); \
if (GET_REGISTER(vsrc2) >= arrayObj->length) { \
dvmThrowArrayIndexOutOfBoundsException( \
- GET_REGISTER(vsrc2), arrayObj->length); \
+ arrayObj->length, GET_REGISTER(vsrc2)); \
GOTO_exceptionThrown(); \
} \
ILOGV("+ APUT[%d]=0x%08x", GET_REGISTER(vsrc2), GET_REGISTER(vdst));\
(md) Correct OP_MONITOR_EXIT (need to adjust PC before throw)
(md) OP_THROW needs to export the PC
-(md) Use dvmThrowArrayIndexOutOfBoundsException(index, length) for
+(md) Use dvmThrowArrayIndexOutOfBoundsException(length, index) for
array bounds errors.
(md) Use dvmThrowClassCastException(actual, desired) for class cast errors.
(md) Use dvmThrowArrayStoreException(actual, desired) for array store errors.
common_errArrayIndex:
EXPORT_PC
movl offArrayObject_length(%eax), %eax
- movl %ecx,OUT_ARG0(%esp)
- movl %eax,OUT_ARG1(%esp)
- call dvmThrowArrayIndexOutOfBoundsException # args (index, length)
+ movl %eax,OUT_ARG0(%esp)
+ movl %ecx,OUT_ARG1(%esp)
+ call dvmThrowArrayIndexOutOfBoundsException # args (length, index)
jmp common_exceptionThrown
/*