}
// Check if 'i' is a call and uses a closure!
// If so, we need to process the closure for live variable info.
if (i instanceof CallInstr) {
CallInstr c = (CallInstr) i;
// SSS FIXME: This relies on the local opt. pass having run already
// so that the built closure from the previous instr. is propagated to the call site here.
// Formalize this dependency somewhere?
Operand o = c.getClosureArg();
// System.out.println("Processing closure: " + o + "-------");
if ((o != null) && (o instanceof MetaObject)) {
IRClosure cl = (IRClosure)((MetaObject)o).scope;
if (c.isLVADataflowBarrier()) {
processClosure(cl, lvp.getAllVars());
// Mark all variables live if 'c' is a dataflow barrier!
// System.out.println(".. call is a data flow barrier ..");
for (int j = 0; j < _setSize; j++)
_tmp.set(j);
}
else {
// Propagate current LVA state through the closure
// SSS FIXME: Think through this .. Is there any way out of having
// to recompute the entire lva for the closure each time through?
// 1. Collect variables live at this point.
List<Variable> liveVars = new ArrayList<Variable>();
for (int j = 0; j < _tmp.size(); j++) {
if (_tmp.get(j) == true) {
// System.out.println(lvp.getVariable(j) + " is live on exit of closure!");
liveVars.add(lvp.getVariable(j));
}
}
// System.out.println(" .. collected live on exit ..");
// 2. Run LVA on the closure
LiveVariablesProblem xlvp = processClosure(cl, liveVars);
// System.out.println("------- done with closure" + o);
// 3. Collect variables live on entry of the closure and merge that info into the current problem.
for (Variable y: xlvp.getVarsLiveOnEntry()) {
DataFlowVar dv = lvp.getDFVar(y);
// This can be null for vars used, but not defined! Yes, the source program is buggy ..
if (dv != null) {
// System.out.println(y + " is live on entry of the closure!");
_tmp.set(dv._id);
}
}
}
}
else if (c.isLVADataflowBarrier()) {
// Mark all variables live if 'c' is a dataflow barrier!
// System.out.println(".. call is a data flow barrier ..");
for (int j = 0; j < _setSize; j++)
_tmp.set(j);
}