}
branch.log(TreeLogger.INFO, "Validation succeeded");
} else {
TreeLogger branch = logger.branch(TreeLogger.INFO,
"Precompiling module " + module.getName());
PropertyPermutations allPermutations = new PropertyPermutations(
module.getProperties());
int potentialPermutations = allPermutations.size();
int permutationsPerIteration = options.getMaxPermsPerPrecompile();
if (permutationsPerIteration <= 0) {
permutationsPerIteration = potentialPermutations;
}
/*
* The potential number of permutations to precompile >= the actual
* number of permutations that end up being precompiled, because some of
* the permutations might collapse due to identical rebind results. So
* we have to track these two counts and ids separately.
*/
int actualPermutations = 0;
for (int potentialFirstPerm = 0; potentialFirstPerm < potentialPermutations; potentialFirstPerm += permutationsPerIteration) {
int numPermsToPrecompile = Math.min(potentialPermutations
- potentialFirstPerm, permutationsPerIteration);
/*
* After the first precompile, we need to forcibly refresh
* CompilationState to clear out generated units from previous
* precompilations.
*/
if (potentialFirstPerm != 0) {
module.getCompilationState(branch).refresh(branch);
}
if (potentialFirstPerm + numPermsToPrecompile < potentialPermutations) {
/*
* On all iterations but the last, force retainCompilationState to
* be true. Otherwise, state will be discarded that is needed on
* later iterations.
*/
options.setCompilationStateRetained(true);
} else {
// On the last iteration, use whatever the original setting was
options.setCompilationStateRetained(originalCompilationStateRetained);
}
// Select only the range of property permutations that we want
PropertyPermutations localPermutations = new PropertyPermutations(
allPermutations, potentialFirstPerm, numPermsToPrecompile);
Precompilation precompilation = precompile(branch, options, module,
actualPermutations, localPermutations, options.getGenDir(),
compilerWorkDir, options.getDumpSignatureFile());