Package org.jf.dexlib2.analysis
Class AnalyzedInstruction
- java.lang.Object
-
- org.jf.dexlib2.analysis.AnalyzedInstruction
-
- All Implemented Interfaces:
java.lang.Comparable<AnalyzedInstruction>
public class AnalyzedInstruction extends java.lang.Object implements java.lang.Comparable<AnalyzedInstruction>
-
-
Field Summary
Fields Modifier and Type Field Description protected Instruction
instruction
The actual instructionprotected int
instructionIndex
The index of the instruction, where the first instruction in the method is at index 0, and so onprotected MethodAnalyzer
methodAnalyzer
The MethodAnalyzer containing this instructionprotected Instruction
originalInstruction
When deodexing, we might need to deodex this instruction multiple times, when we merge in new register information.protected RegisterType[]
postRegisterMap
This contains the register types *after* the instruction has executedprotected java.util.Map<org.jf.dexlib2.analysis.AnalyzedInstruction.PredecessorOverrideKey,RegisterType>
predecessorRegisterOverrides
This contains optional register type overrides for register types from predecessorsprotected java.util.TreeSet<AnalyzedInstruction>
predecessors
Instructions that can pass on execution to this one during normal executionprotected RegisterType[]
preRegisterMap
This contains the register types *before* the instruction has executedprotected java.util.LinkedList<AnalyzedInstruction>
successors
Instructions that can execution could pass on to next during normal execution
-
Constructor Summary
Constructors Constructor Description AnalyzedInstruction(MethodAnalyzer methodAnalyzer, Instruction instruction, int instructionIndex, int registerCount)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
addPredecessor(AnalyzedInstruction predecessor)
protected void
addSuccessor(AnalyzedInstruction successor)
int
compareTo(AnalyzedInstruction analyzedInstruction)
int
getDestinationRegister()
Instruction
getInstruction()
int
getInstructionIndex()
protected RegisterType
getMergedPreRegisterTypeFromPredecessors(int registerNumber)
Iterates over the predecessors of this instruction, and merges all the post-instruction register types for the given register.Instruction
getOriginalInstruction()
RegisterType
getPostInstructionRegisterType(int registerNumber)
int
getPredecessorCount()
RegisterType
getPredecessorRegisterType(AnalyzedInstruction predecessor, int registerNumber)
java.util.SortedSet<AnalyzedInstruction>
getPredecessors()
RegisterType
getPreInstructionRegisterType(int registerNumber)
int
getRegisterCount()
java.util.List<java.lang.Integer>
getSetRegisters()
java.util.List<AnalyzedInstruction>
getSuccessors()
boolean
isBeginningInstruction()
Is this instruction a "beginning instruction".boolean
isInvokeInit()
protected boolean
mergeRegister(int registerNumber, RegisterType registerType, java.util.BitSet verifiedInstructions, boolean override)
protected boolean
overridePredecessorRegisterType(AnalyzedInstruction predecessor, int registerNumber, RegisterType registerType, java.util.BitSet verifiedInstructions)
Adds an override for a register type from a predecessor.protected void
restoreOdexedInstruction()
protected void
setDeodexedInstruction(Instruction instruction)
protected boolean
setPostRegisterType(int registerNumber, RegisterType registerType)
Sets the "post-instruction" register type as indicated.boolean
setsRegister(int registerNumber)
Determines if this instruction sets the given register, or alters its type
-
-
-
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()
-
getPredecessors
public java.util.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 java.util.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, 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 setregisterType
- 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 overriddenregisterNumber
- The register number of the register being overriddenregisterType
- The overridden register typeverifiedInstructions
- 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)
-
compareTo
public int compareTo(@Nonnull AnalyzedInstruction analyzedInstruction)
- Specified by:
compareTo
in interfacejava.lang.Comparable<AnalyzedInstruction>
-
-