/** * Constructor. * * @param cfg * the CFG to compute dominator relationships for * @param ignoreExceptionEdges * true if exception edges should be ignored */ public AbstractDominatorsAnalysis(CFG cfg, final boolean ignoreExceptionEdges) { this(cfg, edge -> { if (ignoreExceptionEdges && edge.isExceptionEdge()) { return false; } else { return true; } }); }
public NonImplicitExceptionPostDominatorsAnalysis(CFG cfg, ReverseDepthFirstSearch rdfs, DepthFirstSearch dfs) { super(cfg, rdfs, dfs, edge -> !edge.isExceptionEdge() || edge.isFlagSet(EdgeTypes.EXPLICIT_EXCEPTIONS_FLAG)); } }
/** * Get number of non-exception control successors of given basic block. * * @param block * a BasicBlock * @return number of non-exception control successors of the basic block */ public int getNumNonExceptionSucessors(BasicBlock block) { int numNonExceptionSuccessors = block.getNumNonExceptionSuccessors(); if (numNonExceptionSuccessors < 0) { numNonExceptionSuccessors = 0; for (Iterator<Edge> i = outgoingEdgeIterator(block); i.hasNext();) { Edge edge = i.next(); if (!edge.isExceptionEdge()) { numNonExceptionSuccessors++; } } block.setNumNonExceptionSuccessors(numNonExceptionSuccessors); } return numNonExceptionSuccessors; }
@Override public void edgeTransfer(Edge edge, ReturnPathType fact) { // The edges leading into the exit block create the "seed" values // for the analysis. The exception edges create values indicating // that a normal (non-exception) return is not possible, // while the non-exception edges create values indicating that // a normal return is possible. if (edge.getTarget() == cfg.getExit()) { fact.setCanReturnNormally(!edge.isExceptionEdge()); } }
@Override public void meetInto(ConstantFrame fact, Edge edge, ConstantFrame result) throws DataflowAnalysisException { if (fact.isValid()) { ConstantFrame tmpFact = null; if (edge.isExceptionEdge()) { tmpFact = modifyFrame(fact, null); tmpFact.clearStack(); tmpFact.pushValue(Constant.NOT_CONSTANT); } if (tmpFact != null) { fact = tmpFact; } } mergeInto(fact, result); }
@Override public void visitEdge(Edge edge) { if (REPORT_PATH_DEBUG) { System.out.println("Edge of type " + Edge.edgeTypeToString(edge.getType()) + " to " + edge.getTarget().getLabel()); if (edge.getTarget().getFirstInstruction() != null) { System.out.println(" First instruction in target: " + edge.getTarget().getFirstInstruction()); } if (edge.getTarget().isExceptionThrower()) { System.out.println(" exception thrower for " + edge.getTarget().getExceptionThrower()); } if (edge.isExceptionEdge()) { System.out.println(" exceptions thrown: " + typeDataflow.getEdgeExceptionSet(edge)); } } } };
if (!edge.isExceptionEdge()) { continue;
/** * Determine whether dataflow should be propagated on given edge. * * @param edge * the edge * @return true if dataflow should be propagated on the edge, false * otherwise */ private boolean isExceptionEdge(Edge edge) { boolean isExceptionEdge = edge.isExceptionEdge(); if (isExceptionEdge) { if (DEBUG) { System.out.println("NOT Ignoring " + edge); } return true; // false } if (edge.getType() != EdgeTypes.FALL_THROUGH_EDGE) { return false; } InstructionHandle h = edge.getSource().getLastInstruction(); if (h != null && h.getInstruction() instanceof IFNONNULL && isNullCheck(h, methodGen.getConstantPool())) { return true; } return false; }
if (e.isExceptionEdge()) { exceptionEdgeCount++; lastExceptionEdge = e; if (edge.isExceptionEdge()) { cachedExceptionSet.setEdgeExceptionSet(edge, computeEdgeExceptionSet(edge, thrownExceptionSet));
if (edge.isExceptionEdge()) { if (DEBUG_DEREFS) { System.out.println("On exception edge " + edge.formatAsString(false)); if (edge.isExceptionEdge()) { BasicBlock b = cfg.getSuccessorWithEdgeType(source, EdgeTypes.FALL_THROUGH_EDGE); if (b != null) {
if (!exceptionEdge.isExceptionEdge()) { throw new IllegalArgumentException();
if (!edge.isExceptionEdge() && cfg.getNumNonExceptionSucessors(edge.getSource()) > 1) { tmpFact = modifyFrame(fact, null); tmpFact.downgradeOnControlSplit();
@Override public void edgeTransfer(Edge edge, StateSet fact) throws DataflowAnalysisException { if (edge.isExceptionEdge()) { if ( !edge.isFlagSet(EdgeTypes.CHECKED_EXCEPTIONS_FLAG)) {
if (edge.isExceptionEdge()) {
@Override public boolean choose(Edge edge) { if (ignoreExceptionEdges && edge.isExceptionEdge()) { return false; } else { return true; } } });
@Override public boolean choose(Edge edge) { return !edge.isExceptionEdge() || edge.isFlagSet(EdgeTypes.EXPLICIT_EXCEPTIONS_FLAG); } });
@Override public void edgeTransfer(Edge edge, ReturnPathType fact) { // The edges leading into the exit block create the "seed" values // for the analysis. The exception edges create values indicating // that a normal (non-exception) return is not possible, // while the non-exception edges create values indicating that // a normal return is possible. if (edge.getTarget() == cfg.getExit()) { fact.setCanReturnNormally(!edge.isExceptionEdge()); } }
@Override public void meetInto(ConstantFrame fact, Edge edge, ConstantFrame result) throws DataflowAnalysisException { if (fact.isValid()) { ConstantFrame tmpFact = null; if (edge.isExceptionEdge()) { tmpFact = modifyFrame(fact, null); tmpFact.clearStack(); tmpFact.pushValue(Constant.NOT_CONSTANT); } if (tmpFact != null) { fact = tmpFact; } } mergeInto(fact, result); }
@Override public void meetInto(TaintFrame fact, Edge edge, TaintFrame result) throws DataflowAnalysisException { if (fact.isValid() && edge.isExceptionEdge()) { TaintFrame copy = null; // creates modifiable copy copy = modifyFrame(fact, copy); copy.clearStack(); // do not trust values that are safe just when an exception occurs copy.pushValue(new Taint(Taint.State.UNKNOWN)); fact = copy; } mergeInto(fact, result); }
@Override public void meetInto(TaintFrame fact, Edge edge, TaintFrame result) throws DataflowAnalysisException { if (fact.isValid() && edge.isExceptionEdge()) { TaintFrame copy = null; // creates modifiable copy copy = modifyFrame(fact, copy); copy.clearStack(); // do not trust values that are safe just when an exception occurs copy.pushValue(new Taint(Taint.State.UNKNOWN)); fact = copy; } mergeInto(fact, result); }