avrora.core
Class ProcedureMap

java.lang.Object
  extended byavrora.core.ProcedureMap

public class ProcedureMap
extends java.lang.Object

The ProcedureMap class represents a mapping from basic blocks to the procedures that contain them. Built by the ProcedureMapBuilder class and accessible through the ControlFlowGraph.getProcedureMap(), the ProcedureMap, the mapping is built by first recognized static call sites and marking their target basic blocks as procedure entry points. Those entrypoints are propagated through the control flow graph to all reachable basic blocks (ignoring call edges). If a basic block is reachable through more than one procedure entry, it is considered shared.

The result is a conservative approximation of which basic blocks are in which procedure. Given a basic block, this class can look up the basic block which represents the entrypoint of that procedure. Also, given the entrypoint of a procedure, the class can return a collection of the basic blocks that are reachable from that entrypoint.

Interrupt handlers are not considered the entrypoints of procedures.

See Also:
Program, ControlFlowGraph

Field Summary
protected  java.util.HashMap entryMap
           
protected  java.util.HashSet entryPoints
           
protected  java.util.HashMap procMap
           
 
Method Summary
 java.util.Collection getProcedureBlocks(ControlFlowGraph.Block entry)
          The getProcedureBlocks() method returns the collection of basic blocks contained in the procedure with the specified entrypoint.
 ControlFlowGraph.Block getProcedureContaining(ControlFlowGraph.Block b)
          The getProcedureContaining() method looks up the entrypoint of the procedure that contains this basic block.
 java.util.Collection getProcedureEntrypoints()
          The getProcedureEntrypoints() method returns a collection of basic blocks that are entrypoints of procedures in the control flow graph.
 boolean isInAnyProcedure(ControlFlowGraph.Block b)
          The isInAnyProcedure() method queries whether the specified basic block is reachable from any procedure entry point in the program.
 boolean isSharedBetweenProcedures(ControlFlowGraph.Block b)
          The isSharedBetweenProcedures() method queries whether the specified basic block is reachable from more than one procedure entrypoint.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

entryPoints

protected final java.util.HashSet entryPoints

entryMap

protected final java.util.HashMap entryMap

procMap

protected final java.util.HashMap procMap
Method Detail

isInAnyProcedure

public boolean isInAnyProcedure(ControlFlowGraph.Block b)
The isInAnyProcedure() method queries whether the specified basic block is reachable from any procedure entry point in the program.

Parameters:
b - the basic block to query
Returns:
true if this basic block is in one or more procedure; false otherwise

isSharedBetweenProcedures

public boolean isSharedBetweenProcedures(ControlFlowGraph.Block b)
The isSharedBetweenProcedures() method queries whether the specified basic block is reachable from more than one procedure entrypoint.

Parameters:
b - the basic block to query
Returns:
true if this basic block is reachable from more than one procedure; false otherwise

getProcedureContaining

public ControlFlowGraph.Block getProcedureContaining(ControlFlowGraph.Block b)
The getProcedureContaining() method looks up the entrypoint of the procedure that contains this basic block. If the block is not in any procedure, or if the block is shared by multiple procedures, then this method returns null.

Parameters:
b - the basic block to find the procedure of
Returns:
a reference to the unique ControlFlowGraph.Block instance that is the entrypoint of the procedure containing the specified basic block; null otherwise

getProcedureBlocks

public java.util.Collection getProcedureBlocks(ControlFlowGraph.Block entry)
The getProcedureBlocks() method returns the collection of basic blocks contained in the procedure with the specified entrypoint. If the block passed is not the entrypoint of any procedure, this method will return null.

Parameters:
entry - the basic block representing the entrypoint of the procedure
Returns:
a collection of the basic blocks contained in the procedure with the specified entrypoint

getProcedureEntrypoints

public java.util.Collection getProcedureEntrypoints()
The getProcedureEntrypoints() method returns a collection of basic blocks that are entrypoints of procedures in the control flow graph.

Returns:
a collection of basic blocks that are entrypoints to procedures