public BackIterator(CFG cfg, BasicBlock block) { this.block = block; this.cfg = cfg; this.next = block.getLastInstruction(); }
public static Location getLastLocation(@Nonnull BasicBlock basicBlock) { InstructionHandle lastInstruction = basicBlock.getLastInstruction(); /* * if (lastInstruction == null) lastInstruction = * basicBlock.getExceptionThrower(); if (lastInstruction == null) * lastInstruction = basicBlock.getFirstInstruction(); */ if (lastInstruction == null) { return null; } return new Location(lastInstruction, basicBlock); }
/** * Return whether or not the Location is positioned at the last instruction * in the basic block. */ public boolean isLastInstructionInBasicBlock() { return !basicBlock.isEmpty() && handle == basicBlock.getLastInstruction(); }
private Location getEdgeSourceLocation(CFG cfg, Edge edge) { BasicBlock sourceBlock = edge.getSource(); return (sourceBlock.getLastInstruction() != null) ? new Location(sourceBlock.getLastInstruction(), sourceBlock) : null; }
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()); }
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; }
@Override public void transfer(BasicBlock basicBlock, @CheckForNull InstructionHandle end, TypeFrame start, TypeFrame result) throws DataflowAnalysisException { visitor.startBasicBlock(); super.transfer(basicBlock, end, start, result); // Compute thrown exception types computeThrownExceptionTypes(basicBlock, end, result); if (DEBUG) { System.out.println("After " + basicBlock.getFirstInstruction() + " -> " + basicBlock.getLastInstruction()); System.out.println(" frame: " + result); } // If this block ends with an instanceof check, // update the cached information about it. instanceOfCheckMap.remove(basicBlock); if (visitor.isInstanceOfFollowedByBranch()) { InstanceOfCheck check = new InstanceOfCheck(visitor.getInstanceOfValueNumber(), visitor.getInstanceOfType()); instanceOfCheckMap.put(basicBlock, check); } }
buf.append(" to block "); buf.append(reverse ? source.getLabel() : target.getLabel()); InstructionHandle sourceInstruction = source.getLastInstruction(); InstructionHandle targetInstruction = target.getFirstInstruction(); String exInfo = " -> ";
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(); }
while (bbi.hasNext()) { BasicBlock bb = bbi.next(); InstructionHandle last = bb.getLastInstruction(); // may be null if (prevs.contains(last)) { // danger will robinson Iterator<Edge> iei = cfg.outgoingEdgeIterator(bb); InstructionHandle last = myBB.getLastInstruction(); if (last != null) {
private @CheckForNull Location getPreviousLocation(CFG cfg, Location startLocation, boolean skipNops) { Location loc = startLocation; InstructionHandle prev = getPreviousInstruction(loc.getHandle(), skipNops); if (prev != null) { return new Location(prev, loc.getBasicBlock()); } BasicBlock block = loc.getBasicBlock(); while (true) { block = cfg.getPredecessorWithEdgeType(block, EdgeTypes.FALL_THROUGH_EDGE); if (block == null) { return null; } InstructionHandle lastInstruction = block.getLastInstruction(); if (lastInstruction != null) { return new Location(lastInstruction, block); } } }
/** * 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; }
public Location getPreviousLocation(Location loc) { InstructionHandle handle = loc.getHandle(); BasicBlock basicBlock = loc.getBasicBlock(); if (basicBlock.getFirstInstruction().equals(handle)) { BasicBlock prevBlock = basicBlock; while (true) { prevBlock = getPredecessorWithEdgeType(prevBlock, EdgeTypes.FALL_THROUGH_EDGE); if (prevBlock == null) { return loc; } handle = prevBlock.getLastInstruction(); if (handle != null) { return new Location(handle, prevBlock); } } } else { handle = handle.getPrev(); return new Location(handle, basicBlock); } }
InstructionHandle lastHandle = basicBlock.getLastInstruction(); Instruction last = lastHandle.getInstruction(); switch (last.getOpcode()) {
private Obligation comparesObligationTypeToNull(Edge edge) throws DataflowAnalysisException { BasicBlock sourceBlock = edge.getSource(); InstructionHandle last = sourceBlock.getLastInstruction(); if (last == null) { if (DEBUG_NULL_CHECK) {
/** * Get the dataflow fact representing the point just after given Location. * Note "after" is meant in the logical sense, so for backward analyses, * after means before the location in the control flow sense. * * @param location * the location * @return the fact at the point just after the location */ @Override public Fact getFactAfterLocation(Location location) throws DataflowAnalysisException { BasicBlock basicBlock = location.getBasicBlock(); InstructionHandle handle = location.getHandle(); if (handle == (isForwards() ? basicBlock.getLastInstruction() : basicBlock.getFirstInstruction())) { return getResultFact(basicBlock); } else { return getFactAtLocation(new Location(isForwards() ? handle.getNext() : handle.getPrev(), basicBlock)); } }
if (edge.getSource().getLastInstruction() != null) { locationToReport = getEdgeSourceLocation(cfg, edge); } else {
+ edge.getSource().getLastInstruction());
short branchOpcode = edge.getSource().getLastInstruction().getInstruction().getOpcode();
if (handle == basicBlock.getLastInstruction()) { lastFrame = createFact(); lastFrame.copyFrom(fact);