Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2022, 2025, 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
Expand Down Expand Up @@ -38,13 +38,13 @@

/*
* @test
* @requires vm.debug == true & vm.flagless
* @requires vm.flagless
* @summary Test compile command file writer.
* @library /test/lib /testlibrary_tests /
* @build jdk.test.whitebox.WhiteBox
* @run driver jdk.test.lib.helpers.ClassFileInstaller jdk.test.whitebox.WhiteBox
* @run junit/othervm -Xbootclasspath/a:. -DSkipWhiteBoxInstall=true -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
* -XX:+WhiteBoxAPI compiler.lib.ir_framework.flag.TestCompilePhaseCollector
* @run junit/othervm -Xbootclasspath/a:. -DSkipWhiteBoxInstall=true -XX:+UnlockDiagnosticVMOptions
* -XX:+WhiteBoxAPI compiler.lib.ir_framework.flag.TestCompileCommandFileWriter
*/
public class TestCompileCommandFileWriter {

Expand Down Expand Up @@ -81,6 +81,8 @@ public void testMix() throws IOException {
}

private void check(Class<?> testClass, boolean findIdeal, boolean findOpto, CompilePhase... compilePhases) throws IOException {
var compilerDirectivesFlagBuilder = new CompilerDirectivesFlagBuilder(testClass);
compilerDirectivesFlagBuilder.build();
Copy link
Member Author

Choose a reason for hiding this comment

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

I was tempted to write

new CompilerDirectivesFlagBuilder(testClass).build();

since we don't use compilerDirectivesFlagBuilder after. But I felt like the style might not be liked. Opinions on that?

Copy link
Member

Choose a reason for hiding this comment

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

I guess it's fine to go with new CompilerDirectivesFlagBuilder(testClass).build().

Copy link
Member Author

Choose a reason for hiding this comment

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

If there is no strong preference, I'll just leave it as it is: having the variable doesn't hurt, as far as I know, and it helps slightly if one wants to debug, to make a breakpoint, to inspect the state of the object etc..

try (Scanner scanner = new Scanner(Paths.get(FlagVM.TEST_VM_COMPILE_COMMANDS_FILE))) {
boolean foundIdeal = false;
boolean foundOpto = false;
Expand Down Expand Up @@ -132,29 +134,29 @@ public void test() {

static class OptoOnly1 {
@Test
@IR(failOn = IRNode.ALLOC)
@IR(failOn = IRNode.FIELD_ACCESS)
public void test() {
}
}

static class OptoOnly2 {
@Test
@IR(failOn = IRNode.ALLOC, phase = PRINT_OPTO_ASSEMBLY)
@IR(failOn = IRNode.FIELD_ACCESS, phase = PRINT_OPTO_ASSEMBLY)
public void test() {
}
}

static class Both1 {
@Test
@IR(failOn = IRNode.STORE)
@IR(failOn = IRNode.ALLOC)
@IR(failOn = IRNode.FIELD_ACCESS)
public void test() {
}
}

static class Both2 {
@Test
@IR(failOn = {IRNode.STORE, IRNode. ALLOC})
@IR(failOn = {IRNode.STORE, IRNode. FIELD_ACCESS})
public void test() {
}
}
Expand Down Expand Up @@ -183,7 +185,7 @@ public void test() {

static class Mix2 {
@Test
@IR(failOn = IRNode.ALLOC, phase = AFTER_PARSING)
@IR(failOn = IRNode.FIELD_ACCESS, phase = AFTER_PARSING)
@IR(failOn = IRNode.STORE, phase = PRINT_OPTO_ASSEMBLY)
public void test() {
}
Expand All @@ -193,15 +195,15 @@ static class Mix3 {
@Test
@IR(failOn = IRNode.STORE, phase = AFTER_PARSING)
@IR(failOn = IRNode.STORE, phase = PRINT_IDEAL)
@IR(failOn = IRNode.ALLOC, phase = PRINT_OPTO_ASSEMBLY)
@IR(failOn = IRNode.FIELD_ACCESS, phase = PRINT_OPTO_ASSEMBLY)
public void test() {
}
}

static class Mix4 {
@Test
@IR(failOn = IRNode.STORE, phase = {AFTER_PARSING, PRINT_IDEAL})
@IR(failOn = IRNode.ALLOC, phase = PRINT_OPTO_ASSEMBLY)
@IR(failOn = IRNode.FIELD_ACCESS, phase = PRINT_OPTO_ASSEMBLY)
public void test() {
}
}
Expand Down