+
+
+
+
+ public Set<Alloc> canPointTo( TempDescriptor x ) {
+
+ if( !DisjointAnalysis.shouldAnalysisTrack( x.getType() ) ) {
+ // if we don't care to track it, return null which means
+ // "a client of this result shouldn't care either"
+ return HeapAnalysis.DONTCARE_PTR;
+ }
+
+ Set<Alloc> out = new HashSet<Alloc>();
+
+ VariableNode vn = getVariableNodeNoMutation( x );
+ if( vn == null ) {
+ // the empty set means "can't point to anything"
+ return out;
+ }
+
+ Iterator<RefEdge> edgeItr = vn.iteratorToReferencees();
+ while( edgeItr.hasNext() ) {
+ HeapRegionNode hrn = edgeItr.next().getDst();
+ out.add( hrn.getAllocSite() );
+ }
+
+ return out;
+ }
+
+
+
+ public Hashtable< Alloc, Set<Alloc> > canPointTo( TempDescriptor x,
+ String field,
+ TypeDescriptor fieldType ) {
+
+ if( !DisjointAnalysis.shouldAnalysisTrack( x.getType() ) ) {
+ // if we don't care to track it, return null which means
+ // "a client of this result shouldn't care either"
+ return HeapAnalysis.DONTCARE_DREF;
+ }
+
+ Hashtable< Alloc, Set<Alloc> > out = new Hashtable< Alloc, Set<Alloc> >();
+
+ VariableNode vn = getVariableNodeNoMutation( x );
+ if( vn == null ) {
+ // the empty table means "x can't point to anything"
+ return out;
+ }
+
+ Iterator<RefEdge> edgeItr = vn.iteratorToReferencees();
+ while( edgeItr.hasNext() ) {
+ HeapRegionNode hrn = edgeItr.next().getDst();
+ Alloc key = hrn.getAllocSite();
+
+ if( !DisjointAnalysis.shouldAnalysisTrack( fieldType ) ) {
+ // if we don't care to track it, put no entry which means
+ // "a client of this result shouldn't care either"
+ out.put( key, HeapAnalysis.DONTCARE_PTR );
+ continue;
+ }
+
+ Set<Alloc> moreValues = new HashSet<Alloc>();
+ Iterator<RefEdge> edgeItr2 = hrn.iteratorToReferencees();
+ while( edgeItr2.hasNext() ) {
+ RefEdge edge = edgeItr2.next();
+
+ if( field.equals( edge.getField() ) ) {
+ moreValues.add( edge.getDst().getAllocSite() );
+ }
+ }
+
+ if( out.containsKey( key ) ) {
+ out.get( key ).addAll( moreValues );
+ } else {
+ out.put( key, moreValues );
+ }
+ }
+
+ return out;
+ }
+
+
+
+ // for debugging
+ public TempDescriptor findVariableByName( String name ) {
+
+ for( TempDescriptor td: td2vn.keySet() ) {
+ if( td.getSymbol().contains( name ) ) {
+ return td;
+ }
+ }
+
+ return null;
+ }
+
+
+ public String countGraphElements() {
+ long numNodes = 0;
+ long numEdges = 0;
+ long numNodeStates = 0;
+ long numEdgeStates = 0;
+ long numNodeStateNonzero = 0;
+ long numEdgeStateNonzero = 0;
+
+ for( HeapRegionNode node : id2hrn.values() ) {
+ numNodes++;
+ numNodeStates += node.getAlpha().numStates();
+ numNodeStateNonzero += node.getAlpha().numNonzeroTuples();
+
+ // all edges in the graph point TO a heap node, so scanning
+ // all referencers of all nodes gets every edge
+ Iterator<RefEdge> refItr = node.iteratorToReferencers();
+ while( refItr.hasNext() ) {
+ RefEdge edge = refItr.next();
+
+ numEdges++;
+ numEdgeStates += edge.getBeta().numStates();
+ numEdgeStateNonzero += edge.getBeta().numNonzeroTuples();
+ }
+ }
+
+ return
+ "################################################\n"+
+ "Nodes = "+numNodes+"\n"+
+ "Edges = "+numEdges+"\n"+
+ "Node states = "+numNodeStates+"\n"+
+ "Edge states = "+numEdgeStates+"\n"+
+ "Node non-zero tuples = "+numNodeStateNonzero+"\n"+
+ "Edge non-zero tuples = "+numEdgeStateNonzero+"\n"+
+ "################################################\n";
+ }