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