test/compiler/whitebox/CompilerWhiteBoxTest.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File
hotspot Cdiff test/compiler/whitebox/CompilerWhiteBoxTest.java
test/compiler/whitebox/CompilerWhiteBoxTest.java
Print this page
*** 67,87 ****
protected static final int TIERED_STOP_AT_LEVEL
= Integer.parseInt(getVMOption("TieredStopAtLevel", "0"));
/** Flag for verbose output, true if {@code -Dverbose} specified */
protected static final boolean IS_VERBOSE
= System.getProperty("verbose") != null;
! /** count of invocation to triger compilation */
protected static final int THRESHOLD;
! /** count of invocation to triger OSR compilation */
protected static final long BACKEDGE_THRESHOLD;
/** Value of {@code java.vm.info} (interpreted|mixed|comp mode) */
protected static final String MODE = System.getProperty("java.vm.info");
static {
if (TIERED_COMPILATION) {
BACKEDGE_THRESHOLD = THRESHOLD = 150000;
} else {
THRESHOLD = COMPILE_THRESHOLD;
BACKEDGE_THRESHOLD = COMPILE_THRESHOLD * Long.parseLong(getVMOption(
"OnStackReplacePercentage"));
}
}
--- 67,91 ----
protected static final int TIERED_STOP_AT_LEVEL
= Integer.parseInt(getVMOption("TieredStopAtLevel", "0"));
/** Flag for verbose output, true if {@code -Dverbose} specified */
protected static final boolean IS_VERBOSE
= System.getProperty("verbose") != null;
! /** invocation count to trigger compilation */
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;
/** Value of {@code java.vm.info} (interpreted|mixed|comp mode) */
protected static final String MODE = System.getProperty("java.vm.info");
static {
if (TIERED_COMPILATION) {
+ OSR_WARMUP = 200;
BACKEDGE_THRESHOLD = THRESHOLD = 150000;
} else {
+ OSR_WARMUP = 2000;
THRESHOLD = COMPILE_THRESHOLD;
BACKEDGE_THRESHOLD = COMPILE_THRESHOLD * Long.parseLong(getVMOption(
"OnStackReplacePercentage"));
}
}
*** 481,512 ****
private static final Callable<Integer> OSR_CONSTRUCTOR_CALLABLE
= new Callable<Integer>() {
@Override
public Integer call() throws Exception {
! return new Helper(null).hashCode();
}
};
private static final Callable<Integer> OSR_METHOD_CALLABLE
= new Callable<Integer>() {
private final Helper helper = new Helper();
@Override
public Integer call() throws Exception {
! return helper.osrMethod();
}
};
private static final Callable<Integer> OSR_STATIC_CALLABLE
= new Callable<Integer>() {
@Override
public Integer call() throws Exception {
! return osrStaticMethod();
}
};
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;
--- 485,558 ----
private static final Callable<Integer> OSR_CONSTRUCTOR_CALLABLE
= new Callable<Integer>() {
@Override
public Integer call() throws Exception {
! int result = warmup(OSR_CONSTRUCTOR);
! return result + new Helper(null, CompilerWhiteBoxTest.BACKEDGE_THRESHOLD).hashCode();
}
};
private static final Callable<Integer> OSR_METHOD_CALLABLE
= new Callable<Integer>() {
private final Helper helper = new Helper();
@Override
public Integer call() throws Exception {
! int result = warmup(OSR_METHOD);
! return result + helper.osrMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD);
}
};
private static final Callable<Integer> OSR_STATIC_CALLABLE
= new Callable<Integer>() {
@Override
public Integer call() throws Exception {
! int result = warmup(OSR_STATIC);
! return result + osrStaticMethod(CompilerWhiteBoxTest.BACKEDGE_THRESHOLD);
}
};
+ /**
+ * Executes the method multiple times to make sure we have
+ * enough profiling information before triggering an OSR
+ * compilation. Otherwise the C2 compiler may add uncommon traps.
+ *
+ * @param m Method to be executed
+ * @return Number of times the method was executed
+ * @throws Exception
+ */
+ private static int warmup(Method m) throws Exception {
+ Helper helper = new Helper();
+ int result = 0;
+ for (long i = 0; i < CompilerWhiteBoxTest.OSR_WARMUP; ++i) {
+ result += (int)m.invoke(helper, 1);
+ }
+ // Make sure method is not (yet) compiled
+ WhiteBox.getWhiteBox().deoptimizeMethod(m, false);
+ return result;
+ }
+
+ /**
+ * Executes the constructor multiple times to make sure we
+ * have enough profiling information before triggering an OSR
+ * compilation. Otherwise the C2 compiler may add uncommon traps.
+ *
+ * @param c Constructor to be executed
+ * @return Number of times the constructor was executed
+ * @throws Exception
+ */
+ private static int warmup(Constructor c) throws Exception {
+ int result = 0;
+ for (long i = 0; i < CompilerWhiteBoxTest.OSR_WARMUP; ++i) {
+ result += c.newInstance(null, 1).hashCode();
+ }
+ // Make sure method is not (yet) compiled
+ WhiteBox.getWhiteBox().deoptimizeMethod(c, false);
+ 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;
*** 519,568 ****
throw new RuntimeException(
"exception on getting method Helper.<init>(int)", e);
}
try {
OSR_CONSTRUCTOR = Helper.class.getDeclaredConstructor(
! Object.class);
} catch (NoSuchMethodException | SecurityException e) {
throw new RuntimeException(
! "exception on getting method Helper.<init>(Object)", e);
}
METHOD = getMethod("method");
STATIC = getMethod("staticMethod");
! OSR_METHOD = getMethod("osrMethod");
! OSR_STATIC = getMethod("osrStaticMethod");
}
! private static Method getMethod(String name) {
try {
! return Helper.class.getDeclaredMethod(name);
} 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() {
int result = 0;
! for (long i = 0; i < CompilerWhiteBoxTest.BACKEDGE_THRESHOLD; ++i) {
result += staticMethod();
}
return result;
}
! private int osrMethod() {
int result = 0;
! for (long i = 0; i < CompilerWhiteBoxTest.BACKEDGE_THRESHOLD; ++i) {
result += method();
}
return result;
}
--- 565,613 ----
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) {
int result = 0;
! for (long i = 0; i < limit; ++i) {
result += staticMethod();
}
return result;
}
! private int osrMethod(long limit) {
int result = 0;
! for (long i = 0; i < limit; ++i) {
result += method();
}
return result;
}
*** 572,584 ****
public Helper() {
x = 0;
}
// for OSR constructor test case
! private Helper(Object o) {
int result = 0;
! for (long i = 0; i < CompilerWhiteBoxTest.BACKEDGE_THRESHOLD; ++i) {
result += method();
}
x = result;
}
--- 617,629 ----
public Helper() {
x = 0;
}
// for OSR constructor test case
! private Helper(Object o, long limit) {
int result = 0;
! for (long i = 0; i < limit; ++i) {
result += method();
}
x = result;
}
test/compiler/whitebox/CompilerWhiteBoxTest.java
Index
Unified diffs
Context diffs
Sdiffs
Patch
New
Old
Previous File
Next File