hotspot/test/compiler/intrinsics/mathexact/sanity/IntrinsicBase.java
changeset 31962 d05e0a4d1b43
parent 30761 ce08cd63451f
child 34155 8d9e0cbf93a2
equal deleted inserted replaced
31961:70adcff5840c 31962:d05e0a4d1b43
    65                 } else {
    65                 } else {
    66                     deoptimize();
    66                     deoptimize();
    67                     compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
    67                     compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
    68                 }
    68                 }
    69 
    69 
    70                 if (!isIntrinsicSupported()) {
    70                 if (!isIntrinsicAvailable()) {
    71                     expectedIntrinsicCount = 0;
    71                     expectedIntrinsicCount = 0;
    72                 }
    72                 }
    73                 break;
    73                 break;
    74             case "interpreted mode": //test is not applicable in this mode;
    74             case "interpreted mode": //test is not applicable in this mode;
    75                 System.err.println("Warning: This test is not applicable in mode: " + MODE);
    75                 System.err.println("Warning: This test is not applicable in mode: " + MODE);
   112                 throw new RuntimeException("Test bug, expected compilation (level): " + level + ", but level: " + compilationLevel);
   112                 throw new RuntimeException("Test bug, expected compilation (level): " + level + ", but level: " + compilationLevel);
   113             }
   113             }
   114         }
   114         }
   115     }
   115     }
   116 
   116 
   117     protected abstract boolean isIntrinsicSupported();
   117     // An intrinsic is available if:
       
   118     // - the intrinsic is enabled (by using the appropriate command-line flag) and
       
   119     // - the intrinsic is supported by the VM (i.e., the platform on which the VM is
       
   120     //   running provides the instructions necessary for the VM to generate the intrinsic).
       
   121     protected abstract boolean isIntrinsicAvailable();
   118 
   122 
   119     protected abstract String getIntrinsicId();
   123     protected abstract String getIntrinsicId();
   120 
   124 
   121     protected boolean isServerVM() {
   125     protected boolean isServerVM() {
   122         return javaVmName.toLowerCase().contains("server");
   126         return javaVmName.toLowerCase().contains("server");
   123     }
   127     }
   124 
   128 
   125     static class IntTest extends IntrinsicBase {
   129     static class IntTest extends IntrinsicBase {
       
   130 
       
   131         protected boolean isIntrinsicAvailable; // The tested intrinsic is available on the current platform.
       
   132 
   126         protected IntTest(MathIntrinsic.IntIntrinsic testCase) {
   133         protected IntTest(MathIntrinsic.IntIntrinsic testCase) {
   127             super(testCase);
   134             super(testCase);
       
   135             // Only the C2 compiler intrinsifies exact math methods
       
   136             // so check if the intrinsics are available with C2.
       
   137             isIntrinsicAvailable = WHITE_BOX.isIntrinsicAvailable(testCase.getTestMethod(),
       
   138                                                                   COMP_LEVEL_FULL_OPTIMIZATION);
   128         }
   139         }
   129 
   140 
   130         @Override
   141         @Override
   131         protected boolean isIntrinsicSupported() {
   142         protected boolean isIntrinsicAvailable() {
   132             return isServerVM() && Boolean.valueOf(useMathExactIntrinsics)
   143             return isIntrinsicAvailable;
   133                 && (Platform.isX86() || Platform.isX64() || Platform.isAArch64());
       
   134         }
   144         }
   135 
   145 
   136         @Override
   146         @Override
   137         protected String getIntrinsicId() {
   147         protected String getIntrinsicId() {
   138             return "_" + testCase.name().toLowerCase() + "ExactI";
   148             return "_" + testCase.name().toLowerCase() + "ExactI";
   139         }
   149         }
   140     }
   150     }
   141 
   151 
   142     static class LongTest extends IntrinsicBase {
   152     static class LongTest extends IntrinsicBase {
       
   153 
       
   154         protected boolean isIntrinsicAvailable; // The tested intrinsic is available on the current platform.
       
   155 
   143         protected LongTest(MathIntrinsic.LongIntrinsic testCase) {
   156         protected LongTest(MathIntrinsic.LongIntrinsic testCase) {
   144             super(testCase);
   157             super(testCase);
       
   158             // Only the C2 compiler intrinsifies exact math methods
       
   159             // so check if the intrinsics are available with C2.
       
   160             isIntrinsicAvailable = WHITE_BOX.isIntrinsicAvailable(testCase.getTestMethod(),
       
   161                                                                   COMP_LEVEL_FULL_OPTIMIZATION);
   145         }
   162         }
   146 
   163 
   147         @Override
   164         @Override
   148         protected boolean isIntrinsicSupported() {
   165         protected boolean isIntrinsicAvailable() {
   149             return isServerVM() && Boolean.valueOf(useMathExactIntrinsics) &&
   166             return isIntrinsicAvailable;
   150                 (Platform.isX64() || Platform.isPPC() || Platform.isAArch64());
       
   151         }
   167         }
   152 
   168 
   153         @Override
   169         @Override
   154         protected String getIntrinsicId() {
   170         protected String getIntrinsicId() {
   155             return "_" + testCase.name().toLowerCase() + "ExactL";
   171             return "_" + testCase.name().toLowerCase() + "ExactL";