1 /*
   2  * Copyright (c) 2017, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   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.reflect.Array;
  27 import java.lang.reflect.Field;
  28 import java.util.Arrays;
  29 
  30 import jdk.test.lib.Asserts;
  31 import jdk.internal.misc.Unsafe;
  32 
  33 /*
  34  * @test
  35  * @summary Test intrinsic support for value types
  36  * @library /testlibrary /test/lib /compiler/whitebox /
  37  * @modules java.base/jdk.internal.misc
  38  * @compile -XDallowWithFieldOperator TestIntrinsics.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.TestIntrinsics
  44  */
  45 public class TestIntrinsics extends ValueTypeTest {
  46     // Extra VM parameters for some test scenarios. See ValueTypeTest.getVMParameters()
  47     @Override
  48     public String[] getExtraVMParameters(int scenario) {
  49         switch (scenario) {
  50         case 3: return new String[] {"-XX:-MonomorphicArrayCheck", "-XX:ValueArrayElemMaxFlatSize=-1"};
  51         case 4: return new String[] {"-XX:-MonomorphicArrayCheck"};
  52         }
  53         return null;
  54     }
  55 
  56     public static void main(String[] args) throws Throwable {
  57         TestIntrinsics test = new TestIntrinsics();
  58         test.run(args, MyValue1.class, MyValue2.class, MyValue2Inline.class);
  59     }
  60 
  61     // Test correctness of the Class::isAssignableFrom intrinsic
  62     @Test()
  63     public boolean test1(Class<?> supercls, Class<?> subcls) {
  64         return supercls.isAssignableFrom(subcls);
  65     }
  66 
  67     public void test1_verifier(boolean warmup) {
  68         Asserts.assertTrue(test1(Object.class, MyValue1.class), "test1_1 failed");
  69         Asserts.assertTrue(test1(MyValue1.class, MyValue1.class), "test1_2 failed");
  70         Asserts.assertTrue(test1(Object.class, java.util.ArrayList.class), "test1_3 failed");
  71         Asserts.assertTrue(test1(java.util.ArrayList.class, java.util.ArrayList.class), "test1_4 failed");
  72     }
  73 
  74     // Verify that Class::isAssignableFrom checks with statically known classes are folded
  75     @Test(failOn = LOADK)
  76     public boolean test2() {
  77         boolean check1 = java.util.AbstractList.class.isAssignableFrom(java.util.ArrayList.class);
  78         boolean check2 = MyValue1.class.isAssignableFrom(MyValue1.class);
  79         boolean check3 = Object.class.isAssignableFrom(java.util.ArrayList.class);
  80         boolean check4 = Object.class.isAssignableFrom(MyValue1.class);
  81         boolean check5 = !MyValue1.class.isAssignableFrom(Object.class);
  82         return check1 && check2 && check3 && check4 && check5;
  83     }
  84 
  85     public void test2_verifier(boolean warmup) {
  86         Asserts.assertTrue(test2(), "test2 failed");
  87     }
  88 
  89     // Test correctness of the Class::getSuperclass intrinsic
  90     @Test()
  91     public Class<?> test3(Class<?> cls) {
  92         return cls.getSuperclass();
  93     }
  94 
  95     public void test3_verifier(boolean warmup) {
  96         Asserts.assertTrue(test3(Object.class) == null, "test3_1 failed");
  97         Asserts.assertTrue(test3(MyValue1.class) == Object.class, "test3_2 failed");
  98         Asserts.assertTrue(test3(Class.class) == Object.class, "test3_3 failed");
  99     }
 100 
 101     // Verify that Class::getSuperclass checks with statically known classes are folded
 102     @Test(failOn = LOADK)
 103     public boolean test4() {
 104         boolean check1 = Object.class.getSuperclass() == null;
 105         boolean check2 = MyValue1.class.getSuperclass() == Object.class;
 106         boolean check3 = Class.class.getSuperclass() == Object.class;
 107         return check1 && check2 && check3;
 108     }
 109 
 110     public void test4_verifier(boolean warmup) {
 111         Asserts.assertTrue(test4(), "test4 failed");
 112     }
 113 
 114     // Test toString() method
 115     @Test()
 116     public String test5(MyValue1 v) {
 117         return v.toString();
 118     }
 119 
 120     @DontCompile
 121     public void test5_verifier(boolean warmup) {
 122         MyValue1 v = MyValue1.createDefaultInline();
 123         test5(v);
 124     }
 125 
 126     // Test hashCode() method
 127     @Test()
 128     public int test6(MyValue1 v) {
 129         return v.hashCode();
 130     }
 131 
 132     @DontCompile
 133     public void test6_verifier(boolean warmup) {
 134         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 135         int res = test6(v);
 136         Asserts.assertEQ(res, v.hashCode());
 137     }
 138 
 139     // Test default value type array creation via reflection
 140     @Test()
 141     public Object[] test7(Class<?> componentType, int len) {
 142         Object[] va = (Object[])Array.newInstance(componentType, len);
 143         return va;
 144     }
 145 
 146     @DontCompile
 147     public void test7_verifier(boolean warmup) {
 148         int len = Math.abs(rI) % 42;
 149         long hash = MyValue1.createDefaultDontInline().hashPrimitive();
 150         Object[] va = test7(MyValue1.class, len);
 151         for (int i = 0; i < len; ++i) {
 152             Asserts.assertEQ(((MyValue1)va[i]).hashPrimitive(), hash);
 153         }
 154     }
 155 
 156     // Class.isInstance
 157     @Test()
 158     public boolean test8(Class c, MyValue1 vt) {
 159         return c.isInstance(vt);
 160     }
 161 
 162     @DontCompile
 163     public void test8_verifier(boolean warmup) {
 164         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
 165         boolean result = test8(MyValue1.class, vt);
 166         Asserts.assertTrue(result);
 167     }
 168 
 169     @Test()
 170     public boolean test9(Class c, MyValue1 vt) {
 171         return c.isInstance(vt);
 172     }
 173 
 174     @DontCompile
 175     public void test9_verifier(boolean warmup) {
 176         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
 177         boolean result = test9(MyValue2.class, vt);
 178         Asserts.assertFalse(result);
 179     }
 180 
 181     // Class.cast
 182     @Test()
 183     public Object test10(Class c, MyValue1 vt) {
 184         return c.cast(vt);
 185     }
 186 
 187     @DontCompile
 188     public void test10_verifier(boolean warmup) {
 189         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
 190         Object result = test10(MyValue1.class, vt);
 191         Asserts.assertEQ(((MyValue1)result).hash(), vt.hash());
 192     }
 193 
 194     @Test()
 195     public Object test11(Class c, MyValue1 vt) {
 196         return c.cast(vt);
 197     }
 198 
 199     @DontCompile
 200     public void test11_verifier(boolean warmup) {
 201         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
 202         try {
 203             test11(MyValue2.class, vt);
 204             throw new RuntimeException("should have thrown");
 205         } catch(ClassCastException cce) {
 206         }
 207     }
 208 
 209     @Test()
 210     public Object test12(MyValue1 vt) {
 211         return MyValue1.class.cast(vt);
 212     }
 213 
 214     @DontCompile
 215     public void test12_verifier(boolean warmup) {
 216         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
 217         Object result = test12(vt);
 218         Asserts.assertEQ(((MyValue1)result).hash(), vt.hash());
 219     }
 220 
 221     @Test()
 222     public Object test13(MyValue1 vt) {
 223         return MyValue2.class.cast(vt);
 224     }
 225 
 226     @DontCompile
 227     public void test13_verifier(boolean warmup) {
 228         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
 229         try {
 230             test13(vt);
 231             throw new RuntimeException("should have thrown");
 232         } catch(ClassCastException cce) {
 233         }
 234     }
 235 
 236     // value type array creation via reflection
 237     @Test()
 238     public void test14(int len, long hash) {
 239         Object[] va = (Object[])Array.newInstance(MyValue1.class, len);
 240         for (int i = 0; i < len; ++i) {
 241             Asserts.assertEQ(((MyValue1)va[i]).hashPrimitive(), hash);
 242         }
 243     }
 244 
 245     @DontCompile
 246     public void test14_verifier(boolean warmup) {
 247         int len = Math.abs(rI) % 42;
 248         long hash = MyValue1.createDefaultDontInline().hashPrimitive();
 249         test14(len, hash);
 250     }
 251 
 252     // Test hashCode() method
 253     @Test()
 254     public int test15(Object v) {
 255         return v.hashCode();
 256     }
 257 
 258     @DontCompile
 259     public void test15_verifier(boolean warmup) {
 260         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 261         int res = test15(v);
 262         Asserts.assertEQ(res, v.hashCode());
 263     }
 264 
 265     @Test()
 266     public int test16(Object v) {
 267         return System.identityHashCode(v);
 268     }
 269 
 270     @DontCompile
 271     public void test16_verifier(boolean warmup) {
 272         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 273         int res = test16(v);
 274         Asserts.assertEQ(res, System.identityHashCode((Object)v));
 275     }
 276 
 277     @Test()
 278     public int test17(Object v) {
 279         return System.identityHashCode(v);
 280     }
 281 
 282     @DontCompile
 283     public void test17_verifier(boolean warmup) {
 284         Integer v = new Integer(rI);
 285         int res = test17(v);
 286         Asserts.assertEQ(res, System.identityHashCode(v));
 287     }
 288 
 289     @Test()
 290     public int test18(Object v) {
 291         return System.identityHashCode(v);
 292     }
 293 
 294     @DontCompile
 295     public void test18_verifier(boolean warmup) {
 296         Object v = null;
 297         int res = test18(v);
 298         Asserts.assertEQ(res, System.identityHashCode(v));
 299     }
 300 
 301     // hashCode() and toString() with different value types
 302     @Test()
 303     public int test19(MyValue1 vt1, MyValue1 vt2, boolean b) {
 304         MyValue1 res = b ? vt1 : vt2;
 305         return res.hashCode();
 306     }
 307 
 308     @DontCompile
 309     public void test19_verifier(boolean warmup) {
 310         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
 311         int res = test19(vt, vt, true);
 312         Asserts.assertEQ(res, vt.hashCode());
 313         res = test19(vt, vt, false);
 314         Asserts.assertEQ(res, vt.hashCode());
 315     }
 316 
 317     @Test()
 318     public String test20(MyValue1 vt1, MyValue1 vt2, boolean b) {
 319         MyValue1 res = b ? vt1 : vt2;
 320         return res.toString();
 321     }
 322 
 323     @DontCompile
 324     public void test20_verifier(boolean warmup) {
 325         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
 326         String res = test20(vt, vt, true);
 327         Asserts.assertEQ(res, vt.toString());
 328         res = test20(vt, vt, false);
 329         Asserts.assertEQ(res, vt.toString());
 330     }
 331 
 332     private static final Unsafe U = Unsafe.getUnsafe();
 333     private static final long X_OFFSET;
 334     private static final long Y_OFFSET;
 335     private static final long V1_OFFSET;
 336     private static final boolean V1_FLATTENED;
 337     static {
 338         try {
 339             Field xField = MyValue1.class.getDeclaredField("x");
 340             X_OFFSET = U.objectFieldOffset(xField);
 341             Field yField = MyValue1.class.getDeclaredField("y");
 342             Y_OFFSET = U.objectFieldOffset(yField);
 343             Field v1Field = MyValue1.class.getDeclaredField("v1");
 344             V1_OFFSET = U.objectFieldOffset(v1Field);
 345             V1_FLATTENED = U.isFlattened(v1Field);
 346         } catch (Exception e) {
 347             throw new RuntimeException(e);
 348         }
 349     }
 350 
 351     protected static final String CALL_Unsafe = START + "CallStaticJava" + MID + "# Static  jdk.internal.misc.Unsafe::" + END;
 352 
 353     @Test(failOn=CALL_Unsafe)
 354     public int test21(MyValue1 v) {
 355        return U.getInt(v, X_OFFSET);
 356     }
 357 
 358     @DontCompile
 359     public void test21_verifier(boolean warmup) {
 360         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 361         int res = test21(v);
 362         Asserts.assertEQ(res, v.x);
 363     }
 364 
 365     MyValue1.val test22_vt;
 366     @Test(failOn=CALL_Unsafe + ALLOC)
 367     public void test22(MyValue1 v) {
 368         v = U.makePrivateBuffer(v);
 369         U.putInt(v, X_OFFSET, rI);
 370         v = U.finishPrivateBuffer(v);
 371         test22_vt = v;
 372     }
 373 
 374     @DontCompile
 375     public void test22_verifier(boolean warmup) {
 376         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 377         test22(v.setX(v, 0));
 378         Asserts.assertEQ(test22_vt.hash(), v.hash());
 379     }
 380 
 381     @Test(failOn=CALL_Unsafe)
 382     public int test23(MyValue1 v, long offset) {
 383         return U.getInt(v, offset);
 384     }
 385 
 386     @DontCompile
 387     public void test23_verifier(boolean warmup) {
 388         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 389         int res = test23(v, X_OFFSET);
 390         Asserts.assertEQ(res, v.x);
 391     }
 392 
 393     MyValue1.val test24_vt = MyValue1.createWithFieldsInline(rI, rL);
 394 
 395     @Test(failOn=CALL_Unsafe)
 396     public int test24(long offset) {
 397         return U.getInt(test24_vt, offset);
 398     }
 399 
 400     @DontCompile
 401     public void test24_verifier(boolean warmup) {
 402         int res = test24(X_OFFSET);
 403         Asserts.assertEQ(res, test24_vt.x);
 404     }
 405 
 406     // Test copyOf intrinsic with allocated value type in it's debug information
 407     value final class Test25Value {
 408         final int x;
 409         public Test25Value() {
 410             this.x = 42;
 411         }
 412     }
 413 
 414     final Test25Value[] test25Array = new Test25Value[10];
 415 
 416     @Test
 417     public Test25Value[] test25(Test25Value element) {
 418         Test25Value[] newArray = Arrays.copyOf(test25Array, test25Array.length + 1);
 419         newArray[test25Array.length] = element;
 420         return newArray;
 421     }
 422 
 423     @DontCompile
 424     public void test25_verifier(boolean warmup) {
 425         Test25Value vt = new Test25Value();
 426         test25(vt);
 427     }
 428 
 429     @Test
 430     public Object test26() {
 431         Class<?>[] ca = new Class<?>[1];
 432         for (int i = 0; i < 1; ++i) {
 433           // Folds during loop opts
 434           ca[i] = MyValue1.class;
 435         }
 436         return Array.newInstance(ca[0], 1);
 437     }
 438 
 439     @DontCompile
 440     public void test26_verifier(boolean warmup) {
 441         Object[] res = (Object[])test26();
 442         Asserts.assertEQ(((MyValue1)res[0]).hashPrimitive(), MyValue1.createDefaultInline().hashPrimitive());
 443     }
 444 
 445     // Load non-flattenable value type field with unsafe
 446     MyValue1.box test27_vt = MyValue1.createWithFieldsInline(rI, rL);
 447     private static final long TEST27_OFFSET;
 448     static {
 449         try {
 450             Field field = TestIntrinsics.class.getDeclaredField("test27_vt");
 451             TEST27_OFFSET = U.objectFieldOffset(field);
 452         } catch (Exception e) {
 453             throw new RuntimeException(e);
 454         }
 455     }
 456 
 457     @Test(failOn=CALL_Unsafe)
 458     public MyValue1 test27() {
 459         return (MyValue1)U.getReference(this, TEST27_OFFSET);
 460     }
 461 
 462     @DontCompile
 463     public void test27_verifier(boolean warmup) {
 464         MyValue1 res = test27();
 465         Asserts.assertEQ(res.hash(), test24_vt.hash());
 466     }
 467 
 468     // Mismatched type
 469     @Test(failOn=CALL_Unsafe)
 470     public int test28(MyValue1 v) {
 471         return U.getByte(v, X_OFFSET);
 472     }
 473 
 474     @DontCompile
 475     public void test28_verifier(boolean warmup) {
 476         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 477         int res = test28(v);
 478         if (java.nio.ByteOrder.nativeOrder() == java.nio.ByteOrder.LITTLE_ENDIAN) {
 479             Asserts.assertEQ(res, (int)((byte)v.x));
 480         } else {
 481             Asserts.assertEQ(res, (int)((byte)Integer.reverseBytes(v.x)));
 482         }
 483     }
 484 
 485     // Wrong alignment
 486     @Test(failOn=CALL_Unsafe)
 487     public long test29(MyValue1 v) {
 488         // Read the field that's guaranteed to not be last in the
 489         // value so we don't read out of the value
 490         if (X_OFFSET < Y_OFFSET) {
 491             return U.getInt(v, X_OFFSET+1);
 492         }
 493         return U.getLong(v, Y_OFFSET+1);
 494     }
 495 
 496     @DontCompile
 497     public void test29_verifier(boolean warmup) {
 498         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 499         long res = test29(v);
 500         if (java.nio.ByteOrder.nativeOrder() == java.nio.ByteOrder.LITTLE_ENDIAN) {
 501             if (X_OFFSET < Y_OFFSET) {
 502                 Asserts.assertEQ(((int)res) << 8, (v.x >> 8) << 8);
 503             } else {
 504                 Asserts.assertEQ(res << 8, (v.y >> 8) << 8);
 505             }
 506         } else {
 507             if (X_OFFSET < Y_OFFSET) {
 508                 Asserts.assertEQ(((int)res), v.x >>> 8);
 509             } else {
 510                 Asserts.assertEQ(res, v.y >>> 8);
 511             }
 512         }
 513     }
 514 
 515     // getValue to retrieve flattened field from value
 516     @Test(failOn=CALL_Unsafe)
 517     public MyValue2 test30(MyValue1 v) {
 518         if (V1_FLATTENED) {
 519             return U.getValue(v, V1_OFFSET, MyValue2.class);
 520         }
 521         return (MyValue2)U.getReference(v, V1_OFFSET);
 522     }
 523 
 524     @DontCompile
 525     public void test30_verifier(boolean warmup) {
 526         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 527         MyValue2 res = test30(v);
 528         Asserts.assertEQ(res.hash(), v.v1.hash());
 529     }
 530 
 531     MyValue1.val test31_vt;
 532     private static final long TEST31_VT_OFFSET;
 533     private static final boolean TEST31_VT_FLATTENED;
 534     static {
 535         try {
 536             Field test31_vt_Field = TestIntrinsics.class.getDeclaredField("test31_vt");
 537             TEST31_VT_OFFSET = U.objectFieldOffset(test31_vt_Field);
 538             TEST31_VT_FLATTENED = U.isFlattened(test31_vt_Field);
 539         } catch (Exception e) {
 540             throw new RuntimeException(e);
 541         }
 542     }
 543 
 544     // getValue to retrieve flattened field from object
 545     @Test(failOn=CALL_Unsafe)
 546     public MyValue1 test31() {
 547         if (TEST31_VT_FLATTENED) {
 548             return U.getValue(this, TEST31_VT_OFFSET, MyValue1.class);
 549         }
 550         return (MyValue1)U.getReference(this, TEST31_VT_OFFSET);
 551     }
 552 
 553     @DontCompile
 554     public void test31_verifier(boolean warmup) {
 555         test31_vt = MyValue1.createWithFieldsInline(rI, rL);
 556         MyValue1 res = test31();
 557         Asserts.assertEQ(res.hash(), test31_vt.hash());
 558     }
 559 
 560     // putValue to set flattened field in object
 561     @Test(failOn=CALL_Unsafe)
 562     public void test32(MyValue1 vt) {
 563         if (TEST31_VT_FLATTENED) {
 564             U.putValue(this, TEST31_VT_OFFSET, MyValue1.class, vt);
 565         } else {
 566             U.putReference(this, TEST31_VT_OFFSET, vt);
 567         }
 568     }
 569 
 570     @DontCompile
 571     public void test32_verifier(boolean warmup) {
 572         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
 573         test31_vt = MyValue1.createDefaultInline();
 574         test32(vt);
 575         Asserts.assertEQ(vt.hash(), test31_vt.hash());
 576     }
 577 
 578     private static final int TEST33_BASE_OFFSET;
 579     private static final int TEST33_INDEX_SCALE;
 580     private static final boolean TEST33_FLATTENED_ARRAY;
 581     static {
 582         try {
 583             TEST33_BASE_OFFSET = U.arrayBaseOffset(MyValue1[].class);
 584             TEST33_INDEX_SCALE = U.arrayIndexScale(MyValue1[].class);
 585             TEST33_FLATTENED_ARRAY = U.isFlattenedArray(MyValue1[].class);
 586         } catch (Exception e) {
 587             throw new RuntimeException(e);
 588         }
 589     }
 590     // getValue to retrieve flattened field from array
 591     @Test(failOn=CALL_Unsafe)
 592     public MyValue1 test33(MyValue1[] arr) {
 593         if (TEST33_FLATTENED_ARRAY) {
 594             return U.getValue(arr, TEST33_BASE_OFFSET + TEST33_INDEX_SCALE, MyValue1.class);
 595         }
 596         return (MyValue1)U.getReference(arr, TEST33_BASE_OFFSET + TEST33_INDEX_SCALE);
 597     }
 598 
 599     @DontCompile
 600     public void test33_verifier(boolean warmup) {
 601         MyValue1[] arr = new MyValue1[2];
 602         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
 603         arr[1] = vt;
 604         MyValue1 res = test33(arr);
 605         Asserts.assertEQ(res.hash(), vt.hash());
 606     }
 607 
 608     // putValue to set flattened field in array
 609     @Test(failOn=CALL_Unsafe)
 610     public void test34(MyValue1[] arr, MyValue1 vt) {
 611         if (TEST33_FLATTENED_ARRAY) {
 612             U.putValue(arr, TEST33_BASE_OFFSET + TEST33_INDEX_SCALE, MyValue1.class, vt);
 613         } else {
 614             U.putReference(arr, TEST33_BASE_OFFSET + TEST33_INDEX_SCALE, vt);
 615         }
 616     }
 617 
 618     @DontCompile
 619     public void test34_verifier(boolean warmup) {
 620         MyValue1[] arr = new MyValue1[2];
 621         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
 622         test34(arr, vt);
 623         Asserts.assertEQ(arr[1].hash(), vt.hash());
 624     }
 625 
 626     // getValue to retrieve flattened field from object with unknown
 627     // container type
 628     @Test(failOn=CALL_Unsafe)
 629     public MyValue1 test35(Object o) {
 630         if (TEST31_VT_FLATTENED) {
 631             return U.getValue(o, TEST31_VT_OFFSET, MyValue1.class);
 632         }
 633         return (MyValue1)U.getReference(o, TEST31_VT_OFFSET);
 634     }
 635 
 636     @DontCompile
 637     public void test35_verifier(boolean warmup) {
 638         test31_vt = MyValue1.createWithFieldsInline(rI, rL);
 639         MyValue1 res = test35(this);
 640         Asserts.assertEQ(res.hash(), test31_vt.hash());
 641     }
 642 
 643     // getValue to retrieve flattened field from object at unknown
 644     // offset
 645     @Test(failOn=CALL_Unsafe)
 646     public MyValue1 test36(long offset) {
 647         if (TEST31_VT_FLATTENED) {
 648             return U.getValue(this, offset, MyValue1.class);
 649         }
 650         return (MyValue1)U.getReference(this, offset);
 651     }
 652 
 653     @DontCompile
 654     public void test36_verifier(boolean warmup) {
 655         test31_vt = MyValue1.createWithFieldsInline(rI, rL);
 656         MyValue1 res = test36(TEST31_VT_OFFSET);
 657         Asserts.assertEQ(res.hash(), test31_vt.hash());
 658     }
 659 
 660     // putValue to set flattened field in object with unknown
 661     // container
 662     @Test(failOn=CALL_Unsafe)
 663     public void test37(Object o, MyValue1 vt) {
 664         if (TEST31_VT_FLATTENED) {
 665             U.putValue(o, TEST31_VT_OFFSET, MyValue1.class, vt);
 666         } else {
 667             U.putReference(o, TEST31_VT_OFFSET, vt);
 668         }
 669     }
 670 
 671     @DontCompile
 672     public void test37_verifier(boolean warmup) {
 673         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
 674         test31_vt = MyValue1.createDefaultInline();
 675         test37(this, vt);
 676         Asserts.assertEQ(vt.hash(), test31_vt.hash());
 677     }
 678 
 679     // putValue to set flattened field in object, non value argument
 680     // to store
 681     @Test(match = { CALL_Unsafe }, matchCount = { 1 })
 682     public void test38(Object o) {
 683         if (TEST31_VT_FLATTENED) {
 684             U.putValue(this, TEST31_VT_OFFSET, MyValue1.class, o);
 685         } else {
 686             U.putReference(this, TEST31_VT_OFFSET, o);
 687         }
 688     }
 689 
 690     @DontCompile
 691     public void test38_verifier(boolean warmup) {
 692         MyValue1 vt = MyValue1.createWithFieldsInline(rI, rL);
 693         test31_vt = MyValue1.createDefaultInline();
 694         test38(vt);
 695         Asserts.assertEQ(vt.hash(), test31_vt.hash());
 696     }
 697 
 698     @Test(failOn=CALL_Unsafe)
 699     public MyValue1 test39(MyValue1 v) {
 700         v = U.makePrivateBuffer(v);
 701         U.putInt(v, X_OFFSET, rI);
 702         v = U.finishPrivateBuffer(v);
 703         return v;
 704     }
 705 
 706     @DontCompile
 707     public void test39_verifier(boolean warmup) {
 708         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 709         MyValue1 res = test39(v.setX(v, 0));
 710         Asserts.assertEQ(res.hash(), v.hash());
 711     }
 712 }