test for immutable instead of primitive to decide if a field cannot create an alias
authorjjenista <jjenista>
Thu, 18 Sep 2008 20:03:02 +0000 (20:03 +0000)
committerjjenista <jjenista>
Thu, 18 Sep 2008 20:03:02 +0000 (20:03 +0000)
Robust/src/Analysis/OwnershipAnalysis/OwnershipAnalysis.java
Robust/src/Analysis/OwnershipAnalysis/OwnershipGraph.java
Robust/src/Tests/OwnershipAnalysisTest/test01/test01.java
Robust/src/Tests/OwnershipAnalysisTest/test02/makefile

index 7d597ae09ca46540304b5d7b4924252c948460d3..a7730c5745a646d91df3f6f0473133209be185ea 100644 (file)
@@ -347,7 +347,6 @@ public class OwnershipAnalysis {
       OwnershipGraph og = analyzeFlatMethod(d, fm);
       OwnershipGraph ogPrev = mapDescriptorToCompleteOwnershipGraph.get(d);
       if( !og.equals(ogPrev) ) {
-
        setGraphForDescriptor(d, og);
 
        // only methods have dependents, tasks cannot
@@ -452,7 +451,8 @@ public class OwnershipAnalysis {
       assert mapFlatNodeToOwnershipGraph.containsKey(frn);
       OwnershipGraph ogr = mapFlatNodeToOwnershipGraph.get(frn);
       completeGraph.merge(ogr);
-    }
+    }   
+
     return completeGraph;
   }
 
@@ -518,7 +518,7 @@ public class OwnershipAnalysis {
       lhs = ffn.getDst();
       rhs = ffn.getSrc();
       fld = ffn.getField();
-      if( !fld.getType().isPrimitive() ) {
+      if( !fld.getType().isImmutable() ) {
        og.assignTempXEqualToTempYFieldF(lhs, rhs, fld);
       }
       break;
@@ -528,14 +528,16 @@ public class OwnershipAnalysis {
       lhs = fsfn.getDst();
       fld = fsfn.getField();
       rhs = fsfn.getSrc();
-      og.assignTempXFieldFEqualToTempY(lhs, fld, rhs);
+      if( !fld.getType().isImmutable() ) {
+       og.assignTempXFieldFEqualToTempY(lhs, fld, rhs);
+      }
       break;
 
     case FKind.FlatElementNode:
       FlatElementNode fen = (FlatElementNode) fn;
       lhs = fen.getDst();
       rhs = fen.getSrc();
-      if( !lhs.getType().isPrimitive() ) {
+      if( !lhs.getType().isImmutable() ) {
        og.assignTempXEqualToTempYFieldF(lhs, rhs, fdElement);
       }
       break;
@@ -544,7 +546,7 @@ public class OwnershipAnalysis {
       FlatSetElementNode fsen = (FlatSetElementNode) fn;
       lhs = fsen.getDst();
       rhs = fsen.getSrc();
-      if( !rhs.getType().isPrimitive() ) {
+      if( !rhs.getType().isImmutable() ) {
        og.assignTempXFieldFEqualToTempY(lhs, fdElement, rhs);
       }
       break;
@@ -552,9 +554,10 @@ public class OwnershipAnalysis {
     case FKind.FlatNew:
       FlatNew fnn = (FlatNew) fn;
       lhs = fnn.getDst();
-      AllocationSite as = getAllocationSiteFromFlatNewPRIVATE(fnn);
-
-      og.assignTempEqualToNewAlloc(lhs, as);
+      if( !lhs.getType().isImmutable() ) {
+       AllocationSite as = getAllocationSiteFromFlatNewPRIVATE(fnn);
+       og.assignTempEqualToNewAlloc(lhs, as);
+      }
       break;
 
     case FKind.FlatCall:
@@ -596,11 +599,9 @@ public class OwnershipAnalysis {
     case FKind.FlatReturnNode:
       FlatReturnNode frn = (FlatReturnNode) fn;
       rhs = frn.getReturnTemp();
-
-      if( rhs != null ) {
+      if( rhs != null && !rhs.getType().isImmutable() ) {
        og.assignReturnEqualToTemp(rhs);
       }
-
       setRetNodes.add(frn);
       break;
     }
@@ -612,10 +613,10 @@ public class OwnershipAnalysis {
   // insert a call to debugSnapshot() somewhere in the analysis to get
   // successive captures of the analysis state
   int debugCounter        = 0;
-  int numStartCountReport = 66000;
-  int freqCountReport     = 50;
-  int iterStartCapture    = 70000;
-  int numIterToCapture    = 100;
+  int numStartCountReport = 10000;
+  int freqCountReport     = 10;
+  int iterStartCapture    = 50;
+  int numIterToCapture    = 16;
   void debugSnapshot( OwnershipGraph og, FlatNode fn ) {
     ++debugCounter;
     if( debugCounter > numStartCountReport &&
index fce6f0d0be3785848fa34ccf3cc2514823c5e2f0..e87ce0d3e7cf119fe023efa40696d88c8dfa882d 100644 (file)
@@ -1334,9 +1334,10 @@ public class OwnershipGraph {
 
 
     // return value may need to be assigned in caller
-    if( fc.getReturnTemp() != null ) {
+    TempDescriptor returnTemp = fc.getReturnTemp();
+    if( returnTemp != null && !returnTemp.getType().isImmutable() ) {
 
-      LabelNode lnLhsCaller = getLabelNodeFromTemp(fc.getReturnTemp() );
+      LabelNode lnLhsCaller = getLabelNodeFromTemp(returnTemp);
       clearReferenceEdgesFrom(lnLhsCaller, null, true);
 
       LabelNode lnReturnCallee = ogCallee.getLabelNodeFromTemp(tdReturn);
index cf4df16aeb65a86dd530c6ec2527fffb465f9c9d..cb70ee67bc50a919748212579eb6e2496272a701 100644 (file)
@@ -44,7 +44,8 @@ public class Voo {
 public class Baw {
   int y;
   Foo f;
-  
+  String s;
+
   public Baw() {}
   
   public void doTheBaw( Voo v ) { v = new Voo(); }
@@ -395,6 +396,23 @@ task showPrunedEdgesInMethodCall( Foo a{ f } ) {
   taskexit( a{ !f } );
 }
 
+task showStringIsImmutable( Foo a{ f } ) {
+
+  Baw x = new Baw();
+  Baw y = new Baw();
+
+  Foo f = new Foo();
+  String s = new String();
+
+  x.f = f;
+  y.f = f;
+
+  x.s = s;
+  y.s = s;
+
+  taskexit( a{ !f } );
+}
+
 
 task methodTest( Foo p0{ f } ) {
 
index c0b91f75d1151485bf42d21873623cada169daac..2f989a124eae515164ea94d29187994da2fd312e 100644 (file)
@@ -3,7 +3,7 @@ PROGRAM=test02
 SOURCE_FILES=$(PROGRAM).java
 
 BUILDSCRIPT=~/research/Robust/src/buildscript
-BSFLAGS= -recover -flatirtasks -ownership -enable-assertions
+BSFLAGS= -recover -ownership -ownwritedots final -enable-assertions
 
 all: $(PROGRAM).bin