Class BasicBlocker
java.lang.Object
com.android.dx.cf.code.BasicBlocker
- All Implemented Interfaces:
BytecodeArray.Visitor
Utility that identifies basic blocks in bytecode.
-
Method Summary
Modifier and TypeMethodDescriptionintGet previous bytecode offsetstatic ByteBlockListidentifyBlocks(ConcreteMethod method) Identifies and enumerates the basic blocks in the given method, returning a list of them.voidsetPreviousOffset(int offset) Set previous bytecode offsetvoidvisitBranch(int opcode, int offset, int length, int target) Visits an instruction which has a branch target argument.voidvisitConstant(int opcode, int offset, int length, Constant cst, int value) Visits an instruction which has a (possibly synthetic) constant argument, and possibly also an additional literal integer argument.voidvisitInvalid(int opcode, int offset, int length) Visits an invalid instruction.voidvisitLocal(int opcode, int offset, int length, int idx, Type type, int value) Visits an instruction which has a local variable index argument.voidvisitNewarray(int offset, int length, CstType type, ArrayList<Constant> intVals) Visits a newarray instruction.voidvisitNoArgs(int opcode, int offset, int length, Type type) Visits an instruction which has no inline arguments (implicit or explicit).voidvisitSwitch(int opcode, int offset, int length, SwitchList cases, int padding) Visits a switch instruction.
-
Method Details
-
identifyBlocks
Identifies and enumerates the basic blocks in the given method, returning a list of them. The returned list notably omits any definitely-dead code that is identified in the process.- Parameters:
method-non-null;method to convert- Returns:
non-null;list of basic blocks
-
visitInvalid
public void visitInvalid(int opcode, int offset, int length) Visits an invalid instruction.- Specified by:
visitInvalidin interfaceBytecodeArray.Visitor- Parameters:
opcode- the opcodeoffset- offset to the instructionlength- length of the instruction, in bytes
-
visitNoArgs
Visits an instruction which has no inline arguments (implicit or explicit).- Specified by:
visitNoArgsin interfaceBytecodeArray.Visitor- Parameters:
opcode- the opcodeoffset- offset to the instructionlength- length of the instruction, in bytestype-non-null;type the instruction operates on
-
visitLocal
Visits an instruction which has a local variable index argument.- Specified by:
visitLocalin interfaceBytecodeArray.Visitor- Parameters:
opcode- the opcodeoffset- offset to the instructionlength- length of the instruction, in bytesidx- the local variable indextype-non-null;the type of the accessed valuevalue- additional literal integer argument, if salient (i.e., foriinc)
-
visitConstant
Visits an instruction which has a (possibly synthetic) constant argument, and possibly also an additional literal integer argument. In the case ofmultianewarray, the argument is the count of dimensions. In the case ofinvokeinterface, the argument is the parameter count or'ed with the should-be-zero value left-shifted by 8. In the case of entries of typeint, thevaluefield always holds the raw value (for convenience of clients).Note: In order to avoid giving it a barely-useful visitor all its own,
newarrayalso uses this form, passingvalueas the array type code andcstas aCstTypeinstance corresponding to the array type.- Specified by:
visitConstantin interfaceBytecodeArray.Visitor- Parameters:
opcode- the opcodeoffset- offset to the instructionlength- length of the instruction, in bytescst-non-null;the constantvalue- additional literal integer argument, if salient (ignore if not)
-
visitBranch
public void visitBranch(int opcode, int offset, int length, int target) Visits an instruction which has a branch target argument.- Specified by:
visitBranchin interfaceBytecodeArray.Visitor- Parameters:
opcode- the opcodeoffset- offset to the instructionlength- length of the instruction, in bytestarget- the absolute (not relative) branch target
-
visitSwitch
Visits a switch instruction.- Specified by:
visitSwitchin interfaceBytecodeArray.Visitor- Parameters:
opcode- the opcodeoffset- offset to the instructionlength- length of the instruction, in bytescases-non-null;list of (value, target) pairs, plus the default targetpadding- the bytes found in the padding area (if any), packed
-
visitNewarray
Visits a newarray instruction.- Specified by:
visitNewarrayin interfaceBytecodeArray.Visitor- Parameters:
offset- offset to the instructionlength- length of the instruction, in bytestype-non-null;the type of the arrayintVals-non-null;list of bytecode offsets for init values
-
setPreviousOffset
public void setPreviousOffset(int offset) Set previous bytecode offset- Specified by:
setPreviousOffsetin interfaceBytecodeArray.Visitor- Parameters:
offset- offset of the previous fully parsed bytecode
-
getPreviousOffset
public int getPreviousOffset()Get previous bytecode offset- Specified by:
getPreviousOffsetin interfaceBytecodeArray.Visitor- Returns:
- return the recored offset of the previous bytecode
-