/** * @param fastMerge if true, the representation uses extra space in order to support faster merge operations */ public LocalPathEdges(boolean fastMerge) { altPaths = fastMerge ? new SparseVector<>(1, 1.1f) : null; }
public void clearMutatedCache(CallSiteReference cs) { targets.remove(cs.getProgramCounter()); }
public void remove(int x) { int index = indices.getIndex(x); if (index == -1) { return; } else { System.arraycopy(data, index + 1, data, index, size() - index - 1); indices.remove(x); } } }
/** * Record that in this procedure we've discovered a same-level realizable path from (s_p,i) to (n,i) * * @param n local block number of the basic block n */ @SuppressWarnings("unused") private void addIdentityPathEdge(int i, int n) { BitVectorIntSet s = (BitVectorIntSet) identityPaths.get(i); if (s == null) { s = new BitVectorIntSet(); identityPaths.set(i, s); } s.add(n); if (altPaths != null) { IBinaryNaturalRelation R2 = altPaths.get(i); if (R2 == null) { // we expect the first dimension of R to be dense, the second sparse R2 = new BasicNaturalRelation(new byte[] { BasicNaturalRelation.SIMPLE_SPACE_STINGY }, BasicNaturalRelation.TWO_LEVEL); altPaths.set(i, R2); } R2.add(n, i); } if (TabulationSolver.DEBUG_LEVEL > 1) { System.err.println("recording self-path edge, now d1= " + i + " reaches " + s); } }
public void removeTarget(CGNode target) { allTargets.remove(getCallGraph().getNumber(target)); for (IntIterator it = targets.safeIterateIndices(); it.hasNext();) { int pc = it.next(); Object value = targets.get(pc); if (value instanceof CGNode) { if (value.equals(target)) { targets.remove(pc); } } else { MutableIntSet s = (MutableIntSet) value; int n = getCallGraph().getNumber(target); if (s.size() > 2) { s.remove(n); } else { assert s.size() == 2; if (s.contains(n)) { s.remove(n); int i = s.intIterator().next(); targets.set(pc, getCallGraph().getNode(i)); } } } } }
if (paths.size() > 0) { Iterator<IBinaryNaturalRelation> contents = paths.iterator(); for (IntIterator it = paths.iterateIndices(); it.hasNext();) { int d2 = it.next(); IBinaryNaturalRelation R = contents.next(); if (identityPaths.size() > 0) { BitVectorIntSet s = (BitVectorIntSet) identityPaths.get(d1); if (s != null && s.contains(n)) { result.add(d1); if (d1 == 0 && zeroPaths.size() > 0) { Iterator<IntSet> contents = zeroPaths.iterator(); for (IntIterator it = zeroPaths.iterateIndices(); it.hasNext();) { int d2 = it.next(); IntSet s = contents.next();
if (paths.size() > 0) { Iterator<IBinaryNaturalRelation> contents = paths.iterator(); for (IntIterator it = paths.iterateIndices(); it.hasNext();) { int d2 = it.next(); IBinaryNaturalRelation R = contents.next(); if (identityPaths.size() > 0) { Iterator<IntSet> contents = identityPaths.iterator(); for (IntIterator it = identityPaths.iterateIndices(); it.hasNext();) { int d1 = it.next(); IntSet s = contents.next(); if (zeroPaths.size() > 0) { Iterator<IntSet> contents = zeroPaths.iterator(); for (IntIterator it = zeroPaths.iterateIndices(); it.hasNext();) { int d2 = it.next(); IntSet s = contents.next();
/** * @return set of d2 s.t. d1 -> d2 is a path edge for node n */ private IntSet getReachableFast(int n, int d1) { IBinaryNaturalRelation R = altPaths.get(d1); if (R != null) { return R.getRelated(n); } return null; }
/** * TODO: this can be optimized * * @see com.ibm.wala.util.intset.IntVector#set(int, int) */ @Override public void set(int x, T value) { int index = indices.getIndex(x); if (index == -1) { indices.add(x); index = indices.getIndex(x); ensureCapacity(indices.size() + 1); if (index < (data.length - 1)) { System.arraycopy(data, index, data, index + 1, indices.size() - index); } } data[index] = value; }
public void delegate(CallSiteReference site, CGNode delegateNode, CallSiteReference delegateSite) { CallSite d = new CallSite(delegateSite, delegateNode); targets.set(site.getProgramCounter(), d); int y = getCallGraph().getNumber(this); int x = getCallGraph().getNumber(delegateNode); delegateR.add(x, y); } }
public void clearAllTargets() { targets.clear(); allTargets.clear(); }
public void removeTarget(CGNode target) { allTargets.remove(getCallGraph().getNumber(target)); for (IntIterator it = targets.safeIterateIndices(); it.hasNext();) { int pc = it.next(); Object value = targets.get(pc); if (value instanceof CGNode) { if (value.equals(target)) { targets.remove(pc); } } else { MutableIntSet s = (MutableIntSet) value; int n = getCallGraph().getNumber(target); if (s.size() > 2) { s.remove(n); } else { assert s.size() == 2; if (s.contains(n)) { s.remove(n); int i = s.intIterator().next(); targets.set(pc, getCallGraph().getNode(i)); } } } } }
if (paths.size() > 0) { Iterator<IBinaryNaturalRelation> contents = paths.iterator(); for (IntIterator it = paths.iterateIndices(); it.hasNext();) { int d2 = it.next(); IBinaryNaturalRelation R = contents.next(); if (identityPaths.size() > 0) { BitVectorIntSet s = (BitVectorIntSet) identityPaths.get(d1); if (s != null && s.contains(n)) { result.add(d1); if (d1 == 0 && zeroPaths.size() > 0) { Iterator<IntSet> contents = zeroPaths.iterator(); for (IntIterator it = zeroPaths.iterateIndices(); it.hasNext();) { int d2 = it.next(); IntSet s = contents.next();
/** * Record that in this procedure we've discovered a same-level realizable path from (s_p,i) to (n,i) * * @param n local block number of the basic block n */ @SuppressWarnings("unused") private void addIdentityPathEdge(int i, int n) { BitVectorIntSet s = (BitVectorIntSet) identityPaths.get(i); if (s == null) { s = new BitVectorIntSet(); identityPaths.set(i, s); } s.add(n); if (altPaths != null) { IBinaryNaturalRelation R2 = altPaths.get(i); if (R2 == null) { // we expect the first dimension of R to be dense, the second sparse R2 = new BasicNaturalRelation(new byte[] { BasicNaturalRelation.SIMPLE_SPACE_STINGY }, BasicNaturalRelation.TWO_LEVEL); altPaths.set(i, R2); } R2.add(n, i); } if (TabulationSolver.DEBUG_LEVEL > 1) { System.err.println("recording self-path edge, now d1= " + i + " reaches " + s); } }
if (paths.size() > 0) { Iterator<IBinaryNaturalRelation> contents = paths.iterator(); for (IntIterator it = paths.iterateIndices(); it.hasNext();) { int d2 = it.next(); IBinaryNaturalRelation R = contents.next(); if (identityPaths.size() > 0) { Iterator<IntSet> contents = identityPaths.iterator(); for (IntIterator it = identityPaths.iterateIndices(); it.hasNext();) { int d1 = it.next(); IntSet s = contents.next(); if (zeroPaths.size() > 0) { Iterator<IntSet> contents = zeroPaths.iterator(); for (IntIterator it = zeroPaths.iterateIndices(); it.hasNext();) { int d2 = it.next(); IntSet s = contents.next();
/** * @return set of d2 s.t. d1 -> d2 is a path edge for node n */ private IntSet getReachableFast(int n, int d1) { IBinaryNaturalRelation R = altPaths.get(d1); if (R != null) { return R.getRelated(n); } return null; }
/** * TODO: this can be optimized * * @see com.ibm.wala.util.intset.IntVector#set(int, int) */ @Override public void set(int x, T value) { int index = indices.getIndex(x); if (index == -1) { indices.add(x); index = indices.getIndex(x); ensureCapacity(indices.size() + 1); if (index < (data.length - 1)) { System.arraycopy(data, index, data, index + 1, indices.size() - index); } } data[index] = value; }
public void delegate(CallSiteReference site, CGNode delegateNode, CallSiteReference delegateSite) { CallSite d = new CallSite(delegateSite, delegateNode); targets.set(site.getProgramCounter(), d); int y = getCallGraph().getNumber(this); int x = getCallGraph().getNumber(delegateNode); delegateR.add(x, y); } }
public void clearAllTargets() { targets.clear(); allTargets.clear(); }
/** * Record that in this procedure we've discovered a same-level realizable path from (s_p,0) to (n,d_j) * * @param n local block number of the basic block n */ @SuppressWarnings("unused") private void addZeroPathEdge(int n, int j) { BitVectorIntSet z = (BitVectorIntSet) zeroPaths.get(j); if (z == null) { z = new BitVectorIntSet(); zeroPaths.set(j, z); } z.add(n); if (altPaths != null) { IBinaryNaturalRelation R = altPaths.get(0); if (R == null) { // we expect the first dimension of R to be dense, the second sparse R = new BasicNaturalRelation(new byte[] { BasicNaturalRelation.SIMPLE_SPACE_STINGY }, BasicNaturalRelation.TWO_LEVEL); altPaths.set(0, R); } R.add(n, j); } if (TabulationSolver.DEBUG_LEVEL > 1) { System.err.println("recording 0-path edge, now d2= " + j + " reached at " + z); } }