提交 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 {
protected static final int THRESHOLD;
/** invocation count to trigger OSR compilation */
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) */
protected static final String MODE = System.getProperty("java.vm.info");
......@@ -509,8 +507,7 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
= new Callable<Integer>() {
@Override
public Integer call() throws Exception {
int result = warmup(OSR_CONSTRUCTOR);
return result + new Helper(null, CompilerWhiteBoxTest.BACKEDGE_THRESHOLD).hashCode();
return new Helper(null, CompilerWhiteBoxTest.BACKEDGE_THRESHOLD).hashCode();
}
};
......@@ -520,8 +517,7 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
@Override
public Integer call() throws Exception {
int result = warmup(OSR_METHOD);
return result + helper.osrMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD);
return helper.osrMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD);
}
};
......@@ -529,11 +525,54 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
= new Callable<Integer>() {
@Override
public Integer call() throws Exception {
int result = warmup(OSR_STATIC);
return result + osrStaticMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD);
return 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
* compilation finished.
......@@ -560,11 +599,15 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
* @throws Exception
*/
private static int warmup(Method m) throws Exception {
waitAndDeoptimize(m);
Helper helper = new Helper();
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);
}
// Wait to make sure OSR compilation is not blocked by
// non-OSR compilation in the compile queue
CompilerWhiteBoxTest.waitBackgroundCompilation(m);
return result;
}
......@@ -578,77 +621,35 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
* @throws Exception
*/
private static int warmup(Constructor c) throws Exception {
waitAndDeoptimize(c);
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();
}
// Wait to make sure OSR compilation is not blocked by
// non-OSR compilation in the compile queue
CompilerWhiteBoxTest.waitBackgroundCompilation(c);
return result;
}
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;
}
private static int osrStaticMethod(long limit) {
private static int osrStaticMethod(long limit) throws Exception {
int result = 0;
if (limit != 1) {
// Make sure there is no compiled version after warmup
waitAndDeoptimize(OSR_STATIC);
result = warmup(OSR_STATIC);
}
// Trigger osr compilation
int result = 0;
for (long i = 0; i < limit; ++i) {
result += staticMethod();
}
return result;
}
private int osrMethod(long limit) {
private int osrMethod(long limit) throws Exception {
int result = 0;
if (limit != 1) {
// Make sure there is no compiled version after warmup
waitAndDeoptimize(OSR_METHOD);
result = warmup(OSR_METHOD);
}
// Trigger osr compilation
int result = 0;
for (long i = 0; i < limit; ++i) {
result += method();
}
......@@ -663,13 +664,12 @@ enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase {
}
// 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) {
// Make sure there is no compiled version after warmup
waitAndDeoptimize(OSR_CONSTRUCTOR);
result = warmup(OSR_CONSTRUCTOR);
}
// Trigger osr compilation
int result = 0;
for (long i = 0; i < limit; ++i) {
result += method();
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册