Class BasicBlock<InsnType extends ILocatedInstruction>
- Type Parameters:
InsnType- located instruction type
- All Implemented Interfaces:
IBasicBlock<InsnType>,Iterable<InsnType>
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionCreate a new empty basic block.BasicBlock(Collection<InsnType> insnlist) Create a new basic block with the provided instructions. -
Method Summary
Modifier and TypeMethodDescriptionvoidDANGEROUS! Add an instruction to the block.voidDANGEROUS! Append an instruction to the block.voidaddAll(Collection<InsnType> insnlist) DANGEROUS! Append instructions to the block.intGet the total number of input edges to this block.intGet the total number of output edges from this block.booleancanThrow()Determine whether this block can throw an exception.get(int index) Get the instruction at the specified index.longGet the block address.longgetAddressOfInstruction(int index) Get the address of an instruction by index.Get regular and irregular input blocks.Retrieve a read-only iterable of regular and irregular input blocks.Get regular and irregular output blocks.Retrieve a read-only iterable of regular and irregular output blocks.longgetBase()Address of first instruction in the block.longAddress following the last instruction of the block (ie, last exclusive address).longAddress of first instruction in the block.intgetIndexOfInstruction(long address) Get the index of an instruction by address.intgetIndexOfInstruction(long address, boolean precise) Get the index of an instruction by address.getInputBlock(int index) Get a regular input block.Get the regular input blocks.Get the addresses of regular input blocks.Retrieve a read-only list of input blocks (regular).getInstruction(long address) Get the instruction located at the exact address.Get a copy of the list of instructions that make up this basic block.getIrregularInputBlock(int index) Get an irregular input block.Get irregular input blocks.Get the addresses of irregular input blocks.Retrieve a read-only list of irregular input blocks.getIrregularOutputBlock(int index) Get an irregular output block.Get irregular output blocks.Get the addresses of irregular output blocks.Retrieve a read-only list of irregular output blocks.getLast()Get the last instruction of the block.longAddress of last instruction in the block.getOutputBlock(int index) Get a regular output block.Get the regular output blocks.Get the addresses of regular output blocks.Retrieve a read-only list of output blocks (regular).intGet the total size of instructions in the block.intinsize()Get the number of regular input edges to this block.intGet the number of irregular input edges to this block.intGet the number of irregular output edges from this block.booleanisEmpty()Determine if the block has 0 instruction.iterator()intoutsize()Get the number of regular output edges from this block.remove(int index) DANGEROUS! Remove an instruction from the block.voidDANGEROUS! Remove all instructions from the block.Replace an instruction.Replace an instruction.intsize()Get the number of instructions in the block.toString()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Constructor Details
-
BasicBlock
public BasicBlock()Create a new empty basic block. -
BasicBlock
Create a new basic block with the provided instructions.- Parameters:
insnlist- instructions to add to the block
-
-
Method Details
-
size
public int size()Description copied from interface:IBasicBlockGet the number of instructions in the block.- Specified by:
sizein interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- instruction count
-
isEmpty
public boolean isEmpty()Description copied from interface:IBasicBlockDetermine if the block has 0 instruction.- Specified by:
isEmptyin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- true if the block has no instruction
-
get
Description copied from interface:IBasicBlockGet the instruction at the specified index.- Specified by:
getin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Parameters:
index- instruction index- Returns:
- instruction
-
getLast
Description copied from interface:IBasicBlockGet the last instruction of the block.- Specified by:
getLastin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- last instruction
-
getInstructions
Description copied from interface:IBasicBlockGet a copy of the list of instructions that make up this basic block.- Specified by:
getInstructionsin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- instruction list
-
getSizeOfInstructions
public int getSizeOfInstructions()Description copied from interface:IBasicBlockGet the total size of instructions in the block.- Specified by:
getSizeOfInstructionsin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- instruction size
-
getBase
public long getBase()Description copied from interface:IBasicBlockAddress of first instruction in the block.- Specified by:
getBasein interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- first instruction address
-
getAddress
public long getAddress()Get the block address.- Returns:
- the first instruction address
-
getFirstAddress
public long getFirstAddress()Description copied from interface:IBasicBlockAddress of first instruction in the block.- Specified by:
getFirstAddressin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- first instruction address
-
getLastAddress
public long getLastAddress()Description copied from interface:IBasicBlockAddress of last instruction in the block.- Specified by:
getLastAddressin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- last instruction address
-
getEndAddress
public long getEndAddress()Description copied from interface:IBasicBlockAddress following the last instruction of the block (ie, last exclusive address).- Specified by:
getEndAddressin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- end address
-
getAddressOfInstruction
public long getAddressOfInstruction(int index) Description copied from interface:IBasicBlockGet the address of an instruction by index.- Specified by:
getAddressOfInstructionin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Parameters:
index- instruction index- Returns:
- instruction address
-
getIndexOfInstruction
public int getIndexOfInstruction(long address) Description copied from interface:IBasicBlockGet the index of an instruction by address.- Specified by:
getIndexOfInstructionin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Parameters:
address- instruction address- Returns:
- -1 if there is no instruction starting at the provided address
-
getIndexOfInstruction
public int getIndexOfInstruction(long address, boolean precise) Get the index of an instruction by address.- Parameters:
address- instruction addressprecise- if true, the address must match the instruction start; otherwise, any address within the instruction is accepted- Returns:
- the instruction index, or -1 if none was found
-
getInstruction
Description copied from interface:IBasicBlockGet the instruction located at the exact address.- Specified by:
getInstructionin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Parameters:
address- instruction address- Returns:
- instruction, or null
-
canThrow
public boolean canThrow()Description copied from interface:IBasicBlockDetermine whether this block can throw an exception.- Specified by:
canThrowin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- true if the block can throw
-
remove
DANGEROUS! Remove an instruction from the block.The instruction is removed from the block. The edges are not updated. The block may end up empty.
- Parameters:
index- instruction index- Returns:
- true if the CFG need refreshing
-
removeAll
public void removeAll()DANGEROUS! Remove all instructions from the block.The edges are not updated. The block may end up empty.
-
add
DANGEROUS! Append an instruction to the block.The instruction is appended to the block. The edges are not updated.
The caller is responsible for maintaining the consistency of the block and of the CFG.- Parameters:
insn- the instruction to be appended
-
addAll
DANGEROUS! Append instructions to the block.The instructions are appended to the block. The edges are not updated.
The caller is responsible for maintaining the consistency of the block and of the CFG.- Parameters:
insnlist- the collection of instructions to be appended
-
add
DANGEROUS! Add an instruction to the block.The instruction is inserted in the block. The edges are not updated.
The caller is responsible for maintaining the consistency of the block and of the CFG.- Parameters:
index- insertion indexinsn- the instruction to be inserted
-
set
Replace an instruction. The size is validated, the offset is not validated.- Parameters:
index- index in the blockinsn- instruction to set at index- Returns:
- the instruction that was replaced
-
set
Replace an instruction. The size and offset may be validated.- Parameters:
index- index in the blockinsn- instruction to set at indexverifySize- if false, validating and updating the instruction size is the responsibility of the caller; else, the size is validated and must match the replaced instruction'sverifyOffset- if false, validating and updating the instruction offset is the responsibility of the caller; else, the offset is validated and must match the replaced instruction's- Returns:
- the instruction that was replaced
-
insize
public int insize()Description copied from interface:IBasicBlockGet the number of regular input edges to this block.- Specified by:
insizein interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- regular input edge count
-
irrinsize
public int irrinsize()Description copied from interface:IBasicBlockGet the number of irregular input edges to this block.- Specified by:
irrinsizein interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- irregular input edge count
-
allinsize
public int allinsize()Description copied from interface:IBasicBlockGet the total number of input edges to this block.- Specified by:
allinsizein interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- input edge count
-
getInputBlock
Description copied from interface:IBasicBlockGet a regular input block.- Specified by:
getInputBlockin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Parameters:
index- block index- Returns:
- a block
-
getInputBlocks
Description copied from interface:IBasicBlockGet the regular input blocks.- Specified by:
getInputBlocksin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- a copy of the list of regular input blocks
-
getInputOffsets
Get the addresses of regular input blocks.- Returns:
- a list of input block addresses
-
getIrregularInputBlock
Description copied from interface:IBasicBlockGet an irregular input block.- Specified by:
getIrregularInputBlockin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Parameters:
index- block index- Returns:
- a block
-
getIrregularInputBlocks
Description copied from interface:IBasicBlockGet irregular input blocks.- Specified by:
getIrregularInputBlocksin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- a copy of the list of irregular input blocks
-
getIrregularInputOffsets
Get the addresses of irregular input blocks.- Returns:
- a list of irregular input block addresses
-
getAllInputBlocks
Description copied from interface:IBasicBlockGet regular and irregular input blocks.- Specified by:
getAllInputBlocksin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- a copy of the list of all input blocks
-
outsize
public int outsize()Description copied from interface:IBasicBlockGet the number of regular output edges from this block.- Specified by:
outsizein interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- regular output edge count
-
irroutsize
public int irroutsize()Description copied from interface:IBasicBlockGet the number of irregular output edges from this block.- Specified by:
irroutsizein interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- irregular output edge count
-
alloutsize
public int alloutsize()Description copied from interface:IBasicBlockGet the total number of output edges from this block.- Specified by:
alloutsizein interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- output edge count
-
getOutputBlock
Description copied from interface:IBasicBlockGet a regular output block.- Specified by:
getOutputBlockin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Parameters:
index- block index- Returns:
- output block
-
getOutputBlocks
Description copied from interface:IBasicBlockGet the regular output blocks.- Specified by:
getOutputBlocksin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- a copy of the list of regular output blocks
-
getOutputOffsets
Get the addresses of regular output blocks.- Returns:
- a list of output block addresses
-
getIrregularOutputBlock
Description copied from interface:IBasicBlockGet an irregular output block.- Specified by:
getIrregularOutputBlockin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Parameters:
index- block index- Returns:
- irregular output block
-
getIrregularOutputBlocks
Description copied from interface:IBasicBlockGet irregular output blocks.- Specified by:
getIrregularOutputBlocksin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- a copy of the list of irregular output blocks
-
getIrregularOutputOffsets
Get the addresses of irregular output blocks.- Returns:
- a list of irregular output block addresses
-
getAllOutputBlocks
Description copied from interface:IBasicBlockGet regular and irregular output blocks.- Specified by:
getAllOutputBlocksin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- a copy of the list of all output blocks
-
getInputs
Retrieve a read-only list of input blocks (regular).NOTE: This method is faster than
getInputBlocks()since it does not provide a copy of the list.- Specified by:
getInputsin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- an unmodifiable view of regular input blocks
-
getIrregularInputs
Retrieve a read-only list of irregular input blocks.NOTE: This method is faster than
getIrregularInputBlocks()since it does not provide a copy of the list.- Specified by:
getIrregularInputsin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- an unmodifiable view of irregular input blocks
-
getOutputs
Retrieve a read-only list of output blocks (regular).NOTE: This method is faster than
getOutputBlocks()since it does not provide a copy of the list.- Specified by:
getOutputsin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- an unmodifiable view of regular output blocks
-
getIrregularOutputs
Retrieve a read-only list of irregular output blocks.NOTE: This method is faster than
getIrregularOutputBlocks()since it does not provide a copy of the list.- Specified by:
getIrregularOutputsin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- an unmodifiable view of irregular output blocks
-
getAllInputs
Description copied from interface:IBasicBlockRetrieve a read-only iterable of regular and irregular input blocks.NOTE: This method is faster than
IBasicBlock.getAllInputBlocks()since it does not provide a copy of the list.- Specified by:
getAllInputsin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- all input blocks view
-
getAllOutputs
Description copied from interface:IBasicBlockRetrieve a read-only iterable of regular and irregular output blocks.NOTE: This method is faster than
IBasicBlock.getAllOutputBlocks()since it does not provide a copy of the list.- Specified by:
getAllOutputsin interfaceIBasicBlock<InsnType extends ILocatedInstruction>- Returns:
- all output blocks view
-
iterator
- Specified by:
iteratorin interfaceIterable<InsnType extends ILocatedInstruction>
-
toString
-