JDK-8073480 : C2 should optimize explicit range checks
  • Type: Enhancement
  • Component: hotspot
  • Sub-Component: compiler
  • Affected Version: 9
  • Priority: P3
  • Status: Resolved
  • Resolution: Fixed
  • Submitted: 2015-02-19
  • Updated: 2024-03-26
  • Resolved: 2015-03-20
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 9
9 b64Fixed
Related Reports
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Relates :  
Description
See JDK-8042997

Consider the following code:

   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 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. 
Comments
URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/f5fae6f265e2 User: lana Date: 2015-05-13 21:19:48 +0000
13-05-2015

URL: http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/rev/f5fae6f265e2 User: roland Date: 2015-03-20 00:58:42 +0000
20-03-2015