< prev index next >

test/compiler/valhalla/valuetypes/ValueTypeTestBench.java

Print this page

        

*** 26,50 **** /* * @test * @library /testlibrary /test/lib /compiler/whitebox / * @requires os.simpleArch == "x64" * @modules java.base/jdk.internal.misc:+open - * @modules java.base/jvm.internal.value * @compile -XDenableValueTypes ValueCapableClass1.java ValueCapableClass2.java ValueTypeTestBench.java * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller jdk.test.lib.Platform * @run main/othervm -Xbootclasspath/a:. -ea -noverify -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI -XX:-TieredCompilation -XX:+VerifyAdapterSharing * -XX:+EnableValhalla -XX:+EnableMVT -XX:+ValueTypePassFieldsAsArgs -XX:+ValueArrayFlatten * compiler.valhalla.valuetypes.ValueTypeTestBench * @run main/othervm -Xbootclasspath/a:. -ea -noverify -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI -XX:-TieredCompilation * -XX:+EnableValhalla -XX:+EnableMVT -XX:-ValueTypePassFieldsAsArgs -XX:-ValueArrayFlatten * compiler.valhalla.valuetypes.ValueTypeTestBench * @run main/othervm -Xbootclasspath/a:. -ea -noverify -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI -XX:-TieredCompilation -XX:+AlwaysIncrementalInline * -XX:+EnableValhalla -XX:+EnableMVT -XX:+ValueTypePassFieldsAsArgs -XX:+ValueArrayFlatten * compiler.valhalla.valuetypes.ValueTypeTestBench */ package compiler.valhalla.valuetypes; --- 26,51 ---- /* * @test * @library /testlibrary /test/lib /compiler/whitebox / * @requires os.simpleArch == "x64" * @modules java.base/jdk.internal.misc:+open * @compile -XDenableValueTypes ValueCapableClass1.java ValueCapableClass2.java ValueTypeTestBench.java * @run main ClassFileInstaller sun.hotspot.WhiteBox * @run main ClassFileInstaller jdk.test.lib.Platform * @run main/othervm -Xbootclasspath/a:. -ea -noverify -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI -XX:-TieredCompilation -XX:+VerifyAdapterSharing * -XX:+EnableValhalla -XX:+EnableMVT -XX:+ValueTypePassFieldsAsArgs -XX:+ValueArrayFlatten + * -XX:ValueArrayElemMaxFlatSize=-1 -XX:ValueArrayElemMaxFlatOops=-1 -XX:+FullGCALotWithValueTypes * compiler.valhalla.valuetypes.ValueTypeTestBench * @run main/othervm -Xbootclasspath/a:. -ea -noverify -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI -XX:-TieredCompilation * -XX:+EnableValhalla -XX:+EnableMVT -XX:-ValueTypePassFieldsAsArgs -XX:-ValueArrayFlatten * compiler.valhalla.valuetypes.ValueTypeTestBench * @run main/othervm -Xbootclasspath/a:. -ea -noverify -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI -XX:-TieredCompilation -XX:+AlwaysIncrementalInline * -XX:+EnableValhalla -XX:+EnableMVT -XX:+ValueTypePassFieldsAsArgs -XX:+ValueArrayFlatten + * -XX:ValueArrayElemMaxFlatSize=-1 -XX:ValueArrayElemMaxFlatOops=-1 * compiler.valhalla.valuetypes.ValueTypeTestBench */ package compiler.valhalla.valuetypes;
*** 75,104 **** static int s; static final long sf = ValueTypeTestBench.rL; final int x; final long y; final short z; final MyValue2 v1; final MyValue2 v2; static final MyValue2 v3 = MyValue2.createWithFieldsInline(ValueTypeTestBench.rI, true); final int c; ! private MyValue1(int x, long y, short z, MyValue2 v1, MyValue2 v2, int c) { s = x; this.x = x; this.y = y; this.z = z; this.v1 = v1; this.v2 = v2; this.c = c; } private MyValue1() { s = 0; this.x = 0; this.y = 0; this.z = 0; this.v1 = MyValue2.createDefaultInline(); this.v2 = MyValue2.createDefaultInline(); this.c = 0; } --- 76,111 ---- static int s; static final long sf = ValueTypeTestBench.rL; final int x; final long y; final short z; + final Integer o; + final int[] oa; final MyValue2 v1; final MyValue2 v2; static final MyValue2 v3 = MyValue2.createWithFieldsInline(ValueTypeTestBench.rI, true); final int c; ! private MyValue1(int x, long y, short z, Integer o, int[] oa, MyValue2 v1, MyValue2 v2, int c) { s = x; this.x = x; this.y = y; this.z = z; + this.o = o; + this.oa = oa; this.v1 = v1; this.v2 = v2; this.c = c; } private MyValue1() { s = 0; this.x = 0; this.y = 0; this.z = 0; + this.o = null; + this.oa = null; this.v1 = MyValue2.createDefaultInline(); this.v2 = MyValue2.createDefaultInline(); this.c = 0; }
*** 116,125 **** --- 123,135 ---- static MyValue1 createWithFieldsDontInline(int x, long y) { MyValue1 v = createDefaultInline(); v = setX(v, x); v = setY(v, y); v = setZ(v, (short)x); + v = setO(v, new Integer(x)); + int[] oa = {x}; + v = setOA(v, oa); v = setV1(v, MyValue2.createWithFieldsInline(x, x < y)); v = setV2(v, MyValue2.createWithFieldsInline(x, x > y)); v = setC(v, ValueTypeTestBench.rI); return v; }
*** 128,156 **** static MyValue1 createWithFieldsInline(int x, long y) { MyValue1 v = createDefaultInline(); v = setX(v, x); v = setY(v, y); v = setZ(v, (short)x); v = setV1(v, MyValue2.createWithFieldsInline(x, x < y)); v = setV2(v, MyValue2.createWithFieldsInline(x, x > y)); v = setC(v, ValueTypeTestBench.rI); return v; } @ForceInline ! public long hash() { return s + sf + x + y + z + c + v1.hash() + v2.hash() + v3.hash(); } @DontCompile public long hashInterpreted() { ! return s + sf + x + y + z + c + v1.hashInterpreted() + v2.hashInterpreted() + v3.hashInterpreted(); } @ForceInline public void print() { ! System.out.print("s=" + s + ", sf=" + sf + ", x=" + x + ", y=" + y + ", z=" + z + ", v1["); v1.print(); System.out.print("], v2["); v2.print(); System.out.print("], v3["); v3.print(); --- 138,175 ---- static MyValue1 createWithFieldsInline(int x, long y) { MyValue1 v = createDefaultInline(); v = setX(v, x); v = setY(v, y); v = setZ(v, (short)x); + v = setO(v, new Integer(x)); + int[] oa = {x}; + v = setOA(v, oa); v = setV1(v, MyValue2.createWithFieldsInline(x, x < y)); v = setV2(v, MyValue2.createWithFieldsInline(x, x > y)); v = setC(v, ValueTypeTestBench.rI); return v; } + // Hash only primitive and value type fields to avoid NullPointerException @ForceInline ! public long hashPrimitive() { return s + sf + x + y + z + c + v1.hash() + v2.hash() + v3.hash(); } + @ForceInline + public long hash() { + return hashPrimitive() + o + oa[0]; + } + @DontCompile public long hashInterpreted() { ! return s + sf + x + y + z + o + oa[0] + c + v1.hashInterpreted() + v2.hashInterpreted() + v3.hashInterpreted(); } @ForceInline public void print() { ! System.out.print("s=" + s + ", sf=" + sf + ", x=" + x + ", y=" + y + ", z=" + z + ", o=" + (o != null ? (Integer)o : "NULL") + ", v1["); v1.print(); System.out.print("], v2["); v2.print(); System.out.print("], v3["); v3.print();
*** 174,183 **** --- 193,214 ---- v.z = z; return v; } @ForceInline + __ValueFactory static MyValue1 setO(MyValue1 v, Integer o) { + v.o = o; + return v; + } + + @ForceInline + __ValueFactory static MyValue1 setOA(MyValue1 v, int[] oa) { + v.oa = oa; + return v; + } + + @ForceInline __ValueFactory static MyValue1 setC(MyValue1 v, int c) { v.c = c; return v; }
*** 475,485 **** long result = test10(rI, rL); Asserts.assertEQ(result, hash(rI + 10, rL + 10)); } // Merge value types created in a loop (inlined) ! @Test(failOn = ALLOC + LOAD + STORE + LOOP + TRAP) public long test11(int x, long y) { MyValue1 v = MyValue1.createWithFieldsInline(x, y); for (int i = 0; i < 10; ++i) { v = MyValue1.createWithFieldsInline(v.x + 1, v.y + 1); } --- 506,516 ---- long result = test10(rI, rL); Asserts.assertEQ(result, hash(rI + 10, rL + 10)); } // Merge value types created in a loop (inlined) ! @Test(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) { v = MyValue1.createWithFieldsInline(v.x + 1, v.y + 1); }
*** 654,675 **** // correctly allocated. @Test(valid = ValueTypePassFieldsAsArgsOn, failOn = LOAD + ALLOC + STORE) @Test(valid = ValueTypePassFieldsAsArgsOff, match = {ALLOC}, matchCount = {2}, failOn = LOAD) public long test20(boolean deopt) { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); ! MyValue1[] va = new MyValue1[3]; if (deopt) { // uncommon trap WHITE_BOX.deoptimizeMethod(tests.get("ValueTypeTestBench::test20")); } return v.hashInterpreted() + va[0].hashInterpreted() + va[1].hashInterpreted() + va[2].hashInterpreted(); } @DontCompile public void test20_verifier(boolean warmup) { ! MyValue1[] va = new MyValue1[42]; long result = test20(!warmup); Asserts.assertEQ(result, hash() + va[0].hash() + va[1].hash() + va[2].hash()); } // Value type fields in regular object --- 685,706 ---- // correctly allocated. @Test(valid = ValueTypePassFieldsAsArgsOn, failOn = LOAD + ALLOC + STORE) @Test(valid = ValueTypePassFieldsAsArgsOff, match = {ALLOC}, matchCount = {2}, failOn = LOAD) public long test20(boolean deopt) { MyValue1 v = MyValue1.createWithFieldsInline(rI, rL); ! MyValue2[] va = new MyValue2[3]; if (deopt) { // uncommon trap WHITE_BOX.deoptimizeMethod(tests.get("ValueTypeTestBench::test20")); } return v.hashInterpreted() + va[0].hashInterpreted() + va[1].hashInterpreted() + va[2].hashInterpreted(); } @DontCompile public void test20_verifier(boolean warmup) { ! MyValue2[] va = new MyValue2[42]; long result = test20(!warmup); Asserts.assertEQ(result, hash() + va[0].hash() + va[1].hash() + va[2].hash()); } // Value type fields in regular object
*** 1158,1167 **** --- 1189,1199 ---- for (int i = 0; i < 10; ++i) { Asserts.assertEQ(va[i].hash(), hash(rI + i, rL + i)); } } + // Merge value type arrays created from two branches @Test(failOn = (TRAP)) public MyValue1[] test45(boolean b) { MyValue1[] va; if (b) { va = new MyValue1[5];
*** 1209,1219 **** @DontCompile public void test46_verifier(boolean warmup) { MyValue1[] va = new MyValue1[1]; MyValue1 v = test46(); ! Asserts.assertEQ(v.hash(), va[0].hash()); } // Test default initialization of value type arrays @Test(failOn = LOAD) public MyValue1[] test47(int len) { --- 1241,1251 ---- @DontCompile public void test46_verifier(boolean warmup) { MyValue1[] va = new MyValue1[1]; MyValue1 v = test46(); ! Asserts.assertEQ(v.hashPrimitive(), va[0].hashPrimitive()); } // Test default initialization of value type arrays @Test(failOn = LOAD) public MyValue1[] test47(int len) {
*** 1224,1234 **** public void test47_verifier(boolean warmup) { int len = Math.abs(rI % 10); MyValue1[] va = new MyValue1[len]; MyValue1[] var = test47(len); for (int i = 0; i < len; ++i) { ! Asserts.assertEQ(va[i].hash(), var[i].hash()); } } // Test creation of value type array with zero length @Test(failOn = ALLOC + LOAD + STORE + LOOP + TRAP) --- 1256,1266 ---- public void test47_verifier(boolean warmup) { int len = Math.abs(rI % 10); MyValue1[] va = new MyValue1[len]; MyValue1[] var = test47(len); for (int i = 0; i < len; ++i) { ! Asserts.assertEQ(va[i].hashPrimitive(), var[i].hashPrimitive()); } } // Test creation of value type array with zero length @Test(failOn = ALLOC + LOAD + STORE + LOOP + TRAP)
*** 1274,1290 **** // test vdefault @Test(failOn = ALLOC + STORE + LOOP + TRAP) public long test51() { MyValue1 v1 = MyValue1.createDefaultInline(); MyValue1 v2 = MyValue1.createDefaultDontInline(); ! return v1.hash() + v2.hash(); } @DontCompile public void test51_verifier(boolean warmup) { long result = test51(); ! Asserts.assertEQ(result, 2 * MyValue1.createDefaultInline().hash()); } // test vwithfield @Test(failOn = ALLOC + LOAD + LOADP + STORE + LOOP + TRAP) public long test52() { --- 1306,1322 ---- // test vdefault @Test(failOn = ALLOC + STORE + LOOP + TRAP) public long test51() { MyValue1 v1 = MyValue1.createDefaultInline(); MyValue1 v2 = MyValue1.createDefaultDontInline(); ! return v1.hashPrimitive() + v2.hashPrimitive(); } @DontCompile public void test51_verifier(boolean warmup) { long result = test51(); ! Asserts.assertEQ(result, 2 * MyValue1.createDefaultInline().hashPrimitive()); } // test vwithfield @Test(failOn = ALLOC + LOAD + LOADP + STORE + LOOP + TRAP) public long test52() {
*** 1432,1443 **** public void test58_verifier(boolean warmup) { test58(); } // When calling a method on __Value, passing fields as arguments is impossible ! @Test(valid = ValueTypePassFieldsAsArgsOn, match = {ALLOC, STORE}, matchCount={1, 0}) ! @Test(valid = ValueTypePassFieldsAsArgsOff, failOn = STORE + LOAD) public String test59(MyValue1 v) { return v.toString(); } @DontCompile --- 1464,1474 ---- public void test58_verifier(boolean warmup) { test58(); } // When calling a method on __Value, passing fields as arguments is impossible ! @Test(failOn = ALLOC + STORE + LOAD) public String test59(MyValue1 v) { return v.toString(); } @DontCompile
*** 1669,1686 **** // Regular expressions used to match nodes in the PrintIdeal output private static final String START = "(\\d+\\t(.*"; private static final String MID = ".*)+\\t===.*"; private static final String END = ")|"; ! private static final String ALLOC = START + "CallStaticJava" + MID + "_new_instance_Java" + END; ! private static final String ALLOCA = START + "CallStaticJava" + MID + "_new_array_Java" + END; private static final String LOAD = START + "Load(B|S|I|L|F|D)" + MID + "valuetype\\*" + END; private static final String LOADP = START + "Load(P|N)" + MID + "valuetype\\*" + END; private static final String STORE = START + "Store(B|S|I|L|F|D)" + MID + "valuetype\\*" + END; private static final String STOREP = START + "Store(P|N)" + MID + "valuetype\\*" + END; private static final String LOOP = START + "Loop" + MID + "" + END; ! private static final String TRAP = START + "CallStaticJava" + MID + "uncommon_trap" + END; 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 SCOBJ = "(.*# ScObj.*" + END; --- 1700,1717 ---- // Regular expressions used to match nodes in the PrintIdeal output private static final String START = "(\\d+\\t(.*"; private static final String MID = ".*)+\\t===.*"; private static final String END = ")|"; ! private static final String ALLOC = "(.*precise klass compiler/valhalla/valuetypes/MyValue.*\\R(.*nop.*\\R)*.*_new_instance_Java" + END; ! private static final String ALLOCA = "(.*precise klass \\[Qcompiler/valhalla/valuetypes/MyValue.*\\R(.*nop.*\\R)*.*_new_array_Java" + END; private static final String LOAD = START + "Load(B|S|I|L|F|D)" + MID + "valuetype\\*" + END; private static final String LOADP = START + "Load(P|N)" + MID + "valuetype\\*" + END; private static final String STORE = START + "Store(B|S|I|L|F|D)" + MID + "valuetype\\*" + END; private static final String STOREP = START + "Store(P|N)" + MID + "valuetype\\*" + END; private static final String LOOP = START + "Loop" + MID + "" + END; ! private static final String TRAP = START + "CallStaticJava" + MID + "uncommon_trap.*(unstable_if|predicate)" + END; 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 SCOBJ = "(.*# ScObj.*" + END;
< prev index next >