annotate test/compiler/types/TypeSpeculation.java @ 17735:8f28240318a2

8032633: Enable type speculation by default Summary: enable type speculation Reviewed-by: kvn
author roland
date Thu, 06 Mar 2014 11:11:04 +0100
parents 29463147336b
children 92aa6797d639 52b4284cb496
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
12966
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
1 /*
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved.
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
4 *
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
5 * This code is free software; you can redistribute it and/or modify it
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
6 * under the terms of the GNU General Public License version 2 only, as
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
7 * published by the Free Software Foundation.
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
8 *
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
9 * This code is distributed in the hope that it will be useful, but WITHOUT
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
12 * version 2 for more details (a copy is included in the LICENSE file that
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
13 * accompanied this code).
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
14 *
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
15 * You should have received a copy of the GNU General Public License version
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
16 * 2 along with this work; if not, write to the Free Software Foundation,
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
18 *
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
20 * or visit www.oracle.com if you need additional information or have any
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
21 * questions.
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
22 */
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
23
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
24 /*
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
25 * @test
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
26 * @bug 8024070
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
27 * @summary Test that type speculation doesn't cause incorrect execution
17735
8f28240318a2 8032633: Enable type speculation by default
roland
parents: 17617
diff changeset
28 * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:TypeProfileLevel=222 -XX:+UseTypeSpeculation TypeSpeculation
12966
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
29 *
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
30 */
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
31
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
32 public class TypeSpeculation {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
33
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
34 interface I {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
35 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
36
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
37 static class A {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
38 int m() {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
39 return 1;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
40 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
41 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
42
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
43 static class B extends A implements I {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
44 int m() {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
45 return 2;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
46 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
47 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
48
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
49 static class C extends B {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
50 int m() {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
51 return 3;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
52 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
53 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
54
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
55 static int test1_invokevirtual(A a) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
56 return a.m();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
57 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
58
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
59 static int test1_1(A a) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
60 return test1_invokevirtual(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
61 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
62
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
63 static boolean test1() {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
64 A a = new A();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
65 B b = new B();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
66 C c = new C();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
67
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
68 // pollute profile at test1_invokevirtual to make sure the
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
69 // compiler cannot rely on it
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
70 for (int i = 0; i < 5000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
71 test1_invokevirtual(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
72 test1_invokevirtual(b);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
73 test1_invokevirtual(c);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
74 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
75
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
76 // profiling + speculation should make test1_invokevirtual
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
77 // inline A.m() with a guard
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
78 for (int i = 0; i < 20000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
79 int res = test1_1(b);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
80 if (res != b.m()) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
81 System.out.println("test1 failed with class B");
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
82 return false;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
83 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
84 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
85 // check that the guard works as expected by passing a
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
86 // different type
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
87 int res = test1_1(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
88 if (res != a.m()) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
89 System.out.println("test1 failed with class A");
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
90 return false;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
91 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
92 return true;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
93 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
94
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
95 static int test2_invokevirtual(A a) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
96 return a.m();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
97 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
98
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
99 static int test2_1(A a, boolean t) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
100 A aa;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
101 if (t) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
102 aa = (B)a;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
103 } else {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
104 aa = a;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
105 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
106 // if a of type B is passed to test2_1, the static type of aa
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
107 // here is no better than A but the profiled type is B so this
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
108 // should inline
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
109 return test2_invokevirtual(aa);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
110 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
111
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
112 static boolean test2() {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
113 A a = new A();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
114 B b = new B();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
115 C c = new C();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
116
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
117 // pollute profile at test2_invokevirtual to make sure the
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
118 // compiler cannot rely on it
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
119 for (int i = 0; i < 5000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
120 test2_invokevirtual(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
121 test2_invokevirtual(b);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
122 test2_invokevirtual(c);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
123 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
124
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
125 // profiling + speculation should make test2_invokevirtual
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
126 // inline A.m() with a guard
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
127 for (int i = 0; i < 20000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
128 int res = test2_1(b, (i % 2) == 0);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
129 if (res != b.m()) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
130 System.out.println("test2 failed with class B");
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
131 return false;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
132 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
133 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
134 // check that the guard works as expected by passing a
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
135 // different type
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
136 int res = test2_1(a, false);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
137 if (res != a.m()) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
138 System.out.println("test2 failed with class A");
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
139 return false;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
140 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
141 return true;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
142 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
143
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
144 static int test3_invokevirtual(A a) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
145 return a.m();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
146 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
147
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
148 static void test3_2(A a) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
149 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
150
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
151 static int test3_1(A a, int i) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
152 if (i == 0) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
153 return 0;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
154 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
155 // If we come here and a is of type B but parameter profiling
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
156 // is polluted, both branches of the if below should have
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
157 // profiling that tell us and inlining of the virtual call
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
158 // should happen
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
159 if (i == 1) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
160 test3_2(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
161 } else {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
162 test3_2(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
163 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
164 return test3_invokevirtual(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
165 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
166
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
167 static boolean test3() {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
168 A a = new A();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
169 B b = new B();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
170 C c = new C();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
171
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
172 // pollute profile at test3_invokevirtual and test3_1 to make
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
173 // sure the compiler cannot rely on it
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
174 for (int i = 0; i < 3000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
175 test3_invokevirtual(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
176 test3_invokevirtual(b);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
177 test3_invokevirtual(c);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
178 test3_1(a, 0);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
179 test3_1(b, 0);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
180 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
181
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
182 // profiling + speculation should make test3_invokevirtual
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
183 // inline A.m() with a guard
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
184 for (int i = 0; i < 20000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
185 int res = test3_1(b, (i % 2) + 1);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
186 if (res != b.m()) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
187 System.out.println("test3 failed with class B");
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
188 return false;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
189 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
190 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
191 // check that the guard works as expected by passing a
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
192 // different type
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
193 int res = test3_1(a, 1);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
194 if (res != a.m()) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
195 System.out.println("test3 failed with class A");
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
196 return false;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
197 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
198 return true;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
199 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
200
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
201 // Mix 2 incompatible profiled types
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
202 static int test4_invokevirtual(A a) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
203 return a.m();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
204 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
205
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
206 static void test4_2(A a) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
207 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
208
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
209 static int test4_1(A a, boolean b) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
210 if (b) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
211 test4_2(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
212 } else {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
213 test4_2(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
214 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
215 // shouldn't inline
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
216 return test4_invokevirtual(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
217 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
218
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
219 static boolean test4() {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
220 A a = new A();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
221 B b = new B();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
222 C c = new C();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
223
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
224 // pollute profile at test3_invokevirtual and test3_1 to make
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
225 // sure the compiler cannot rely on it
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
226 for (int i = 0; i < 3000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
227 test4_invokevirtual(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
228 test4_invokevirtual(b);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
229 test4_invokevirtual(c);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
230 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
231
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
232 for (int i = 0; i < 20000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
233 if ((i % 2) == 0) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
234 int res = test4_1(a, true);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
235 if (res != a.m()) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
236 System.out.println("test4 failed with class A");
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
237 return false;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
238 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
239 } else {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
240 int res = test4_1(b, false);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
241 if (res != b.m()) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
242 System.out.println("test4 failed with class B");
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
243 return false;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
244 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
245 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
246 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
247 return true;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
248 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
249
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
250 // Mix one profiled type with an incompatible type
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
251 static int test5_invokevirtual(A a) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
252 return a.m();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
253 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
254
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
255 static void test5_2(A a) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
256 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
257
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
258 static int test5_1(A a, boolean b) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
259 if (b) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
260 test5_2(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
261 } else {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
262 A aa = (B)a;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
263 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
264 // shouldn't inline
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
265 return test5_invokevirtual(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
266 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
267
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
268 static boolean test5() {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
269 A a = new A();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
270 B b = new B();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
271 C c = new C();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
272
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
273 // pollute profile at test3_invokevirtual and test3_1 to make
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
274 // sure the compiler cannot rely on it
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
275 for (int i = 0; i < 3000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
276 test5_invokevirtual(a);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
277 test5_invokevirtual(b);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
278 test5_invokevirtual(c);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
279 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
280
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
281 for (int i = 0; i < 20000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
282 if ((i % 2) == 0) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
283 int res = test5_1(a, true);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
284 if (res != a.m()) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
285 System.out.println("test5 failed with class A");
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
286 return false;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
287 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
288 } else {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
289 int res = test5_1(b, false);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
290 if (res != b.m()) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
291 System.out.println("test5 failed with class B");
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
292 return false;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
293 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
294 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
295 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
296 return true;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
297 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
298
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
299 // Mix incompatible profiled types
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
300 static void test6_2(Object o) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
301 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
302
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
303 static Object test6_1(Object o, boolean b) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
304 if (b) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
305 test6_2(o);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
306 } else {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
307 test6_2(o);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
308 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
309 return o;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
310 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
311
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
312 static boolean test6() {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
313 A a = new A();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
314 A[] aa = new A[10];
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
315
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
316 for (int i = 0; i < 20000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
317 if ((i % 2) == 0) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
318 test6_1(a, true);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
319 } else {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
320 test6_1(aa, false);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
321 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
322 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
323 return true;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
324 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
325
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
326 // Mix a profiled type with an incompatible type
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
327 static void test7_2(Object o) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
328 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
329
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
330 static Object test7_1(Object o, boolean b) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
331 if (b) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
332 test7_2(o);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
333 } else {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
334 Object oo = (A[])o;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
335 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
336 return o;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
337 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
338
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
339 static boolean test7() {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
340 A a = new A();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
341 A[] aa = new A[10];
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
342
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
343 for (int i = 0; i < 20000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
344 if ((i % 2) == 0) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
345 test7_1(a, true);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
346 } else {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
347 test7_1(aa, false);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
348 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
349 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
350 return true;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
351 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
352
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
353 // Mix a profiled type with an interface
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
354 static void test8_2(Object o) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
355 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
356
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
357 static I test8_1(Object o) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
358 test8_2(o);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
359 return (I)o;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
360 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
361
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
362 static boolean test8() {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
363 A a = new A();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
364 B b = new B();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
365 C c = new C();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
366
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
367 for (int i = 0; i < 20000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
368 test8_1(b);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
369 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
370 return true;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
371 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
372
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
373 // Mix a profiled type with a constant
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
374 static void test9_2(Object o) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
375 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
376
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
377 static Object test9_1(Object o, boolean b) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
378 Object oo;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
379 if (b) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
380 test9_2(o);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
381 oo = o;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
382 } else {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
383 oo = "some string";
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
384 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
385 return oo;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
386 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
387
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
388 static boolean test9() {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
389 A a = new A();
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
390
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
391 for (int i = 0; i < 20000; i++) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
392 if ((i % 2) == 0) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
393 test9_1(a, true);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
394 } else {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
395 test9_1(a, false);
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
396 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
397 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
398 return true;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
399 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
400
17617
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
401 // java/lang/Object:AnyNull:exact *,iid=top
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
402 // meets
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
403 // stable:bottom[int:max..0]:NotNull *
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
404 static void test10_4(Object o) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
405 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
406
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
407 static void test10_3(Object o, boolean b) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
408 if (b) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
409 test10_4(o);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
410 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
411 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
412
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
413 static void test10_2(Object o, boolean b1, boolean b2) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
414 if (b1) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
415 test10_3(o, b2);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
416 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
417 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
418
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
419 static void test10_1(B[] b, boolean b1, boolean b2) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
420 test10_2(b, b1, b2);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
421 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
422
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
423 static boolean test10() {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
424 Object o = new Object();
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
425 A[] a = new A[10];
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
426 B[] b = new B[10];
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
427 B[] c = new C[10];
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
428 for (int i = 0; i < 20000; i++) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
429 test10_1(b, false, false);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
430 test10_1(c, false, false);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
431 test10_2(a, true, false);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
432 test10_3(o, true);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
433 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
434 return true;
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
435 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
436
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
437 // stable:TypeSpeculation$B:TopPTR *,iid=top[int:max..0]:TopPTR *,iid=top
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
438 // meets
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
439 // java/lang/Object:AnyNull:exact *,iid=top
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
440 static void test11_3(Object o) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
441 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
442
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
443 static void test11_2(Object o, boolean b) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
444 if (b) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
445 test11_3(o);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
446 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
447 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
448
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
449 static void test11_1(B[] b, boolean bb) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
450 test11_2(b, bb);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
451 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
452
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
453 static boolean test11() {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
454 Object o = new Object();
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
455 B[] b = new B[10];
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
456 B[] c = new C[10];
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
457 for (int i = 0; i < 20000; i++) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
458 test11_1(b, false);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
459 test11_1(c, false);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
460 test11_2(o, true);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
461 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
462 return true;
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
463 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
464
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
465 // TypeSpeculation$I *
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
466 // meets
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
467 // java/lang/Object:AnyNull *,iid=top
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
468 static void test12_3(Object o) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
469 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
470
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
471 static void test12_2(Object o, boolean b) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
472 if (b) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
473 test12_3(o);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
474 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
475 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
476
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
477 static void test12_1(I i, boolean b) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
478 test12_2(i, b);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
479 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
480
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
481 static boolean test12() {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
482 Object o = new Object();
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
483 B b = new B();
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
484 C c = new C();
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
485 for (int i = 0; i < 20000; i++) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
486 test12_1(b, false);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
487 test12_1(c, false);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
488 test12_2(o, true);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
489 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
490 return true;
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
491 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
492
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
493 // stable:bottom[int:max..0]:NotNull *
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
494 // meets
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
495 // stable:TypeSpeculation$A:TopPTR *,iid=top[int:max..0]:AnyNull:exact *,iid=top
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
496 static Object test13_3(Object o, boolean b) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
497 Object oo;
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
498 if (b) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
499 oo = o;
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
500 } else {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
501 oo = new A[10];
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
502 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
503 return oo;
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
504 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
505
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
506 static void test13_2(Object o, boolean b1, boolean b2) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
507 if (b1) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
508 test13_3(o, b2);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
509 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
510 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
511
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
512 static void test13_1(B[] b, boolean b1, boolean b2) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
513 test13_2(b, b1, b2);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
514 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
515
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
516 static boolean test13() {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
517 A[] a = new A[10];
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
518 B[] b = new B[10];
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
519 B[] c = new C[10];
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
520 for (int i = 0; i < 20000; i++) {
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
521 test13_1(b, false, false);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
522 test13_1(c, false, false);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
523 test13_2(a, true, (i%2) == 0);
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
524 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
525 return true;
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
526 }
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
527
12966
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
528 static public void main(String[] args) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
529 boolean success = true;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
530
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
531 success = test1() && success;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
532
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
533 success = test2() && success;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
534
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
535 success = test3() && success;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
536
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
537 success = test4() && success;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
538
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
539 success = test5() && success;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
540
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
541 success = test6() && success;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
542
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
543 success = test7() && success;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
544
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
545 success = test8() && success;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
546
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
547 success = test9() && success;
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
548
17617
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
549 success = test10() && success;
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
550
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
551 success = test11() && success;
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
552
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
553 success = test12() && success;
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
554
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
555 success = test13() && success;
29463147336b 8028536: Test cases to cover type system fixes pushed with 8024070
roland
parents: 12966
diff changeset
556
12966
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
557 if (success) {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
558 System.out.println("TEST PASSED");
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
559 } else {
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
560 throw new RuntimeException("TEST FAILED: erroneous bound check elimination");
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
561 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
562 }
b2ee5dc63353 8024070: C2 needs some form of type speculation
roland
parents:
diff changeset
563 }