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

UnsafeGetStableArrayElement should account for different JIT implementation details

    XMLWordPrintable

    Details

    • Subcomponent:
    • Resolved In Build:
      b16

      Description

      The UnsafeGetStableArrayElement jtreg tests fails on GraalVM because it asserts semantics implemented by C1 and C2 that are beyond the spec of @Stable. In particular, it asserts that the JIT will not constant fold an unsafe read of a stable array element if the type of the read does not match the type of the array element. For example:

      @Stable static final byte[] STABLE_BYTE_ARRAY = {Byte.MAX_VALUE, 0, 0, 0};
      @Stable static final int[] STABLE_INT_ARRAY = {Integer.MAX_VALUE, 0, 0, 0};

      unsafe.getInt(STABLE_BYTE_ARRAY, ARRAY_BYTE_BASE_OFFSET);
      unsafe.getByte(STABLE_INT_ARRAY, ARRAY_INT_BASE_OFFSET);

      The Graal compiler will constant fold these reads where as C1 and C2 will not. Both implementations are permissible. There are no predictability guarantees about constant-folding provided by Stable and it's perfectly fine not to optimize stable fields/arrays at all.

      The test should be modified to take into account the JIT being used when deciding what is to be asserted.

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              dnsimon Douglas Simon
              Reporter:
              dnsimon Douglas Simon
              Votes:
              0 Vote for this issue
              Watchers:
              4 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved: