< prev index next >

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

Print this page
rev 55127 : 8223351: [lworld] Primary mirror and nullable mirror for inline type
Reviewed-by: tbd


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


1268         MyValue1[] vals = new MyValue1[] {(MyValue1) test42VT1, (MyValue1) test42VT2};
1269 
1270         if (deopt) {
1271             // uncommon trap
1272             WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test43"));
1273             Asserts.assertEQ(vals[0].hash(), test42VT1.hash());
1274             Asserts.assertEQ(vals[1].hash(), test42VT2.hash());
1275         }
1276 
1277         return vals[0].hash();
1278     }
1279 
1280     @DontCompile
1281     public void test43_verifier(boolean warmup) {
1282         test43(!warmup);
1283     }
1284 
1285     // Tests writing an array element with a (statically known) incompatible type
1286     private static final MethodHandle setArrayElementIncompatible = MethodHandleBuilder.loadCode(MethodHandles.lookup(),
1287         "setArrayElementIncompatible",
1288         MethodType.methodType(void.class, TestLWorld.class, MyValue1[].class, int.class, MyValue2.class.asValueType()),
1289         CODE -> {
1290             CODE.
1291             aload_1().
1292             iload_2().
1293             aload_3().
1294             aastore().
1295             return_();
1296         });
1297 
1298     @Test()
1299     public void test44(MyValue1[] va, int index, MyValue2 v) throws Throwable {
1300         setArrayElementIncompatible.invoke(this, va, index, v);
1301     }
1302 
1303     @DontCompile
1304     public void test44_verifier(boolean warmup) throws Throwable {
1305         int index = Math.abs(rI) % 3;
1306         try {
1307             test44(testValue1Array, index, testValue2);
1308             throw new RuntimeException("No ArrayStoreException thrown");




   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     public int getNumScenarios() {
  46         if (TEST_C1) {


1267         MyValue1[] vals = new MyValue1[] {(MyValue1) test42VT1, (MyValue1) test42VT2};
1268 
1269         if (deopt) {
1270             // uncommon trap
1271             WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test43"));
1272             Asserts.assertEQ(vals[0].hash(), test42VT1.hash());
1273             Asserts.assertEQ(vals[1].hash(), test42VT2.hash());
1274         }
1275 
1276         return vals[0].hash();
1277     }
1278 
1279     @DontCompile
1280     public void test43_verifier(boolean warmup) {
1281         test43(!warmup);
1282     }
1283 
1284     // Tests writing an array element with a (statically known) incompatible type
1285     private static final MethodHandle setArrayElementIncompatible = MethodHandleBuilder.loadCode(MethodHandles.lookup(),
1286         "setArrayElementIncompatible",
1287         MethodType.methodType(void.class, TestLWorld.class, MyValue1[].class, int.class, MyValue2.class.asPrimaryType()),
1288         CODE -> {
1289             CODE.
1290             aload_1().
1291             iload_2().
1292             aload_3().
1293             aastore().
1294             return_();
1295         });
1296 
1297     @Test()
1298     public void test44(MyValue1[] va, int index, MyValue2 v) throws Throwable {
1299         setArrayElementIncompatible.invoke(this, va, index, v);
1300     }
1301 
1302     @DontCompile
1303     public void test44_verifier(boolean warmup) throws Throwable {
1304         int index = Math.abs(rI) % 3;
1305         try {
1306             test44(testValue1Array, index, testValue2);
1307             throw new RuntimeException("No ArrayStoreException thrown");


< prev index next >