// Recompute clinits each time, they can become empty.
jprogram.typeOracle.recomputeAfterOptimizations();
// jprogram.methodOracle =
// MethodOracleBuilder.buildMethodOracle(jprogram);
OptimizerStats stats = new OptimizerStats(passName);
// Remove unreferenced types, fields, methods, [params, locals]
stats.add(Pruner.exec(jprogram, true).recordVisits(numNodes));
// finalize locals, params, fields, methods, classes
stats.add(Finalizer.exec(jprogram).recordVisits(numNodes));
// rewrite non-polymorphic calls as static calls; update all call sites
stats.add(MakeCallsStatic.exec(jprogram).recordVisits(numNodes));
// type flow tightening
// - fields, locals based on assignment
// - params based on assignment and call sites
// - method bodies based on return statements
// - polymorphic methods based on return types of all implementors
// - optimize casts and instance of
stats.add(TypeTightener.exec(jprogram).recordVisits(numNodes));
// tighten method call bindings
stats.add(MethodCallTightener.exec(jprogram).recordVisits(numNodes));
// dead code removal??
stats.add(DeadCodeElimination.exec(jprogram).recordVisits(numNodes));
// inlining
stats.add(MethodInliner.exec(jprogram).recordVisits(numNodes));
if (isAggressivelyOptimize) {
// remove same parameters value
stats.add(SameParameterValueOptimizer.exec(jprogram).recordVisits(
numNodes));
/*
* Enum ordinalization.
*
* TODO(jbrosenberg): graduate this out of the 'isAggressivelyOptimize'
* block, over time.
*/
stats.add(EnumOrdinalizer.exec(jprogram).recordVisits(numNodes));
}
// prove that any types that have been culled from the main tree are
// unreferenced due to type tightening?