24 */ |
24 */ |
25 |
25 |
26 /* |
26 /* |
27 * @test |
27 * @test |
28 * @summary tests on constant folding of unsafe get operations from stable arrays |
28 * @summary tests on constant folding of unsafe get operations from stable arrays |
29 * @library /testlibrary /test/lib |
29 * @library /testlibrary |
30 * @ignore 8151137 |
|
31 * |
30 * |
32 * @requires vm.flavor != "client" |
31 * @requires vm.flavor != "client" |
33 * |
32 * |
|
33 * @modules java.base/jdk.internal.vm.annotation |
|
34 * java.base/jdk.internal.misc |
|
35 |
34 * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions |
36 * @run main/bootclasspath -XX:+UnlockDiagnosticVMOptions |
35 * -Xbatch -XX:-TieredCompilation |
37 * -Xbatch -XX:-TieredCompilation |
36 * -XX:+FoldStableValues |
38 * -XX:+FoldStableValues |
37 * -XX:CompileCommand=dontinline,*Test::test* |
39 * -XX:CompileCommand=dontinline,*Test::test* |
38 * UnsafeGetStableArrayElement |
40 * compiler.unsafe.UnsafeGetStableArrayElement |
39 */ |
41 */ |
|
42 package compiler.unsafe; |
|
43 |
40 import jdk.internal.misc.Unsafe; |
44 import jdk.internal.misc.Unsafe; |
41 import jdk.internal.vm.annotation.Stable; |
45 import jdk.internal.vm.annotation.Stable; |
42 import java.util.concurrent.Callable; |
46 import java.util.concurrent.Callable; |
|
47 import jdk.test.lib.Platform; |
43 |
48 |
44 import static jdk.internal.misc.Unsafe.*; |
49 import static jdk.internal.misc.Unsafe.*; |
45 import static jdk.test.lib.Asserts.*; |
50 import static jdk.test.lib.Asserts.*; |
46 import static jdk.test.lib.Platform; |
|
47 |
51 |
48 public class UnsafeGetStableArrayElement { |
52 public class UnsafeGetStableArrayElement { |
49 @Stable static final boolean[] STABLE_BOOLEAN_ARRAY = new boolean[16]; |
53 @Stable static final boolean[] STABLE_BOOLEAN_ARRAY = new boolean[16]; |
50 @Stable static final byte[] STABLE_BYTE_ARRAY = new byte[16]; |
54 @Stable static final byte[] STABLE_BYTE_ARRAY = new byte[16]; |
51 @Stable static final short[] STABLE_SHORT_ARRAY = new short[8]; |
55 @Stable static final short[] STABLE_SHORT_ARRAY = new short[8]; |
217 static void testMismatched(Callable<?> c, Runnable setDefaultAction) throws Exception { |
221 static void testMismatched(Callable<?> c, Runnable setDefaultAction) throws Exception { |
218 run(c, null, setDefaultAction); |
222 run(c, null, setDefaultAction); |
219 Setter.reset(); |
223 Setter.reset(); |
220 } |
224 } |
221 |
225 |
222 public static void main(String[] args) throws Exception { |
226 static void testUnsafeAccess() throws Exception { |
223 if (Platform.isServer()) { |
|
224 test(); |
|
225 } |
|
226 } |
|
227 |
|
228 static void test() throws Exception { |
|
229 // boolean[], aligned accesses |
227 // boolean[], aligned accesses |
230 testMatched( Test::testZ_Z, Test::changeZ); |
228 testMatched( Test::testZ_Z, Test::changeZ); |
231 testMismatched(Test::testZ_B, Test::changeZ); |
229 testMismatched(Test::testZ_B, Test::changeZ); |
232 testMismatched(Test::testZ_S, Test::changeZ); |
230 testMismatched(Test::testZ_S, Test::changeZ); |
233 testMismatched(Test::testZ_C, Test::changeZ); |
231 testMismatched(Test::testZ_C, Test::changeZ); |