From cd472090540704223e79f2f957e544e5b2df36da Mon Sep 17 00:00:00 2001 From: Dongxu Wang Date: Fri, 25 Nov 2022 05:55:19 +0000 Subject: [PATCH 1/7] 8297385: Remove duplicated null typos in javadoc Reviewed-by: dfuchs, rriggs --- .../share/classes/javax/xml/parsers/DocumentBuilder.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/java.xml/share/classes/javax/xml/parsers/DocumentBuilder.java b/src/java.xml/share/classes/javax/xml/parsers/DocumentBuilder.java index ee893cb5892..f9d5aa9108c 100644 --- a/src/java.xml/share/classes/javax/xml/parsers/DocumentBuilder.java +++ b/src/java.xml/share/classes/javax/xml/parsers/DocumentBuilder.java @@ -155,7 +155,7 @@ public Document parse(InputStream is, String systemId) * Parse the content of the given URI as an XML document * and return a new DOM {@link Document} object. * An IllegalArgumentException is thrown if the - * URI is null null. + * URI is null. * * @param uri The location of the content to be parsed. * @@ -182,7 +182,7 @@ public Document parse(String uri) * Parse the content of the given file as an XML document * and return a new DOM {@link Document} object. * An IllegalArgumentException is thrown if the - * File is null null. + * File is null. * * @param f The file containing the XML to parse. * @@ -210,7 +210,7 @@ public Document parse(File f) throws SAXException, IOException { * Parse the content of the given input source as an XML document * and return a new DOM {@link Document} object. * An IllegalArgumentException is thrown if the - * InputSource is null null. + * InputSource is null. * * @param is InputSource containing the content to be parsed. * From 2d62767f5ff35cc8a7b54daa79aa55336855084c Mon Sep 17 00:00:00 2001 From: Volodymyr Paprotski Date: Fri, 25 Nov 2022 07:07:39 +0000 Subject: [PATCH 2/7] 8297417: Poly1305IntrinsicFuzzTest fails with tag mismatch exception Reviewed-by: sviswanathan, vlivanov, rcastanedalo, thartmann --- .../Cipher/ChaCha20/unittest/Poly1305UnitTestDriver.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/jdk/com/sun/crypto/provider/Cipher/ChaCha20/unittest/Poly1305UnitTestDriver.java b/test/jdk/com/sun/crypto/provider/Cipher/ChaCha20/unittest/Poly1305UnitTestDriver.java index 34bb118155f..3431ba0da28 100644 --- a/test/jdk/com/sun/crypto/provider/Cipher/ChaCha20/unittest/Poly1305UnitTestDriver.java +++ b/test/jdk/com/sun/crypto/provider/Cipher/ChaCha20/unittest/Poly1305UnitTestDriver.java @@ -49,14 +49,14 @@ * @key randomness * @modules java.base/com.sun.crypto.provider * @summary Unit test for IntrinsicCandidate in com.sun.crypto.provider.Poly1305. - * @run main/othervm -Xcomp -XX:-TieredCompilation java.base/com.sun.crypto.provider.Poly1305IntrinsicFuzzTest + * @run main/othervm -Xcomp -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+ForceUnreachable java.base/com.sun.crypto.provider.Poly1305IntrinsicFuzzTest */ /* * @test * @modules java.base/com.sun.crypto.provider * @summary Unit test for IntrinsicCandidate in com.sun.crypto.provider.Poly1305. - * @run main/othervm -Xcomp -XX:-TieredCompilation java.base/com.sun.crypto.provider.Poly1305KAT + * @run main/othervm -Xcomp -XX:-TieredCompilation -XX:+UnlockDiagnosticVMOptions -XX:+ForceUnreachable java.base/com.sun.crypto.provider.Poly1305KAT */ package com.sun.crypto.provider.Cipher.ChaCha20; From d0c1d5b4f10096c5e4764dbcbc4acf6a5dbb4c0c Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Fri, 25 Nov 2022 08:06:14 +0000 Subject: [PATCH 3/7] 8297556: Parse::check_interpreter_type fails with assert "must constrain OSR typestate" Reviewed-by: thartmann, vlivanov --- .../types/TestExactArrayOfBasicType.java | 46 +++++++++++++++++++ 1 file changed, 46 insertions(+) create mode 100644 test/hotspot/jtreg/compiler/types/TestExactArrayOfBasicType.java diff --git a/test/hotspot/jtreg/compiler/types/TestExactArrayOfBasicType.java b/test/hotspot/jtreg/compiler/types/TestExactArrayOfBasicType.java new file mode 100644 index 00000000000..4ff660cfcec --- /dev/null +++ b/test/hotspot/jtreg/compiler/types/TestExactArrayOfBasicType.java @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2022, Red Hat, Inc. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8297556 + * @summary Parse::check_interpreter_type fails with assert "must constrain OSR typestate" + * + * @run main/othervm -Xbatch -XX:-TieredCompilation -XX:CompileOnly=TestExactArrayOfBasicType::test TestExactArrayOfBasicType + * + */ + + +public class TestExactArrayOfBasicType { + public static void test() { + int[][][][][] array = new int[1][2][3][4][5]; + + for (int i = 0; i < 50_000; ++i) { + array[0] = new int[0][1][2][3]; + } + } + + public static void main(String args[]) { + test(); + } +} From 9cca7298401785823a336a634f5842e3a92dfd65 Mon Sep 17 00:00:00 2001 From: Zhiqiang Zang Date: Fri, 25 Nov 2022 08:17:44 +0000 Subject: [PATCH 4/7] 8297384: Add IR tests for existing idealizations of arithmetic nodes Reviewed-by: chagedorn --- .../c2/irTests/AddINodeIdealizationTests.java | 70 ++++++++++------- .../c2/irTests/AddLNodeIdealizationTests.java | 69 ++++++++++------- .../c2/irTests/AndINodeIdealizationTests.java | 66 ++++++++++++++++ .../irTests/LShiftINodeIdealizationTests.java | 74 ++++++++++++++++++ .../c2/irTests/MulINodeIdealizationTests.java | 45 +++++++---- .../c2/irTests/MulLNodeIdealizationTests.java | 45 +++++++---- .../RotateLeftNodeIntIdealizationTests.java | 67 +++++++++++++++++ .../RotateLeftNodeLongIdealizationTests.java | 67 +++++++++++++++++ .../URShiftINodeIdealizationTests.java | 75 +++++++++++++++++++ .../URShiftLNodeIdealizationTests.java | 75 +++++++++++++++++++ .../compiler/lib/ir_framework/IRNode.java | 20 +++++ 11 files changed, 596 insertions(+), 77 deletions(-) create mode 100644 test/hotspot/jtreg/compiler/c2/irTests/AndINodeIdealizationTests.java create mode 100644 test/hotspot/jtreg/compiler/c2/irTests/LShiftINodeIdealizationTests.java create mode 100644 test/hotspot/jtreg/compiler/c2/irTests/RotateLeftNodeIntIdealizationTests.java create mode 100644 test/hotspot/jtreg/compiler/c2/irTests/RotateLeftNodeLongIdealizationTests.java create mode 100644 test/hotspot/jtreg/compiler/c2/irTests/URShiftINodeIdealizationTests.java create mode 100644 test/hotspot/jtreg/compiler/c2/irTests/URShiftLNodeIdealizationTests.java diff --git a/test/hotspot/jtreg/compiler/c2/irTests/AddINodeIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/AddINodeIdealizationTests.java index afd28850df3..c82f82a19b1 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/AddINodeIdealizationTests.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/AddINodeIdealizationTests.java @@ -45,7 +45,7 @@ public static void main(String[] args) { "test14", "test15", "test16", "test17", "test18", "test19", "test20", "test21", "test22", - "test23"}) + "test23", "test24", "test25"}) public void runMethod() { int a = RunInfo.getRandom().nextInt(); int b = RunInfo.getRandom().nextInt(); @@ -63,31 +63,33 @@ public void runMethod() { @DontCompile public void assertResult(int a, int b, int c, int d) { - Asserts.assertEQ(((a+a) + (a+a)) , additions(a)); - Asserts.assertEQ(0 , xMinusX(a)); - Asserts.assertEQ(a + 1 + 2 , test1(a)); - Asserts.assertEQ((a + 2021) + b , test2(a, b)); - Asserts.assertEQ(a + (b + 2021) , test3(a, b)); - Asserts.assertEQ((1 - a) + 2 , test4(a)); - Asserts.assertEQ((a - b) + (c - d), test5(a, b, c, d)); - Asserts.assertEQ((a - b) + (b + c), test6(a, b, c)); - Asserts.assertEQ((a - b) + (c + b), test7(a, b, c)); - Asserts.assertEQ((a - b) + (b - c), test8(a, b, c)); - Asserts.assertEQ((a - b) + (c - a), test9(a, b, c)); - Asserts.assertEQ(a + (0 - b) , test10(a, b)); - Asserts.assertEQ((0 - b) + a , test11(a, b)); - Asserts.assertEQ((a - b) + b , test12(a, b)); - Asserts.assertEQ(b + (a - b) , test13(a, b)); - Asserts.assertEQ(a + 0 , test14(a)); - Asserts.assertEQ(0 + a , test15(a)); - Asserts.assertEQ(a*b + a*c , test16(a, b, c)); - Asserts.assertEQ(a*b + b*c , test17(a, b, c)); - Asserts.assertEQ(a*c + b*c , test18(a, b, c)); - Asserts.assertEQ(a*b + c*a , test19(a, b, c)); - Asserts.assertEQ((a - b) + 210 , test20(a, b)); - Asserts.assertEQ((a - b) + 190 , test21(a, b)); - Asserts.assertEQ((a - b) + 210 , test22(a, b)); - Asserts.assertEQ((a - b) + 190 , test23(a, b)); + Asserts.assertEQ(((a+a) + (a+a)) , additions(a)); + Asserts.assertEQ(0 , xMinusX(a)); + Asserts.assertEQ(a + 1 + 2 , test1(a)); + Asserts.assertEQ((a + 2021) + b , test2(a, b)); + Asserts.assertEQ(a + (b + 2021) , test3(a, b)); + Asserts.assertEQ((1 - a) + 2 , test4(a)); + Asserts.assertEQ((a - b) + (c - d) , test5(a, b, c, d)); + Asserts.assertEQ((a - b) + (b + c) , test6(a, b, c)); + Asserts.assertEQ((a - b) + (c + b) , test7(a, b, c)); + Asserts.assertEQ((a - b) + (b - c) , test8(a, b, c)); + Asserts.assertEQ((a - b) + (c - a) , test9(a, b, c)); + Asserts.assertEQ(a + (0 - b) , test10(a, b)); + Asserts.assertEQ((0 - b) + a , test11(a, b)); + Asserts.assertEQ((a - b) + b , test12(a, b)); + Asserts.assertEQ(b + (a - b) , test13(a, b)); + Asserts.assertEQ(a + 0 , test14(a)); + Asserts.assertEQ(0 + a , test15(a)); + Asserts.assertEQ(a*b + a*c , test16(a, b, c)); + Asserts.assertEQ(a*b + b*c , test17(a, b, c)); + Asserts.assertEQ(a*c + b*c , test18(a, b, c)); + Asserts.assertEQ(a*b + c*a , test19(a, b, c)); + Asserts.assertEQ((a - b) + 210 , test20(a, b)); + Asserts.assertEQ((a - b) + 190 , test21(a, b)); + Asserts.assertEQ((a - b) + 210 , test22(a, b)); + Asserts.assertEQ((a - b) + 190 , test23(a, b)); + Asserts.assertEQ(Math.max(a, b) + Math.min(a, b), test24(a, b)); + Asserts.assertEQ(Math.min(a, b) + Math.max(a, b), test25(a, b)); } @Test @@ -293,4 +295,20 @@ public int test22(int x, int y) { public int test23(int x, int y) { return x + (-10 - y) + 200; // transformed to (x - y) + 190; } + + @Test + @IR(failOn = { IRNode.MAX, IRNode.MIN }) + @IR(counts = { IRNode.ADD, "1" }) + // Checks Math.max(a, b) + Math.min(a, b) => a + b + public int test24(int a, int b) { + return Math.max(a, b) + Math.min(a, b); + } + + @Test + @IR(failOn = { IRNode.MAX, IRNode.MIN }) + @IR(counts = { IRNode.ADD, "1" }) + // Checks Math.min(a, b) + Math.max(a, b) => a + b + public int test25(int a, int b) { + return Math.min(a, b) + Math.max(a, b); + } } diff --git a/test/hotspot/jtreg/compiler/c2/irTests/AddLNodeIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/AddLNodeIdealizationTests.java index a53da5a3cba..0c41beaee22 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/AddLNodeIdealizationTests.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/AddLNodeIdealizationTests.java @@ -44,7 +44,8 @@ public static void main(String[] args) { "test11", "test12", "test13", "test14", "test15", "test16", "test17", "test18", "test19", - "test20", "test21", "test22"}) + "test20", "test21", "test22", + "test23", "test24"}) public void runMethod() { long a = RunInfo.getRandom().nextLong(); long b = RunInfo.getRandom().nextLong(); @@ -62,30 +63,32 @@ public void runMethod() { @DontCompile public void assertResult(long a, long b, long c, long d) { - Asserts.assertEQ(((a+a) + (a+a)) , additions(a)); - Asserts.assertEQ(0L , xMinusX(a)); - Asserts.assertEQ(a + 1 + 2 , test1(a)); - Asserts.assertEQ((a + 2021) + b , test2(a, b)); - Asserts.assertEQ(a + (b + 2021) , test3(a, b)); - Asserts.assertEQ((1 - a) + 2 , test4(a)); - Asserts.assertEQ((a - b) + (c - d) , test5(a, b, c, d)); - Asserts.assertEQ((a - b) + (b + c) , test6(a, b, c)); - Asserts.assertEQ((a - b) + (c + b) , test7(a, b, c)); - Asserts.assertEQ((a - b) + (c - a) , test8(a, b, c)); - Asserts.assertEQ(a + (0 - b) , test9(a, b)); - Asserts.assertEQ((0 - b) + a , test10(a, b)); - Asserts.assertEQ((a - b) + b , test11(a, b)); - Asserts.assertEQ(b + (a - b) , test12(a, b)); - Asserts.assertEQ(a + 0 , test13(a)); - Asserts.assertEQ(0 + a , test14(a)); - Asserts.assertEQ(a*b + a*c , test15(a, b, c)); - Asserts.assertEQ(a*b + b*c , test16(a, b, c)); - Asserts.assertEQ(a*c + b*c , test17(a, b, c)); - Asserts.assertEQ(a*b + c*a , test18(a, b, c)); - Asserts.assertEQ((a - b) + 123_456_789_123L , test19(a, b)); - Asserts.assertEQ((a - b) + -123_456_788_877L , test20(a, b)); - Asserts.assertEQ((a - b) + 123_456_789_123L , test21(a, b)); - Asserts.assertEQ((a - b) + -123_456_788_877L , test22(a, b)); + Asserts.assertEQ(((a+a) + (a+a)) , additions(a)); + Asserts.assertEQ(0L , xMinusX(a)); + Asserts.assertEQ(a + 1 + 2 , test1(a)); + Asserts.assertEQ((a + 2021) + b , test2(a, b)); + Asserts.assertEQ(a + (b + 2021) , test3(a, b)); + Asserts.assertEQ((1 - a) + 2 , test4(a)); + Asserts.assertEQ((a - b) + (c - d) , test5(a, b, c, d)); + Asserts.assertEQ((a - b) + (b + c) , test6(a, b, c)); + Asserts.assertEQ((a - b) + (c + b) , test7(a, b, c)); + Asserts.assertEQ((a - b) + (c - a) , test8(a, b, c)); + Asserts.assertEQ(a + (0 - b) , test9(a, b)); + Asserts.assertEQ((0 - b) + a , test10(a, b)); + Asserts.assertEQ((a - b) + b , test11(a, b)); + Asserts.assertEQ(b + (a - b) , test12(a, b)); + Asserts.assertEQ(a + 0 , test13(a)); + Asserts.assertEQ(0 + a , test14(a)); + Asserts.assertEQ(a*b + a*c , test15(a, b, c)); + Asserts.assertEQ(a*b + b*c , test16(a, b, c)); + Asserts.assertEQ(a*c + b*c , test17(a, b, c)); + Asserts.assertEQ(a*b + c*a , test18(a, b, c)); + Asserts.assertEQ((a - b) + 123_456_789_123L , test19(a, b)); + Asserts.assertEQ((a - b) + -123_456_788_877L , test20(a, b)); + Asserts.assertEQ((a - b) + 123_456_789_123L , test21(a, b)); + Asserts.assertEQ((a - b) + -123_456_788_877L , test22(a, b)); + Asserts.assertEQ(Math.max(a, b) + Math.min(a, b), test23(a, b)); + Asserts.assertEQ(Math.min(a, b) + Math.max(a, b), test24(a, b)); } @Test @@ -287,4 +290,20 @@ public long test22(long x, long y) { return x + (-123_456_789_000L - y) + 123; // transformed to (x - y) + -123_456_788_877L; } + + @Test + @IR(failOn = { IRNode.MAX, IRNode.MIN }) + @IR(counts = { IRNode.ADD, "1" }) + // Checks Math.max(a, b) + Math.min(a, b) => a + b + public long test23(long a, long b) { + return Math.max(a, b) + Math.min(a, b); + } + + @Test + @IR(failOn = { IRNode.MAX, IRNode.MIN }) + @IR(counts = { IRNode.ADD, "1" }) + // Checks Math.min(a, b) + Math.max(a, b) => a + b + public long test24(long a, long b) { + return Math.min(a, b) + Math.max(a, b); + } } diff --git a/test/hotspot/jtreg/compiler/c2/irTests/AndINodeIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/AndINodeIdealizationTests.java new file mode 100644 index 00000000000..ad2b52392b6 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/irTests/AndINodeIdealizationTests.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package compiler.c2.irTests; + +import jdk.test.lib.Asserts; +import compiler.lib.ir_framework.*; + +/* + * @test + * @bug 8297384 + * @summary Test that Ideal transformations of AndINode* are being performed as expected. + * @library /test/lib / + * @run driver compiler.c2.irTests.AndINodeIdealizationTests + */ +public class AndINodeIdealizationTests { + + public static void main(String[] args) { + TestFramework.run(); + } + + @Run(test = { "test1" }) + public void runMethod() { + int a = RunInfo.getRandom().nextInt(); + + int min = Integer.MIN_VALUE; + int max = Integer.MAX_VALUE; + + assertResult(0); + assertResult(a); + assertResult(min); + assertResult(max); + } + + @DontCompile + public void assertResult(int a) { + Asserts.assertEQ((0 - a) & 1, test1(a)); + } + + @Test + @IR(failOn = { IRNode.SUB }) + @IR(counts = { IRNode.AND, "1" }) + // Checks (0 - x) & 1 => x & 1 + public int test1(int x) { + return (0 - x) & 1; + } +} diff --git a/test/hotspot/jtreg/compiler/c2/irTests/LShiftINodeIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/LShiftINodeIdealizationTests.java new file mode 100644 index 00000000000..645e103aaff --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/irTests/LShiftINodeIdealizationTests.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package compiler.c2.irTests; + +import jdk.test.lib.Asserts; +import compiler.lib.ir_framework.*; + +/* + * @test + * @bug 8297384 + * @summary Test that Ideal transformations of LShiftINode* are being performed as expected. + * @library /test/lib / + * @run driver compiler.c2.irTests.LShiftINodeIdealizationTests + */ +public class LShiftINodeIdealizationTests { + public static void main(String[] args) { + TestFramework.run(); + } + + @Run(test = { "test1", "test2" }) + public void runMethod() { + int a = RunInfo.getRandom().nextInt(); + + int min = Integer.MIN_VALUE; + int max = Integer.MAX_VALUE; + + assertResult(0); + assertResult(a); + assertResult(min); + assertResult(max); + } + + @DontCompile + public void assertResult(int a) { + Asserts.assertEQ((a >> 2022) << 2022, test1(a)); + Asserts.assertEQ((a >>> 2022) << 2022, test2(a)); + } + + @Test + @IR(failOn = { IRNode.LSHIFT, IRNode.RSHIFT }) + @IR(counts = { IRNode.AND, "1" }) + // Checks (x >> 2022) << 2022 => x & C where C = -(1 << 6) + public int test1(int x) { + return (x >> 2022) << 2022; + } + + @Test + @IR(failOn = { IRNode.LSHIFT, IRNode.URSHIFT }) + @IR(counts = { IRNode.AND, "1" }) + // Checks (x >>> 2022) << 2022 => x & C where C = -(1 << 6) + public int test2(int x) { + return (x >>> 2022) << 2022; + } +} diff --git a/test/hotspot/jtreg/compiler/c2/irTests/MulINodeIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/MulINodeIdealizationTests.java index 233efe84a04..121d6e33dfa 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/MulINodeIdealizationTests.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/MulINodeIdealizationTests.java @@ -40,7 +40,8 @@ public static void main(String[] args) { @Run(test = {"combineConstants", "moveConstants", "moveConstantsAgain", "multiplyZero", "multiplyZeroAgain", "distribute", "identity", "identityAgain", "powerTwo", - "powerTwoAgain", "powerTwoPlusOne", "powerTwoMinusOne"}) + "powerTwoAgain", "powerTwoPlusOne", "powerTwoMinusOne", + "negativeCancelledOut", "maxMin"}) public void runMethod() { int a = RunInfo.getRandom().nextInt(); int b = RunInfo.getRandom().nextInt(); @@ -56,18 +57,20 @@ public void runMethod() { @DontCompile public void assertResult(int a, int b) { - Asserts.assertEQ((a * 13) * 14 , combineConstants(a)); - Asserts.assertEQ((a * 13) * b , moveConstants(a, b)); - Asserts.assertEQ(a * (b * 13) , moveConstantsAgain(a, b)); - Asserts.assertEQ(0 * a , multiplyZero(a)); - Asserts.assertEQ(a * 0 , multiplyZeroAgain(a)); - Asserts.assertEQ((13 + a) * 14 , distribute(a)); - Asserts.assertEQ(1 * a , identity(a)); - Asserts.assertEQ(a * 1 , identityAgain(a)); - Asserts.assertEQ(a * 64 , powerTwo(a)); - Asserts.assertEQ(a * (1025 - 1), powerTwoAgain(a)); - Asserts.assertEQ(a * (64 + 1) , powerTwoPlusOne(a)); - Asserts.assertEQ(a * (64 - 1) , powerTwoMinusOne(a)); + Asserts.assertEQ((a * 13) * 14 , combineConstants(a)); + Asserts.assertEQ((a * 13) * b , moveConstants(a, b)); + Asserts.assertEQ(a * (b * 13) , moveConstantsAgain(a, b)); + Asserts.assertEQ(0 * a , multiplyZero(a)); + Asserts.assertEQ(a * 0 , multiplyZeroAgain(a)); + Asserts.assertEQ((13 + a) * 14 , distribute(a)); + Asserts.assertEQ(1 * a , identity(a)); + Asserts.assertEQ(a * 1 , identityAgain(a)); + Asserts.assertEQ(a * 64 , powerTwo(a)); + Asserts.assertEQ(a * (1025 - 1) , powerTwoAgain(a)); + Asserts.assertEQ(a * (64 + 1) , powerTwoPlusOne(a)); + Asserts.assertEQ(a * (64 - 1) , powerTwoMinusOne(a)); + Asserts.assertEQ((0 - a) * (0 - b) , negativeCancelledOut(a, b)); + Asserts.assertEQ(Math.max(a, b) * Math.min(a, b), maxMin(a, b)); } @Test @@ -163,4 +166,20 @@ public int powerTwoPlusOne(int x) { public int powerTwoMinusOne(int x) { return x * (64 - 1); } + + @Test + @IR(failOn = { IRNode.SUB }) + @IR(counts = { IRNode.MUL, "1" }) + // Checks (0 - x) * (0 - y) => x * y + public int negativeCancelledOut(int x, int y) { + return (0 - x) * (0 - y); + } + + @Test + @IR(failOn = { IRNode.MAX, IRNode.MIN }) + @IR(counts = { IRNode.MUL, "1" }) + // Checks Math.max(x, y) * Math.min(x, y) => x * y + public int maxMin(int x, int y) { + return Math.max(x, y) * Math.min(x, y); + } } diff --git a/test/hotspot/jtreg/compiler/c2/irTests/MulLNodeIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/MulLNodeIdealizationTests.java index 8a8b5923bcc..cc863912456 100644 --- a/test/hotspot/jtreg/compiler/c2/irTests/MulLNodeIdealizationTests.java +++ b/test/hotspot/jtreg/compiler/c2/irTests/MulLNodeIdealizationTests.java @@ -40,7 +40,8 @@ public static void main(String[] args) { @Run(test = {"combineConstants", "moveConstants", "moveConstantsAgain", "multiplyZero", "multiplyZeroAgain", "distribute", "identity", "identityAgain", "powerTwo", - "powerTwoAgain", "powerTwoPlusOne", "powerTwoMinusOne"}) + "powerTwoAgain", "powerTwoPlusOne", "powerTwoMinusOne", + "negativeCancelledOut", "maxMin"}) public void runMethod() { long a = RunInfo.getRandom().nextLong(); long b = RunInfo.getRandom().nextLong(); @@ -56,18 +57,20 @@ public void runMethod() { @DontCompile public void assertResult(long a, long b) { - Asserts.assertEQ((a * 13) * 14 * 15, combineConstants(a)); - Asserts.assertEQ((a * 13) * b , moveConstants(a, b)); - Asserts.assertEQ(a * (b * 13) , moveConstantsAgain(a, b)); - Asserts.assertEQ(0 * a , multiplyZero(a)); - Asserts.assertEQ(a * 0 , multiplyZeroAgain(a)); - Asserts.assertEQ((13 + a) * 14 , distribute(a)); - Asserts.assertEQ(1 * a , identity(a)); - Asserts.assertEQ(a * 1 , identityAgain(a)); - Asserts.assertEQ(a * 64 , powerTwo(a)); - Asserts.assertEQ(a * (1025 - 1) , powerTwoAgain(a)); - Asserts.assertEQ(a * (64 + 1) , powerTwoPlusOne(a)); - Asserts.assertEQ(a * (64 - 1) , powerTwoMinusOne(a)); + Asserts.assertEQ((a * 13) * 14 * 15 , combineConstants(a)); + Asserts.assertEQ((a * 13) * b , moveConstants(a, b)); + Asserts.assertEQ(a * (b * 13) , moveConstantsAgain(a, b)); + Asserts.assertEQ(0 * a , multiplyZero(a)); + Asserts.assertEQ(a * 0 , multiplyZeroAgain(a)); + Asserts.assertEQ((13 + a) * 14 , distribute(a)); + Asserts.assertEQ(1 * a , identity(a)); + Asserts.assertEQ(a * 1 , identityAgain(a)); + Asserts.assertEQ(a * 64 , powerTwo(a)); + Asserts.assertEQ(a * (1025 - 1) , powerTwoAgain(a)); + Asserts.assertEQ(a * (64 + 1) , powerTwoPlusOne(a)); + Asserts.assertEQ(a * (64 - 1) , powerTwoMinusOne(a)); + Asserts.assertEQ((0 - a) * (0 - b) , negativeCancelledOut(a, b)); + Asserts.assertEQ(Math.max(a, b) * Math.min(a, b), maxMin(a, b)); } @Test @@ -163,4 +166,20 @@ public long powerTwoPlusOne(long x) { public long powerTwoMinusOne(long x) { return x * (64 - 1); } + + @Test + @IR(failOn = { IRNode.SUB }) + @IR(counts = { IRNode.MUL, "1" }) + // Checks (0 - x) * (0 - y) => x * y + public long negativeCancelledOut(long x, long y) { + return (0 - x) * (0 - y); + } + + @Test + @IR(failOn = { IRNode.MAX, IRNode.MIN }) + @IR(counts = { IRNode.MUL, "1" }) + // Checks Math.max(x, y) * Math.min(x, y) => x * y + public long maxMin(long x, long y) { + return Math.max(x, y) * Math.min(x, y); + } } diff --git a/test/hotspot/jtreg/compiler/c2/irTests/RotateLeftNodeIntIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/RotateLeftNodeIntIdealizationTests.java new file mode 100644 index 00000000000..5d8b2475ee0 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/irTests/RotateLeftNodeIntIdealizationTests.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package compiler.c2.irTests; + +import jdk.test.lib.Asserts; +import compiler.lib.ir_framework.*; + +/* + * @test + * @bug 8297384 + * @summary Test that Ideal transformations of RotateLeftNode* are being performed as expected. + * @library /test/lib / + * @run driver compiler.c2.irTests.RotateLeftNodeIntIdealizationTests + * @requires os.arch == "x86_64" | os.arch == "aarch64" | os.arch == "riscv64" + */ +public class RotateLeftNodeIntIdealizationTests { + + public static void main(String[] args) { + TestFramework.run(); + } + + @Run(test = { "test1" }) + public void runMethod() { + int a = RunInfo.getRandom().nextInt(); + + int min = Integer.MIN_VALUE; + int max = Integer.MAX_VALUE; + + assertResult(0); + assertResult(a); + assertResult(min); + assertResult(max); + } + + @DontCompile + public void assertResult(int a) { + Asserts.assertEQ(Integer.rotateLeft(a, 2022), test1(a)); + } + + @Test + @IR(failOn = { IRNode.ROTATE_LEFT }) + @IR(counts = { IRNode.ROTATE_RIGHT, "1" }) + // Checks Integer.rotateLeft(x, 2022) => Integer.rotateRight(x, C) where C = 32 - (2022 & 31) + public int test1(int x) { + return Integer.rotateLeft(x, 2022); + } +} diff --git a/test/hotspot/jtreg/compiler/c2/irTests/RotateLeftNodeLongIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/RotateLeftNodeLongIdealizationTests.java new file mode 100644 index 00000000000..c9705c8ad64 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/irTests/RotateLeftNodeLongIdealizationTests.java @@ -0,0 +1,67 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package compiler.c2.irTests; + +import jdk.test.lib.Asserts; +import compiler.lib.ir_framework.*; + +/* + * @test + * @bug 8297384 + * @summary Test that Ideal transformations of RotateLeftNode* are being performed as expected. + * @library /test/lib / + * @run driver compiler.c2.irTests.RotateLeftNodeLongIdealizationTests + * @requires os.arch == "x86_64" | os.arch == "aarch64" | os.arch == "riscv64" + */ +public class RotateLeftNodeLongIdealizationTests { + + public static void main(String[] args) { + TestFramework.run(); + } + + @Run(test = { "test1" }) + public void runMethod() { + long a = RunInfo.getRandom().nextInt(); + + long min = Long.MIN_VALUE; + long max = Long.MAX_VALUE; + + assertResult(0); + assertResult(a); + assertResult(min); + assertResult(max); + } + + @DontCompile + public void assertResult(long a) { + Asserts.assertEQ(Long.rotateLeft(a, 2022), test1(a)); + } + + @Test + @IR(failOn = { IRNode.ROTATE_LEFT }) + @IR(counts = { IRNode.ROTATE_RIGHT, "1" }) + // Checks Long.rotateLeft(x, 2022) => Long.rotateRight(x, C) where C = 64 - (2022 & 63) + public long test1(long x) { + return Long.rotateLeft(x, 2022); + } +} diff --git a/test/hotspot/jtreg/compiler/c2/irTests/URShiftINodeIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/URShiftINodeIdealizationTests.java new file mode 100644 index 00000000000..8ab6c38645c --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/irTests/URShiftINodeIdealizationTests.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package compiler.c2.irTests; + +import jdk.test.lib.Asserts; +import compiler.lib.ir_framework.*; + +/* + * @test + * @bug 8297384 + * @summary Test that Ideal transformations of URShiftINode* are being performed as expected. + * @library /test/lib / + * @run driver compiler.c2.irTests.URShiftINodeIdealizationTests + */ +public class URShiftINodeIdealizationTests { + + public static void main(String[] args) { + TestFramework.run(); + } + + @Run(test = { "test1", "test2" }) + public void runMethod() { + int a = RunInfo.getRandom().nextInt(); + + int min = Integer.MIN_VALUE; + int max = Integer.MAX_VALUE; + + assertResult(0); + assertResult(a); + assertResult(min); + assertResult(max); + } + + @DontCompile + public void assertResult(int a) { + Asserts.assertEQ((a << 2022) >>> 2022, test1(a)); + Asserts.assertEQ((a >> 2022) >>> 31, test2(a)); + } + + @Test + @IR(failOn = { IRNode.LSHIFT, IRNode.URSHIFT }) + @IR(counts = { IRNode.AND, "1" }) + // Checks (x << 2022) >>> 2022 => x & C where C = ((1 << (32 - 6)) - 1) + public int test1(int x) { + return (x << 2022) >>> 2022; + } + + @Test + @IR(failOn = { IRNode.RSHIFT }) + @IR(counts = { IRNode.URSHIFT, "1" }) + // Checks (x >> 2022) >>> 31 => x >>> 31 + public int test2(int x) { + return (x >> 2022) >>> 31; + } +} diff --git a/test/hotspot/jtreg/compiler/c2/irTests/URShiftLNodeIdealizationTests.java b/test/hotspot/jtreg/compiler/c2/irTests/URShiftLNodeIdealizationTests.java new file mode 100644 index 00000000000..2fc1689cc58 --- /dev/null +++ b/test/hotspot/jtreg/compiler/c2/irTests/URShiftLNodeIdealizationTests.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +package compiler.c2.irTests; + +import jdk.test.lib.Asserts; +import compiler.lib.ir_framework.*; + +/* + * @test + * @bug 8297384 + * @summary Test that Ideal transformations of URShiftLNode* are being performed as expected. + * @library /test/lib / + * @run driver compiler.c2.irTests.URShiftLNodeIdealizationTests + */ +public class URShiftLNodeIdealizationTests { + + public static void main(String[] args) { + TestFramework.run(); + } + + @Run(test = { "test1", "test2" }) + public void runMethod() { + long a = RunInfo.getRandom().nextInt(); + + long min = Long.MIN_VALUE; + long max = Long.MAX_VALUE; + + assertResult(0); + assertResult(a); + assertResult(min); + assertResult(max); + } + + @DontCompile + public void assertResult(long a) { + Asserts.assertEQ((a << 2022) >>> 2022, test1(a)); + Asserts.assertEQ((a >> 2022) >>> 63, test2(a)); + } + + @Test + @IR(failOn = { IRNode.LSHIFT, IRNode.URSHIFT }) + @IR(counts = { IRNode.AND, "1" }) + // Checks (x << 2022) >>> 2022 => x & C where C = ((1 << (64 - 38)) - 1) + public long test1(long x) { + return (x << 2022) >>> 2022; + } + + @Test + @IR(failOn = { IRNode.RSHIFT }) + @IR(counts = { IRNode.URSHIFT, "1" }) + // Checks (x >> 2022) >>> 63 => x >>> 63 + public long test2(long x) { + return (x >> 2022) >>> 63; + } +} diff --git a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java index 52fa4a1f163..5997435a748 100644 --- a/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java +++ b/test/hotspot/jtreg/compiler/lib/ir_framework/IRNode.java @@ -593,6 +593,11 @@ public class IRNode { afterBarrierExpansionToBeforeMatching(MACRO_LOGIC_V, "MacroLogicV"); } + public static final String MAX = PREFIX + "MAX" + POSTFIX; + static { + beforeMatchingNameRegex(MAX, "Max(I|L)"); + } + public static final String MAX_I = PREFIX + "MAX_I" + POSTFIX; static { beforeMatchingNameRegex(MAX_I, "MaxI"); @@ -613,6 +618,11 @@ public class IRNode { beforeMatchingNameRegex(MEMBAR_STORESTORE, "MemBarStoreStore"); } + public static final String MIN = PREFIX + "MIN" + POSTFIX; + static { + beforeMatchingNameRegex(MIN, "Min(I|L)"); + } + public static final String MIN_I = PREFIX + "MIN_I" + POSTFIX; static { beforeMatchingNameRegex(MIN_I, "MinI"); @@ -752,6 +762,16 @@ public class IRNode { beforeMatchingNameRegex(ROUND_VF, "RoundVF"); } + public static final String ROTATE_LEFT = PREFIX + "ROTATE_LEFT" + POSTFIX; + static { + beforeMatchingNameRegex(ROTATE_LEFT, "RotateLeft"); + } + + public static final String ROTATE_RIGHT = PREFIX + "ROTATE_RIGHT" + POSTFIX; + static { + beforeMatchingNameRegex(ROTATE_RIGHT, "RotateRight"); + } + public static final String RSHIFT = PREFIX + "RSHIFT" + POSTFIX; static { beforeMatchingNameRegex(RSHIFT, "RShift(I|L)"); From 3d858078130ef64ce47e800482bf64a252f3b5b2 Mon Sep 17 00:00:00 2001 From: Aggelos Biboudis Date: Fri, 25 Nov 2022 12:31:47 +0000 Subject: [PATCH 5/7] 8294583: JShell: NPE in switch with non existing record pattern Reviewed-by: jlahoda --- .../com/sun/tools/javac/comp/Attr.java | 1 + test/langtools/jdk/jshell/Test8294583.java | 48 +++++++++++++++++++ 2 files changed, 49 insertions(+) create mode 100644 test/langtools/jdk/jshell/Test8294583.java diff --git a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java index 9cd9b6492fe..a697db1cff1 100644 --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Attr.java @@ -4183,6 +4183,7 @@ public void visitRecordPattern(JCRecordPattern tree) { expectedRecordTypes = Stream.generate(() -> Type.noType) .limit(tree.nested.size()) .collect(List.collector()); + tree.record = syms.errSymbol; } ListBuffer outBindings = new ListBuffer<>(); List recordTypes = expectedRecordTypes; diff --git a/test/langtools/jdk/jshell/Test8294583.java b/test/langtools/jdk/jshell/Test8294583.java new file mode 100644 index 00000000000..3d2ce2e3638 --- /dev/null +++ b/test/langtools/jdk/jshell/Test8294583.java @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2022, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8294583 + * @summary JShell: NPE in switch with non existing record pattern + * @build KullaTesting TestingInputStream + * @run testng Test8294583 + */ + +import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; + +@Test +public class Test8294583 extends KullaTesting { + + public void test() { + assertEvalFail("switch (new Object()) {\n" + + " case Foo() -> {}\n" + + "};"); + } + + @org.testng.annotations.BeforeMethod + public void setUp() { + super.setUp(bc -> bc.compilerOptions("--source", System.getProperty("java.specification.version"), "--enable-preview").remoteVMOptions("--enable-preview")); + } +} From a6e85bf612ccc9b882a390977dada1b56fd8a31a Mon Sep 17 00:00:00 2001 From: Severin Gehwolf Date: Fri, 25 Nov 2022 16:29:53 +0000 Subject: [PATCH 6/7] 8297590: [TESTBUG] HotSpotResolvedJavaFieldTest does not run Reviewed-by: chagedorn, dnsimon --- .../hotspot/test/HotSpotResolvedJavaFieldTest.java | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotResolvedJavaFieldTest.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotResolvedJavaFieldTest.java index 9aa1efc236e..c85241decfc 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotResolvedJavaFieldTest.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.hotspot.test/src/jdk/vm/ci/hotspot/test/HotSpotResolvedJavaFieldTest.java @@ -47,7 +47,15 @@ import jdk.vm.ci.runtime.JVMCI; /** - * Tests {@link HotSpotResolvedJavaField} functionality. + * + * @test + * @requires vm.jvmci + * @summary Tests HotSpotResolvedJavaField functionality + * @library ../../../../../ + * @modules jdk.internal.vm.ci/jdk.vm.ci.meta + * jdk.internal.vm.ci/jdk.vm.ci.runtime + * jdk.internal.vm.ci/jdk.vm.ci.hotspot + * @run junit/othervm --add-opens=jdk.internal.vm.ci/jdk.vm.ci.hotspot=ALL-UNNAMED -XX:+UnlockExperimentalVMOptions -XX:+EnableJVMCI -XX:-UseJVMCICompiler jdk.vm.ci.hotspot.test.HotSpotResolvedJavaFieldTest */ public class HotSpotResolvedJavaFieldTest { @@ -61,7 +69,7 @@ public class HotSpotResolvedJavaFieldTest { Field f = null; try { Class typeImpl = Class.forName("jdk.vm.ci.hotspot.HotSpotResolvedObjectTypeImpl"); - m = typeImpl.getDeclaredMethod("createField", JavaType.class, long.class, int.class, int.class); + m = typeImpl.getDeclaredMethod("createField", JavaType.class, int.class, int.class, int.class); m.setAccessible(true); Class fieldImpl = Class.forName("jdk.vm.ci.hotspot.HotSpotResolvedJavaFieldImpl"); f = fieldImpl.getDeclaredField("index"); From 0a0d7189e66f8fb806de9b4695c8ea66f52bd920 Mon Sep 17 00:00:00 2001 From: Ioi Lam Date: Fri, 25 Nov 2022 19:54:03 +0000 Subject: [PATCH 7/7] 8295253: Remove kludge from v1_0/PerfDataBuffer.java Reviewed-by: sspitsyn, dholmes, cjplummer --- .../perfdata/monitor/v1_0/PerfDataBuffer.java | 150 +----------------- 1 file changed, 1 insertion(+), 149 deletions(-) diff --git a/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java b/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java index 60c512b9e41..35582943c3d 100644 --- a/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java +++ b/src/jdk.internal.jvmstat/share/classes/sun/jvmstat/perfdata/monitor/v1_0/PerfDataBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2021, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2022, 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 @@ -136,9 +136,6 @@ protected void buildMonitorMap(Map map) throws MonitorException // synchronize with the target jvm synchWithTarget(map); - // work around 1.4.2 counter inititization bugs - kludge(map); - insertedMonitors = new ArrayList(map.values()); } @@ -301,151 +298,6 @@ protected Monitor pollFor(Map map, String name, long timeLimit) return monitor; } - /** - * method to make adjustments for known counter problems. This - * method depends on the availability of certain counters, which - * is generally guaranteed by the synchWithTarget() method. - */ - protected void kludge(Map map) { - if (Boolean.getBoolean("sun.jvmstat.perfdata.disableKludge")) { - // bypass all kludges - return; - } - - String name = "java.vm.version"; - StringMonitor jvm_version = (StringMonitor)map.get(name); - if (jvm_version == null) { - jvm_version = (StringMonitor)findByAlias(name); - } - - name = "java.vm.name"; - StringMonitor jvm_name = (StringMonitor)map.get(name); - if (jvm_name == null) { - jvm_name = (StringMonitor)findByAlias(name); - } - - name = "hotspot.vm.args"; - StringMonitor args = (StringMonitor)map.get(name); - if (args == null) { - args = (StringMonitor)findByAlias(name); - } - - assert ((jvm_name != null) && (jvm_version != null) && (args != null)); - - if (jvm_name.stringValue().indexOf("HotSpot") >= 0) { - if (jvm_version.stringValue().startsWith("1.4.2")) { - kludgeMantis(map, args); - } - } - } - - /** - * method to repair the 1.4.2 parallel scavenge counters that are - * incorrectly initialized by the JVM when UseAdaptiveSizePolicy - * is set. This bug couldn't be fixed for 1.4.2 FCS due to putback - * restrictions. - */ - private void kludgeMantis(Map map, StringMonitor args) { - /* - * the HotSpot 1.4.2 JVM with the +UseParallelGC option along - * with its default +UseAdaptiveSizePolicy option has a bug with - * the initialization of the sizes of the eden and survivor spaces. - * See bugid 4890736. - * - * note - use explicit 1.4.2 counter names here - don't update - * to latest counter names or attempt to find aliases. - */ - - String cname = "hotspot.gc.collector.0.name"; - StringMonitor collector = (StringMonitor)map.get(cname); - - if (collector.stringValue().equals("PSScavenge")) { - boolean adaptiveSizePolicy = true; - - /* - * HotSpot processes the -XX:Flags/.hotspotrc arguments prior to - * processing the command line arguments. This allows the command - * line arguments to override any defaults set in .hotspotrc - */ - cname = "hotspot.vm.flags"; - StringMonitor flags = (StringMonitor)map.get(cname); - String allArgs = flags.stringValue() + " " + args.stringValue(); - - /* - * ignore the -XX: prefix as it only applies to the arguments - * passed from the command line (i.e. the invocation api). - * arguments passed through .hotspotrc omit the -XX: prefix. - */ - int ahi = allArgs.lastIndexOf("+AggressiveHeap"); - int aspi = allArgs.lastIndexOf("-UseAdaptiveSizePolicy"); - - if (ahi != -1) { - /* - * +AggressiveHeap was set, check if -UseAdaptiveSizePolicy - * is set after +AggressiveHeap. - */ - // - if ((aspi != -1) && (aspi > ahi)) { - adaptiveSizePolicy = false; - } - } else { - /* - * +AggressiveHeap not set, must be +UseParallelGC. The - * relative position of -UseAdaptiveSizePolicy is not - * important in this case, as it will override the - * UseParallelGC default (+UseAdaptiveSizePolicy) if it - * appears anywhere in the JVM arguments. - */ - if (aspi != -1) { - adaptiveSizePolicy = false; - } - } - - if (adaptiveSizePolicy) { - // adjust the buggy AdaptiveSizePolicy size counters. - - // first remove the real counters. - String eden_size = "hotspot.gc.generation.0.space.0.size"; - String s0_size = "hotspot.gc.generation.0.space.1.size"; - String s1_size = "hotspot.gc.generation.0.space.2.size"; - map.remove(eden_size); - map.remove(s0_size); - map.remove(s1_size); - - // get the maximum new generation size - String new_max_name = "hotspot.gc.generation.0.capacity.max"; - LongMonitor new_max = (LongMonitor)map.get(new_max_name); - - /* - * replace the real counters with pseudo counters that are - * initialized to the correct values. The maximum size of - * the eden and survivor spaces are supposed to be: - * max_eden_size = new_size - (2*alignment). - * max_survivor_size = new_size - (2*alignment). - * since we don't know the alignment value used, and because - * of other parallel scavenge bugs that result in oversized - * spaces, we just set the maximum size of each space to the - * full new gen size. - */ - Monitor monitor = null; - - LongBuffer lb = LongBuffer.allocate(1); - lb.put(new_max.longValue()); - monitor = new PerfLongMonitor(eden_size, Units.BYTES, - Variability.CONSTANT, false, lb); - map.put(eden_size, monitor); - - monitor = new PerfLongMonitor(s0_size, Units.BYTES, - Variability.CONSTANT, false, lb); - map.put(s0_size, monitor); - - monitor = new PerfLongMonitor(s1_size, Units.BYTES, - Variability.CONSTANT, false, lb); - map.put(s1_size, monitor); - } - } - } - /** * method to extract the next monitor entry from the instrumentation memory. * assumes that nextEntry is the offset into the byte array