/** * @return a Relation object to track implicit equations using the operator */ private static IBinaryNaturalRelation makeRelation(AbstractOperator op) { byte[] implementation = null; if (op instanceof AssignOperator) { // lots of assignments. implementation = new byte[] { BasicNaturalRelation.SIMPLE_SPACE_STINGY, BasicNaturalRelation.SIMPLE_SPACE_STINGY }; } else { // assume sparse assignments with any other operator. implementation = new byte[] { BasicNaturalRelation.SIMPLE_SPACE_STINGY }; } return new BasicNaturalRelation(implementation, BasicNaturalRelation.SIMPLE); }
@Override public String toString() { StringBuilder result = new StringBuilder(); for (int i = 0; i <= maxX; i++) { result.append(i).append(':'); result.append(getRelated(i)); result.append('\n'); } return result.toString(); } }
@Override public int getRelatedCount(int x) throws IllegalArgumentException { if (x < 0) { throw new IllegalArgumentException("x must be greater than zero"); } if (!anyRelated(x)) { return 0; } else { if (usingDelegate(x)) { return getDelegate(x).size(); } else { int result = 0; for (IntVector element : smallStore) { if (element.get(x) == EMPTY_CODE) { break; } result++; } return result; } } }
@Override public boolean contains(int x, int y) { if (x < 0) { throw new IllegalArgumentException("invalid x: " + x); } if (y < 0) { throw new IllegalArgumentException("invalid y: " + y); } if (usingDelegate(x)) { return getDelegate(x).contains(y); } else { for (IntVector element : smallStore) { if (element.get(x) == y) { return true; } } return false; } }
result.add(src, dst); } else { stack.push(current);
private void advanceX() { delegateIterator = null; for (int i = nextX + 1; i <= maxX; i++) { if (anyRelated(i)) { nextX = i; nextIndex = getFirstIndex(i); if (nextIndex == smallStore.length) { IntSet s = delegateStore.get(i); assert s.size() > 0; delegateIterator = s.intIterator(); } return; } } nextX = -1; }
throw new IllegalArgumentException("illegal y: " + y); if (usingDelegate(x)) {
} else { if (ss0 == DELEGATE_CODE) { return getDelegate(x); } else { int ssLength = smallStore.length;
private void advance() { while (callSiteMapping.getRelatedCount(++i) == 0 && i <= limit) ; }
public Iterator<CallSiteReference> iterateCallSites() { return new Iterator<CallSiteReference>() { private final int limit = callSiteMapping.maxKeyValue();
result.add(src, dst); } else { stack.push(current);
@Override public boolean contains(int x, int y) { if (x < 0) { throw new IllegalArgumentException("invalid x: " + x); } if (y < 0) { throw new IllegalArgumentException("invalid y: " + y); } if (usingDelegate(x)) { return getDelegate(x).contains(y); } else { for (IntVector element : smallStore) { if (element.get(x) == y) { return true; } } return false; } }
private void advanceX() { delegateIterator = null; for (int i = nextX + 1; i <= maxX; i++) { if (anyRelated(i)) { nextX = i; nextIndex = getFirstIndex(i); if (nextIndex == smallStore.length) { IntSet s = delegateStore.get(i); assert s.size() > 0; delegateIterator = s.intIterator(); } return; } } nextX = -1; }
throw new IllegalArgumentException("illegal y: " + y); if (usingDelegate(x)) {
} else { if (ss0 == DELEGATE_CODE) { return getDelegate(x); } else { int ssLength = smallStore.length;
private void advance() { while (callSiteMapping.getRelatedCount(++i) == 0 && i <= limit) ; }
public Iterator<CallSiteReference> iterateCallSites() { return new Iterator<CallSiteReference>() { private final int limit = callSiteMapping.maxKeyValue();
/** * @return a Relation object to track implicit equations using the operator */ private static IBinaryNaturalRelation makeRelation(AbstractOperator op) { byte[] implementation = null; if (op instanceof AssignOperator) { // lots of assignments. implementation = new byte[] { BasicNaturalRelation.SIMPLE_SPACE_STINGY, BasicNaturalRelation.SIMPLE_SPACE_STINGY }; } else { // assume sparse assignments with any other operator. implementation = new byte[] { BasicNaturalRelation.SIMPLE_SPACE_STINGY }; } return new BasicNaturalRelation(implementation, BasicNaturalRelation.SIMPLE); }
private static <T> void dfs(BasicNaturalRelation result, T root, NumberedGraph<T> G, Set<T> visited, Set<T> onstack) { visited.add(root); onstack.add(root); for (T dstNode : Iterator2Iterable.make(G.getSuccNodes(root))) { if (onstack.contains(dstNode)) { int src = G.getNumber(root); int dst = G.getNumber(dstNode); result.add(src, dst); } if (!visited.contains(dstNode)) { dfs(result, dstNode, G, visited, onstack); } } onstack.remove(root); }
@Override public String toString() { StringBuilder result = new StringBuilder(); for (int i = 0; i <= maxX; i++) { result.append(i).append(':'); result.append(getRelated(i)); result.append('\n'); } return result.toString(); } }