< prev index next >
test/compiler/valhalla/valuetypes/ValueTypeTestBench.java
Print this page
@@ -2751,10 +2751,17 @@
MethodHandles.dropArguments(test104_mh1, 0, MethodHandle.class, MethodHandle.class),
MethodHandles.guardWithTest(test104_mh_test2,
MethodHandles.dropArguments(MethodHandles.invoker(test104_mt3), 1, MethodHandle.class),
MethodHandles.dropArguments(MethodHandles.invoker(test104_mt3), 0, MethodHandle.class))
);
+
+ MethodHandle test105_mh1 = lookup.findStatic(ValueTypeTestBench.class, "test105_target1", myvalue2_mt);
+ test105_mh2 = lookup.findStatic(ValueTypeTestBench.class, "test105_target2", myvalue2_mt);
+ MethodHandle test105_mh_test = lookup.findStatic(ValueTypeTestBench.class, "test105_test", boolean_mt);
+ test105_mh = MethodHandles.guardWithTest(test105_mh_test,
+ MethodHandles.dropArguments(test105_mh1, 0, MethodHandle.class),
+ MethodHandles.invoker(myvalue2_mt));
} catch (NoSuchMethodException|IllegalAccessException|NoSuchFieldException e) {
e.printStackTrace();
throw new RuntimeException("method handle lookup fails");
}
}
@@ -2779,11 +2786,11 @@
return test99_bool;
}
static final MethodHandle test99_mh;
- @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE)
+ @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE + STOREVALUETYPEFIELDS)
@Test(valid = ValueTypeReturnedAsFieldsOff)
MyValue3 test99() throws Throwable {
return (MyValue3)test99_mh.invokeExact(this);
}
@@ -2813,11 +2820,11 @@
}
static final MethodHandle test100_mh;
static MethodHandle test100_mh1;
- @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE)
+ @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE + STOREVALUETYPEFIELDS)
@Test(valid = ValueTypeReturnedAsFieldsOff)
long test100() throws Throwable {
return ((MyValue2)test100_mh.invokeExact(test100_mh1)).hash();
}
@@ -2847,11 +2854,11 @@
}
static final MethodHandle test101_mh;
static MethodHandle test101_mh2;
- @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE)
+ @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE + STOREVALUETYPEFIELDS)
@Test(valid = ValueTypeReturnedAsFieldsOff)
long test101() throws Throwable {
return ((MyValue2)test101_mh.invokeExact(test101_mh2)).hash();
}
@@ -2865,11 +2872,11 @@
// Simple reduction with intermediate result merged in a Lambda
// Form as an __Value. Shouldn't cause any allocations. The entire
// loop should go away as the result is a constant.
static final MethodHandle test102_mh;
- @Test(failOn = ALLOC + STORE + LOOP)
+ @Test(failOn = ALLOC + STORE + LOOP + STOREVALUETYPEFIELDS)
long test102() throws Throwable {
return (long)test102_mh.invokeExact();
}
@DontCompile
@@ -2910,11 +2917,11 @@
return test103_bool2;
}
static final MethodHandle test103_mh;
- @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE)
+ @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE + STOREVALUETYPEFIELDS)
@Test(valid = ValueTypeReturnedAsFieldsOff)
MyValue3 test103() throws Throwable {
return (MyValue3)test103_mh.invokeExact(this);
}
@@ -2958,11 +2965,11 @@
static final MethodHandle test104_mh;
static MethodHandle test104_mh2;
static MethodHandle test104_mh3;
- @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE)
+ @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE + STOREVALUETYPEFIELDS)
@Test(valid = ValueTypeReturnedAsFieldsOff)
long test104() throws Throwable {
return ((MyValue2)test104_mh.invokeExact(test104_mh2, test104_mh3)).hash();
}
@@ -2976,10 +2983,46 @@
int i = rI+(test104_bool1 ? 0 : (test104_bool2 ? 1 : 2));
boolean b = test104_bool1 ? true : (test104_bool2 ? false : true);
Asserts.assertEQ(hash, MyValue2.createWithFieldsInline(i, b).hash());
}
+ @ForceInline
+ static MyValue2 test105_target1() {
+ return MyValue2.createWithFieldsInline(rI+test105_i, true);
+ }
+
+ @ForceInline
+ static MyValue2 test105_target2() {
+ return MyValue2.createWithFieldsInline(rI-test105_i, false);
+ }
+
+ static int test105_i = 0;
+ @ForceInline
+ static boolean test105_test() {
+ return (test105_i % 100) == 0;
+ }
+
+ static final MethodHandle test105_mh;
+ static MethodHandle test105_mh2;
+
+ // Check that a buffered value returned by a compiled lambda form
+ // is properly handled by the caller.
+ @Test(valid = ValueTypeReturnedAsFieldsOn, failOn = ALLOC + ALLOCA + STORE + STOREVALUETYPEFIELDS)
+ @Test(valid = ValueTypeReturnedAsFieldsOff)
+ @Warmup(11000)
+ long test105() throws Throwable {
+ return ((MyValue2)test105_mh.invokeExact(test105_mh2)).hash();
+ }
+
+ @DontCompile
+ public void test105_verifier(boolean warmup) throws Throwable {
+ test105_i++;
+ long hash = test105();
+ boolean b = (test105_i % 100) == 0;
+ Asserts.assertEQ(hash, MyValue2.createWithFieldsInline(rI+test105_i * (b ? 1 : -1), b).hash());
+ }
+
// ========== Test infrastructure ==========
private static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
private static final int ValueTypePassFieldsAsArgsOn = 0x1;
private static final int ValueTypePassFieldsAsArgsOff = 0x2;
@@ -2989,11 +3032,11 @@
private static final int ValueTypeReturnedAsFieldsOff = 0x20;
static final int AllFlags = ValueTypePassFieldsAsArgsOn | ValueTypePassFieldsAsArgsOff | ValueTypeArrayFlattenOn | ValueTypeArrayFlattenOff | ValueTypeReturnedAsFieldsOn;
private static final boolean ValueTypePassFieldsAsArgs = (Boolean)WHITE_BOX.getVMFlag("ValueTypePassFieldsAsArgs");
private static final boolean ValueTypeArrayFlatten = (Boolean)WHITE_BOX.getVMFlag("ValueArrayFlatten");
private static final boolean ValueTypeReturnedAsFields = (Boolean)WHITE_BOX.getVMFlag("ValueTypeReturnedAsFields");
- private static final int COMP_LEVEL_ANY = -1;
+ private static final int COMP_LEVEL_ANY = -2;
private static final int COMP_LEVEL_FULL_OPTIMIZATION = 4;
private static final Hashtable<String, Method> tests = new Hashtable<String, Method>();
private static final int WARMUP = 251;
private static boolean USE_COMPILER = WHITE_BOX.getBooleanVMFlag("UseCompiler");
private static boolean PRINT_IDEAL = WHITE_BOX.getBooleanVMFlag("PrintIdeal");
@@ -3015,10 +3058,11 @@
private static final String RETURN = START + "Return" + MID + "returns" + END;
private static final String LINKTOSTATIC = START + "CallStaticJava" + MID + "linkToStatic" + END;
private static final String NPE = START + "CallStaticJava" + MID + "null_check" + END;
private static final String CCE = START + "CallStaticJava" + MID + "class_check" + END;
private static final String CALL = START + "CallStaticJava" + MID + END;
+ private static final String STOREVALUETYPEFIELDS = START + "CallStaticJava" + MID + "store_value_type_fields" + END;
private static final String SCOBJ = "(.*# ScObj.*" + END;
static {
// Gather all test methods and put them in Hashtable
for (Method m : ValueTypeTestBench.class.getDeclaredMethods()) {
@@ -3051,11 +3095,11 @@
System.out.println("WARNING: IR verification disabled! Running with -Xint, -Xcomp or release build?");
}
}
public static void main(String[] args) throws Throwable {
- //tests.values().removeIf(p -> !p.getName().equals("test85")); // Run single test
+ //tests.values().removeIf(p -> !p.getName().equals("test104")); // Run single test
if (args.length == 0) {
execute_vm("-XX:+IgnoreUnrecognizedVMOptions", "-XX:-BackgroundCompilation",
"-XX:+PrintCompilation", "-XX:+PrintInlining", "-XX:+PrintIdeal", "-XX:+PrintOptoAssembly",
"-XX:CICompilerCount=1",
"-XX:CompileCommand=quiet", "-XX:CompileCommand=compileonly,compiler.valhalla.valuetypes.ValueTypeTestBench::*",
@@ -3216,11 +3260,13 @@
// Execute tests
for (Method test : tests.values()) {
Method verifier = getClass().getDeclaredMethod(test.getName() + "_verifier", boolean.class);
// Warmup using verifier method
- for (int i = 0; i < WARMUP; ++i) {
+ 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");
@@ -3257,5 +3303,10 @@
@interface DontInline { }
// Prevent method compilation
@Retention(RetentionPolicy.RUNTIME)
@interface DontCompile { }
+
+@Retention(RetentionPolicy.RUNTIME)
+@interface Warmup {
+ int value();
+}
< prev index next >