# HG changeset patch # User iignatyev # Date 1388503617 -14400 # Node ID d1760952ebdd2c447de231ba861a46ea1ceac4eb # Parent 6d2fe9c23878db2cae44618809c12deb789e0aa6 8028587: New tests development for intrisics for basic operators - add, neg, inc, dec, sub, mul Reviewed-by: twisti Contributed-by: anton.ivanov@oracle.com diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/AddExactIntTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/AddExactIntTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build AddExactIntTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics AddExactIntTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics AddExactIntTest + * @run main Verifier hs_neg.log hs.log + */ + +public class AddExactIntTest { + + public static void main(String[] args) throws Exception { + new IntrinsicBase.IntTest(MathIntrinsic.IntIntrinsic.Add).test(); + } +} diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/AddExactLongTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/AddExactLongTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build AddExactLongTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics AddExactLongTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics AddExactLongTest + * @run main Verifier hs_neg.log hs.log + */ + +public class AddExactLongTest { + + public static void main(String[] args) throws Exception { + new IntrinsicBase.LongTest(MathIntrinsic.LongIntrinsic.Add).test(); + } +} diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/DecrementExactIntTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/DecrementExactIntTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build DecrementExactIntTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics DecrementExactIntTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics DecrementExactIntTest + * @run main Verifier hs_neg.log hs.log + */ + +public class DecrementExactIntTest { + + public static void main(String[] args) throws Exception { + new IntrinsicBase.IntTest(MathIntrinsic.IntIntrinsic.Decrement).test(); + } +} diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/DecrementExactLongTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/DecrementExactLongTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build DecrementExactLongTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics DecrementExactLongTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics DecrementExactLongTest + * @run main Verifier hs_neg.log hs.log + */ + +public class DecrementExactLongTest { + + public static void main(String[] args) throws Exception { + new IntrinsicBase.LongTest(MathIntrinsic.LongIntrinsic.Decrement).test(); + } +} \ No newline at end of file diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/IncrementExactIntTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/IncrementExactIntTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build IncrementExactIntTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics IncrementExactIntTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics IncrementExactIntTest + * @run main Verifier hs_neg.log hs.log + */ + +public class IncrementExactIntTest { + + public static void main(String[] args) throws Exception { + new IntrinsicBase.IntTest(MathIntrinsic.IntIntrinsic.Increment).test(); + } +} diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/IncrementExactLongTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/IncrementExactLongTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build IncrementExactLongTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics IncrementExactLongTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics IncrementExactLongTest + * @run main Verifier hs_neg.log hs.log + */ + +public class IncrementExactLongTest { + + public static void main(String[] args) throws Exception { + new IntrinsicBase.LongTest(MathIntrinsic.LongIntrinsic.Increment).test(); + } +} diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/IntrinsicBase.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/IntrinsicBase.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2013, 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. + */ + +import com.oracle.java.testlibrary.Platform; + +import java.io.FileOutputStream; +import java.lang.reflect.Executable; +import java.util.Properties; + +public abstract class IntrinsicBase extends CompilerWhiteBoxTest { + protected String javaVmName; + protected String useMathExactIntrinsics; + + protected IntrinsicBase(TestCase testCase) { + super(testCase); + javaVmName = System.getProperty("java.vm.name"); + useMathExactIntrinsics = getVMOption("UseMathExactIntrinsics"); + } + + @Override + protected void test() throws Exception { + //java.lang.Math should be loaded to allow a compilation of the methods that use Math's method + System.out.println("class java.lang.Math should be loaded. Proof: " + Math.class); + printEnvironmentInfo(); + + int expectedIntrinsicCount = 0; + + switch (MODE) { + case "compiled mode": + case "mixed mode": + if (isServerVM()) { + if (TIERED_COMPILATION) { + int max_level = TIERED_STOP_AT_LEVEL; + expectedIntrinsicCount = (max_level == COMP_LEVEL_MAX) ? 1 : 0; + for (int i = CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE; i <= max_level; ++i) { + deoptimize(); + compileAtLevel(i); + } + } else { + expectedIntrinsicCount = 1; + deoptimize(); + compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_MAX); + } + } else { + deoptimize(); + compileAtLevel(CompilerWhiteBoxTest.COMP_LEVEL_SIMPLE); + } + + if (!isIntrinsicSupported()) { + expectedIntrinsicCount = 0; + } + break; + case "interpreted mode": //test is not applicable in this mode; + System.err.println("Warning: This test is not applicable in mode: " + MODE); + break; + default: + throw new RuntimeException("Test bug, unknown VM mode: " + MODE); + } + + System.out.println("Expected intrinsic count is " + expectedIntrinsicCount + " name " + getIntrinsicId()); + + final FileOutputStream out = new FileOutputStream(getVMOption("LogFile") + ".verify.properties"); + Properties expectedProps = new Properties(); + expectedProps.setProperty("intrinsic.name", getIntrinsicId()); + expectedProps.setProperty("intrinsic.expectedCount", String.valueOf(expectedIntrinsicCount)); + expectedProps.store(out, null); + + out.close(); + } + + protected void printEnvironmentInfo() { + System.out.println("java.vm.name=" + javaVmName); + System.out.println("os.arch=" + Platform.getOsArch()); + System.out.println("java.vm.info=" + MODE); + System.out.println("useMathExactIntrinsics=" + useMathExactIntrinsics); + } + + protected void compileAtLevel(int level) { + WHITE_BOX.enqueueMethodForCompilation(method, level); + waitBackgroundCompilation(); + checkCompilation(method, level); + } + + protected void checkCompilation(Executable executable, int level) { + if (!WHITE_BOX.isMethodCompiled(executable)) { + throw new RuntimeException("Test bug, expected compilation (level): " + level + ", but not compiled"); + } + final int compilationLevel = WHITE_BOX.getMethodCompilationLevel(executable); + if (compilationLevel != level) { + if (!(TIERED_COMPILATION && level == COMP_LEVEL_FULL_PROFILE && compilationLevel == COMP_LEVEL_LIMITED_PROFILE)) { //possible case + throw new RuntimeException("Test bug, expected compilation (level): " + level + ", but level: " + compilationLevel); + } + } + } + + protected abstract boolean isIntrinsicSupported(); + + protected abstract String getIntrinsicId(); + + protected boolean isServerVM() { + return javaVmName.toLowerCase().contains("server"); + } + + static class IntTest extends IntrinsicBase { + protected IntTest(MathIntrinsic.IntIntrinsic testCase) { + super(testCase); + } + + @Override + protected boolean isIntrinsicSupported() { + return isServerVM() && Boolean.valueOf(useMathExactIntrinsics) && (Platform.isX86() || Platform.isX64()); + } + + @Override + protected String getIntrinsicId() { + return "_" + testCase.name().toLowerCase() + "ExactI"; + } + } + + static class LongTest extends IntrinsicBase { + protected LongTest(MathIntrinsic.LongIntrinsic testCase) { + super(testCase); + } + + @Override + protected boolean isIntrinsicSupported() { + return isServerVM() && Boolean.valueOf(useMathExactIntrinsics) && Platform.isX64(); + } + + @Override + protected String getIntrinsicId() { + return "_" + testCase.name().toLowerCase() + "ExactL"; + } + } +} diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/MathIntrinsic.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/MathIntrinsic.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,155 @@ +/* + * Copyright (c) 2013, 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. + */ + +import java.lang.reflect.Executable; +import java.util.concurrent.Callable; + +public class MathIntrinsic { + + enum IntIntrinsic implements CompilerWhiteBoxTest.TestCase { + Add { + @Override + Object execMathMethod() { + return intR = Math.addExact(int1, int2); + } + }, + Subtract { + @Override + Object execMathMethod() { + return intR = Math.subtractExact(int1, int2); + } + }, + Multiply { + @Override + Object execMathMethod() { + return intR = Math.multiplyExact(int1, int2); + } + }, + Increment { + @Override + Object execMathMethod() { + return intR = Math.incrementExact(int1); + } + }, + Decrement { + @Override + Object execMathMethod() { + return intR = Math.decrementExact(int1); + } + }, + Negate { + @Override + Object execMathMethod() { + return intR = Math.negateExact(int1); + } + }; + protected int int1; + protected int int2; + protected int intR; + + abstract Object execMathMethod(); + + @Override + public Executable getExecutable() { + try { + return getClass().getDeclaredMethod("execMathMethod"); + } catch (NoSuchMethodException e) { + throw new RuntimeException("Test bug, no such method: " + e); + } + } + + @Override + public Callable getCallable() { + return null; + } + + @Override + public boolean isOsr() { + return false; + } + + } + + enum LongIntrinsic implements CompilerWhiteBoxTest.TestCase { + Add { + @Override + Object execMathMethod() { + return longR = Math.addExact(long1, long2); + } + }, + Subtract { + @Override + Object execMathMethod() { + return longR = Math.subtractExact(long1, long2); + } + }, + Multiply { + @Override + Object execMathMethod() { + return longR = Math.multiplyExact(long1, long2); + } + }, + Increment { + @Override + Object execMathMethod() { + return longR = Math.incrementExact(long1); + } + }, + Decrement { + @Override + Object execMathMethod() { + return longR = Math.decrementExact(long1); + } + }, + Negate { + @Override + Object execMathMethod() { + return longR = Math.negateExact(long1); + } + }; + protected long long1; + protected long long2; + protected long longR; + + abstract Object execMathMethod(); + + @Override + public Executable getExecutable() { + try { + return getClass().getDeclaredMethod("execMathMethod"); + } catch (NoSuchMethodException e) { + throw new RuntimeException("Test bug, no such method: " + e); + } + } + + @Override + public Callable getCallable() { + return null; + } + + @Override + public boolean isOsr() { + return false; + } + } +} diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/MultiplyExactIntTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/MultiplyExactIntTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build MultiplyExactIntTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics MultiplyExactIntTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics MultiplyExactIntTest + * @run main Verifier hs_neg.log hs.log + */ + +public class MultiplyExactIntTest { + + public static void main(String[] args) throws Exception { + new IntrinsicBase.IntTest(MathIntrinsic.IntIntrinsic.Multiply).test(); + } +} diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/MultiplyExactLongTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/MultiplyExactLongTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build MultiplyExactLongTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics MultiplyExactLongTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics MultiplyExactLongTest + * @run main Verifier hs_neg.log hs.log + */ + +public class MultiplyExactLongTest { + + public static void main(String[] args) throws Exception { + new IntrinsicBase.LongTest(MathIntrinsic.LongIntrinsic.Multiply).test(); + } +} diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/NegateExactIntTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/NegateExactIntTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build NegateExactIntTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics NegateExactIntTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics NegateExactIntTest + * @run main Verifier hs_neg.log hs.log + */ + +public class NegateExactIntTest { + + public static void main(String[] args) throws Exception { + new IntrinsicBase.IntTest(MathIntrinsic.IntIntrinsic.Negate).test(); + } +} diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/NegateExactLongTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/NegateExactLongTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build NegateExactLongTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics NegateExactLongTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics NegateExactLongTest + * @run main Verifier hs_neg.log hs.log + */ + +public class NegateExactLongTest { + + public static void main(String[] args) throws Exception { + new IntrinsicBase.LongTest(MathIntrinsic.LongIntrinsic.Negate).test(); + } +} diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/SubtractExactIntTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/SubtractExactIntTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,46 @@ +/* + * Copyright (c) 2013, 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 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build SubtractExactIntTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics SubtractExactIntTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics SubtractExactIntTest + * @run main Verifier hs_neg.log hs.log + + */ + +public class SubtractExactIntTest { + + public static void main(String[] args) throws Exception { + new IntrinsicBase.IntTest(MathIntrinsic.IntIntrinsic.Subtract).test(); + } +} diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/SubtractExactLongTest.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/SubtractExactLongTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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 + * @library /testlibrary /testlibrary/whitebox /compiler/whitebox + * @build SubtractExactLongTest + * @run main ClassFileInstaller sun.hotspot.WhiteBox + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics SubtractExactLongTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation + * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod + * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics SubtractExactLongTest + * @run main Verifier hs_neg.log hs.log + */ + +public class SubtractExactLongTest { + + public static void main(String[] args) throws Exception { + new IntrinsicBase.LongTest(MathIntrinsic.LongIntrinsic.Subtract).test(); + } +} diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/intrinsics/mathexact/sanity/Verifier.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/compiler/intrinsics/mathexact/sanity/Verifier.java Tue Dec 31 19:26:57 2013 +0400 @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2013, 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. + */ + +import java.io.BufferedReader; +import java.io.FileReader; +import java.util.Properties; + +public class Verifier { + + public static void main(String[] args) throws Exception { + if (args.length == 0) + throw new RuntimeException("Test bug, nothing to verify"); + for (String hsLogFile : args) { + verify(hsLogFile); + } + } + + private static void verify(String hsLogFile) throws Exception { + System.out.println("Verifying " + hsLogFile); + + final Properties expectedProperties = new Properties(); + final FileReader reader = new FileReader(hsLogFile + ".verify.properties"); + expectedProperties.load(reader); + reader.close(); + + int fullMatchCnt = 0; + int suspectCnt = 0; + final String intrinsicId = expectedProperties.getProperty("intrinsic.name"); + final String prefix = " constructor, + String[] args) { + if (args.length == 0) { + for (TestCase test : SimpleTestCase.values()) { + constructor.apply(test).runTest(); + } + } else { + for (String name : args) { + constructor.apply(SimpleTestCase.valueOf(name)).runTest(); + } + } + } + /** tested method */ protected final Executable method; protected final TestCase testCase; @@ -145,7 +159,7 @@ protected CompilerWhiteBoxTest(TestCase testCase) { Objects.requireNonNull(testCase); System.out.println("TEST CASE:" + testCase.name()); - method = testCase.executable; + method = testCase.getExecutable(); this.testCase = testCase; } @@ -204,7 +218,7 @@ if (WHITE_BOX.getMethodCompilationLevel(method, true) != 0) { throw new RuntimeException(method + " osr_comp_level must be == 0"); } - } + } /** * Checks, that {@linkplain #method} is compiled. @@ -221,44 +235,46 @@ method, System.currentTimeMillis() - start); return; } - if (!WHITE_BOX.isMethodCompiled(method, testCase.isOsr)) { + if (!WHITE_BOX.isMethodCompiled(method, testCase.isOsr())) { throw new RuntimeException(method + " must be " - + (testCase.isOsr ? "osr_" : "") + "compiled"); + + (testCase.isOsr() ? "osr_" : "") + "compiled"); } - if (WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr) == 0) { + if (WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr()) + == 0) { throw new RuntimeException(method - + (testCase.isOsr ? " osr_" : " ") + + (testCase.isOsr() ? " osr_" : " ") + "comp_level must be != 0"); } } protected final void deoptimize() { - WHITE_BOX.deoptimizeMethod(method, testCase.isOsr); - if (testCase.isOsr) { + WHITE_BOX.deoptimizeMethod(method, testCase.isOsr()); + if (testCase.isOsr()) { WHITE_BOX.deoptimizeMethod(method, false); } } protected final int getCompLevel() { - return WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr); + return WHITE_BOX.getMethodCompilationLevel(method, testCase.isOsr()); } protected final boolean isCompilable() { return WHITE_BOX.isMethodCompilable(method, COMP_LEVEL_ANY, - testCase.isOsr); + testCase.isOsr()); } protected final boolean isCompilable(int compLevel) { - return WHITE_BOX.isMethodCompilable(method, compLevel, testCase.isOsr); + return WHITE_BOX + .isMethodCompilable(method, compLevel, testCase.isOsr()); } protected final void makeNotCompilable() { WHITE_BOX.makeMethodNotCompilable(method, COMP_LEVEL_ANY, - testCase.isOsr); + testCase.isOsr()); } protected final void makeNotCompilable(int compLevel) { - WHITE_BOX.makeMethodNotCompilable(method, compLevel, testCase.isOsr); + WHITE_BOX.makeMethodNotCompilable(method, compLevel, testCase.isOsr()); } /** @@ -298,7 +314,7 @@ WHITE_BOX.isMethodCompiled(method, true)); System.out.printf("\tosr_comp_level:\t%d%n", WHITE_BOX.getMethodCompilationLevel(method, true)); - System.out.printf("\tin_queue:\t%b%n", + System.out.printf("\tin_queue:\t%b%n", WHITE_BOX.isMethodQueuedForCompilation(method)); System.out.printf("compile_queues_size:\t%d%n%n", WHITE_BOX.getCompileQueuesSize()); @@ -311,13 +327,13 @@ /** * Tries to trigger compilation of {@linkplain #method} by call - * {@linkplain #testCase.callable} enough times. + * {@linkplain TestCase#getCallable()} enough times. * * @return accumulated result * @see #compile(int) */ protected final int compile() { - if (testCase.isOsr) { + if (testCase.isOsr()) { return compile(1); } else { return compile(THRESHOLD); @@ -326,7 +342,7 @@ /** * Tries to trigger compilation of {@linkplain #method} by call - * {@linkplain #testCase.callable} specified times. + * {@linkplain TestCase#getCallable()} specified times. * * @param count invocation count * @return accumulated result @@ -336,7 +352,7 @@ Integer tmp; for (int i = 0; i < count; ++i) { try { - tmp = testCase.callable.call(); + tmp = testCase.getCallable().call(); } catch (Exception e) { tmp = null; } @@ -347,19 +363,32 @@ } return result; } + + /** + * Utility interface provides tested method and object to invoke it. + */ + public interface TestCase { + /** the name of test case */ + String name(); + + /** tested method */ + Executable getExecutable(); + + /** object to invoke {@linkplain #getExecutable()} */ + Callable getCallable(); + + /** flag for OSR test case */ + boolean isOsr(); + } } -/** - * Utility structure containing tested method and object to invoke it. - */ -enum TestCase { +enum SimpleTestCase implements CompilerWhiteBoxTest.TestCase { /** constructor test case */ CONSTRUCTOR_TEST(Helper.CONSTRUCTOR, Helper.CONSTRUCTOR_CALLABLE, false), /** method test case */ METOD_TEST(Helper.METHOD, Helper.METHOD_CALLABLE, false), /** static method test case */ STATIC_TEST(Helper.STATIC, Helper.STATIC_CALLABLE, false), - /** OSR constructor test case */ OSR_CONSTRUCTOR_TEST(Helper.OSR_CONSTRUCTOR, Helper.OSR_CONSTRUCTOR_CALLABLE, true), @@ -368,20 +397,32 @@ /** OSR static method test case */ OSR_STATIC_TEST(Helper.OSR_STATIC, Helper.OSR_STATIC_CALLABLE, true); - /** tested method */ - final Executable executable; - /** object to invoke {@linkplain #executable} */ - final Callable callable; - /** flag for OSR test case */ - final boolean isOsr; + private final Executable executable; + private final Callable callable; + private final boolean isOsr; - private TestCase(Executable executable, Callable callable, + private SimpleTestCase(Executable executable, Callable callable, boolean isOsr) { this.executable = executable; this.callable = callable; this.isOsr = isOsr; } + @Override + public Executable getExecutable() { + return executable; + } + + @Override + public Callable getCallable() { + return callable; + } + + @Override + public boolean isOsr() { + return isOsr; + } + private static class Helper { private static final Callable CONSTRUCTOR_CALLABLE @@ -436,7 +477,6 @@ } }; - private static final Constructor CONSTRUCTOR; private static final Constructor OSR_CONSTRUCTOR; private static final Method METHOD; diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/whitebox/DeoptimizeAllTest.java --- a/test/compiler/whitebox/DeoptimizeAllTest.java Thu Dec 26 21:00:23 2013 -0800 +++ b/test/compiler/whitebox/DeoptimizeAllTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -27,19 +27,17 @@ * @library /testlibrary /testlibrary/whitebox * @build DeoptimizeAllTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* DeoptimizeAllTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* DeoptimizeAllTest * @summary testing of WB::deoptimizeAll() * @author igor.ignatyev@oracle.com */ public class DeoptimizeAllTest extends CompilerWhiteBoxTest { public static void main(String[] args) throws Exception { - for (TestCase test : TestCase.values()) { - new DeoptimizeAllTest(test).runTest(); - } + CompilerWhiteBoxTest.main(DeoptimizeAllTest::new, args); } - public DeoptimizeAllTest(TestCase testCase) { + private DeoptimizeAllTest(TestCase testCase) { super(testCase); // to prevent inlining of #method WHITE_BOX.testSetDontInlineMethod(method, true); @@ -53,7 +51,7 @@ */ @Override protected void test() throws Exception { - if (testCase.isOsr && CompilerWhiteBoxTest.MODE.startsWith( + if (testCase.isOsr() && CompilerWhiteBoxTest.MODE.startsWith( "compiled ")) { System.err.printf("Warning: %s is not applicable in %s%n", testCase.name(), CompilerWhiteBoxTest.MODE); diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/whitebox/DeoptimizeMethodTest.java --- a/test/compiler/whitebox/DeoptimizeMethodTest.java Thu Dec 26 21:00:23 2013 -0800 +++ b/test/compiler/whitebox/DeoptimizeMethodTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -27,19 +27,17 @@ * @library /testlibrary /testlibrary/whitebox * @build DeoptimizeMethodTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* DeoptimizeMethodTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* DeoptimizeMethodTest * @summary testing of WB::deoptimizeMethod() * @author igor.ignatyev@oracle.com */ public class DeoptimizeMethodTest extends CompilerWhiteBoxTest { public static void main(String[] args) throws Exception { - for (TestCase test : TestCase.values()) { - new DeoptimizeMethodTest(test).runTest(); - } + CompilerWhiteBoxTest.main(DeoptimizeMethodTest::new, args); } - public DeoptimizeMethodTest(TestCase testCase) { + private DeoptimizeMethodTest(TestCase testCase) { super(testCase); // to prevent inlining of #method WHITE_BOX.testSetDontInlineMethod(method, true); @@ -53,7 +51,7 @@ */ @Override protected void test() throws Exception { - if (testCase.isOsr && CompilerWhiteBoxTest.MODE.startsWith( + if (testCase.isOsr() && CompilerWhiteBoxTest.MODE.startsWith( "compiled ")) { System.err.printf("Warning: %s is not applicable in %s%n", testCase.name(), CompilerWhiteBoxTest.MODE); diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/whitebox/EnqueueMethodForCompilationTest.java --- a/test/compiler/whitebox/EnqueueMethodForCompilationTest.java Thu Dec 26 21:00:23 2013 -0800 +++ b/test/compiler/whitebox/EnqueueMethodForCompilationTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -27,19 +27,17 @@ * @library /testlibrary /testlibrary/whitebox * @build EnqueueMethodForCompilationTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm/timeout=600 -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* EnqueueMethodForCompilationTest + * @run main/othervm/timeout=600 -Xbootclasspath/a:. -Xmixed -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* EnqueueMethodForCompilationTest * @summary testing of WB::enqueueMethodForCompilation() * @author igor.ignatyev@oracle.com */ public class EnqueueMethodForCompilationTest extends CompilerWhiteBoxTest { public static void main(String[] args) throws Exception { - for (TestCase test : TestCase.values()) { - new EnqueueMethodForCompilationTest(test).runTest(); - } + CompilerWhiteBoxTest.main(EnqueueMethodForCompilationTest::new, args); } - public EnqueueMethodForCompilationTest(TestCase testCase) { + private EnqueueMethodForCompilationTest(TestCase testCase) { super(testCase); // to prevent inlining of #method WHITE_BOX.testSetDontInlineMethod(method, true); diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/whitebox/IsMethodCompilableTest.java --- a/test/compiler/whitebox/IsMethodCompilableTest.java Thu Dec 26 21:00:23 2013 -0800 +++ b/test/compiler/whitebox/IsMethodCompilableTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -27,7 +27,7 @@ * @library /testlibrary /testlibrary/whitebox * @build IsMethodCompilableTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* IsMethodCompilableTest + * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* IsMethodCompilableTest * @summary testing of WB::isMethodCompilable() * @author igor.ignatyev@oracle.com */ @@ -48,12 +48,10 @@ } public static void main(String[] args) throws Exception { - for (TestCase test : TestCase.values()) { - new IsMethodCompilableTest(test).runTest(); - } + CompilerWhiteBoxTest.main(IsMethodCompilableTest::new, args); } - public IsMethodCompilableTest(TestCase testCase) { + private IsMethodCompilableTest(TestCase testCase) { super(testCase); // to prevent inlining of #method WHITE_BOX.testSetDontInlineMethod(method, true); @@ -68,7 +66,7 @@ */ @Override protected void test() throws Exception { - if (testCase.isOsr && CompilerWhiteBoxTest.MODE.startsWith( + if (testCase.isOsr() && CompilerWhiteBoxTest.MODE.startsWith( "compiled ")) { System.err.printf("Warning: %s is not applicable in %s%n", testCase.name(), CompilerWhiteBoxTest.MODE); @@ -89,7 +87,7 @@ for (long i = 0L, n = PER_METHOD_RECOMPILATION_CUTOFF - 1; i < n; ++i) { compileAndDeoptimize(); } - if (!testCase.isOsr && !isCompilable()) { + if (!testCase.isOsr() && !isCompilable()) { // in osr test case count of deopt maybe more than iterations throw new RuntimeException(method + " is not compilable after " + (PER_METHOD_RECOMPILATION_CUTOFF - 1) + " iterations"); @@ -102,7 +100,7 @@ && isCompilable(); ++i) { compileAndDeoptimize(); } - if (!testCase.isOsr && i != PER_METHOD_RECOMPILATION_CUTOFF) { + if (!testCase.isOsr() && i != PER_METHOD_RECOMPILATION_CUTOFF) { // in osr test case count of deopt maybe more than iterations throw new RuntimeException(method + " is not compilable after " + i + " iterations, but must only after " diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/whitebox/MakeMethodNotCompilableTest.java --- a/test/compiler/whitebox/MakeMethodNotCompilableTest.java Thu Dec 26 21:00:23 2013 -0800 +++ b/test/compiler/whitebox/MakeMethodNotCompilableTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -27,26 +27,17 @@ * @library /testlibrary /testlibrary/whitebox * @build MakeMethodNotCompilableTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* MakeMethodNotCompilableTest + * @run main/othervm/timeout=2400 -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* MakeMethodNotCompilableTest * @summary testing of WB::makeMethodNotCompilable() * @author igor.ignatyev@oracle.com */ public class MakeMethodNotCompilableTest extends CompilerWhiteBoxTest { private int bci; public static void main(String[] args) throws Exception { - if (args.length == 0) { - for (TestCase test : TestCase.values()) { - new MakeMethodNotCompilableTest(test).runTest(); - } - } else { - for (String name : args) { - new MakeMethodNotCompilableTest( - TestCase.valueOf(name)).runTest(); - } - } + CompilerWhiteBoxTest.main(MakeMethodNotCompilableTest::new, args); } - public MakeMethodNotCompilableTest(TestCase testCase) { + private MakeMethodNotCompilableTest(TestCase testCase) { super(testCase); // to prevent inlining of #method WHITE_BOX.testSetDontInlineMethod(method, true); @@ -62,7 +53,7 @@ */ @Override protected void test() throws Exception { - if (testCase.isOsr && CompilerWhiteBoxTest.MODE.startsWith( + if (testCase.isOsr() && CompilerWhiteBoxTest.MODE.startsWith( "compiled ")) { System.err.printf("Warning: %s is not applicable in %s%n", testCase.name(), CompilerWhiteBoxTest.MODE); diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/whitebox/SetDontInlineMethodTest.java --- a/test/compiler/whitebox/SetDontInlineMethodTest.java Thu Dec 26 21:00:23 2013 -0800 +++ b/test/compiler/whitebox/SetDontInlineMethodTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -27,19 +27,17 @@ * @library /testlibrary /testlibrary/whitebox * @build SetDontInlineMethodTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* SetDontInlineMethodTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* SetDontInlineMethodTest * @summary testing of WB::testSetDontInlineMethod() * @author igor.ignatyev@oracle.com */ public class SetDontInlineMethodTest extends CompilerWhiteBoxTest { public static void main(String[] args) throws Exception { - for (TestCase test : TestCase.values()) { - new SetDontInlineMethodTest(test).runTest(); - } + CompilerWhiteBoxTest.main(SetDontInlineMethodTest::new, args); } - public SetDontInlineMethodTest(TestCase testCase) { + private SetDontInlineMethodTest(TestCase testCase) { super(testCase); } diff -r 6d2fe9c23878 -r d1760952ebdd test/compiler/whitebox/SetForceInlineMethodTest.java --- a/test/compiler/whitebox/SetForceInlineMethodTest.java Thu Dec 26 21:00:23 2013 -0800 +++ b/test/compiler/whitebox/SetForceInlineMethodTest.java Tue Dec 31 19:26:57 2013 +0400 @@ -27,19 +27,17 @@ * @library /testlibrary /testlibrary/whitebox * @build SetForceInlineMethodTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,TestCase$Helper::* SetForceInlineMethodTest + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -XX:CompileCommand=compileonly,SimpleTestCase$Helper::* SetForceInlineMethodTest * @summary testing of WB::testSetForceInlineMethod() * @author igor.ignatyev@oracle.com */ public class SetForceInlineMethodTest extends CompilerWhiteBoxTest { public static void main(String[] args) throws Exception { - for (TestCase test : TestCase.values()) { - new SetForceInlineMethodTest(test).runTest(); - } + CompilerWhiteBoxTest.main(SetForceInlineMethodTest::new, args); } - public SetForceInlineMethodTest(TestCase testCase) { + private SetForceInlineMethodTest(TestCase testCase) { super(testCase); }