< prev index next >

test/hotspot/jtreg/runtime/cds/appcds/AOTFlags.java

Print this page
@@ -49,10 +49,16 @@
          positiveTests();
          negativeTests();
      }
  
      static void positiveTests() throws Exception {
+         String hasTrainingDataPattern = "MethodTrainingData *= *[1-9]";
+         String noTrainingDataPattern = "MethodTrainingData *= *0";
+         String hasAOTCodePattern = "Shared file region .ac. .: *[1-9]";
+         String noAOTCodePattern = "Shared file region .ac. .: *0";
+         String hasMappedAOTCodePattern = "Mapped [0-9]+ bytes at address 0x[0-9a-f]+ from AOT Code Cache";
+ 
          //----------------------------------------------------------------------
          printTestCase("Training Run");
          ProcessBuilder pb = ProcessTools.createLimitedTestJavaProcessBuilder(
              "-XX:AOTMode=record",
              "-XX:AOTConfiguration=" + aotConfigFile,

@@ -60,10 +66,12 @@
              "-cp", appJar, helloClass);
  
          OutputAnalyzer out = CDSTestUtils.executeAndLog(pb, "train");
          out.shouldContain("Hello World");
          out.shouldContain("AOTConfiguration recorded: " + aotConfigFile);
+         out.shouldMatch(hasTrainingDataPattern);
+         out.shouldMatch(noAOTCodePattern);
          out.shouldHaveExitValue(0);
  
          //----------------------------------------------------------------------
          printTestCase("Assembly Phase (AOTClassLinking unspecified -> should be enabled by default)");
          pb = ProcessTools.createLimitedTestJavaProcessBuilder(

@@ -73,22 +81,26 @@
              "-Xlog:cds",
              "-cp", appJar);
          out = CDSTestUtils.executeAndLog(pb, "asm");
          out.shouldContain("Dumping shared data to file:");
          out.shouldMatch("cds.*hello[.]aot");
+         out.shouldMatch(hasTrainingDataPattern);
+         out.shouldMatch(hasAOTCodePattern);
          out.shouldHaveExitValue(0);
  
          //----------------------------------------------------------------------
          printTestCase("Production Run with AOTCache");
          pb = ProcessTools.createLimitedTestJavaProcessBuilder(
              "-XX:AOTCache=" + aotCacheFile,
              "-Xlog:cds",
+             "-Xlog:aot+codecache*",
              "-cp", appJar, helloClass);
          out = CDSTestUtils.executeAndLog(pb, "prod");
          out.shouldContain("Using AOT-linked classes: true (static archive: has aot-linked classes)");
          out.shouldContain("Opened AOT cache hello.aot.");
          out.shouldContain("Hello World");
+         out.shouldMatch(hasMappedAOTCodePattern);
          out.shouldHaveExitValue(0);
  
          //----------------------------------------------------------------------
          printTestCase("AOTMode=off");
          pb = ProcessTools.createLimitedTestJavaProcessBuilder(

@@ -136,27 +148,107 @@
          pb = ProcessTools.createLimitedTestJavaProcessBuilder(
              "-XX:AOTMode=create",
              "-XX:-AOTClassLinking",
              "-XX:AOTConfiguration=" + aotConfigFile,
              "-XX:AOTCache=" + aotCacheFile,
-             "-Xlog:cds",
+             "-Xlog:cds=debug",
              "-cp", appJar);
          out = CDSTestUtils.executeAndLog(pb, "asm");
          out.shouldContain("Dumping shared data to file:");
          out.shouldMatch("cds.*hello[.]aot");
+         out.shouldMatch(noTrainingDataPattern);
+         out.shouldMatch(noAOTCodePattern);
          out.shouldHaveExitValue(0);
  
          //----------------------------------------------------------------------
          printTestCase("Production Run with AOTCache, which was created with -XX:-AOTClassLinking");
          pb = ProcessTools.createLimitedTestJavaProcessBuilder(
              "-XX:AOTCache=" + aotCacheFile,
              "-Xlog:cds",
+             "-Xlog:aot+codecache*",
              "-cp", appJar, helloClass);
          out = CDSTestUtils.executeAndLog(pb, "prod");
          out.shouldContain("Using AOT-linked classes: false (static archive: no aot-linked classes)");
          out.shouldContain("Opened AOT cache hello.aot.");
          out.shouldContain("Hello World");
+         out.shouldNotMatch(hasMappedAOTCodePattern);
+         out.shouldHaveExitValue(0);
+ 
+         //----------------------------------------------------------------------
+         printTestCase("Training run with -XX:-AOTClassLinking, but assembly run with -XX:+AOTClassLinking");
+         pb = ProcessTools.createLimitedTestJavaProcessBuilder(
+             "-XX:AOTMode=record",
+             "-XX:-AOTClassLinking",
+             "-XX:AOTConfiguration=" + aotConfigFile,
+             "-Xlog:cds=debug",
+             "-cp", appJar, helloClass);
+         out = CDSTestUtils.executeAndLog(pb, "train");
+         out.shouldContain("Hello World");
+         out.shouldContain("AOTConfiguration recorded: " + aotConfigFile);
+         out.shouldHaveExitValue(0);
+ 
+         pb = ProcessTools.createLimitedTestJavaProcessBuilder(
+             "-XX:AOTMode=create",
+             "-XX:+AOTClassLinking",
+             "-XX:AOTConfiguration=" + aotConfigFile,
+             "-XX:AOTCache=" + aotCacheFile,
+             "-Xlog:cds=debug",
+             "-cp", appJar);
+         out = CDSTestUtils.executeAndLog(pb, "asm");
+         out.shouldContain("Dumping shared data to file:");
+         out.shouldMatch("cds.*hello[.]aot");
+         out.shouldHaveExitValue(0);
+ 
+         //----------------------------------------------------------------------
+         printTestCase("One step training run (JEP-JDK-8354330");
+ 
+         // Set all AOTMode/AOTCacheOutput/AOTConfiguration
+         pb = ProcessTools.createLimitedTestJavaProcessBuilder(
+             "-XX:AOTMode=record",
+             "-XX:AOTCacheOutput=" + aotCacheFile,
+             "-XX:AOTConfiguration=" + aotConfigFile,
+             "-Xlog:cds=debug",
+             "-cp", appJar, helloClass);
+         out = CDSTestUtils.executeAndLog(pb, "ontstep-train");
+         out.shouldContain("Hello World");
+         out.shouldContain("AOTConfiguration recorded: " + aotConfigFile);
+         out.shouldContain("AOTCache creation is complete: hello.aot");
+         out.shouldHaveExitValue(0);
+ 
+         // Set AOTCacheOutput/AOTConfiguration only; Ergo for: AOTMode=record
+         pb = ProcessTools.createLimitedTestJavaProcessBuilder(
+             "-XX:AOTCacheOutput=" + aotCacheFile,
+             "-XX:AOTConfiguration=" + aotConfigFile,
+             "-Xlog:cds=debug",
+             "-cp", appJar, helloClass);
+         out = CDSTestUtils.executeAndLog(pb, "ontstep-train");
+         out.shouldContain("Hello World");
+         out.shouldContain("AOTConfiguration recorded: " + aotConfigFile);
+         out.shouldContain("AOTCache creation is complete: hello.aot");
+         out.shouldHaveExitValue(0);
+ 
+         // Set AOTCacheOutput only; Ergo for: AOTMode=record, AOTConfiguration=<temp>
+         pb = ProcessTools.createLimitedTestJavaProcessBuilder(
+             "-XX:AOTCacheOutput=" + aotCacheFile,
+             "-Xlog:cds=debug",
+             "-cp", appJar, helloClass);
+         out = CDSTestUtils.executeAndLog(pb, "ontstep-train");
+         out.shouldContain("Hello World");
+         out.shouldContain("Temporary AOTConfiguration recorded: " + aotCacheFile + ".config");
+         out.shouldContain("AOTCache creation is complete: hello.aot");
+         out.shouldHaveExitValue(0);
+ 
+         // Quoating of space characters in child JVM process
+         pb = ProcessTools.createLimitedTestJavaProcessBuilder(
+             "-XX:AOTCacheOutput=" + aotCacheFile,
+             "-Dmy.prop=My string -Xshare:off here", // -Xshare:off should not be treated as a single VM opt for the child JVM
+             "-Xlog:cds=debug",
+             "-cp", appJar, helloClass);
+         out = CDSTestUtils.executeAndLog(pb, "ontstep-train");
+         out.shouldContain("Hello World");
+         out.shouldContain("AOTCache creation is complete: hello.aot");
+         out.shouldMatch("Picked up JAVA_TOOL_OPTIONS:.* -Dmy.prop=My' 'string' '-Xshare:off' 'here");
          out.shouldHaveExitValue(0);
      }
  
      static void negativeTests() throws Exception {
         //----------------------------------------------------------------------

@@ -191,17 +283,17 @@
          out = CDSTestUtils.executeAndLog(pb, "neg");
          out.shouldContain("AOTConfiguration can only be used with -XX:AOTMode=record or -XX:AOTMode=create");
          out.shouldNotHaveExitValue(0);
  
          //----------------------------------------------------------------------
-         printTestCase("Use AOTMode without AOTConfiguration");
+         printTestCase("Use AOTMode without AOTCacheOutput or AOTConfiguration");
          pb = ProcessTools.createLimitedTestJavaProcessBuilder(
              "-XX:AOTMode=record",
              "-cp", appJar, helloClass);
  
          out = CDSTestUtils.executeAndLog(pb, "neg");
-         out.shouldContain("-XX:AOTMode=record cannot be used without setting AOTConfiguration");
+         out.shouldContain("-XX:AOTMode=record cannot be used without setting AOTCacheOutput or AOTConfiguration");
  
          pb = ProcessTools.createLimitedTestJavaProcessBuilder(
              "-XX:AOTMode=create",
              "-cp", appJar, helloClass);
  

@@ -230,18 +322,31 @@
          out = CDSTestUtils.executeAndLog(pb, "neg");
          out.shouldContain("AOTCache must not be specified when using -XX:AOTMode=record");
          out.shouldNotHaveExitValue(0);
  
          //----------------------------------------------------------------------
-         printTestCase("AOTCache not specified with -XX:AOTMode=create");
+         printTestCase("AOTCache/AOTCacheOutput not specified with -XX:AOTMode=create");
+         pb = ProcessTools.createLimitedTestJavaProcessBuilder(
+             "-XX:AOTMode=create",
+             "-XX:AOTConfiguration=" + aotConfigFile,
+             "-cp", appJar, helloClass);
+ 
+         out = CDSTestUtils.executeAndLog(pb, "neg");
+         out.shouldContain("AOTCache or AOTCacheOutput must be specified when using -XX:AOTMode=create");
+         out.shouldNotHaveExitValue(0);
+ 
+         //----------------------------------------------------------------------
+         printTestCase("AOTCache and AOTCacheOutput have different values");
          pb = ProcessTools.createLimitedTestJavaProcessBuilder(
              "-XX:AOTMode=create",
              "-XX:AOTConfiguration=" + aotConfigFile,
+             "-XX:AOTCache=aaa",
+             "-XX:AOTCacheOutput=bbb",
              "-cp", appJar, helloClass);
  
          out = CDSTestUtils.executeAndLog(pb, "neg");
-         out.shouldContain("AOTCache must be specified when using -XX:AOTMode=create");
+         out.shouldContain("AOTCache and AOTCacheOutput have different values");
          out.shouldNotHaveExitValue(0);
  
          //----------------------------------------------------------------------
          printTestCase("No such config file");
          pb = ProcessTools.createLimitedTestJavaProcessBuilder(

@@ -356,9 +461,9 @@
          out.shouldHaveExitValue(1);
      }
  
      static int testNum = 0;
      static void printTestCase(String s) {
-         System.out.println("vvvvvvv TEST CASE " + testNum + ": " + s + " starts here vvvvvvv");
+         System.out.println("vvvvvvv TEST CASE " + testNum + ": " + s + ": starts here vvvvvvv");
          testNum++;
      }
  }
< prev index next >