Class MethodFlow

java.lang.Object
org.objectweb.asm.MethodVisitor
org.objectweb.asm.tree.MethodNode
kilim.analysis.MethodFlow

public class MethodFlow extends org.objectweb.asm.tree.MethodNode
This represents all the basic blocks of a method.
  • Field Details

    • classFlow

      ClassFlow classFlow
      The classFlow to which this methodFlow belongs
    • posToLabelMap

      private ArrayList<org.objectweb.asm.tree.LabelNode> posToLabelMap
      Maps instructions[i] to LabelNode or null (if no label). Note that LabelInsnNodes are not accounted for here because they themselves are not labelled.
    • labelToPosMap

      private HashMap<org.objectweb.asm.tree.LabelNode,Integer> labelToPosMap
      Reverse map of posToLabelMap. Maps Labels to index within method.instructions.
    • labelToBBMap

      private HashMap<org.objectweb.asm.tree.LabelNode,BasicBlock> labelToBBMap
      Maps labels to BasicBlocks
    • basicBlocks

      private BBList basicBlocks
      The list of basic blocks, in the order in which they occur in the class file. Maintaining this order is important, because we'll use it to drive duplication (in case of JSRs) and also while writing out the class file.
    • workset

      private PriorityQueue<BasicBlock> workset
    • hasPausableAnnotation

      private boolean hasPausableAnnotation
    • suppressPausableCheck

      private boolean suppressPausableCheck
    • pausableMethods

      private List<org.objectweb.asm.tree.MethodInsnNode> pausableMethods
    • detector

      final Detector detector
    • lineNumberNodes

      private TreeMap<Integer,org.objectweb.asm.tree.LineNumberNode> lineNumberNodes
    • frameNodes

      private HashMap<Integer,org.objectweb.asm.tree.FrameNode> frameNodes
    • hasPausableInvokeDynamic

      private boolean hasPausableInvokeDynamic
    • origHandlers

      ArrayList<Handler> origHandlers
      copy of handlers provided by asm - null after being assigned to the BBs
    • handlerMap

      private int[] handlerMap
    • debugPrintLiveness

      public static boolean debugPrintLiveness
      print the bit by bit liveness data after calculation
  • Constructor Details

  • Method Details

    • restoreNonInstructionNodes

      public void restoreNonInstructionNodes()
    • analyze

      public void analyze() throws KilimException
      Throws:
      KilimException
    • verifyPausables

      public void verifyPausables() throws KilimException
      Throws:
      KilimException
    • checkStatus

      private void checkStatus(String superClassName, String methodName, String desc) throws KilimException
      Throws:
      KilimException
    • toString

      private String toString(String className, String methName, String desc)
    • visitMethodInsn

      public void visitMethodInsn(int opcode, String owner, String name, String desc, boolean itf)
      Overrides:
      visitMethodInsn in class org.objectweb.asm.tree.MethodNode
    • visitInvokeDynamicInsn

      public void visitInvokeDynamicInsn(String name, String desc, org.objectweb.asm.Handle bsm, Object... bsmArgs)
      Overrides:
      visitInvokeDynamicInsn in class org.objectweb.asm.tree.MethodNode
    • visitLabel

      public void visitLabel(org.objectweb.asm.Label label)
      Overrides:
      visitLabel in class org.objectweb.asm.tree.MethodNode
    • visitLineNumber

      public void visitLineNumber(int line, org.objectweb.asm.Label start)
      Overrides:
      visitLineNumber in class org.objectweb.asm.tree.MethodNode
    • visitLineNumbers

      void visitLineNumbers(org.objectweb.asm.MethodVisitor mv)
    • visitFrame

      public void visitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack)
      Overrides:
      visitFrame in class org.objectweb.asm.tree.MethodNode
    • inlineSubroutines

      private void inlineSubroutines() throws KilimException
      Throws:
      KilimException
    • markPausableJSRs

      private void markPausableJSRs() throws KilimException
      Throws:
      KilimException
    • isPausableMethodInsn

      boolean isPausableMethodInsn(org.objectweb.asm.tree.MethodInsnNode min)
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • getBasicBlocks

      public BBList getBasicBlocks()
    • preAssignCatchHandlers

      private void preAssignCatchHandlers()
    • assignCatchHandlers

      private void assignCatchHandlers()
    • buildHandlerMap

      private void buildHandlerMap(ArrayList<Handler> sorted)
    • mapHandler

      int mapHandler(int start)
      return the next handler.from >= start, else -1 - valid only until catch handlers are assigned
    • buildBasicBlocks

      void buildBasicBlocks()
    • calcBornOnce

      private boolean calcBornOnce()
    • calcBornUsage

      private void calcBornUsage()
    • doLiveVarAnalysis

      private void doLiveVarAnalysis()
      In live var analysis a BB asks its successor (in essence) about which vars are live, mixes it with its own uses and defs and passes on a new list of live vars to its predecessors. Since the information bubbles up the chain, we iterate the list in reverse order, for efficiency. We could order the list topologically or do a depth-first spanning tree, but it seems like overkill for most bytecode procedures. The order of computation doesn't affect the correctness; it merely changes the number of iterations to reach a fixpoint. the algorithm has been updated to track vars that been born, ie def'd by a parameter
    • setArgsBorn

      private void setArgsBorn(BasicBlock bb)
    • printUsage

      void printUsage(ArrayList<BasicBlock> bbs)
    • consolidateBasicBlocks

      private void consolidateBasicBlocks()
      In the first pass (buildBasicBlocks()), we create BBs whenever we encounter a label. We don't really know until we are done with that pass whether a label is the target of a branch instruction or it is there because of an exception handler. See coalesceWithFollowingBlock() for more detail.
    • checkNoBasicBlockLeftBehind

      private boolean checkNoBasicBlockLeftBehind()
    • dataFlow

      private void dataFlow()
    • setLabel

      void setLabel(int pos, org.objectweb.asm.tree.LabelNode l)
    • getOrCreateLabelAtPos

      org.objectweb.asm.tree.LabelNode getOrCreateLabelAtPos(int pos)
    • getLabelPosition

      int getLabelPosition(org.objectweb.asm.tree.LabelNode l)
    • getOrCreateBasicBlock

      BasicBlock getOrCreateBasicBlock(org.objectweb.asm.tree.LabelNode l)
    • getBasicBlock

      BasicBlock getBasicBlock(org.objectweb.asm.tree.LabelNode l)
    • dequeue

      private BasicBlock dequeue()
    • enqueue

      void enqueue(BasicBlock bb)
    • getLabelAt

      public org.objectweb.asm.tree.LabelNode getLabelAt(int pos)
    • addInlinedBlock

      void addInlinedBlock(BasicBlock bb)
    • getNumArgs

      public int getNumArgs()
    • isPausable

      public boolean isPausable()
    • setPausable

      public void setPausable(boolean isPausable)
    • acceptAnnotation

      public static void acceptAnnotation(org.objectweb.asm.AnnotationVisitor av, String name, Object value)
    • isAbstract

      public boolean isAbstract()
    • isStatic

      public boolean isStatic()
    • isBridge

      public boolean isBridge()
    • resetLabels

      public void resetLabels()
    • needsWeaving

      boolean needsWeaving()