diff test/compiler/whitebox/CompilerWhiteBoxTest.java @ 14909:4ca6dc0799b6

Backout jdk9 merge
author Gilles Duboscq <duboscq@ssw.jku.at>
date Tue, 01 Apr 2014 13:57:07 +0200
parents f9a4b59ae350
children 52b4284cb496
line wrap: on
line diff
--- a/test/compiler/whitebox/CompilerWhiteBoxTest.java	Tue Apr 01 14:09:03 2014 +0200
+++ b/test/compiler/whitebox/CompilerWhiteBoxTest.java	Tue Apr 01 13:57:07 2014 +0200
@@ -31,7 +31,6 @@
 import java.lang.reflect.Method;
 import java.util.Objects;
 import java.util.concurrent.Callable;
-import java.util.function.Function;
 
 /**
  * Abstract class for WhiteBox testing of JIT.
@@ -51,7 +50,7 @@
     protected static int COMP_LEVEL_FULL_PROFILE = 3;
     /** {@code CompLevel::CompLevel_full_optimization} -- C2 or Shark */
     protected static int COMP_LEVEL_FULL_OPTIMIZATION = 4;
-    /** Maximal value for CompLevel */
+    /** Maximal value for CompLeveL */
     protected static int COMP_LEVEL_MAX = COMP_LEVEL_FULL_OPTIMIZATION;
 
     /** Instance of WhiteBox */
@@ -76,7 +75,8 @@
     /** count of invocation to triger OSR compilation */
     protected static final long BACKEDGE_THRESHOLD;
     /** Value of {@code java.vm.info} (interpreted|mixed|comp mode) */
-    protected static final String MODE = System.getProperty("java.vm.info");
+    protected static final String MODE
+            = System.getProperty("java.vm.info");
 
     static {
         if (TIERED_COMPILATION) {
@@ -133,20 +133,6 @@
         return compLevel == COMP_LEVEL_FULL_OPTIMIZATION;
     }
 
-    protected static void main(
-            Function<TestCase, CompilerWhiteBoxTest> constructor,
-            String[] args) {
-        if (args.length == 0) {
-            for (TestCase test : SimpleTestCase.values()) {
-                constructor.apply(test).runTest();
-            }
-        } else {
-            for (String name : args) {
-                constructor.apply(SimpleTestCase.valueOf(name)).runTest();
-            }
-        }
-    }
-
     /** tested method */
     protected final Executable method;
     protected final TestCase testCase;
@@ -159,7 +145,7 @@
     protected CompilerWhiteBoxTest(TestCase testCase) {
         Objects.requireNonNull(testCase);
         System.out.println("TEST CASE:" + testCase.name());
-        method = testCase.getExecutable();
+        method = testCase.executable;
         this.testCase = testCase;
     }
 
@@ -218,7 +204,7 @@
         if (WHITE_BOX.getMethodCompilationLevel(method, true) != 0) {
             throw new RuntimeException(method + " osr_comp_level must be == 0");
         }
-    }
+   }
 
     /**
      * Checks, that {@linkplain #method} is compiled.
@@ -235,46 +221,44 @@
                     method, System.currentTimeMillis() - start);
             return;
         }
-        if (!WHITE_BOX.isMethodCompiled(method, testCase.isOsr())) {
+        if (!WHITE_BOX.isMethodCompiled(method, testCase.isOsr)) {
             throw new RuntimeException(method + " must be "
-                    + (testCase.isOsr() ? "osr_" : "") + "compiled");
+                    + (testCase.isOsr ? "osr_" : "") + "compiled");
         }
-        if (WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr())
-                == 0) {
+        if (WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr) == 0) {
             throw new RuntimeException(method
-                    + (testCase.isOsr() ? " osr_" : " ")
+                    + (testCase.isOsr ? " osr_" : " ")
                     + "comp_level must be != 0");
         }
     }
 
     protected final void deoptimize() {
-        WHITE_BOX.deoptimizeMethod(method, testCase.isOsr());
-        if (testCase.isOsr()) {
+        WHITE_BOX.deoptimizeMethod(method, testCase.isOsr);
+        if (testCase.isOsr) {
             WHITE_BOX.deoptimizeMethod(method, false);
         }
     }
 
     protected final int getCompLevel() {
-        return WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr());
+        return WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr);
     }
 
     protected final boolean isCompilable() {
         return WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY,
-                testCase.isOsr());
+                testCase.isOsr);
     }
 
     protected final boolean isCompilable(int compLevel) {
-        return WHITE_BOX
-                .isMethodCompilable(method, compLevel, testCase.isOsr());
+        return WHITE_BOX.isMethodCompilable(method, compLevel, testCase.isOsr);
     }
 
     protected final void makeNotCompilable() {
         WHITE_BOX.makeMethodNotCompilable(method, COMP_LEVEL_ANY,
-                testCase.isOsr());
+                testCase.isOsr);
     }
 
     protected final void makeNotCompilable(int compLevel) {
-        WHITE_BOX.makeMethodNotCompilable(method, compLevel, testCase.isOsr());
+        WHITE_BOX.makeMethodNotCompilable(method, compLevel, testCase.isOsr);
     }
 
     /**
@@ -314,7 +298,7 @@
                 WHITE_BOX.isMethodCompiled(method, true));
         System.out.printf("\tosr_comp_level:\t%d%n",
                 WHITE_BOX.getMethodCompilationLevel(method, true));
-        System.out.printf("\tin_queue:\t%b%n",
+         System.out.printf("\tin_queue:\t%b%n",
                 WHITE_BOX.isMethodQueuedForCompilation(method));
         System.out.printf("compile_queues_size:\t%d%n%n",
                 WHITE_BOX.getCompileQueuesSize());
@@ -327,13 +311,13 @@
 
     /**
      * Tries to trigger compilation of {@linkplain #method} by call
-     * {@linkplain TestCase#getCallable()} enough times.
+     * {@linkplain #testCase.callable} enough times.
      *
      * @return accumulated result
      * @see #compile(int)
      */
     protected final int compile() {
-        if (testCase.isOsr()) {
+        if (testCase.isOsr) {
             return compile(1);
         } else {
             return compile(THRESHOLD);
@@ -342,7 +326,7 @@
 
     /**
      * Tries to trigger compilation of {@linkplain #method} by call
-     * {@linkplain TestCase#getCallable()} specified times.
+     * {@linkplain #testCase.callable} specified times.
      *
      * @param count invocation count
      * @return accumulated result
@@ -352,7 +336,7 @@
         Integer tmp;
         for (int i = 0; i < count; ++i) {
             try {
-                tmp = testCase.getCallable().call();
+                tmp = testCase.callable.call();
             } catch (Exception e) {
                 tmp = null;
             }
@@ -363,32 +347,19 @@
         }
         return result;
     }
-
-    /**
-     * Utility interface provides tested method and object to invoke it.
-     */
-    public interface TestCase {
-        /** the name of test case */
-        String name();
-
-        /** tested method */
-        Executable getExecutable();
-
-        /** object to invoke {@linkplain #getExecutable()} */
-        Callable<Integer> getCallable();
-
-        /** flag for OSR test case */
-        boolean isOsr();
-    }
 }
 
-enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
+/**
+ * Utility structure containing tested method and object to invoke it.
+ */
+enum TestCase {
     /** constructor test case */
     CONSTRUCTOR_TEST(Helper.CONSTRUCTOR, Helper.CONSTRUCTOR_CALLABLE, false),
     /** method test case */
     METOD_TEST(Helper.METHOD, Helper.METHOD_CALLABLE, false),
     /** static method test case */
     STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE, false),
+
     /** OSR constructor test case */
     OSR_CONSTRUCTOR_TEST(Helper.OSR_CONSTRUCTOR,
             Helper.OSR_CONSTRUCTOR_CALLABLE, true),
@@ -397,32 +368,20 @@
     /** OSR static method test case */
     OSR_STATIC_TEST(Helper.OSR_STATIC, Helper.OSR_STATIC_CALLABLE, true);
 
-    private final Executable executable;
-    private final Callable<Integer> callable;
-    private final boolean isOsr;
+    /** tested method */
+    final Executable executable;
+    /** object to invoke {@linkplain #executable} */
+    final Callable<Integer> callable;
+    /** flag for OSR test case */
+    final boolean isOsr;
 
-    private SimpleTestCase(Executable executable, Callable<Integer> callable,
+    private TestCase(Executable executable, Callable<Integer> callable,
             boolean isOsr) {
         this.executable = executable;
         this.callable = callable;
         this.isOsr = isOsr;
     }
 
-    @Override
-    public Executable getExecutable() {
-        return executable;
-    }
-
-    @Override
-    public Callable<Integer> getCallable() {
-        return callable;
-    }
-
-    @Override
-    public boolean isOsr() {
-        return isOsr;
-    }
-
     private static class Helper {
 
         private static final Callable<Integer> CONSTRUCTOR_CALLABLE
@@ -477,6 +436,7 @@
             }
         };
 
+
         private static final Constructor CONSTRUCTOR;
         private static final Constructor OSR_CONSTRUCTOR;
         private static final Method METHOD;