harpoon.Analysis.Quads
Class CachingCallGraph

java.lang.Object
  extended by jpaul.Graphs.DiGraph<HMethod>
      extended by harpoon.Analysis.CallGraph
          extended by harpoon.Analysis.Quads.CallGraph
              extended by harpoon.Analysis.Quads.CachingCallGraph

public class CachingCallGraph
extends CallGraph

CachingCallGraph is a caching wrapper for a call graph. In general, multiple stages in the compiler will use the call graph so it is good to cache it. You should manually take care of constructing a new call graph when you modify the code in some way that might invalidate the old call graph.

Version:
$Id: CachingCallGraph.java,v 1.5 2004/02/08 03:20:10 cananian Exp $
Author:
Alexandru SALCIANU <salcianu@MIT.edu>

Field Summary
 
Fields inherited from class harpoon.Analysis.CallGraph
navigator
 
Fields inherited from class jpaul.Graphs.DiGraph
CACHING
 
Constructor Summary
CachingCallGraph(CallGraph cg)
          Convenient to use constructor.
CachingCallGraph(CallGraph cg, boolean m_cache, boolean cs_cache)
          Creates a CachingCallGraph that caches the results of cg.
 
Method Summary
 Set callableMethods()
          Returns the set of all the methods that can be called in the execution of the program.
 HMethod[] calls(HMethod hm)
          Returns an array containing all possible methods called by method m.
 HMethod[] calls(HMethod hm, CALL cs)
          Returns an array containing all possible methods called by method m at the call site cs.
 CALL[] getCallSites(HMethod hm)
          Returns a list of all the CALLs quads in the code of hm.
 Set getRunMethods()
           
 void load_caches()
           
 
Methods inherited from class harpoon.Analysis.CallGraph
getBiDiNavigator, getForwardNavigator, getRoots
 
Methods inherited from class jpaul.Graphs.DiGraph
constructBiDiNavigator, dfs, dfs2, diGraph, diGraph, findPath, findPath, forAllVertices, getComponentDiGraph, numArcs, numVertices, reverseDiGraph, subDiGraph, toString, transitivePred, transitivePred, transitiveSucc, transitiveSucc, union, vertices
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CachingCallGraph

public CachingCallGraph(CallGraph cg,
                        boolean m_cache,
                        boolean cs_cache)
Creates a CachingCallGraph that caches the results of cg.

Parameters:
cg - underlying call graph (the one actually doing the job)
m_cache - specifies whether to cache the results of calls(HMethod hm)
cs_cache - specifies whether to cache the results of calls(HMethod hm, CALL cs)

CachingCallGraph

public CachingCallGraph(CallGraph cg)
Convenient to use constructor. If cg is a subclass of CallGraphImpl, it is equivalent to CallGraphImpl(cg, false, true) (CallGraphImpl already caches the callees of a method. Otherwise, it is equivalent to CallGraphImpl(cg, true, true) (full caching).

Parameters:
cg - underlying call graph
Method Detail

calls

public HMethod[] calls(HMethod hm)
Description copied from class: CallGraph
Returns an array containing all possible methods called by method m. If hm doesn't call any method, return an array of length 0.

Specified by:
calls in class CallGraph

calls

public HMethod[] calls(HMethod hm,
                       CALL cs)
Description copied from class: CallGraph
Returns an array containing all possible methods called by method m at the call site cs. If there is no known callee for the call site cs, or if cs doesn't belong to the code of hm, return an array of length 0.

Specified by:
calls in class CallGraph

getCallSites

public CALL[] getCallSites(HMethod hm)
Description copied from class: CallGraph
Returns a list of all the CALLs quads in the code of hm.

Specified by:
getCallSites in class CallGraph

callableMethods

public Set callableMethods()
Description copied from class: CallGraph
Returns the set of all the methods that can be called in the execution of the program.

Specified by:
callableMethods in class CallGraph

getRunMethods

public Set getRunMethods()
Overrides:
getRunMethods in class CallGraph
Returns:
set of all run() methods that may be the bodies of a thread started by the program (optional operation).

load_caches

public void load_caches()