Class CFGAnalysis

java.lang.Object
mockit.asm.controlFlow.CFGAnalysis

public final class CFGAnalysis extends Object
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 Details

  • Method Details

    • getLabelForFirstBasicBlock

      @NonNull public Label getLabelForFirstBasicBlock()
    • getFirstFrame

      public Frame getFirstFrame()
    • getLabelForCurrentBasicBlock

      @Nullable public Label 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

      public void updateCurrentBlockForTypeInstruction(int opcode, @NonNull StringItem typeItem)
    • 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

      @Nullable public Label updateCurrentBlockForJumpInstruction(int opcode, @NonNull Label label)
    • updateCurrentBlockForJumpTarget

      public void updateCurrentBlockForJumpTarget(int opcode, @Nullable Label nextInsn)
    • updateCurrentBlockForLabelBeforeNextInstruction

      public void updateCurrentBlockForLabelBeforeNextInstruction(@NonNull Label label)
    • updateCurrentBlockForLDCInstruction

      public void updateCurrentBlockForLDCInstruction(@NonNull Item constItem)
    • updateCurrentBlockForIINCInstruction

      public void updateCurrentBlockForIINCInstruction(@org.checkerframework.checker.index.qual.NonNegative int varIndex)
    • updateCurrentBlockForSwitchInstruction

      public void updateCurrentBlockForSwitchInstruction(@NonNull Label dflt, @NonNull Label[] caseLabels)
    • 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, the Label.inputStackTop of the blocks in the block stack are the true (non relative) beginning stack sizes of these blocks.