Details
-
Enhancement
-
Resolution: Fixed
-
P3
-
None
-
b96
Description
static void setVolatile(ArrayRefHandle handle, Object[] array, int index,
Object value) {
if (index < 0 || index >= array.length) // bounds and null check
throw new ArrayIndexOutOfBoundsException();
UNSAFE.putObjectVolatile(array,
(((long) index) << handle.ashift) + handle.abase,
castReference(handle.componentType, value));
}
For such a user written range test the compiler does not fully recognize an array access is going on and so certain optimizations tend not to kick in, such as removing or strength reducing range checks, treating "index" as an unsigned value as opposed to a signed value, or coalescing write barriers when loop unrolling.
In addition to such user written ranges being detected and optimized by the compiler it would be useful to have intrinsic methods such as:
rangeCheck(Object[]/int[]/long[]... array, int index)
and the optimizer should generate similar code in both cases.
Ideally the same form of machine code (minus the differences in form of access) should be generated as if an aaload/aastore access was performed.
Attachments
Issue Links
- is blocked by
-
JDK-8135248 Add utility methods to check indexes and ranges
- Resolved
- relates to
-
JDK-8003585 strength reduce or eliminate range checks for power-of-two sized arrays
- Resolved
-
JDK-8074383 Redundant "compare" in generated code for String.charAt bounds checks
- Resolved
-
JDK-8206932 Add utility methods to check machine word indexes and ranges
- New
-
JDK-8080588 VarHandles development
- Resolved
-
JDK-8073480 C2 should optimize explicit range checks
- Resolved
-
JDK-8256730 Code that uses Object.checkIndex() range checks doesn't optimize well
- Resolved