Copyright | Galois, Inc. 2012-2014 |
---|---|
License | BSD3 |
Maintainer | atomb@galois.com |
Stability | provisional |
Portability | non-portable |
Safe Haskell | None |
Language | Haskell98 |
Control Flow Graphs of JVM bytecode. For now, this module simply builds CFGs from instruction streams and does post-dominator analysis.
- data BasicBlock
- data BBId
- ppBBId :: BBId -> Doc
- data CFG
- buildCFG :: ExceptionTable -> InstructionStream -> CFG
- cfgInstByPC :: CFG -> PC -> Maybe Instruction
- ppBB :: BasicBlock -> String
- ppInst :: Instruction -> String
- cfgToDot :: ExceptionTable -> CFG -> String -> String
- isImmediatePostDominator :: CFG -> BBId -> BBId -> Bool
- getPostDominators :: CFG -> BBId -> [BBId]
Basic blocks
Our notion of basic block is fairly standard: a maximal sequence of instructions that that can only be entered at the first of them and existed only from the last of them. I.e., a contiguous sequence of instructions that neither branch or are themselves branch targets.
The first instruction in a basic block (i.e., a "leader") may be (a) a method entry point, (b) a branch target, or (c) an instruction immediately following a branch/return.
To identify constituent basic blocks of a given instruction sequence, we identify leaders and then, for each leader, include in its basic block all instructions, in order, that intervene it and the next leader or the end of the instruction sequence, whichever comes first.
data BasicBlock Source
A basic block consists of an identifier and the instructions contained in that block.
Control flow graphs
buildCFG :: ExceptionTable -> InstructionStream -> CFG Source
Build a control-flow graph from an instruction stream. We assume that the first instruction in the instruction stream is the only external entry point in the sequence (typically, the method entry point)
cfgInstByPC :: CFG -> PC -> Maybe Instruction Source
fetch an instruction from a CFG by position
ppBB :: BasicBlock -> String Source
ppInst :: Instruction -> String Source
:: ExceptionTable | |
-> CFG | |
-> String | method name |
-> String |
Render the CFG of a method into Graphviz .dot format
isImmediatePostDominator :: CFG -> BBId -> BBId -> Bool Source
isImmediatePostDominator g x y
returns True
if y
immediately post-dominates x
in control-flow graph g
.
getPostDominators :: CFG -> BBId -> [BBId] Source
Calculate the post-dominators of a given basic block