22 * questions.
23 */
24
25 /*
26 * common code to run and validate tests of code generation for
27 * volatile ops on AArch64
28 *
29 * incoming args are <testclass> <testtype>
30 *
31 * where <testclass> in {TestVolatileLoad,
32 * TestVolatileStore,
33 * TestUnsafeVolatileLoad,
34 * TestUnsafeVolatileStore,
35 * TestUnsafeVolatileCAS,
36 * TestUnsafeVolatileWeakCAS,
37 * TestUnsafeVolatileCAE,
38 * TestUnsafeVolatileGAS}
39 * and <testtype> in {G1,
40 * Serial,
41 * Parallel,
42 * Shenandoah,
43 * ShenandoahIU}
44 */
45
46
47 package compiler.c2.aarch64;
48
49 import java.util.List;
50 import java.util.ListIterator;
51 import java.util.Iterator;
52 import java.util.regex.Pattern;
53 import java.io.*;
54
55 import jdk.test.lib.Asserts;
56 import jdk.test.lib.compiler.InMemoryJavaCompiler;
57 import jdk.test.lib.process.OutputAnalyzer;
58 import jdk.test.lib.process.ProcessTools;
59 import jdk.test.whitebox.WhiteBox;
60
61 // runner class that spawns a new JVM to exercises a combination of
62 // volatile MemOp and GC. The ops are compiled with the dmb -->
63 // ldar/stlr transforms either enabled or disabled. this runner parses
78 argcount = 9;
79 procArgs = new String[argcount];
80 procArgs[argcount - 2] = "-XX:+UseG1GC";
81 break;
82 case "Parallel":
83 argcount = 9;
84 procArgs = new String[argcount];
85 procArgs[argcount - 2] = "-XX:+UseParallelGC";
86 break;
87 case "Serial":
88 argcount = 9;
89 procArgs = new String[argcount];
90 procArgs[argcount - 2] = "-XX:+UseSerialGC";
91 break;
92 case "Shenandoah":
93 argcount = 10;
94 procArgs = new String[argcount];
95 procArgs[argcount - 3] = "-XX:+UnlockExperimentalVMOptions";
96 procArgs[argcount - 2] = "-XX:+UseShenandoahGC";
97 break;
98 case "ShenandoahIU":
99 argcount = 11;
100 procArgs = new String[argcount];
101 procArgs[argcount - 4] = "-XX:+UnlockExperimentalVMOptions";
102 procArgs[argcount - 3] = "-XX:+UseShenandoahGC";
103 procArgs[argcount - 2] = "-XX:ShenandoahGCMode=iu";
104 break;
105 default:
106 throw new RuntimeException("unexpected test type " + testType);
107 }
108
109 // fill in arguments common to all cases
110
111 // the first round of test enables transform of barriers to
112 // use acquiring loads and releasing stores by setting arg
113 // zero appropriately. this arg is reset in the second run to
114 // disable the transform.
115
116 procArgs[0] = "-XX:+UseCompressedOops";
117 procArgs[1] = "-XX:-BackgroundCompilation";
118 procArgs[2] = "-XX:-TieredCompilation";
119 procArgs[3] = "-XX:+PrintOptoAssembly";
120 procArgs[4] = "-XX:CompileCommand=compileonly," + fullclassname + "::" + "test*";
121 procArgs[5] = "--add-exports";
122 procArgs[6] = "java.base/jdk.internal.misc=ALL-UNNAMED";
123 procArgs[argcount - 1] = fullclassname;
124
269 };
270 break;
271 case "G1":
272 // a card mark volatile barrier should be generated
273 // before the card mark strb
274 //
275 // following the fix for 8225776 the G1 barrier is now
276 // scheduled out of line after the membar volatile and
277 // and subsequent return
278 matches = new String[] {
279 "membar_release \\(elided\\)",
280 useCompressedOops ? "stlrw?" : "stlr",
281 "membar_volatile \\(elided\\)",
282 "ret",
283 "membar_volatile",
284 "dmb ish",
285 "strb"
286 };
287 break;
288 case "Shenandoah":
289 case "ShenandoahIU":
290 // Shenandoah generates normal object graphs for
291 // volatile stores
292 matches = new String[] {
293 "membar_release \\(elided\\)",
294 useCompressedOops ? "stlrw?" : "stlr",
295 "membar_volatile \\(elided\\)",
296 "ret"
297 };
298 break;
299 }
300
301 checkCompile(iter, "testObj", matches, output, true);
302 }
303
304 // check for expected asm output from a volatile cas
305
306 private void checkcas(OutputAnalyzer output, String testType, boolean useCompressedOops) throws Throwable
307 {
308 Iterator<String> iter = output.asLines().listIterator();
309
341 };
342 break;
343 case "G1":
344 // a card mark volatile barrier should be generated
345 // before the card mark strb
346 //
347 // following the fix for 8225776 the G1 barrier is now
348 // scheduled out of line after the membar acquire and
349 // and subsequent return
350 matches = new String[] {
351 "membar_release \\(elided\\)",
352 useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq",
353 "membar_acquire \\(elided\\)",
354 "ret",
355 "membar_volatile",
356 "dmb ish",
357 "strb"
358 };
359 break;
360 case "Shenandoah":
361 case "ShenandoahIU":
362 // For volatile CAS, Shenanodoah generates normal
363 // graphs with a shenandoah-specific cmpxchg
364 matches = new String[] {
365 "membar_release \\(elided\\)",
366 useCompressedOops ? "cmpxchgw?_acq_shenandoah" : "cmpxchg_acq_shenandoah",
367 "membar_acquire \\(elided\\)",
368 "ret"
369 };
370 break;
371 }
372 checkCompile(iter, "testObj", matches, output, true);
373 }
374
375 private void checkcae(OutputAnalyzer output, String testType, boolean useCompressedOops) throws Throwable
376 {
377 ListIterator<String> iter = output.asLines().listIterator();
378
379 String[] matches;
380 String[][] tests = {
381 { "testInt", "cmpxchgw" },
428 return;
429
430 case "G1":
431 // a card mark volatile barrier should be generated
432 // before the card mark strb
433 //
434 // following the fix for 8225776 the G1 barrier is now
435 // scheduled out of line after the membar acquire and
436 // and subsequent return
437 matches = new String[] {
438 "membar_release \\(elided\\)",
439 useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq",
440 "membar_acquire \\(elided\\)",
441 "ret",
442 "membar_volatile",
443 "dmb ish",
444 "strb"
445 };
446 break;
447 case "Shenandoah":
448 case "ShenandoahIU":
449 // For volatile CAS, Shenanodoah generates normal
450 // graphs with a shenandoah-specific cmpxchg
451 matches = new String[] {
452 "membar_release \\(elided\\)",
453 useCompressedOops ? "cmpxchgw?_acq_shenandoah" : "cmpxchg_acq_shenandoah",
454 "membar_acquire \\(elided\\)",
455 "ret"
456 };
457 break;
458 }
459 checkCompile(iter, "testObj", matches, output, true);
460 }
461
462 private void checkgas(OutputAnalyzer output, String testType, boolean useCompressedOops) throws Throwable
463 {
464 Iterator<String> iter = output.asLines().listIterator();
465
466 String[] matches;
467 String[][] tests = {
468 { "testInt", "atomic_xchgw" },
495 };
496 break;
497 case "G1":
498 // a card mark volatile barrier should be generated
499 // before the card mark strb
500 //
501 // following the fix for 8225776 the G1 barrier is now
502 // scheduled out of line after the membar acquire and
503 // and subsequent return
504 matches = new String[] {
505 "membar_release \\(elided\\)",
506 useCompressedOops ? "atomic_xchgw?_acq" : "atomic_xchg_acq",
507 "membar_acquire \\(elided\\)",
508 "ret",
509 "membar_volatile",
510 "dmb ish",
511 "strb"
512 };
513 break;
514 case "Shenandoah":
515 case "ShenandoahIU":
516 matches = new String[] {
517 "membar_release \\(elided\\)",
518 useCompressedOops ? "atomic_xchgw?_acq" : "atomic_xchg_acq",
519 "membar_acquire \\(elided\\)",
520 "ret"
521 };
522 break;
523 }
524
525 checkCompile(iter, "testObj", matches, output, true);
526 }
527
528 private void checkgaa(OutputAnalyzer output, String testType) throws Throwable
529 {
530 Iterator<String> iter = output.asLines().listIterator();
531
532 String[] matches;
533 String[][] tests = {
534 { "testInt", "get_and_addI" },
535 { "testLong", "get_and_addL" },
|
22 * questions.
23 */
24
25 /*
26 * common code to run and validate tests of code generation for
27 * volatile ops on AArch64
28 *
29 * incoming args are <testclass> <testtype>
30 *
31 * where <testclass> in {TestVolatileLoad,
32 * TestVolatileStore,
33 * TestUnsafeVolatileLoad,
34 * TestUnsafeVolatileStore,
35 * TestUnsafeVolatileCAS,
36 * TestUnsafeVolatileWeakCAS,
37 * TestUnsafeVolatileCAE,
38 * TestUnsafeVolatileGAS}
39 * and <testtype> in {G1,
40 * Serial,
41 * Parallel,
42 * Shenandoah}
43 */
44
45
46 package compiler.c2.aarch64;
47
48 import java.util.List;
49 import java.util.ListIterator;
50 import java.util.Iterator;
51 import java.util.regex.Pattern;
52 import java.io.*;
53
54 import jdk.test.lib.Asserts;
55 import jdk.test.lib.compiler.InMemoryJavaCompiler;
56 import jdk.test.lib.process.OutputAnalyzer;
57 import jdk.test.lib.process.ProcessTools;
58 import jdk.test.whitebox.WhiteBox;
59
60 // runner class that spawns a new JVM to exercises a combination of
61 // volatile MemOp and GC. The ops are compiled with the dmb -->
62 // ldar/stlr transforms either enabled or disabled. this runner parses
77 argcount = 9;
78 procArgs = new String[argcount];
79 procArgs[argcount - 2] = "-XX:+UseG1GC";
80 break;
81 case "Parallel":
82 argcount = 9;
83 procArgs = new String[argcount];
84 procArgs[argcount - 2] = "-XX:+UseParallelGC";
85 break;
86 case "Serial":
87 argcount = 9;
88 procArgs = new String[argcount];
89 procArgs[argcount - 2] = "-XX:+UseSerialGC";
90 break;
91 case "Shenandoah":
92 argcount = 10;
93 procArgs = new String[argcount];
94 procArgs[argcount - 3] = "-XX:+UnlockExperimentalVMOptions";
95 procArgs[argcount - 2] = "-XX:+UseShenandoahGC";
96 break;
97 default:
98 throw new RuntimeException("unexpected test type " + testType);
99 }
100
101 // fill in arguments common to all cases
102
103 // the first round of test enables transform of barriers to
104 // use acquiring loads and releasing stores by setting arg
105 // zero appropriately. this arg is reset in the second run to
106 // disable the transform.
107
108 procArgs[0] = "-XX:+UseCompressedOops";
109 procArgs[1] = "-XX:-BackgroundCompilation";
110 procArgs[2] = "-XX:-TieredCompilation";
111 procArgs[3] = "-XX:+PrintOptoAssembly";
112 procArgs[4] = "-XX:CompileCommand=compileonly," + fullclassname + "::" + "test*";
113 procArgs[5] = "--add-exports";
114 procArgs[6] = "java.base/jdk.internal.misc=ALL-UNNAMED";
115 procArgs[argcount - 1] = fullclassname;
116
261 };
262 break;
263 case "G1":
264 // a card mark volatile barrier should be generated
265 // before the card mark strb
266 //
267 // following the fix for 8225776 the G1 barrier is now
268 // scheduled out of line after the membar volatile and
269 // and subsequent return
270 matches = new String[] {
271 "membar_release \\(elided\\)",
272 useCompressedOops ? "stlrw?" : "stlr",
273 "membar_volatile \\(elided\\)",
274 "ret",
275 "membar_volatile",
276 "dmb ish",
277 "strb"
278 };
279 break;
280 case "Shenandoah":
281 // Shenandoah generates normal object graphs for
282 // volatile stores
283 matches = new String[] {
284 "membar_release \\(elided\\)",
285 useCompressedOops ? "stlrw?" : "stlr",
286 "membar_volatile \\(elided\\)",
287 "ret"
288 };
289 break;
290 }
291
292 checkCompile(iter, "testObj", matches, output, true);
293 }
294
295 // check for expected asm output from a volatile cas
296
297 private void checkcas(OutputAnalyzer output, String testType, boolean useCompressedOops) throws Throwable
298 {
299 Iterator<String> iter = output.asLines().listIterator();
300
332 };
333 break;
334 case "G1":
335 // a card mark volatile barrier should be generated
336 // before the card mark strb
337 //
338 // following the fix for 8225776 the G1 barrier is now
339 // scheduled out of line after the membar acquire and
340 // and subsequent return
341 matches = new String[] {
342 "membar_release \\(elided\\)",
343 useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq",
344 "membar_acquire \\(elided\\)",
345 "ret",
346 "membar_volatile",
347 "dmb ish",
348 "strb"
349 };
350 break;
351 case "Shenandoah":
352 // For volatile CAS, Shenanodoah generates normal
353 // graphs with a shenandoah-specific cmpxchg
354 matches = new String[] {
355 "membar_release \\(elided\\)",
356 useCompressedOops ? "cmpxchgw?_acq_shenandoah" : "cmpxchg_acq_shenandoah",
357 "membar_acquire \\(elided\\)",
358 "ret"
359 };
360 break;
361 }
362 checkCompile(iter, "testObj", matches, output, true);
363 }
364
365 private void checkcae(OutputAnalyzer output, String testType, boolean useCompressedOops) throws Throwable
366 {
367 ListIterator<String> iter = output.asLines().listIterator();
368
369 String[] matches;
370 String[][] tests = {
371 { "testInt", "cmpxchgw" },
418 return;
419
420 case "G1":
421 // a card mark volatile barrier should be generated
422 // before the card mark strb
423 //
424 // following the fix for 8225776 the G1 barrier is now
425 // scheduled out of line after the membar acquire and
426 // and subsequent return
427 matches = new String[] {
428 "membar_release \\(elided\\)",
429 useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq",
430 "membar_acquire \\(elided\\)",
431 "ret",
432 "membar_volatile",
433 "dmb ish",
434 "strb"
435 };
436 break;
437 case "Shenandoah":
438 // For volatile CAS, Shenanodoah generates normal
439 // graphs with a shenandoah-specific cmpxchg
440 matches = new String[] {
441 "membar_release \\(elided\\)",
442 useCompressedOops ? "cmpxchgw?_acq_shenandoah" : "cmpxchg_acq_shenandoah",
443 "membar_acquire \\(elided\\)",
444 "ret"
445 };
446 break;
447 }
448 checkCompile(iter, "testObj", matches, output, true);
449 }
450
451 private void checkgas(OutputAnalyzer output, String testType, boolean useCompressedOops) throws Throwable
452 {
453 Iterator<String> iter = output.asLines().listIterator();
454
455 String[] matches;
456 String[][] tests = {
457 { "testInt", "atomic_xchgw" },
484 };
485 break;
486 case "G1":
487 // a card mark volatile barrier should be generated
488 // before the card mark strb
489 //
490 // following the fix for 8225776 the G1 barrier is now
491 // scheduled out of line after the membar acquire and
492 // and subsequent return
493 matches = new String[] {
494 "membar_release \\(elided\\)",
495 useCompressedOops ? "atomic_xchgw?_acq" : "atomic_xchg_acq",
496 "membar_acquire \\(elided\\)",
497 "ret",
498 "membar_volatile",
499 "dmb ish",
500 "strb"
501 };
502 break;
503 case "Shenandoah":
504 matches = new String[] {
505 "membar_release \\(elided\\)",
506 useCompressedOops ? "atomic_xchgw?_acq" : "atomic_xchg_acq",
507 "membar_acquire \\(elided\\)",
508 "ret"
509 };
510 break;
511 }
512
513 checkCompile(iter, "testObj", matches, output, true);
514 }
515
516 private void checkgaa(OutputAnalyzer output, String testType) throws Throwable
517 {
518 Iterator<String> iter = output.asLines().listIterator();
519
520 String[] matches;
521 String[][] tests = {
522 { "testInt", "get_and_addI" },
523 { "testLong", "get_and_addL" },
|