< prev index next >

test/hotspot/jtreg/compiler/c2/aarch64/TestVolatiles.java

Print this page
rev 52710 : Upstream/backport Shenandoah to JDK11u


  22  */
  23 
  24 /*
  25  * common code to run and validate tests of code generation for
  26  * volatile ops on AArch64
  27  *
  28  * incoming args are <testclass> <testtype>
  29  *
  30  * where <testclass> in {TestVolatileLoad,
  31  *                       TestVolatileStore,
  32  *                       TestUnsafeVolatileLoad,
  33  *                       TestUnsafeVolatileStore,
  34  *                       TestUnsafeVolatileCAS,
  35  *                       TestUnsafeVolatileWeakCAS,
  36  *                       TestUnsafeVolatileCAE,
  37  *                       TestUnsafeVolatileGAS}
  38  * and <testtype> in {G1,
  39  *                    CMS,
  40  *                    CMSCondMark,
  41  *                    Serial,
  42  *                    Parallel}


  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 sun.hotspot.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


  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 "CMS":
  92             argcount = 10;
  93             procArgs = new String[argcount];
  94             procArgs[argcount - 3] = "-XX:+UseConcMarkSweepGC";
  95             procArgs[argcount - 2] = "-XX:-UseCondCardMark";
  96             break;
  97         case "CMSCondMark":
  98             argcount = 10;
  99             procArgs = new String[argcount];
 100             procArgs[argcount - 3] = "-XX:+UseConcMarkSweepGC";
 101             procArgs[argcount - 2] = "-XX:+UseCondCardMark";
 102             break;












 103         default:
 104             throw new RuntimeException("unexpected test type " + testType);
 105         }
 106 
 107         // fill in arguments common to all cases
 108 
 109         // the first round of test enables transform of barriers to
 110         // use acquiring loads and releasing stores by setting arg
 111         // zero appropriately. this arg is reset in the second run to
 112         // disable the transform.
 113 
 114         procArgs[0] = "-XX:-UseBarriersForVolatile";
 115         procArgs[1] = "-XX:+UseCompressedOops";
 116 
 117         procArgs[2] = "-XX:-TieredCompilation";
 118         procArgs[3] = "-XX:+PrintOptoAssembly";
 119         procArgs[4] = "-XX:CompileCommand=compileonly," + fullclassname + "::" + "test*";
 120         procArgs[5] = "--add-exports";
 121         procArgs[6] = "java.base/jdk.internal.misc=ALL-UNNAMED";
 122         procArgs[argcount - 1] = fullclassname;


 338                     "strb",
 339                     "membar_volatile \\(elided\\)",
 340                     "ret"
 341                 };
 342                 break;
 343             case "CMS":
 344                 // a volatile card mark membar should not be generated
 345                 // before the card mark strb from the StoreCM and the
 346                 // storestore barrier from the StoreCM should be
 347                 // generated as "dmb ishst"
 348                 matches = new String[] {
 349                     "membar_release \\(elided\\)",
 350                     useCompressedOops ? "stlrw?" : "stlr",
 351                     "storestore",
 352                     "dmb ishst",
 353                     "strb",
 354                     "membar_volatile \\(elided\\)",
 355                     "ret"
 356                 };
 357                 break;











 358             }
 359         } else {
 360             switch (testType) {
 361             default:
 362                 // this is the basic sequence of instructions
 363                 matches = new String[] {
 364                     "membar_release",
 365                     "dmb ish",
 366                     useCompressedOops ? "strw?" : "str",
 367                     "membar_volatile",
 368                     "dmb ish",
 369                     "ret"
 370                 };
 371                 break;
 372             case "G1":
 373                 // a card mark volatile barrier should be generated
 374                 // before the card mark strb
 375                 matches = new String[] {
 376                     "membar_release",
 377                     "dmb ish",


 401                     "ret"
 402                 };
 403                 break;
 404             case "CMS":
 405                 // a volatile card mark membar should not be generated
 406                 // before the card mark strb from the StoreCM and the
 407                 // storestore barrier from the StoreCM should be generated
 408                 // as "dmb ishst"
 409                 matches = new String[] {
 410                     "membar_release",
 411                     "dmb ish",
 412                     useCompressedOops ? "strw?" : "str",
 413                     "storestore",
 414                     "dmb ishst",
 415                     "strb",
 416                     "membar_volatile",
 417                     "dmb ish",
 418                     "ret"
 419                 };
 420                 break;














 421             }
 422         }
 423 
 424         checkCompile(iter, "testObj", matches, output, true);
 425     }
 426 
 427     // check for expected asm output from a volatile cas
 428 
 429     private void checkcas(OutputAnalyzer output, String testType, boolean useBarriersForVolatile, boolean useCompressedOops) throws Throwable
 430     {
 431         Iterator<String> iter = output.asLines().listIterator();
 432 
 433         String[] matches;
 434         String[][] tests = {
 435             { "testInt", "cmpxchgw" },
 436             { "testLong", "cmpxchg" },
 437             { "testByte", "cmpxchgb" },
 438             { "testShort", "cmpxchgs" },
 439         };
 440 


 503                     "storestore \\(elided\\)",
 504                     "strb",
 505                     "membar_acquire \\(elided\\)",
 506                     "ret"
 507                 };
 508                 break;
 509             case "CMS":
 510                 // a volatile card mark membar should not be generated
 511                 // before the card mark strb from the StoreCM and the
 512                 // storestore barrier from the StoreCM should be elided
 513                 matches = new String[] {
 514                     "membar_release \\(elided\\)",
 515                     useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq",
 516                     "storestore",
 517                     "dmb ishst",
 518                     "strb",
 519                     "membar_acquire \\(elided\\)",
 520                     "ret"
 521                 };
 522                 break;











 523             }
 524         } else {
 525             switch (testType) {
 526             default:
 527                 // this is the basic sequence of instructions
 528                 matches = new String[] {
 529                     "membar_release",
 530                     "dmb ish",
 531                     useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
 532                     "membar_acquire",
 533                     "dmb ish",
 534                     "ret"
 535                 };
 536                 break;
 537             case "G1":
 538                 // a card mark volatile barrier should be generated
 539                 // before the card mark strb
 540                 matches = new String[] {
 541                     "membar_release",
 542                     "dmb ish",


 742                     "dmb ish",
 743                     "storestore \\(elided\\)",
 744                     "strb",
 745                     "membar_acquire",
 746                     "dmb ish",
 747                     "ret"
 748                 };
 749                 break;
 750             case "CMS":
 751                 // a volatile card mark membar should not be generated
 752                 // before the card mark strb from the StoreCM and the
 753                 // storestore barrier from the StoreCM should be generated
 754                 // as "dmb ishst"
 755                 matches = new String[] {
 756                     "membar_release",
 757                     "dmb ish",
 758                     useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
 759                     "storestore",
 760                     "dmb ishst",
 761                     "strb",













 762                     "membar_acquire",
 763                     "dmb ish",
 764                     "ret"
 765                 };
 766                 break;
 767             }
 768         }
 769 
 770         checkCompile(iter, "testObj", matches, output, true);
 771     }
 772 
 773     private void checkgas(OutputAnalyzer output, String testType, boolean useBarriersForVolatile, boolean useCompressedOops) throws Throwable
 774     {
 775         Iterator<String> iter = output.asLines().listIterator();
 776 
 777         String[] matches;
 778         String[][] tests = {
 779             { "testInt", "atomic_xchgw" },
 780             { "testLong", "atomic_xchg" },
 781         };




  22  */
  23 
  24 /*
  25  * common code to run and validate tests of code generation for
  26  * volatile ops on AArch64
  27  *
  28  * incoming args are <testclass> <testtype>
  29  *
  30  * where <testclass> in {TestVolatileLoad,
  31  *                       TestVolatileStore,
  32  *                       TestUnsafeVolatileLoad,
  33  *                       TestUnsafeVolatileStore,
  34  *                       TestUnsafeVolatileCAS,
  35  *                       TestUnsafeVolatileWeakCAS,
  36  *                       TestUnsafeVolatileCAE,
  37  *                       TestUnsafeVolatileGAS}
  38  * and <testtype> in {G1,
  39  *                    CMS,
  40  *                    CMSCondMark,
  41  *                    Serial,
  42  *                    Parallel,
  43  *                    Shenandoah,
  44  *                    ShenandoahTraversal}
  45  */
  46 
  47 
  48 package compiler.c2.aarch64;
  49 
  50 import java.util.List;
  51 import java.util.ListIterator;
  52 import java.util.Iterator;
  53 import java.util.regex.Pattern;
  54 import java.io.*;
  55 
  56 import jdk.test.lib.Asserts;
  57 import jdk.test.lib.compiler.InMemoryJavaCompiler;
  58 import jdk.test.lib.process.OutputAnalyzer;
  59 import jdk.test.lib.process.ProcessTools;
  60 import sun.hotspot.WhiteBox;
  61 
  62 // runner class that spawns a new JVM to exercises a combination of
  63 // volatile MemOp and GC. The ops are compiled with the dmb -->
  64 // ldar/stlr transforms either enabled or disabled. this runner parses


  85             procArgs = new String[argcount];
  86             procArgs[argcount - 2] = "-XX:+UseParallelGC";
  87             break;
  88         case "Serial":
  89             argcount = 9;
  90             procArgs = new String[argcount];
  91             procArgs[argcount - 2] = "-XX:+UseSerialGC";
  92             break;
  93         case "CMS":
  94             argcount = 10;
  95             procArgs = new String[argcount];
  96             procArgs[argcount - 3] = "-XX:+UseConcMarkSweepGC";
  97             procArgs[argcount - 2] = "-XX:-UseCondCardMark";
  98             break;
  99         case "CMSCondMark":
 100             argcount = 10;
 101             procArgs = new String[argcount];
 102             procArgs[argcount - 3] = "-XX:+UseConcMarkSweepGC";
 103             procArgs[argcount - 2] = "-XX:+UseCondCardMark";
 104             break;
 105         case "Shenandoah":
 106             argcount = 8;
 107             procArgs = new String[argcount];
 108             procArgs[argcount - 2] = "-XX:+UseShenandoahGC";
 109             break;
 110         case "ShenandoahTraversal":
 111             argcount = 10;
 112             procArgs = new String[argcount];
 113             procArgs[argcount - 4] = "-XX:+UseShenandoahGC";
 114             procArgs[argcount - 3] = "-XX:+UnlockExperimentalVMOptions";
 115             procArgs[argcount - 2] = "-XX:ShenandoahGCMode=traversal";
 116             break;
 117         default:
 118             throw new RuntimeException("unexpected test type " + testType);
 119         }
 120 
 121         // fill in arguments common to all cases
 122 
 123         // the first round of test enables transform of barriers to
 124         // use acquiring loads and releasing stores by setting arg
 125         // zero appropriately. this arg is reset in the second run to
 126         // disable the transform.
 127 
 128         procArgs[0] = "-XX:-UseBarriersForVolatile";
 129         procArgs[1] = "-XX:+UseCompressedOops";
 130 
 131         procArgs[2] = "-XX:-TieredCompilation";
 132         procArgs[3] = "-XX:+PrintOptoAssembly";
 133         procArgs[4] = "-XX:CompileCommand=compileonly," + fullclassname + "::" + "test*";
 134         procArgs[5] = "--add-exports";
 135         procArgs[6] = "java.base/jdk.internal.misc=ALL-UNNAMED";
 136         procArgs[argcount - 1] = fullclassname;


 352                     "strb",
 353                     "membar_volatile \\(elided\\)",
 354                     "ret"
 355                 };
 356                 break;
 357             case "CMS":
 358                 // a volatile card mark membar should not be generated
 359                 // before the card mark strb from the StoreCM and the
 360                 // storestore barrier from the StoreCM should be
 361                 // generated as "dmb ishst"
 362                 matches = new String[] {
 363                     "membar_release \\(elided\\)",
 364                     useCompressedOops ? "stlrw?" : "stlr",
 365                     "storestore",
 366                     "dmb ishst",
 367                     "strb",
 368                     "membar_volatile \\(elided\\)",
 369                     "ret"
 370                 };
 371                 break;
 372             case "Shenandoah":
 373             case "ShenandoahTraversal":
 374                  // Shenandoah generates normal object graphs for
 375                  // volatile stores
 376                 matches = new String[] {
 377                     "membar_release (elided)",
 378                     "stlrw",
 379                     "membar_volatile (elided)",
 380                     "ret"
 381                 };
 382                 break;
 383             }
 384         } else {
 385             switch (testType) {
 386             default:
 387                 // this is the basic sequence of instructions
 388                 matches = new String[] {
 389                     "membar_release",
 390                     "dmb ish",
 391                     useCompressedOops ? "strw?" : "str",
 392                     "membar_volatile",
 393                     "dmb ish",
 394                     "ret"
 395                 };
 396                 break;
 397             case "G1":
 398                 // a card mark volatile barrier should be generated
 399                 // before the card mark strb
 400                 matches = new String[] {
 401                     "membar_release",
 402                     "dmb ish",


 426                     "ret"
 427                 };
 428                 break;
 429             case "CMS":
 430                 // a volatile card mark membar should not be generated
 431                 // before the card mark strb from the StoreCM and the
 432                 // storestore barrier from the StoreCM should be generated
 433                 // as "dmb ishst"
 434                 matches = new String[] {
 435                     "membar_release",
 436                     "dmb ish",
 437                     useCompressedOops ? "strw?" : "str",
 438                     "storestore",
 439                     "dmb ishst",
 440                     "strb",
 441                     "membar_volatile",
 442                     "dmb ish",
 443                     "ret"
 444                 };
 445                 break;
 446 
 447             case "Shenandoah":
 448             case "ShenandoahTraversal":
 449                  // Shenandoah generates normal object graphs for
 450                  // volatile stores
 451                 matches = new String[] {
 452                     "membar_release",
 453                     "dmb ish",
 454                     "strw",
 455                     "membar_volatile",
 456                     "dmb ish",
 457                     "ret"
 458                 };
 459                 break;
 460             }
 461         }
 462 
 463         checkCompile(iter, "testObj", matches, output, true);
 464     }
 465 
 466     // check for expected asm output from a volatile cas
 467 
 468     private void checkcas(OutputAnalyzer output, String testType, boolean useBarriersForVolatile, boolean useCompressedOops) throws Throwable
 469     {
 470         Iterator<String> iter = output.asLines().listIterator();
 471 
 472         String[] matches;
 473         String[][] tests = {
 474             { "testInt", "cmpxchgw" },
 475             { "testLong", "cmpxchg" },
 476             { "testByte", "cmpxchgb" },
 477             { "testShort", "cmpxchgs" },
 478         };
 479 


 542                     "storestore \\(elided\\)",
 543                     "strb",
 544                     "membar_acquire \\(elided\\)",
 545                     "ret"
 546                 };
 547                 break;
 548             case "CMS":
 549                 // a volatile card mark membar should not be generated
 550                 // before the card mark strb from the StoreCM and the
 551                 // storestore barrier from the StoreCM should be elided
 552                 matches = new String[] {
 553                     "membar_release \\(elided\\)",
 554                     useCompressedOops ? "cmpxchgw?_acq" : "cmpxchg_acq",
 555                     "storestore",
 556                     "dmb ishst",
 557                     "strb",
 558                     "membar_acquire \\(elided\\)",
 559                     "ret"
 560                 };
 561                 break;
 562             case "Shenandoah":
 563             case "ShenandoahTraversal":
 564                 // For volatile CAS, Shenanodoah generates normal
 565                 // graphs with a shenandoah-specific cmpxchg
 566                 matches = new String[] {
 567                     "membar_release (elided)",
 568                     "cmpxchgw_acq_shenandoah",
 569                     "membar_acquire (elided)",
 570                     "ret"
 571                 };
 572                 break;
 573             }
 574         } else {
 575             switch (testType) {
 576             default:
 577                 // this is the basic sequence of instructions
 578                 matches = new String[] {
 579                     "membar_release",
 580                     "dmb ish",
 581                     useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
 582                     "membar_acquire",
 583                     "dmb ish",
 584                     "ret"
 585                 };
 586                 break;
 587             case "G1":
 588                 // a card mark volatile barrier should be generated
 589                 // before the card mark strb
 590                 matches = new String[] {
 591                     "membar_release",
 592                     "dmb ish",


 792                     "dmb ish",
 793                     "storestore \\(elided\\)",
 794                     "strb",
 795                     "membar_acquire",
 796                     "dmb ish",
 797                     "ret"
 798                 };
 799                 break;
 800             case "CMS":
 801                 // a volatile card mark membar should not be generated
 802                 // before the card mark strb from the StoreCM and the
 803                 // storestore barrier from the StoreCM should be generated
 804                 // as "dmb ishst"
 805                 matches = new String[] {
 806                     "membar_release",
 807                     "dmb ish",
 808                     useCompressedOops ? "cmpxchgw? " : "cmpxchg ",
 809                     "storestore",
 810                     "dmb ishst",
 811                     "strb",
 812                     "membar_acquire",
 813                     "dmb ish",
 814                     "ret"
 815                 };
 816                 break;
 817             case "Shenandoah":
 818             case "ShenandoahTraversal":
 819                 // For volatile CAS, Shenanodoah generates normal
 820                 // graphs with a shenandoah-specific cmpxchg
 821                 matches = new String[] {
 822                     "membar_release",
 823                     "dmb ish",
 824                     "cmpxchgw_shenandoah",
 825                     "membar_acquire",
 826                     "dmb ish",
 827                     "ret"
 828                 };
 829                 break;
 830             }
 831         }
 832 
 833         checkCompile(iter, "testObj", matches, output, true);
 834     }
 835 
 836     private void checkgas(OutputAnalyzer output, String testType, boolean useBarriersForVolatile, boolean useCompressedOops) throws Throwable
 837     {
 838         Iterator<String> iter = output.asLines().listIterator();
 839 
 840         String[] matches;
 841         String[][] tests = {
 842             { "testInt", "atomic_xchgw" },
 843             { "testLong", "atomic_xchg" },
 844         };


< prev index next >