Class MethodFlow


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

      Fields 
      Modifier and Type Field Description
      private BBList basicBlocks
      The list of basic blocks, in the order in which they occur in the class file.
      (package private) ClassFlow classFlow
      The classFlow to which this methodFlow belongs
      static boolean debugPrintLiveness
      print the bit by bit liveness data after calculation
      (package private) Detector detector  
      private java.util.HashMap<java.lang.Integer,​org.objectweb.asm.tree.FrameNode> frameNodes  
      private int[] handlerMap  
      private boolean hasPausableAnnotation  
      private boolean hasPausableInvokeDynamic  
      private java.util.HashMap<org.objectweb.asm.tree.LabelNode,​BasicBlock> labelToBBMap
      Maps labels to BasicBlocks
      private java.util.HashMap<org.objectweb.asm.tree.LabelNode,​java.lang.Integer> labelToPosMap
      Reverse map of posToLabelMap.
      private java.util.TreeMap<java.lang.Integer,​org.objectweb.asm.tree.LineNumberNode> lineNumberNodes  
      (package private) java.util.ArrayList<Handler> origHandlers
      copy of handlers provided by asm - null after being assigned to the BBs
      private java.util.List<org.objectweb.asm.tree.MethodInsnNode> pausableMethods  
      private java.util.ArrayList<org.objectweb.asm.tree.LabelNode> posToLabelMap
      Maps instructions[i] to LabelNode or null (if no label).
      private boolean suppressPausableCheck  
      private java.util.PriorityQueue<BasicBlock> workset  
      • Fields inherited from class org.objectweb.asm.tree.MethodNode

        access, annotationDefault, attrs, desc, exceptions, instructions, invisibleAnnotableParameterCount, invisibleAnnotations, invisibleLocalVariableAnnotations, invisibleParameterAnnotations, invisibleTypeAnnotations, localVariables, maxLocals, maxStack, name, parameters, signature, tryCatchBlocks, visibleAnnotableParameterCount, visibleAnnotations, visibleLocalVariableAnnotations, visibleParameterAnnotations, visibleTypeAnnotations
      • Fields inherited from class org.objectweb.asm.MethodVisitor

        api, mv
    • Constructor Summary

      Constructors 
      Constructor Description
      MethodFlow​(ClassFlow classFlow, int access, java.lang.String name, java.lang.String desc, java.lang.String signature, java.lang.String[] exceptions, Detector detector)  
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static void acceptAnnotation​(org.objectweb.asm.AnnotationVisitor av, java.lang.String name, java.lang.Object value)  
      (package private) void addInlinedBlock​(BasicBlock bb)  
      void analyze()  
      private void assignCatchHandlers()  
      (package private) void buildBasicBlocks()  
      private void buildHandlerMap​(java.util.ArrayList<Handler> sorted)  
      private boolean calcBornOnce()  
      private void calcBornUsage()  
      private boolean checkNoBasicBlockLeftBehind()  
      private void checkStatus​(java.lang.String superClassName, java.lang.String methodName, java.lang.String desc)  
      private void consolidateBasicBlocks()
      In the first pass (buildBasicBlocks()), we create BBs whenever we encounter a label.
      private void dataFlow()  
      private BasicBlock dequeue()  
      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.
      (package private) void enqueue​(BasicBlock bb)  
      (package private) BasicBlock getBasicBlock​(org.objectweb.asm.tree.LabelNode l)  
      BBList getBasicBlocks()  
      org.objectweb.asm.tree.LabelNode getLabelAt​(int pos)  
      (package private) int getLabelPosition​(org.objectweb.asm.tree.LabelNode l)  
      int getNumArgs()  
      (package private) BasicBlock getOrCreateBasicBlock​(org.objectweb.asm.tree.LabelNode l)  
      (package private) org.objectweb.asm.tree.LabelNode getOrCreateLabelAtPos​(int pos)  
      private void inlineSubroutines()  
      boolean isAbstract()  
      boolean isBridge()  
      boolean isPausable()  
      (package private) boolean isPausableMethodInsn​(org.objectweb.asm.tree.MethodInsnNode min)  
      boolean isStatic()  
      (package private) int mapHandler​(int start)
      return the next handler.from >= start, else -1 - valid only until catch handlers are assigned
      private void markPausableJSRs()  
      (package private) boolean needsWeaving()  
      private void preAssignCatchHandlers()  
      (package private) void printUsage​(java.util.ArrayList<BasicBlock> bbs)  
      void resetLabels()  
      void restoreNonInstructionNodes()  
      private void setArgsBorn​(BasicBlock bb)  
      (package private) void setLabel​(int pos, org.objectweb.asm.tree.LabelNode l)  
      void setPausable​(boolean isPausable)  
      java.lang.String toString()  
      private java.lang.String toString​(java.lang.String className, java.lang.String methName, java.lang.String desc)  
      void verifyPausables()  
      void visitFrame​(int type, int nLocal, java.lang.Object[] local, int nStack, java.lang.Object[] stack)  
      void visitInvokeDynamicInsn​(java.lang.String name, java.lang.String desc, org.objectweb.asm.Handle bsm, java.lang.Object... bsmArgs)  
      void visitLabel​(org.objectweb.asm.Label label)  
      void visitLineNumber​(int line, org.objectweb.asm.Label start)  
      (package private) void visitLineNumbers​(org.objectweb.asm.MethodVisitor mv)  
      void visitMethodInsn​(int opcode, java.lang.String owner, java.lang.String name, java.lang.String desc, boolean itf)  
      • Methods inherited from class org.objectweb.asm.tree.MethodNode

        accept, accept, check, getLabelNode, visitAnnotableParameterCount, visitAnnotation, visitAnnotationDefault, visitAttribute, visitCode, visitEnd, visitFieldInsn, visitIincInsn, visitInsn, visitInsnAnnotation, visitIntInsn, visitJumpInsn, visitLdcInsn, visitLocalVariable, visitLocalVariableAnnotation, visitLookupSwitchInsn, visitMaxs, visitMultiANewArrayInsn, visitParameter, visitParameterAnnotation, visitTableSwitchInsn, visitTryCatchAnnotation, visitTryCatchBlock, visitTypeAnnotation, visitTypeInsn, visitVarInsn
      • Methods inherited from class org.objectweb.asm.MethodVisitor

        getDelegate, visitMethodInsn
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • classFlow

        ClassFlow classFlow
        The classFlow to which this methodFlow belongs
      • posToLabelMap

        private java.util.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 java.util.HashMap<org.objectweb.asm.tree.LabelNode,​java.lang.Integer> labelToPosMap
        Reverse map of posToLabelMap. Maps Labels to index within method.instructions.
      • labelToBBMap

        private java.util.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 java.util.PriorityQueue<BasicBlock> workset
      • hasPausableAnnotation

        private boolean hasPausableAnnotation
      • suppressPausableCheck

        private boolean suppressPausableCheck
      • pausableMethods

        private java.util.List<org.objectweb.asm.tree.MethodInsnNode> pausableMethods
      • lineNumberNodes

        private java.util.TreeMap<java.lang.Integer,​org.objectweb.asm.tree.LineNumberNode> lineNumberNodes
      • frameNodes

        private java.util.HashMap<java.lang.Integer,​org.objectweb.asm.tree.FrameNode> frameNodes
      • hasPausableInvokeDynamic

        private boolean hasPausableInvokeDynamic
      • origHandlers

        java.util.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 Detail

      • MethodFlow

        public MethodFlow​(ClassFlow classFlow,
                          int access,
                          java.lang.String name,
                          java.lang.String desc,
                          java.lang.String signature,
                          java.lang.String[] exceptions,
                          Detector detector)
    • Method Detail

      • restoreNonInstructionNodes

        public void restoreNonInstructionNodes()
      • checkStatus

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

        private java.lang.String toString​(java.lang.String className,
                                          java.lang.String methName,
                                          java.lang.String desc)
      • visitMethodInsn

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

        public void visitInvokeDynamicInsn​(java.lang.String name,
                                           java.lang.String desc,
                                           org.objectweb.asm.Handle bsm,
                                           java.lang.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,
                               java.lang.Object[] local,
                               int nStack,
                               java.lang.Object[] stack)
        Overrides:
        visitFrame in class org.objectweb.asm.tree.MethodNode
      • isPausableMethodInsn

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

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

        public BBList getBasicBlocks()
      • preAssignCatchHandlers

        private void preAssignCatchHandlers()
      • assignCatchHandlers

        private void assignCatchHandlers()
      • buildHandlerMap

        private void buildHandlerMap​(java.util.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​(java.util.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)
      • 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,
                                            java.lang.String name,
                                            java.lang.Object value)
      • isAbstract

        public boolean isAbstract()
      • isStatic

        public boolean isStatic()
      • isBridge

        public boolean isBridge()
      • resetLabels

        public void resetLabels()
      • needsWeaving

        boolean needsWeaving()