8288926: make runtime/logging/DeoptStats.java more reliable

Reviewed-by: simonis, phh
This commit is contained in:
Xin Liu 2022-06-22 15:57:48 +00:00
parent d4de475747
commit 82c77ca807

View File

@ -28,11 +28,9 @@
* @summary Verify that the Deoptimization statistics are printed to the VM/Compiler log file
* @library /test/lib
* @run main/othervm -Xbatch -XX:-UseOnStackReplacement -XX:-OmitStackTraceInFastThrow
* -XX:-OmitStackTraceInFastThrow
* -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation
* -XX:-LogVMOutput -XX:LogFile=compilation.log DeoptStats
* @run main/othervm -Xbatch -XX:-UseOnStackReplacement -XX:-OmitStackTraceInFastThrow
* -XX:-OmitStackTraceInFastThrow
* -XX:+UnlockDiagnosticVMOptions -XX:+LogCompilation
* -XX:+LogVMOutput -XX:LogFile=vmOutput.log DeoptStats
* @run main/othervm DeoptStats compilation.log vmOutput.log
@ -45,10 +43,16 @@ public class DeoptStats {
static class Value {
int i;
public Value(int i) { this.i = i; }
}
static int f(Value v) {
return v.i;
try {
return v.i;
} catch (NullPointerException npe) {
return -1;
}
}
public static void verify(String[] logFiles) throws Exception {
@ -64,12 +68,12 @@ public class DeoptStats {
if (args.length > 0) {
verify(args);
} else {
Value zero = new Value(0);
for (int i = 0; i < 20_000; i++) {
try {
f(null);
}
catch (NullPointerException npe) { }
f(zero);
}
// trigger null_check
f(null);
}
}
}