6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package compiler.valhalla.valuetypes;
25
26 import jdk.test.lib.Asserts;
27
28 /*
29 * @test
30 * @summary Test calls from {C1} to {C2, Interpreter}, and vice versa.
31 * @library /testlibrary /test/lib /compiler/whitebox /
32 * @requires os.simpleArch == "x64"
33 * @compile TestCallingConventionC1.java
34 * @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform
35 * @run main/othervm/timeout=120 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
36 * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI -XX:+EnableValhalla
37 * compiler.valhalla.valuetypes.ValueTypeTest
38 * compiler.valhalla.valuetypes.TestCallingConventionC1
39 */
40 public class TestCallingConventionC1 extends ValueTypeTest {
41 public static final int C1 = COMP_LEVEL_SIMPLE;
42 public static final int C2 = COMP_LEVEL_FULL_OPTIMIZATION;
43
44 @Override
45 public int getNumScenarios() {
46 return 2;
47 }
48
49 @Override
50 public String[] getVMParameters(int scenario) {
51 switch (scenario) {
52
53 // Default: both C1 and C2 are enabled, tierd compilation enabled
54 case 0: return new String[] {"-XX:+EnableValhallaC1", "-XX:CICompilerCount=2"
55 , "-XX:-CheckCompressedOops", "-XX:CompileCommand=print,*::test52_helper"
56 //, "-XX:CompileCommand=print,*::func_c1"
57 };
58 // Only C1. Tierd compilation disabled.
59 case 1: return new String[] {"-XX:+EnableValhallaC1", "-XX:TieredStopAtLevel=1"
60 , "-XX:-CheckCompressedOops", "-XX:CompileCommand=print,*::test32*"
61 };
62 }
63 return null;
64 }
65
66 public static void main(String[] args) throws Throwable {
67 TestCallingConventionC1 test = new TestCallingConventionC1();
68 test.run(args,
69 Point.class,
70 Functor.class,
71 Functor1.class,
72 Functor2.class,
73 Functor3.class,
74 Functor4.class,
75 MyImplPojo1.class,
76 MyImplPojo2.class,
77 MyImplVal.class,
78 FixedPoints.class,
79 FloatPoint.class);
80 }
81
82 static inline class Point {
83 final int x;
84 final int y;
85 public Point(int x, int y) {
86 this.x = x;
87 this.y = y;
88 }
89
90 @DontCompile
91 @DontInline
92 public int func() {
93 return x + y;
94 }
95
96 @ForceCompile(compLevel = C1)
97 @DontInline
98 public int func_c1(Point p) {
99 return x + y + p.x + p.y;
243 f2 = 2.2f;
244 f3 = 3.3f;
245 f4 = 4.4f;
246 f5 = 5.5f;
247 f6 = 6.6f;
248 f7 = 7.7f;
249 f8 = 8.8f;
250 }
251 }
252 static EightFloats eightFloatsField = new EightFloats();
253
254 static class Number {
255 int n;
256 Number(int v) {
257 n = v;
258 }
259 void set(int v) {
260 n = v;
261 }
262 }
263 static inline class RefPoint {
264 final Number x;
265 final Number y;
266 public RefPoint(int x, int y) {
267 this.x = new Number(x);
268 this.y = new Number(y);
269 }
270 }
271
272 static RefPoint refPointField1 = new RefPoint(12, 34);
273 static RefPoint refPointField2 = new RefPoint(56789, 0x12345678);
274
275 //**********************************************************************
276 // PART 1 - C1 calls interpreted code
277 //**********************************************************************
278
279
280 //** C1 passes value to interpreter (static)
281 @Test(compLevel = C1)
282 public int test1() {
283 return test1_helper(pointField);
284 }
285
286 @DontInline
287 @DontCompile
288 private static int test1_helper(Point p) {
289 return p.func();
1049
1050 @DontInline
1051 @ForceCompile(compLevel = C1)
1052 private static int test54_helper(RefPoint rp1, RefPoint rp2, float f, int i, RefPoint rp3, RefPoint rp4) {
1053 return rp1.x.n + rp1.y.n +
1054 rp2.x.n + rp2.y.n +
1055 (int)(f) + i +
1056 rp3.x.n + rp3.y.n +
1057 rp4.x.n + rp4.y.n;
1058 }
1059
1060 @DontCompile
1061 public void test54_verifier(boolean warmup) {
1062 int count = warmup ? 1 : 5;
1063 for (int i=0; i<count; i++) { // need a loop to test inline cache
1064 int result = test54();
1065 int n = test54_helper(refPointField1, refPointField2, 1.0f, 2, refPointField1, refPointField2);
1066 Asserts.assertEQ(result, n);
1067 }
1068 }
1069 }
|
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 */
23
24 package compiler.valhalla.valuetypes;
25
26 import sun.hotspot.WhiteBox;
27 import jdk.test.lib.Asserts;
28
29 /*
30 * @test
31 * @summary Test calls from {C1} to {C2, Interpreter}, and vice versa.
32 * @library /testlibrary /test/lib /compiler/whitebox /
33 * @requires os.simpleArch == "x64"
34 * @compile TestCallingConventionC1.java
35 * @run driver ClassFileInstaller sun.hotspot.WhiteBox jdk.test.lib.Platform
36 * @run main/othervm/timeout=120 -Xbootclasspath/a:. -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockDiagnosticVMOptions
37 * -XX:+UnlockExperimentalVMOptions -XX:+WhiteBoxAPI -XX:+EnableValhalla
38 * compiler.valhalla.valuetypes.ValueTypeTest
39 * compiler.valhalla.valuetypes.TestCallingConventionC1
40 */
41 public class TestCallingConventionC1 extends ValueTypeTest {
42 public static final int C1 = COMP_LEVEL_SIMPLE;
43 public static final int C2 = COMP_LEVEL_FULL_OPTIMIZATION;
44
45 @Override
46 public int getNumScenarios() {
47 return 2;
48 }
49
50 @Override
51 public String[] getVMParameters(int scenario) {
52 switch (scenario) {
53
54 // Default: both C1 and C2 are enabled, tierd compilation enabled
55 case 0: return new String[] {"-XX:+EnableValhallaC1", "-XX:CICompilerCount=2"
56 , "-XX:-CheckCompressedOops", "-XX:CompileCommand=print,*::test60*"
57 //, "-XX:CompileCommand=print,*::func_c1"
58 };
59 // Only C1. Tierd compilation disabled.
60 case 1: return new String[] {"-XX:+EnableValhallaC1", "-XX:TieredStopAtLevel=1"
61 , "-XX:-CheckCompressedOops", "-XX:CompileCommand=print,*::test76*"
62 };
63 }
64 return null;
65 }
66
67 public static void main(String[] args) throws Throwable {
68 System.gc(); // Resolve this call, to avoid C1 code patching in the test cases.
69 TestCallingConventionC1 test = new TestCallingConventionC1();
70 test.run(args,
71 Point.class,
72 Functor.class,
73 Functor1.class,
74 Functor2.class,
75 Functor3.class,
76 Functor4.class,
77 MyImplPojo1.class,
78 MyImplPojo2.class,
79 MyImplVal.class,
80 FixedPoints.class,
81 FloatPoint.class,
82 RefPoint.class);
83 }
84
85 static inline class Point {
86 final int x;
87 final int y;
88 public Point(int x, int y) {
89 this.x = x;
90 this.y = y;
91 }
92
93 @DontCompile
94 @DontInline
95 public int func() {
96 return x + y;
97 }
98
99 @ForceCompile(compLevel = C1)
100 @DontInline
101 public int func_c1(Point p) {
102 return x + y + p.x + p.y;
246 f2 = 2.2f;
247 f3 = 3.3f;
248 f4 = 4.4f;
249 f5 = 5.5f;
250 f6 = 6.6f;
251 f7 = 7.7f;
252 f8 = 8.8f;
253 }
254 }
255 static EightFloats eightFloatsField = new EightFloats();
256
257 static class Number {
258 int n;
259 Number(int v) {
260 n = v;
261 }
262 void set(int v) {
263 n = v;
264 }
265 }
266
267 static interface RefPoint_Access {
268 public int func1(RefPoint rp2);
269 public int func2(RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2);
270 }
271
272 static inline class RefPoint implements RefPoint_Access {
273 final Number x;
274 final Number y;
275 public RefPoint(int x, int y) {
276 this.x = new Number(x);
277 this.y = new Number(y);
278 }
279
280 @DontInline
281 @ForceCompile(compLevel = C1)
282 public final int test76_helper(RefPoint rp2) { // opt_virtual_call
283 return this.x.n + this.y.n + rp2.x.n + rp2.y.n;
284 }
285
286 @DontInline
287 @ForceCompile(compLevel = C1)
288 public int func1(RefPoint rp2) {
289 return this.x.n + this.y.n + rp2.x.n + rp2.y.n;
290 }
291
292 @DontInline
293 @ForceCompile(compLevel = C1)
294 public int func2(RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) {
295 return x.n + y.n +
296 rp1.x.n + rp1.y.n +
297 rp2.x.n + rp2.y.n +
298 n1.n +
299 rp3.x.n + rp3.y.n +
300 rp4.x.n + rp4.y.n +
301 n2.n;
302 }
303 }
304
305 static class RefPoint_Access_Impl1 implements RefPoint_Access {
306 @DontInline @DontCompile
307 public int func1(RefPoint rp2) {
308 return rp2.x.n + rp2.y.n + 1111111;
309 }
310 @DontInline @DontCompile
311 public int func2(RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) {
312 return 111111 +
313 rp1.x.n + rp1.y.n +
314 rp2.x.n + rp2.y.n +
315 n1.n +
316 rp3.x.n + rp3.y.n +
317 rp4.x.n + rp4.y.n +
318 n2.n;
319 }
320 }
321 static class RefPoint_Access_Impl2 implements RefPoint_Access {
322 @DontInline @DontCompile
323 public int func1(RefPoint rp2) {
324 return rp2.x.n + rp2.y.n + 2222222;
325 }
326 @DontInline @DontCompile
327 public int func2(RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) {
328 return 222222 +
329 rp1.x.n + rp1.y.n +
330 rp2.x.n + rp2.y.n +
331 n1.n +
332 rp3.x.n + rp3.y.n +
333 rp4.x.n + rp4.y.n +
334 n2.n;
335 }
336 }
337
338 static RefPoint_Access refPoint_Access_impls[] = {
339 new RefPoint_Access_Impl1(),
340 new RefPoint_Access_Impl2(),
341 new RefPoint(0x12345, 0x6789a)
342 };
343
344 static int next_RefPoint_Access = 0;
345 static RefPoint_Access get_RefPoint_Access() {
346 int i = next_RefPoint_Access ++;
347 return refPoint_Access_impls[i % refPoint_Access_impls.length];
348 }
349
350 static RefPoint refPointField1 = new RefPoint(12, 34);
351 static RefPoint refPointField2 = new RefPoint(56789, 0x12345678);
352
353 //**********************************************************************
354 // PART 1 - C1 calls interpreted code
355 //**********************************************************************
356
357
358 //** C1 passes value to interpreter (static)
359 @Test(compLevel = C1)
360 public int test1() {
361 return test1_helper(pointField);
362 }
363
364 @DontInline
365 @DontCompile
366 private static int test1_helper(Point p) {
367 return p.func();
1127
1128 @DontInline
1129 @ForceCompile(compLevel = C1)
1130 private static int test54_helper(RefPoint rp1, RefPoint rp2, float f, int i, RefPoint rp3, RefPoint rp4) {
1131 return rp1.x.n + rp1.y.n +
1132 rp2.x.n + rp2.y.n +
1133 (int)(f) + i +
1134 rp3.x.n + rp3.y.n +
1135 rp4.x.n + rp4.y.n;
1136 }
1137
1138 @DontCompile
1139 public void test54_verifier(boolean warmup) {
1140 int count = warmup ? 1 : 5;
1141 for (int i=0; i<count; i++) { // need a loop to test inline cache
1142 int result = test54();
1143 int n = test54_helper(refPointField1, refPointField2, 1.0f, 2, refPointField1, refPointField2);
1144 Asserts.assertEQ(result, n);
1145 }
1146 }
1147
1148 static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
1149 static final String ScavengeALot = "ScavengeALot";
1150
1151
1152 /**
1153 * Each allocation with a "try" block like this will cause a GC
1154 *
1155 * try (ForceGCMarker m = ForceGCMarker.mark(warmup)) {
1156 * result = test55(p1);
1157 * }
1158 */
1159 static class ForceGCMarker implements java.io.Closeable {
1160 static final WhiteBox WHITE_BOX = WhiteBox.getWhiteBox();
1161
1162 ForceGCMarker() {
1163 WHITE_BOX.setBooleanVMFlag(ScavengeALot, true);
1164 }
1165 public void close() {
1166 WHITE_BOX.setBooleanVMFlag(ScavengeALot, false);
1167 }
1168
1169 static ForceGCMarker mark(boolean warmup) {
1170 return warmup ? null : new ForceGCMarker();
1171 }
1172 }
1173
1174 // C2->C1 invokestatic, force GC for every allocation when entering a C1 VEP (Point)
1175 @Test(compLevel = C2)
1176 public int test55(Point p1) {
1177 return test55_helper(p1);
1178 }
1179
1180 @DontInline
1181 @ForceCompile(compLevel = C1)
1182 private static int test55_helper(Point p1) {
1183 return p1.x + p1.y;
1184 }
1185
1186 @DontCompile
1187 public void test55_verifier(boolean warmup) {
1188 int count = warmup ? 1 : 5;
1189 for (int i=0; i<count; i++) { // need a loop to test inline cache
1190 Point p1 = new Point(1, 2);
1191 int result;
1192 try (ForceGCMarker m = ForceGCMarker.mark(warmup)) {
1193 result = test55(p1);
1194 }
1195 int n = test55_helper(p1);
1196 Asserts.assertEQ(result, n);
1197 }
1198 }
1199
1200 // C2->C1 invokestatic, force GC for every allocation when entering a C1 VEP (RefPoint)
1201 @Test(compLevel = C2)
1202 public int test56(RefPoint rp1) {
1203 return test56_helper(rp1);
1204 }
1205
1206 @DontInline
1207 @ForceCompile(compLevel = C1)
1208 private static int test56_helper(RefPoint rp1) {
1209 return rp1.x.n + rp1.y.n;
1210 }
1211
1212 @DontCompile
1213 public void test56_verifier(boolean warmup) {
1214 int count = warmup ? 1 : 5;
1215 for (int i=0; i<count; i++) { // need a loop to test inline cache
1216 RefPoint rp1 = new RefPoint(1, 2);
1217 int result;
1218 try (ForceGCMarker m = ForceGCMarker.mark(warmup)) {
1219 result = test56(rp1);
1220 }
1221 int n = test56_helper(rp1);
1222 Asserts.assertEQ(result, n);
1223 }
1224 }
1225
1226 // C2->Interpreter (same as test56, but test c2i entry instead of C1)
1227 @Test(compLevel = C2)
1228 public int test57(RefPoint rp1) {
1229 return test57_helper(rp1);
1230 }
1231
1232 @DontInline @DontCompile
1233 private static int test57_helper(RefPoint rp1) {
1234 return rp1.x.n + rp1.y.n;
1235 }
1236
1237 @DontCompile
1238 public void test57_verifier(boolean warmup) {
1239 int count = warmup ? 1 : 5;
1240 for (int i=0; i<count; i++) { // need a loop to test inline cache
1241 RefPoint rp1 = new RefPoint(1, 2);
1242 int result;
1243 try (ForceGCMarker m = ForceGCMarker.mark(warmup)) {
1244 result = test57(rp1);
1245 }
1246 int n = test57_helper(rp1);
1247 Asserts.assertEQ(result, n);
1248 }
1249 }
1250
1251 // C2->C1 invokestatic, force GC for every allocation when entering a C1 VEP (a bunch of RefPoints and Numbers);
1252 @Test(compLevel = C2)
1253 public int test58(RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) {
1254 return test58_helper(rp1, rp2, n1, rp3, rp4, n2);
1255 }
1256
1257 @DontInline
1258 @ForceCompile(compLevel = C1)
1259 private static int test58_helper(RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) {
1260 return rp1.x.n + rp1.y.n +
1261 rp2.x.n + rp2.y.n +
1262 n1.n +
1263 rp3.x.n + rp3.y.n +
1264 rp4.x.n + rp4.y.n +
1265 n2.n;
1266 }
1267
1268 @DontCompile
1269 public void test58_verifier(boolean warmup) {
1270 int count = warmup ? 1 : 5;
1271 for (int i=0; i<count; i++) { // need a loop to test inline cache
1272 RefPoint rp1 = new RefPoint(1, 2);
1273 RefPoint rp2 = refPointField1;
1274 RefPoint rp3 = new RefPoint(222, 777);
1275 RefPoint rp4 = refPointField2;
1276 Number n1 = new Number(5878);
1277 Number n2 = new Number(1234);
1278 int result;
1279 try (ForceGCMarker m = ForceGCMarker.mark(warmup)) {
1280 result = test58(rp1, rp2, n1, rp3, rp4, n2);
1281 }
1282 int n = test58_helper(rp1, rp2, n1, rp3, rp4, n2);
1283 Asserts.assertEQ(result, n);
1284 }
1285 }
1286
1287 // C2->C1 invokestatic, GC inside main body of C1-compiled method (caller's args should not be GC'ed).
1288 @Test(compLevel = C2)
1289 public int test59(RefPoint rp1, boolean doGC) {
1290 return test59_helper(rp1, 11, 222, 3333, 4444, doGC);
1291 }
1292
1293 @DontInline
1294 @ForceCompile(compLevel = C1)
1295 private static int test59_helper(RefPoint rp1, int a1, int a2, int a3, int a4, boolean doGC) {
1296 if (doGC) {
1297 System.gc();
1298 }
1299 return rp1.x.n + rp1.y.n + a1 + a2 + a3 + a4;
1300 }
1301
1302 @DontCompile
1303 public void test59_verifier(boolean warmup) {
1304 int count = warmup ? 1 : 5;
1305 boolean doGC = !warmup;
1306 for (int i=0; i<count; i++) { // need a loop to test inline cache
1307 RefPoint rp1 = new RefPoint(1, 2);
1308 int result = test59(rp1, doGC);
1309 int n = test59_helper(rp1, 11, 222, 3333, 4444, doGC);
1310 Asserts.assertEQ(result, n);
1311 }
1312 }
1313
1314 // C2->C1 invokestatic, GC inside main body of C1-compiled method (caller's args should not be GC'ed).
1315 // same as test59, but the incoming (scalarized) oops are passed in both registers and stack.
1316 @Test(compLevel = C2)
1317 public int test60(RefPoint rp1, RefPoint rp2, boolean doGC) {
1318 return test60_helper(555, 6666, 77777, rp1, rp2, 11, 222, 3333, 4444, doGC);
1319 }
1320
1321 @DontInline
1322 @ForceCompile(compLevel = C1)
1323 private static int test60_helper(int x0, int x1, int x2, RefPoint rp1, RefPoint rp2,int a1, int a2, int a3, int a4, boolean doGC) {
1324 // On x64, C2 passes: reg0=x1, reg1=x1, reg2=x2, reg3=rp1.x, reg4=rp1.y, reg5=rp2.x stack0=rp2.y ....
1325 // C1 expects: reg0=x1, reg1=x1, reg2=x2, reg3=rp1, reg4=rp2, reg5=a1 stack0=a2 ...
1326 // When GC happens, make sure it does not treat reg5 and stack0 as oops!
1327 if (doGC) {
1328 System.gc();
1329 }
1330 return x0 + x1 + x2 + rp1.x.n + rp1.y.n + rp2.x.n + rp2.y.n + a1 + a2 + a3 + a4;
1331 }
1332
1333 @DontCompile
1334 public void test60_verifier(boolean warmup) {
1335 int count = warmup ? 1 : 5;
1336 boolean doGC = !warmup;
1337 for (int i=0; i<count; i++) { // need a loop to test inline cache
1338 RefPoint rp1 = new RefPoint(1, 2);
1339 RefPoint rp2 = new RefPoint(33, 44);
1340 int result = test60(rp1, rp2, doGC);
1341 int n = test60_helper(555, 6666, 77777, rp1, rp2, 11, 222, 3333, 4444, doGC);
1342 Asserts.assertEQ(result, n);
1343 }
1344 }
1345
1346 // C2->C1 invokeinterface via VVEP(RO)
1347 @Test(compLevel = C2)
1348 public int test61(RefPoint_Access rpa, RefPoint rp2) {
1349 return rpa.func1(rp2);
1350 }
1351
1352 @DontCompile
1353 public void test61_verifier(boolean warmup) {
1354 int count = warmup ? 1 : 20;
1355 for (int i=0; i<count; i++) { // need a loop to test inline cache
1356 RefPoint_Access rpa = get_RefPoint_Access();
1357 RefPoint rp2 = refPointField2;
1358 int result = test61(rpa, rp2);
1359 int n = rpa.func1(rp2);
1360 Asserts.assertEQ(result, n);
1361 }
1362 }
1363
1364 // C2->C1 invokeinterface via VVEP(RO) -- force GC for every allocation when entering a C1 VVEP(RO) (RefPoint)
1365 @Test(compLevel = C2)
1366 public int test62(RefPoint_Access rpa, RefPoint rp2) {
1367 return rpa.func1(rp2);
1368 }
1369
1370 @DontCompile
1371 public void test62_verifier(boolean warmup) {
1372 int count = warmup ? 1 : 20;
1373 for (int i=0; i<count; i++) { // need a loop to test inline cache
1374 RefPoint_Access rpa = get_RefPoint_Access();
1375 RefPoint rp2 = new RefPoint(111, 2222);
1376 int result;
1377 try (ForceGCMarker m = ForceGCMarker.mark(warmup)) {
1378 result = test62(rpa, rp2);
1379 }
1380 int n = rpa.func1(rp2);
1381 Asserts.assertEQ(result, n);
1382 }
1383 }
1384
1385
1386 /*
1387
1388 // FIXME: C1 fails with "Could not resolve circular dependency when shuffling value type arguments" when compiling test63()
1389
1390 // C2->C1 invokeinterface via VVEP(RO) -- force GC for every allocation when entering a C1 VVEP(RO) (a bunch of RefPoints and Numbers)
1391 @Test(compLevel = C2)
1392 public int test63(RefPoint_Access rpa, RefPoint rp1, RefPoint rp2, Number n1, RefPoint rp3, RefPoint rp4, Number n2) {
1393 return rpa.func2(rp1, rp2, n1, rp3, rp4, n2);
1394 }
1395
1396 @DontCompile
1397 public void test63_verifier(boolean warmup) {
1398 int count = warmup ? 1 : 20;
1399 for (int i=0; i<count; i++) { // need a loop to test inline cache
1400 RefPoint_Access rpa = get_RefPoint_Access();
1401 RefPoint rp1 = new RefPoint(1, 2);
1402 RefPoint rp2 = refPointField1;
1403 RefPoint rp3 = new RefPoint(222, 777);
1404 RefPoint rp4 = refPointField2;
1405 Number n1 = new Number(5878);
1406 Number n2 = new Number(1234);
1407 int result;
1408 try (ForceGCMarker m = ForceGCMarker.mark(warmup)) {
1409 result = test63(rpa, rp1, rp2, n1, rp3, rp4, n2);
1410 }
1411 int n = rpa.func2(rp1, rp2, n1, rp3, rp4, n2);
1412 Asserts.assertEQ(result, n);
1413 }
1414 }
1415 /**/
1416
1417 /*
1418
1419
1420 // FIXME: when C1 makes opt_virtual_call to RefPoint::test76_helper, method resolution fails with an assert
1421
1422 // C2->C1 invokevirtual via VVEP(RO) (opt_virtual_call)
1423 @Test(compLevel = C2)
1424 public int test76(RefPoint rp1, RefPoint rp2) {
1425 return rp1.test76_helper(rp2);
1426 }
1427
1428 @DontCompile
1429 public void test76_verifier(boolean warmup) {
1430 int count = warmup ? 1 : 5;
1431 for (int i=0; i<count; i++) { // need a loop to test inline cache
1432 RefPoint rp1 = refPointField1;
1433 RefPoint rp2 = refPointField2;
1434 int result = test76(rp1, rp2);
1435 int n = rp1.test76_helper(rp2);
1436 Asserts.assertEQ(result, n);
1437 }
1438 }
1439 /**/
1440
1441 /*
1442
1443 // C2->C1 invokevirtual, force GC for every allocation when entering a C1 VEP (RefPoint)
1444 // Same as test56, except we call the VVEP(RO) instead of VEP.
1445 @Test(compLevel = C2)
1446 public int test77(RefPoint rp1, RefPoint rp2) {
1447 return rp1.test76_helper(rp2);
1448 }
1449
1450 @DontCompile
1451 public void test77_verifier(boolean warmup) {
1452 int count = warmup ? 1 : 5;
1453 for (int i=0; i<count; i++) { // need a loop to test inline cache
1454 RefPoint rp1 = new RefPoint(1, 2);
1455 RefPoint rp2 = new RefPoint(22, 33);
1456 int result;
1457 if (!warmup) {
1458 System.out.println("Hello: " + i);
1459 }
1460 try (ForceGCMarker m = ForceGCMarker.mark(warmup)) {
1461 result = test77(rp1, rp2);
1462 }
1463 int n = rp1.test77_helper(rp2);
1464 Asserts.assertEQ(result, n);
1465 }
1466 }
1467 /**/
1468 }
|