RFR: 8264135: UnsafeGetStableArrayElement should account for different JIT implementation details
Vladimir Ivanov
vlivanov at openjdk.java.net
Wed Mar 24 21:22:40 UTC 2021
On Wed, 24 Mar 2021 21:03:15 GMT, Doug Simon <dnsimon at openjdk.org> wrote:
> 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.
I suggest to leave `testUnsafeAccess()` intact and adjust `testMatched`/`testMismatched` to take into account whether `Compiler.isGraalEnabled() == true` or not.
-------------
PR: https://git.openjdk.java.net/jdk/pull/3180
More information about the hotspot-compiler-dev
mailing list