< prev index next >

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

Print this page




  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 /*
  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  * and <testtype> in {G1,
  36  *                    CMS,
  37  *                    CMSCondMark,
  38  *                    Serial,
  39  *                    Parallel}


  40  */
  41 
  42 
  43 package compiler.c2.aarch64;
  44 
  45 import java.util.List;
  46 import java.util.Iterator;
  47 import java.io.*;
  48 
  49 import jdk.test.lib.Asserts;
  50 import jdk.test.lib.compiler.InMemoryJavaCompiler;
  51 import jdk.test.lib.process.OutputAnalyzer;
  52 import jdk.test.lib.process.ProcessTools;
  53 
  54 // runner class that spawns a new JVM to exercises a combination of
  55 // volatile MemOp and GC. The ops are compiled with the dmb -->
  56 // ldar/stlr transforms either enabled or disabled. this runner parses
  57 // the PrintOptoAssembly output checking that the generated code is
  58 // correct.
  59 


  77             procArgs = new String[argcount];
  78             procArgs[argcount - 2] = "-XX:+UseParallelGC";
  79             break;
  80         case "Serial":
  81             argcount = 8;
  82             procArgs = new String[argcount];
  83             procArgs[argcount - 2] = "-XX:+UseSerialGC";
  84             break;
  85         case "CMS":
  86             argcount = 9 ;
  87             procArgs = new String[argcount];
  88             procArgs[argcount - 3] = "-XX:+UseConcMarkSweepGC";
  89             procArgs[argcount - 2] = "-XX:-UseCondCardMark";
  90             break;
  91         case "CMSCondMark":
  92             argcount = 9 ;
  93             procArgs = new String[argcount];
  94             procArgs[argcount - 3] = "-XX:+UseConcMarkSweepGC";
  95             procArgs[argcount - 2] = "-XX:+UseCondCardMark";
  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:-UseBarriersForVolatile";
 109 
 110         procArgs[1] = "-XX:-TieredCompilation";
 111         procArgs[2] = "-XX:+PrintOptoAssembly";
 112         procArgs[3] = "-XX:CompileCommand=compileonly," + fullclassname + "::" + "test*";
 113         procArgs[4] = "--add-exports";
 114         procArgs[5] = "java.base/jdk.internal.misc=ALL-UNNAMED";
 115         procArgs[argcount - 1] = fullclassname;
 116 


 300                     "strb",
 301                     "membar_volatile (elided)",
 302                     "ret"
 303                 };
 304                 break;
 305             case "CMS":
 306                 // a volatile card mark membar should not be generated
 307                 // before the card mark strb from the StoreCM and the
 308                 // storestore barrier from the StoreCM should be
 309                 // generated as "dmb ishst"
 310                 matches = new String[] {
 311                     "membar_release (elided)",
 312                     "stlrw",
 313                     "storestore",
 314                     "dmb ishst",
 315                     "strb",
 316                     "membar_volatile (elided)",
 317                     "ret"
 318                 };
 319                 break;











 320             }
 321         } else {
 322             switch (testType) {
 323             default:
 324                 // this is the basic sequence of instructions
 325                 matches = new String[] {
 326                     "membar_release",
 327                     "dmb ish",
 328                     "strw",
 329                     "membar_volatile",
 330                     "dmb ish",
 331                     "ret"
 332                 };
 333                 break;
 334             case "G1":
 335                 // a card mark volatile barrier should be generated
 336                 // before the card mark strb
 337                 matches = new String[] {
 338                     "membar_release",
 339                     "dmb ish",


 363                     "ret"
 364                 };
 365                 break;
 366             case "CMS":
 367                 // a volatile card mark membar should not be generated
 368                 // before the card mark strb from the StoreCM and the
 369                 // storestore barrier from the StoreCM should be generated
 370                 // as "dmb ishst"
 371                 matches = new String[] {
 372                     "membar_release",
 373                     "dmb ish",
 374                     "strw",
 375                     "storestore",
 376                     "dmb ishst",
 377                     "strb",
 378                     "membar_volatile",
 379                     "dmb ish",
 380                     "ret"
 381                 };
 382                 break;














 383             }
 384         }
 385 
 386         checkCompile(iter, "testObj", matches, output);
 387     }
 388 
 389     // check for expected asm output from a volatile cas
 390 
 391     private void checkcas(OutputAnalyzer output, String testType, boolean useBarriersForVolatile) throws Throwable
 392     {
 393         Iterator<String> iter = output.asLines().listIterator();
 394 
 395         String[] matches;
 396 
 397         // non object stores are straightforward
 398         if (!useBarriersForVolatile) {
 399             // this is the sequence of instructions for all cases
 400             matches = new String[] {
 401                 "membar_release (elided)",
 402                 "cmpxchgw_acq",


 457                     "storestore (elided)",
 458                     "strb",
 459                     "membar_acquire (elided)",
 460                     "ret"
 461                 };
 462                 break;
 463             case "CMS":
 464                 // a volatile card mark membar should not be generated
 465                 // before the card mark strb from the StoreCM and the
 466                 // storestore barrier from the StoreCM should be elided
 467                 matches = new String[] {
 468                     "membar_release (elided)",
 469                     "cmpxchgw_acq",
 470                     "storestore",
 471                     "dmb ishst",
 472                     "strb",
 473                     "membar_acquire (elided)",
 474                     "ret"
 475                 };
 476                 break;











 477             }
 478         } else {
 479             switch (testType) {
 480             default:
 481                 // this is the basic sequence of instructions
 482                 matches = new String[] {
 483                     "membar_release",
 484                     "dmb ish",
 485                     "cmpxchgw",
 486                     "membar_acquire",
 487                     "dmb ish",
 488                     "ret"
 489                 };
 490                 break;
 491             case "G1":
 492                 // a card mark volatile barrier should be generated
 493                 // before the card mark strb
 494                 matches = new String[] {
 495                     "membar_release",
 496                     "dmb ish",


 515                     "dmb ish",
 516                     "storestore (elided)",
 517                     "strb",
 518                     "membar_acquire",
 519                     "dmb ish",
 520                     "ret"
 521                 };
 522                 break;
 523             case "CMS":
 524                 // a volatile card mark membar should not be generated
 525                 // before the card mark strb from the StoreCM and the
 526                 // storestore barrier from the StoreCM should be generated
 527                 // as "dmb ishst"
 528                 matches = new String[] {
 529                     "membar_release",
 530                     "dmb ish",
 531                     "cmpxchgw",
 532                     "storestore",
 533                     "dmb ishst",
 534                     "strb",













 535                     "membar_acquire",
 536                     "dmb ish",
 537                     "ret"
 538                 };
 539                 break;
 540             }
 541         }
 542 
 543         checkCompile(iter, "testObj", matches, output);
 544     }
 545 
 546     // perform a check appropriate to the classname
 547 
 548     private void checkoutput(OutputAnalyzer output, String classname, String testType, boolean useBarriersForVolatile) throws Throwable
 549     {
 550         // trace call to allow eyeball check of what is being checked
 551         System.out.println("checkoutput(" +
 552                            classname + ", " +
 553                            testType + ", " +
 554                            useBarriersForVolatile + ")\n" +




  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 /*
  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  * and <testtype> in {G1,
  36  *                    CMS,
  37  *                    CMSCondMark,
  38  *                    Serial,
  39  *                    Parallel,
  40  *                    Shenandoah,
  41  *                    ShenandoahTraversal}
  42  */
  43 
  44 
  45 package compiler.c2.aarch64;
  46 
  47 import java.util.List;
  48 import java.util.Iterator;
  49 import java.io.*;
  50 
  51 import jdk.test.lib.Asserts;
  52 import jdk.test.lib.compiler.InMemoryJavaCompiler;
  53 import jdk.test.lib.process.OutputAnalyzer;
  54 import jdk.test.lib.process.ProcessTools;
  55 
  56 // runner class that spawns a new JVM to exercises a combination of
  57 // volatile MemOp and GC. The ops are compiled with the dmb -->
  58 // ldar/stlr transforms either enabled or disabled. this runner parses
  59 // the PrintOptoAssembly output checking that the generated code is
  60 // correct.
  61 


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


 314                     "strb",
 315                     "membar_volatile (elided)",
 316                     "ret"
 317                 };
 318                 break;
 319             case "CMS":
 320                 // a volatile card mark membar should not be generated
 321                 // before the card mark strb from the StoreCM and the
 322                 // storestore barrier from the StoreCM should be
 323                 // generated as "dmb ishst"
 324                 matches = new String[] {
 325                     "membar_release (elided)",
 326                     "stlrw",
 327                     "storestore",
 328                     "dmb ishst",
 329                     "strb",
 330                     "membar_volatile (elided)",
 331                     "ret"
 332                 };
 333                 break;
 334             case "Shenandoah":
 335             case "ShenandoahTraversal":
 336                  // Shenandoah generates normal object graphs for
 337                  // volatile stores
 338                 matches = new String[] {
 339                     "membar_release (elided)",
 340                     "stlrw",
 341                     "membar_volatile (elided)",
 342                     "ret"
 343                 };
 344                 break;
 345             }
 346         } else {
 347             switch (testType) {
 348             default:
 349                 // this is the basic sequence of instructions
 350                 matches = new String[] {
 351                     "membar_release",
 352                     "dmb ish",
 353                     "strw",
 354                     "membar_volatile",
 355                     "dmb ish",
 356                     "ret"
 357                 };
 358                 break;
 359             case "G1":
 360                 // a card mark volatile barrier should be generated
 361                 // before the card mark strb
 362                 matches = new String[] {
 363                     "membar_release",
 364                     "dmb ish",


 388                     "ret"
 389                 };
 390                 break;
 391             case "CMS":
 392                 // a volatile card mark membar should not be generated
 393                 // before the card mark strb from the StoreCM and the
 394                 // storestore barrier from the StoreCM should be generated
 395                 // as "dmb ishst"
 396                 matches = new String[] {
 397                     "membar_release",
 398                     "dmb ish",
 399                     "strw",
 400                     "storestore",
 401                     "dmb ishst",
 402                     "strb",
 403                     "membar_volatile",
 404                     "dmb ish",
 405                     "ret"
 406                 };
 407                 break;
 408 
 409             case "Shenandoah":
 410             case "ShenandoahTraversal":
 411                  // Shenandoah generates normal object graphs for
 412                  // volatile stores
 413                 matches = new String[] {
 414                     "membar_release",
 415                     "dmb ish",
 416                     "strw",
 417                     "membar_volatile",
 418                     "dmb ish",
 419                     "ret"
 420                 };
 421                 break;
 422             }
 423         }
 424 
 425         checkCompile(iter, "testObj", matches, output);
 426     }
 427 
 428     // check for expected asm output from a volatile cas
 429 
 430     private void checkcas(OutputAnalyzer output, String testType, boolean useBarriersForVolatile) throws Throwable
 431     {
 432         Iterator<String> iter = output.asLines().listIterator();
 433 
 434         String[] matches;
 435 
 436         // non object stores are straightforward
 437         if (!useBarriersForVolatile) {
 438             // this is the sequence of instructions for all cases
 439             matches = new String[] {
 440                 "membar_release (elided)",
 441                 "cmpxchgw_acq",


 496                     "storestore (elided)",
 497                     "strb",
 498                     "membar_acquire (elided)",
 499                     "ret"
 500                 };
 501                 break;
 502             case "CMS":
 503                 // a volatile card mark membar should not be generated
 504                 // before the card mark strb from the StoreCM and the
 505                 // storestore barrier from the StoreCM should be elided
 506                 matches = new String[] {
 507                     "membar_release (elided)",
 508                     "cmpxchgw_acq",
 509                     "storestore",
 510                     "dmb ishst",
 511                     "strb",
 512                     "membar_acquire (elided)",
 513                     "ret"
 514                 };
 515                 break;
 516             case "Shenandoah":
 517             case "ShenandoahTraversal":
 518                 // For volatile CAS, Shenanodoah generates normal
 519                 // graphs with a shenandoah-specific cmpxchg
 520                 matches = new String[] {
 521                     "membar_release (elided)",
 522                     "cmpxchgw_acq_shenandoah",
 523                     "membar_acquire (elided)",
 524                     "ret"
 525                 };
 526                 break;
 527             }
 528         } else {
 529             switch (testType) {
 530             default:
 531                 // this is the basic sequence of instructions
 532                 matches = new String[] {
 533                     "membar_release",
 534                     "dmb ish",
 535                     "cmpxchgw",
 536                     "membar_acquire",
 537                     "dmb ish",
 538                     "ret"
 539                 };
 540                 break;
 541             case "G1":
 542                 // a card mark volatile barrier should be generated
 543                 // before the card mark strb
 544                 matches = new String[] {
 545                     "membar_release",
 546                     "dmb ish",


 565                     "dmb ish",
 566                     "storestore (elided)",
 567                     "strb",
 568                     "membar_acquire",
 569                     "dmb ish",
 570                     "ret"
 571                 };
 572                 break;
 573             case "CMS":
 574                 // a volatile card mark membar should not be generated
 575                 // before the card mark strb from the StoreCM and the
 576                 // storestore barrier from the StoreCM should be generated
 577                 // as "dmb ishst"
 578                 matches = new String[] {
 579                     "membar_release",
 580                     "dmb ish",
 581                     "cmpxchgw",
 582                     "storestore",
 583                     "dmb ishst",
 584                     "strb",
 585                     "membar_acquire",
 586                     "dmb ish",
 587                     "ret"
 588                 };
 589                 break;
 590             case "Shenandoah":
 591             case "ShenandoahTraversal":
 592                 // For volatile CAS, Shenanodoah generates normal
 593                 // graphs with a shenandoah-specific cmpxchg
 594                 matches = new String[] {
 595                     "membar_release",
 596                     "dmb ish",
 597                     "cmpxchgw_shenandoah",
 598                     "membar_acquire",
 599                     "dmb ish",
 600                     "ret"
 601                 };
 602                 break;
 603             }
 604         }
 605 
 606         checkCompile(iter, "testObj", matches, output);
 607     }
 608 
 609     // perform a check appropriate to the classname
 610 
 611     private void checkoutput(OutputAnalyzer output, String classname, String testType, boolean useBarriersForVolatile) throws Throwable
 612     {
 613         // trace call to allow eyeball check of what is being checked
 614         System.out.println("checkoutput(" +
 615                            classname + ", " +
 616                            testType + ", " +
 617                            useBarriersForVolatile + ")\n" +


< prev index next >