1.1 --- a/test/compiler/whitebox/IsMethodCompilableTest.java Fri Apr 11 00:34:51 2014 +0400 1.2 +++ b/test/compiler/whitebox/IsMethodCompilableTest.java Tue Jan 28 15:05:46 2014 +0100 1.3 @@ -24,13 +24,17 @@ 1.4 /* 1.5 * @test IsMethodCompilableTest 1.6 * @bug 8007270 8006683 8007288 8022832 1.7 - * @library /testlibrary /testlibrary/whitebox 1.8 + * @library /testlibrary /testlibrary/whitebox /testlibrary/com/oracle/java/testlibrary 1.9 * @build IsMethodCompilableTest 1.10 * @run main ClassFileInstaller sun.hotspot.WhiteBox 1.11 - * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* IsMethodCompilableTest 1.12 + * @run main ClassFileInstaller com.oracle.java.testlibrary.Platform 1.13 + * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:PerMethodRecompilationCutoff=3 -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* IsMethodCompilableTest 1.14 * @summary testing of WB::isMethodCompilable() 1.15 * @author igor.ignatyev@oracle.com 1.16 */ 1.17 + 1.18 +import com.oracle.java.testlibrary.Platform; 1.19 + 1.20 public class IsMethodCompilableTest extends CompilerWhiteBoxTest { 1.21 /** 1.22 * Value of {@code -XX:PerMethodRecompilationCutoff} 1.23 @@ -43,7 +47,7 @@ 1.24 if (tmp == -1) { 1.25 PER_METHOD_RECOMPILATION_CUTOFF = -1 /* Inf */; 1.26 } else { 1.27 - PER_METHOD_RECOMPILATION_CUTOFF = 1 + (0xFFFFFFFFL & tmp); 1.28 + PER_METHOD_RECOMPILATION_CUTOFF = (0xFFFFFFFFL & tmp); 1.29 } 1.30 } 1.31 1.32 @@ -60,16 +64,22 @@ 1.33 /** 1.34 * Tests {@code WB::isMethodCompilable()} by recompilation of tested method 1.35 * 'PerMethodRecompilationCutoff' times and checks compilation status. Also 1.36 - * checks that WB::clearMethodState() clears no-compilable flags. 1.37 + * checks that WB::clearMethodState() clears no-compilable flags. Only 1.38 + * applicable to c2 compiled methods. 1.39 * 1.40 * @throws Exception if one of the checks fails. 1.41 */ 1.42 @Override 1.43 protected void test() throws Exception { 1.44 + // Only c2 compilations can be disabled through PerMethodRecompilationCutoff 1.45 + if (!Platform.isServer()) { 1.46 + return; 1.47 + } 1.48 + 1.49 if (skipXcompOSR()) { 1.50 return; 1.51 } 1.52 - if (!isCompilable()) { 1.53 + if (!isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { 1.54 throw new RuntimeException(method + " must be compilable"); 1.55 } 1.56 System.out.println("PerMethodRecompilationCutoff = " 1.57 @@ -80,39 +90,37 @@ 1.58 return; 1.59 } 1.60 1.61 - // deoptimize 'PerMethodRecompilationCutoff' times and clear state 1.62 - for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) { 1.63 - compileAndDeoptimize(); 1.64 + // deoptimize 'PerMethodRecompilationCutoff' times 1.65 + for (long attempts = 0, successes = 0; 1.66 + (successes < PER_METHOD_RECOMPILATION_CUTOFF) && 1.67 + (attempts < PER_METHOD_RECOMPILATION_CUTOFF*2) && 1.68 + isCompilable(COMP_LEVEL_FULL_OPTIMIZATION); attempts++) { 1.69 + if (compileAndDeoptimize() == COMP_LEVEL_FULL_OPTIMIZATION) { 1.70 + successes++; 1.71 + } 1.72 } 1.73 - if (!testCase.isOsr() && !isCompilable()) { 1.74 + 1.75 + if (!testCase.isOsr() && !isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { 1.76 // in osr test case count of deopt maybe more than iterations 1.77 throw new RuntimeException(method + " is not compilable after " 1.78 - + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations"); 1.79 + + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); 1.80 } 1.81 - WHITE_BOX.clearMethodState(method); 1.82 1.83 - // deoptimize 'PerMethodRecompilationCutoff' + 1 times 1.84 - long i; 1.85 - for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF 1.86 - && isCompilable(); ++i) { 1.87 - compileAndDeoptimize(); 1.88 - } 1.89 - if (!testCase.isOsr() && i != PER_METHOD_RECOMPILATION_CUTOFF) { 1.90 - // in osr test case count of deopt maybe more than iterations 1.91 - throw new RuntimeException(method + " is not compilable after " 1.92 - + i + " iterations, but must only after " 1.93 - + PER_METHOD_RECOMPILATION_CUTOFF); 1.94 - } 1.95 - if (isCompilable()) { 1.96 + // Now compile once more 1.97 + compileAndDeoptimize(); 1.98 + 1.99 + if (isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { 1.100 throw new RuntimeException(method + " is still compilable after " 1.101 + PER_METHOD_RECOMPILATION_CUTOFF + " iterations"); 1.102 } 1.103 + checkNotCompiled(); 1.104 compile(); 1.105 - checkNotCompiled(); 1.106 + waitBackgroundCompilation(); 1.107 + checkNotCompiled(COMP_LEVEL_FULL_OPTIMIZATION); 1.108 1.109 // WB.clearMethodState() must reset no-compilable flags 1.110 WHITE_BOX.clearMethodState(method); 1.111 - if (!isCompilable()) { 1.112 + if (!isCompilable(COMP_LEVEL_FULL_OPTIMIZATION)) { 1.113 throw new RuntimeException(method 1.114 + " is not compilable after clearMethodState()"); 1.115 } 1.116 @@ -120,9 +128,11 @@ 1.117 checkCompiled(); 1.118 } 1.119 1.120 - private void compileAndDeoptimize() throws Exception { 1.121 + private int compileAndDeoptimize() throws Exception { 1.122 compile(); 1.123 waitBackgroundCompilation(); 1.124 + int compLevel = getCompLevel(); 1.125 deoptimize(); 1.126 + return compLevel; 1.127 } 1.128 }