X-Git-Url: http://plrg.eecs.uci.edu/git/?a=blobdiff_plain;f=Robust%2Fsrc%2FAnalysis%2FOwnershipAnalysis%2FHeapRegionNode.java;h=71db77b17c8892d6726f33fcfa9a54d7dae66072;hb=6f3292fbc8049ac7b12855ad312025ba4bb6743d;hp=8141f6e434d777b2c380d2a9a3cf34a598301ede;hpb=473fc4921dcecab1415c96d1c2b93a76efd1ac9f;p=IRC.git diff --git a/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java b/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java index 8141f6e4..71db77b1 100644 --- a/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java +++ b/Robust/src/Analysis/OwnershipAnalysis/HeapRegionNode.java @@ -6,181 +6,220 @@ import java.util.*; public class HeapRegionNode extends OwnershipNode { - protected Integer id; + protected Integer id; - protected boolean isSingleObject; - protected boolean isFlagged; - protected boolean isNewSummary; + protected boolean isSingleObject; + protected boolean isFlagged; + protected boolean isParameter; + protected boolean isNewSummary; - protected HashSet referencers; + protected HashSet referencers; - protected AllocationSite allocSite; + protected TypeDescriptor type; - protected ReachabilitySet alpha; - protected ReachabilitySet alphaNew; + protected AllocationSite allocSite; - protected String description; + protected ReachabilitySet alpha; + protected ReachabilitySet alphaNew; + protected String description; - public HeapRegionNode( Integer id, - boolean isSingleObject, - boolean isFlagged, - boolean isNewSummary, - AllocationSite allocSite, - ReachabilitySet alpha, - String description ) { - this.id = id; - this.isSingleObject = isSingleObject; - this.isFlagged = isFlagged; - this.isNewSummary = isNewSummary; - this.allocSite = allocSite; - this.alpha = alpha; - this.description = description; - referencers = new HashSet(); - alphaNew = new ReachabilitySet().makeCanonical(); - } + public HeapRegionNode(Integer id, + boolean isSingleObject, + boolean isFlagged, + boolean isParameter, + boolean isNewSummary, + TypeDescriptor type, + AllocationSite allocSite, + ReachabilitySet alpha, + String description) { + this.id = id; + this.isSingleObject = isSingleObject; + this.isFlagged = isFlagged; + this.isParameter = isParameter; + this.isNewSummary = isNewSummary; + this.type = type; + this.allocSite = allocSite; + this.alpha = alpha; + this.description = description; - public HeapRegionNode copy() { - return new HeapRegionNode( id, - isSingleObject, - isFlagged, - isNewSummary, - allocSite, - alpha, - description ); - } + referencers = new HashSet(); + alphaNew = new ReachabilitySet().makeCanonical(); + } + public HeapRegionNode copy() { + return new HeapRegionNode(id, + isSingleObject, + isFlagged, + isParameter, + isNewSummary, + type, + allocSite, + alpha, + description); + } - public Integer getID() { - return id; - } + public Integer getID() { + return id; + } - public boolean equals( Object o ) { - if( o == null ) { - return false; - } - if( !( o instanceof HeapRegionNode) ) { - return false; - } + public boolean equalsIncludingAlpha(HeapRegionNode hrn) { + return equals(hrn) && alpha.equals(hrn.alpha); + } - HeapRegionNode hrn = (HeapRegionNode) o; - return id.equals( hrn.getID() ) && - isSingleObject == hrn.isSingleObject() && - isFlagged == hrn.isFlagged() && - isNewSummary == hrn.isNewSummary() && - alpha.equals( hrn.getAlpha() ) && - description.equals( hrn.getDescription() ); + public boolean equals(Object o) { + if( o == null ) { + return false; } - public int hashCode() { - return id.intValue(); + if( !( o instanceof HeapRegionNode) ) { + return false; } + HeapRegionNode hrn = (HeapRegionNode) o; - public boolean isSingleObject() { - return isSingleObject; + if( !id.equals(hrn.getID() ) ) { + return false; } - public boolean isFlagged() { - return isFlagged; - } + assert isSingleObject == hrn.isSingleObject(); + assert isFlagged == hrn.isFlagged(); + assert isParameter == hrn.isParameter(); + assert isNewSummary == hrn.isNewSummary(); + assert description.equals(hrn.getDescription() ); - public boolean isNewSummary() { - return isNewSummary; - } + return true; + } + public int hashCode() { + return id.intValue()*17; + } - public Iterator iteratorToReferencers() { - return referencers.iterator(); - } + public boolean isSingleObject() { + return isSingleObject; + } - public Iterator iteratorToReferencersClone() { - HashSet clone = (HashSet) referencers.clone(); - return clone.iterator(); - } + public boolean isFlagged() { + return isFlagged; + } - public void addReferencer( ReferenceEdge edge ) { - assert edge != null; + public boolean isParameter() { + return isParameter; + } - referencers.add( edge ); - } + public boolean isNewSummary() { + return isNewSummary; + } - public void removeReferencer( ReferenceEdge edge ) { - assert edge != null; - assert referencers.contains( edge ); - referencers.remove( edge ); - } - public ReferenceEdge getReferenceFrom( OwnershipNode on, - FieldDescriptor fd ) { - assert on != null; + public Iterator iteratorToReferencers() { + return referencers.iterator(); + } - Iterator itrEdge = referencers.iterator(); - while( itrEdge.hasNext() ) { - ReferenceEdge edge = itrEdge.next(); - if( edge.getSrc().equals( on ) && - edge.getFieldDesc() == fd ) { - return edge; - } - } + public Iterator iteratorToReferencersClone() { + HashSet clone = (HashSet)referencers.clone(); + return clone.iterator(); + } - return null; - } + public int getNumReferencers() { + return referencers.size(); + } - public AllocationSite getAllocationSite() { - return allocSite; - } + public void addReferencer(ReferenceEdge edge) { + assert edge != null; + referencers.add(edge); + } - public void setAlpha( ReachabilitySet alpha ) { - this.alpha = alpha; - } + public void removeReferencer(ReferenceEdge edge) { + assert edge != null; + assert referencers.contains(edge); - public ReachabilitySet getAlpha() { - return alpha; - } + referencers.remove(edge); + } - public ReachabilitySet getAlphaNew() { - return alphaNew; - } + public ReferenceEdge getReferenceFrom(OwnershipNode on, + TypeDescriptor type, + String field) { + assert on != null; - public void setAlphaNew( ReachabilitySet alpha ) { - this.alphaNew = alpha; + Iterator itrEdge = referencers.iterator(); + while( itrEdge.hasNext() ) { + ReferenceEdge edge = itrEdge.next(); + if( edge.getSrc().equals(on) && + edge.typeEquals(type) && + edge.fieldEquals(field) ) { + return edge; + } } - public void applyAlphaNew() { - assert alphaNew != null; + return null; + } - alpha = alphaNew; - alphaNew = new ReachabilitySet(); - alphaNew = alphaNew.makeCanonical(); - } + public TypeDescriptor getType() { + return type; + } + public AllocationSite getAllocationSite() { + return allocSite; + } - public String getIDString() { - return id.toString(); - } - public String getAlphaString() { - return alpha.toStringEscapeNewline(); - } + public void setAlpha(ReachabilitySet alpha) { + this.alpha = alpha; + } - public String toString() { - return "HRN"+getIDString(); - } + public ReachabilitySet getAlpha() { + return alpha; + } + + public ReachabilitySet getAlphaNew() { + return alphaNew; + } + + public void setAlphaNew(ReachabilitySet alpha) { + this.alphaNew = alpha; + } + + public void applyAlphaNew() { + assert alphaNew != null; + alpha = alphaNew; + alphaNew = new ReachabilitySet().makeCanonical(); + } - // WHY WHY WHY WHY WHY WHY?! - public String getDescription() { - return new String( description ); - //return new String( description+" ID "+getIDString() ); + + public String getIDString() { + String s; + + if( id < 0 ) { + s = "minus" + new Integer(-id).toString(); + } else { + s = id.toString(); } + + return s; + } + + public String getAlphaString( boolean hideSubsetReachability ) { + return alpha.toStringEscapeNewline(hideSubsetReachability); + } + + public String toString() { + return "HRN"+getIDString(); + } + + // WHY WHY WHY WHY WHY WHY?! + public String getDescription() { + return new String(description); + //return new String( description+" ID "+getIDString() ); + } }