< prev index next >

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

Print this page

*** 19,61 **** * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. */ /** * @test ! * @library /test/lib * @summary Test the handling of fields of unloaded value classes. * @compile -XDallowWithFieldOperator hack/GetUnresolvedValueFieldWrongSignature.java * @compile -XDallowWithFieldOperator TestUnloadedValueTypeField.java ! * @run main/othervm -XX:+EnableValhalla -Xcomp -XX:+Inline ! * -XX:CompileCommand=compileonly,TestUnloadedValueTypeField::test1 ! * -XX:CompileCommand=print,TestUnloadedValueTypeField::test1 ! * -XX:CompileCommand=compileonly,TestUnloadedValueTypeField::test2 ! * -XX:CompileCommand=compileonly,GetUnresolvedValueFieldWrongSignature::test3 ! * -XX:CompileCommand=compileonly,TestUnloadedValueTypeField::test4 ! * -XX:CompileCommand=compileonly,TestUnloadedValueTypeField::test5 ! * -XX:CompileCommand=compileonly,TestUnloadedValueTypeField::test11 ! * -XX:CompileCommand=compileonly,TestUnloadedValueTypeField::test12 ! * TestUnloadedValueTypeField */ ! import jdk.test.lib.Asserts; ! public class TestUnloadedValueTypeField { ! static final int WARMUP_LOOPS = 10000; ! static public void main(String[] args) { ! // instance fields ! test1_verifier(); ! test2_verifier(); ! test3_verifier(); ! test4_verifier(); ! test5_verifier(); ! ! // static fields ! test11_verifier(); ! test12_verifier(); } // Test case 1: // The value type field class has been loaded, but the holder class has not been loaded. // --- 19,63 ---- * 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.valuetypes; + import jdk.test.lib.Asserts; + /** * @test ! * @library /testlibrary /test/lib /compiler/whitebox / * @summary Test the handling of fields of unloaded value classes. * @compile -XDallowWithFieldOperator hack/GetUnresolvedValueFieldWrongSignature.java * @compile -XDallowWithFieldOperator TestUnloadedValueTypeField.java ! * @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform ! * @run main/othervm/timeout=120 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions ! * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI -XX:+EnableValhalla ! * compiler.valhalla.valuetypes.ValueTypeTest ! * compiler.valhalla.valuetypes.TestUnloadedValueTypeField */ ! public class TestUnloadedValueTypeField extends compiler.valhalla.valuetypes.ValueTypeTest { ! public static void main(String[] args) throws Throwable { ! TestUnloadedValueTypeField test = new TestUnloadedValueTypeField(); ! test.run(args); ! } ! static final String[][] scenarios = { ! {}, ! {"-XX:ValueFieldMaxFlatSize=0"} ! }; ! ! @Override ! public int getNumScenarios() { ! return scenarios.length; ! } ! ! @Override ! public String[] getVMParameters(int scenario) { ! return scenarios[scenario]; } // Test case 1: // The value type field class has been loaded, but the holder class has not been loaded. //
*** 83,109 **** static MyValue1 test1_precondition() { return MyValue1.make(); } ! static int test1(MyValue1Holder holder) { if (holder != null) { return holder.v.foo + 1; } else { return 0; } } ! static void test1_verifier() { ! for (int i=0; i<WARMUP_LOOPS; i++) { ! // Make sure test1() is compiled for the first iteration of this loop, ! // while MyValue1Holder is yet to be loaded. test1(null); ! } MyValue1Holder holder = new MyValue1Holder(); Asserts.assertEQ(test1(holder), 1235); } // Test case 2: // Both the value type field class, and the holder class have not been loaded. // // aload_0 --- 85,111 ---- static MyValue1 test1_precondition() { return MyValue1.make(); } ! @Test ! public int test1(MyValue1Holder holder) { if (holder != null) { return holder.v.foo + 1; } else { return 0; } } ! public void test1_verifier(boolean warmup) { ! if (warmup) { test1(null); ! } else { MyValue1Holder holder = new MyValue1Holder(); Asserts.assertEQ(test1(holder), 1235); } + } // Test case 2: // Both the value type field class, and the holder class have not been loaded. // // aload_0
*** 127,153 **** v = MyValue2.make(1234); } } ! static int test2(MyValue2Holder holder) { if (holder != null) { return holder.v.foo + 2; } else { return 0; } } ! static void test2_verifier() { ! for (int i=0; i<WARMUP_LOOPS; i++) { ! // Make sure test2() is compiled for the first iteration of this loop, ! // while MyValue2Holder2 and MyValue2 is yet to be loaded. test2(null); ! } MyValue2Holder holder2 = new MyValue2Holder(); Asserts.assertEQ(test2(holder2), 1236); } // Test case 3: same as test1, except we are using an incorrect signature to // refer to the value class. // The value type field class has been loaded, but the holder class has not been loaded. // --- 129,155 ---- v = MyValue2.make(1234); } } ! @Test ! public int test2(MyValue2Holder holder) { if (holder != null) { return holder.v.foo + 2; } else { return 0; } } ! public void test2_verifier(boolean warmup) { ! if (warmup) { test2(null); ! } else { MyValue2Holder holder2 = new MyValue2Holder(); Asserts.assertEQ(test2(holder2), 1236); } + } // Test case 3: same as test1, except we are using an incorrect signature to // refer to the value class. // The value type field class has been loaded, but the holder class has not been loaded. //
*** 178,206 **** static MyValue3 test3_precondition() { return MyValue3.make(); } ! static int test3(MyValue3Holder holder) { return GetUnresolvedValueFieldWrongSignature.test3(holder); } ! static void test3_verifier() { ! for (int i=0; i<WARMUP_LOOPS; i++) { ! // Make sure test3() is compiled for the first iteration of this loop, ! // while MyValue3Holder is yet to be loaded. test3(null); ! } ! MyValue3Holder holder = new MyValue3Holder(); try { test3(holder); Asserts.fail("Should have thrown NoSuchFieldError"); } catch (NoSuchFieldError e) { // OK } } // Test case 4: // Same as case 1, except we use putfield instead of getfield. static value final class MyValue4 { final int foo = 0; --- 180,207 ---- static MyValue3 test3_precondition() { return MyValue3.make(); } ! @Test ! public int test3(MyValue3Holder holder) { return GetUnresolvedValueFieldWrongSignature.test3(holder); } ! public void test3_verifier(boolean warmup) { ! if (warmup) { test3(null); ! } else { MyValue3Holder holder = new MyValue3Holder(); try { test3(holder); Asserts.fail("Should have thrown NoSuchFieldError"); } catch (NoSuchFieldError e) { // OK } } + } // Test case 4: // Same as case 1, except we use putfield instead of getfield. static value final class MyValue4 { final int foo = 0;
*** 220,246 **** static MyValue4 test4_precondition() { return MyValue4.make(0); } ! static void test4(MyValue4Holder holder, MyValue4 v) { if (holder != null) { holder.v = v; } } ! static void test4_verifier() { MyValue4 v = MyValue4.make(5678); ! for (int i=0; i<WARMUP_LOOPS; i++) { ! // Make sure test4() is compiled for the first iteration of this loop, ! // while MyValue4Holder is yet to be loaded. test4(null, v); ! } MyValue4Holder holder = new MyValue4Holder(); test4(holder, v); Asserts.assertEQ(holder.v.foo, 5678); } // Test case 5: // Same as case 2, except we use putfield instead of getfield. static value final class MyValue5 { final int foo = 0; --- 221,247 ---- static MyValue4 test4_precondition() { return MyValue4.make(0); } ! @Test ! public void test4(MyValue4Holder holder, MyValue4 v) { if (holder != null) { holder.v = v; } } ! public void test4_verifier(boolean warmup) { MyValue4 v = MyValue4.make(5678); ! if (warmup) { test4(null, v); ! } else { MyValue4Holder holder = new MyValue4Holder(); test4(holder, v); Asserts.assertEQ(holder.v.foo, 5678); } + } // Test case 5: // Same as case 2, except we use putfield instead of getfield. static value final class MyValue5 { final int foo = 0;
*** 259,287 **** public Object make(int n) { return MyValue5.make(n); } } ! static void test5(MyValue5Holder holder, Object o) { if (holder != null) { MyValue5 v = (MyValue5)o; holder.v = v; } } ! static void test5_verifier() { ! for (int i=0; i<WARMUP_LOOPS; i++) { ! // Make sure test5() is compiled for the first iteration of this loop, ! // while both MyValue5Holder and MyValye5 are yet to be loaded. test5(null, null); ! } ! MyValue5Holder holder = new MyValue5Holder(); Object v = holder.make(5679); test5(holder, v); Asserts.assertEQ(holder.v.foo, 5679); } // Test case 11: (same as test1, except we use getstatic instead of getfield) // The value type field class has been loaded, but the holder class has not been loaded. // --- 260,287 ---- public Object make(int n) { return MyValue5.make(n); } } ! @Test ! public void test5(MyValue5Holder holder, Object o) { if (holder != null) { MyValue5 v = (MyValue5)o; holder.v = v; } } ! public void test5_verifier(boolean warmup) { ! if (warmup) { test5(null, null); ! } else { MyValue5Holder holder = new MyValue5Holder(); Object v = holder.make(5679); test5(holder, v); Asserts.assertEQ(holder.v.foo, 5679); } + } // Test case 11: (same as test1, except we use getstatic instead of getfield) // The value type field class has been loaded, but the holder class has not been loaded. //
*** 304,329 **** static MyValue11 test11_precondition() { return MyValue11.make(); } ! static int test11(int n) { if (n == 0) { return 0; } else { return MyValue11Holder.v.foo + n; } } ! static void test11_verifier() { ! for (int i=0; i<WARMUP_LOOPS; i++) { ! // Make sure test1() is compiled for the first iteration of this loop, ! // while MyValue1Holder is yet to be loaded. test11(0); ! } Asserts.assertEQ(test11(2), 1236); } // Test case 12: (same as test2, except we use getstatic instead of getfield) // Both the value type field class, and the holder class have not been loaded. // --- 304,329 ---- static MyValue11 test11_precondition() { return MyValue11.make(); } ! @Test ! public int test11(int n) { if (n == 0) { return 0; } else { return MyValue11Holder.v.foo + n; } } ! public void test11_verifier(boolean warmup) { ! if (warmup) { test11(0); ! } else { Asserts.assertEQ(test11(2), 1236); } + } // Test case 12: (same as test2, except we use getstatic instead of getfield) // Both the value type field class, and the holder class have not been loaded. //
*** 342,363 **** static class MyValue12Holder { static MyValue12 v = MyValue12.make(12); } ! static int test12(int n) { if (n == 0) { return 0; } else { return MyValue12Holder.v.foo + n; } } ! static void test12_verifier() { ! for (int i=0; i<WARMUP_LOOPS; i++) { ! // Make sure test2() is compiled for the first iteration of this loop, ! // while MyValue2Holder2 and MyValue2 is yet to be loaded. test12(0); ! } Asserts.assertEQ(test12(1), 13); } } --- 342,363 ---- static class MyValue12Holder { static MyValue12 v = MyValue12.make(12); } ! @Test ! public int test12(int n) { if (n == 0) { return 0; } else { return MyValue12Holder.v.foo + n; } } ! public void test12_verifier(boolean warmup) { ! if (warmup) { test12(0); ! } else { Asserts.assertEQ(test12(1), 13); } + } }
< prev index next >