81 @Test(valid = ValueTypeArrayFlattenOff, failOn = LOAD)
82 @Test(valid = ValueTypeArrayFlattenOn)
83 public MyValue1[] test1(int len) {
84 MyValue1[] va = new MyValue1[len];
85 for (int i = 0; i < len; ++i) {
86 va[i] = MyValue1.createWithFieldsDontInline(rI, rL);
87 }
88 return va;
89 }
90
91 @DontCompile
92 public void test1_verifier(boolean warmup) {
93 int len = Math.abs(rI % 10);
94 MyValue1[] va = test1(len);
95 for (int i = 0; i < len; ++i) {
96 Asserts.assertEQ(va[i].hash(), hash());
97 }
98 }
99
100 // Test creation of a value type array and element access
101 @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + LOADP + STORE + TRAP)
102 public long test2() {
103 MyValue1[] va = new MyValue1[1];
104 va[0] = MyValue1.createWithFieldsInline(rI, rL);
105 return va[0].hash();
106 }
107
108 @DontCompile
109 public void test2_verifier(boolean warmup) {
110 long result = test2();
111 Asserts.assertEQ(result, hash());
112 }
113
114 // Test receiving a value type array from the interpreter,
115 // updating its elements in a loop and computing a hash.
116 @Test(failOn = ALLOCA)
117 public long test3(MyValue1[] va) {
118 long result = 0;
119 for (int i = 0; i < 10; ++i) {
120 result += va[i].hash();
121 va[i] = MyValue1.createWithFieldsInline(rI + 1, rL + 1);
124 }
125
126 @DontCompile
127 public void test3_verifier(boolean warmup) {
128 MyValue1[] va = new MyValue1[10];
129 long expected = 0;
130 for (int i = 0; i < 10; ++i) {
131 va[i] = MyValue1.createWithFieldsDontInline(rI + i, rL + i);
132 expected += va[i].hash();
133 }
134 long result = test3(va);
135 Asserts.assertEQ(expected, result);
136 for (int i = 0; i < 10; ++i) {
137 if (va[i].hash() != hash(rI + 1, rL + 1)) {
138 Asserts.assertEQ(va[i].hash(), hash(rI + 1, rL + 1));
139 }
140 }
141 }
142
143 // Test returning a value type array received from the interpreter
144 @Test(failOn = ALLOC + ALLOCA + LOAD + LOADP + STORE + LOOP + TRAP)
145 public MyValue1[] test4(MyValue1[] va) {
146 return va;
147 }
148
149 @DontCompile
150 public void test4_verifier(boolean warmup) {
151 MyValue1[] va = new MyValue1[10];
152 for (int i = 0; i < 10; ++i) {
153 va[i] = MyValue1.createWithFieldsDontInline(rI + i, rL + i);
154 }
155 va = test4(va);
156 for (int i = 0; i < 10; ++i) {
157 Asserts.assertEQ(va[i].hash(), hash(rI + i, rL + i));
158 }
159 }
160
161 // Merge value type arrays created from two branches
162 @Test
163 public MyValue1[] test5(boolean b) {
164 MyValue1[] va;
641 // short arraycopy() with oop fields and offsets
642 @Test
643 public void test27(MyValue1[] src, MyValue1[] dst) {
644 System.arraycopy(src, 1, dst, 2, 6);
645 }
646
647 @DontCompile
648 public void test27_verifier(boolean warmup) {
649 MyValue1[] src = new MyValue1[8];
650 MyValue1[] dst = new MyValue1[8];
651 for (int i = 0; i < 8; ++i) {
652 src[i] = MyValue1.createWithFieldsInline(rI, rL);
653 }
654 test27(src, dst);
655 for (int i = 2; i < 8; ++i) {
656 Asserts.assertEQ(src[i-1].hash(), dst[i].hash());
657 }
658 }
659
660 // non escaping allocations
661 @Test(failOn = ALLOCA + LOOP + LOAD + LOADP + TRAP)
662 public MyValue2 test28() {
663 MyValue2[] src = new MyValue2[10];
664 src[0] = MyValue2.createWithFieldsInline(rI, false);
665 MyValue2[] dst = (MyValue2[])src.clone();
666 return dst[0];
667 }
668
669 @DontCompile
670 public void test28_verifier(boolean warmup) {
671 MyValue2 v = MyValue2.createWithFieldsInline(rI, false);
672 MyValue2 result = test28();
673 Asserts.assertEQ(result.hash(), v.hash());
674 }
675
676 // non escaping allocations
677 @Test(failOn = ALLOCA + LOOP + LOAD + LOADP + TRAP)
678 public MyValue2 test29(MyValue2[] src) {
679 MyValue2[] dst = new MyValue2[10];
680 System.arraycopy(src, 0, dst, 0, 10);
681 return dst[0];
682 }
683
684 @DontCompile
685 public void test29_verifier(boolean warmup) {
686 MyValue2[] src = new MyValue2[10];
687 for (int i = 0; i < 10; ++i) {
688 src[i] = MyValue2.createWithFieldsInline(rI, (i % 2) == 0);
689 }
690 MyValue2 v = test29(src);
691 Asserts.assertEQ(src[0].hash(), v.hash());
692 }
693
694 // non escaping allocation with uncommon trap that needs
695 // eliminated value type array element as debug info
696 @Test
697 @Warmup(10000)
698 public MyValue2 test30(MyValue2[] src, boolean flag) {
699 MyValue2[] dst = new MyValue2[10];
700 System.arraycopy(src, 0, dst, 0, 10);
701 if (flag) { }
702 return dst[0];
703 }
704
705 @DontCompile
706 public void test30_verifier(boolean warmup) {
707 MyValue2[] src = new MyValue2[10];
708 for (int i = 0; i < 10; ++i) {
709 src[i] = MyValue2.createWithFieldsInline(rI, (i % 2) == 0);
710 }
711 MyValue2 v = test30(src, false);
712 Asserts.assertEQ(src[0].hash(), v.hash());
713 }
714
715 // non escaping allocation with memory phi
716 @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + LOADP + TRAP)
717 public long test31(boolean b, boolean deopt) {
718 MyValue2[] src = new MyValue2[1];
719 if (b) {
720 src[0] = MyValue2.createWithFieldsInline(rI, true);
721 } else {
722 src[0] = MyValue2.createWithFieldsInline(rI, false);
723 }
724 if (deopt) {
725 // uncommon trap
726 WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test31"));
727 }
728 return src[0].hash();
729 }
730
731 @DontCompile
732 public void test31_verifier(boolean warmup) {
733 MyValue2 v1 = MyValue2.createWithFieldsInline(rI, true);
734 long result1 = test31(true, !warmup);
735 Asserts.assertEQ(result1, v1.hash());
736 MyValue2 v2 = MyValue2.createWithFieldsInline(rI, false);
|
81 @Test(valid = ValueTypeArrayFlattenOff, failOn = LOAD)
82 @Test(valid = ValueTypeArrayFlattenOn)
83 public MyValue1[] test1(int len) {
84 MyValue1[] va = new MyValue1[len];
85 for (int i = 0; i < len; ++i) {
86 va[i] = MyValue1.createWithFieldsDontInline(rI, rL);
87 }
88 return va;
89 }
90
91 @DontCompile
92 public void test1_verifier(boolean warmup) {
93 int len = Math.abs(rI % 10);
94 MyValue1[] va = test1(len);
95 for (int i = 0; i < len; ++i) {
96 Asserts.assertEQ(va[i].hash(), hash());
97 }
98 }
99
100 // Test creation of a value type array and element access
101 @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + STORE + TRAP)
102 public long test2() {
103 MyValue1[] va = new MyValue1[1];
104 va[0] = MyValue1.createWithFieldsInline(rI, rL);
105 return va[0].hash();
106 }
107
108 @DontCompile
109 public void test2_verifier(boolean warmup) {
110 long result = test2();
111 Asserts.assertEQ(result, hash());
112 }
113
114 // Test receiving a value type array from the interpreter,
115 // updating its elements in a loop and computing a hash.
116 @Test(failOn = ALLOCA)
117 public long test3(MyValue1[] va) {
118 long result = 0;
119 for (int i = 0; i < 10; ++i) {
120 result += va[i].hash();
121 va[i] = MyValue1.createWithFieldsInline(rI + 1, rL + 1);
124 }
125
126 @DontCompile
127 public void test3_verifier(boolean warmup) {
128 MyValue1[] va = new MyValue1[10];
129 long expected = 0;
130 for (int i = 0; i < 10; ++i) {
131 va[i] = MyValue1.createWithFieldsDontInline(rI + i, rL + i);
132 expected += va[i].hash();
133 }
134 long result = test3(va);
135 Asserts.assertEQ(expected, result);
136 for (int i = 0; i < 10; ++i) {
137 if (va[i].hash() != hash(rI + 1, rL + 1)) {
138 Asserts.assertEQ(va[i].hash(), hash(rI + 1, rL + 1));
139 }
140 }
141 }
142
143 // Test returning a value type array received from the interpreter
144 @Test(failOn = ALLOC + ALLOCA + LOAD + STORE + LOOP + TRAP)
145 public MyValue1[] test4(MyValue1[] va) {
146 return va;
147 }
148
149 @DontCompile
150 public void test4_verifier(boolean warmup) {
151 MyValue1[] va = new MyValue1[10];
152 for (int i = 0; i < 10; ++i) {
153 va[i] = MyValue1.createWithFieldsDontInline(rI + i, rL + i);
154 }
155 va = test4(va);
156 for (int i = 0; i < 10; ++i) {
157 Asserts.assertEQ(va[i].hash(), hash(rI + i, rL + i));
158 }
159 }
160
161 // Merge value type arrays created from two branches
162 @Test
163 public MyValue1[] test5(boolean b) {
164 MyValue1[] va;
641 // short arraycopy() with oop fields and offsets
642 @Test
643 public void test27(MyValue1[] src, MyValue1[] dst) {
644 System.arraycopy(src, 1, dst, 2, 6);
645 }
646
647 @DontCompile
648 public void test27_verifier(boolean warmup) {
649 MyValue1[] src = new MyValue1[8];
650 MyValue1[] dst = new MyValue1[8];
651 for (int i = 0; i < 8; ++i) {
652 src[i] = MyValue1.createWithFieldsInline(rI, rL);
653 }
654 test27(src, dst);
655 for (int i = 2; i < 8; ++i) {
656 Asserts.assertEQ(src[i-1].hash(), dst[i].hash());
657 }
658 }
659
660 // non escaping allocations
661 @Test(failOn = ALLOCA + LOOP + LOAD + TRAP)
662 public MyValue2 test28() {
663 MyValue2[] src = new MyValue2[10];
664 src[0] = MyValue2.createWithFieldsInline(rI, false);
665 MyValue2[] dst = (MyValue2[])src.clone();
666 return dst[0];
667 }
668
669 @DontCompile
670 public void test28_verifier(boolean warmup) {
671 MyValue2 v = MyValue2.createWithFieldsInline(rI, false);
672 MyValue2 result = test28();
673 Asserts.assertEQ(result.hash(), v.hash());
674 }
675
676 // non escaping allocations
677 @Test(failOn = ALLOCA + LOOP + LOAD + TRAP)
678 public MyValue2 test29(MyValue2[] src) {
679 MyValue2[] dst = new MyValue2[10];
680 System.arraycopy(src, 0, dst, 0, 10);
681 return dst[0];
682 }
683
684 @DontCompile
685 public void test29_verifier(boolean warmup) {
686 MyValue2[] src = new MyValue2[10];
687 for (int i = 0; i < 10; ++i) {
688 src[i] = MyValue2.createWithFieldsInline(rI, (i % 2) == 0);
689 }
690 MyValue2 v = test29(src);
691 Asserts.assertEQ(src[0].hash(), v.hash());
692 }
693
694 // non escaping allocation with uncommon trap that needs
695 // eliminated value type array element as debug info
696 @Test
697 @Warmup(10000)
698 public MyValue2 test30(MyValue2[] src, boolean flag) {
699 MyValue2[] dst = new MyValue2[10];
700 System.arraycopy(src, 0, dst, 0, 10);
701 if (flag) { }
702 return dst[0];
703 }
704
705 @DontCompile
706 public void test30_verifier(boolean warmup) {
707 MyValue2[] src = new MyValue2[10];
708 for (int i = 0; i < 10; ++i) {
709 src[i] = MyValue2.createWithFieldsInline(rI, (i % 2) == 0);
710 }
711 MyValue2 v = test30(src, false);
712 Asserts.assertEQ(src[0].hash(), v.hash());
713 }
714
715 // non escaping allocation with memory phi
716 @Test(failOn = ALLOC + ALLOCA + LOOP + LOAD + TRAP)
717 public long test31(boolean b, boolean deopt) {
718 MyValue2[] src = new MyValue2[1];
719 if (b) {
720 src[0] = MyValue2.createWithFieldsInline(rI, true);
721 } else {
722 src[0] = MyValue2.createWithFieldsInline(rI, false);
723 }
724 if (deopt) {
725 // uncommon trap
726 WHITE_BOX.deoptimizeMethod(tests.get(getClass().getSimpleName() + "::test31"));
727 }
728 return src[0].hash();
729 }
730
731 @DontCompile
732 public void test31_verifier(boolean warmup) {
733 MyValue2 v1 = MyValue2.createWithFieldsInline(rI, true);
734 long result1 = test31(true, !warmup);
735 Asserts.assertEQ(result1, v1.hash());
736 MyValue2 v2 = MyValue2.createWithFieldsInline(rI, false);
|