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

C2 should optimize explicit range checks

    XMLWordPrintable

Details

    • Enhancement
    • Resolution: Fixed
    • P3
    • 9
    • 9
    • hotspot
    • None
    • 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.

        Attachments

          Issue Links

            Activity

              People

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

                Dates

                  Created:
                  Updated:
                  Resolved: