added support for null heap region, doesn't work perfectly because null region gets...
authorjjenista <jjenista>
Tue, 15 Sep 2009 17:57:58 +0000 (17:57 +0000)
committerjjenista <jjenista>
Tue, 15 Sep 2009 17:57:58 +0000 (17:57 +0000)
Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java
Robust/src/Tests/OwnershipAnalysisTest/testBug/makefile [new file with mode: 0644]
Robust/src/Tests/OwnershipAnalysisTest/testBug/test.java [new file with mode: 0644]
Robust/src/Tests/OwnershipAnalysisTest/testNull/makefile [new file with mode: 0644]
Robust/src/Tests/OwnershipAnalysisTest/testNull/test.java [new file with mode: 0644]

index 276890f2d6027c590b1d2401929d41f1315e69ca..f1d1d1c615088d31420b01118d5e1a9e4f77cc8f 100644 (file)
@@ -313,6 +313,10 @@ public class OwnershipAnalysis {
   // reserved IDs for special purposes
   static private int uniqueIDcount = 10;
 
+  // special purpose region for "null" 
+  // included in every graph
+  static public int nullRegionID =  9;
+
 
   // Use these data structures to track progress of
   // processing all methods in the program, and by methods
@@ -757,6 +761,16 @@ public class OwnershipAnalysis {
       }
       break;
 
+    case FKind.FlatLiteralNode:
+      FlatLiteralNode fln = (FlatLiteralNode) fn;
+      if( fln.getValue() == null ) {
+       // when we set something to null, use the special
+       // "null" heap region as the target
+       lhs = fln.getDst();
+       og.assignTempXEqualToNull(lhs);
+      }
+      break;
+
     case FKind.FlatOpNode:
       FlatOpNode fon = (FlatOpNode) fn;
       if( fon.getOp().getOp() == Operation.ASSIGN ) {
index ed84c1b971ef374181bb6cfa9af200ef80279384..b1a3ef7eb79da93d827daea8d8dec0767382ea68 100644 (file)
@@ -67,6 +67,9 @@ public class OwnershipGraph {
   public Hashtable<Integer, TokenTuple> paramIndex2paramTokenSecondaryStar;
 
 
+  public HeapRegionNode hrnNull;
+
+
   public OwnershipGraph(int allocationDepth, TypeUtil typeUtil) {
     this.allocationDepth = allocationDepth;
     this.typeUtil        = typeUtil;
@@ -91,6 +94,16 @@ public class OwnershipGraph {
     paramIndex2paramTokenSecondaryStar = new Hashtable<Integer,        TokenTuple    >();
 
     allocationSites = new HashSet <AllocationSite>();
+
+    hrnNull = createNewHeapRegionNode( OwnershipAnalysis.nullRegionID,
+                                      false,
+                                      false,
+                                      false,
+                                      false,
+                                      null,
+                                      null,
+                                      null,
+                                      "null" );
   }
 
 
@@ -312,6 +325,23 @@ public class OwnershipGraph {
   }
 
 
+  public void assignTempXEqualToNull(TempDescriptor x) {
+
+    LabelNode lnX = getLabelNodeFromTemp(x);
+
+    clearReferenceEdgesFrom(lnX, null, null, true);
+
+    ReferenceEdge edgeNew = new ReferenceEdge(lnX,
+                                             hrnNull,
+                                             null,
+                                             null,
+                                             false,
+                                             null);
+
+    addReferenceEdge(lnX, hrnNull, edgeNew);
+  }
+
+
   public void assignTypedTempXEqualToTempY(TempDescriptor x,
                                           TempDescriptor y,
                                           TypeDescriptor type) {
@@ -3222,6 +3252,12 @@ public class OwnershipGraph {
     
     HashSet<HeapRegionNode> possibleCallerHRNs = new HashSet<HeapRegionNode>();
 
+    if( hrnCallee == ogCallee.hrnNull ) {
+      // this is the null heap region
+      possibleCallerHRNs.add( id2hrn.get( hrnCallee.getID() ) );
+      return possibleCallerHRNs;
+    }
+
     Set<Integer> paramIndicesCallee_p = ogCallee.idPrimary2paramIndexSet  .get( hrnCallee.getID() );
     Set<Integer> paramIndicesCallee_s = ogCallee.idSecondary2paramIndexSet.get( hrnCallee.getID() );
 
diff --git a/Robust/src/Tests/OwnershipAnalysisTest/testBug/makefile b/Robust/src/Tests/OwnershipAnalysisTest/testBug/makefile
new file mode 100644 (file)
index 0000000..fdfcf35
--- /dev/null
@@ -0,0 +1,27 @@
+PROGRAM=test
+
+SOURCE_FILES=$(PROGRAM).java
+
+BUILDSCRIPT=~/research/Robust/src/buildscript
+BSFLAGS= -mainclass Test -justanalyze -ownership -ownallocdepth 1 -ownwritedots final -ownaliasfile aliases.txt -enable-assertions
+
+all: $(PROGRAM).bin
+
+view: PNGs
+       eog *.png &
+
+PNGs: DOTs
+       d2p *COMPLETE*.dot
+
+DOTs: $(PROGRAM).bin
+
+$(PROGRAM).bin: $(SOURCE_FILES)
+       $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES)
+
+clean:
+       rm -f  $(PROGRAM).bin
+       rm -fr tmpbuilddirectory
+       rm -f  *~
+       rm -f  *.dot
+       rm -f  *.png
+       rm -f  aliases.txt
diff --git a/Robust/src/Tests/OwnershipAnalysisTest/testBug/test.java b/Robust/src/Tests/OwnershipAnalysisTest/testBug/test.java
new file mode 100644 (file)
index 0000000..a313b76
--- /dev/null
@@ -0,0 +1,24 @@
+public class Foo {
+  public Foo() {}
+
+  Bar x;
+  Bar y;
+}
+
+public class Bar {
+  public Bar() {}
+}
+
+
+public class Test {
+
+  static public void main( String[] args ) {
+    
+    Foo foo = new Foo();
+
+    foo.x = new Bar();
+    foo.y = new Bar();
+
+    Bar a1 = foo.x;
+  }
+}
diff --git a/Robust/src/Tests/OwnershipAnalysisTest/testNull/makefile b/Robust/src/Tests/OwnershipAnalysisTest/testNull/makefile
new file mode 100644 (file)
index 0000000..fdfcf35
--- /dev/null
@@ -0,0 +1,27 @@
+PROGRAM=test
+
+SOURCE_FILES=$(PROGRAM).java
+
+BUILDSCRIPT=~/research/Robust/src/buildscript
+BSFLAGS= -mainclass Test -justanalyze -ownership -ownallocdepth 1 -ownwritedots final -ownaliasfile aliases.txt -enable-assertions
+
+all: $(PROGRAM).bin
+
+view: PNGs
+       eog *.png &
+
+PNGs: DOTs
+       d2p *COMPLETE*.dot
+
+DOTs: $(PROGRAM).bin
+
+$(PROGRAM).bin: $(SOURCE_FILES)
+       $(BUILDSCRIPT) $(BSFLAGS) -o $(PROGRAM) $(SOURCE_FILES)
+
+clean:
+       rm -f  $(PROGRAM).bin
+       rm -fr tmpbuilddirectory
+       rm -f  *~
+       rm -f  *.dot
+       rm -f  *.png
+       rm -f  aliases.txt
diff --git a/Robust/src/Tests/OwnershipAnalysisTest/testNull/test.java b/Robust/src/Tests/OwnershipAnalysisTest/testNull/test.java
new file mode 100644 (file)
index 0000000..e0b1231
--- /dev/null
@@ -0,0 +1,26 @@
+public class Foo {
+  public Foo() {}
+
+  Bar x;
+  Bar y;
+}
+
+public class Bar {
+  public Bar() {}
+}
+
+
+public class Test {
+
+  static public void main( String[] args ) {
+    
+    Foo foo = new Foo();
+
+    foo.x = new Bar();
+    foo.y = new Bar();
+
+    Bar a1 = foo.x;
+
+    a1 = null;
+  }
+}