Skip to content

Commit

Permalink
8270447: [IR Framework] Add missing compilation level restriction whe…
Browse files Browse the repository at this point in the history
…n using FlipC1C2 stress option

Backport-of: 36aefa351afeb5fd6b87060e06c1e8060afb87a0
  • Loading branch information
GoeLin committed Sep 20, 2023
1 parent be52dc5 commit f908cee
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions test/hotspot/jtreg/compiler/lib/ir_framework/test/TestVM.java
Expand Up @@ -281,7 +281,7 @@ private void addBaseTests() {
BaseTest baseTest = new BaseTest(test, shouldExcludeTest(m.getName()));
allTests.add(baseTest);
if (PRINT_VALID_IR_RULES) {
irMatchRulePrinter.emitRuleEncoding(m, baseTest.isSkipped());
irMatchRulePrinter.emitRuleEncoding(m, baseTest.isSkipped());
}
} catch (TestFormatException e) {
// Failure logged. Continue and report later.
Expand Down Expand Up @@ -462,19 +462,20 @@ private void dontCompileWithCompiler(Executable ex, Compiler compiler) {
private void applyForceCompileCommand(Executable ex) {
ForceCompile forceCompileAnno = getAnnotation(ex, ForceCompile.class);
if (forceCompileAnno != null) {
CompLevel complevel = forceCompileAnno.value();
TestFormat.check(complevel != CompLevel.SKIP && complevel != CompLevel.WAIT_FOR_COMPILATION,
CompLevel compLevel = forceCompileAnno.value();
TestFormat.check(compLevel != CompLevel.SKIP && compLevel != CompLevel.WAIT_FOR_COMPILATION,
"Cannot define compilation level SKIP or WAIT_FOR_COMPILATION in @ForceCompile at " + ex);
complevel = restrictCompLevel(forceCompileAnno.value());
compLevel = restrictCompLevel(forceCompileAnno.value());
if (FLIP_C1_C2) {
complevel = complevel.flipCompLevel();
compLevel = compLevel.flipCompLevel();
compLevel = restrictCompLevel(compLevel.flipCompLevel());
}
if (EXCLUDE_RANDOM) {
complevel = complevel.excludeCompilationRandomly(ex);
compLevel = compLevel.excludeCompilationRandomly(ex);
}
if (complevel != CompLevel.SKIP) {
enqueueForCompilation(ex, complevel);
forceCompileMap.put(ex, complevel);
if (compLevel != CompLevel.SKIP) {
enqueueForCompilation(ex, compLevel);
forceCompileMap.put(ex, compLevel);
}
}
}
Expand Down Expand Up @@ -504,7 +505,7 @@ private void setupDeclaredTests() {
} else {
TestFormat.checkNoThrow(!m.isAnnotationPresent(IR.class), "Found @IR annotation on non-@Test method " + m);
TestFormat.checkNoThrow(!m.isAnnotationPresent(Warmup.class) || getAnnotation(m, Run.class) != null,
"Found @Warmup annotation on non-@Test or non-@Run method " + m);
"Found @Warmup annotation on non-@Test or non-@Run method " + m);
}
} catch (TestFormatException e) {
// Failure logged. Continue and report later.
Expand All @@ -530,6 +531,7 @@ private void addDeclaredTest(Method m) {
CompLevel compLevel = restrictCompLevel(testAnno.compLevel());
if (FLIP_C1_C2) {
compLevel = compLevel.flipCompLevel();
compLevel = restrictCompLevel(compLevel.flipCompLevel());
}
if (EXCLUDE_RANDOM) {
compLevel = compLevel.excludeCompilationRandomly(m);
Expand Down Expand Up @@ -727,8 +729,8 @@ private void checkCustomRunTest(Method m, String testName, Method testMethod, De
"Cannot use @Arguments at test method " + testMethod + " in combination with @Run method " + m);
Warmup warmupAnno = getAnnotation(testMethod, Warmup.class);
TestFormat.checkNoThrow(warmupAnno == null,
"Cannot set @Warmup at @Test method " + testMethod + " when used with its @Run method "
+ m + ". Use @Warmup at @Run method instead.");
"Cannot set @Warmup at @Test method " + testMethod + " when used with its @Run method "
+ m + ". Use @Warmup at @Run method instead.");
Test testAnno = getAnnotation(testMethod, Test.class);
TestFormat.checkNoThrow(runMode != RunMode.STANDALONE || testAnno.compLevel() == CompLevel.ANY,
"Setting explicit compilation level for @Test method " + testMethod + " has no effect "
Expand Down Expand Up @@ -864,7 +866,7 @@ enum TriState {

public static void compile(Method m, CompLevel compLevel) {
TestRun.check(compLevel != CompLevel.SKIP && compLevel != CompLevel.WAIT_FOR_COMPILATION,
"Invalid compilation request with level " + compLevel);
"Invalid compilation request with level " + compLevel);
enqueueForCompilation(m, compLevel);
}

Expand Down Expand Up @@ -907,7 +909,7 @@ public static void assertDeoptimizedByC2(Method m) {
*/
private static boolean notUnstableDeoptAssertion(Method m, CompLevel level) {
return (USE_COMPILER && !XCOMP && !IGNORE_COMPILER_CONTROLS && !TEST_C1 &&
(!EXCLUDE_RANDOM || WHITE_BOX.isMethodCompilable(m, level.getValue(), false)));
(!EXCLUDE_RANDOM || WHITE_BOX.isMethodCompilable(m, level.getValue(), false)));
}

public static void assertCompiledByC1(Method m) {
Expand Down Expand Up @@ -962,7 +964,7 @@ private static TriState compiledAtLevel(Method m, CompLevel level) {
default -> throw new TestRunException("compiledAtLevel() should not be called with " + level);
}
}
if (!USE_COMPILER || XCOMP || TEST_C1 || IGNORE_COMPILER_CONTROLS ||
if (!USE_COMPILER || XCOMP || TEST_C1 || IGNORE_COMPILER_CONTROLS || FLIP_C1_C2 ||
(EXCLUDE_RANDOM && !WHITE_BOX.isMethodCompilable(m, level.getValue(), false))) {
return TriState.Maybe;
}
Expand Down

1 comment on commit f908cee

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.