10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test TestNewAcmp
26 * @summary Verifies correctness of the new acmp bytecode.
27 * @library /testlibrary /test/lib /compiler/whitebox /
28 * @compile TestNewAcmp.java
29 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
30 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbatch
31 * -XX:+EnableValhalla -XX:TypeProfileLevel=222
32 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*
33 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*
34 * compiler.valhalla.valuetypes.TestNewAcmp 0
35 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
36 * -XX:+WhiteBoxAPI -Xbatch -XX:+EnableValhalla -XX:TypeProfileLevel=222
37 * -XX:+AlwaysIncrementalInline
38 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*
39 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*
40 * compiler.valhalla.valuetypes.TestNewAcmp 0
41 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbatch
42 * -XX:+EnableValhalla -XX:TypeProfileLevel=222
43 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*
44 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*
45 * compiler.valhalla.valuetypes.TestNewAcmp 1
46 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
47 * -XX:+WhiteBoxAPI -Xbatch -XX:+EnableValhalla -XX:TypeProfileLevel=222
48 * -XX:+AlwaysIncrementalInline
49 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*
50 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*
51 * compiler.valhalla.valuetypes.TestNewAcmp 1
52 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbatch
53 * -XX:+EnableValhalla -XX:TypeProfileLevel=222
54 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*
55 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*
56 * compiler.valhalla.valuetypes.TestNewAcmp 2
57 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
58 * -XX:+WhiteBoxAPI -Xbatch -XX:+EnableValhalla -XX:TypeProfileLevel=222
59 * -XX:+AlwaysIncrementalInline
60 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*
61 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*
62 * compiler.valhalla.valuetypes.TestNewAcmp 2
63 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbatch
64 * -XX:+EnableValhalla -XX:TypeProfileLevel=222
65 * -XX:+UnlockExperimentalVMOptions -XX:ACmpOnValues=3
66 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*
67 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*
68 * compiler.valhalla.valuetypes.TestNewAcmp 0
69 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
70 * -XX:+WhiteBoxAPI -Xbatch -XX:+EnableValhalla -XX:TypeProfileLevel=222
71 * -XX:+UnlockExperimentalVMOptions -XX:ACmpOnValues=3
72 * -XX:+AlwaysIncrementalInline
73 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*
74 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*
75 * compiler.valhalla.valuetypes.TestNewAcmp 0
76 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbatch
77 * -XX:+EnableValhalla -XX:TypeProfileLevel=222
78 * -XX:+UnlockExperimentalVMOptions -XX:ACmpOnValues=3
79 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*
80 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*
81 * compiler.valhalla.valuetypes.TestNewAcmp 1
82 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
83 * -XX:+WhiteBoxAPI -Xbatch -XX:+EnableValhalla -XX:TypeProfileLevel=222
84 * -XX:+UnlockExperimentalVMOptions -XX:ACmpOnValues=3
85 * -XX:+AlwaysIncrementalInline
86 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*
87 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*
88 * compiler.valhalla.valuetypes.TestNewAcmp 1
89 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xbatch
90 * -XX:+EnableValhalla -XX:TypeProfileLevel=222
91 * -XX:+UnlockExperimentalVMOptions -XX:ACmpOnValues=3
92 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*
93 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*
94 * compiler.valhalla.valuetypes.TestNewAcmp 2
95 * @run main/othervm -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
96 * -XX:+WhiteBoxAPI -Xbatch -XX:+EnableValhalla -XX:TypeProfileLevel=222
97 * -XX:+UnlockExperimentalVMOptions -XX:ACmpOnValues=3
98 * -XX:+AlwaysIncrementalInline
99 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*
100 * -XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*
101 * compiler.valhalla.valuetypes.TestNewAcmp 2
102 */
103
104 package compiler.valhalla.valuetypes;
105
106 import jdk.test.lib.Asserts;
107 import java.lang.annotation.Retention;
108 import java.lang.annotation.RetentionPolicy;
109 import java.lang.invoke.*;
110 import java.lang.reflect.Method;
111 import java.util.regex.Pattern;
112 import java.util.regex.Matcher;
113 import java.util.Arrays;
114 import sun.hotspot.WhiteBox;
115
116 interface MyInterface {
117
118 }
119
120 inline class MyValue1 implements MyInterface {
121 final int x;
122
123 MyValue1(int x) {
124 this.x = x;
125 }
126
127 static MyValue1 createDefault() {
128 return MyValue1.default;
129 }
130
131 static MyValue1 setX(MyValue1 v, int x) {
132 return new MyValue1(x);
133 }
134 }
135
1577 int idx = i % args.length;
1578 compiled = WHITE_BOX.isMethodCompiled(cmpSometimesEqual1_m, false);
1579 res = cmpSometimesEqual1(args[idx]);
1580 if (ACmpOnValues != 3) {
1581 Asserts.assertEQ(res, args[idx] == null || !args[idx].getClass().isValue());
1582 } else if (compiled) {
1583 Asserts.assertTrue(res);
1584 }
1585 compiled = WHITE_BOX.isMethodCompiled(cmpSometimesEqual2_m, false);
1586 res = cmpSometimesEqual2(args[idx]);
1587 if (ACmpOnValues != 3) {
1588 Asserts.assertNE(res, args[idx] == null || !args[idx].getClass().isValue());
1589 } else if (compiled) {
1590 Asserts.assertFalse(res);
1591 }
1592 }
1593 }
1594
1595 public static void main(String[] args) throws Exception {
1596 if (Boolean.getBoolean("test.c1")) {
1597 System.out.println("new acmp is not implemented for C1");
1598 return;
1599 }
1600
1601 int nullMode = Integer.valueOf(args[0]);
1602 TestNewAcmp t = new TestNewAcmp();
1603 t.run(nullMode);
1604 }
1605 }
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 /**
25 * @test TestNewAcmp
26 * @summary Verifies correctness of the new acmp bytecode.
27 * @library /testlibrary /test/lib /compiler/whitebox /
28 * @compile TestNewAcmp.java
29 * @run driver ClassFileInstaller sun.hotspot.WhiteBox
30 * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:+EnableValhalla
31 * compiler.valhalla.valuetypes.TestNewAcmp
32 */
33
34 package compiler.valhalla.valuetypes;
35
36 import jdk.test.lib.Asserts;
37 import jdk.test.lib.process.ProcessTools;
38 import jdk.test.lib.process.OutputAnalyzer;
39 import java.lang.annotation.Retention;
40 import java.lang.annotation.RetentionPolicy;
41 import java.lang.invoke.*;
42 import java.lang.reflect.Method;
43 import java.util.regex.Pattern;
44 import java.util.regex.Matcher;
45 import java.util.ArrayList;
46 import java.util.Arrays;
47 import java.util.List;
48 import sun.hotspot.WhiteBox;
49
50
51 interface MyInterface {
52
53 }
54
55 inline class MyValue1 implements MyInterface {
56 final int x;
57
58 MyValue1(int x) {
59 this.x = x;
60 }
61
62 static MyValue1 createDefault() {
63 return MyValue1.default;
64 }
65
66 static MyValue1 setX(MyValue1 v, int x) {
67 return new MyValue1(x);
68 }
69 }
70
1512 int idx = i % args.length;
1513 compiled = WHITE_BOX.isMethodCompiled(cmpSometimesEqual1_m, false);
1514 res = cmpSometimesEqual1(args[idx]);
1515 if (ACmpOnValues != 3) {
1516 Asserts.assertEQ(res, args[idx] == null || !args[idx].getClass().isValue());
1517 } else if (compiled) {
1518 Asserts.assertTrue(res);
1519 }
1520 compiled = WHITE_BOX.isMethodCompiled(cmpSometimesEqual2_m, false);
1521 res = cmpSometimesEqual2(args[idx]);
1522 if (ACmpOnValues != 3) {
1523 Asserts.assertNE(res, args[idx] == null || !args[idx].getClass().isValue());
1524 } else if (compiled) {
1525 Asserts.assertFalse(res);
1526 }
1527 }
1528 }
1529
1530 public static void main(String[] args) throws Exception {
1531 if (Boolean.getBoolean("test.c1")) {
1532 System.out.println("new acmp is not implemented for C1"); // TMP
1533 return;
1534 }
1535
1536 if (args.length == 0) {
1537 enumerateVMOptions();
1538 } else {
1539 int nullMode = Integer.valueOf(args[0]);
1540 TestNewAcmp t = new TestNewAcmp();
1541 t.run(nullMode);
1542 }
1543 }
1544
1545 private static String[] addOptions(String prefix[], String... extra) {
1546 ArrayList<String> list = new ArrayList<String>();
1547 if (prefix != null) {
1548 for (String s : prefix) {
1549 list.add(s);
1550 }
1551 }
1552 if (extra != null) {
1553 for (String s : extra) {
1554 System.out.println(" " + s);
1555 list.add(s);
1556 }
1557 }
1558
1559 return list.toArray(new String[list.size()]);
1560 }
1561
1562 private static void enumerateVMOptions() throws Exception {
1563 String[] baseOptions = {
1564 "-Xbootclasspath/a:.",
1565 "-XX:+UnlockDiagnosticVMOptions",
1566 "-XX:+WhiteBoxAPI",
1567 "-Xbatch",
1568 "-XX:+EnableValhalla",
1569 "-XX:TypeProfileLevel=222",
1570 "-XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::test*",
1571 "-XX:CompileCommand=dontinline,compiler.valhalla.valuetypes.TestNewAcmp::cmp*"};
1572
1573 String SCENARIOS = System.getProperty("Scenarios", "");
1574 List<String> scenarios = null;
1575 if (!SCENARIOS.isEmpty()) {
1576 scenarios = Arrays.asList(SCENARIOS.split(","));
1577 }
1578
1579 int scenario = -1;
1580 for (int nullMode = 0; nullMode <= 2; nullMode++) { // null mode
1581 for (int onVal = 0; onVal < 2; onVal++) { // 0 = default, 1 = -XX:ACmpOnValues=3
1582 for (int incrInline = 0; incrInline < 2; incrInline++) { // 0 = default, 1 = -XX:+AlwaysIncrementalInline
1583 scenario++;
1584 if (scenarios != null && !scenarios.contains(Integer.toString(scenario))) {
1585 System.out.println("Scenario #" + scenario + " is skipped due to -Dscenarios=" + SCENARIOS);
1586 continue;
1587 } else {
1588 System.out.println("Scenario #" + scenario + " -------------------");
1589 }
1590
1591 String[] cmds = baseOptions;
1592 if (incrInline != 0) {
1593 cmds = addOptions(cmds, "-XX:+AlwaysIncrementalInline");
1594 }
1595 if (onVal != 0) {
1596 cmds = addOptions(cmds, "-XX:+UnlockExperimentalVMOptions", "-XX:ACmpOnValues=3");
1597 }
1598 cmds = addOptions(cmds, "compiler.valhalla.valuetypes.TestNewAcmp");
1599 cmds = addOptions(cmds, Integer.toString(nullMode));
1600
1601 OutputAnalyzer oa = ProcessTools.executeTestJvm(cmds);
1602 String output = oa.getOutput();
1603 oa.shouldHaveExitValue(0);
1604 System.out.println(output);
1605 }
1606 }
1607 }
1608 }
1609 }
|