class LiveVariablesAnalysis extends DataFlowAnalysis<Node,LiveVariablesAnalysis.LiveVariableLattice>
Due to the possibility of inner functions and closures, certain "local"
variables can escape the function. These variables will be considered as
global and they can be retrieved with getEscapedLocals().
| Modifier and Type | Class and Description |
|---|---|
private static class |
LiveVariablesAnalysis.LiveVariableJoinOp |
(package private) static class |
LiveVariablesAnalysis.LiveVariableLattice
The lattice that stores the liveness of all local variables at a given
point in the program.
|
DataFlowAnalysis.BranchedFlowState<L extends LatticeElement>, DataFlowAnalysis.BranchedForwardDataFlowAnalysis<N,L extends LatticeElement>, DataFlowAnalysis.FlowState<L extends LatticeElement>, DataFlowAnalysis.MaxIterationsExceededException| Modifier and Type | Field and Description |
|---|---|
static java.lang.String |
ARGUMENT_ARRAY_ALIAS |
private java.util.Set<Var> |
escaped |
private Scope |
jsScope |
(package private) static int |
MAX_VARIABLES_TO_ANALYZE |
joinOp, MAX_STEPS, orderedWorkSet| Constructor and Description |
|---|
LiveVariablesAnalysis(ControlFlowGraph<Node> cfg,
Scope jsScope,
AbstractCompiler compiler) |
| Modifier and Type | Method and Description |
|---|---|
private void |
addToSetIfLocal(Node node,
BitSet set) |
private void |
computeGenKill(Node n,
BitSet gen,
BitSet kill,
boolean conditional)
Computes the GEN and KILL set.
|
(package private) LiveVariablesAnalysis.LiveVariableLattice |
createEntryLattice()
Gets the incoming state of the entry node.
|
(package private) LiveVariablesAnalysis.LiveVariableLattice |
createInitialEstimateLattice()
Gets the state of the initial estimation at each node.
|
(package private) LiveVariablesAnalysis.LiveVariableLattice |
flowThrough(Node node,
LiveVariablesAnalysis.LiveVariableLattice input)
Computes the output state for a given node and input state.
|
java.util.Set<? extends Var> |
getEscapedLocals() |
int |
getVarIndex(java.lang.String var) |
private boolean |
isArgumentsName(Node n) |
(package private) boolean |
isForward()
Checks whether the analysis is a forward flow analysis or backward flow
analysis.
|
(package private) void |
markAllParametersEscaped()
Give up computing liveness of formal parameter by putting all the parameter
names in the escaped set.
|
analyze, analyze, computeEscaped, flow, getCfg, getExitLatticeElement, initialize, join, joinInputsstatic final int MAX_VARIABLES_TO_ANALYZE
public static final java.lang.String ARGUMENT_ARRAY_ALIAS
private final Scope jsScope
private final java.util.Set<Var> escaped
LiveVariablesAnalysis(ControlFlowGraph<Node> cfg, Scope jsScope, AbstractCompiler compiler)
public java.util.Set<? extends Var> getEscapedLocals()
public int getVarIndex(java.lang.String var)
boolean isForward()
DataFlowAnalysisisForward in class DataFlowAnalysis<Node,LiveVariablesAnalysis.LiveVariableLattice>true if it is a forward analysis.LiveVariablesAnalysis.LiveVariableLattice createEntryLattice()
DataFlowAnalysiscreateEntryLattice in class DataFlowAnalysis<Node,LiveVariablesAnalysis.LiveVariableLattice>LiveVariablesAnalysis.LiveVariableLattice createInitialEstimateLattice()
DataFlowAnalysiscreateInitialEstimateLattice in class DataFlowAnalysis<Node,LiveVariablesAnalysis.LiveVariableLattice>LiveVariablesAnalysis.LiveVariableLattice flowThrough(Node node, LiveVariablesAnalysis.LiveVariableLattice input)
DataFlowAnalysisflowThrough in class DataFlowAnalysis<Node,LiveVariablesAnalysis.LiveVariableLattice>node - The node.input - Input lattice that should be read-only.private void computeGenKill(Node n, BitSet gen, BitSet kill, boolean conditional)
n - Root node.gen - Local variables that are live because of the instruction at
n will be added to this set.kill - Local variables that are killed because of the instruction at
n will be added to this set.conditional - true if any assignments encountered are
conditionally executed. These assignments might not kill a variable.void markAllParametersEscaped()
private boolean isArgumentsName(Node n)