Handle multi-dimensional arrays in disjointness analysis
authorjjenista <jjenista>
Wed, 4 Feb 2009 00:46:18 +0000 (00:46 +0000)
committerjjenista <jjenista>
Wed, 4 Feb 2009 00:46:18 +0000 (00:46 +0000)
Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java
Robust/src/Tests/OwnershipAnalysisTest/testArrays/makefile [new file with mode: 0644]
Robust/src/Tests/OwnershipAnalysisTest/testArrays/test.java [new file with mode: 0644]

index cc5b0a55be60f069e4af1b4482fd26816bd0f966..850445b87d43d7cfd09379213c63734d46c90efa 100644 (file)
@@ -629,7 +629,7 @@ public class OwnershipAnalysis {
       lhs = ffn.getDst();
       rhs = ffn.getSrc();
       fld = ffn.getField();
-      if( !fld.getType().isImmutable() ) {
+      if( !fld.getType().isImmutable() || fld.getType().isArray() ) {
        og.assignTempXEqualToTempYFieldF(lhs, rhs, fld);
       }
       break;
@@ -639,7 +639,7 @@ public class OwnershipAnalysis {
       lhs = fsfn.getDst();
       fld = fsfn.getField();
       rhs = fsfn.getSrc();
-      if( !fld.getType().isImmutable() ) {
+      if( !fld.getType().isImmutable() || fld.getType().isArray() ) {
        og.assignTempXFieldFEqualToTempY(lhs, fld, rhs);
       }
       break;
@@ -648,7 +648,7 @@ public class OwnershipAnalysis {
       FlatElementNode fen = (FlatElementNode) fn;
       lhs = fen.getDst();
       rhs = fen.getSrc();
-      if( !lhs.getType().isImmutable() ) {
+      if( !lhs.getType().isImmutable() || lhs.getType().isArray() ) {
        og.assignTempXEqualToTempYFieldF(lhs, rhs, fdElement);
       }
       break;
@@ -657,7 +657,7 @@ public class OwnershipAnalysis {
       FlatSetElementNode fsen = (FlatSetElementNode) fn;
       lhs = fsen.getDst();
       rhs = fsen.getSrc();
-      if( !rhs.getType().isImmutable() ) {
+      if( !rhs.getType().isImmutable() || rhs.getType().isArray() ) {
        og.assignTempXFieldFEqualToTempY(lhs, fdElement, rhs);
       }
       break;
@@ -665,7 +665,7 @@ public class OwnershipAnalysis {
     case FKind.FlatNew:
       FlatNew fnn = (FlatNew) fn;
       lhs = fnn.getDst();
-      if( !lhs.getType().isImmutable() ) {
+      if( !lhs.getType().isImmutable() || lhs.getType().isArray() ) {
        AllocationSite as = getAllocationSiteFromFlatNewPRIVATE(fnn);
        og.assignTempEqualToNewAlloc(lhs, as);
       }
diff --git a/Robust/src/Tests/OwnershipAnalysisTest/testArrays/makefile b/Robust/src/Tests/OwnershipAnalysisTest/testArrays/makefile
new file mode 100644 (file)
index 0000000..f044964
--- /dev/null
@@ -0,0 +1,27 @@
+PROGRAM=test
+
+SOURCE_FILES=$(PROGRAM).java
+
+BUILDSCRIPT=~/research/Robust/src/buildscript
+BSFLAGS= -justanalyze -ownership -ownallocdepth 1 -ownwritedots final -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/testArrays/test.java b/Robust/src/Tests/OwnershipAnalysisTest/testArrays/test.java
new file mode 100644 (file)
index 0000000..5d424b8
--- /dev/null
@@ -0,0 +1,24 @@
+//
+//  We should see b and c aliased
+//
+//  Also, a and f aliased, and e references a sub region from there
+//
+
+public class TestArrays {
+
+  static public void main( String[] args ) {
+
+    int[] b = new int[10];
+    int[] c = b;
+
+    int[][] a = new int[40][30];
+
+    int     d = a[2][1];
+    int[]   e = a[1];
+    int[][] f = a;
+
+    int [][] g = disjoint l1 new int[10][];
+    int [][] h = disjoint l2 new int[10][];
+    g[0] = h[0] = new int[5];
+  }
+}