RFR: 8332111: [BACKOUT] A way to align already compiled methods with compiler directives
Evgeny Astigeevich
eastigeevich at openjdk.org
Mon May 13 20:37:40 UTC 2024
On Mon, 13 May 2024 16:29:35 GMT, Vladimir Kozlov <kvn at openjdk.org> wrote:
> do you have tests which shows issues you listed in description?
Here is a jtreg test:
- `refresh_control.02.txt`
[
{
match: "serviceability.dcmd.compiler.DirectivesRefreshTest::callable",
c2: {
PrintOptoAssembly: true
}
}
]
- `DirectivesRefreshTest02.java`
/**
* @test DirectivesRefreshTest02
* @summary Test of forced recompile after compiler directives changes by diagnostic command
* @requires vm.compiler1.enabled & vm.compiler2.enabled
* @library /test/lib /
* @modules java.base/jdk.internal.misc
*
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
*
* @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI
* -XX:+BackgroundCompilation -Xlog:codecache=trace -XX:-Inline -XX:+TieredCompilation -XX:CICompilerCount=2
* -XX:+UnlockDiagnosticVMOptions
* serviceability.dcmd.compiler.DirectivesRefreshTest02
*/
package serviceability.dcmd.compiler;
import jdk.test.whitebox.WhiteBox;
import jdk.test.lib.process.OutputAnalyzer;
import jdk.test.lib.dcmd.CommandExecutor;
import jdk.test.lib.dcmd.JMXExecutor;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.lang.reflect.Method;
import java.util.Random;
import static jdk.test.lib.Asserts.assertEQ;
import static compiler.whitebox.CompilerWhiteBoxTest.COMP_LEVEL_NONE;
import static compiler.whitebox.CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE;
import static compiler.whitebox.CompilerWhiteBoxTest.COMP_LEVEL_FULL_OPTIMIZATION;
public class DirectivesRefreshTest02 {
static Path cmdPath = Paths.get(System.getProperty("test.src", "."), "refresh_control.02.txt");
static WhiteBox wb = WhiteBox.getWhiteBox();
static Random random = new Random();
static Method method;
static CommandExecutor executor;
static int callable() {
int result = 0;
for (int i = 0; i < 100; i++) {
result += random.nextInt(100);
}
return result;
}
static void setup() throws Exception {
method = DirectivesRefreshTest.class.getDeclaredMethod("callable");
executor = new JMXExecutor();
wb.enqueueMethodForCompilation(method, COMP_LEVEL_SIMPLE);
while (wb.isMethodQueuedForCompilation(method)) {
Thread.onSpinWait();
}
wb.lockCompilation();
boolean r = wb.enqueueMethodForCompilation(method, COMP_LEVEL_FULL_OPTIMIZATION);
System.out.println("Method enqueued: " + r);
}
static void testDirectivesAddRefresh() {
var output = executor.execute("Compiler.directives_add -r " + cmdPath.toString());
output.stderrShouldBeEmpty().shouldContain("1 compiler directives added");
System.out.println("Method enqueued: " + wb.isMethodQueuedForCompilation(method));
wb.unlockCompilation();
wb.enqueueMethodForCompilation(method, COMP_LEVEL_FULL_OPTIMIZATION);
while (wb.isMethodQueuedForCompilation(method)) {
Thread.onSpinWait();
}
System.out.println("Method compilation level: " + wb.getMethodCompilationLevel(method));
assertEQ(true, false, "Stop here");
}
public static void main(String[] args) throws Exception {
setup();
testDirectivesAddRefresh();
}
}
-------------
PR Comment: https://git.openjdk.org/jdk/pull/19215#issuecomment-2108744800
More information about the hotspot-compiler-dev
mailing list