public class HeapRegionNode extends OwnershipNode {
- public HeapRegionNode( Integer id,
- boolean isSingleObject,
- boolean isFlagged,
- boolean isNewSummary ) {
- this.id = id;
- this.isSingleObject = isSingleObject;
- this.isFlagged = isFlagged;
- this.isNewSummary = isNewSummary;
-
- referencers = new HashSet<OwnershipNode>();
- //analysisRegionAliases = new HashSet<TempDescriptor>();
- memberFields = new HashSet<TempDescriptor>();
- }
+ protected Integer id;
- public HeapRegionNode copy() {
- return new HeapRegionNode( id,
- isSingleObject,
- isFlagged,
- isNewSummary );
- }
+ protected boolean isSingleObject;
+ protected boolean isFlagged;
+ protected boolean isParameter;
+ protected boolean isNewSummary;
+ protected HashSet<ReferenceEdge> referencers;
- /////////////////
- // equality
- /////////////////
- protected Integer id;
+ protected TypeDescriptor type;
- public Integer getID() {
- return id;
- }
+ protected AllocationSite allocSite;
- public boolean equals( HeapRegionNode hrn ) {
- assert hrn != null;
+ protected ReachabilitySet alpha;
+ protected ReachabilitySet alphaNew;
- return id.equals( hrn.getID() ) &&
- isSingleObject == hrn.isSingleObject() &&
- isFlagged == hrn.isFlagged() &&
- isNewSummary == hrn.isNewSummary();
- }
- /////////////////
- // end equality
- /////////////////
-
-
-
- /////////////////
- // predicates
- /////////////////
- boolean isSingleObject;
- public boolean isSingleObject() {
- return isSingleObject;
- }
+ protected String description;
- boolean isFlagged;
- public boolean isFlagged() {
- return isFlagged;
- }
- boolean isNewSummary;
- public boolean isNewSummary() {
- return isNewSummary;
- }
- ///////////////////
- // end predicates
- ///////////////////
+ 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;
+
+ referencers = new HashSet<ReferenceEdge>();
+ alphaNew = new ReachabilitySet().makeCanonical();
+ }
+
+ public HeapRegionNode copy() {
+ return new HeapRegionNode(id,
+ isSingleObject,
+ isFlagged,
+ isParameter,
+ isNewSummary,
+ type,
+ allocSite,
+ alpha,
+ description);
+ }
+
+
+ public Integer getID() {
+ return id;
+ }
- ///////////////////////////////////////////
- // interface with larger graph
- ///////////////////////////////////////////
- protected HashSet<TempDescriptor> memberFields;
- protected HashSet<OwnershipNode> referencers;
+ public boolean equalsIncludingAlpha(HeapRegionNode hrn) {
+ return equals(hrn) && alpha.equals(hrn.alpha);
+ }
- public Iterator iteratorToReferencers() {
- return referencers.iterator();
+
+ public boolean equals(Object o) {
+ if( o == null ) {
+ return false;
}
- public Iterator iteratorToReferencersClone() {
- HashSet hs = (HashSet) referencers.clone();
- return hs.iterator();
+ if( !( o instanceof HeapRegionNode) ) {
+ return false;
}
- public void addReferencer( OwnershipNode on ) {
- assert on != null;
+ HeapRegionNode hrn = (HeapRegionNode) o;
- referencers.add( on );
+ if( !id.equals(hrn.getID() ) ) {
+ return false;
}
- public void removeReferencer( OwnershipNode on ) {
- assert on != null;
- assert referencers.contains( on );
+ assert isSingleObject == hrn.isSingleObject();
+ assert isFlagged == hrn.isFlagged();
+ assert isParameter == hrn.isParameter();
+ assert isNewSummary == hrn.isNewSummary();
+ assert description.equals(hrn.getDescription() );
- referencers.remove( on );
- }
+ return true;
+ }
- public boolean isReferencedBy( OwnershipNode on ) {
- assert on != null;
- return referencers.contains( on );
- }
- ///////////////////////////////////////////////
- // end interface with larger graph
- ///////////////////////////////////////////////
+ public int hashCode() {
+ return id.intValue()*17;
+ }
+ public boolean isSingleObject() {
+ return isSingleObject;
+ }
+ public boolean isFlagged() {
+ return isFlagged;
+ }
- ///////////////////////////////////////////////
- // analysis interface
- ///////////////////////////////////////////////
- /*
- protected HashSet<TempDescriptor> analysisRegionAliases;
+ public boolean isParameter() {
+ return isParameter;
+ }
- public void addAnalysisRegionAlias( TempDescriptor td ) {
- assert td != null;
- assert !analysisRegionAliases.contains( td );
-
- analysisRegionAliases.add( td );
- }
+ public boolean isNewSummary() {
+ return isNewSummary;
+ }
+
+
+
+ public Iterator<ReferenceEdge> iteratorToReferencers() {
+ return referencers.iterator();
+ }
+
+ public Iterator<ReferenceEdge> iteratorToReferencersClone() {
+ HashSet<ReferenceEdge> clone = (HashSet<ReferenceEdge>)referencers.clone();
+ return clone.iterator();
+ }
+
+ public int getNumReferencers() {
+ return referencers.size();
+ }
- public Iterator iteratorToAnalysisRegionAliases() {
- return analysisRegionAliases.iterator();
- }
- */
- ///////////////////////////////////////////////
- // end analysis interface
- ///////////////////////////////////////////////
+ public void addReferencer(ReferenceEdge edge) {
+ assert edge != null;
- // for writing out
- public String getIDString() {
- return id.toString();
+ referencers.add(edge);
+ }
+
+ public void removeReferencer(ReferenceEdge edge) {
+ assert edge != null;
+ assert referencers.contains(edge);
+
+ referencers.remove(edge);
+ }
+
+ public ReferenceEdge getReferenceFrom(OwnershipNode on,
+ TypeDescriptor type,
+ String field) {
+ assert on != null;
+
+ Iterator<ReferenceEdge> itrEdge = referencers.iterator();
+ while( itrEdge.hasNext() ) {
+ ReferenceEdge edge = itrEdge.next();
+ if( edge.getSrc().equals(on) &&
+ edge.typeEquals(type) &&
+ edge.fieldEquals(field) ) {
+ return edge;
+ }
}
- public String toString() {
- return "HRN"+getIDString();
+ return null;
+ }
+
+
+ public TypeDescriptor getType() {
+ return type;
+ }
+
+ public AllocationSite getAllocationSite() {
+ return allocSite;
+ }
+
+
+ public void setAlpha(ReachabilitySet alpha) {
+ this.alpha = alpha;
+ }
+
+ 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();
+ }
+
+
+ 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() );
+ }
}