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

Make intrinsic some or all check index/range methods

    Details

    • Subcomponent:
    • Resolved In Build:
      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.

        Issue Links

          Activity

          Hide
          roland Roland Westrelin added a comment -
          No regression test: this affects code generation and so is hard to observe from a java test case.
          Show
          roland Roland Westrelin added a comment - No regression test: this affects code generation and so is hard to observe from a java test case.
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/hs-comp/jdk/rev/8cb7f8165fbd
          User: roland
          Date: 2015-11-16 13:40:39 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/hs-comp/jdk/rev/8cb7f8165fbd User: roland Date: 2015-11-16 13:40:39 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/rev/af5d7716ac09
          User: roland
          Date: 2015-11-16 13:40:40 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/hs-comp/hotspot/rev/af5d7716ac09 User: roland Date: 2015-11-16 13:40:40 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/af5d7716ac09
          User: lana
          Date: 2015-12-10 00:26:59 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/hotspot/rev/af5d7716ac09 User: lana Date: 2015-12-10 00:26:59 +0000
          Hide
          hgupdate HG Updates added a comment -
          URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/8cb7f8165fbd
          User: lana
          Date: 2015-12-10 00:27:01 +0000
          Show
          hgupdate HG Updates added a comment - URL: http://hg.openjdk.java.net/jdk9/jdk9/jdk/rev/8cb7f8165fbd User: lana Date: 2015-12-10 00:27:01 +0000

            People

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

              Dates

              • Created:
                Updated:
                Resolved: