Package org.jf.dexlib2.analysis
Class AnalyzedInstruction
java.lang.Object
org.jf.dexlib2.analysis.AnalyzedInstruction
- All Implemented Interfaces:
Comparable<AnalyzedInstruction>
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected InstructionThe actual instructionprotected final intThe index of the instruction, where the first instruction in the method is at index 0, and so onprotected final MethodAnalyzerThe MethodAnalyzer containing this instructionprotected final InstructionWhen deodexing, we might need to deodex this instruction multiple times, when we merge in new register information.protected final RegisterType[]This contains the register types *after* the instruction has executedThis contains optional register type overrides for register types from predecessorsprotected final TreeSet<AnalyzedInstruction> Instructions that can pass on execution to this one during normal executionprotected final RegisterType[]This contains the register types *before* the instruction has executedprotected final LinkedList<AnalyzedInstruction> Instructions that can execution could pass on to next during normal execution -
Constructor Summary
ConstructorsConstructorDescriptionAnalyzedInstruction(MethodAnalyzer methodAnalyzer, Instruction instruction, int instructionIndex, int registerCount) -
Method Summary
Modifier and TypeMethodDescriptionprotected booleanaddPredecessor(AnalyzedInstruction predecessor) protected voidaddSuccessor(AnalyzedInstruction successor) intcompareTo(AnalyzedInstruction analyzedInstruction) intintprotected RegisterTypegetMergedPreRegisterTypeFromPredecessors(int registerNumber) Iterates over the predecessors of this instruction, and merges all the post-instruction register types for the given register.getPostInstructionRegisterType(int registerNumber) intgetPredecessorRegisterType(AnalyzedInstruction predecessor, int registerNumber) getPreInstructionRegisterType(int registerNumber) intbooleanIs this instruction a "beginning instruction".booleanprotected booleanmergeRegister(int registerNumber, RegisterType registerType, BitSet verifiedInstructions, boolean override) protected booleanoverridePredecessorRegisterType(AnalyzedInstruction predecessor, int registerNumber, RegisterType registerType, BitSet verifiedInstructions) Adds an override for a register type from a predecessor.protected voidprotected voidsetDeodexedInstruction(Instruction instruction) protected booleansetPostRegisterType(int registerNumber, RegisterType registerType) Sets the "post-instruction" register type as indicated.booleansetsRegister(int registerNumber) Determines if this instruction sets the given register, or alters its type
-
Field Details
-
methodAnalyzer
The MethodAnalyzer containing this instruction -
instruction
The actual instruction -
instructionIndex
protected final int instructionIndexThe index of the instruction, where the first instruction in the method is at index 0, and so on -
predecessors
Instructions that can pass on execution to this one during normal execution -
successors
Instructions that can execution could pass on to next during normal execution -
preRegisterMap
This contains the register types *before* the instruction has executed -
postRegisterMap
This contains the register types *after* the instruction has executed -
predecessorRegisterOverrides
@Nullable protected Map<AnalyzedInstruction.PredecessorOverrideKey,RegisterType> predecessorRegisterOverridesThis contains optional register type overrides for register types from predecessors -
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
-
getPredecessorRegisterType
public RegisterType getPredecessorRegisterType(@Nonnull AnalyzedInstruction predecessor, int registerNumber) -
addPredecessor
-
addSuccessor
-
setDeodexedInstruction
-
restoreOdexedInstruction
protected void restoreOdexedInstruction() -
getSuccessors
-
getInstruction
-
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
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
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, 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
-
getDestinationRegister
public int getDestinationRegister() -
getRegisterCount
public int getRegisterCount() -
getPostInstructionRegisterType
-
getPreInstructionRegisterType
-
compareTo
- Specified by:
compareToin interfaceComparable<AnalyzedInstruction>
-