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