< prev index next >

test/lib/jdk/test/lib/cds/CDSAppTester.java

Print this page
*** 51,10 ***
--- 51,14 ---
      private final String staticArchiveFileLog;
      private final String aotCacheFile;
      private final String aotCacheFileLog;
      private final String dynamicArchiveFile;
      private final String dynamicArchiveFileLog;
+     private final String cdsFile;        // new workflow: -XX:CacheDataStore=<foo>.cds
+     private final String cdsFileLog;
+     private final String cdsFilePreImage;        // new workflow: -XX:CacheDataStore=<foo>.cds
+     private final String cdsFilePreImageLog;
      private final String tempBaseArchiveFile;
      private int numProductionRuns = 0;
      private String whiteBoxJar = null;
      private boolean inOneStepTraining = false;
  

*** 79,10 ***
--- 83,14 ---
          staticArchiveFileLog = logFileName(staticArchiveFile);
          aotCacheFile = name() + ".aot";
          aotCacheFileLog = logFileName(aotCacheFile);;
          dynamicArchiveFile = name() + ".dynamic.jsa";
          dynamicArchiveFileLog = logFileName(dynamicArchiveFile);
+         cdsFile = name() + ".cds";
+         cdsFileLog = logFileName(cdsFile);
+         cdsFilePreImage = cdsFile + ".preimage";
+         cdsFilePreImageLog = logFileName(cdsFilePreImage);
          tempBaseArchiveFile = name() + ".temp-base.jsa";
      }
  
      private String productionRunLog() {
          if (numProductionRuns == 0) {

*** 100,14 ***
--- 108,17 ---
  
      private enum Workflow {
          STATIC,        // classic -Xshare:dump workflow
          DYNAMIC,       // classic -XX:ArchiveClassesAtExit
          AOT,           // JEP 483 Ahead-of-Time Class Loading & Linking
+         LEYDEN,        // The new "one step training workflow" -- see JDK-8320264
      }
  
      public enum RunMode {
          TRAINING,       // -XX:DumpLoadedClassList OR {-XX:AOTMode=record -XX:AOTConfiguration}
+         TRAINING0,      // LEYDEN only
+         TRAINING1,      // LEYDEN only (assembly phase, app logic not executed)
          DUMP_STATIC,    // -Xshare:dump
          DUMP_DYNAMIC,   // -XX:ArchiveClassesArExit
          ASSEMBLY,       // JEP 483 (assembly phase, app logic not executed)
          PRODUCTION;     // Running with the CDS archive produced from the above steps
  

*** 119,11 ***
          }
  
          // When <code>CDSAppTester::checkExecution(out, runMode)</code> is called, has the application been
          // executed? If so, <code>out</code> should contain logs printed by the application's own logic.
          public boolean isApplicationExecuted() {
!             return (this != ASSEMBLY) && (this != DUMP_STATIC);
          }
      }
  
      public boolean isDumping(RunMode runMode) {
          if (isStaticWorkflow()) {
--- 130,11 ---
          }
  
          // When <code>CDSAppTester::checkExecution(out, runMode)</code> is called, has the application been
          // executed? If so, <code>out</code> should contain logs printed by the application's own logic.
          public boolean isApplicationExecuted() {
!             return (this != TRAINING1) && (this != ASSEMBLY) && (this != DUMP_STATIC);
          }
      }
  
      public boolean isDumping(RunMode runMode) {
          if (isStaticWorkflow()) {

*** 131,11 ***
          } else if (isDynamicWorkflow()) {
              return runMode == RunMode.DUMP_DYNAMIC;
          } else if (isAOTWorkflow()) {
              return runMode == RunMode.TRAINING || runMode == RunMode.ASSEMBLY;
          } else {
!             return false;
          }
      }
  
      public final String name() {
          return this.name;
--- 142,11 ---
          } else if (isDynamicWorkflow()) {
              return runMode == RunMode.DUMP_DYNAMIC;
          } else if (isAOTWorkflow()) {
              return runMode == RunMode.TRAINING || runMode == RunMode.ASSEMBLY;
          } else {
!             return runMode == RunMode.TRAINING || runMode == RunMode.TRAINING0 || runMode == RunMode.TRAINING1;
          }
      }
  
      public final String name() {
          return this.name;

*** 184,10 ***
--- 195,14 ---
  
      public final boolean isAOTWorkflow() {
          return workflow == Workflow.AOT;
      }
  
+     public final boolean isLeydenWorkflow() {
+         return workflow == Workflow.LEYDEN;
+     }
+ 
      private String logToFile(String logFile, String... logTags) {
          StringBuilder sb = new StringBuilder("-Xlog:arguments");
          String prefix = ",";
          for (String tag : logTags) {
              sb.append(prefix);

*** 214,11 ***
              listOutputFile(logFile);
          }
          if (checkExitValue) {
              output.shouldHaveExitValue(0);
          }
!         output.shouldNotContain(CDSTestUtils.MSG_STATIC_FIELD_MAY_HOLD_DIFFERENT_VALUE);
          CDSTestUtils.checkCommonExecExceptions(output);
          checkExecution(output, runMode);
          return output;
      }
  
--- 229,11 ---
              listOutputFile(logFile);
          }
          if (checkExitValue) {
              output.shouldHaveExitValue(0);
          }
!         //output.shouldNotContain(CDSTestUtils.MSG_STATIC_FIELD_MAY_HOLD_DIFFERENT_VALUE); // FIXME -- leyden+JEP483 merge
          CDSTestUtils.checkCommonExecExceptions(output);
          checkExecution(output, runMode);
          return output;
      }
  

*** 259,12 ***
                                                     "-XX:AOTMode=record",
                                                     "-XX:AOTConfiguration=" + aotConfigurationFile,
                                                     logToFile(aotConfigurationFileLog,
                                                               "class+load=debug",
                                                               "aot=debug",
!                                                              "cds=debug",
-                                                              "cds+class=debug"));
          cmdLine = addCommonVMArgs(runMode, cmdLine);
          cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode));
          return executeAndCheck(cmdLine, runMode, aotConfigurationFile, aotConfigurationFileLog);
      }
  
--- 274,11 ---
                                                     "-XX:AOTMode=record",
                                                     "-XX:AOTConfiguration=" + aotConfigurationFile,
                                                     logToFile(aotConfigurationFileLog,
                                                               "class+load=debug",
                                                               "aot=debug",
!                                                              "aot+class=debug"));
          cmdLine = addCommonVMArgs(runMode, cmdLine);
          cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode));
          return executeAndCheck(cmdLine, runMode, aotConfigurationFile, aotConfigurationFileLog);
      }
  

*** 273,12 ***
          String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode),
                                                     "-XX:AOTMode=record",
                                                     "-XX:AOTCacheOutput=" + aotCacheFile,
                                                     logToFile(aotCacheFileLog,
                                                               "class+load=debug",
!                                                              "cds=debug",
!                                                              "cds+class=debug"));
          cmdLine = addCommonVMArgs(runMode, cmdLine);
          cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode));
          OutputAnalyzer out =  executeAndCheck(cmdLine, runMode, aotCacheFile, aotCacheFileLog);
          listOutputFile(aotCacheFileLog + ".0"); // the log file for the training run
          return out;
--- 287,12 ---
          String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode),
                                                     "-XX:AOTMode=record",
                                                     "-XX:AOTCacheOutput=" + aotCacheFile,
                                                     logToFile(aotCacheFileLog,
                                                               "class+load=debug",
!                                                              "aot=debug",
!                                                              "aot+class=debug"));
          cmdLine = addCommonVMArgs(runMode, cmdLine);
          cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode));
          OutputAnalyzer out =  executeAndCheck(cmdLine, runMode, aotCacheFile, aotCacheFileLog);
          listOutputFile(aotCacheFileLog + ".0"); // the log file for the training run
          return out;

*** 297,21 ***
      }
  
      private OutputAnalyzer dumpStaticArchive() throws Exception {
          RunMode runMode = RunMode.DUMP_STATIC;
          String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode),
-                                                    "-Xlog:aot",
-                                                    "-Xlog:aot+heap=error",
                                                     "-Xlog:cds",
                                                     "-Xshare:dump",
                                                     "-XX:SharedArchiveFile=" + staticArchiveFile,
                                                     "-XX:SharedClassListFile=" + classListFile,
                                                     logToFile(staticArchiveFileLog,
-                                                              "aot=debug",
                                                               "cds=debug",
                                                               "cds+class=debug",
!                                                              "aot+heap=warning",
                                                               "cds+resolve=debug"));
          cmdLine = addCommonVMArgs(runMode, cmdLine);
          cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode));
          return executeAndCheck(cmdLine, runMode, staticArchiveFile, staticArchiveFileLog);
      }
--- 311,19 ---
      }
  
      private OutputAnalyzer dumpStaticArchive() throws Exception {
          RunMode runMode = RunMode.DUMP_STATIC;
          String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode),
                                                     "-Xlog:cds",
+                                                    "-Xlog:cds+heap=error",
                                                     "-Xshare:dump",
                                                     "-XX:SharedArchiveFile=" + staticArchiveFile,
                                                     "-XX:SharedClassListFile=" + classListFile,
                                                     logToFile(staticArchiveFileLog,
                                                               "cds=debug",
                                                               "cds+class=debug",
!                                                              "cds+heap=warning",
                                                               "cds+resolve=debug"));
          cmdLine = addCommonVMArgs(runMode, cmdLine);
          cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode));
          return executeAndCheck(cmdLine, runMode, staticArchiveFile, staticArchiveFileLog);
      }

*** 319,20 ***
      private OutputAnalyzer createAOTCache() throws Exception {
          RunMode runMode = RunMode.ASSEMBLY;
          String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode),
                                                     "-Xlog:aot",
                                                     "-Xlog:aot+heap=error",
-                                                    "-Xlog:cds",
                                                     "-XX:AOTMode=create",
                                                     "-XX:AOTConfiguration=" + aotConfigurationFile,
                                                     "-XX:AOTCache=" + aotCacheFile,
                                                     logToFile(aotCacheFileLog,
                                                               "aot=debug",
!                                                              "cds=debug",
-                                                              "cds+class=debug",
                                                               "aot+heap=warning",
!                                                              "cds+resolve=debug"));
          cmdLine = addCommonVMArgs(runMode, cmdLine);
          cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode));
          return executeAndCheck(cmdLine, runMode, aotCacheFile, aotCacheFileLog);
      }
  
--- 331,18 ---
      private OutputAnalyzer createAOTCache() throws Exception {
          RunMode runMode = RunMode.ASSEMBLY;
          String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode),
                                                     "-Xlog:aot",
                                                     "-Xlog:aot+heap=error",
                                                     "-XX:AOTMode=create",
                                                     "-XX:AOTConfiguration=" + aotConfigurationFile,
                                                     "-XX:AOTCache=" + aotCacheFile,
                                                     logToFile(aotCacheFileLog,
                                                               "aot=debug",
!                                                              "aot+class=debug",
                                                               "aot+heap=warning",
!                                                              "aot+resolve=debug"));
          cmdLine = addCommonVMArgs(runMode, cmdLine);
          cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode));
          return executeAndCheck(cmdLine, runMode, aotCacheFile, aotCacheFileLog);
      }
  

*** 372,11 ***
            cmdLine = StringArrayUtils.concat(vmArgs(runMode),
                                              "-Xlog:aot",
                                              "-Xlog:cds",
                                              "-XX:ArchiveClassesAtExit=" + dynamicArchiveFile,
                                              logToFile(dynamicArchiveFileLog,
-                                                       "aot=debug",
                                                        "cds=debug",
                                                        "cds+class=debug",
                                                        "cds+resolve=debug",
                                                        "class+load=debug"));
            cmdLine = addCommonVMArgs(runMode, cmdLine);
--- 382,10 ---

*** 386,10 ***
--- 395,73 ---
          }
          cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode));
          return executeAndCheck(cmdLine, runMode, dynamicArchiveFile, dynamicArchiveFileLog);
      }
  
+     private String trainingLog(String file) {
+         return logToFile(file,
+                          "cds=debug",
+                          "cds+class=debug",
+                          "cds+heap=warning",
+                          "cds+resolve=debug");
+     }
+ 
+     // normal training workflow (main JVM process spawns child process)
+     private OutputAnalyzer trainingRun() throws Exception {
+         RunMode runMode = RunMode.TRAINING;
+         File f = new File(cdsFile);
+         f.delete();
+         String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode),
+                                                    "-XX:+AOTClassLinking",
+                                                    "-XX:+ArchiveDynamicProxies",
+                                                  //"-XX:+ArchiveReflectionData",
+                                                    "-XX:CacheDataStore=" + cdsFile,
+                                                    "-cp", classpath(runMode),
+                                                    // Use PID to distinguish the logs of the training process
+                                                    // and the forked final image dump process.
+                                                    "-Xlog:cds::uptime,level,tags,pid",
+                                                    trainingLog(cdsFileLog));
+         cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode));
+         OutputAnalyzer out =  executeAndCheck(cmdLine, runMode, cdsFile, cdsFileLog);
+         listOutputFile(cdsFileLog + ".0"); // the preimage dump
+         return out;
+     }
+ 
+     // "split" training workflow (launch the two processes manually, for easier debugging);
+     private OutputAnalyzer trainingRun0() throws Exception {
+         RunMode runMode = RunMode.TRAINING0;
+         File f = new File(cdsFile);
+         f.delete();
+         String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode),
+                                                    "-XX:+UnlockDiagnosticVMOptions",
+                                                    "-XX:+CDSManualFinalImage",
+                                                    "-XX:+AOTClassLinking",
+                                                    "-XX:+ArchiveDynamicProxies",
+                                                  //"-XX:+ArchiveReflectionData",
+                                                    "-XX:CacheDataStore=" + cdsFile,
+                                                    "-cp", classpath(runMode),
+                                                    trainingLog(cdsFilePreImageLog));
+         cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode));
+         return executeAndCheck(cmdLine, runMode, cdsFilePreImage, cdsFilePreImageLog);
+     }
+     private OutputAnalyzer trainingRun1() throws Exception {
+         RunMode runMode = RunMode.TRAINING1;
+         File f = new File(cdsFile);
+         f.delete();
+         String[] cmdLine = StringArrayUtils.concat(vmArgs(runMode),
+                                                    "-XX:+UnlockDiagnosticVMOptions",
+                                                    "-XX:+AOTClassLinking",
+                                                    "-XX:+ArchiveDynamicProxies",
+                                                  //"-XX:+ArchiveReflectionData",
+                                                    "-XX:CacheDataStore=" + cdsFile,
+                                                    "-XX:CDSPreimage=" + cdsFilePreImage,
+                                                    "-cp", classpath(runMode),
+                                                    trainingLog(cdsFileLog));
+         cmdLine = StringArrayUtils.concat(cmdLine, appCommandLine(runMode));
+         return executeAndCheck(cmdLine, runMode, cdsFile, cdsFileLog);
+     }
+ 
      public OutputAnalyzer productionRun() throws Exception {
          return productionRun(null, null);
      }
  
      public OutputAnalyzer productionRun(String[] extraVmArgs) throws Exception {

*** 410,10 ***
--- 482,12 ---
              cmdLine = StringArrayUtils.concat(cmdLine, "-Xshare:on", "-XX:SharedArchiveFile=" + staticArchiveFile);
          } else if (isDynamicWorkflow()) {
              cmdLine = StringArrayUtils.concat(cmdLine, "-Xshare:on", "-XX:SharedArchiveFile=" + dynamicArchiveFile);
         } else if (isAOTWorkflow()) {
              cmdLine = StringArrayUtils.concat(cmdLine, "-XX:AOTMode=on", "-XX:AOTCache=" + aotCacheFile);
+         } else {
+             cmdLine = StringArrayUtils.concat(cmdLine, "-XX:CacheDataStore=" + cdsFile);
          }
  
          if (extraVmArgs != null) {
              cmdLine = StringArrayUtils.concat(cmdLine, extraVmArgs);
          }

*** 444,10 ***
--- 518,14 ---
                  runStaticWorkflow();
              } else if (args[0].equals("DYNAMIC")) {
                  runDynamicWorkflow();
              } else if (args[0].equals("AOT")) {
                  runAOTWorkflow(args);
+             } else if (args[0].equals("LEYDEN")) {
+                 runLeydenWorkflow(false);
+             } else if (args[0].equals("LEYDEN_TRAINONLY")) {
+                 runLeydenWorkflow(true);
              } else {
                  throw new RuntimeException(err);
              }
          }
      }

*** 463,10 ***
--- 541,17 ---
          this.workflow = Workflow.DYNAMIC;
          dumpDynamicArchive();
          productionRun();
      }
  
+     // See JEP 483; stop at the assembly run; do not execute production run
+     public void runAOTAssemblyWorkflow() throws Exception {
+         this.workflow = Workflow.AOT;
+         recordAOTConfiguration();
+         createAOTCache();
+     }
+ 
      // See JEP 483
      public void runAOTWorkflow(String... args) throws Exception {
          this.workflow = Workflow.AOT;
          boolean oneStepTraining = true; // by default use onestep trainning
  

*** 498,12 ***
              createAOTCache();
          }
          productionRun();
      }
  
!     // See JEP 483; stop at the assembly run; do not execute production run
!     public void runAOTAssemblyWorkflow() throws Exception {
!         this.workflow = Workflow.AOT;
!         recordAOTConfiguration();
!         createAOTCache();
      }
  }
--- 583,18 ---
              createAOTCache();
          }
          productionRun();
      }
  
!     private void runLeydenWorkflow(boolean trainOnly) throws Exception {
!         this.workflow = Workflow.LEYDEN;
!         if (System.getProperty("CDSAppTester.split.new.workflow") != null) {
!             trainingRun0();
!             trainingRun1();
+         } else {
+             trainingRun();
+         }
+         if (!trainOnly) {
+             productionRun();
+         }
      }
  }
< prev index next >