@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)); } } } };
/** * Get the first successor reachable from given edge type. * * @param source * the source block * @param edgeType * the edge type leading to the successor * @return the successor, or null if there is no outgoing edge with the * specified edge type */ public BasicBlock getSuccessorWithEdgeType(BasicBlock source, @Type int edgeType) { Edge edge = getOutgoingEdgeWithType(source, edgeType); return edge != null ? edge.getTarget() : null; }
@Override public int hashCode() { return 2003 * getSource().getLabel() + getTarget().getLabel(); }
@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()); } }
BasicBlock target = edge.getTarget(); if (!reachedBlocks.get(target.getLabel())) { walkStates.push(new WalkState(numbers, target));
/** * Like bb.getFirstInstruction() except that if null is returned it will * follow the FALL_THROUGH_EDGE (if any) */ private static InstructionHandle getDeepFirstInstruction(CFG cfg, BasicBlock bb) { InstructionHandle ih = bb.getFirstInstruction(); if (ih != null) { return ih; } Iterator<Edge> iei = cfg.outgoingEdgeIterator(bb); while (iei.hasNext()) { Edge e = iei.next(); if (EdgeTypes.FALL_THROUGH_EDGE == e.getType()) { return getDeepFirstInstruction(cfg, e.getTarget()); } } return null; }
/** * Return a new State for continuing the overall pattern match in a * successor basic block. * * @param edge * the Edge leading to the successor basic block * @param matchResult * a MatchResult representing the match of the last * instruction in the predecessor block; null if none */ public State advanceToSuccessor(Edge edge, MatchResult matchResult) { // If we have just matched an instruction, then we allow the // matching PatternElement to choose which edges are acceptable. // This allows PatternElements to select particular control edges; // for example, only continue the pattern on the true branch // of an "if" comparison. if (matchResult != null && !matchResult.getPatternElement().acceptBranch(edge, getLastMatchedInstruction())) { return null; } return new State(this, edge.getTarget(), edge.getTarget().instructionIterator(), patternElement, matchCount, currentMatch, bindingSet, canFork); }
BasicBlock target = getTarget();
private InstructionHandle findThenFinish(CFG cfg, BasicBlock thenBB, int elsePos) { InstructionHandle inst = thenBB.getFirstInstruction(); while (inst == null) { Iterator<Edge> ie = cfg.outgoingEdgeIterator(thenBB); while (ie.hasNext()) { Edge e = ie.next(); if (e.getType() == EdgeTypes.FALL_THROUGH_EDGE) { thenBB = e.getTarget(); break; } } inst = thenBB.getFirstInstruction(); } InstructionHandle lastIns = inst; while (inst.getPosition() < elsePos) { lastIns = inst; inst = inst.getNext(); } return lastIns; }
public boolean isBackwardInBytecode() { BasicBlock source = getSource(); BasicBlock target = getTarget(); InstructionHandle sourceInstruction = source.getLastInstruction(); InstructionHandle targetInstruction = target.getFirstInstruction(); if (targetInstruction == null || sourceInstruction == null) { return false; } return targetInstruction.getPosition() < sourceInstruction.getPosition(); }
@Override public void meetInto(ValueNumberFrame fact, Edge edge, ValueNumberFrame result) throws DataflowAnalysisException { if (edge.getTarget().isExceptionHandler() && fact.isValid()) { // Special case: when merging predecessor facts for entry to // an exception handler, we clear the stack and push a // single entry for the exception object. That way, the locals // can still be merged. // Get the value number for the exception BasicBlock handlerBlock = edge.getTarget(); ValueNumber exceptionValueNumber = getExceptionValueNumber(handlerBlock); // Set up the stack frame ValueNumberFrame tmpFact = createFact(); tmpFact.copyFrom(fact); tmpFact.clearStack(); tmpFact.pushValue(exceptionValueNumber); fact = tmpFact; } mergeInto(fact, result); }
private Location getEdgeTargetLocation(CFG cfg, Edge edge) { BasicBlock targetBlock = edge.getTarget(); // Target block is nonempty? if (targetBlock.getFirstInstruction() != null) { return new Location(targetBlock.getFirstInstruction(), targetBlock); } // Target block is an ETB? if (targetBlock.isExceptionThrower()) { BasicBlock fallThroughSuccessor = cfg.getSuccessorWithEdgeType(targetBlock, EdgeTypes.FALL_THROUGH_EDGE); if (fallThroughSuccessor == null) { // Fall through edge might have been pruned for (Iterator<Edge> i = cfg.removedEdgeIterator(); i.hasNext();) { Edge removedEdge = i.next(); if (removedEdge.getSource() == targetBlock && removedEdge.getType() == EdgeTypes.FALL_THROUGH_EDGE) { fallThroughSuccessor = removedEdge.getTarget(); break; } } } if (fallThroughSuccessor != null && fallThroughSuccessor.getFirstInstruction() != null) { return new Location(fallThroughSuccessor.getFirstInstruction(), fallThroughSuccessor); } } return null; }
public IsNullValueFrame getFactAtMidEdge(Edge edge) throws DataflowAnalysisException { BasicBlock block = isForwards() ? edge.getSource() : edge.getTarget(); IsNullValueFrame predFact = createFact(); copy(getResultFact(block), predFact); edgeTransfer(edge, predFact); IsNullValueFrame result = createFact(); makeFactTop(result); meetInto(predFact, edge, result, false); return result; }
if (removedEdge.getType() == EdgeTypes.FALL_THROUGH_EDGE && removedEdge.getSource() == exceptionEdge.getSource()) { basicBlock = removedEdge.getTarget(); break;
ValueNumberFrame targetVnaFrame = vnaDataflow.getStartFact(edge.getTarget()); ValueNumberFrame sourceVnaFrame = vnaDataflow.getResultFact(edge.getSource());
TypeQualifierValueSet backwardFact = backwardDataflow.getResultFact(edge.getTarget());
/** * Get the fact that is true on the given control edge, * <em>after applying the edge transfer function</em> (if any). * * @param edge * the edge * @return the fact that is true after applying the edge transfer function * @throws DataflowAnalysisException */ @Override public/* final */Fact getFactOnEdge(Edge edge) throws DataflowAnalysisException { BasicBlock block = isForwards() ? edge.getSource() : edge.getTarget(); Fact predFact = createFact(); copy(getResultFact(block), predFact); edgeTransfer(edge, predFact); Fact result = createFact(); makeFactTop(result); if (this instanceof UnconditionalValueDerefAnalysis) { ((UnconditionalValueDerefAnalysis)this).meetInto((UnconditionalValueDerefSet)predFact, edge, (UnconditionalValueDerefSet)result, true); } else { meetInto(predFact, edge, result); } return result; }