diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/InlineTypeTest.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/InlineTypeTest.java deleted file mode 100644 index d4516a4fd34..00000000000 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/InlineTypeTest.java +++ /dev/null @@ -1,860 +0,0 @@ -/* - * Copyright (c) 2017, 2020, 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.valhalla.inlinetypes; - -import compiler.whitebox.CompilerWhiteBoxTest; -import jdk.test.lib.Asserts; -import jdk.test.lib.management.InputArguments; -import jdk.test.lib.Platform; -import jdk.test.lib.process.ProcessTools; -import jdk.test.lib.process.OutputAnalyzer; -import jdk.test.lib.Utils; -import sun.hotspot.WhiteBox; - -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Repeatable; -import java.lang.invoke.*; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.Collections; -import java.util.Hashtable; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import java.util.stream.Stream; -import java.util.TreeMap; -import java.util.function.BooleanSupplier; - -// Mark method as test -@Retention(RetentionPolicy.RUNTIME) -@Repeatable(Tests.class) -@interface Test { - // Regular expression used to match forbidden IR nodes - // in the C2 IR emitted for this test. - String failOn() default ""; - // Regular expressions used to match and count IR nodes. - String[] match() default { }; - int[] matchCount() default { }; - int compLevel() default InlineTypeTest.COMP_LEVEL_ANY; - int valid() default 0; -} - -@Retention(RetentionPolicy.RUNTIME) -@interface Tests { - Test[] value(); -} - -// Force method inlining during compilation -@Retention(RetentionPolicy.RUNTIME) -@interface ForceInline { } - -// Prevent method inlining during compilation -@Retention(RetentionPolicy.RUNTIME) -@interface DontInline { } - -// Prevent method compilation -@Retention(RetentionPolicy.RUNTIME) -@interface DontCompile { } - -// Force method compilation -@Retention(RetentionPolicy.RUNTIME) -@interface ForceCompile { - int compLevel() default InlineTypeTest.COMP_LEVEL_ANY; -} - -// Number of warmup iterations -@Retention(RetentionPolicy.RUNTIME) -@interface Warmup { - int value(); -} - -// Do not enqueue the test method for compilation immediately after warmup loops have finished. Instead -// let the test method be compiled with on-stack-replacement. -@Retention(RetentionPolicy.RUNTIME) -@interface OSRCompileOnly {} - -// Skip this test temporarily for C1 testing -@Retention(RetentionPolicy.RUNTIME) -@interface TempSkipForC1 { - String reason() default ""; -} - -public abstract class InlineTypeTest { - protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); - - protected static final int COMP_LEVEL_ANY = -1; - protected static final int COMP_LEVEL_SIMPLE = 1; // C1 - protected static final int COMP_LEVEL_LIMITED_PROFILE = 2; // C1, invocation & backedge counters - protected static final int COMP_LEVEL_FULL_PROFILE = 3; // C1, invocation & backedge counters + mdo - protected static final int COMP_LEVEL_FULL_OPTIMIZATION = 4; // C2 or JVMCI - - protected static final boolean TieredCompilation = (Boolean)WHITE_BOX.getVMFlag("TieredCompilation"); - protected static final long TieredStopAtLevel = (Long)WHITE_BOX.getVMFlag("TieredStopAtLevel"); - static final boolean TEST_C1 = TieredCompilation && TieredStopAtLevel < COMP_LEVEL_FULL_OPTIMIZATION; - - // Random test values - public static final int rI = Utils.getRandomInstance().nextInt() % 1000; - public static final long rL = Utils.getRandomInstance().nextLong() % 1000; - public static final double rD = Utils.getRandomInstance().nextDouble() % 1000; - - // User defined settings - protected static final boolean XCOMP = Platform.isComp(); - private static final boolean PRINT_GRAPH = true; - private static final boolean VERBOSE = Boolean.parseBoolean(System.getProperty("Verbose", "false")); - private static final boolean PRINT_TIMES = Boolean.parseBoolean(System.getProperty("PrintTimes", "false")); - private static final boolean COMPILE_COMMANDS = Boolean.parseBoolean(System.getProperty("CompileCommands", "true")) && !XCOMP; - private static boolean VERIFY_IR = Boolean.parseBoolean(System.getProperty("VerifyIR", "true")) && !XCOMP && !TEST_C1 && COMPILE_COMMANDS; - private static final String SCENARIOS = System.getProperty("Scenarios", ""); - private static final String TESTLIST = System.getProperty("Testlist", ""); - private static final String EXCLUDELIST = System.getProperty("Exclude", ""); - private static final int WARMUP = Integer.parseInt(System.getProperty("Warmup", "251")); - private static final boolean DUMP_REPLAY = Boolean.parseBoolean(System.getProperty("DumpReplay", "false")); - private static final boolean FLIP_C1_C2 = Boolean.parseBoolean(System.getProperty("FlipC1C2", "false")); - private static final boolean GC_AFTER = Boolean.parseBoolean(System.getProperty("GCAfter", "false")); - private static final int OSR_TEST_TIMEOUT = Integer.parseInt(System.getProperty("OSRTestTimeOut", "5000")); - protected static final boolean STRESS_CC = Boolean.parseBoolean(System.getProperty("StressCC", "false")); - private static final boolean SHUFFLE_TESTS = Boolean.parseBoolean(System.getProperty("ShuffleTests", "true")); - private static final boolean PREFER_CL_FLAGS = Boolean.parseBoolean(System.getProperty("PreferCommandLineFlags", "false")); - - // Pre-defined settings - private static final String[] defaultFlags = { - "-XX:-BackgroundCompilation"}; - private static final String[] compileCommandFlags = { - "-XX:CompileCommand=quiet", - "-XX:CompileCommand=compileonly,java.lang.invoke.*::*", - "-XX:CompileCommand=compileonly,java.lang.Long::sum", - "-XX:CompileCommand=compileonly,java.lang.Object::", - "-XX:CompileCommand=inline,compiler.valhalla.inlinetypes.MyValue*::", - "-XX:CompileCommand=compileonly,compiler.valhalla.inlinetypes.*::*"}; - private static final String[] printFlags = { - "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+UnlockDiagnosticVMOptions", "-XX:+PrintOptoAssembly"}; - - protected static final int InlineTypePassFieldsAsArgsOn = 0x1; - protected static final int InlineTypePassFieldsAsArgsOff = 0x2; - protected static final int InlineTypeArrayFlattenOn = 0x4; - protected static final int InlineTypeArrayFlattenOff = 0x8; - protected static final int InlineTypeReturnedAsFieldsOn = 0x10; - protected static final int InlineTypeReturnedAsFieldsOff = 0x20; - protected static final int AlwaysIncrementalInlineOn = 0x40; - protected static final int AlwaysIncrementalInlineOff = 0x80; - protected static final int G1GCOn = 0x100; - protected static final int G1GCOff = 0x200; - protected static final int ZGCOn = 0x400; - protected static final int ZGCOff = 0x800; - protected static final int ArrayLoadStoreProfileOn = 0x1000; - protected static final int ArrayLoadStoreProfileOff = 0x2000; - protected static final int TypeProfileOn = 0x4000; - protected static final int TypeProfileOff = 0x8000; - protected static final int ACmpProfileOn = 0x10000; - protected static final int ACmpProfileOff = 0x20000; - protected static final boolean InlineTypePassFieldsAsArgs = (Boolean)WHITE_BOX.getVMFlag("InlineTypePassFieldsAsArgs"); - protected static final boolean InlineTypeArrayFlatten = (WHITE_BOX.getIntxVMFlag("FlatArrayElementMaxSize") == -1); - protected static final boolean InlineTypeReturnedAsFields = (Boolean)WHITE_BOX.getVMFlag("InlineTypeReturnedAsFields"); - protected static final boolean AlwaysIncrementalInline = (Boolean)WHITE_BOX.getVMFlag("AlwaysIncrementalInline"); - protected static final boolean G1GC = (Boolean)WHITE_BOX.getVMFlag("UseG1GC"); - protected static final boolean ZGC = (Boolean)WHITE_BOX.getVMFlag("UseZGC"); - protected static final boolean VerifyOops = (Boolean)WHITE_BOX.getVMFlag("VerifyOops"); - protected static final boolean UseArrayLoadStoreProfile = (Boolean)WHITE_BOX.getVMFlag("UseArrayLoadStoreProfile"); - protected static final long TypeProfileLevel = (Long)WHITE_BOX.getVMFlag("TypeProfileLevel"); - protected static final boolean UseACmpProfile = (Boolean)WHITE_BOX.getVMFlag("UseACmpProfile"); - protected static final long PerMethodTrapLimit = (Long)WHITE_BOX.getVMFlag("PerMethodTrapLimit"); - protected static final boolean ProfileInterpreter = (Boolean)WHITE_BOX.getVMFlag("ProfileInterpreter"); - - protected static final Hashtable tests = new Hashtable(); - protected static final boolean USE_COMPILER = WHITE_BOX.getBooleanVMFlag("UseCompiler"); - protected static final boolean PRINT_IDEAL = WHITE_BOX.getBooleanVMFlag("PrintIdeal"); - - // Regular expressions used to match nodes in the PrintIdeal output - protected static final String START = "(\\d+ (.*"; - protected static final String MID = ".*)+ ===.*"; - protected static final String END = ")|"; - // Generic allocation - protected static final String ALLOC_G = "(.*call,static wrapper for: _new_instance_Java" + END; - protected static final String ALLOCA_G = "(.*call,static wrapper for: _new_array_Java" + END; - // Inline type allocation - protected static final String ALLOC = "(.*precise klass compiler/valhalla/inlinetypes/MyValue.*\\R(.*(movl|xorl|nop|spill).*\\R)*.*_new_instance_Java" + END; - protected static final String ALLOCA = "(.*precise klass \\[(L|Q)compiler/valhalla/inlinetypes/MyValue.*\\R(.*(movl|xorl|nop|spill).*\\R)*.*_new_array_Java" + END; - protected static final String LOAD = START + "Load(B|S|I|L|F|D|P|N)" + MID + "@compiler/valhalla/inlinetypes/MyValue.*" + END; - protected static final String LOADK = START + "LoadK" + MID + END; - protected static final String STORE = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@compiler/valhalla/inlinetypes/MyValue.*" + END; - protected static final String LOOP = START + "Loop" + MID + "" + END; - protected static final String COUNTEDLOOP = START + "CountedLoop\\b" + MID + "" + END; - protected static final String COUNTEDLOOP_MAIN = START + "CountedLoop\\b" + MID + "main" + END; - protected static final String TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*(unstable_if|predicate)" + END; - protected static final String LINKTOSTATIC = START + "CallStaticJava" + MID + "linkToStatic" + END; - protected static final String NPE = START + "CallStaticJava" + MID + "null_check" + END; - protected static final String CALL = START + "CallStaticJava" + MID + END; - protected static final String STORE_INLINE_FIELDS = START + "CallStaticJava" + MID + "store_inline_type_fields" + END; - protected static final String SCOBJ = "(.*# ScObj.*" + END; - protected static final String LOAD_UNKNOWN_INLINE = "(.*call_leaf,runtime load_unknown_inline.*" + END; - protected static final String STORE_UNKNOWN_INLINE = "(.*call_leaf,runtime store_unknown_inline.*" + END; - protected static final String INLINE_ARRAY_NULL_GUARD = "(.*call,static wrapper for: uncommon_trap.*reason='null_check' action='none'.*" + END; - protected static final String INTRINSIC_SLOW_PATH = "(.*call,static wrapper for: uncommon_trap.*reason='intrinsic_or_type_checked_inlining'.*" + END; - protected static final String CLONE_INTRINSIC_SLOW_PATH = "(.*call,static.*java.lang.Object::clone.*" + END; - protected static final String CLASS_CHECK_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*class_check" + END; - protected static final String NULL_CHECK_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*null_check" + END; - protected static final String NULL_ASSERT_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*null_assert" + END; - protected static final String RANGE_CHECK_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*range_check" + END; - protected static final String UNHANDLED_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*unhandled" + END; - protected static final String PREDICATE_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*predicate" + END; - protected static final String MEMBAR = START + "MemBar" + MID + END; - protected static final String CHECKCAST_ARRAY = "(cmp.*precise klass \\[(L|Q)compiler/valhalla/inlinetypes/MyValue.*" + END; - protected static final String CHECKCAST_ARRAYCOPY = "(.*call_leaf_nofp,runtime checkcast_arraycopy.*" + END; - protected static final String JLONG_ARRAYCOPY = "(.*call_leaf_nofp,runtime jlong_disjoint_arraycopy.*" + END; - protected static final String FIELD_ACCESS = "(.*Field: *" + END; - protected static final String SUBSTITUTABILITY_TEST = START + "CallStaticJava" + MID + "java.lang.invoke.ValueBootstrapMethods::isSubstitutable" + END; - - public static String[] concat(String prefix[], String... extra) { - ArrayList list = new ArrayList(); - if (prefix != null) { - for (String s : prefix) { - list.add(s); - } - } - if (extra != null) { - for (String s : extra) { - list.add(s); - } - } - - return list.toArray(new String[list.size()]); - } - - /** - * Override getNumScenarios and getVMParameters if you want to run with more than - * the 6 built-in scenarios - */ - public int getNumScenarios() { - return 6; - } - - /** - * VM parameters for the 5 built-in test scenarios. If your test needs to append - * extra parameters for (some of) these scenarios, override getExtraVMParameters(). - */ - public String[] getVMParameters(int scenario) { - switch (scenario) { - case 0: return new String[] { - "-XX:-UseACmpProfile", - "-XX:+AlwaysIncrementalInline", - "-XX:FlatArrayElementMaxOops=5", - "-XX:FlatArrayElementMaxSize=-1", - "-XX:-UseArrayLoadStoreProfile", - "-XX:InlineFieldMaxFlatSize=-1", - "-XX:+InlineTypePassFieldsAsArgs", - "-XX:+InlineTypeReturnedAsFields"}; - case 1: return new String[] { - "-XX:-UseACmpProfile", - "-XX:-UseCompressedOops", - "-XX:FlatArrayElementMaxOops=5", - "-XX:FlatArrayElementMaxSize=-1", - "-XX:-UseArrayLoadStoreProfile", - "-XX:InlineFieldMaxFlatSize=-1", - "-XX:-InlineTypePassFieldsAsArgs", - "-XX:-InlineTypeReturnedAsFields"}; - case 2: return new String[] { - "-XX:-UseACmpProfile", - "-XX:-UseCompressedOops", - "-XX:FlatArrayElementMaxOops=0", - "-XX:FlatArrayElementMaxSize=0", - "-XX:-UseArrayLoadStoreProfile", - "-XX:InlineFieldMaxFlatSize=-1", - "-XX:+InlineTypePassFieldsAsArgs", - "-XX:+InlineTypeReturnedAsFields", - "-XX:+StressInlineTypeReturnedAsFields"}; - case 3: return new String[] { - "-DVerifyIR=false", - "-XX:+AlwaysIncrementalInline", - "-XX:FlatArrayElementMaxOops=0", - "-XX:FlatArrayElementMaxSize=0", - "-XX:InlineFieldMaxFlatSize=0", - "-XX:+InlineTypePassFieldsAsArgs", - "-XX:+InlineTypeReturnedAsFields"}; - case 4: return new String[] { - "-DVerifyIR=false", - "-XX:FlatArrayElementMaxOops=-1", - "-XX:FlatArrayElementMaxSize=-1", - "-XX:InlineFieldMaxFlatSize=0", - "-XX:+InlineTypePassFieldsAsArgs", - "-XX:-InlineTypeReturnedAsFields", - "-XX:-ReduceInitialCardMarks"}; - case 5: return new String[] { - "-XX:-UseACmpProfile", - "-XX:+AlwaysIncrementalInline", - "-XX:FlatArrayElementMaxOops=5", - "-XX:FlatArrayElementMaxSize=-1", - "-XX:-UseArrayLoadStoreProfile", - "-XX:InlineFieldMaxFlatSize=-1", - "-XX:-InlineTypePassFieldsAsArgs", - "-XX:-InlineTypeReturnedAsFields"}; - } - return null; - } - - /** - * Override this method and return a non-null reason if the given scenario should be - * ignored (due to an existing bug, etc). - */ - String isScenarioIgnored(int scenario) { - return null; - } - - /** - * Override this method to provide extra parameters for selected scenarios - */ - public String[] getExtraVMParameters(int scenario) { - return null; - } - - public static void main(String[] args) throws Throwable { - if (args.length != 1) { - throw new RuntimeException("Usage: @run main/othervm/timeout=120 -Xbootclasspath/a:." + - " -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions" + - " -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI" + - " compiler.valhalla.inlinetypes.InlineTypeTest "); - } - String testMainClassName = args[0]; - Class testMainClass = Class.forName(testMainClassName); - InlineTypeTest test = (InlineTypeTest)testMainClass.newInstance(); - List scenarios = null; - if (!SCENARIOS.isEmpty()) { - scenarios = Arrays.asList(SCENARIOS.split(",")); - } - for (int i=0; i,,... - // Each case can be just the method name, or can be .. The latter form is useful - // when you are running several tests at the same time. - // - // jtreg -DExclude=test12 TestArrays.java - // jtreg -DExclude=test34 TestLWorld.java - // -- or -- - // jtreg -DExclude=TestArrays.test12,TestLWorld.test34 TestArrays.java TestLWorld.java - // - private List buildExcludeList() { - List exclude = null; - String classPrefix = getClass().getSimpleName() + "."; - if (!EXCLUDELIST.isEmpty()) { - exclude = new ArrayList(Arrays.asList(EXCLUDELIST.split(","))); - for (int i = exclude.size() - 1; i >= 0; i--) { - String ex = exclude.get(i); - if (ex.indexOf(".") > 0) { - if (ex.startsWith(classPrefix)) { - ex = ex.substring(classPrefix.length()); - exclude.set(i, ex); - } else { - exclude.remove(i); - } - } - } - } - return exclude; - } - - protected InlineTypeTest() { - List list = null; - if (!TESTLIST.isEmpty()) { - list = Arrays.asList(TESTLIST.split(",")); - } - List exclude = buildExcludeList(); - - // Gather all test methods and put them in Hashtable - for (Method m : getClass().getDeclaredMethods()) { - Test[] annos = m.getAnnotationsByType(Test.class); - if (annos.length != 0 && - ((list == null || list.contains(m.getName())) && (exclude == null || !exclude.contains(m.getName())))) { - tests.put(getClass().getSimpleName() + "::" + m.getName(), m); - } else if (annos.length == 0 && m.getName().startsWith("test")) { - try { - getClass().getMethod(m.getName() + "_verifier", boolean.class); - throw new RuntimeException(m.getName() + " has a verifier method but no @Test annotation"); - } catch (NoSuchMethodException e) { - // Expected - } - } - } - } - - protected void run(String[] args, Class... classes) throws Throwable { - if (args.length == 0) { - // Spawn a new VM instance - execute_vm(); - } else { - // Execute tests in the VM spawned by the above code. - Asserts.assertTrue(args.length == 1 && args[0].equals("run"), "must be"); - run(classes); - } - } - - private void execute_vm() throws Throwable { - Asserts.assertFalse(tests.isEmpty(), "no tests to execute"); - String[] vmInputArgs = InputArguments.getVmInputArgs(); - for (String arg : vmInputArgs) { - if (arg.startsWith("-XX:CompileThreshold")) { - // Disable IR verification if non-default CompileThreshold is set - VERIFY_IR = false; - } - } - // Each VM is launched with flags in this order, so the later ones can override the earlier one: - // VERIFY_IR flags specified below - // vmInputArgs, which consists of: - // @run options - // getVMParameters() - // getExtraVMParameters() - // defaultFlags - // compileCommandFlags - String cmds[] = null; - if (VERIFY_IR) { - // Add print flags for IR verification - cmds = concat(cmds, printFlags); - // Always trap for exception throwing to not confuse IR verification - cmds = concat(cmds, "-XX:-OmitStackTraceInFastThrow"); - } - cmds = concat(cmds, vmInputArgs); - cmds = concat(cmds, defaultFlags); - if (COMPILE_COMMANDS) { - cmds = concat(cmds, compileCommandFlags); - } - - // Run tests in own process and verify output - cmds = concat(cmds, getClass().getName(), "run"); - OutputAnalyzer oa = ProcessTools.executeTestJvm(cmds); - // If ideal graph printing is enabled/supported, verify output - String output = oa.getOutput(); - oa.shouldHaveExitValue(0); - if (VERIFY_IR) { - if (output.contains("PrintIdeal enabled")) { - parseOutput(output); - } else { - System.out.println(output); - System.out.println("WARNING: IR verification failed! Running with -Xint, -Xcomp or release build?"); - } - } - } - - static final class TestAnnotation { - private final int flag; - private final BooleanSupplier predicate; - - private static final TestAnnotation testAnnotations[] = { - new TestAnnotation(InlineTypePassFieldsAsArgsOn, () -> InlineTypePassFieldsAsArgs), - new TestAnnotation(InlineTypePassFieldsAsArgsOff, () -> !InlineTypePassFieldsAsArgs), - new TestAnnotation(InlineTypeArrayFlattenOn, () -> InlineTypeArrayFlatten), - new TestAnnotation(InlineTypeArrayFlattenOff, () -> !InlineTypeArrayFlatten), - new TestAnnotation(InlineTypeReturnedAsFieldsOn, () -> InlineTypeReturnedAsFields), - new TestAnnotation(InlineTypeReturnedAsFieldsOff, () -> !InlineTypeReturnedAsFields), - new TestAnnotation(AlwaysIncrementalInlineOn, () -> AlwaysIncrementalInline), - new TestAnnotation(AlwaysIncrementalInlineOff, () -> !AlwaysIncrementalInline), - new TestAnnotation(G1GCOn, () -> G1GC), - new TestAnnotation(G1GCOff, () -> !G1GC), - new TestAnnotation(ZGCOn, () -> ZGC), - new TestAnnotation(ZGCOff, () -> !ZGC), - new TestAnnotation(ArrayLoadStoreProfileOn, () -> UseArrayLoadStoreProfile), - new TestAnnotation(ArrayLoadStoreProfileOff, () -> !UseArrayLoadStoreProfile), - new TestAnnotation(TypeProfileOn, () -> TypeProfileLevel == 222), - new TestAnnotation(TypeProfileOff, () -> TypeProfileLevel == 0), - new TestAnnotation(ACmpProfileOn, () -> UseACmpProfile), - new TestAnnotation(ACmpProfileOff, () -> !UseACmpProfile), - }; - - private TestAnnotation(int flag, BooleanSupplier predicate) { - this.flag = flag; - this.predicate = predicate; - } - - private boolean match(Test a) { - return (a.valid() & flag) != 0 && predicate.getAsBoolean(); - } - - static boolean find(Test a) { - Stream s = Arrays.stream(testAnnotations).filter(t -> t.match(a)); - long c = s.count(); - if (c > 1) { - throw new RuntimeException("At most one Test annotation should match"); - } - return c > 0; - } - } - - private void parseOutput(String output) throws Exception { - Pattern comp_re = Pattern.compile("\\n\\s+\\d+\\s+\\d+\\s+(%| )(s| )(!| )b(n| )\\s+\\d?\\s+\\S+\\.(?[^.]+::\\S+)\\s+(?@ \\d+\\s+)?[(]\\d+ bytes[)]"); - Matcher m = comp_re.matcher(output); - Map compilations = new LinkedHashMap<>(); - int prev = 0; - String methodName = null; - while (m.find()) { - if (prev == 0) { - // Print header - System.out.print(output.substring(0, m.start()+1)); - } else if (methodName != null) { - compilations.put(methodName, output.substring(prev, m.start()+1)); - } - if (m.group("osr") != null) { - methodName = null; - } else { - methodName = m.group("name"); - } - prev = m.end(); - } - if (prev == 0) { - // Print header - System.out.print(output); - } else if (methodName != null) { - compilations.put(methodName, output.substring(prev)); - } - // Iterate over compilation output - for (String testName : compilations.keySet()) { - Method test = tests.get(testName); - if (test == null) { - // Skip helper methods - continue; - } - String graph = compilations.get(testName); - System.out.println("\nGraph for " + testName + "\n" + graph); - // Parse graph using regular expressions to determine if it contains forbidden nodes - Test[] annos = test.getAnnotationsByType(Test.class); - Test anno = Arrays.stream(annos).filter(TestAnnotation::find).findFirst().orElse(null); - if (anno == null) { - Object[] res = Arrays.stream(annos).filter(a -> a.valid() == 0).toArray(); - if (res.length != 1) { - throw new RuntimeException("Only one Test annotation should match"); - } - anno = (Test)res[0]; - } - String regexFail = anno.failOn(); - if (!regexFail.isEmpty()) { - Pattern pattern = Pattern.compile(regexFail.substring(0, regexFail.length()-1)); - Matcher matcher = pattern.matcher(graph); - boolean found = matcher.find(); - Asserts.assertFalse(found, "Graph for '" + testName + "' contains forbidden node:\n" + (found ? matcher.group() : "")); - } - String[] regexMatch = anno.match(); - int[] matchCount = anno.matchCount(); - for (int i = 0; i < regexMatch.length; ++i) { - Pattern pattern = Pattern.compile(regexMatch[i].substring(0, regexMatch[i].length()-1)); - Matcher matcher = pattern.matcher(graph); - int count = 0; - String nodes = ""; - while (matcher.find()) { - count++; - nodes += matcher.group() + "\n"; - } - if (matchCount[i] < 0) { - Asserts.assertLTE(Math.abs(matchCount[i]), count, "Graph for '" + testName + "' contains different number of match nodes (expected >= " + Math.abs(matchCount[i]) + " but got " + count + "):\n" + nodes); - } else { - Asserts.assertEQ(matchCount[i], count, "Graph for '" + testName + "' contains different number of match nodes (expected " + matchCount[i] + " but got " + count + "):\n" + nodes); - } - } - tests.remove(testName); - System.out.println(testName + " passed"); - } - // Check if all tests were compiled - if (tests.size() != 0) { - for (String name : tests.keySet()) { - System.out.println("Test '" + name + "' not compiled!"); - } - throw new RuntimeException("Not all tests were compiled"); - } - } - - private void setup(Class clazz) { - if (XCOMP) { - // Don't control compilation if -Xcomp is enabled - return; - } - if (DUMP_REPLAY) { - // Generate replay compilation files - String directive = "[{ match: \"*.*\", DumpReplay: true }]"; - if (WHITE_BOX.addCompilerDirective(directive) != 1) { - throw new RuntimeException("Failed to add compiler directive"); - } - } - - Method[] methods = clazz.getDeclaredMethods(); - for (Method m : methods) { - if (m.isAnnotationPresent(Test.class)) { - // Don't inline tests - WHITE_BOX.testSetDontInlineMethod(m, true); - } - if (m.isAnnotationPresent(DontCompile.class)) { - WHITE_BOX.makeMethodNotCompilable(m, COMP_LEVEL_ANY, true); - WHITE_BOX.makeMethodNotCompilable(m, COMP_LEVEL_ANY, false); - WHITE_BOX.testSetDontInlineMethod(m, true); - } - if (m.isAnnotationPresent(ForceInline.class)) { - Asserts.assertFalse(m.isAnnotationPresent(DontInline.class), "Method " + m.getName() + " has contradicting DontInline annotation"); - WHITE_BOX.testSetForceInlineMethod(m, true); - } - if (m.isAnnotationPresent(DontInline.class)) { - Asserts.assertFalse(m.isAnnotationPresent(ForceInline.class), "Method " + m.getName() + " has contradicting ForceInline annotation"); - WHITE_BOX.testSetDontInlineMethod(m, true); - } - if (STRESS_CC) { - // Exclude some methods from compilation with C2 to stress test the calling convention - if (Utils.getRandomInstance().nextBoolean()) { - System.out.println("Excluding from C2 compilation: " + m); - WHITE_BOX.makeMethodNotCompilable(m, COMP_LEVEL_FULL_OPTIMIZATION, false); - } - } - } - // Only force compilation now because above annotations affect inlining - for (Method m : methods) { - if (m.isAnnotationPresent(ForceCompile.class)) { - Asserts.assertFalse(m.isAnnotationPresent(DontCompile.class), "Method " + m.getName() + " has contradicting DontCompile annotation"); - int compLevel = getCompLevel(m.getAnnotation(ForceCompile.class)); - enqueueMethodForCompilation(m, compLevel); - } - } - // Compile class initializers - int compLevel = getCompLevel(null); - WHITE_BOX.enqueueInitializerForCompilation(clazz, compLevel); - } - - private void run(Class... classes) throws Exception { - if (USE_COMPILER && PRINT_IDEAL && !XCOMP && !STRESS_CC) { - System.out.println("PrintIdeal enabled"); - } - System.out.format("rI = %d, rL = %d\n", rI, rL); - - setup(getClass()); - for (Class clazz : classes) { - setup(clazz); - } - - TreeMap durations = (PRINT_TIMES || VERBOSE) ? new TreeMap() : null; - List testList = new ArrayList(tests.values()); - if (SHUFFLE_TESTS) { - // Execute tests in random order (execution sequence affects profiling) - Collections.shuffle(testList, Utils.getRandomInstance()); - } - for (Method test : testList) { - if (VERBOSE) { - System.out.println("Starting " + test.getName()); - } - TempSkipForC1 c1skip = test.getAnnotation(TempSkipForC1.class); - if (TEST_C1 && c1skip != null) { - System.out.println("Skipped " + test.getName() + " for C1 testing: " + c1skip.reason()); - continue; - } - long startTime = System.nanoTime(); - Method verifier = getClass().getMethod(test.getName() + "_verifier", boolean.class); - // Warmup using verifier method - Warmup anno = test.getAnnotation(Warmup.class); - int warmup = anno == null ? WARMUP : anno.value(); - for (int i = 0; i < warmup; ++i) { - verifier.invoke(this, true); - } - boolean osrOnly = (test.getAnnotation(OSRCompileOnly.class) != null); - int compLevel = getCompLevel(test.getAnnotation(Test.class)); - - // C1 generates a lot of code when VerifyOops is enabled and may run out of space (for a small - // number of test cases). - boolean maybeCodeBufferOverflow = (TEST_C1 && VerifyOops); - - if (osrOnly) { - long started = System.currentTimeMillis(); - boolean stateCleared = false; - for (;;) { - long elapsed = System.currentTimeMillis() - started; - int level = WHITE_BOX.getMethodCompilationLevel(test); - if (maybeCodeBufferOverflow && elapsed > 5000 && (!WHITE_BOX.isMethodCompiled(test, false) || level != compLevel)) { - System.out.println("Temporarily disabling VerifyOops"); - try { - WHITE_BOX.setBooleanVMFlag("VerifyOops", false); - if (!stateCleared) { - WHITE_BOX.clearMethodState(test); - stateCleared = true; - } - verifier.invoke(this, false); - } finally { - WHITE_BOX.setBooleanVMFlag("VerifyOops", true); - System.out.println("Re-enabled VerifyOops"); - } - } else { - verifier.invoke(this, false); - } - - boolean b = WHITE_BOX.isMethodCompiled(test, false); - if (VERBOSE) { - System.out.println("Is " + test.getName() + " compiled? " + b); - } - if (b || XCOMP || STRESS_CC || !USE_COMPILER) { - // Don't control compilation if -Xcomp is enabled, or if compiler is disabled - break; - } - Asserts.assertTrue(OSR_TEST_TIMEOUT < 0 || elapsed < OSR_TEST_TIMEOUT, test + " not compiled after " + OSR_TEST_TIMEOUT + " ms"); - } - } else { - // Trigger compilation - enqueueMethodForCompilation(test, compLevel); - if (maybeCodeBufferOverflow && !WHITE_BOX.isMethodCompiled(test, false)) { - // Let's disable VerifyOops temporarily and retry. - WHITE_BOX.setBooleanVMFlag("VerifyOops", false); - WHITE_BOX.clearMethodState(test); - enqueueMethodForCompilation(test, compLevel); - WHITE_BOX.setBooleanVMFlag("VerifyOops", true); - } - if (!STRESS_CC && USE_COMPILER) { - Asserts.assertTrue(WHITE_BOX.isMethodCompiled(test, false), test + " not compiled"); - int level = WHITE_BOX.getMethodCompilationLevel(test); - Asserts.assertEQ(level, compLevel, "Unexpected compilation level for " + test); - } - // Check result - verifier.invoke(this, false); - } - if (PRINT_TIMES || VERBOSE) { - long endTime = System.nanoTime(); - long duration = (endTime - startTime); - durations.put(duration, test.getName()); - if (VERBOSE) { - System.out.println("Done " + test.getName() + ": " + duration + " ns = " + (duration / 1000000) + " ms"); - } - } - if (GC_AFTER) { - System.out.println("doing GC"); - System.gc(); - } - } - - // Print execution times - if (PRINT_TIMES) { - System.out.println("\n\nTest execution times:"); - for (Map.Entry entry : durations.entrySet()) { - System.out.format("%-10s%15d ns\n", entry.getValue() + ":", entry.getKey()); - } - } - } - - // Get the appropriate compilation level for a method, according to the - // given annotation, as well as the current test scenario and VM options. - // - private int getCompLevel(Object annotation) { - int compLevel; - if (annotation == null) { - compLevel = COMP_LEVEL_ANY; - } else if (annotation instanceof Test) { - compLevel = ((Test)annotation).compLevel(); - } else { - compLevel = ((ForceCompile)annotation).compLevel(); - } - - return restrictCompLevel(compLevel); - } - - // Get the appropriate level as permitted by the test scenario and VM options. - private static int restrictCompLevel(int compLevel) { - if (compLevel == COMP_LEVEL_ANY) { - compLevel = COMP_LEVEL_FULL_OPTIMIZATION; - } - if (FLIP_C1_C2) { - // Effectively treat all (compLevel = C1) as (compLevel = C2), and - // (compLevel = C2) as (compLevel = C1). - if (compLevel == COMP_LEVEL_SIMPLE) { - compLevel = COMP_LEVEL_FULL_OPTIMIZATION; - } else if (compLevel == COMP_LEVEL_FULL_OPTIMIZATION) { - compLevel = COMP_LEVEL_SIMPLE; - } - } - if (!TEST_C1 && compLevel < COMP_LEVEL_FULL_OPTIMIZATION) { - compLevel = COMP_LEVEL_FULL_OPTIMIZATION; - } - if (TieredCompilation && compLevel > (int)TieredStopAtLevel) { - compLevel = (int)TieredStopAtLevel; - } - return compLevel; - } - - public static void enqueueMethodForCompilation(Method m, int level) { - level = restrictCompLevel(level); - if (VERBOSE) { - System.out.println("enqueueMethodForCompilation " + m + ", level = " + level); - } - WHITE_BOX.enqueueMethodForCompilation(m, level); - } - - enum TriState { - Maybe, - Yes, - No - } - - static private TriState compiledByC2(Method m) { - if (!USE_COMPILER || XCOMP || TEST_C1 || - (STRESS_CC && !WHITE_BOX.isMethodCompilable(m, COMP_LEVEL_FULL_OPTIMIZATION, false))) { - return TriState.Maybe; - } - if (WHITE_BOX.isMethodCompiled(m, false) && - WHITE_BOX.getMethodCompilationLevel(m, false) >= COMP_LEVEL_FULL_OPTIMIZATION) { - return TriState.Yes; - } - return TriState.No; - } - - static boolean isCompiledByC2(Method m) { - return compiledByC2(m) == TriState.Yes; - } - - static void assertDeoptimizedByC2(Method m) { - if (compiledByC2(m) == TriState.Yes && PerMethodTrapLimit != 0 && ProfileInterpreter) { - throw new RuntimeException("Expected to have deoptimized"); - } - } - - static void assertCompiledByC2(Method m) { - if (compiledByC2(m) == TriState.No) { - throw new RuntimeException("Expected to be compiled"); - } - } -} diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/InlineTypes.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/InlineTypes.java new file mode 100644 index 00000000000..c6a2d980af9 --- /dev/null +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/InlineTypes.java @@ -0,0 +1,149 @@ +/* + * Copyright (c) 2017, 2021, 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.valhalla.inlinetypes; + +import jdk.test.lib.Utils; +import compiler.lib.ir_framework.Scenario; +import compiler.lib.ir_framework.TestFramework; + +public class InlineTypes { + public static final int rI = Utils.getRandomInstance().nextInt() % 1000; + public static final long rL = Utils.getRandomInstance().nextLong() % 1000; + public static final double rD = Utils.getRandomInstance().nextDouble() % 1000; + + public static final Scenario[] DEFAULT_SCENARIOS = { + new Scenario(0, + "-XX:+IgnoreUnrecognizedVMOptions", + "-XX:-UseACmpProfile", + "-XX:+AlwaysIncrementalInline", + "-XX:FlatArrayElementMaxOops=5", + "-XX:FlatArrayElementMaxSize=-1", + "-XX:-UseArrayLoadStoreProfile", + "-XX:InlineFieldMaxFlatSize=-1", + "-XX:+InlineTypePassFieldsAsArgs", + "-XX:+InlineTypeReturnedAsFields" + ), + new Scenario(1, + "-XX:+IgnoreUnrecognizedVMOptions", + "-XX:-UseACmpProfile", + "-XX:-UseCompressedOops", + "-XX:FlatArrayElementMaxOops=5", + "-XX:FlatArrayElementMaxSize=-1", + "-XX:-UseArrayLoadStoreProfile", + "-XX:InlineFieldMaxFlatSize=-1", + "-XX:-InlineTypePassFieldsAsArgs", + "-XX:-InlineTypeReturnedAsFields" + ), + new Scenario(2, + "-XX:+IgnoreUnrecognizedVMOptions", + "-XX:-UseACmpProfile", + "-XX:-UseCompressedOops", + "-XX:FlatArrayElementMaxOops=0", + "-XX:FlatArrayElementMaxSize=0", + "-XX:-UseArrayLoadStoreProfile", + "-XX:InlineFieldMaxFlatSize=-1", + "-XX:+InlineTypePassFieldsAsArgs", + "-XX:+InlineTypeReturnedAsFields", + "-XX:+StressInlineTypeReturnedAsFields" + ), + new Scenario(3, + "-XX:+IgnoreUnrecognizedVMOptions", + "-DVerifyIR=false", + "-XX:+AlwaysIncrementalInline", + "-XX:FlatArrayElementMaxOops=0", + "-XX:FlatArrayElementMaxSize=0", + "-XX:InlineFieldMaxFlatSize=0", + "-XX:+InlineTypePassFieldsAsArgs", + "-XX:+InlineTypeReturnedAsFields" + ), + new Scenario(4, + "-XX:+IgnoreUnrecognizedVMOptions", + "-DVerifyIR=false", + "-XX:FlatArrayElementMaxOops=-1", + "-XX:FlatArrayElementMaxSize=-1", + "-XX:InlineFieldMaxFlatSize=0", + "-XX:+InlineTypePassFieldsAsArgs", + "-XX:-InlineTypeReturnedAsFields", + "-XX:-ReduceInitialCardMarks" + ), + new Scenario(5, + "-XX:+IgnoreUnrecognizedVMOptions", + "-XX:-UseACmpProfile", + "-XX:+AlwaysIncrementalInline", + "-XX:FlatArrayElementMaxOops=5", + "-XX:FlatArrayElementMaxSize=-1", + "-XX:-UseArrayLoadStoreProfile", + "-XX:InlineFieldMaxFlatSize=-1", + "-XX:-InlineTypePassFieldsAsArgs", + "-XX:-InlineTypeReturnedAsFields" + ) + }; + + public static TestFramework getFramework() { + StackWalker walker = StackWalker.getInstance(StackWalker.Option.RETAIN_CLASS_REFERENCE); + return new TestFramework(walker.getCallerClass()).setDefaultWarmup(251); + } + + static class IRNode { + // Regular expressions used to match nodes in the PrintIdeal output + protected static final String START = "(\\d+ (.*"; + protected static final String MID = ".*)+ ===.*"; + protected static final String END = ")"; + // Generic allocation + protected static final String ALLOC_G = "(.*call,static wrapper for: _new_instance_Java" + END; + protected static final String ALLOCA_G = "(.*call,static wrapper for: _new_array_Java" + END; + // Inline type allocation + protected static final String ALLOC = "(.*precise klass compiler/valhalla/inlinetypes/MyValue.*\\R(.*(movl|xorl|nop|spill).*\\R)*.*_new_instance_Java" + END; + protected static final String ALLOCA = "(.*precise klass \\[(L|Q)compiler/valhalla/inlinetypes/MyValue.*\\R(.*(movl|xorl|nop|spill).*\\R)*.*_new_array_Java" + END; + protected static final String LOAD = START + "Load(B|S|I|L|F|D|P|N)" + MID + "@compiler/valhalla/inlinetypes/MyValue.*" + END; + protected static final String LOADK = START + "LoadK" + MID + END; + protected static final String STORE = START + "Store(B|C|S|I|L|F|D|P|N)" + MID + "@compiler/valhalla/inlinetypes/MyValue.*" + END; + protected static final String LOOP = START + "Loop" + MID + "" + END; + protected static final String COUNTEDLOOP = START + "CountedLoop\\b" + MID + "" + END; + protected static final String COUNTEDLOOP_MAIN = START + "CountedLoop\\b" + MID + "main" + END; + protected static final String TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*(unstable_if|predicate)" + END; + protected static final String LINKTOSTATIC = START + "CallStaticJava" + MID + "linkToStatic" + END; + protected static final String NPE = START + "CallStaticJava" + MID + "null_check" + END; + protected static final String CALL = START + "CallStaticJava" + MID + END; + protected static final String STORE_INLINE_FIELDS = START + "CallStaticJava" + MID + "store_inline_type_fields" + END; + protected static final String SCOBJ = "(.*# ScObj.*" + END; + protected static final String LOAD_UNKNOWN_INLINE = "(.*call_leaf,runtime load_unknown_inline.*" + END; + protected static final String STORE_UNKNOWN_INLINE = "(.*call_leaf,runtime store_unknown_inline.*" + END; + protected static final String INLINE_ARRAY_NULL_GUARD = "(.*call,static wrapper for: uncommon_trap.*reason='null_check' action='none'.*" + END; + protected static final String INTRINSIC_SLOW_PATH = "(.*call,static wrapper for: uncommon_trap.*reason='intrinsic_or_type_checked_inlining'.*" + END; + protected static final String CLONE_INTRINSIC_SLOW_PATH = "(.*call,static.*java.lang.Object::clone.*" + END; + protected static final String CLASS_CHECK_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*class_check" + END; + protected static final String NULL_CHECK_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*null_check" + END; + protected static final String NULL_ASSERT_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*null_assert" + END; + protected static final String RANGE_CHECK_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*range_check" + END; + protected static final String UNHANDLED_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*unhandled" + END; + protected static final String PREDICATE_TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*predicate" + END; + protected static final String MEMBAR = START + "MemBar" + MID + END; + protected static final String CHECKCAST_ARRAY = "(cmp.*precise klass \\[(L|Q)compiler/valhalla/inlinetypes/MyValue.*" + END; + protected static final String CHECKCAST_ARRAYCOPY = "(.*call_leaf_nofp,runtime checkcast_arraycopy.*" + END; + protected static final String JLONG_ARRAYCOPY = "(.*call_leaf_nofp,runtime jlong_disjoint_arraycopy.*" + END; + protected static final String FIELD_ACCESS = "(.*Field: *" + END; + protected static final String SUBSTITUTABILITY_TEST = START + "CallStaticJava" + MID + "java.lang.invoke.ValueBootstrapMethods::isSubstitutable" + END; + } +} diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue1.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue1.java index 016ebf4dc41..4634e9e8b89 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue1.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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 @@ -23,9 +23,15 @@ package compiler.valhalla.inlinetypes; +import compiler.lib.ir_framework.DontCompile; +import compiler.lib.ir_framework.DontInline; +import compiler.lib.ir_framework.ForceCompileClassInitializer; +import compiler.lib.ir_framework.ForceInline; + +@ForceCompileClassInitializer public final primitive class MyValue1 extends MyAbstract { static int s; - static final long sf = InlineTypeTest.rL; + static final long sf = InlineTypes.rL; final int x; final long y; final short z; @@ -33,7 +39,7 @@ public final primitive class MyValue1 extends MyAbstract { final int[] oa; final MyValue2 v1; final MyValue2 v2; - static final MyValue2 v3 = MyValue2.createWithFieldsInline(InlineTypeTest.rI, InlineTypeTest.rD); + static final MyValue2 v3 = MyValue2.createWithFieldsInline(InlineTypes.rI, InlineTypes.rD); final int c; @ForceInline @@ -74,8 +80,8 @@ static MyValue1 createWithFieldsInline(int x, long y) { v = setO(v, new Integer(x)); int[] oa = {x}; v = setOA(v, oa); - v = setV1(v, MyValue2.createWithFieldsInline(x, y, InlineTypeTest.rD)); - v = setV2(v, MyValue2.createWithFieldsInline(x, y, InlineTypeTest.rD+x)); + v = setV1(v, MyValue2.createWithFieldsInline(x, y, InlineTypes.rD)); + v = setV2(v, MyValue2.createWithFieldsInline(x, y, InlineTypes.rD + x)); v = setC(v, (int)(x+y)); return v; } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue2.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue2.java index 859708d8575..7496c20e0c5 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue2.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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 @@ -23,6 +23,9 @@ package compiler.valhalla.inlinetypes; +import compiler.lib.ir_framework.DontInline; +import compiler.lib.ir_framework.ForceInline; + final primitive class MyValue2Inline { final double d; final long l; @@ -88,7 +91,7 @@ public static MyValue2 createWithFieldsInline(int x, double d) { MyValue2 v = createDefaultInline(); v = setX(v, x); v = setY(v, (byte)x); - v = setV(v, MyValue2Inline.createWithFieldsInline(d, InlineTypeTest.rL)); + v = setV(v, MyValue2Inline.createWithFieldsInline(d, InlineTypes.rL)); return v; } @@ -97,7 +100,7 @@ public static MyValue2 createWithFieldsDontInline(int x, double d) { MyValue2 v = createDefaultInline(); v = setX(v, x); v = setY(v, (byte)x); - v = setV(v, MyValue2Inline.createWithFieldsInline(d, InlineTypeTest.rL)); + v = setV(v, MyValue2Inline.createWithFieldsInline(d, InlineTypes.rL)); return v; } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue3.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue3.java index fa3b468a790..4b6ef9df780 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue3.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue3.java @@ -25,6 +25,8 @@ import jdk.test.lib.Asserts; import jdk.test.lib.Utils; +import compiler.lib.ir_framework.DontInline; +import compiler.lib.ir_framework.ForceInline; final primitive class MyValue3Inline { final float f7; diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue4.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue4.java index fcf3f38d7ea..a0e7ad47e68 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue4.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/MyValue4.java @@ -23,6 +23,8 @@ package compiler.valhalla.inlinetypes; +import compiler.lib.ir_framework.ForceInline; + // Inline type definition with too many fields to return in registers final primitive class MyValue4 extends MyAbstract { final MyValue3 v1; diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestArrays.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestArrays.java index b139467bfde..58a244344d8 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestArrays.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestArrays.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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 @@ -23,43 +23,44 @@ package compiler.valhalla.inlinetypes; +import compiler.lib.ir_framework.*; import jdk.test.lib.Asserts; -import java.lang.invoke.*; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import java.lang.reflect.Method; import java.util.Arrays; +import static compiler.valhalla.inlinetypes.InlineTypes.IRNode.*; +import static compiler.valhalla.inlinetypes.InlineTypes.*; + /* * @test * @key randomness * @summary Test inline type arrays - * @library /testlibrary /test/lib /compiler/whitebox / + * @library /test/lib / * @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64") - * @compile TestArrays.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestArrays + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestArrays */ -public class TestArrays extends InlineTypeTest { - // Extra VM parameters for some test scenarios. See InlineTypeTest.getVMParameters() - @Override - public String[] getExtraVMParameters(int scenario) { - switch (scenario) { - case 2: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast", "-XX:+StressArrayCopyMacroNode"}; - case 3: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:FlatArrayElementMaxSize=-1", "-XX:-UncommonNullCast"}; - case 4: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"}; - case 5: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast", "-XX:+StressArrayCopyMacroNode"}; - } - return null; - } - public static void main(String[] args) throws Throwable { - TestArrays test = new TestArrays(); - test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class); +@ForceCompileClassInitializer +public class TestArrays { + + public static void main(String[] args) { + Scenario[] scenarios = InlineTypes.DEFAULT_SCENARIOS; + scenarios[2].addFlags("-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast", "-XX:+StressArrayCopyMacroNode"); + scenarios[3].addFlags("-XX:-MonomorphicArrayCheck", "-XX:FlatArrayElementMaxSize=-1", "-XX:-UncommonNullCast"); + scenarios[4].addFlags("-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"); + scenarios[5].addFlags("-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast", "-XX:+StressArrayCopyMacroNode"); + + InlineTypes.getFramework() + .addScenarios(scenarios) + .addHelperClasses(MyValue1.class, MyValue2.class, MyValue2Inline.class) + .start(); } - // Helper methods + // Helper methods and classes protected long hash() { return hash(rI, rL); @@ -69,9 +70,68 @@ protected long hash(int x, long y) { return MyValue1.createWithFieldsInline(x, y).hash(); } + static void verify(Object[] src, Object[] dst) { + if (src instanceof MyInterface[] && dst instanceof MyInterface[]) { + for (int i = 0; i < src.length; ++i) { + Asserts.assertEQ(((MyInterface)src[i]).hash(), ((MyInterface)dst[i]).hash()); + } + } else { + for (int i = 0; i < src.length; ++i) { + Asserts.assertEQ(src[i], dst[i]); + } + } + } + + static void verify(MyValue1[] src, MyValue1[] dst) { + for (int i = 0; i < src.length; ++i) { + Asserts.assertEQ(src[i].hash(), dst[i].hash()); + } + } + + static void verify(MyValue1[] src, Object[] dst) { + for (int i = 0; i < src.length; ++i) { + Asserts.assertEQ(src[i].hash(), ((MyInterface)dst[i]).hash()); + } + } + + static void verify(MyValue2[] src, MyValue2[] dst) { + for (int i = 0; i < src.length; ++i) { + Asserts.assertEQ(src[i].hash(), dst[i].hash()); + } + } + + static void verify(MyValue2[] src, Object[] dst) { + for (int i = 0; i < src.length; ++i) { + Asserts.assertEQ(src[i].hash(), ((MyInterface)dst[i]).hash()); + } + } + + static boolean compile_and_run_again_if_deoptimized(RunInfo info) { + if (!info.isWarmUp()) { + Method m = info.getTest(); + if (TestFramework.isCompiled(m)) { + TestFramework.compile(m, CompLevel.C2); + } + } + return false; + } + + primitive static class NotFlattenable { + private final Object o1 = null; + private final Object o2 = null; + private final Object o3 = null; + private final Object o4 = null; + private final Object o5 = null; + private final Object o6 = null; + } + // Test inline type array creation and initialization - @Test(valid = InlineTypeArrayFlattenOn, match = { ALLOCA }, matchCount = { 1 }) - @Test(valid = InlineTypeArrayFlattenOff, match = { ALLOCA }, matchCount = { 1 }, failOn = LOAD) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + counts = {ALLOCA, "= 1"}) + @IR(applyIf = {"FlatArrayElementMaxSize", "!= -1"}, + counts = {ALLOCA, "= 1"}, + failOn = LOAD) public MyValue1[] test1(int len) { MyValue1[] va = new MyValue1[len]; for (int i = 0; i < len; ++i) { @@ -80,8 +140,8 @@ public MyValue1[] test1(int len) { return va; } - @DontCompile - public void test1_verifier(boolean warmup) { + @Run(test = "test1") + public void test1_verifier() { int len = Math.abs(rI % 10); MyValue1[] va = test1(len); for (int i = 0; i < len; ++i) { @@ -90,22 +150,24 @@ public void test1_verifier(boolean warmup) { } // Test creation of an inline type array and element access - @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOOP, LOAD, STORE, TRAP}) public long test2() { MyValue1[] va = new MyValue1[1]; va[0] = MyValue1.createWithFieldsInline(rI, rL); return va[0].hash(); } - @DontCompile - public void test2_verifier(boolean warmup) { + @Run(test = "test2") + public void test2_verifier() { long result = test2(); Asserts.assertEQ(result, hash()); } // Test receiving an inline type array from the interpreter, // updating its elements in a loop and computing a hash. - @Test(failOn = ALLOCA) + @Test + @IR(failOn = ALLOCA) public long test3(MyValue1[] va) { long result = 0; for (int i = 0; i < 10; ++i) { @@ -115,8 +177,8 @@ public long test3(MyValue1[] va) { return result; } - @DontCompile - public void test3_verifier(boolean warmup) { + @Run(test = "test3") + public void test3_verifier() { MyValue1[] va = new MyValue1[10]; long expected = 0; for (int i = 0; i < 10; ++i) { @@ -133,13 +195,14 @@ public void test3_verifier(boolean warmup) { } // Test returning an inline type array received from the interpreter - @Test(failOn = ALLOC + ALLOCA + LOAD + STORE + LOOP + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOAD, STORE, LOOP, TRAP}) public MyValue1[] test4(MyValue1[] va) { return va; } - @DontCompile - public void test4_verifier(boolean warmup) { + @Run(test = "test4") + public void test4_verifier() { MyValue1[] va = new MyValue1[10]; for (int i = 0; i < 10; ++i) { va[i] = MyValue1.createWithFieldsDontInline(rI + i, rL + i); @@ -174,8 +237,8 @@ public MyValue1[] test5(boolean b) { return va; } - @DontCompile - public void test5_verifier(boolean warmup) { + @Run(test = "test5") + public void test5_verifier() { MyValue1[] va = test5(true); Asserts.assertEQ(va.length, 5); Asserts.assertEQ(va[0].hash(), hash(rI, hash())); @@ -191,27 +254,29 @@ public void test5_verifier(boolean warmup) { } // Test creation of inline type array with single element - @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOOP, LOAD, STORE, TRAP}) public MyValue1 test6() { MyValue1[] va = new MyValue1[1]; return va[0]; } - @DontCompile - public void test6_verifier(boolean warmup) { + @Run(test = "test6") + public void test6_verifier() { MyValue1[] va = new MyValue1[1]; MyValue1 v = test6(); Asserts.assertEQ(v.hashPrimitive(), va[0].hashPrimitive()); } // Test default initialization of inline type arrays - @Test(failOn = LOAD) + @Test + @IR(failOn = LOAD) public MyValue1[] test7(int len) { return new MyValue1[len]; } - @DontCompile - public void test7_verifier(boolean warmup) { + @Run(test = "test7") + public void test7_verifier() { int len = Math.abs(rI % 10); MyValue1[] va = new MyValue1[len]; MyValue1[] var = test7(len); @@ -221,13 +286,14 @@ public void test7_verifier(boolean warmup) { } // Test creation of inline type array with zero length - @Test(failOn = ALLOC + LOAD + STORE + LOOP + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, LOOP, TRAP}) public MyValue1[] test8() { return new MyValue1[0]; } - @DontCompile - public void test8_verifier(boolean warmup) { + @Run(test = "test8") + public void test8_verifier() { MyValue1[] va = test8(); Asserts.assertEQ(va.length, 0); } @@ -235,13 +301,14 @@ public void test8_verifier(boolean warmup) { static MyValue1[] test9_va; // Test that inline type array loaded from field has correct type - @Test(failOn = LOOP) + @Test + @IR(failOn = LOOP) public long test9() { return test9_va[0].hash(); } - @DontCompile - public void test9_verifier(boolean warmup) { + @Run(test = "test9") + public void test9_verifier() { test9_va = new MyValue1[1]; test9_va[0] = MyValue1.createWithFieldsInline(rI, rL); long result = test9(); @@ -262,8 +329,8 @@ public MyValue1[][][] test10(int len1, int len2, int len3) { return arr; } - @DontCompile - public void test10_verifier(boolean warmup) { + @Run(test = "test10") + public void test10_verifier() { MyValue1[][][] arr = test10(2, 3, 4); for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { @@ -287,8 +354,8 @@ public void test11(MyValue1[][][] arr, long[] res) { } } - @DontCompile - public void test11_verifier(boolean warmup) { + @Run(test = "test11") + public void test11_verifier() { MyValue1[][][] arr = new MyValue1[2][3][4]; long[] res = new long[2*3*4]; long[] verif = new long[2*3*4]; @@ -325,8 +392,8 @@ public int test12() { } } - @DontCompile - public void test12_verifier(boolean warmup) { + @Run(test = "test12") + public void test12_verifier() { Asserts.assertEQ(test12(), rI); } @@ -347,8 +414,8 @@ public int test13() { } } - @DontCompile - public void test13_verifier(boolean warmup) { + @Run(test = "test13") + public void test13_verifier() { Asserts.assertEQ(test13(), rI); } @@ -358,8 +425,8 @@ public int test14(MyValue1[] va, int index) { return va[index].x; } - @DontCompile - public void test14_verifier(boolean warmup) { + @Run(test = "test14") + public void test14_verifier() { int arraySize = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[arraySize]; @@ -394,8 +461,8 @@ public int test15() { } } - @DontCompile - public void test15_verifier(boolean warmup) { + @Run(test = "test15") + public void test15_verifier() { Asserts.assertEQ(test15(), rI); } @@ -415,8 +482,8 @@ public int test16() { } } - @DontCompile - public void test16_verifier(boolean warmup) { + @Run(test = "test16") + public void test16_verifier() { Asserts.assertEQ(test16(), rI); } @@ -427,8 +494,8 @@ public int test17(MyValue1[] va, int index, MyValue1 vt) { return va[index].x; } - @DontCompile - public void test17_verifier(boolean warmup) { + @Run(test = "test17") + public void test17_verifier() { int arraySize = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[arraySize]; @@ -458,8 +525,8 @@ public MyValue1[] test18(MyValue1[] va) { return va.clone(); } - @DontCompile - public void test18_verifier(boolean warmup) { + @Run(test = "test18") + public void test18_verifier() { int len = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[len]; for (int i = 0; i < len; ++i) { @@ -485,8 +552,8 @@ public MyValue1[] test19() { return va.clone(); } - @DontCompile - public void test19_verifier(boolean warmup) { + @Run(test = "test19") + public void test19_verifier() { MyValue1[] result = test19(); for (int i = 0; i < test19_orig.length; ++i) { Asserts.assertEQ(result[i].hash(), test19_orig[i].hash()); @@ -499,8 +566,8 @@ public void test20(MyValue1[] src, MyValue1[] dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test20_verifier(boolean warmup) { + @Run(test = "test20") + public void test20_verifier() { int len = Math.abs(rI) % 10; MyValue1[] src = new MyValue1[len]; MyValue1[] dst = new MyValue1[len]; @@ -519,8 +586,8 @@ public void test21(MyValue2[] src, MyValue2[] dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test21_verifier(boolean warmup) { + @Run(test = "test21") + public void test21_verifier() { int len = Math.abs(rI) % 10; MyValue2[] src = new MyValue2[len]; MyValue2[] dst = new MyValue2[len]; @@ -542,8 +609,8 @@ public MyValue1[] test22(MyValue1[] src) { return dst; } - @DontCompile - public void test22_verifier(boolean warmup) { + @Run(test = "test22") + public void test22_verifier() { int len = Math.abs(rI) % 10; MyValue1[] src = new MyValue1[len]; for (int i = 0; i < len; ++i) { @@ -564,8 +631,8 @@ public MyValue1[] test23(MyValue1[] src) { return dst; } - @DontCompile - public void test23_verifier(boolean warmup) { + @Run(test = "test23") + public void test23_verifier() { int len = Math.abs(rI) % 10; MyValue1[] src = new MyValue1[len]; for (int i = 0; i < len; ++i) { @@ -583,8 +650,8 @@ public void test24(MyValue1[] src, Object dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test24_verifier(boolean warmup) { + @Run(test = "test24") + public void test24_verifier() { int len = Math.abs(rI) % 10; MyValue1[] src = new MyValue1[len]; MyValue1[] dst1 = new MyValue1[len]; @@ -608,8 +675,8 @@ public void test25(MyValue2[] src, MyValue2[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test25_verifier(boolean warmup) { + @Run(test = "test25") + public void test25_verifier() { MyValue2[] src = new MyValue2[8]; MyValue2[] dst = new MyValue2[8]; for (int i = 0; i < 8; ++i) { @@ -627,8 +694,8 @@ public void test26(MyValue1[] src, MyValue1[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test26_verifier(boolean warmup) { + @Run(test = "test26") + public void test26_verifier() { MyValue1[] src = new MyValue1[8]; MyValue1[] dst = new MyValue1[8]; for (int i = 0; i < 8; ++i) { @@ -646,8 +713,8 @@ public void test27(MyValue1[] src, MyValue1[] dst) { System.arraycopy(src, 1, dst, 2, 6); } - @DontCompile - public void test27_verifier(boolean warmup) { + @Run(test = "test27") + public void test27_verifier() { MyValue1[] src = new MyValue1[8]; MyValue1[] dst = new MyValue1[8]; for (int i = 0; i < 8; ++i) { @@ -661,8 +728,9 @@ public void test27_verifier(boolean warmup) { // non escaping allocations // TODO 8252027: Make sure this is optimized with ZGC - @Test(valid = ZGCOff, failOn = ALLOCA + LOOP + LOAD + TRAP) - @Test(valid = ZGCOn) + @Test + @IR(applyIf = {"UseZGC", "false"}, + failOn = {ALLOCA, LOOP, LOAD, TRAP}) public MyValue2 test28() { MyValue2[] src = new MyValue2[10]; src[0] = MyValue2.createWithFieldsInline(rI, rD); @@ -670,8 +738,8 @@ public MyValue2 test28() { return dst[0]; } - @DontCompile - public void test28_verifier(boolean warmup) { + @Run(test = "test28") + public void test28_verifier() { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); MyValue2 result = test28(); Asserts.assertEQ(result.hash(), v.hash()); @@ -680,16 +748,19 @@ public void test28_verifier(boolean warmup) { // non escaping allocations // TODO 8227588: shouldn't this have the same IR matching rules as test6? // @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP) - @Test(valid = InlineTypeArrayFlattenOn, failOn = ALLOCA + LOOP + LOAD + TRAP) - @Test(valid = InlineTypeArrayFlattenOff, failOn = ALLOCA + LOOP + TRAP) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + failOn = {ALLOCA, LOOP, LOAD, TRAP}) + @IR(applyIf = {"FlatArrayElementMaxSize", "!= -1"}, + failOn = {ALLOCA, LOOP, TRAP}) public MyValue2 test29(MyValue2[] src) { MyValue2[] dst = new MyValue2[10]; System.arraycopy(src, 0, dst, 0, 10); return dst[0]; } - @DontCompile - public void test29_verifier(boolean warmup) { + @Run(test = "test29") + public void test29_verifier() { MyValue2[] src = new MyValue2[10]; for (int i = 0; i < 10; ++i) { src[i] = MyValue2.createWithFieldsInline(rI+i, rD+i); @@ -701,7 +772,6 @@ public void test29_verifier(boolean warmup) { // non escaping allocation with uncommon trap that needs // eliminated inline type array element as debug info @Test - @Warmup(10000) public MyValue2 test30(MyValue2[] src, boolean flag) { MyValue2[] dst = new MyValue2[10]; System.arraycopy(src, 0, dst, 0, 10); @@ -709,19 +779,22 @@ public MyValue2 test30(MyValue2[] src, boolean flag) { return dst[0]; } - @DontCompile - public void test30_verifier(boolean warmup) { + @Run(test = "test30") + @Warmup(10000) + public void test30_verifier(RunInfo info) { MyValue2[] src = new MyValue2[10]; for (int i = 0; i < 10; ++i) { src[i] = MyValue2.createWithFieldsInline(rI+i, rD+i); } - MyValue2 v = test30(src, !warmup); + MyValue2 v = test30(src, !info.isWarmUp()); Asserts.assertEQ(src[0].hash(), v.hash()); } + // non escaping allocation with memory phi - @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP) - public long test31(boolean b, boolean deopt) { + @Test + @IR(failOn = {ALLOC, ALLOCA, LOOP, LOAD, STORE, TRAP}) + public long test31(boolean b, boolean deopt, Method m) { MyValue2[] src = new MyValue2[1]; if (b) { src[0] = MyValue2.createWithFieldsInline(rI, rD); @@ -730,18 +803,18 @@ public long test31(boolean b, boolean deopt) { } if (deopt) { // uncommon trap - WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test31")); + TestFramework.deoptimize(m); } return src[0].hash(); } - @DontCompile - public void test31_verifier(boolean warmup) { + @Run(test = "test31") + public void test31_verifier(RunInfo info) { MyValue2 v1 = MyValue2.createWithFieldsInline(rI, rD); - long result1 = test31(true, !warmup); + long result1 = test31(true, !info.isWarmUp(), info.getTest()); Asserts.assertEQ(result1, v1.hash()); - MyValue2 v2 = MyValue2.createWithFieldsInline(rI+1, rD+1); - long result2 = test31(false, !warmup); + MyValue2 v2 = MyValue2.createWithFieldsInline(rI + 1, rD + 1); + long result2 = test31(false, !info.isWarmUp(), info.getTest()); Asserts.assertEQ(result2, v2.hash()); } @@ -752,8 +825,8 @@ public Object[] test32(Object[] va) { return va.clone(); } - @DontCompile - public void test32_verifier(boolean warmup) { + @Run(test = "test32") + public void test32_verifier() { int len = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[len]; for (int i = 0; i < len; ++i) { @@ -770,8 +843,8 @@ public Object[] test33(Object[] va) { return va.clone(); } - @DontCompile - public void test33_verifier(boolean warmup) { + @Run(test = "test33") + public void test33_verifier() { int len = Math.abs(rI) % 10; Object[] va = new Object[len]; for (int i = 0; i < len; ++i) { @@ -809,8 +882,8 @@ public Object[] test34(boolean flag) { return va.clone(); } - @DontCompile - public void test34_verifier(boolean warmup) { + @Run(test = "test34") + public void test34_verifier(RunInfo info) { test34(false); for (int i = 0; i < 10; i++) { // make sure we do deopt Object[] result = test34(true); @@ -823,7 +896,7 @@ public void test34_verifier(boolean warmup) { // Expected } } - if (compile_and_run_again_if_deoptimized(warmup, "TestArrays::test34")) { + if (compile_and_run_again_if_deoptimized(info)) { Object[] result = test34(true); verify(test34_orig, result); // Check that array has correct properties (null-free) @@ -836,64 +909,14 @@ public void test34_verifier(boolean warmup) { } } - static void verify(Object[] src, Object[] dst) { - if (src instanceof MyInterface[] && dst instanceof MyInterface[]) { - for (int i = 0; i < src.length; ++i) { - Asserts.assertEQ(((MyInterface)src[i]).hash(), ((MyInterface)dst[i]).hash()); - } - } else { - for (int i = 0; i < src.length; ++i) { - Asserts.assertEQ(src[i], dst[i]); - } - } - } - - static void verify(MyValue1[] src, MyValue1[] dst) { - for (int i = 0; i < src.length; ++i) { - Asserts.assertEQ(src[i].hash(), dst[i].hash()); - } - } - - static void verify(MyValue1[] src, Object[] dst) { - for (int i = 0; i < src.length; ++i) { - Asserts.assertEQ(src[i].hash(), ((MyInterface)dst[i]).hash()); - } - } - - static void verify(MyValue2[] src, MyValue2[] dst) { - for (int i = 0; i < src.length; ++i) { - Asserts.assertEQ(src[i].hash(), dst[i].hash()); - } - } - - static void verify(MyValue2[] src, Object[] dst) { - for (int i = 0; i < src.length; ++i) { - Asserts.assertEQ(src[i].hash(), ((MyInterface)dst[i]).hash()); - } - } - - static boolean compile_and_run_again_if_deoptimized(boolean warmup, String test) { - if (!warmup) { - Method m = tests.get(test); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false)) { - if (!InlineTypeArrayFlatten && !XCOMP && !STRESS_CC) { - throw new RuntimeException("Unexpected deoptimization"); - } - enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); - return true; - } - } - return false; - } - // arraycopy() of inline type array of unknown size @Test public void test35(Object src, Object dst, int len) { System.arraycopy(src, 0, dst, 0, len); } - @DontCompile - public void test35_verifier(boolean warmup) { + @Run(test = "test35") + public void test35_verifier(RunInfo info) { int len = Math.abs(rI) % 10; MyValue1[] src = new MyValue1[len]; MyValue1[] dst1 = new MyValue1[len]; @@ -905,7 +928,7 @@ public void test35_verifier(boolean warmup) { verify(src, dst1); test35(src, dst2, src.length); verify(src, dst2); - if (compile_and_run_again_if_deoptimized(warmup, "TestArrays::test35")) { + if (compile_and_run_again_if_deoptimized(info)) { test35(src, dst1, src.length); verify(src, dst1); } @@ -916,8 +939,8 @@ public void test36(Object src, MyValue2[] dst) { System.arraycopy(src, 0, dst, 0, dst.length); } - @DontCompile - public void test36_verifier(boolean warmup) { + @Run(test = "test36") + public void test36_verifier(RunInfo info) { int len = Math.abs(rI) % 10; MyValue2[] src = new MyValue2[len]; MyValue2[] dst = new MyValue2[len]; @@ -926,7 +949,7 @@ public void test36_verifier(boolean warmup) { } test36(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestArrays::test36")) { + if (compile_and_run_again_if_deoptimized(info)) { test36(src, dst); verify(src, dst); } @@ -937,8 +960,8 @@ public void test37(MyValue2[] src, Object dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test37_verifier(boolean warmup) { + @Run(test = "test37") + public void test37_verifier(RunInfo info) { int len = Math.abs(rI) % 10; MyValue2[] src = new MyValue2[len]; MyValue2[] dst = new MyValue2[len]; @@ -947,20 +970,20 @@ public void test37_verifier(boolean warmup) { } test37(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestArrays::test37")) { + if (compile_and_run_again_if_deoptimized(info)) { test37(src, dst); verify(src, dst); } } @Test - @Warmup(1) // Avoid early compilation public void test38(Object src, MyValue2[] dst) { System.arraycopy(src, 0, dst, 0, dst.length); } - @DontCompile - public void test38_verifier(boolean warmup) { + @Run(test = "test38") + @Warmup(1) // Avoid early compilation + public void test38_verifier(RunInfo info) { int len = Math.abs(rI) % 10; Object[] src = new Object[len]; MyValue2[] dst = new MyValue2[len]; @@ -969,15 +992,13 @@ public void test38_verifier(boolean warmup) { } test38(src, dst); verify(dst, src); - if (!warmup) { - Method m = tests.get("TestArrays::test38"); - assertDeoptimizedByC2(m); - enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertDeoptimizedByC2(m); + TestFramework.compile(m, CompLevel.C2); test38(src, dst); verify(dst, src); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false) && !XCOMP && !STRESS_CC) { - throw new RuntimeException("unexpected deoptimization"); - } + TestFramework.assertCompiledByC2(m); } } @@ -986,8 +1007,8 @@ public void test39(MyValue2[] src, Object dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test39_verifier(boolean warmup) { + @Run(test = "test39") + public void test39_verifier(RunInfo info) { int len = Math.abs(rI) % 10; MyValue2[] src = new MyValue2[len]; Object[] dst = new Object[len]; @@ -996,20 +1017,20 @@ public void test39_verifier(boolean warmup) { } test39(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestArrays::test39")) { + if (compile_and_run_again_if_deoptimized(info)) { test39(src, dst); verify(src, dst); } } @Test - @Warmup(1) // Avoid early compilation public void test40(Object[] src, Object dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test40_verifier(boolean warmup) { + @Run(test = "test40") + @Warmup(1) // Avoid early compilation + public void test40_verifier(RunInfo info) { int len = Math.abs(rI) % 10; Object[] src = new Object[len]; MyValue2[] dst = new MyValue2[len]; @@ -1018,15 +1039,13 @@ public void test40_verifier(boolean warmup) { } test40(src, dst); verify(dst, src); - if (!warmup) { - Method m = tests.get("TestArrays::test40"); - assertDeoptimizedByC2(m); - enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertDeoptimizedByC2(m); + TestFramework.compile(m, CompLevel.C2); test40(src, dst); verify(dst, src); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false) && !XCOMP && !STRESS_CC) { - throw new RuntimeException("unexpected deoptimization"); - } + TestFramework.assertCompiledByC2(m); } } @@ -1035,8 +1054,8 @@ public void test41(Object src, Object[] dst) { System.arraycopy(src, 0, dst, 0, dst.length); } - @DontCompile - public void test41_verifier(boolean warmup) { + @Run(test = "test41") + public void test41_verifier(RunInfo info) { int len = Math.abs(rI) % 10; MyValue2[] src = new MyValue2[len]; Object[] dst = new Object[len]; @@ -1045,7 +1064,7 @@ public void test41_verifier(boolean warmup) { } test41(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestArrays::test41")) { + if (compile_and_run_again_if_deoptimized(info)) { test41(src, dst); verify(src, dst); } @@ -1056,8 +1075,8 @@ public void test42(Object[] src, Object[] dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test42_verifier(boolean warmup) { + @Run(test = "test42") + public void test42_verifier(RunInfo info) { int len = Math.abs(rI) % 10; Object[] src = new Object[len]; Object[] dst = new Object[len]; @@ -1066,11 +1085,8 @@ public void test42_verifier(boolean warmup) { } test42(src, dst); verify(src, dst); - if (!warmup) { - Method m = tests.get("TestArrays::test42"); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false) && !XCOMP && !STRESS_CC) { - throw new RuntimeException("unexpected deoptimization"); - } + if (!info.isWarmUp()) { + TestFramework.assertCompiledByC2(info.getTest()); } } @@ -1080,8 +1096,8 @@ public void test43(Object src, Object dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test43_verifier(boolean warmup) { + @Run(test = "test43") + public void test43_verifier(RunInfo info) { MyValue1[] src = new MyValue1[8]; MyValue1[] dst = new MyValue1[8]; for (int i = 0; i < 8; ++i) { @@ -1089,7 +1105,7 @@ public void test43_verifier(boolean warmup) { } test43(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestArrays::test43")) { + if (compile_and_run_again_if_deoptimized(info)) { test43(src, dst); verify(src, dst); } @@ -1100,8 +1116,8 @@ public void test44(Object src, MyValue2[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test44_verifier(boolean warmup) { + @Run(test = "test44") + public void test44_verifier(RunInfo info) { MyValue2[] src = new MyValue2[8]; MyValue2[] dst = new MyValue2[8]; for (int i = 0; i < 8; ++i) { @@ -1109,7 +1125,7 @@ public void test44_verifier(boolean warmup) { } test44(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestArrays::test44")) { + if (compile_and_run_again_if_deoptimized(info)) { test44(src, dst); verify(src, dst); } @@ -1120,8 +1136,8 @@ public void test45(MyValue2[] src, Object dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test45_verifier(boolean warmup) { + @Run(test = "test45") + public void test45_verifier(RunInfo info) { MyValue2[] src = new MyValue2[8]; MyValue2[] dst = new MyValue2[8]; for (int i = 0; i < 8; ++i) { @@ -1129,20 +1145,20 @@ public void test45_verifier(boolean warmup) { } test45(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestArrays::test45")) { + if (compile_and_run_again_if_deoptimized(info)) { test45(src, dst); verify(src, dst); } } @Test - @Warmup(1) // Avoid early compilation public void test46(Object[] src, MyValue2[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test46_verifier(boolean warmup) { + @Run(test = "test46") + @Warmup(1) // Avoid early compilation + public void test46_verifier(RunInfo info) { Object[] src = new Object[8]; MyValue2[] dst = new MyValue2[8]; for (int i = 0; i < 8; ++i) { @@ -1150,15 +1166,13 @@ public void test46_verifier(boolean warmup) { } test46(src, dst); verify(dst, src); - if (!warmup) { - Method m = tests.get("TestArrays::test46"); - assertDeoptimizedByC2(m); - enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertDeoptimizedByC2(m); + TestFramework.compile(m, CompLevel.C2); test46(src, dst); verify(dst, src); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false) && !XCOMP && !STRESS_CC) { - throw new RuntimeException("unexpected deoptimization"); - } + TestFramework.assertCompiledByC2(m); } } @@ -1167,8 +1181,8 @@ public void test47(MyValue2[] src, Object[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test47_verifier(boolean warmup) { + @Run(test = "test47") + public void test47_verifier(RunInfo info) { MyValue2[] src = new MyValue2[8]; Object[] dst = new Object[8]; for (int i = 0; i < 8; ++i) { @@ -1176,20 +1190,20 @@ public void test47_verifier(boolean warmup) { } test47(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestArrays::test47")) { + if (compile_and_run_again_if_deoptimized(info)) { test47(src, dst); verify(src, dst); } } @Test - @Warmup(1) // Avoid early compilation public void test48(Object[] src, Object dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test48_verifier(boolean warmup) { + @Run(test = "test48") + @Warmup(1) // Avoid early compilation + public void test48_verifier(RunInfo info) { Object[] src = new Object[8]; MyValue2[] dst = new MyValue2[8]; for (int i = 0; i < 8; ++i) { @@ -1197,15 +1211,13 @@ public void test48_verifier(boolean warmup) { } test48(src, dst); verify(dst, src); - if (!warmup) { - Method m = tests.get("TestArrays::test48"); - assertDeoptimizedByC2(m); - enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertDeoptimizedByC2(m); + TestFramework.compile(m, CompLevel.C2); test48(src, dst); verify(dst, src); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false) && !XCOMP && !STRESS_CC) { - throw new RuntimeException("unexpected deoptimization"); - } + TestFramework.assertCompiledByC2(m); } } @@ -1214,8 +1226,8 @@ public void test49(Object src, Object[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test49_verifier(boolean warmup) { + @Run(test = "test49") + public void test49_verifier(RunInfo info) { MyValue2[] src = new MyValue2[8]; Object[] dst = new Object[8]; for (int i = 0; i < 8; ++i) { @@ -1223,7 +1235,7 @@ public void test49_verifier(boolean warmup) { } test49(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestArrays::test49")) { + if (compile_and_run_again_if_deoptimized(info)) { test49(src, dst); verify(src, dst); } @@ -1234,8 +1246,8 @@ public void test50(Object[] src, Object[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test50_verifier(boolean warmup) { + @Run(test = "test50") + public void test50_verifier(RunInfo info) { Object[] src = new Object[8]; Object[] dst = new Object[8]; for (int i = 0; i < 8; ++i) { @@ -1243,11 +1255,9 @@ public void test50_verifier(boolean warmup) { } test50(src, dst); verify(src, dst); - if (!warmup) { - Method m = tests.get("TestArrays::test50"); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false) && !XCOMP && !STRESS_CC) { - throw new RuntimeException("unexpected deoptimization"); - } + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); } } @@ -1257,8 +1267,8 @@ public MyValue1[] test51(MyValue1[] va) { return (MyValue1[]) res; } - @DontCompile - public void test51_verifier(boolean warmup) { + @Run(test = "test51") + public void test51_verifier() { int len = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[len]; for (int i = 0; i < len; ++i) { @@ -1276,8 +1286,8 @@ public MyValue1[] test52() { return (MyValue1[]) res; } - @DontCompile - public void test52_verifier(boolean warmup) { + @Run(test = "test52") + public void test52_verifier() { for (int i = 0; i < 8; ++i) { test52_va[i] = MyValue1.createWithFieldsInline(rI, rL); } @@ -1291,8 +1301,8 @@ public MyValue1[] test53(Object[] va) { return (MyValue1[]) res; } - @DontCompile - public void test53_verifier(boolean warmup) { + @Run(test = "test53") + public void test53_verifier() { int len = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[len]; for (int i = 0; i < len; ++i) { @@ -1307,8 +1317,8 @@ public Object[] test54(MyValue1[] va) { return Arrays.copyOf(va, va.length, Object[].class); } - @DontCompile - public void test54_verifier(boolean warmup) { + @Run(test = "test54") + public void test54_verifier() { int len = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[len]; for (int i = 0; i < len; ++i) { @@ -1323,8 +1333,8 @@ public Object[] test55(Object[] va) { return Arrays.copyOf(va, va.length, Object[].class); } - @DontCompile - public void test55_verifier(boolean warmup) { + @Run(test = "test55") + public void test55_verifier() { int len = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[len]; for (int i = 0; i < len; ++i) { @@ -1340,8 +1350,8 @@ public MyValue1[] test56(Object[] va) { return (MyValue1[]) res; } - @DontCompile - public void test56_verifier(boolean warmup) { + @Run(test = "test56") + public void test56_verifier() { int len = Math.abs(rI) % 10; Object[] va = new Object[len]; for (int i = 0; i < len; ++i) { @@ -1351,13 +1361,13 @@ public void test56_verifier(boolean warmup) { verify(result, va); } - @Test + @Test public Object[] test57(Object[] va, Class klass) { return Arrays.copyOf(va, va.length, klass); } - @DontCompile - public void test57_verifier(boolean warmup) { + @Run(test = "test57") + public void test57_verifier() { int len = Math.abs(rI) % 10; Object[] va = new MyValue1[len]; for (int i = 0; i < len; ++i) { @@ -1372,8 +1382,8 @@ public Object[] test58(MyValue1[] va, Class klass) { return Arrays.copyOf(va, va.length, klass); } - @DontCompile - public void test58_verifier(boolean warmup) { + @Run(test = "test58") + public void test58_verifier(RunInfo info) { int len = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[len]; for (int i = 0; i < len; ++i) { @@ -1383,7 +1393,7 @@ public void test58_verifier(boolean warmup) { Object[] result = test58(va, MyValue1[].class); verify(va, result); } - if (compile_and_run_again_if_deoptimized(warmup, "TestArrays::test58")) { + if (compile_and_run_again_if_deoptimized(info)) { Object[] result = test58(va, MyValue1[].class); verify(va, result); } @@ -1394,8 +1404,8 @@ public Object[] test59(MyValue1[] va) { return Arrays.copyOf(va, va.length+1, MyValue1[].class); } - @DontCompile - public void test59_verifier(boolean warmup) { + @Run(test = "test59") + public void test59_verifier() { int len = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[len]; MyValue1[] verif = new MyValue1[len+1]; @@ -1412,8 +1422,8 @@ public Object[] test60(Object[] va, Class klass) { return Arrays.copyOf(va, va.length+1, klass); } - @DontCompile - public void test60_verifier(boolean warmup) { + @Run(test = "test60") + public void test60_verifier() { int len = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[len]; MyValue1[] verif = new MyValue1[len+1]; @@ -1430,8 +1440,8 @@ public Object[] test61(Object[] va, Class klass) { return Arrays.copyOf(va, va.length+1, klass); } - @DontCompile - public void test61_verifier(boolean warmup) { + @Run(test = "test61") + public void test61_verifier() { int len = Math.abs(rI) % 10; Object[] va = new Integer[len]; for (int i = 0; i < len; ++i) { @@ -1464,8 +1474,8 @@ public Object[] test62(MyValue1[] va, Integer[] oa) { return Arrays.copyOf(arr, arr.length+1, arr.getClass()); } - @DontCompile - public void test62_verifier(boolean warmup) { + @Run(test = "test62") + public void test62_verifier() { int len = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[len]; Integer[] oa = new Integer[len]; @@ -1500,8 +1510,8 @@ public Object[] test63(MyValue1[] va, Integer[] oa) { return Arrays.copyOf(arr, arr.length+1, arr.getClass()); } - @DontCompile - public void test63_verifier(boolean warmup) { + @Run(test = "test63") + public void test63_verifier() { int len = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[len]; MyValue1[] verif = new MyValue1[len+1]; @@ -1521,8 +1531,8 @@ public MyValue1[] test64() { return new MyValue1[8]; } - @DontCompile - public void test64_verifier(boolean warmup) { + @Run(test = "test64") + public void test64_verifier() { MyValue1[] va = new MyValue1[8]; MyValue1[] var = test64(); for (int i = 0; i < 8; ++i) { @@ -1536,8 +1546,8 @@ public MyValue1[] test65() { return new MyValue1[32]; } - @DontCompile - public void test65_verifier(boolean warmup) { + @Run(test = "test65") + public void test65_verifier() { MyValue1[] va = new MyValue1[32]; MyValue1[] var = test65(); for (int i = 0; i < 32; ++i) { @@ -1546,15 +1556,16 @@ public void test65_verifier(boolean warmup) { } // Check init store elimination - @Test(match = { ALLOCA }, matchCount = { 1 }) + @Test + @IR(counts = {ALLOCA, "= 1"}) public MyValue1[] test66(MyValue1 vt) { MyValue1[] va = new MyValue1[1]; va[0] = vt; return va; } - @DontCompile - public void test66_verifier(boolean warmup) { + @Run(test = "test66") + public void test66_verifier() { MyValue1 vt = MyValue1.createWithFieldsDontInline(rI, rL); MyValue1[] va = test66(vt); Asserts.assertEQ(va[0].hashPrimitive(), vt.hashPrimitive()); @@ -1568,8 +1579,8 @@ public MyValue1[] test67(MyValue1[] src) { return dst; } - @DontCompile - public void test67_verifier(boolean warmup) { + @Run(test = "test67") + public void test67_verifier() { MyValue1[] va = new MyValue1[16]; MyValue1[] var = test67(va); for (int i = 0; i < 16; ++i) { @@ -1585,8 +1596,8 @@ public MyValue1[] test68() { return va; } - @DontCompile - public void test68_verifier(boolean warmup) { + @Run(test = "test68") + public void test68_verifier() { MyValue1[] va = new MyValue1[2]; MyValue1[] var = test68(); for (int i = 0; i < 2; ++i) { @@ -1603,8 +1614,8 @@ public MyValue1[] test69(MyValue1 vt) { return va; } - @DontCompile - public void test69_verifier(boolean warmup) { + @Run(test = "test69") + public void test69_verifier() { MyValue1 vt = MyValue1.createWithFieldsDontInline(rI, rL); MyValue1[] va = new MyValue1[4]; va[0] = vt; @@ -1626,8 +1637,8 @@ public MyValue1[] test70(MyValue1[] other) { return va; } - @DontCompile - public void test70_verifier(boolean warmup) { + @Run(test = "test70") + public void test70_verifier() { MyValue1[] va = new MyValue1[2]; MyValue1[] var = test70(va); for (int i = 0; i < 2; ++i) { @@ -1650,8 +1661,8 @@ public void test71() { } } - @DontCompile - public void test71_verifier(boolean warmup) { + @Run(test = "test71") + public void test71_verifier() { test71(); } @@ -1667,8 +1678,8 @@ public void test72(Object[] o, boolean b, Object element) { arr2[0] = element; } - @DontCompile - public void test72_verifier(boolean warmup) { + @Run(test = "test72") + public void test72_verifier() { Object[] arr = new Object[1]; Object elem = new Object(); test72(arr, true, elem); @@ -1686,8 +1697,8 @@ public void test73(Object[] oa, MyValue1 v, Object o) { oa[0] = oa; // The stored value is known to be not flattenable (an Object[]) } - @DontCompile - public void test73_verifier(boolean warmup) { + @Run(test = "test73") + public void test73_verifier() { MyValue1 v0 = MyValue1.createWithFieldsDontInline(rI, rL); MyValue1 v1 = MyValue1.createWithFieldsDontInline(rI+1, rL+1); MyValue1[] arr = new MyValue1[3]; @@ -1706,13 +1717,13 @@ public static void test74Callee(MyValue1[] va) { } // Tests invoking unloaded method with inline type array in signature @Test - @Warmup(0) public void test74(MethodHandle m, MyValue1[] va) throws Throwable { m.invoke(va); } - @DontCompile - public void test74_verifier(boolean warmup) throws Throwable { + @Run(test = "test74") + @Warmup(0) + public void test74_verifier() throws Throwable { MethodHandle m = MethodHandles.lookup().findStatic(TestArrays.class, "test74Callee", MethodType.methodType(void.class, MyValue1[].class)); MyValue1[] va = new MyValue1[0]; test74(m, va); @@ -1739,8 +1750,8 @@ public Object[] test75(MyValue1[] va, Integer[] oa) { return arr.clone(); } - @DontCompile - public void test75_verifier(boolean warmup) { + @Run(test = "test75") + public void test75_verifier() { int len = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[len]; Integer[] oa = new Integer[len]; @@ -1777,8 +1788,8 @@ public Object[] test76(MyValue1[] va, Integer[] oa) { return arr.clone(); } - @DontCompile - public void test76_verifier(boolean warmup) { + @Run(test = "test76") + public void test76_verifier() { int len = Math.abs(rI) % 10; MyValue1[] va = new MyValue1[len]; MyValue1[] verif = new MyValue1[len]; @@ -1817,8 +1828,8 @@ public void test77() { } - @DontCompile - public void test77_verifier(boolean warmup) { + @Run(test = "test77") + public void test77_verifier() { test77(); } @@ -1837,23 +1848,26 @@ public long test78(MyValue1 v, int n) { return x; } - @DontCompile - public void test78_verifier(boolean warmup) { + @Run(test = "test78") + public void test78_verifier() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); Asserts.assertEQ(test78(v, 1), v.hash()); } // Verify that casting an array element to a non-flattenable type marks the array as not-flat - @Test(valid = InlineTypeArrayFlattenOn, match = { ALLOC_G, LOAD_UNKNOWN_INLINE }, matchCount = { 1, 1 }) - @Test(valid = InlineTypeArrayFlattenOff, failOn = ALLOC_G + ALLOCA_G + LOAD_UNKNOWN_INLINE) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + counts = {ALLOC_G, "= 1", LOAD_UNKNOWN_INLINE, "= 1"}) + @IR(applyIf = {"FlatArrayElementMaxSize", "!= -1"}, + failOn = {ALLOC_G, ALLOCA_G, LOAD_UNKNOWN_INLINE}) public Object test79(Object[] array, int i) { Integer i1 = (Integer)array[0]; Object o = array[1]; return array[i]; } - @DontCompile - public void test79_verifier(boolean warmup) { + @Run(test = "test79") + public void test79_verifier() { Integer i = Integer.valueOf(rI); Integer[] array = new Integer[2]; array[1] = i; @@ -1861,26 +1875,20 @@ public void test79_verifier(boolean warmup) { Asserts.assertEquals(result, i); } - primitive static class NotFlattenable { - private final Object o1 = null; - private final Object o2 = null; - private final Object o3 = null; - private final Object o4 = null; - private final Object o5 = null; - private final Object o6 = null; - } - // Same as test79 but with not-flattenable inline type - @Test(valid = InlineTypeArrayFlattenOn, match = { ALLOC_G, LOAD_UNKNOWN_INLINE }, matchCount = { 1, 1 }) - @Test(valid = InlineTypeArrayFlattenOff, failOn = ALLOC_G + ALLOCA_G + LOAD_UNKNOWN_INLINE) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + counts = {ALLOC_G, "= 1", LOAD_UNKNOWN_INLINE, "= 1"}) + @IR(applyIf = {"FlatArrayElementMaxSize", "!= -1"}, + failOn = {ALLOC_G, ALLOCA_G, LOAD_UNKNOWN_INLINE}) public Object test80(Object[] array, int i) { NotFlattenable vt = (NotFlattenable)array[0]; Object o = array[1]; return array[i]; } - @DontCompile - public void test80_verifier(boolean warmup) { + @Run(test = "test80") + public void test80_verifier() { NotFlattenable vt = new NotFlattenable(); NotFlattenable[] array = new NotFlattenable[2]; array[1] = vt; @@ -1889,7 +1897,8 @@ public void test80_verifier(boolean warmup) { } // Verify that writing an object of a non-inline, non-null type to an array marks the array as not-null-free and not-flat - @Test(failOn = ALLOC_G + ALLOCA_G + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD) + @Test + @IR(failOn = {ALLOC_G, ALLOCA_G, LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}) public Object test81(Object[] array, Integer v, Object o, int i) { if (v == null) { return null; @@ -1900,8 +1909,8 @@ public Object test81(Object[] array, Integer v, Object o, int i) { return array[i]; } - @DontCompile - public void test81_verifier(boolean warmup) { + @Run(test = "test81") + public void test81_verifier() { Integer i = Integer.valueOf(rI); Integer[] array1 = new Integer[3]; Object[] array2 = new Object[3]; @@ -1918,8 +1927,11 @@ public void test81_verifier(boolean warmup) { } // Verify that writing an object of a non-flattenable inline type to an array marks the array as not-flat - @Test(valid = InlineTypePassFieldsAsArgsOn, failOn = ALLOCA_G + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE) - @Test(valid = InlineTypePassFieldsAsArgsOff, failOn = ALLOC_G + ALLOCA_G + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE) + @Test + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "true"}, + failOn = {ALLOCA_G, LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE}) + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "false"}, + failOn = {ALLOC_G, ALLOCA_G, LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE}) public Object test82(Object[] array, NotFlattenable vt, Object o, int i) { array[0] = vt; array[1] = array[0]; @@ -1927,8 +1939,8 @@ public Object test82(Object[] array, NotFlattenable vt, Object o, int i) { return array[i]; } - @DontCompile - public void test82_verifier(boolean warmup) { + @Run(test = "test82") + public void test82_verifier() { NotFlattenable vt = new NotFlattenable(); NotFlattenable[] array1 = new NotFlattenable[3]; Object[] array2 = new Object[3]; @@ -1945,15 +1957,19 @@ public void test82_verifier(boolean warmup) { } // Verify that casting an array element to a non-inline type type marks the array as not-null-free and not-flat - @Test(valid = InlineTypeArrayFlattenOn, match = { ALLOC_G, LOAD_UNKNOWN_INLINE }, matchCount = { 1, 1 }, failOn = ALLOCA_G + STORE_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD) - @Test(valid = InlineTypeArrayFlattenOff, failOn = ALLOC_G + ALLOCA_G + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + counts = {ALLOC_G, "= 1", LOAD_UNKNOWN_INLINE, "= 1"}, + failOn = {ALLOCA_G, STORE_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}) + @IR(applyIf = {"FlatArrayElementMaxSize", "!= -1"}, + failOn = {ALLOC_G, ALLOCA_G, LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}) public void test83(Object[] array, Object o) { Integer i = (Integer)array[0]; array[1] = o; } - @DontCompile - public void test83_verifier(boolean warmup) { + @Run(test = "test83") + public void test83_verifier() { Integer i = Integer.valueOf(rI); Integer[] array1 = new Integer[2]; Object[] array2 = new Object[2]; @@ -1964,15 +1980,17 @@ public void test83_verifier(boolean warmup) { } // Verify that writing constant null into an array marks the array as not-null-free and not-flat - @Test(failOn = ALLOC_G + ALLOCA_G + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE, match = { INLINE_ARRAY_NULL_GUARD }, matchCount = { 1 }) + @Test + @IR(failOn = {ALLOC_G, ALLOCA_G, LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE}, + counts = {INLINE_ARRAY_NULL_GUARD, "= 1"}) public Object test84(Object[] array, int i) { array[0] = null; array[1] = null; return array[i]; } - @DontCompile - public void test84_verifier(boolean warmup) { + @Run(test = "test84") + public void test84_verifier(RunInfo info) { NotFlattenable.ref[] array1 = new NotFlattenable.ref[2]; Object[] array2 = new Object[2]; Object result = test84(array1, 0); @@ -1981,7 +1999,7 @@ public void test84_verifier(boolean warmup) { result = test84(array2, 1); Asserts.assertEquals(array2[0], null); Asserts.assertEquals(result, null); - if (!warmup) { + if (!info.isWarmUp()) { NotFlattenable[] array3 = new NotFlattenable[2]; try { test84(array3, 1); @@ -1993,7 +2011,9 @@ public void test84_verifier(boolean warmup) { } // Same as test84 but with branches - @Test(failOn = ALLOC_G + ALLOCA_G + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE, match = { INLINE_ARRAY_NULL_GUARD }, matchCount = { 2 }) + @Test + @IR(failOn = {ALLOC_G, ALLOCA_G, LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE}, + counts = {INLINE_ARRAY_NULL_GUARD, "= 2"}) public void test85(Object[] array, Object o, boolean b) { if (b) { array[0] = null; @@ -2003,8 +2023,8 @@ public void test85(Object[] array, Object o, boolean b) { array[1] = o; } - @DontCompile - public void test85_verifier(boolean warmup) { + @Run(test = "test85") + public void test85_verifier(RunInfo info) { Integer i = Integer.valueOf(rI); Integer[] array1 = new Integer[2]; Object[] array2 = new Object[2]; @@ -2016,7 +2036,7 @@ public void test85_verifier(boolean warmup) { Asserts.assertEquals(array2[1], i); test85(array2, null, false); Asserts.assertEquals(array2[1], null); - if (!warmup) { + if (!info.isWarmUp()) { NotFlattenable[] array3 = new NotFlattenable[2]; try { test85(array3, null, true); @@ -2028,7 +2048,9 @@ public void test85_verifier(boolean warmup) { } // Same as test85 but with not-flattenable inline type array - @Test(failOn = ALLOC_G + ALLOCA_G + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE, match = { INLINE_ARRAY_NULL_GUARD }, matchCount = { 2 }) + @Test + @IR(failOn = {ALLOC_G, ALLOCA_G, LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE}, + counts = {INLINE_ARRAY_NULL_GUARD, "= 2"}) public void test86(NotFlattenable.ref[] array, NotFlattenable.ref o, boolean b) { if (b) { array[0] = null; @@ -2038,15 +2060,15 @@ public void test86(NotFlattenable.ref[] array, NotFlattenable.ref o, boolean b) array[1] = o; } - @DontCompile - public void test86_verifier(boolean warmup) { + @Run(test = "test86") + public void test86_verifier(RunInfo info) { NotFlattenable vt = new NotFlattenable(); NotFlattenable.ref[] array1 = new NotFlattenable.ref[2]; test86(array1, vt, true); Asserts.assertEquals(array1[1], vt); test86(array1, null, false); Asserts.assertEquals(array1[1], null); - if (!warmup) { + if (!info.isWarmUp()) { NotFlattenable[] array2 = new NotFlattenable[2]; try { test86(array2, null, true); @@ -2058,7 +2080,9 @@ public void test86_verifier(boolean warmup) { } // Same as test85 but with inline type array - @Test(failOn = ALLOC_G + ALLOCA_G + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE, match = { INLINE_ARRAY_NULL_GUARD }, matchCount = { 2 }) + @Test + @IR(failOn = {ALLOC_G, ALLOCA_G, LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE}, + counts = {INLINE_ARRAY_NULL_GUARD, "= 2"}) public void test87(MyValue1.ref[] array, MyValue1.ref o, boolean b) { if (b) { array[0] = null; @@ -2068,15 +2092,15 @@ public void test87(MyValue1.ref[] array, MyValue1.ref o, boolean b) { array[1] = o; } - @DontCompile - public void test87_verifier(boolean warmup) { + @Run(test = "test87") + public void test87_verifier(RunInfo info) { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); MyValue1.ref[] array1 = new MyValue1.ref[2]; test87(array1, vt, true); Asserts.assertEquals(array1[1], vt); test87(array1, null, false); Asserts.assertEquals(array1[1], null); - if (!warmup) { + if (!info.isWarmUp()) { MyValue1[] array2 = new MyValue1[2]; try { test87(array2, null, true); @@ -2093,15 +2117,15 @@ public void test88(Object[] array, Integer v) { array[0] = v; } - @DontCompile - public void test88_verifier(boolean warmup) { + @Run(test = "test88") + public void test88_verifier(RunInfo info) { Integer[] array1 = new Integer[1]; Object[] array2 = new Object[1]; test88(array1, null); Asserts.assertEquals(array1[0], null); test88(array2, null); Asserts.assertEquals(array2[0], null); - if (!warmup) { + if (!info.isWarmUp()) { MyValue1[] array3 = new MyValue1[1]; try { test88(array3, null); @@ -2118,12 +2142,12 @@ public void test89(MyValue1.ref[] array, Integer v) { array[0] = (MyValue1.ref)o; } - @DontCompile - public void test89_verifier(boolean warmup) { + @Run(test = "test89") + public void test89_verifier(RunInfo info) { MyValue1.ref[] array1 = new MyValue1.ref[1]; test89(array1, null); Asserts.assertEquals(array1[0], null); - if (!warmup) { + if (!info.isWarmUp()) { MyValue1[] array2 = new MyValue1[1]; try { test89(array2, null); @@ -2153,8 +2177,8 @@ public boolean test90() { return b; } - @DontCompile - public void test90_verifier(boolean warmup) { + @Run(test = "test90") + public void test90_verifier() { Asserts.assertEQ(test90(), true); } @@ -2184,7 +2208,6 @@ public void verify() { // Test anti-dependencies between loads and stores from flattened array @Test - @Warmup(0) public int test91(Test91Value[] array, int lo, int val) { int i = 3; while (lo < i) { @@ -2195,8 +2218,9 @@ public int test91(Test91Value[] array, int lo, int val) { return val; } - @DontCompile - public void test91_verifier(boolean warmup) { + @Run(test = "test91") + @Warmup(0) + public void test91_verifier() { Test91Value[] array = new Test91Value[5]; for (int i = 0; i < 5; ++i) { array[i] = new Test91Value(i); @@ -2213,8 +2237,8 @@ public void test92(Object[] src, Object[] dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test92_verifier(boolean warmup) { + @Run(test = "test92") + public void test92_verifier() { MyValue1[] a = new MyValue1[1]; MyValue1[] b = new MyValue1[1]; try { @@ -2234,7 +2258,6 @@ public void test92_verifier(boolean warmup) { // Same as test30 but accessing all elements of the non-escaping array @Test - @Warmup(10000) public long test93(MyValue2[] src, boolean flag) { MyValue2[] dst = new MyValue2[10]; System.arraycopy(src, 0, dst, 0, 10); @@ -2243,13 +2266,14 @@ public long test93(MyValue2[] src, boolean flag) { dst[5].hash() + dst[6].hash() + dst[7].hash() + dst[8].hash() + dst[9].hash(); } - @DontCompile - public void test93_verifier(boolean warmup) { + @Run(test = "test93") + @Warmup(10000) + public void test93_verifier(RunInfo info) { MyValue2[] src = new MyValue2[10]; for (int i = 0; i < 10; ++i) { src[i] = MyValue2.createWithFieldsInline(rI+i, rD+i); } - long res = test93(src, !warmup); + long res = test93(src, !info.isWarmUp()); long expected = 0; for (int i = 0; i < 10; ++i) { expected += src[i].hash(); @@ -2259,7 +2283,6 @@ public void test93_verifier(boolean warmup) { // Same as test93 but with variable source array offset @Test - @Warmup(10000) public long test94(MyValue2[] src, int i, boolean flag) { MyValue2[] dst = new MyValue2[10]; System.arraycopy(src, i, dst, 0, 1); @@ -2268,21 +2291,23 @@ public long test94(MyValue2[] src, int i, boolean flag) { dst[5].hash() + dst[6].hash() + dst[7].hash() + dst[8].hash() + dst[9].hash(); } - @DontCompile - public void test94_verifier(boolean warmup) { + @Run(test = "test94") + @Warmup(10000) + public void test94_verifier(RunInfo info) { MyValue2[] src = new MyValue2[10]; for (int i = 0; i < 10; ++i) { src[i] = MyValue2.createWithFieldsInline(rI+i, rD+i); } for (int i = 0; i < 10; ++i) { - long res = test94(src, i, !warmup); + long res = test94(src, i, !info.isWarmUp()); long expected = src[i].hash() + 9*MyValue2.default.hash(); Asserts.assertEQ(res, expected); } } // Test propagation of not null-free/flat information - @Test(failOn = CHECKCAST_ARRAY) + @Test + @IR(failOn = CHECKCAST_ARRAY) public MyValue1[] test95(Object[] array) { array[0] = null; // Always throws a ClassCastException because we just successfully @@ -2290,8 +2315,8 @@ public MyValue1[] test95(Object[] array) { return (MyValue1[])array; } - @DontCompile - public void test95_verifier(boolean warmup) { + @Run(test = "test95") + public void test95_verifier() { MyValue1[] array1 = new MyValue1[1]; Integer[] array2 = new Integer[1]; try { @@ -2309,7 +2334,8 @@ public void test95_verifier(boolean warmup) { } // Same as test95 but with cmp user of cast result - @Test(failOn = CHECKCAST_ARRAY) + @Test + @IR(failOn = CHECKCAST_ARRAY) public boolean test96(Object[] array) { array[0] = null; // Always throws a ClassCastException because we just successfully @@ -2318,8 +2344,8 @@ public boolean test96(Object[] array) { return casted != null; } - @DontCompile - public void test96_verifier(boolean warmup) { + @Run(test = "test96") + public void test96_verifier() { MyValue1[] array1 = new MyValue1[1]; Integer[] array2 = new Integer[1]; try { @@ -2337,7 +2363,8 @@ public void test96_verifier(boolean warmup) { } // Same as test95 but with instanceof instead of cast - @Test(failOn = CHECKCAST_ARRAY) + @Test + @IR(failOn = CHECKCAST_ARRAY) public boolean test97(Object[] array) { array[0] = 42; // Always throws a ClassCastException because we just successfully stored @@ -2345,8 +2372,8 @@ public boolean test97(Object[] array) { return array instanceof MyValue1[]; } - @DontCompile - public void test97_verifier(boolean warmup) { + @Run(test = "test97") + public void test97_verifier() { MyValue1[] array1 = new MyValue1[1]; Integer[] array2 = new Integer[1]; try { @@ -2360,8 +2387,9 @@ public void test97_verifier(boolean warmup) { } // Same as test95 but with non-flattenable store - @Test(valid = InlineTypeArrayFlattenOn, failOn = CHECKCAST_ARRAY) - @Test(valid = InlineTypeArrayFlattenOff) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + failOn = CHECKCAST_ARRAY) public MyValue1[] test98(Object[] array) { array[0] = NotFlattenable.default; // Always throws a ClassCastException because we just successfully stored a @@ -2369,8 +2397,8 @@ public MyValue1[] test98(Object[] array) { return (MyValue1[])array; } - @DontCompile - public void test98_verifier(boolean warmup) { + @Run(test = "test98") + public void test98_verifier() { MyValue1[] array1 = new MyValue1[1]; NotFlattenable[] array2 = new NotFlattenable[1]; try { @@ -2388,8 +2416,9 @@ public void test98_verifier(boolean warmup) { } // Same as test98 but with cmp user of cast result - @Test(valid = InlineTypeArrayFlattenOn, failOn = CHECKCAST_ARRAY) - @Test(valid = InlineTypeArrayFlattenOff) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + failOn = CHECKCAST_ARRAY) public boolean test99(Object[] array) { array[0] = NotFlattenable.default; // Always throws a ClassCastException because we just successfully stored a @@ -2398,8 +2427,8 @@ public boolean test99(Object[] array) { return casted != null; } - @DontCompile - public void test99_verifier(boolean warmup) { + @Run(test = "test99") + public void test99_verifier() { MyValue1[] array1 = new MyValue1[1]; NotFlattenable[] array2 = new NotFlattenable[1]; try { @@ -2417,8 +2446,9 @@ public void test99_verifier(boolean warmup) { } // Same as test98 but with instanceof instead of cast - @Test(valid = InlineTypeArrayFlattenOn, failOn = CHECKCAST_ARRAY) - @Test(valid = InlineTypeArrayFlattenOff) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + failOn = CHECKCAST_ARRAY) public boolean test100(Object[] array) { array[0] = NotFlattenable.default; // Always throws a ClassCastException because we just successfully stored a @@ -2426,8 +2456,8 @@ public boolean test100(Object[] array) { return array instanceof MyValue1[]; } - @DontCompile - public void test100_verifier(boolean warmup) { + @Run(test = "test100") + public void test100_verifier() { MyValue1[] array1 = new MyValue1[1]; NotFlattenable[] array2 = new NotFlattenable[1]; try { @@ -2441,13 +2471,14 @@ public void test100_verifier(boolean warmup) { } // Test that CHECKCAST_ARRAY matching works as expected - @Test(match = { CHECKCAST_ARRAY }, matchCount = { 1 }) + @Test + @IR(counts = { CHECKCAST_ARRAY, "= 1" }) public boolean test101(Object[] array) { return array instanceof MyValue1[]; } - @DontCompile - public void test101_verifier(boolean warmup) { + @Run(test = "test101") + public void test101_verifier() { MyValue1[] array1 = new MyValue1[1]; NotFlattenable[] array2 = new NotFlattenable[1]; Asserts.assertTrue(test101(array1)); @@ -2479,62 +2510,69 @@ public void test101_verifier(boolean warmup) { } // Arraycopy with constant source and destination arrays - @Test(valid = InlineTypeArrayFlattenOn, match = { INTRINSIC_SLOW_PATH }, matchCount = { 1 }) - @Test(valid = InlineTypeArrayFlattenOff, failOn = INTRINSIC_SLOW_PATH) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + counts = {INTRINSIC_SLOW_PATH, "= 1"}) + @IR(applyIf = {"FlatArrayElementMaxSize", "!= -1"}, + failOn = INTRINSIC_SLOW_PATH) public void test102() { System.arraycopy(val_src, 0, obj_dst, 0, 8); } - @DontCompile - public void test102_verifier(boolean warmup) { + @Run(test = "test102") + public void test102_verifier() { test102(); verify(val_src, obj_dst); } // Same as test102 but with MyValue2[] dst - @Test(failOn = INTRINSIC_SLOW_PATH) + @Test + @IR(failOn = INTRINSIC_SLOW_PATH) public void test103() { System.arraycopy(val_src, 0, val_dst, 0, 8); } - @DontCompile - public void test103_verifier(boolean warmup) { + @Run(test = "test103") + public void test103_verifier() { test103(); verify(val_src, val_dst); } // Same as test102 but with Object[] src - @Test(failOn = INTRINSIC_SLOW_PATH) + @Test + @IR(failOn = INTRINSIC_SLOW_PATH) public void test104() { System.arraycopy(obj_src, 0, obj_dst, 0, 8); } - @DontCompile - public void test104_verifier(boolean warmup) { + @Run(test = "test104") + public void test104_verifier() { test104(); verify(obj_src, obj_dst); } // Same as test103 but with Object[] src - @Test(match = { INTRINSIC_SLOW_PATH }, matchCount = { 1 }) + @Test + @IR(counts = {INTRINSIC_SLOW_PATH, "= 1"}) public void test105() { System.arraycopy(obj_src, 0, val_dst, 0, 8); } - @DontCompile - public void test105_verifier(boolean warmup) { + @Run(test = "test105") + public void test105_verifier() { test105(); verify(obj_src, val_dst); } // Same as test103 but with Object[] src containing null - @Test(match = { INTRINSIC_SLOW_PATH }, matchCount = { 1 }) + @Test + @IR(counts = {INTRINSIC_SLOW_PATH, "= 1"}) public void test105_null() { System.arraycopy(obj_null_src, 0, val_dst, 0, 8); } - @DontCompile - public void test105_null_verifier(boolean warmup) { + @Run(test = "test105_null") + public void test105_null_verifier() { try { test105_null(); throw new RuntimeException("NullPointerException expected"); @@ -2545,62 +2583,68 @@ public void test105_null_verifier(boolean warmup) { // Below tests are equal to test102-test105 but hide the src/dst types until // after the arraycopy intrinsic is emitted (with incremental inlining). - - @Test(valid = InlineTypeArrayFlattenOn, match = { INTRINSIC_SLOW_PATH }, matchCount = { 1 }) - @Test(valid = InlineTypeArrayFlattenOff, failOn = INTRINSIC_SLOW_PATH) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + counts = {INTRINSIC_SLOW_PATH, "= 1"}) + @IR(applyIf = {"FlatArrayElementMaxSize", "!= -1"}, + failOn = INTRINSIC_SLOW_PATH) public void test106() { System.arraycopy(get_val_src(), 0, get_obj_dst(), 0, 8); } - @DontCompile - public void test106_verifier(boolean warmup) { + @Run(test = "test106") + public void test106_verifier() { test106(); verify(val_src, obj_dst); } // TODO 8251971: Should be optimized but we are bailing out because // at parse time it looks as if src could be flat and dst could be not flat. - @Test(valid = InlineTypeArrayFlattenOn) - @Test(valid = InlineTypeArrayFlattenOff, failOn = INTRINSIC_SLOW_PATH) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "!= -1"}, + failOn = INTRINSIC_SLOW_PATH) public void test107() { System.arraycopy(get_val_src(), 0, get_val_dst(), 0, 8); } - @DontCompile - public void test107_verifier(boolean warmup) { + @Run(test = "test107") + public void test107_verifier() { test107(); verify(val_src, val_dst); } - @Test(failOn = INTRINSIC_SLOW_PATH) + @Test + @IR(failOn = INTRINSIC_SLOW_PATH) public void test108() { System.arraycopy(get_obj_src(), 0, get_obj_dst(), 0, 8); } - @DontCompile - public void test108_verifier(boolean warmup) { + @Run(test = "test108") + public void test108_verifier() { test108(); verify(obj_src, obj_dst); } - @Test(match = { INTRINSIC_SLOW_PATH }, matchCount = { 1 }) + @Test + @IR(counts = {INTRINSIC_SLOW_PATH, "= 1"}) public void test109() { System.arraycopy(get_obj_src(), 0, get_val_dst(), 0, 8); } - @DontCompile - public void test109_verifier(boolean warmup) { + @Run(test = "test109") + public void test109_verifier() { test109(); verify(obj_src, val_dst); } - @Test(match = { INTRINSIC_SLOW_PATH }, matchCount = { 1 }) + @Test + @IR(counts = {INTRINSIC_SLOW_PATH, "= 1"}) public void test109_null() { System.arraycopy(get_obj_null_src(), 0, get_val_dst(), 0, 8); } - @DontCompile - public void test109_null_verifier(boolean warmup) { + @Run(test = "test109_null") + public void test109_null_verifier() { try { test109_null(); throw new RuntimeException("NullPointerException expected"); @@ -2610,62 +2654,69 @@ public void test109_null_verifier(boolean warmup) { } // Arrays.copyOf with constant source and destination arrays - @Test(valid = InlineTypeArrayFlattenOn, match = { INTRINSIC_SLOW_PATH }, matchCount = { 1 }) - @Test(valid = InlineTypeArrayFlattenOff, failOn = INTRINSIC_SLOW_PATH + CLASS_CHECK_TRAP) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + counts = {INTRINSIC_SLOW_PATH, "= 1"}) + @IR(applyIf = {"FlatArrayElementMaxSize", "!= -1"}, + failOn = {INTRINSIC_SLOW_PATH, CLASS_CHECK_TRAP}) public Object[] test110() { return Arrays.copyOf(val_src, 8, Object[].class); } - @DontCompile - public void test110_verifier(boolean warmup) { + @Run(test = "test110") + public void test110_verifier() { Object[] res = test110(); verify(val_src, res); } // Same as test110 but with MyValue2[] dst - @Test(failOn = INTRINSIC_SLOW_PATH + CLASS_CHECK_TRAP) + @Test + @IR(failOn = {INTRINSIC_SLOW_PATH, CLASS_CHECK_TRAP}) public Object[] test111() { return Arrays.copyOf(val_src, 8, MyValue2[].class); } - @DontCompile - public void test111_verifier(boolean warmup) { + @Run(test = "test111") + public void test111_verifier() { Object[] res = test111(); verify(val_src, res); } // Same as test110 but with Object[] src - @Test(failOn = INTRINSIC_SLOW_PATH + CLASS_CHECK_TRAP) + @Test + @IR(failOn = {INTRINSIC_SLOW_PATH, CLASS_CHECK_TRAP}) public Object[] test112() { return Arrays.copyOf(obj_src, 8, Object[].class); } - @DontCompile - public void test112_verifier(boolean warmup) { + @Run(test = "test112") + public void test112_verifier() { Object[] res = test112(); verify(obj_src, res); } // Same as test111 but with Object[] src - @Test(match = { INTRINSIC_SLOW_PATH + CLASS_CHECK_TRAP }, matchCount = { 1 }) + @Test + @IR(counts = {INTRINSIC_SLOW_PATH + "|" + CLASS_CHECK_TRAP, " = 1"}) public Object[] test113() { return Arrays.copyOf(obj_src, 8, MyValue2[].class); } - @DontCompile - public void test113_verifier(boolean warmup) { + @Run(test = "test113") + public void test113_verifier() { Object[] res = test113(); verify(obj_src, res); } // Same as test111 but with Object[] src containing null - @Test(match = { INTRINSIC_SLOW_PATH + CLASS_CHECK_TRAP }, matchCount = { 1 }) + @Test + @IR(counts = {INTRINSIC_SLOW_PATH + "|" + CLASS_CHECK_TRAP, " = 1"}) public Object[] test113_null() { return Arrays.copyOf(obj_null_src, 8, MyValue2[].class); } - @DontCompile - public void test113_null_verifier(boolean warmup) { + @Run(test = "test113_null") + public void test113_null_verifier() { try { test113_null(); throw new RuntimeException("NullPointerException expected"); @@ -2677,61 +2728,68 @@ public void test113_null_verifier(boolean warmup) { // Below tests are equal to test110-test113 but hide the src/dst types until // after the arraycopy intrinsic is emitted (with incremental inlining). - @Test(valid = InlineTypeArrayFlattenOn, match = { INTRINSIC_SLOW_PATH }, matchCount = { 1 }) - @Test(valid = InlineTypeArrayFlattenOff, failOn = INTRINSIC_SLOW_PATH + CLASS_CHECK_TRAP) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + counts = {INTRINSIC_SLOW_PATH, "= 1"}) + @IR(applyIf = {"FlatArrayElementMaxSize", "!= -1"}, + failOn = {INTRINSIC_SLOW_PATH, CLASS_CHECK_TRAP}) public Object[] test114() { return Arrays.copyOf((Object[])get_val_src(), 8, get_obj_class()); } - @DontCompile - public void test114_verifier(boolean warmup) { + @Run(test = "test114") + public void test114_verifier() { Object[] res = test114(); verify(val_src, res); } // TODO 8251971: Should be optimized but we are bailing out because // at parse time it looks as if src could be flat and dst could be not flat - @Test(valid = InlineTypeArrayFlattenOn) - @Test(valid = InlineTypeArrayFlattenOff, failOn = INTRINSIC_SLOW_PATH + CLASS_CHECK_TRAP) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "!= -1"}, + failOn = {INTRINSIC_SLOW_PATH, CLASS_CHECK_TRAP}) public Object[] test115() { return Arrays.copyOf((Object[])get_val_src(), 8, get_val_class()); } - @DontCompile - public void test115_verifier(boolean warmup) { + @Run(test = "test115") + public void test115_verifier() { Object[] res = test115(); verify(val_src, res); } - @Test(failOn = INTRINSIC_SLOW_PATH + CLASS_CHECK_TRAP) + @Test + @IR(failOn = {INTRINSIC_SLOW_PATH, CLASS_CHECK_TRAP}) public Object[] test116() { return Arrays.copyOf((Object[])get_obj_src(), 8, get_obj_class()); } - @DontCompile - public void test116_verifier(boolean warmup) { + @Run(test = "test116") + public void test116_verifier() { Object[] res = test116(); verify(obj_src, res); } - @Test(match = { INTRINSIC_SLOW_PATH + CLASS_CHECK_TRAP }, matchCount = { 1 }) + @Test + @IR(counts = {INTRINSIC_SLOW_PATH + "|" + CLASS_CHECK_TRAP, " = 1"}) public Object[] test117() { return Arrays.copyOf((Object[])get_obj_src(), 8, get_val_class()); } - @DontCompile - public void test117_verifier(boolean warmup) { + @Run(test = "test117") + public void test117_verifier() { Object[] res = test117(); verify(obj_src, res); } - @Test(match = { INTRINSIC_SLOW_PATH + CLASS_CHECK_TRAP }, matchCount = { 1 }) + @Test + @IR(counts = {INTRINSIC_SLOW_PATH + "|" + CLASS_CHECK_TRAP, " = 1"}) public Object[] test117_null() { return Arrays.copyOf((Object[])get_obj_null_src(), 8, get_val_class()); } - @DontCompile - public void test117_null_verifier(boolean warmup) { + @Run(test = "test117_null") + public void test117_null_verifier() { try { test117_null(); throw new RuntimeException("NullPointerException expected"); @@ -2742,13 +2800,15 @@ public void test117_null_verifier(boolean warmup) { // Some more Arrays.copyOf tests with only constant class - @Test(match = { CLASS_CHECK_TRAP }, matchCount = { 1 }, failOn = INTRINSIC_SLOW_PATH) + @Test + @IR(counts = {CLASS_CHECK_TRAP, "= 1"}, + failOn = INTRINSIC_SLOW_PATH) public Object[] test118(Object[] src) { return Arrays.copyOf(src, 8, MyValue2[].class); } - @DontCompile - public void test118_verifier(boolean warmup) { + @Run(test = "test118") + public void test118_verifier() { Object[] res = test118(obj_src); verify(obj_src, res); res = test118(val_src); @@ -2766,21 +2826,23 @@ public Object[] test119(Object[] src) { return Arrays.copyOf(src, 8, Object[].class); } - @DontCompile - public void test119_verifier(boolean warmup) { + @Run(test = "test119") + public void test119_verifier() { Object[] res = test119(obj_src); verify(obj_src, res); res = test119(val_src); verify(val_src, res); } - @Test(match = { CLASS_CHECK_TRAP }, matchCount = { 1 }, failOn = INTRINSIC_SLOW_PATH) + @Test + @IR(counts = {CLASS_CHECK_TRAP, "= 1"}, + failOn = INTRINSIC_SLOW_PATH) public Object[] test120(Object[] src) { return Arrays.copyOf(src, 8, Integer[].class); } - @DontCompile - public void test120_verifier(boolean warmup) { + @Run(test = "test120") + public void test120_verifier() { Integer[] arr = new Integer[8]; for (int i = 0; i < 8; ++i) { arr[i] = rI + i; @@ -2796,13 +2858,13 @@ public void test120_verifier(boolean warmup) { } @Test - @Warmup(10000) // Make sure we hit too_many_traps for the src <: dst check public Object[] test121(Object[] src) { return Arrays.copyOf(src, 8, MyValue2[].class); } - @DontCompile - public void test121_verifier(boolean warmup) { + @Run(test = "test121") + @Warmup(10000) // Make sure we hit too_many_traps for the src <: dst check + public void test121_verifier() { Object[] res = test121(obj_src); verify(obj_src, res); res = test121(val_src); @@ -2816,13 +2878,13 @@ public void test121_verifier(boolean warmup) { } @Test - @Warmup(10000) // Make sure we hit too_many_traps for the src <: dst check public Object[] test122(Object[] src) { return Arrays.copyOf(src, 8, get_val_class()); } - @DontCompile - public void test122_verifier(boolean warmup) { + @Run(test = "test122") + @Warmup(10000) // Make sure we hit too_many_traps for the src <: dst check + public void test122_verifier() { Object[] res = test122(obj_src); verify(obj_src, res); res = test122(val_src); @@ -2836,13 +2898,13 @@ public void test122_verifier(boolean warmup) { } @Test - @Warmup(10000) // Make sure we hit too_many_traps for the src <: dst check public Object[] test123(Object[] src) { return Arrays.copyOf(src, 8, Integer[].class); } - @DontCompile - public void test123_verifier(boolean warmup) { + @Run(test = "test123") + @Warmup(10000) // Make sure we hit too_many_traps for the src <: dst check + public void test123_verifier() { Integer[] arr = new Integer[8]; for (int i = 0; i < 8; ++i) { arr[i] = rI + i; @@ -2858,13 +2920,13 @@ public void test123_verifier(boolean warmup) { } @Test - @Warmup(10000) // Make sure we hit too_many_traps for the src <: dst check public Object[] test124(Object[] src) { return Arrays.copyOf(src, 8, get_int_class()); } - @DontCompile - public void test124_verifier(boolean warmup) { + @Run(test = "test124") + @Warmup(10000) // Make sure we hit too_many_traps for the src <: dst check + public void test124_verifier() { Integer[] arr = new Integer[8]; for (int i = 0; i < 8; ++i) { arr[i] = rI + i; @@ -2880,13 +2942,13 @@ public void test124_verifier(boolean warmup) { } @Test - @Warmup(10000) // Make sure we hit too_many_traps for the src <: dst check public Object[] test125(Object[] src, Class klass) { return Arrays.copyOf(src, 8, klass); } - @DontCompile - public void test125_verifier(boolean warmup) { + @Run(test = "test125") + @Warmup(10000) // Make sure we hit too_many_traps for the src <: dst check + public void test125_verifier() { Integer[] arr = new Integer[8]; for (int i = 0; i < 8; ++i) { arr[i] = rI + i; @@ -2917,15 +2979,20 @@ public void test125_verifier(boolean warmup) { } } + // Verify that clone from (flat) inline type array not containing oops is always optimized. - @Test(valid = InlineTypeArrayFlattenOn, match = { JLONG_ARRAYCOPY }, matchCount = { 1 }, failOn = CHECKCAST_ARRAYCOPY + CLONE_INTRINSIC_SLOW_PATH) - @Test(valid = InlineTypeArrayFlattenOff, failOn = CLONE_INTRINSIC_SLOW_PATH) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + counts = {JLONG_ARRAYCOPY, "= 1"}, + failOn = {CHECKCAST_ARRAYCOPY, CLONE_INTRINSIC_SLOW_PATH}) + @IR(applyIf = {"FlatArrayElementMaxSize", "!= -1"}, + failOn = CLONE_INTRINSIC_SLOW_PATH) public Object[] test126(MyValue2[] src) { return src.clone(); } - @DontCompile - public void test126_verifier(boolean warmup) { + @Run(test = "test126") + public void test126_verifier() { Object[] res = test126(val_src); verify(val_src, res); } @@ -2936,8 +3003,8 @@ public void test127(Object src, Object dst, int len) { System.arraycopy(src, 0, dst, 0, len); } - @DontCompile - public void test127_verifier(boolean warmup) { + @Run(test = "test127") + public void test127_verifier() { test127(val_src, obj_dst, 8); verify(val_src, obj_dst); test127(val_src, val_dst, 8); @@ -2953,14 +3020,16 @@ public void test127_verifier(boolean warmup) { } // Verify that copyOf with known source and unknown destination class is optimized - @Test(valid = InlineTypeArrayFlattenOn, match = { JLONG_ARRAYCOPY }, matchCount = { 1 }, failOn = CHECKCAST_ARRAYCOPY) - @Test(valid = InlineTypeArrayFlattenOff) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + counts = {JLONG_ARRAYCOPY, "= 1"}, + failOn = CHECKCAST_ARRAYCOPY) public Object[] test128(MyValue2[] src, Class klass) { return Arrays.copyOf(src, 8, klass); } - @DontCompile - public void test128_verifier(boolean warmup) { + @Run(test = "test128") + public void test128_verifier() { Object[] res = test128(val_src, MyValue2[].class); verify(val_src, res); res = test128(val_src, Object[].class); @@ -2979,8 +3048,8 @@ public void test129(Object src, Object dst, int len) { System.arraycopy(src, 0, dst, 0, len); } - @DontCompile - public void test129_verifier(boolean warmup) { + @Run(test = "test129") + public void test129_verifier() { try { test129(new Object(), new Object[0], 0); throw new RuntimeException("ArrayStoreException expected"); @@ -2996,14 +3065,15 @@ public void test129_verifier(boolean warmup) { } // Empty inline type array access - @Test(failOn = ALLOC + ALLOCA + LOAD + STORE) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOAD, STORE}) public MyValueEmpty test130(MyValueEmpty[] array) { array[0] = new MyValueEmpty(); return array[1]; } - @DontCompile - public void test130_verifier(boolean warmup) { + @Run(test = "test130") + public void test130_verifier() { MyValueEmpty[] array = new MyValueEmpty[2]; MyValueEmpty empty = test130(array); Asserts.assertEquals(array[0], MyValueEmpty.default); @@ -3015,14 +3085,15 @@ static primitive class EmptyContainer { } // Empty inline type container array access - @Test(failOn = ALLOC + ALLOCA + LOAD + STORE) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOAD, STORE}) public MyValueEmpty test131(EmptyContainer[] array) { array[0] = new EmptyContainer(); return array[1].empty; } - @DontCompile - public void test131_verifier(boolean warmup) { + @Run(test = "test131") + public void test131_verifier() { EmptyContainer[] array = new EmptyContainer[2]; MyValueEmpty empty = test131(array); Asserts.assertEquals(array[0], EmptyContainer.default); @@ -3036,8 +3107,8 @@ public Object test132(Object[] array) { return array[1]; } - @DontCompile - public void test132_verifier(boolean warmup) { + @Run(test = "test132") + public void test132_verifier() { Object[] array = new MyValueEmpty[2]; Object empty = test132(array); Asserts.assertEquals(array[0], MyValueEmpty.default); @@ -3055,8 +3126,8 @@ public Object test133(Object[] array) { return array[1]; } - @DontCompile - public void test133_verifier(boolean warmup) { + @Run(test = "test133") + public void test133_verifier() { Object[] array = new EmptyContainer[2]; Object empty = test133(array); Asserts.assertEquals(array[0], EmptyContainer.default); @@ -3068,15 +3139,16 @@ public void test133_verifier(boolean warmup) { } // Non-escaping empty inline type array access - @Test(failOn = ALLOC + ALLOCA + LOAD + STORE) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOAD, STORE}) public static MyValueEmpty test134(MyValueEmpty val) { MyValueEmpty[] array = new MyValueEmpty[1]; array[0] = val; return array[0]; } - @DontCompile - public void test134_verifier(boolean warmup) { + @Run(test = "test134") + public void test134_verifier() { MyValueEmpty empty = test134(MyValueEmpty.default); Asserts.assertEquals(empty, MyValueEmpty.default); } @@ -3088,8 +3160,8 @@ public Object test135(Object[] array, Object val) { return array[1]; } - @DontCompile - public void test135_verifier(boolean warmup) { + @Run(test = "test135") + public void test135_verifier() { MyValue1[] array1 = new MyValue1[2]; array1[1] = MyValue1.createWithFieldsInline(rI, rL); synchronized (array1) { @@ -3117,8 +3189,8 @@ public Object test136(Object[] array, Object val) { return res; } - @DontCompile - public void test136_verifier(boolean warmup) { + @Run(test = "test136") + public void test136_verifier() { MyValue1[] array1 = new MyValue1[2]; array1[1] = MyValue1.createWithFieldsInline(rI, rL); Object res = test136(array1, array1[1]); @@ -3142,8 +3214,8 @@ public void test137(Object[] array1, Object[] array2) { } } - @DontCompile - public void test137_verifier(boolean warmup) { + @Run(test = "test137") + public void test137_verifier() { MyValue1[] array1 = new MyValue1[100]; Arrays.fill(array1, MyValue1.createWithFieldsInline(rI, rL)); Integer[] array2 = new Integer[100]; @@ -3185,8 +3257,8 @@ public void test138(Object[] array1, Object[] array2) { } } - @DontCompile - public void test138_verifier(boolean warmup) { + @Run(test = "test138") + public void test138_verifier() { MyValue1[] array1 = new MyValue1[100]; Arrays.fill(array1, MyValue1.createWithFieldsInline(rI, rL)); Integer[] array2 = new Integer[100]; @@ -3207,7 +3279,9 @@ public void test138_verifier(boolean warmup) { } // Test load from array that is only known to be non-inline after parsing - @Test(failOn = ALLOC + ALLOCA + ALLOC_G + ALLOCA_G + LOOP + LOAD + STORE + TRAP + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD) + @Test + @IR(failOn = {ALLOC, ALLOCA, ALLOC_G, ALLOCA_G, LOOP, LOAD, STORE, TRAP, LOAD_UNKNOWN_INLINE, + STORE_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}) public Object test139() { Object[] array = null; Object[] iarray = new Integer[1]; @@ -3219,14 +3293,16 @@ public Object test139() { return array[0]; } - @DontCompile - public void test139_verifier(boolean warmup) { + @Run(test = "test139") + public void test139_verifier() { Object res = test139(); Asserts.assertEquals(res, null); } // Test store to array that is only known to be non-inline after parsing - @Test(failOn = ALLOC + ALLOCA + ALLOC_G + LOOP + LOAD + STORE + TRAP + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD) + @Test + @IR(failOn = {ALLOC, ALLOCA, ALLOC_G, LOOP, LOAD, STORE, TRAP, + LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}) public Object[] test140(Object val) { Object[] array = null; Object[] iarray = new Integer[1]; @@ -3239,8 +3315,8 @@ public Object[] test140(Object val) { return array; } - @DontCompile - public void test140_verifier(boolean warmup) { + @Run(test = "test140") + public void test140_verifier() { Object[] res = test140(rI); Asserts.assertEquals(res[0], rI); res = test140(null); @@ -3249,8 +3325,8 @@ public void test140_verifier(boolean warmup) { // Test load from array that is only known to be inline after parsing // TODO 8255938 - // @Test(failOn = ALLOC + ALLOCA + ALLOC_G + ALLOCA_G + LOOP + LOAD + STORE + TRAP + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD) @Test + // @IR(failOn = {ALLOC, ALLOCA, ALLOC_G, ALLOCA_G, LOOP, LOAD, STORE, TRAP, LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}) public Object test141() { Object[] array = null; Object[] iarray = new Integer[1]; @@ -3262,16 +3338,16 @@ public Object test141() { return array[0]; } - @DontCompile - public void test141_verifier(boolean warmup) { + @Run(test = "test141") + public void test141_verifier() { Object res = test141(); Asserts.assertEquals(res, MyValue1.default); } // Test store to array that is only known to be inline after parsing // TODO 8255938 - // @Test(failOn = ALLOC + ALLOCA + ALLOC_G + LOOP + LOAD + STORE + TRAP + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD) @Test + // @IR(failOn = {ALLOC, ALLOCA, ALLOC_G, LOOP, LOAD, STORE, TRAP, LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}) public Object[] test142(Object val) { Object[] array = null; Object[] iarray = new Integer[1]; @@ -3284,11 +3360,11 @@ public Object[] test142(Object val) { return array; } - @DontCompile - public void test142_verifier(boolean warmup) { + @Run(test = "test142") + public void test142_verifier(RunInfo info) { Object[] res = test142(MyValue1.default); Asserts.assertEquals(res[0], MyValue1.default); - if (!warmup) { + if (!info.isWarmUp()) { try { test142(null); throw new RuntimeException("Should throw NullPointerException"); @@ -3313,7 +3389,6 @@ static class MyObject143 implements MyInterface143 { // Test that triggers an anti dependency failure when array mark word is loaded from immutable memory @Test - @Warmup(0) public void test143() { MyInterface143[] arr = array143; int tmp = arr.length; @@ -3324,14 +3399,14 @@ public void test143() { } } - @DontCompile - public void test143_verifier(boolean warmup) { + @Run(test = "test143") + @Warmup(0) + public void test143_verifier() { test143(); } // Same as test143 but with two flat array checks that are unswitched @Test - @Warmup(0) public void test144() { MyInterface143[] arr1 = array143; MyInterface143[] arr2 = array143; @@ -3344,8 +3419,9 @@ public void test144() { } } - @DontCompile - public void test144_verifier(boolean warmup) { + @Run(test = "test144") + @Warmup(0) + public void test144_verifier() { test144(); } @@ -3355,16 +3431,16 @@ public Object test145(Object[] array) { return array[0]; } - @DontCompile - public void test145_verifier(boolean warmup) { + @Run(test = "test145") + public void test145_verifier() { Object[] array = new EmptyContainer[1]; EmptyContainer empty = (EmptyContainer)test145(array); Asserts.assertEquals(empty, EmptyContainer.default); } // Test that non-flattened array does not block inline type scalarization - @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE) - @Warmup(50000) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOOP, LOAD, STORE}) public void test146(boolean b) { MyValue2 vt = MyValue2.createWithFieldsInline(rI, rD); MyValue2[] array = { vt }; @@ -3377,14 +3453,15 @@ public void test146(boolean b) { } } - @DontCompile - public void test146_verifier(boolean warmup) { + @Run(test = "test146") + @Warmup(50000) + public void test146_verifier() { test146(true); } // Test that non-flattened array does not block inline type scalarization - @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE) - @Warmup(50000) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOOP, LOAD, STORE}) public int test147(boolean deopt) { // Both vt and array should be scalarized MyValue2 vt = MyValue2.createWithFieldsInline(rI, rD); @@ -3408,9 +3485,10 @@ public int test147(boolean deopt) { return array[0].x; } - @DontCompile - public void test147_verifier(boolean warmup) { - int res = test147(!warmup); - Asserts.assertEquals(res, MyValue2.createWithFieldsInline(rI, rD).x + (warmup ? 0 : 42)); + @Run(test = "test147") + @Warmup(50000) + public void test147_verifier(RunInfo info) { + int res = test147(!info.isWarmUp()); + Asserts.assertEquals(res, MyValue2.createWithFieldsInline(rI, rD).x + (info.isWarmUp() ? 0 : 42)); } } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestBasicFunctionality.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestBasicFunctionality.java index 1c9e7288406..aee5e36b203 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestBasicFunctionality.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestBasicFunctionality.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2021, 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 @@ -23,38 +23,42 @@ package compiler.valhalla.inlinetypes; +import compiler.lib.ir_framework.*; import jdk.test.lib.Asserts; +import java.lang.reflect.Method; + +import static compiler.valhalla.inlinetypes.InlineTypes.IRNode.*; +import static compiler.valhalla.inlinetypes.InlineTypes.*; + /* * @test * @key randomness * @summary Test the basic inline type implementation in C2 - * @library /testlibrary /test/lib /compiler/whitebox / + * * @requires os.simpleArch == "x64" - * @compile TestBasicFunctionality.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestBasicFunctionality + * @library /test/lib / + * @compile InlineTypes.java + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestBasicFunctionality */ -public class TestBasicFunctionality extends InlineTypeTest { - // Extra VM parameters for some test scenarios. See InlineTypeTest.getVMParameters() - @Override - public String[] getExtraVMParameters(int scenario) { - switch (scenario) { - case 2: return new String[] {"-DVerifyIR=false"}; - case 3: return new String[] {"-XX:FlatArrayElementMaxSize=0"}; - } - return null; - } - public static void main(String[] args) throws Throwable { - TestBasicFunctionality test = new TestBasicFunctionality(); - test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class, MyValue3.class, MyValue3Inline.class); - } +@ForceCompileClassInitializer +public class TestBasicFunctionality { - // Helper methods + public static void main(String[] args) { + Scenario[] scenarios = InlineTypes.DEFAULT_SCENARIOS; + scenarios[2].addFlags("-DVerifyIR=false"); + scenarios[3].addFlags("-XX:FlatArrayElementMaxSize=0"); + + InlineTypes.getFramework() + .addScenarios(scenarios) + .addHelperClasses(MyValue1.class, + MyValue2.class, + MyValue2Inline.class, + MyValue3.class, + MyValue3Inline.class) + .start(); + } protected long hash() { return hash(rI, rL); @@ -64,41 +68,50 @@ protected long hash(int x, long y) { return MyValue1.createWithFieldsInline(x, y).hash(); } + // Receive inline type through call to interpreter - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test1() { MyValue1 v = MyValue1.createWithFieldsDontInline(rI, rL); return v.hash(); } - @DontCompile - public void test1_verifier(boolean warmup) { + @Run(test = "test1") + public void test1_verifier() { long result = test1(); Asserts.assertEQ(result, hash()); } + // Receive inline type from interpreter via parameter - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test2(MyValue1 v) { return v.hash(); } - @DontCompile - public void test2_verifier(boolean warmup) { + @Run(test = "test2") + public void test2_verifier() { MyValue1 v = MyValue1.createWithFieldsDontInline(rI, rL); long result = test2(v); Asserts.assertEQ(result, hash()); } + // Return incoming inline type without accessing fields - @Test(valid = InlineTypePassFieldsAsArgsOn, match = {ALLOC, STORE}, matchCount = {1, 14}, failOn = LOAD + TRAP) - @Test(valid = InlineTypePassFieldsAsArgsOff, failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "true"}, + counts = {ALLOC, "= 1", STORE, "= 14"}, + failOn = {LOAD, TRAP}) + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "false"}, + failOn = {ALLOC, LOAD, STORE, TRAP}) public MyValue1 test3(MyValue1 v) { return v; } - @DontCompile - public void test3_verifier(boolean warmup) { + @Run(test = "test3") + public void test3_verifier() { MyValue1 v1 = MyValue1.createWithFieldsDontInline(rI, rL); MyValue1 v2 = test3(v1); Asserts.assertEQ(v1.x, v2.x); @@ -107,21 +120,23 @@ public void test3_verifier(boolean warmup) { // Create an inline type in compiled code and only use fields. // Allocation should go away because inline type does not escape. - @Test(failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public long test4() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); return v.hash(); } - @DontCompile - public void test4_verifier(boolean warmup) { + @Run(test = "test4") + public void test4_verifier() { long result = test4(); Asserts.assertEQ(result, hash()); } // Create an inline type in compiled code and pass it to // an inlined compiled method via a call. - @Test(failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public long test5() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); return test5Inline(v); @@ -132,43 +147,50 @@ public long test5Inline(MyValue1 v) { return v.hash(); } - @DontCompile - public void test5_verifier(boolean warmup) { + @Run(test = "test5") + public void test5_verifier() { long result = test5(); Asserts.assertEQ(result, hash()); } // Create an inline type in compiled code and pass it to // the interpreter via a call. - @Test(valid = InlineTypePassFieldsAsArgsOn, failOn = LOAD + TRAP + ALLOC) - @Test(valid = InlineTypePassFieldsAsArgsOff, match = {ALLOC}, matchCount = {1}, failOn = LOAD + TRAP) + @Test + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "true"}, + failOn = {LOAD, TRAP, ALLOC}) + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "false"}, + counts = {ALLOC, "= 1"}, + failOn = {LOAD, TRAP}) public long test6() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); // Pass to interpreter return v.hashInterpreted(); } - @DontCompile - public void test6_verifier(boolean warmup) { + @Run(test = "test6") + public void test6_verifier() { long result = test6(); Asserts.assertEQ(result, hash()); } // Create an inline type in compiled code and pass it to // the interpreter by returning. - @Test(match = {ALLOC}, matchCount = {1}, failOn = LOAD + TRAP) + @Test + @IR(counts = {ALLOC, "= 1"}, + failOn = {LOAD, TRAP}) public MyValue1 test7(int x, long y) { return MyValue1.createWithFieldsInline(x, y); } - @DontCompile - public void test7_verifier(boolean warmup) { + @Run(test = "test7") + public void test7_verifier() { MyValue1 v = test7(rI, rL); Asserts.assertEQ(v.hash(), hash()); } // Merge inline types created from two branches - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test8(boolean b) { MyValue1 v; if (b) { @@ -179,15 +201,20 @@ public long test8(boolean b) { return v.hash(); } - @DontCompile - public void test8_verifier(boolean warmup) { + @Run(test = "test8") + public void test8_verifier() { Asserts.assertEQ(test8(true), hash()); Asserts.assertEQ(test8(false), hash(rI + 1, rL + 1)); } // Merge inline types created from two branches - @Test(valid = InlineTypePassFieldsAsArgsOn, match = {LOAD}, matchCount = {14}, failOn = TRAP + ALLOC + STORE) - @Test(valid = InlineTypePassFieldsAsArgsOff, match = {ALLOC, STORE}, matchCount = {1, 13}, failOn = LOAD + TRAP) + @Test + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "true"}, + counts = {LOAD, "= 14"}, + failOn = {TRAP, ALLOC, STORE}) + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "false"}, + counts = {ALLOC, "= 1", STORE, "= 13"}, + failOn = {LOAD, TRAP}) public MyValue1 test9(boolean b, int localrI, long localrL) { MyValue1 v; if (b) { @@ -211,8 +238,8 @@ public MyValue1 test9(boolean b, int localrI, long localrL) { return v; } - @DontCompile - public void test9_verifier(boolean warmup) { + @Run(test = "test9") + public void test9_verifier() { MyValue1 v = test9(true, rI, rL); Asserts.assertEQ(v.x, rI); Asserts.assertEQ(v.y, hash()); @@ -222,7 +249,8 @@ public void test9_verifier(boolean warmup) { } // Merge inline types created in a loop (not inlined) - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test10(int x, long y) { MyValue1 v = MyValue1.createWithFieldsDontInline(x, y); for (int i = 0; i < 10; ++i) { @@ -231,14 +259,15 @@ public long test10(int x, long y) { return v.hash(); } - @DontCompile - public void test10_verifier(boolean warmup) { + @Run(test = "test10") + public void test10_verifier() { long result = test10(rI, rL); Asserts.assertEQ(result, hash(rI + 10, rL + 10)); } // Merge inline types created in a loop (inlined) - @Test(failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public long test11(int x, long y) { MyValue1 v = MyValue1.createWithFieldsInline(x, y); for (int i = 0; i < 10; ++i) { @@ -247,14 +276,16 @@ public long test11(int x, long y) { return v.hash(); } - @DontCompile - public void test11_verifier(boolean warmup) { + @Run(test = "test11") + public void test11_verifier() { long result = test11(rI, rL); Asserts.assertEQ(result, hash(rI + 10, rL + 10)); } // Test loop with uncommon trap referencing an inline type - @Test(match = {SCOBJ}, matchCount = {-1 /* at least 1 */}, failOn = LOAD) + @Test + @IR(counts = {SCOBJ, ">= 1"}, // at least 1 + failOn = LOAD) public long test12(boolean b) { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); MyValue1[] va = new MyValue1[Math.abs(rI) % 10]; @@ -277,10 +308,10 @@ public long test12(boolean b) { return result; } - @DontCompile - public void test12_verifier(boolean warmup) { - long result = test12(warmup); - Asserts.assertEQ(result, warmup ? rL + (1000 * rI) : ((Math.abs(rI) % 10) + 1) * hash()); + @Run(test = "test12") + public void test12_verifier(RunInfo info) { + long result = test12(info.isWarmUp()); + Asserts.assertEQ(result, info.isWarmUp() ? rL + (1000 * rI) : ((Math.abs(rI) % 10) + 1) * hash()); } // Test loop with uncommon trap referencing an inline type @@ -307,66 +338,76 @@ public long test13(boolean b) { return result; } - @DontCompile - public void test13_verifier(boolean warmup) { - long result = test13(warmup); - Asserts.assertEQ(result, warmup ? rL + (1000 * rI) : ((Math.abs(rI) % 10) + 1) * hash()); + @Run(test = "test13") + public void test13_verifier(RunInfo info) { + long result = test13(info.isWarmUp()); + Asserts.assertEQ(result, info.isWarmUp() ? rL + (1000 * rI) : ((Math.abs(rI) % 10) + 1) * hash()); } // Create an inline type in a non-inlined method and then call a // non-inlined method on that inline type. - @Test(valid = InlineTypePassFieldsAsArgsOn, failOn = (ALLOC + STORE + TRAP), match = {LOAD}, matchCount = {14}) - @Test(valid = InlineTypePassFieldsAsArgsOff, failOn = (ALLOC + LOAD + STORE + TRAP)) + @Test + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "true"}, + failOn = {ALLOC, STORE, TRAP}, + counts = {LOAD, "= 14"}) + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "false"}, + failOn = {ALLOC, LOAD, STORE, TRAP}) public long test14() { MyValue1 v = MyValue1.createWithFieldsDontInline(rI, rL); return v.hashInterpreted(); } - @DontCompile - public void test14_verifier(boolean b) { + @Run(test = "test14") + public void test14_verifier() { long result = test14(); Asserts.assertEQ(result, hash()); } // Create an inline type in an inlined method and then call a // non-inlined method on that inline type. - @Test(valid = InlineTypePassFieldsAsArgsOn, failOn = (LOAD + TRAP + ALLOC)) - @Test(valid = InlineTypePassFieldsAsArgsOff, failOn = (LOAD + TRAP), match = {ALLOC}, matchCount = {1}) + @Test + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "true"}, + failOn = {LOAD, TRAP, ALLOC}) + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "false"}, + failOn = {LOAD, TRAP}, + counts = {ALLOC, "= 1"}) public long test15() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); return v.hashInterpreted(); } - @DontCompile - public void test15_verifier(boolean b) { + @Run(test = "test15") + public void test15_verifier() { long result = test15(); Asserts.assertEQ(result, hash()); } // Create an inline type in a non-inlined method and then call an // inlined method on that inline type. - @Test(failOn = (ALLOC + STORE + TRAP)) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test16() { MyValue1 v = MyValue1.createWithFieldsDontInline(rI, rL); return v.hash(); } - @DontCompile - public void test16_verifier(boolean b) { + @Run(test = "test16") + public void test16_verifier() { long result = test16(); Asserts.assertEQ(result, hash()); } // Create an inline type in an inlined method and then call an // inlined method on that inline type. - @Test(failOn = (ALLOC + LOAD + STORE + TRAP)) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public long test17() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); return v.hash(); } - @DontCompile - public void test17_verifier(boolean b) { + @Run(test = "test17") + public void test17_verifier() { long result = test17(); Asserts.assertEQ(result, hash()); } @@ -374,16 +415,20 @@ public void test17_verifier(boolean b) { // Create an inline type in compiled code and pass it to the // interpreter via a call. The inline type is live at the first call so // debug info should include a reference to all its fields. - @Test(valid = InlineTypePassFieldsAsArgsOn, failOn = ALLOC + LOAD + TRAP) - @Test(valid = InlineTypePassFieldsAsArgsOff, match = {ALLOC}, matchCount = {1}, failOn = LOAD + TRAP) + @Test + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "true"}, + failOn = {ALLOC, LOAD, TRAP}) + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "false"}, + counts = {ALLOC, "= 1"}, + failOn = {LOAD, TRAP}) public long test18() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); v.hashInterpreted(); return v.hashInterpreted(); } - @DontCompile - public void test18_verifier(boolean warmup) { + @Run(test = "test18") + public void test18_verifier() { long result = test18(); Asserts.assertEQ(result, hash()); } @@ -391,8 +436,12 @@ public void test18_verifier(boolean warmup) { // Create an inline type in compiled code and pass it to the // interpreter via a call. The inline type is passed twice but // should only be allocated once. - @Test(valid = InlineTypePassFieldsAsArgsOn, failOn = ALLOC + LOAD + TRAP) - @Test(valid = InlineTypePassFieldsAsArgsOff, match = {ALLOC}, matchCount = {1}, failOn = LOAD + TRAP) + @Test + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "true"}, + failOn = {ALLOC, LOAD, TRAP}) + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "false"}, + counts = {ALLOC, "= 1"}, + failOn = {LOAD, TRAP}) public long test19() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); return sumValue(v, v); @@ -403,8 +452,8 @@ public long sumValue(MyValue1 v, MyValue1 dummy) { return v.hash(); } - @DontCompile - public void test19_verifier(boolean warmup) { + @Run(test = "test19") + public void test19_verifier() { long result = test19(); Asserts.assertEQ(result, hash()); } @@ -413,23 +462,28 @@ public void test19_verifier(boolean warmup) { // interpreter via a call. The inline type is live at the uncommon // trap: verify that deoptimization causes the inline type to be // correctly allocated. - @Test(valid = InlineTypePassFieldsAsArgsOn, failOn = LOAD + ALLOC + STORE) - @Test(valid = InlineTypePassFieldsAsArgsOff, match = {ALLOC}, matchCount = {1}, failOn = LOAD) - public long test20(boolean deopt) { + @Test + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "true"}, + failOn = {LOAD, ALLOC, STORE}) + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "false"}, + counts = {ALLOC, "= 1"}, + failOn = LOAD) + public long test20(boolean deopt, Method m) { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); MyValue2[] va = new MyValue2[3]; if (deopt) { // uncommon trap - WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test20")); + TestFramework.deoptimize(m); } + return v.hashInterpreted() + va[0].hashInterpreted() + - va[1].hashInterpreted() + va[2].hashInterpreted(); + va[1].hashInterpreted() + va[2].hashInterpreted(); } - @DontCompile - public void test20_verifier(boolean warmup) { + @Run(test = "test20") + public void test20_verifier(RunInfo info) { MyValue2[] va = new MyValue2[42]; - long result = test20(!warmup); + long result = test20(!info.isWarmUp(), info.getTest()); Asserts.assertEQ(result, hash() + va[0].hash() + va[1].hash() + va[2].hash()); } @@ -441,7 +495,9 @@ public void test20_verifier(boolean warmup) { static final MyValue1 val5 = MyValue1.createWithFieldsInline(rI, rL); // Test inline type fields in objects - @Test(match = {ALLOC}, matchCount = {1}, failOn = (TRAP)) + @Test + @IR(counts = {ALLOC, "= 1"}, + failOn = TRAP) public long test21(int x, long y) { // Compute hash of inline type fields long result = val1.hash() + val2.hash() + val3.hash() + val4.hash() + val5.hash(); @@ -452,8 +508,8 @@ public long test21(int x, long y) { return result; } - @DontCompile - public void test21_verifier(boolean warmup) { + @Run(test = "test21") + public void test21_verifier() { // Check if hash computed by test18 is correct val1 = MyValue1.createWithFieldsInline(rI, rL); val2 = val1.v2; @@ -470,68 +526,73 @@ public void test21_verifier(boolean warmup) { } // Test folding of constant inline type fields - @Test(failOn = ALLOC + LOAD + STORE + LOOP + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, LOOP, TRAP}) public long test22() { // This should be constant folded return val5.hash() + val5.v3.hash(); } - @DontCompile - public void test22_verifier(boolean warmup) { + @Run(test = "test22") + public void test22_verifier() { long result = test22(); Asserts.assertEQ(result, val5.hash() + val5.v3.hash()); } // Test defaultvalue - @Test(failOn = ALLOC + LOAD + STORE + LOOP + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, LOOP, TRAP}) public long test23() { MyValue2 v = MyValue2.createDefaultInline(); return v.hash(); } - @DontCompile - public void test23_verifier(boolean warmup) { + @Run(test = "test23") + public void test23_verifier() { long result = test23(); Asserts.assertEQ(result, MyValue2.createDefaultInline().hash()); } // Test defaultvalue - @Test(failOn = ALLOC + STORE + LOOP + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, LOOP, TRAP}) public long test24() { MyValue1 v1 = MyValue1.createDefaultInline(); MyValue1 v2 = MyValue1.createDefaultDontInline(); return v1.hashPrimitive() + v2.hashPrimitive(); } - @DontCompile - public void test24_verifier(boolean warmup) { + @Run(test = "test24") + public void test24_verifier() { long result = test24(); Asserts.assertEQ(result, 2 * MyValue1.createDefaultInline().hashPrimitive()); } // Test withfield - @Test(failOn = ALLOC + LOAD + STORE + LOOP + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, LOOP, TRAP}) public long test25() { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); return v.hash(); } - @DontCompile - public void test25_verifier(boolean warmup) { + @Run(test = "test25") + public void test25_verifier() { long result = test25(); Asserts.assertEQ(result, MyValue2.createWithFieldsInline(rI, rD).hash()); } // Test withfield - @Test(failOn = ALLOC + STORE + LOOP + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, LOOP, TRAP}) public long test26() { MyValue1 v1 = MyValue1.createWithFieldsInline(rI, rL); MyValue1 v2 = MyValue1.createWithFieldsDontInline(rI, rL); return v1.hash() + v2.hash(); } - @DontCompile - public void test26_verifier(boolean warmup) { + @Run(test = "test26") + public void test26_verifier() { long result = test26(); Asserts.assertEQ(result, 2 * hash()); } @@ -541,27 +602,29 @@ class TestClass27 { } // Test allocation elimination of unused object with initialized inline type field - @Test(failOn = ALLOC + LOAD + STORE + LOOP) - public void test27(boolean deopt) { + @Test + @IR(failOn = {ALLOC, LOAD, STORE, LOOP}) + public void test27(boolean deopt, Method m) { TestClass27 unused = new TestClass27(); MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); unused.v = v; if (deopt) { // uncommon trap - WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test27")); + TestFramework.deoptimize(m); } } - @DontCompile - public void test27_verifier(boolean warmup) { - test27(!warmup); + @Run(test = "test27") + public void test27_verifier(RunInfo info) { + test27(!info.isWarmUp(), info.getTest()); } static MyValue3 staticVal3; static MyValue3 staticVal3_copy; // Check elimination of redundant inline type allocations - @Test(match = {ALLOC}, matchCount = {1}) + @Test + @IR(counts = {ALLOC, "= 1"}) public MyValue3 test28(MyValue3[] va) { // Create inline type and force allocation MyValue3 vt = MyValue3.create(); @@ -578,8 +641,8 @@ public MyValue3 test28(MyValue3[] va) { return copy; } - @DontCompile - public void test28_verifier(boolean warmup) { + @Run(test = "test28") + public void test28_verifier() { MyValue3[] va = new MyValue3[1]; MyValue3 vt = test28(va); staticVal3.verify(vt); @@ -603,16 +666,17 @@ public MyValue3 test29(boolean warmup) { return copy; } - @DontCompile - public void test29_verifier(boolean warmup) { - MyValue3 vt = test29(warmup); - if (warmup) { + @Run(test = "test29") + public void test29_verifier(RunInfo info) { + MyValue3 vt = test29(info.isWarmUp()); + if (info.isWarmUp()) { staticVal3.verify(vt); } } // Verify that C2 recognizes inline type loads and re-uses the oop to avoid allocations - @Test(failOn = ALLOC + ALLOCA + STORE) + @Test + @IR(failOn = {ALLOC, ALLOCA, STORE}) public MyValue3 test30(MyValue3[] va) { // C2 can re-use the oop of staticVal3 because staticVal3 is equal to copy MyValue3 copy = MyValue3.copy(staticVal3); @@ -622,8 +686,8 @@ public MyValue3 test30(MyValue3[] va) { return copy; } - @DontCompile - public void test30_verifier(boolean warmup) { + @Run(test = "test30") + public void test30_verifier() { staticVal3 = MyValue3.create(); MyValue3[] va = new MyValue3[1]; MyValue3 vt = test30(va); @@ -632,8 +696,9 @@ public void test30_verifier(boolean warmup) { } // Verify that C2 recognizes inline type loads and re-uses the oop to avoid allocations - @Test(valid = InlineTypeReturnedAsFieldsOn) - @Test(valid = InlineTypeReturnedAsFieldsOff, failOn = ALLOC + ALLOCA + STORE) + @Test + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "false"}, + failOn = {ALLOC, ALLOCA, STORE}) public MyValue3 test31(MyValue3[] va) { // C2 can re-use the oop returned by createDontInline() // because the corresponding inline type is equal to 'copy'. @@ -644,8 +709,8 @@ public MyValue3 test31(MyValue3[] va) { return copy; } - @DontCompile - public void test31_verifier(boolean warmup) { + @Run(test = "test31") + public void test31_verifier() { MyValue3[] va = new MyValue3[1]; MyValue3 vt = test31(va); staticVal3.verify(vt); @@ -653,8 +718,9 @@ public void test31_verifier(boolean warmup) { } // Verify that C2 recognizes inline type loads and re-uses the oop to avoid allocations - @Test(valid = InlineTypePassFieldsAsArgsOn) - @Test(valid = InlineTypePassFieldsAsArgsOff, failOn = ALLOC + ALLOCA + STORE) + @Test + @IR(applyIf = {"InlineTypePassFieldsAsArgs", "false"}, + failOn = {ALLOC, ALLOCA, STORE}) public MyValue3 test32(MyValue3 vt, MyValue3[] va) { // C2 can re-use the oop of vt because vt is equal to 'copy'. MyValue3 copy = MyValue3.copy(vt); @@ -664,8 +730,8 @@ public MyValue3 test32(MyValue3 vt, MyValue3[] va) { return copy; } - @DontCompile - public void test32_verifier(boolean warmup) { + @Run(test = "test32") + public void test32_verifier() { MyValue3 vt = MyValue3.create(); MyValue3[] va = new MyValue3[1]; MyValue3 result = test32(vt, va); @@ -675,7 +741,7 @@ public void test32_verifier(boolean warmup) { } // Test correct identification of inline type copies - @Test() + @Test public MyValue3 test33(MyValue3[] va) { MyValue3 vt = MyValue3.copy(staticVal3); vt = MyValue3.setI(vt, vt.c); @@ -686,8 +752,8 @@ public MyValue3 test33(MyValue3[] va) { return vt; } - @DontCompile - public void test33_verifier(boolean warmup) { + @Run(test = "test33") + public void test33_verifier() { staticVal3 = MyValue3.create(); MyValue3[] va = new MyValue3[1]; MyValue3 vt = test33(va); @@ -698,7 +764,8 @@ public void test33_verifier(boolean warmup) { // Verify that the default inline type is never allocated. // C2 code should load and use the default oop from the java mirror. - @Test(failOn = ALLOC + ALLOCA + LOAD + STORE + LOOP + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOAD, STORE, LOOP, TRAP}) public MyValue3 test34(MyValue3[] va) { // Explicitly create default value MyValue3 vt = MyValue3.createDefault(); @@ -714,8 +781,8 @@ public MyValue3 test34(MyValue3[] va) { return vt; } - @DontCompile - public void test34_verifier(boolean warmup) { + @Run(test = "test34") + public void test34_verifier() { MyValue3 vt = MyValue3.createDefault(); MyValue3[] va = new MyValue3[2]; va[0] = MyValue3.create(); @@ -729,7 +796,8 @@ public void test34_verifier(boolean warmup) { } // Same as above but manually initialize inline type fields to default. - @Test(failOn = ALLOC + ALLOCA + LOAD + STORE + LOOP + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOAD, STORE, LOOP, TRAP}) public MyValue3 test35(MyValue3 vt, MyValue3[] va) { vt = MyValue3.setC(vt, (char)0); vt = MyValue3.setBB(vt, (byte)0); @@ -750,8 +818,8 @@ public MyValue3 test35(MyValue3 vt, MyValue3[] va) { return vt; } - @DontCompile - public void test35_verifier(boolean warmup) { + @Run(test = "test35") + public void test35_verifier() { MyValue3 vt = MyValue3.createDefault(); MyValue3[] va = new MyValue3[1]; va[0] = MyValue3.create(); @@ -767,7 +835,8 @@ private Object test36_helper(Object v) { return v; } - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test36(boolean b) { Object o; if (b) { @@ -779,8 +848,8 @@ public long test36(boolean b) { return v.hash(); } - @DontCompile - public void test36_verifier(boolean warmup) { + @Run(test = "test36") + public void test36_verifier() { Asserts.assertEQ(test36(true), hash()); Asserts.assertEQ(test36(false), hash(rI + 1, rL + 1)); } @@ -802,8 +871,8 @@ public Test37Value1 test37(Test37Value1 vt) { return vt; } - @DontCompile - public void test37_verifier(boolean warmup) { + @Run(test = "test37") + public void test37_verifier() { Test37Value1 vt = new Test37Value1(); Asserts.assertEQ(test37(vt), vt); } @@ -828,8 +897,8 @@ public void test38() { } } - @DontCompile - public void test38_verifier(boolean warmup) { + @Run(test = "test38") + public void test38_verifier() { test38Field = Test38Value.default; test38(); Asserts.assertEQ(test38Field, new Test38Value(99)); @@ -853,26 +922,25 @@ public int[] getArray() { } @Test - @Warmup(10) public int test39() { int result = 0; for (int i = 0; i < 100; ++i) { switch ((i >>> 1) % 3) { - case 0: - test39A1[i][i] = i; - break; - case 1: - for (int j = 0; j < 100; ++j) { - test39A1[i] = getArray(); - test39Val = new Test39Value(j, test39Val.iFld2); - } - break; - case 2: - for (float f = 142; f > i; f--) { - test39A2[i + 1] += 3; - } - result += test39Val.iFld1; - break; + case 0: + test39A1[i][i] = i; + break; + case 1: + for (int j = 0; j < 100; ++j) { + test39A1[i] = getArray(); + test39Val = new Test39Value(j, test39Val.iFld2); + } + break; + case 2: + for (float f = 142; f > i; f--) { + test39A2[i + 1] += 3; + } + result += test39Val.iFld1; + break; } double d1 = 1; while (++d1 < 142) { @@ -883,8 +951,9 @@ public int test39() { return result; } - @DontCompile - public void test39_verifier(boolean warmup) { + @Run(test = "test39") + @Warmup(10) + public void test39_verifier() { int result = test39(); Asserts.assertEQ(result, 1552); } @@ -902,9 +971,10 @@ public long test40(boolean b) { return result; } - @DontCompile - public void test40_verifier(boolean warmup) { - long result = test40(warmup); - Asserts.assertEQ(result, warmup ? 0 : hash()); + @Run(test = "test40") + public void test40_verifier(RunInfo info) { + long result = test40(info.isWarmUp()); + Asserts.assertEQ(result, info.isWarmUp() ? 0 : hash()); } + } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestC1.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestC1.java index a7f94329926..5a8d03bf8af 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestC1.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestC1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, 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 @@ -21,74 +21,59 @@ * questions. */ - package compiler.valhalla.inlinetypes; -import java.lang.invoke.*; -import java.lang.reflect.Method; -import java.util.Arrays; - +import compiler.lib.ir_framework.CompLevel; +import compiler.lib.ir_framework.Run; +import compiler.lib.ir_framework.Scenario; +import compiler.lib.ir_framework.Test; import jdk.test.lib.Asserts; +import static compiler.valhalla.inlinetypes.InlineTypes.rI; +import static compiler.valhalla.inlinetypes.InlineTypes.rL; + /* * @test * @key randomness * @summary Various tests that are specific for C1. - * @library /testlibrary /test/lib /compiler/whitebox / + * @library /test/lib / * @requires os.simpleArch == "x64" * @compile -XDallowWithFieldOperator TestC1.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestC1 + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestC1 */ -public class TestC1 extends InlineTypeTest { - public static final int C1 = COMP_LEVEL_SIMPLE; - public static final int C2 = COMP_LEVEL_FULL_OPTIMIZATION; - - public static void main(String[] args) throws Throwable { - TestC1 test = new TestC1(); - test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class, MyValue3.class, MyValue3Inline.class); - } - @Override - public int getNumScenarios() { - return 5; - } - - @Override - public String[] getVMParameters(int scenario) { - switch (scenario) { - case 0: return new String[] { // C1 only - "-XX:TieredStopAtLevel=1", - "-XX:+TieredCompilation", - }; - case 1: return new String[] { // C2 only. (Make sure the tests are correctly written) - "-XX:TieredStopAtLevel=4", - "-XX:-TieredCompilation", - }; - case 2: return new String[] { // interpreter only - "-Xint", - }; - case 3: return new String[] { +public class TestC1 { + public static void main(String[] args) { + final Scenario[] scenarios = { + // C1 only + new Scenario(0, + "-XX:TieredStopAtLevel=1", "-XX:+TieredCompilation"), + // C2 only. (Make sure the tests are correctly written) + new Scenario(1, + "-XX:TieredStopAtLevel=4", "-XX:-TieredCompilation"), + // interpreter only + new Scenario(2, + "-Xint"), // Xcomp Only C1. - "-XX:TieredStopAtLevel=1", - "-XX:+TieredCompilation", - "-Xcomp", - }; - case 4: return new String[] { + new Scenario(3, + "-XX:TieredStopAtLevel=1", "-XX:+TieredCompilation", "-Xcomp"), // Xcomp Only C2. - "-XX:TieredStopAtLevel=4", - "-XX:-TieredCompilation", - "-Xcomp", - }; - } - return null; + new Scenario(4, + "-XX:TieredStopAtLevel=4", "-XX:-TieredCompilation", "-Xcomp") + }; + + InlineTypes.getFramework() + .addScenarios(scenarios) + .addHelperClasses(MyValue1.class, + MyValue2.class, + MyValue2Inline.class, + MyValue3.class, + MyValue3Inline.class) + .start(); } // JDK-8229799 - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public long test1(Object a, Object b, long n) { long r; n += (a == b) ? 0x5678123456781234L : 0x1234567812345678L; @@ -96,8 +81,8 @@ public long test1(Object a, Object b, long n) { return n; } - @DontCompile - public void test1_verifier(boolean warmup) { + @Run(test = "test1") + public void test1_verifier() { MyValue1 v1 = MyValue1.createWithFieldsInline(rI, rL); MyValue1 v2 = MyValue1.createWithFieldsInline(rI, rL+1); long r1 = test1(v1, v1, 1); @@ -116,13 +101,13 @@ static primitive class SimpleValue2 { // JDK-8231961 // Test that the value numbering optimization does not remove // the second load from the buffered array element. - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public int test2(SimpleValue2[] array) { return array[0].value + array[0].value; } - @DontCompile - public void test2_verifier(boolean warmup) { + @Run(test = "test2") + public void test2_verifier() { SimpleValue2[] array = new SimpleValue2[1]; array[0] = new SimpleValue2(rI); int result = test2(array); @@ -134,13 +119,13 @@ public void test2_verifier(boolean warmup) { // sub-elements of a flattened array without copying the element first // Test access to a null array - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public int test3(MyValue2[] array, int index) { return array[index].x; } - @DontCompile - public void test3_verifier(boolean warmup) { + @Run(test = "test3") + public void test3_verifier() { NullPointerException npe = null; try { test3(null, 0); @@ -151,13 +136,13 @@ public void test3_verifier(boolean warmup) { } // Test out of bound accesses - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public int test4(MyValue2[] array, int index) { return array[index].x; } - @DontCompile - public void test4_verifier(boolean warmup) { + @Run(test = "test4") + public void test4_verifier() { MyValue2[] array = new MyValue2[2]; ArrayIndexOutOfBoundsException aioob = null; try { @@ -176,13 +161,13 @@ public void test4_verifier(boolean warmup) { } // Test 1st level sub-element access to primitive field - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public int test5(MyValue2[] array, int index) { return array[index].x; } - @DontCompile - public void test5_verifier(boolean warmup) { + @Run(test = "test5") + public void test5_verifier() { MyValue2[] array = new MyValue2[2]; MyValue2 v = new MyValue2(1,(byte)2, new MyValue2Inline(5.0d, 345L)); array[1] = v; @@ -191,13 +176,13 @@ public void test5_verifier(boolean warmup) { } // Test 1st level sub-element access to flattened field - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public MyValue2Inline test6(MyValue2[] array, int index) { return array[index].v; } - @DontCompile - public void test6_verifier(boolean warmup) { + @Run(test = "test6") + public void test6_verifier() { MyValue2[] array = new MyValue2[2]; MyValue2Inline vi = new MyValue2Inline(3.5d, 678L); MyValue2 v = new MyValue2(1,(byte)2, vi); @@ -250,13 +235,13 @@ static primitive class TestValue { } } - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public Big test7(TestValue[] array, int index) { return array[index].big; } - @DontCompile - public void test7_verifier(boolean warmup) { + @Run(test = "test7") + public void test7_verifier() { TestValue[] array = new TestValue[7]; Big b0 = test7(array, 3); b0.check(0, 0); @@ -267,13 +252,13 @@ public void test7_verifier(boolean warmup) { } // Test 2nd level sub-element access to primitive field - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public byte test8(MyValue1[] array, int index) { return array[index].v2.y; } - @DontCompile - public void test8_verifier(boolean warmup) { + @Run(test = "test8") + public void test8_verifier() { MyValue1[] array = new MyValue1[23]; MyValue2 mv2a = MyValue2.createWithFieldsInline(7, 63L, 8.9d); MyValue2 mv2b = MyValue2.createWithFieldsInline(11, 69L, 17.3d); @@ -290,37 +275,37 @@ public void test8_verifier(boolean warmup) { // (OOB, null pointer) static primitive class EmptyType {} - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public EmptyType test9() { EmptyType[] array = new EmptyType[10]; return array[4]; } - @DontCompile - public void test9_verifier(boolean warmup) { + @Run(test = "test9") + public void test9_verifier() { EmptyType et = test9(); Asserts.assertEQ(et, EmptyType.default); } - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public EmptyType test10(EmptyType[] array) { return array[0]; } - @DontCompile - public void test10_verifier(boolean warmup) { + @Run(test = "test10") + public void test10_verifier() { EmptyType[] array = new EmptyType[16]; EmptyType et = test10(array); Asserts.assertEQ(et, EmptyType.default); } - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public EmptyType test11(EmptyType[] array, int index) { return array[index]; } - @DontCompile - public void test11_verifier(boolean warmup) { + @Run(test = "test11") + public void test11_verifier() { Exception e = null; EmptyType[] array = new EmptyType[10]; try { @@ -345,13 +330,13 @@ public void test11_verifier(boolean warmup) { Asserts.assertNotNull(e); } - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public void test12(EmptyType[] array, int index, EmptyType value) { array[index] = value; } - @DontCompile - public void test12_verifier(boolean warmup) { + @Run(test = "test12") + public void test12_verifier() { EmptyType[] array = new EmptyType[16]; test12(array, 2, EmptyType.default); Exception e = null; @@ -376,5 +361,4 @@ public void test12_verifier(boolean warmup) { } Asserts.assertNotNull(e); } - } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestCallingConvention.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestCallingConvention.java index 63117803890..380ff6ccda6 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestCallingConvention.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestCallingConvention.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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 @@ -23,36 +23,28 @@ package compiler.valhalla.inlinetypes; +import compiler.lib.ir_framework.*; import jdk.test.lib.Asserts; -import java.lang.invoke.*; +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import java.lang.reflect.Method; +import static compiler.valhalla.inlinetypes.InlineTypes.IRNode.*; +import static compiler.valhalla.inlinetypes.InlineTypes.*; + /* * @test * @key randomness * @summary Test inline type calling convention optimizations - * @library /testlibrary /test/lib /compiler/whitebox / + * @library /test/lib / * @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64") - * @compile TestCallingConvention.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestCallingConvention + * @run driver/timeout=450 compiler.valhalla.inlinetypes.TestCallingConvention */ -public class TestCallingConvention extends InlineTypeTest { - // Extra VM parameters for some test scenarios. See InlineTypeTest.getVMParameters() - @Override - public String[] getExtraVMParameters(int scenario) { - switch (scenario) { - case 0: return new String[] {"-Dsun.reflect.inflationThreshold=10000"}; // Don't generate bytecodes but call through runtime for reflective calls - case 1: return new String[] {"-Dsun.reflect.inflationThreshold=10000"}; - case 3: return new String[] {"-XX:FlatArrayElementMaxSize=0"}; - case 4: return new String[] {"-XX:-UseTLAB"}; - } - return null; - } + +@ForceCompileClassInitializer +public class TestCallingConvention { static { try { @@ -73,80 +65,110 @@ public String[] getExtraVMParameters(int scenario) { } } - public static void main(String[] args) throws Throwable { - TestCallingConvention test = new TestCallingConvention(); - test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class, MyValue3.class, MyValue3Inline.class, MyValue4.class, - Test27Value1.class, Test27Value2.class, Test27Value3.class, Test37Value.class, EmptyContainer.class, MixedContainer.class); + public static void main(String[] args) { + + Scenario[] scenarios = InlineTypes.DEFAULT_SCENARIOS; + // Don't generate bytecodes but call through runtime for reflective calls + scenarios[0].addFlags("-Dsun.reflect.inflationThreshold=10000"); + scenarios[1].addFlags("-Dsun.reflect.inflationThreshold=10000"); + scenarios[3].addFlags("-XX:FlatArrayElementMaxSize=0"); + scenarios[4].addFlags("-XX:-UseTLAB"); + + InlineTypes.getFramework() + .addScenarios(scenarios) + .addHelperClasses(MyValue1.class, + MyValue2.class, + MyValue2Inline.class, + MyValue3.class, + MyValue3Inline.class, + MyValue4.class) + .start(); + } + + // Helper methods and classes + + private void deoptimize(String name, Class... params) { + try { + TestFramework.deoptimize(getClass().getDeclaredMethod(name, params)); + } catch (NoSuchMethodException e) { + throw new RuntimeException(e); + } } // Test interpreter to compiled code with various signatures - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test1(MyValue2 v) { return v.hash(); } - @DontCompile - public void test1_verifier(boolean warmup) { + @Run(test = "test1") + public void test1_verifier() { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); long result = test1(v); Asserts.assertEQ(result, v.hashInterpreted()); } - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test2(int i1, MyValue2 v, int i2) { return v.hash() + i1 - i2; } - @DontCompile - public void test2_verifier(boolean warmup) { + @Run(test = "test2") + public void test2_verifier() { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); long result = test2(rI, v, 2*rI); Asserts.assertEQ(result, v.hashInterpreted() - rI); } - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test3(long l1, MyValue2 v, long l2) { return v.hash() + l1 - l2; } - @DontCompile - public void test3_verifier(boolean warmup) { + @Run(test = "test3") + public void test3_verifier() { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); long result = test3(rL, v, 2*rL); Asserts.assertEQ(result, v.hashInterpreted() - rL); } - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test4(int i, MyValue2 v, long l) { return v.hash() + i + l; } - @DontCompile - public void test4_verifier(boolean warmup) { + @Run(test = "test4") + public void test4_verifier() { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); long result = test4(rI, v, rL); Asserts.assertEQ(result, v.hashInterpreted() + rL + rI); } - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test5(long l, MyValue2 v, int i) { return v.hash() + i + l; } - @DontCompile - public void test5_verifier(boolean warmup) { + @Run(test = "test5") + public void test5_verifier() { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); long result = test5(rL, v, rI); Asserts.assertEQ(result, v.hashInterpreted() + rL + rI); } - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test6(long l, MyValue1 v1, int i, MyValue2 v2) { return v1.hash() + i + l + v2.hash(); } - @DontCompile - public void test6_verifier(boolean warmup) { + @Run(test = "test6") + public void test6_verifier() { MyValue1 v1 = MyValue1.createWithFieldsDontInline(rI, rL); MyValue2 v2 = MyValue2.createWithFieldsInline(rI, rD); long result = test6(rL, v1, rI, v2); @@ -159,13 +181,14 @@ public long test7_interp(MyValue2 v) { return v.hash(); } - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test7(MyValue2 v) { return test7_interp(v); } - @DontCompile - public void test7_verifier(boolean warmup) { + @Run(test = "test7") + public void test7_verifier() { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); long result = test7(v); Asserts.assertEQ(result, v.hashInterpreted()); @@ -176,13 +199,14 @@ public long test8_interp(int i1, MyValue2 v, int i2) { return v.hash() + i1 - i2; } - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test8(int i1, MyValue2 v, int i2) { return test8_interp(i1, v, i2); } - @DontCompile - public void test8_verifier(boolean warmup) { + @Run(test = "test8") + public void test8_verifier() { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); long result = test8(rI, v, 2*rI); Asserts.assertEQ(result, v.hashInterpreted() - rI); @@ -193,13 +217,14 @@ public long test9_interp(long l1, MyValue2 v, long l2) { return v.hash() + l1 - l2; } - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test9(long l1, MyValue2 v, long l2) { return test9_interp(l1, v, l2); } - @DontCompile - public void test9_verifier(boolean warmup) { + @Run(test = "test9") + public void test9_verifier() { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); long result = test9(rL, v, 2*rL); Asserts.assertEQ(result, v.hashInterpreted() - rL); @@ -210,13 +235,14 @@ public long test10_interp(int i, MyValue2 v, long l) { return v.hash() + i + l; } - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test10(int i, MyValue2 v, long l) { return test10_interp(i, v, l); } - @DontCompile - public void test10_verifier(boolean warmup) { + @Run(test = "test10") + public void test10_verifier() { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); long result = test10(rI, v, rL); Asserts.assertEQ(result, v.hashInterpreted() + rL + rI); @@ -227,13 +253,14 @@ public long test11_interp(long l, MyValue2 v, int i) { return v.hash() + i + l; } - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test11(long l, MyValue2 v, int i) { return test11_interp(l, v, i); } - @DontCompile - public void test11_verifier(boolean warmup) { + @Run(test = "test11") + public void test11_verifier() { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); long result = test11(rL, v, rI); Asserts.assertEQ(result, v.hashInterpreted() + rL + rI); @@ -244,13 +271,14 @@ public long test12_interp(long l, MyValue1 v1, int i, MyValue2 v2) { return v1.hash() + i + l + v2.hash(); } - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test12(long l, MyValue1 v1, int i, MyValue2 v2) { return test12_interp(l, v1, i, v2); } - @DontCompile - public void test12_verifier(boolean warmup) { + @Run(test = "test12") + public void test12_verifier() { MyValue1 v1 = MyValue1.createWithFieldsDontInline(rI, rL); MyValue2 v2 = MyValue2.createWithFieldsInline(rI, rD); long result = test12(rL, v1, rI, v2); @@ -262,23 +290,24 @@ public void test12_verifier(boolean warmup) { public long test13_interp(MyValue2 v, MyValue1[] va, boolean deopt) { if (deopt) { // uncommon trap - WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test13")); + deoptimize("test13", MyValue2.class, MyValue1[].class, boolean.class, long.class); } return v.hash() + va[0].hash() + va[1].hash(); } - @Test(failOn = ALLOC + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, STORE, TRAP}) public long test13(MyValue2 v, MyValue1[] va, boolean flag, long l) { return test13_interp(v, va, flag) + l; } - @DontCompile - public void test13_verifier(boolean warmup) { + @Run(test = "test13") + public void test13_verifier(RunInfo info) { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); MyValue1[] va = new MyValue1[2]; va[0] = MyValue1.createWithFieldsDontInline(rI, rL); va[1] = MyValue1.createWithFieldsDontInline(rI, rL); - long result = test13(v, va, !warmup, rL); + long result = test13(v, va, !info.isWarmUp(), rL); Asserts.assertEQ(result, v.hashInterpreted() + va[0].hash() + va[1].hash() + rL); } @@ -287,19 +316,19 @@ public void test13_verifier(boolean warmup) { public MyValue2 test14_interp(boolean deopt) { if (deopt) { // uncommon trap - WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test14")); + deoptimize("test14", boolean.class); } return MyValue2.createWithFieldsInline(rI, rD); } - @Test() + @Test public MyValue2 test14(boolean flag) { return test14_interp(flag); } - @DontCompile - public void test14_verifier(boolean warmup) { - MyValue2 result = test14(!warmup); + @Run(test = "test14") + public void test14_verifier(RunInfo info) { + MyValue2 result = test14(!info.isWarmUp()); MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); Asserts.assertEQ(result.hash(), v.hash()); } @@ -312,28 +341,30 @@ public MyValue3 test15_interp() { } MyValue3 test15_vt2; - @Test(valid = InlineTypeReturnedAsFieldsOn, failOn = ALLOC + LOAD + TRAP) - @Test(valid = InlineTypeReturnedAsFieldsOff) + @Test + @IR(applyIf = {"InlineTypeReturnedAsFields", "true"}, + failOn = {ALLOC, LOAD, TRAP}) public void test15() { test15_vt2 = test15_interp(); } - @DontCompile - public void test15_verifier(boolean warmup) { + @Run(test = "test15") + public void test15_verifier() { test15(); test15_vt.verify(test15_vt2); } // Return inline types in registers from compiled -> interpreter final MyValue3 test16_vt = MyValue3.create(); - @Test(valid = InlineTypeReturnedAsFieldsOn, failOn = ALLOC + STORE + TRAP) - @Test(valid = InlineTypeReturnedAsFieldsOff) + @Test + @IR(applyIf = {"InlineTypeReturnedAsFields", "true"}, + failOn = {ALLOC, STORE, TRAP}) public MyValue3 test16() { return test16_vt; } - @DontCompile - public void test16_verifier(boolean warmup) { + @Run(test = "test16") + public void test16_verifier() { MyValue3 vt = test16(); test16_vt.verify(vt); } @@ -346,19 +377,21 @@ public MyValue3 test17_comp() { } MyValue3 test17_vt2; - @Test(valid = InlineTypeReturnedAsFieldsOn, failOn = ALLOC + LOAD + TRAP) - @Test(valid = InlineTypeReturnedAsFieldsOff) + @Test + @IR(applyIf = {"InlineTypeReturnedAsFields", "true"}, + failOn = {ALLOC, LOAD, TRAP}) public void test17() { test17_vt2 = test17_comp(); } - @DontCompile - public void test17_verifier(boolean warmup) throws Exception { + @Run(test = "test17") + public void test17_verifier(RunInfo info) throws Exception { Method helper_m = getClass().getDeclaredMethod("test17_comp"); - if (!warmup && USE_COMPILER && !WHITE_BOX.isMethodCompiled(helper_m, false)) { - enqueueMethodForCompilation(helper_m, COMP_LEVEL_FULL_OPTIMIZATION); - Asserts.assertTrue(WHITE_BOX.isMethodCompiled(helper_m, false), "test17_comp not compiled"); + if (!info.isWarmUp() && TestFramework.isCompiled(helper_m)) { + TestFramework.compile(helper_m, CompLevel.C2); + TestFramework.assertCompiledByC2(helper_m); } + test17(); test17_vt.verify(test17_vt2); } @@ -378,8 +411,8 @@ public void test18() { test18_vt2 = test18_interp(); } - @DontCompile - public void test18_verifier(boolean warmup) { + @Run(test = "test18") + public void test18_verifier() { test18(); test18_vt.verify(test18_vt2); } @@ -391,8 +424,8 @@ public MyValue4 test19() { return test19_vt; } - @DontCompile - public void test19_verifier(boolean warmup) { + @Run(test = "test19") + public void test19_verifier() { MyValue4 vt = test19(); test19_vt.verify(vt); } @@ -410,12 +443,12 @@ public void test20() { test20_vt2 = test20_comp(); } - @DontCompile - public void test20_verifier(boolean warmup) throws Exception { + @Run(test = "test20") + public void test20_verifier(RunInfo info) throws Exception { Method helper_m = getClass().getDeclaredMethod("test20_comp"); - if (!warmup && USE_COMPILER && !WHITE_BOX.isMethodCompiled(helper_m, false)) { - enqueueMethodForCompilation(helper_m, COMP_LEVEL_FULL_OPTIMIZATION); - Asserts.assertTrue(WHITE_BOX.isMethodCompiled(helper_m, false), "test20_comp not compiled"); + if (!info.isWarmUp() && TestFramework.isCompiled(helper_m)) { + TestFramework.compile(helper_m, CompLevel.C2); + TestFramework.assertCompiledByC2(helper_m); } test20(); test20_vt.verify(test20_vt2); @@ -436,8 +469,8 @@ public MyValue3 test21() { } } - @DontCompile - public void test21_verifier(boolean warmup) { + @Run(test = "test21") + public void test21_verifier() { MyValue3 vt = test21(); test21_vt.verify(vt); } @@ -450,8 +483,8 @@ public MyValue3 test22() { return (MyValue3) test22_vt; } - @DontCompile - public void test22_verifier(boolean warmup) { + @Run(test = "test22") + public void test22_verifier() { MyValue3 vt = test22(); test22_vt.verify(vt); } @@ -479,8 +512,8 @@ public double test23(int i1, int i2, int i3, int i4, int i5, int i6, d1, d2, d3, d4, d5, d6, d7, d8); } - @DontCompile - public void test23_verifier(boolean warmup) { + @Run(test = "test23") + public void test23_verifier() { TestValue23 vt = new TestValue23(rI); double res1 = test23(rI, rI, rI, rI, rI, rI, vt, vt, vt, vt, vt, vt, vt, vt, @@ -499,8 +532,8 @@ public MyValue2.ref test24() { return null; } - @DontCompile - public void test24_verifier(boolean warmup) { + @Run(test = "test24") + public void test24_verifier() { MyValue2.ref vt = test24(); Asserts.assertEQ(vt, null); } @@ -520,8 +553,8 @@ public MyValue2.ref test26(boolean b) { return test26_callee(b); } - @DontCompile - public void test26_verifier(boolean warmup) { + @Run(test = "test26") + public void test26_verifier() { MyValue2.ref vt = test26(true); Asserts.assertEQ(vt, null); vt = test26(false); @@ -573,8 +606,8 @@ public int test27(Test27Value1 val) { return val.test(val); } - @DontCompile - public void test27_verifier(boolean warmup) { + @Run(test = "test27") + public void test27_verifier() { Test27Value3 val3 = new Test27Value3(rI); Test27Value2 val2 = new Test27Value2(val3); Test27Value1 val1 = new Test27Value1(val2); @@ -585,13 +618,13 @@ public void test27_verifier(boolean warmup) { static final MyValue1.ref test28Val = MyValue1.createWithFieldsDontInline(rI, rL); @Test - @Warmup(0) public String test28() { return test28Val.toString(); } - @DontCompile - public void test28_verifier(boolean warmup) { + @Run(test = "test28") + @Warmup(0) + public void test28_verifier() { String result = test28(); } @@ -603,8 +636,8 @@ public MyValue3 test29() { return test29_vt; } - @DontCompile - public void test29_verifier(boolean warmup) throws Exception { + @Run(test = "test29") + public void test29_verifier() throws Exception { MyValue3 vt = (MyValue3)TestCallingConvention.class.getDeclaredMethod("test29").invoke(this); test29_vt.verify(vt); } @@ -616,8 +649,8 @@ public MyValue3 test30(MyValue3[] array) { return result; } - @DontCompile - public void test30_verifier(boolean warmup) throws Exception { + @Run(test = "test30") + public void test30_verifier() throws Exception { MyValue3[] array = new MyValue3[1]; MyValue3 vt = (MyValue3)TestCallingConvention.class.getDeclaredMethod("test30", MyValue3[].class).invoke(this, (Object)array); array[0].verify(vt); @@ -632,8 +665,8 @@ public MyValue3 test31() { return result; } - @DontCompile - public void test31_verifier(boolean warmup) throws Exception { + @Run(test = "test31") + public void test31_verifier() throws Exception { MyValue3 vt = (MyValue3)TestCallingConvention.class.getDeclaredMethod("test31").invoke(this); test31_vt.verify(vt); } @@ -646,7 +679,7 @@ public void test31_verifier(boolean warmup) throws Exception { public MyValue2 test32_interp(boolean deopt) { if (deopt) { // uncommon trap - WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test32")); + deoptimize("test32", boolean.class); } return MyValue2.createWithFieldsInline(rI+32, rD); } @@ -656,9 +689,9 @@ public MyValue2 test32(boolean flag) throws Throwable { return (MyValue2)test32_mh.invokeExact(this, flag); } - @DontCompile - public void test32_verifier(boolean warmup) throws Throwable { - MyValue2 result = test32(!warmup); + @Run(test = "test32") + public void test32_verifier(RunInfo info) throws Throwable { + MyValue2 result = test32(!info.isWarmUp()); MyValue2 v = MyValue2.createWithFieldsInline(rI+32, rD); Asserts.assertEQ(result.hash(), v.hash()); } @@ -670,7 +703,7 @@ public void test32_verifier(boolean warmup) throws Throwable { public Object test33_interp(boolean deopt) { if (deopt) { // uncommon trap - WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test33")); + deoptimize("test33", boolean.class); } return MyValue2.createWithFieldsInline(rI+33, rD); } @@ -681,9 +714,9 @@ public MyValue2 test33(boolean flag) throws Throwable { return (MyValue2)o; } - @DontCompile - public void test33_verifier(boolean warmup) throws Throwable { - MyValue2 result = test33(!warmup); + @Run(test = "test33") + public void test33_verifier(RunInfo info) throws Throwable { + MyValue2 result = test33(!info.isWarmUp()); MyValue2 v = MyValue2.createWithFieldsInline(rI+33, rD); Asserts.assertEQ(result.hash(), v.hash()); } @@ -710,17 +743,17 @@ public static long test34_callee(MyValue2 vt, int i1, int i2, int i3, int i4) { } @Test() - @Warmup(10000) // Make sure test34_callee is compiled public static long test34(MyValue2 vt, int i1, int i2, int i3, int i4) { return test34_callee(vt, i1, i2, i3, i4); } - @DontCompile - public void test34_verifier(boolean warmup) { + @Run(test = "test34") + @Warmup(10000) // Make sure test34_callee is compiled + public void test34_verifier(RunInfo info) { MyValue2 vt = MyValue2.createWithFieldsInline(rI, rD); long result = test34(vt, rI, rI, rI, rI); Asserts.assertEQ(result, vt.hash()+4*rI); - if (!warmup) { + if (!info.isWarmUp()) { test34_deopt = true; for (int i = 0; i < 100; ++i) { result = test34(vt, rI, rI, rI, rI); @@ -740,8 +773,8 @@ public static long test35(MyValue2 vt, int i1, int i2, int i3, int i4) { return vt.hash() + i1 + i2 + i3 + i4 + result; } - @DontCompile - public void test35_verifier(boolean warmup) { + @Run(test = "test35") + public void test35_verifier() { MyValue2 vt = MyValue2.createWithFieldsInline(rI, rD); long result = test35(vt, rI, rI, rI, rI); Asserts.assertEQ(result, vt.hash()+10004*rI); @@ -759,8 +792,8 @@ public MyValue3 test36() { return result; } - @DontCompile - public void test36_verifier(boolean warmup) throws Exception { + @Run(test = "test36") + public void test36_verifier() throws Exception { MyValue3 vt = (MyValue3)TestCallingConvention.class.getDeclaredMethod("test36").invoke(this); test36_vt.verify(vt); } @@ -783,21 +816,22 @@ public int test37(Test37Value vt) throws Throwable { return (int)test37_mh.invokeExact(vt); } - @DontCompile - public void test37_verifier(boolean warmup) throws Throwable { + @Run(test = "test37") + public void test37_verifier() throws Throwable { Test37Value vt = new Test37Value(); int res = test37(vt); Asserts.assertEQ(res, rI); } // Test passing/returning an empty inline type - @Test(failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public MyValueEmpty test38(MyValueEmpty vt) { return vt.copy(vt); } - @DontCompile - public void test38_verifier(boolean warmup) { + @Run(test = "test38") + public void test38_verifier() { MyValueEmpty vt = new MyValueEmpty(); MyValueEmpty res = test38(vt); Asserts.assertEQ(res, vt); @@ -884,8 +918,8 @@ public static LargeValueWithOops test39(LargeValueWithOops vt) { return vt; } - @DontCompile - public void test39_verifier(boolean warmup) { + @Run(test = "test39") + public void test39_verifier() { LargeValueWithOops vt = new LargeValueWithOops(); LargeValueWithOops res = test39(vt); Asserts.assertEQ(res, vt); @@ -897,8 +931,8 @@ public static LargeValueWithoutOops test40(LargeValueWithoutOops vt) { return vt; } - @DontCompile - public void test40_verifier(boolean warmup) { + @Run(test = "test40") + public void test40_verifier() { LargeValueWithoutOops vt = new LargeValueWithoutOops(); LargeValueWithoutOops res = test40(vt); Asserts.assertEQ(res, vt); @@ -906,13 +940,14 @@ public void test40_verifier(boolean warmup) { // Test passing/returning an empty inline type together with non-empty // inline types such that only some inline type arguments are scalarized. - @Test(failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public MyValueEmpty test41(MyValue1 vt1, MyValueEmpty vt2, MyValue1 vt3) { return vt2.copy(vt2); } - @DontCompile - public void test41_verifier(boolean warmup) { + @Run(test = "test41") + public void test41_verifier() { MyValueEmpty res = test41(MyValue1.default, MyValueEmpty.default, MyValue1.default); Asserts.assertEQ(res, MyValueEmpty.default); } @@ -950,89 +985,96 @@ static primitive class MixedContainer { } // Empty inline type return - @Test(failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public MyValueEmpty test42() { EmptyContainer c = new EmptyContainer(MyValueEmpty.default); return c.getInline(); } - @DontCompile - public void test42_verifier(boolean warmup) { + @Run(test = "test42") + public void test42_verifier() { MyValueEmpty empty = test42(); Asserts.assertEquals(empty, MyValueEmpty.default); } // Empty inline type container return - @Test(failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public EmptyContainer test43(EmptyContainer c) { return c; } - @DontCompile - public void test43_verifier(boolean warmup) { + @Run(test = "test43") + public void test43_verifier() { EmptyContainer c = test43(EmptyContainer. default); Asserts.assertEquals(c, EmptyContainer.default); } // Empty inline type container (mixed) return - @Test(failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public MixedContainer test44() { MixedContainer c = new MixedContainer(rI, EmptyContainer.default); c = new MixedContainer(rI, c.getInline()); return c; } - @DontCompile - public void test44_verifier(boolean warmup) { + @Run(test = "test44") + public void test44_verifier() { MixedContainer c = test44(); Asserts.assertEquals(c, new MixedContainer(rI, EmptyContainer.default)); } // Empty inline type container argument - @Test(failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public EmptyContainer test45(EmptyContainer c) { return new EmptyContainer(c.getInline()); } - @DontCompile - public void test45_verifier(boolean warmup) { + @Run(test = "test45") + public void test45_verifier() { EmptyContainer empty = test45(EmptyContainer.default); Asserts.assertEquals(empty, EmptyContainer.default); } // Empty inline type container and mixed container arguments - @Test(failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public MyValueEmpty test46(EmptyContainer c1, MixedContainer c2, MyValueEmpty empty) { c2 = new MixedContainer(c2.val, c1); return c2.getNoInline().getNoInline(); } - @DontCompile - public void test46_verifier(boolean warmup) { + @Run(test = "test46") + public void test46_verifier() { MyValueEmpty empty = test46(EmptyContainer.default, MixedContainer.default, MyValueEmpty.default); Asserts.assertEquals(empty, MyValueEmpty.default); } // No receiver and only empty argument - @Test(failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public static MyValueEmpty test47(MyValueEmpty empty) { return empty; } - @DontCompile - public void test47_verifier(boolean warmup) { + @Run(test = "test47") + public void test47_verifier() { MyValueEmpty empty = test47(MyValueEmpty.default); Asserts.assertEquals(empty, MyValueEmpty.default); } // No receiver and only empty container argument - @Test(failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public static MyValueEmpty test48(EmptyContainer empty) { return empty.getNoInline(); } - @DontCompile - public void test48_verifier(boolean warmup) { + @Run(test = "test48") + public void test48_verifier() { MyValueEmpty empty = test48(EmptyContainer.default); Asserts.assertEquals(empty, MyValueEmpty.default); } @@ -1055,8 +1097,8 @@ public void test49(boolean b) { test49_inlined2(b); } - @DontCompile - public void test49_verifier(boolean warmup) { + @Run(test = "test49") + public void test49_verifier() { test49(true); test49(false); } @@ -1083,8 +1125,8 @@ public void test50(boolean b) { test50_vt.verify(vt); } - @DontCompile - public void test50_verifier(boolean warmup) { + @Run(test = "test50") + public void test50_verifier() { test50(true); test50(false); } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestCallingConventionC1.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestCallingConventionC1.java index 1baa644b75a..93825d957d6 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestCallingConventionC1.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestCallingConventionC1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, 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 @@ -23,94 +23,65 @@ package compiler.valhalla.inlinetypes; -import sun.hotspot.WhiteBox; +import compiler.lib.ir_framework.*; import jdk.test.lib.Asserts; +import sun.hotspot.WhiteBox; + +import static compiler.valhalla.inlinetypes.InlineTypes.rI; +import static compiler.valhalla.inlinetypes.InlineTypes.rL; /* * @test * @key randomness * @summary Test calls from {C1} to {C2, Interpreter}, and vice versa. - * @library /testlibrary /test/lib /compiler/whitebox / + * @library /test/lib / * @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64") - * @compile TestCallingConventionC1.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestCallingConventionC1 + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestCallingConventionC1 */ -public class TestCallingConventionC1 extends InlineTypeTest { - public static final int C1 = COMP_LEVEL_SIMPLE; - public static final int C2 = COMP_LEVEL_FULL_OPTIMIZATION; - @Override - public int getNumScenarios() { - return 5; - } +@ForceCompileClassInitializer +public class TestCallingConventionC1 { - @Override - public String[] getVMParameters(int scenario) { - switch (scenario) { - case 0: return new String[] { + public static void main(String[] args) { + final Scenario[] scenarios = { // Default: both C1 and C2 are enabled, tiered compilation enabled - "-XX:CICompilerCount=2", - "-XX:TieredStopAtLevel=4", - "-XX:+TieredCompilation", - }; - case 1: return new String[] { + new Scenario(0, + "-XX:CICompilerCount=2", + "-XX:TieredStopAtLevel=4", + "-XX:+TieredCompilation"), // Default: both C1 and C2 are enabled, tiered compilation enabled - "-XX:CICompilerCount=2", - "-XX:TieredStopAtLevel=4", - "-XX:+TieredCompilation", - "-XX:+StressInlineTypeReturnedAsFields" - }; - case 2: return new String[] { - // Same as above, but flip all the compLevel=C1 and compLevel=C2, so we test + new Scenario(1, + "-XX:CICompilerCount=2", + "-XX:TieredStopAtLevel=4", + "-XX:+TieredCompilation", + "-XX:+IgnoreUnrecognizedVMOptions", + "-XX:+StressInlineTypeReturnedAsFields"), + // Same as above, but flip all the compLevel=CompLevel.C1_SIMPLE and compLevel=CompLevel.C2, so we test // the compliment of the above scenario. - "-XX:CICompilerCount=2", - "-XX:TieredStopAtLevel=4", - "-XX:+TieredCompilation", - "-DFlipC1C2=true" - }; - case 3: return new String[] { + new Scenario(2, + "-XX:CICompilerCount=2", + "-XX:TieredStopAtLevel=4", + "-XX:+TieredCompilation", + "-DFlipC1C2=true"), // Only C1. Tiered compilation disabled. - "-XX:TieredStopAtLevel=1", - "-XX:+TieredCompilation", - }; - case 4: return new String[] { + new Scenario(3, + "-XX:TieredStopAtLevel=1", + "-XX:+TieredCompilation"), // Only C2. - "-XX:TieredStopAtLevel=4", - "-XX:-TieredCompilation", - }; - } - return null; - } + new Scenario(4, + "-XX:TieredStopAtLevel=4", + "-XX:-TieredCompilation") + }; - public static void main(String[] args) throws Throwable { System.gc(); // Resolve this call, to avoid C1 code patching in the test cases. - TestCallingConventionC1 test = new TestCallingConventionC1(); - test.run(args, - Point.class, - Functor.class, - Functor1.class, - Functor2.class, - Functor3.class, - Functor4.class, - MyImplPojo0.class, - MyImplPojo1.class, - MyImplPojo2.class, - MyImplPojo3.class, - MyImplVal1.class, - MyImplVal2.class, - MyImplVal1X.class, - MyImplVal2X.class, - FixedPoints.class, - FloatPoint.class, - RefPoint.class, - RefPoint_Access_Impl1.class, - RefPoint_Access_Impl2.class); + + InlineTypes.getFramework() + .addScenarios(scenarios) + .start(); } + // Helper methods and classes + static primitive class Point { final int x; final int y; @@ -120,12 +91,11 @@ public Point(int x, int y) { } @DontCompile - @DontInline public int func() { return x + y; } - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) @DontInline public int func_c1(Point p) { return x + y + p.x + p.y; @@ -138,35 +108,34 @@ static interface FunctorInterface { static class Functor implements FunctorInterface { @DontCompile - @DontInline public int apply_interp(Point p) { return p.func() + 0; } } + static class Functor1 extends Functor { @DontCompile - @DontInline public int apply_interp(Point p) { return p.func() + 10000; } } + static class Functor2 extends Functor { @DontCompile - @DontInline public int apply_interp(Point p) { return p.func() + 20000; } } + static class Functor3 extends Functor { @DontCompile - @DontInline public int apply_interp(Point p) { return p.func() + 30000; } } + static class Functor4 extends Functor { @DontCompile - @DontInline public int apply_interp(Point p) { return p.func() + 40000; } @@ -196,27 +165,33 @@ static interface Intf { static class MyImplPojo0 implements Intf { int field = 0; - @DontInline @DontCompile + @DontCompile public int func1(int a, int b) { return field + a + b + 1; } - @DontInline @DontCompile + @DontCompile public int func2(int a, int b, Point p) { return field + a + b + p.x + p.y + 1; } } static class MyImplPojo1 implements Intf { int field = 1000; - @DontInline @ForceCompile(compLevel = C1) + @DontInline + @ForceCompile(CompLevel.C1_SIMPLE) public int func1(int a, int b) { return field + a + b + 20; } - @DontInline @ForceCompile(compLevel = C1) + + @DontInline + @ForceCompile(CompLevel.C1_SIMPLE) public int func2(int a, int b, Point p) { return field + a + b + p.x + p.y + 20; } } static class MyImplPojo2 implements Intf { int field = 2000; - @DontInline @ForceCompile(compLevel = C2) + @DontInline + @ForceCompile(CompLevel.C2) public int func1(int a, int b) { return field + a + b + 20; } - @DontInline @ForceCompile(compLevel = C2) + + @DontInline + @ForceCompile(CompLevel.C2) public int func2(int a, int b, Point p) { return field + a + b + p.x + p.y + 20; } } @@ -234,10 +209,12 @@ static primitive class MyImplVal1 implements Intf { field = 11000; } - @DontInline @ForceCompile(compLevel = C1) - public int func1(int a, int b) { return field + a + b + 300; } + @DontInline + @ForceCompile(CompLevel.C1_SIMPLE) + public int func1(int a, int b) { return field + a + b + 300; } - @DontInline @ForceCompile(compLevel = C1) + @DontInline + @ForceCompile(CompLevel.C1_SIMPLE) public int func2(int a, int b, Point p) { return field + a + b + p.x + p.y + 300; } } @@ -247,10 +224,12 @@ static primitive class MyImplVal2 implements Intf { field = 12000; } - @DontInline @ForceCompile(compLevel = C2) + @DontInline + @ForceCompile(CompLevel.C2) public int func1(int a, int b) { return field + a + b + 300; } - @DontInline @ForceCompile(compLevel = C2) + @DontInline + @ForceCompile(CompLevel.C2) public int func2(int a, int b, Point p) { return field + a + b + p.x + p.y + 300; } } @@ -260,10 +239,10 @@ static primitive class MyImplVal1X implements Intf { field = 11000; } - @DontInline @DontCompile + @DontCompile public int func1(int a, int b) { return field + a + b + 300; } - @DontInline @DontCompile + @DontCompile public int func2(int a, int b, Point p) { return field + a + b + p.x + p.y + 300; } } @@ -311,6 +290,7 @@ public FloatPoint(float x, float y) { this.y = y; } } + static primitive class DoublePoint { final double x; final double y; @@ -365,19 +345,19 @@ public RefPoint(Number x, Number y) { } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) public final int final_func(RefPoint rp2) { // opt_virtual_call return this.x.n + this.y.n + rp2.x.n + rp2.y.n; } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) public int func1(RefPoint rp2) { return this.x.n + this.y.n + rp2.x.n + rp2.y.n; } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) public int func2(RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) { return x.n + y.n + rp1.x.n + rp1.y.n + @@ -390,12 +370,12 @@ public int func2(RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint r } static class RefPoint_Access_Impl1 implements RefPoint_Access { - @DontInline @DontCompile + @DontCompile public int func1(RefPoint rp2) { return rp2.x.n + rp2.y.n + 1111111; } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) public int func2(RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) { return 111111 + rp1.x.n + rp1.y.n + @@ -406,13 +386,14 @@ public int func2(RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint r n2.n; } } + static class RefPoint_Access_Impl2 implements RefPoint_Access { - @DontInline @DontCompile + @DontCompile public int func1(RefPoint rp2) { return rp2.x.n + rp2.y.n + 2222222; } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) public int func2(RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) { return 222222 + rp1.x.n + rp1.y.n + @@ -460,44 +441,40 @@ static primitive class TooBigToReturnAsFields { // PART 1 - C1 calls interpreted code //********************************************************************** - //** C1 passes inline type to interpreter (static) - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public int test1() { return test1_helper(pointField); } - @DontInline @DontCompile private static int test1_helper(Point p) { return p.func(); } - @DontCompile - public void test1_verifier(boolean warmup) { - int count = warmup ? 1 : 10; + @Run(test = "test1") + public void test1_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 10; for (int i=0; iC1 invokestatic, single inline arg - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test30() { return test30_helper(pointField); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test30_helper(Point p) { return p.x + p.y; } - @DontCompile - public void test30_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test30") + public void test30_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, two single inline args - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test31() { return test31_helper(pointField1, pointField2); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test31_helper(Point p1, Point p2) { return p1.x + p2.y; } - @DontCompile - public void test31_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test31") + public void test31_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, two single inline args and interleaving ints (all passed in registers on x64) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test32() { return test32_helper(0, pointField1, 1, pointField2); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test32_helper(int x, Point p1, int y, Point p2) { return p1.x + p2.y + x + y; } - @DontCompile - public void test32_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test32") + public void test32_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokeinterface -- no verified_ro_entry (no inline args except for receiver) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test33(Intf intf, int a, int b) { return intf.func1(a, b); } - @DontCompile - public void test33_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test33") + public void test33_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC1 invokeinterface -- use verified_ro_entry (has inline args other than receiver) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test34(Intf intf, int a, int b) { return intf.func2(a, b, pointField); } - @DontCompile - public void test34_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test34") + public void test34_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC1 invokestatic, Point.y is on stack (x64) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test35() { return test35_helper(1, 2, 3, 4, 5, pointField); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test35_helper(int a1, int a2, int a3, int a4, int a5, Point p) { return a1 + a2 + a3 + a4 + a5 + p.x + p.y; } - @DontCompile - public void test35_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test35") + public void test35_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, shuffling arguments that are passed on stack - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test36() { return test36_helper(pointField, 1, 2, 3, 4, 5, 6, 7, 8); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test36_helper(Point p, int a1, int a2, int a3, int a4, int a5, int a6, int a7, int a8) { return a6 + a8; } - @DontCompile - public void test36_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test36") + public void test36_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, shuffling long arguments - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test37() { return test37_helper(pointField, 1, 2, 3, 4, 5, 6, 7, 8); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test37_helper(Point p, long a1, long a2, long a3, long a4, long a5, long a6, long a7, long a8) { return (int)(a6 + a8); } - @DontCompile - public void test37_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test37") + public void test37_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, shuffling boolean, byte, char, short, int, long arguments - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test38() { return test38_helper(pointField, true, (byte)1, (char)2, (short)3, 4, 5, (byte)6, (short)7, 8); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test38_helper(Point p, boolean a0, byte a1, char a2, short a3, int a4, long a5, byte a6, short a7, int a8) { if (a0) { return (int)(a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8); @@ -773,9 +749,9 @@ private static int test38_helper(Point p, boolean a0, byte a1, char a2, short a3 } } - @DontCompile - public void test38_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test38") + public void test38_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, packing an inline type with all types of fixed point primitive fields. - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public long test39() { return test39_helper(1, fixedPointsField, 2, fixedPointsField); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static long test39_helper(int a1, FixedPoints f1, int a2, FixedPoints f2) { if (f1.Z0 == false && f1.Z1 == true && f2.Z0 == false && f2.Z1 == true) { return f1.B + f2.C + f1.S + f2.I + f1.J; @@ -799,9 +775,9 @@ private static long test39_helper(int a1, FixedPoints f1, int a2, FixedPoints f2 } } - @DontCompile - public void test39_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test39") + public void test39_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, shuffling floating point args - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public double test40() { return test40_helper(1.1f, 1.2, floatPointField, doublePointField, 1.3f, 1.4, 1.5f, 1.7, 1.7, 1.8, 1.9, 1.10, 1.11, 1.12); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static double test40_helper(float a1, double a2, FloatPoint fp, DoublePoint dp, float a3, double a4, float a5, double a6, double a7, double a8, double a9, double a10, double a11, double a12) { return a1 + a2 + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10 + a11 + a12 + fp.x + fp.y - dp.x - dp.y; } - @DontCompile - public void test40_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test40") + public void test40_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, mixing floats and ints - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public double test41() { return test41_helper(1, 1.2, pointField, floatPointField, doublePointField, 1.3f, 4, 1.5f, 1.7, 1.7, 1.8, 9, 1.10, 1.11, 1.12); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static double test41_helper(int a1, double a2, Point p, FloatPoint fp, DoublePoint dp, float a3, int a4, float a5, double a6, double a7, double a8, long a9, double a10, double a11, double a12) { return a1 + a2 + fp.x + fp.y - dp.x - dp.y + a3 + a4 + a5 + a6 + a7 + a8 + a9 + a10 + a11 + a12; } - @DontCompile - public void test41_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test41") + public void test41_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, circular dependency (between rdi and first stack slot on x64) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public float test42() { return test42_helper(eightFloatsField, pointField, 3, 4, 5, floatPointField, 7); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static float test42_helper(EightFloats ep1, // (xmm0 ... xmm7) -> rsi Point p2, // (rsi, rdx) -> rdx int i3, // rcx -> rcx @@ -873,9 +849,9 @@ private static float test42_helper(EightFloats ep1, // (xmm0 ... xmm7) -> rsi p2.x + p2.y + i3 + i4 + i5 + fp6.x + fp6.y + i7; } - @DontCompile - public void test42_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test42") + public void test42_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, packing causes stack growth (1 extra stack word) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public float test43() { return test43_helper(floatPointField, 1, 2, 3, 4, 5, 6); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static float test43_helper(FloatPoint fp, int a1, int a2, int a3, int a4, int a5, int a6) { // On x64: // Scalarized entry -- all parameters are passed in registers @@ -898,9 +874,9 @@ private static float test43_helper(FloatPoint fp, int a1, int a2, int a3, int a4 return fp.x + fp.y + a1 + a2 + a3 + a4 + a5 + a6; } - @DontCompile - public void test43_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test43") + public void test43_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, packing causes stack growth (2 extra stack words) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public float test44() { return test44_helper(floatPointField, floatPointField, 1, 2, 3, 4, 5, 6); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static float test44_helper(FloatPoint fp1, FloatPoint fp2, int a1, int a2, int a3, int a4, int a5, int a6) { // On x64: // Scalarized entry -- all parameters are passed in registers @@ -926,9 +902,9 @@ private static float test44_helper(FloatPoint fp1, FloatPoint fp2, int a1, int a a1 + a2 + a3 + a4 + a5 + a6; } - @DontCompile - public void test44_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test44") + public void test44_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, packing causes stack growth (5 extra stack words) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public float test45() { return test45_helper(floatPointField, floatPointField, floatPointField, floatPointField, floatPointField, 1, 2, 3, 4, 5, 6, 7); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static float test45_helper(FloatPoint fp1, FloatPoint fp2, FloatPoint fp3, FloatPoint fp4, FloatPoint fp5, int a1, int a2, int a3, int a4, int a5, int a6, int a7) { return fp1.x + fp1.y + fp2.x + fp2.y + @@ -953,9 +929,9 @@ private static float test45_helper(FloatPoint fp1, FloatPoint fp2, FloatPoint fp a1 + a2 + a3 + a4 + a5 + a6 + a7; } - @DontCompile - public void test45_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test45") + public void test45_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, packing causes stack growth (1 extra stack word -- mixing Point and FloatPoint) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public float test46() { return test46_helper(floatPointField, floatPointField, pointField, floatPointField, floatPointField, pointField, floatPointField, 1, 2, 3, 4, 5, 6, 7); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static float test46_helper(FloatPoint fp1, FloatPoint fp2, Point p1, FloatPoint fp3, FloatPoint fp4, Point p2, FloatPoint fp5, int a1, int a2, int a3, int a4, int a5, int a6, int a7) { return p1.x + p1.y + p2.x + p2.y + @@ -982,9 +958,9 @@ private static float test46_helper(FloatPoint fp1, FloatPoint fp2, Point p1, Flo a1 + a2 + a3 + a4 + a5 + a6 + a7; } - @DontCompile - public void test46_verifier(boolean warmup) { - int count = warmup ? 1 : 2; + @Run(test = "test46") + public void test46_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 2; for (int i=0; iC1 invokestatic, make sure stack walking works (with static variable) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public void test47(int n) { try { test47_helper(floatPointField, 1, 2, 3, 4, 5); @@ -1024,13 +1000,13 @@ public void test47(int n) { } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static float test47_helper(FloatPoint fp, int a1, int a2, int a3, int a4, int a5) { test47_thrower(); return 0.0f; } - @DontInline @DontCompile + @DontCompile private static void test47_thrower() { MyRuntimeException e = new MyRuntimeException("This exception should have been caught!"); checkStackTrace(e, "test47_thrower", "test47_helper", "test47", "test47_verifier"); @@ -1039,9 +1015,9 @@ private static void test47_thrower() { static int test47_value = 999; - @DontCompile - public void test47_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test47") + public void test47_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iC1 invokestatic, make sure stack walking works (with returned inline type) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test48(int n) { try { test48_helper(floatPointField, 1, 2, 3, 4, 5); @@ -1062,22 +1038,22 @@ public int test48(int n) { } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static float test48_helper(FloatPoint fp, int a1, int a2, int a3, int a4, int a5) { test48_thrower(); return 0.0f; } - @DontInline @DontCompile + @DontCompile private static void test48_thrower() { MyRuntimeException e = new MyRuntimeException("This exception should have been caught!"); checkStackTrace(e, "test48_thrower", "test48_helper", "test48", "test48_verifier"); throw e; } - @DontCompile - public void test48_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test48") + public void test48_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iinterpreter invokestatic, make sure stack walking works (same as test 48, but with stack extension/repair) // (this is the baseline for test50 -- // the only difference is: test49_helper is interpreted but test50_helper is compiled by C1). - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test49(int n) { try { test49_helper(floatPointField, 1, 2, 3, 4, 5, 6); @@ -1098,22 +1074,22 @@ public int test49(int n) { return n; } - @DontInline @DontCompile + @DontCompile private static float test49_helper(FloatPoint fp, int a1, int a2, int a3, int a4, int a5, int a6) { test49_thrower(); return 0.0f; } - @DontInline @DontCompile + @DontCompile private static void test49_thrower() { MyRuntimeException e = new MyRuntimeException("This exception should have been caught!"); checkStackTrace(e, "test49_thrower", "test49_helper", "test49", "test49_verifier"); throw e; } - @DontCompile - public void test49_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test49") + public void test49_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iC1 invokestatic, make sure stack walking works (same as test 48, but with stack extension/repair) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test50(int n) { try { test50_helper(floatPointField, 1, 2, 3, 4, 5, 6); @@ -1133,22 +1109,22 @@ public int test50(int n) { } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static float test50_helper(FloatPoint fp, int a1, int a2, int a3, int a4, int a5, int a6) { test50_thrower(); return 0.0f; } - @DontInline @DontCompile + @DontCompile private static void test50_thrower() { MyRuntimeException e = new MyRuntimeException("This exception should have been caught!"); checkStackTrace(e, "test50_thrower", "test50_helper", "test50", "test50_verifier"); throw e; } - @DontCompile - public void test50_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test50") + public void test50_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iC1 invokestatic, inline class with ref fields (RefPoint) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test51() { return test51_helper(refPointField1); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test51_helper(RefPoint rp1) { return rp1.x.n + rp1.y.n; } - @DontCompile - public void test51_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test51") + public void test51_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iC1 invokestatic, inline class with ref fields (Point, RefPoint) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test52() { return test52_helper(pointField, refPointField1); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test52_helper(Point p1, RefPoint rp1) { return p1.x + p1.y + rp1.x.n + rp1.y.n; } - @DontCompile - public void test52_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test52") + public void test52_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iC1 invokestatic, inline class with ref fields (RefPoint, RefPoint, RefPoint, RefPoint) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test53() { return test53_helper(refPointField1, refPointField2, refPointField1, refPointField2); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test53_helper(RefPoint rp1, RefPoint rp2, RefPoint rp3, RefPoint rp4) { return rp1.x.n + rp1.y.n + rp2.x.n + rp2.y.n + @@ -1215,9 +1191,9 @@ private static int test53_helper(RefPoint rp1, RefPoint rp2, RefPoint rp3, RefPo rp4.x.n + rp4.y.n; } - @DontCompile - public void test53_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test53") + public void test53_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iC1 invokestatic, inline class with ref fields (RefPoint, RefPoint, float, int, RefPoint, RefPoint) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test54() { return test54_helper(refPointField1, refPointField2, 1.0f, 2, refPointField1, refPointField2); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test54_helper(RefPoint rp1, RefPoint rp2, float f, int i, RefPoint rp3, RefPoint rp4) { return rp1.x.n + rp1.y.n + rp2.x.n + rp2.y.n + @@ -1241,9 +1217,9 @@ private static int test54_helper(RefPoint rp1, RefPoint rp2, float f, int i, Ref rp4.x.n + rp4.y.n; } - @DontCompile - public void test54_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test54") + public void test54_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iC1 invokestatic, force GC for every allocation when entering a C1 VEP (Point) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test55(Point p1) { return test55_helper(p1); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test55_helper(Point p1) { return p1.x + p1.y; } - @DontCompile - public void test55_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test55") + public void test55_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iC1 invokestatic, force GC for every allocation when entering a C1 VEP (RefPoint) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test56(RefPoint rp1) { return test56_helper(rp1); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test56_helper(RefPoint rp1) { return rp1.x.n + rp1.y.n; } - @DontCompile - public void test56_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test56") + public void test56_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iInterpreter (same as test56, but test c2i entry instead of C1) - @Test(compLevel = C2) + // C2->Interpreter (same as test56, but test C2i entry instead of C1) + @Test(compLevel = CompLevel.C2) public int test57(RefPoint rp1) { return test57_helper(rp1); } - @DontInline @DontCompile + @DontCompile private static int test57_helper(RefPoint rp1) { return rp1.x.n + rp1.y.n; } - @DontCompile - public void test57_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test57") + public void test57_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iC1 invokestatic, force GC for every allocation when entering a C1 VEP (a bunch of RefPoints and Numbers); - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test58(RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) { return test58_helper(rp1, rp2, n1, rp3, rp4, n2); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test58_helper(RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) { return rp1.x.n + rp1.y.n + rp2.x.n + rp2.y.n + @@ -1371,9 +1344,9 @@ private static int test58_helper(RefPoint rp1, RefPoint rp2, Number n1, RefPoint n2.n; } - @DontCompile - public void test58_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test58") + public void test58_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iC1 invokestatic, GC inside main body of C1-compiled method (caller's args should not be GC'ed). - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test59(RefPoint rp1, boolean doGC) { return test59_helper(rp1, 11, 222, 3333, 4444, doGC); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test59_helper(RefPoint rp1, int a1, int a2, int a3, int a4, boolean doGC) { if (doGC) { System.gc(); @@ -1405,10 +1378,10 @@ private static int test59_helper(RefPoint rp1, int a1, int a2, int a3, int a4, b return rp1.x.n + rp1.y.n + a1 + a2 + a3 + a4; } - @DontCompile - public void test59_verifier(boolean warmup) { - int count = warmup ? 1 : 5; - boolean doGC = !warmup; + @Run(test = "test59") + public void test59_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; + boolean doGC = !info.isWarmUp(); for (int i=0; iC1 invokestatic, GC inside main body of C1-compiled method (caller's args should not be GC'ed). // same as test59, but the incoming (scalarized) oops are passed in both registers and stack. - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test60(RefPoint rp1, RefPoint rp2, boolean doGC) { return test60_helper(555, 6666, 77777, rp1, rp2, 11, 222, 3333, 4444, doGC); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static int test60_helper(int x0, int x1, int x2, RefPoint rp1, RefPoint rp2,int a1, int a2, int a3, int a4, boolean doGC) { // On x64, C2 passes: reg0=x1, reg1=x1, reg2=x2, reg3=rp1.x, reg4=rp1.y, reg5=rp2.x stack0=rp2.y .... // C1 expects: reg0=x1, reg1=x1, reg2=x2, reg3=rp1, reg4=rp2, reg5=a1 stack0=a2 ... @@ -1436,10 +1409,10 @@ private static int test60_helper(int x0, int x1, int x2, RefPoint rp1, RefPoint return x0 + x1 + x2 + rp1.x.n + rp1.y.n + rp2.x.n + rp2.y.n + a1 + a2 + a3 + a4; } - @DontCompile - public void test60_verifier(boolean warmup) { - int count = warmup ? 1 : 5; - boolean doGC = !warmup; + @Run(test = "test60") + public void test60_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; + boolean doGC = !info.isWarmUp(); for (int i=0; iC1 invokeinterface via VVEP(RO) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test61(RefPoint_Access rpa, RefPoint rp2) { return rpa.func1(rp2); } - @DontCompile - public void test61_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test61") + public void test61_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC1 invokeinterface via VVEP(RO) -- force GC for every allocation when entering a C1 VVEP(RO) (RefPoint) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test62(RefPoint_Access rpa, RefPoint rp2) { return rpa.func1(rp2); } - @DontCompile - public void test62_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test62") + public void test62_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC1 invokeinterface via VVEP(RO) -- force GC for every allocation when entering a C1 VVEP(RO) (a bunch of RefPoints and Numbers) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test63(RefPoint_Access rpa, RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) { return rpa.func2(rp1, rp2, n1, rp3, rp4, n2); } - @DontCompile - public void test63_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test63") + public void test63_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC1 invokestatic (same as test63, but use invokestatic instead) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test64(RefPoint_Access rpa, RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) { return test64_helper(rpa, rp1, rp2, n1, rp3, rp4, n2); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) public static int test64_helper(RefPoint_Access rpa, RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) { return rp3.y.n; } - @DontCompile - public void test64_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test64") + public void test64_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC1 invokevirtual via VVEP(RO) (opt_virtual_call) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test76(RefPoint rp1, RefPoint rp2) { return rp1.final_func(rp2); } - @DontCompile - public void test76_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test76") + public void test76_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iC1 invokevirtual, force GC for every allocation when entering a C1 VEP (RefPoint) // Same as test56, except we call the VVEP(RO) instead of VEP. - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test77(RefPoint rp1, RefPoint rp2) { return rp1.final_func(rp2); } - @DontCompile - public void test77_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test77") + public void test77_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iC1 invokestatic with InlineTypeReturnedAsFields (Point) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test78(Point p) { Point np = test78_helper(p); return np.x + np.y; } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static Point test78_helper(Point p) { return p; } - @DontCompile - public void test78_verifier(boolean warmup) { + @Run(test = "test78") + public void test78_verifier() { int result = test78(pointField1); int n = pointField1.x + pointField1.y; Asserts.assertEQ(result, n); } // C2->C1 invokestatic with InlineTypeReturnedAsFields (RefPoint) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test79(RefPoint p) { RefPoint np = test79_helper(p); return np.x.n + np.y.n; } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static RefPoint test79_helper(RefPoint p) { return p; } - @DontCompile - public void test79_verifier(boolean warmup) { + @Run(test = "test79") + public void test79_verifier() { int result = test79(refPointField1); int n = refPointField1.x.n + refPointField1.y.n; Asserts.assertEQ(result, n); } // C1->C2 invokestatic with InlineTypeReturnedAsFields (RefPoint) - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public int test80(RefPoint p) { RefPoint np = test80_helper(p); return np.x.n + np.y.n; } @DontInline - @ForceCompile(compLevel = C2) + @ForceCompile(CompLevel.C2) private static RefPoint test80_helper(RefPoint p) { return p; } - @DontCompile - public void test80_verifier(boolean warmup) { + @Run(test = "test80") + public void test80_verifier() { int result = test80(refPointField1); int n = refPointField1.x.n + refPointField1.y.n; Asserts.assertEQ(result, n); } // Interpreter->C1 invokestatic with InlineTypeReturnedAsFields (Point) - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public Point test81(Point p) { return p; } - @DontCompile - public void test81_verifier(boolean warmup) { + @Run(test = "test81") + public void test81_verifier() { Point p = test81(pointField1); Asserts.assertEQ(p.x, pointField1.x); Asserts.assertEQ(p.y, pointField1.y); @@ -1666,19 +1639,19 @@ public void test81_verifier(boolean warmup) { } // C1->Interpreter invokestatic with InlineTypeReturnedAsFields (RefPoint) - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public int test82(RefPoint p) { RefPoint np = test82_helper(p); return np.x.n + np.y.n; } - @DontInline @DontCompile + @DontCompile private static RefPoint test82_helper(RefPoint p) { return p; } - @DontCompile - public void test82_verifier(boolean warmup) { + @Run(test = "test82") + public void test82_verifier() { int result = test82(refPointField1); int n = refPointField1.x.n + refPointField1.y.n; Asserts.assertEQ(result, n); @@ -1689,72 +1662,72 @@ public void test82_verifier(boolean warmup) { //------------------------------------------------------------------------------- // C2->C1 invokestatic with InlineTypeReturnedAsFields (TooBigToReturnAsFields) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test83(TooBigToReturnAsFields p) { TooBigToReturnAsFields np = test83_helper(p); return p.a0 + p.a5; } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static TooBigToReturnAsFields test83_helper(TooBigToReturnAsFields p) { return p; } - @DontCompile - public void test83_verifier(boolean warmup) { + @Run(test = "test83") + public void test83_verifier() { int result = test83(tooBig); int n = tooBig.a0 + tooBig.a5; Asserts.assertEQ(result, n); } // C1->C2 invokestatic with InlineTypeReturnedAsFields (TooBigToReturnAsFields) - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public int test84(TooBigToReturnAsFields p) { TooBigToReturnAsFields np = test84_helper(p); return p.a0 + p.a5; } @DontInline - @ForceCompile(compLevel = C2) + @ForceCompile(CompLevel.C2) private static TooBigToReturnAsFields test84_helper(TooBigToReturnAsFields p) { return p; } - @DontCompile - public void test84_verifier(boolean warmup) { + @Run(test = "test84") + public void test84_verifier() { int result = test84(tooBig); int n = tooBig.a0 + tooBig.a5; Asserts.assertEQ(result, n); } // Interpreter->C1 invokestatic with InlineTypeReturnedAsFields (TooBigToReturnAsFields) - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public TooBigToReturnAsFields test85(TooBigToReturnAsFields p) { return p; } - @DontCompile - public void test85_verifier(boolean warmup) { + @Run(test = "test85") + public void test85_verifier() { TooBigToReturnAsFields p = test85(tooBig); Asserts.assertEQ(p.a0, tooBig.a0); Asserts.assertEQ(p.a2, tooBig.a2); } // C1->Interpreter invokestatic with InlineTypeReturnedAsFields (TooBigToReturnAsFields) - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public int test86(TooBigToReturnAsFields p) { TooBigToReturnAsFields np = test86_helper(p); return p.a0 + p.a5; } - @DontInline @DontCompile + @DontCompile private static TooBigToReturnAsFields test86_helper(TooBigToReturnAsFields p) { return p; } - @DontCompile - public void test86_verifier(boolean warmup) { + @Run(test = "test86") + public void test86_verifier() { int result = test86(tooBig); int n = tooBig.a0 + tooBig.a5; Asserts.assertEQ(result, n); @@ -1765,55 +1738,55 @@ public void test86_verifier(boolean warmup) { //------------------------------------------------------------------------------- // C2->C1 invokestatic with InlineTypeReturnedAsFields (RefPoint.ref) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public RefPoint.ref test87(RefPoint.ref p) { return test87_helper(p); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static RefPoint.ref test87_helper(RefPoint.ref p) { return p; } - @DontCompile - public void test87_verifier(boolean warmup) { + @Run(test = "test87") + public void test87_verifier() { Object result = test87(null); Asserts.assertEQ(result, null); } // C2->C1 invokestatic with InlineTypeReturnedAsFields (RefPoint.ref with constant null) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public RefPoint.ref test88() { return test88_helper(); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static RefPoint.ref test88_helper() { return null; } - @DontCompile - public void test88_verifier(boolean warmup) { + @Run(test = "test88") + public void test88_verifier() { Object result = test88(); Asserts.assertEQ(result, null); } // C1->C2 invokestatic with InlineTypeReturnedAsFields (RefPoint.ref) - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public RefPoint.ref test89(RefPoint.ref p) { return test89_helper(p); } @DontInline - @ForceCompile(compLevel = C2) + @ForceCompile(CompLevel.C2) private static RefPoint.ref test89_helper(RefPoint.ref p) { return p; } - @DontCompile - public void test89_verifier(boolean warmup) { + @Run(test = "test89") + public void test89_verifier() { Object result = test89(null); Asserts.assertEQ(result, null); } @@ -1829,7 +1802,7 @@ public void test89_verifier(boolean warmup) { //---------------------------------------------------------------------------------- // C1->C1 invokeinterface -- call Unverified Value Entry of MyImplPojo1.func2 (compiled by C1) - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public int test90(Intf intf, int a, int b) { return intf.func2(a, b, pointField); } @@ -1839,9 +1812,9 @@ public int test90(Intf intf, int a, int b) { new MyImplPojo2(), }; - @DontCompile - public void test90_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test90") + public void test90_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC2 invokeinterface -- call Unverified Value Entry of MyImplPojo2.func2 (compiled by C2) - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public int test91(Intf intf, int a, int b) { return intf.func2(a, b, pointField); } @@ -1860,9 +1833,9 @@ public int test91(Intf intf, int a, int b) { new MyImplPojo1(), }; - @DontCompile - public void test91_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test91") + public void test91_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC1 invokeinterface -- call Unverified Entry of MyImplPojo1.func2 (compiled by C1) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test92(Intf intf, int a, int b) { return intf.func2(a, b, pointField); } @@ -1881,9 +1854,9 @@ public int test92(Intf intf, int a, int b) { new MyImplPojo2(), }; - @DontCompile - public void test92_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test92") + public void test92_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC2 invokeinterface -- call Unverified Entry of MyImplPojo2.func2 (compiled by C2) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test93(Intf intf, int a, int b) { return intf.func2(a, b, pointField); } @@ -1902,9 +1875,9 @@ public int test93(Intf intf, int a, int b) { new MyImplPojo1(), }; - @DontCompile - public void test93_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test93") + public void test93_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC1 invokeinterface -- call Unverified Entry of MyImplVal1.func2 (compiled by C1 - has VVEP_RO) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test94(Intf intf, int a, int b) { return intf.func2(a, b, pointField); } @@ -1923,9 +1896,9 @@ public int test94(Intf intf, int a, int b) { new MyImplVal2(), }; - @DontCompile - public void test94_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test94") + public void test94_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC2 invokeinterface -- call Unverified Entry of MyImplVal2.func2 (compiled by C2 - has VVEP_RO) - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test95(Intf intf, int a, int b) { return intf.func2(a, b, pointField); } @@ -1944,9 +1917,9 @@ public int test95(Intf intf, int a, int b) { new MyImplVal1(), }; - @DontCompile - public void test95_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test95") + public void test95_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC2 GC handling in StubRoutines::store_inline_type_fields_to_buf() - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public RefPoint test96(RefPoint rp, boolean b) { RefPoint p = test96_helper(rp); if (b) { @@ -1964,19 +1937,20 @@ public RefPoint test96(RefPoint rp, boolean b) { return p; } - @DontInline @ForceCompile(compLevel = C2) + @DontInline + @ForceCompile(CompLevel.C2) public RefPoint test96_helper(RefPoint rp) { return rp; } - @DontCompile - public void test96_verifier(boolean warmup) { - int count = warmup ? 1 : 20000; // Do enough iteration to cause GC inside StubRoutines::store_inline_type_fields_to_buf + @Run(test = "test96") + public void test96_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20000; // Do enough iteration to cause GC inside StubRoutines::store_inline_type_fields_to_buf Number x = new Number(10); // old object for (int i=0; itest97. - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public int test97(Point p1, Point p2) { return test97_helper(p1, p2); } - @DontInline @DontCompile + @DontCompile public int test97_helper(Point p1, Point p2) { return p1.x + p1.y + p2.x + p2.y; } - @ForceCompile(compLevel = C1) - public void test97_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @ForceCompile(CompLevel.C1_SIMPLE) + public void test97_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC2 - same as test97, except the callee is compiled by c2. - @Test(compLevel = C2) + @Run(test = "test97") + public void run_test97_verifier(RunInfo info) { + test97_verifier(info); + } + + // C1->C2 - same as test97, except the callee is compiled by C2. + @Test(compLevel = CompLevel.C2) public int test98(Point p1, Point p2) { return test98_helper(p1, p2); } - @DontInline @DontCompile + @DontCompile public int test98_helper(Point p1, Point p2) { return p1.x + p1.y + p2.x + p2.y; } - @ForceCompile(compLevel = C1) - public void test98_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @ForceCompile(CompLevel.C1_SIMPLE) + public void test98_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC2 - same as test97, except the callee is a static method. - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public static int test99(Point p1, Point p2) { return test99_helper(p1, p2); } - @DontInline @DontCompile + @DontCompile public static int test99_helper(Point p1, Point p2) { return p1.x + p1.y + p2.x + p2.y; } - @ForceCompile(compLevel = C1) - public void test99_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @ForceCompile(CompLevel.C1_SIMPLE) + public void test99_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC1 invokestatic, packing causes stack growth (1 extra stack word). // Make sure stack frame is set up properly for GC. - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public float test100(FloatPoint fp1, FloatPoint fp2, RefPoint rp, int a1, int a2, int a3, int a4) { return test100_helper(fp1, fp2, rp, a1, a2, a3, a4); } @DontInline - @ForceCompile(compLevel = C1) + @ForceCompile(CompLevel.C1_SIMPLE) private static float test100_helper(FloatPoint fp1, FloatPoint fp2, RefPoint rp, int a1, int a2, int a3, int a4) { // On x64: // Scalarized entry -- all parameters are passed in registers @@ -2084,15 +2072,15 @@ private static float test100_helper(FloatPoint fp1, FloatPoint fp2, RefPoint rp, return fp1.x + fp1.y + fp2.x + fp2.y + rp.x.n + rp.y.n + a1 + a2 + a3 + a4; } - @DontCompile - public void test100_verifier(boolean warmup) { - int count = warmup ? 1 : 4; + @Run(test = "test100") + public void test100_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 4; for (int i=0; iC2 force GC for every allocation when storing the returned // fields back into a buffered object. - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public RefPoint test101(RefPoint rp) { return test101_helper(rp); } - @ForceCompile(compLevel = C2) @DontInline + @DontInline + @ForceCompile(CompLevel.C2) public RefPoint test101_helper(RefPoint rp) { return rp; } - @DontCompile - public void test101_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test101") + public void test101_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; iC2 instead. - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public RefPoint test102(RefPoint rp) { return test102_interp(rp); } - @DontCompile @DontInline + @DontInline public RefPoint test102_interp(RefPoint rp) { return test102_helper(rp); } - @ForceCompile(compLevel = C2) @DontInline + @DontInline + @ForceCompile(CompLevel.C2) public RefPoint test102_helper(RefPoint rp) { return rp; } - @DontCompile - public void test102_verifier(boolean warmup) { - int count = warmup ? 1 : 5; + @Run(test = "test102") + public void test102_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 5; for (int i=0; i()QTest103Value;" @@ -2176,9 +2166,9 @@ static primitive class Test103Value { static Object test103_v; - @DontCompile - public void test103_verifier(boolean warmup) { - if (warmup) { + @Run(test = "test103") + public void test103_verifier(RunInfo info) { + if (info.isWarmUp()) { // Make sure test103() is compiled before Test103Value is loaded return; } @@ -2189,7 +2179,7 @@ public void test103_verifier(boolean warmup) { // Same as test103, but with an inline class that's too big to return as fields. - @Test(compLevel = C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public void test104() { // when this method is compiled by C1, the Test104Value class is not yet loaded. test104_v = new Test104Value(); // invokestatic "Test104Value.()QTest104Value;" @@ -2216,9 +2206,9 @@ static primitive class Test104Value { static Object test104_v; - @DontCompile - public void test104_verifier(boolean warmup) { - if (warmup) { + @Run(test = "test104") + public void test104_verifier(RunInfo info) { + if (info.isWarmUp()) { // Make sure test104() is compiled before Test104Value is loaded return; } @@ -2229,7 +2219,7 @@ public void test104_verifier(boolean warmup) { // C2->C1 invokeinterface -- call Unverified Entry of MyImplVal1.func1 (compiled by C1 - has VVEP_RO) /// (same as test94, except we are calling func1, which shares VVEP and VVEP_RO - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test105(Intf intf, int a, int b) { return intf.func1(a, b); } @@ -2239,9 +2229,9 @@ public int test105(Intf intf, int a, int b) { new MyImplVal2(), }; - @DontCompile - public void test105_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test105") + public void test105_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC2 invokeinterface -- call Unverified Entry of MyImplVal2.func1 (compiled by C2 - has VVEP_RO) /// (same as test95, except we are calling func1, which shares VVEP and VVEP_RO - @Test(compLevel = C2) + @Test(compLevel = CompLevel.C2) public int test106(Intf intf, int a, int b) { return intf.func1(a, b); } @@ -2261,9 +2251,9 @@ public int test106(Intf intf, int a, int b) { new MyImplVal1(), }; - @DontCompile - public void test106_verifier(boolean warmup) { - int count = warmup ? 1 : 20; + @Run(test = "test106") + public void test106_verifier(RunInfo info) { + int count = info.isWarmUp() ? 1 : 20; for (int i=0; iC1 invokeinterface -- C2 calls call Unverified Entry of MyImplVal2X.func1 (compiled by // C1, with VVEP_RO==VVEP) // This test is developed to validate JDK-8230325. - @Test() @Warmup(0) @OSRCompileOnly + @Test(compLevel = CompLevel.WAIT_FOR_COMPILATION) public int test107(Intf intf, int a, int b) { return intf.func1(a, b); } @ForceCompile - public void test107_verifier(boolean warmup) { + public void test107_verifier() { Intf intf1 = new MyImplVal1X(); Intf intf2 = new MyImplVal2X(); @@ -2302,14 +2292,20 @@ public void test107_verifier(boolean warmup) { } } + @Run(test = "test107") + @Warmup(0) + public void run_test107_verifier() { + test107_verifier(); + } + // Same as test107, except we call MyImplVal2X.func2 (compiled by C1, VVEP_RO != VVEP) - @Test() @Warmup(0) @OSRCompileOnly + @Test(compLevel = CompLevel.WAIT_FOR_COMPILATION) public int test108(Intf intf, int a, int b) { return intf.func2(a, b, pointField); } @ForceCompile - public void test108_verifier(boolean warmup) { + public void test108_verifier() { Intf intf1 = new MyImplVal1X(); Intf intf2 = new MyImplVal2X(); @@ -2331,14 +2327,20 @@ public void test108_verifier(boolean warmup) { } } + @Run(test = "test108") + @Warmup(0) + public void run_test108_verifier() { + test108_verifier(); + } + // Same as test107, except we call MyImplPojo3.func2 (compiled by C1, VVEP_RO == VEP) - @Test() @Warmup(0) @OSRCompileOnly + @Test(compLevel = CompLevel.WAIT_FOR_COMPILATION) public int test109(Intf intf, int a, int b) { return intf.func2(a, b, pointField); } @ForceCompile - public void test109_verifier(boolean warmup) { + public void test109_verifier() { Intf intf1 = new MyImplPojo0(); Intf intf2 = new MyImplPojo3(); @@ -2359,4 +2361,10 @@ public void test109_verifier(boolean warmup) { } } } + + @Run(test = "test109") + @Warmup(0) + public void run_test109_verifier() { + test109_verifier(); + } } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestGetfieldChains.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestGetfieldChains.java index cd1e91ed553..d2183100fea 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestGetfieldChains.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestGetfieldChains.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2020, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2020, 2021, 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 @@ -21,103 +21,88 @@ * questions. */ - package compiler.valhalla.inlinetypes; -import java.lang.invoke.*; -import java.lang.reflect.Method; -import java.nio.file.NoSuchFileException; -import java.util.Arrays; - +import compiler.lib.ir_framework.CompLevel; +import compiler.lib.ir_framework.Run; +import compiler.lib.ir_framework.Scenario; +import compiler.lib.ir_framework.Test; import jdk.test.lib.Asserts; + /* * @test * @key randomness * @summary Verify that chains of getfields on flattened fields are correctly optimized - * @library /testlibrary /test/lib /compiler/whitebox / + * @library /test/lib / * @requires os.simpleArch == "x64" - * @compile TestGetfieldChains.java NamedRectangle.java Rectangle.java Point.java GetfieldChains.jcod - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestGetfieldChains + * @compile GetfieldChains.jcod + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestGetfieldChains */ -public class TestGetfieldChains extends InlineTypeTest { - public static final int C1 = COMP_LEVEL_SIMPLE; - public static final int C2 = COMP_LEVEL_FULL_OPTIMIZATION; - - public static void main(String[] args) throws Throwable { - TestGetfieldChains test = new TestGetfieldChains(); - test.run(args, TestGetfieldChains.class); - } - - @Override - public int getNumScenarios() { - return 5; - } - - @Override - public String[] getVMParameters(int scenario) { - switch (scenario) { - case 0: return new String[] { // C1 only - "-XX:TieredStopAtLevel=1", - "-XX:+TieredCompilation", - }; - case 1: return new String[] { // C2 only. (Make sure the tests are correctly written) - "-XX:TieredStopAtLevel=4", - "-XX:-TieredCompilation", - "-XX:-OmitStackTraceInFastThrow", - }; - case 2: return new String[] { // interpreter only - "-Xint", - }; - case 3: return new String[] { - // Xcomp Only C1. - "-XX:TieredStopAtLevel=1", - "-XX:+TieredCompilation", - "-Xcomp", - }; - case 4: return new String[] { - // Xcomp Only C2. - "-XX:TieredStopAtLevel=4", - "-XX:-TieredCompilation", - "-XX:-OmitStackTraceInFastThrow", - "-Xcomp", - }; - } - return null; +public class TestGetfieldChains { + + public static void main(String[] args) { + + final Scenario[] scenarios = { + new Scenario(0, + // C1 only + "-XX:TieredStopAtLevel=1", + "-XX:+TieredCompilation"), + new Scenario(1, + // C2 only. (Make sure the tests are correctly written) + "-XX:TieredStopAtLevel=4", + "-XX:-TieredCompilation", + "-XX:-OmitStackTraceInFastThrow"), + new Scenario(2, + // interpreter only + "-Xint"), + new Scenario(3, + // Xcomp Only C1. + "-XX:TieredStopAtLevel=1", + "-XX:+TieredCompilation", + "-Xcomp"), + new Scenario(4, + // Xcomp Only C2. + "-XX:TieredStopAtLevel=4", + "-XX:-TieredCompilation", + "-XX:-OmitStackTraceInFastThrow", + "-Xcomp") + }; + + InlineTypes.getFramework() + .addScenarios(scenarios) + .start(); } + // Simple chain of getfields ending with primitive field - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public int test1() { return NamedRectangle.getP1X(new NamedRectangle()); } - @DontCompile - public void test1_verifier(boolean warmup) { + @Run(test = "test1") + public void test1_verifier() { int res = test1(); Asserts.assertEQ(res, 4); } // Simple chain of getfields ending with a flattened field - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public Point test2() { return NamedRectangle.getP1(new NamedRectangle()); } - @DontCompile - public void test2_verifier(boolean warmup) { + @Run(test = "test2") + public void test2_verifier() { Point p = test2(); Asserts.assertEQ(p.x, 4); Asserts.assertEQ(p.y, 7); } // Chain of getfields but the initial receiver is null - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public NullPointerException test3() { NullPointerException npe = null; try { @@ -128,8 +113,8 @@ public NullPointerException test3() { return npe; } - @DontCompile - public void test3_verifier(boolean warmup) { + @Run(test = "test3") + public void test3_verifier() { NullPointerException npe = test3(); Asserts.assertNE(npe, null); StackTraceElement st = npe.getStackTrace()[0]; @@ -138,7 +123,7 @@ public void test3_verifier(boolean warmup) { } // Chain of getfields but one getfield in the middle of the chain trigger an illegal access - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public IllegalAccessError test4() { IllegalAccessError iae = null; try { @@ -149,8 +134,8 @@ public IllegalAccessError test4() { return iae; } - @DontCompile - public void test4_verifier(boolean warmup) { + @Run(test = "test4") + public void test4_verifier() { IllegalAccessError iae = test4(); Asserts.assertNE(iae, null); StackTraceElement st = iae.getStackTrace()[0]; @@ -160,7 +145,7 @@ public void test4_verifier(boolean warmup) { } // Chain of getfields but the last getfield trigger a NoSuchFieldError - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public NoSuchFieldError test5() { NoSuchFieldError nsfe = null; try { @@ -171,8 +156,8 @@ public NoSuchFieldError test5() { return nsfe; } - @DontCompile - public void test5_verifier(boolean warmup) { + @Run(test = "test5") + public void test5_verifier() { NoSuchFieldError nsfe = test5(); Asserts.assertNE(nsfe, null); StackTraceElement st = nsfe.getStackTrace()[0]; @@ -191,26 +176,26 @@ static primitive class Container { EmptyContainer container1 = new EmptyContainer(); } - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public EmptyType test6() { Container c = new Container(); return c.container1.et; } - @DontCompile - public void test6_verifier(boolean warmup) { + @Run(test = "test6") + public void test6_verifier() { EmptyType et = test6(); Asserts.assertEQ(et, EmptyType.default); } - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public EmptyType test7() { Container[] ca = new Container[10]; return ca[3].container0.et; } - @DontCompile - public void test7_verifier(boolean warmup) { + @Run(test = "test7") + public void test7_verifier() { EmptyType et = test7(); Asserts.assertEQ(et, EmptyType.default); } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestIntrinsics.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestIntrinsics.java index 167a32128ef..07fae417ff1 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestIntrinsics.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestIntrinsics.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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 @@ -23,42 +23,46 @@ package compiler.valhalla.inlinetypes; +import jdk.internal.misc.Unsafe; +import jdk.test.lib.Asserts; +import compiler.lib.ir_framework.*; + import java.lang.reflect.Array; import java.lang.reflect.Field; import java.util.Arrays; -import java.util.List; -import jdk.test.lib.Asserts; -import jdk.internal.misc.Unsafe; +import static compiler.valhalla.inlinetypes.InlineTypes.IRNode.*; +import static compiler.valhalla.inlinetypes.InlineTypes.rI; +import static compiler.valhalla.inlinetypes.InlineTypes.rL; /* * @test * @key randomness * @summary Test intrinsic support for inline types - * @library /testlibrary /test/lib /compiler/whitebox / + * @library /test/lib / * @modules java.base/jdk.internal.misc * @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64") - * @compile TestIntrinsics.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestIntrinsics + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestIntrinsics */ -public class TestIntrinsics extends InlineTypeTest { - // Extra VM parameters for some test scenarios. See InlineTypeTest.getVMParameters() - @Override - public String[] getExtraVMParameters(int scenario) { - switch (scenario) { - case 3: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:FlatArrayElementMaxSize=-1"}; - case 4: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:+UnlockExperimentalVMOptions", "-XX:PerMethodSpecTrapLimit=0", "-XX:PerMethodTrapLimit=0"}; + +@ForceCompileClassInitializer +public class TestIntrinsics { + + public static void main(String[] args) { + + Scenario[] scenarios = InlineTypes.DEFAULT_SCENARIOS; + for (Scenario scenario: scenarios) { + scenario.addFlags("--add-exports", "java.base/jdk.internal.misc=ALL-UNNAMED"); } - return null; - } + scenarios[3].addFlags("-XX:-MonomorphicArrayCheck", "-XX:FlatArrayElementMaxSize=-1"); + scenarios[4].addFlags("-XX:-MonomorphicArrayCheck", "-XX:+UnlockExperimentalVMOptions", "-XX:PerMethodSpecTrapLimit=0", "-XX:PerMethodTrapLimit=0"); - public static void main(String[] args) throws Throwable { - TestIntrinsics test = new TestIntrinsics(); - test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class); + InlineTypes.getFramework() + .addScenarios(scenarios) + .addHelperClasses(MyValue1.class, + MyValue2.class, + MyValue2Inline.class) + .start(); } // Test correctness of the Class::isAssignableFrom intrinsic @@ -67,8 +71,8 @@ public boolean test1(Class supercls, Class subcls) { return supercls.isAssignableFrom(subcls); } - @DontCompile - public void test1_verifier(boolean warmup) { + @Run(test = "test1") + public void test1_verifier() { Asserts.assertTrue(test1(java.util.AbstractList.class, java.util.ArrayList.class), "test1_1 failed"); Asserts.assertTrue(test1(MyValue1.ref.class, MyValue1.ref.class), "test1_2 failed"); Asserts.assertTrue(test1(MyValue1.class, MyValue1.class), "test1_3 failed"); @@ -82,7 +86,8 @@ public void test1_verifier(boolean warmup) { } // Verify that Class::isAssignableFrom checks with statically known classes are folded - @Test(failOn = LOADK) + @Test + @IR(failOn = {LOADK}) public boolean test2() { boolean check1 = java.util.AbstractList.class.isAssignableFrom(java.util.ArrayList.class); boolean check2 = MyValue1.ref.class.isAssignableFrom(MyValue1.ref.class); @@ -97,8 +102,8 @@ public boolean test2() { return check1 && check2 && check3 && check4 && check5 && check6 && check7 && check8 && check9 && check10; } - @DontCompile - public void test2_verifier(boolean warmup) { + @Run(test = "test2") + public void test2_verifier() { Asserts.assertTrue(test2(), "test2 failed"); } @@ -108,8 +113,8 @@ public Class test3(Class cls) { return cls.getSuperclass(); } - @DontCompile - public void test3_verifier(boolean warmup) { + @Run(test = "test3") + public void test3_verifier() { Asserts.assertTrue(test3(Object.class) == null, "test3_1 failed"); Asserts.assertTrue(test3(MyValue1.ref.class) == MyAbstract.class, "test3_2 failed"); Asserts.assertTrue(test3(MyValue1.val.class) == MyAbstract.class, "test3_3 failed"); @@ -117,7 +122,8 @@ public void test3_verifier(boolean warmup) { } // Verify that Class::getSuperclass checks with statically known classes are folded - @Test(failOn = LOADK) + @Test + @IR(failOn = {LOADK}) public boolean test4() { boolean check1 = Object.class.getSuperclass() == null; boolean check2 = MyValue1.ref.class.getSuperclass() == MyAbstract.class; @@ -126,8 +132,8 @@ public boolean test4() { return check1 && check2 && check3 && check4; } - @DontCompile - public void test4_verifier(boolean warmup) { + @Run(test = "test4") + public void test4_verifier() { Asserts.assertTrue(test4(), "test4 failed"); } @@ -137,8 +143,8 @@ public String test5(MyValue1 v) { return v.toString(); } - @DontCompile - public void test5_verifier(boolean warmup) { + @Run(test = "test5") + public void test5_verifier() { MyValue1 v = MyValue1.createDefaultInline(); test5(v); } @@ -149,8 +155,8 @@ public int test6(MyValue1 v) { return v.hashCode(); } - @DontCompile - public void test6_verifier(boolean warmup) { + @Run(test = "test6") + public void test6_verifier() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); int res = test6(v); Asserts.assertEQ(res, v.hashCode()); @@ -163,8 +169,8 @@ public Object[] test7(Class componentType, int len) { return va; } - @DontCompile - public void test7_verifier(boolean warmup) { + @Run(test = "test7") + public void test7_verifier() { int len = Math.abs(rI) % 42; long hash = MyValue1.createDefaultDontInline().hashPrimitive(); Object[] va = test7(MyValue1.class, len); @@ -179,8 +185,8 @@ public boolean test8(Class c, MyValue1 vt) { return c.isInstance(vt); } - @DontCompile - public void test8_verifier(boolean warmup) { + @Run(test = "test8") + public void test8_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); boolean result = test8(MyValue1.class, vt); Asserts.assertTrue(result); @@ -193,8 +199,8 @@ public boolean test9(Class c, MyValue1 vt) { return c.isInstance(vt); } - @DontCompile - public void test9_verifier(boolean warmup) { + @Run(test = "test9") + public void test9_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); boolean result = test9(MyValue2.class, vt); Asserts.assertFalse(result); @@ -208,8 +214,8 @@ public Object test10(Class c, MyValue1 vt) { return c.cast(vt); } - @DontCompile - public void test10_verifier(boolean warmup) { + @Run(test = "test10") + public void test10_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); Object result = test10(MyValue1.class, vt); Asserts.assertEQ(((MyValue1)result).hash(), vt.hash()); @@ -220,8 +226,8 @@ public Object test11(Class c, MyValue1 vt) { return c.cast(vt); } - @DontCompile - public void test11_verifier(boolean warmup) { + @Run(test = "test11") + public void test11_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); try { test11(MyValue2.class, vt); @@ -235,8 +241,8 @@ public Object test12(MyValue1 vt) { return MyValue1.class.cast(vt); } - @DontCompile - public void test12_verifier(boolean warmup) { + @Run(test = "test12") + public void test12_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); Object result = test12(vt); Asserts.assertEQ(((MyValue1)result).hash(), vt.hash()); @@ -247,8 +253,8 @@ public Object test13(MyValue1 vt) { return MyValue2.class.cast(vt); } - @DontCompile - public void test13_verifier(boolean warmup) { + @Run(test = "test13") + public void test13_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); try { test13(vt); @@ -266,8 +272,8 @@ public void test14(int len, long hash) { } } - @DontCompile - public void test14_verifier(boolean warmup) { + @Run(test = "test14") + public void test14_verifier() { int len = Math.abs(rI) % 42; long hash = MyValue1.createDefaultDontInline().hashPrimitive(); test14(len, hash); @@ -279,8 +285,8 @@ public int test15(Object v) { return v.hashCode(); } - @DontCompile - public void test15_verifier(boolean warmup) { + @Run(test = "test15") + public void test15_verifier() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); int res = test15(v); Asserts.assertEQ(res, v.hashCode()); @@ -291,8 +297,8 @@ public int test16(Object v) { return System.identityHashCode(v); } - @DontCompile - public void test16_verifier(boolean warmup) { + @Run(test = "test16") + public void test16_verifier() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); int res = test16(v); Asserts.assertEQ(res, System.identityHashCode((Object)v)); @@ -303,8 +309,8 @@ public int test17(Object v) { return System.identityHashCode(v); } - @DontCompile - public void test17_verifier(boolean warmup) { + @Run(test = "test17") + public void test17_verifier() { Integer v = Integer.valueOf(rI); int res = test17(v); Asserts.assertEQ(res, System.identityHashCode(v)); @@ -315,8 +321,8 @@ public int test18(Object v) { return System.identityHashCode(v); } - @DontCompile - public void test18_verifier(boolean warmup) { + @Run(test = "test18") + public void test18_verifier() { Object v = null; int res = test18(v); Asserts.assertEQ(res, System.identityHashCode(v)); @@ -329,8 +335,8 @@ public int test19(MyValue1 vt1, MyValue1 vt2, boolean b) { return res.hashCode(); } - @DontCompile - public void test19_verifier(boolean warmup) { + @Run(test = "test19") + public void test19_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); int res = test19(vt, vt, true); Asserts.assertEQ(res, vt.hashCode()); @@ -344,8 +350,8 @@ public String test20(MyValue1 vt1, MyValue1 vt2, boolean b) { return res.toString(); } - @DontCompile - public void test20_verifier(boolean warmup) { + @Run(test = "test20") + public void test20_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); String res = test20(vt, vt, true); Asserts.assertEQ(res, vt.toString()); @@ -374,20 +380,22 @@ public void test20_verifier(boolean warmup) { protected static final String CALL_Unsafe = START + "CallStaticJava" + MID + "# Static jdk.internal.misc.Unsafe::" + END; - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public int test21(MyValue1 v) { return U.getInt(v, X_OFFSET); } - @DontCompile - public void test21_verifier(boolean warmup) { + @Run(test = "test21") + public void test21_verifier() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); int res = test21(v); Asserts.assertEQ(res, v.x); } MyValue1 test22_vt; - @Test(failOn=CALL_Unsafe + ALLOC) + @Test + @IR(failOn = {CALL_Unsafe, ALLOC}) public void test22(MyValue1 v) { v = U.makePrivateBuffer(v); U.putInt(v, X_OFFSET, rI); @@ -395,20 +403,21 @@ public void test22(MyValue1 v) { test22_vt = v; } - @DontCompile - public void test22_verifier(boolean warmup) { + @Run(test = "test22") + public void test22_verifier() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); test22(v.setX(v, 0)); Asserts.assertEQ(test22_vt.hash(), v.hash()); } - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public int test23(MyValue1 v, long offset) { return U.getInt(v, offset); } - @DontCompile - public void test23_verifier(boolean warmup) { + @Run(test = "test23") + public void test23_verifier() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); int res = test23(v, X_OFFSET); Asserts.assertEQ(res, v.x); @@ -416,13 +425,14 @@ public void test23_verifier(boolean warmup) { MyValue1 test24_vt = MyValue1.createWithFieldsInline(rI, rL); - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public int test24(long offset) { return U.getInt(test24_vt, offset); } - @DontCompile - public void test24_verifier(boolean warmup) { + @Run(test = "test24") + public void test24_verifier() { int res = test24(X_OFFSET); Asserts.assertEQ(res, test24_vt.x); } @@ -444,8 +454,8 @@ public Test25Value[] test25(Test25Value element) { return (Test25Value[]) newArray; } - @DontCompile - public void test25_verifier(boolean warmup) { + @Run(test = "test25") + public void test25_verifier() { Test25Value vt = new Test25Value(); test25(vt); } @@ -460,8 +470,8 @@ public Object test26() { return Array.newInstance(ca[0], 1); } - @DontCompile - public void test26_verifier(boolean warmup) { + @Run(test = "test26") + public void test26_verifier() { Object[] res = (Object[])test26(); Asserts.assertEQ(((MyValue1)res[0]).hashPrimitive(), MyValue1.createDefaultInline().hashPrimitive()); } @@ -478,13 +488,14 @@ public void test26_verifier(boolean warmup) { } } - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public MyValue1.ref test27() { return (MyValue1.ref)U.getReference(this, TEST27_OFFSET); } - @DontCompile - public void test27_verifier(boolean warmup) { + @Run(test = "test27") + public void test27_verifier() { test27_vt = null; MyValue1.ref res = test27(); Asserts.assertEQ(res, null); @@ -494,13 +505,14 @@ public void test27_verifier(boolean warmup) { } // Mismatched type - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public int test28(MyValue1 v) { return U.getByte(v, X_OFFSET); } - @DontCompile - public void test28_verifier(boolean warmup) { + @Run(test = "test28") + public void test28_verifier() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); int res = test28(v); if (java.nio.ByteOrder.nativeOrder() == java.nio.ByteOrder.LITTLE_ENDIAN) { @@ -511,7 +523,8 @@ public void test28_verifier(boolean warmup) { } // Wrong alignment - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public long test29(MyValue1 v) { // Read the field that's guaranteed to not be last in the // inline type so we don't read out of bounds. @@ -521,8 +534,8 @@ public long test29(MyValue1 v) { return U.getLong(v, Y_OFFSET+1); } - @DontCompile - public void test29_verifier(boolean warmup) { + @Run(test = "test29") + public void test29_verifier() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); long res = test29(v); if (java.nio.ByteOrder.nativeOrder() == java.nio.ByteOrder.LITTLE_ENDIAN) { @@ -541,7 +554,8 @@ public void test29_verifier(boolean warmup) { } // getValue to retrieve flattened field from inline type - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public MyValue2 test30(MyValue1 v) { if (V1_FLATTENED) { return U.getValue(v, V1_OFFSET, MyValue2.val.class); @@ -549,8 +563,8 @@ public MyValue2 test30(MyValue1 v) { return (MyValue2)U.getReference(v, V1_OFFSET); } - @DontCompile - public void test30_verifier(boolean warmup) { + @Run(test = "test30") + public void test30_verifier() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); MyValue2 res = test30(v); Asserts.assertEQ(res.hash(), v.v1.hash()); @@ -570,7 +584,8 @@ public void test30_verifier(boolean warmup) { } // getValue to retrieve flattened field from object - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public MyValue1 test31() { if (TEST31_VT_FLATTENED) { return U.getValue(this, TEST31_VT_OFFSET, MyValue1.val.class); @@ -578,15 +593,16 @@ public MyValue1 test31() { return (MyValue1)U.getReference(this, TEST31_VT_OFFSET); } - @DontCompile - public void test31_verifier(boolean warmup) { + @Run(test = "test31") + public void test31_verifier() { test31_vt = MyValue1.createWithFieldsInline(rI, rL); MyValue1 res = test31(); Asserts.assertEQ(res.hash(), test31_vt.hash()); } // putValue to set flattened field in object - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public void test32(MyValue1 vt) { if (TEST31_VT_FLATTENED) { U.putValue(this, TEST31_VT_OFFSET, MyValue1.val.class, vt); @@ -595,8 +611,8 @@ public void test32(MyValue1 vt) { } } - @DontCompile - public void test32_verifier(boolean warmup) { + @Run(test = "test32") + public void test32_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); test31_vt = MyValue1.createDefaultInline(); test32(vt); @@ -616,7 +632,8 @@ public void test32_verifier(boolean warmup) { } } // getValue to retrieve flattened field from array - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public MyValue1 test33(MyValue1[] arr) { if (TEST33_FLATTENED_ARRAY) { return U.getValue(arr, TEST33_BASE_OFFSET + TEST33_INDEX_SCALE, MyValue1.val.class); @@ -624,8 +641,8 @@ public MyValue1 test33(MyValue1[] arr) { return (MyValue1)U.getReference(arr, TEST33_BASE_OFFSET + TEST33_INDEX_SCALE); } - @DontCompile - public void test33_verifier(boolean warmup) { + @Run(test = "test33") + public void test33_verifier() { MyValue1[] arr = new MyValue1[2]; MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); arr[1] = vt; @@ -634,7 +651,8 @@ public void test33_verifier(boolean warmup) { } // putValue to set flattened field in array - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public void test34(MyValue1[] arr, MyValue1 vt) { if (TEST33_FLATTENED_ARRAY) { U.putValue(arr, TEST33_BASE_OFFSET + TEST33_INDEX_SCALE, MyValue1.val.class, vt); @@ -643,8 +661,8 @@ public void test34(MyValue1[] arr, MyValue1 vt) { } } - @DontCompile - public void test34_verifier(boolean warmup) { + @Run(test = "test34") + public void test34_verifier() { MyValue1[] arr = new MyValue1[2]; MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); test34(arr, vt); @@ -653,7 +671,8 @@ public void test34_verifier(boolean warmup) { // getValue to retrieve flattened field from object with unknown // container type - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public MyValue1 test35(Object o) { if (TEST31_VT_FLATTENED) { return U.getValue(o, TEST31_VT_OFFSET, MyValue1.val.class); @@ -661,8 +680,8 @@ public MyValue1 test35(Object o) { return (MyValue1)U.getReference(o, TEST31_VT_OFFSET); } - @DontCompile - public void test35_verifier(boolean warmup) { + @Run(test = "test35") + public void test35_verifier() { test31_vt = MyValue1.createWithFieldsInline(rI, rL); MyValue1 res = test35(this); Asserts.assertEQ(res.hash(), test31_vt.hash()); @@ -670,7 +689,8 @@ public void test35_verifier(boolean warmup) { // getValue to retrieve flattened field from object at unknown // offset - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public MyValue1 test36(long offset) { if (TEST31_VT_FLATTENED) { return U.getValue(this, offset, MyValue1.val.class); @@ -678,8 +698,8 @@ public MyValue1 test36(long offset) { return (MyValue1)U.getReference(this, offset); } - @DontCompile - public void test36_verifier(boolean warmup) { + @Run(test = "test36") + public void test36_verifier() { test31_vt = MyValue1.createWithFieldsInline(rI, rL); MyValue1 res = test36(TEST31_VT_OFFSET); Asserts.assertEQ(res.hash(), test31_vt.hash()); @@ -687,7 +707,8 @@ public void test36_verifier(boolean warmup) { // putValue to set flattened field in object with unknown // container - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public void test37(Object o, MyValue1 vt) { if (TEST31_VT_FLATTENED) { U.putValue(o, TEST31_VT_OFFSET, MyValue1.val.class, vt); @@ -696,8 +717,8 @@ public void test37(Object o, MyValue1 vt) { } } - @DontCompile - public void test37_verifier(boolean warmup) { + @Run(test = "test37") + public void test37_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); test31_vt = MyValue1.createDefaultInline(); test37(this, vt); @@ -706,7 +727,8 @@ public void test37_verifier(boolean warmup) { // putValue to set flattened field in object, non inline argument // to store - @Test(match = { CALL_Unsafe }, matchCount = { 1 }) + @Test + @IR(counts = {CALL_Unsafe, "= 1"}) public void test38(Object o) { if (TEST31_VT_FLATTENED) { U.putValue(this, TEST31_VT_OFFSET, MyValue1.val.class, o); @@ -715,15 +737,16 @@ public void test38(Object o) { } } - @DontCompile - public void test38_verifier(boolean warmup) { + @Run(test = "test38") + public void test38_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); test31_vt = MyValue1.createDefaultInline(); test38(vt); Asserts.assertEQ(vt.hash(), test31_vt.hash()); } - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public MyValue1 test39(MyValue1 v) { v = U.makePrivateBuffer(v); U.putInt(v, X_OFFSET, rI); @@ -731,8 +754,8 @@ public MyValue1 test39(MyValue1 v) { return v; } - @DontCompile - public void test39_verifier(boolean warmup) { + @Run(test = "test39") + public void test39_verifier() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); MyValue1 res = test39(v.setX(v, 0)); Asserts.assertEQ(res.hash(), v.hash()); @@ -745,8 +768,8 @@ public Object[] test40(Class componentType, int len) { return va; } - @DontCompile - public void test40_verifier(boolean warmup) { + @Run(test = "test40") + public void test40_verifier() { int len = Math.abs(rI) % 42; Object[] va = test40(MyValue1.ref.class, len); for (int i = 0; i < len; ++i) { @@ -760,8 +783,8 @@ public boolean test41(Class c, MyValue1.ref vt) { return c.isInstance(vt); } - @DontCompile - public void test41_verifier(boolean warmup) { + @Run(test = "test41") + public void test41_verifier() { MyValue1.ref vt = MyValue1.createWithFieldsInline(rI, rL); boolean result = test41(MyValue1.ref.class, vt); Asserts.assertTrue(result); @@ -774,8 +797,8 @@ public boolean test42(Class c, MyValue1.ref vt) { return c.isInstance(vt); } - @DontCompile - public void test42_verifier(boolean warmup) { + @Run(test = "test42") + public void test42_verifier() { MyValue1.ref vt = MyValue1.createWithFieldsInline(rI, rL); boolean result = test42(MyValue2.ref.class, vt); Asserts.assertFalse(result); @@ -789,8 +812,8 @@ public Object test43(Class c, MyValue1.ref vt) { return c.cast(vt); } - @DontCompile - public void test43_verifier(boolean warmup) { + @Run(test = "test43") + public void test43_verifier() { MyValue1.ref vt = MyValue1.createWithFieldsInline(rI, rL); Object result = test43(MyValue1.ref.class, vt); Asserts.assertEQ(((MyValue1)result).hash(), vt.hash()); @@ -803,8 +826,8 @@ public Object test44(Class c, MyValue1.ref vt) { return c.cast(vt); } - @DontCompile - public void test44_verifier(boolean warmup) { + @Run(test = "test44") + public void test44_verifier() { MyValue1.ref vt = MyValue1.createWithFieldsInline(rI, rL); try { test44(MyValue2.ref.class, vt); @@ -818,8 +841,8 @@ public Object test45(MyValue1.ref vt) { return MyValue1.ref.class.cast(vt); } - @DontCompile - public void test45_verifier(boolean warmup) { + @Run(test = "test45") + public void test45_verifier() { MyValue1.ref vt = MyValue1.createWithFieldsInline(rI, rL); Object result = test45(vt); Asserts.assertEQ(((MyValue1)result).hash(), vt.hash()); @@ -832,8 +855,8 @@ public Object test46(MyValue1.ref vt) { return MyValue2.ref.class.cast(vt); } - @DontCompile - public void test46_verifier(boolean warmup) { + @Run(test = "test46") + public void test46_verifier() { MyValue1.ref vt = MyValue1.createWithFieldsInline(rI, rL); test46(null); try { @@ -848,8 +871,8 @@ public Object test47(MyValue1.ref vt) { return MyValue1.val.class.cast(vt); } - @DontCompile - public void test47_verifier(boolean warmup) { + @Run(test = "test47") + public void test47_verifier() { MyValue1.ref vt = MyValue1.createWithFieldsInline(rI, rL); Object result = test47(vt); Asserts.assertEQ(((MyValue1)result).hash(), vt.hash()); @@ -865,8 +888,8 @@ public Object test48(Class c, MyValue1.ref vt) { return c.cast(vt); } - @DontCompile - public void test48_verifier(boolean warmup) { + @Run(test = "test48") + public void test48_verifier() { MyValue1.ref vt = MyValue1.createWithFieldsInline(rI, rL); Object result = test48(MyValue1.class, vt); Asserts.assertEQ(((MyValue1)result).hash(), vt.hash()); @@ -882,8 +905,8 @@ public Object test49(MyValue1 vt) { return MyValue1.ref.class.cast(vt); } - @DontCompile - public void test49_verifier(boolean warmup) { + @Run(test = "test49") + public void test49_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); Object result = test49(vt); Asserts.assertEQ(((MyValue1)result).hash(), vt.hash()); @@ -894,8 +917,8 @@ public Object test50(Class c, Object obj) { return c.cast(obj); } - @DontCompile - public void test50_verifier(boolean warmup) { + @Run(test = "test50") + public void test50_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); MyValue1[] va = new MyValue1[42]; MyValue1.ref[] vba = new MyValue1.ref[42]; @@ -930,8 +953,8 @@ public void test51(int len) { } } - @DontCompile - public void test51_verifier(boolean warmup) { + @Run(test = "test51") + public void test51_verifier() { int len = Math.abs(rI) % 42; test51(len); } @@ -958,8 +981,8 @@ public Object[][] test52(int len, int val) { return result; } - @DontCompile - public void test52_verifier(boolean warmup) { + @Run(test = "test52") + public void test52_verifier() { test52(1, 1); test52(1, 2); } @@ -1002,8 +1025,8 @@ public Object[][] test53(Class c1, Class c2, int len, int val) { return result; } - @DontCompile - public void test53_verifier(boolean warmup) { + @Run(test = "test53") + public void test53_verifier() { int len = Math.abs(rI) % 42; test53(MyValue1[].class, MyValue1.ref[].class, len, 1); test53(MyValue1[].class, MyValue1.ref[].class, len, 2); @@ -1018,7 +1041,6 @@ public void test54_callee(MyValue1.ref v) { // Use .ref here to make sure the ar } @Test() - @Warmup(10000) // Fill up the TLAB to trigger slow path allocation public MyValue1 test54(MyValue1 v) { v = U.makePrivateBuffer(v); test54_callee(v); @@ -1026,8 +1048,9 @@ public MyValue1 test54(MyValue1 v) { return v; } - @DontCompile - public void test54_verifier(boolean warmup) { + @Run(test = "test54") + @Warmup(10000) // Fill up the TLAB to trigger slow path allocation + public void test54_verifier() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); MyValue1 res = test54(v.setX(v, 0)); Asserts.assertEQ(res.hash(), v.hash()); @@ -1036,7 +1059,8 @@ public void test54_verifier(boolean warmup) { static final MyValue1 test55_vt = MyValue1.createWithFieldsInline(rI, rL); // Same as test30 but with constant field holder - @Test(failOn=CALL_Unsafe) + @Test + @IR(failOn = {CALL_Unsafe}) public MyValue2 test55() { if (V1_FLATTENED) { return U.getValue(test55_vt, V1_OFFSET, MyValue2.val.class); @@ -1044,8 +1068,8 @@ public MyValue2 test55() { return (MyValue2)U.getReference(test55_vt, V1_OFFSET); } - @DontCompile - public void test55_verifier(boolean warmup) { + @Run(test = "test55") + public void test55_verifier() { MyValue2 res = test55(); Asserts.assertEQ(res.hash(), test55_vt.v1.hash()); } @@ -1059,8 +1083,8 @@ public void test56(int idx) { } } - @DontCompile - public void test56_verifier(boolean warmup) { + @Run(test = "test56") + public void test56_verifier() { test56(0); } @@ -1073,8 +1097,8 @@ public void test57() { } } - @DontCompile - public void test57_verifier(boolean warmup) { + @Run(test = "test57") + public void test57_verifier() { test57(); } @@ -1086,8 +1110,8 @@ public boolean test58(Class c1, Class c2) throws Exception { return obj1 == obj2; } - @DontCompile - public void test58_verifier(boolean warmup) throws Exception { + @Run(test = "test58") + public void test58_verifier() throws Exception { boolean res = test58(MyValue1.class, MyValue1.class); Asserts.assertTrue(res); res = test58(Object.class, MyValue1.class); @@ -1105,8 +1129,8 @@ public void test59(Class c) throws Exception { } } - @DontCompile - public void test59_verifier(boolean warmup) throws Exception { + @Run(test = "test59") + public void test59_verifier() throws Exception { test59(Integer.class); try { test59(MyValue1.class); @@ -1124,8 +1148,8 @@ public boolean test60(Class c1, Class c2, boolean b1, boolean b2) throws E return obj1 == obj2; } - @DontCompile - public void test60_verifier(boolean warmup) throws Exception { + @Run(test = "test60") + public void test60_verifier() throws Exception { Asserts.assertTrue(test60(MyValue1.class, MyValue1.class, false, false)); Asserts.assertFalse(test60(MyValue1.class, MyValue2.class, false, false)); Asserts.assertFalse(test60(MyValue1.class, MyValue1.class, false, true)); diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestJNICalls.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestJNICalls.java index bf3662817f2..7e39353ebab 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestJNICalls.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestJNICalls.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, 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 @@ -24,32 +24,30 @@ package compiler.valhalla.inlinetypes; import jdk.test.lib.Asserts; +import compiler.lib.ir_framework.*; -import java.lang.reflect.Method; +import static compiler.valhalla.inlinetypes.InlineTypes.rI; +import static compiler.valhalla.inlinetypes.InlineTypes.rL; /* * @test * @key randomness * @summary Test calling native methods with inline type arguments from compiled code. - * @library /testlibrary /test/lib /compiler/whitebox / + * @library /test/lib / * @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64") - * @compile TestJNICalls.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestJNICalls + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestJNICalls */ -public class TestJNICalls extends InlineTypeTest { - // Extra VM parameters for some test scenarios. See InlineTypeTest.getVMParameters() - @Override - public String[] getExtraVMParameters(int scenario) { - return null; - } - public static void main(String[] args) throws Throwable { - TestJNICalls test = new TestJNICalls(); - test.run(args, MyValue1.class); +@ForceCompileClassInitializer +public class TestJNICalls { + + public static void main(String[] args) { + Scenario[] scenarios = InlineTypes.DEFAULT_SCENARIOS; + + InlineTypes.getFramework() + .addScenarios(scenarios) + .addHelperClasses(MyValue1.class) + .start(); } static { @@ -61,7 +59,6 @@ public static void main(String[] args) throws Throwable { // Pass an inline type to a native method that calls back into Java code and returns an inline type @Test - @Warmup(10000) // Make sure native method is compiled public MyValue1 test1(MyValue1 vt, boolean callback) { if (!callback) { return (MyValue1)testMethod1(vt); @@ -70,8 +67,9 @@ public MyValue1 test1(MyValue1 vt, boolean callback) { } } - @DontCompile - public void test1_verifier(boolean warmup) { + @Run(test = "test1") + @Warmup(10000) // Make sure native method is compiled + public void test1_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); MyValue1 result = test1(vt, false); Asserts.assertEQ(result.hash(), vt.hash()); @@ -81,13 +79,13 @@ public void test1_verifier(boolean warmup) { // Pass an inline type to a native method that calls the hash method and returns the result @Test - @Warmup(10000) // Make sure native method is compiled public long test2(MyValue1 vt) { return testMethod2(vt); } - @DontCompile - public void test2_verifier(boolean warmup) { + @Run(test = "test2") + @Warmup(10000) // Make sure native method is compiled + public void test2_verifier() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); long result = test2(vt); Asserts.assertEQ(result, vt.hash()); @@ -105,13 +103,13 @@ private MyValueWithNative(int x) { // Call a native method with an inline type receiver @Test - @Warmup(10000) // Make sure native method is compiled public int test3(MyValueWithNative vt) { return vt.testMethod3(); } - @DontCompile - public void test3_verifier(boolean warmup) { + @Run(test = "test3") + @Warmup(10000) // Make sure native method is compiled + public void test3_verifier() { MyValueWithNative vt = new MyValueWithNative(rI); int result = test3(vt); Asserts.assertEQ(result, rI); diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorld.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorld.java index 273cb03d3c2..68cfbbd242c 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorld.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorld.java @@ -23,49 +23,52 @@ package compiler.valhalla.inlinetypes; -import java.lang.invoke.*; +import compiler.lib.ir_framework.*; +import jdk.test.lib.Asserts; +import test.java.lang.invoke.lib.InstructionHelper; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import java.lang.reflect.Method; import java.util.Arrays; -import jdk.test.lib.Asserts; -import test.java.lang.invoke.lib.InstructionHelper; +import static compiler.valhalla.inlinetypes.InlineTypes.IRNode.*; +import static compiler.valhalla.inlinetypes.InlineTypes.*; /* * @test * @key randomness * @summary Test inline types in LWorld. - * @library /test/lib /test/jdk/lib/testlibrary/bytecode /test/jdk/java/lang/invoke/common /testlibrary /compiler/whitebox / - * @build jdk.experimental.bytecode.BasicClassBuilder test.java.lang.invoke.lib.InstructionHelper + * @library /test/lib /test/jdk/lib/testlibrary/bytecode /test/jdk/java/lang/invoke/common / * @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64") - * @compile TestLWorld.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestLWorld + * @build jdk.experimental.bytecode.BasicClassBuilder test.java.lang.invoke.lib.InstructionHelper + * @run driver/timeout=450 compiler.valhalla.inlinetypes.TestLWorld */ -public class TestLWorld extends InlineTypeTest { - // Extra VM parameters for some test scenarios. See InlineTypeTest.getVMParameters() - @Override - public String[] getExtraVMParameters(int scenario) { - switch (scenario) { - case 2: return new String[] {"-DVerifyIR=false"}; - case 3: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:FlatArrayElementMaxSize=-1"}; - case 4: return new String[] {"-XX:-MonomorphicArrayCheck"}; - } - return null; - } - public static void main(String[] args) throws Throwable { +@ForceCompileClassInitializer +public class TestLWorld { + + public static void main(String[] args) { // Make sure Test140Value is loaded but not linked Class class1 = Test140Value.class; // Make sure Test141Value is linked but not initialized Class class2 = Test141Value.class; class2.getDeclaredFields(); - TestLWorld test = new TestLWorld(); - test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class, MyValue3.class, - MyValue3Inline.class, Test51Value.class); + Scenario[] scenarios = InlineTypes.DEFAULT_SCENARIOS; + scenarios[2].addFlags("-DVerifyIR=false"); + scenarios[3].addFlags("-XX:-MonomorphicArrayCheck", "-XX:FlatArrayElementMaxSize=-1"); + scenarios[4].addFlags("-XX:-MonomorphicArrayCheck"); + + InlineTypes.getFramework() + .addScenarios(scenarios) + .addHelperClasses(MyValue1.class, + MyValue2.class, + MyValue2Inline.class, + MyValue3.class, + MyValue3Inline.class) + .start(); } // Helper methods @@ -98,7 +101,7 @@ public MyValue1 test1_inline2(Object o) { return (MyValue1)o; } - @Test() + @Test public MyValue1 test1() { MyValue1 vt = testValue1; vt = (MyValue1)test1_dontinline1(vt); @@ -108,8 +111,8 @@ public MyValue1 test1() { return vt; } - @DontCompile - public void test1_verifier(boolean warmup) { + @Run(test = "test1") + public void test1_verifier() { Asserts.assertEQ(test1().hash(), hash()); } @@ -142,7 +145,7 @@ public Object readStaticValueField4() { return (Object)staticValueField4; } - @Test() + @Test public long test2(MyValue1 vt1, Object vt2) { objectField1 = vt1; objectField2 = (MyValue1)vt2; @@ -166,8 +169,8 @@ public long test2(MyValue1 vt1, Object vt2) { staticValueField1.hash() + staticValueField2.hash() + staticValueField3.hashPrimitive(); } - @DontCompile - public void test2_verifier(boolean warmup) { + @Run(test = "test2") + public void test2_verifier() { MyValue1 vt = testValue1; MyValue1 def = MyValue1.createDefaultDontInline(); long result = test2(vt, vt); @@ -175,7 +178,7 @@ public void test2_verifier(boolean warmup) { } // Test merging inline types and objects - @Test() + @Test public Object test3(int state) { Object res = null; if (state == 0) { @@ -198,8 +201,8 @@ public Object test3(int state) { return res; } - @DontCompile - public void test3_verifier(boolean warmup) { + @Run(test = "test3") + public void test3_verifier() { objectField1 = valueField1; Object result = null; result = test3(0); @@ -221,7 +224,7 @@ public void test3_verifier(boolean warmup) { } // Test merging inline types and objects in loops - @Test() + @Test public Object test4(int iters) { Object res = Integer.valueOf(rI); for (int i = 0; i < iters; ++i) { @@ -234,8 +237,8 @@ public Object test4(int iters) { return res; } - @DontCompile - public void test4_verifier(boolean warmup) { + @Run(test = "test4") + public void test4_verifier() { Integer result1 = (Integer)test4(0); Asserts.assertEQ(result1, rI); int iters = (Math.abs(rI) % 10) + 1; @@ -245,28 +248,30 @@ public void test4_verifier(boolean warmup) { } // Test inline types in object variables that are live at safepoint - @Test(failOn = ALLOC + STORE + LOOP) - public long test5(MyValue1 arg, boolean deopt) { + @Test + @IR(failOn = {ALLOC, STORE, LOOP}) + public long test5(MyValue1 arg, boolean deopt, Method m) { Object vt1 = MyValue1.createWithFieldsInline(rI, rL); Object vt2 = MyValue1.createWithFieldsDontInline(rI, rL); Object vt3 = arg; Object vt4 = valueField1; if (deopt) { // uncommon trap - WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test5")); + TestFramework.deoptimize(m); } return ((MyValue1)vt1).hash() + ((MyValue1)vt2).hash() + ((MyValue1)vt3).hash() + ((MyValue1)vt4).hash(); } - @DontCompile - public void test5_verifier(boolean warmup) { - long result = test5(valueField1, !warmup); + @Run(test = "test5") + public void test5_verifier(RunInfo info) { + long result = test5(valueField1, !info.isWarmUp(), info.getTest()); Asserts.assertEQ(result, 4*hash()); } // Test comparing inline types with objects - @Test(failOn = LOAD + LOOP) + @Test + @IR(failOn = {LOAD, LOOP}) public boolean test6(Object arg) { Object vt = MyValue1.createWithFieldsInline(rI, rL); if (vt == arg || vt == (Object)valueField1 || vt == objectField1 || vt == null || @@ -276,8 +281,8 @@ public boolean test6(Object arg) { return false; } - @DontCompile - public void test6_verifier(boolean warmup) { + @Run(test = "test6") + public void test6_verifier() { boolean result = test6(null); Asserts.assertFalse(result); } @@ -294,8 +299,8 @@ public Object test7(boolean flag) { return res; } - @DontCompile - public void test7_verifier(boolean warmup) { + @Run(test = "test7") + public void test7_verifier() { test7(true); test7(false); } @@ -311,8 +316,8 @@ public Object test8(boolean flag) { return res; } - @DontCompile - public void test8_verifier(boolean warmup) { + @Run(test = "test8") + public void test8_verifier() { test8(true); test8(false); } @@ -328,8 +333,8 @@ public Object test9() { return o; } - @DontCompile - public void test9_verifier(boolean warmup) { + @Run(test = "test9") + public void test9_verifier() { test9(); } @@ -339,7 +344,8 @@ public Object test10_helper() { return valueField1; } - @Test(failOn = ALLOC + LOAD + STORE) + @Test + @IR(failOn = {ALLOC, LOAD, STORE}) public void test10(boolean flag) { Object o = null; if (flag) { @@ -350,8 +356,8 @@ public void test10(boolean flag) { valueField1 = (MyValue1)o; } - @DontCompile - public void test10_verifier(boolean warmup) { + @Run(test = "test10") + public void test10_verifier() { test10(true); test10(false); } @@ -378,7 +384,7 @@ public MyValue1 test11_inline2(MyInterface o) { return (MyValue1)o; } - @Test() + @Test public MyValue1 test11() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); vt = (MyValue1)test11_dontinline1(vt); @@ -388,8 +394,8 @@ public MyValue1 test11() { return vt; } - @DontCompile - public void test11_verifier(boolean warmup) { + @Run(test = "test11") + public void test11_verifier() { Asserts.assertEQ(test11().hash(), hash()); } @@ -411,7 +417,7 @@ public MyInterface readStaticValueField4AsInterface() { return (MyInterface)staticValueField4; } - @Test() + @Test public long test12(MyValue1 vt1, MyInterface vt2) { interfaceField1 = vt1; interfaceField2 = (MyValue1)vt2; @@ -435,8 +441,8 @@ public long test12(MyValue1 vt1, MyInterface vt2) { staticValueField1.hash() + staticValueField2.hash() + staticValueField3.hashPrimitive(); } - @DontCompile - public void test12_verifier(boolean warmup) { + @Run(test = "test12") + public void test12_verifier() { MyValue1 vt = testValue1; MyValue1 def = MyValue1.createDefaultDontInline(); long result = test12(vt, vt); @@ -457,7 +463,7 @@ public long hash() { } // Test merging inline types and interfaces - @Test() + @Test public MyInterface test13(int state) { MyInterface res = null; if (state == 0) { @@ -476,8 +482,8 @@ public MyInterface test13(int state) { return res; } - @DontCompile - public void test13_verifier(boolean warmup) { + @Run(test = "test13") + public void test13_verifier() { objectField1 = valueField1; MyInterface result = null; result = test13(0); @@ -495,7 +501,7 @@ public void test13_verifier(boolean warmup) { } // Test merging inline types and interfaces in loops - @Test() + @Test public MyInterface test14(int iters) { MyInterface res = new MyObject1(rI); for (int i = 0; i < iters; ++i) { @@ -508,8 +514,8 @@ public MyInterface test14(int iters) { return res; } - @DontCompile - public void test14_verifier(boolean warmup) { + @Run(test = "test14") + public void test14_verifier() { MyObject1 result1 = (MyObject1)test14(0); Asserts.assertEQ(result1.x, rI); int iters = (Math.abs(rI) % 10) + 1; @@ -519,28 +525,30 @@ public void test14_verifier(boolean warmup) { } // Test inline types in interface variables that are live at safepoint - @Test(failOn = ALLOC + STORE + LOOP) - public long test15(MyValue1 arg, boolean deopt) { + @Test + @IR(failOn = {ALLOC, STORE, LOOP}) + public long test15(MyValue1 arg, boolean deopt, Method m) { MyInterface vt1 = MyValue1.createWithFieldsInline(rI, rL); MyInterface vt2 = MyValue1.createWithFieldsDontInline(rI, rL); MyInterface vt3 = arg; MyInterface vt4 = valueField1; if (deopt) { // uncommon trap - WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test15")); + TestFramework.deoptimize(m); } return ((MyValue1)vt1).hash() + ((MyValue1)vt2).hash() + ((MyValue1)vt3).hash() + ((MyValue1)vt4).hash(); } - @DontCompile - public void test15_verifier(boolean warmup) { - long result = test15(valueField1, !warmup); + @Run(test = "test15") + public void test15_verifier(RunInfo info) { + long result = test15(valueField1, !info.isWarmUp(), info.getTest()); Asserts.assertEQ(result, 4*hash()); } // Test comparing inline types with interfaces - @Test(failOn = LOAD + LOOP) + @Test + @IR(failOn = {LOAD, LOOP}) public boolean test16(Object arg) { MyInterface vt = MyValue1.createWithFieldsInline(rI, rL); if (vt == arg || vt == (MyInterface)valueField1 || vt == interfaceField1 || vt == null || @@ -550,8 +558,8 @@ public boolean test16(Object arg) { return false; } - @DontCompile - public void test16_verifier(boolean warmup) { + @Run(test = "test16") + public void test16_verifier() { boolean result = test16(null); Asserts.assertFalse(result); } @@ -568,8 +576,8 @@ public MyValue1 test17(MyValue1 vt, Object obj) { return vt; } - @DontCompile - public void test17_verifier(boolean warmup) { + @Run(test = "test17") + public void test17_verifier() { MyValue1 vt = testValue1; MyValue1 result = test17(vt, Integer.valueOf(rI)); Asserts.assertEquals(result.hash(), vt.hash()); @@ -582,8 +590,8 @@ public MyValue1 test18(MyValue1 vt) { return vt; } - @DontCompile - public void test18_verifier(boolean warmup) { + @Run(test = "test18") + public void test18_verifier() { MyValue1 vt = testValue1; MyValue1 result = test18(vt); Asserts.assertEquals(result.hash(), vt.hash()); @@ -600,8 +608,8 @@ public void test19(MyValue1 vt) { } } - @DontCompile - public void test19_verifier(boolean warmup) { + @Run(test = "test19") + public void test19_verifier() { test19(valueField1); } @@ -616,8 +624,8 @@ public void test20(MyValue1 vt) { } } - @DontCompile - public void test20_verifier(boolean warmup) { + @Run(test = "test20") + public void test20_verifier() { test20(valueField1); } @@ -638,37 +646,37 @@ public void test20_verifier(boolean warmup) { private static final Integer[] testIntegerArray = new Integer[42]; // Test load from (flattened) inline type array disguised as object array - @Test() + @Test public Object test21(Object[] oa, int index) { return oa[index]; } - @DontCompile - public void test21_verifier(boolean warmup) { + @Run(test = "test21") + public void test21_verifier() { MyValue1 result = (MyValue1)test21(testValue1Array, Math.abs(rI) % 3); Asserts.assertEQ(result.hash(), hash()); } // Test load from (flattened) inline type array disguised as interface array - @Test() + @Test public Object test22Interface(MyInterface[] ia, int index) { return ia[index]; } - @DontCompile - public void test22Interface_verifier(boolean warmup) { + @Run(test = "test22Interface") + public void test22Interface_verifier() { MyValue1 result = (MyValue1)test22Interface(testValue1Array, Math.abs(rI) % 3); Asserts.assertEQ(result.hash(), hash()); } // Test load from (flattened) inline type array disguised as abstract array - @Test() + @Test public Object test22Abstract(MyAbstract[] ia, int index) { return ia[index]; } - @DontCompile - public void test22Abstract_verifier(boolean warmup) { + @Run(test = "test22Abstract") + public void test22Abstract_verifier() { MyValue1 result = (MyValue1)test22Abstract(testValue1Array, Math.abs(rI) % 3); Asserts.assertEQ(result.hash(), hash()); } @@ -679,13 +687,13 @@ public void test23_inline(Object[] oa, Object o, int index) { oa[index] = o; } - @Test() + @Test public void test23(Object[] oa, MyValue1 vt, int index) { test23_inline(oa, vt, index); } - @DontCompile - public void test23_verifier(boolean warmup) { + @Run(test = "test23") + public void test23_verifier() { int index = Math.abs(rI) % 3; MyValue1 vt = MyValue1.createWithFieldsInline(rI + 1, rL + 1); test23(testValue1Array, vt, index); @@ -705,13 +713,13 @@ public void test24_inline(Object[] oa, Object o, int index) { oa[index] = o; } - @Test() + @Test public void test24(Object[] oa, MyValue1 vt, int index) { test24_inline(oa, vt, index); } - @DontCompile - public void test24_verifier(boolean warmup) { + @Run(test = "test24") + public void test24_verifier() { int index = Math.abs(rI) % 3; try { test24(testIntegerArray, testValue1, index); @@ -726,13 +734,13 @@ public void test25_inline(Object[] oa, Object o, int index) { oa[index] = o; } - @Test() + @Test public void test25(Object[] oa, MyValue1 vt, int index) { test25_inline(oa, vt, index); } - @DontCompile - public void test25_verifier(boolean warmup) { + @Run(test = "test25") + public void test25_verifier() { int index = Math.abs(rI) % 3; try { test25(null, testValue1, index); @@ -748,13 +756,13 @@ public void test26Interface_inline(MyInterface[] ia, MyInterface i, int index) { ia[index] = i; } - @Test() + @Test public void test26Interface(MyInterface[] ia, MyValue1 vt, int index) { test26Interface_inline(ia, vt, index); } - @DontCompile - public void test26Interface_verifier(boolean warmup) { + @Run(test = "test26Interface") + public void test26Interface_verifier() { int index = Math.abs(rI) % 3; MyValue1 vt = MyValue1.createWithFieldsInline(rI + 1, rL + 1); test26Interface(testValue1Array, vt, index); @@ -774,13 +782,13 @@ public void test27Interface_inline(MyInterface[] ia, MyInterface i, int index) { ia[index] = i; } - @Test() + @Test public void test27Interface(MyInterface[] ia, MyValue1 vt, int index) { test27Interface_inline(ia, vt, index); } - @DontCompile - public void test27Interface_verifier(boolean warmup) { + @Run(test = "test27Interface") + public void test27Interface_verifier() { int index = Math.abs(rI) % 3; try { test27Interface(null, testValue1, index); @@ -796,13 +804,13 @@ public void test26Abstract_inline(MyAbstract[] ia, MyAbstract i, int index) { ia[index] = i; } - @Test() + @Test public void test26Abstract(MyAbstract[] ia, MyValue1 vt, int index) { test26Abstract_inline(ia, vt, index); } - @DontCompile - public void test26Abstract_verifier(boolean warmup) { + @Run(test = "test26Abstract") + public void test26Abstract_verifier() { int index = Math.abs(rI) % 3; MyValue1 vt = MyValue1.createWithFieldsInline(rI + 1, rL + 1); test26Abstract(testValue1Array, vt, index); @@ -822,13 +830,13 @@ public void test27Abstract_inline(MyAbstract[] ia, MyAbstract i, int index) { ia[index] = i; } - @Test() + @Test public void test27Abstract(MyAbstract[] ia, MyValue1 vt, int index) { test27Abstract_inline(ia, vt, index); } - @DontCompile - public void test27Abstract_verifier(boolean warmup) { + @Run(test = "test27Abstract") + public void test27Abstract_verifier() { int index = Math.abs(rI) % 3; try { test27Abstract(null, testValue1, index); @@ -844,13 +852,13 @@ public void test28_inline(Object[] oa, Object o, int index) { oa[index] = o; } - @Test() + @Test public void test28(Object[] oa, Object o, int index) { test28_inline(oa, o, index); } - @DontCompile - public void test28_verifier(boolean warmup) { + @Run(test = "test28") + public void test28_verifier() { int index = Math.abs(rI) % 3; MyValue1 vt1 = MyValue1.createWithFieldsInline(rI + 1, rL + 1); test28(testValue1Array, vt1, index); @@ -870,13 +878,13 @@ public void test29_inline(Object[] oa, Object o, int index) { oa[index] = o; } - @Test() + @Test public void test29(Object[] oa, Object o, int index) { test29_inline(oa, o, index); } - @DontCompile - public void test29_verifier(boolean warmup) { + @Run(test = "test29") + public void test29_verifier() { int index = Math.abs(rI) % 3; try { test29(testValue2Array, testValue1, index); @@ -892,13 +900,13 @@ public void test30_inline(Object[] oa, Object o, int index) { oa[index] = o; } - @Test() + @Test public void test30(Object[] oa, Object o, int index) { test30_inline(oa, o, index); } - @DontCompile - public void test30_verifier(boolean warmup) { + @Run(test = "test30") + public void test30_verifier() { int index = Math.abs(rI) % 3; try { test30(testIntegerArray, testValue1, index); @@ -914,13 +922,13 @@ public void test31Interface_inline(MyInterface[] ia, MyInterface i, int index) { ia[index] = i; } - @Test() + @Test public void test31Interface(MyInterface[] ia, MyInterface i, int index) { test31Interface_inline(ia, i, index); } - @DontCompile - public void test31Interface_verifier(boolean warmup) { + @Run(test = "test31Interface") + public void test31Interface_verifier() { int index = Math.abs(rI) % 3; MyValue1 vt1 = MyValue1.createWithFieldsInline(rI + 1, rL + 1); test31Interface(testValue1Array, vt1, index); @@ -940,13 +948,13 @@ public void test32Interface_inline(MyInterface[] ia, MyInterface i, int index) { ia[index] = i; } - @Test() + @Test public void test32Interface(MyInterface[] ia, MyInterface i, int index) { test32Interface_inline(ia, i, index); } - @DontCompile - public void test32Interface_verifier(boolean warmup) { + @Run(test = "test32Interface") + public void test32Interface_verifier() { int index = Math.abs(rI) % 3; try { test32Interface(testValue2Array, testValue1, index); @@ -962,13 +970,13 @@ public void test31Abstract_inline(MyAbstract[] ia, MyAbstract i, int index) { ia[index] = i; } - @Test() + @Test public void test31Abstract(MyAbstract[] ia, MyAbstract i, int index) { test31Abstract_inline(ia, i, index); } - @DontCompile - public void test31Abstract_verifier(boolean warmup) { + @Run(test = "test31Abstract") + public void test31Abstract_verifier() { int index = Math.abs(rI) % 3; MyValue1 vt1 = MyValue1.createWithFieldsInline(rI + 1, rL + 1); test31Abstract(testValue1Array, vt1, index); @@ -988,13 +996,13 @@ public void test32Abstract_inline(MyAbstract[] ia, MyAbstract i, int index) { ia[index] = i; } - @Test() + @Test public void test32Abstract(MyAbstract[] ia, MyAbstract i, int index) { test32Abstract_inline(ia, i, index); } - @DontCompile - public void test32Abstract_verifier(boolean warmup) { + @Run(test = "test32Abstract") + public void test32Abstract_verifier() { int index = Math.abs(rI) % 3; try { test32Abstract(testValue2Array, testValue1, index); @@ -1010,13 +1018,13 @@ public void test33_inline(Object[] oa, Object o, int index) { oa[index] = o; } - @Test() + @Test public void test33(Object[] oa, Object o, int index) { test33_inline(oa, o, index); } - @DontCompile - public void test33_verifier(boolean warmup) { + @Run(test = "test33") + public void test33_verifier() { int index = Math.abs(rI) % 3; try { test33(testValue1Array, null, index); @@ -1034,13 +1042,13 @@ public void test34_inline(Object[] oa, Object o, int index) { oa[index] = o; } - @Test() + @Test public void test34(Object[] oa, int index) { test34_inline(oa, null, index); } - @DontCompile - public void test34_verifier(boolean warmup) { + @Run(test = "test34") + public void test34_verifier() { int index = Math.abs(rI) % 3; try { test34(testValue1Array, index); @@ -1065,13 +1073,13 @@ public void test34_verifier(boolean warmup) { return_(); }); - @Test() + @Test public void test35(MyValue1[] va, int index) throws Throwable { setArrayElementNull.invoke(this, va, index); } - @DontCompile - public void test35_verifier(boolean warmup) throws Throwable { + @Run(test = "test35") + public void test35_verifier() throws Throwable { int index = Math.abs(rI) % 3; try { test35(testValue1Array, index); @@ -1083,13 +1091,13 @@ public void test35_verifier(boolean warmup) throws Throwable { } // Test writing an inline type to a null inline type array - @Test() + @Test public void test36(MyValue1[] va, MyValue1 vt, int index) { va[index] = vt; } - @DontCompile - public void test36_verifier(boolean warmup) { + @Run(test = "test36") + public void test36_verifier() { int index = Math.abs(rI) % 3; try { test36(null, testValue1Array[index], index); @@ -1105,13 +1113,13 @@ public void test37_inline(Object[] oa, Object o, int index) { oa[index] = o; } - @Test() + @Test public void test37(MyValue1[] va, Object o, int index) { test37_inline(va, o, index); } - @DontCompile - public void test37_verifier(boolean warmup) { + @Run(test = "test37") + public void test37_verifier() { int index = Math.abs(rI) % 3; MyValue1 vt1 = MyValue1.createWithFieldsInline(rI + 1, rL + 1); test37(testValue1Array, vt1, index); @@ -1133,7 +1141,7 @@ public Object[] test38_inline() { return new MyValue1[42]; } - @Test() + @Test public Object[] test38(Object[] oa, Object o, int i1, int i2, int num) { Object[] result = null; switch (num) { @@ -1164,8 +1172,8 @@ public Object[] test38(Object[] oa, Object o, int i1, int i2, int num) { return result; } - @DontCompile - public void test38_verifier(boolean warmup) { + @Run(test = "test38") + public void test38_verifier() { int index = Math.abs(rI) % 3; MyValue1[] va = new MyValue1[42]; Object[] result = test38(null, testValue1, index, index, 0); @@ -1205,7 +1213,7 @@ public Object test39_inline() { } // Same as above but merging into Object instead of Object[] - @Test() + @Test public Object test39(Object oa, Object o, int i1, int i2, int num) { Object result = null; switch (num) { @@ -1250,8 +1258,8 @@ public Object test39(Object oa, Object o, int i1, int i2, int num) { return result; } - @DontCompile - public void test39_verifier(boolean warmup) { + @Run(test = "test39") + public void test39_verifier() { int index = Math.abs(rI) % 3; MyValue1[] va = new MyValue1[42]; Object result = test39(null, testValue1, index, index, 0); @@ -1290,7 +1298,7 @@ public void test39_verifier(boolean warmup) { } // Test instanceof with inline types and arrays - @Test() + @Test public long test40(Object o, int index) { if (o instanceof MyValue1) { return ((MyValue1)o).hashInterpreted(); @@ -1308,8 +1316,8 @@ public long test40(Object o, int index) { return 0; } - @DontCompile - public void test40_verifier(boolean warmup) { + @Run(test = "test40") + public void test40_verifier() { int index = Math.abs(rI) % 3; long result = test40(testValue1, 0); Asserts.assertEQ(result, testValue1.hash()); @@ -1331,15 +1339,15 @@ public void test41_dontinline(Object o) { Asserts.assertEQ(o, rI); } - @Test() + @Test public void test41() { MyValue1[] vals = new MyValue1[] {testValue1}; test41_dontinline(vals[0].oa[0]); test41_dontinline(vals[0].oa[0]); } - @DontCompile - public void test41_verifier(boolean warmup) { + @Run(test = "test41") + public void test41_verifier() { test41(); } @@ -1347,26 +1355,26 @@ public void test41_verifier(boolean warmup) { private static final MyValue1.ref test42VT1 = MyValue1.createWithFieldsInline(rI, rL); private static final MyValue1.ref test42VT2 = MyValue1.createWithFieldsInline(rI + 1, rL + 1); - @Test() + @Test public void test42() { MyValue1[] vals = new MyValue1[] {(MyValue1) test42VT1, (MyValue1) test42VT2}; Asserts.assertEQ(vals[0].hash(), test42VT1.hash()); Asserts.assertEQ(vals[1].hash(), test42VT2.hash()); } - @DontCompile - public void test42_verifier(boolean warmup) { - if (!warmup) test42(); // We need -Xcomp behavior + @Run(test = "test42") + public void test42_verifier(RunInfo info) { + if (!info.isWarmUp()) test42(); // We need -Xcomp behavior } // Test for bug in Escape Analysis - @Test() - public long test43(boolean deopt) { + @Test + public long test43(boolean deopt, Method m) { MyValue1[] vals = new MyValue1[] {(MyValue1) test42VT1, (MyValue1) test42VT2}; if (deopt) { // uncommon trap - WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test43")); + TestFramework.deoptimize(m); Asserts.assertEQ(vals[0].hash(), test42VT1.hash()); Asserts.assertEQ(vals[1].hash(), test42VT2.hash()); } @@ -1374,9 +1382,9 @@ public long test43(boolean deopt) { return vals[0].hash(); } - @DontCompile - public void test43_verifier(boolean warmup) { - test43(!warmup); + @Run(test = "test43") + public void test43_verifier(RunInfo info) { + test43(!info.isWarmUp(), info.getTest()); } // Tests writing an array element with a (statically known) incompatible type @@ -1392,13 +1400,13 @@ public void test43_verifier(boolean warmup) { return_(); }); - @Test() + @Test public void test44(MyValue1[] va, int index, MyValue2 v) throws Throwable { setArrayElementIncompatible.invoke(this, va, index, v); } - @DontCompile - public void test44_verifier(boolean warmup) throws Throwable { + @Run(test = "test44") + public void test44_verifier() throws Throwable { int index = Math.abs(rI) % 3; try { test44(testValue1Array, index, testValue2); @@ -1415,13 +1423,13 @@ public void test45_inline(Object[] oa, Object o, int index) { oa[index] = o; } - @Test() + @Test public void test45(MyValue1[] va, int index, MyValue2 v) throws Throwable { test45_inline(va, v, index); } - @DontCompile - public void test45_verifier(boolean warmup) throws Throwable { + @Run(test = "test45") + public void test45_verifier() throws Throwable { int index = Math.abs(rI) % 3; try { test45(testValue1Array, index, testValue2); @@ -1439,8 +1447,8 @@ public boolean test46(MyValue1 vt) { return obj instanceof MyValue1; } - @DontCompile - public void test46_verifier(boolean warmup) { + @Run(test = "test46") + public void test46_verifier() { MyValue1 vt = testValue1; boolean result = test46(vt); Asserts.assertTrue(result); @@ -1452,8 +1460,8 @@ public boolean test47(MyValue1 vt) { return obj instanceof MyValue2; } - @DontCompile - public void test47_verifier(boolean warmup) { + @Run(test = "test47") + public void test47_verifier() { MyValue1 vt = testValue1; boolean result = test47(vt); Asserts.assertFalse(result); @@ -1464,8 +1472,8 @@ public boolean test48(Object obj) { return obj instanceof MyValue1; } - @DontCompile - public void test48_verifier(boolean warmup) { + @Run(test = "test48") + public void test48_verifier() { MyValue1 vt = testValue1; boolean result = test48(vt); Asserts.assertTrue(result); @@ -1476,8 +1484,8 @@ public boolean test49(Object obj) { return obj instanceof MyValue2; } - @DontCompile - public void test49_verifier(boolean warmup) { + @Run(test = "test49") + public void test49_verifier() { MyValue1 vt = testValue1; boolean result = test49(vt); Asserts.assertFalse(result); @@ -1488,8 +1496,8 @@ public boolean test50(Object obj) { return obj instanceof MyValue1; } - @DontCompile - public void test50_verifier(boolean warmup) { + @Run(test = "test50") + public void test50_verifier() { boolean result = test49(Integer.valueOf(42)); Asserts.assertFalse(result); } @@ -1573,13 +1581,13 @@ public long test(Test51Value holder, MyValue1 vt1, Object vt2) { } // Same as test2 but with field holder being an inline type - @Test() + @Test public long test51(Test51Value holder, MyValue1 vt1, Object vt2) { return holder.test(holder, vt1, vt2); } - @DontCompile - public void test51_verifier(boolean warmup) { + @Run(test = "test51") + public void test51_verifier() { MyValue1 vt = testValue1; MyValue1 def = MyValue1.createDefaultDontInline(); Test51Value holder = new Test51Value(); @@ -1590,56 +1598,56 @@ public void test51_verifier(boolean warmup) { } // Access non-flattened, uninitialized inline type field with inline type holder - @Test() + @Test public void test52(Test51Value holder) { if ((Object)holder.valueField5 != null) { throw new RuntimeException("Should be null"); } } - @DontCompile - public void test52_verifier(boolean warmup) { + @Run(test = "test52") + public void test52_verifier() { Test51Value vt = Test51Value.default; test52(vt); } // Merging inline types of different types - @Test() + @Test public Object test53(Object o, boolean b) { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); return b ? vt : o; } - @DontCompile - public void test53_verifier(boolean warmup) { + @Run(test = "test53") + public void test53_verifier() { test53(new Object(), false); MyValue1 result = (MyValue1)test53(new Object(), true); Asserts.assertEQ(result.hash(), hash()); } - @Test() + @Test public Object test54(boolean b) { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); return b ? vt : testValue2; } - @DontCompile - public void test54_verifier(boolean warmup) { + @Run(test = "test54") + public void test54_verifier() { MyValue1 result1 = (MyValue1)test54(true); Asserts.assertEQ(result1.hash(), hash()); MyValue2 result2 = (MyValue2)test54(false); Asserts.assertEQ(result2.hash(), testValue2.hash()); } - @Test() + @Test public Object test55(boolean b) { MyValue1 vt1 = MyValue1.createWithFieldsInline(rI, rL); MyValue2 vt2 = MyValue2.createWithFieldsInline(rI, rD); return b ? vt1 : vt2; } - @DontCompile - public void test55_verifier(boolean warmup) { + @Run(test = "test55") + public void test55_verifier() { MyValue1 result1 = (MyValue1)test55(true); Asserts.assertEQ(result1.hash(), hash()); MyValue2 result2 = (MyValue2)test55(false); @@ -1647,15 +1655,15 @@ public void test55_verifier(boolean warmup) { } // Test synchronization on inline types - @Test() + @Test public void test56(Object vt) { synchronized (vt) { throw new RuntimeException("test56 failed: synchronization on inline type should not succeed"); } } - @DontCompile - public void test56_verifier(boolean warmup) { + @Run(test = "test56") + public void test56_verifier() { try { test56(testValue1); throw new RuntimeException("test56 failed: no exception thrown"); @@ -1671,13 +1679,13 @@ public void test57_inline(Object vt) { } } - @Test() + @Test public void test57(MyValue1 vt) { test57_inline(vt); } - @DontCompile - public void test57_verifier(boolean warmup) { + @Run(test = "test57") + public void test57_verifier() { try { test57(testValue1); throw new RuntimeException("test57 failed: no exception thrown"); @@ -1693,14 +1701,14 @@ public void test58_inline(Object vt) { } } - @Test() + @Test public void test58() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); test58_inline(vt); } - @DontCompile - public void test58_verifier(boolean warmup) { + @Run(test = "test58") + public void test58_verifier() { try { test58(); throw new RuntimeException("test58 failed: no exception thrown"); @@ -1709,7 +1717,7 @@ public void test58_verifier(boolean warmup) { } } - @Test() + @Test public void test59(Object o, boolean b) { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); Object sync = b ? vt : o; @@ -1720,8 +1728,8 @@ public void test59(Object o, boolean b) { } } - @DontCompile - public void test59_verifier(boolean warmup) { + @Run(test = "test59") + public void test59_verifier() { test59(new Object(), false); try { test59(new Object(), true); @@ -1731,7 +1739,7 @@ public void test59_verifier(boolean warmup) { } } - @Test() + @Test public void test60(boolean b) { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); Object sync = b ? vt : testValue2; @@ -1740,8 +1748,8 @@ public void test60(boolean b) { } } - @DontCompile - public void test60_verifier(boolean warmup) { + @Run(test = "test60") + public void test60_verifier() { try { test60(false); throw new RuntimeException("test60 failed: no exception thrown"); @@ -1757,7 +1765,7 @@ public void test60_verifier(boolean warmup) { } // Test catching the IllegalMonitorStateException in compiled code - @Test() + @Test public void test61(Object vt) { boolean thrown = false; try { @@ -1772,12 +1780,12 @@ public void test61(Object vt) { } } - @DontCompile - public void test61_verifier(boolean warmup) { + @Run(test = "test61") + public void test61_verifier() { test61(testValue1); } - @Test() + @Test public void test62(Object o) { try { synchronized (o) { } @@ -1788,19 +1796,19 @@ public void test62(Object o) { throw new RuntimeException("test62 failed: no exception thrown"); } - @DontCompile - public void test62_verifier(boolean warmup) { + @Run(test = "test62") + public void test62_verifier() { test62(testValue1); } // Test synchronization without any instructions in the synchronized block - @Test() + @Test public void test63(Object o) { synchronized (o) { } } - @DontCompile - public void test63_verifier(boolean warmup) { + @Run(test = "test63") + public void test63_verifier() { try { test63(testValue1); } catch (IllegalMonitorStateException ex) { @@ -1816,13 +1824,13 @@ public MyInterface test64Interface_helper(MyValue1 vt) { return vt; } - @Test() + @Test public MyInterface test64Interface(MyValue1 vt) { return test64Interface_helper(vt); } - @DontCompile - public void test64Interface_verifier(boolean warmup) { + @Run(test = "test64Interface") + public void test64Interface_verifier() { test64Interface(testValue1); } @@ -1832,60 +1840,60 @@ public MyAbstract test64Abstract_helper(MyValue1 vt) { return vt; } - @Test() + @Test public MyAbstract test64Abstract(MyValue1 vt) { return test64Abstract_helper(vt); } - @DontCompile - public void test64Abstract_verifier(boolean warmup) { + @Run(test = "test64Abstract") + public void test64Abstract_verifier() { test64Abstract(testValue1); } // Array store tests - @Test() + @Test public void test65(Object[] array, MyValue1 vt) { array[0] = vt; } - @DontCompile - public void test65_verifier(boolean warmup) { + @Run(test = "test65") + public void test65_verifier() { Object[] array = new Object[1]; test65(array, testValue1); Asserts.assertEQ(((MyValue1)array[0]).hash(), testValue1.hash()); } - @Test() + @Test public void test66(Object[] array, MyValue1 vt) { array[0] = vt; } - @DontCompile - public void test66_verifier(boolean warmup) { + @Run(test = "test66") + public void test66_verifier() { MyValue1[] array = new MyValue1[1]; test66(array, testValue1); Asserts.assertEQ(array[0].hash(), testValue1.hash()); } - @Test() + @Test public void test67(Object[] array, Object vt) { array[0] = vt; } - @DontCompile - public void test67_verifier(boolean warmup) { + @Run(test = "test67") + public void test67_verifier() { MyValue1[] array = new MyValue1[1]; test67(array, testValue1); Asserts.assertEQ(array[0].hash(), testValue1.hash()); } - @Test() + @Test public void test68(Object[] array, Integer o) { array[0] = o; } - @DontCompile - public void test68_verifier(boolean warmup) { + @Run(test = "test68") + public void test68_verifier() { Integer[] array = new Integer[1]; test68(array, 1); Asserts.assertEQ(array[0], Integer.valueOf(1)); @@ -1898,7 +1906,8 @@ public Object test69_sum(Object a, Object b) { return MyValue1.setX(((MyValue1)a), sum); } - @Test(failOn = ALLOC + STORE) + @Test + @IR(failOn = {ALLOC, STORE}) public int test69(MyValue1[] array) { MyValue1 result = MyValue1.createDefaultInline(); for (int i = 0; i < array.length; ++i) { @@ -1907,8 +1916,8 @@ public int test69(MyValue1[] array) { return result.x; } - @DontCompile - public void test69_verifier(boolean warmup) { + @Run(test = "test69") + public void test69_verifier() { int result = test69(testValue1Array); Asserts.assertEQ(result, rI * testValue1Array.length); } @@ -1920,7 +1929,8 @@ public MyInterface test70Interface_sum(MyInterface a, MyInterface b) { return MyValue1.setX(((MyValue1)a), sum); } - @Test(failOn = ALLOC + STORE) + @Test + @IR(failOn = {ALLOC, STORE}) public int test70Interface(MyValue1[] array) { MyValue1 result = MyValue1.createDefaultInline(); for (int i = 0; i < array.length; ++i) { @@ -1929,8 +1939,8 @@ public int test70Interface(MyValue1[] array) { return result.x; } - @DontCompile - public void test70Interface_verifier(boolean warmup) { + @Run(test = "test70Interface") + public void test70Interface_verifier() { int result = test70Interface(testValue1Array); Asserts.assertEQ(result, rI * testValue1Array.length); } @@ -1942,7 +1952,8 @@ public MyAbstract test70Abstract_sum(MyAbstract a, MyAbstract b) { return MyValue1.setX(((MyValue1)a), sum); } - @Test(failOn = ALLOC + STORE) + @Test + @IR(failOn = {ALLOC, STORE}) public int test70Abstract(MyValue1[] array) { MyValue1 result = MyValue1.createDefaultInline(); for (int i = 0; i < array.length; ++i) { @@ -1951,8 +1962,8 @@ public int test70Abstract(MyValue1[] array) { return result.x; } - @DontCompile - public void test70Abstract_verifier(boolean warmup) { + @Run(test = "test70Abstract") + public void test70Abstract_verifier() { int result = test70Abstract(testValue1Array); Asserts.assertEQ(result, rI * testValue1Array.length); } @@ -1974,8 +1985,8 @@ public MyValue1 test71() { return test71_inline(null); } - @DontCompile - public void test71_verifier(boolean warmup) { + @Run(test = "test71") + public void test71_verifier() { MyValue1 vt = test71(); Asserts.assertEquals(vt.hash(), hash()); } @@ -1992,14 +2003,14 @@ public int get() { public void unused(Test72Value vt) { } @Test - @Warmup(0) public int test72() { Test72Value vt = Test72Value.default; return vt.get(); } - @DontCompile - public void test72_verifier(boolean warmup) { + @Run(test = "test72") + @Warmup(0) + public void test72_verifier() { int result = test72(); Asserts.assertEquals(result, 0); } @@ -2010,8 +2021,8 @@ public Object test73(Object[] va) { return va[0]; } - @DontCompile - public void test73_verifier(boolean warmup) { + @Run(test = "test73") + public void test73_verifier() { MyValue1 vt = (MyValue1)test73(testValue1Array); Asserts.assertEquals(testValue1Array[0].hash(), vt.hash()); } @@ -2021,8 +2032,8 @@ public void test74(Object[] va, Object vt) { va[0] = vt; } - @DontCompile - public void test74_verifier(boolean warmup) { + @Run(test = "test74") + public void test74_verifier() { MyValue1[] va = new MyValue1[1]; test74(va, testValue1); Asserts.assertEquals(va[0].hash(), testValue1.hash()); @@ -2042,8 +2053,8 @@ public Object test75(Object o) { return arr[0]; } - @DontCompile - public void test75_verifier(boolean warmup) { + @Run(test = "test75") + public void test75_verifier() { test75(42); } @@ -2058,8 +2069,8 @@ public MyValue1 test76(Integer i) throws Throwable { return test76_helper(i); } - @DontCompile - public void test76_verifier(boolean warmup) throws Throwable { + @Run(test = "test76") + public void test76_verifier() throws Throwable { try { test76(null); throw new RuntimeException("NullPointerException expected"); @@ -2081,8 +2092,8 @@ public MyValue1 test77(Integer i) throws Throwable { return test77_helper(i); } - @DontCompile - public void test77_verifier(boolean warmup) throws Throwable { + @Run(test = "test77") + public void test77_verifier() throws Throwable { try { test77(Integer.valueOf(42)); throw new RuntimeException("ClassCastException expected"); @@ -2104,8 +2115,8 @@ public MyValue1.ref test78(Integer i) throws Throwable { return test78_helper(i); } - @DontCompile - public void test78_verifier(boolean warmup) throws Throwable { + @Run(test = "test78") + public void test78_verifier() throws Throwable { try { test78(null); // Should not throw } catch (Exception e) { @@ -2124,8 +2135,8 @@ public MyValue1.ref test79(Integer i) throws Throwable { return test79_helper(i); } - @DontCompile - public void test79_verifier(boolean warmup) throws Throwable { + @Run(test = "test79") + public void test79_verifier() throws Throwable { try { test79(Integer.valueOf(42)); throw new RuntimeException("ClassCastException expected"); @@ -2169,8 +2180,8 @@ public long test80() { return small.i + small.big.l0 + smallDefault.i + smallDefault.big.l29 + big.l0 + bigDefault.l29; } - @DontCompile - public void test80_verifier(boolean warmup) throws Throwable { + @Run(test = "test80") + public void test80_verifier() throws Throwable { long result = test80(); Asserts.assertEQ(result, rI + 2*rL); } @@ -2180,7 +2191,8 @@ public int test81Callee(MyValue1 vt) { return vt.x; } - @Test(failOn = ALLOC + LOAD + STORE) + @Test + @IR(failOn = {ALLOC, LOAD, STORE}) public int test81() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); int result = 0; @@ -2194,8 +2206,8 @@ public int test81() { return result; } - @DontCompile - public void test81_verifier(boolean warmup) { + @Run(test = "test81") + public void test81_verifier() { int result = test81(); Asserts.assertEQ(result, 10*rI); } @@ -2206,11 +2218,11 @@ public void test82(Object[] dst, Object v) { dst[0] = v; } - @DontCompile - public void test82_verifier(boolean warmup) { + @Run(test = "test82") + public void test82_verifier(RunInfo info) { MyValue2[] dst = new MyValue2[1]; test82(dst, testValue2); - if (!warmup) { + if (!info.isWarmUp()) { try { test82(dst, null); throw new RuntimeException("No ArrayStoreException thrown"); @@ -2221,7 +2233,6 @@ public void test82_verifier(boolean warmup) { } @Test - @Warmup(10000) public void test83(Object[] dst, Object v, boolean flag) { if (dst == null) { // null check } @@ -2234,12 +2245,13 @@ public void test83(Object[] dst, Object v, boolean flag) { dst[0] = v; } - @DontCompile - public void test83_verifier(boolean warmup) { + @Run(test = "test83") + @Warmup(10000) + public void test83_verifier(RunInfo info) { MyValue2[] dst = new MyValue2[1]; test83(dst, testValue2, false); test83(dst, testValue2, true); - if (!warmup) { + if (!info.isWarmUp()) { try { test83(dst, null, true); throw new RuntimeException("No ArrayStoreException thrown"); @@ -2249,98 +2261,104 @@ public void test83_verifier(boolean warmup) { } } - private void rerun_and_recompile_for(String name, int num, Runnable test) { - Method m = tests.get(name); - + private void rerun_and_recompile_for(Method m, int num, Runnable test) { for (int i = 1; i < num; i++) { test.run(); - if (!WHITE_BOX.isMethodCompiled(m, false)) { - enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); + if (!TestFramework.isCompiled(m)) { + TestFramework.compile(m, CompLevel.C2); } } } // Tests for the Loop Unswitching optimization // Should make 2 copies of the loop, one for non flattened arrays, one for other cases. - @Test(match = { COUNTEDLOOP_MAIN }, matchCount = { 2 } ) - @Warmup(0) + @Test + @IR(counts = {COUNTEDLOOP_MAIN, "= 2"}) public void test84(Object[] src, Object[] dst) { for (int i = 0; i < src.length; i++) { dst[i] = src[i]; } } - @DontCompile - public void test84_verifier(boolean warmup) { + @Run(test = "test84") + @Warmup(0) + public void test84_verifier(RunInfo info) { MyValue2[] src = new MyValue2[100]; Arrays.fill(src, testValue2); MyValue2[] dst = new MyValue2[100]; - rerun_and_recompile_for("TestLWorld::test84", 10, + rerun_and_recompile_for(info.getTest(), 10, () -> { test84(src, dst); Asserts.assertTrue(Arrays.equals(src, dst)); }); } - @Test(valid = G1GCOn, match = { COUNTEDLOOP, LOAD_UNKNOWN_INLINE }, matchCount = { 2, 1 } ) - @Test(valid = G1GCOff, match = { COUNTEDLOOP_MAIN, LOAD_UNKNOWN_INLINE }, matchCount = { 2, 4 } ) - @Warmup(0) + @Test + @IR(applyIf = {"UseG1GC", "true"}, + counts = {COUNTEDLOOP, "= 2", LOAD_UNKNOWN_INLINE, "= 1"}) + @IR(applyIf = {"UseG1GC", "false"}, + counts = {COUNTEDLOOP_MAIN, "= 2", LOAD_UNKNOWN_INLINE, "= 4"}) public void test85(Object[] src, Object[] dst) { for (int i = 0; i < src.length; i++) { dst[i] = src[i]; } } - @DontCompile - public void test85_verifier(boolean warmup) { + @Run(test = "test85") + @Warmup(0) + public void test85_verifier(RunInfo info) { Object[] src = new Object[100]; Arrays.fill(src, new Object()); src[0] = null; Object[] dst = new Object[100]; - rerun_and_recompile_for("TestLWorld::test85", 10, + rerun_and_recompile_for(info.getTest(), 10, () -> { test85(src, dst); Asserts.assertTrue(Arrays.equals(src, dst)); }); } - @Test(valid = G1GCOn, match = { COUNTEDLOOP }, matchCount = { 2 } ) - @Test(valid = G1GCOff, match = { COUNTEDLOOP_MAIN }, matchCount = { 2 } ) - @Warmup(0) + @Test + @IR(applyIf = {"UseG1GC", "true"}, + counts = {COUNTEDLOOP, "= 2"}) + @IR(applyIf = {"UseG1GC", "false"}, + counts = {COUNTEDLOOP_MAIN, "= 2"}) public void test86(Object[] src, Object[] dst) { for (int i = 0; i < src.length; i++) { dst[i] = src[i]; } } - @DontCompile - public void test86_verifier(boolean warmup) { + @Run(test = "test86") + @Warmup(0) + public void test86_verifier(RunInfo info) { MyValue2[] src = new MyValue2[100]; Arrays.fill(src, testValue2); Object[] dst = new Object[100]; - rerun_and_recompile_for("TestLWorld::test86", 10, + rerun_and_recompile_for(info.getTest(), 10, () -> { test86(src, dst); Asserts.assertTrue(Arrays.equals(src, dst)); }); } - @Test(match = { COUNTEDLOOP_MAIN }, matchCount = { 2 } ) - @Warmup(0) + @Test + @IR(counts = {COUNTEDLOOP_MAIN, "= 2"}) public void test87(Object[] src, Object[] dst) { for (int i = 0; i < src.length; i++) { dst[i] = src[i]; } } - @DontCompile - public void test87_verifier(boolean warmup) { + @Run(test = "test87") + @Warmup(0) + public void test87_verifier(RunInfo info) { Object[] src = new Object[100]; Arrays.fill(src, testValue2); MyValue2[] dst = new MyValue2[100]; - rerun_and_recompile_for("TestLWorld::test87", 10, + rerun_and_recompile_for(info.getTest(), 10, () -> { test87(src, dst); Asserts.assertTrue(Arrays.equals(src, dst)); }); } - @Test(match = { COUNTEDLOOP_MAIN }, matchCount = { 2 } ) - @Warmup(0) + @Test + @IR(counts = {COUNTEDLOOP_MAIN, "= 2"}) public void test88(Object[] src1, Object[] dst1, Object[] src2, Object[] dst2) { for (int i = 0; i < src1.length; i++) { dst1[i] = src1[i]; @@ -2348,8 +2366,9 @@ public void test88(Object[] src1, Object[] dst1, Object[] src2, Object[] dst2) { } } - @DontCompile - public void test88_verifier(boolean warmup) { + @Run(test = "test88") + @Warmup(0) + public void test88_verifier(RunInfo info) { MyValue2[] src1 = new MyValue2[100]; Arrays.fill(src1, testValue2); MyValue2[] dst1 = new MyValue2[100]; @@ -2357,7 +2376,7 @@ public void test88_verifier(boolean warmup) { Arrays.fill(src2, new Object()); Object[] dst2 = new Object[100]; - rerun_and_recompile_for("TestLWorld::test88", 10, + rerun_and_recompile_for(info.getTest(), 10, () -> { test88(src1, dst1, src2, dst2); Asserts.assertTrue(Arrays.equals(src1, dst1)); Asserts.assertTrue(Arrays.equals(src2, dst2)); }); @@ -2368,8 +2387,8 @@ public boolean test89(Object obj) { return obj.getClass() == Integer.class; } - @DontCompile - public void test89_verifier(boolean warmup) { + @Run(test = "test89") + public void test89_verifier() { Asserts.assertTrue(test89(Integer.valueOf(42))); Asserts.assertFalse(test89(new Object())); } @@ -2379,8 +2398,8 @@ public Integer test90(Object obj) { return (Integer)obj; } - @DontCompile - public void test90_verifier(boolean warmup) { + @Run(test = "test90") + public void test90_verifier() { test90(Integer.valueOf(42)); try { test90(new Object()); @@ -2395,8 +2414,8 @@ public boolean test91(Object obj) { return obj.getClass() == MyValue2[].class; } - @DontCompile - public void test91_verifier(boolean warmup) { + @Run(test = "test91") + public void test91_verifier() { Asserts.assertTrue(test91(new MyValue2[1])); Asserts.assertFalse(test91(new Object())); } @@ -2408,8 +2427,9 @@ public Test92Value() { } } - @Warmup(10000) - @Test(match = { CLASS_CHECK_TRAP }, matchCount = { 2 }, failOn = LOAD_UNKNOWN_INLINE + ALLOC_G + MEMBAR) + @Test + @IR(counts = {CLASS_CHECK_TRAP, "= 2"}, + failOn = {LOAD_UNKNOWN_INLINE, ALLOC_G, MEMBAR}) public Object test92(Object[] array) { // Dummy loops to ensure we run enough passes of split if for (int i = 0; i < 2; i++) { @@ -2422,8 +2442,9 @@ public Object test92(Object[] array) { return (Integer)array[0]; } - @DontCompile - public void test92_verifier(boolean warmup) { + @Run(test = "test92") + @Warmup(10000) + public void test92_verifier() { Object[] array = new Object[1]; array[0] = 0x42; Object result = test92(array); @@ -2434,7 +2455,6 @@ public void test92_verifier(boolean warmup) { // precedes will never succeed and the flat array branch should // trigger an uncommon trap. @Test - @Warmup(10000) public Object test93(Object[] array) { for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { @@ -2445,16 +2465,17 @@ public Object test93(Object[] array) { return v; } - @DontCompile - public void test93_verifier(boolean warmup) { - if (warmup) { + @Run(test = "test93") + @Warmup(10000) + public void test93_verifier(RunInfo info) { + if (info.isWarmUp()) { Object[] array = new Object[1]; array[0] = 0x42; Object result = test93(array); Asserts.assertEquals(result, 0x42); } else { Object[] array = new Test92Value[1]; - Method m = tests.get("TestLWorld::test93"); + Method m = info.getTest(); int extra = 3; for (int j = 0; j < extra; j++) { for (int i = 0; i < 10; i++) { @@ -2463,17 +2484,19 @@ public void test93_verifier(boolean warmup) { } catch (ClassCastException cce) { } } - boolean compiled = isCompiledByC2(m); - Asserts.assertTrue(!USE_COMPILER || XCOMP || STRESS_CC || TEST_C1 || !ProfileInterpreter || compiled || (j != extra-1)); - if (!compiled) { - enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); + boolean compiled = TestFramework.isCompiled(m); + boolean compilationSkipped = info.isCompilationSkipped(); + Asserts.assertTrue(compilationSkipped || compiled || (j != extra-1)); + if (!compilationSkipped && !compiled) { + TestFramework.compile(m, CompLevel.ANY); } } } } - @Warmup(10000) - @Test(match = { CLASS_CHECK_TRAP, LOOP }, matchCount = { 2, 1 }, failOn = LOAD_UNKNOWN_INLINE + ALLOC_G + MEMBAR) + @Test + @IR(counts = {CLASS_CHECK_TRAP, "= 2", LOOP, "= 1"}, + failOn = {LOAD_UNKNOWN_INLINE, ALLOC_G, MEMBAR}) public int test94(Object[] array) { int res = 0; for (int i = 1; i < 4; i *= 2) { @@ -2483,8 +2506,9 @@ public int test94(Object[] array) { return res; } - @DontCompile - public void test94_verifier(boolean warmup) { + @Run(test = "test94") + @Warmup(10000) + public void test94_verifier() { Object[] array = new Object[4]; array[0] = 0x42; array[1] = 0x42; @@ -2494,14 +2518,14 @@ public void test94_verifier(boolean warmup) { Asserts.assertEquals(result, 0x42 * 2); } - @Warmup(10000) @Test public boolean test95(Object o1, Object o2) { return o1 == o2; } - @DontCompile - public void test95_verifier(boolean warmup) { + @Run(test = "test95") + @Warmup(10000) + public void test95_verifier() { Object o1 = new Object(); Object o2 = new Object(); Asserts.assertTrue(test95(o1, o1)); @@ -2510,19 +2534,19 @@ public void test95_verifier(boolean warmup) { Asserts.assertFalse(test95(o1, o2)); } - @Warmup(10000) @Test public boolean test96(Object o1, Object o2) { return o1 == o2; } - @DontCompile - public void test96_verifier(boolean warmup) { + @Run(test = "test96") + @Warmup(10000) + public void test96_verifier(RunInfo info) { Object o1 = new Object(); Object o2 = new Object(); Asserts.assertTrue(test96(o1, o1)); Asserts.assertFalse(test96(o1, o2)); - if (!warmup) { + if (!info.isWarmUp()) { Asserts.assertTrue(test96(null, null)); Asserts.assertFalse(test96(o1, null)); } @@ -2550,7 +2574,7 @@ public MyValue1 test97_inline2(MyAbstract o) { return (MyValue1)o; } - @Test() + @Test public MyValue1 test97() { MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL); vt = (MyValue1)test97_dontinline1(vt); @@ -2560,8 +2584,8 @@ public MyValue1 test97() { return vt; } - @DontCompile - public void test97_verifier(boolean warmup) { + @Run(test = "test97") + public void test97_verifier() { Asserts.assertEQ(test97().hash(), hash()); } @@ -2583,7 +2607,7 @@ public MyAbstract readStaticValueField4AsAbstract() { return (MyAbstract)staticValueField4; } - @Test() + @Test public long test98(MyValue1 vt1, MyAbstract vt2) { abstractField1 = vt1; abstractField2 = (MyValue1)vt2; @@ -2607,8 +2631,8 @@ public long test98(MyValue1 vt1, MyAbstract vt2) { staticValueField1.hash() + staticValueField2.hash() + staticValueField3.hashPrimitive(); } - @DontCompile - public void test98_verifier(boolean warmup) { + @Run(test = "test98") + public void test98_verifier() { MyValue1 vt = testValue1; MyValue1 def = MyValue1.createDefaultDontInline(); long result = test98(vt, vt); @@ -2629,7 +2653,7 @@ public long hash() { } // Test merging inline types and abstract classes - @Test() + @Test public MyAbstract test99(int state) { MyAbstract res = null; if (state == 0) { @@ -2648,8 +2672,8 @@ public MyAbstract test99(int state) { return res; } - @DontCompile - public void test99_verifier(boolean warmup) { + @Run(test = "test99") + public void test99_verifier() { objectField1 = valueField1; MyAbstract result = null; result = test99(0); @@ -2667,7 +2691,7 @@ public void test99_verifier(boolean warmup) { } // Test merging inline types and abstract classes in loops - @Test() + @Test public MyAbstract test100(int iters) { MyAbstract res = new MyObject2(rI); for (int i = 0; i < iters; ++i) { @@ -2680,8 +2704,8 @@ public MyAbstract test100(int iters) { return res; } - @DontCompile - public void test100_verifier(boolean warmup) { + @Run(test = "test100") + public void test100_verifier() { MyObject2 result1 = (MyObject2)test100(0); Asserts.assertEQ(result1.x, rI); int iters = (Math.abs(rI) % 10) + 1; @@ -2691,28 +2715,30 @@ public void test100_verifier(boolean warmup) { } // Test inline types in abstract class variables that are live at safepoint - @Test(failOn = ALLOC + STORE + LOOP) - public long test101(MyValue1 arg, boolean deopt) { + @Test + @IR(failOn = {ALLOC, STORE, LOOP}) + public long test101(MyValue1 arg, boolean deopt, Method m) { MyAbstract vt1 = MyValue1.createWithFieldsInline(rI, rL); MyAbstract vt2 = MyValue1.createWithFieldsDontInline(rI, rL); MyAbstract vt3 = arg; MyAbstract vt4 = valueField1; if (deopt) { // uncommon trap - WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test101")); + TestFramework.deoptimize(m); } return ((MyValue1)vt1).hash() + ((MyValue1)vt2).hash() + ((MyValue1)vt3).hash() + ((MyValue1)vt4).hash(); } - @DontCompile - public void test101_verifier(boolean warmup) { - long result = test101(valueField1, !warmup); + @Run(test = "test101") + public void test101_verifier(RunInfo info) { + long result = test101(valueField1, !info.isWarmUp(), info.getTest()); Asserts.assertEQ(result, 4*hash()); } // Test comparing inline types with abstract classes - @Test(failOn = LOAD + LOOP) + @Test + @IR(failOn = {LOAD, LOOP}) public boolean test102(Object arg) { MyAbstract vt = MyValue1.createWithFieldsInline(rI, rL); if (vt == arg || vt == (MyAbstract)valueField1 || vt == abstractField1 || vt == null || @@ -2722,8 +2748,8 @@ public boolean test102(Object arg) { return false; } - @DontCompile - public void test102_verifier(boolean warmup) { + @Run(test = "test102") + public void test102_verifier() { boolean result = test102(null); Asserts.assertFalse(result); } @@ -2742,13 +2768,15 @@ class MyObject4 extends NoValueImplementors1 { } // Loading from an abstract class array does not require a flatness check if the abstract class has a non-static field - @Test(failOn = ALLOC_G + MEMBAR + ALLOCA_G + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD) + @Test + @IR(failOn = {ALLOC_G, MEMBAR, ALLOCA_G, + LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}) public NoValueImplementors1 test103(NoValueImplementors1[] array, int i) { return array[i]; } - @DontCompile - public void test103_verifier(boolean warmup) { + @Run(test = "test103") + public void test103_verifier() { NoValueImplementors1[] array1 = new NoValueImplementors1[3]; MyObject3[] array2 = new MyObject3[3]; MyObject4[] array3 = new MyObject4[3]; @@ -2763,7 +2791,9 @@ public void test103_verifier(boolean warmup) { } // Storing to an abstract class array does not require a flatness/null check if the abstract class has a non-static field - @Test(failOn = ALLOC_G + ALLOCA_G + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD) + @Test + @IR(failOn = {ALLOC_G, ALLOCA_G, + LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}) public NoValueImplementors1 test104(NoValueImplementors1[] array, NoValueImplementors1 v, MyObject3 o, int i) { array[0] = v; array[1] = array[0]; @@ -2771,8 +2801,8 @@ public NoValueImplementors1 test104(NoValueImplementors1[] array, NoValueImpleme return array[i]; } - @DontCompile - public void test104_verifier(boolean warmup) { + @Run(test = "test104") + public void test104_verifier() { MyObject4 v = new MyObject4(); MyObject3 o = new MyObject3(); NoValueImplementors1[] array1 = new NoValueImplementors1[3]; @@ -2807,13 +2837,15 @@ class MyObject5 extends NoValueImplementors2 { } // Loading from an abstract class array does not require a flatness check if the abstract class has no inline implementor - @Test(failOn = ALLOC_G + MEMBAR + ALLOCA_G + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD) + @Test + @IR(failOn = {ALLOC_G, MEMBAR, ALLOCA_G, + LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}) public NoValueImplementors2 test105(NoValueImplementors2[] array, int i) { return array[i]; } - @DontCompile - public void test105_verifier(boolean warmup) { + @Run(test = "test105") + public void test105_verifier() { NoValueImplementors2[] array1 = new NoValueImplementors2[3]; MyObject5[] array2 = new MyObject5[3]; NoValueImplementors2 result = test105(array1, 0); @@ -2824,7 +2856,9 @@ public void test105_verifier(boolean warmup) { } // Storing to an abstract class array does not require a flatness/null check if the abstract class has no inline implementor - @Test(failOn = ALLOC_G + ALLOCA_G + LOAD_UNKNOWN_INLINE + STORE_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD) + @Test + @IR(failOn = {ALLOC_G, ALLOCA_G, + LOAD_UNKNOWN_INLINE, STORE_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}) public NoValueImplementors2 test106(NoValueImplementors2[] array, NoValueImplementors2 v, MyObject5 o, int i) { array[0] = v; array[1] = array[0]; @@ -2832,8 +2866,8 @@ public NoValueImplementors2 test106(NoValueImplementors2[] array, NoValueImpleme return array[i]; } - @DontCompile - public void test106_verifier(boolean warmup) { + @Run(test = "test106") + public void test106_verifier() { MyObject5 v = new MyObject5(); NoValueImplementors2[] array1 = new NoValueImplementors2[3]; MyObject5[] array2 = new MyObject5[3]; @@ -2853,9 +2887,13 @@ public void test106_verifier(boolean warmup) { // More tests for the Loop Unswitching optimization (similar to test84 and following) Object oFld1, oFld2; - @Test(valid = G1GCOn, failOn = STORE_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD, match = { COUNTEDLOOP, LOAD_UNKNOWN_INLINE }, matchCount = { 2, 2 } ) - @Test(valid = G1GCOff, failOn = STORE_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD, match = { COUNTEDLOOP, LOAD_UNKNOWN_INLINE }, matchCount = { 3, 2 } ) - @Warmup(0) + @Test + @IR(applyIf = {"UseG1GC", "true"}, + failOn = {STORE_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}, + counts = {COUNTEDLOOP, "= 2", LOAD_UNKNOWN_INLINE, "= 2"}) + @IR(applyIf = {"UseG1GC", "false"}, + failOn = {STORE_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}, + counts = {COUNTEDLOOP, "= 3", LOAD_UNKNOWN_INLINE, "= 2"}) public void test107(Object[] src1, Object[] src2) { for (int i = 0; i < src1.length; i++) { oFld1 = src1[i]; @@ -2863,14 +2901,15 @@ public void test107(Object[] src1, Object[] src2) { } } - @DontCompile - public void test107_verifier(boolean warmup) { + @Run(test = "test107") + @Warmup(0) + public void test107_verifier(RunInfo info) { MyValue2[] src1 = new MyValue2[100]; Arrays.fill(src1, testValue2); Object[] src2 = new Object[100]; Object obj = new Object(); Arrays.fill(src2, obj); - rerun_and_recompile_for("TestLWorld::test107", 10, + rerun_and_recompile_for(info.getTest(), 10, () -> { test107(src1, src2); Asserts.assertEquals(oFld1, testValue2); Asserts.assertEquals(oFld2, obj); @@ -2879,9 +2918,13 @@ public void test107_verifier(boolean warmup) { Asserts.assertEquals(oFld2, testValue2); }); } - @Test(valid = G1GCOn, failOn = LOAD_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD, match = { COUNTEDLOOP, STORE_UNKNOWN_INLINE }, matchCount = { 4, 9 } ) - @Test(valid = G1GCOff, failOn = LOAD_UNKNOWN_INLINE + INLINE_ARRAY_NULL_GUARD, match = { COUNTEDLOOP, STORE_UNKNOWN_INLINE }, matchCount = { 4, 12 } ) - @Warmup(0) + @Test + @IR(applyIf = {"UseG1GC", "true"}, + failOn = {LOAD_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}, + counts = {COUNTEDLOOP, "= 4", STORE_UNKNOWN_INLINE, "= 9"}) + @IR(applyIf = {"UseG1GC", "false"}, + failOn = {LOAD_UNKNOWN_INLINE, INLINE_ARRAY_NULL_GUARD}, + counts = {COUNTEDLOOP, "= 4", STORE_UNKNOWN_INLINE, "= 12"}) public void test108(Object[] dst1, Object[] dst2, Object o1, Object o2) { for (int i = 0; i < dst1.length; i++) { dst1[i] = o1; @@ -2889,12 +2932,13 @@ public void test108(Object[] dst1, Object[] dst2, Object o1, Object o2) { } } - @DontCompile - public void test108_verifier(boolean warmup) { + @Run(test = "test108") + @Warmup(0) + public void test108_verifier(RunInfo info) { MyValue2[] dst1 = new MyValue2[100]; Object[] dst2 = new Object[100]; Object o1 = new Object(); - rerun_and_recompile_for("TestLWorld::test108", 10, + rerun_and_recompile_for(info.getTest(), 10, () -> { test108(dst1, dst2, testValue2, o1); for (int i = 0; i < dst1.length; i++) { Asserts.assertEquals(dst1[i], testValue2); @@ -2919,6 +2963,7 @@ static WrapperInterface wrap(long val) { } } + @ForceCompileClassInitializer static primitive class LongWrapper implements WrapperInterface { final static LongWrapper ZERO = new LongWrapper(0); private long val; @@ -3015,8 +3060,9 @@ static GenericBox box(long val) { long[] lArr = {0L, rL, 0L, rL, 0L, rL, 0L, rL, 0L, rL}; // Test removal of allocations when inline type instance is wrapped into box object - @Warmup(10000) // Make sure interface calls are inlined - @Test(failOn = ALLOC_G + MEMBAR, match = { PREDICATE_TRAP }, matchCount = { 1 }) + @Test + @IR(failOn = {ALLOC_G, MEMBAR}, + counts = {PREDICATE_TRAP, "= 1"}) public long test109() { long res = 0; for (int i = 0 ; i < lArr.length; i++) { @@ -3025,14 +3071,16 @@ public long test109() { return res; } - @DontCompile - public void test109_verifier(boolean warmup) { + @Run(test = "test109") + @Warmup(10000) // Make sure interface calls are inlined + public void test109_verifier() { long res = test109(); Asserts.assertEquals(res, 5*rL); } - @Warmup(10000) // Make sure interface calls are inlined - @Test(failOn = ALLOC_G + MEMBAR, match = { PREDICATE_TRAP }, matchCount = { 1 }) + @Test + @IR(failOn = {ALLOC_G, MEMBAR}, + counts = {PREDICATE_TRAP, "= 1"}) public long test109_sharp() { long res = 0; for (int i = 0 ; i < lArr.length; i++) { @@ -3041,15 +3089,17 @@ public long test109_sharp() { return res; } - @DontCompile - public void test109_sharp_verifier(boolean warmup) { + @Run(test = "test109_sharp") + @Warmup(10000) // Make sure interface calls are inlined + public void test109_sharp_verifier() { long res = test109_sharp(); Asserts.assertEquals(res, 5*rL); } // Same as test109 but with ObjectBox - @Test(failOn = ALLOC_G + MEMBAR, match = { PREDICATE_TRAP }, matchCount = { 1 }) - @Warmup(10000) // Make sure interface calls are inlined + @Test + @IR(failOn = {ALLOC_G, MEMBAR}, + counts = {PREDICATE_TRAP, "= 1"}) public long test110() { long res = 0; for (int i = 0 ; i < lArr.length; i++) { @@ -3058,14 +3108,16 @@ public long test110() { return res; } - @DontCompile - public void test110_verifier(boolean warmup) { + @Run(test = "test110") + @Warmup(10000) // Make sure interface calls are inlined + public void test110_verifier() { long res = test110(); Asserts.assertEquals(res, 5*rL); } - @Test(failOn = ALLOC_G + MEMBAR, match = { PREDICATE_TRAP }, matchCount = { 1 }) - @Warmup(10000) // Make sure interface calls are inlined + @Test + @IR(failOn = {ALLOC_G, MEMBAR}, + counts = {PREDICATE_TRAP, "= 1"}) public long test110_sharp() { long res = 0; for (int i = 0 ; i < lArr.length; i++) { @@ -3074,14 +3126,17 @@ public long test110_sharp() { return res; } - @DontCompile - public void test110_sharp_verifier(boolean warmup) { + @Run(test = "test110_sharp") + @Warmup(10000) // Make sure interface calls are inlined + public void test110_sharp_verifier() { long res = test110_sharp(); Asserts.assertEquals(res, 5*rL); } // Same as test109 but with RefBox - @Test(failOn = ALLOC_G + MEMBAR, match = { PREDICATE_TRAP }, matchCount = { 1 }) + @Test + @IR(failOn = {ALLOC_G, MEMBAR}, + counts = {PREDICATE_TRAP, "= 1"}) public long test111() { long res = 0; for (int i = 0 ; i < lArr.length; i++) { @@ -3090,13 +3145,15 @@ public long test111() { return res; } - @DontCompile - public void test111_verifier(boolean warmup) { + @Run(test = "test111") + public void test111_verifier() { long res = test111(); Asserts.assertEquals(res, 5*rL); } - @Test(failOn = ALLOC_G + MEMBAR, match = { PREDICATE_TRAP }, matchCount = { 1 }) + @Test + @IR(failOn = {ALLOC_G, MEMBAR}, + counts = {PREDICATE_TRAP, "= 1"}) public long test111_sharp() { long res = 0; for (int i = 0 ; i < lArr.length; i++) { @@ -3105,14 +3162,16 @@ public long test111_sharp() { return res; } - @DontCompile - public void test111_sharp_verifier(boolean warmup) { + @Run(test = "test111_sharp") + public void test111_sharp_verifier() { long res = test111_sharp(); Asserts.assertEquals(res, 5*rL); } // Same as test109 but with InlineBox - @Test(failOn = ALLOC_G + MEMBAR, match = { PREDICATE_TRAP }, matchCount = { 1 }) + @Test + @IR(failOn = {ALLOC_G, MEMBAR}, + counts = {PREDICATE_TRAP, "= 1"}) public long test112() { long res = 0; for (int i = 0 ; i < lArr.length; i++) { @@ -3121,15 +3180,16 @@ public long test112() { return res; } - @DontCompile - public void test112_verifier(boolean warmup) { + @Run(test = "test112") + public void test112_verifier() { long res = test112(); Asserts.assertEquals(res, 5*rL); } // Same as test109 but with GenericBox - @Test(failOn = ALLOC_G + MEMBAR, match = { PREDICATE_TRAP }, matchCount = { 1 }) - @Warmup(10000) // Make sure interface calls are inlined + @Test + @IR(failOn = {ALLOC_G, MEMBAR}, + counts = {PREDICATE_TRAP, "= 1"}) public long test113() { long res = 0; for (int i = 0 ; i < lArr.length; i++) { @@ -3138,14 +3198,16 @@ public long test113() { return res; } - @DontCompile - public void test113_verifier(boolean warmup) { + @Run(test = "test113") + @Warmup(10000) // Make sure interface calls are inlined + public void test113_verifier() { long res = test113(); Asserts.assertEquals(res, 5*rL); } - @Test(failOn = ALLOC_G + MEMBAR, match = { PREDICATE_TRAP }, matchCount = { 1 }) - @Warmup(10000) // Make sure interface calls are inlined + @Test + @IR(failOn = {ALLOC_G, MEMBAR}, + counts = {PREDICATE_TRAP, "= 1"}) public long test113_sharp() { long res = 0; for (int i = 0 ; i < lArr.length; i++) { @@ -3154,8 +3216,9 @@ public long test113_sharp() { return res; } - @DontCompile - public void test113_sharp_verifier(boolean warmup) { + @Run(test = "test113_sharp") + @Warmup(10000) // Make sure interface calls are inlined + public void test113_sharp_verifier() { long res = test113_sharp(); Asserts.assertEquals(res, 5*rL); } @@ -3211,8 +3274,9 @@ static InterfaceBox2 box_default(long val) { } // Same as tests above but with ZERO hidden in field of another inline type - @Test(failOn = ALLOC_G + MEMBAR, match = { PREDICATE_TRAP }, matchCount = { 1 }) - @Warmup(10000) + @Test + @IR(failOn = {ALLOC_G, MEMBAR}, + counts = {PREDICATE_TRAP, "= 1"}) public long test114() { long res = 0; for (int i = 0; i < lArr.length; i++) { @@ -3221,15 +3285,17 @@ public long test114() { return res; } - @DontCompile - public void test114_verifier(boolean warmup) { + @Run(test = "test114") + @Warmup(10000) + public void test114_verifier() { long res = test114(); Asserts.assertEquals(res, 5*rL); } // Same as test114 but with .default instead of ZERO field - @Test(failOn = ALLOC_G + MEMBAR, match = { PREDICATE_TRAP }, matchCount = { 1 }) - @Warmup(10000) + @Test + @IR(failOn = {ALLOC_G, MEMBAR}, + counts = {PREDICATE_TRAP, "= 1"}) public long test115() { long res = 0; for (int i = 0; i < lArr.length; i++) { @@ -3238,8 +3304,9 @@ public long test115() { return res; } - @DontCompile - public void test115_verifier(boolean warmup) { + @Run(test = "test115") + @Warmup(10000) + public void test115_verifier() { long res = test115(); Asserts.assertEquals(res, 5*rL); } @@ -3250,7 +3317,8 @@ public void test115_verifier(boolean warmup) { MyValueEmpty.ref fEmpty4 = MyValueEmpty.default; // Test fields loads/stores with empty inline types - @Test(failOn = ALLOC + ALLOC_G + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOC_G, LOAD, STORE, TRAP}) public void test116() { fEmpty1 = fEmpty4; fEmpty2 = fEmpty1; @@ -3258,8 +3326,8 @@ public void test116() { fEmpty4 = fEmpty3; } - @DontCompile - public void test116_verifier(boolean warmup) { + @Run(test = "test116") + public void test116_verifier() { test116(); Asserts.assertEquals(fEmpty1, fEmpty2); Asserts.assertEquals(fEmpty2, fEmpty3); @@ -3267,15 +3335,16 @@ public void test116_verifier(boolean warmup) { } // Test array loads/stores with empty inline types - @Test(failOn = ALLOC + ALLOC_G) + @Test + @IR(failOn = {ALLOC, ALLOC_G}) public MyValueEmpty test117(MyValueEmpty[] arr1, MyValueEmpty.ref[] arr2) { arr1[0] = arr2[0]; arr2[0] = new MyValueEmpty(); return arr1[0]; } - @DontCompile - public void test117_verifier(boolean warmup) { + @Run(test = "test117") + public void test117_verifier() { MyValueEmpty[] arr1 = new MyValueEmpty[]{MyValueEmpty.default}; MyValueEmpty res = test117(arr1, arr1); Asserts.assertEquals(res, MyValueEmpty.default); @@ -3283,13 +3352,14 @@ public void test117_verifier(boolean warmup) { } // Test acmp with empty inline types - @Test(failOn = ALLOC + ALLOC_G) + @Test + @IR(failOn = {ALLOC, ALLOC_G}) public boolean test118(MyValueEmpty v1, MyValueEmpty.ref v2, Object o1) { return (v1 == v2) && (v2 == o1); } - @DontCompile - public void test118_verifier(boolean warmup) { + @Run(test = "test118") + public void test118_verifier() { boolean res = test118(MyValueEmpty.default, MyValueEmpty.default, new MyValueEmpty()); Asserts.assertTrue(res); } @@ -3305,60 +3375,62 @@ static primitive class MixedContainer { // Test re-allocation of empty inline type array during deoptimization @Test - public void test119(boolean deopt) { + public void test119(boolean deopt, Method m) { MyValueEmpty[] array1 = new MyValueEmpty[]{MyValueEmpty.default}; EmptyContainer[] array2 = new EmptyContainer[]{EmptyContainer.default}; MixedContainer[] array3 = new MixedContainer[]{MixedContainer.default}; if (deopt) { // uncommon trap - WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test119")); + TestFramework.deoptimize(m); } Asserts.assertEquals(array1[0], MyValueEmpty.default); Asserts.assertEquals(array2[0], EmptyContainer.default); Asserts.assertEquals(array3[0], MixedContainer.default); } - @DontCompile - public void test119_verifier(boolean warmup) { - test119(!warmup); + @Run(test = "test119") + public void test119_verifier(RunInfo info) { + test119(!info.isWarmUp(), info.getTest()); } // Test removal of empty inline type field stores - @Test(failOn = ALLOC + ALLOC_G + LOAD + STORE + FIELD_ACCESS + NULL_CHECK_TRAP + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOC_G, LOAD, STORE, FIELD_ACCESS, NULL_CHECK_TRAP, TRAP}) public void test120(MyValueEmpty empty) { fEmpty1 = empty; fEmpty3 = empty; // fEmpty2 and fEmpty4 could be null, store can't be removed } - @DontCompile - public void test120_verifier(boolean warmup) { + @Run(test = "test120") + public void test120_verifier() { test120(MyValueEmpty.default); Asserts.assertEquals(fEmpty1, MyValueEmpty.default); Asserts.assertEquals(fEmpty2, MyValueEmpty.default); } // Test removal of empty inline type field loads - @Test(failOn = ALLOC + ALLOC_G + LOAD + STORE + FIELD_ACCESS + NULL_CHECK_TRAP + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOC_G, LOAD, STORE, FIELD_ACCESS, NULL_CHECK_TRAP, TRAP}) public boolean test121() { return fEmpty1.equals(fEmpty3); // fEmpty2 and fEmpty4 could be null, load can't be removed } - @DontCompile - public void test121_verifier(boolean warmup) { + @Run(test = "test121") + public void test121_verifier() { boolean res = test121(); Asserts.assertTrue(res); } // Verify that empty inline type field loads check for null holder - @Test() + @Test public MyValueEmpty test122(TestLWorld t) { return t.fEmpty3; } - @DontCompile - public void test122_verifier(boolean warmup) { + @Run(test = "test122") + public void test122_verifier() { MyValueEmpty res = test122(this); Asserts.assertEquals(res, MyValueEmpty.default); try { @@ -3370,13 +3442,13 @@ public void test122_verifier(boolean warmup) { } // Verify that empty inline type field stores check for null holder - @Test() + @Test public void test123(TestLWorld t) { t.fEmpty3 = MyValueEmpty.default; } - @DontCompile - public void test123_verifier(boolean warmup) { + @Run(test = "test123") + public void test123_verifier() { test123(this); Asserts.assertEquals(fEmpty3, MyValueEmpty.default); try { @@ -3389,33 +3461,35 @@ public void test123_verifier(boolean warmup) { // acmp doesn't need substitutability test when one input is known // not to be a value type - @Test(failOn = SUBSTITUTABILITY_TEST) + @Test + @IR(failOn = SUBSTITUTABILITY_TEST) public boolean test124(Integer o1, Object o2) { return o1 == o2; } - @DontCompile - public void test124_verifier(boolean warmup) { + @Run(test = "test124") + public void test124_verifier() { test124(42, 42); test124(42, testValue1); } // acmp doesn't need substitutability test when one input null - @Test(failOn = SUBSTITUTABILITY_TEST) + @Test + @IR(failOn = {SUBSTITUTABILITY_TEST}) public boolean test125(Object o1) { Object o2 = null; return o1 == o2; } - @DontCompile - public void test125_verifier(boolean warmup) { + @Run(test = "test125") + public void test125_verifier() { test125(testValue1); test125(null); } // Test inline type that can only be scalarized after loop opts - @Test(failOn = ALLOC + LOAD + STORE) - @Warmup(10000) + @Test + @IR(failOn = {ALLOC, LOAD, STORE}) public long test126(boolean trap) { MyValue2 nonNull = MyValue2.createWithFieldsInline(rI, rD); MyValue2.ref val = null; @@ -3433,19 +3507,20 @@ public long test126(boolean trap) { return 0; } - @DontCompile - public void test126_verifier(boolean warmup) { + @Run(test = "test126") + @Warmup(10000) + public void test126_verifier(RunInfo info) { long res = test126(false); Asserts.assertEquals(res, 0L); - if (!warmup) { + if (!info.isWarmUp()) { res = test126(true); Asserts.assertEquals(res, testValue2.hash()); } } // Same as test126 but with interface type - @Test(failOn = ALLOC + LOAD + STORE) - @Warmup(10000) + @Test + @IR(failOn = {ALLOC, LOAD, STORE}) public long test127(boolean trap) { MyValue2 nonNull = MyValue2.createWithFieldsInline(rI, rD); MyInterface val = null; @@ -3463,19 +3538,20 @@ public long test127(boolean trap) { return 0; } - @DontCompile - public void test127_verifier(boolean warmup) { + @Run(test = "test127") + @Warmup(10000) + public void test127_verifier(RunInfo info) { long res = test127(false); Asserts.assertEquals(res, 0L); - if (!warmup) { + if (!info.isWarmUp()) { res = test127(true); Asserts.assertEquals(res, testValue2.hash()); } } // Test inline type that can only be scalarized after CCP - @Test(failOn = ALLOC + LOAD + STORE) - @Warmup(10000) + @Test + @IR(failOn = {ALLOC, LOAD, STORE}) public long test128(boolean trap) { MyValue2 nonNull = MyValue2.createWithFieldsInline(rI, rD); MyValue2.ref val = null; @@ -3493,19 +3569,20 @@ public long test128(boolean trap) { return 0; } - @DontCompile - public void test128_verifier(boolean warmup) { + @Run(test = "test128") + @Warmup(10000) + public void test128_verifier(RunInfo info) { long res = test128(false); Asserts.assertEquals(res, 0L); - if (!warmup) { + if (!info.isWarmUp()) { res = test128(true); Asserts.assertEquals(res, testValue2.hash()); } } // Same as test128 but with interface type - @Test(failOn = ALLOC + LOAD + STORE) - @Warmup(10000) + @Test + @IR(failOn = {ALLOC, LOAD, STORE}) public long test129(boolean trap) { MyValue2 nonNull = MyValue2.createWithFieldsInline(rI, rD); MyInterface val = null; @@ -3523,11 +3600,12 @@ public long test129(boolean trap) { return 0; } - @DontCompile - public void test129_verifier(boolean warmup) { + @Run(test = "test129") + @Warmup(10000) + public void test129_verifier(RunInfo info) { long res = test129(false); Asserts.assertEquals(res, 0L); - if (!warmup) { + if (!info.isWarmUp()) { res = test129(true); Asserts.assertEquals(res, testValue2.hash()); } @@ -3539,7 +3617,7 @@ public Object test130_inlinee() { return MyValue1.createWithFieldsInline(rI, rL); } - @Test() + @Test public void test130() { Object obj = test130_inlinee(); synchronized (obj) { @@ -3547,8 +3625,8 @@ public void test130() { } } - @DontCompile - public void test130_verifier(boolean warmup) { + @Run(test = "test130") + public void test130_verifier() { try { test130(); throw new RuntimeException("test130 failed: no exception thrown"); @@ -3563,7 +3641,7 @@ public Object test131_inlinee() { return testValue1; } - @Test() + @Test public void test131() { Object obj = test131_inlinee(); synchronized (obj) { @@ -3571,8 +3649,8 @@ public void test131() { } } - @DontCompile - public void test131_verifier(boolean warmup) { + @Run(test = "test131") + public void test131_verifier() { try { test131(); throw new RuntimeException("test131 failed: no exception thrown"); @@ -3582,8 +3660,7 @@ public void test131_verifier(boolean warmup) { } // Test locking on object that is known to be an inline type only after CCP - @Test() - @Warmup(10000) + @Test public void test132() { MyValue2 vt = MyValue2.createWithFieldsInline(rI, rD); Object obj = Integer.valueOf(42); @@ -3598,8 +3675,9 @@ public void test132() { } } - @DontCompile - public void test132_verifier(boolean warmup) { + @Run(test = "test132") + @Warmup(10000) + public void test132_verifier() { try { test132(); throw new RuntimeException("test132 failed: no exception thrown"); @@ -3609,7 +3687,7 @@ public void test132_verifier(boolean warmup) { } // Test conditional locking on inline type and non-escaping object - @Test() + @Test public void test133(boolean b) { Object obj = b ? Integer.valueOf(42) : MyValue2.createWithFieldsInline(rI, rD); synchronized (obj) { @@ -3619,8 +3697,8 @@ public void test133(boolean b) { } } - @DontCompile - public void test133_verifier(boolean warmup) { + @Run(test = "test133") + public void test133_verifier() { test133(true); try { test133(false); @@ -3631,7 +3709,7 @@ public void test133_verifier(boolean warmup) { } // Variant with non-scalarized inline type - @Test() + @Test public static void test134(boolean b) { Object obj = null; if (b) { @@ -3642,8 +3720,8 @@ public static void test134(boolean b) { } } - @DontCompile - public void test134_verifier(boolean warmup) { + @Run(test = "test134") + public void test134_verifier() { try { test134(true); throw new RuntimeException("test134 failed: no exception thrown"); @@ -3653,19 +3731,21 @@ public void test134_verifier(boolean warmup) { } // Test that acmp of the same inline object is removed - @Test(failOn = ALLOC + LOAD + STORE + NULL_CHECK_TRAP + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, NULL_CHECK_TRAP, TRAP}) public static boolean test135() { MyValue1 val = MyValue1.createWithFieldsInline(rI, rL); return val == val; } - @DontCompile - public void test135_verifier(boolean warmup) { + @Run(test = "test135") + public void test135_verifier() { Asserts.assertTrue(test135()); } // Same as test135 but with .ref - @Test(failOn = ALLOC + LOAD + STORE + NULL_CHECK_TRAP + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, NULL_CHECK_TRAP, TRAP}) public static boolean test136(boolean b) { MyValue1.ref val = MyValue1.createWithFieldsInline(rI, rL); if (b) { @@ -3674,8 +3754,8 @@ public static boolean test136(boolean b) { return val == val; } - @DontCompile - public void test136_verifier(boolean warmup) { + @Run(test = "test136") + public void test136_verifier() { Asserts.assertTrue(test136(false)); Asserts.assertTrue(test136(true)); } @@ -3688,20 +3768,22 @@ public SimpleInlineType(int x) { } // Test that acmp of different inline objects with same content is removed - @Test(failOn = ALLOC + LOAD + STORE + NULL_CHECK_TRAP + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, NULL_CHECK_TRAP, TRAP}) public static boolean test137(int i) { SimpleInlineType val1 = new SimpleInlineType(i); SimpleInlineType val2 = new SimpleInlineType(i); return val1 == val2; } - @DontCompile - public void test137_verifier(boolean warmup) { + @Run(test = "test137") + public void test137_verifier() { Asserts.assertTrue(test137(rI)); } // Same as test137 but with .ref - @Test(failOn = ALLOC + LOAD + STORE + NULL_CHECK_TRAP + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, NULL_CHECK_TRAP, TRAP}) public static boolean test138(int i, boolean b) { SimpleInlineType.ref val1 = new SimpleInlineType(i); SimpleInlineType.ref val2 = new SimpleInlineType(i); @@ -3712,8 +3794,8 @@ public static boolean test138(int i, boolean b) { return val1 == val2; } - @DontCompile - public void test138_verifier(boolean warmup) { + @Run(test = "test138") + public void test138_verifier() { Asserts.assertTrue(test138(rI, false)); Asserts.assertTrue(test138(rI, true)); } @@ -3727,14 +3809,15 @@ static primitive class Test139Wrapper { Test139Value value = Test139Value.default; } - @Test(failOn = ALLOC + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, TRAP}) public MyValueEmpty test139() { Test139Wrapper w = new Test139Wrapper(); return w.value.empty; } - @DontCompile - public void test139_verifier(boolean warmup) { + @Run(test = "test139") + public void test139_verifier() { MyValueEmpty empty = test139(); Asserts.assertEquals(empty, MyValueEmpty.default); } @@ -3748,14 +3831,14 @@ public int get() { } @Test - @Warmup(0) public int test140() { Test140Value vt = Test140Value.default; return vt.get(); } - @DontCompile - public void test140_verifier(boolean warmup) { + @Run(test = "test140") + @Warmup(0) + public void test140_verifier() { int result = test140(); Asserts.assertEquals(result, 0); } @@ -3769,20 +3852,21 @@ public int get() { } @Test - @Warmup(0) public int test141() { Test141Value vt = Test141Value.default; return vt.get(); } - @DontCompile - public void test141_verifier(boolean warmup) { + @Run(test = "test141") + @Warmup(0) + public void test141_verifier() { int result = test141(); Asserts.assertEquals(result, 0); } // Test that virtual calls on inline type receivers are properly inlined - @Test(failOn = ALLOC + LOAD + STORE) + @Test + @IR(failOn = {ALLOC, LOAD, STORE}) public long test142() { MyValue2 nonNull = MyValue2.createWithFieldsInline(rI, rD); MyInterface val = null; @@ -3795,8 +3879,8 @@ public long test142() { return val.hash(); } - @DontCompile - public void test142_verifier(boolean warmup) { + @Run(test = "test142") + public void test142_verifier() { long res = test142(); Asserts.assertEquals(res, testValue2.hash()); } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorldProfiling.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorldProfiling.java index 12232c26655..66e8a0e1e0e 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorldProfiling.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestLWorldProfiling.java @@ -23,66 +23,77 @@ package compiler.valhalla.inlinetypes; +import compiler.lib.ir_framework.*; import jdk.test.lib.Asserts; +import sun.hotspot.WhiteBox; + import java.lang.reflect.Method; +import static compiler.valhalla.inlinetypes.InlineTypes.IRNode.*; +import static compiler.valhalla.inlinetypes.InlineTypes.*; + /* * @test * @key randomness * @summary Test inline type specific profiling - * @library /testlibrary /test/lib /compiler/whitebox / + * @library /test/lib / * @requires (os.simpleArch == "x64") - * @compile TestLWorldProfiling.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI -XX:FlatArrayElementMaxSize=-1 - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestLWorldProfiling + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestLWorldProfiling */ -public class TestLWorldProfiling extends InlineTypeTest { - - static final String[][] scenarios = { - {"-XX:-UseArrayLoadStoreProfile", - "-XX:-UseACmpProfile", - "-XX:TypeProfileLevel=0", - "-XX:-MonomorphicArrayCheck" }, - { "-XX:+UseArrayLoadStoreProfile", - "-XX:+UseACmpProfile", - "-XX:TypeProfileLevel=0" }, - { "-XX:-UseArrayLoadStoreProfile", - "-XX:-UseACmpProfile", - "-XX:TypeProfileLevel=222", - "-XX:-MonomorphicArrayCheck" }, - { "-XX:-UseArrayLoadStoreProfile", - "-XX:-UseACmpProfile", - "-XX:TypeProfileLevel=0", - "-XX:-MonomorphicArrayCheck", - "-XX:TieredStopAtLevel=4", - "-XX:-TieredCompilation" }, - { "-XX:+UseArrayLoadStoreProfile", - "-XX:+UseACmpProfile", - "-XX:TypeProfileLevel=0", - "-XX:TieredStopAtLevel=4", - "-XX:-TieredCompilation" }, - { "-XX:-UseArrayLoadStoreProfile", - "-XX:-UseACmpProfile", - "-XX:TypeProfileLevel=222", - "-XX:-MonomorphicArrayCheck", - "-XX:TieredStopAtLevel=4", - "-XX:-TieredCompilation" } - }; - - public int getNumScenarios() { - return scenarios.length; - } - - public String[] getVMParameters(int scenario) { - return scenarios[scenario]; - } - - public static void main(String[] args) throws Throwable { - TestLWorldProfiling test = new TestLWorldProfiling(); - test.run(args, MyValue1.class, MyValue2.class); + +@ForceCompileClassInitializer +public class TestLWorldProfiling { + + public static void main(String[] args) { + final Scenario[] scenarios = { + new Scenario(0, + "-XX:FlatArrayElementMaxSize=-1", + "-XX:-UseArrayLoadStoreProfile", + "-XX:-UseACmpProfile", + "-XX:TypeProfileLevel=0", + "-XX:-MonomorphicArrayCheck"), + new Scenario(1, + "-XX:FlatArrayElementMaxSize=-1", + "-XX:+UseArrayLoadStoreProfile", + "-XX:+UseACmpProfile", + "-XX:TypeProfileLevel=0"), + new Scenario(2, + "-XX:FlatArrayElementMaxSize=-1", + "-XX:-UseArrayLoadStoreProfile", + "-XX:-UseACmpProfile", + "-XX:TypeProfileLevel=222", + "-XX:-MonomorphicArrayCheck"), + new Scenario(3, + "-XX:FlatArrayElementMaxSize=-1", + "-XX:-UseArrayLoadStoreProfile", + "-XX:-UseACmpProfile", + "-XX:TypeProfileLevel=0", + "-XX:-MonomorphicArrayCheck", + "-XX:TieredStopAtLevel=4", + "-XX:-TieredCompilation"), + new Scenario(4, + "-XX:FlatArrayElementMaxSize=-1", + "-XX:+UseArrayLoadStoreProfile", + "-XX:+UseACmpProfile", + "-XX:TypeProfileLevel=0", + "-XX:TieredStopAtLevel=4", + "-XX:-TieredCompilation"), + new Scenario(5, + "-XX:FlatArrayElementMaxSize=-1", + "-XX:-UseArrayLoadStoreProfile", + "-XX:-UseACmpProfile", + "-XX:TypeProfileLevel=222", + "-XX:-MonomorphicArrayCheck", + "-XX:TieredStopAtLevel=4", + "-XX:-TieredCompilation") + }; + + InlineTypes.getFramework() + .addScenarios(scenarios) + .addFlags("-XX:+IgnoreUnrecognizedVMOptions") + .addHelperClasses(MyValue1.class, + MyValue2.class) + .start(); } private static final MyValue1 testValue1 = MyValue1.createWithFieldsInline(rI, rL); @@ -95,19 +106,31 @@ public static void main(String[] args) throws Throwable { private static final MyValue1.ref[] testValue1NotFlatArray = new MyValue1.ref[] {testValue1}; private static final MyValue1[][] testValue1ArrayArray = new MyValue1[][] {testValue1Array}; + // Wrap these variables into helper class because + // WhiteBox API needs to be initialized by TestFramework first. + static class WBFlags { + static final boolean UseACmpProfile = (Boolean) WhiteBox.getWhiteBox().getVMFlag("UseACmpProfile"); + static final boolean TieredCompilation = (Boolean) WhiteBox.getWhiteBox().getVMFlag("TieredCompilation"); + static final boolean ProfileInterpreter = (Boolean) WhiteBox.getWhiteBox().getVMFlag("ProfileInterpreter"); + static final boolean UseArrayLoadStoreProfile = (Boolean) WhiteBox.getWhiteBox().getVMFlag("UseArrayLoadStoreProfile"); + static final long TypeProfileLevel = (Long) WhiteBox.getWhiteBox().getVMFlag("TypeProfileLevel"); + } + // aaload - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, failOn = LOAD_UNKNOWN_INLINE) - @Test(valid = TypeProfileOn, failOn = LOAD_UNKNOWN_INLINE) - @Test(match = { LOAD_UNKNOWN_INLINE }, matchCount = { 1 }) + @Test + @IR(applyIfOr = {"UseArrayLoadStoreProfile", "true", "TypeProfileLevel", "= 222"}, + failOn = {LOAD_UNKNOWN_INLINE}) + @IR(applyIfAnd={"UseACmpProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {LOAD_UNKNOWN_INLINE, "= 1"}) public Object test1(Object[] array) { return array[0]; } - @DontCompile - public void test1_verifier(boolean warmup) { - if (warmup) { + @Run(test = "test1") + @Warmup(10000) + public void test1_verifier(RunInfo info) { + if (info.isWarmUp()) { Object o = test1(testValue1Array); Asserts.assertEQ(((MyValue1)o).hash(), testValue1.hash()); } else { @@ -116,17 +139,19 @@ public void test1_verifier(boolean warmup) { } } - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, failOn = LOAD_UNKNOWN_INLINE) - @Test(valid = TypeProfileOn, failOn = LOAD_UNKNOWN_INLINE) - @Test(match = { LOAD_UNKNOWN_INLINE }, matchCount = { 1 }) + @Test + @IR(applyIfOr = {"UseArrayLoadStoreProfile", "true", "TypeProfileLevel", "= 222"}, + failOn = {LOAD_UNKNOWN_INLINE}) + @IR(applyIfAnd = {"UseArrayLoadStoreProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {LOAD_UNKNOWN_INLINE, "= 1"}) public Object test2(Object[] array) { return array[0]; } - @DontCompile - public void test2_verifier(boolean warmup) { - if (warmup) { + @Run(test = "test2") + @Warmup(10000) + public void test2_verifier(RunInfo info) { + if (info.isWarmUp()) { Object o = test2(testIntegerArray); Asserts.assertEQ(o, 42); } else { @@ -135,30 +160,34 @@ public void test2_verifier(boolean warmup) { } } - @Warmup(10000) - @Test(match = { LOAD_UNKNOWN_INLINE }, matchCount = { 1 }) + @Test + @IR(counts = {LOAD_UNKNOWN_INLINE, "= 1"}) public Object test3(Object[] array) { return array[0]; } - @DontCompile - public void test3_verifier(boolean warmup) { + @Run(test = "test3") + @Warmup(10000) + public void test3_verifier() { Object o = test3(testValue1Array); Asserts.assertEQ(((MyValue1)o).hash(), testValue1.hash()); o = test3(testValue2Array); Asserts.assertEQ(((MyValue2)o).hash(), testValue2.hash()); } - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, failOn = LOAD_UNKNOWN_INLINE) - @Test(match = { LOAD_UNKNOWN_INLINE }, matchCount = { 1 }) + @Test + @IR(applyIf = {"UseArrayLoadStoreProfile", "true"}, + failOn = {LOAD_UNKNOWN_INLINE}) + @IR(applyIf = {"UseArrayLoadStoreProfile", "false"}, + counts = {LOAD_UNKNOWN_INLINE, "= 1"}) public Object test4(Object[] array) { return array[0]; } - @DontCompile - public void test4_verifier(boolean warmup) { - if (warmup) { + @Run(test = "test4") + @Warmup(10000) + public void test4_verifier(RunInfo info) { + if (info.isWarmUp()) { Object o = test4(testIntegerArray); Asserts.assertEQ(o, 42); o = test4(testLongArray); @@ -169,14 +198,15 @@ public void test4_verifier(boolean warmup) { } } - @Warmup(10000) - @Test(match = { LOAD_UNKNOWN_INLINE }, matchCount = { 1 }) + @Test + @IR(counts = {LOAD_UNKNOWN_INLINE, "= 1"}) public Object test5(Object[] array) { return array[0]; } - @DontCompile - public void test5_verifier(boolean warmup) { + @Run(test = "test5") + @Warmup(10000) + public void test5_verifier() { Object o = test5(testValue1Array); Asserts.assertEQ(((MyValue1)o).hash(), testValue1.hash()); o = test5(testValue1NotFlatArray); @@ -196,19 +226,21 @@ public void test6_helper(Number[] arg) { } } - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, match = { CALL, CLASS_CHECK_TRAP, NULL_CHECK_TRAP, RANGE_CHECK_TRAP }, matchCount = { 3, 1, 1, 1 }) - @Test(valid = TypeProfileOn, match = { CALL, CLASS_CHECK_TRAP, NULL_CHECK_TRAP, RANGE_CHECK_TRAP }, matchCount = { 3, 1, 1, 1 }) - @Test(match = { CALL, RANGE_CHECK_TRAP, NULL_CHECK_TRAP }, matchCount = { 5, 1, 1 }) + @Test + @IR(applyIfOr = {"UseArrayLoadStoreProfile", "true", "TypeProfileLevel", "= 222"}, + counts = {CALL, "= 3", CLASS_CHECK_TRAP, "= 1", NULL_CHECK_TRAP, "= 1", RANGE_CHECK_TRAP, "= 1"}) + @IR(applyIfAnd = {"UseArrayLoadStoreProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {CALL, "= 5", RANGE_CHECK_TRAP, "= 1", NULL_CHECK_TRAP, "= 1"}) public Object test6(Number[] array) { Number v = array[0]; test6_helper(array); return v; } - @DontCompile - public void test6_verifier(boolean warmup) { - if (warmup) { + @Run(test = "test6") + @Warmup(10000) + public void test6_verifier(RunInfo info) { + if (info.isWarmUp()) { // pollute profile test6_helper(testLongArray); test6_helper(testDoubleArray); @@ -227,19 +259,21 @@ public void test7_helper(Number arg) { } } - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, match = { CALL, CLASS_CHECK_TRAP, NULL_CHECK_TRAP, RANGE_CHECK_TRAP }, matchCount = { 4, 1, 2, 1 }) - @Test(valid = TypeProfileOn, match = { CALL, CLASS_CHECK_TRAP, NULL_CHECK_TRAP, RANGE_CHECK_TRAP }, matchCount = { 4, 1, 2, 1 }) - @Test(match = { CALL, RANGE_CHECK_TRAP, NULL_CHECK_TRAP }, matchCount = { 6, 1, 2 }) + @Test + @IR(applyIfOr = {"UseArrayLoadStoreProfile", "true", "TypeProfileLevel", "= 222"}, + counts = {CALL, "= 4", CLASS_CHECK_TRAP, "= 1", NULL_CHECK_TRAP, "= 2", RANGE_CHECK_TRAP, "= 1"}) + @IR(applyIfAnd = {"UseArrayLoadStoreProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {CALL, "= 6", RANGE_CHECK_TRAP, "= 1", NULL_CHECK_TRAP, "= 2"}) public Object test7(Number[] array) { Number v = array[0]; test7_helper(v); return v; } - @DontCompile - public void test7_verifier(boolean warmup) { - if (warmup) { + @Run(test = "test7") + @Warmup(10000) + public void test7_verifier(RunInfo info) { + if (info.isWarmUp()) { // pollute profile test7_helper(42L); test7_helper(42.0D); @@ -258,18 +292,23 @@ public void test8_helper(Object arg) { } } - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, match = { CALL, CLASS_CHECK_TRAP, NULL_CHECK_TRAP, RANGE_CHECK_TRAP, UNHANDLED_TRAP, ALLOC_G }, matchCount = { 6, 1, 2, 1, 1, 1 }) - @Test(match = { CALL, RANGE_CHECK_TRAP, NULL_CHECK_TRAP, UNHANDLED_TRAP, ALLOC_G }, matchCount = { 6, 1, 2, 1, 1 }) + @Test + @IR(applyIf = {"UseArrayLoadStoreProfile", "true"}, + counts = {CALL, "= 6", CLASS_CHECK_TRAP, "= 1", NULL_CHECK_TRAP, "= 2", + RANGE_CHECK_TRAP, "= 1", UNHANDLED_TRAP, "= 1", ALLOC_G, "= 1"}) + @IR(applyIf = {"UseArrayLoadStoreProfile", "false"}, + counts = {CALL, "= 6", RANGE_CHECK_TRAP, "= 1", NULL_CHECK_TRAP, "= 2", + UNHANDLED_TRAP, "= 1", ALLOC_G, "= 1"}) public Object test8(Object[] array) { Object v = array[0]; test8_helper(v); return v; } - @DontCompile - public void test8_verifier(boolean warmup) { - if (warmup) { + @Run(test = "test8") + @Warmup(10000) + public void test8_verifier(RunInfo info) { + if (info.isWarmUp()) { // pollute profile test8_helper(42L); test8_helper(42.0D); @@ -280,91 +319,103 @@ public void test8_verifier(boolean warmup) { // aastore - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, failOn = STORE_UNKNOWN_INLINE) - @Test(valid = TypeProfileOn, failOn = STORE_UNKNOWN_INLINE) - @Test(match = { STORE_UNKNOWN_INLINE }, matchCount = { 1 }) + @Test + @IR(applyIfOr = {"UseArrayLoadStoreProfile", "true", "TypeProfileLevel", "= 222"}, + failOn = {STORE_UNKNOWN_INLINE}) + @IR(applyIfAnd = {"UseArrayLoadStoreProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {STORE_UNKNOWN_INLINE, "= 1"}) public void test9(Object[] array, Object v) { array[0] = v; } - @DontCompile - public void test9_verifier(boolean warmup) { + @Run(test = "test9") + @Warmup(10000) + public void test9_verifier() { test9(testValue1Array, testValue1); Asserts.assertEQ(testValue1Array[0].hash(), testValue1.hash()); } - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, failOn = STORE_UNKNOWN_INLINE) - @Test(valid = TypeProfileOn, failOn = STORE_UNKNOWN_INLINE) - @Test(match = { STORE_UNKNOWN_INLINE }, matchCount = { 1 }) + + @Test + @IR(applyIfOr = {"UseArrayLoadStoreProfile", "true", "TypeProfileLevel", "= 222"}, + failOn = {STORE_UNKNOWN_INLINE}) + @IR(applyIfAnd = {"UseArrayLoadStoreProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {STORE_UNKNOWN_INLINE, "= 1"}) public void test10(Object[] array, Object v) { array[0] = v; } - @DontCompile - public void test10_verifier(boolean warmup) { + @Run(test = "test10") + @Warmup(10000) + public void test10_verifier() { test10(testIntegerArray, 42); } - @Warmup(10000) - @Test(match = { STORE_UNKNOWN_INLINE }, matchCount = { 1 }) + @Test + @IR(counts = {STORE_UNKNOWN_INLINE, "= 1"}) public void test11(Object[] array, Object v) { array[0] = v; } - @DontCompile - public void test11_verifier(boolean warmup) { + @Run(test = "test11") + @Warmup(10000) + public void test11_verifier() { test11(testValue1Array, testValue1); test11(testValue2Array, testValue2); } - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, failOn = STORE_UNKNOWN_INLINE) - @Test(match = { STORE_UNKNOWN_INLINE }, matchCount = { 1 }) + @Test + @IR(applyIf = {"UseArrayLoadStoreProfile", "true"}, + failOn = {STORE_UNKNOWN_INLINE}) + @IR(applyIf = {"UseArrayLoadStoreProfile", "false"}, + counts = {STORE_UNKNOWN_INLINE, "= 1"}) public void test12(Object[] array, Object v) { array[0] = v; } - @DontCompile - public void test12_verifier(boolean warmup) { + @Run(test = "test12") + @Warmup(10000) + public void test12_verifier() { test12(testIntegerArray, 42); test12(testLongArray, 42L); } - @Warmup(10000) - @Test(match = { STORE_UNKNOWN_INLINE }, matchCount = { 1 }) + @Test + @IR(counts = {STORE_UNKNOWN_INLINE, "= 1"}) public void test13(Object[] array, Object v) { array[0] = v; } - @DontCompile - public void test13_verifier(boolean warmup) { + @Run(test = "test13") + @Warmup(10000) + public void test13_verifier() { test13(testValue1Array, testValue1); test13(testValue1NotFlatArray, testValue1); } // MonomorphicArrayCheck - @Warmup(10000) @Test public void test14(Number[] array, Number v) { array[0] = v; } - @DontCompile - public void test14_verifier(boolean warmup) { - if (warmup) { + @Run(test = "test14") + @Warmup(10000) + public void test14_verifier(RunInfo info) { + if (info.isWarmUp()) { test14(testIntegerArray, 42); } else { - Method m = tests.get("TestLWorldProfiling::test14"); + Method m = info.getTest(); boolean deopt = false; for (int i = 0; i < 100; i++) { test14(testIntegerArray, 42); - if (!WHITE_BOX.isMethodCompiled(m, false)) { + if (!info.isCompilationSkipped() && !TestFramework.isCompiled(m)) { deopt = true; } } - if (deopt && !TieredCompilation && !STRESS_CC && ProfileInterpreter && (UseArrayLoadStoreProfile || TypeProfileLevel == 222)) { + + if (deopt && !WBFlags.TieredCompilation && WBFlags.ProfileInterpreter && + (WBFlags.UseArrayLoadStoreProfile || WBFlags.TypeProfileLevel == 222)) { throw new RuntimeException("Monomorphic array check should rely on profiling and be accurate"); } } @@ -384,16 +435,19 @@ primitive static class NotFlattenable { private static final NotFlattenable notFlattenable = new NotFlattenable(); private static final NotFlattenable[] testNotFlattenableArray = new NotFlattenable[] { notFlattenable }; - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, match = { NULL_CHECK_TRAP }, matchCount = { 2 }, failOn = STORE_UNKNOWN_INLINE) - @Test(valid = TypeProfileOn, match = { NULL_CHECK_TRAP }, matchCount = { 2 }, failOn = STORE_UNKNOWN_INLINE) - @Test(match = { NULL_CHECK_TRAP, STORE_UNKNOWN_INLINE }, matchCount = { 3, 1 }) + @Test + @IR(applyIfOr = {"UseArrayLoadStoreProfile", "true", "TypeProfileLevel", "= 222"}, + counts = {NULL_CHECK_TRAP, "= 2"}, + failOn = {STORE_UNKNOWN_INLINE}) + @IR(applyIfAnd = {"UseArrayLoadStoreProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {NULL_CHECK_TRAP, "= 3", STORE_UNKNOWN_INLINE, "= 1"}) public void test15(Object[] array, Object v) { array[0] = v; } - @DontCompile - public void test15_verifier(boolean warmup) { + @Run(test = "test15") + @Warmup(10000) + public void test15_verifier() { test15(testNotFlattenableArray, notFlattenable); try { test15(testNotFlattenableArray, null); @@ -403,15 +457,19 @@ public void test15_verifier(boolean warmup) { } } - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, match = { NULL_CHECK_TRAP }, matchCount = { 2 }, failOn = STORE_UNKNOWN_INLINE) - @Test(match = { NULL_CHECK_TRAP, STORE_UNKNOWN_INLINE }, matchCount = { 3, 1 }) + @Test + @IR(applyIf = {"UseArrayLoadStoreProfile", "true"}, + counts = {NULL_CHECK_TRAP, "= 2"}, + failOn = {STORE_UNKNOWN_INLINE}) + @IR(applyIf = {"UseArrayLoadStoreProfile", "false"}, + counts = {NULL_CHECK_TRAP, "= 3", STORE_UNKNOWN_INLINE, "= 1"}) public void test16(Object[] array, Object v) { array[0] = v; } - @DontCompile - public void test16_verifier(boolean warmup) { + @Run(test = "test16") + @Warmup(10000) + public void test16_verifier() { test16(testNotFlattenableArray, notFlattenable); try { test16(testNotFlattenableArray, null); @@ -422,15 +480,19 @@ public void test16_verifier(boolean warmup) { test16(testIntegerArray, 42); } - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, match = { NULL_CHECK_TRAP }, matchCount = { 1 }, failOn = STORE_UNKNOWN_INLINE) - @Test(match = { NULL_CHECK_TRAP, STORE_UNKNOWN_INLINE }, matchCount = { 3, 1 }) + @Test + @IR(applyIf = {"UseArrayLoadStoreProfile", "true"}, + counts = {NULL_CHECK_TRAP, "= 1"}, + failOn = {STORE_UNKNOWN_INLINE}) + @IR(applyIf = {"UseArrayLoadStoreProfile", "false"}, + counts = {NULL_CHECK_TRAP, "= 3", STORE_UNKNOWN_INLINE, "= 1"}) public void test17(Object[] array, Object v) { array[0] = v; } - @DontCompile - public void test17_verifier(boolean warmup) { + @Run(test = "test17") + @Warmup(10000) + public void test17_verifier() { test17(testIntegerArray, 42); test17(testIntegerArray, null); testIntegerArray[0] = 42; @@ -441,17 +503,21 @@ public void test18_helper(Object[] array, Object v) { array[0] = v; } - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, match = { NULL_CHECK_TRAP }, matchCount = { 1 }, failOn = STORE_UNKNOWN_INLINE) - @Test(match = { NULL_CHECK_TRAP, STORE_UNKNOWN_INLINE }, matchCount = { 3, 1 }) + @Test + @IR(applyIf = {"UseArrayLoadStoreProfile", "true"}, + counts = {NULL_CHECK_TRAP, "= 1"}, + failOn = {STORE_UNKNOWN_INLINE}) + @IR(applyIf = {"UseArrayLoadStoreProfile", "false"}, + counts = {NULL_CHECK_TRAP, "= 3", STORE_UNKNOWN_INLINE, "= 1"}) public Object test18(Object[] array, Object v1) { Object v2 = array[0]; test18_helper(array, v1); return v2; } - @DontCompile - public void test18_verifier(boolean warmup) { + @Run(test = "test18") + @Warmup(10000) + public void test18_verifier() { test18_helper(testValue1Array, testValue1); // pollute profile test18(testIntegerArray, 42); test18(testIntegerArray, null); @@ -461,30 +527,36 @@ public void test18_verifier(boolean warmup) { // maybe null free, not flat - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, failOn = LOAD_UNKNOWN_INLINE) - @Test(match = { LOAD_UNKNOWN_INLINE }, matchCount = { 1 }) + @Test + @IR(applyIf = {"UseArrayLoadStoreProfile", "true"}, + failOn = {LOAD_UNKNOWN_INLINE}) + @IR(applyIf = {"UseArrayLoadStoreProfile", "false"}, + counts = {LOAD_UNKNOWN_INLINE, "= 1"}) public Object test19(Object[] array) { return array[0]; } - @DontCompile - public void test19_verifier(boolean warmup) { + @Run(test = "test19") + @Warmup(10000) + public void test19_verifier() { Object o = test19(testIntegerArray); Asserts.assertEQ(o, 42); o = test19(testNotFlattenableArray); Asserts.assertEQ(o, notFlattenable); } - @Warmup(10000) - @Test(valid = ArrayLoadStoreProfileOn, failOn = STORE_UNKNOWN_INLINE) - @Test(match = { STORE_UNKNOWN_INLINE }, matchCount = { 1 }) + @Test + @IR(applyIf = {"UseArrayLoadStoreProfile", "true"}, + failOn = {STORE_UNKNOWN_INLINE}) + @IR(applyIf = {"UseArrayLoadStoreProfile", "false"}, + counts = {STORE_UNKNOWN_INLINE, "= 1"}) public void test20(Object[] array, Object o) { array[0] = o; } - @DontCompile - public void test20_verifier(boolean warmup) { + @Run(test = "test20") + @Warmup(10000) + public void test20_verifier() { test20(testIntegerArray, 42); test20(testNotFlattenableArray, notFlattenable); } @@ -492,384 +564,460 @@ public void test20_verifier(boolean warmup) { // acmp tests // branch frequency profiling causes not equal branch to be optimized out - @Warmup(10000) - @Test(failOn = SUBSTITUTABILITY_TEST) + @Test + @IR(failOn = {SUBSTITUTABILITY_TEST}) public boolean test21(Object o1, Object o2) { return o1 == o2; } - @DontCompile - public void test21_verifier(boolean warmup) { + @Run(test = "test21") + @Warmup(10000) + public void test21_verifier() { test21(42, 42); test21(testValue1, testValue1); } // Input profiled non null - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_ASSERT_TRAP }, matchCount = { 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIf = {"UseACmpProfile", "true"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = {NULL_ASSERT_TRAP, "= 1"}) + @IR(applyIf = {"UseACmpProfile", "false"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test22(Object o1, Object o2) { return o1 == o2; } - @DontCompile - public void test22_verifier(boolean warmup) { + @Run(test = "test22") + @Warmup(10000) + public void test22_verifier(RunInfo info) { test22(42, null); test22(42.0, null); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test22")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); test22(42, 42.0); - if (UseACmpProfile) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test22")); + if (WBFlags.UseACmpProfile) { + TestFramework.assertDeoptimizedByC2(m); } } } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_ASSERT_TRAP }, matchCount = { 1}) - @Test(valid = TypeProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_ASSERT_TRAP }, matchCount = { 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIfOr = {"UseACmpProfile", "true", "TypeProfileLevel", "= 222"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = {NULL_ASSERT_TRAP, "= 1"}) + @IR(applyIfAnd = {"UseACmpProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test23(Object o1, Object o2) { return o1 == o2; } - @DontCompile - public void test23_verifier(boolean warmup) { + @Run(test = "test23") + @Warmup(10000) + public void test23_verifier(RunInfo info) { test23(null, 42); test23(null, 42.0); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test23")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); test23(42, 42.0); - if (UseACmpProfile || TypeProfileLevel != 0) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test23")); + if (WBFlags.UseACmpProfile || WBFlags.TypeProfileLevel != 0) { + TestFramework.assertDeoptimizedByC2(m); } } } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_ASSERT_TRAP }, matchCount = { 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIf = {"UseACmpProfile", "true"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = {NULL_ASSERT_TRAP, "= 1"}) + @IR(applyIf = {"UseACmpProfile", "false"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test24(Object o1, Object o2) { return o1 != o2; } - @DontCompile - public void test24_verifier(boolean warmup) { + @Run(test = "test24") + @Warmup(10000) + public void test24_verifier(RunInfo info) { test24(42, null); test24(42.0, null); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test24")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); test24(42, 42.0); - if (UseACmpProfile) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test24")); + if (WBFlags.UseACmpProfile) { + TestFramework.assertDeoptimizedByC2(m); } } } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_ASSERT_TRAP }, matchCount = { 1}) - @Test(valid = TypeProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_ASSERT_TRAP }, matchCount = { 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIfOr = {"UseACmpProfile", "true", "TypeProfileLevel", "= 222"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = {NULL_ASSERT_TRAP, "= 1"}) + @IR(applyIfAnd = {"UseACmpProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test25(Object o1, Object o2) { return o1 != o2; } - @DontCompile - public void test25_verifier(boolean warmup) { + @Run(test = "test25") + @Warmup(10000) + public void test25_verifier(RunInfo info) { test25(null, 42); test25(null, 42.0); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test25")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); test25(42, 42.0); - if (UseACmpProfile || TypeProfileLevel != 0) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test25")); + if (WBFlags.UseACmpProfile || WBFlags.TypeProfileLevel != 0) { + TestFramework.assertDeoptimizedByC2(m); } } } // Input profiled not inline type with known type - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_CHECK_TRAP, CLASS_CHECK_TRAP }, matchCount = { 1, 1}) - @Test(valid = TypeProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_CHECK_TRAP, CLASS_CHECK_TRAP }, matchCount = { 1, 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIfOr = {"UseACmpProfile", "true", "TypeProfileLevel", "= 222"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = {NULL_CHECK_TRAP, "= 1", CLASS_CHECK_TRAP, "= 1"}) + @IR(applyIfAnd = {"UseACmpProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test26(Object o1, Object o2) { return o1 == o2; } - @DontCompile - public void test26_verifier(boolean warmup) { + @Run(test = "test26") + @Warmup(10000) + public void test26_verifier(RunInfo info) { test26(42, 42); test26(42, 42.0); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test26")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); for (int i = 0; i < 10; i++) { test26(42.0, 42); } - if (UseACmpProfile || TypeProfileLevel != 0) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test26")); + if (WBFlags.UseACmpProfile || WBFlags.TypeProfileLevel != 0) { + TestFramework.assertDeoptimizedByC2(m); } } } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_CHECK_TRAP, CLASS_CHECK_TRAP }, matchCount = { 1, 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIf = {"UseACmpProfile", "true"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = { NULL_CHECK_TRAP, "= 1", CLASS_CHECK_TRAP, "= 1"}) + @IR(applyIf = {"UseACmpProfile", "false"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test27(Object o1, Object o2) { return o1 == o2; } - @DontCompile - public void test27_verifier(boolean warmup) { + @Run(test = "test27") + @Warmup(10000) + public void test27_verifier(RunInfo info) { test27(42, 42); test27(42.0, 42); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test27")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); for (int i = 0; i < 10; i++) { test27(42, 42.0); } - if (UseACmpProfile) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test27")); + if (WBFlags.UseACmpProfile) { + TestFramework.assertDeoptimizedByC2(m); } } } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_CHECK_TRAP, CLASS_CHECK_TRAP }, matchCount = { 1, 1}) - @Test(valid = TypeProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_CHECK_TRAP, CLASS_CHECK_TRAP }, matchCount = { 1, 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIfOr = {"UseACmpProfile", "true", "TypeProfileLevel", "= 222"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = {NULL_CHECK_TRAP, "= 1", CLASS_CHECK_TRAP, "= 1"}) + @IR(applyIfAnd = {"UseACmpProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test28(Object o1, Object o2) { return o1 != o2; } - @DontCompile - public void test28_verifier(boolean warmup) { + @Run(test = "test28") + @Warmup(10000) + public void test28_verifier(RunInfo info) { test28(42, 42); test28(42, 42.0); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test28")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); for (int i = 0; i < 10; i++) { test28(42.0, 42); } - if (UseACmpProfile || TypeProfileLevel != 0) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test28")); + if (WBFlags.UseACmpProfile || WBFlags.TypeProfileLevel != 0) { + TestFramework.assertDeoptimizedByC2(m); } } } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_CHECK_TRAP, CLASS_CHECK_TRAP }, matchCount = { 1, 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIf = {"UseACmpProfile", "true"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = {NULL_CHECK_TRAP, "= 1", CLASS_CHECK_TRAP, "= 1"}) + @IR(applyIf = {"UseACmpProfile", "false"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test29(Object o1, Object o2) { return o1 != o2; } - @DontCompile - public void test29_verifier(boolean warmup) { + @Run(test = "test29") + @Warmup(10000) + public void test29_verifier(RunInfo info) { test29(42, 42); test29(42.0, 42); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test29")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); for (int i = 0; i < 10; i++) { test29(42, 42.0); } - if (UseACmpProfile) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test29")); + if (WBFlags.UseACmpProfile) { + TestFramework.assertDeoptimizedByC2(m); } } } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST + NULL_CHECK_TRAP, match = { CLASS_CHECK_TRAP }, matchCount = { 1}) - @Test(valid = TypeProfileOn, failOn = SUBSTITUTABILITY_TEST + NULL_CHECK_TRAP, match = { CLASS_CHECK_TRAP }, matchCount = { 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIfOr = {"UseACmpProfile", "true", "TypeProfileLevel", "= 222"}, + failOn = {SUBSTITUTABILITY_TEST, NULL_CHECK_TRAP}, + counts = {CLASS_CHECK_TRAP, "= 1"}) + @IR(applyIfAnd = {"UseACmpProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test30(Object o1, Object o2) { return o1 == o2; } - @DontCompile - public void test30_verifier(boolean warmup) { + @Run(test = "test30") + @Warmup(10000) + public void test30_verifier(RunInfo info) { test30(42, 42); test30(42, 42.0); test30(null, 42); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test30")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); for (int i = 0; i < 10; i++) { test30(42.0, 42); } - if (UseACmpProfile || TypeProfileLevel != 0) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test30")); + if (WBFlags.UseACmpProfile || WBFlags.TypeProfileLevel != 0) { + TestFramework.assertDeoptimizedByC2(m); } } } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST + NULL_CHECK_TRAP) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIf = {"UseACmpProfile", "true"}, + failOn = {SUBSTITUTABILITY_TEST, NULL_CHECK_TRAP}) + @IR(applyIf = {"UseACmpProfile", "false"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test31(Object o1, Object o2) { return o1 == o2; } - @DontCompile - public void test31_verifier(boolean warmup) { + @Run(test = "test31") + @Warmup(10000) + public void test31_verifier(RunInfo info) { test31(42, 42); test31(42.0, 42); test31(42, null); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test31")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); for (int i = 0; i < 10; i++) { test31(42, 42.0); } - if (UseACmpProfile) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test31")); + if (WBFlags.UseACmpProfile) { + TestFramework.assertDeoptimizedByC2(m); } } } // Input profiled not inline type with unknown type - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_CHECK_TRAP, CLASS_CHECK_TRAP }, matchCount = { 1, 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIf = {"UseACmpProfile", "true"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = {NULL_CHECK_TRAP, "= 1", CLASS_CHECK_TRAP, "= 1"}) + @IR(applyIf = {"UseACmpProfile", "false"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test32(Object o1, Object o2) { return o1 == o2; } - @DontCompile - public void test32_verifier(boolean warmup) { + @Run(test = "test32") + @Warmup(10000) + public void test32_verifier(RunInfo info) { test32(42, 42); test32(42, testValue1); test32(42.0, 42); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test32")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); for (int i = 0; i < 10; i++) { test32(testValue1, 42); } - if (UseACmpProfile) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test32")); + if (WBFlags.UseACmpProfile) { + TestFramework.assertDeoptimizedByC2(m); } } } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_CHECK_TRAP, CLASS_CHECK_TRAP }, matchCount = { 1, 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIf = {"UseACmpProfile", "true"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = {NULL_CHECK_TRAP, "= 1", CLASS_CHECK_TRAP, "= 1"}) + @IR(applyIf = {"UseACmpProfile", "false"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test33(Object o1, Object o2) { return o1 == o2; } - @DontCompile - public void test33_verifier(boolean warmup) { + @Run(test = "test33") + @Warmup(10000) + public void test33_verifier(RunInfo info) { test33(42, 42); test33(testValue1, 42); test33(42, 42.0); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test33")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); for (int i = 0; i < 10; i++) { test33(42, testValue1); } - if (UseACmpProfile) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test33")); + if (WBFlags.UseACmpProfile) { + TestFramework.assertDeoptimizedByC2(m); } } } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_CHECK_TRAP, CLASS_CHECK_TRAP }, matchCount = { 1, 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIf = {"UseACmpProfile", "true"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = {NULL_CHECK_TRAP, "= 1", CLASS_CHECK_TRAP, "= 1"}) + @IR(applyIf = {"UseACmpProfile", "false"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test34(Object o1, Object o2) { return o1 != o2; } - @DontCompile - public void test34_verifier(boolean warmup) { + @Run(test = "test34") + @Warmup(10000) + public void test34_verifier(RunInfo info) { test34(42, 42); test34(42, testValue1); test34(42.0, 42); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test34")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); for (int i = 0; i < 10; i++) { test34(testValue1, 42); } - if (UseACmpProfile) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test34")); + if (WBFlags.UseACmpProfile) { + TestFramework.assertDeoptimizedByC2(m); } } } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { NULL_CHECK_TRAP, CLASS_CHECK_TRAP }, matchCount = { 1, 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIf = {"UseACmpProfile", "true"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = {NULL_CHECK_TRAP, "= 1", CLASS_CHECK_TRAP, "= 1"}) + @IR(applyIf = {"UseACmpProfile", "false"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test35(Object o1, Object o2) { return o1 != o2; } - @DontCompile - public void test35_verifier(boolean warmup) { + @Run(test = "test35") + @Warmup(10000) + public void test35_verifier(RunInfo info) { test35(42, 42); test35(testValue1, 42); test35(42, 42.0); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test35")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); for (int i = 0; i < 10; i++) { test35(42, testValue1); } - if (UseACmpProfile) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test35")); + if (WBFlags.UseACmpProfile) { + TestFramework.assertDeoptimizedByC2(m); } } } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST + NULL_CHECK_TRAP, match = { CLASS_CHECK_TRAP }, matchCount = { 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIf = {"UseACmpProfile", "true"}, + failOn = {SUBSTITUTABILITY_TEST, NULL_CHECK_TRAP}, + counts = {CLASS_CHECK_TRAP, "= 1"}) + @IR(applyIf = {"UseACmpProfile", "false"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test36(Object o1, Object o2) { return o1 == o2; } - @DontCompile - public void test36_verifier(boolean warmup) { + @Run(test = "test36") + @Warmup(10000) + public void test36_verifier(RunInfo info) { test36(42, 42.0); test36(42.0, testValue1); test36(null, 42); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test36")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); for (int i = 0; i < 10; i++) { test36(testValue1, 42); } - if (UseACmpProfile) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test36")); + if (WBFlags.UseACmpProfile) { + TestFramework.assertDeoptimizedByC2(m); } } } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST + NULL_CHECK_TRAP) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1}) + @Test + @IR(applyIf = {"UseACmpProfile", "true"}, + failOn = {SUBSTITUTABILITY_TEST, NULL_CHECK_TRAP}) + @IR(applyIf = {"UseACmpProfile", "false"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public boolean test37(Object o1, Object o2) { return o1 == o2; } - @DontCompile - public void test37_verifier(boolean warmup) { + @Run(test = "test37") + @Warmup(10000) + public void test37_verifier(RunInfo info) { test37(42.0, 42); test37(testValue1, 42.0); test37(42, null); - if (!warmup) { - assertCompiledByC2(tests.get("TestLWorldProfiling::test37")); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiledByC2(m); for (int i = 0; i < 10; i++) { test37(42, testValue1); } - if (UseACmpProfile) { - assertDeoptimizedByC2(tests.get("TestLWorldProfiling::test37")); + if (WBFlags.UseACmpProfile) { + TestFramework.assertDeoptimizedByC2(m); } } } // Test that acmp profile data that's unused at the acmp is fed to // speculation and leverage later - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { CLASS_CHECK_TRAP }, matchCount = { 1}) - @Test(valid = TypeProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { CLASS_CHECK_TRAP }, matchCount = { 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1 }) + @Test + @IR(applyIfOr = {"UseACmpProfile", "true", "TypeProfileLevel", "= 222"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = {CLASS_CHECK_TRAP, "= 1"}) + @IR(applyIfAnd = {"UseACmpProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public void test38(Object o1, Object o2, Object o3) { if (o1 == o2) { test38_helper2(); @@ -885,16 +1033,20 @@ public void test38_helper(Object o1, Object o2) { public void test38_helper2() { } - @DontCompile - public void test38_verifier(boolean warmup) { + @Run(test = "test38") + @Warmup(10000) + public void test38_verifier() { test38(42, 42, 42); test38_helper(testValue1, testValue2); } - @Warmup(10000) - @Test(valid = ACmpProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { CLASS_CHECK_TRAP }, matchCount = { 1}) - @Test(valid = TypeProfileOn, failOn = SUBSTITUTABILITY_TEST, match = { CLASS_CHECK_TRAP }, matchCount = { 1}) - @Test(match = { SUBSTITUTABILITY_TEST }, matchCount = { 1 }) + + @Test + @IR(applyIfOr = {"UseACmpProfile", "true", "TypeProfileLevel", "= 222"}, + failOn = {SUBSTITUTABILITY_TEST}, + counts = {CLASS_CHECK_TRAP, "= 1"}) + @IR(applyIfAnd = {"UseACmpProfile", "false", "TypeProfileLevel", "!= 222"}, + counts = {SUBSTITUTABILITY_TEST, "= 1"}) public void test39(Object o1, Object o2, Object o3) { if (o1 == o2) { test39_helper2(); @@ -910,8 +1062,9 @@ public void test39_helper(Object o1, Object o2) { public void test39_helper2() { } - @DontCompile - public void test39_verifier(boolean warmup) { + @Run(test = "test39") + @Warmup(10000) + public void test39_verifier() { test39(42, 42, 42); test39_helper(testValue1, testValue2); } @@ -926,18 +1079,18 @@ public Object test40_access(Object[] array) { return array[0]; } - @Warmup(10000) - @Test() + @Test public Object test40(Test40Abstract[] array) { return test40_access(array); } - @DontCompile - public void test40_verifier(boolean warmup) { + @Run(test = "test40") + @Warmup(10000) + public void test40_verifier(RunInfo info) { // Make sure multiple implementors of Test40Abstract are loaded Test40Inline tmp1 = new Test40Inline(); Test40Class tmp2 = new Test40Class(); - if (warmup) { + if (info.isWarmUp()) { // Pollute profile with Object[] (exact) test40_access(new Object[1]); } else { @@ -952,18 +1105,18 @@ public void test41_access(Object[] array, Object val) { array[0] = val; } - @Warmup(10000) - @Test() + @Test public void test41(Test40Inline[] array, Object val) { test41_access(array, val); } - @DontCompile - public void test41_verifier(boolean warmup) { + @Run(test = "test41") + @Warmup(10000) + public void test41_verifier(RunInfo info) { // Make sure multiple implementors of Test40Abstract are loaded Test40Inline tmp1 = new Test40Inline(); Test40Class tmp2 = new Test40Class(); - if (warmup) { + if (info.isWarmUp()) { // Pollute profile with exact Object[] test41_access(new Object[1], new Object()); } else { diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestMethodHandles.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestMethodHandles.java index 6e093b45ff9..3263c9936a8 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestMethodHandles.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestMethodHandles.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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 @@ -23,35 +23,29 @@ package compiler.valhalla.inlinetypes; -import java.lang.invoke.*; +import compiler.lib.ir_framework.*; +import jdk.test.lib.Asserts; +import sun.hotspot.WhiteBox; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import java.lang.reflect.Method; -import jdk.test.lib.Asserts; +import static compiler.valhalla.inlinetypes.InlineTypes.IRNode.*; +import static compiler.valhalla.inlinetypes.InlineTypes.*; /* * @test * @key randomness * @summary Test method handle support for inline types - * @library /testlibrary /test/lib /compiler/whitebox / + * @library /test/lib / * @requires os.simpleArch == "x64" - * @compile TestMethodHandles.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestMethodHandles + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestMethodHandles */ -public class TestMethodHandles extends InlineTypeTest { - // Extra VM parameters for some test scenarios. See InlineTypeTest.getVMParameters() - @Override - public String[] getExtraVMParameters(int scenario) { - switch (scenario) { - // Prevent inlining through MethodHandle linkTo adapters to stress the calling convention - case 2: return new String[] {"-DVerifyIR=false", "-XX:CompileCommand=dontinline,java.lang.invoke.DirectMethodHandle::internalMemberName"}; - case 4: return new String[] {"-XX:CompileCommand=dontinline,java.lang.invoke.DirectMethodHandle::internalMemberName"}; - } - return null; - } + +@ForceCompileClassInitializer +public class TestMethodHandles { static { try { @@ -132,9 +126,22 @@ public String[] getExtraVMParameters(int scenario) { } } - public static void main(String[] args) throws Throwable { - TestMethodHandles test = new TestMethodHandles(); - test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class, MyValue3.class, MyValue3Inline.class); + public static void main(String[] args) { + Scenario[] scenarios = InlineTypes.DEFAULT_SCENARIOS; + + // Prevent inlining through MethodHandle linkTo adapters to stress the calling convention + scenarios[2].addFlags("-DVerifyIR=false", + "-XX:CompileCommand=dontinline,java.lang.invoke.DirectMethodHandle::internalMemberName"); + scenarios[4].addFlags("-XX:CompileCommand=dontinline,java.lang.invoke.DirectMethodHandle::internalMemberName"); + + InlineTypes.getFramework() + .addScenarios(scenarios) + .addHelperClasses(MyValue1.class, + MyValue2.class, + MyValue2Inline.class, + MyValue3.class, + MyValue3Inline.class) + .start(); } // Everything inlined @@ -147,14 +154,17 @@ MyValue3 test1_target() { static final MethodHandle test1_mh; - @Test(valid = InlineTypeReturnedAsFieldsOn, failOn = ALLOC + STORE + CALL) - @Test(valid = InlineTypeReturnedAsFieldsOff, match = { ALLOC, STORE }, matchCount = { 1, 14 }) + @Test + @IR(applyIf = {"InlineTypeReturnedAsFields", "true"}, + failOn = {ALLOC, STORE, CALL}) + @IR(applyIf = {"InlineTypeReturnedAsFields", "false"}, + counts = {ALLOC, "= 1", STORE, "= 14"}) public MyValue3 test1() throws Throwable { return (MyValue3)test1_mh.invokeExact(this); } - @DontCompile - public void test1_verifier(boolean warmup) throws Throwable { + @Run(test = "test1") + public void test1_verifier() throws Throwable { MyValue3 vt = test1(); test1_vt.verify(vt); } @@ -173,12 +183,13 @@ public MyValue3 test2() throws Throwable { return (MyValue3)test2_mh.invokeExact(this); } - @DontCompile - public void test2_verifier(boolean warmup) throws Throwable { - Method helper_m = getClass().getDeclaredMethod("test2_target"); - if (!warmup && USE_COMPILER && !WHITE_BOX.isMethodCompiled(helper_m, false)) { - enqueueMethodForCompilation(helper_m, COMP_LEVEL_FULL_OPTIMIZATION); - Asserts.assertTrue(WHITE_BOX.isMethodCompiled(helper_m, false), "test2_target not compiled"); + @Run(test = "test2") + public void test2_verifier(RunInfo info) throws Throwable { + if (!info.isWarmUp()) { + Method helper_m = getClass().getDeclaredMethod("test2_target"); + if (!TestFramework.isCompiled(helper_m)) { + TestFramework.compile(helper_m, CompLevel.C2); + } } MyValue3 vt = test2(); test2_vt.verify(vt); @@ -198,12 +209,12 @@ public MyValue3 test3() throws Throwable { return (MyValue3)test3_mh.invokeExact(this); } - @DontCompile - public void test3_verifier(boolean warmup) throws Throwable { + @Run(test = "test3") + public void test3_verifier(RunInfo info) throws Throwable { // hack so C2 doesn't know the target of the invoke call Class c = Class.forName("java.lang.invoke.DirectMethodHandle"); Method m = c.getDeclaredMethod("internalMemberName", Object.class); - WHITE_BOX.testSetDontInlineMethod(m, warmup); + WhiteBox.getWhiteBox().testSetDontInlineMethod(m, info.isWarmUp()); MyValue3 vt = test3(); test3_vt.verify(vt); } @@ -228,8 +239,8 @@ public int test4() throws Throwable { return (int)test4_mh.invokeExact(); } - @DontCompile - public void test4_verifier(boolean warmup) throws Throwable { + @Run(test = "test4") + public void test4_verifier() throws Throwable { int i = test4(); Asserts.assertEQ(i, test4_vt.x); } @@ -247,8 +258,8 @@ public int test5() throws Throwable { return (int)test5_mh.invokeExact(this, test5_vt); } - @DontCompile - public void test5_verifier(boolean warmup) throws Throwable { + @Run(test = "test5") + public void test5_verifier() throws Throwable { int i = test5(); Asserts.assertEQ(i, test5_vt.x); } @@ -275,14 +286,15 @@ boolean test6_test() { static final MethodHandle test6_mh; - @Test(valid = InlineTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE + STORE_INLINE_FIELDS) - @Test(valid = InlineTypeReturnedAsFieldsOff) + @Test + @IR(applyIf = {"InlineTypeReturnedAsFields", "true"}, + failOn = {ALLOC, ALLOCA, STORE, STORE_INLINE_FIELDS}) public MyValue3 test6() throws Throwable { return (MyValue3)test6_mh.invokeExact(this); } - @DontCompile - public void test6_verifier(boolean warmup) throws Throwable { + @Run(test = "test6") + public void test6_verifier() throws Throwable { test6_bool = !test6_bool; MyValue3 vt = test6(); vt.verify(test6_bool ? test6_vt1 : test6_vt2); @@ -314,8 +326,8 @@ public long test7() throws Throwable { return ((MyValue2)test7_mh.invokeExact(test7_mh1)).hash(); } - @DontCompile - public void test7_verifier(boolean warmup) throws Throwable { + @Run(test = "test7") + public void test7_verifier() throws Throwable { test7_bool = !test7_bool; long hash = test7(); Asserts.assertEQ(hash, MyValue2.createWithFieldsInline(rI+(test7_bool ? 0 : 1), rD+(test7_bool ? 0 : 1)).hash()); @@ -347,8 +359,8 @@ public long test8() throws Throwable { return ((MyValue2)test8_mh.invokeExact(test8_mh2)).hash(); } - @DontCompile - public void test8_verifier(boolean warmup) throws Throwable { + @Run(test = "test8") + public void test8_verifier() throws Throwable { test8_bool = !test8_bool; long hash = test8(); Asserts.assertEQ(hash, MyValue2.createWithFieldsInline(rI+(test8_bool ? 0 : 1), rD+(test8_bool ? 0 : 1)).hash()); @@ -388,15 +400,16 @@ boolean test9_test2() { static final MethodHandle test9_mh; - @Test(valid = InlineTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE + STORE_INLINE_FIELDS) - @Test(valid = InlineTypeReturnedAsFieldsOff) - public MyValue3 test9() throws Throwable { + @Test + @IR(applyIf = {"InlineTypeReturnedAsFields", "true"}, + failOn = {ALLOC, ALLOCA, STORE, STORE_INLINE_FIELDS}) + public MyValue3 test9() throws Throwable { return (MyValue3)test9_mh.invokeExact(this); } static int test9_i = 0; - @DontCompile - public void test9_verifier(boolean warmup) throws Throwable { + @Run(test = "test9") + public void test9_verifier() throws Throwable { test9_i++; test9_bool1 = (test9_i % 2) == 0; test9_bool2 = (test9_i % 3) == 0; @@ -443,8 +456,8 @@ public long test10() throws Throwable { static int test10_i = 0; - @DontCompile - public void test10_verifier(boolean warmup) throws Throwable { + @Run(test = "test10") + public void test10_verifier() throws Throwable { test10_i++; test10_bool1 = (test10_i % 2) == 0; test10_bool2 = (test10_i % 3) == 0; @@ -477,13 +490,13 @@ static boolean test11_test() { // Check that a buffered inline type returned by a compiled lambda form // is properly handled by the caller. @Test - @Warmup(11000) public long test11() throws Throwable { return ((MyValue2)test11_mh.invokeExact(test11_mh2)).hash(); } - @DontCompile - public void test11_verifier(boolean warmup) throws Throwable { + @Run(test = "test11") + @Warmup(11000) + public void test11_verifier() throws Throwable { test11_i++; long hash = test11(); boolean b = (test11_i % 100) == 0; diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNewAcmp.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNewAcmp.java index d77e17b00bf..2575dc65511 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNewAcmp.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNewAcmp.java @@ -33,6 +33,8 @@ package compiler.valhalla.inlinetypes; +import compiler.lib.ir_framework.CompLevel; +import compiler.lib.ir_framework.TestFramework; import jdk.test.lib.Asserts; import jdk.test.lib.process.ProcessTools; import jdk.test.lib.process.OutputAnalyzer; @@ -1804,7 +1806,7 @@ public void run(int nullMode) throws Exception { // Do some warmup runs runTest(m, args, 1000, nullMode, equalities); // Make sure method is compiled - InlineTypeTest.enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); + TestFramework.compile(m, CompLevel.ANY); Asserts.assertTrue(WHITE_BOX.isMethodCompiled(m, false), m + " not compiled"); // Run again to verify correctness of compiled code runTest(m, args, 1, nullMode, equalities); diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNullableArrays.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNullableArrays.java index c3be6cb6d79..2b00bcbdec2 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNullableArrays.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNullableArrays.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, 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 @@ -24,6 +24,12 @@ package compiler.valhalla.inlinetypes; import jdk.test.lib.Asserts; +import compiler.lib.ir_framework.*; +import static compiler.valhalla.inlinetypes.InlineTypes.rI; +import static compiler.valhalla.inlinetypes.InlineTypes.rL; +import static compiler.valhalla.inlinetypes.InlineTypes.rD; +import static compiler.valhalla.inlinetypes.InlineTypes.IRNode.*; + import java.lang.reflect.Method; import java.util.Arrays; @@ -31,31 +37,28 @@ * @test * @key randomness * @summary Test nullable inline type arrays - * @library /testlibrary /test/lib /compiler/whitebox / + * @library /test/lib / * @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64") - * @compile TestNullableArrays.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestNullableArrays + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestNullableArrays */ -public class TestNullableArrays extends InlineTypeTest { - // Extra VM parameters for some test scenarios. See InlineTypeTest.getVMParameters() - @Override - public String[] getExtraVMParameters(int scenario) { - switch (scenario) { - case 2: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast", "-XX:+StressArrayCopyMacroNode"}; - case 3: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"}; - case 4: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"}; - case 5: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast", "-XX:+StressArrayCopyMacroNode"}; - } - return null; - } - public static void main(String[] args) throws Throwable { - TestNullableArrays test = new TestNullableArrays(); - test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class); +@ForceCompileClassInitializer +public class TestNullableArrays { + + public static void main(String[] args) { + + Scenario[] scenarios = InlineTypes.DEFAULT_SCENARIOS; + scenarios[2].addFlags("-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast", "-XX:+StressArrayCopyMacroNode"); + scenarios[3].addFlags("-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"); + scenarios[4].addFlags("-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast"); + scenarios[5].addFlags("-XX:-MonomorphicArrayCheck", "-XX:-UncommonNullCast", "-XX:+StressArrayCopyMacroNode"); + + InlineTypes.getFramework() + .addScenarios(scenarios) + .addHelperClasses(MyValue1.class, + MyValue2.class, + MyValue2Inline.class) + .start(); } // Helper methods @@ -71,8 +74,12 @@ protected long hash(int x, long y) { private static final MyValue1 testValue1 = MyValue1.createWithFieldsInline(rI, rL); // Test nullable inline type array creation and initialization - @Test(valid = InlineTypeArrayFlattenOn, match = { ALLOCA }, matchCount = { 1 }) - @Test(valid = InlineTypeArrayFlattenOff, match = { ALLOCA }, matchCount = { 1 }, failOn = LOAD) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + counts = {ALLOCA, "= 1"}) + @IR(applyIf = {"FlatArrayElementMaxSize", "!= -1"}, + counts = {ALLOCA, "= 1"}, + failOn = LOAD) public MyValue1.ref[] test1(int len) { MyValue1.ref[] va = new MyValue1.ref[len]; if (len > 0) { @@ -84,8 +91,8 @@ public MyValue1.ref[] test1(int len) { return va; } - @DontCompile - public void test1_verifier(boolean warmup) { + @Run(test = "test1") + public void test1_verifier() { int len = Math.abs(rI % 10); MyValue1.ref[] va = test1(len); if (len > 0) { @@ -97,22 +104,24 @@ public void test1_verifier(boolean warmup) { } // Test creation of an inline type array and element access - @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOOP, LOAD, STORE, TRAP}) public long test2() { MyValue1.ref[] va = new MyValue1.ref[1]; va[0] = MyValue1.createWithFieldsInline(rI, rL); return va[0].hash(); } - @DontCompile - public void test2_verifier(boolean warmup) { + @Run(test = "test2") + public void test2_verifier() { long result = test2(); Asserts.assertEQ(result, hash()); } // Test receiving an inline type array from the interpreter, // updating its elements in a loop and computing a hash. - @Test(failOn = ALLOCA) + @Test + @IR(failOn = {ALLOCA}) public long test3(MyValue1.ref[] va) { long result = 0; for (int i = 0; i < 10; ++i) { @@ -125,8 +134,8 @@ public long test3(MyValue1.ref[] va) { return result; } - @DontCompile - public void test3_verifier(boolean warmup) { + @Run(test = "test3") + public void test3_verifier() { MyValue1.ref[] va = new MyValue1.ref[10]; long expected = 0; for (int i = 1; i < 10; ++i) { @@ -144,13 +153,14 @@ public void test3_verifier(boolean warmup) { } // Test returning an inline type array received from the interpreter - @Test(failOn = ALLOC + ALLOCA + LOAD + STORE + LOOP + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOAD, STORE, LOOP, TRAP}) public MyValue1.ref[] test4(MyValue1.ref[] va) { return va; } - @DontCompile - public void test4_verifier(boolean warmup) { + @Run(test = "test4") + public void test4_verifier() { MyValue1.ref[] va = new MyValue1.ref[10]; for (int i = 0; i < 10; ++i) { va[i] = MyValue1.createWithFieldsDontInline(rI + i, rL + i); @@ -187,8 +197,8 @@ public MyValue1.ref[] test5(boolean b) { return va; } - @DontCompile - public void test5_verifier(boolean warmup) { + @Run(test = "test5") + public void test5_verifier() { MyValue1.ref[] va = test5(true); Asserts.assertEQ(va.length, 5); Asserts.assertEQ(va[0].hash(), hash(rI, hash())); @@ -206,27 +216,29 @@ public void test5_verifier(boolean warmup) { } // Test creation of inline type array with single element - @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOOP, LOAD, STORE, TRAP}) public MyValue1.ref test6() { MyValue1.ref[] va = new MyValue1.ref[1]; return va[0]; } - @DontCompile - public void test6_verifier(boolean warmup) { + @Run(test = "test6") + public void test6_verifier() { MyValue1.ref[] va = new MyValue1.ref[1]; MyValue1.ref v = test6(); Asserts.assertEQ(v, null); } // Test default initialization of inline type arrays - @Test(failOn = LOAD) + @Test + @IR(failOn = LOAD) public MyValue1.ref[] test7(int len) { return new MyValue1.ref[len]; } - @DontCompile - public void test7_verifier(boolean warmup) { + @Run(test = "test7") + public void test7_verifier() { int len = Math.abs(rI % 10); MyValue1.ref[] va = test7(len); for (int i = 0; i < len; ++i) { @@ -236,13 +248,14 @@ public void test7_verifier(boolean warmup) { } // Test creation of inline type array with zero length - @Test(failOn = ALLOC + LOAD + STORE + LOOP + TRAP) + @Test + @IR(failOn = {ALLOC, LOAD, STORE, LOOP, TRAP}) public MyValue1.ref[] test8() { return new MyValue1.ref[0]; } - @DontCompile - public void test8_verifier(boolean warmup) { + @Run(test = "test8") + public void test8_verifier() { MyValue1.ref[] va = test8(); Asserts.assertEQ(va.length, 0); } @@ -250,13 +263,14 @@ public void test8_verifier(boolean warmup) { static MyValue1.ref[] test9_va; // Test that inline type array loaded from field has correct type - @Test(failOn = LOOP) + @Test + @IR(failOn = LOOP) public long test9() { return test9_va[0].hash(); } - @DontCompile - public void test9_verifier(boolean warmup) { + @Run(test = "test9") + public void test9_verifier() { test9_va = new MyValue1.ref[1]; test9_va[0] = testValue1; long result = test9(); @@ -280,8 +294,8 @@ public MyValue1.ref[][][] test10(int len1, int len2, int len3) { return arr; } - @DontCompile - public void test10_verifier(boolean warmup) { + @Run(test = "test10") + public void test10_verifier() { MyValue1.ref[][][] arr = test10(2, 3, 4); for (int i = 0; i < 2; i++) { for (int j = 0; j < 3; j++) { @@ -313,8 +327,8 @@ public void test11(MyValue1.ref[][][] arr, long[] res) { } } - @DontCompile - public void test11_verifier(boolean warmup) { + @Run(test = "test11") + public void test11_verifier() { MyValue1.ref[][][] arr = new MyValue1.ref[2][3][4]; long[] res = new long[2*3*4]; long[] verif = new long[2*3*4]; @@ -353,8 +367,8 @@ public int test12() { } } - @DontCompile - public void test12_verifier(boolean warmup) { + @Run(test = "test12") + public void test12_verifier() { Asserts.assertEQ(test12(), rI); } @@ -375,8 +389,8 @@ public int test13() { } } - @DontCompile - public void test13_verifier(boolean warmup) { + @Run(test = "test13") + public void test13_verifier() { Asserts.assertEQ(test13(), rI); } @@ -386,8 +400,8 @@ public int test14(MyValue1.ref[] va, int index) { return va[index].x; } - @DontCompile - public void test14_verifier(boolean warmup) { + @Run(test = "test14") + public void test14_verifier() { int arraySize = Math.abs(rI) % 10; MyValue1.ref[] va = new MyValue1.ref[arraySize]; @@ -422,8 +436,8 @@ public int test15() { } } - @DontCompile - public void test15_verifier(boolean warmup) { + @Run(test = "test15") + public void test15_verifier() { Asserts.assertEQ(test15(), rI); } @@ -443,8 +457,8 @@ public int test16() { } } - @DontCompile - public void test16_verifier(boolean warmup) { + @Run(test = "test16") + public void test16_verifier() { Asserts.assertEQ(test16(), rI); } @@ -455,8 +469,8 @@ public int test17(MyValue1.ref[] va, int index, MyValue1 vt) { return va[index].x; } - @DontCompile - public void test17_verifier(boolean warmup) { + @Run(test = "test17") + public void test17_verifier() { int arraySize = Math.abs(rI) % 10; MyValue1.ref[] va = new MyValue1.ref[arraySize]; @@ -486,8 +500,8 @@ public MyValue1.ref[] test18(MyValue1.ref[] va) { return va.clone(); } - @DontCompile - public void test18_verifier(boolean warmup) { + @Run(test = "test18") + public void test18_verifier(RunInfo info) { int len = Math.abs(rI) % 10; MyValue1.ref[] va1 = new MyValue1.ref[len]; MyValue1[] va2 = new MyValue1[len]; @@ -511,7 +525,7 @@ public void test18_verifier(boolean warmup) { Asserts.assertEQ(result2[i].hash(), va2[i].hash()); } } - if (compile_and_run_again_if_deoptimized(warmup, "TestNullableArrays::test18")) { + if (compile_and_run_again_if_deoptimized(info)) { MyValue1.ref[] result2 = test18(va2); for (int i = 0; i < len; ++i) { Asserts.assertEQ(result2[i].hash(), va2[i].hash()); @@ -533,8 +547,8 @@ public MyValue1.ref[] test19() { return va.clone(); } - @DontCompile - public void test19_verifier(boolean warmup) { + @Run(test = "test19") + public void test19_verifier() { MyValue1.ref[] result = test19(); Asserts.assertEQ(result[0], null); for (int i = 1; i < test19_orig.length; ++i) { @@ -548,8 +562,8 @@ public void test20(MyValue1.ref[] src, MyValue1.ref[] dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test20_verifier(boolean warmup) { + @Run(test = "test20") + public void test20_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] src1 = new MyValue1.ref[len]; MyValue1.ref[] src2 = new MyValue1.ref[len]; @@ -592,8 +606,8 @@ public void test21(MyValue2.ref[] src, MyValue2.ref[] dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test21_verifier(boolean warmup) { + @Run(test = "test21") + public void test21_verifier() { int len = Math.abs(rI) % 10; MyValue2.ref[] src1 = new MyValue2.ref[len]; MyValue2.ref[] src2 = new MyValue2.ref[len]; @@ -639,8 +653,8 @@ public MyValue1.ref[] test22(MyValue1.ref[] src) { return dst; } - @DontCompile - public void test22_verifier(boolean warmup) { + @Run(test = "test22") + public void test22_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] src1 = new MyValue1.ref[len]; MyValue1[] src2 = new MyValue1[len]; @@ -669,8 +683,8 @@ public MyValue1.ref[] test23(MyValue1.ref[] src) { return dst; } - @DontCompile - public void test23_verifier(boolean warmup) { + @Run(test = "test23") + public void test23_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] src1 = new MyValue1.ref[len]; MyValue1[] src2 = new MyValue1[len]; @@ -696,8 +710,8 @@ public void test24(MyValue1.ref[] src, Object dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test24_verifier(boolean warmup) { + @Run(test = "test24") + public void test24_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] src1 = new MyValue1.ref[len]; MyValue1.ref[] src2 = new MyValue1.ref[len]; @@ -740,8 +754,8 @@ public void test25(MyValue2.ref[] src, MyValue2.ref[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test25_verifier(boolean warmup) { + @Run(test = "test25") + public void test25_verifier() { MyValue2.ref[] src1 = new MyValue2.ref[8]; MyValue2.ref[] src2 = new MyValue2.ref[8]; MyValue2[] src3 = new MyValue2[8]; @@ -779,8 +793,8 @@ public void test26(MyValue1.ref[] src, MyValue1.ref[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test26_verifier(boolean warmup) { + @Run(test = "test26") + public void test26_verifier() { MyValue1.ref[] src1 = new MyValue1.ref[8]; MyValue1.ref[] src2 = new MyValue1.ref[8]; MyValue1[] src3 = new MyValue1[8]; @@ -818,8 +832,8 @@ public void test27(MyValue1.ref[] src, MyValue1.ref[] dst) { System.arraycopy(src, 1, dst, 2, 6); } - @DontCompile - public void test27_verifier(boolean warmup) { + @Run(test = "test27") + public void test27_verifier() { MyValue1.ref[] src1 = new MyValue1.ref[8]; MyValue1.ref[] src2 = new MyValue1.ref[8]; MyValue1[] src3 = new MyValue1[8]; @@ -854,8 +868,9 @@ public void test27_verifier(boolean warmup) { // non escaping allocations // TODO 8252027: Make sure this is optimized with ZGC - @Test(valid = ZGCOff, failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP) - @Test(valid = ZGCOn) + @Test + @IR(applyIf = {"UseZGC", "false"}, + failOn = {ALLOC, ALLOCA, LOOP, LOAD, STORE, TRAP}) public MyValue2.ref test28() { MyValue2.ref[] src = new MyValue2.ref[10]; src[0] = null; @@ -863,8 +878,8 @@ public MyValue2.ref test28() { return dst[0]; } - @DontCompile - public void test28_verifier(boolean warmup) { + @Run(test = "test28") + public void test28_verifier() { MyValue2 v = MyValue2.createWithFieldsInline(rI, rD); MyValue2.ref result = test28(); Asserts.assertEQ(result, null); @@ -872,15 +887,16 @@ public void test28_verifier(boolean warmup) { // non escaping allocations // TODO 8227588: shouldn't this have the same IR matching rules as test6? - @Test(failOn = ALLOCA + LOOP + TRAP) + @Test + @IR(failOn = {ALLOCA, LOOP, TRAP}) public MyValue2.ref test29(MyValue2.ref[] src) { MyValue2.ref[] dst = new MyValue2.ref[10]; System.arraycopy(src, 0, dst, 0, 10); return dst[0]; } - @DontCompile - public void test29_verifier(boolean warmup) { + @Run(test = "test29") + public void test29_verifier(RunInfo info) { MyValue2.ref[] src1 = new MyValue2.ref[10]; MyValue2.val[] src2 = new MyValue2.val[10]; for (int i = 0; i < 10; ++i) { @@ -889,7 +905,7 @@ public void test29_verifier(boolean warmup) { } MyValue2.ref v = test29(src1); Asserts.assertEQ(src1[0].hash(), v.hash()); - if (!warmup) { + if (!info.isWarmUp()) { v = test29(src2); Asserts.assertEQ(src2[0].hash(), v.hash()); } @@ -898,7 +914,6 @@ public void test29_verifier(boolean warmup) { // non escaping allocation with uncommon trap that needs // eliminated inline type array element as debug info @Test - @Warmup(10000) public MyValue2.ref test30(MyValue2.ref[] src, boolean flag) { MyValue2.ref[] dst = new MyValue2.ref[10]; System.arraycopy(src, 0, dst, 0, 10); @@ -906,17 +921,18 @@ public MyValue2.ref test30(MyValue2.ref[] src, boolean flag) { return dst[0]; } - @DontCompile - public void test30_verifier(boolean warmup) { + @Run(test = "test30") + @Warmup(10000) + public void test30_verifier(RunInfo info) { MyValue2.ref[] src1 = new MyValue2.ref[10]; MyValue2.val[] src2 = new MyValue2.val[10]; for (int i = 0; i < 10; ++i) { src1[i] = MyValue2.createWithFieldsInline(rI+i, rD+i); src2[i] = MyValue2.createWithFieldsInline(rI+i, rD+i); } - MyValue2.ref v = test30(src1, !warmup); + MyValue2.ref v = test30(src1, !info.isWarmUp()); Asserts.assertEQ(src1[0].hash(), v.hash()); - if (!warmup) { + if (!info.isWarmUp()) { v = test30(src2, true); Asserts.assertEQ(src2[0].hash(), v.hash()); } @@ -926,7 +942,7 @@ public void test30_verifier(boolean warmup) { @Test() // TODO 8227588 // @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP) - public long test31(boolean b, boolean deopt) { + public long test31(boolean b, boolean deopt, Method m) { MyValue2.ref[] src = new MyValue2.ref[1]; if (b) { src[0] = MyValue2.createWithFieldsInline(rI, rD); @@ -935,18 +951,18 @@ public long test31(boolean b, boolean deopt) { } if (deopt) { // uncommon trap - WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test31")); + TestFramework.deoptimize(m); } return src[0].hash(); } - @DontCompile - public void test31_verifier(boolean warmup) { + @Run(test = "test31") + public void test31_verifier(RunInfo info) { MyValue2 v1 = MyValue2.createWithFieldsInline(rI, rD); - long result1 = test31(true, !warmup); + long result1 = test31(true, !info.isWarmUp(), info.getTest()); Asserts.assertEQ(result1, v1.hash()); MyValue2 v2 = MyValue2.createWithFieldsInline(rI+1, rD+1); - long result2 = test31(false, !warmup); + long result2 = test31(false, !info.isWarmUp(), info.getTest()); Asserts.assertEQ(result2, v2.hash()); } @@ -957,8 +973,8 @@ public Object[] test32(Object[] va) { return va.clone(); } - @DontCompile - public void test32_verifier(boolean warmup) { + @Run(test = "test32") + public void test32_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] va1 = new MyValue1.ref[len]; MyValue1[] va2 = new MyValue1[len]; @@ -983,8 +999,8 @@ public Object[] test33(Object[] va) { return va.clone(); } - @DontCompile - public void test33_verifier(boolean warmup) { + @Run(test = "test33") + public void test33_verifier() { int len = Math.abs(rI) % 10; Object[] va = new Object[len]; for (int i = 0; i < len; ++i) { @@ -1020,14 +1036,14 @@ public Object[] test34(boolean flag) { return va.clone(); } - @DontCompile - public void test34_verifier(boolean warmup) { + @Run(test = "test34") + public void test34_verifier(RunInfo info) { test34(false); for (int i = 0; i < 10; i++) { // make sure we do deopt Object[] result = test34(true); verify(test34_orig, result); } - if (compile_and_run_again_if_deoptimized(warmup, "TestNullableArrays::test34")) { + if (compile_and_run_again_if_deoptimized(info)) { Object[] result = test34(true); verify(test34_orig, result); } @@ -1083,15 +1099,11 @@ static void verify(MyValue2.ref[] src, Object[] dst) { } } - static boolean compile_and_run_again_if_deoptimized(boolean warmup, String test) { - if (!warmup) { - Method m = tests.get(test); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false)) { - if (!InlineTypeArrayFlatten && !XCOMP && !STRESS_CC) { - throw new RuntimeException("Unexpected deoptimization"); - } - enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); - return true; + static boolean compile_and_run_again_if_deoptimized(RunInfo info) { + if (!info.isWarmUp()) { + Method m = info.getTest(); + if (TestFramework.isCompiled(m)) { + TestFramework.compile(m, CompLevel.C2); } } return false; @@ -1103,8 +1115,8 @@ public void test35(Object src, Object dst, int len) { System.arraycopy(src, 0, dst, 0, len); } - @DontCompile - public void test35_verifier(boolean warmup) { + @Run(test = "test35") + public void test35_verifier(RunInfo info) { int len = Math.abs(rI) % 10; MyValue1.ref[] src = new MyValue1.ref[len]; MyValue1.ref[] dst = new MyValue1.ref[len]; @@ -1113,7 +1125,7 @@ public void test35_verifier(boolean warmup) { } test35(src, dst, src.length); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestNullableArrays::test35")) { + if (compile_and_run_again_if_deoptimized(info)) { test35(src, dst, src.length); verify(src, dst); } @@ -1124,8 +1136,8 @@ public void test36(Object src, MyValue2.ref[] dst) { System.arraycopy(src, 0, dst, 0, dst.length); } - @DontCompile - public void test36_verifier(boolean warmup) { + @Run(test = "test36") + public void test36_verifier(RunInfo info) { int len = Math.abs(rI) % 10; MyValue2.ref[] src = new MyValue2.ref[len]; MyValue2.ref[] dst = new MyValue2.ref[len]; @@ -1134,7 +1146,7 @@ public void test36_verifier(boolean warmup) { } test36(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestNullableArrays::test36")) { + if (compile_and_run_again_if_deoptimized(info)) { test36(src, dst); verify(src, dst); } @@ -1145,8 +1157,8 @@ public void test37(MyValue2.ref[] src, Object dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test37_verifier(boolean warmup) { + @Run(test = "test37") + public void test37_verifier(RunInfo info) { int len = Math.abs(rI) % 10; MyValue2.ref[] src = new MyValue2.ref[len]; MyValue2.ref[] dst = new MyValue2.ref[len]; @@ -1155,20 +1167,20 @@ public void test37_verifier(boolean warmup) { } test37(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestNullableArrays::test37")) { + if (compile_and_run_again_if_deoptimized(info)) { test37(src, dst); verify(src, dst); } } @Test - @Warmup(1) // Avoid early compilation public void test38(Object src, MyValue2.ref[] dst) { System.arraycopy(src, 0, dst, 0, dst.length); } - @DontCompile - public void test38_verifier(boolean warmup) { + @Run(test = "test38") + @Warmup(1) // Avoid early compilation + public void test38_verifier(RunInfo info) { int len = Math.abs(rI) % 10; Object[] src = new Object[len]; MyValue2.ref[] dst = new MyValue2.ref[len]; @@ -1177,15 +1189,13 @@ public void test38_verifier(boolean warmup) { } test38(src, dst); verify(dst, src); - if (!warmup) { - Method m = tests.get("TestNullableArrays::test38"); - assertDeoptimizedByC2(m); - enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertDeoptimizedByC2(m); + TestFramework.compile(m, CompLevel.C2); test38(src, dst); verify(dst, src); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false) && !XCOMP && !STRESS_CC) { - throw new RuntimeException("unexpected deoptimization"); - } + TestFramework.assertCompiled(m); } } @@ -1194,8 +1204,8 @@ public void test39(MyValue2.ref[] src, Object dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test39_verifier(boolean warmup) { + @Run(test = "test39") + public void test39_verifier(RunInfo info) { int len = Math.abs(rI) % 10; MyValue2.ref[] src = new MyValue2.ref[len]; Object[] dst = new Object[len]; @@ -1204,20 +1214,20 @@ public void test39_verifier(boolean warmup) { } test39(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestNullableArrays::test39")) { + if (compile_and_run_again_if_deoptimized(info)) { test39(src, dst); verify(src, dst); } } @Test - @Warmup(1) // Avoid early compilation public void test40(Object[] src, Object dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test40_verifier(boolean warmup) { + @Run(test = "test40") + @Warmup(1) // Avoid early compilation + public void test40_verifier(RunInfo info) { int len = Math.abs(rI) % 10; Object[] src = new Object[len]; MyValue2.ref[] dst = new MyValue2.ref[len]; @@ -1226,15 +1236,13 @@ public void test40_verifier(boolean warmup) { } test40(src, dst); verify(dst, src); - if (!warmup) { - Method m = tests.get("TestNullableArrays::test40"); - assertDeoptimizedByC2(m); - enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertDeoptimizedByC2(m); + TestFramework.compile(m, CompLevel.C2); test40(src, dst); verify(dst, src); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false) && !XCOMP && !STRESS_CC) { - throw new RuntimeException("unexpected deoptimization"); - } + TestFramework.assertCompiled(m); } } @@ -1243,8 +1251,8 @@ public void test41(Object src, Object[] dst) { System.arraycopy(src, 0, dst, 0, dst.length); } - @DontCompile - public void test41_verifier(boolean warmup) { + @Run(test = "test41") + public void test41_verifier(RunInfo info) { int len = Math.abs(rI) % 10; MyValue2.ref[] src = new MyValue2.ref[len]; Object[] dst = new Object[len]; @@ -1253,7 +1261,7 @@ public void test41_verifier(boolean warmup) { } test41(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestNullableArrays::test41")) { + if (compile_and_run_again_if_deoptimized(info)) { test41(src, dst); verify(src, dst); } @@ -1264,8 +1272,8 @@ public void test42(Object[] src, Object[] dst) { System.arraycopy(src, 0, dst, 0, src.length); } - @DontCompile - public void test42_verifier(boolean warmup) { + @Run(test = "test42") + public void test42_verifier(RunInfo info) { int len = Math.abs(rI) % 10; Object[] src = new Object[len]; Object[] dst = new Object[len]; @@ -1274,11 +1282,9 @@ public void test42_verifier(boolean warmup) { } test42(src, dst); verify(src, dst); - if (!warmup) { - Method m = tests.get("TestNullableArrays::test42"); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false) && !XCOMP && !STRESS_CC) { - throw new RuntimeException("unexpected deoptimization"); - } + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiled(m); } } @@ -1288,8 +1294,8 @@ public void test43(Object src, Object dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test43_verifier(boolean warmup) { + @Run(test = "test43") + public void test43_verifier(RunInfo info) { MyValue1.ref[] src = new MyValue1.ref[8]; MyValue1.ref[] dst = new MyValue1.ref[8]; for (int i = 1; i < 8; ++i) { @@ -1297,7 +1303,7 @@ public void test43_verifier(boolean warmup) { } test43(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestNullableArrays::test43")) { + if (compile_and_run_again_if_deoptimized(info)) { test43(src, dst); verify(src, dst); } @@ -1308,8 +1314,8 @@ public void test44(Object src, MyValue2.ref[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test44_verifier(boolean warmup) { + @Run(test = "test44") + public void test44_verifier(RunInfo info) { MyValue2.ref[] src = new MyValue2.ref[8]; MyValue2.ref[] dst = new MyValue2.ref[8]; for (int i = 1; i < 8; ++i) { @@ -1317,7 +1323,7 @@ public void test44_verifier(boolean warmup) { } test44(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestNullableArrays::test44")) { + if (compile_and_run_again_if_deoptimized(info)) { test44(src, dst); verify(src, dst); } @@ -1328,8 +1334,8 @@ public void test45(MyValue2.ref[] src, Object dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test45_verifier(boolean warmup) { + @Run(test = "test45") + public void test45_verifier(RunInfo info) { MyValue2.ref[] src = new MyValue2.ref[8]; MyValue2.ref[] dst = new MyValue2.ref[8]; for (int i = 1; i < 8; ++i) { @@ -1337,20 +1343,20 @@ public void test45_verifier(boolean warmup) { } test45(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestNullableArrays::test45")) { + if (compile_and_run_again_if_deoptimized(info)) { test45(src, dst); verify(src, dst); } } @Test - @Warmup(1) // Avoid early compilation public void test46(Object[] src, MyValue2.ref[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test46_verifier(boolean warmup) { + @Run(test = "test46") + @Warmup(1) // Avoid early compilation + public void test46_verifier(RunInfo info) { Object[] src = new Object[8]; MyValue2.ref[] dst = new MyValue2.ref[8]; for (int i = 1; i < 8; ++i) { @@ -1358,15 +1364,13 @@ public void test46_verifier(boolean warmup) { } test46(src, dst); verify(dst, src); - if (!warmup) { - Method m = tests.get("TestNullableArrays::test46"); - assertDeoptimizedByC2(m); - enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertDeoptimizedByC2(m); + TestFramework.compile(m, CompLevel.C2); test46(src, dst); verify(dst, src); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false) && !XCOMP && !STRESS_CC) { - throw new RuntimeException("unexpected deoptimization"); - } + TestFramework.assertCompiled(m); } } @@ -1375,8 +1379,8 @@ public void test47(MyValue2.ref[] src, Object[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test47_verifier(boolean warmup) { + @Run(test = "test47") + public void test47_verifier(RunInfo info) { MyValue2.ref[] src = new MyValue2.ref[8]; Object[] dst = new Object[8]; for (int i = 1; i < 8; ++i) { @@ -1384,20 +1388,20 @@ public void test47_verifier(boolean warmup) { } test47(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestNullableArrays::test47")) { + if (compile_and_run_again_if_deoptimized(info)) { test47(src, dst); verify(src, dst); } } @Test - @Warmup(1) // Avoid early compilation public void test48(Object[] src, Object dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test48_verifier(boolean warmup) { + @Run(test = "test48") + @Warmup(1) // Avoid early compilation + public void test48_verifier(RunInfo info) { Object[] src = new Object[8]; MyValue2.ref[] dst = new MyValue2.ref[8]; for (int i = 1; i < 8; ++i) { @@ -1405,15 +1409,13 @@ public void test48_verifier(boolean warmup) { } test48(src, dst); verify(dst, src); - if (!warmup) { - Method m = tests.get("TestNullableArrays::test48"); - assertDeoptimizedByC2(m); - enqueueMethodForCompilation(m, COMP_LEVEL_FULL_OPTIMIZATION); + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertDeoptimizedByC2(m); + TestFramework.compile(m, CompLevel.C2); test48(src, dst); verify(dst, src); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false) && !XCOMP && !STRESS_CC) { - throw new RuntimeException("unexpected deoptimization"); - } + TestFramework.assertCompiled(m); } } @@ -1422,8 +1424,8 @@ public void test49(Object src, Object[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test49_verifier(boolean warmup) { + @Run(test = "test49") + public void test49_verifier(RunInfo info) { MyValue2.ref[] src = new MyValue2.ref[8]; Object[] dst = new Object[8]; for (int i = 1; i < 8; ++i) { @@ -1431,7 +1433,7 @@ public void test49_verifier(boolean warmup) { } test49(src, dst); verify(src, dst); - if (compile_and_run_again_if_deoptimized(warmup, "TestNullableArrays::test49")) { + if (compile_and_run_again_if_deoptimized(info)) { test49(src, dst); verify(src, dst); } @@ -1442,8 +1444,8 @@ public void test50(Object[] src, Object[] dst) { System.arraycopy(src, 0, dst, 0, 8); } - @DontCompile - public void test50_verifier(boolean warmup) { + @Run(test = "test50") + public void test50_verifier(RunInfo info) { Object[] src = new Object[8]; Object[] dst = new Object[8]; for (int i = 1; i < 8; ++i) { @@ -1451,11 +1453,9 @@ public void test50_verifier(boolean warmup) { } test50(src, dst); verify(src, dst); - if (!warmup) { - Method m = tests.get("TestNullableArrays::test50"); - if (USE_COMPILER && !WHITE_BOX.isMethodCompiled(m, false) && !XCOMP && !STRESS_CC) { - throw new RuntimeException("unexpected deoptimization"); - } + if (!info.isWarmUp()) { + Method m = info.getTest(); + TestFramework.assertCompiled(m); } } @@ -1464,8 +1464,8 @@ public MyValue1.ref[] test51(MyValue1.ref[] va) { return Arrays.copyOf(va, va.length, MyValue1.ref[].class); } - @DontCompile - public void test51_verifier(boolean warmup) { + @Run(test = "test51") + public void test51_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] va = new MyValue1.ref[len]; for (int i = 1; i < len; ++i) { @@ -1482,8 +1482,8 @@ public MyValue1.ref[] test52() { return Arrays.copyOf(test52_va, 8, MyValue1.ref[].class); } - @DontCompile - public void test52_verifier(boolean warmup) { + @Run(test = "test52") + public void test52_verifier() { for (int i = 1; i < 8; ++i) { test52_va[i] = testValue1; } @@ -1496,8 +1496,8 @@ public MyValue1.ref[] test53(Object[] va) { return Arrays.copyOf(va, va.length, MyValue1.ref[].class); } - @DontCompile - public void test53_verifier(boolean warmup) { + @Run(test = "test53") + public void test53_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] va = new MyValue1.ref[len]; for (int i = 1; i < len; ++i) { @@ -1512,8 +1512,8 @@ public Object[] test54(MyValue1.ref[] va) { return Arrays.copyOf(va, va.length, Object[].class); } - @DontCompile - public void test54_verifier(boolean warmup) { + @Run(test = "test54") + public void test54_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] va = new MyValue1.ref[len]; for (int i = 1; i < len; ++i) { @@ -1528,8 +1528,8 @@ public Object[] test55(Object[] va) { return Arrays.copyOf(va, va.length, Object[].class); } - @DontCompile - public void test55_verifier(boolean warmup) { + @Run(test = "test55") + public void test55_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] va = new MyValue1.ref[len]; for (int i = 1; i < len; ++i) { @@ -1544,8 +1544,8 @@ public MyValue1.ref[] test56(Object[] va) { return Arrays.copyOf(va, va.length, MyValue1.ref[].class); } - @DontCompile - public void test56_verifier(boolean warmup) { + @Run(test = "test56") + public void test56_verifier() { int len = Math.abs(rI) % 10; Object[] va = new Object[len]; for (int i = 1; i < len; ++i) { @@ -1560,8 +1560,8 @@ public Object[] test57(Object[] va, Class klass) { return Arrays.copyOf(va, va.length, klass); } - @DontCompile - public void test57_verifier(boolean warmup) { + @Run(test = "test57") + public void test57_verifier() { int len = Math.abs(rI) % 10; Object[] va = new MyValue1.ref[len]; for (int i = 1; i < len; ++i) { @@ -1576,8 +1576,8 @@ public Object[] test58(MyValue1.ref[] va, Class klass) { return Arrays.copyOf(va, va.length, klass); } - @DontCompile - public void test58_verifier(boolean warmup) { + @Run(test = "test58") + public void test58_verifier(RunInfo info) { int len = Math.abs(rI) % 10; MyValue1.ref[] va = new MyValue1.ref[len]; for (int i = 1; i < len; ++i) { @@ -1587,7 +1587,7 @@ public void test58_verifier(boolean warmup) { Object[] result = test58(va, MyValue1.ref[].class); verify(va, result); } - if (compile_and_run_again_if_deoptimized(warmup, "TestNullableArrays::test58")) { + if (compile_and_run_again_if_deoptimized(info)) { Object[] result = test58(va, MyValue1.ref[].class); verify(va, result); } @@ -1598,8 +1598,8 @@ public Object[] test59(MyValue1.ref[] va) { return Arrays.copyOf(va, va.length+1, MyValue1.ref[].class); } - @DontCompile - public void test59_verifier(boolean warmup) { + @Run(test = "test59") + public void test59_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] va = new MyValue1.ref[len]; MyValue1.ref[] verif = new MyValue1.ref[len+1]; @@ -1616,8 +1616,8 @@ public Object[] test60(Object[] va, Class klass) { return Arrays.copyOf(va, va.length+1, klass); } - @DontCompile - public void test60_verifier(boolean warmup) { + @Run(test = "test60") + public void test60_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] va = new MyValue1.ref[len]; MyValue1.ref[] verif = new MyValue1.ref[len+1]; @@ -1634,8 +1634,8 @@ public Object[] test61(Object[] va, Class klass) { return Arrays.copyOf(va, va.length+1, klass); } - @DontCompile - public void test61_verifier(boolean warmup) { + @Run(test = "test61") + public void test61_verifier() { int len = Math.abs(rI) % 10; Object[] va = new Integer[len]; for (int i = 1; i < len; ++i) { @@ -1668,8 +1668,8 @@ public Object[] test62(MyValue1.ref[] va, Integer[] oa) { return Arrays.copyOf(arr, arr.length+1, arr.getClass()); } - @DontCompile - public void test62_verifier(boolean warmup) { + @Run(test = "test62") + public void test62_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] va = new MyValue1.ref[len]; Integer[] oa = new Integer[len]; @@ -1704,8 +1704,8 @@ public Object[] test63(MyValue1.ref[] va, Integer[] oa) { return Arrays.copyOf(arr, arr.length+1, arr.getClass()); } - @DontCompile - public void test63_verifier(boolean warmup) { + @Run(test = "test63") + public void test63_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] va = new MyValue1.ref[len]; MyValue1.ref[] verif = new MyValue1.ref[len+1]; @@ -1725,8 +1725,8 @@ public MyValue1.ref[] test64() { return new MyValue1.ref[8]; } - @DontCompile - public void test64_verifier(boolean warmup) { + @Run(test = "test64") + public void test64_verifier() { MyValue1.ref[] va = test64(); for (int i = 0; i < 8; ++i) { Asserts.assertEQ(va[i], null); @@ -1739,8 +1739,8 @@ public MyValue1.ref[] test65() { return new MyValue1.ref[32]; } - @DontCompile - public void test65_verifier(boolean warmup) { + @Run(test = "test65") + public void test65_verifier() { MyValue1.ref[] va = test65(); for (int i = 0; i < 32; ++i) { Asserts.assertEQ(va[i], null); @@ -1748,15 +1748,16 @@ public void test65_verifier(boolean warmup) { } // Check init store elimination - @Test(match = { ALLOCA }, matchCount = { 1 }) + @Test + @IR(counts = {ALLOCA, "= 1"}) public MyValue1.ref[] test66(MyValue1.ref vt) { MyValue1.ref[] va = new MyValue1.ref[1]; va[0] = vt; return va; } - @DontCompile - public void test66_verifier(boolean warmup) { + @Run(test = "test66") + public void test66_verifier() { MyValue1.ref vt = MyValue1.createWithFieldsDontInline(rI, rL); MyValue1.ref[] va = test66(vt); Asserts.assertEQ(va[0].hashPrimitive(), vt.hashPrimitive()); @@ -1770,8 +1771,8 @@ public MyValue1.ref[] test67(MyValue1.ref[] src) { return dst; } - @DontCompile - public void test67_verifier(boolean warmup) { + @Run(test = "test67") + public void test67_verifier() { MyValue1.ref[] va = new MyValue1.ref[16]; MyValue1.ref[] var = test67(va); for (int i = 0; i < 16; ++i) { @@ -1787,8 +1788,8 @@ public MyValue1.ref[] test68() { return va; } - @DontCompile - public void test68_verifier(boolean warmup) { + @Run(test = "test68") + public void test68_verifier() { MyValue1.ref[] va = test68(); for (int i = 0; i < 2; ++i) { Asserts.assertEQ(va[i], null); @@ -1804,8 +1805,8 @@ public MyValue1.ref[] test69(MyValue1.ref vt) { return va; } - @DontCompile - public void test69_verifier(boolean warmup) { + @Run(test = "test69") + public void test69_verifier() { MyValue1.ref vt = MyValue1.createWithFieldsDontInline(rI, rL); MyValue1.ref[] va = new MyValue1.ref[4]; va[0] = vt; @@ -1827,8 +1828,8 @@ public MyValue1.ref[] test70(MyValue1.ref[] other) { return va; } - @DontCompile - public void test70_verifier(boolean warmup) { + @Run(test = "test70") + public void test70_verifier() { MyValue1.ref[] va = new MyValue1.ref[2]; MyValue1.ref[] var = test70(va); for (int i = 0; i < 2; ++i) { @@ -1855,8 +1856,8 @@ public void test71() { } } - @DontCompile - public void test71_verifier(boolean warmup) { + @Run(test = "test71") + public void test71_verifier() { test71(); } @@ -1872,8 +1873,8 @@ public void test72(Object[] o, boolean b, Object element) { arr2[0] = element; } - @DontCompile - public void test72_verifier(boolean warmup) { + @Run(test = "test72") + public void test72_verifier() { Object[] arr = new Object[1]; Object elem = new Object(); test72(arr, true, elem); @@ -1891,8 +1892,8 @@ public void test73(Object[] oa, MyValue1.ref v, Object o) { oa[0] = oa; // The stored value is known to be not flattenable (an Object[]) } - @DontCompile - public void test73_verifier(boolean warmup) { + @Run(test = "test73") + public void test73_verifier() { MyValue1.ref v0 = MyValue1.createWithFieldsDontInline(rI, rL); MyValue1.ref v1 = MyValue1.createWithFieldsDontInline(rI+1, rL+1); MyValue1.ref[] arr = new MyValue1.ref[3]; @@ -1928,8 +1929,8 @@ public Object[] test74(MyValue1.ref[] va, Integer[] oa) { return arr.clone(); } - @DontCompile - public void test74_verifier(boolean warmup) { + @Run(test = "test74") + public void test74_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] va = new MyValue1.ref[len]; Integer[] oa = new Integer[len]; @@ -1966,8 +1967,8 @@ public Object[] test75(MyValue1.ref[] va, Integer[] oa) { return arr.clone(); } - @DontCompile - public void test75_verifier(boolean warmup) { + @Run(test = "test75") + public void test75_verifier() { int len = Math.abs(rI) % 10; MyValue1.ref[] va = new MyValue1.ref[len]; MyValue1.ref[] verif = new MyValue1.ref[len]; @@ -2003,8 +2004,8 @@ public Object[] test76(MyValue1[] vva, MyValue1.ref[] vba, MyValue1 vt, Object[] return result; } - @DontCompile - public void test76_verifier(boolean warmup) { + @Run(test = "test76") + public void test76_verifier() { MyValue1 vt = testValue1; Object[] out = new Object[1]; MyValue1[] vva = new MyValue1[42]; @@ -2050,8 +2051,8 @@ public Object[] test77(boolean b) { return va; } - @DontCompile - public void test77_verifier(boolean warmup) { + @Run(test = "test77") + public void test77_verifier() { Object[] va = test77(true); Asserts.assertEQ(va.length, 5); Asserts.assertEQ(((MyValue1)va[0]).hash(), hash(rI, hash())); @@ -2086,8 +2087,8 @@ public Object[] test78(MyValue1[] vva, MyValue1.ref[] vba, Object val, Object[] return result; } - @DontCompile - public void test78_verifier(boolean warmup) { + @Run(test = "test78") + public void test78_verifier() { MyValue1 vt = testValue1; Integer i = Integer.valueOf(42); Object[] out = new Object[1]; @@ -2115,13 +2116,14 @@ public void test78_verifier(boolean warmup) { } // Test widening conversions from [Q to [L - @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOOP, LOAD, STORE, TRAP}) public static MyValue1.ref[] test79(MyValue1[] va) { return va; } - @DontCompile - public void test79_verifier(boolean warmup) { + @Run(test = "test79") + public void test79_verifier() { MyValue1[] va = new MyValue1[1]; va[0] = testValue1; MyValue1.ref[] res = test79(va); @@ -2137,13 +2139,14 @@ public void test79_verifier(boolean warmup) { } // Same as test79 but with explicit cast and Object return - @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOOP, LOAD, STORE, TRAP}) public static Object[] test80(MyValue1[] va) { return (MyValue1.ref[])va; } - @DontCompile - public void test80_verifier(boolean warmup) { + @Run(test = "test80") + public void test80_verifier() { MyValue1[] va = new MyValue1[1]; va[0] = testValue1; Object[] res = test80(va); @@ -2170,8 +2173,8 @@ public static long test81(MyValue1[] va1, MyValue1.ref[] va2, MyValue1 vt, boole return result[1].hash(); } - @DontCompile - public void test81_verifier(boolean warmup) { + @Run(test = "test81") + public void test81_verifier() { MyValue1[] va = new MyValue1[2]; MyValue1.ref[] vaB = new MyValue1.ref[2]; va[1] = testValue1; @@ -2214,8 +2217,8 @@ public static long test82(MyValue1[] va1, MyValue1.ref[] va2, MyValue1 vt1, MyVa return result[1].hash(); } - @DontCompile - public void test82_verifier(boolean warmup) { + @Run(test = "test82") + public void test82_verifier() { MyValue1[] va = new MyValue1[2]; MyValue1.ref[] vaB = new MyValue1.ref[2]; va[1] = testValue1; @@ -2237,22 +2240,24 @@ public void test82_verifier(boolean warmup) { Asserts.assertEquals(res, testValue1.hash()); } - @Test(failOn = ALLOC + ALLOCA + STORE) + @Test + @IR(failOn = {ALLOC, ALLOCA, STORE}) public static long test83(MyValue1[] va) { MyValue1.ref[] result = va; return result[0].hash(); } - @DontCompile - public void test83_verifier(boolean warmup) { + @Run(test = "test83") + public void test83_verifier() { MyValue1[] va = new MyValue1[42]; va[0] = testValue1; long res = test83(va); Asserts.assertEquals(res, testValue1.hash()); } - @Test(valid = InlineTypeArrayFlattenOn, failOn = ALLOC + LOOP + STORE + TRAP) - @Test(valid = InlineTypeArrayFlattenOff) + @Test + @IR(applyIf = {"FlatArrayElementMaxSize", "= -1"}, + failOn = {ALLOC, LOOP, STORE, TRAP}) public static MyValue1.ref[] test84(MyValue1 vt1, MyValue1.ref vt2) { MyValue1.ref[] result = new MyValue1[2]; result[0] = vt1; @@ -2260,8 +2265,8 @@ public static MyValue1.ref[] test84(MyValue1 vt1, MyValue1.ref vt2) { return result; } - @DontCompile - public void test84_verifier(boolean warmup) { + @Run(test = "test84") + public void test84_verifier() { MyValue1.ref[] res = test84(testValue1, testValue1); Asserts.assertEquals(res[0].hash(), testValue1.hash()); Asserts.assertEquals(res[1].hash(), testValue1.hash()); @@ -2279,8 +2284,8 @@ public static long test85(MyValue1.ref[] va, MyValue1 val) { return va[1].hash(); } - @DontCompile - public void test85_verifier(boolean warmup) { + @Run(test = "test85") + public void test85_verifier() { MyValue1[] va = new MyValue1[2]; MyValue1.ref[] vab = new MyValue1.ref[2]; va[1] = testValue1; @@ -2300,8 +2305,8 @@ public static long test86(MyValue1.ref[] va, MyValue1.ref val) { return va[1].hash(); } - @DontCompile - public void test86_verifier(boolean warmup) { + @Run(test = "test86") + public void test86_verifier() { MyValue1[] va = new MyValue1[2]; MyValue1.ref[] vab = new MyValue1.ref[2]; va[1] = testValue1; @@ -2331,20 +2336,21 @@ public long test87() { return va[0].hash(); } - @DontCompile - public void test87_verifier(boolean warmup) { + @Run(test = "test87") + public void test87_verifier() { long result = test87(); Asserts.assertEQ(result, hash()); } // Test narrowing conversion from [L to [Q - @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOOP, LOAD, STORE, TRAP}) public static MyValue1[] test88(MyValue1.ref[] va) { return (MyValue1[])va; } - @DontCompile - public void test88_verifier(boolean warmup) { + @Run(test = "test88") + public void test88_verifier() { MyValue1[] va = new MyValue1[1]; va[0] = testValue1; MyValue1[] res = test88(va); @@ -2360,13 +2366,14 @@ public void test88_verifier(boolean warmup) { } // Same as test88 but with explicit cast and Object argument - @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP) + @Test + @IR(failOn = {ALLOC, ALLOCA, LOOP, LOAD, STORE, TRAP}) public static MyValue1[] test89(Object[] va) { return (MyValue1[])va; } - @DontCompile - public void test89_verifier(boolean warmup) { + @Run(test = "test89") + public void test89_verifier() { MyValue1[] va = new MyValue1[1]; va[0] = testValue1; MyValue1[] res = test89(va); @@ -2387,8 +2394,8 @@ public static MyValue1.ref[] test90(Object va) { return (MyValue1.ref[])va; } - @DontCompile - public void test90_verifier(boolean warmup) { + @Run(test = "test90") + public void test90_verifier() { MyValue1[] va = new MyValue1[1]; MyValue1.ref[] vab = new MyValue1.ref[1]; try { @@ -2407,8 +2414,8 @@ public static MyValue1.ref[] test91(Object[] va) { return (MyValue1.ref[])va; } - @DontCompile - public void test91_verifier(boolean warmup) { + @Run(test = "test91") + public void test91_verifier() { MyValue1[] va = new MyValue1[1]; MyValue1.ref[] vab = new MyValue1.ref[1]; try { @@ -2428,8 +2435,8 @@ public static void test92(MyValue1.ref[] src, MyValue1.ref[] dst) { System.arraycopy(src, 0, dst, 0, 2); } - @DontCompile - public void test92_verifier(boolean warmup) { + @Run(test = "test92") + public void test92_verifier() { MyValue1[] va = new MyValue1[2]; MyValue1.ref[] vab = new MyValue1.ref[2]; va[0] = testValue1; @@ -2444,8 +2451,8 @@ public static void test93(Object src, MyValue1.ref[] dst) { System.arraycopy(src, 0, dst, 0, 2); } - @DontCompile - public void test93_verifier(boolean warmup) { + @Run(test = "test93") + public void test93_verifier() { MyValue1[] va = new MyValue1[2]; MyValue1.ref[] vab = new MyValue1.ref[2]; va[0] = testValue1; @@ -2468,8 +2475,8 @@ public static long test94() { return dst[0].hash(); } - @DontCompile - public static void test94_verifier(boolean warmup) { + @Run(test = "test94") + public static void test94_verifier() { long result = test94(); Asserts.assertEquals(result, MyValue1.default.hash()); } @@ -2483,13 +2490,13 @@ public long test95_callee() { } @Test() - @Warmup(0) public long test95() { return test95_callee(); } - @DontCompile - public void test95_verifier(boolean warmup) { + @Run(test = "test95") + @Warmup(0) + public void test95_verifier() { long result = test95(); Asserts.assertEQ(result, hash()); } @@ -2542,8 +2549,8 @@ public Complex.ref[][] test96(Complex.ref[][] A, Complex.ref[][] B) { } } - @DontCompile - public void test96_verifier(boolean warmup) { + @Run(test = "test96") + public void test96_verifier() { Complex.ref[][] result = test96(test96_A, test96_B); if (test96_R == null) { test96_R = result; @@ -2556,13 +2563,14 @@ public void test96_verifier(boolean warmup) { } // Test loads from vararg arrays - @Test(failOn = LOAD_UNKNOWN_INLINE) + @Test + @IR(failOn = {LOAD_UNKNOWN_INLINE}) public static Object test97(Object... args) { return args[0]; } - @DontCompile - public static void test97_verifier(boolean warmup) { + @Run(test = "test97") + public static void test97_verifier() { Object obj = new Object(); Object result = test97(obj); Asserts.assertEquals(result, obj); @@ -2577,8 +2585,8 @@ public static Object test98(Object... args) { return args[0]; } - @DontCompile - public static void test98_verifier(boolean warmup) { + @Run(test = "test98") + public static void test98_verifier(RunInfo info) { Object obj = new Object(); Object result = test98(obj); Asserts.assertEquals(result, obj); @@ -2586,7 +2594,7 @@ public static void test98_verifier(boolean warmup) { myInt[0] = rI; result = test98((Object[])myInt); Asserts.assertEquals(result, rI); - if (!warmup) { + if (!info.isWarmUp()) { MyValue1[] va = new MyValue1[1]; MyValue1.ref[] vab = new MyValue1.ref[1]; result = test98((Object[])va); @@ -2601,8 +2609,8 @@ public static Object test99(Object... args) { return args[0]; } - @DontCompile - public static void test99_verifier(boolean warmup) { + @Run(test = "test99") + public static void test99_verifier(RunInfo info) { Object obj = new Object(); Object result = test99(obj); Asserts.assertEquals(result, obj); @@ -2610,7 +2618,7 @@ public static void test99_verifier(boolean warmup) { myInt[0] = rI; result = test99((Object[])myInt); Asserts.assertEquals(result, rI); - if (!warmup) { + if (!info.isWarmUp()) { try { test99((Object[])null); throw new RuntimeException("No NPE thrown"); @@ -2625,8 +2633,8 @@ public static Object test100(Object... args) { return args[0]; } - @DontCompile - public static void test100_verifier(boolean warmup) { + @Run(test = "test100") + public static void test100_verifier(RunInfo info) { Object obj = new Object(); Object result = test100(obj); Asserts.assertEquals(result, obj); @@ -2634,7 +2642,7 @@ public static void test100_verifier(boolean warmup) { myInt[0] = rI; result = test100((Object[])myInt); Asserts.assertEquals(result, rI); - if (!warmup) { + if (!info.isWarmUp()) { try { test100(); throw new RuntimeException("No AIOOBE thrown"); @@ -2645,13 +2653,14 @@ public static void test100_verifier(boolean warmup) { } // Test stores to varag arrays - @Test(failOn = STORE_UNKNOWN_INLINE) + @Test + @IR(failOn = STORE_UNKNOWN_INLINE) public static void test101(Object val, Object... args) { args[0] = val; } - @DontCompile - public static void test101_verifier(boolean warmup) { + @Run(test = "test101") + public static void test101_verifier() { Object obj = new Object(); test101(obj, obj); Integer[] myInt = new Integer[1]; @@ -2666,8 +2675,8 @@ public static void test102(Object val, Object... args) { args[0] = val; } - @DontCompile - public static void test102_verifier(boolean warmup) { + @Run(test = "test102") + public static void test102_verifier(RunInfo info) { Object obj = new Object(); test102(obj, obj); Integer[] myInt = new Integer[1]; @@ -2675,7 +2684,7 @@ public static void test102_verifier(boolean warmup) { Asserts.assertEquals(myInt[0], rI); test102(null, (Object[])myInt); Asserts.assertEquals(myInt[0], null); - if (!warmup) { + if (!info.isWarmUp()) { MyValue1[] va = new MyValue1[1]; MyValue1.ref[] vab = new MyValue1.ref[1]; test102(testValue1, (Object[])va); @@ -2692,8 +2701,8 @@ public static void test103(Object val, Object... args) { args[0] = val; } - @DontCompile - public static void test103_verifier(boolean warmup) { + @Run(test = "test103") + public static void test103_verifier(RunInfo info) { Object obj = new Object(); test103(obj, obj); Integer[] myInt = new Integer[1]; @@ -2701,7 +2710,7 @@ public static void test103_verifier(boolean warmup) { Asserts.assertEquals(myInt[0], rI); test103(null, (Object[])myInt); Asserts.assertEquals(myInt[0], null); - if (!warmup) { + if (!info.isWarmUp()) { MyValue1[] va = new MyValue1[1]; try { test103(null, (Object[])va); @@ -2717,8 +2726,8 @@ public static void test104(Object val, Object... args) { args[0] = val; } - @DontCompile - public static void test104_verifier(boolean warmup) { + @Run(test = "test104") + public static void test104_verifier(RunInfo info) { Object obj = new Object(); test104(obj, obj); Integer[] myInt = new Integer[1]; @@ -2726,7 +2735,7 @@ public static void test104_verifier(boolean warmup) { Asserts.assertEquals(myInt[0], rI); test104(null, (Object[])myInt); Asserts.assertEquals(myInt[0], null); - if (!warmup) { + if (!info.isWarmUp()) { try { test104(testValue1); throw new RuntimeException("No AIOOBE thrown"); @@ -2741,8 +2750,8 @@ public static void test105(Object val, Object... args) { args[0] = val; } - @DontCompile - public static void test105_verifier(boolean warmup) { + @Run(test = "test105") + public static void test105_verifier(RunInfo info) { Object obj = new Object(); test105(obj, obj); Integer[] myInt = new Integer[1]; @@ -2750,7 +2759,7 @@ public static void test105_verifier(boolean warmup) { Asserts.assertEquals(myInt[0], rI); test105(null, (Object[])myInt); Asserts.assertEquals(myInt[0], null); - if (!warmup) { + if (!info.isWarmUp()) { try { test105(testValue1, (Object[])null); throw new RuntimeException("No NPE thrown"); @@ -2775,8 +2784,8 @@ public static Object[] test106(Object[] dst, Object... args) { return Arrays.copyOf(args, args.length, Object[].class); } - @DontCompile - public static void test106_verifier(boolean warmup) { + @Run(test = "test106") + public static void test106_verifier(RunInfo info) { Object[] dst = new Object[1]; Object obj = new Object(); Object[] result = test106(dst, obj); @@ -2785,7 +2794,7 @@ public static void test106_verifier(boolean warmup) { myInt[0] = rI; result = test106(myInt, (Object[])myInt); Asserts.assertEquals(result[0], rI); - if (!warmup) { + if (!info.isWarmUp()) { MyValue1[] va = new MyValue1[1]; MyValue1.ref[] vab = new MyValue1.ref[1]; result = test106(va, (Object[])va); @@ -2814,13 +2823,12 @@ public void test107() { Asserts.assertEquals(res2, MyValue1.default.hash()); } - @DontCompile - public void test107_verifier(boolean warmup) { + @Run(test = "test107") + public void test107_verifier() { test107(); } @Test - @Warmup(10000) public Object test108(MyValue1.ref[] src, boolean flag) { MyValue1.ref[] dst = new MyValue1.ref[8]; System.arraycopy(src, 1, dst, 2, 6); @@ -2828,10 +2836,11 @@ public Object test108(MyValue1.ref[] src, boolean flag) { return dst[2]; } - @DontCompile - public void test108_verifier(boolean warmup) { + @Run(test = "test108") + @Warmup(10000) + public void test108_verifier(RunInfo info) { MyValue1.ref[] src = new MyValue1.ref[8]; - test108(src, !warmup); + test108(src, !info.isWarmUp()); } // Test LoadNode::can_see_arraycopy_value optimization @@ -2844,8 +2853,8 @@ public static void test109() { Asserts.assertEquals(src[0], dst[0]); } - @DontCompile - public void test109_verifier(boolean warmup) { + @Run(test = "test109") + public void test109_verifier() { test109(); } @@ -2859,8 +2868,8 @@ public static void test110() { Asserts.assertEquals(src[0], dst[0]); } - @DontCompile - public void test110_verifier(boolean warmup) { + @Run(test = "test110") + public void test110_verifier() { test110(); } @@ -2873,8 +2882,8 @@ public static void test111() { Asserts.assertEquals(src[0], dst[0]); } - @DontCompile - public void test111_verifier(boolean warmup) { + @Run(test = "test111") + public void test111_verifier() { test111(); } } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNullableInlineTypes.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNullableInlineTypes.java index 7f235130fa6..3c124f28943 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNullableInlineTypes.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestNullableInlineTypes.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, 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 @@ -23,38 +23,43 @@ package compiler.valhalla.inlinetypes; -import java.lang.invoke.*; +import compiler.lib.ir_framework.*; +import jdk.test.lib.Asserts; + +import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodType; import java.lang.reflect.Method; -import jdk.test.lib.Asserts; +import static compiler.valhalla.inlinetypes.InlineTypes.IRNode.ALLOC; +import static compiler.valhalla.inlinetypes.InlineTypes.IRNode.STORE; +import static compiler.valhalla.inlinetypes.InlineTypes.rI; +import static compiler.valhalla.inlinetypes.InlineTypes.rL; /* * @test * @key randomness * @summary Test correct handling of nullable inline types. - * @library /testlibrary /test/lib /compiler/whitebox / + * @library /test/lib / * @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64") - * @compile TestNullableInlineTypes.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestNullableInlineTypes + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestNullableInlineTypes */ -public class TestNullableInlineTypes extends InlineTypeTest { - // Extra VM parameters for some test scenarios. See InlineTypeTest.getVMParameters() - @Override - public String[] getExtraVMParameters(int scenario) { - switch (scenario) { - case 3: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:FlatArrayElementMaxSize=-1"}; - case 4: return new String[] {"-XX:-MonomorphicArrayCheck"}; - } - return null; - } - public static void main(String[] args) throws Throwable { - TestNullableInlineTypes test = new TestNullableInlineTypes(); - test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class, Test17Value.class, Test21Value.class); +@ForceCompileClassInitializer +public class TestNullableInlineTypes { + + public static void main(String[] args) { + + Scenario[] scenarios = InlineTypes.DEFAULT_SCENARIOS; + scenarios[3].addFlags("-XX:-MonomorphicArrayCheck", "-XX:FlatArrayElementMaxSize=-1"); + scenarios[4].addFlags("-XX:-MonomorphicArrayCheck"); + + InlineTypes.getFramework() + .addScenarios(scenarios) + .addHelperClasses(MyValue1.class, + MyValue2.class, + MyValue2Inline.class) + .start(); } static { @@ -95,8 +100,8 @@ public long test1(MyValue1.ref vt) { return result; } - @DontCompile - public void test1_verifier(boolean warmup) throws Throwable { + @Run(test = "test1") + public void test1_verifier() throws Throwable { long result = test1(null); Asserts.assertEquals(result, 0L); } @@ -113,8 +118,8 @@ public long test2(MyValue1.ref vt) { return result; } - @DontCompile - public void test2_verifier(boolean warmup) { + @Run(test = "test2") + public void test2_verifier() { long result = test2(nullField); Asserts.assertEquals(result, 0L); } @@ -134,8 +139,8 @@ public long test3() { return result; } - @DontCompile - public void test3_verifier(boolean warmup) { + @Run(test = "test3") + public void test3_verifier() { long result = test3(); Asserts.assertEquals(result, 0L); } @@ -150,8 +155,8 @@ public void test4() { } } - @DontCompile - public void test4_verifier(boolean warmup) { + @Run(test = "test4") + public void test4_verifier() { test4(); } @@ -171,8 +176,8 @@ public MyValue1.ref test5(MyValue1.ref vt) { return vt; } - @DontCompile - public void test5_verifier(boolean warmup) { + @Run(test = "test5") + public void test5_verifier() { MyValue1.ref vt = test5(nullField); Asserts.assertEquals((Object)vt, null); } @@ -199,8 +204,8 @@ public MyValue1 test6(Object obj) { return vt; } - @DontCompile - public void test6_verifier(boolean warmup) { + @Run(test = "test6") + public void test6_verifier() { MyValue1 vt = test6(null); Asserts.assertEquals(vt.hash(), testValue1.hash()); } @@ -233,8 +238,8 @@ public void test7() throws Throwable { } } - @DontCompile - public void test7_verifier(boolean warmup) throws Throwable { + @Run(test = "test7") + public void test7_verifier() throws Throwable { test7(); } @@ -248,8 +253,8 @@ public void test8() throws Throwable { } } - @DontCompile - public void test8_verifier(boolean warmup) throws Throwable { + @Run(test = "test8") + public void test8_verifier() throws Throwable { test8(); } @@ -265,8 +270,8 @@ public void test9(boolean flag1) { valueField1 = v; } - @DontCompile - public void test9_verifier(boolean warmup) { + @Run(test = "test9") + public void test9_verifier() { test9(true); try { test9(false); @@ -283,8 +288,8 @@ public void test10(boolean flag) throws Throwable { valueField1 = (MyValue1) val; } - @DontCompile - public void test10_verifier(boolean warmup) throws Throwable { + @Run(test = "test10") + public void test10_verifier() throws Throwable { test10(true); try { test10(false); @@ -301,8 +306,8 @@ public void test11(boolean flag) throws Throwable { valueField1 = (MyValue1) val; } - @DontCompile - public void test11_verifier(boolean warmup) throws Throwable { + @Run(test = "test11") + public void test11_verifier() throws Throwable { test11(false); try { test11(true); @@ -326,8 +331,8 @@ public void test12() { valueField1 = (MyValue1) test12_helper(); } - @DontCompile - public void test12_verifier(boolean warmup) { + @Run(test = "test12") + public void test12_verifier() { try { test12_cnt = 0; test12(); @@ -370,8 +375,8 @@ public void test13(A a) { valueField1 = (MyValue1) a.test13_helper(); } - @DontCompile - public void test13_verifier(boolean warmup) { + @Run(test = "test13") + public void test13_verifier() { A a = new A(); A b = new B(); A c = new C(); @@ -413,8 +418,8 @@ public void test14(MyValue1[] va, int index) { test14_inline(va, nullField, index); } - @DontCompile - public void test14_verifier(boolean warmup) { + @Run(test = "test14") + public void test14_verifier() { int index = Math.abs(rI) % 3; try { test14(testValue1Array, index); @@ -452,8 +457,8 @@ public void test15() { } } - @DontCompile - public void test15_verifier(boolean warmup) { + @Run(test = "test15") + public void test15_verifier() { test15(); } @@ -464,14 +469,14 @@ public boolean test16_dontinline(MyValue1.ref vt) { // Test c2c call passing null for an inline type @Test - @Warmup(10000) // Warmup to make sure 'test17_dontinline' is compiled public boolean test16(Object arg) throws Exception { Method test16method = getClass().getMethod("test16_dontinline", MyValue1.ref.class); return (boolean)test16method.invoke(this, arg); } - @DontCompile - public void test16_verifier(boolean warmup) throws Exception { + @Run(test = "test16") + @Warmup(10000) // Warmup to make sure 'test17_dontinline' is compiled + public void test16_verifier() throws Exception { boolean res = test16(null); Asserts.assertTrue(res); } @@ -496,8 +501,8 @@ public Test17Value test17(boolean b) { return b ? vt1 : vt2; } - @DontCompile - public void test17_verifier(boolean warmup) { + @Run(test = "test17") + public void test17_verifier() { test17(true); test17(false); } @@ -519,14 +524,14 @@ static void test18_target2(MyValue1.ref vt) { // Test passing null for an inline type @Test - @Warmup(11000) // Make sure lambda forms get compiled public void test18() throws Throwable { test18_mh1.invokeExact(nullValue); test18_mh2.invokeExact(nullValue); } - @DontCompile - public void test18_verifier(boolean warmup) { + @Run(test = "test18") + @Warmup(11000) // Make sure lambda forms get compiled + public void test18_verifier() { try { test18(); } catch (Throwable t) { @@ -549,14 +554,14 @@ static void test19_target2(MyValue1.ref vt) { // Same as test12 but with non-final mh @Test - @Warmup(11000) // Make sure lambda forms get compiled public void test19() throws Throwable { test19_mh1.invokeExact(nullValue); test19_mh2.invokeExact(nullValue); } - @DontCompile - public void test19_verifier(boolean warmup) { + @Run(test = "test19") + @Warmup(11000) // Make sure lambda forms get compiled + public void test19_verifier() { try { test19(); } catch (Throwable t) { @@ -566,13 +571,13 @@ public void test19_verifier(boolean warmup) { // Same as test12/13 but with constant null @Test - @Warmup(11000) // Make sure lambda forms get compiled public void test20(MethodHandle mh) throws Throwable { mh.invoke(null); } - @DontCompile - public void test20_verifier(boolean warmup) { + @Run(test = "test20") + @Warmup(11000) // Make sure lambda forms get compiled + public void test20_verifier() { try { test20(test18_mh1); test20(test18_mh2); @@ -618,8 +623,8 @@ public Test21Value test21(Test21Value vt) { return vt; } - @DontCompile - public void test21_verifier(boolean warmup) { + @Run(test = "test21") + public void test21_verifier() { test21(Test21Value.default); } @@ -633,8 +638,8 @@ public void test22() { valueField1 = test22_helper(); } - @DontCompile - public void test22_verifier(boolean warmup) { + @Run(test = "test22") + public void test22_verifier() { try { test22(); throw new RuntimeException("NullPointerException expected"); @@ -648,8 +653,8 @@ public void test23(MyValue1[] arr, MyValue1.ref b) { arr[0] = (MyValue1) b; } - @DontCompile - public void test23_verifier(boolean warmup) { + @Run(test = "test23") + public void test23_verifier() { MyValue1[] arr = new MyValue1[2]; MyValue1.ref b = null; try { @@ -667,8 +672,8 @@ public MyValue1 test24() { return (MyValue1) nullBox; } - @DontCompile - public void test24_verifier(boolean warmup) { + @Run(test = "test24") + public void test24_verifier() { try { test24(); throw new RuntimeException("NullPointerException expected"); @@ -682,7 +687,8 @@ public void test25_callee(MyValue1 val) { } // Test that when checkcasting from null-ok to null-free and back to null-ok we // keep track of the information that the inline type can never be null. - @Test(failOn = ALLOC + STORE) + @Test + @IR(failOn = {ALLOC, STORE}) public int test25(boolean b, MyValue1.ref vt1, MyValue1 vt2) { vt1 = (MyValue1)vt1; Object obj = b ? vt1 : vt2; // We should not allocate here @@ -690,8 +696,8 @@ public int test25(boolean b, MyValue1.ref vt1, MyValue1 vt2) { return ((MyValue1)obj).x; } - @DontCompile - public void test25_verifier(boolean warmup) { + @Run(test = "test25") + public void test25_verifier() { int res = test25(true, testValue1, testValue1); Asserts.assertEquals(res, testValue1.x); res = test25(false, testValue1, testValue1); @@ -699,25 +705,27 @@ public void test25_verifier(boolean warmup) { } // Test that chains of casts are folded and don't trigger an allocation - @Test(failOn = ALLOC + STORE) + @Test + @IR(failOn = {ALLOC, STORE}) public MyValue3 test26(MyValue3 vt) { return ((MyValue3)((Object)((MyValue3.ref)(MyValue3)((MyValue3.ref)((Object)vt))))); } - @DontCompile - public void test26_verifier(boolean warmup) { + @Run(test = "test26") + public void test26_verifier() { MyValue3 vt = MyValue3.create(); MyValue3 result = test26(vt); Asserts.assertEquals(result, vt); } - @Test(failOn = ALLOC + STORE) + @Test + @IR(failOn = {ALLOC, STORE}) public MyValue3.ref test27(MyValue3.ref vt) { return ((MyValue3.ref)((Object)((MyValue3)(MyValue3.ref)((MyValue3)((Object)vt))))); } - @DontCompile - public void test27_verifier(boolean warmup) { + @Run(test = "test27") + public void test27_verifier() { MyValue3 vt = MyValue3.create(); MyValue3 result = (MyValue3) test27(vt); Asserts.assertEquals(result, vt); @@ -738,8 +746,8 @@ public MyValue1.ref test28(MyValue1 vt, MyValue1.ref vtBox, int i) { return result; } - @DontCompile - public void test28_verifier(boolean warmup) { + @Run(test = "test28") + public void test28_verifier() { MyValue1.ref result = test28(testValue1, null, 0); Asserts.assertEquals(result, null); result = test28(testValue1, testValue1, 1); @@ -770,8 +778,8 @@ public long test29(MyValue1 vt, MyValue1.ref vtBox) { return result; } - @DontCompile - public void test29_verifier(boolean warmup) { + @Run(test = "test29") + public void test29_verifier() { long result = test29(testValue1, null); Asserts.assertEquals(result, testValue1.hash()*98); result = test29(testValue1, testValue1); @@ -795,8 +803,8 @@ public long test30() { return test30_callee(nullField); } - @DontCompile - public void test30_verifier(boolean warmup) { + @Run(test = "test30") + public void test30_verifier() { long result = test30(); Asserts.assertEquals(result, 0L); } @@ -816,8 +824,8 @@ public void test31(Object o) { } } - @DontCompile - public void test31_verifier(boolean warmup) { + @Run(test = "test31") + public void test31_verifier() { test31(null); } @@ -828,8 +836,8 @@ public MyValue1.ref test32() { return constNullField; } - @DontCompile - public void test32_verifier(boolean warmup) { + @Run(test = "test32") + public void test32_verifier() { MyValue1.ref result = test32(); Asserts.assertEquals(result, null); } @@ -853,8 +861,8 @@ public Test33Value2 test33() { return test33Val; } - @DontCompile - public void test33_verifier(boolean warmup) { + @Run(test = "test33") + public void test33_verifier() { Test33Value2 result = test33(); Asserts.assertEquals(result, test33Val); } @@ -870,10 +878,10 @@ public void test34(MyValue1 vt) { } } - @DontCompile - public void test34_verifier(boolean warmup) { + @Run(test = "test34") + public void test34_verifier(RunInfo info) { test34(testValue1); - if (!warmup) { + if (!info.isWarmUp()) { test34Val = null; test34(testValue1); Asserts.assertEquals(test34Val, testValue1); @@ -892,15 +900,16 @@ public Test17Value test35(boolean b) { return b ? vt1 : vt2; } - @DontCompile - public void test35_verifier(boolean warmup) { + @Run(test = "test35") + public void test35_verifier() { test35(true); test35(false); } // Test that when explicitly null checking an inline type, we keep // track of the information that the inline type can never be null. - @Test(failOn = ALLOC + STORE) + @Test + @IR(failOn = {ALLOC, STORE}) public int test37(boolean b, MyValue1.ref vt1, MyValue1.val vt2) { if (vt1 == null) { return 0; @@ -911,8 +920,8 @@ public int test37(boolean b, MyValue1.ref vt1, MyValue1.val vt2) { return ((MyValue1)obj).x; } - @DontCompile - public void test37_verifier(boolean warmup) { + @Run(test = "test37") + public void test37_verifier() { int res = test37(true, testValue1, testValue1); Asserts.assertEquals(res, testValue1.x); res = test37(false, testValue1, testValue1); @@ -921,7 +930,8 @@ public void test37_verifier(boolean warmup) { // Test that when explicitly null checking an inline type receiver, // we keep track of the information that the inline type can never be null. - @Test(failOn = ALLOC + STORE) + @Test + @IR(failOn = {ALLOC, STORE}) public int test38(boolean b, MyValue1.ref vt1, MyValue1.val vt2) { vt1.hash(); // Inlined - Explicit null check // vt1 should be scalarized because it's always non-null @@ -930,8 +940,8 @@ public int test38(boolean b, MyValue1.ref vt1, MyValue1.val vt2) { return ((MyValue1)obj).x; } - @DontCompile - public void test38_verifier(boolean warmup) { + @Run(test = "test38") + public void test38_verifier() { int res = test38(true, testValue1, testValue1); Asserts.assertEquals(res, testValue1.x); res = test38(false, testValue1, testValue1); @@ -940,7 +950,8 @@ public void test38_verifier(boolean warmup) { // Test that when implicitly null checking an inline type receiver, // we keep track of the information that the inline type can never be null. - @Test(failOn = ALLOC + STORE) + @Test + @IR(failOn = {ALLOC, STORE}) public int test39(boolean b, MyValue1.ref vt1, MyValue1.val vt2) { vt1.hashInterpreted(); // Not inlined - Implicit null check // vt1 should be scalarized because it's always non-null @@ -949,8 +960,8 @@ public int test39(boolean b, MyValue1.ref vt1, MyValue1.val vt2) { return ((MyValue1)obj).x; } - @DontCompile - public void test39_verifier(boolean warmup) { + @Run(test = "test39") + public void test39_verifier() { int res = test39(true, testValue1, testValue1); Asserts.assertEquals(res, testValue1.x); res = test39(false, testValue1, testValue1); @@ -958,14 +969,14 @@ public void test39_verifier(boolean warmup) { } // Test NPE when casting constant null to inline type - @Test() + @Test public MyValue1 test40() throws Throwable { Object NULL = null; return (MyValue1)NULL; } - @DontCompile - public void test40_verifier(boolean warmup) throws Throwable { + @Run(test = "test40") + public void test40_verifier() throws Throwable { try { test40(); throw new RuntimeException("NullPointerException expected"); diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestOnStackReplacement.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestOnStackReplacement.java index 7a1c8889c80..70264011080 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestOnStackReplacement.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestOnStackReplacement.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2017, 2021, 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 @@ -23,35 +23,37 @@ package compiler.valhalla.inlinetypes; +import compiler.lib.ir_framework.*; import jdk.test.lib.Asserts; -import java.lang.reflect.Method; + +import static compiler.valhalla.inlinetypes.InlineTypes.IRNode.*; +import static compiler.valhalla.inlinetypes.InlineTypes.rI; +import static compiler.valhalla.inlinetypes.InlineTypes.rL; /* * @test * @key randomness * @summary Test on stack replacement (OSR) with inline types - * @library /testlibrary /test/lib /compiler/whitebox / + * @library /test/lib / * @requires (os.simpleArch == "x64" | os.simpleArch == "aarch64") - * @compile TestOnStackReplacement.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestOnStackReplacement + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestOnStackReplacement */ -public class TestOnStackReplacement extends InlineTypeTest { - // Extra VM parameters for some test scenarios. See InlineTypeTest.getVMParameters() - @Override - public String[] getExtraVMParameters(int scenario) { - switch (scenario) { - case 3: return new String[] {"-XX:FlatArrayElementMaxSize=0"}; - } - return null; - } + +public class TestOnStackReplacement { + public static void main(String[] args) throws Throwable { - TestOnStackReplacement test = new TestOnStackReplacement(); - test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class, MyValue3.class, MyValue3Inline.class); + Scenario[] scenarios = InlineTypes.DEFAULT_SCENARIOS; + scenarios[3].addFlags("-XX:FlatArrayElementMaxSize=0"); + + InlineTypes.getFramework() + .addScenarios(scenarios) + .addHelperClasses(MyValue1.class, + MyValue2.class, + MyValue2Inline.class, + MyValue3.class, + MyValue3Inline.class) + .start(); } // Helper methods @@ -65,7 +67,7 @@ protected long hash(int x, long y) { } // Test OSR compilation - @Test() @Warmup(0) @OSRCompileOnly + @Test(compLevel = CompLevel.WAIT_FOR_COMPILATION) public long test1() { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); MyValue1[] va = new MyValue1[Math.abs(rI) % 3]; @@ -84,14 +86,16 @@ public long test1() { return result; } - @DontCompile - public void test1_verifier(boolean warmup) { + @Run(test = "test1") + @Warmup(0) + public void test1_verifier() { long result = test1(); Asserts.assertEQ(result, ((Math.abs(rI) % 3) + 1) * hash()); } // Test loop peeling - @Test(failOn = ALLOC + LOAD + STORE) @Warmup(0) @OSRCompileOnly + @Test(compLevel = CompLevel.WAIT_FOR_COMPILATION) + @IR(failOn = {ALLOC, LOAD, STORE}) public void test2() { MyValue1 v = MyValue1.createWithFieldsInline(0, 1); // Trigger OSR compilation and loop peeling @@ -104,13 +108,14 @@ public void test2() { } } - @DontCompile - public void test2_verifier(boolean warmup) { + @Run(test = "test2") + @Warmup(0) + public void test2_verifier() { test2(); } // Test loop peeling and unrolling - @Test() @Warmup(0) @OSRCompileOnly + @Test(compLevel = CompLevel.WAIT_FOR_COMPILATION) public void test3() { MyValue1 v1 = MyValue1.createWithFieldsInline(0, 0); MyValue1 v2 = MyValue1.createWithFieldsInline(1, 1); @@ -125,8 +130,9 @@ public void test3() { } } - @DontCompile - public void test3_verifier(boolean warmup) { + @Run(test = "test3") + @Warmup(0) + public void test3_verifier() { test3(); } @@ -141,7 +147,7 @@ public Object test4_body() { return MyValue1.createWithFieldsInline(rI, rL); } - @Test() @Warmup(0) @OSRCompileOnly + @Test(compLevel = CompLevel.WAIT_FOR_COMPILATION) public Object test4() { Object vt = test4_init(); for (int i = 0; i < 50_000; i++) { @@ -152,8 +158,9 @@ public Object test4() { return vt; } - @DontCompile - public void test4_verifier(boolean warmup) { + @Run(test = "test4") + @Warmup(0) + public void test4_verifier() { test4(); } @@ -161,7 +168,7 @@ public void test4_verifier(boolean warmup) { MyValue1.ref nullField; - @Test() @Warmup(0) @OSRCompileOnly + @Test(compLevel = CompLevel.WAIT_FOR_COMPILATION) public void test5() { MyValue1.ref vt = nullField; for (int i = 0; i < 50_000; i++) { @@ -171,8 +178,9 @@ public void test5() { } } - @DontCompile - public void test5_verifier(boolean warmup) { + @Run(test = "test5") + @Warmup(0) + public void test5_verifier() { test5(); } @@ -189,7 +197,7 @@ public int test() { } } - @Test() @Warmup(0) @OSRCompileOnly + @Test(compLevel = CompLevel.WAIT_FOR_COMPILATION) public void test6() { Test6Value tmp = new Test6Value(); for (int i = 0; i < 100; ++i) { @@ -197,8 +205,9 @@ public void test6() { } } - @DontCompile - public void test6_verifier(boolean warmup) { + @Run(test = "test6") + @Warmup(0) + public void test6_verifier() { test6(); } @@ -246,7 +255,7 @@ public int test(String[] args) { } } - @Test() @Warmup(0) @OSRCompileOnly + @Test(compLevel = CompLevel.WAIT_FOR_COMPILATION) public void test7() { Test7Value2 tmp = new Test7Value2(); for (int i = 0; i < 10; ++i) { @@ -254,8 +263,9 @@ public void test7() { } } - @DontCompile - public void test7_verifier(boolean warmup) { + @Run(test = "test7") + @Warmup(0) + public void test7_verifier() { test7(); } @@ -273,7 +283,7 @@ public MyValue3 test8_callee(int len) { return test8_vt; } - @Test() @Warmup(2) + @Test public int test8(int start) { MyValue3 vt = test8_callee(start); test8_vt.verify(vt); @@ -284,8 +294,9 @@ public int test8(int start) { return result; } - @DontCompile - public void test8_verifier(boolean warmup) { + @Run(test = "test8") + @Warmup(2) + public void test8_verifier() { test8(1); test8(50_000); } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestUnloadedInlineTypeField.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestUnloadedInlineTypeField.java index 14fad35bc85..819dca6c90b 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestUnloadedInlineTypeField.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestUnloadedInlineTypeField.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, 2020, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, 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 @@ -22,50 +22,50 @@ */ package compiler.valhalla.inlinetypes; + +import compiler.lib.ir_framework.Run; +import compiler.lib.ir_framework.RunInfo; +import compiler.lib.ir_framework.Scenario; +import compiler.lib.ir_framework.Test; import jdk.test.lib.Asserts; -/** +import static compiler.valhalla.inlinetypes.InlineTypes.rI; + +/* * @test * @key randomness - * @library /testlibrary /test/lib /compiler/whitebox / * @summary Test the handling of fields of unloaded inline classes. + * @library /test/lib / + * @requires os.simpleArch == "x64" * @compile hack/GetUnresolvedInlineFieldWrongSignature.java * @compile TestUnloadedInlineTypeField.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=120 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * -XX:PerMethodRecompilationCutoff=-1 -XX:PerBytecodeRecompilationCutoff=-1 - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestUnloadedInlineTypeField + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestUnloadedInlineTypeField */ -public class TestUnloadedInlineTypeField extends InlineTypeTest { +public class TestUnloadedInlineTypeField { // Only prevent loading of classes when testing with C1. Load classes // early when executing with C2 to prevent uncommon traps. It's still // beneficial to execute this test with C2 because it also checks handling // of type mismatches. - private static final boolean PREVENT_LOADING = TEST_C1; - - public static void main(String[] args) throws Throwable { - TestUnloadedInlineTypeField test = new TestUnloadedInlineTypeField(); - test.run(args); - } - - static final String[][] scenarios = { - {}, - {"-XX:InlineFieldMaxFlatSize=0"}, - {"-XX:+PatchALot"}, - {"-XX:InlineFieldMaxFlatSize=0", "-XX:+PatchALot"} - }; - @Override - public int getNumScenarios() { - return scenarios.length; - } + public static void main(String[] args) { + final Scenario[] scenarios = { + new Scenario(0), + new Scenario(1, "-XX:InlineFieldMaxFlatSize=0"), + new Scenario(2, "-XX:+IgnoreUnrecognizedVMOptions", "-XX:-XX:+PatchALot"), + new Scenario(3, + "-XX:InlineFieldMaxFlatSize=0", + "-XX:+IgnoreUnrecognizedVMOptions", + "-XX:+PatchALot") + }; + final String[] CutoffFlags = {"-XX:PerMethodRecompilationCutoff=-1", "-XX:PerBytecodeRecompilationCutoff=-1"}; + for (Scenario s : scenarios) { + s.addFlags(CutoffFlags); + } - @Override - public String[] getVMParameters(int scenario) { - return scenarios[scenario]; + InlineTypes.getFramework() + .addScenarios(scenarios) + .start(); } // Test case 1: @@ -107,9 +107,9 @@ public int test1(Object holder) { } } - @DontCompile - public void test1_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test1") + public void test1_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test1(null); } else { MyValue1Holder holder = new MyValue1Holder(); @@ -152,9 +152,9 @@ public int test2(Object holder) { } } - @DontCompile - public void test2_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test2") + public void test2_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test2(null); } else { MyValue2Holder holder = new MyValue2Holder(); @@ -201,9 +201,9 @@ public int test3(Object holder) { return GetUnresolvedInlineFieldWrongSignature.test3(holder); } - @DontCompile - public void test3_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test3") + public void test3_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test3(null); } else { // Make sure klass is resolved @@ -245,10 +245,10 @@ public void test4(Object holder, MyValue4 v) { } } - @DontCompile - public void test4_verifier(boolean warmup) { + @Run(test = "test4") + public void test4_verifier(RunInfo info) { MyValue4 v = new MyValue4(rI); - if (warmup && PREVENT_LOADING) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test4(null, v); } else { MyValue4Holder holder = new MyValue4Holder(); @@ -288,9 +288,9 @@ public void test5(Object holder, Object o) { } } - @DontCompile - public void test5_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test5") + public void test5_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test5(null, null); } else { MyValue5Holder holder = new MyValue5Holder(); @@ -334,9 +334,9 @@ public int test6(int n) { } } - @DontCompile - public void test6_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test6") + public void test6_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test6(0); } else { Asserts.assertEQ(test6(rI), 2*rI); @@ -373,9 +373,9 @@ public int test7(int n) { } } - @DontCompile - public void test7_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test7") + public void test7_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test7(0); } else { Asserts.assertEQ(test7(rI), 2*rI); @@ -414,9 +414,9 @@ public int test8(boolean warmup) { } } - @DontCompile - public void test8_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test8") + public void test8_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test8(true); } else { Asserts.assertEQ(test8(false), rI); @@ -451,9 +451,9 @@ public int test9(boolean warmup) { } } - @DontCompile - public void test9_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test9") + public void test9_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test9(true); } else { Asserts.assertEQ(test9(false), rI); @@ -490,9 +490,9 @@ public void test10(Object holder) { GetUnresolvedInlineFieldWrongSignature.test10(holder); } - @DontCompile - public void test10_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test10") + public void test10_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test10(null); } else { // Make sure klass is resolved @@ -537,10 +537,10 @@ public Object test11(boolean warmup, MyValue11 v) { } } - @DontCompile - public void test11_verifier(boolean warmup) { + @Run(test = "test11") + public void test11_verifier(RunInfo info) { MyValue11 v = new MyValue11(rI); - if (warmup && PREVENT_LOADING) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test11(true, v); } else { MyValue11Holder holder = (MyValue11Holder)test11(false, v); @@ -578,9 +578,9 @@ public Object test12(boolean warmup, Object o) { } } - @DontCompile - public void test12_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test12") + public void test12_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test12(true, null); } else { MyValue12 v = new MyValue12(rI); @@ -617,9 +617,9 @@ public void test13(Object holder) { GetUnresolvedInlineFieldWrongSignature.test13(holder); } - @DontCompile - public void test13_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test13") + public void test13_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test13(null); } else { // Make sure klass is resolved @@ -663,9 +663,9 @@ public void test14(Object holder) { GetUnresolvedInlineFieldWrongSignature.test14(holder); } - @DontCompile - public void test14_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test14") + public void test14_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test14(null); } else { // Make sure klass is resolved @@ -705,9 +705,9 @@ public void test15(Object holder) { GetUnresolvedInlineFieldWrongSignature.test15(holder); } - @DontCompile - public void test15_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test15") + public void test15_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test15(null); } else { // Make sure klass is resolved @@ -742,9 +742,9 @@ public Object test16(boolean warmup) { return GetUnresolvedInlineFieldWrongSignature.test16(warmup); } - @DontCompile - public void test16_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test16") + public void test16_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test16(true); } else { // Make sure klass is resolved @@ -774,9 +774,9 @@ public Object test17(boolean warmup) { return GetUnresolvedInlineFieldWrongSignature.test17(warmup); } - @DontCompile - public void test17_verifier(boolean warmup) { - if (warmup && PREVENT_LOADING) { + @Run(test = "test17") + public void test17_verifier(RunInfo info) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test17(true); } else { // Make sure klass is resolved @@ -814,11 +814,11 @@ public int test18(int n) { } } - @DontCompile - public void test18_verifier(boolean warmup) { + @Run(test = "test18") + public void test18_verifier(RunInfo info) { // Make sure MyValue18Holder is loaded MyValue18Holder holder = new MyValue18Holder(); - if (warmup && PREVENT_LOADING) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test18(0); } else { Asserts.assertEQ(test18(rI), 2*rI); @@ -848,11 +848,11 @@ public int test19(int n) { } } - @DontCompile - public void test19_verifier(boolean warmup) { + @Run(test = "test19") + public void test19_verifier(RunInfo info) { // Make sure MyValue19Holder is loaded MyValue19Holder holder = new MyValue19Holder(); - if (warmup && PREVENT_LOADING) { + if (info.isWarmUp() && !info.isC2CompilationEnabled()) { test19(0); } else { Asserts.assertEQ(test19(rI), rI); @@ -878,8 +878,8 @@ public MyValue20 test20() { return new MyValue20(); } - @DontCompile - public void test20_verifier(boolean warmup) { + @Run(test = "test20") + public void test20_verifier() { MyValue20 vt = test20(); Asserts.assertEQ(vt.obj, null); } diff --git a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestWithfieldC1.java b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestWithfieldC1.java index 01be7861736..17b927ee1ce 100644 --- a/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestWithfieldC1.java +++ b/test/hotspot/jtreg/compiler/valhalla/inlinetypes/TestWithfieldC1.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2019, 2021, 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 @@ -21,70 +21,47 @@ * questions. */ - package compiler.valhalla.inlinetypes; -import java.lang.invoke.*; -import java.lang.reflect.Method; -import java.util.Arrays; - import jdk.test.lib.Asserts; +import compiler.lib.ir_framework.*; /* * @test * @key randomness * @summary Verify that C1 performs escape analysis before optimizing withfield bytecode to putfield. - * @library /testlibrary /test/lib /compiler/whitebox / + * @library /test/lib / * @requires os.simpleArch == "x64" * @compile -XDallowWithFieldOperator TestWithfieldC1.java - * @run driver jdk.test.lib.helpers.ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform - * @run main/othervm/timeout=300 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions - * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI - * compiler.valhalla.inlinetypes.InlineTypeTest - * compiler.valhalla.inlinetypes.TestWithfieldC1 + * @run driver/timeout=300 compiler.valhalla.inlinetypes.TestWithfieldC1 */ -public class TestWithfieldC1 extends InlineTypeTest { - public static final int C1 = COMP_LEVEL_SIMPLE; - public static final int C2 = COMP_LEVEL_FULL_OPTIMIZATION; - - public static void main(String[] args) throws Throwable { - TestWithfieldC1 test = new TestWithfieldC1(); - test.run(args, FooValue.class); - } - @Override - public int getNumScenarios() { - return 5; - } - - @Override - public String[] getVMParameters(int scenario) { - switch (scenario) { - case 0: return new String[] { // C1 only - "-XX:TieredStopAtLevel=1", - "-XX:+TieredCompilation", - }; - case 1: return new String[] { // C2 only. (Make sure the tests are correctly written) - "-XX:TieredStopAtLevel=4", - "-XX:-TieredCompilation", - }; - case 2: return new String[] { // interpreter only - "-Xint", - }; - case 3: return new String[] { - // Xcomp Only C1. - "-XX:TieredStopAtLevel=1", - "-XX:+TieredCompilation", - "-Xcomp", - }; - case 4: return new String[] { - // Xcomp Only C2. - "-XX:TieredStopAtLevel=4", - "-XX:-TieredCompilation", - "-Xcomp", - }; - } - return null; +@ForceCompileClassInitializer +public class TestWithfieldC1 { + + public static void main(String[] args) { + final Scenario[] scenarios = { + new Scenario(0, // C1 only + "-XX:TieredStopAtLevel=1", + "-XX:+TieredCompilation"), + new Scenario(1, // C2 only. (Make sure the tests are correctly written) + "-XX:TieredStopAtLevel=4", + "-XX:-TieredCompilation"), + new Scenario(2, // interpreter only + "-Xint"), + new Scenario(3, // Xcomp Only C1. + "-XX:TieredStopAtLevel=1", + "-XX:+TieredCompilation", + "-Xcomp"), + new Scenario(4, // Xcomp Only C2. + "-XX:TieredStopAtLevel=4", + "-XX:-TieredCompilation", + "-Xcomp") + }; + + InlineTypes.getFramework() + .addScenarios(scenarios) + .start(); } static FooValue.ref foo_static; @@ -214,19 +191,19 @@ static void validate_foo_static_and(FooValue v) { } // escape with putstatic - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public FooValue test1() { return FooValue.test1(); } - @DontCompile - public void test1_verifier(boolean warmup) { + @Run(test = "test1") + public void test1_verifier() { FooValue v = test1(); validate_foo_static_and(v); } // escape with putfield - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public FooValue test2() { FooValue v = FooValue.default; @@ -239,8 +216,8 @@ public FooValue test2() { return v; } - @DontCompile - public void test2_verifier(boolean warmup) { + @Run(test = "test2") + public void test2_verifier() { foo_instance = null; FooValue v = test2(); Asserts.assertEQ(foo_instance.x, 1); @@ -250,52 +227,52 @@ public void test2_verifier(boolean warmup) { } // escape with function call - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public FooValue test3() { return FooValue.test3(); } - @DontCompile - public void test3_verifier(boolean warmup) { + @Run(test = "test3") + public void test3_verifier() { foo_static = null; FooValue v = test3(); validate_foo_static_and(v); } // escape and then branch backwards - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public FooValue test4() { return FooValue.test4(); } - @DontCompile - public void test4_verifier(boolean warmup) { + @Run(test = "test4") + public void test4_verifier() { foo_static = null; FooValue v = test4(); validate_foo_static_and(v); } // escape using a different local variable - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public FooValue test5() { return FooValue.test5(); } - @DontCompile - public void test5_verifier(boolean warmup) { + @Run(test = "test5") + public void test5_verifier() { foo_static = null; FooValue v = test5(); validate_foo_static_and(v); } // escape using aastore - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public FooValue test6() { return FooValue.test6(); } - @DontCompile - public void test6_verifier(boolean warmup) { + @Run(test = "test6") + public void test6_verifier() { foo_static_arr[0] = null; FooValue v = test6(); Asserts.assertEQ(foo_static_arr[0].x, 1); @@ -305,33 +282,33 @@ public void test6_verifier(boolean warmup) { } // Copying a value into different local slots -- disable withfield optimization - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public FooValue test7() { return FooValue.test7(); } - @DontCompile - public void test7_verifier(boolean warmup) { + @Run(test = "test7") + public void test7_verifier() { FooValue v = test7(); Asserts.assertEQ(v.x, 1); Asserts.assertEQ(v.y, 1); } // escape by invoking non-static method - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public FooValue test8() { return FooValue.test8(); } - @DontCompile - public void test8_verifier(boolean warmup) { + @Run(test = "test8") + public void test8_verifier() { foo_static = null; FooValue v = test8(); validate_foo_static_and(v); } // duplicate reference with local variables - @Test(compLevel=C1) + @Test(compLevel = CompLevel.C1_SIMPLE) public FooValue test9() { FooValue v = FooValue.default; @@ -350,8 +327,8 @@ public FooValue test9() { return v; } - @DontCompile - public void test9_verifier(boolean warmup) { + @Run(test = "test9") + public void test9_verifier() { foo_instance = null; FooValue v = test9(); Asserts.assertEQ(foo_instance.x, 3);