Skip to content

Commit

Permalink
8264135: UnsafeGetStableArrayElement should account for different JIT…
Browse files Browse the repository at this point in the history
… implementation details

Reviewed-by: vlivanov, never
  • Loading branch information
Doug Simon committed Mar 26, 2021
1 parent bb354b9 commit 5a930c4
Showing 1 changed file with 18 additions and 5 deletions.
Expand Up @@ -25,15 +25,17 @@
* @test
* @summary tests on constant folding of unsafe get operations from stable arrays
* @library /test/lib
*
* @build sun.hotspot.WhiteBox
* @requires vm.flavor == "server" & !vm.emulatedClient
*
* @modules java.base/jdk.internal.vm.annotation
* java.base/jdk.internal.misc
* @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox
*
* @run main/bootclasspath/othervm -XX:+UnlockDiagnosticVMOptions
* -Xbatch -XX:-TieredCompilation
* -XX:+FoldStableValues
* -XX:+WhiteBoxAPI
* -XX:CompileCommand=dontinline,*Test::test*
* compiler.unsafe.UnsafeGetStableArrayElement
*/
Expand All @@ -50,6 +52,8 @@
import static jdk.test.lib.Asserts.assertEQ;
import static jdk.test.lib.Asserts.assertNE;

import sun.hotspot.code.Compiler;

public class UnsafeGetStableArrayElement {
@Stable static final boolean[] STABLE_BOOLEAN_ARRAY = new boolean[16];
@Stable static final byte[] STABLE_BYTE_ARRAY = new byte[16];
Expand Down Expand Up @@ -220,7 +224,16 @@ static void testMatched(Callable<?> c, Runnable setDefaultAction) throws Excepti
}

static void testMismatched(Callable<?> c, Runnable setDefaultAction) throws Exception {
run(c, null, setDefaultAction);
testMismatched(c, setDefaultAction, false);
}

static void testMismatched(Callable<?> c, Runnable setDefaultAction, boolean objectArray) throws Exception {
if (Compiler.isGraalEnabled() && !objectArray) {
// Graal will constant fold mismatched reads from primitive stable arrays
run(c, setDefaultAction, null);
} else {
run(c, null, setDefaultAction);
}
Setter.reset();
}

Expand Down Expand Up @@ -306,8 +319,8 @@ static void testUnsafeAccess() throws Exception {
testMatched( Test::testD_D, Test::changeD);

// Object[], aligned accesses
testMismatched(Test::testL_J, Test::changeL); // long & double are always as large as an OOP
testMismatched(Test::testL_D, Test::changeL);
testMismatched(Test::testL_J, Test::changeL, true); // long & double are always as large as an OOP
testMismatched(Test::testL_D, Test::changeL, true);
testMatched( Test::testL_L, Test::changeL);

// Unaligned accesses
Expand Down

1 comment on commit 5a930c4

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.