joeq.Compiler.Analysis.Primitive
Class PrimitiveMethodSummary

java.lang.Object
  extended by joeq.Compiler.Analysis.Primitive.PrimitiveMethodSummary

public class PrimitiveMethodSummary
extends Object

MethodSummary

Version:
$Id: PrimitiveMethodSummary.java 2465 2006-06-07 23:03:17Z joewhaley $
Author:
John Whaley

Nested Class Summary
static class PrimitiveMethodSummary.AccessPath
          Encodes an access path.
static class PrimitiveMethodSummary.BuildMethodSummary
          Visitor class to build an intramethod summary.
static class PrimitiveMethodSummary.CallSite
          Represents a particular call site in a method.
static class PrimitiveMethodSummary.CheckCastNode
          A CheckCastNode refers to the result of a CheckCast instruction
static class PrimitiveMethodSummary.ConcreteObjectNode
          A ConcreteObjectNode refers to an object that we discovered through reflection.
static class PrimitiveMethodSummary.ConcreteTypeNode
          A ConcreteTypeNode refers to an object with a concrete type.
static class PrimitiveMethodSummary.FakeParamNode
           
static class PrimitiveMethodSummary.FieldNode
          A FieldNode represents the result of a 'load' instruction.
static class PrimitiveMethodSummary.GlobalNode
          A GlobalNode stores references to the static variables.
static interface PrimitiveMethodSummary.HeapObject
           
static class PrimitiveMethodSummary.InsideEdgeNavigator
          Represents a field edge between two nodes.
static class PrimitiveMethodSummary.MethodSummaryBuilder
          Helper class to output method summary in dot graph format.
static class PrimitiveMethodSummary.Node
           
static class PrimitiveMethodSummary.NodeSet
           
static class PrimitiveMethodSummary.OperandToNodeMap
           
static class PrimitiveMethodSummary.OutsideNode
          An outside node is some node that can be mapped to other nodes.
static class PrimitiveMethodSummary.ParamNode
          A ParamNode represents an incoming parameter.
static class PrimitiveMethodSummary.PassedParameter
          Represents a particular parameter passed to a particular method call.
static class PrimitiveMethodSummary.PlaceholderNode
          A PlaceholderNode is used to signify an object that is out-of-scope.
static class PrimitiveMethodSummary.ReturnedNode
          A ReturnedNode represents a return value or thrown exception from a method call.
static class PrimitiveMethodSummary.ReturnValueNode
          A ReturnValueNode represents the return value of a method call.
static class PrimitiveMethodSummary.State
          Records the state of the intramethod analysis at some point in the method.
static class PrimitiveMethodSummary.ThrownExceptionNode
          A ThrownExceptionNode represents the thrown exception of a method call.
static class PrimitiveMethodSummary.UnknownTypeNode
          A UnknownTypeNode refers to an object with an unknown type.
static interface PrimitiveMethodSummary.Variable
           
 
Field Summary
static boolean CACHE_BUILDER
           
static HashMap clone_cache
          Cache of cloned method summaries.
static boolean DETERMINISTIC
           
static boolean DUMP_DOTGRAPH
           
static boolean IGNORE_INSTANCE_FIELDS
           
static boolean IGNORE_STATIC_FIELDS
           
static PrintStream out
           
static boolean SPLIT_THREADS
           
static boolean SSA
           
static Set ssaEntered
           
static Map stringNodes2Values
           
static HashMap summary_cache
          Holds the cache of method summary graphs.
static boolean TRACE_DOT
           
static boolean TRACE_INST
           
static boolean TRACE_INTER
           
static boolean TRACE_INTRA
           
static boolean TRACE_REGISTERS
           
static boolean UNIFY_ACCESS_PATHS
           
static boolean USE_IDENTITY_HASHCODE
           
static boolean USE_PARAMETER_MAP
           
static boolean VERIFY_ASSERTIONS
           
 
Constructor Summary
PrimitiveMethodSummary(PrimitiveMethodSummary.BuildMethodSummary builder, jq_Method method, PrimitiveMethodSummary.ParamNode[] param_nodes, PrimitiveMethodSummary.GlobalNode my_global, Set methodCalls, Map callToRVN, Map callToTEN, Map castMap, Set castPredecessors, Set returned, Set thrown, Set passedAsParameters, Map sync_ops, Collection string_nodes)
           
PrimitiveMethodSummary(PrimitiveMethodSummary.ParamNode[] param_nodes)
           
 
Method Summary
static boolean addToMultiMap(HashMap mm, Object from, Object to)
          Utility function to add to a multi map.
static boolean addToMultiMap(HashMap mm, Object from, Set to)
          Utility function to add to a multi map.
static void clearSummaryCache()
          Clear the method summary graph.
 PrimitiveMethodSummary copy()
          Return a deep copy of this analysis summary.
 void dotGraph(BufferedWriter out)
          Dumps this method summary as a dot graph.
static PrimitiveMethodSummary fakeCloneMethodSummary(jq_FakeInstanceMethod method)
          fake a method summary that simulates the effect of the inherited default clone().
static PrimitiveMethodSummary fakeMethodSummary(jq_Method method)
           
 Set getCalls()
          Get the set of method calls made by this method.
 Map getCastMap()
          Get the map of casts.
 PrimitiveMethodSummary.GlobalNode getGlobal()
          Get the global node for this method.
 jq_Method getMethod()
           
 Set getNodesThatCall(PrimitiveMethodSummary.PassedParameter pp)
          Return the set of nodes that are passed as the given parameter.
 void getNodesThatCall(PrimitiveMethodSummary.PassedParameter pp, Set result)
          Add all nodes that are passed as the given passed parameter to the given result set.
 Set getNodesThatCall(ProgramLocation mc, int k)
           
 int getNumOfParams()
          Get the number of parameters passed into this method.
 PrimitiveMethodSummary.ParamNode getParamNode(int i)
          Get the ith parameter node.
 Collection getRegisterAtLocation(BasicBlock bb, Quad q, RegisterFactory.Register r)
           
 Set getReturned()
          Get the set of returned nodes.
 PrimitiveMethodSummary.ReturnValueNode getRVN(ProgramLocation mc)
          Get the return value node corresponding to the given method call.
static PrimitiveMethodSummary getSummary(ControlFlowGraph cfg)
          Get the method summary for the given CFG.
static PrimitiveMethodSummary getSummary(ControlFlowGraph cfg, PrimitiveMethodSummary.CallSite cs)
          Get the (context-sensitive) method summary for the given control flow graph when called from the given call site.
static PrimitiveMethodSummary getSummary(jq_Method m)
          Get the method summary for the given method.
 Collection getSyncedVars()
           
 PrimitiveMethodSummary.ThrownExceptionNode getTEN(ProgramLocation mc)
          Get the thrown exception node corresponding to the given method call.
 Set getThrown()
          Get the set of thrown nodes.
 int hashCode()
           
static void instantiate(PrimitiveMethodSummary caller, ProgramLocation mc, PrimitiveMethodSummary callee, boolean removeCall)
          Instantiate a copy of the callee summary into the caller.
static boolean isNullConstant(PrimitiveMethodSummary.Node node)
           
static void main(String[] args)
           
 void mergeGlobal()
          Merge the global node for this method summary with the main global node.
 Iterator nodeIterator()
          Returns an iteration of all nodes in this summary.
 String toString()
          Return a string representation of this summary.
 void unifyAccessPathEdges(PrimitiveMethodSummary.Node n)
          Unify similar access path edges from the given node.
 void unifyAccessPaths(Set roots)
          Unify similar access paths from the given roots.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

out

public static PrintStream out

TRACE_INTRA

public static boolean TRACE_INTRA

TRACE_INTER

public static boolean TRACE_INTER

TRACE_INST

public static boolean TRACE_INST

TRACE_DOT

public static boolean TRACE_DOT

TRACE_REGISTERS

public static final boolean TRACE_REGISTERS
See Also:
Constant Field Values

IGNORE_INSTANCE_FIELDS

public static final boolean IGNORE_INSTANCE_FIELDS
See Also:
Constant Field Values

IGNORE_STATIC_FIELDS

public static final boolean IGNORE_STATIC_FIELDS
See Also:
Constant Field Values

VERIFY_ASSERTIONS

public static final boolean VERIFY_ASSERTIONS
See Also:
Constant Field Values

SSA

public static boolean SSA

USE_IDENTITY_HASHCODE

public static final boolean USE_IDENTITY_HASHCODE
See Also:
Constant Field Values

DETERMINISTIC

public static final boolean DETERMINISTIC
See Also:
Constant Field Values

SPLIT_THREADS

public static final boolean SPLIT_THREADS
See Also:
Constant Field Values

ssaEntered

public static Set ssaEntered

stringNodes2Values

public static Map stringNodes2Values

summary_cache

public static HashMap summary_cache
Holds the cache of method summary graphs.


clone_cache

public static HashMap clone_cache
Cache of cloned method summaries.


USE_PARAMETER_MAP

public static final boolean USE_PARAMETER_MAP
See Also:
Constant Field Values

CACHE_BUILDER

public static boolean CACHE_BUILDER

UNIFY_ACCESS_PATHS

public static final boolean UNIFY_ACCESS_PATHS
See Also:
Constant Field Values

DUMP_DOTGRAPH

public static final boolean DUMP_DOTGRAPH
Constructor Detail

PrimitiveMethodSummary

public PrimitiveMethodSummary(PrimitiveMethodSummary.ParamNode[] param_nodes)

PrimitiveMethodSummary

public PrimitiveMethodSummary(PrimitiveMethodSummary.BuildMethodSummary builder,
                              jq_Method method,
                              PrimitiveMethodSummary.ParamNode[] param_nodes,
                              PrimitiveMethodSummary.GlobalNode my_global,
                              Set methodCalls,
                              Map callToRVN,
                              Map callToTEN,
                              Map castMap,
                              Set castPredecessors,
                              Set returned,
                              Set thrown,
                              Set passedAsParameters,
                              Map sync_ops,
                              Collection string_nodes)
Method Detail

getSummary

public static PrimitiveMethodSummary getSummary(ControlFlowGraph cfg)
Get the method summary for the given CFG. Builds and caches it if it doesn't already exist.

Parameters:
cfg -
Returns:
summary for the given CFG

getSummary

public static PrimitiveMethodSummary getSummary(jq_Method m)
Get the method summary for the given method. If we know how to fake a method summary, do so.

Returns:
null if method has no bytecode and we do not know how to fake it

clearSummaryCache

public static void clearSummaryCache()
Clear the method summary graph.


getSummary

public static PrimitiveMethodSummary getSummary(ControlFlowGraph cfg,
                                                PrimitiveMethodSummary.CallSite cs)
Get the (context-sensitive) method summary for the given control flow graph when called from the given call site. If clone_cache is null, falls back to the context-insensitive version.

Parameters:
cfg -
cs -
Returns:
summary for the given CFG and context

getGlobal

public PrimitiveMethodSummary.GlobalNode getGlobal()
Get the global node for this method.


getParamNode

public PrimitiveMethodSummary.ParamNode getParamNode(int i)
Get the ith parameter node.


getNumOfParams

public int getNumOfParams()
Get the number of parameters passed into this method.


getCalls

public Set getCalls()
Get the set of method calls made by this method.


getNodesThatCall

public void getNodesThatCall(PrimitiveMethodSummary.PassedParameter pp,
                             Set result)
Add all nodes that are passed as the given passed parameter to the given result set.


getNodesThatCall

public Set getNodesThatCall(ProgramLocation mc,
                            int k)

getNodesThatCall

public Set getNodesThatCall(PrimitiveMethodSummary.PassedParameter pp)
Return the set of nodes that are passed as the given parameter.


mergeGlobal

public void mergeGlobal()
Merge the global node for this method summary with the main global node.


addToMultiMap

public static boolean addToMultiMap(HashMap mm,
                                    Object from,
                                    Object to)
Utility function to add to a multi map.


addToMultiMap

public static boolean addToMultiMap(HashMap mm,
                                    Object from,
                                    Set to)
Utility function to add to a multi map.


copy

public PrimitiveMethodSummary copy()
Return a deep copy of this analysis summary. Nodes, edges, everything is copied.


unifyAccessPaths

public void unifyAccessPaths(Set roots)
Unify similar access paths from the given roots. The given set is consumed.


unifyAccessPathEdges

public void unifyAccessPathEdges(PrimitiveMethodSummary.Node n)
Unify similar access path edges from the given node.


instantiate

public static void instantiate(PrimitiveMethodSummary caller,
                               ProgramLocation mc,
                               PrimitiveMethodSummary callee,
                               boolean removeCall)
Instantiate a copy of the callee summary into the caller.


getMethod

public jq_Method getMethod()

hashCode

public int hashCode()
Overrides:
hashCode in class Object

toString

public String toString()
Return a string representation of this summary.

Overrides:
toString in class Object

nodeIterator

public Iterator nodeIterator()
Returns an iteration of all nodes in this summary.


getReturned

public Set getReturned()
Get the set of returned nodes.


getThrown

public Set getThrown()
Get the set of thrown nodes.


getCastMap

public Map getCastMap()
Get the map of casts.


getRVN

public PrimitiveMethodSummary.ReturnValueNode getRVN(ProgramLocation mc)
Get the return value node corresponding to the given method call.


getTEN

public PrimitiveMethodSummary.ThrownExceptionNode getTEN(ProgramLocation mc)
Get the thrown exception node corresponding to the given method call.


getSyncedVars

public Collection getSyncedVars()

dotGraph

public void dotGraph(BufferedWriter out)
              throws IOException
Dumps this method summary as a dot graph.

Throws:
IOException

main

public static void main(String[] args)
                 throws IOException
Throws:
IOException

getRegisterAtLocation

public Collection getRegisterAtLocation(BasicBlock bb,
                                        Quad q,
                                        RegisterFactory.Register r)

fakeMethodSummary

public static PrimitiveMethodSummary fakeMethodSummary(jq_Method method)

fakeCloneMethodSummary

public static PrimitiveMethodSummary fakeCloneMethodSummary(jq_FakeInstanceMethod method)
fake a method summary that simulates the effect of the inherited default clone().


isNullConstant

public static boolean isNullConstant(PrimitiveMethodSummary.Node node)


Copyright © 2001-2008 John Whaley. All Rights Reserved.