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 isNewSummary;
- protected HashSet<TempDescriptor> memberFields;
- protected HashSet<OwnershipNode> referencers;
+ protected HashSet<ReferenceEdge> referencers;
- protected AllocationSite allocSite;
+ protected AllocationSite allocSite;
- protected ReachabilitySet alpha;
- protected ReachabilitySet alphaNew;
+ protected ReachabilitySet alpha;
+ protected ReachabilitySet alphaNew;
- protected String description;
+ 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.alphaNew = null;
- this.description = 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>();
- memberFields = new HashSet<TempDescriptor>();
+ referencers = new HashSet<ReferenceEdge>();
+ alphaNew = new ReachabilitySet().makeCanonical();
+ }
+
+ public HeapRegionNode copy() {
+ return new HeapRegionNode(id,
+ isSingleObject,
+ isFlagged,
+ isNewSummary,
+ allocSite,
+ alpha,
+ description);
+ }
+
+
+ public Integer getID() {
+ return id;
+ }
+
+
+ public boolean equalsIncludingAlpha(HeapRegionNode hrn) {
+ return equals(hrn) && alpha.equals(hrn.alpha);
+ }
+
+
+ public boolean equals(Object o) {
+ if( o == null ) {
+ return false;
}
- public HeapRegionNode copy() {
- return new HeapRegionNode( id,
- isSingleObject,
- isFlagged,
- isNewSummary,
- allocSite,
- alpha,
- description );
+ if( !( o instanceof HeapRegionNode) ) {
+ return false;
}
+ HeapRegionNode hrn = (HeapRegionNode) o;
- public Integer getID() {
- return id;
+ if( !id.equals(hrn.getID() ) ) {
+ return false;
}
+ assert isSingleObject == hrn.isSingleObject();
+ assert isFlagged == hrn.isFlagged();
+ assert isNewSummary == hrn.isNewSummary();
+ assert description.equals(hrn.getDescription() );
- public boolean equals( HeapRegionNode hrn ) {
- assert hrn != null;
+ return true;
+ }
- return id.equals( hrn.getID() ) &&
- isSingleObject == hrn.isSingleObject() &&
- isFlagged == hrn.isFlagged() &&
- isNewSummary == hrn.isNewSummary() &&
- alpha.equals( hrn.getAlpha() ) &&
- description.equals( hrn.getDescription() );
- }
+ public int hashCode() {
+ return id.intValue()*17;
+ }
+ public boolean isSingleObject() {
+ return isSingleObject;
+ }
- public boolean isSingleObject() {
- return isSingleObject;
- }
+ public boolean isFlagged() {
+ return isFlagged;
+ }
- public boolean isFlagged() {
- return isFlagged;
- }
+ public boolean isNewSummary() {
+ return isNewSummary;
+ }
- public boolean isNewSummary() {
- return isNewSummary;
- }
+ public Iterator<ReferenceEdge> iteratorToReferencers() {
+ return referencers.iterator();
+ }
- public Iterator iteratorToReferencers() {
- return referencers.iterator();
- }
+ public Iterator<ReferenceEdge> iteratorToReferencersClone() {
+ HashSet<ReferenceEdge> clone = (HashSet<ReferenceEdge>)referencers.clone();
+ return clone.iterator();
+ }
- public Iterator iteratorToReferencersClone() {
- HashSet hs = (HashSet) referencers.clone();
- return hs.iterator();
- }
+ public int getNumReferencers() {
+ return referencers.size();
+ }
- public void addReferencer( OwnershipNode on ) {
- assert on != null;
- referencers.add( on );
- }
+ public void addReferencer(ReferenceEdge edge) {
+ assert edge != null;
- public void removeReferencer( OwnershipNode on ) {
- assert on != null;
- assert referencers.contains( on );
+ referencers.add(edge);
+ }
- referencers.remove( on );
- }
+ public void removeReferencer(ReferenceEdge edge) {
+ assert edge != null;
+ assert referencers.contains(edge);
- public boolean isReferencedBy( OwnershipNode on ) {
- assert on != null;
- return referencers.contains( on );
- }
+ referencers.remove(edge);
+ }
+ public ReferenceEdge getReferenceFrom(OwnershipNode on,
+ FieldDescriptor fd) {
+ assert on != null;
- public AllocationSite getAllocationSite() {
- return allocSite;
+ 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 void setAlpha( ReachabilitySet alpha ) {
- this.alpha = alpha;
- }
- public ReachabilitySet getAlpha() {
- return alpha;
- }
+ public AllocationSite getAllocationSite() {
+ return allocSite;
+ }
- public ReachabilitySet getAlphaNew() {
- return alphaNew;
- }
- public void setAlphaNew( ReachabilitySet alpha ) {
- this.alphaNew = alpha;
- }
+ public void setAlpha(ReachabilitySet alpha) {
+ this.alpha = alpha;
+ }
- public void applyAlphaNew() {
- assert alphaNew != null;
- alpha = alphaNew;
- alphaNew = null;
- }
+ public ReachabilitySet getAlpha() {
+ return alpha;
+ }
+ public ReachabilitySet getAlphaNew() {
+ return alphaNew;
+ }
- public String getIDString() {
- return id.toString();
- }
+ public void setAlphaNew(ReachabilitySet alpha) {
+ this.alphaNew = alpha;
+ }
- public String getAlphaString() {
- return alpha.toStringEscapeNewline();
- }
+ public void applyAlphaNew() {
+ assert alphaNew != null;
- public String toString() {
- return "HRN"+getIDString();
- }
+ alpha = alphaNew;
- // WHY WHY WHY WHY WHY WHY?!
- public String getDescription() {
- return new String( description );
- //return new String( description+" ID "+getIDString() );
+ alphaNew = new ReachabilitySet();
+ alphaNew = alphaNew.makeCanonical();
+ }
+
+
+ public String getIDString() {
+ String s;
+
+ if( id < 0 ) {
+ s = "minus" + new Integer(-id).toString();
+ } else {
+ s = id.toString();
}
+
+ return s;
+ }
+
+ 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() );
+ }
}