/*
* Compute the base fragment. It includes everything that is live when the
* program starts.
*/
LivenessPredicate alreadyLoaded = new NothingAlivePredicate();
LivenessPredicate liveNow = new CfaLivenessPredicate(initiallyLive);
List<JsStatement> noStats = new ArrayList<JsStatement>();
addFragment(0, alreadyLoaded, liveNow, noStats, fragmentStats);
}
/*
* Compute the base fragments, for split points in the initial load
* sequence.
*/
liveAfterInitialSequence = new ControlFlowAnalyzer(initiallyLive);
String extendsCfa = "initial";
for (int sp : initialLoadSequence) {
LivenessPredicate alreadyLoaded = new CfaLivenessPredicate(
liveAfterInitialSequence);
String depGraphName = "sp" + sp;
dependencyRecorder.startDependencyGraph(depGraphName, extendsCfa);
extendsCfa = depGraphName;
ControlFlowAnalyzer liveAfterSp = new ControlFlowAnalyzer(
liveAfterInitialSequence);
traverseEntry(liveAfterSp, sp);
dependencyRecorder.endDependencyGraph();
LivenessPredicate liveNow = new CfaLivenessPredicate(liveAfterSp);
List<JsStatement> statsToAppend = fragmentExtractor.createCallsToEntryMethods(sp);
addFragment(sp, alreadyLoaded, liveNow, statsToAppend, fragmentStats);
liveAfterInitialSequence = liveAfterSp;
}
ExclusivityMap fragmentMap = determineExclusivity();
/*
* Compute the exclusively live fragments. Each includes everything
* exclusively live after entry point i.
*/
for (int i = 1; i < numEntries; i++) {
if (isInitial(i)) {
continue;
}
LivenessPredicate alreadyLoaded = new ExclusivityMapLivenessPredicate(
fragmentMap, 0);
LivenessPredicate liveNow = new ExclusivityMapLivenessPredicate(
fragmentMap, i);
List<JsStatement> statsToAppend = fragmentExtractor.createCallsToEntryMethods(i);
addFragment(i, alreadyLoaded, liveNow, statsToAppend, fragmentStats);
}
/*
* Compute the leftovers fragment.
*/
{
LivenessPredicate alreadyLoaded = new CfaLivenessPredicate(
liveAfterInitialSequence);
LivenessPredicate liveNow = new ExclusivityMapLivenessPredicate(
fragmentMap, 0);
List<JsStatement> statsToAppend = fragmentExtractor.createCallToLeftoversFragmentHasLoaded();
addFragment(numEntries, alreadyLoaded, liveNow, statsToAppend,