hotspot/test/compiler/unsafe/UnsafeGetStableArrayElement.java
changeset 38030 93f24e7b3c43
parent 36617 390e8993b88e
child 38188 e76af590ea2f
equal deleted inserted replaced
38029:c645d414429f 38030:93f24e7b3c43
    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);
   327         run(Test::testL_S);
   325         run(Test::testL_S);
   328         run(Test::testL_C);
   326         run(Test::testL_C);
   329         run(Test::testL_I);
   327         run(Test::testL_I);
   330         run(Test::testL_F);
   328         run(Test::testL_F);
   331     }
   329     }
       
   330 
       
   331     public static void main(String[] args) throws Exception {
       
   332         if (Platform.isServer()) {
       
   333             testUnsafeAccess();
       
   334         }
       
   335         System.out.println("TEST PASSED");
       
   336     }
   332 }
   337 }