Package it.unive.lisa.analysis
Class BackwardOptimizedAnalyzedCFG<A extends AbstractState<A>>
- java.lang.Object
-
- it.unive.lisa.util.datastructures.graph.code.CodeGraph<CFG,Statement,Edge>
-
- it.unive.lisa.program.cfg.CFG
-
- it.unive.lisa.analysis.BackwardAnalyzedCFG<A>
-
- it.unive.lisa.analysis.BackwardOptimizedAnalyzedCFG<A>
-
- Type Parameters:
A
- the type ofAbstractState
contained into the analysis state
- All Implemented Interfaces:
BaseLattice<BackwardAnalyzedCFG<A>>
,Lattice<BackwardAnalyzedCFG<A>>
,CodeMember
,Graph<CFG,Statement,Edge>
,StructuredObject
public class BackwardOptimizedAnalyzedCFG<A extends AbstractState<A>> extends BackwardAnalyzedCFG<A>
ABackwardAnalyzedCFG
that has been built using anOptimizedBackwardFixpoint
. This means that this graph will only contain results for widening points (that is,Statement
s that part ofCFG.getCycleEntries()
), exit statements (that is,Statement
s such thatStatement.stopsExecution()
holds), and hotspots (that is,Statement
s such thatLiSAConfiguration.hotspots
holds). Approximations for other statements can be retrieved throughgetUnwindedAnalysisStateBefore(Statement, FixpointConfiguration)
, that will first expand the results usingunwind(FixpointConfiguration)
.
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.analysis.BackwardAnalyzedCFG
CANNOT_COMPARE_ERROR, CANNOT_GLB_ERROR, CANNOT_LUB_ERROR, CANNOT_NARROW_ERROR, CANNOT_WIDEN_ERROR, exitStates, id, results
-
Fields inherited from class it.unive.lisa.util.datastructures.graph.code.CodeGraph
entrypoints, list
-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_STRING, TOP_STRING
-
-
Constructor Summary
Constructors Constructor Description BackwardOptimizedAnalyzedCFG(CFG cfg, ScopeId id, AnalysisState<A> singleton, InterproceduralAnalysis<A> interprocedural)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.BackwardOptimizedAnalyzedCFG(CFG cfg, ScopeId id, AnalysisState<A> singleton, java.util.Map<Statement,AnalysisState<A>> exitStates, java.util.Map<Statement,AnalysisState<A>> results, InterproceduralAnalysis<A> interprocedural)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.BackwardOptimizedAnalyzedCFG(CFG cfg, ScopeId id, StatementStore<A> exitStates, StatementStore<A> results, InterproceduralAnalysis<A> interprocedural)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description BackwardOptimizedAnalyzedCFG<A>
bottom()
Yields the bottom element of this lattice.AnalysisState<A>
getUnwindedAnalysisStateBefore(Statement st, FixpointConfiguration conf)
Yields the computed result at a given statement (exit state).BackwardOptimizedAnalyzedCFG<A>
glbAux(BackwardAnalyzedCFG<A> other)
Performs the greatest lower bound operation between this lattice element and the given one, assuming that base cases have already been handled.boolean
hasPreStateOf(Statement st)
Yields whether or not the non-unwinded results of this cfg contain the prestate of the given statement.BackwardOptimizedAnalyzedCFG<A>
lubAux(BackwardAnalyzedCFG<A> other)
Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.BackwardOptimizedAnalyzedCFG<A>
narrowingAux(BackwardAnalyzedCFG<A> other)
Performs the narrowing operation between this lattice element and the given one, assuming that base cases have already been handled.void
storePreStateOf(Statement st, AnalysisState<A> prestate)
Stores the given prestate for the statement in the non-unwinded results of this cfg, overwriting any existing value.BackwardOptimizedAnalyzedCFG<A>
top()
Yields the top element of this lattice.void
unwind(FixpointConfiguration conf)
Runs an ascending fixpoint computation starting with the results available in this graph, with the purpose of propagating the approximations held in this result to all the missing nodes.BackwardOptimizedAnalyzedCFG<A>
wideningAux(BackwardAnalyzedCFG<A> other)
Performs the widening operation between this lattice element and the given one, assuming that base cases have already been handled.-
Methods inherited from class it.unive.lisa.analysis.BackwardAnalyzedCFG
equals, getAnalysisStateAfter, getAnalysisStateBefore, getEntryState, getExitState, getId, hashCode, isBottom, isTop, lessOrEqualAux, representation, sameIDs
-
Methods inherited from class it.unive.lisa.program.cfg.CFG
addControlFlowStructure, backwardFixpoint, backwardFixpoint, backwardFixpoint, computeBasicBlocks, extractControlFlowStructures, fixpoint, fixpoint, fixpoint, getAllExitpoints, getBasicBlocks, getControlFlowStructureOf, getControlFlowStructures, getCycleEntries, getDescriptor, getGenericProgramPoint, getGuards, getIfThenElseGuards, getLoopGuards, getMostRecentGuard, getMostRecentIfThenElseGuard, getMostRecentLoopGuard, getNormalExitpoints, isGuarded, isInsideIfThenElse, isInsideLoop, preSimplify, simplify, toSerializableGraph, toString, validate
-
Methods inherited from class it.unive.lisa.util.datastructures.graph.code.CodeGraph
addEdge, addNode, addNode, containsEdge, containsNode, followersOf, getEdgeConnecting, getEdges, getEdgesConnecting, getEdgesCount, getEntrypoints, getIngoingEdges, getNodeList, getNodes, getNodesCount, getOutgoingEdges, isEqualTo, predecessorsOf, simplify
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.analysis.BaseLattice
glb, lessOrEqual, lub, narrowing, toString, widening
-
Methods inherited from interface it.unive.lisa.util.datastructures.graph.Graph
accept, toSerializableGraph
-
-
-
-
Constructor Detail
-
BackwardOptimizedAnalyzedCFG
public BackwardOptimizedAnalyzedCFG(CFG cfg, ScopeId id, AnalysisState<A> singleton, InterproceduralAnalysis<A> interprocedural)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.- Parameters:
cfg
- the original control flow graphid
- aScopeId
meant to identify this specific result based on how it has been producedsingleton
- an instance of theAnalysisState
containing the abstract state of the analysis that was executed, used to retrieve top and bottom valuesinterprocedural
- the analysis that have been used to produce this result, and that can be used to unwind the results
-
BackwardOptimizedAnalyzedCFG
public BackwardOptimizedAnalyzedCFG(CFG cfg, ScopeId id, AnalysisState<A> singleton, java.util.Map<Statement,AnalysisState<A>> exitStates, java.util.Map<Statement,AnalysisState<A>> results, InterproceduralAnalysis<A> interprocedural)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.- Parameters:
cfg
- the original control flow graphid
- aScopeId
meant to identify this specific result based on how it has been producedsingleton
- an instance of theAnalysisState
containing the abstract state of the analysis that was executed, used to retrieve top and bottom valuesexitStates
- the exit state for each exit point of the cfgresults
- the results of the fixpoint computationinterprocedural
- the analysis that have been used to produce this result, and that can be used to unwind the results
-
BackwardOptimizedAnalyzedCFG
public BackwardOptimizedAnalyzedCFG(CFG cfg, ScopeId id, StatementStore<A> exitStates, StatementStore<A> results, InterproceduralAnalysis<A> interprocedural)
Builds the control flow graph, storing the given mapping between nodes and fixpoint computation results.- Parameters:
cfg
- the original control flow graphid
- aScopeId
meant to identify this specific result based on how it has been producedexitStates
- the exit state for each exit point of the cfgresults
- the results of the fixpoint computationinterprocedural
- the analysis that have been used to produce this result, and that can be used to unwind the results
-
-
Method Detail
-
getUnwindedAnalysisStateBefore
public AnalysisState<A> getUnwindedAnalysisStateBefore(Statement st, FixpointConfiguration conf)
Yields the computed result at a given statement (exit state). If such a state is not available as it was discarded due to optimization, and fixpoint's results have not been unwinded yet, a fixpoint iteration is executed in-place throughunwind(FixpointConfiguration)
.- Parameters:
st
- the statementconf
- theFixpointConfiguration
to use for running the fast fixpoint computation- Returns:
- the result computed at the given statement
-
unwind
public void unwind(FixpointConfiguration conf)
Runs an ascending fixpoint computation starting with the results available in this graph, with the purpose of propagating the approximations held in this result to all the missing nodes.- Parameters:
conf
- theFixpointConfiguration
to use for running the fast fixpoint computation
-
hasPreStateOf
public boolean hasPreStateOf(Statement st)
Yields whether or not the non-unwinded results of this cfg contain the prestate of the given statement.- Parameters:
st
- the statement- Returns:
- whether or not a prestate for
st
exists
-
storePreStateOf
public void storePreStateOf(Statement st, AnalysisState<A> prestate)
Stores the given prestate for the statement in the non-unwinded results of this cfg, overwriting any existing value.- Parameters:
st
- the statementprestate
- the prestate
-
lubAux
public BackwardOptimizedAnalyzedCFG<A> lubAux(BackwardAnalyzedCFG<A> other) throws SemanticException
Description copied from interface:BaseLattice
Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
- Specified by:
lubAux
in interfaceBaseLattice<A extends AbstractState<A>>
- Overrides:
lubAux
in classBackwardAnalyzedCFG<A extends AbstractState<A>>
- Parameters:
other
- the other lattice element- Returns:
- the least upper bound between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
glbAux
public BackwardOptimizedAnalyzedCFG<A> glbAux(BackwardAnalyzedCFG<A> other) throws SemanticException
Description copied from interface:BaseLattice
Performs the greatest lower bound operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
- Specified by:
glbAux
in interfaceBaseLattice<A extends AbstractState<A>>
- Overrides:
glbAux
in classBackwardAnalyzedCFG<A extends AbstractState<A>>
- Parameters:
other
- the other lattice element- Returns:
- the greatest lower bound between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
wideningAux
public BackwardOptimizedAnalyzedCFG<A> wideningAux(BackwardAnalyzedCFG<A> other) throws SemanticException
Description copied from interface:BaseLattice
Performs the widening operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
BaseLattice.lubAux(BaseLattice)
, and is thus safe for finite lattices and ACC ones.- Specified by:
wideningAux
in interfaceBaseLattice<A extends AbstractState<A>>
- Overrides:
wideningAux
in classBackwardAnalyzedCFG<A extends AbstractState<A>>
- Parameters:
other
- the other lattice element- Returns:
- the widening between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
narrowingAux
public BackwardOptimizedAnalyzedCFG<A> narrowingAux(BackwardAnalyzedCFG<A> other) throws SemanticException
Description copied from interface:BaseLattice
Performs the narrowing operation between this lattice element and the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:other
is notnull
other
is neither top nor bottomthis
is neither top nor bottomthis
andother
are not the same object (according both to==
and toObject.equals(Object)
)
BaseLattice.glbAux(BaseLattice)
, and is thus safe for finite lattices and DCC ones.- Specified by:
narrowingAux
in interfaceBaseLattice<A extends AbstractState<A>>
- Overrides:
narrowingAux
in classBackwardAnalyzedCFG<A extends AbstractState<A>>
- Parameters:
other
- the other lattice element- Returns:
- the narrowing between this and other
- Throws:
SemanticException
- if an error occurs during the computation
-
top
public BackwardOptimizedAnalyzedCFG<A> top()
Description copied from interface:Lattice
Yields the top element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isTop()
uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isTop()
accordingly to provide a coherent test.- Specified by:
top
in interfaceLattice<A extends AbstractState<A>>
- Overrides:
top
in classBackwardAnalyzedCFG<A extends AbstractState<A>>
- Returns:
- the top element
-
bottom
public BackwardOptimizedAnalyzedCFG<A> bottom()
Description copied from interface:Lattice
Yields the bottom element of this lattice. The returned element should be unique across different calls to this method, sinceLattice.isBottom()
uses reference equality by default. If the value returned by this method is not a singleton, overrideLattice.isBottom()
accordingly to provide a coherent test.- Specified by:
bottom
in interfaceLattice<A extends AbstractState<A>>
- Overrides:
bottom
in classBackwardAnalyzedCFG<A extends AbstractState<A>>
- Returns:
- the bottom element
-
-