class AbstractCommandLineRunner {
/**
* Runs the Compiler and calls System.exit() with the exit status of the
* compiler.
*/
final public void run() {
int result = 0;
int runs = 1;
if (config.computePhaseOrdering) {
runs = NUM_RUNS_TO_DETERMINE_OPTIMAL_ORDER;
PhaseOptimizer.randomizeLoops();
}
try {
for (int i = 0; i < runs && result == 0; i++) {
runTimeStats.recordStartRun();
result = doRun();
runTimeStats.recordEndRun();
}
} catch (AbstractCommandLineRunner.FlagUsageException e) {
System.err.println(e.getMessage());
result = -1;
} catch (Throwable t) {
t.printStackTrace();
result = -2;
}
if (config.computePhaseOrdering) {
runTimeStats.outputBestPhaseOrdering();
}
if (testMode) {
exitCodeReceiverForTesting.apply(result);
} else {
System.exit(result);
}
}
}