Class AnalyzedInstruction

    • Field Detail

      • 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 java.util.TreeSet<AnalyzedInstruction> predecessors
        Instructions that can pass on execution to this one during normal execution
      • successors

        @Nonnull
        protected final java.util.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 java.util.Map<org.jf.dexlib2.analysis.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 Detail

      • AnalyzedInstruction

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

      • getInstructionIndex

        public int getInstructionIndex()
      • getPredecessorCount

        public int getPredecessorCount()
      • setDeodexedInstruction

        protected void setDeodexedInstruction​(Instruction instruction)
      • restoreOdexedInstruction

        protected void restoreOdexedInstruction()
      • 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,
                                        java.util.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,
                                                          java.util.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 java.util.List<java.lang.Integer> getSetRegisters()
      • getDestinationRegister

        public int getDestinationRegister()
      • getRegisterCount

        public int getRegisterCount()
      • getPostInstructionRegisterType

        @Nonnull
        public RegisterType getPostInstructionRegisterType​(int registerNumber)
      • getPreInstructionRegisterType

        @Nonnull
        public RegisterType getPreInstructionRegisterType​(int registerNumber)