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); } } }
@Override public int compareTo(SourceSinkInfo o) { return this.location.compareTo(o.location); }
@Override public boolean equals(Object o) { if (o == null || this.getClass() != o.getClass()) { return false; } IsNullValue other = (IsNullValue) o; if (kind != other.kind) { return false; } if (locationOfKaBoom == other.locationOfKaBoom) { return true; } if (locationOfKaBoom == null || other.locationOfKaBoom == null) { return false; } return locationOfKaBoom.equals(other.locationOfKaBoom); }
private void removeStrictlyDominatedLocations(Set<Location> locations, DominatorsAnalysis domAnalysis) { BitSet strictlyDominated = new BitSet(); for (Location loc : locations) { BitSet allDominatedBy = domAnalysis.getAllDominatedBy(loc.getBasicBlock()); allDominatedBy.clear(loc.getBasicBlock().getLabel()); strictlyDominated.or(allDominatedBy); } LinkedList<Location> locations2 = new LinkedList<>(locations); for (Iterator<Location> i = locations.iterator(); i.hasNext();) { Location loc = i.next(); if (strictlyDominated.get(loc.getBasicBlock().getLabel())) { i.remove(); continue; } for (Location loc2 : locations2) { if (loc.getBasicBlock().equals(loc2.getBasicBlock()) && loc.getHandle().getPosition() > loc2.getHandle().getPosition()) { i.remove(); break; } } } }
/** * Get the instruction which performs the call. */ public InstructionHandle getHandle() { return location.getHandle(); }
BasicBlock b = cfg.getSuccessorWithEdgeType(source, EdgeTypes.FALL_THROUGH_EDGE); if (b != null) { location = new Location(source.getExceptionThrower(), b); location = Location.getLastLocation(source); Instruction in = location.getHandle().getInstruction(); if (assertionMethods.isAssertionInstruction(in, classContext.getConstantPoolGen())) { if (DEBUG_DEREFS) {
if (!location.isFirstInstructionInBasicBlock()) { return; return; BasicBlock fallThroughPredecessor = cfg.getPredecessorWithEdgeType(location.getBasicBlock(), EdgeTypes.FALL_THROUGH_EDGE); if (fallThroughPredecessor == null || !fallThroughPredecessor.isNullCheck()) { return; ValueNumber vn = vnaFrame.getInstance(location.getHandle().getInstruction(), methodGen.getConstantPool()); int slot = startFact.getInstanceSlot(location.getHandle().getInstruction(), methodGen.getConstantPool()); if (!reportDereference(startFact, slot)) { return;
/** * Constructor. * * @param method * the method containing the call site * @param basicBlock * the basic block where the call site is located * @param handle * the instruction which performs the call */ public CallSite(Method method, BasicBlock basicBlock, InstructionHandle handle) { this.method = method; this.location = new Location(handle, basicBlock); }
aliveTarget = trueTarget; redundantConditions.add(new RedundantCondition(Location.getLastLocation(edge.getSource()), condition, !data.reachableBlocks.get(deadTarget.getLabel()), getLocation(deadTarget), getLocation(aliveTarget), branch.trueSet.getSignature(), branch.trueSet.isEmpty() || branch.trueSet.isFull(), List<RedundantCondition> filtered = new ArrayList<>(); for(RedundantCondition condition : redundantConditions) { if(!(assertionBlocks.get(condition.getLocation().getHandle().getPosition()))) { Collections.sort(redundantConditions, (o1, o2) -> o1.location.compareTo(o2.location)); return new ValueRangeAnalysis(redundantConditions);
return; Location location = new Location(handle, basicBlock); if (sourceSinkSet != null) { if (DEBUG_VERBOSE) { System.out.println("Modeling source/sink at " + location.toCompactString() + ": " + sourceSinkSet.toString());
private void checkForEqualityTest(XMethod xmethod, CFG cfg, TypeQualifierValue<?> typeQualifierValue, TypeQualifierValueSet forwardsFact, Location loc, ValueNumberFrame factAtLocation) throws DataflowAnalysisException { InstructionHandle handle = loc.getHandle(); Instruction ins = handle.getInstruction(); boolean isTest = false; FlowValue nextTQ = forwardsFact.getValue(next); if (DEBUG) { System.out.println("Comparing values at " + loc.toCompactString()); System.out.println(" Comparing " + topTQ + " and " + nextTQ);
@Override public int hashCode() { int hashCode = kind; if (locationOfKaBoom != null) { hashCode += locationOfKaBoom.hashCode(); } return hashCode; }
/** * Get the basic block where the call site is located. */ public BasicBlock getBasicBlock() { return location.getBasicBlock(); }
private static void appendSourceSinkInfos(StringBuilder buf, String key, Set<? extends SourceSinkInfo> sourceSinkInfoSet) { TreeSet<SourceSinkInfo> sortedLocSet = new TreeSet<>(); sortedLocSet.addAll(sourceSinkInfoSet); boolean first = true; buf.append(key); buf.append("("); for (SourceSinkInfo loc : sortedLocSet) { if (first) { first = false; } else { buf.append(","); } buf.append(loc.getLocation().toCompactString()); } buf.append(")"); } }
aliveTarget = trueTarget; redundantConditions.add(new RedundantCondition(Location.getLastLocation(edge.getSource()), condition, !data.reachableBlocks.get(deadTarget.getLabel()), getLocation(deadTarget), getLocation(aliveTarget), branch.trueSet.getSignature(), branch.trueSet.isEmpty() || branch.trueSet.isFull(), List<RedundantCondition> filtered = new ArrayList<>(); for(RedundantCondition condition : redundantConditions) { if(!(assertionBlocks.get(condition.getLocation().getHandle().getPosition()))) {
@Override public String toString() { return location.toString() + ": line " + lineNumber; } }
@Override public void transfer(BasicBlock basicBlock, @CheckForNull InstructionHandle end, IsNullValueFrame start, IsNullValueFrame result) throws DataflowAnalysisException { startTransfer(); super.transfer(basicBlock, end, start, result); endTransfer(basicBlock, end, result); if (end == null) { ValueNumberFrame vnaFrameAfter = vnaDataflow.getFactAfterLocation(Location.getLastLocation(basicBlock)); // purge stale information if (!vnaFrameAfter.isTop()) { result.cleanStaleKnowledge(vnaFrameAfter); } } }
private void removeStrictlyPostDominatedLocations(Set<Location> locations, PostDominatorsAnalysis postDomAnalysis) { BitSet strictlyDominated = new BitSet(); for (Location loc : locations) { BitSet allDominatedBy = postDomAnalysis.getAllDominatedBy(loc.getBasicBlock()); allDominatedBy.clear(loc.getBasicBlock().getLabel()); strictlyDominated.or(allDominatedBy); } LinkedList<Location> locations2 = new LinkedList<>(locations); for (Iterator<Location> i = locations.iterator(); i.hasNext();) { Location loc = i.next(); if (strictlyDominated.get(loc.getBasicBlock().getLabel())) { i.remove(); continue; } for (Location loc2 : locations2) { if (loc.getBasicBlock().equals(loc2.getBasicBlock()) && loc.getHandle().getPosition() > loc2.getHandle().getPosition()) { i.remove(); break; } } } }
@Override public String toString() { return valueNumber + " becomes null at " + location.getHandle().getPosition() + ":" + location; } }
BasicBlock b = cfg.getSuccessorWithEdgeType(source, EdgeTypes.FALL_THROUGH_EDGE); if (b != null) { location = new Location(source.getExceptionThrower(), b); location = Location.getLastLocation(source); Instruction in = location.getHandle().getInstruction(); if (assertionMethods.isAssertionInstruction(in, classContext.getConstantPoolGen())) { if (DEBUG_DEREFS) {