149 @DontCompile 150 public void test6_verifier(boolean warmup) { 151 long result = test6(); 152 Asserts.assertEQ(result, hash()); 153 } 154 155 // Create a value type in compiled code and pass it to 156 // the interpreter by returning. 157 @Test(match = {ALLOC}, matchCount = {1}, failOn = LOAD + TRAP) 158 public MyValue1 test7(int x, long y) { 159 return MyValue1.createWithFieldsInline(x, y); 160 } 161 162 @DontCompile 163 public void test7_verifier(boolean warmup) { 164 MyValue1 v = test7(rI, rL); 165 Asserts.assertEQ(v.hash(), hash()); 166 } 167 168 // Merge value types created from two branches 169 // TODO fix this once we can distinguish between nullable and non-nullable value types 170 // @Test(failOn = ALLOC + STORE + TRAP) 171 @Test() 172 public long test8(boolean b) { 173 MyValue1 v; 174 if (b) { 175 v = MyValue1.createWithFieldsInline(rI, rL); 176 } else { 177 v = MyValue1.createWithFieldsDontInline(rI + 1, rL + 1); 178 } 179 return v.hash(); 180 } 181 182 @DontCompile 183 public void test8_verifier(boolean warmup) { 184 Asserts.assertEQ(test8(true), hash()); 185 Asserts.assertEQ(test8(false), hash(rI + 1, rL + 1)); 186 } 187 188 // Merge value types created from two branches 189 @Test(valid = ValueTypePassFieldsAsArgsOn, match = {LOAD}, matchCount = {10}, failOn = TRAP + ALLOC + STORE) 190 @Test(valid = ValueTypePassFieldsAsArgsOff, match = {ALLOC, STORE}, matchCount = {1, 5}, failOn = LOAD + TRAP) 191 public MyValue1 test9(boolean b) { 612 @Test(failOn = ALLOC + ALLOCA + STORE) 613 public MyValue3 test30(MyValue3[] va) { 614 // C2 can re-use the oop of staticVal3 because staticVal3 is equal to copy 615 MyValue3 copy = MyValue3.copy(staticVal3); 616 va[0] = copy; 617 staticVal3 = copy; 618 copy.verify(staticVal3); 619 return copy; 620 } 621 622 @DontCompile 623 public void test30_verifier(boolean warmup) { 624 staticVal3 = MyValue3.create(); 625 MyValue3[] va = new MyValue3[1]; 626 MyValue3 vt = test30(va); 627 staticVal3.verify(vt); 628 staticVal3.verify(va[0]); 629 } 630 631 // Verify that C2 recognizes value type loads and re-uses the oop to avoid allocations 632 @Test(valid = ValueTypeReturnedAsFieldsOff, failOn = ALLOC + ALLOCA + STORE) 633 @Test(valid = ValueTypeReturnedAsFieldsOn) 634 public MyValue3 test31(MyValue3[] va) { 635 // C2 can re-use the oop returned by createDontInline() 636 // because the corresponding value type is equal to 'copy'. 637 MyValue3 copy = MyValue3.copy(MyValue3.createDontInline()); 638 va[0] = copy; 639 staticVal3 = copy; 640 copy.verify(staticVal3); 641 return copy; 642 } 643 644 @DontCompile 645 public void test31_verifier(boolean warmup) { 646 MyValue3[] va = new MyValue3[1]; 647 MyValue3 vt = test31(va); 648 staticVal3.verify(vt); 649 staticVal3.verify(va[0]); 650 } 651 652 // Verify that C2 recognizes value type loads and re-uses the oop to avoid allocations 653 @Test(valid = ValueTypePassFieldsAsArgsOff, failOn = ALLOC + ALLOCA + STORE) 654 @Test(valid = ValueTypePassFieldsAsArgsOn) 655 public MyValue3 test32(MyValue3 vt, MyValue3[] va) { 656 // C2 can re-use the oop of vt because vt is equal to 'copy'. 657 MyValue3 copy = MyValue3.copy(vt); 658 va[0] = copy; 659 staticVal3 = copy; 660 copy.verify(staticVal3); 661 return copy; 662 } 663 664 @DontCompile 665 public void test32_verifier(boolean warmup) { 666 MyValue3 vt = MyValue3.create(); 667 MyValue3[] va = new MyValue3[1]; 668 MyValue3 result = test32(vt, va); 669 staticVal3.verify(vt); 670 va[0].verify(vt); 671 result.verify(vt); 672 } 673 674 // Test correct identification of value type copies | 149 @DontCompile 150 public void test6_verifier(boolean warmup) { 151 long result = test6(); 152 Asserts.assertEQ(result, hash()); 153 } 154 155 // Create a value type in compiled code and pass it to 156 // the interpreter by returning. 157 @Test(match = {ALLOC}, matchCount = {1}, failOn = LOAD + TRAP) 158 public MyValue1 test7(int x, long y) { 159 return MyValue1.createWithFieldsInline(x, y); 160 } 161 162 @DontCompile 163 public void test7_verifier(boolean warmup) { 164 MyValue1 v = test7(rI, rL); 165 Asserts.assertEQ(v.hash(), hash()); 166 } 167 168 // Merge value types created from two branches 169 @Test(valid = AlwaysIncrementalInlineOn, match = {ALLOC, STORE, LOAD}, matchCount = {1, 5, 12}, failOn = TRAP) 170 @Test(valid = AlwaysIncrementalInlineOff, failOn = ALLOC + STORE + TRAP) 171 public long test8(boolean b) { 172 MyValue1 v; 173 if (b) { 174 v = MyValue1.createWithFieldsInline(rI, rL); 175 } else { 176 v = MyValue1.createWithFieldsDontInline(rI + 1, rL + 1); 177 } 178 return v.hash(); 179 } 180 181 @DontCompile 182 public void test8_verifier(boolean warmup) { 183 Asserts.assertEQ(test8(true), hash()); 184 Asserts.assertEQ(test8(false), hash(rI + 1, rL + 1)); 185 } 186 187 // Merge value types created from two branches 188 @Test(valid = ValueTypePassFieldsAsArgsOn, match = {LOAD}, matchCount = {10}, failOn = TRAP + ALLOC + STORE) 189 @Test(valid = ValueTypePassFieldsAsArgsOff, match = {ALLOC, STORE}, matchCount = {1, 5}, failOn = LOAD + TRAP) 190 public MyValue1 test9(boolean b) { 611 @Test(failOn = ALLOC + ALLOCA + STORE) 612 public MyValue3 test30(MyValue3[] va) { 613 // C2 can re-use the oop of staticVal3 because staticVal3 is equal to copy 614 MyValue3 copy = MyValue3.copy(staticVal3); 615 va[0] = copy; 616 staticVal3 = copy; 617 copy.verify(staticVal3); 618 return copy; 619 } 620 621 @DontCompile 622 public void test30_verifier(boolean warmup) { 623 staticVal3 = MyValue3.create(); 624 MyValue3[] va = new MyValue3[1]; 625 MyValue3 vt = test30(va); 626 staticVal3.verify(vt); 627 staticVal3.verify(va[0]); 628 } 629 630 // Verify that C2 recognizes value type loads and re-uses the oop to avoid allocations 631 @Test(valid = ValueTypeReturnedAsFieldsOn) 632 @Test(valid = ValueTypeReturnedAsFieldsOff, failOn = ALLOC + ALLOCA + STORE) 633 public MyValue3 test31(MyValue3[] va) { 634 // C2 can re-use the oop returned by createDontInline() 635 // because the corresponding value type is equal to 'copy'. 636 MyValue3 copy = MyValue3.copy(MyValue3.createDontInline()); 637 va[0] = copy; 638 staticVal3 = copy; 639 copy.verify(staticVal3); 640 return copy; 641 } 642 643 @DontCompile 644 public void test31_verifier(boolean warmup) { 645 MyValue3[] va = new MyValue3[1]; 646 MyValue3 vt = test31(va); 647 staticVal3.verify(vt); 648 staticVal3.verify(va[0]); 649 } 650 651 // Verify that C2 recognizes value type loads and re-uses the oop to avoid allocations 652 @Test(valid = ValueTypePassFieldsAsArgsOn) 653 @Test(valid = ValueTypePassFieldsAsArgsOff, failOn = ALLOC + ALLOCA + STORE) 654 public MyValue3 test32(MyValue3 vt, MyValue3[] va) { 655 // C2 can re-use the oop of vt because vt is equal to 'copy'. 656 MyValue3 copy = MyValue3.copy(vt); 657 va[0] = copy; 658 staticVal3 = copy; 659 copy.verify(staticVal3); 660 return copy; 661 } 662 663 @DontCompile 664 public void test32_verifier(boolean warmup) { 665 MyValue3 vt = MyValue3.create(); 666 MyValue3[] va = new MyValue3[1]; 667 MyValue3 result = test32(vt, va); 668 staticVal3.verify(vt); 669 va[0].verify(vt); 670 result.verify(vt); 671 } 672 673 // Test correct identification of value type copies |