< prev index next >

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

Print this page




   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package compiler.valhalla.valuetypes;
  25 
  26 import java.lang.invoke.*;


  27 
  28 import jdk.experimental.value.MethodHandleBuilder;
  29 import jdk.test.lib.Asserts;
  30 
  31 /*
  32  * @test
  33  * @summary Test value types in LWorld.
  34  * @modules java.base/jdk.experimental.value
  35  * @library /testlibrary /test/lib /compiler/whitebox /
  36  * @requires os.simpleArch == "x64"
  37  * @compile TestLWorld.java
  38  * @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform
  39  * @run main/othervm/timeout=120 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
  40  *                               -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI -XX:+EnableValhalla
  41  *                               compiler.valhalla.valuetypes.ValueTypeTest
  42  *                               compiler.valhalla.valuetypes.TestLWorld
  43  */
  44 public class TestLWorld extends ValueTypeTest {
  45     static {
  46         if (TEST_C1 && (Long)WHITE_BOX.getVMFlag("ValueFieldMaxFlatSize") == 0) {


2038 
2039     @Test(failOn = ALLOC + LOAD + STORE)
2040     public int test81()  {
2041         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
2042         int result = 0;
2043         for (int i = 0; i < 10; i++) {
2044             try {
2045                 result += test81Callee(vt);
2046             } catch (NullPointerException npe) {
2047                 result += rI;
2048             }
2049         }
2050         return result;
2051     }
2052 
2053     @DontCompile
2054     public void test81_verifier(boolean warmup) {
2055         int result = test81();
2056         Asserts.assertEQ(result, 10*rI);
2057     }










































































































































2058 }


   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package compiler.valhalla.valuetypes;
  25 
  26 import java.lang.invoke.*;
  27 import java.lang.reflect.Method;
  28 import java.util.Arrays;
  29 
  30 import jdk.experimental.value.MethodHandleBuilder;
  31 import jdk.test.lib.Asserts;
  32 
  33 /*
  34  * @test
  35  * @summary Test value types in LWorld.
  36  * @modules java.base/jdk.experimental.value
  37  * @library /testlibrary /test/lib /compiler/whitebox /
  38  * @requires os.simpleArch == "x64"
  39  * @compile TestLWorld.java
  40  * @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform
  41  * @run main/othervm/timeout=120 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
  42  *                               -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI -XX:+EnableValhalla
  43  *                               compiler.valhalla.valuetypes.ValueTypeTest
  44  *                               compiler.valhalla.valuetypes.TestLWorld
  45  */
  46 public class TestLWorld extends ValueTypeTest {
  47     static {
  48         if (TEST_C1 && (Long)WHITE_BOX.getVMFlag("ValueFieldMaxFlatSize") == 0) {


2040 
2041     @Test(failOn = ALLOC + LOAD + STORE)
2042     public int test81()  {
2043         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
2044         int result = 0;
2045         for (int i = 0; i < 10; i++) {
2046             try {
2047                 result += test81Callee(vt);
2048             } catch (NullPointerException npe) {
2049                 result += rI;
2050             }
2051         }
2052         return result;
2053     }
2054 
2055     @DontCompile
2056     public void test81_verifier(boolean warmup) {
2057         int result = test81();
2058         Asserts.assertEQ(result, 10*rI);
2059     }
2060 
2061     // Test check for null free array when storing to value array
2062     @Test
2063     public void test82(Object[] dst, Object v) {
2064         dst[0] = v;        
2065     }
2066 
2067     @DontCompile
2068     public void test82_verifier(boolean warmup) {
2069         MyValue2[] dst = new MyValue2[1];
2070         test82(dst, testValue2);
2071         if (!warmup) {
2072             try {
2073                 test82(dst, null);
2074                 throw new RuntimeException("No ArrayStoreException thrown");
2075             } catch (NullPointerException e) {
2076                 // Expected
2077             }
2078         }
2079     }
2080 
2081     @Test
2082     @Warmup(10000)
2083     public void test83(Object[] dst, Object v, boolean flag) {
2084         if (dst == null) { // null check
2085         }
2086         if (flag) {
2087             if (dst.getClass() == MyValue1[].class) { // trigger split if
2088             }
2089         } else {
2090             dst = new MyValue2[1]; // constant null free property
2091         }
2092         dst[0] = v;        
2093     }
2094 
2095     @DontCompile
2096     public void test83_verifier(boolean warmup) {
2097         MyValue2[] dst = new MyValue2[1];
2098         test83(dst, testValue2, false);
2099         if (!warmup) {
2100             try {
2101                 test83(dst, null, true);
2102                 throw new RuntimeException("No ArrayStoreException thrown");
2103             } catch (NullPointerException e) {
2104                 // Expected
2105             }
2106         }
2107     }
2108 
2109     // Following: should make 2 copies of the loop, one for non
2110     // flattened arrays, one for other cases
2111     @Test(match = { COUNTEDLOOP }, matchCount = { 4 } )
2112     public void test84(Object[] src, Object[] dst) {
2113         for (int i = 0; i < src.length; i++) {
2114             dst[i] = src[i];
2115         }
2116     }
2117 
2118     @DontCompile
2119     public void test84_verifier(boolean warmup) {
2120         MyValue2[] src = new MyValue2[100];
2121         Arrays.fill(src, testValue2);
2122         MyValue2[] dst = new MyValue2[100];
2123         test84(src, dst);
2124         Asserts.assertTrue(Arrays.equals(src, dst));
2125     }
2126 
2127     @Test(valid = G1GCOn, match = { COUNTEDLOOP }, matchCount = { 2 } )
2128     @Test(valid = G1GCOff, match = { COUNTEDLOOP }, matchCount = { 3 } )
2129     public void test85(Object[] src, Object[] dst) {
2130         for (int i = 0; i < src.length; i++) {
2131             dst[i] = src[i];
2132         }
2133     }
2134 
2135     @DontCompile
2136     public void test85_verifier(boolean warmup) {
2137         Object[] src = new Object[100];
2138         Arrays.fill(src, new Object());
2139         src[0] = null;
2140         Object[] dst = new Object[100];
2141         test85(src, dst);
2142         Asserts.assertTrue(Arrays.equals(src, dst));
2143     }
2144     
2145     @Test(valid = G1GCOn, match = { COUNTEDLOOP }, matchCount = { 2 } )
2146     @Test(valid = G1GCOff, match = { COUNTEDLOOP }, matchCount = { 3 } )
2147     public void test86(Object[] src, Object[] dst) {
2148         for (int i = 0; i < src.length; i++) {
2149             dst[i] = src[i];
2150         }
2151     }
2152 
2153     @DontCompile
2154     public void test86_verifier(boolean warmup) {
2155         MyValue2[] src = new MyValue2[100];
2156         Arrays.fill(src, testValue2);
2157         Object[] dst = new Object[100];
2158         test86(src, dst);
2159         Asserts.assertTrue(Arrays.equals(src, dst));
2160     }
2161 
2162     @Test(match = { COUNTEDLOOP }, matchCount = { 4 } )
2163     public void test87(Object[] src, Object[] dst) {
2164         for (int i = 0; i < src.length; i++) {
2165             dst[i] = src[i];
2166         }
2167     }
2168 
2169     @DontCompile
2170     public void test87_verifier(boolean warmup) {
2171         Object[] src = new Object[100];
2172         Arrays.fill(src, testValue2);
2173         MyValue2[] dst = new MyValue2[100];
2174         test87(src, dst);
2175         Asserts.assertTrue(Arrays.equals(src, dst));
2176     }
2177 
2178     @Test(match = { COUNTEDLOOP }, matchCount = { 4 } )
2179     public void test88(Object[] src1, Object[] dst1, Object[] src2, Object[] dst2) {
2180         for (int i = 0; i < src1.length; i++) {
2181             dst1[i] = src1[i];
2182             dst2[i] = src2[i];
2183         }
2184     }
2185 
2186     @DontCompile
2187     public void test88_verifier(boolean warmup) {
2188         MyValue2[] src1 = new MyValue2[100];
2189         Arrays.fill(src1, testValue2);
2190         MyValue2[] dst1 = new MyValue2[100];
2191         Object[] src2 = new Object[100];
2192         Arrays.fill(src2, new Object());
2193         Object[] dst2 = new Object[100];
2194         test88(src1, dst1, src2, dst2);
2195         Asserts.assertTrue(Arrays.equals(src1, dst1));
2196         Asserts.assertTrue(Arrays.equals(src2, dst2));
2197     }
2198 }
< prev index next >