1.1 --- a/test/compiler/whitebox/MakeMethodNotCompilableTest.java Thu Apr 25 11:09:24 2013 -0700 1.2 +++ b/test/compiler/whitebox/MakeMethodNotCompilableTest.java Fri Apr 26 07:21:41 2013 -0700 1.3 @@ -23,6 +23,7 @@ 1.4 1.5 /* 1.6 * @test MakeMethodNotCompilableTest 1.7 + * @bug 8012322 1.8 * @library /testlibrary /testlibrary/whitebox 1.9 * @build MakeMethodNotCompilableTest 1.10 * @run main ClassFileInstaller sun.hotspot.WhiteBox 1.11 @@ -67,28 +68,69 @@ 1.12 } 1.13 1.14 if (TIERED_COMPILATION) { 1.15 - for (int i = 1, n = TIERED_STOP_AT_LEVEL + 1; i < n; ++i) { 1.16 - WHITE_BOX.makeMethodNotCompilable(method, i); 1.17 - if (WHITE_BOX.isMethodCompilable(method, i)) { 1.18 + final int tierLimit = TIERED_STOP_AT_LEVEL + 1; 1.19 + for (int testedTier = 1; testedTier < tierLimit; ++testedTier) { 1.20 + testTier(testedTier); 1.21 + } 1.22 + for (int testedTier = 1; testedTier < tierLimit; ++testedTier) { 1.23 + WHITE_BOX.makeMethodNotCompilable(method, testedTier); 1.24 + if (WHITE_BOX.isMethodCompilable(method, testedTier)) { 1.25 throw new RuntimeException(method 1.26 - + " must be not compilable at level" + i); 1.27 + + " must be not compilable at level" + testedTier); 1.28 } 1.29 - WHITE_BOX.enqueueMethodForCompilation(method, i); 1.30 + WHITE_BOX.enqueueMethodForCompilation(method, testedTier); 1.31 checkNotCompiled(); 1.32 1.33 if (!WHITE_BOX.isMethodCompilable(method)) { 1.34 System.out.println(method 1.35 - + " is not compilable after level " + i); 1.36 + + " is not compilable after level " + testedTier); 1.37 } 1.38 } 1.39 + } else { 1.40 + compile(); 1.41 + checkCompiled(); 1.42 + int compLevel = WHITE_BOX.getMethodCompilationLevel(method); 1.43 + WHITE_BOX.deoptimizeMethod(method); 1.44 + WHITE_BOX.makeMethodNotCompilable(method, compLevel); 1.45 + if (WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY)) { 1.46 + throw new RuntimeException(method 1.47 + + " must be not compilable at CompLevel::CompLevel_any," 1.48 + + " after it is not compilable at " + compLevel); 1.49 + } 1.50 + WHITE_BOX.clearMethodState(method); 1.51 1.52 - // WB.clearMethodState() must reset no-compilable flags 1.53 - WHITE_BOX.clearMethodState(method); 1.54 - if (!WHITE_BOX.isMethodCompilable(method)) { 1.55 - throw new RuntimeException(method 1.56 - + " is not compilable after clearMethodState()"); 1.57 + // nocompilable at opposite level must make no sense 1.58 + int oppositeLevel; 1.59 + if (isC1Compile(compLevel)) { 1.60 + oppositeLevel = COMP_LEVEL_FULL_OPTIMIZATION; 1.61 + } else { 1.62 + oppositeLevel = COMP_LEVEL_SIMPLE; 1.63 + } 1.64 + WHITE_BOX.makeMethodNotCompilable(method, oppositeLevel); 1.65 + 1.66 + if (!WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY)) { 1.67 + throw new RuntimeException(method 1.68 + + " must be compilable at CompLevel::CompLevel_any," 1.69 + + " even it is not compilable at opposite level [" 1.70 + + compLevel + "]"); 1.71 + } 1.72 + 1.73 + if (!WHITE_BOX.isMethodCompilable(method, compLevel)) { 1.74 + throw new RuntimeException(method 1.75 + + " must be compilable at level " + compLevel 1.76 + + ", even it is not compilable at opposite level [" 1.77 + + compLevel + "]"); 1.78 } 1.79 } 1.80 + 1.81 + // clearing after tiered/non-tiered tests 1.82 + // WB.clearMethodState() must reset no-compilable flags 1.83 + WHITE_BOX.clearMethodState(method); 1.84 + if (!WHITE_BOX.isMethodCompilable(method)) { 1.85 + throw new RuntimeException(method 1.86 + + " is not compilable after clearMethodState()"); 1.87 + } 1.88 + 1.89 WHITE_BOX.makeMethodNotCompilable(method); 1.90 if (WHITE_BOX.isMethodCompilable(method)) { 1.91 throw new RuntimeException(method + " must be not compilable"); 1.92 @@ -108,4 +150,65 @@ 1.93 compile(); 1.94 checkCompiled(); 1.95 } 1.96 + 1.97 + // separately tests each tier 1.98 + private void testTier(int testedTier) { 1.99 + if (!WHITE_BOX.isMethodCompilable(method, testedTier)) { 1.100 + throw new RuntimeException(method 1.101 + + " is not compilable on start"); 1.102 + } 1.103 + WHITE_BOX.makeMethodNotCompilable(method, testedTier); 1.104 + 1.105 + // tests for all other tiers 1.106 + for (int anotherTier = 1, tierLimit = TIERED_STOP_AT_LEVEL + 1; 1.107 + anotherTier < tierLimit; ++anotherTier) { 1.108 + boolean isCompilable = WHITE_BOX.isMethodCompilable(method, 1.109 + anotherTier); 1.110 + if (sameCompile(testedTier, anotherTier)) { 1.111 + if (isCompilable) { 1.112 + throw new RuntimeException(method 1.113 + + " must be not compilable at level " + anotherTier 1.114 + + ", if it is not compilable at " + testedTier); 1.115 + } 1.116 + WHITE_BOX.enqueueMethodForCompilation(method, anotherTier); 1.117 + checkNotCompiled(); 1.118 + } else { 1.119 + if (!isCompilable) { 1.120 + throw new RuntimeException(method 1.121 + + " must be compilable at level " + anotherTier 1.122 + + ", even if it is not compilable at " 1.123 + + testedTier); 1.124 + } 1.125 + WHITE_BOX.enqueueMethodForCompilation(method, anotherTier); 1.126 + checkCompiled(); 1.127 + WHITE_BOX.deoptimizeMethod(method); 1.128 + } 1.129 + 1.130 + if (!WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY)) { 1.131 + throw new RuntimeException(method 1.132 + + " must be compilable at 'CompLevel::CompLevel_any'" 1.133 + + ", if it is not compilable only at " + testedTier); 1.134 + } 1.135 + } 1.136 + 1.137 + // clear state after test 1.138 + WHITE_BOX.clearMethodState(method); 1.139 + if (!WHITE_BOX.isMethodCompilable(method, testedTier)) { 1.140 + throw new RuntimeException(method 1.141 + + " is not compilable after clearMethodState()"); 1.142 + } 1.143 + } 1.144 + 1.145 + private boolean sameCompile(int level1, int level2) { 1.146 + if (level1 == level2) { 1.147 + return true; 1.148 + } 1.149 + if (isC1Compile(level1) && isC1Compile(level2)) { 1.150 + return true; 1.151 + } 1.152 + if (isC2Compile(level1) && isC2Compile(level2)) { 1.153 + return true; 1.154 + } 1.155 + return false; 1.156 + } 1.157 }