Class EscapeAnalyzer
- java.lang.Object
-
- com.tonic.analysis.simulation.heap.EscapeAnalyzer
-
public final class EscapeAnalyzer extends Object
Escape classifier for simulation heap allocation sites, driven by the heap's escape marks and reachability from them.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classEscapeAnalyzer.EscapeStateHow far an allocation escapes its allocating method.
-
Constructor Summary
Constructors Constructor Description EscapeAnalyzer(SimHeap heap)Creates an analyzer over an existing heap; results reflect the heap's state at each query.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description EscapeAnalyzer.EscapeStateanalyze(AllocationSite site)Classifies a site as globally escaping if the heap marked it escaped, it lands in a static field, or it is reachable from an escaped site.booleandefinitelyEscapes(AllocationSite site)Set<AllocationSite>getEscaping()Set<AllocationSite>getNonEscaping()Set<AllocationSite>getReachableFrom(AllocationSite root)Walks fields and array elements transitively from one site.booleanisReachableFrom(AllocationSite source, AllocationSite target)Tests whether one site can be reached by following fields and array elements from another.booleanmayEscape(AllocationSite site)StringtoString()
-
-
-
Constructor Detail
-
EscapeAnalyzer
public EscapeAnalyzer(SimHeap heap)
Creates an analyzer over an existing heap; results reflect the heap's state at each query.- Parameters:
heap- the simulation heap to inspect
-
-
Method Detail
-
analyze
public EscapeAnalyzer.EscapeState analyze(AllocationSite site)
Classifies a site as globally escaping if the heap marked it escaped, it lands in a static field, or it is reachable from an escaped site.- Parameters:
site- the allocation site to classify- Returns:
- the escape state; ARG_ESCAPE is never reported
-
getNonEscaping
public Set<AllocationSite> getNonEscaping()
- Returns:
- every heap site that classifies as NO_ESCAPE
-
getEscaping
public Set<AllocationSite> getEscaping()
- Returns:
- every heap site that does not classify as NO_ESCAPE
-
mayEscape
public boolean mayEscape(AllocationSite site)
- Parameters:
site- the allocation site to classify- Returns:
- true if the site is anything other than NO_ESCAPE
-
definitelyEscapes
public boolean definitelyEscapes(AllocationSite site)
- Parameters:
site- the allocation site to classify- Returns:
- true if the site is known to escape globally
-
getReachableFrom
public Set<AllocationSite> getReachableFrom(AllocationSite root)
Walks fields and array elements transitively from one site.- Parameters:
root- the site to start from- Returns:
- the reachable sites, including the root
-
isReachableFrom
public boolean isReachableFrom(AllocationSite source, AllocationSite target)
Tests whether one site can be reached by following fields and array elements from another.- Parameters:
source- the site to start fromtarget- the site to look for- Returns:
- true if target is reachable from source
-
-