Package it.unive.lisa.analysis
Class OptimizedAnalyzedCFG<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.AnalyzedCFG<A>
-
- it.unive.lisa.analysis.OptimizedAnalyzedCFG<A>
-
- Type Parameters:
A
- the type ofAbstractState
contained into the analysis state
- All Implemented Interfaces:
BaseLattice<AnalyzedCFG<A>>
,Lattice<AnalyzedCFG<A>>
,CodeMember
,Graph<CFG,Statement,Edge>
,StructuredObject
public class OptimizedAnalyzedCFG<A extends AbstractState<A>> extends AnalyzedCFG<A>
AnAnalyzedCFG
that has been built using anOptimizedFixpoint
. 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 throughgetUnwindedAnalysisStateAfter(Statement, FixpointConfiguration)
, that will first expand the results usingunwind(FixpointConfiguration)
.
-
-
Field Summary
-
Fields inherited from class it.unive.lisa.analysis.AnalyzedCFG
CANNOT_COMPARE_ERROR, CANNOT_GLB_ERROR, CANNOT_LUB_ERROR, CANNOT_NARROW_ERROR, CANNOT_WIDEN_ERROR, entryStates, 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 OptimizedAnalyzedCFG(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.OptimizedAnalyzedCFG(CFG cfg, ScopeId id, AnalysisState<A> singleton, java.util.Map<Statement,AnalysisState<A>> entryStates, 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.OptimizedAnalyzedCFG(CFG cfg, ScopeId id, StatementStore<A> entryStates, 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 OptimizedAnalyzedCFG<A>
bottom()
Yields the bottom element of this lattice.AnalysisState<A>
getUnwindedAnalysisStateAfter(Statement st, FixpointConfiguration conf)
Yields the computed result at a given statement (exit state).OptimizedAnalyzedCFG<A>
glbAux(AnalyzedCFG<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
hasPostStateOf(Statement st)
Yields whether or not the non-unwinded results of this cfg contain the poststate of the given statement.OptimizedAnalyzedCFG<A>
lubAux(AnalyzedCFG<A> other)
Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.OptimizedAnalyzedCFG<A>
narrowingAux(AnalyzedCFG<A> other)
Performs the narrowing operation between this lattice element and the given one, assuming that base cases have already been handled.void
storePostStateOf(Statement st, AnalysisState<A> postState)
Stores the given poststate for the statement in the non-unwinded results of this cfg, overwriting any existing value.OptimizedAnalyzedCFG<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.OptimizedAnalyzedCFG<A>
wideningAux(AnalyzedCFG<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.AnalyzedCFG
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
-
OptimizedAnalyzedCFG
public OptimizedAnalyzedCFG(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
-
OptimizedAnalyzedCFG
public OptimizedAnalyzedCFG(CFG cfg, ScopeId id, AnalysisState<A> singleton, java.util.Map<Statement,AnalysisState<A>> entryStates, 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 valuesentryStates
- the entry state for each entry 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
-
OptimizedAnalyzedCFG
public OptimizedAnalyzedCFG(CFG cfg, ScopeId id, StatementStore<A> entryStates, 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 producedentryStates
- the entry state for each entry 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
-
getUnwindedAnalysisStateAfter
public AnalysisState<A> getUnwindedAnalysisStateAfter(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
-
hasPostStateOf
public boolean hasPostStateOf(Statement st)
Yields whether or not the non-unwinded results of this cfg contain the poststate of the given statement.- Parameters:
st
- the statement- Returns:
- whether or not a poststate for
st
exists
-
storePostStateOf
public void storePostStateOf(Statement st, AnalysisState<A> postState)
Stores the given poststate for the statement in the non-unwinded results of this cfg, overwriting any existing value.- Parameters:
st
- the statementpostState
- the poststate
-
lubAux
public OptimizedAnalyzedCFG<A> lubAux(AnalyzedCFG<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 classAnalyzedCFG<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 OptimizedAnalyzedCFG<A> glbAux(AnalyzedCFG<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 classAnalyzedCFG<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 OptimizedAnalyzedCFG<A> wideningAux(AnalyzedCFG<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 classAnalyzedCFG<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 OptimizedAnalyzedCFG<A> narrowingAux(AnalyzedCFG<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 classAnalyzedCFG<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 OptimizedAnalyzedCFG<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 classAnalyzedCFG<A extends AbstractState<A>>
- Returns:
- the top element
-
bottom
public OptimizedAnalyzedCFG<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 classAnalyzedCFG<A extends AbstractState<A>>
- Returns:
- the bottom element
-
-