Class PointBasedHeap
- java.lang.Object
-
- it.unive.lisa.analysis.BaseLattice<H>
-
- it.unive.lisa.analysis.heap.BaseHeapDomain<PointBasedHeap>
-
- it.unive.lisa.analysis.impl.heap.pointbased.PointBasedHeap
-
- All Implemented Interfaces:
HeapDomain<PointBasedHeap>,HeapSemanticOperation,Lattice<PointBasedHeap>,SemanticDomain<PointBasedHeap,SymbolicExpression,Identifier>
- Direct Known Subclasses:
FieldSensitivePointBasedHeap
public class PointBasedHeap extends BaseHeapDomain<PointBasedHeap>
A field-insensitive point-based heap implementation that abstracts heap locations depending on their allocation sites, namely the position of the code where heap locations are generated. All heap locations that are generated at the same allocation sites are abstracted into a single unique heap identifier. The implementation follows X. Rival and K. Yi, "Introduction to Static Analysis An Abstract Interpretation Perspective", Section 8.3.4
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected classPointBasedHeap.RewriterABaseHeapDomain.Rewriterfor thePointBasedHeapdomain.-
Nested classes/interfaces inherited from interface it.unive.lisa.analysis.heap.HeapSemanticOperation
HeapSemanticOperation.HeapReplacement
-
Nested classes/interfaces inherited from interface it.unive.lisa.analysis.SemanticDomain
SemanticDomain.Satisfiability
-
-
Field Summary
Fields Modifier and Type Field Description protected HeapEnvironment<AllocationSites>heapEnvAn heap environment tracking which allocation sites are associated to each identifier.-
Fields inherited from interface it.unive.lisa.analysis.Lattice
BOTTOM_REPR, BOTTOM_STRING, TOP_REPR, TOP_STRING
-
-
Constructor Summary
Constructors Modifier Constructor Description PointBasedHeap()Builds a new instance of field-insensitive point-based heap.protectedPointBasedHeap(HeapEnvironment<AllocationSites> heapEnv)Builds a new instance of field-insensitive point-based heap from its heap environment.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PointBasedHeapassign(Identifier id, SymbolicExpression expression, ProgramPoint pp)Yields a copy of this domain, whereidhas been assigned tovalue.PointBasedHeapassume(SymbolicExpression expression, ProgramPoint pp)Yields a copy of this domain, modified by assuming that the given expression holds.PointBasedHeapbottom()Yields the bottom element of this lattice.booleanequals(java.lang.Object obj)PointBasedHeapforgetIdentifier(Identifier id)Forgets anIdentifier.protected PointBasedHeapfrom(PointBasedHeap original)Builds a point-based heap from a reference one.java.util.List<HeapSemanticOperation.HeapReplacement>getSubstitution()Yields the substitution, in the form of a list ofHeapSemanticOperation.HeapReplacements that must be processed in their order of appearance, that the creation of this heap domain caused.inthashCode()booleanisBottom()Yieldstrueif and only if this object represents the bottom of the lattice.booleanisTop()Yieldstrueif and only if this object represents the top of the lattice.protected booleanlessOrEqualAux(PointBasedHeap other)Yieldstrueif and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled.protected PointBasedHeaplubAux(PointBasedHeap other)Performs the least upper bound operation between this lattice element and the given one, assuming that base cases have already been handled.PointBasedHeapmk(PointBasedHeap reference)Creates a new instance of this domain containing the same abstract information of reference.PointBasedHeappopScope(ScopeToken scope)Pops the scope identified by the given token from the domain.PointBasedHeappushScope(ScopeToken scope)Pushes a new scope, identified by the give token, in the domain.DomainRepresentationrepresentation()Yields aDomainRepresentationof the information contained in this domain's instance.ExpressionSet<ValueExpression>rewrite(SymbolicExpression expression, ProgramPoint pp)Rewrites aSymbolicExpression, getting rid of the parts that access heap structures, substituting them with syntheticHeapLocations representing the accessed locations.SemanticDomain.Satisfiabilitysatisfies(SymbolicExpression expression, ProgramPoint pp)Checks if the given expression is satisfied by the abstract values of this domain, returning an instance ofSemanticDomain.Satisfiability.protected PointBasedHeapsemanticsOf(HeapExpression expression, ProgramPoint pp)Yields a new instance of this domain, built by evaluating the semantics of the given heap expression.PointBasedHeaptop()Yields the top element of this lattice.protected PointBasedHeapwideningAux(PointBasedHeap 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.heap.BaseHeapDomain
smallStepSemantics, toString
-
Methods inherited from class it.unive.lisa.analysis.BaseLattice
lessOrEqual, lub, widening
-
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface it.unive.lisa.analysis.heap.HeapDomain
rewriteAll
-
Methods inherited from interface it.unive.lisa.analysis.Lattice
lessOrEqual, lub, widening
-
Methods inherited from interface it.unive.lisa.analysis.SemanticDomain
forgetIdentifiers
-
-
-
-
Field Detail
-
heapEnv
protected final HeapEnvironment<AllocationSites> heapEnv
An heap environment tracking which allocation sites are associated to each identifier.
-
-
Constructor Detail
-
PointBasedHeap
public PointBasedHeap()
Builds a new instance of field-insensitive point-based heap.
-
PointBasedHeap
protected PointBasedHeap(HeapEnvironment<AllocationSites> heapEnv)
Builds a new instance of field-insensitive point-based heap from its heap environment.- Parameters:
heapEnv- the heap environment that this instance tracks
-
-
Method Detail
-
from
protected PointBasedHeap from(PointBasedHeap original)
Builds a point-based heap from a reference one.- Parameters:
original- reference point-based heap- Returns:
- a point-based heap build from the original one
-
assign
public PointBasedHeap assign(Identifier id, SymbolicExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:SemanticDomainYields a copy of this domain, whereidhas been assigned tovalue.- Parameters:
id- the identifier to assign the value toexpression- the expression to assignpp- the program point that where this operation is being evaluated- Returns:
- a copy of this domain, modified by the assignment
- Throws:
SemanticException- if an error occurs during the computation
-
assume
public PointBasedHeap assume(SymbolicExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:SemanticDomainYields a copy of this domain, modified by assuming that the given expression holds. It is required that the returned domain is in relation with this one. A safe (but imprecise) implementation of this method can always returnthis.- Parameters:
expression- the expression to assume to hold.pp- the program point that where this operation is being evaluated- Returns:
- the (optionally) modified copy of this domain
- Throws:
SemanticException- if an error occurs during the computation
-
forgetIdentifier
public PointBasedHeap forgetIdentifier(Identifier id) throws SemanticException
Description copied from interface:SemanticDomainForgets anIdentifier. This means that all information regarding the givenidwill be lost. This method should be invoked whenever an identifier gets out of scope.- Parameters:
id- the identifier to forget- Returns:
- the semantic domain without information about the given id
- Throws:
SemanticException- if an error occurs during the computation
-
satisfies
public SemanticDomain.Satisfiability satisfies(SymbolicExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:SemanticDomainChecks if the given expression is satisfied by the abstract values of this domain, returning an instance ofSemanticDomain.Satisfiability.- Parameters:
expression- the expression whose satisfiability is to be evaluatedpp- the program point that where this operation is being evaluated- Returns:
SemanticDomain.Satisfiability.SATISFIEDis the expression is satisfied by the values of this domain,SemanticDomain.Satisfiability.NOT_SATISFIEDif it is not satisfied, orSemanticDomain.Satisfiability.UNKNOWNif it is either impossible to determine if it satisfied, or if it is satisfied by some values and not by some others (this is equivalent to a TOP boolean value)- Throws:
SemanticException- if an error occurs during the computation
-
representation
public DomainRepresentation representation()
Description copied from interface:SemanticDomainYields aDomainRepresentationof the information contained in this domain's instance.- Returns:
- the representation
-
top
public PointBasedHeap top()
Description copied from interface:LatticeYields 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.- Returns:
- the top element
-
isTop
public boolean isTop()
Description copied from interface:LatticeYieldstrueif and only if this object represents the top of the lattice. The default implementation of this method uses reference equality betweenthisand the value returned byLattice.top(), thus assuming that the top element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.- Returns:
trueif this is the top of the lattice
-
bottom
public PointBasedHeap bottom()
Description copied from interface:LatticeYields 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.- Returns:
- the bottom element
-
isBottom
public boolean isBottom()
Description copied from interface:LatticeYieldstrueif and only if this object represents the bottom of the lattice. The default implementation of this method uses reference equality betweenthisand the value returned byLattice.bottom(), thus assuming that the bottom element is a singleton. If this is not the case, override this method accordingly to provide a coherent test.- Returns:
trueif this is the bottom of the lattice
-
getSubstitution
public java.util.List<HeapSemanticOperation.HeapReplacement> getSubstitution()
Description copied from interface:HeapSemanticOperationYields the substitution, in the form of a list ofHeapSemanticOperation.HeapReplacements that must be processed in their order of appearance, that the creation of this heap domain caused. This substitution mapsIdentifiers in the pre-state toIdentifiers in the post state. If no substitution needs to be applied, this method should return an empty list.- Returns:
- the list of replacements
-
mk
public PointBasedHeap mk(PointBasedHeap reference)
Description copied from class:BaseHeapDomainCreates a new instance of this domain containing the same abstract information of reference. The returned object is effectively a new instance, meaning that all substitutions should be cleared. If this domain does not apply substitutions, it is fine to returnthis.- Specified by:
mkin classBaseHeapDomain<PointBasedHeap>- Parameters:
reference- the domain whose abstract information needs to be copied- Returns:
- a new instance of this domain
-
lubAux
protected PointBasedHeap lubAux(PointBasedHeap other) throws SemanticException
Description copied from class:BaseLatticePerforms 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:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
lubAuxin classBaseLattice<PointBasedHeap>- Parameters:
other- the other lattice element- Returns:
- the least upper bound between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
wideningAux
protected PointBasedHeap wideningAux(PointBasedHeap other) throws SemanticException
Description copied from class:BaseLatticePerforms 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:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
wideningAuxin classBaseLattice<PointBasedHeap>- Parameters:
other- the other lattice element- Returns:
- the widening between this and other
- Throws:
SemanticException- if an error occurs during the computation
-
lessOrEqualAux
protected boolean lessOrEqualAux(PointBasedHeap other) throws SemanticException
Description copied from class:BaseLatticeYieldstrueif and only if this lattice element is in relation with (usually represented through ≤) the given one, assuming that base cases have already been handled. In particular, it is guaranteed that:otheris notnullotheris neither top nor bottomthisis neither top nor bottomthisandotherare not the same object (according both to==and toObject.equals(Object))
- Specified by:
lessOrEqualAuxin classBaseLattice<PointBasedHeap>- Parameters:
other- the other lattice element- Returns:
trueif and only if that condition holds- Throws:
SemanticException- if an error occurs during the computation
-
hashCode
public int hashCode()
- Specified by:
hashCodein classBaseLattice<PointBasedHeap>
-
equals
public boolean equals(java.lang.Object obj)
- Specified by:
equalsin classBaseLattice<PointBasedHeap>
-
semanticsOf
protected PointBasedHeap semanticsOf(HeapExpression expression, ProgramPoint pp) throws SemanticException
Description copied from class:BaseHeapDomainYields a new instance of this domain, built by evaluating the semantics of the given heap expression.- Specified by:
semanticsOfin classBaseHeapDomain<PointBasedHeap>- Parameters:
expression- the expression to evaluatepp- the program point that where this expression is being evaluated- Returns:
- a new instance of this domain
- Throws:
SemanticException- if an error occurs during the computation
-
rewrite
public ExpressionSet<ValueExpression> rewrite(SymbolicExpression expression, ProgramPoint pp) throws SemanticException
Description copied from interface:HeapDomainRewrites aSymbolicExpression, getting rid of the parts that access heap structures, substituting them with syntheticHeapLocations representing the accessed locations. The expression returned by this method should not containHeapExpressions.
If no rewriting is necessary, the input expression can be returned instead.- Parameters:
expression- the expression to rewritepp- the program point that where this expression is being rewritten- Returns:
- the rewritten expression, or the original one
- Throws:
SemanticException- if something goes wrong during the rewriting
-
popScope
public PointBasedHeap popScope(ScopeToken scope) throws SemanticException
Description copied from interface:SemanticDomainPops the scope identified by the given token from the domain. This causes all the visible variables (i.e. that are not mapped to a scope) to be removed from the domain, while the local variables that were associated to the given scope token (and thus hidden) will become visible again.- Specified by:
popScopein interfaceSemanticDomain<PointBasedHeap,SymbolicExpression,Identifier>- Overrides:
popScopein classBaseHeapDomain<PointBasedHeap>- Parameters:
scope- the token of the scope to be restored- Returns:
- a copy of this domain where the local variables have been removed, while the variables mapped to the given scope are visible again
- Throws:
SemanticException- if an error occurs during the computation
-
pushScope
public PointBasedHeap pushScope(ScopeToken scope) throws SemanticException
Description copied from interface:SemanticDomainPushes a new scope, identified by the give token, in the domain. This causes information about all variables not associated with a scope (and thus visible) to be mapped to the given scope and hidden away, until the scope is popped withSemanticDomain.popScope(ScopeToken).- Specified by:
pushScopein interfaceSemanticDomain<PointBasedHeap,SymbolicExpression,Identifier>- Overrides:
pushScopein classBaseHeapDomain<PointBasedHeap>- Parameters:
scope- the token identifying the scope to push- Returns:
- a copy of this domain where the local variables have been hidden
- Throws:
SemanticException- if an error occurs during the computation
-
-