changes to build script to increase java heap memory
[IRC.git] / Robust / src / Analysis / OwnershipAnalysis / HeapRegionNode.java
index 88758c0d32506ec856d3b2212eb6ed4b1967e7b6..2604b21fd23ac91eb76d062d086367c6bef8b56f 100644 (file)
@@ -6,20 +6,40 @@ import java.util.*;
 
 public class HeapRegionNode extends OwnershipNode {
 
-    public HeapRegionNode( Integer id,
-                          boolean isSingleObject,
-                          boolean isFlagged,
-                          boolean isNewSummary,
-                          String  description ) {
+    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.description    = description;
+       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() {
@@ -27,130 +47,154 @@ public class HeapRegionNode extends OwnershipNode {
                                   isSingleObject,
                                   isFlagged,
                                   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()   &&
-           description.equals( hrn.getDescription() );
+    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();
+    }
 
-       referencers.add( on );
+
+    public void addReferencer( ReferenceEdge edge ) {
+       assert edge != null;
+
+       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;
     }
-    ///////////////////////////////////////////////
-    // end interface with larger graph
-    ///////////////////////////////////////////////
 
 
+    public AllocationSite getAllocationSite() {
+       return allocSite;
+    }
 
 
-    ///////////////////////////////////////////////
-    // analysis interface
-    ///////////////////////////////////////////////
-    /*
-    protected HashSet<TempDescriptor> analysisRegionAliases;
+    public void setAlpha( ReachabilitySet alpha ) {
+       this.alpha = alpha;
+    }
 
-    public void addAnalysisRegionAlias( TempDescriptor td ) {
-       assert td != null;
-       assert !analysisRegionAliases.contains( td );
-       
-       analysisRegionAliases.add( td );
+    public ReachabilitySet getAlpha() {
+       return alpha;
     }
 
-    public Iterator iteratorToAnalysisRegionAliases() {
-       return analysisRegionAliases.iterator();
+    public ReachabilitySet getAlphaNew() {
+       return alphaNew;
     }
-    */
-    ///////////////////////////////////////////////
-    // end analysis interface
-    ///////////////////////////////////////////////
 
+    public void setAlphaNew( ReachabilitySet alpha ) {
+       this.alphaNew = alpha;
+    }
+
+    public void applyAlphaNew() {
+       assert alphaNew != null;
+
+       alpha = alphaNew;
+
+       alphaNew = new ReachabilitySet();
+       alphaNew = alphaNew.makeCanonical();
+    }
 
-    // for writing out
-    String description;
 
     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 description;
+       return new String( description );
+       //return new String( description+" ID "+getIDString() );
     }
 }