85 // before the first field write.
86 TestFramework.runWithFlags("-XX:+UseG1GC");
87 }
88
89 @Run(test = "testScalarReplacementWithGCBarrier")
90 private void runner() {
91 List list = new List();
92 for (int i = 0; i < SIZE; i++) {
93 list.push(i);
94 }
95 testScalarReplacementWithGCBarrier(list);
96 }
97
98 // Allocation of `Iter iter` should be eliminated by scalar replacement, and
99 // the allocation of `Integer sum` can not be eliminated, so there should be
100 // 1 allocation after allocations and locks elimination.
101 //
102 // Before the patch of JDK-8333334, both allocations of `Iter` and `Integer`
103 // could not be eliminated.
104 @Test
105 @IR(phase = { CompilePhase.AFTER_PARSING }, counts = { IRNode.ALLOC, "1" })
106 @IR(phase = { CompilePhase.INCREMENTAL_BOXING_INLINE }, counts = { IRNode.ALLOC, "2" })
107 @IR(phase = { CompilePhase.ITER_GVN_AFTER_ELIMINATION }, counts = { IRNode.ALLOC, "1" })
108 private int testScalarReplacementWithGCBarrier(List list) {
109 Iter iter = list.iter();
110 while (true) {
111 while (iter.next()) {}
112 if (list.head == null) break;
113 list.head = list.head.next;
114 iter.n = list.head;
115 }
116 return iter.sum;
117 }
118 }
|
85 // before the first field write.
86 TestFramework.runWithFlags("-XX:+UseG1GC");
87 }
88
89 @Run(test = "testScalarReplacementWithGCBarrier")
90 private void runner() {
91 List list = new List();
92 for (int i = 0; i < SIZE; i++) {
93 list.push(i);
94 }
95 testScalarReplacementWithGCBarrier(list);
96 }
97
98 // Allocation of `Iter iter` should be eliminated by scalar replacement, and
99 // the allocation of `Integer sum` can not be eliminated, so there should be
100 // 1 allocation after allocations and locks elimination.
101 //
102 // Before the patch of JDK-8333334, both allocations of `Iter` and `Integer`
103 // could not be eliminated.
104 @Test
105 @IR(phase = { CompilePhase.PHASEIDEAL_BEFORE_EA }, counts = { IRNode.ALLOC, "2" })
106 @IR(phase = { CompilePhase.ITER_GVN_AFTER_ELIMINATION }, counts = { IRNode.ALLOC, "1" })
107 private int testScalarReplacementWithGCBarrier(List list) {
108 Iter iter = list.iter();
109 while (true) {
110 while (iter.next()) {}
111 if (list.head == null) break;
112 list.head = list.head.next;
113 iter.n = list.head;
114 }
115 return iter.sum;
116 }
117 }
|