protected PointsToSetInternal checkContextsForAllocsCache( VarAndContext varAndContext, AllocAndContextSet ret, PointsToSetInternal locs) { PointsToSetInternal retSet = null; if (contextsForAllocsCache.containsKey(varAndContext)) { for (AllocAndContext allocAndContext : contextsForAllocsCache.get( varAndContext).getO2()) { if (locs.contains(allocAndContext.alloc)) { ret.add(allocAndContext); } } final PointsToSetInternal oldLocs = contextsForAllocsCache.get( varAndContext).getO1(); final PointsToSetInternal tmpSet = new HybridPointsToSet(locs .getType(), pag); locs.forall(new P2SetVisitor() { @Override public void visit(Node n) { if (!oldLocs.contains(n)) { tmpSet.add(n); } } }); retSet = tmpSet; oldLocs.addAll(tmpSet, null); } else { PointsToSetInternal storedSet = new HybridPointsToSet(locs .getType(), pag); storedSet.addAll(locs, null); contextsForAllocsCache.put(varAndContext, new Pair<PointsToSetInternal, AllocAndContextSet>( storedSet, new AllocAndContextSet())); retSet = locs; } return retSet; }
public boolean hasNonEmptyIntersection(PointsToSet other) { if (other instanceof AllocAndContextSet) { return nonEmptyHelper((AllocAndContextSet) other); } else if (other instanceof WrappedPointsToSet) { return hasNonEmptyIntersection(((WrappedPointsToSet) other).getWrapped()); } else if (other instanceof PointsToSetInternal) { return ((PointsToSetInternal) other).forall(new P2SetVisitor() { @Override public void visit(Node n) { if (!returnValue) { for (AllocAndContext allocAndContext : AllocAndContextSet.this) { if (n.equals(allocAndContext.alloc)) { returnValue = true; break; } } } } }); } throw new UnsupportedOperationException("can't check intersection with set of type " + other.getClass()); }
@Override public void injectPts() { final GeomPointsTo geomPTA = (GeomPointsTo)Scene.v().getPointsToAnalysis(); pt_objs = new HashMap<AllocNode, HeapInsIntervalManager>(); me.getP2Set().forall( new P2SetVisitor() { @Override public void visit(Node n) { if ( geomPTA.isValidGeometricNode(n) ) pt_objs.put((AllocNode)n, (HeapInsIntervalManager)stubManager); } }); new_pts = null; }
/** * We transfer the SPARK results to current pointer if this pointer is not involved in the geometric analysis. * Note that, the unreachable objects will not be inserted. */ @Override public void injectPts() { final GeomPointsTo geomPTA = (GeomPointsTo)Scene.v().getPointsToAnalysis(); pt_objs = new HashMap<AllocNode, GeometricManager>(); me.getP2Set().forall( new P2SetVisitor() { @Override public void visit(Node n) { if ( geomPTA.isValidGeometricNode(n) ) pt_objs.put((AllocNode)n, (GeometricManager)stubManager); } }); new_pts = null; }
@Override public void injectPts() { final GeomPointsTo geomPTA = (GeomPointsTo)Scene.v().getPointsToAnalysis(); pt_objs = new HashMap<AllocNode, PtInsIntervalManager>(); me.getP2Set().forall( new P2SetVisitor() { @Override public void visit(Node n) { if ( geomPTA.isValidGeometricNode(n) ) pt_objs.put((AllocNode)n, (PtInsIntervalManager)stubManager); } }); new_pts = null; }
private List<AllocNode> getMayAliasList(PointsToSetInternal pts) { List<AllocNode> list = new ArrayList<AllocNode>(); final HashSet<AllocNode> ret = new HashSet<AllocNode>(); pts.forall( new P2SetVisitor() { public void visit( Node n ) { ret.add( (AllocNode)n ); } } ); Iterator<AllocNode> it = ret.iterator(); while (it.hasNext()){ list.add( it.next() ); } return list; }
private boolean isArrayAccessShared(Local local) { PointsToSetInternal pts = (PointsToSetInternal) pag.reachingObjects(local); return pts.forall(new P2SetVisitor() { boolean isShared ; @Override public void visit(Node n) { if(!isShared) { int id = n.getNumber(); XNode xn = indexNodeMap.get(id); if(xn!=null) isShared = xn.isArrayShared(); } } @Override public boolean getReturnValue() { return isShared; } }); }
private void accessArray(Local local, final boolean isWrite) { PointsToSetInternal pts = (PointsToSetInternal) pag.reachingObjects(local); pts.forall(new P2SetVisitor() { @Override public void visit(Node n) { int id = n.getNumber(); XNode xn = indexNodeMap.get(id); if(xn==null) { xn = new XNode(); indexNodeMap.put(id,xn); } xn.accessArray(currentThreadID,isWrite); if(currentThread.runsMany) { xn.accessArray((byte) (currentThreadID+1),isWrite); } } }); }
private void accessField(Local local, final SootField sf, final boolean isWrite) { PointsToSetInternal pts = (PointsToSetInternal) pag.reachingObjects(local); pts.forall(new P2SetVisitor() { @Override public void visit(Node n) { int id = n.getNumber(); XNode xn = indexNodeMap.get(id); if(xn==null) { xn = new XNode(); indexNodeMap.put(id,xn); } accessField(id,sf,isWrite); } }); }
public boolean shouldHandle(VarNode dst) { // TODO Auto-generated method stub P2SetVisitor v = new P2SetVisitor() { @Override public void visit(Node n) { if (!returnValue) { returnValue = !manager.castNeverFails(n.getType(), type); } } }; dst.getP2Set().forall(v); return v.getReturnValue(); }
protected void checkAll( final Node container, PointsToSetInternal nodes, final Node upstream ) { nodes.forall( new P2SetVisitor() { public final void visit( Node n ) { checkNode( container, n, upstream ); } } ); }
private PointsToSetInternal field_p2set( PointsToSet s, final SparkField f ) { if ( !(s instanceof PointsToSetInternal) ) throw new RuntimeException( "Base pointers must be stored in *PointsToSetInternal*." ); PointsToSetInternal bases = (PointsToSetInternal) s; final PointsToSetInternal ret = getSetFactory().newSet(f.getType(), this); bases.forall(new P2SetVisitor() { public final void visit(Node n) { Node nDotF = ((AllocNode) n).dot(f); if (nDotF != null) { //nDotF.getP2Set() has been discarded in solve() IVarAbstraction pn = consG.get(nDotF); if (pn == null || hasTransformed || nDotF.getP2Set() != EmptyPointsToSet.v()) { ret.addAll(nDotF.getP2Set(), null); return; } pn = pn.getRepresentative(); //PointsToSetInternal ptSet = nDotF.makeP2Set(); for ( AllocNode obj : pn.get_all_points_to_objects() ) { ret.add( obj ); //ptSet.add(obj); } } } }); return ret; }