test/compiler/intrinsics/mathexact/sanity/IntrinsicBase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File 8130832-review Sdiff test/compiler/intrinsics/mathexact/sanity

test/compiler/intrinsics/mathexact/sanity/IntrinsicBase.java

Print this page
rev 8688 : 1234567: Invalid bug number
Summary: This is a local commit to reduce jprt submit time.
Reviewed-by: kvn


  50             case "compiled mode":
  51             case "mixed mode":
  52                 if (isServerVM()) {
  53                     if (TIERED_COMPILATION) {
  54                         int max_level = TIERED_STOP_AT_LEVEL;
  55                         expectedIntrinsicCount = (max_level == COMP_LEVEL_MAX) ? 1 : 0;
  56                         for (int i = CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE; i <= max_level; ++i) {
  57                             deoptimize();
  58                             compileAtLevel(i);
  59                         }
  60                     } else {
  61                         expectedIntrinsicCount = 1;
  62                         deoptimize();
  63                         compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_MAX);
  64                     }
  65                 } else {
  66                     deoptimize();
  67                     compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
  68                 }
  69 
  70                 if (!isIntrinsicSupported()) {
  71                     expectedIntrinsicCount = 0;
  72                 }
  73                 break;
  74             case "interpreted mode": //test is not applicable in this mode;
  75                 System.err.println("Warning: This test is not applicable in mode: " + MODE);
  76                 break;
  77             default:
  78                 throw new RuntimeException("Test bug, unknown VM mode: " + MODE);
  79         }
  80 
  81         System.out.println("Expected intrinsic count is " + expectedIntrinsicCount + " name " + getIntrinsicId());
  82 
  83         final FileOutputStream out = new FileOutputStream(getVMOption("LogFile") + Verifier.PROPERTY_FILE_SUFFIX);
  84         Properties expectedProps = new Properties();
  85         expectedProps.setProperty(Verifier.INTRINSIC_NAME_PROPERTY, getIntrinsicId());
  86         expectedProps.setProperty(Verifier.INTRINSIC_EXPECTED_COUNT_PROPERTY, String.valueOf(expectedIntrinsicCount));
  87         expectedProps.store(out, null);
  88 
  89         out.close();
  90     }


  97     }
  98 
  99     protected void compileAtLevel(int level) {
 100         WHITE_BOX.enqueueMethodForCompilation(method, level);
 101         waitBackgroundCompilation();
 102         checkCompilation(method, level);
 103     }
 104 
 105     protected void checkCompilation(Executable executable, int level) {
 106         if (!WHITE_BOX.isMethodCompiled(executable)) {
 107             throw new RuntimeException("Test bug, expected compilation (level): " + level + ", but not compiled");
 108         }
 109         final int compilationLevel = WHITE_BOX.getMethodCompilationLevel(executable);
 110         if (compilationLevel != level) {
 111             if (!(TIERED_COMPILATION && level == COMP_LEVEL_FULL_PROFILE && compilationLevel == COMP_LEVEL_LIMITED_PROFILE)) { //possible case
 112                 throw new RuntimeException("Test bug, expected compilation (level): " + level + ", but level: " + compilationLevel);
 113             }
 114         }
 115     }
 116 
 117     protected abstract boolean isIntrinsicSupported();




 118 
 119     protected abstract String getIntrinsicId();
 120 
 121     protected boolean isServerVM() {
 122         return javaVmName.toLowerCase().contains("server");
 123     }
 124 
 125     static class IntTest extends IntrinsicBase {



 126         protected IntTest(MathIntrinsic.IntIntrinsic testCase) {
 127             super(testCase);




 128         }
 129 
 130         @Override
 131         protected boolean isIntrinsicSupported() {
 132             return isServerVM() && Boolean.valueOf(useMathExactIntrinsics)
 133                 && (Platform.isX86() || Platform.isX64() || Platform.isAArch64());
 134         }
 135 
 136         @Override
 137         protected String getIntrinsicId() {
 138             return "_" + testCase.name().toLowerCase() + "ExactI";
 139         }
 140     }
 141 
 142     static class LongTest extends IntrinsicBase {



 143         protected LongTest(MathIntrinsic.LongIntrinsic testCase) {
 144             super(testCase);




 145         }
 146 
 147         @Override
 148         protected boolean isIntrinsicSupported() {
 149             return isServerVM() && Boolean.valueOf(useMathExactIntrinsics) &&
 150                 (Platform.isX64() || Platform.isPPC() || Platform.isAArch64());
 151         }
 152 
 153         @Override
 154         protected String getIntrinsicId() {
 155             return "_" + testCase.name().toLowerCase() + "ExactL";
 156         }
 157     }
 158 }


  50             case "compiled mode":
  51             case "mixed mode":
  52                 if (isServerVM()) {
  53                     if (TIERED_COMPILATION) {
  54                         int max_level = TIERED_STOP_AT_LEVEL;
  55                         expectedIntrinsicCount = (max_level == COMP_LEVEL_MAX) ? 1 : 0;
  56                         for (int i = CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE; i <= max_level; ++i) {
  57                             deoptimize();
  58                             compileAtLevel(i);
  59                         }
  60                     } else {
  61                         expectedIntrinsicCount = 1;
  62                         deoptimize();
  63                         compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_MAX);
  64                     }
  65                 } else {
  66                     deoptimize();
  67                     compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE);
  68                 }
  69 
  70                 if (!isIntrinsicAvailable()) {
  71                     expectedIntrinsicCount = 0;
  72                 }
  73                 break;
  74             case "interpreted mode": //test is not applicable in this mode;
  75                 System.err.println("Warning: This test is not applicable in mode: " + MODE);
  76                 break;
  77             default:
  78                 throw new RuntimeException("Test bug, unknown VM mode: " + MODE);
  79         }
  80 
  81         System.out.println("Expected intrinsic count is " + expectedIntrinsicCount + " name " + getIntrinsicId());
  82 
  83         final FileOutputStream out = new FileOutputStream(getVMOption("LogFile") + Verifier.PROPERTY_FILE_SUFFIX);
  84         Properties expectedProps = new Properties();
  85         expectedProps.setProperty(Verifier.INTRINSIC_NAME_PROPERTY, getIntrinsicId());
  86         expectedProps.setProperty(Verifier.INTRINSIC_EXPECTED_COUNT_PROPERTY, String.valueOf(expectedIntrinsicCount));
  87         expectedProps.store(out, null);
  88 
  89         out.close();
  90     }


  97     }
  98 
  99     protected void compileAtLevel(int level) {
 100         WHITE_BOX.enqueueMethodForCompilation(method, level);
 101         waitBackgroundCompilation();
 102         checkCompilation(method, level);
 103     }
 104 
 105     protected void checkCompilation(Executable executable, int level) {
 106         if (!WHITE_BOX.isMethodCompiled(executable)) {
 107             throw new RuntimeException("Test bug, expected compilation (level): " + level + ", but not compiled");
 108         }
 109         final int compilationLevel = WHITE_BOX.getMethodCompilationLevel(executable);
 110         if (compilationLevel != level) {
 111             if (!(TIERED_COMPILATION && level == COMP_LEVEL_FULL_PROFILE && compilationLevel == COMP_LEVEL_LIMITED_PROFILE)) { //possible case
 112                 throw new RuntimeException("Test bug, expected compilation (level): " + level + ", but level: " + compilationLevel);
 113             }
 114         }
 115     }
 116 
 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();
 122 
 123     protected abstract String getIntrinsicId();
 124 
 125     protected boolean isServerVM() {
 126         return javaVmName.toLowerCase().contains("server");
 127     }
 128 
 129     static class IntTest extends IntrinsicBase {
 130 
 131         protected boolean isIntrinsicAvailable; // The tested intrinsic is available on the current platform.
 132 
 133         protected IntTest(MathIntrinsic.IntIntrinsic 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.isIntrinsicAvailableForMethod(testCase.getTestMethod(),
 138                                                                            COMP_LEVEL_FULL_OPTIMIZATION);
 139         }
 140 
 141         @Override
 142         protected boolean isIntrinsicAvailable() {
 143             return isIntrinsicAvailable;

 144         }
 145 
 146         @Override
 147         protected String getIntrinsicId() {
 148             return "_" + testCase.name().toLowerCase() + "ExactI";
 149         }
 150     }
 151 
 152     static class LongTest extends IntrinsicBase {
 153 
 154         protected boolean isIntrinsicAvailable; // The tested intrinsic is available on the current platform.
 155 
 156         protected LongTest(MathIntrinsic.LongIntrinsic 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.isIntrinsicAvailableForMethod(testCase.getTestMethod(),
 161                                                                            COMP_LEVEL_FULL_OPTIMIZATION);
 162         }
 163 
 164         @Override
 165         protected boolean isIntrinsicAvailable() {
 166             return isIntrinsicAvailable;

 167         }
 168 
 169         @Override
 170         protected String getIntrinsicId() {
 171             return "_" + testCase.name().toLowerCase() + "ExactL";
 172         }
 173     }
 174 }
test/compiler/intrinsics/mathexact/sanity/IntrinsicBase.java
Index Unified diffs Context diffs Sdiffs Patch New Old Previous File Next File