8011971: WB API doesn't accept j.l.reflect.Constructor

Reviewed-by: kvn, vlivanov
This commit is contained in:
Igor Ignatyev 2013-04-16 10:04:01 -07:00
parent 23e34191a6
commit 33e3f6b59b
11 changed files with 535 additions and 175 deletions

View file

@ -28,9 +28,13 @@
* @build IsMethodCompilableTest
* @run main ClassFileInstaller sun.hotspot.WhiteBox
* @run main/othervm/timeout=600 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI IsMethodCompilableTest
* @summary testing of WB::isMethodCompilable()
* @author igor.ignatyev@oracle.com
*/
public class IsMethodCompilableTest extends CompilerWhiteBoxTest {
/**
* Value of {@code -XX:PerMethodRecompilationCutoff}
*/
protected static final long PER_METHOD_RECOMPILATION_CUTOFF;
static {
@ -44,14 +48,28 @@ public class IsMethodCompilableTest extends CompilerWhiteBoxTest {
}
public static void main(String[] args) throws Exception {
// to prevent inlining #method into #compile()
WHITE_BOX.testSetDontInlineMethod(METHOD, true);
new IsMethodCompilableTest().runTest();
for (TestCase test : TestCase.values()) {
new IsMethodCompilableTest(test).runTest();
}
}
public IsMethodCompilableTest(TestCase testCase) {
super(testCase);
// to prevent inlining of #method
WHITE_BOX.testSetDontInlineMethod(method, true);
}
/**
* 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 (!WHITE_BOX.isMethodCompilable(METHOD)) {
throw new RuntimeException(METHOD + " must be compilable");
if (!WHITE_BOX.isMethodCompilable(method)) {
throw new RuntimeException(method + " must be compilable");
}
System.out.println("PerMethodRecompilationCutoff = "
+ PER_METHOD_RECOMPILATION_CUTOFF);
@ -61,46 +79,47 @@ public class IsMethodCompilableTest extends CompilerWhiteBoxTest {
return;
}
// deoptimze 'PerMethodRecompilationCutoff' times and clear state
// deoptimize 'PerMethodRecompilationCutoff' times and clear state
for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) {
compileAndDeoptimaze();
compileAndDeoptimize();
}
if (!WHITE_BOX.isMethodCompilable(METHOD)) {
throw new RuntimeException(METHOD + " is not compilable after "
if (!WHITE_BOX.isMethodCompilable(method)) {
throw new RuntimeException(method + " is not compilable after "
+ (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations");
}
WHITE_BOX.clearMethodState(METHOD);
WHITE_BOX.clearMethodState(method);
// deoptimze 'PerMethodRecompilationCutoff' + 1 times
// deoptimize 'PerMethodRecompilationCutoff' + 1 times
long i;
for (i = 0L; i < PER_METHOD_RECOMPILATION_CUTOFF
&& WHITE_BOX.isMethodCompilable(METHOD); ++i) {
compileAndDeoptimaze();
&& WHITE_BOX.isMethodCompilable(method); ++i) {
compileAndDeoptimize();
}
if (i != PER_METHOD_RECOMPILATION_CUTOFF) {
throw new RuntimeException(METHOD + " is not compilable after "
+ i + " iterations, but must only after "
+ PER_METHOD_RECOMPILATION_CUTOFF);
throw new RuntimeException(method + " is not compilable after "
+ i + " iterations, but must only after "
+ PER_METHOD_RECOMPILATION_CUTOFF);
}
if (WHITE_BOX.isMethodCompilable(METHOD)) {
throw new RuntimeException(METHOD + " is still compilable after "
if (WHITE_BOX.isMethodCompilable(method)) {
throw new RuntimeException(method + " is still compilable after "
+ PER_METHOD_RECOMPILATION_CUTOFF + " iterations");
}
compile();
checkNotCompiled(METHOD);
checkNotCompiled();
WHITE_BOX.clearMethodState(METHOD);
if (!WHITE_BOX.isMethodCompilable(METHOD)) {
throw new RuntimeException(METHOD
+ " is compilable after clearMethodState()");
// WB.clearMethodState() must reset no-compilable flags
WHITE_BOX.clearMethodState(method);
if (!WHITE_BOX.isMethodCompilable(method)) {
throw new RuntimeException(method
+ " is not compilable after clearMethodState()");
}
compile();
checkCompiled(METHOD);
checkCompiled();
}
private void compileAndDeoptimaze() throws Exception {
private void compileAndDeoptimize() throws Exception {
compile();
waitBackgroundCompilation(METHOD);
WHITE_BOX.deoptimizeMethod(METHOD);
waitBackgroundCompilation();
WHITE_BOX.deoptimizeMethod(method);
}
}