/** * Get the set of exceptions that can be thrown on given edge. This should * only be called after the analysis completes. * * @param edge * the Edge * @return the ExceptionSet */ public ExceptionSet getEdgeExceptionSet(Edge edge) { CachedExceptionSet cachedExceptionSet = thrownExceptionSetMap.get(edge.getSource()); return cachedExceptionSet.getEdgeExceptionSet(edge); }
public boolean sourceIsTopOfLoop(@Nonnull Set<Integer> positions) { if (positions == null) { AnalysisContext.logError("Null positions", new NullPointerException("positions can't be null")); return false; } BasicBlock source = getSource(); InstructionHandle sourceInstruction = source.getLastInstruction(); if (sourceInstruction == null) { return false; } return positions.contains(sourceInstruction.getPosition()); }
/** * Get the first predecessor reachable from given edge type. * * @param target * the target block * @param edgeType * the edge type leading from the predecessor * @return the predecessor, or null if there is no incoming edge with the * specified edge type */ public BasicBlock getPredecessorWithEdgeType(BasicBlock target, @Type int edgeType) { Edge edge = getIncomingEdgeWithType(target, edgeType); return edge != null ? edge.getSource() : null; }
public List<Edge> getDuplicates(CFG cfg, Edge edge) { InstructionHandle ih = edge.getSource().getLastInstruction(); if(ih == null) { return Collections.emptyList(); } BitSet duplicates = getDuplicates(ih.getPosition()); if(duplicates.isEmpty()) { return Collections.emptyList(); } List<Edge> result = new ArrayList<>(); for(Iterator<Edge> edgeIterator = cfg.edgeIterator(); edgeIterator.hasNext(); ) { Edge next = edgeIterator.next(); if(next.getType() != edge.getType()) { continue; } InstructionHandle lastInst = next.getSource().getLastInstruction(); if(lastInst != null && lastInst.getPosition() >= 0 && duplicates.get(lastInst.getPosition())) { result.add(next); } } return result; }
private Location getEdgeSourceLocation(CFG cfg, Edge edge) { BasicBlock sourceBlock = edge.getSource(); return (sourceBlock.getLastInstruction() != null) ? new Location(sourceBlock.getLastInstruction(), sourceBlock) : null; }
@Override public int hashCode() { return 2003 * getSource().getLabel() + getTarget().getLabel(); }
InstructionHandle handle = exceptionEdge.getSource().getExceptionThrower(); if (handle == null) { throw new IllegalStateException(); BasicBlock basicBlock = (handle.getInstruction() instanceof ATHROW) ? exceptionEdge.getSource() : getSuccessorWithEdgeType(exceptionEdge.getSource(), EdgeTypes.FALL_THROUGH_EDGE); && removedEdge.getSource() == exceptionEdge.getSource()) { basicBlock = removedEdge.getTarget(); break;
BasicBlock source = edge.getSource(); if (DEBUG) { System.out.println("ISD: scanning instructions in block " + source.getLabel());
@Override public InstructionHandle next() { if (!hasNext()) { throw new NoSuchElementException(); } InstructionHandle result = next; if(result == block.getFirstInstruction()) { do { Iterator<Edge> edgeIterator = cfg.incomingEdgeIterator(block); if(!edgeIterator.hasNext()) { break; } Edge edge = edgeIterator.next(); if(!edgeIterator.hasNext() && edge.getType() == EdgeTypes.FALL_THROUGH_EDGE) { block = edge.getSource(); } else { break; } } while(block.isExceptionThrower()); } next = (block.isExceptionThrower() || result == block.getFirstInstruction()) ? null : next.getPrev(); return result; }
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(); }
/** * Clear deref sets of values if this edge is the non-null branch of an if * comparison. * * @param fact * a datflow fact * @param edge * edge to check * @return possibly-modified dataflow fact */ private @CheckForNull ValueNumber findValueKnownNonnullOnBranch(UnconditionalValueDerefSet fact, Edge edge) { IsNullValueFrame invFrame = invDataflow.getResultFact(edge.getSource()); if (!invFrame.isValid()) { return null; } IsNullConditionDecision decision = invFrame.getDecision(); if (decision == null) { return null; } IsNullValue inv = decision.getDecision(edge.getType()); if (inv == null || !inv.isDefinitelyNotNull()) { return null; } ValueNumber value = decision.getValue(); if (DEBUG) { System.out.println("Value number " + value + " is known nonnull on " + edge); } return value; }
/** * 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; }
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; }
BasicBlock source = edge.getSource(); ValueNumberFrame vnaFact = vnaDataflow.getResultFact(source); IsNullValueFrame invFact = invDataflow.getFactAtMidEdge(edge);
private Obligation comparesObligationTypeToNull(Edge edge) throws DataflowAnalysisException { BasicBlock sourceBlock = edge.getSource(); InstructionHandle last = sourceBlock.getLastInstruction(); if (last == null) {
ValueNumberFrame sourceVnaFrame = vnaDataflow.getResultFact(edge.getSource());
/** * 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; }