RFR: 8264135: UnsafeGetStableArrayElement should account for different JIT implementation details

Doug Simon dnsimon at openjdk.java.net
Wed Mar 24 21:08:56 UTC 2021


The `UnsafeGetStableArrayElement` test fails on GraalVM because it asserts implementation specific behavior of C1 and C2. 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.

This PR modifies the test to take into account the JIT being used when deciding what to assert.

-------------

Commit messages:
 - 8264135: UnsafeGetStableArrayElement should account for different JIT implementation details

Changes: https://git.openjdk.java.net/jdk/pull/3180/files
 Webrev: https://webrevs.openjdk.java.net/?repo=jdk&pr=3180&range=00
  Issue: https://bugs.openjdk.java.net/browse/JDK-8264135
  Stats: 86 lines in 1 file changed: 6 ins; 1 del; 79 mod
  Patch: https://git.openjdk.java.net/jdk/pull/3180.diff
  Fetch: git fetch https://git.openjdk.java.net/jdk pull/3180/head:pull/3180

PR: https://git.openjdk.java.net/jdk/pull/3180


More information about the hotspot-compiler-dev mailing list