Class SsaMethod

java.lang.Object
com.android.dx.ssa.SsaMethod

public final class SsaMethod extends Object
A method in SSA form.
  • Method Details

    • newFromRopMethod

      public static SsaMethod newFromRopMethod(RopMethod ropMethod, int paramWidth, boolean isStatic)
      Parameters:
      ropMethod - rop-form method to convert from
      paramWidth - the total width, in register-units, of the method's parameters
      isStatic - true if this method has no this pointer argument
    • indexListFromLabelList

      public static IntList indexListFromLabelList(BasicBlockList ropBlocks, IntList labelList)
      Builds an IntList of block indices from a basic block list and a list of labels taken from Rop form.
      Parameters:
      ropBlocks - Rop blocks
      labelList - list of rop block labels
      Returns:
      IntList of block indices
    • makeNewGotoBlock

      public SsaBasicBlock makeNewGotoBlock()
      Makes a new basic block for this method, which is empty besides a single GOTO. Successors and predecessors are not yet set.
      Returns:
      new block
    • getEntryBlockIndex

      public int getEntryBlockIndex()
      Returns:
      block index of first execution block
    • getEntryBlock

      public SsaBasicBlock getEntryBlock()
      Returns:
      first execution block
    • getExitBlockIndex

      public int getExitBlockIndex()
      Returns:
      block index of exit block or -1 if there is none
    • getExitBlock

      public SsaBasicBlock getExitBlock()
      Returns:
      null-ok; block of exit block or null if there is none
    • blockIndexToRopLabel

      public int blockIndexToRopLabel(int bi)
      Parameters:
      bi - block index or -1 for none
      Returns:
      rop label or {code -1} if bi was -1
    • getRegCount

      public int getRegCount()
      Returns:
      count of registers used in this method
    • getParamWidth

      public int getParamWidth()
      Returns:
      the total width, in register units, of the method's parameters
    • isStatic

      public boolean isStatic()
      Returns true if this is a static method.
      Returns:
      true if this is a static method
    • borrowSpareRegister

      public int borrowSpareRegister(int category)
      Borrows a register to use as a temp. Used in the phi removal process. Call returnSpareRegisters() when done.
      Parameters:
      category - width (1 or 2) of the register
      Returns:
      register number to use
    • returnSpareRegisters

      public void returnSpareRegisters()
      Returns all borrowed registers.
    • getBlocks

      public ArrayList<SsaBasicBlock> getBlocks()
      Returns:
      non-null; basic block list. Do not modify.
    • computeReachability

      public BitSet computeReachability()
      Computes reachability for all blocks in the method.
      Returns:
      a BitSet of reachable blocks.
    • mapRegisters

      public void mapRegisters(RegisterMapper mapper)
      Remaps unversioned registers.
      Parameters:
      mapper - maps old registers to new.
    • getDefinitionForRegister

      public SsaInsn getDefinitionForRegister(int reg)
      Returns the insn that defines the given register
      Parameters:
      reg - register in question
      Returns:
      insn (actual instance from code) that defined this reg or null if reg is not defined.
    • onInsnsChanged

      public void onInsnsChanged()
      Indicates that the instruction list has changed or the SSA register count has increased, so that internal datastructures that rely on it should be rebuild. In general, the various other on* methods should be called in preference when changes occur if they are applicable.
    • getUseListForRegister

      public List<SsaInsn> getUseListForRegister(int reg)
      Returns the list of all source uses (not results) for a register.
      Parameters:
      reg - register in question
      Returns:
      unmodifiable instruction list
    • getUseListCopy

      public ArrayList<SsaInsn>[] getUseListCopy()
      Returns a modifiable copy of the register use list.
      Returns:
      modifiable copy of the use-list, indexed by register
    • isRegALocal

      public boolean isRegALocal(RegisterSpec spec)
      Checks to see if the given SSA reg is ever associated with a local local variable. Each SSA reg may be associated with at most one local var.
      Parameters:
      spec - non-null; ssa reg
      Returns:
      true if reg is ever associated with a local
    • makeNewSsaReg

      public int makeNewSsaReg()
      Makes a new SSA register. For use after renaming has completed.
      Returns:
      >=0; new SSA register.
    • forEachInsn

      public void forEachInsn(SsaInsn.Visitor visitor)
      Visits all insns in this method.
      Parameters:
      visitor - non-null; callback interface
    • forEachPhiInsn

      public void forEachPhiInsn(PhiInsn.Visitor v)
      Visits each phi insn in this method
      Parameters:
      v - non-null; callback.
    • forEachBlockDepthFirst

      public void forEachBlockDepthFirst(boolean reverse, SsaBasicBlock.Visitor v)
      Walks the basic block tree in depth-first order, calling the visitor method once for every block. This depth-first walk may be run forward from the method entry point or backwards from the method exit points.
      Parameters:
      reverse - true if this should walk backwards from the exit points
      v - non-null; callback interface. parent is set unless this is the root node
    • forEachBlockDepthFirstDom

      public void forEachBlockDepthFirstDom(SsaBasicBlock.Visitor v)
      Visits blocks in dom-tree order, starting at the current node. The parent parameter of the Visitor.visitBlock callback is currently always set to null.
      Parameters:
      v - non-null; callback interface
    • deleteInsns

      public void deleteInsns(Set<SsaInsn> deletedInsns)
      Deletes all insns in the set from this method.
      Parameters:
      deletedInsns - non-null; insns to delete
    • setBackMode

      public void setBackMode()
      Sets "back-convert mode". Set during back-conversion when registers are about to be mapped into a non-SSA namespace. When true, use and def lists are unavailable.