Skip to content

Commit 3b189e0

Browse files
author
Hamlin Li
committed
8351345: [IR Framework] Improve reported disabled IR verification messages
Reviewed-by: chagedorn, epeter
1 parent 95b66d5 commit 3b189e0

File tree

1 file changed

+37
-21
lines changed

1 file changed

+37
-21
lines changed

test/hotspot/jtreg/compiler/lib/ir_framework/TestFramework.java

Lines changed: 37 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -593,27 +593,42 @@ private void installWhiteBox() {
593593
* Disable IR verification completely in certain cases.
594594
*/
595595
private void disableIRVerificationIfNotFeasible() {
596-
if (irVerificationPossible) {
597-
irVerificationPossible = Platform.isDebugBuild() && !Platform.isInt() && !Platform.isComp();
598-
if (!irVerificationPossible) {
599-
System.out.println("IR verification disabled due to not running a debug build (required for PrintIdeal" +
600-
"and PrintOptoAssembly), running with -Xint, or -Xcomp (use warm-up of 0 instead)");
601-
return;
602-
}
596+
if (!irVerificationPossible) {
597+
return;
598+
}
603599

604-
irVerificationPossible = hasIRAnnotations();
605-
if (!irVerificationPossible) {
606-
System.out.println("IR verification disabled due to test " + testClass + " not specifying any @IR annotations");
607-
return;
608-
}
600+
boolean debugTest = Platform.isDebugBuild();
601+
boolean intTest = !Platform.isInt();
602+
boolean compTest = !Platform.isComp();
603+
boolean irTest = hasIRAnnotations();
604+
// No IR verification is done if additional non-whitelisted JTreg VM or Javaoptions flag is specified.
605+
List<String> nonWhiteListedFlags = anyNonWhitelistedJTregVMAndJavaOptsFlags();
606+
boolean nonWhiteListedTest = nonWhiteListedFlags.isEmpty();
609607

610-
// No IR verification is done if additional non-whitelisted JTreg VM or Javaoptions flag is specified.
611-
irVerificationPossible = onlyWhitelistedJTregVMAndJavaOptsFlags();
612-
if (!irVerificationPossible) {
613-
System.out.println("IR verification disabled due to using non-whitelisted JTreg VM or Javaoptions flag(s)."
614-
+ System.lineSeparator());
615-
}
608+
irVerificationPossible = debugTest && intTest && compTest && irTest && nonWhiteListedTest;
609+
if (irVerificationPossible) {
610+
return;
616611
}
612+
613+
System.out.println("IR verification disabled due to the following reason(s):");
614+
if (!debugTest) {
615+
System.out.println("- Not running a debug build (required for PrintIdeal and PrintOptoAssembly)");
616+
}
617+
if (!intTest) {
618+
System.out.println("- Running with -Xint (no compilations)");
619+
}
620+
if (!compTest) {
621+
System.out.println("- Running with -Xcomp (use warm-up of 0 instead)");
622+
}
623+
if (!irTest) {
624+
System.out.println("- Test " + testClass + " not specifying any @IR annotations");
625+
}
626+
if (!nonWhiteListedTest) {
627+
System.out.println("- Using non-whitelisted JTreg VM or Javaoptions flag(s):");
628+
nonWhiteListedFlags.forEach((f) -> System.out.println(" - " + f));
629+
}
630+
631+
System.out.println("");
617632
}
618633

619634
/**
@@ -741,18 +756,19 @@ private boolean hasIRAnnotations() {
741756
return Arrays.stream(testClass.getDeclaredMethods()).anyMatch(m -> m.getAnnotationsByType(IR.class).length > 0);
742757
}
743758

744-
private boolean onlyWhitelistedJTregVMAndJavaOptsFlags() {
759+
private List<String> anyNonWhitelistedJTregVMAndJavaOptsFlags() {
745760
List<String> flags = Arrays.stream(Utils.getTestJavaOpts())
746761
.map(s -> s.replaceFirst("-XX:[+|-]?|-(?=[^D|^e])", ""))
747762
.collect(Collectors.toList());
763+
List<String> nonWhiteListedFlags = new ArrayList();
748764
for (String flag : flags) {
749765
// Property flags (prefix -D), -ea and -esa are whitelisted.
750766
if (!flag.startsWith("-D") && !flag.startsWith("-e") && JTREG_WHITELIST_FLAGS.stream().noneMatch(flag::contains)) {
751767
// Found VM flag that is not whitelisted
752-
return false;
768+
nonWhiteListedFlags.add(flag);
753769
}
754770
}
755-
return true;
771+
return nonWhiteListedFlags;
756772
}
757773

758774
private void runTestVM(List<String> additionalFlags) {

0 commit comments

Comments
 (0)