Mon, 18 Mar 2013 04:29:08 -0700
8008211: Some of WB tests on compiler fail
Reviewed-by: kvn, vlivanov
1.1 --- a/test/compiler/whitebox/CompilerWhiteBoxTest.java Sat Mar 16 21:44:52 2013 -0700 1.2 +++ b/test/compiler/whitebox/CompilerWhiteBoxTest.java Mon Mar 18 04:29:08 2013 -0700 1.3 @@ -35,6 +35,8 @@ 1.4 protected static final Method METHOD = getMethod("method"); 1.5 protected static final int COMPILE_THRESHOLD 1.6 = Integer.parseInt(getVMOption("CompileThreshold", "10000")); 1.7 + protected static final boolean BACKGROUND_COMPILATION 1.8 + = Boolean.valueOf(getVMOption("BackgroundCompilation", "true")); 1.9 1.10 protected static Method getMethod(String name) { 1.11 try { 1.12 @@ -45,11 +47,16 @@ 1.13 } 1.14 } 1.15 1.16 - protected static String getVMOption(String name, String defaultValue) { 1.17 + protected static String getVMOption(String name) { 1.18 String result; 1.19 HotSpotDiagnosticMXBean diagnostic 1.20 = ManagementFactoryHelper.getDiagnosticMXBean(); 1.21 result = diagnostic.getVMOption(name).getValue(); 1.22 + return result; 1.23 + } 1.24 + 1.25 + protected static String getVMOption(String name, String defaultValue) { 1.26 + String result = getVMOption(name); 1.27 return result == null ? defaultValue : result; 1.28 } 1.29 1.30 @@ -66,6 +73,7 @@ 1.31 } catch (Exception e) { 1.32 System.out.printf("on exception '%s':", e.getMessage()); 1.33 printInfo(METHOD); 1.34 + e.printStackTrace(); 1.35 throw new RuntimeException(e); 1.36 } 1.37 System.out.println("at test's end:"); 1.38 @@ -100,6 +108,9 @@ 1.39 1.40 protected static void waitBackgroundCompilation(Method method) 1.41 throws InterruptedException { 1.42 + if (!BACKGROUND_COMPILATION) { 1.43 + return; 1.44 + } 1.45 final Object obj = new Object(); 1.46 synchronized (obj) { 1.47 for (int i = 0; i < 10; ++i) { 1.48 @@ -129,13 +140,14 @@ 1.49 1.50 protected final int compile() { 1.51 int result = 0; 1.52 - for (int i = 0; i < COMPILE_THRESHOLD; ++i) { 1.53 + int count = Math.max(COMPILE_THRESHOLD, 150000); 1.54 + for (int i = 0; i < count; ++i) { 1.55 result += method(); 1.56 } 1.57 + System.out.println("method was invoked " + count + " times"); 1.58 return result; 1.59 } 1.60 1.61 - 1.62 protected int method() { 1.63 return 42; 1.64 }
2.1 --- a/test/compiler/whitebox/DeoptimizeAllTest.java Sat Mar 16 21:44:52 2013 -0700 2.2 +++ b/test/compiler/whitebox/DeoptimizeAllTest.java Mon Mar 18 04:29:08 2013 -0700 2.3 @@ -32,12 +32,12 @@ 2.4 public class DeoptimizeAllTest extends CompilerWhiteBoxTest { 2.5 2.6 public static void main(String[] args) throws Exception { 2.7 + // to prevent inlining #method into #compile() 2.8 + WHITE_BOX.setDontInlineMethod(METHOD, true); 2.9 new DeoptimizeAllTest().runTest(); 2.10 } 2.11 2.12 protected void test() throws Exception { 2.13 - // to prevent inlining #method into #compile() 2.14 - WHITE_BOX.setDontInlineMethod(METHOD, true); 2.15 compile(); 2.16 checkCompiled(METHOD); 2.17 WHITE_BOX.deoptimizeAll();
3.1 --- a/test/compiler/whitebox/DeoptimizeMethodTest.java Sat Mar 16 21:44:52 2013 -0700 3.2 +++ b/test/compiler/whitebox/DeoptimizeMethodTest.java Mon Mar 18 04:29:08 2013 -0700 3.3 @@ -32,12 +32,12 @@ 3.4 public class DeoptimizeMethodTest extends CompilerWhiteBoxTest { 3.5 3.6 public static void main(String[] args) throws Exception { 3.7 + // to prevent inlining #method into #compile() 3.8 + WHITE_BOX.setDontInlineMethod(METHOD, true); 3.9 new DeoptimizeMethodTest().runTest(); 3.10 } 3.11 3.12 protected void test() throws Exception { 3.13 - // to prevent inlining #method into #compile() 3.14 - WHITE_BOX.setDontInlineMethod(METHOD, true); 3.15 compile(); 3.16 checkCompiled(METHOD); 3.17 WHITE_BOX.deoptimizeMethod(METHOD);
4.1 --- a/test/compiler/whitebox/IsMethodCompilableTest.java Sat Mar 16 21:44:52 2013 -0700 4.2 +++ b/test/compiler/whitebox/IsMethodCompilableTest.java Mon Mar 18 04:29:08 2013 -0700 4.3 @@ -44,6 +44,8 @@ 4.4 } 4.5 4.6 public static void main(String[] args) throws Exception { 4.7 + // to prevent inlining #method into #compile() 4.8 + WHITE_BOX.setDontInlineMethod(METHOD, true); 4.9 new IsMethodCompilableTest().runTest(); 4.10 } 4.11 4.12 @@ -58,8 +60,6 @@ 4.13 "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf"); 4.14 return; 4.15 } 4.16 - // to prevent inlining #method into #compile() 4.17 - WHITE_BOX.setDontInlineMethod(METHOD, true); 4.18 boolean madeNotCompilable = false; 4.19 4.20 for (long i = 0; i < PER_METHOD_RECOMPILATION_CUTOFF; ++i) {
5.1 --- a/test/compiler/whitebox/MakeMethodNotCompilableTest.java Sat Mar 16 21:44:52 2013 -0700 5.2 +++ b/test/compiler/whitebox/MakeMethodNotCompilableTest.java Mon Mar 18 04:29:08 2013 -0700 5.3 @@ -32,6 +32,8 @@ 5.4 public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest { 5.5 5.6 public static void main(String[] args) throws Exception { 5.7 + // to prevent inlining #method into #compile() 5.8 + WHITE_BOX.setDontInlineMethod(METHOD, true); 5.9 new MakeMethodNotCompilableTest().runTest(); 5.10 } 5.11