mirror of
https://github.com/openjdk/jdk.git
synced 2026-01-28 12:09:14 +00:00
8375271: [IR Framework] Rename IREncoding to ApplicableIRRules and driver/flag/test VM to Driver/Flag/Test VM
Reviewed-by: dfenacci, thartmann, mhaessig
This commit is contained in:
parent
6942bb2b31
commit
e7f1f16a88
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -103,7 +103,7 @@ abstract public class AbstractInfo {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a boolean indicating if the test VM runs with flags that allow C2 compilations.
|
||||
* Returns a boolean indicating if the Test VM runs with flags that allow C2 compilations.
|
||||
*
|
||||
* @return {@code true} if C2 compilations are allowed;
|
||||
* {@code false} otherwise (run with {@code -XX:TieredStopAtLevel={1,2,3}, -XX:-UseCompiler}).
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -51,7 +51,7 @@ public enum CompLevel {
|
||||
* Can only be used at {@link Test#compLevel()}. After the warm-up, the framework keeps invoking the test over a span
|
||||
* of 10s (configurable by setting the property flag {@code -DWaitForCompilationTimeout}) until HotSpot compiles the
|
||||
* {@link Test} method. If the method was not compiled after 10s, an exception is thrown. The framework does not wait
|
||||
* for the compilation if the test VM is run with {@code -Xcomp}, {@code -XX:-UseCompiler}, or
|
||||
* for the compilation if the Test VM is run with {@code -Xcomp}, {@code -XX:-UseCompiler}, or
|
||||
* {@code -DExcludeRandom=true}.
|
||||
*/
|
||||
WAIT_FOR_COMPILATION(-4),
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -55,7 +55,7 @@ import java.lang.annotation.RetentionPolicy;
|
||||
* For any other flag specified either by user code (e.g. {@link Scenario#Scenario(int, String...)},
|
||||
* {@link TestFramework#runWithFlags(String...) etc.} or as part of the JTreg whitelist, IR verification is applied.
|
||||
* To restrict the application of IR rules when certain flags are present that could change the IR, each {@code @IR}
|
||||
* annotation can specify additional preconditions on the allowed test VM flags that must hold when an IR rule is applied.
|
||||
* annotation can specify additional preconditions on the allowed Test VM flags that must hold when an IR rule is applied.
|
||||
* If the specified preconditions fail, then the framework does not apply the IR rule. These preconditions can be
|
||||
* set with {@link #applyIf()}, {@link #applyIfNot()}, {@link #applyIfAnd()}, or {@link #applyIfOr()}.
|
||||
* <p>
|
||||
|
||||
@ -115,7 +115,7 @@ The [@IR](./IR.java) annotation provides two kinds of checks:
|
||||
- `counts`: A list of one or more "IR node/user-defined regex - counter" pairs which specify how often each IR node/user-defined regex should be matched on the compilation output of each compile phase.
|
||||
|
||||
#### Disable/Enable IR Rules based on VM Flags
|
||||
One might also want to restrict the application of certain `@IR` rules depending on the used flags in the test VM. These could be flags defined by the user or by JTreg. In the latter case, the flags must be whitelisted in `JTREG_WHITELIST_FLAGS` in [TestFramework](./TestFramework.java) (i.e. have no unexpected impact on the IR except if the flag simulates a specific machine setup like `UseAVX={1,2,3}` etc.) to enable an IR verification by the framework. The `@IR` rules thus have an option to restrict their application:
|
||||
One might also want to restrict the application of certain `@IR` rules depending on the used flags in the Test VM. These could be flags defined by the user or by JTreg. In the latter case, the flags must be whitelisted in `JTREG_WHITELIST_FLAGS` in [TestFramework](./TestFramework.java) (i.e. have no unexpected impact on the IR except if the flag simulates a specific machine setup like `UseAVX={1,2,3}` etc.) to enable an IR verification by the framework. The `@IR` rules thus have an option to restrict their application:
|
||||
|
||||
- `applyIf`: Only apply a rule if a flag has the specified value/range of values.
|
||||
- `applyIfNot`: Only apply a rule if a flag has **not** a specified value/range of values
|
||||
@ -144,7 +144,7 @@ An IR verification cannot always be performed. Certain VM flags explicitly disab
|
||||
More information about IR matching can be found in the Javadocs of [IR](./IR.java). Concrete examples on how to specify IR constraint/rules can be found in [IRExample](../../../testlibrary_tests/ir_framework/examples/IRExample.java), [TestIRMatching](../../../testlibrary_tests/ir_framework/tests/TestIRMatching.java) (internal framework test), and [TestPhaseIRMatching](../../../testlibrary_tests/ir_framework/tests/TestPhaseIRMatching.java) (internal framework test).
|
||||
|
||||
### 2.3 Test VM Flags and Scenarios
|
||||
The recommended way to use the framework is by defining a single `@run driver` statement in the JTreg header which, however, does not allow the specification of additional test VM flags. Instead, the user has the possibility to provide VM flags by calling `TestFramework.runWithFlags()` or by creating a `TestFramework` builder object on which `addFlags()` can be called.
|
||||
The recommended way to use the framework is by defining a single `@run driver` statement in the JTreg header which, however, does not allow the specification of additional Test VM flags. Instead, the user has the possibility to provide VM flags by calling `TestFramework.runWithFlags()` or by creating a `TestFramework` builder object on which `addFlags()` can be called.
|
||||
|
||||
If a user wants to provide multiple flag combinations for a single test, he or she has the option to provide different scenarios. A scenario based flag will always have precedence over other user defined flags. More information about scenarios can be found in the Javadocs of [Scenario](./Scenario.java). If a user wants to test all combinations of multiple sets of flags, they can use `TestFramework.addCrossProductScenarios()`.
|
||||
|
||||
@ -174,16 +174,16 @@ The framework provides various stress and debug flags. They should mainly be use
|
||||
- `-DExclude=test3`: Provide a list of `@Test` method names which should be excluded from execution.
|
||||
- `-DScenarios=1,2`: Provide a list of scenario indexes to specify which scenarios should be executed.
|
||||
- `-DWarmup=200`: Provide a new default value of the number of warm-up iterations (framework default is 2000). This might have an influence on the resulting IR and could lead to matching failures (the user can also set a fixed default warm-up value in a test with `testFrameworkObject.setDefaultWarmup(200)`).
|
||||
- `-DReportStdout=true`: Print the standard output of the test VM.
|
||||
- `-DReportStdout=true`: Print the standard output of the Test VM.
|
||||
- `-DVerbose=true`: Enable more fine-grained logging (slows the execution down).
|
||||
- `-DReproduce=true`: Flag to use when directly running a test VM to bypass dependencies to the driver VM state (for example, when reproducing an issue).
|
||||
- `-DReproduce=true`: Flag to use when directly running a Test VM to bypass dependencies to the Driver VM state (for example, when reproducing an issue).
|
||||
- `-DPrintTimes=true`: Print the execution time measurements of each executed test.
|
||||
- `-DPrintRuleMatchingTime=true`: Print the time of matching IR rules per method. Slows down the execution as the rules are warmed up before measurement.
|
||||
- `-DVerifyVM=true`: The framework runs the test VM with additional verification flags (slows the execution down).
|
||||
- `-DVerifyVM=true`: The framework runs the Test VM with additional verification flags (slows the execution down).
|
||||
- `-DExcludeRandom=true`: The framework randomly excludes some methods from compilation. IR verification is disabled completely with this flag.
|
||||
- `-DFlipC1C2=true`: The framework compiles all `@Test` annotated method with C1 if a C2 compilation would have been applied and vice versa. IR verification is disabled completely with this flag.
|
||||
- `-DShuffleTests=false`: Disables the random execution order of all tests (such a shuffling is always done by default).
|
||||
- `-DDumpReplay=true`: Add the `DumpReplay` directive to the test VM.
|
||||
- `-DDumpReplay=true`: Add the `DumpReplay` directive to the Test VM.
|
||||
- `-DGCAfter=true`: Perform `System.gc()` after each test (slows the execution down).
|
||||
- `-DTestCompilationTimeout=20`: Change the default waiting time (default: 10s) for a compilation of a normal `@Test` annotated method.
|
||||
- `-DWaitForCompilationTimeout=20`: Change the default waiting time (default: 10s) for a compilation of a `@Test` annotated method with compilation level [WAIT\_FOR\_COMPILATION](./CompLevel.java).
|
||||
@ -193,12 +193,12 @@ The framework provides various stress and debug flags. They should mainly be use
|
||||
## 3. Test Framework Execution
|
||||
This section gives an overview of how the framework is executing a JTreg test that calls the framework from within its `main()` method.
|
||||
|
||||
The framework will spawn a new "test VM" to execute the user defined tests. The test VM collects all tests of the test class specified by the user code in `main()` and ensures that there is no violation of the required format by the framework. In a next step, the framework does the following for each test in general:
|
||||
The framework will spawn a new "Test VM" to execute the user defined tests. The Test VM collects all tests of the test class specified by the user code in `main()` and ensures that there is no violation of the required format by the framework. In a next step, the framework does the following for each test in general:
|
||||
1. Warm the test up for a predefined number of times (default 2000). This can also be adapted for all tests by using `testFrameworkobject.setDefaultWarmup(100)` or for individual tests with an additional [@Warmup](./Warmup.java) annotation.
|
||||
2. After the warm-up is finished, the framework compiles the associated `@Test` annotated method at the specified compilation level (default: C2).
|
||||
3. After the compilation, the test is invoked one more time.
|
||||
|
||||
Once the test VM terminates, IR verification (if possible) is performed on the output of the test VM. If any test throws an exception during its execution or if IR matching fails, the failures are collected and reported in a pretty format. Check the standard error and output for more information and how to reproduce these failures.
|
||||
Once the Test VM terminates, IR verification (if possible) is performed on the output of the Test VM. If any test throws an exception during its execution or if IR matching fails, the failures are collected and reported in a pretty format. Check the standard error and output for more information and how to reproduce these failures.
|
||||
|
||||
Some of the steps above can be different due to the kind of the test or due to using non-default annotation properties. These details and differences are described in the Javadocs for the three tests (see section 2.1 Different Tests).
|
||||
|
||||
@ -212,10 +212,10 @@ Additional testing was performed by converting all compiler Inline Types tests t
|
||||
## 5. Framework Package Structure
|
||||
A user only needs to import classes from the package `compiler.lib.ir_framework` (e.g. `import compiler.lib.ir_framework.*;`) which represents the interface classes to the framework. The remaining framework internal classes are kept in separate subpackages and should not directly be imported:
|
||||
|
||||
- `compiler.lib.ir_framework.driver`: These classes are used while running the driver VM (same VM as the one running the user code's `main()` method of a JTreg test).
|
||||
- `compiler.lib.ir_framework.flag`: These classes are used while running the flag VM to determine additional flags for the test VM which are required for IR verification.
|
||||
- `compiler.lib.ir_framework.test`: These classes are used while running the test VM (i.e. the actual execution of the user tests as described in section 3).
|
||||
- `compiler.lib.ir_framework.shared`: These classes can be called from either the driver, flag, or test VM.
|
||||
- `compiler.lib.ir_framework.driver`: These classes are used while running the Driver VM (same VM as the one running the user code's `main()` method of a JTreg test).
|
||||
- `compiler.lib.ir_framework.flag`: These classes are used while running the Flag VM to determine additional flags for the Test VM which are required for IR verification.
|
||||
- `compiler.lib.ir_framework.test`: These classes are used while running the Test VM (i.e. the actual execution of the user tests as described in section 3).
|
||||
- `compiler.lib.ir_framework.shared`: These classes can be called from either the driver, flag, or Test VM.
|
||||
|
||||
## 6. Summary
|
||||
The initial design and feature set was kept simple and straight forward and serves well for small to medium sized tests. There are a lot of possibilities to further enhance the framework and make it more powerful. This can be tackled in additional RFEs. A few ideas can be found as subtasks of the [initial RFE](https://bugs.openjdk.org/browse/JDK-8254129) for this framework.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -121,16 +121,16 @@ public class Scenario {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the test VM output (stdout + stderr) of this scenario from the last execution of the framework.
|
||||
* Get the Test VM output (stdout + stderr) of this scenario from the last execution of the framework.
|
||||
*
|
||||
* @return the test VM output.
|
||||
* @return the Test VM output.
|
||||
*/
|
||||
public String getTestVMOutput() {
|
||||
return testVMOutput;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the test VM output, called by the framework.
|
||||
* Set the Test VM output, called by the framework.
|
||||
*/
|
||||
void setTestVMOutput(String testVMOutput) {
|
||||
this.testVMOutput = testVMOutput;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -85,19 +85,19 @@ import java.util.stream.Stream;
|
||||
* {@code runXX()} methods of {@link TestFramework}. The second way, which gives more control, is to create a new
|
||||
* {@code TestFramework} builder object on which {@link #start()} needs to be eventually called to start the testing.
|
||||
* <p>
|
||||
* The framework is called from the <i>driver VM</i> in which the JTreg test is initially run by specifying {@code
|
||||
* The framework is called from the <i>Driver VM</i> in which the JTreg test is initially run by specifying {@code
|
||||
* @run driver} in the JTreg header. This strips all additionally specified JTreg VM and Javaoptions.
|
||||
* The framework creates a new <i>flag VM</i> with all these flags added again in order to figure out which flags are
|
||||
* The framework creates a new <i>Flag VM</i> with all these flags added again in order to figure out which flags are
|
||||
* required to run the tests specified in the test class (e.g. {@code -XX:+PrintIdeal} and {@code -XX:+PrintOptoAssembly}
|
||||
* for IR matching).
|
||||
* <p>
|
||||
* After the flag VM terminates, it starts a new <i>test VM</i> which performs the execution of the specified
|
||||
* After the Flag VM terminates, it starts a new <i>Test VM</i> which performs the execution of the specified
|
||||
* tests in the test class as described in {@link Test}, {@link Check}, and {@link Run}.
|
||||
* <p>
|
||||
* In a last step, once the test VM has terminated without exceptions, IR matching is performed if there are any IR
|
||||
* In a last step, once the Test VM has terminated without exceptions, IR matching is performed if there are any IR
|
||||
* rules and if no VM flags disable it (e.g. not running with {@code -Xint}, see {@link IR} for more details).
|
||||
* The IR regex matching is done on the output of {@code -XX:+PrintIdeal} and {@code -XX:+PrintOptoAssembly} by parsing
|
||||
* the hotspot_pid file of the test VM. Failing IR rules are reported by throwing a {@link IRViolationException}.
|
||||
* the hotspot_pid file of the Test VM. Failing IR rules are reported by throwing a {@link IRViolationException}.
|
||||
*
|
||||
* @see Test
|
||||
* @see Check
|
||||
@ -166,7 +166,7 @@ public class TestFramework {
|
||||
#############################################################
|
||||
- To only run the failed tests use -DTest, -DExclude,
|
||||
and/or -DScenarios.
|
||||
- To also get the standard output of the test VM run with
|
||||
- To also get the standard output of the Test VM run with
|
||||
-DReportStdout=true or for even more fine-grained logging
|
||||
use -DVerbose=true.
|
||||
#############################################################
|
||||
@ -236,10 +236,10 @@ public class TestFramework {
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the class from which this method was invoked from. The test VM is called with the specified {@code flags}.
|
||||
* Tests the class from which this method was invoked from. The Test VM is called with the specified {@code flags}.
|
||||
* <ul>
|
||||
* <li><p>The {@code flags} override any set VM or Javaoptions flags by JTreg by default.<p>
|
||||
* Use {@code -DPreferCommandLineFlags=true} if you want to prefer the JTreg VM and Javaoptions flags over
|
||||
* Use {@code -DPreferCommandLineFlags=true} if you want to prefer the JTreg VM and Javaoptions flags over
|
||||
* the specified {@code flags} of this method.</li>
|
||||
* <li><p>If you want to run your entire JTreg test with additional flags, use this method.</li>
|
||||
* <li><p>If you want to run your entire JTreg test with additional flags but for another test class then the one
|
||||
@ -248,7 +248,7 @@ public class TestFramework {
|
||||
* {@link #addScenarios(Scenario...)}</li>
|
||||
* </ul>
|
||||
*
|
||||
* @param flags VM flags to be used for the test VM.
|
||||
* @param flags VM flags to be used for the Test VM.
|
||||
*/
|
||||
public static void runWithFlags(String... flags) {
|
||||
StackWalker walker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE);
|
||||
@ -258,13 +258,13 @@ public class TestFramework {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add VM flags to be used for the test VM. These flags override any VM or Javaoptions set by JTreg by default.<p>
|
||||
* Add VM flags to be used for the Test VM. These flags override any VM or Javaoptions set by JTreg by default.<p>
|
||||
* Use {@code -DPreferCommandLineFlags=true} if you want to prefer the VM or Javaoptions over the scenario flags.
|
||||
*
|
||||
* <p>
|
||||
* The testing can be started by invoking {@link #start()}
|
||||
*
|
||||
* @param flags VM options to be applied to the test VM.
|
||||
* @param flags VM options to be applied to the Test VM.
|
||||
* @return the same framework instance.
|
||||
*/
|
||||
public TestFramework addFlags(String... flags) {
|
||||
@ -306,7 +306,7 @@ public class TestFramework {
|
||||
}
|
||||
|
||||
/**
|
||||
* Add scenarios to be used for the test VM. A test VM is called for each scenario in {@code scenarios} by using the
|
||||
* Add scenarios to be used for the Test VM. A Test VM is called for each scenario in {@code scenarios} by using the
|
||||
* specified VM flags in the scenario. The scenario flags override any flags set by {@link #addFlags(String...)}
|
||||
* and thus also override any VM or Javaoptions set by JTreg by default.<p>
|
||||
* Use {@code -DPreferCommandLineFlags=true} if you want to prefer the VM and Javaoptions over the scenario flags.
|
||||
@ -314,7 +314,7 @@ public class TestFramework {
|
||||
* <p>
|
||||
* The testing can be started by invoking {@link #start()}
|
||||
*
|
||||
* @param scenarios scenarios which specify specific flags for the test VM.
|
||||
* @param scenarios scenarios which specify specific flags for the Test VM.
|
||||
* @return the same framework instance.
|
||||
*/
|
||||
public TestFramework addScenarios(Scenario... scenarios) {
|
||||
@ -503,10 +503,10 @@ public class TestFramework {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the VM output of the test VM. Use {@code -DVerbose=true} to enable more debug information. If scenarios
|
||||
* Get the VM output of the Test VM. Use {@code -DVerbose=true} to enable more debug information. If scenarios
|
||||
* were run, use {@link Scenario#getTestVMOutput()}.
|
||||
*
|
||||
* @return the last test VM output.
|
||||
* @return the last Test VM output.
|
||||
*/
|
||||
public static String getLastTestVMOutput() {
|
||||
return TestVMProcess.getLastTestVMOutput();
|
||||
@ -796,9 +796,9 @@ public class TestFramework {
|
||||
}
|
||||
|
||||
/**
|
||||
* Execute a separate "flag" VM with White Box access to determine all test VM flags. The flag VM sends an encoding of
|
||||
* all required flags for the test VM to the driver VM over a socket. Once the flag VM exits, this driver VM parses the
|
||||
* test VM flags, which also determine if IR matching should be done, and then starts the test VM to execute all tests.
|
||||
* Execute a separate Flag VM with White Box access to determine all Test VM flags. The Flag VM sends an encoding of
|
||||
* all required flags for the Test VM to the Driver VM over a socket. Once the Flag VM exits, this Driver VM parses the
|
||||
* Test VM flags, which also determine if IR matching should be done, and then starts the Test VM to execute all tests.
|
||||
*/
|
||||
private void start(Scenario scenario) {
|
||||
if (scenario != null && !scenario.isEnabled()) {
|
||||
@ -823,12 +823,12 @@ public class TestFramework {
|
||||
"" : " - [" + String.join(", ", additionalFlags) + "]";
|
||||
|
||||
if (shouldVerifyIR) {
|
||||
// Only need to use flag VM if an IR verification is possibly done.
|
||||
// Only need to use Flag VM if an IR verification is possibly done.
|
||||
System.out.println("Run Flag VM:");
|
||||
FlagVMProcess flagVMProcess = new FlagVMProcess(testClass, additionalFlags);
|
||||
shouldVerifyIR = flagVMProcess.shouldVerifyIR();
|
||||
if (shouldVerifyIR) {
|
||||
// Add more flags for the test VM which are required to do IR verification.
|
||||
// Add more flags for the Test VM which are required to do IR verification.
|
||||
additionalFlags.addAll(flagVMProcess.getTestVMFlags());
|
||||
} // else: Flag VM found a reason to not do IR verification.
|
||||
} else {
|
||||
@ -882,7 +882,7 @@ public class TestFramework {
|
||||
try {
|
||||
TestClassParser testClassParser = new TestClassParser(testClass, isAllowNotCompilable);
|
||||
Matchable testClassMatchable = testClassParser.parse(testVMProcess.getHotspotPidFileName(),
|
||||
testVMProcess.getIrEncoding());
|
||||
testVMProcess.getApplicableIRRules());
|
||||
IRMatcher matcher = new IRMatcher(testClassMatchable);
|
||||
matcher.match();
|
||||
} catch (IRViolationException e) {
|
||||
@ -892,7 +892,7 @@ public class TestFramework {
|
||||
} else {
|
||||
System.out.println("IR verification disabled either due to no @IR annotations, through explicitly setting " +
|
||||
"-DVerify=false, due to not running a debug build, using a non-whitelisted JTreg VM or " +
|
||||
"Javaopts flag like -Xint, or running the test VM with other VM flags added by user code " +
|
||||
"Javaopts flag like -Xint, or running the Test VM with other VM flags added by user code " +
|
||||
"that make the IR verification impossible (e.g. -XX:-UseCompile, " +
|
||||
"-XX:TieredStopAtLevel=[1,2,3], etc.).");
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2024, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -41,9 +41,9 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* This class prepares, creates, and runs the "flag" VM with verification of proper termination. The flag VM determines
|
||||
* the flags required for the "test" VM. The flag VM writes these flags to a dedicated file which is then parsed by this
|
||||
* class after the termination of the flag VM.
|
||||
* This class prepares, creates, and runs the Flag VM with verification of proper termination. The Flag VM determines
|
||||
* the flags required for the Test VM. The Flag VM writes these flags to a dedicated file which is then parsed by this
|
||||
* class after the termination of the Flag VM.
|
||||
*
|
||||
* @see FlagVM
|
||||
*/
|
||||
@ -73,7 +73,7 @@ public class FlagVMProcess {
|
||||
String patternString = "(.*DShouldDoIRVerification=(true|false).*)";
|
||||
Pattern pattern = Pattern.compile(patternString);
|
||||
Matcher matcher = pattern.matcher(flags);
|
||||
TestFramework.check(matcher.find(), "Invalid flag encoding emitted by flag VM");
|
||||
TestFramework.check(matcher.find(), "Invalid flag encoding emitted by Flag VM");
|
||||
// Maybe we run with flags that make IR verification impossible
|
||||
shouldVerifyIR = Boolean.parseBoolean(matcher.group(2));
|
||||
testVMFlags.addAll(Arrays.asList(matcher.group(1).split(FlagVM.TEST_VM_FLAGS_DELIMITER)));
|
||||
@ -91,8 +91,8 @@ public class FlagVMProcess {
|
||||
}
|
||||
|
||||
/**
|
||||
* The flag VM needs White Box access to prepare all test VM flags. The flag VM will write the test VM flags to
|
||||
* a dedicated file which is afterwards parsed by the driver VM and added as flags to the test VM.
|
||||
* The Flag VM needs White Box access to prepare all Test VM flags. The Flag VM will write the Test VM flags to
|
||||
* a dedicated file which is afterwards parsed by the Driver VM and added as flags to the Test VM.
|
||||
*/
|
||||
private void prepareVMFlags(Class<?> testClass, List<String> additionalFlags) {
|
||||
cmds.add("-Dtest.jdk=" + Utils.TEST_JDK);
|
||||
@ -103,7 +103,7 @@ public class FlagVMProcess {
|
||||
cmds.add("-Xbootclasspath/a:.");
|
||||
cmds.add("-XX:+UnlockDiagnosticVMOptions");
|
||||
cmds.add("-XX:+WhiteBoxAPI");
|
||||
// TestFramework and scenario flags might have an influence on the later used test VM flags. Add them as well.
|
||||
// TestFramework and scenario flags might have an influence on the later used Test VM flags. Add them as well.
|
||||
cmds.addAll(additionalFlags);
|
||||
cmds.add(FlagVM.class.getCanonicalName());
|
||||
cmds.add(testClass.getCanonicalName());
|
||||
@ -111,10 +111,10 @@ public class FlagVMProcess {
|
||||
|
||||
private void start() {
|
||||
try {
|
||||
// Run "flag" VM with White Box access to determine the test VM flags and if IR verification should be done.
|
||||
// Run Flag VM with White Box access to determine the Test VM flags and if IR verification should be done.
|
||||
oa = ProcessTools.executeTestJava(cmds);
|
||||
} catch (Exception e) {
|
||||
throw new TestRunException("Failed to execute TestFramework flag VM", e);
|
||||
throw new TestRunException("Failed to execute TestFramework Flag VM", e);
|
||||
}
|
||||
testVMFlagsFile = FlagVM.TEST_VM_FLAGS_FILE_PREFIX + oa.pid()
|
||||
+ FlagVM.FILE_POSTFIX;
|
||||
@ -125,14 +125,14 @@ public class FlagVMProcess {
|
||||
String flagVMOutput = oa.getOutput();
|
||||
int exitCode = oa.getExitValue();
|
||||
if (VERBOSE && exitCode == 0) {
|
||||
System.out.println("--- OUTPUT TestFramework flag VM ---");
|
||||
System.out.println("--- OUTPUT TestFramework Flag VM ---");
|
||||
System.out.println(flagVMOutput);
|
||||
}
|
||||
|
||||
if (exitCode != 0) {
|
||||
System.err.println("--- OUTPUT TestFramework flag VM ---");
|
||||
System.err.println("--- OUTPUT TestFramework Flag VM ---");
|
||||
System.err.println(flagVMOutput);
|
||||
throw new RuntimeException("TestFramework flag VM exited with " + exitCode);
|
||||
throw new RuntimeException("TestFramework Flag VM exited with " + exitCode);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -26,7 +26,7 @@ package compiler.lib.ir_framework.driver;
|
||||
import compiler.lib.ir_framework.shared.TestFormatException;
|
||||
|
||||
/**
|
||||
* Exception that is thrown if the test VM has thrown any kind of exception (except for {@link TestFormatException}).
|
||||
* Exception that is thrown if the Test VM has thrown any kind of exception (except for {@link TestFormatException}).
|
||||
*/
|
||||
public class TestVMException extends RuntimeException {
|
||||
private final String exceptionInfo;
|
||||
@ -37,9 +37,9 @@ public class TestVMException extends RuntimeException {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get some more detailed information about the exception thrown in the test VM and how to reproduce it.
|
||||
* Get some more detailed information about the exception thrown in the Test VM and how to reproduce it.
|
||||
*
|
||||
* @return a formatted string containing information about the exception of the test VM and how to reproduce it.
|
||||
* @return a formatted string containing information about the exception of the Test VM and how to reproduce it.
|
||||
*/
|
||||
public String getExceptionInfo() {
|
||||
return exceptionInfo;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -41,9 +41,9 @@ 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
|
||||
* information about the test VM which is later queried for IR matching. The communication between this driver VM
|
||||
* and the test VM is done over a dedicated socket.
|
||||
* This class prepares, creates, and runs the Test VM with verification of proper termination. The class also stores
|
||||
* information about the Test VM which is later queried for IR matching. The communication between this Driver VM
|
||||
* and the Test VM is done over a dedicated socket.
|
||||
*
|
||||
* @see TestVM
|
||||
* @see TestFrameworkSocket
|
||||
@ -62,7 +62,7 @@ public class TestVMProcess {
|
||||
private String hotspotPidFileName;
|
||||
private String commandLine;
|
||||
private OutputAnalyzer oa;
|
||||
private String irEncoding;
|
||||
private String applicableIRRules;
|
||||
|
||||
public TestVMProcess(List<String> additionalFlags, Class<?> testClass, Set<Class<?>> helperClasses, int defaultWarmup,
|
||||
boolean allowNotCompilable, boolean testClassesOnBootClassPath) {
|
||||
@ -81,8 +81,8 @@ public class TestVMProcess {
|
||||
return commandLine;
|
||||
}
|
||||
|
||||
public String getIrEncoding() {
|
||||
return irEncoding;
|
||||
public String getApplicableIRRules() {
|
||||
return applicableIRRules;
|
||||
}
|
||||
|
||||
public String getHotspotPidFileName() {
|
||||
@ -98,7 +98,7 @@ public class TestVMProcess {
|
||||
boolean testClassesOnBootClassPath) {
|
||||
// Set java.library.path so JNI tests which rely on jtreg nativepath setting work
|
||||
cmds.add("-Djava.library.path=" + Utils.TEST_NATIVE_PATH);
|
||||
// Need White Box access in test VM.
|
||||
// Need White Box access in Test VM.
|
||||
String bootClassPath = "-Xbootclasspath/a:.";
|
||||
if (testClassesOnBootClassPath) {
|
||||
// Add test classes themselves to boot classpath to make them privileged.
|
||||
@ -112,7 +112,8 @@ public class TestVMProcess {
|
||||
if (!PREFER_COMMAND_LINE_FLAGS) {
|
||||
cmds.addAll(jtregVMFlags);
|
||||
}
|
||||
// Add server property flag that enables test VM to print encoding for IR verification last and debug messages.
|
||||
// Add server property flag that enables the Test VM to print the Applicable IR Rules for IR verification and
|
||||
// debug messages.
|
||||
cmds.add(socket.getPortPropertyFlag());
|
||||
cmds.addAll(additionalFlags);
|
||||
cmds.addAll(Arrays.asList(getDefaultFlags()));
|
||||
@ -142,7 +143,7 @@ public class TestVMProcess {
|
||||
}
|
||||
|
||||
/**
|
||||
* Default flags that are added used for the test VM.
|
||||
* Default flags that are added used for the Test VM.
|
||||
*/
|
||||
private static String[] getDefaultFlags() {
|
||||
return new String[] {"-XX:-BackgroundCompilation", "-XX:CompileCommand=quiet"};
|
||||
@ -169,7 +170,7 @@ public class TestVMProcess {
|
||||
throw new TestFrameworkException("Error while executing Test VM", e);
|
||||
}
|
||||
|
||||
process.command().add(1, "-DReproduce=true"); // Add after "/path/to/bin/java" in order to rerun the test VM directly
|
||||
process.command().add(1, "-DReproduce=true"); // Add after "/path/to/bin/java" in order to rerun the Test VM directly
|
||||
commandLine = "Command Line:" + System.lineSeparator() + String.join(" ", process.command())
|
||||
+ System.lineSeparator();
|
||||
hotspotPidFileName = String.format("hotspot_pid%d.log", oa.pid());
|
||||
@ -178,7 +179,7 @@ public class TestVMProcess {
|
||||
|
||||
/**
|
||||
* Process the socket output: All prefixed lines are dumped to the standard output while the remaining lines
|
||||
* represent the IR encoding used for IR matching later.
|
||||
* represent the Applicable IR Rules used for IR matching later.
|
||||
*/
|
||||
private void processSocketOutput(TestFrameworkSocket socket) {
|
||||
String output = socket.getOutput();
|
||||
@ -215,16 +216,16 @@ public class TestVMProcess {
|
||||
System.out.println("---------------------");
|
||||
System.out.println(messagesBuilder);
|
||||
}
|
||||
irEncoding = nonStdOutBuilder.toString();
|
||||
applicableIRRules = nonStdOutBuilder.toString();
|
||||
} else {
|
||||
irEncoding = output;
|
||||
applicableIRRules = output;
|
||||
}
|
||||
}
|
||||
|
||||
private void checkTestVMExitCode() {
|
||||
final int exitCode = oa.getExitValue();
|
||||
if (EXCLUDE_RANDOM || REPORT_STDOUT || (VERBOSE && exitCode == 0)) {
|
||||
System.out.println("--- OUTPUT TestFramework test VM ---");
|
||||
System.out.println("--- OUTPUT TestFramework Test VM ---");
|
||||
System.out.println(oa.getOutput());
|
||||
}
|
||||
|
||||
@ -234,7 +235,7 @@ public class TestVMProcess {
|
||||
}
|
||||
|
||||
/**
|
||||
* Exit code was non-zero of test VM. Check the stderr to determine what kind of exception that should be thrown to
|
||||
* Exit code was non-zero of Test VM. Check the stderr to determine what kind of exception that should be thrown to
|
||||
* react accordingly later.
|
||||
*/
|
||||
private void throwTestVMException() {
|
||||
@ -266,7 +267,7 @@ public class TestVMProcess {
|
||||
stdOut = System.lineSeparator() + System.lineSeparator() + "Standard Output" + System.lineSeparator()
|
||||
+ "---------------" + System.lineSeparator() + oa.getOutput();
|
||||
}
|
||||
return "TestFramework test VM exited with code " + exitCode + System.lineSeparator() + stdOut
|
||||
return "TestFramework Test VM exited with code " + exitCode + System.lineSeparator() + stdOut
|
||||
+ System.lineSeparator() + commandLine + System.lineSeparator() + System.lineSeparator()
|
||||
+ "Error Output" + System.lineSeparator() + "------------" + System.lineSeparator() + stdErr
|
||||
+ System.lineSeparator() + System.lineSeparator();
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, 2026, 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
|
||||
@ -28,7 +28,7 @@ import compiler.lib.ir_framework.TestFramework;
|
||||
import compiler.lib.ir_framework.driver.irmatching.parser.hotspot.HotSpotPidFileParser;
|
||||
import compiler.lib.ir_framework.shared.TestFormat;
|
||||
import compiler.lib.ir_framework.shared.TestFrameworkException;
|
||||
import compiler.lib.ir_framework.test.IREncodingPrinter;
|
||||
import compiler.lib.ir_framework.test.ApplicableIRRulesPrinter;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.HashMap;
|
||||
@ -37,34 +37,34 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Class to parse the IR encoding emitted by the test VM and creating {@link TestMethod} objects for each entry.
|
||||
* Class to parse the Applicable IR Rules emitted by the Test VM and creating {@link TestMethod} objects for each entry.
|
||||
*
|
||||
* @see TestMethod
|
||||
*/
|
||||
public class IREncodingParser {
|
||||
public class ApplicableIRRulesParser {
|
||||
|
||||
private static final boolean PRINT_IR_ENCODING = Boolean.parseBoolean(System.getProperty("PrintIREncoding", "false"));
|
||||
private static final Pattern IR_ENCODING_PATTERN =
|
||||
Pattern.compile("(?<=" + IREncodingPrinter.START + "\r?\n).*\\R([\\s\\S]*)(?=" + IREncodingPrinter.END + ")");
|
||||
private static final boolean PRINT_APPLICABLE_IR_RULES = Boolean.parseBoolean(System.getProperty("PrintApplicableIRRules", "false"));
|
||||
private static final Pattern APPLICABLE_IR_RULES_PATTERN =
|
||||
Pattern.compile("(?<=" + ApplicableIRRulesPrinter.START + "\r?\n).*\\R([\\s\\S]*)(?=" + ApplicableIRRulesPrinter.END + ")");
|
||||
|
||||
private final Map<String, TestMethod> testMethods;
|
||||
private final Class<?> testClass;
|
||||
|
||||
public IREncodingParser(Class<?> testClass) {
|
||||
public ApplicableIRRulesParser(Class<?> testClass) {
|
||||
this.testClass = testClass;
|
||||
this.testMethods = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the IR encoding passed as parameter and return a "test name" -> TestMethod map that contains an entry
|
||||
* for each method that needs to be IR matched on.
|
||||
* Parse the Applicable IR rules passed as parameter and return a "test name" -> TestMethod map that contains an
|
||||
* entry for each method that needs to be IR matched on.
|
||||
*/
|
||||
public TestMethods parse(String irEncoding) {
|
||||
if (TestFramework.VERBOSE || PRINT_IR_ENCODING) {
|
||||
System.out.println("Read IR encoding from test VM:");
|
||||
System.out.println(irEncoding);
|
||||
public TestMethods parse(String applicableIRRules) {
|
||||
if (TestFramework.VERBOSE || PRINT_APPLICABLE_IR_RULES) {
|
||||
System.out.println("Read Applicable IR Rules from Test VM:");
|
||||
System.out.println(applicableIRRules);
|
||||
}
|
||||
createTestMethodMap(irEncoding, testClass);
|
||||
createTestMethodMap(applicableIRRules, testClass);
|
||||
// We could have found format errors in @IR annotations. Report them now with an exception.
|
||||
TestFormat.throwIfAnyFailures();
|
||||
return new TestMethods(testMethods);
|
||||
@ -74,22 +74,22 @@ public class IREncodingParser {
|
||||
* Sets up a map testname -> TestMethod map. The TestMethod object will later be filled with the ideal and opto
|
||||
* assembly output in {@link HotSpotPidFileParser}.
|
||||
*/
|
||||
private void createTestMethodMap(String irEncoding, Class<?> testClass) {
|
||||
Map<String, int[]> irRulesMap = parseIREncoding(irEncoding);
|
||||
createTestMethodsWithEncoding(testClass, irRulesMap);
|
||||
private void createTestMethodMap(String applicableIRRules, Class<?> testClass) {
|
||||
Map<String, int[]> irRulesMap = parseApplicableIRRules(applicableIRRules);
|
||||
createTestMethodsWithApplicableIRRules(testClass, irRulesMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* Read the IR encoding emitted by the test VM to decide if an @IR rule must be checked for a method.
|
||||
* Read the Applicable IR Rules emitted by the Test VM to decide if an @IR rule must be checked for a method.
|
||||
*/
|
||||
private Map<String, int[]> parseIREncoding(String irEncoding) {
|
||||
private Map<String, int[]> parseApplicableIRRules(String applicableIRRules) {
|
||||
Map<String, int[]> irRulesMap = new HashMap<>();
|
||||
String[] irEncodingLines = getIREncodingLines(irEncoding);
|
||||
for (String s : irEncodingLines) {
|
||||
String[] applicableIRRulesLines = getApplicableIRRulesLines(applicableIRRules);
|
||||
for (String s : applicableIRRulesLines) {
|
||||
String line = s.trim();
|
||||
String[] splitLine = line.split(",");
|
||||
if (splitLine.length < 2) {
|
||||
throw new TestFrameworkException("Invalid IR match rule encoding. No comma found: " + splitLine[0]);
|
||||
throw new TestFrameworkException("Invalid Applicable IR Rules format. No comma found: " + splitLine[0]);
|
||||
}
|
||||
String testName = splitLine[0];
|
||||
int[] irRulesIdx = getRuleIndexes(splitLine);
|
||||
@ -99,11 +99,12 @@ public class IREncodingParser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the IR encoding lines without header, explanation line and footer and return them in an array.
|
||||
* Parse the Applicable IR Rules lines without header, explanation line and footer and return them in an array.
|
||||
*/
|
||||
private String[] getIREncodingLines(String irEncoding) {
|
||||
Matcher matcher = IR_ENCODING_PATTERN.matcher(irEncoding);
|
||||
TestFramework.check(matcher.find(), "Did not find IR encoding in:" + System.lineSeparator() + irEncoding);
|
||||
private String[] getApplicableIRRulesLines(String applicableIRRules) {
|
||||
Matcher matcher = APPLICABLE_IR_RULES_PATTERN.matcher(applicableIRRules);
|
||||
TestFramework.check(matcher.find(), "Did not find Applicable IR Rules in:" +
|
||||
System.lineSeparator() + applicableIRRules);
|
||||
String lines = matcher.group(1).trim();
|
||||
if (lines.isEmpty()) {
|
||||
// Nothing to IR match.
|
||||
@ -113,7 +114,7 @@ public class IREncodingParser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse rule indexes from IR encoding line of the format: <method,idx1,idx2,...>
|
||||
* Parse rule indexes from a single line of the Applicable IR Rules in the format: <method,idx1,idx2,...>
|
||||
*/
|
||||
private int[] getRuleIndexes(String[] splitLine) {
|
||||
int[] irRulesIdx = new int[splitLine.length - 1];
|
||||
@ -121,13 +122,13 @@ public class IREncodingParser {
|
||||
try {
|
||||
irRulesIdx[i - 1] = Integer.parseInt(splitLine[i]);
|
||||
} catch (NumberFormatException e) {
|
||||
throw new TestFrameworkException("Invalid IR match rule encoding. No number found: " + splitLine[i]);
|
||||
throw new TestFrameworkException("Invalid Applicable IR Rules format. No number found: " + splitLine[i]);
|
||||
}
|
||||
}
|
||||
return irRulesIdx;
|
||||
}
|
||||
|
||||
private void createTestMethodsWithEncoding(Class<?> testClass, Map<String, int[]> irRulesMap) {
|
||||
private void createTestMethodsWithApplicableIRRules(Class<?> testClass, Map<String, int[]> irRulesMap) {
|
||||
for (Method m : testClass.getDeclaredMethods()) {
|
||||
IR[] irAnnos = m.getAnnotationsByType(IR.class);
|
||||
if (irAnnos.length > 0) {
|
||||
@ -144,7 +145,7 @@ public class IREncodingParser {
|
||||
private void validateIRRuleIds(Method m, IR[] irAnnos, int[] ids) {
|
||||
TestFramework.check(ids != null, "Should find method name in validIrRulesMap for " + m);
|
||||
TestFramework.check(ids.length > 0, "Did not find any rule indices for " + m);
|
||||
TestFramework.check((ids[0] >= 1 || ids[0] == IREncodingPrinter.NO_RULE_APPLIED)
|
||||
TestFramework.check((ids[0] >= 1 || ids[0] == ApplicableIRRulesPrinter.NO_RULE_APPLIED)
|
||||
&& ids[ids.length - 1] <= irAnnos.length,
|
||||
"Invalid IR rule index found in validIrRulesMap for " + m);
|
||||
}
|
||||
@ -153,6 +154,6 @@ public class IREncodingParser {
|
||||
* Does the list of IR rules contain any applicable IR rules for the given conditions?
|
||||
*/
|
||||
private boolean hasAnyApplicableIRRules(int[] irRuleIds) {
|
||||
return irRuleIds[0] != IREncodingPrinter.NO_RULE_APPLIED;
|
||||
return irRuleIds[0] != ApplicableIRRulesPrinter.NO_RULE_APPLIED;
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2023, 2026, 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
|
||||
@ -24,7 +24,6 @@
|
||||
package compiler.lib.ir_framework.driver.irmatching.parser;
|
||||
|
||||
import compiler.lib.ir_framework.Test;
|
||||
import compiler.lib.ir_framework.TestFramework;
|
||||
import compiler.lib.ir_framework.driver.irmatching.Compilation;
|
||||
import compiler.lib.ir_framework.driver.irmatching.irmethod.IRMethod;
|
||||
import compiler.lib.ir_framework.driver.irmatching.irmethod.IRMethodMatchable;
|
||||
@ -53,7 +52,7 @@ class IRMethodBuilder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create IR methods for all test methods identified by {@link IREncodingParser} by combining them with the parsed
|
||||
* Create IR methods for all test methods identified by {@link ApplicableIRRulesParser} by combining them with the parsed
|
||||
* compilation output from {@link HotSpotPidFileParser}.
|
||||
*/
|
||||
public SortedSet<IRMethodMatchable> build(VMInfo vmInfo) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, 2026, 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
|
||||
@ -50,13 +50,13 @@ public class TestClassParser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the IR encoding and hotspot_pid* file to create a collection of {@link IRMethod} objects.
|
||||
* Parse the Applicable IR Rules and hotspot_pid* file to create a collection of {@link IRMethod} objects.
|
||||
* Return a default/empty TestClass object if there are no applicable @IR rules in any method of the test class.
|
||||
*/
|
||||
public Matchable parse(String hotspotPidFileName, String irEncoding) {
|
||||
IREncodingParser irEncodingParser = new IREncodingParser(testClass);
|
||||
TestMethods testMethods = irEncodingParser.parse(irEncoding);
|
||||
VMInfo vmInfo = VMInfoParser.parseVMInfo(irEncoding);
|
||||
public Matchable parse(String hotspotPidFileName, String applicableIRRules) {
|
||||
ApplicableIRRulesParser applicableIRRulesParser = new ApplicableIRRulesParser(testClass);
|
||||
TestMethods testMethods = applicableIRRulesParser.parse(applicableIRRules);
|
||||
VMInfo vmInfo = VMInfoParser.parseVMInfo(applicableIRRules);
|
||||
if (testMethods.hasTestMethods()) {
|
||||
HotSpotPidFileParser hotSpotPidFileParser = new HotSpotPidFileParser(testClass.getName(), testMethods);
|
||||
LoggedMethods loggedMethods = hotSpotPidFileParser.parse(hotspotPidFileName);
|
||||
@ -66,7 +66,7 @@ public class TestClassParser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Create test class with IR methods for all test methods identified by {@link IREncodingParser} by combining them
|
||||
* Create test class with IR methods for all test methods identified by {@link ApplicableIRRulesParser} by combining them
|
||||
* with the parsed compilation output from {@link HotSpotPidFileParser}.
|
||||
*/
|
||||
private Matchable createTestClass(TestMethods testMethods, LoggedMethods loggedMethods, VMInfo vmInfo) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, 2026, 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
|
||||
@ -30,10 +30,10 @@ import compiler.lib.ir_framework.driver.irmatching.parser.hotspot.LoggedMethod;
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/**
|
||||
* This class represents a test method parsed by {@link IREncodingParser}. In combination with the associated
|
||||
* This class represents a test method parsed by {@link ApplicableIRRulesParser}. In combination with the associated
|
||||
* {@link LoggedMethod}, a new {@link IRMethod} is created to IR match on later.
|
||||
*
|
||||
* @see IREncodingParser
|
||||
* @see ApplicableIRRulesParser
|
||||
* @see LoggedMethod
|
||||
* @see IRMethod
|
||||
*/
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2023, 2026, 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
|
||||
@ -29,15 +29,15 @@ import compiler.lib.ir_framework.driver.irmatching.parser.hotspot.HotSpotPidFile
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* This class stores all test methods that need to be IR matched as identified by {@link IREncodingParser}.
|
||||
* This class stores all test methods that need to be IR matched as identified by {@link ApplicableIRRulesParser}.
|
||||
*
|
||||
* @see IREncodingParser
|
||||
* @see ApplicableIRRulesParser
|
||||
* @see HotSpotPidFileParser
|
||||
* @see IRMethod
|
||||
*/
|
||||
public class TestMethods {
|
||||
/**
|
||||
* "Method name" -> TestMethod map created by {@link IREncodingParser} which contains an entry for each method that
|
||||
* "Method name" -> TestMethod map created by {@link ApplicableIRRulesParser} which contains an entry for each method that
|
||||
* needs to be IR matched on.
|
||||
*/
|
||||
private final Map<String, TestMethod> testMethods;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2023, 2026, 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
|
||||
@ -33,7 +33,7 @@ import java.util.regex.Pattern;
|
||||
/**
|
||||
* This class stores the key value mapping from the VMInfo.
|
||||
*
|
||||
* @see IREncodingParser
|
||||
* @see ApplicableIRRulesParser
|
||||
*/
|
||||
public class VMInfo {
|
||||
/**
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2023, 2026, 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
|
||||
@ -33,7 +33,7 @@ import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* Class to parse the VMInfo emitted by the test VM and creating {@link VMInfo} objects for each entry.
|
||||
* Class to parse the VMInfo emitted by the Test VM and creating {@link VMInfo} objects for each entry.
|
||||
*
|
||||
* @see VMInfo
|
||||
*/
|
||||
@ -43,11 +43,11 @@ public class VMInfoParser {
|
||||
Pattern.compile("(?<=" + VMInfoPrinter.START_VM_INFO + "\r?\n).*\\R([\\s\\S]*)(?=" + VMInfoPrinter.END_VM_INFO + ")");
|
||||
|
||||
/**
|
||||
* Extract VMInfo from the irEncoding.
|
||||
* Extract VMInfo from the applicableIRRules.
|
||||
*/
|
||||
public static VMInfo parseVMInfo(String irEncoding) {
|
||||
public static VMInfo parseVMInfo(String applicableIRRules) {
|
||||
Map<String, String> map = new HashMap<>();
|
||||
String[] lines = getVMInfoLines(irEncoding);
|
||||
String[] lines = getVMInfoLines(applicableIRRules);
|
||||
for (String s : lines) {
|
||||
String line = s.trim();
|
||||
String[] splitLine = line.split(":", 2);
|
||||
@ -62,11 +62,11 @@ public class VMInfoParser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Extract the VMInfo from the irEncoding string, strip away the header and return the individual key-value lines.
|
||||
* Extract the VMInfo from the applicableIRRules string, strip away the header and return the individual key-value lines.
|
||||
*/
|
||||
private static String[] getVMInfoLines(String irEncoding) {
|
||||
Matcher matcher = VM_INFO_PATTERN.matcher(irEncoding);
|
||||
TestFramework.check(matcher.find(), "Did not find VMInfo in:" + System.lineSeparator() + irEncoding);
|
||||
private static String[] getVMInfoLines(String applicableIRRules) {
|
||||
Matcher matcher = VM_INFO_PATTERN.matcher(applicableIRRules);
|
||||
TestFramework.check(matcher.find(), "Did not find VMInfo in:" + System.lineSeparator() + applicableIRRules);
|
||||
String lines = matcher.group(1).trim();
|
||||
if (lines.isEmpty()) {
|
||||
// Nothing to IR match.
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2023, 2026, 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
|
||||
@ -24,7 +24,7 @@
|
||||
package compiler.lib.ir_framework.driver.irmatching.parser.hotspot;
|
||||
|
||||
import compiler.lib.ir_framework.TestFramework;
|
||||
import compiler.lib.ir_framework.driver.irmatching.parser.IREncodingParser;
|
||||
import compiler.lib.ir_framework.driver.irmatching.parser.ApplicableIRRulesParser;
|
||||
import compiler.lib.ir_framework.driver.irmatching.parser.TestMethods;
|
||||
|
||||
import java.util.HashMap;
|
||||
@ -34,9 +34,9 @@ import java.util.regex.Pattern;
|
||||
|
||||
/**
|
||||
* This class parses compile queue messages found in the hotspot_pid* files and keeps track of those that need to be
|
||||
* IR matched (i.e. identified by {@link IREncodingParser}.
|
||||
* IR matched (i.e. identified by {@link ApplicableIRRulesParser}.
|
||||
*
|
||||
* @see IREncodingParser
|
||||
* @see ApplicableIRRulesParser
|
||||
*/
|
||||
class CompileQueueMessages {
|
||||
private static final Pattern COMPILE_ID_PATTERN = Pattern.compile("compile_id='(\\d+)'");
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, 2026, 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
|
||||
@ -24,7 +24,7 @@
|
||||
package compiler.lib.ir_framework.driver.irmatching.parser.hotspot;
|
||||
|
||||
import compiler.lib.ir_framework.driver.irmatching.irmethod.IRMethod;
|
||||
import compiler.lib.ir_framework.driver.irmatching.parser.IREncodingParser;
|
||||
import compiler.lib.ir_framework.driver.irmatching.parser.ApplicableIRRulesParser;
|
||||
import compiler.lib.ir_framework.driver.irmatching.parser.TestMethods;
|
||||
import compiler.lib.ir_framework.shared.TestFrameworkException;
|
||||
|
||||
@ -34,10 +34,10 @@ import java.nio.file.Paths;
|
||||
|
||||
/**
|
||||
* Class to parse the ideal compile phases and PrintOptoAssembly outputs of the test class from the hotspot_pid* file
|
||||
* of all methods identified by {@link IREncodingParser}.
|
||||
* of all methods identified by {@link ApplicableIRRulesParser}.
|
||||
*
|
||||
* @see IRMethod
|
||||
* @see IREncodingParser
|
||||
* @see ApplicableIRRulesParser
|
||||
*/
|
||||
public class HotSpotPidFileParser {
|
||||
private final State state;
|
||||
@ -47,8 +47,8 @@ public class HotSpotPidFileParser {
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse the hotspot_pid*.log file from the test VM. Read the ideal compile phase and PrintOptoAssembly outputs for
|
||||
* all methods defined by the IR encoding.
|
||||
* Parse the hotspot_pid*.log file from the Test VM. Read the ideal compile phase and PrintOptoAssembly outputs for
|
||||
* all methods defined by the Applicable IR Rules.
|
||||
*/
|
||||
public LoggedMethods parse(String hotspotPidFileName) {
|
||||
try (var reader = Files.newBufferedReader(Paths.get(hotspotPidFileName))) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2022, 2026, 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
|
||||
@ -53,7 +53,7 @@ class CompilePhaseCollector {
|
||||
collectCompilePhases(method));
|
||||
}
|
||||
} catch (TestFormatException e) {
|
||||
// Create default map and let the IR matcher report the format failures later in the driver VM.
|
||||
// Create default map and let the IR matcher report the format failures later in the Driver VM.
|
||||
return createDefaultMap(testClass);
|
||||
}
|
||||
return methodNameToCompilePhasesMap;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2022, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -38,8 +38,8 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
|
||||
/**
|
||||
* This class' main method is called from {@link TestFramework} and represents the so-called "flag VM". It uses the
|
||||
* Whitebox API to determine the necessary additional flags to run the test VM (e.g. to do IR matching). It returns
|
||||
* This class' main method is called from {@link TestFramework} and represents the so-called "Flag VM". It uses the
|
||||
* Whitebox API to determine the necessary additional flags to run the Test VM (e.g. to do IR matching). It returns
|
||||
* the flags over the dedicated TestFramework socket.
|
||||
*/
|
||||
public class FlagVM {
|
||||
@ -79,12 +79,12 @@ public class FlagVM {
|
||||
private static final boolean VERIFY_IR = REQUESTED_VERIFY_IR && USE_COMPILER && !EXCLUDE_RANDOM && !FLIP_C1_C2 && !TEST_C1 && Platform.isServer();
|
||||
|
||||
/**
|
||||
* Main entry point of the flag VM.
|
||||
* Main entry point of the Flag VM.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
String testClassName = args[0];
|
||||
if (VERBOSE) {
|
||||
System.out.println("FlagVM main() called. Prepare test VM flags to run class " + testClassName);
|
||||
System.out.println("FlagVM main() called. Prepare Test VM flags to run class " + testClassName);
|
||||
}
|
||||
Class<?> testClass;
|
||||
try {
|
||||
@ -96,8 +96,8 @@ public class FlagVM {
|
||||
}
|
||||
|
||||
/**
|
||||
* Emit test VM flags to the dedicated test VM flags file to parse them from the TestFramework "driver" VM again
|
||||
* which adds them to the test VM.
|
||||
* Emit Test VM flags to the dedicated Test VM flags file to parse them from the TestFramework Driver VM again
|
||||
* which adds them to the Test VM.
|
||||
*/
|
||||
private static void emitTestVMFlags(ArrayList<String> flags) {
|
||||
try (var bw = Files.newBufferedWriter(Paths.get(TEST_VM_FLAGS_FILE))) {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -24,17 +24,17 @@
|
||||
package compiler.lib.ir_framework.shared;
|
||||
|
||||
/**
|
||||
* Exception that is thrown by the test VM if no tests are run as a result of specifying {@code -DTest} and/or
|
||||
* {@code -DExclude} defining an empty set with the used test VM flags.
|
||||
* Exception that is thrown by the Test VM if no tests are run as a result of specifying {@code -DTest} and/or
|
||||
* {@code -DExclude} defining an empty set with the used Test VM flags.
|
||||
*/
|
||||
public class NoTestsRunException extends RuntimeException {
|
||||
/**
|
||||
* Default constructor used by test VM
|
||||
* Default constructor used by Test VM
|
||||
*/
|
||||
public NoTestsRunException() {}
|
||||
|
||||
/**
|
||||
* Constructor used to eventually throw the exception in the driver VM.
|
||||
* Constructor used to eventually throw the exception in the Driver VM.
|
||||
*/
|
||||
public NoTestsRunException(String message) {
|
||||
super(message);
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -37,7 +37,7 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
/**
|
||||
* Dedicated socket to send data from the flag and test VM back to the driver VM.
|
||||
* Dedicated socket to send data from the flag and Test VM back to the Driver VM.
|
||||
*/
|
||||
public class TestFrameworkSocket implements AutoCloseable {
|
||||
public static final String STDOUT_PREFIX = "[STDOUT]";
|
||||
@ -46,7 +46,7 @@ public class TestFrameworkSocket implements AutoCloseable {
|
||||
public static final String PRINT_TIMES_TAG = "[PRINT_TIMES]";
|
||||
public static final String NOT_COMPILABLE_TAG = "[NOT_COMPILABLE]";
|
||||
|
||||
// Static fields used for test VM only.
|
||||
// Static fields used for Test VM only.
|
||||
private static final String SERVER_PORT_PROPERTY = "ir.framework.server.port";
|
||||
private static final int SERVER_PORT = Integer.getInteger(SERVER_PORT_PROPERTY, -1);
|
||||
|
||||
@ -85,7 +85,7 @@ public class TestFrameworkSocket implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Waits for a client (created by flag or test VM) to connect. Return the messages received from the client.
|
||||
* Waits for a client (created by flag or Test VM) to connect. Return the messages received from the client.
|
||||
*/
|
||||
private FutureTask<String> initSocketTask() {
|
||||
return new FutureTask<>(() -> {
|
||||
@ -117,18 +117,18 @@ public class TestFrameworkSocket implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Only called by test VM to write to server socket.
|
||||
* Only called by Test VM to write to server socket.
|
||||
*/
|
||||
public static void write(String msg, String tag) {
|
||||
write(msg, tag, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only called by test VM to write to server socket.
|
||||
* Only called by Test VM to write to server socket.
|
||||
* <p>
|
||||
* The test VM is spawned by the main jtreg VM. The stdout of the test VM is hidden
|
||||
* The Test VM is spawned by the main jtreg VM. The stdout of the Test VM is hidden
|
||||
* unless the Verbose or ReportStdout flag is used. TestFrameworkSocket is used by the parent jtreg
|
||||
* VM and the test VM to communicate. By sending the prints through the TestFrameworkSocket with the
|
||||
* VM and the Test VM to communicate. By sending the prints through the TestFrameworkSocket with the
|
||||
* parameter stdout set to true, the parent VM will print the received messages to its stdout, making it
|
||||
* visible to the user.
|
||||
*/
|
||||
@ -137,10 +137,10 @@ public class TestFrameworkSocket implements AutoCloseable {
|
||||
System.out.println("Debugging Test VM: Skip writing due to -DReproduce");
|
||||
return;
|
||||
}
|
||||
TestFramework.check(SERVER_PORT != -1, "Server port was not set correctly for flag and/or test VM "
|
||||
+ "or method not called from flag or test VM");
|
||||
TestFramework.check(SERVER_PORT != -1, "Server port was not set correctly for flag and/or Test VM "
|
||||
+ "or method not called from flag or Test VM");
|
||||
try {
|
||||
// Keep the client socket open until the test VM terminates (calls closeClientSocket before exiting main()).
|
||||
// Keep the client socket open until the Test VM terminates (calls closeClientSocket before exiting main()).
|
||||
if (clientSocket == null) {
|
||||
clientSocket = new Socket(InetAddress.getLoopbackAddress(), SERVER_PORT);
|
||||
clientWriter = new PrintWriter(clientSocket.getOutputStream(), true);
|
||||
@ -150,11 +150,11 @@ public class TestFrameworkSocket implements AutoCloseable {
|
||||
}
|
||||
clientWriter.println(msg);
|
||||
} catch (Exception e) {
|
||||
// When the test VM is directly run, we should ignore all messages that would normally be sent to the
|
||||
// driver VM.
|
||||
// When the Test VM is directly run, we should ignore all messages that would normally be sent to the
|
||||
// Driver VM.
|
||||
String failMsg = System.lineSeparator() + System.lineSeparator() + """
|
||||
###########################################################
|
||||
Did you directly run the test VM (TestVM class)
|
||||
Did you directly run the Test VM (TestVM class)
|
||||
to reproduce a bug?
|
||||
=> Append the flag -DReproduce=true and try again!
|
||||
###########################################################
|
||||
@ -169,7 +169,7 @@ public class TestFrameworkSocket implements AutoCloseable {
|
||||
|
||||
/**
|
||||
* Closes (and flushes) the printer to the socket and the socket itself. Is called as last thing before exiting
|
||||
* the main() method of the flag and the test VM.
|
||||
* the main() method of the flag and the Test VM.
|
||||
*/
|
||||
public static void closeClientSocket() {
|
||||
if (clientSocket != null) {
|
||||
@ -183,7 +183,7 @@ public class TestFrameworkSocket implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the socket output of the flag VM.
|
||||
* Get the socket output of the Flag VM.
|
||||
*/
|
||||
public String getOutput() {
|
||||
try {
|
||||
@ -197,7 +197,7 @@ public class TestFrameworkSocket implements AutoCloseable {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return whether test VM sent messages to be put on stdout (starting with {@link ::STDOUT_PREFIX}).
|
||||
* Return whether Test VM sent messages to be put on stdout (starting with {@link ::STDOUT_PREFIX}).
|
||||
*/
|
||||
public boolean hasStdOut() {
|
||||
return receivedStdOut;
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -39,12 +39,13 @@ import java.util.Objects;
|
||||
import java.util.function.Function;
|
||||
|
||||
/**
|
||||
* Prints an encoding to the dedicated test framework socket whether @IR rules of @Test methods should be applied or not.
|
||||
* This is done during the execution of the test VM by checking the active VM flags. This encoding is eventually parsed
|
||||
* and checked by the IRMatcher class in the driver VM after the termination of the test VM. IR rule indices start at 1.
|
||||
* Prints all applicable IR rules to the dedicated test framework socket whether @IR rules of @Test methods should be
|
||||
* applied or not. This is done during the execution of the Test VM by checking the active VM flags. This
|
||||
* Applicable IR Rules message is eventually parsed and checked by the IRMatcher class in the Driver VM after the
|
||||
* termination of the Test VM. IR rule indices start at 1.
|
||||
*/
|
||||
public class IREncodingPrinter {
|
||||
public static final String START = "##### IRMatchRulesEncoding - used by TestFramework #####";
|
||||
public class ApplicableIRRulesPrinter {
|
||||
public static final String START = "##### ApplicableIRRules - used by TestFramework #####";
|
||||
public static final String END = "----- END -----";
|
||||
public static final int NO_RULE_APPLIED = -1;
|
||||
|
||||
@ -60,7 +61,7 @@ public class IREncodingPrinter {
|
||||
// Platforms for use in IR preconditions. Please verify that e.g. there is
|
||||
// a corresponding use in a jtreg @requires annotation before adding new platforms,
|
||||
// as adding non-existent platforms can lead to skipped tests.
|
||||
private static final List<String> irTestingPlatforms = new ArrayList<String>(Arrays.asList(
|
||||
private static final List<String> irTestingPlatforms = new ArrayList<>(Arrays.asList(
|
||||
// os.family
|
||||
"aix",
|
||||
"linux",
|
||||
@ -85,7 +86,7 @@ public class IREncodingPrinter {
|
||||
// Please verify new CPU features before adding them. If we allow non-existent features
|
||||
// on this list, we will ignore tests and never execute them. Consult CPU_FEATURE_FLAGS
|
||||
// in corresponding vm_version_.hpp file to find correct cpu feature's name.
|
||||
private static final List<String> verifiedCPUFeatures = new ArrayList<String>( Arrays.asList(
|
||||
private static final List<String> verifiedCPUFeatures = new ArrayList<>( Arrays.asList(
|
||||
// x86
|
||||
"fma",
|
||||
"f16c",
|
||||
@ -126,7 +127,7 @@ public class IREncodingPrinter {
|
||||
"zvkn"
|
||||
));
|
||||
|
||||
public IREncodingPrinter() {
|
||||
public ApplicableIRRulesPrinter() {
|
||||
output.append(START).append(System.lineSeparator());
|
||||
output.append("<method>,{comma separated applied @IR rule ids}").append(System.lineSeparator());
|
||||
}
|
||||
@ -136,7 +137,7 @@ public class IREncodingPrinter {
|
||||
* - indices of all @IR rules that should be applied, separated by a comma
|
||||
* - "-1" if no @IR rule should not be applied
|
||||
*/
|
||||
public void emitRuleEncoding(Method m, boolean skipped) {
|
||||
public void emitApplicableIRRules(Method m, boolean skipped) {
|
||||
method = m;
|
||||
int i = 0;
|
||||
ArrayList<Integer> validRules = new ArrayList<>();
|
||||
@ -170,7 +171,7 @@ public class IREncodingPrinter {
|
||||
private void printDisableReason(String method, String reason, String[] apply, int ruleIndex, int ruleMax) {
|
||||
TestFrameworkSocket.write("Disabling IR matching for rule " + ruleIndex + " of " + ruleMax + " in " +
|
||||
method + ": " + reason + ": " + String.join(", ", apply),
|
||||
"[IREncodingPrinter]", true);
|
||||
"[ApplicableIRRules]", true);
|
||||
}
|
||||
|
||||
private boolean shouldApplyIrRule(IR irAnno, String m, int ruleIndex, int ruleMax) {
|
||||
@ -521,7 +522,7 @@ public class IREncodingPrinter {
|
||||
|
||||
public void emit() {
|
||||
output.append(END);
|
||||
TestFrameworkSocket.write(output.toString(), "IR rule application encoding");
|
||||
TestFrameworkSocket.write(output.toString(), "ApplicableIRRules");
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -41,7 +41,7 @@ import java.util.stream.Stream;
|
||||
import static compiler.lib.ir_framework.shared.TestFrameworkSocket.PRINT_TIMES_TAG;
|
||||
|
||||
/**
|
||||
* This class' main method is called from {@link TestFramework} and represents the so-called "test VM". The class is
|
||||
* This class' main method is called from {@link TestFramework} and represents the so-called "Test VM". The class is
|
||||
* the heart of the framework and is responsible for executing all the specified tests in the test class. It uses the
|
||||
* Whitebox API and reflection to achieve this task.
|
||||
*/
|
||||
@ -58,7 +58,7 @@ public class TestVM {
|
||||
TestFramework in main() of your test? Make sure to
|
||||
only call setup/run methods and no checks or
|
||||
assertions from main() of your test!
|
||||
- Are you rerunning the test VM (TestVM class)
|
||||
- Are you rerunning the Test VM (TestVM class)
|
||||
directly after a JTreg run? Make sure to start it
|
||||
from within JTwork/scratch and with the flag
|
||||
-DReproduce=true!
|
||||
@ -100,7 +100,7 @@ public class TestVM {
|
||||
private static final boolean DUMP_REPLAY = Boolean.getBoolean("DumpReplay");
|
||||
private static final boolean GC_AFTER = Boolean.getBoolean("GCAfter");
|
||||
private static final boolean SHUFFLE_TESTS = Boolean.parseBoolean(System.getProperty("ShuffleTests", "true"));
|
||||
// Use separate flag as VERIFY_IR could have been set by user but due to other flags it was disabled by flag VM.
|
||||
// Use separate flag as VERIFY_IR could have been set by user but due to other flags it was disabled by Flag VM.
|
||||
private static final boolean PRINT_VALID_IR_RULES = Boolean.getBoolean("ShouldDoIRVerification");
|
||||
protected static final long PER_METHOD_TRAP_LIMIT = (Long)WHITE_BOX.getVMFlag("PerMethodTrapLimit");
|
||||
protected static final boolean PROFILE_INTERPRETER = (Boolean)WHITE_BOX.getVMFlag("ProfileInterpreter");
|
||||
@ -114,7 +114,7 @@ public class TestVM {
|
||||
private final List<String> excludeList;
|
||||
private final List<String> testList;
|
||||
private Set<Class<?>> helperClasses = null; // Helper classes that contain framework annotations to be processed.
|
||||
private final IREncodingPrinter irMatchRulePrinter;
|
||||
private final ApplicableIRRulesPrinter irMatchRulePrinter;
|
||||
private final Class<?> testClass;
|
||||
private final Map<Executable, CompLevel> forceCompileMap = new HashMap<>();
|
||||
|
||||
@ -125,7 +125,7 @@ public class TestVM {
|
||||
this.excludeList = createTestFilterList(EXCLUDELIST, testClass);
|
||||
|
||||
if (PRINT_VALID_IR_RULES) {
|
||||
irMatchRulePrinter = new IREncodingPrinter();
|
||||
irMatchRulePrinter = new ApplicableIRRulesPrinter();
|
||||
} else {
|
||||
irMatchRulePrinter = null;
|
||||
}
|
||||
@ -155,7 +155,7 @@ public class TestVM {
|
||||
}
|
||||
|
||||
/**
|
||||
* Main entry point of the test VM.
|
||||
* Main entry point of the Test VM.
|
||||
*/
|
||||
public static void main(String[] args) {
|
||||
try {
|
||||
@ -293,7 +293,7 @@ public class TestVM {
|
||||
BaseTest baseTest = new BaseTest(test, shouldExcludeTest(m.getName()));
|
||||
allTests.add(baseTest);
|
||||
if (PRINT_VALID_IR_RULES) {
|
||||
irMatchRulePrinter.emitRuleEncoding(m, baseTest.isSkipped());
|
||||
irMatchRulePrinter.emitApplicableIRRules(m, baseTest.isSkipped());
|
||||
}
|
||||
} catch (TestFormatException e) {
|
||||
// Failure logged. Continue and report later.
|
||||
@ -687,7 +687,7 @@ public class TestVM {
|
||||
allTests.add(checkedTest);
|
||||
if (PRINT_VALID_IR_RULES) {
|
||||
// Only need to emit IR verification information if IR verification is actually performed.
|
||||
irMatchRulePrinter.emitRuleEncoding(testMethod, checkedTest.isSkipped());
|
||||
irMatchRulePrinter.emitApplicableIRRules(testMethod, checkedTest.isSkipped());
|
||||
}
|
||||
}
|
||||
|
||||
@ -755,7 +755,7 @@ public class TestVM {
|
||||
CustomRunTest customRunTest = new CustomRunTest(m, getAnnotation(m, Warmup.class), runAnno, tests, shouldExcludeTest);
|
||||
allTests.add(customRunTest);
|
||||
if (PRINT_VALID_IR_RULES) {
|
||||
tests.forEach(test -> irMatchRulePrinter.emitRuleEncoding(test.getTestMethod(), customRunTest.isSkipped()));
|
||||
tests.forEach(test -> irMatchRulePrinter.emitApplicableIRRules(test.getTestMethod(), customRunTest.isSkipped()));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2023, 2026, 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
|
||||
@ -27,7 +27,7 @@ import compiler.lib.ir_framework.shared.TestFrameworkSocket;
|
||||
import jdk.test.whitebox.WhiteBox;
|
||||
|
||||
/**
|
||||
* Prints some test VM info to the socket.
|
||||
* Prints some Test VM info to the socket.
|
||||
*/
|
||||
public class VMInfoPrinter {
|
||||
public static final String START_VM_INFO = "##### IRMatchingVMInfo - used by TestFramework #####";
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -38,13 +38,13 @@ import java.util.regex.Pattern;
|
||||
/*
|
||||
* @test
|
||||
* @requires vm.debug == true & vm.compMode != "Xint" & vm.compiler1.enabled & vm.compiler2.enabled & vm.flagless
|
||||
* @summary Test IR matcher with different default IR node regexes. Use -DPrintIREncoding.
|
||||
* @summary Test IR matcher with different default IR node regexes. Use -DPrintApplicableIRRules.
|
||||
* Normally, the framework should be called with driver.
|
||||
* @library /test/lib /testlibrary_tests /
|
||||
* @build jdk.test.whitebox.WhiteBox
|
||||
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
|
||||
* @run main/othervm/timeout=240 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
|
||||
* -XX:+WhiteBoxAPI -DPrintIREncoding=true ir_framework.tests.TestIRMatching
|
||||
* -XX:+WhiteBoxAPI -DPrintApplicableIRRules=true ir_framework.tests.TestIRMatching
|
||||
*/
|
||||
|
||||
public class TestIRMatching {
|
||||
@ -440,7 +440,8 @@ public class TestIRMatching {
|
||||
}
|
||||
}
|
||||
if (!output.contains(builder.toString())) {
|
||||
addException(new RuntimeException("Could not find encoding: \"" + builder + System.lineSeparator()));
|
||||
addException(new RuntimeException("Could not find line in Applicable IR Rules: \"" + builder +
|
||||
System.lineSeparator()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2021, 2025, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2021, 2026, 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
|
||||
@ -70,7 +70,7 @@ public class TestPhaseIRMatching {
|
||||
TestVMProcess testVMProcess = new TestVMProcess(testVMFlags, testClass, null, -1, false, false);
|
||||
TestClassParser testClassParser = new TestClassParser(testClass, false);
|
||||
Matchable testClassMatchable = testClassParser.parse(testVMProcess.getHotspotPidFileName(),
|
||||
testVMProcess.getIrEncoding());
|
||||
testVMProcess.getApplicableIRRules());
|
||||
MatchResult result = testClassMatchable.match();
|
||||
List<Failure> expectedFails = new ExpectedFailsBuilder().build(testClass);
|
||||
List<Failure> foundFailures = new FailureBuilder().build(result);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user