/** * Get the basic block where the call site is located. */ public BasicBlock getBasicBlock() { return location.getBasicBlock(); }
/** * Get dataflow fact at (just before) given Location. Note "before" is meant * in the logical sense, so for backward analyses, before means after the * location in the control flow sense. * * <p> * The default implementation ignores instructions within basic blocks. * Subclasses that model individual instructions must override this method. * </p> * * @param location * the Location * @return the dataflow value at given Location * @throws DataflowAnalysisException */ @Override public Fact getFactAtLocation(Location location) throws DataflowAnalysisException { return getStartFact(location.getBasicBlock()); }
/** * 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. * * <p> * The default implementation ignores instructions within basic blocks. * Subclasses that model individual instructions must override this method. * </p> * * @param location * the Location * @return the dataflow value after given Location * @throws DataflowAnalysisException */ @Override public Fact getFactAfterLocation(Location location) throws DataflowAnalysisException { return getResultFact(location.getBasicBlock()); }
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; } } } }
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; } } } }
private boolean mightCloseResource(ClassContext classContext, Method method, ResourceTrackerType resourceTracker) throws CFGBuilderException, DataflowAnalysisException { CFG cfg = classContext.getCFG(method); ConstantPoolGen cpg = classContext.getConstantPoolGen(); for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) { Location location = i.next(); if (resourceTracker.mightCloseResource(location.getBasicBlock(), location.getHandle(), cpg)) { return true; } } return false; }
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); } } }
buf.append(','); buf.append("(" + location.getBasicBlock().getLabel() + ":" + location.getHandle().getPosition() + ")");
/** * Get the dataflow fact representing the point just before given Location. * Note "before" is meant in the logical sense, so for backward analyses, * before means after the location in the control flow sense. * * @param location * the location * @return the fact at the point just before the location */ @Override public Fact getFactAtLocation(Location location) throws DataflowAnalysisException { Fact start = getStartFact(location.getBasicBlock()); Fact result = createFact(); makeFactTop(result); transfer(location.getBasicBlock(), location.getHandle(), start, result); return result; }
private ResourceCollection<Resource> buildResourceCollection(ClassContext classContext, Method method, ResourceTrackerType resourceTracker) throws CFGBuilderException, DataflowAnalysisException { ResourceCollection<Resource> resourceCollection = new ResourceCollection<>(); CFG cfg = classContext.getCFG(method); ConstantPoolGen cpg = classContext.getConstantPoolGen(); for (Iterator<Location> i = cfg.locationIterator(); i.hasNext();) { Location location = i.next(); Resource resource = resourceTracker.isResourceCreation(location.getBasicBlock(), location.getHandle(), cpg); if (resource != null) { resourceCollection.addCreatedResource(location, resource); } } return resourceCollection; }
Location location = i.next(); if (location.getBasicBlock().isExceptionHandler()) { continue;
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); } }
} else if (redundantBranch.location.getBasicBlock().isInJSRSubroutine() /*
return; BasicBlock fallThroughPredecessor = cfg.getPredecessorWithEdgeType(location.getBasicBlock(), EdgeTypes.FALL_THROUGH_EDGE); if (fallThroughPredecessor == null || !fallThroughPredecessor.isNullCheck()) { return;
if (handle == creationPoint.getHandle() && basicBlock == creationPoint.getBasicBlock()) { status = ResourceValueFrame.OPEN; if (DEBUG) {
return new Location(handle, location.getBasicBlock());
BasicBlock b = loc.getBasicBlock(); BasicBlock b2 = null; if (b.getFirstInstruction() != null && b.getFirstInstruction().getPosition() == pc) {
/** * 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)); } }
private MatchResult matchLocation(Location location) throws DataflowAnalysisException { // Get the ValueNumberFrames before and after the instruction ValueNumberFrame before = vnaDataflow.getFactAtLocation(location); ValueNumberFrame after = vnaDataflow.getFactAfterLocation(location); // Try to match the instruction against the pattern element. boolean debug = DEBUG && (!(patternElement instanceof Wild) || SHOW_WILD); if (debug) { debug((parentPath >= 0 ? parentPath + "->" : "") + path + ": Match " + patternElement + " against " + location.getHandle() + " " + (bindingSet != null ? bindingSet.toString() : "[]") + "..."); } MatchResult matchResult = patternElement.match(location.getHandle(), cpg, before, after, bindingSet); if (debug) { debug("\t" + ((matchResult != null) ? " ==> MATCH" : " ==> NOT A MATCH")); } if (matchResult != null) { // Successful match! // Update state to reflect that the match has occurred. ++matchCount; canFork = true; currentMatch = new PatternElementMatch(matchResult.getPatternElement(), location.getHandle(), location.getBasicBlock(), matchCount, currentMatch); bindingSet = matchResult.getBindingSet(); } return matchResult; } }
if (handle == creationPoint.getHandle() && basicBlock == creationPoint.getBasicBlock()) {