Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8073480

C2 should optimize explicit range checks

    Details

    • Type: Enhancement
    • Status: Resolved
    • Priority: P3
    • Resolution: Fixed
    • Affects Version/s: 9
    • Fix Version/s: 9
    • Component/s: hotspot
    • Labels:
      None
    • Subcomponent:
    • Resolved In Build:
      b64

      Backports

        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.

          Issue Links

            Activity

            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/rev/f5fae6f265e2
            User: roland
            Date: 2015-03-20 00:58:42 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/rev/f5fae6f265e2 User: roland Date: 2015-03-20 00:58:42 +0000
            Hide
            hgupdate HG Updates added a comment -
            URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/f5fae6f265e2
            User: lana
            Date: 2015-05-13 21:19:48 +0000
            Show
            hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/f5fae6f265e2 User: lana Date: 2015-05-13 21:19:48 +0000

              People

              • Assignee:
                roland Roland Westrelin
                Reporter:
                roland Roland Westrelin
              • Votes:
                0 Vote for this issue
                Watchers:
                2 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: