< prev index next > test/lib/jdk/test/lib/cds/CDSAppTester.java
Print this page
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;
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) {
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
}
// 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()) {
}
// 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()) {
} 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;
} 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;
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);
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;
}
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;
}
"-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);
}
"-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);
}
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;
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;
}
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);
}
}
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);
}
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);
}
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);
}
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);
}
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 {
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);
}
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);
}
}
}
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
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();
}
}
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 >