Package kilim.analysis
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 Summary
FieldsModifier and TypeFieldDescriptionprivate BBListThe list of basic blocks, in the order in which they occur in the class file.(package private) ClassFlowThe classFlow to which this methodFlow belongsstatic booleanprint the bit by bit liveness data after calculation(package private) final Detectorprivate int[]private booleanprivate booleanprivate HashMap<org.objectweb.asm.tree.LabelNode, BasicBlock> Maps labels to BasicBlocksReverse map of posToLabelMap.copy of handlers provided by asm - null after being assigned to the BBsprivate List<org.objectweb.asm.tree.MethodInsnNode> private ArrayList<org.objectweb.asm.tree.LabelNode> Maps instructions[i] to LabelNode or null (if no label).private booleanprivate PriorityQueue<BasicBlock> 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, visibleTypeAnnotationsFields inherited from class org.objectweb.asm.MethodVisitor
api, mv -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidacceptAnnotation(org.objectweb.asm.AnnotationVisitor av, String name, Object value) (package private) voidvoidanalyze()private void(package private) voidprivate voidbuildHandlerMap(ArrayList<Handler> sorted) private booleanprivate voidprivate booleanprivate voidcheckStatus(String superClassName, String methodName, String desc) private voidIn the first pass (buildBasicBlocks()), we create BBs whenever we encounter a label.private voiddataFlow()private BasicBlockdequeue()private voidIn 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) voidenqueue(BasicBlock bb) (package private) BasicBlockgetBasicBlock(org.objectweb.asm.tree.LabelNode l) org.objectweb.asm.tree.LabelNodegetLabelAt(int pos) (package private) intgetLabelPosition(org.objectweb.asm.tree.LabelNode l) int(package private) BasicBlockgetOrCreateBasicBlock(org.objectweb.asm.tree.LabelNode l) (package private) org.objectweb.asm.tree.LabelNodegetOrCreateLabelAtPos(int pos) private voidbooleanbooleanisBridge()boolean(package private) booleanisPausableMethodInsn(org.objectweb.asm.tree.MethodInsnNode min) booleanisStatic()(package private) intmapHandler(int start) return the next handler.from >= start, else -1 - valid only until catch handlers are assignedprivate void(package private) booleanprivate void(package private) voidprintUsage(ArrayList<BasicBlock> bbs) voidvoidprivate void(package private) voidsetLabel(int pos, org.objectweb.asm.tree.LabelNode l) voidsetPausable(boolean isPausable) toString()private StringvoidvoidvisitFrame(int type, int nLocal, Object[] local, int nStack, Object[] stack) voidvisitInvokeDynamicInsn(String name, String desc, org.objectweb.asm.Handle bsm, Object... bsmArgs) voidvisitLabel(org.objectweb.asm.Label label) voidvisitLineNumber(int line, org.objectweb.asm.Label start) (package private) voidvisitLineNumbers(org.objectweb.asm.MethodVisitor mv) voidvisitMethodInsn(int opcode, String owner, String name, 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, visitVarInsnMethods inherited from class org.objectweb.asm.MethodVisitor
getDelegate, visitMethodInsn
-
Field Details
-
classFlow
ClassFlow classFlowThe classFlow to which this methodFlow belongs -
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
Reverse map of posToLabelMap. Maps Labels to index within method.instructions. -
labelToBBMap
Maps labels to BasicBlocks -
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
-
hasPausableAnnotation
private boolean hasPausableAnnotation -
suppressPausableCheck
private boolean suppressPausableCheck -
pausableMethods
-
detector
-
lineNumberNodes
-
frameNodes
-
hasPausableInvokeDynamic
private boolean hasPausableInvokeDynamic -
origHandlers
copy of handlers provided by asm - null after being assigned to the BBs -
handlerMap
private int[] handlerMap -
debugPrintLiveness
public static boolean debugPrintLivenessprint the bit by bit liveness data after calculation
-
-
Constructor Details
-
MethodFlow
-
-
Method Details
-
restoreNonInstructionNodes
public void restoreNonInstructionNodes() -
analyze
- Throws:
KilimException
-
verifyPausables
- Throws:
KilimException
-
checkStatus
private void checkStatus(String superClassName, String methodName, String desc) throws KilimException - Throws:
KilimException
-
toString
-
visitMethodInsn
- Overrides:
visitMethodInsnin classorg.objectweb.asm.tree.MethodNode
-
visitInvokeDynamicInsn
public void visitInvokeDynamicInsn(String name, String desc, org.objectweb.asm.Handle bsm, Object... bsmArgs) - Overrides:
visitInvokeDynamicInsnin classorg.objectweb.asm.tree.MethodNode
-
visitLabel
public void visitLabel(org.objectweb.asm.Label label) - Overrides:
visitLabelin classorg.objectweb.asm.tree.MethodNode
-
visitLineNumber
public void visitLineNumber(int line, org.objectweb.asm.Label start) - Overrides:
visitLineNumberin classorg.objectweb.asm.tree.MethodNode
-
visitLineNumbers
void visitLineNumbers(org.objectweb.asm.MethodVisitor mv) -
visitFrame
- Overrides:
visitFramein classorg.objectweb.asm.tree.MethodNode
-
inlineSubroutines
- Throws:
KilimException
-
markPausableJSRs
- Throws:
KilimException
-
isPausableMethodInsn
boolean isPausableMethodInsn(org.objectweb.asm.tree.MethodInsnNode min) -
toString
-
getBasicBlocks
-
preAssignCatchHandlers
private void preAssignCatchHandlers() -
assignCatchHandlers
private void assignCatchHandlers() -
buildHandlerMap
-
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
-
printUsage
-
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
-
getBasicBlock
-
dequeue
-
enqueue
-
getLabelAt
public org.objectweb.asm.tree.LabelNode getLabelAt(int pos) -
addInlinedBlock
-
getNumArgs
public int getNumArgs() -
isPausable
public boolean isPausable() -
setPausable
public void setPausable(boolean isPausable) -
acceptAnnotation
-
isAbstract
public boolean isAbstract() -
isStatic
public boolean isStatic() -
isBridge
public boolean isBridge() -
resetLabels
public void resetLabels() -
needsWeaving
boolean needsWeaving()
-