Class IRMethod


  • public class IRMethod
    extends Object
    A method in SSA form: its CFG blocks plus parameters, exception handlers, and lowering metadata.
    • Constructor Detail

      • IRMethod

        public IRMethod​(String ownerClass,
                        String name,
                        String descriptor,
                        boolean isStatic)
        Creates a new IR method.
        Parameters:
        ownerClass - the class containing this method
        name - the method name
        descriptor - the method descriptor
        isStatic - whether the method is static
    • 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
      • getParameters

        public List<SSAValue> getParameters()
        Returns:
        the parameters
      • 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 null
        b - the other value of the pair; ignored if null or identical to a
      • getSlotAffinities

        public List<SSAValue[]> getSlotAffinities()
        Returns:
        the slot affinities
      • getBlocks

        public List<IRBlock> getBlocks()
        Returns:
        the blocks
      • 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); see IRMethod.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