soot.jimple.toolkits.thread.mhp
Class PegGraph

java.lang.Object
  extended by soot.jimple.toolkits.thread.mhp.PegGraph
All Implemented Interfaces:
Iterable, DirectedGraph

public class PegGraph
extends Object
implements DirectedGraph

Oct. 7, 2003 modify buildPegChain() for building chain without inliner. June 19, 2003 add begin node to peg June 18, 2003 modify the iterator() to be iterator for all nodes of PEG and mainIterator() to be the iterator for main chain. June 12, 2003 add monitor Map, notifyAll Map, waitingNodes Map.


Field Summary
protected  Map<AllocNode,String> allocNodeToObj
           
protected  Map<AllocNode,PegChain> allocNodeToThread
           
protected  Map<JPegStmt,Chain> joinStmtToThread
           
 HashMap startToAllocNodes
           
 HashMap<JPegStmt,List> startToThread
           
protected  Map threadNameToStart
           
protected  Map threadNo
           
protected  HashMap<Object,List> unitToPreds
           
protected  HashMap<Object,List> unitToSuccs
           
 
Constructor Summary
PegGraph(CallGraph callGraph, Hierarchy hierarchy, PAG pag, Set<Object> methodsNeedingInlining, Set<AllocNode> allocNodes, List inlineSites, Map synchObj, Set<AllocNode> multiRunAllocNodes, Map allocNodeToObj, Body unitBody, SootMethod sm, boolean addExceptionEdges, boolean dontAddEdgeFromStmtBeforeAreaOfProtectionToCatchBlock)
          Constructs a graph for the units found in the provided Body instance.
PegGraph(CallGraph callGraph, Hierarchy hierarchy, PAG pag, Set methodsNeedingInlining, Set allocNodes, List<List> inlineSites, Map<SootMethod,String> synchObj, Set multiRunAllocNodes, Map<AllocNode,String> allocNodeToObj, Body unitBody, String threadName, SootMethod sm, boolean addExceEdge, boolean dontAddEdgeFromStmtBeforeAreaOfProtectionToCatchBlock)
          Constructs a graph for the units found in the provided Body instance.
 
Method Summary
protected  void addMonitorStmt()
           
 boolean addPeg(PegGraph pg, Chain chain)
           
protected  void addTag()
           
protected  void buildMaps(PegGraph pg)
           
protected  void buildPreds()
           
protected  void buildSuccsForInlining(JPegStmt stmt, Chain chain, PegGraph inlinee)
           
protected  void computeEdgeAndThreadNo()
           
 void computeMonitorObjs()
           
protected  FlowSet getAllNodes()
           
protected  Map<AllocNode,String> getAllocNodeToObj()
           
 Map<AllocNode,PegChain> getAllocNodeToThread()
           
 Body getBody()
           
 Set getCanNotBeCompacted()
           
protected  Set<Unit> getExceHandlers()
           
 List getHeads()
          Returns a list of entry points for this graph.
protected  Map<JPegStmt,Chain> getJoinStmtToThread()
           
 PegChain getMainPegChain()
           
 Set getMethodsNeedingInlining()
           
 Map<String,FlowSet> getMonitor()
           
 Set<Object> getMonitorObjs()
           
protected  boolean getNeedInlining()
           
 Map<String,Set<JPegStmt>> getNotifyAll()
           
 List getPredsOf(Object s)
          Returns a list of predecessors for the given node in the graph.
protected  Set<JPegStmt> getSpecialJoin()
           
 Map getStartToAllocNodes()
           
protected  Map getStartToBeginNodes()
           
 Map<JPegStmt,List> getStartToThread()
           
 List getSuccsOf(Object s)
          Returns a list of successors for the given node in the graph.
 HashSet<List> getSynch()
           
 List getTails()
          Returns a list of exit points for this graph.
protected  Set getThreadAllocSites()
           
protected  Map getThreadNameToStart()
           
protected  Map getUnitToPegMap()
           
protected  HashMap getUnitToPreds()
           
protected  HashMap getUnitToSuccs()
           
protected  Map<String,FlowSet> getWaitingNodes()
           
 Iterator iterator()
          Returns an iterator for the nodes in this graph.
 Iterator mainIterator()
           
protected  void setMonitor(Map<String,FlowSet> m)
           
 int size()
          Returns the node count for this graph.
protected  void testIterator()
           
protected  void testJoinStmtToThread()
           
protected  void testList(List list)
           
 void testMonitor()
           
protected  void testPegChain(Chain chain)
           
protected  void testSet(Set set, String name)
           
protected  void testStartToThread()
           
protected  void testSynch()
           
protected  void testThreadNameToStart()
           
protected  void testUnitToPeg(HashMap unitToPeg)
           
protected  void testUnitToPred()
           
protected  void testUnitToSucc()
           
 void testWaitingNodes()
           
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

unitToSuccs

protected HashMap<Object,List> unitToSuccs

unitToPreds

protected HashMap<Object,List> unitToPreds

startToThread

public HashMap<JPegStmt,List> startToThread

startToAllocNodes

public HashMap startToAllocNodes

threadNo

protected Map threadNo

threadNameToStart

protected Map threadNameToStart

allocNodeToObj

protected Map<AllocNode,String> allocNodeToObj

allocNodeToThread

protected Map<AllocNode,PegChain> allocNodeToThread

joinStmtToThread

protected Map<JPegStmt,Chain> joinStmtToThread
Constructor Detail

PegGraph

public PegGraph(CallGraph callGraph,
                Hierarchy hierarchy,
                PAG pag,
                Set<Object> methodsNeedingInlining,
                Set<AllocNode> allocNodes,
                List inlineSites,
                Map synchObj,
                Set<AllocNode> multiRunAllocNodes,
                Map allocNodeToObj,
                Body unitBody,
                SootMethod sm,
                boolean addExceptionEdges,
                boolean dontAddEdgeFromStmtBeforeAreaOfProtectionToCatchBlock)
Constructs a graph for the units found in the provided Body instance. Each node in the graph corresponds to a unit. The edges are derived from the control flow.

Parameters:
Body - The underlying body of main thread
addExceptionEdges - If true then the control flow edges associated with exceptions are added.
Hierarchy - Using class hierarchy analysis to find the run method of started thread
PointsToAnalysis - Using point to analysis (SPARK package) to improve the precision of results

PegGraph

public PegGraph(CallGraph callGraph,
                Hierarchy hierarchy,
                PAG pag,
                Set methodsNeedingInlining,
                Set allocNodes,
                List<List> inlineSites,
                Map<SootMethod,String> synchObj,
                Set multiRunAllocNodes,
                Map<AllocNode,String> allocNodeToObj,
                Body unitBody,
                String threadName,
                SootMethod sm,
                boolean addExceEdge,
                boolean dontAddEdgeFromStmtBeforeAreaOfProtectionToCatchBlock)
Constructs a graph for the units found in the provided Body instance. Each node in the graph corresponds to a unit. The edges are derived from the control flow.

Parameters:
body - The underlying body we want to make a graph for.
addExceptionEdges - If true then the control flow edges associated with exceptions are added.
dontAddEdgeFromStmtBeforeAreaOfProtectionToCatchBlock - This was added for Dava. If true, edges are not added from statement before area of protection to catch. If false, edges ARE added. For Dava, it should be true. For flow analyses, it should be false.
Hierarchy - Using class hierarchy analysis to find the run method of started thread
PointsToAnalysis - Using point to analysis (SPARK package) to improve the precision of results
Method Detail

getStartToBeginNodes

protected Map getStartToBeginNodes()

getJoinStmtToThread

protected Map<JPegStmt,Chain> getJoinStmtToThread()

getUnitToPegMap

protected Map getUnitToPegMap()

addMonitorStmt

protected void addMonitorStmt()

addPeg

public boolean addPeg(PegGraph pg,
                      Chain chain)

buildSuccsForInlining

protected void buildSuccsForInlining(JPegStmt stmt,
                                     Chain chain,
                                     PegGraph inlinee)

buildMaps

protected void buildMaps(PegGraph pg)

buildPreds

protected void buildPreds()

computeMonitorObjs

public void computeMonitorObjs()

getNeedInlining

protected boolean getNeedInlining()

getAllNodes

protected FlowSet getAllNodes()

getUnitToSuccs

protected HashMap getUnitToSuccs()

getUnitToPreds

protected HashMap getUnitToPreds()

getBody

public Body getBody()

getHeads

public List getHeads()
Description copied from interface: DirectedGraph
Returns a list of entry points for this graph.

Specified by:
getHeads in interface DirectedGraph

getTails

public List getTails()
Description copied from interface: DirectedGraph
Returns a list of exit points for this graph.

Specified by:
getTails in interface DirectedGraph

getPredsOf

public List getPredsOf(Object s)
Description copied from interface: DirectedGraph
Returns a list of predecessors for the given node in the graph.

Specified by:
getPredsOf in interface DirectedGraph

getSuccsOf

public List getSuccsOf(Object s)
Description copied from interface: DirectedGraph
Returns a list of successors for the given node in the graph.

Specified by:
getSuccsOf in interface DirectedGraph

getCanNotBeCompacted

public Set getCanNotBeCompacted()

size

public int size()
Description copied from interface: DirectedGraph
Returns the node count for this graph.

Specified by:
size in interface DirectedGraph

mainIterator

public Iterator mainIterator()

iterator

public Iterator iterator()
Description copied from interface: DirectedGraph
Returns an iterator for the nodes in this graph. No specific ordering of the nodes is guaranteed.

Specified by:
iterator in interface Iterable
Specified by:
iterator in interface DirectedGraph

toString

public String toString()
Overrides:
toString in class Object

getExceHandlers

protected Set<Unit> getExceHandlers()

setMonitor

protected void setMonitor(Map<String,FlowSet> m)

getMonitor

public Map<String,FlowSet> getMonitor()

getMonitorObjs

public Set<Object> getMonitorObjs()

getThreadAllocSites

protected Set getThreadAllocSites()

getSpecialJoin

protected Set<JPegStmt> getSpecialJoin()

getSynch

public HashSet<List> getSynch()

getStartToThread

public Map<JPegStmt,List> getStartToThread()

getStartToAllocNodes

public Map getStartToAllocNodes()

getWaitingNodes

protected Map<String,FlowSet> getWaitingNodes()

getNotifyAll

public Map<String,Set<JPegStmt>> getNotifyAll()

getAllocNodeToObj

protected Map<AllocNode,String> getAllocNodeToObj()

getAllocNodeToThread

public Map<AllocNode,PegChain> getAllocNodeToThread()

getThreadNameToStart

protected Map getThreadNameToStart()

getMainPegChain

public PegChain getMainPegChain()

getMethodsNeedingInlining

public Set getMethodsNeedingInlining()

testIterator

protected void testIterator()

testWaitingNodes

public void testWaitingNodes()

testStartToThread

protected void testStartToThread()

testUnitToPeg

protected void testUnitToPeg(HashMap unitToPeg)

testUnitToSucc

protected void testUnitToSucc()

testUnitToPred

protected void testUnitToPred()

addTag

protected void addTag()

testSynch

protected void testSynch()

testThreadNameToStart

protected void testThreadNameToStart()

testJoinStmtToThread

protected void testJoinStmtToThread()

testPegChain

protected void testPegChain(Chain chain)

computeEdgeAndThreadNo

protected void computeEdgeAndThreadNo()

testList

protected void testList(List list)

testSet

protected void testSet(Set set,
                       String name)

testMonitor

public void testMonitor()