Unsigned comparison for array bounds check.
The interpreter calls Array::IsValidIndex for aget/aput instructions. Instead
of doing two signed comparisons, we now do one unsigned comparison. The Quick
and Portable compilers already do this.
Change-Id: I635a1a3cc8a793fd2ceaf1432d3b3f712d8e85bf
diff --git a/runtime/mirror/array.h b/runtime/mirror/array.h
index b195a87..db6132d 100644
--- a/runtime/mirror/array.h
+++ b/runtime/mirror/array.h
@@ -72,7 +72,7 @@
bool IsValidIndex(int32_t index) const
SHARED_LOCKS_REQUIRED(Locks::mutator_lock_) {
- if (UNLIKELY(index < 0 || index >= GetLength())) {
+ if (UNLIKELY(static_cast<uint32_t>(index) >= static_cast<uint32_t>(GetLength()))) {
ThrowArrayIndexOutOfBoundsException(index);
return false;
}