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

Make intrinsic some or all check index/range methods

    XMLWordPrintable

Details

    • b96

    Description

      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 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

          Activity

            People

              roland Roland Westrelin
              psandoz Paul Sandoz
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: