Class JitReachabilityModel

java.lang.Object
ghidra.pcode.emu.jit.analysis.JitReachabilityModel

public class JitReachabilityModel extends Object
The p-code block reachability analysis for JIT-accelerated emulation.

The implements the Reachability phase of the JitCompiler using a simple graph traversal. The result is the set of basic blocks and edges that are actually reachable from a passage's entries.

The traversal is seeded with each of the passage's entry points, and then each outbound flow is considered. Consider a conditional branch. The control-flow graph will have two outbound flows, one for the branch case, and one for the fall-through case. It's possible the data-flow phase detected its condition was constant, and so it would be re-written as an unconditional branch or nop, so we must examine the actual JitOp presented, not just the original p-code op, when determining which flows can be taken. We perform this traversal in the downstream direction only.

  • Constructor Details

    • JitReachabilityModel

      public JitReachabilityModel(JitAnalysisContext context, JitControlFlowModel cfm, JitDataFlowModel dfm)
      Create the reachability model
      Parameters:
      context - the analysis context
      cfm - the control-flow model
      dfm - the data-flow model.
      Implementation Notes:
      We're being a bit lazy here requiring the DFM, because we use the re-written JitOps so that reachability heeds folded indirect and conditional branches. If we don't want this dependency, we could inspect the folded constants for the ops ourselves.
  • Method Details

    • isReachable

      public boolean isReachable(JitControlFlowModel.JitBlock block)
      Check whether the given block can be reached
      Parameters:
      block - the block to check
      Returns:
      true if reachable, i.e., non-removable
    • isTakeable

      public boolean isTakeable(JitControlFlowModel.BlockFlow flow)
      Check whether the given flow can be taken
      Parameters:
      flow - the flow to check
      Returns:
      true if it can be taken, i.e., analysis must consider this edge.
    • dumpResult

      public void dumpResult()
      For diagnostics: Dump the analysis result to stder
      See Also: