Skip to content

Commit 7a140af

Browse files
committed
8276546: [IR Framework] Whitelist and ignore CompileThreshold
Reviewed-by: kvn, neliasso
1 parent 91bb0d6 commit 7a140af

File tree

3 files changed

+109
-3
lines changed

3 files changed

+109
-3
lines changed

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,7 @@ public class TestFramework {
122122
"BackgroundCompilation",
123123
"Xbatch",
124124
"TieredCompilation",
125+
"CompileThreshold",
125126
"Xmixed",
126127
"server",
127128
"Xlog",

test/hotspot/jtreg/compiler/lib/ir_framework/driver/TestVMProcess.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
import java.util.*;
3838
import java.util.regex.Matcher;
3939
import java.util.regex.Pattern;
40+
import java.util.stream.Collectors;
4041

4142
/**
4243
* This class prepares, creates, and runs the "test" VM with verification of proper termination. The class also stores
@@ -97,9 +98,10 @@ private void prepareTestVMFlags(List<String> additionalFlags, TestFrameworkSocke
9798
cmds.add("-Xbootclasspath/a:.");
9899
cmds.add("-XX:+UnlockDiagnosticVMOptions");
99100
cmds.add("-XX:+WhiteBoxAPI");
100-
String[] jtregVMFlags = Utils.getTestJavaOpts();
101+
// Ignore CompileCommand flags which have an impact on the profiling information.
102+
List<String> jtregVMFlags = Arrays.stream(Utils.getTestJavaOpts()).filter(s -> !s.contains("CompileThreshold")).collect(Collectors.toList());
101103
if (!PREFER_COMMAND_LINE_FLAGS) {
102-
cmds.addAll(Arrays.asList(jtregVMFlags));
104+
cmds.addAll(jtregVMFlags);
103105
}
104106
// Add server property flag that enables test VM to print encoding for IR verification last and debug messages.
105107
cmds.add(socket.getPortPropertyFlag());
@@ -111,7 +113,7 @@ private void prepareTestVMFlags(List<String> additionalFlags, TestFrameworkSocke
111113

112114
if (PREFER_COMMAND_LINE_FLAGS) {
113115
// Prefer flags set via the command line over the ones set by scenarios.
114-
cmds.addAll(Arrays.asList(jtregVMFlags));
116+
cmds.addAll(jtregVMFlags);
115117
}
116118

117119
if (WARMUP_ITERATIONS < 0 && defaultWarmup != -1) {
Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
/*
2+
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* This code is free software; you can redistribute it and/or modify it
6+
* under the terms of the GNU General Public License version 2 only, as
7+
* published by the Free Software Foundation.
8+
*
9+
* This code is distributed in the hope that it will be useful, but WITHOUT
10+
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11+
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12+
* version 2 for more details (a copy is included in the LICENSE file that
13+
* accompanied this code).
14+
*
15+
* You should have received a copy of the GNU General Public License version
16+
* 2 along with this work; if not, write to the Free Software Foundation,
17+
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18+
*
19+
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20+
* or visit www.oracle.com if you need additional information or have any
21+
* questions.
22+
*/
23+
24+
package ir_framework.tests;
25+
26+
import compiler.lib.ir_framework.*;
27+
import compiler.lib.ir_framework.driver.IRViolationException;
28+
import jdk.test.lib.Asserts;
29+
30+
/*
31+
* @test
32+
* @bug 8276546
33+
* @requires vm.debug == true & vm.compMode != "Xint" & vm.compMode != "Xcomp" & vm.compiler1.enabled & vm.compiler2.enabled & vm.flagless
34+
* @summary Test that CompileThreshold flag is ignored when passed as Java/VM option to the framework.
35+
* Normally, the framework should be called with driver.
36+
* @library /test/lib /testlibrary_tests /
37+
* @run main/othervm -XX:CompileThreshold=12 -XX:+UseG1GC ir_framework.tests.TestCompileThreshold
38+
*/
39+
40+
public class TestCompileThreshold {
41+
public int iFld = 0;
42+
43+
public static void main(String[] args) throws Exception {
44+
try {
45+
// CompileThreshold=12 passed to the JTreg test is ignored even though we prefer command line flags.
46+
// CompileThreshold=10 is user defined and passed directly to the framework and thus not ignored.
47+
// InterpreterProfilePercentage=0 ensures that we compile exactly after 10 invocations.
48+
TestFramework.runWithFlags("-XX:CompileThreshold=10", "-XX:InterpreterProfilePercentage=0",
49+
"-XX:-TieredCompilation", "-DTest=testWithCompileThreshold",
50+
"-DPreferCommandLineFlags=true");
51+
} catch (IRViolationException e) {
52+
Asserts.assertTrue(e.getExceptionInfo().contains("Failed IR Rules (1)"), "exactly one rule failed");
53+
Asserts.assertTrue(e.getExceptionInfo().contains("testWithCompileThreshold()"),
54+
"testWithCompileThreshold() failed");
55+
}
56+
57+
try {
58+
TestFramework.runWithFlags("-XX:InterpreterProfilePercentage=0", "-XX:-TieredCompilation",
59+
"-DTest=testWithoutCompileThreshold");
60+
} catch (IRViolationException e) {
61+
Asserts.assertTrue(e.getExceptionInfo().contains("Failed IR Rules (1)"), "exactly one rule failed");
62+
Asserts.assertTrue(e.getExceptionInfo().contains("testWithoutCompileThreshold()"),
63+
"testWithoutCompileThreshold() failed");
64+
}
65+
}
66+
67+
@Test
68+
@IR(counts = {IRNode.CALL, "1"}) // fails
69+
public void testWithCompileThreshold() {
70+
iFld++;
71+
}
72+
73+
@Run(test = "testWithCompileThreshold")
74+
@Warmup(20)
75+
public void runTestWithCompileThreshold(RunInfo info) {
76+
if (iFld == 10) {
77+
TestFramework.assertNotCompiled(info.getTest());
78+
} else if (iFld == 11) {
79+
// CompileThreshold=10 is passed directly as a flag to the framework.
80+
// Therefore, testWithCompileThreshold() must be compiled by now.
81+
TestFramework.assertCompiled(info.getTest());
82+
}
83+
testWithCompileThreshold();
84+
}
85+
86+
87+
@Test
88+
@IR(counts = {IRNode.CALL, "1"}) // fails
89+
public void testWithoutCompileThreshold() {
90+
iFld++;
91+
}
92+
93+
@Run(test = "testWithoutCompileThreshold")
94+
@Warmup(20)
95+
public void runTestWithoutCompileThreshold(RunInfo info) {
96+
testWithCompileThreshold();
97+
if (info.isWarmUp()) {
98+
// CompileThreshold=12 is passed to the JTreg test but not directly to the framework.
99+
// Therefore, it is ignored and we do not trigger a compilation until the framework does.
100+
TestFramework.assertNotCompiled(info.getTest());
101+
}
102+
}
103+
}

0 commit comments

Comments
 (0)