Class 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.
    • 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 from
        target - the site to look for
        Returns:
        true if target is reachable from source