Class MutableBlockControlFlowGraph

All Implemented Interfaces:
Iterable<Stmt>

public class MutableBlockControlFlowGraph extends MutableControlFlowGraph
Control flow graph that stores Stmts in maximal basic blocks.

Every mutation is built from three structural primitives on top of the edge primitives of MutableBasicBlockImpl:

  • split(sootup.core.graph.MutableBasicBlockImpl, int): cut a block so that a given stmt becomes the head of a block,
  • merge(sootup.core.graph.MutableBasicBlockImpl, sootup.core.graph.MutableBasicBlockImpl): join a block with its only, fall-through successor,
  • normalize(sootup.core.graph.MutableBasicBlockImpl): merge a block with its neighbours where possible.
Operations validate their arguments first, split what they need, change edges, then normalize, so blocks stay maximal. Within beginBatch()/endBatch() merging is deferred.

Costs: a stmt index (IdentityHashMap) maps stmts to blocks; blocks store stmts in a deque with a position cache, so lookups and head/tail changes are O(1) and a split or merge moves the smaller part. The linearized block order is cached and survives changes inside a block.

Author:
Markus Schmidt