提交 33fe8ef6 编写于 作者: I iignatyev

8008211: Some of WB tests on compiler fail

Reviewed-by: kvn, vlivanov
上级 f71c860d
...@@ -35,6 +35,8 @@ public abstract class CompilerWhiteBoxTest { ...@@ -35,6 +35,8 @@ public abstract class CompilerWhiteBoxTest {
protected static final Method METHOD = getMethod("method"); protected static final Method METHOD = getMethod("method");
protected static final int COMPILE_THRESHOLD protected static final int COMPILE_THRESHOLD
= Integer.parseInt(getVMOption("CompileThreshold", "10000")); = Integer.parseInt(getVMOption("CompileThreshold", "10000"));
protected static final boolean BACKGROUND_COMPILATION
= Boolean.valueOf(getVMOption("BackgroundCompilation", "true"));
protected static Method getMethod(String name) { protected static Method getMethod(String name) {
try { try {
...@@ -45,11 +47,16 @@ public abstract class CompilerWhiteBoxTest { ...@@ -45,11 +47,16 @@ public abstract class CompilerWhiteBoxTest {
} }
} }
protected static String getVMOption(String name, String defaultValue) { protected static String getVMOption(String name) {
String result; String result;
HotSpotDiagnosticMXBean diagnostic HotSpotDiagnosticMXBean diagnostic
= ManagementFactoryHelper.getDiagnosticMXBean(); = ManagementFactoryHelper.getDiagnosticMXBean();
result = diagnostic.getVMOption(name).getValue(); result = diagnostic.getVMOption(name).getValue();
return result;
}
protected static String getVMOption(String name, String defaultValue) {
String result = getVMOption(name);
return result == null ? defaultValue : result; return result == null ? defaultValue : result;
} }
...@@ -66,6 +73,7 @@ public abstract class CompilerWhiteBoxTest { ...@@ -66,6 +73,7 @@ public abstract class CompilerWhiteBoxTest {
} catch (Exception e) { } catch (Exception e) {
System.out.printf("on exception '%s':", e.getMessage()); System.out.printf("on exception '%s':", e.getMessage());
printInfo(METHOD); printInfo(METHOD);
e.printStackTrace();
throw new RuntimeException(e); throw new RuntimeException(e);
} }
System.out.println("at test's end:"); System.out.println("at test's end:");
...@@ -100,6 +108,9 @@ public abstract class CompilerWhiteBoxTest { ...@@ -100,6 +108,9 @@ public abstract class CompilerWhiteBoxTest {
protected static void waitBackgroundCompilation(Method method) protected static void waitBackgroundCompilation(Method method)
throws InterruptedException { throws InterruptedException {
if (!BACKGROUND_COMPILATION) {
return;
}
final Object obj = new Object(); final Object obj = new Object();
synchronized (obj) { synchronized (obj) {
for (int i = 0; i < 10; ++i) { for (int i = 0; i < 10; ++i) {
...@@ -129,13 +140,14 @@ public abstract class CompilerWhiteBoxTest { ...@@ -129,13 +140,14 @@ public abstract class CompilerWhiteBoxTest {
protected final int compile() { protected final int compile() {
int result = 0; int result = 0;
for (int i = 0; i < COMPILE_THRESHOLD; ++i) { int count = Math.max(COMPILE_THRESHOLD, 150000);
for (int i = 0; i < count; ++i) {
result += method(); result += method();
} }
System.out.println("method was invoked " + count + " times");
return result; return result;
} }
protected int method() { protected int method() {
return 42; return 42;
} }
......
...@@ -32,12 +32,12 @@ ...@@ -32,12 +32,12 @@
public class DeoptimizeAllTest extends CompilerWhiteBoxTest { public class DeoptimizeAllTest extends CompilerWhiteBoxTest {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// to prevent inlining #method into #compile()
WHITE_BOX.setDontInlineMethod(METHOD, true);
new DeoptimizeAllTest().runTest(); new DeoptimizeAllTest().runTest();
} }
protected void test() throws Exception { protected void test() throws Exception {
// to prevent inlining #method into #compile()
WHITE_BOX.setDontInlineMethod(METHOD, true);
compile(); compile();
checkCompiled(METHOD); checkCompiled(METHOD);
WHITE_BOX.deoptimizeAll(); WHITE_BOX.deoptimizeAll();
......
...@@ -32,12 +32,12 @@ ...@@ -32,12 +32,12 @@
public class DeoptimizeMethodTest extends CompilerWhiteBoxTest { public class DeoptimizeMethodTest extends CompilerWhiteBoxTest {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// to prevent inlining #method into #compile()
WHITE_BOX.setDontInlineMethod(METHOD, true);
new DeoptimizeMethodTest().runTest(); new DeoptimizeMethodTest().runTest();
} }
protected void test() throws Exception { protected void test() throws Exception {
// to prevent inlining #method into #compile()
WHITE_BOX.setDontInlineMethod(METHOD, true);
compile(); compile();
checkCompiled(METHOD); checkCompiled(METHOD);
WHITE_BOX.deoptimizeMethod(METHOD); WHITE_BOX.deoptimizeMethod(METHOD);
......
...@@ -44,6 +44,8 @@ public class IsMethodCompilableTest extends CompilerWhiteBoxTest { ...@@ -44,6 +44,8 @@ public class IsMethodCompilableTest extends CompilerWhiteBoxTest {
} }
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// to prevent inlining #method into #compile()
WHITE_BOX.setDontInlineMethod(METHOD, true);
new IsMethodCompilableTest().runTest(); new IsMethodCompilableTest().runTest();
} }
...@@ -58,8 +60,6 @@ public class IsMethodCompilableTest extends CompilerWhiteBoxTest { ...@@ -58,8 +60,6 @@ public class IsMethodCompilableTest extends CompilerWhiteBoxTest {
"Warning: test is not applicable if PerMethodRecompilationCutoff == Inf"); "Warning: test is not applicable if PerMethodRecompilationCutoff == Inf");
return; return;
} }
// to prevent inlining #method into #compile()
WHITE_BOX.setDontInlineMethod(METHOD, true);
boolean madeNotCompilable = false; boolean madeNotCompilable = false;
for (long i = 0; i < PER_METHOD_RECOMPILATION_CUTOFF; ++i) { for (long i = 0; i < PER_METHOD_RECOMPILATION_CUTOFF; ++i) {
......
...@@ -32,6 +32,8 @@ ...@@ -32,6 +32,8 @@
public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest { public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest {
public static void main(String[] args) throws Exception { public static void main(String[] args) throws Exception {
// to prevent inlining #method into #compile()
WHITE_BOX.setDontInlineMethod(METHOD, true);
new MakeMethodNotCompilableTest().runTest(); new MakeMethodNotCompilableTest().runTest();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册