Class AnalyzedInstruction

java.lang.Object
org.jf.dexlib2.analysis.AnalyzedInstruction
All Implemented Interfaces:
Comparable<AnalyzedInstruction>

public class AnalyzedInstruction extends Object implements Comparable<AnalyzedInstruction>
  • Field Details

    • methodAnalyzer

      @Nonnull protected final MethodAnalyzer methodAnalyzer
      The MethodAnalyzer containing this instruction
    • instruction

      @Nonnull protected Instruction instruction
      The actual instruction
    • instructionIndex

      protected final int instructionIndex
      The index of the instruction, where the first instruction in the method is at index 0, and so on
    • predecessors

      @Nonnull protected final TreeSet<AnalyzedInstruction> predecessors
      Instructions that can pass on execution to this one during normal execution
    • successors

      @Nonnull protected final LinkedList<AnalyzedInstruction> successors
      Instructions that can execution could pass on to next during normal execution
    • preRegisterMap

      @Nonnull protected final RegisterType[] preRegisterMap
      This contains the register types *before* the instruction has executed
    • postRegisterMap

      @Nonnull protected final RegisterType[] postRegisterMap
      This contains the register types *after* the instruction has executed
    • predecessorRegisterOverrides

      @Nullable protected Map<AnalyzedInstruction.PredecessorOverrideKey,RegisterType> predecessorRegisterOverrides
      This contains optional register type overrides for register types from predecessors
    • originalInstruction

      protected final Instruction originalInstruction
      When deodexing, we might need to deodex this instruction multiple times, when we merge in new register information. When this happens, we need to restore the original (odexed) instruction, so we can deodex it again
  • Constructor Details

    • AnalyzedInstruction

      public AnalyzedInstruction(@Nonnull MethodAnalyzer methodAnalyzer, @Nonnull Instruction instruction, int instructionIndex, int registerCount)
  • Method Details

    • getInstructionIndex

      public int getInstructionIndex()
    • getPredecessorCount

      public int getPredecessorCount()
    • getPredecessors

      public SortedSet<AnalyzedInstruction> getPredecessors()
    • getPredecessorRegisterType

      public RegisterType getPredecessorRegisterType(@Nonnull AnalyzedInstruction predecessor, int registerNumber)
    • addPredecessor

      protected boolean addPredecessor(AnalyzedInstruction predecessor)
    • addSuccessor

      protected void addSuccessor(AnalyzedInstruction successor)
    • setDeodexedInstruction

      protected void setDeodexedInstruction(Instruction instruction)
    • restoreOdexedInstruction

      protected void restoreOdexedInstruction()
    • getSuccessors

      @Nonnull public List<AnalyzedInstruction> getSuccessors()
    • getInstruction

      @Nonnull public Instruction getInstruction()
    • getOriginalInstruction

      @Nonnull public Instruction getOriginalInstruction()
    • isBeginningInstruction

      public boolean isBeginningInstruction()
      Is this instruction a "beginning instruction". A beginning instruction is defined to be an instruction that can be the first successfully executed instruction in the method. The first instruction is always a beginning instruction. If the first instruction can throw an exception, and is covered by a try block, then the first instruction of any exception handler for that try block is also a beginning instruction. And likewise, if any of those instructions can throw an exception and are covered by try blocks, the first instruction of the corresponding exception handler is a beginning instruction, etc. To determine this, we simply check if the first predecessor is the fake "StartOfMethod" instruction, which has an instruction index of -1.
      Returns:
      a boolean value indicating whether this instruction is a beginning instruction
    • mergeRegister

      protected boolean mergeRegister(int registerNumber, RegisterType registerType, BitSet verifiedInstructions, boolean override)
    • getMergedPreRegisterTypeFromPredecessors

      @Nonnull protected RegisterType getMergedPreRegisterTypeFromPredecessors(int registerNumber)
      Iterates over the predecessors of this instruction, and merges all the post-instruction register types for the given register. Any dead, unreachable, or odexed predecessor is ignored. This takes into account any overridden predecessor register types
      Parameters:
      registerNumber - the register number
      Returns:
      The register type resulting from merging the post-instruction register types from all predecessors
    • setPostRegisterType

      protected boolean setPostRegisterType(int registerNumber, RegisterType registerType)
      Sets the "post-instruction" register type as indicated.
      Parameters:
      registerNumber - Which register to set
      registerType - The "post-instruction" register type
      Returns:
      true if the given register type is different than the existing post-instruction register type
    • overridePredecessorRegisterType

      protected boolean overridePredecessorRegisterType(@Nonnull AnalyzedInstruction predecessor, int registerNumber, @Nonnull RegisterType registerType, BitSet verifiedInstructions)
      Adds an override for a register type from a predecessor. This is used to set the register type for only one branch from a conditional jump.
      Parameters:
      predecessor - Which predecessor is being overridden
      registerNumber - The register number of the register being overridden
      registerType - The overridden register type
      verifiedInstructions - A bit vector of instructions that have been verified
      Returns:
      true if the post-instruction register type for this instruction changed as a result of this override
    • isInvokeInit

      public boolean isInvokeInit()
    • setsRegister

      public boolean setsRegister(int registerNumber)
      Determines if this instruction sets the given register, or alters its type
      Parameters:
      registerNumber - The register to check
      Returns:
      true if this instruction sets the given register or alters its type
    • getSetRegisters

      public List<Integer> getSetRegisters()
    • getDestinationRegister

      public int getDestinationRegister()
    • getRegisterCount

      public int getRegisterCount()
    • getPostInstructionRegisterType

      @Nonnull public RegisterType getPostInstructionRegisterType(int registerNumber)
    • getPreInstructionRegisterType

      @Nonnull public RegisterType getPreInstructionRegisterType(int registerNumber)
    • compareTo

      public int compareTo(@Nonnull AnalyzedInstruction analyzedInstruction)
      Specified by:
      compareTo in interface Comparable<AnalyzedInstruction>