Package com.tonic.analysis.ssa.cfg
Class IRMethod
- java.lang.Object
-
- com.tonic.analysis.ssa.cfg.IRMethod
-
public class IRMethod extends Object
A method in SSA form: its CFG blocks plus parameters, exception handlers, and lowering metadata.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classIRMethod.SourceLocalA source-declared variable (the receiver, a parameter, or a body local) and the SSA value(s) it lowered to.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddBlock(IRBlock block)Adds a basic block to this method.voidaddExceptionHandler(ExceptionHandler handler)Adds an exception handler to this method.voidaddParameter(SSAValue param)Adds a parameter to this method.voidaddSlotAffinity(SSAValue a, SSAValue b)Requests that two values share one local slot.voidaddSourceLocal(IRMethod.SourceLocal local)Records a source-level local (or appends an SSA value to an existing one); seeIRMethod.SourceLocal.intgetBlockCount()Gets the number of basic blocks in this method.List<IRBlock>getBlocks()List<IRBlock>getBlocksInOrder()Gets blocks in breadth-first order starting from entry block.StringgetDescriptor()IRBlockgetEntryBlock()List<ExceptionHandler>getExceptionHandlers()SSAValuegetHandlerExceptionValue(IRBlock handlerBlock)Returns the caught-exception value for a handler block, or null if none is known.Map<IRBlock,SSAValue>getHandlerExceptionValues()intgetInstructionCount()Gets the total number of instructions in this method.intgetMaxLocals()intgetMaxStack()StringgetName()StringgetOwnerClass()List<SSAValue>getParameters()Map<SSAValue,List<CopyInfo>>getPhiCopyMapping()List<IRBlock>getPostOrder()Gets blocks in post-order traversal.IRTypegetReturnType()List<IRBlock>getReversePostOrder()Gets blocks in reverse post-order traversal.List<SSAValue[]>getSlotAffinities()List<IRMethod.SourceLocal>getSourceLocals()MethodEntrygetSourceMethod()Set<SSAValue>getStackResidentPhiIncomings()Set<SSAValue>getStackResidentPhiResults()booleanisStatic()voidremoveBlock(IRBlock block)Removes a basic block from this method and updates CFG edges.voidsetEntryBlock(IRBlock entryBlock)voidsetHandlerExceptionValues(Map<IRBlock,SSAValue> values)Records the caught-exception value for each handler block, as recovered by the bytecode lifter.voidsetMaxLocals(int maxLocals)voidsetMaxStack(int maxStack)voidsetPhiCopyMapping(Map<SSAValue,List<CopyInfo>> phiCopyMapping)voidsetReturnType(IRType returnType)Sets the return type of this method.voidsetSourceMethod(MethodEntry sourceMethod)IRMethod.SourceLocalsourceLocalOf(SSAValue value)Finds the source local a value was lowered from.StringtoString()
-
-
-
Method Detail
-
getOwnerClass
public String getOwnerClass()
- Returns:
- the owner class
-
getName
public String getName()
- Returns:
- the name
-
getDescriptor
public String getDescriptor()
- Returns:
- the descriptor
-
isStatic
public boolean isStatic()
- Returns:
- whether static
-
getSourceMethod
public MethodEntry getSourceMethod()
- Returns:
- the source method
-
setSourceMethod
public void setSourceMethod(MethodEntry sourceMethod)
- Parameters:
sourceMethod- the class-file method this IR was lifted from
-
addSlotAffinity
public void addSlotAffinity(SSAValue a, SSAValue b)
Requests that two values share one local slot.- Parameters:
a- one value of the pair; ignored if nullb- the other value of the pair; ignored if null or identical to a
-
getSourceLocals
public List<IRMethod.SourceLocal> getSourceLocals()
- Returns:
- the source locals
-
getEntryBlock
public IRBlock getEntryBlock()
- Returns:
- the entry block
-
setEntryBlock
public void setEntryBlock(IRBlock entryBlock)
- Parameters:
entryBlock- the entry block of the CFG
-
getExceptionHandlers
public List<ExceptionHandler> getExceptionHandlers()
- Returns:
- the exception handlers
-
getHandlerExceptionValues
public Map<IRBlock,SSAValue> getHandlerExceptionValues()
- Returns:
- the handler exception values
-
getReturnType
public IRType getReturnType()
- Returns:
- the return type
-
getMaxLocals
public int getMaxLocals()
- Returns:
- the max locals
-
setMaxLocals
public void setMaxLocals(int maxLocals)
- Parameters:
maxLocals- the number of local variable slots
-
getMaxStack
public int getMaxStack()
- Returns:
- the max stack
-
setMaxStack
public void setMaxStack(int maxStack)
- Parameters:
maxStack- the maximum operand stack depth
-
getPhiCopyMapping
public Map<SSAValue,List<CopyInfo>> getPhiCopyMapping()
- Returns:
- the phi results mapped to their copy instructions, which the register allocator coalesces into one register
-
setPhiCopyMapping
public void setPhiCopyMapping(Map<SSAValue,List<CopyInfo>> phiCopyMapping)
- Parameters:
phiCopyMapping- mapping from phi results to their copy instructions
-
getStackResidentPhiResults
public Set<SSAValue> getStackResidentPhiResults()
- Returns:
- the phi results kept on the operand stack across the merge instead of spilled to a local
-
getStackResidentPhiIncomings
public Set<SSAValue> getStackResidentPhiIncomings()
- Returns:
- the incoming values of stack-resident phis, each left on the operand stack by its predecessor block
-
addParameter
public void addParameter(SSAValue param)
Adds a parameter to this method.- Parameters:
param- the parameter SSA value
-
addSourceLocal
public void addSourceLocal(IRMethod.SourceLocal local)
Records a source-level local (or appends an SSA value to an existing one); seeIRMethod.SourceLocal.- Parameters:
local- the source local to record
-
sourceLocalOf
public IRMethod.SourceLocal sourceLocalOf(SSAValue value)
Finds the source local a value was lowered from.- Parameters:
value- the SSA value to look up- Returns:
- the owning source local, or null if no local claims it
-
addBlock
public void addBlock(IRBlock block)
Adds a basic block to this method.- Parameters:
block- the block to add
-
removeBlock
public void removeBlock(IRBlock block)
Removes a basic block from this method and updates CFG edges.- Parameters:
block- the block to remove
-
addExceptionHandler
public void addExceptionHandler(ExceptionHandler handler)
Adds an exception handler to this method.- Parameters:
handler- the exception handler
-
setHandlerExceptionValues
public void setHandlerExceptionValues(Map<IRBlock,SSAValue> values)
Records the caught-exception value for each handler block, as recovered by the bytecode lifter.- Parameters:
values- map from handler block to the SSA value holding the caught exception
-
getHandlerExceptionValue
public SSAValue getHandlerExceptionValue(IRBlock handlerBlock)
Returns the caught-exception value for a handler block, or null if none is known.- Parameters:
handlerBlock- the handler block- Returns:
- the SSA value holding the caught exception, or null
-
getBlocksInOrder
public List<IRBlock> getBlocksInOrder()
Gets blocks in breadth-first order starting from entry block.- Returns:
- ordered list of blocks
-
getPostOrder
public List<IRBlock> getPostOrder()
Gets blocks in post-order traversal.- Returns:
- blocks in post-order
-
getReversePostOrder
public List<IRBlock> getReversePostOrder()
Gets blocks in reverse post-order traversal.- Returns:
- blocks in reverse post-order
-
getBlockCount
public int getBlockCount()
Gets the number of basic blocks in this method.- Returns:
- block count
-
getInstructionCount
public int getInstructionCount()
Gets the total number of instructions in this method.- Returns:
- instruction count
-
setReturnType
public void setReturnType(IRType returnType)
Sets the return type of this method.- Parameters:
returnType- the IR return type
-
-