Class BasicBlockList

All Implemented Interfaces:
ToHuman

public final class BasicBlockList extends LabeledList
List of BasicBlock instances.
  • Constructor Details

    • BasicBlockList

      public BasicBlockList(int size)
      Constructs an instance. All indices initially contain null, and the first-block label is initially -1.
      Parameters:
      size - the size of the list
  • Method Details

    • get

      public BasicBlock get(int n)
      Gets the element at the given index. It is an error to call this with the index for an element which was never set; if you do that, this will throw NullPointerException.
      Parameters:
      n - >= 0, < size(); which index
      Returns:
      non-null; element at that index
    • set

      public void set(int n, BasicBlock bb)
      Sets the basic block at the given index.
      Parameters:
      n - >= 0, < size(); which index
      bb - null-ok; the element to set at n
    • getRegCount

      public int getRegCount()
      Returns how many registers this method requires. This is simply the maximum of register-number-plus-category referred to by this instance's instructions (indirectly through BasicBlock instances).
      Returns:
      >= 0; the register count
    • getInstructionCount

      public int getInstructionCount()
      Gets the total instruction count for this instance. This is the sum of the instruction counts of each block.
      Returns:
      >= 0; the total instruction count
    • getEffectiveInstructionCount

      public int getEffectiveInstructionCount()
      Gets the total instruction count for this instance, ignoring mark-local instructions which are not actually emitted.
      Returns:
      >= 0; the total instruction count
    • labelToBlock

      public BasicBlock labelToBlock(int label)
      Gets the first block in the list with the given label, if any.
      Parameters:
      label - label >= 0; the label to look for
      Returns:
      non-null; the so-labelled block
      Throws:
      IllegalArgumentException - thrown if the label isn't found
    • forEachInsn

      public void forEachInsn(Insn.Visitor visitor)
      Visits each instruction of each block in the list, in order.
      Parameters:
      visitor - non-null; visitor to use
    • withRegisterOffset

      public BasicBlockList withRegisterOffset(int delta)
      Returns an instance that is identical to this one, except that the registers in each instruction are offset by the given amount. Mutability of the result is inherited from the original.
      Parameters:
      delta - the amount to offset register numbers by
      Returns:
      non-null; an appropriately-constructed instance
    • getMutableCopy

      public BasicBlockList getMutableCopy()
      Returns a mutable copy of this list.
      Returns:
      non-null; an appropriately-constructed instance
    • preferredSuccessorOf

      public BasicBlock preferredSuccessorOf(BasicBlock block)
      Gets the preferred successor for the given block. If the block only has one successor, then that is the preferred successor. Otherwise, if the block has a primay successor, then that is the preferred successor. If the block has no successors, then this returns null.
      Parameters:
      block - non-null; the block in question
      Returns:
      null-ok; the preferred successor, if any
    • catchesEqual

      public boolean catchesEqual(BasicBlock block1, BasicBlock block2)
      Compares the catches of two blocks for equality. This includes both the catch types and target labels.
      Parameters:
      block1 - non-null; one block to compare
      block2 - non-null; the other block to compare
      Returns:
      true if the two blocks' non-primary successors are identical