< prev index next >

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

Print this page




 410         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 411         return sumValue(v, v);
 412     }
 413 
 414     @DontCompile
 415     public long sumValue(MyValue1 v, MyValue1 dummy) {
 416         return v.hash();
 417     }
 418 
 419     @DontCompile
 420     public void test19_verifier(boolean warmup) {
 421         long result = test19();
 422         Asserts.assertEQ(result, hash());
 423     }
 424 
 425     // Create a value type (array) in compiled code and pass it to the
 426     // interpreter via a call. The value type is live at the uncommon
 427     // trap: verify that deoptimization causes the value type to be
 428     // correctly allocated.
 429     @Test(valid = ValueTypePassFieldsAsArgsOn, failOn = LOAD + ALLOC + STORE)
 430     @Test(valid = ValueTypePassFieldsAsArgsOff, match = {ALLOC}, matchCount = {2}, failOn = LOAD)
 431     public long test20(boolean deopt) {
 432         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 433         MyValue2[] va = new MyValue2[3];
 434         if (deopt) {
 435             // uncommon trap
 436             WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test20"));
 437         }
 438         return v.hashInterpreted() + va[0].hashInterpreted() +
 439                 va[1].hashInterpreted() + va[2].hashInterpreted();
 440     }
 441 
 442     @DontCompile
 443     public void test20_verifier(boolean warmup) {
 444         MyValue2[] va = new MyValue2[42];
 445         long result = test20(!warmup);
 446         Asserts.assertEQ(result, hash() + va[0].hash() + va[1].hash() + va[2].hash());
 447     }
 448 
 449     // Value type fields in regular object
 450     MyValue1 val1;


 711 
 712     // Test __Value in the method signature
 713     @DontInline
 714     public __Value test34_callee(__Value vt) {
 715         return vt;
 716     }
 717 
 718     @Test()
 719     public __Value test34(boolean b, __Value vt) throws Throwable {
 720         if (b) {
 721             return test34_callee(vt);
 722         } else {
 723             return MyValue1.createWithFieldsInline(rI + 1, rL + 1);
 724         }
 725     }
 726 
 727     @DontCompile
 728     public void test34_verifier(boolean warmup) throws Throwable {
 729         test34(true, MyValue1.createWithFieldsInline(rI, rL));
 730         test34(false, MyValue1.createWithFieldsInline(rI, rL));

































































 731     }
 732 }


 410         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 411         return sumValue(v, v);
 412     }
 413 
 414     @DontCompile
 415     public long sumValue(MyValue1 v, MyValue1 dummy) {
 416         return v.hash();
 417     }
 418 
 419     @DontCompile
 420     public void test19_verifier(boolean warmup) {
 421         long result = test19();
 422         Asserts.assertEQ(result, hash());
 423     }
 424 
 425     // Create a value type (array) in compiled code and pass it to the
 426     // interpreter via a call. The value type is live at the uncommon
 427     // trap: verify that deoptimization causes the value type to be
 428     // correctly allocated.
 429     @Test(valid = ValueTypePassFieldsAsArgsOn, failOn = LOAD + ALLOC + STORE)
 430     @Test(valid = ValueTypePassFieldsAsArgsOff, match = {ALLOC}, matchCount = {1}, failOn = LOAD)
 431     public long test20(boolean deopt) {
 432         MyValue1 v = MyValue1.createWithFieldsInline(rI, rL);
 433         MyValue2[] va = new MyValue2[3];
 434         if (deopt) {
 435             // uncommon trap
 436             WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test20"));
 437         }
 438         return v.hashInterpreted() + va[0].hashInterpreted() +
 439                 va[1].hashInterpreted() + va[2].hashInterpreted();
 440     }
 441 
 442     @DontCompile
 443     public void test20_verifier(boolean warmup) {
 444         MyValue2[] va = new MyValue2[42];
 445         long result = test20(!warmup);
 446         Asserts.assertEQ(result, hash() + va[0].hash() + va[1].hash() + va[2].hash());
 447     }
 448 
 449     // Value type fields in regular object
 450     MyValue1 val1;


 711 
 712     // Test __Value in the method signature
 713     @DontInline
 714     public __Value test34_callee(__Value vt) {
 715         return vt;
 716     }
 717 
 718     @Test()
 719     public __Value test34(boolean b, __Value vt) throws Throwable {
 720         if (b) {
 721             return test34_callee(vt);
 722         } else {
 723             return MyValue1.createWithFieldsInline(rI + 1, rL + 1);
 724         }
 725     }
 726 
 727     @DontCompile
 728     public void test34_verifier(boolean warmup) throws Throwable {
 729         test34(true, MyValue1.createWithFieldsInline(rI, rL));
 730         test34(false, MyValue1.createWithFieldsInline(rI, rL));
 731     }
 732 
 733     // Verify that the default value type is never allocated.
 734     // C2 code should load and use the default oop from the java mirror.
 735     @Test(failOn = ALLOC + ALLOCA + LOAD + STORE + LOOP + TRAP)
 736     public MyValue3 test35(MyValue3[] va) {
 737         // Explicitly create default value
 738         MyValue3 vt = MyValue3.createDefault();
 739         va[0] = vt;
 740         staticVal3 = vt;
 741         vt.verify(vt);
 742 
 743         // Load default value from uninitialized value array
 744         MyValue3[] dva = new MyValue3[1];
 745         staticVal3_copy = dva[0];
 746         va[1] = dva[0];
 747         dva[0].verify(dva[0]);
 748         return vt;
 749     }
 750 
 751     @DontCompile
 752     public void test35_verifier(boolean warmup) {
 753         MyValue3 vt = MyValue3.createDefault();
 754         MyValue3[] va = new MyValue3[2];
 755         va[0] = MyValue3.create();
 756         va[1] = MyValue3.create();
 757         MyValue3 res = test35(va);
 758         res.verify(vt);
 759         staticVal3.verify(vt);
 760         staticVal3_copy.verify(vt);
 761         va[0].verify(vt);
 762         va[1].verify(vt);
 763     }
 764 
 765     // Same as above but manually initialize value type fields to default.
 766     @Test(failOn = ALLOC + ALLOCA + LOAD + STORE + LOOP + TRAP)
 767     public MyValue3 test36(MyValue3 vt, MyValue3[] va) {
 768         vt = MyValue3.setC(vt, (char)0);
 769         vt = MyValue3.setBB(vt, (byte)0);
 770         vt = MyValue3.setS(vt, (short)0);
 771         vt = MyValue3.setI(vt, 0);
 772         vt = MyValue3.setL(vt, 0);
 773         vt = MyValue3.setO(vt, null);
 774         vt = MyValue3.setF1(vt, 0);
 775         vt = MyValue3.setF2(vt, 0);
 776         vt = MyValue3.setF3(vt, 0);
 777         vt = MyValue3.setF4(vt, 0);
 778         vt = MyValue3.setF5(vt, 0);
 779         vt = MyValue3.setF6(vt, 0);
 780         vt = MyValue3.setV1(vt, MyValue3Inline.createDefault());
 781         va[0] = vt;
 782         staticVal3 = vt;
 783         vt.verify(vt);
 784         return vt;
 785     }
 786 
 787     @DontCompile
 788     public void test36_verifier(boolean warmup) {
 789         MyValue3 vt = MyValue3.createDefault();
 790         MyValue3[] va = new MyValue3[1];
 791         va[0] = MyValue3.create();
 792         MyValue3 res = test36(va[0], va);
 793         res.verify(vt);
 794         staticVal3.verify(vt);
 795         va[0].verify(vt);
 796     }
 797 }
< prev index next >