Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
8276546: [IR Framework] Whitelist and ignore CompileThreshold
Reviewed-by: kvn, neliasso
  • Loading branch information
chhagedorn committed Nov 11, 2021
1 parent 91bb0d6 commit 7a140af
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 3 deletions.
Expand Up @@ -122,6 +122,7 @@ public class TestFramework {
"BackgroundCompilation",
"Xbatch",
"TieredCompilation",
"CompileThreshold",
"Xmixed",
"server",
"Xlog",
Expand Down
Expand Up @@ -37,6 +37,7 @@
import java.util.*;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.stream.Collectors;

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

if (PREFER_COMMAND_LINE_FLAGS) {
// Prefer flags set via the command line over the ones set by scenarios.
cmds.addAll(Arrays.asList(jtregVMFlags));
cmds.addAll(jtregVMFlags);
}

if (WARMUP_ITERATIONS < 0 && defaultWarmup != -1) {
Expand Down
@@ -0,0 +1,103 @@
/*
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/

package ir_framework.tests;

import compiler.lib.ir_framework.*;
import compiler.lib.ir_framework.driver.IRViolationException;
import jdk.test.lib.Asserts;

/*
* @test
* @bug 8276546
* @requires vm.debug == true & vm.compMode != "Xint" & vm.compMode != "Xcomp" & vm.compiler1.enabled & vm.compiler2.enabled & vm.flagless
* @summary Test that CompileThreshold flag is ignored when passed as Java/VM option to the framework.
* Normally, the framework should be called with driver.
* @library /test/lib /testlibrary_tests /
* @run main/othervm -XX:CompileThreshold=12 -XX:+UseG1GC ir_framework.tests.TestCompileThreshold
*/

public class TestCompileThreshold {
public int iFld = 0;

public static void main(String[] args) throws Exception {
try {
// CompileThreshold=12 passed to the JTreg test is ignored even though we prefer command line flags.
// CompileThreshold=10 is user defined and passed directly to the framework and thus not ignored.
// InterpreterProfilePercentage=0 ensures that we compile exactly after 10 invocations.
TestFramework.runWithFlags("-XX:CompileThreshold=10", "-XX:InterpreterProfilePercentage=0",
"-XX:-TieredCompilation", "-DTest=testWithCompileThreshold",
"-DPreferCommandLineFlags=true");
} catch (IRViolationException e) {
Asserts.assertTrue(e.getExceptionInfo().contains("Failed IR Rules (1)"), "exactly one rule failed");
Asserts.assertTrue(e.getExceptionInfo().contains("testWithCompileThreshold()"),
"testWithCompileThreshold() failed");
}

try {
TestFramework.runWithFlags("-XX:InterpreterProfilePercentage=0", "-XX:-TieredCompilation",
"-DTest=testWithoutCompileThreshold");
} catch (IRViolationException e) {
Asserts.assertTrue(e.getExceptionInfo().contains("Failed IR Rules (1)"), "exactly one rule failed");
Asserts.assertTrue(e.getExceptionInfo().contains("testWithoutCompileThreshold()"),
"testWithoutCompileThreshold() failed");
}
}

@Test
@IR(counts = {IRNode.CALL, "1"}) // fails
public void testWithCompileThreshold() {
iFld++;
}

@Run(test = "testWithCompileThreshold")
@Warmup(20)
public void runTestWithCompileThreshold(RunInfo info) {
if (iFld == 10) {
TestFramework.assertNotCompiled(info.getTest());
} else if (iFld == 11) {
// CompileThreshold=10 is passed directly as a flag to the framework.
// Therefore, testWithCompileThreshold() must be compiled by now.
TestFramework.assertCompiled(info.getTest());
}
testWithCompileThreshold();
}


@Test
@IR(counts = {IRNode.CALL, "1"}) // fails
public void testWithoutCompileThreshold() {
iFld++;
}

@Run(test = "testWithoutCompileThreshold")
@Warmup(20)
public void runTestWithoutCompileThreshold(RunInfo info) {
testWithCompileThreshold();
if (info.isWarmUp()) {
// CompileThreshold=12 is passed to the JTreg test but not directly to the framework.
// Therefore, it is ignored and we do not trigger a compilation until the framework does.
TestFramework.assertNotCompiled(info.getTest());
}
}
}

3 comments on commit 7a140af

@openjdk-notifier
Copy link

Choose a reason for hiding this comment

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

@GoeLin
Copy link
Member

@GoeLin GoeLin commented on 7a140af Jul 4, 2022

Choose a reason for hiding this comment

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

/backport jdk17u-dev

@openjdk
Copy link

@openjdk openjdk bot commented on 7a140af Jul 4, 2022

Choose a reason for hiding this comment

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

@GoeLin the backport was successfully created on the branch GoeLin-backport-7a140af2 in my personal fork of openjdk/jdk17u-dev. To create a pull request with this backport targeting openjdk/jdk17u-dev:master, just click the following link:

➡️ Create pull request

The title of the pull request is automatically filled in correctly and below you find a suggestion for the pull request body:

Hi all,

This pull request contains a backport of commit 7a140af2 from the openjdk/jdk repository.

The commit being backported was authored by Christian Hagedorn on 11 Nov 2021 and was reviewed by Vladimir Kozlov and Nils Eliasson.

Thanks!

If you need to update the source branch of the pull then run the following commands in a local clone of your personal fork of openjdk/jdk17u-dev:

$ git fetch https://github.com/openjdk-bots/jdk17u-dev GoeLin-backport-7a140af2:GoeLin-backport-7a140af2
$ git checkout GoeLin-backport-7a140af2
# make changes
$ git add paths/to/changed/files
$ git commit --message 'Describe additional changes made'
$ git push https://github.com/openjdk-bots/jdk17u-dev GoeLin-backport-7a140af2

Please sign in to comment.