test/compiler/whitebox/IsMethodCompilableTest.java
Print this page
rev 5819 : 8007270: Make IsMethodCompilable test work with tiered
Summary: Only c2 compiles counts toward cutoff
Reviewed-by:
*** 25,35 ****
* @test IsMethodCompilableTest
* @bug 8007270 8006683 8007288 8022832
* @library /testlibrary /testlibrary/whitebox
* @build IsMethodCompilableTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
! * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* IsMethodCompilableTest
* @summary testing of WB::isMethodCompilable()
* @author igor.ignatyev@oracle.com
*/
public class IsMethodCompilableTest extends CompilerWhiteBoxTest {
/**
--- 25,35 ----
* @test IsMethodCompilableTest
* @bug 8007270 8006683 8007288 8022832
* @library /testlibrary /testlibrary/whitebox
* @build IsMethodCompilableTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
! * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:PerMethodRecompilationCutoff=4 -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* IsMethodCompilableTest
* @summary testing of WB::isMethodCompilable()
* @author igor.ignatyev@oracle.com
*/
public class IsMethodCompilableTest extends CompilerWhiteBoxTest {
/**
*** 41,51 ****
long tmp = Long.parseLong(
getVMOption("PerMethodRecompilationCutoff", "400"));
if (tmp == -1) {
PER_METHOD_RECOMPILATION_CUTOFF = -1 /* Inf */;
} else {
! PER_METHOD_RECOMPILATION_CUTOFF = 1 + (0xFFFFFFFFL & tmp);
}
}
public static void main(String[] args) throws Exception {
CompilerWhiteBoxTest.main(IsMethodCompilableTest::new, args);
--- 41,51 ----
long tmp = Long.parseLong(
getVMOption("PerMethodRecompilationCutoff", "400"));
if (tmp == -1) {
PER_METHOD_RECOMPILATION_CUTOFF = -1 /* Inf */;
} else {
! PER_METHOD_RECOMPILATION_CUTOFF = (0xFFFFFFFFL & tmp);
}
}
public static void main(String[] args) throws Exception {
CompilerWhiteBoxTest.main(IsMethodCompilableTest::new, args);
*** 58,73 ****
}
/**
* Tests {@code WB::isMethodCompilable()} by recompilation of tested method
* 'PerMethodRecompilationCutoff' times and checks compilation status. Also
! * checks that WB::clearMethodState() clears no-compilable flags.
*
* @throws Exception if one of the checks fails.
*/
@Override
protected void test() throws Exception {
if (testCase.isOsr() && CompilerWhiteBoxTest.MODE.startsWith(
"compiled ")) {
System.err.printf("Warning: %s is not applicable in %s%n",
testCase.name(), CompilerWhiteBoxTest.MODE);
return;
--- 58,81 ----
}
/**
* Tests {@code WB::isMethodCompilable()} by recompilation of tested method
* 'PerMethodRecompilationCutoff' times and checks compilation status. Also
! * checks that WB::clearMethodState() clears no-compilable flags. Only
! * applicable to c2 compiled methods.
*
* @throws Exception if one of the checks fails.
*/
@Override
protected void test() throws Exception {
+
+ // Only c2 compilations can be disabled through PerMethodRecompilationCutoff
+ if (TIERED_STOP_AT_LEVEL < COMP_LEVEL_FULL_OPTIMIZATION) {
+ System.out.println("C2 compiler not available. Skipping test.");
+ return;
+ }
+
if (testCase.isOsr() && CompilerWhiteBoxTest.MODE.startsWith(
"compiled ")) {
System.err.printf("Warning: %s is not applicable in %s%n",
testCase.name(), CompilerWhiteBoxTest.MODE);
return;
*** 81,113 ****
System.err.println(
"Warning: test is not applicable if PerMethodRecompilationCutoff == Inf");
return;
}
! // deoptimize 'PerMethodRecompilationCutoff' times and clear state
! for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) {
! compileAndDeoptimize();
}
if (!testCase.isOsr() && !isCompilable()) {
// in osr test case count of deopt maybe more than iterations
throw new RuntimeException(method + " is not compilable after "
! + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations");
}
- WHITE_BOX.clearMethodState(method);
! // deoptimize 'PerMethodRecompilationCutoff' + 1 times
! long i;
! for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF
! && isCompilable(); ++i) {
compileAndDeoptimize();
! }
! if (!testCase.isOsr() && i != PER_METHOD_RECOMPILATION_CUTOFF) {
! // in osr test case count of deopt maybe more than iterations
! throw new RuntimeException(method + " is not compilable after "
! + i + " iterations, but must only after "
! + PER_METHOD_RECOMPILATION_CUTOFF);
! }
if (isCompilable()) {
throw new RuntimeException(method + " is still compilable after "
+ PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
}
compile();
--- 89,118 ----
System.err.println(
"Warning: test is not applicable if PerMethodRecompilationCutoff == Inf");
return;
}
! long cutoff = PER_METHOD_RECOMPILATION_CUTOFF;
! // deoptimize 'PerMethodRecompilationCutoff' times
! for (long i = 0L; i < cutoff; ++i) {
! int level = compileAndDeoptimize();
! if (level < COMP_LEVEL_FULL_OPTIMIZATION) {
! if (i == 0) {
! // Add one if a lower tier is compiled on first iteration
! cutoff++;
! }
! }
}
if (!testCase.isOsr() && !isCompilable()) {
// in osr test case count of deopt maybe more than iterations
throw new RuntimeException(method + " is not compilable after "
! + PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
}
! // Now compile once more
compileAndDeoptimize();
!
if (isCompilable()) {
throw new RuntimeException(method + " is still compilable after "
+ PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
}
compile();
*** 121,131 ****
}
compile();
checkCompiled();
}
! private void compileAndDeoptimize() throws Exception {
compile();
waitBackgroundCompilation();
deoptimize();
}
}
--- 126,138 ----
}
compile();
checkCompiled();
}
! private int compileAndDeoptimize() throws Exception {
compile();
waitBackgroundCompilation();
+ int compLevel = getCompLevel();
deoptimize();
+ return compLevel;
}
}