public class

CFG

extends Object
implements IControlFlowGraph<InsnType extends IInstruction> Iterable<T>
java.lang.Object
   ↳ com.pnfsoftware.jeb.core.units.code.android.controlflow.CFG<InsnType extends com.pnfsoftware.jeb.core.units.code.ILocatedInstruction>

Class Overview

This class represents a Control Flow Graph for a method, or more generally, any body of code. The CFG can be typed to handle specific instructions. It is used by the Android plugins specifically, including dexdec. (The native code analysis pipeline, including gendec, use another class of CFG components.)

This class provides Data Flow Analysis support. A client can request simple and full def-use- and use-def chains. Full chains contain more precise cross-block information. Reach-chains are also available.

There are two ways to build a CFG:

  • By using the simple #CFG() constructor, and then calling #buildGraph(List, List) with a list of pre-basic blocks.
  • By calling the #CFG(List) or CFG(List, List) constructor and passing a flat list of instructions.

NOTE: This class is to be used exclusively by the Android components.

Summary

Public Constructors
CFG(Collection<BasicBlockBuilder<InsnType>> builders)
Create a CFG using a pre-computed list of partial basic block.
CFG(List<InsnType> insns, List<IrregularFlowData> irrdata)
Create a CFG by recursively parsing a list of instructions.
Public Methods
void addBlock(BasicBlock<InsnType> b)
Add a block, does nothing else.
void addBlock(int index, BasicBlock<InsnType> b)
Insert a block, does nothing else.
boolean addEdge(BasicBlock<InsnType> x, BasicBlock<InsnType> y)
TODO: rename to connect() and SHOULD NOT USE.
int addEdge(BasicBlock<InsnType> x, BasicBlock<InsnType> y, int index)
int addIrregularEdge(BasicBlock<InsnType> x, BasicBlock<InsnType> y, int index)
boolean addIrregularEdge(BasicBlock<InsnType> x, BasicBlock<InsnType> y)
TODO: Rename to connectIrregular() and SHOULD NOT USE.
int deleteEdge(BasicBlock<InsnType> x, BasicBlock<InsnType> y, int xToYPos)
Delete an edge x->y.
boolean deleteEdge(BasicBlock<InsnType> x, BasicBlock<InsnType> y)
Delete an edge x->y.
int deleteEdges(BasicBlock<InsnType> x, BasicBlock<InsnType> y)
boolean deleteIrregularEdge(BasicBlock<InsnType> x, BasicBlock<InsnType> y)
Delete an irregular edge x->y.
int deleteIrregularEdge(BasicBlock<InsnType> x, BasicBlock<InsnType> y, int xToYPos)
Delete an irregular edge x->y.
int deleteIrregularEdges(BasicBlock<InsnType> x, BasicBlock<InsnType> y)
void deleteIrregularOutEdges(BasicBlock<InsnType> b)
Delete all irregular output edges for the provided block.
void deleteOutEdges(BasicBlock<InsnType> b)
Delete all regular output edges for the provided block.
synchronized boolean doDataFlowAnalysis()
Perform data flow analysis on the CFG.
synchronized boolean doDataFlowAnalysis(boolean redo)
Perform data flow analysis on the CFG.
String format(boolean format_addresses, int format_chains, Object context)
Format the CFG into a printable string.
String format(boolean format_addresses, int format_chains, Object context, boolean format_edgelists)
Format the CFG into a printable string.
String format()
String formatBlockInstruction(InsnType insn)
String formatBlockInstructions(BasicBlock<InsnType> bb)
String formatChains(InsnType insn, ChainType type)
String formatEdges()
Format the edges of this CFG to a string:
String formatFullChains(InsnType insn, ChainType type)
String formatInstruction(InsnType insn)
String formatInstructions(Collection<InsnType> insns)
Format a list of instructions and their associated full chains.
String formatInstructions()
Format all the instructions (and their full chains) of a CFG into a printable string.
List<IrregularFlowData> generateIrregularFlowDataObjects()
(Re-)generate the irregular control flow information present in this CFG.
BasicBlock<InsnType> get(int index)
Retrieve a basic block.
TreeMap<Long, BasicBlock<InsnType>> getAddressBlockMap()
Get a complete map of the basic blocks and their addresses in the CFG.
BasicBlock<InsnType> getBlock(int index)
BasicBlock<InsnType> getBlockAt(long base)
Get the basic block that starts at the provided address or offset.
BasicBlock<InsnType> getBlockContaining(long address)
Get the basic block that contains the provided address.
BasicBlock<InsnType> getBlockEndingAt(long end)
BasicBlock<InsnType> getBlockFor(InsnType insn)
int getBlockIndex(long base)
List<BasicBlock<InsnType>> getBlocks()
Get a copy of the block list of the CFG.
List<? extends IBasicBlock<InsnType>> getBlocksView()
Get a read-only view of the list of blocks for this CFG.
Map<InsnType, Map<Integer, List<Integer>>> getDefUseChains()
Retrieve the simple def-use chains.
int getEffectiveSize()
Calculate the 'effective' size of this CFG, that is, the sum of the size of each basic block.
long getEndAddress()
Routine highest address (exclusive).
long getEntryAddress()
Routine entry-point address.
BasicBlock<InsnType> getEntryBlock()
Get the entry block.
List<BasicBlock<InsnType>> getExitBlocks()
Get the ordered list of exit blocks.
long getFirstAddress()
Routine lowest address (inclusive).
Map<InsnType, Map<Integer, List<InsnType>>> getFullDefUseChains()
Retrieve the full def-use chains.
Map<InsnType, Map<Integer, List<InsnType>>> getFullUseDefChains()
Retrieve the full use-def chains.
void getGraphRepresentation(List<int[]> edges, List<int[]> irregularEdges)
Get the a graph representation of the CFG.
Map<Integer, Set<InsnType>> getInputMap()
Retrieve the input map.
InsnType getInstruction(long address)
Get the instruction located at the exact address.
InsnType getInstructionAt(long address)
int getInstructionCount()
Get the total number of instructions in the CFG.
Couple<BasicBlock<InsnType>, Integer> getInstructionLocation(long address)
Locate an instruction.
Couple<BasicBlock<InsnType>, Integer> getInstructionLocation(long address, boolean precise)
Locate an instruction.
TreeMap<Long, InsnType> getInstructionSet()
Retrieve an ordered dictionary of instructions.
List<InsnType> getInstructions()
Get the instruction list of this CFG by aggregating each instruction of every block.
BasicBlock<InsnType> getLast()
long getLastAddress()
Routine highest address (inclusive).
Map<Integer, Set<InsnType>> getLiveMap(BasicBlock<InsnType> b)
Retrieve the variables alive at a block.
Map<Integer, Set<InsnType>> getOuputMap()
Retrieve the output map.
Map<Integer, Set<InsnType>> getReachMap(BasicBlock<InsnType> b)
Retrieve the variables reaching a block.
Map<Integer, Set<InsnType>> getReachMap(InsnType insn)
Retrieve the variables reaching an instruction.
synchronized Map<InsnType, Map<Integer, Set<InsnType>>> getReachMaps()
Computable reachability maps for all instructions of the CFG.
Map<InsnType, Map<Integer, List<Integer>>> getUseDefChains()
Retrieve the simple use-def chains.
synchronized IVariableInformationProvider getVariableInformationProvider()
boolean hasExit()
Determine if this CFG has exit blocks, that is, blocks without out-edges.
boolean hasNoExit()
Determine if this CFG does not have any exit block.
int indexOf(IBasicBlock<InsnType> b)
Iterable<InsnType> instructions()
Iterator<BasicBlock<InsnType>> iterator()
synchronized boolean lockDataFlowAnalysis()
Perform a non-forced, data-flow analysis and lock the shared DFA object to prevent resetDFA().
int reconnectEdge(BasicBlock<InsnType> x, BasicBlock<InsnType> y, BasicBlock<InsnType> z, Integer xToYPos)
This method reconnects a block x from y to z, i.e.
int reconnectEdge(BasicBlock<InsnType> x, BasicBlock<InsnType> y, BasicBlock<InsnType> z)
This method reconnects a block x from y to z, i.e.
int reconnectEdges(BasicBlock<InsnType> x, BasicBlock<InsnType> y, BasicBlock<InsnType> z)
int reconnectIrregularEdge(BasicBlock<InsnType> x, BasicBlock<InsnType> y, BasicBlock<InsnType> z, Integer xToYPos)
This method irregularly reconnects a block x from y to z, i.e.
int reconnectIrregularEdge(BasicBlock<InsnType> x, BasicBlock<InsnType> y, BasicBlock<InsnType> z)
This method irregularly reconnects a block x from y to z, i.e.
int reconnectIrregularEdges(BasicBlock<InsnType> x, BasicBlock<InsnType> y, BasicBlock<InsnType> z)
void removeBlock(BasicBlock<InsnType> b)
Remove a block, and update the fixtures.
int removeDuplicateEdges(BasicBlock<InsnType> x, BasicBlock<InsnType> y)
Remove duplicate edges (regular) from a source block to a destination block.
int removeDuplicateIrregularEdges(BasicBlock<InsnType> x, BasicBlock<InsnType> y)
Remove duplicate irregular edges from a source block to a destination block.
int reorganizeInputs()
Reorganize the input block list so that the fallthrough input block, if any, is placed first.
synchronized boolean resetDFA()
Reset (invalidate) the current data flow analysis.
synchronized boolean resetDataFlowAnalysis()
Reset (invalidate) the current data flow analysis.
synchronized IVariableInformationProvider setVariableInformationProvider(IVariableInformationProvider prv)
int simplify()
Merge the blocks that can be merged, without changing the flow of the graph.
int simplifyIrregularFlows()
Merge blocks that can be merged, taking into accounts irregular flows.
int size()
Get the number of blocks.
BasicBlock<InsnType> splitBlock(BasicBlock<InsnType> b, int index)
Split a block into two blocks.
String toString()
synchronized int unlockDataFlowAnalysis()
Request to unlock a previously locked DFA.
[Expand]
Inherited Methods
From class java.lang.Object
From interface com.pnfsoftware.jeb.core.units.code.IControlFlowGraph
From interface java.lang.Iterable

Public Constructors

public CFG (Collection<BasicBlockBuilder<InsnType>> builders)

Create a CFG using a pre-computed list of partial basic block.

public CFG (List<InsnType> insns, List<IrregularFlowData> irrdata)

Create a CFG by recursively parsing a list of instructions.

Parameters
insns list of instructions to be processed
irrdata (optional) irregular flow information, used for exception support

Public Methods

public void addBlock (BasicBlock<InsnType> b)

Add a block, does nothing else. The block is not connected, it is up to client code to connect it.

public void addBlock (int index, BasicBlock<InsnType> b)

Insert a block, does nothing else. The block is not connected, it is up to client code to connect it.

public boolean addEdge (BasicBlock<InsnType> x, BasicBlock<InsnType> y)

TODO: rename to connect() and SHOULD NOT USE.

Returns
  • true if an edge was added, false if one already existed

public int addEdge (BasicBlock<InsnType> x, BasicBlock<InsnType> y, int index)

Returns
  • the updated number of edges x->y

public int addIrregularEdge (BasicBlock<InsnType> x, BasicBlock<InsnType> y, int index)

Returns
  • the updated number of irregular edges x->y

public boolean addIrregularEdge (BasicBlock<InsnType> x, BasicBlock<InsnType> y)

TODO: Rename to connectIrregular() and SHOULD NOT USE.

Returns
  • true if an edge was added, false if one already existed

public int deleteEdge (BasicBlock<InsnType> x, BasicBlock<InsnType> y, int xToYPos)

Delete an edge x->y.

public boolean deleteEdge (BasicBlock<InsnType> x, BasicBlock<InsnType> y)

Delete an edge x->y. If duplicates exist, the first one in the list of out-edges is deleted.

Parameters
x source block
y destination block
Returns
  • true if x->y existed and was deleted

public int deleteEdges (BasicBlock<InsnType> x, BasicBlock<InsnType> y)

Returns
  • the number of deleted edges

public boolean deleteIrregularEdge (BasicBlock<InsnType> x, BasicBlock<InsnType> y)

Delete an irregular edge x->y. If duplicates exist, the first one in the list of irrout-edges is deleted.

Parameters
x source block
y destination block
Returns
  • true if x->y existed and was deleted

public int deleteIrregularEdge (BasicBlock<InsnType> x, BasicBlock<InsnType> y, int xToYPos)

Delete an irregular edge x->y.

public int deleteIrregularEdges (BasicBlock<InsnType> x, BasicBlock<InsnType> y)

public void deleteIrregularOutEdges (BasicBlock<InsnType> b)

Delete all irregular output edges for the provided block.

Parameters
b block

public void deleteOutEdges (BasicBlock<InsnType> b)

Delete all regular output edges for the provided block.

Parameters
b block

public synchronized boolean doDataFlowAnalysis ()

Perform data flow analysis on the CFG.

This method does not force a new analysis: it is the same as doDataFlowAnalysis(false).

Returns
  • success indicator

public synchronized boolean doDataFlowAnalysis (boolean redo)

Perform data flow analysis on the CFG.

Parameters
redo force a new analysis
Returns
  • success indicator

public String format (boolean format_addresses, int format_chains, Object context)

Format the CFG into a printable string. The graph edges are generated and appended to the instructions.

public String format (boolean format_addresses, int format_chains, Object context, boolean format_edgelists)

Format the CFG into a printable string.

Parameters
format_addresses true to prepend instructions by their addresses
format_chains 0=no, 1=simple chains, 2=full chains (DFA must be performed first)
context keep null
format_edgelists true to append the explicit list of edges to the CFG

public String format ()

public String formatBlockInstruction (InsnType insn)

public String formatBlockInstructions (BasicBlock<InsnType> bb)

public String formatChains (InsnType insn, ChainType type)

public String formatEdges ()

Format the edges of this CFG to a string:

public String formatFullChains (InsnType insn, ChainType type)

public String formatInstruction (InsnType insn)

public String formatInstructions (Collection<InsnType> insns)

Format a list of instructions and their associated full chains.

public String formatInstructions ()

Format all the instructions (and their full chains) of a CFG into a printable string.

public List<IrregularFlowData> generateIrregularFlowDataObjects ()

(Re-)generate the irregular control flow information present in this CFG.

public BasicBlock<InsnType> get (int index)

Retrieve a basic block.

public TreeMap<Long, BasicBlock<InsnType>> getAddressBlockMap ()

Get a complete map of the basic blocks and their addresses in the CFG. This method is recommended for use when multiple, repeated invocations of #getBlockAt(int) are to be made.

Returns
  • a map of address->block

public BasicBlock<InsnType> getBlock (int index)

public BasicBlock<InsnType> getBlockAt (long base)

Get the basic block that starts at the provided address or offset.

Parameters
base the block address/offset
Returns
  • basic block, or null if none starts at that address

public BasicBlock<InsnType> getBlockContaining (long address)

Get the basic block that contains the provided address.

Note that the address just needs to be in the block address range; it does not need to point to the beginning of an instruction within the block

Parameters
address an address within the block

public BasicBlock<InsnType> getBlockEndingAt (long end)

public BasicBlock<InsnType> getBlockFor (InsnType insn)

public int getBlockIndex (long base)

public List<BasicBlock<InsnType>> getBlocks ()

Get a copy of the block list of the CFG. The list is ordered by ascending block address. Modifying the list does not impact the CFG.

Returns
  • a copy of the list of blocks

public List<? extends IBasicBlock<InsnType>> getBlocksView ()

Get a read-only view of the list of blocks for this CFG. The list is ordered by ascending block address.

Returns
  • the list of blocks

public Map<InsnType, Map<Integer, List<Integer>>> getDefUseChains ()

Retrieve the simple def-use chains. Simple chains are used for intra-block def-use examinations. Use getFullDefUseChains() for full visibility chains.

Note: a data flow analysis must be performed first.

Returns
  • key= an instruction I; value= {key= a register R defined by I; value= the set of basic block instruction indices that use R (if the instruction is outside the block containing I, the index will be set to -1)}

public int getEffectiveSize ()

Calculate the 'effective' size of this CFG, that is, the sum of the size of each basic block.

Returns
  • the CFG size

public long getEndAddress ()

Routine highest address (exclusive).

public long getEntryAddress ()

Routine entry-point address. Note that this address may not be the lowest one in the CFG.

Returns
  • the address of the entry block

public BasicBlock<InsnType> getEntryBlock ()

Get the entry block. The entry block is unique.

Returns
  • never null; the method throws on error

public List<BasicBlock<InsnType>> getExitBlocks ()

Get the ordered list of exit blocks. A CFG may have zero or more exit blocks; CFG representing standard routines will have at least one (generally one) exit block.

Returns
  • a collection of blocks, possibly empty

public long getFirstAddress ()

Routine lowest address (inclusive). Note that this address may not be the entry-point address for this routine.

public Map<InsnType, Map<Integer, List<InsnType>>> getFullDefUseChains ()

Retrieve the full def-use chains.

This chain is the only one to have an extra key, set to null, which lists the registers defined 'outside' the routine and used throughout the routine, i.e. those which should be passed as parameters to the routine. It is the caller's responsibility to check that these registers are indeed provided as parameters.

Note: a data flow analysis must be performed first.

Returns
  • key= an instruction I; value= {key= a register R defined by I; value= the set of instructions that use that definition of R}

public Map<InsnType, Map<Integer, List<InsnType>>> getFullUseDefChains ()

Retrieve the full use-def chains.

Note: a data flow analysis must be performed first.

Returns
  • key= an instruction I; value= {key= a register R defined by I; value= the set of instructions that use that definition of R}

public void getGraphRepresentation (List<int[]> edges, List<int[]> irregularEdges)

Get the a graph representation of the CFG. The list of edges return use a 1-based node numbering scheme.

Parameters
edges (output) array of regular edges, eg: {{1,2},{1,3},{2,3}}
irregularEdges (output) array of irregular edges

public Map<Integer, Set<InsnType>> getInputMap ()

Retrieve the input map. key= register defined at input (when entering the routine from the entry block); value= set of instructions that use that register.

Note: a data flow analysis must be performed first.

public InsnType getInstruction (long address)

Get the instruction located at the exact address.

Returns
  • an instruction, null if none

public InsnType getInstructionAt (long address)

public int getInstructionCount ()

Get the total number of instructions in the CFG. This method sums the number of instructions of each block of the CFG.

public Couple<BasicBlock<InsnType>, Integer> getInstructionLocation (long address)

Locate an instruction.

Parameters
address instruction address
Returns
  • a couple (basic block, instruction index within that block); null on error

public Couple<BasicBlock<InsnType>, Integer> getInstructionLocation (long address, boolean precise)

Locate an instruction.

Parameters
address instruction address
precise if true, the instruction is expected to start at the provided address; else, the provided address may address any byte of the instruction
Returns
  • a couple (basic block, instruction index within that block); null on error

public TreeMap<Long, InsnType> getInstructionSet ()

Retrieve an ordered dictionary of instructions.

Returns
  • key= offset, value= instruction at offset

public List<InsnType> getInstructions ()

Get the instruction list of this CFG by aggregating each instruction of every block. The list is ordered by ascending address/offset.

public BasicBlock<InsnType> getLast ()

public long getLastAddress ()

Routine highest address (inclusive).

public Map<Integer, Set<InsnType>> getLiveMap (BasicBlock<InsnType> b)

Retrieve the variables alive at a block.

Note: a data flow analysis must be performed first.

Returns
  • key= a register that is used at some point after reaching the provided block; value= the set of instructions that may use that register

public Map<Integer, Set<InsnType>> getOuputMap ()

Retrieve the output map. key= register that reaches a non-output block; value= set of instructions that may have defined that register. Note: a data flow analysis must be performed first.

public Map<Integer, Set<InsnType>> getReachMap (BasicBlock<InsnType> b)

Retrieve the variables reaching a block.

Note: a data flow analysis must be performed first.

Returns
  • key= a register that has a defined value when reaching the provided block; value= the set of instructions that may have defined that register

public Map<Integer, Set<InsnType>> getReachMap (InsnType insn)

Retrieve the variables reaching an instruction.

Note: a data flow analysis must be performed first.

Returns
  • key= a register that has a defined value when reaching the provided instruction; value= the set of instructions that may have defined that register

public synchronized Map<InsnType, Map<Integer, Set<InsnType>>> getReachMaps ()

Computable reachability maps for all instructions of the CFG. A data-flow analysis will be performed if necessary.

Beware when using this method on large CFGs onto which SSA transformation was performed, as reaching-register chains can become very large.

Returns
  • key=an instruction D; value= {key: a register reaching instruction D; value: the set of instructions S that may have defined that register before it reached D}

public Map<InsnType, Map<Integer, List<Integer>>> getUseDefChains ()

Retrieve the simple use-def chains. Simple chains are used for intra-block use-def examinations. Use getFullUseDefChains() for full visibility chains.

Note: a data flow analysis must be performed first.

Returns
  • key= an instruction I; value= {key= a register R used by I; value= the set of basic block instruction indices that define R (if the instruction is outside the block containing I, the index will be set to -1)}

public synchronized IVariableInformationProvider getVariableInformationProvider ()

public boolean hasExit ()

Determine if this CFG has exit blocks, that is, blocks without out-edges.

public boolean hasNoExit ()

Determine if this CFG does not have any exit block.

public int indexOf (IBasicBlock<InsnType> b)

public Iterable<InsnType> instructions ()

public Iterator<BasicBlock<InsnType>> iterator ()

public synchronized boolean lockDataFlowAnalysis ()

Perform a non-forced, data-flow analysis and lock the shared DFA object to prevent resetDFA().

Returns
  • success indicator

public int reconnectEdge (BasicBlock<InsnType> x, BasicBlock<InsnType> y, BasicBlock<InsnType> z, Integer xToYPos)

This method reconnects a block x from y to z, i.e. x->y becomes x->z. If z is null, this method deletes the edge x>y.

Parameters
x source block
y original destination block
z new destination block; null to indicate that the edge x>y should be deleted
xToYPos optional index specifying which x>y edge (if there are more than one) should be picked (this index is not an index into the full out-list of x); if null, this method will fail on duplicate edges (see return codes)
Returns
  • +1: success
    0: failure, x->y does not exist
    -1: failure, a edge x->z already exists, and duplicate edges are never allowed
    -2: failure, multiple edges x->y were found

public int reconnectEdge (BasicBlock<InsnType> x, BasicBlock<InsnType> y, BasicBlock<InsnType> z)

This method reconnects a block x from y to z, i.e. x->y becomes x->z. Duplicates edges are forbidden.

See reconnectEdge(BasicBlock, BasicBlock, BasicBlock, Integer).

public int reconnectEdges (BasicBlock<InsnType> x, BasicBlock<InsnType> y, BasicBlock<InsnType> z)

Returns
  • the number of reconnected edges

public int reconnectIrregularEdge (BasicBlock<InsnType> x, BasicBlock<InsnType> y, BasicBlock<InsnType> z, Integer xToYPos)

This method irregularly reconnects a block x from y to z, i.e. x->y becomes x->z. If z is null, this method deletes the irregular edge x>y.

Parameters
x source block
y original destination block
z new destination block; null to indicate that the irregular edge x>y should be deleted
xToYPos optional index specifying which x>y irregular edge (if there are more than one) should be picked (this index is not an index into the full irrout-list of x); if null, this method will fail on duplicate irregular edges (see return codes)
Returns
  • +1: success
    0: failure, x->y does not exist
    -1: failure, a edge x->z already exists, and duplicate irregular edges are never allowed
    -2: failure, multiple irregular edges x->y were found

public int reconnectIrregularEdge (BasicBlock<InsnType> x, BasicBlock<InsnType> y, BasicBlock<InsnType> z)

This method irregularly reconnects a block x from y to z, i.e. x->y becomes x->z. Duplicates edges are forbidden.

See reconnectIrregularEdge(BasicBlock, BasicBlock, BasicBlock, Integer).

public int reconnectIrregularEdges (BasicBlock<InsnType> x, BasicBlock<InsnType> y, BasicBlock<InsnType> z)

public void removeBlock (BasicBlock<InsnType> b)

Remove a block, and update the fixtures. This method is content-agnostic.

A CFG should never contain empty blocks. However, when the CFG is optimized, instructions are removed, and some nodes might end up empty. This transient, stale state is fine AS LONG AS the client knows what it is doing and removes the empty block as soon as they're done, before passing it down the processing chain. This method removes empty blocks and updates the edges of connected and connecting blocks.

1st caveat: the empty block's out-degree or in-degree MUST be one. (Otherwise, stitching up the edges would not be possible.)

2nd caveat: duplicate edges can be introduced. The client should remove them if it doesn't like that.

3rd caveat: the fixtures update is instruction-agnostic. This means that the client is solely responsible regarding the decision to remove an empty block. For instance, the last instruction of the predecessor block should be checked and the client should make sure that removing the block and updating the fixtures is an operation compatible with the semantics of that last instruction.

Parameters
b block to be removed

public int removeDuplicateEdges (BasicBlock<InsnType> x, BasicBlock<InsnType> y)

Remove duplicate edges (regular) from a source block to a destination block.

Parameters
x src block
y dst block
Returns
  • the number of duplicate edges removed; -1 if no such edge exists

public int removeDuplicateIrregularEdges (BasicBlock<InsnType> x, BasicBlock<InsnType> y)

Remove duplicate irregular edges from a source block to a destination block.

Parameters
x src block
y dst block
Returns
  • the number of duplicate edges removed; -1 if no such edge exists

public int reorganizeInputs ()

Reorganize the input block list so that the fallthrough input block, if any, is placed first.

Returns
  • the number of reorganizations

public synchronized boolean resetDFA ()

Reset (invalidate) the current data flow analysis. A data flow analysis must be invalidated if CFG modifications change how variables are accessed.

Note: This method is equivalent to resetDataFlowAnalysis().

Returns
  • true if the DFA object was reset; false otherwise, indicating the DFA is in use and has not been #unlockDFA() unlocked

public synchronized boolean resetDataFlowAnalysis ()

Reset (invalidate) the current data flow analysis. A data flow analysis must be invalidated if CFG modifications change how variables are accessed.

Returns
  • true if the DFA object was reset; false otherwise, indicating the DFA is in use and has not been #unlockDFA() unlocked

public synchronized IVariableInformationProvider setVariableInformationProvider (IVariableInformationProvider prv)

public int simplify ()

Merge the blocks that can be merged, without changing the flow of the graph.
Necessary conditions include: adjacent blocks, first block falls thru the second one, no block shall have irregular outputs, and only the first block may have irregular inputs. or contents of the nodes.

Returns
  • number of mergers

public int simplifyIrregularFlows ()

Merge blocks that can be merged, taking into accounts irregular flows.
A follow through may be merged with a block inside a try (with irregular outedges) if no instruction within the block can raise.

Returns
  • the number of simplifications performed

public int size ()

Get the number of blocks.

public BasicBlock<InsnType> splitBlock (BasicBlock<InsnType> b, int index)

Split a block into two blocks. Note that the newly-created block will be set up to have the same irregular outputs as the original block.

Parameters
b block to split
index index of the "split instruction" in the block; that instruction will be the first instruction of the newly-created block
Returns
  • the newly-created block

public String toString ()

public synchronized int unlockDataFlowAnalysis ()

Request to unlock a previously locked DFA. Every call to lockDataFlowAnalysis() must be matched by a call to this method.

Returns
  • current lock count