< prev index next >

test/hotspot/jtreg/compiler/valhalla/valuetypes/ValueTypeTest.java

Print this page

*** 55,64 **** --- 55,65 ---- // 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 ValueTypeTest.COMP_LEVEL_ANY; int valid() default ValueTypeTest.AllFlags; } @Retention(RetentionPolicy.RUNTIME) @interface Tests {
*** 75,92 **** // Prevent method compilation @Retention(RetentionPolicy.RUNTIME) @interface DontCompile { } // Number of warmup iterations @Retention(RetentionPolicy.RUNTIME) @interface Warmup { int value(); } public abstract class ValueTypeTest { ! // Run "jtreg -Dtest.c1=true" to enable experimental C1 testing. static final boolean TEST_C1 = Boolean.getBoolean("test.c1"); // Should we execute tests that assume (ValueType[] <: Object[])? static final boolean ENABLE_VALUE_ARRAY_COVARIANCE = Boolean.getBoolean("ValueArrayCovariance"); --- 76,100 ---- // Prevent method compilation @Retention(RetentionPolicy.RUNTIME) @interface DontCompile { } + // Force method compilation + @Retention(RetentionPolicy.RUNTIME) + @interface ForceCompile { + int compLevel() default ValueTypeTest.COMP_LEVEL_ANY; + } + // Number of warmup iterations @Retention(RetentionPolicy.RUNTIME) @interface Warmup { int value(); } public abstract class ValueTypeTest { ! // Run "jtreg -Dtest.c1=true" to enable experimental C1 testing. This forces all ! // compilable methods to be compiled with C1, regardless of the @Test(compLevel=?) setting. static final boolean TEST_C1 = Boolean.getBoolean("test.c1"); // Should we execute tests that assume (ValueType[] <: Object[])? static final boolean ENABLE_VALUE_ARRAY_COVARIANCE = Boolean.getBoolean("ValueArrayCovariance");
*** 105,126 **** 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")); // Pre-defined settings ! private static final List<String> defaultFlags = Arrays.asList( "-XX:-BackgroundCompilation", "-XX:CICompilerCount=1", "-XX:CompileCommand=quiet", "-XX:CompileCommand=compileonly,java.lang.invoke.*::*", "-XX:CompileCommand=compileonly,java.lang.Long::sum", "-XX:CompileCommand=compileonly,java.lang.Object::<init>", ! "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.*::*"); ! private static final List<String> printFlags = Arrays.asList( ! "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+PrintOptoAssembly"); ! private static final List<String> verifyFlags = Arrays.asList( "-XX:+VerifyOops", "-XX:+VerifyStack", "-XX:+VerifyLastFrame", "-XX:+VerifyBeforeGC", "-XX:+VerifyAfterGC", ! "-XX:+VerifyDuringGC", "-XX:+VerifyAdapterSharing"); protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); protected static final int ValueTypePassFieldsAsArgsOn = 0x1; protected static final int ValueTypePassFieldsAsArgsOff = 0x2; protected static final int ValueTypeArrayFlattenOn = 0x4; --- 113,134 ---- 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")); // Pre-defined settings ! private static final String[] defaultFlags = { "-XX:-BackgroundCompilation", "-XX:CICompilerCount=1", "-XX:CompileCommand=quiet", "-XX:CompileCommand=compileonly,java.lang.invoke.*::*", "-XX:CompileCommand=compileonly,java.lang.Long::sum", "-XX:CompileCommand=compileonly,java.lang.Object::<init>", ! "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.*::*"}; ! private static final String[] printFlags = { ! "-XX:+PrintCompilation", "-XX:+PrintIdeal", "-XX:+PrintOptoAssembly"}; ! private static final String[] verifyFlags = { "-XX:+VerifyOops", "-XX:+VerifyStack", "-XX:+VerifyLastFrame", "-XX:+VerifyBeforeGC", "-XX:+VerifyAfterGC", ! "-XX:+VerifyDuringGC", "-XX:+VerifyAdapterSharing"}; protected static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox(); protected static final int ValueTypePassFieldsAsArgsOn = 0x1; protected static final int ValueTypePassFieldsAsArgsOff = 0x2; protected static final int ValueTypeArrayFlattenOn = 0x4;
*** 132,143 **** static final int AllFlags = ValueTypePassFieldsAsArgsOn | ValueTypePassFieldsAsArgsOff | ValueTypeArrayFlattenOn | ValueTypeArrayFlattenOff | ValueTypeReturnedAsFieldsOn; protected static final boolean ValueTypePassFieldsAsArgs = (Boolean)WHITE_BOX.getVMFlag("ValueTypePassFieldsAsArgs"); protected static final boolean ValueTypeArrayFlatten = (WHITE_BOX.getIntxVMFlag("ValueArrayElemMaxFlatSize") == -1); // FIXME - fix this if default of ValueArrayElemMaxFlatSize is changed protected static final boolean ValueTypeReturnedAsFields = (Boolean)WHITE_BOX.getVMFlag("ValueTypeReturnedAsFields"); protected static final boolean AlwaysIncrementalInline = (Boolean)WHITE_BOX.getVMFlag("AlwaysIncrementalInline"); protected static final int COMP_LEVEL_ANY = -2; ! protected static final int COMP_LEVEL_FULL_OPTIMIZATION = TEST_C1 ? 1 : 4; protected static final Hashtable<String, Method> tests = new Hashtable<String, Method>(); 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 --- 140,159 ---- static final int AllFlags = ValueTypePassFieldsAsArgsOn | ValueTypePassFieldsAsArgsOff | ValueTypeArrayFlattenOn | ValueTypeArrayFlattenOff | ValueTypeReturnedAsFieldsOn; protected static final boolean ValueTypePassFieldsAsArgs = (Boolean)WHITE_BOX.getVMFlag("ValueTypePassFieldsAsArgs"); protected static final boolean ValueTypeArrayFlatten = (WHITE_BOX.getIntxVMFlag("ValueArrayElemMaxFlatSize") == -1); // FIXME - fix this if default of ValueArrayElemMaxFlatSize is changed protected static final boolean ValueTypeReturnedAsFields = (Boolean)WHITE_BOX.getVMFlag("ValueTypeReturnedAsFields"); protected static final boolean AlwaysIncrementalInline = (Boolean)WHITE_BOX.getVMFlag("AlwaysIncrementalInline"); + protected static final long TieredStopAtLevel = (Long)WHITE_BOX.getVMFlag("TieredStopAtLevel"); protected static final int COMP_LEVEL_ANY = -2; ! protected static final int COMP_LEVEL_ALL = -2; ! protected static final int COMP_LEVEL_AOT = -1; ! protected static final int COMP_LEVEL_NONE = 0; ! 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 Hashtable<String, Method> tests = new Hashtable<String, Method>(); 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
*** 192,201 **** --- 208,220 ---- */ public String[] getVMParameters(int scenario) { if (TEST_C1) { return new String[] { "-XX:+EnableValhallaC1", + "-XX:TieredStopAtLevel=1", + "-XX:-ValueTypePassFieldsAsArgs", + "-XX:-ValueTypeReturnedAsFields" }; } switch (scenario) { case 0: return new String[] {
*** 338,377 **** protected void run(String[] args, Class<?>... classes) throws Throwable { if (args.length == 0) { // Spawn a new VM instance execute_vm(); } else { ! // Execute tests run(classes); } } private void execute_vm() throws Throwable { Asserts.assertFalse(tests.isEmpty(), "no tests to execute"); - ArrayList<String> args = new ArrayList<String>(defaultFlags); 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; } } if (VERIFY_IR) { // Add print flags for IR verification ! args.addAll(printFlags); // Always trap for exception throwing to not confuse IR verification ! args.add("-XX:-OmitStackTraceInFastThrow"); } if (VERIFY_VM) { ! args.addAll(verifyFlags); } // Run tests in own process and verify output ! args.add(getClass().getName()); ! args.add("run"); ! // Spawn process with default JVM options from the test's run command ! String[] cmds = Arrays.copyOf(vmInputArgs, vmInputArgs.length + args.size()); ! System.arraycopy(args.toArray(), 0, cmds, vmInputArgs.length, args.size()); OutputAnalyzer oa = ProcessTools.executeTestJvm(cmds); // If ideal graph printing is enabled/supported, verify output String output = oa.getOutput(); oa.shouldHaveExitValue(0); if (VERIFY_IR) { --- 357,406 ---- 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; } + if (arg.startsWith("-XX:+EnableValhallaC1")) { + // Disable IR verification if C1 is used (FIXME!) + VERIFY_IR = false; + } } + // Each VM is launched with flags in this order, so the later ones can override the earlier one: + // defaultFlags + // VERIFY_IR/VERIFY_VM flags specified below + // vmInputArgs, which consists of: + // @run options + // getVMParameters() + // getExtraVMParameters() + String cmds[] = defaultFlags; 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"); } if (VERIFY_VM) { ! cmds = concat(cmds, verifyFlags); } + cmds = concat(cmds, vmInputArgs); + // 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) {
*** 509,528 **** } 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)) { WHITE_BOX.testSetForceInlineMethod(m, true); } else if (m.isAnnotationPresent(DontInline.class)) { WHITE_BOX.testSetDontInlineMethod(m, true); } } // Compile class initializers ! WHITE_BOX.enqueueInitializerForCompilation(clazz, COMP_LEVEL_FULL_OPTIMIZATION); } private void run(Class<?>... classes) throws Exception { if (USE_COMPILER && PRINT_IDEAL && !XCOMP) { System.out.println("PrintIdeal enabled"); --- 538,561 ---- } 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); + } else if (m.isAnnotationPresent(ForceCompile.class)) { + int compLevel = getCompLevel(m.getAnnotation(ForceCompile.class)); + WHITE_BOX.enqueueMethodForCompilation(m, compLevel); } if (m.isAnnotationPresent(ForceInline.class)) { WHITE_BOX.testSetForceInlineMethod(m, true); } else if (m.isAnnotationPresent(DontInline.class)) { WHITE_BOX.testSetDontInlineMethod(m, true); } } // 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) { System.out.println("PrintIdeal enabled");
*** 543,554 **** Warmup anno = test.getAnnotation(Warmup.class); int warmup = anno == null ? WARMUP : anno.value(); for (int i = 0; i < warmup; ++i) { verifier.invoke(this, true); } // Trigger compilation ! WHITE_BOX.enqueueMethodForCompilation(test, COMP_LEVEL_FULL_OPTIMIZATION); Asserts.assertTrue(!USE_COMPILER || WHITE_BOX.isMethodCompiled(test, false), test + " not compiled"); // Check result verifier.invoke(this, false); if (PRINT_TIMES) { long endTime = System.nanoTime(); --- 576,588 ---- Warmup anno = test.getAnnotation(Warmup.class); int warmup = anno == null ? WARMUP : anno.value(); for (int i = 0; i < warmup; ++i) { verifier.invoke(this, true); } + int compLevel = getCompLevel(test.getAnnotation(Test.class)); // Trigger compilation ! WHITE_BOX.enqueueMethodForCompilation(test, compLevel); Asserts.assertTrue(!USE_COMPILER || WHITE_BOX.isMethodCompiled(test, false), test + " not compiled"); // Check result verifier.invoke(this, false); if (PRINT_TIMES) { long endTime = System.nanoTime();
*** 563,568 **** --- 597,627 ---- for (Map.Entry<Long, String> entry : durations.entrySet()) { System.out.format("%-10s%15d ns\n", entry.getValue() + ":", entry.getKey()); } } } + + // Choose the appropriate compilation level for a method, according to the given annotation. + // + // Currently, if TEST_C1 is true, we always use COMP_LEVEL_SIMPLE. Otherwise, if the + // compLevel is unspecified, the default is COMP_LEVEL_FULL_OPTIMIZATION. + int getCompLevel(Object annotation) { + if (TEST_C1) { + return COMP_LEVEL_SIMPLE; + } + int compLevel; + if (annotation == null) { + compLevel = COMP_LEVEL_ANY; + } else if (annotation instanceof Test) { + compLevel = ((Test)annotation).compLevel(); + } else { + compLevel = ((ForceCompile)annotation).compLevel(); + } + if (compLevel == COMP_LEVEL_ANY) { + compLevel = COMP_LEVEL_FULL_OPTIMIZATION; + } + if (compLevel > (int)TieredStopAtLevel) { + compLevel = (int)TieredStopAtLevel; + } + return compLevel; + } }
< prev index next >