< prev index next >

test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java

Print this page

233      */
234     private static void runTestsOnSameVM(Class<?> testClass) {
235         if (testClass == null) {
236             StackWalker walker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
237             testClass = walker.getCallerClass();
238         }
239         TestVM framework = new TestVM(testClass);
240         framework.start();
241     }
242 
243     /**
244      * Once everything is initialized and set up, start collecting tests and executing them afterwards.
245      */
246     private void start() {
247         setupTests();
248         checkForcedCompilationsCompleted();
249         runTests();
250     }
251 
252     private void setupTests() {
253         for (Class<?> clazz : testClass.getDeclaredClasses()) {
254             checkAnnotationsInClass(clazz, "inner");



255         }
256         if (DUMP_REPLAY) {
257             addReplay();
258         }
259         // Make sure to first setup test methods and make them non-inlineable and only then process compile commands.
260         setupDeclaredTests();
261         processControlAnnotations(testClass);
262         processHelperClasses();
263         setupCheckedAndCustomRunTests();
264 
265         // All remaining tests are simple base tests without check or specific way to run them.
266         addBaseTests();
267         if (PRINT_VALID_IR_RULES) {
268             irMatchRulePrinter.emit();
269         }
270         TestFormat.throwIfAnyFailures();
271         declaredTests.clear();
272         testMethodMap.clear();
273     }
274 

874         WHITE_BOX.deoptimizeMethod(m);
875     }
876 
877     public static boolean isCompiled(Method m) {
878         return compiledAtLevel(m, CompLevel.ANY) == TriState.Yes;
879     }
880 
881     public static boolean isC1Compiled(Method m) {
882         return compiledByC1(m) == TriState.Yes;
883     }
884 
885     public static boolean isC2Compiled(Method m) {
886         return compiledByC2(m) == TriState.Yes;
887     }
888 
889     public static boolean isCompiledAtLevel(Method m, CompLevel compLevel) {
890         return compiledAtLevel(m, compLevel) == TriState.Yes;
891     }
892 
893     public static void assertDeoptimizedByC1(Method m) {
894         if (notUnstableDeoptAssertion(m, CompLevel.C1_SIMPLE)) {
895             TestRun.check(compiledByC1(m) != TriState.Yes || PER_METHOD_TRAP_LIMIT == 0 || !PROFILE_INTERPRETER,
896                           m + " should have been deoptimized by C1");
897         }
898     }
899 
900     public static void assertDeoptimizedByC2(Method m) {
901         if (notUnstableDeoptAssertion(m, CompLevel.C2)) {
902             TestRun.check(compiledByC2(m) != TriState.Yes || PER_METHOD_TRAP_LIMIT == 0 || !PROFILE_INTERPRETER,
903                           m + " should have been deoptimized by C2");
904         }
905     }
906 
907     /**
908      * Some VM flags could make the deopt assertions unstable.
909      */
910     private static boolean notUnstableDeoptAssertion(Method m, CompLevel level) {
911         return (USE_COMPILER && !XCOMP && !IGNORE_COMPILER_CONTROLS && !TEST_C1 &&
912                 (!EXCLUDE_RANDOM || WHITE_BOX.isMethodCompilable(m, level.getValue(), false)));
913     }
914 
915     public static void assertCompiledByC1(Method m) {
916         TestRun.check(compiledByC1(m) != TriState.No, m + " should have been C1 compiled");
917     }
918 
919     public static void assertCompiledByC2(Method m) {
920         TestRun.check(compiledByC2(m) != TriState.No, m + " should have been C2 compiled");
921     }
922 
923     public static void assertCompiledAtLevel(Method m, CompLevel level) {
924         TestRun.check(compiledAtLevel(m, level) != TriState.No, m + " should have been compiled at level " + level.name());
925     }
926 
927     public static void assertNotCompiled(Method m) {
928         TestRun.check(!isC1Compiled(m), m + " should not have been compiled by C1");
929         TestRun.check(!isC2Compiled(m), m + " should not have been compiled by C2");
930     }

233      */
234     private static void runTestsOnSameVM(Class<?> testClass) {
235         if (testClass == null) {
236             StackWalker walker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
237             testClass = walker.getCallerClass();
238         }
239         TestVM framework = new TestVM(testClass);
240         framework.start();
241     }
242 
243     /**
244      * Once everything is initialized and set up, start collecting tests and executing them afterwards.
245      */
246     private void start() {
247         setupTests();
248         checkForcedCompilationsCompleted();
249         runTests();
250     }
251 
252     private void setupTests() {
253         // TODO remove this once JDK-8273591 is fixed
254         if (!IGNORE_COMPILER_CONTROLS) {
255             for (Class<?> clazz : testClass.getDeclaredClasses()) {
256                 checkAnnotationsInClass(clazz, "inner");
257             }
258         }
259         if (DUMP_REPLAY) {
260             addReplay();
261         }
262         // Make sure to first setup test methods and make them non-inlineable and only then process compile commands.
263         setupDeclaredTests();
264         processControlAnnotations(testClass);
265         processHelperClasses();
266         setupCheckedAndCustomRunTests();
267 
268         // All remaining tests are simple base tests without check or specific way to run them.
269         addBaseTests();
270         if (PRINT_VALID_IR_RULES) {
271             irMatchRulePrinter.emit();
272         }
273         TestFormat.throwIfAnyFailures();
274         declaredTests.clear();
275         testMethodMap.clear();
276     }
277 

877         WHITE_BOX.deoptimizeMethod(m);
878     }
879 
880     public static boolean isCompiled(Method m) {
881         return compiledAtLevel(m, CompLevel.ANY) == TriState.Yes;
882     }
883 
884     public static boolean isC1Compiled(Method m) {
885         return compiledByC1(m) == TriState.Yes;
886     }
887 
888     public static boolean isC2Compiled(Method m) {
889         return compiledByC2(m) == TriState.Yes;
890     }
891 
892     public static boolean isCompiledAtLevel(Method m, CompLevel compLevel) {
893         return compiledAtLevel(m, compLevel) == TriState.Yes;
894     }
895 
896     public static void assertDeoptimizedByC1(Method m) {
897         if (isStableDeopt(m, CompLevel.C1_SIMPLE)) {
898             TestRun.check(compiledByC1(m) != TriState.Yes || PER_METHOD_TRAP_LIMIT == 0 || !PROFILE_INTERPRETER,
899                           m + " should have been deoptimized by C1");
900         }
901     }
902 
903     public static void assertDeoptimizedByC2(Method m) {
904         if (isStableDeopt(m, CompLevel.C2)) {
905             TestRun.check(compiledByC2(m) != TriState.Yes || PER_METHOD_TRAP_LIMIT == 0 || !PROFILE_INTERPRETER,
906                           m + " should have been deoptimized by C2");
907         }
908     }
909 
910     /**
911      * Some VM flags could make the deopt assertions unstable.
912      */
913     public static boolean isStableDeopt(Method m, CompLevel level) {
914         return (USE_COMPILER && !XCOMP && !IGNORE_COMPILER_CONTROLS && !TEST_C1 &&
915                 (!EXCLUDE_RANDOM || WHITE_BOX.isMethodCompilable(m, level.getValue(), false)));
916     }
917 
918     public static void assertCompiledByC1(Method m) {
919         TestRun.check(compiledByC1(m) != TriState.No, m + " should have been C1 compiled");
920     }
921 
922     public static void assertCompiledByC2(Method m) {
923         TestRun.check(compiledByC2(m) != TriState.No, m + " should have been C2 compiled");
924     }
925 
926     public static void assertCompiledAtLevel(Method m, CompLevel level) {
927         TestRun.check(compiledAtLevel(m, level) != TriState.No, m + " should have been compiled at level " + level.name());
928     }
929 
930     public static void assertNotCompiled(Method m) {
931         TestRun.check(!isC1Compiled(m), m + " should not have been compiled by C1");
932         TestRun.check(!isC2Compiled(m), m + " should not have been compiled by C2");
933     }
< prev index next >