Package mockit.asm.controlFlow
Class CFGAnalysis
java.lang.Object
mockit.asm.controlFlow.CFGAnalysis
The control flow graph analysis algorithm, used to compute the maximum stack size for a method or constructor.
A control flow graph contains one node per "basic block", and one edge per "jump" from one basic block to another. Each node (i.e., each basic block) is represented by the Label object that corresponds to the first instruction of this basic block. Each node also stores the list of its successors in the graph, as a linked list of Edge objects.
-
Constructor Summary
ConstructorsConstructorDescriptionCFGAnalysis
(ConstantPoolGeneration cp, String classDesc, ByteVector code, boolean computeFrames) -
Method Summary
Modifier and TypeMethodDescription@org.checkerframework.checker.index.qual.NonNegative int
Control flow analysis algorithm: while the block stack is not empty, pop a block from this stack, update the max stack size, compute the true (non relative) begin stack size of the successors of this block, and push these successors onto the stack (unless they have already been pushed onto the stack).@org.checkerframework.checker.index.qual.NonNegative int
Fix point algorithm: mark the first basic block as 'changed' (i.e. put it in the 'changed' list) and, while there are changed basic blocks, choose one, mark it as unchanged, and update its successors (which can be changed in the process).void
updateCurrentBlockForFieldInstruction
(int opcode, TypeOrMemberItem fieldItem, String fieldTypeDesc) void
updateCurrentBlockForIINCInstruction
(@org.checkerframework.checker.index.qual.NonNegative int varIndex) void
updateCurrentBlockForInvokeInstruction
(TypeOrMemberItem invokeItem, int opcode, String desc) updateCurrentBlockForJumpInstruction
(int opcode, Label label) void
updateCurrentBlockForJumpTarget
(int opcode, Label nextInsn) void
void
updateCurrentBlockForLDCInstruction
(Item constItem) void
updateCurrentBlockForLocalVariableInstruction
(int opcode, @org.checkerframework.checker.index.qual.NonNegative int varIndex) void
updateCurrentBlockForMULTIANEWARRAYInstruction
(StringItem arrayTypeItem, @org.checkerframework.checker.index.qual.NonNegative int dims) void
updateCurrentBlockForSingleIntOperandInstruction
(int opcode, int operand) void
updateCurrentBlockForSwitchInstruction
(Label dflt, Label[] caseLabels) void
updateCurrentBlockForTypeInstruction
(int opcode, StringItem typeItem) void
updateCurrentBlockForZeroOperandInstruction
(int opcode)
-
Constructor Details
-
CFGAnalysis
public CFGAnalysis(@NonNull ConstantPoolGeneration cp, @NonNull String classDesc, @NonNull ByteVector code, boolean computeFrames)
-
-
Method Details
-
getLabelForFirstBasicBlock
-
getFirstFrame
-
getLabelForCurrentBasicBlock
-
updateCurrentBlockForZeroOperandInstruction
public void updateCurrentBlockForZeroOperandInstruction(int opcode) -
updateCurrentBlockForSingleIntOperandInstruction
public void updateCurrentBlockForSingleIntOperandInstruction(int opcode, int operand) -
updateCurrentBlockForLocalVariableInstruction
public void updateCurrentBlockForLocalVariableInstruction(int opcode, @org.checkerframework.checker.index.qual.NonNegative int varIndex) -
updateCurrentBlockForTypeInstruction
-
updateCurrentBlockForFieldInstruction
public void updateCurrentBlockForFieldInstruction(int opcode, @NonNull TypeOrMemberItem fieldItem, @NonNull String fieldTypeDesc) -
updateCurrentBlockForInvokeInstruction
public void updateCurrentBlockForInvokeInstruction(@NonNull TypeOrMemberItem invokeItem, int opcode, @NonNull String desc) -
updateCurrentBlockForJumpInstruction
-
updateCurrentBlockForJumpTarget
-
updateCurrentBlockForLabelBeforeNextInstruction
-
updateCurrentBlockForLDCInstruction
-
updateCurrentBlockForIINCInstruction
public void updateCurrentBlockForIINCInstruction(@org.checkerframework.checker.index.qual.NonNegative int varIndex) -
updateCurrentBlockForSwitchInstruction
-
updateCurrentBlockForMULTIANEWARRAYInstruction
public void updateCurrentBlockForMULTIANEWARRAYInstruction(@NonNull StringItem arrayTypeItem, @org.checkerframework.checker.index.qual.NonNegative int dims) -
computeMaxStackSizeFromComputedFrames
public @org.checkerframework.checker.index.qual.NonNegative int computeMaxStackSizeFromComputedFrames()Fix point algorithm: mark the first basic block as 'changed' (i.e. put it in the 'changed' list) and, while there are changed basic blocks, choose one, mark it as unchanged, and update its successors (which can be changed in the process). -
computeMaxStackSize
public @org.checkerframework.checker.index.qual.NonNegative int computeMaxStackSize()Control flow analysis algorithm: while the block stack is not empty, pop a block from this stack, update the max stack size, compute the true (non relative) begin stack size of the successors of this block, and push these successors onto the stack (unless they have already been pushed onto the stack). Note: by hypothesis, theLabel.inputStackTop
of the blocks in the block stack are the true (non relative) beginning stack sizes of these blocks.
-