public int getNumber(PointerKey p) { return pointsToMap.getIndex(p); }
/** * warning: this is _real_ slow; don't use it anywhere performance critical */ public int getNumberOfPointerKeys() { return pointsToMap.getNumberOfPointerKeys(); }
/** * Wipe out the cached transitive closure information */ public void revertToPreTransitive() { for (PointerKey key : Iterator2Iterable.make(iterateKeys())) { if (!isTransitiveRoot(key) && !isImplicit(key) && !isUnified(key)) { PointsToSetVariable v = getPointsToSet(key); v.removeAll(); } } }
/** * did the pointer analysis use a type filter for a given points-to set? (this is ugly). */ @Override public boolean isFiltered(PointerKey key) { if (pointsToMap.isImplicit(key)) { return false; } PointsToSetVariable v = pointsToMap.getPointsToSet(key); if (v == null) { return false; } else { return v.getPointerKey() instanceof FilteredPointerKey; } }
recordUnified(pi.getPointerKey()); upgradeTypeFilter(pi, p); recordUnified(pj.getPointerKey()); upgradeTypeFilter(pj, p); if (isTransitiveRoot(pi.getPointerKey()) || isTransitiveRoot(pj.getPointerKey())) { recordTransitiveRoot(p.getPointerKey());
if (pointsToMap.isImplicit(key)) { System.err.println("Did not expect to findOrCreatePointsToSet for implicitly represented PointerKey"); System.err.println(key); Assertions.UNREACHABLE(); PointsToSetVariable result = pointsToMap.getPointsToSet(key); if (result == null) { result = new PointsToSetVariable(key); pointsToMap.put(key, result); } else { if (!pointsToMap.isUnified(key) && key instanceof FilteredPointerKey) { PointerKey pk = result.getPointerKey(); if (!(pk instanceof FilteredPointerKey)) {
/** * Unify the points-to-sets for the variables identified by the set s * * @param s numbers of points-to-set variables * @throws IllegalArgumentException if s is null */ public void unify(IntSet s) { if (s == null) { throw new IllegalArgumentException("s is null"); } // cache the variables represented HashSet<PointsToSetVariable> cache = HashSetFactory.make(s.size()); for (IntIterator it = s.intIterator(); it.hasNext();) { int i = it.next(); cache.add(pointsToMap.getPointsToSet(i)); } // unify the variables pointsToMap.unify(s); int rep = pointsToMap.getRepresentative(s.intIterator().next()); // clean up the equations updateEquationsForUnification(cache, rep); // special logic to clean up side effects updateSideEffectsForUnification(cache, rep); }
PointsToSetVariable pRef = pointsToMap.getPointsToSet(rep); for (PointsToSetVariable p : s) { if (p != pRef) { AssignEquation assign = (AssignEquation) as; PointsToSetVariable rhs = assign.getRightHandSide(); int rhsRep = pointsToMap.getRepresentative(pointsToMap.getIndex(rhs.getPointerKey())); if (rhsRep == rep) { flowGraph.removeStatement(as); AssignEquation assign = (AssignEquation) as; PointsToSetVariable lhs = assign.getLHS(); int lhsRep = pointsToMap.getRepresentative(pointsToMap.getIndex(lhs.getPointerKey())); if (lhsRep == rep) { flowGraph.removeStatement(as);
public boolean isUnified(PointerKey p) { if (p == null) { throw new IllegalArgumentException("null p"); } int i = findOrCreateIndex(p); return pointsToSets.get(i) == UNIFIED; }
public boolean isUnified(PointerKey result) { return pointsToMap.isUnified(result); }
@Override public Iterator<PointerKey> iteratePointerKeys() { return pointsToMap.iterateKeys(); }
/** * If p is unified, returns the representative for p. */ public PointsToSetVariable getPointsToSet(PointerKey p) { if (p == null) { throw new IllegalArgumentException("null p"); } if (isImplicit(p)) { throw new IllegalArgumentException("unexpected: shouldn't ask a PointsToMap for an implicit points-to-set: " + p); } int i = pointerKeys.getMappedIndex(p); if (i == -1) { return null; } int repI = uf.find(i); PointsToSetVariable result = (PointsToSetVariable) pointsToSets.get(repI); if (result != null && p instanceof FilteredPointerKey && (!(result.getPointerKey() instanceof FilteredPointerKey))) { upgradeToFilter(result, ((FilteredPointerKey) p).getTypeFilter()); } return result; }
/** * Update side effect after unification * * @param s set of PointsToSetVariables that have been unified * @param rep number of the representative variable for the unified set. */ private void updateSideEffectsForUnification(HashSet<PointsToSetVariable> s, int rep) { PointsToSetVariable pRef = pointsToMap.getPointsToSet(rep); for (PointsToSetVariable p : s) { updateSideEffects(p, pRef); } }
public boolean isTransitiveRoot(PointerKey key) { return pointsToMap.isTransitiveRoot(key); }
public boolean isImplicit(PointerKey result) { return pointsToMap.isImplicit(result); }
public Iterator<PointerKey> getTransitiveRoots() { return pointsToMap.getTransitiveRoots(); }
recordUnified(pi.getPointerKey()); upgradeTypeFilter(pi, p); recordUnified(pj.getPointerKey()); upgradeTypeFilter(pj, p); if (isTransitiveRoot(pi.getPointerKey()) || isTransitiveRoot(pj.getPointerKey())) { recordTransitiveRoot(p.getPointerKey());
if (pointsToMap.isImplicit(key)) { System.err.println("Did not expect to findOrCreatePointsToSet for implicitly represented PointerKey"); System.err.println(key); Assertions.UNREACHABLE(); PointsToSetVariable result = pointsToMap.getPointsToSet(key); if (result == null) { result = new PointsToSetVariable(key); pointsToMap.put(key, result); } else { if (!pointsToMap.isUnified(key) && key instanceof FilteredPointerKey) { PointerKey pk = result.getPointerKey(); if (!(pk instanceof FilteredPointerKey)) {
/** * Unify the points-to-sets for the variables identified by the set s * * @param s numbers of points-to-set variables * @throws IllegalArgumentException if s is null */ public void unify(IntSet s) { if (s == null) { throw new IllegalArgumentException("s is null"); } // cache the variables represented HashSet<PointsToSetVariable> cache = HashSetFactory.make(s.size()); for (IntIterator it = s.intIterator(); it.hasNext();) { int i = it.next(); cache.add(pointsToMap.getPointsToSet(i)); } // unify the variables pointsToMap.unify(s); int rep = pointsToMap.getRepresentative(s.intIterator().next()); // clean up the equations updateEquationsForUnification(cache, rep); // special logic to clean up side effects updateSideEffectsForUnification(cache, rep); }
PointsToSetVariable pRef = pointsToMap.getPointsToSet(rep); for (PointsToSetVariable p : s) { if (p != pRef) { AssignEquation assign = (AssignEquation) as; PointsToSetVariable rhs = assign.getRightHandSide(); int rhsRep = pointsToMap.getRepresentative(pointsToMap.getIndex(rhs.getPointerKey())); if (rhsRep == rep) { flowGraph.removeStatement(as); AssignEquation assign = (AssignEquation) as; PointsToSetVariable lhs = assign.getLHS(); int lhsRep = pointsToMap.getRepresentative(pointsToMap.getIndex(lhs.getPointerKey())); if (lhsRep == rep) { flowGraph.removeStatement(as);