提交 6e8572c5 编写于 作者: T thartmann

8061486: [TESTBUG] compiler/whitebox/ tests fail : must be osr_compiled (reappeared in nightlies)

Summary: Call warmup code from OSR triggering method to make sure no non-OSR compilation is triggered in the loop.
Reviewed-by: kvn
上级 b7d00208
...@@ -76,8 +76,6 @@ public abstract class CompilerWhiteBoxTest { ...@@ -76,8 +76,6 @@ public abstract class CompilerWhiteBoxTest {
protected static final int THRESHOLD; protected static final int THRESHOLD;
/** invocation count to trigger OSR compilation */ /** invocation count to trigger OSR compilation */
protected static final long BACKEDGE_THRESHOLD; protected static final long BACKEDGE_THRESHOLD;
/** invocation count to warm up method before triggering OSR compilation */
protected static final long OSR_WARMUP = 2000;
/** Value of {@code java.vm.info} (interpreted|mixed|comp mode) */ /** Value of {@code java.vm.info} (interpreted|mixed|comp mode) */
protected static final String MODE = System.getProperty("java.vm.info"); protected static final String MODE = System.getProperty("java.vm.info");
...@@ -509,8 +507,7 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { ...@@ -509,8 +507,7 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
= new Callable<Integer>() { = new Callable<Integer>() {
@Override @Override
public Integer call() throws Exception { public Integer call() throws Exception {
int result = warmup(OSR_CONSTRUCTOR); return new Helper(null, CompilerWhiteBoxTest.BACKEDGE_THRESHOLD).hashCode();
return result + new Helper(null, CompilerWhiteBoxTest.BACKEDGE_THRESHOLD).hashCode();
} }
}; };
...@@ -520,8 +517,7 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { ...@@ -520,8 +517,7 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
@Override @Override
public Integer call() throws Exception { public Integer call() throws Exception {
int result = warmup(OSR_METHOD); return helper.osrMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD);
return result + helper.osrMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD);
} }
}; };
...@@ -529,11 +525,54 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { ...@@ -529,11 +525,54 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
= new Callable<Integer>() { = new Callable<Integer>() {
@Override @Override
public Integer call() throws Exception { public Integer call() throws Exception {
int result = warmup(OSR_STATIC); return osrStaticMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD);
return result + osrStaticMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD);
} }
}; };
private static final Constructor CONSTRUCTOR;
private static final Constructor OSR_CONSTRUCTOR;
private static final Method METHOD;
private static final Method STATIC;
private static final Method OSR_METHOD;
private static final Method OSR_STATIC;
static {
try {
CONSTRUCTOR = Helper.class.getDeclaredConstructor(int.class);
} catch (NoSuchMethodException | SecurityException e) {
throw new RuntimeException(
"exception on getting method Helper.<init>(int)", e);
}
try {
OSR_CONSTRUCTOR = Helper.class.getDeclaredConstructor(
Object.class, long.class);
} catch (NoSuchMethodException | SecurityException e) {
throw new RuntimeException(
"exception on getting method Helper.<init>(Object, long)", e);
}
METHOD = getMethod("method");
STATIC = getMethod("staticMethod");
OSR_METHOD = getMethod("osrMethod", long.class);
OSR_STATIC = getMethod("osrStaticMethod", long.class);
}
private static Method getMethod(String name, Class<?>... parameterTypes) {
try {
return Helper.class.getDeclaredMethod(name, parameterTypes);
} catch (NoSuchMethodException | SecurityException e) {
throw new RuntimeException(
"exception on getting method Helper." + name, e);
}
}
private static int staticMethod() {
return 1138;
}
private int method() {
return 42;
}
/** /**
* Deoptimizes all non-osr versions of the given executable after * Deoptimizes all non-osr versions of the given executable after
* compilation finished. * compilation finished.
...@@ -560,11 +599,15 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { ...@@ -560,11 +599,15 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
* @throws Exception * @throws Exception
*/ */
private static int warmup(Method m) throws Exception { private static int warmup(Method m) throws Exception {
waitAndDeoptimize(m);
Helper helper = new Helper(); Helper helper = new Helper();
int result = 0; int result = 0;
for (long i = 0; i < CompilerWhiteBoxTest.OSR_WARMUP; ++i) { for (long i = 0; i < CompilerWhiteBoxTest.THRESHOLD; ++i) {
result += (int)m.invoke(helper, 1); result += (int)m.invoke(helper, 1);
} }
// Wait to make sure OSR compilation is not blocked by
// non-OSR compilation in the compile queue
CompilerWhiteBoxTest.waitBackgroundCompilation(m);
return result; return result;
} }
...@@ -578,77 +621,35 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { ...@@ -578,77 +621,35 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
* @throws Exception * @throws Exception
*/ */
private static int warmup(Constructor c) throws Exception { private static int warmup(Constructor c) throws Exception {
waitAndDeoptimize(c);
int result = 0; int result = 0;
for (long i = 0; i < CompilerWhiteBoxTest.OSR_WARMUP; ++i) { for (long i = 0; i < CompilerWhiteBoxTest.THRESHOLD; ++i) {
result += c.newInstance(null, 1).hashCode(); result += c.newInstance(null, 1).hashCode();
} }
// Wait to make sure OSR compilation is not blocked by
// non-OSR compilation in the compile queue
CompilerWhiteBoxTest.waitBackgroundCompilation(c);
return result; return result;
} }
private static final Constructor CONSTRUCTOR; private static int osrStaticMethod(long limit) throws Exception {
private static final Constructor OSR_CONSTRUCTOR; int result = 0;
private static final Method METHOD;
private static final Method STATIC;
private static final Method OSR_METHOD;
private static final Method OSR_STATIC;
static {
try {
CONSTRUCTOR = Helper.class.getDeclaredConstructor(int.class);
} catch (NoSuchMethodException | SecurityException e) {
throw new RuntimeException(
"exception on getting method Helper.<init>(int)", e);
}
try {
OSR_CONSTRUCTOR = Helper.class.getDeclaredConstructor(
Object.class, long.class);
} catch (NoSuchMethodException | SecurityException e) {
throw new RuntimeException(
"exception on getting method Helper.<init>(Object, long)", e);
}
METHOD = getMethod("method");
STATIC = getMethod("staticMethod");
OSR_METHOD = getMethod("osrMethod", long.class);
OSR_STATIC = getMethod("osrStaticMethod", long.class);
}
private static Method getMethod(String name, Class<?>... parameterTypes) {
try {
return Helper.class.getDeclaredMethod(name, parameterTypes);
} catch (NoSuchMethodException | SecurityException e) {
throw new RuntimeException(
"exception on getting method Helper." + name, e);
}
}
private static int staticMethod() {
return 1138;
}
private int method() {
return 42;
}
private static int osrStaticMethod(long limit) {
if (limit != 1) { if (limit != 1) {
// Make sure there is no compiled version after warmup result = warmup(OSR_STATIC);
waitAndDeoptimize(OSR_STATIC);
} }
// Trigger osr compilation // Trigger osr compilation
int result = 0;
for (long i = 0; i < limit; ++i) { for (long i = 0; i < limit; ++i) {
result += staticMethod(); result += staticMethod();
} }
return result; return result;
} }
private int osrMethod(long limit) { private int osrMethod(long limit) throws Exception {
int result = 0;
if (limit != 1) { if (limit != 1) {
// Make sure there is no compiled version after warmup result = warmup(OSR_METHOD);
waitAndDeoptimize(OSR_METHOD);
} }
// Trigger osr compilation // Trigger osr compilation
int result = 0;
for (long i = 0; i < limit; ++i) { for (long i = 0; i < limit; ++i) {
result += method(); result += method();
} }
...@@ -663,13 +664,12 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { ...@@ -663,13 +664,12 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
} }
// for OSR constructor test case // for OSR constructor test case
private Helper(Object o, long limit) { private Helper(Object o, long limit) throws Exception {
int result = 0;
if (limit != 1) { if (limit != 1) {
// Make sure there is no compiled version after warmup result = warmup(OSR_CONSTRUCTOR);
waitAndDeoptimize(OSR_CONSTRUCTOR);
} }
// Trigger osr compilation // Trigger osr compilation
int result = 0;
for (long i = 0; i < limit; ++i) { for (long i = 0; i < limit; ++i) {
result += method(); result += method();
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册